Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Layout issue with container children (Read 6074 times)
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Layout issue with container children
Oct 18th, 2013 at 10:42am
Print Post  
Hi,

I am using the below code to auto arrange the shapes in canvas.
But the children inside the container node is not getting arranged. It is still displaying as overlapped.

Is there any solution ?
Below is my code

var LayeredLayout = MindFusion.Graphs.LayeredLayout;
            var LayoutDirection = MindFusion.Graphs.LayoutDirection;

            var layout = new LayeredLayout();
            layout.direction = LayoutDirection.TopToBottom;
            layout.siftingRounds = 0;
            layout.nodeDistance = 8;
            layout.layerDistance = 8;
            _diagram.arrange(layout);
            _diagram.resizeToFitItems();

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Layout issue with container children
Reply #1 - Oct 21st, 2013 at 7:12am
Print Post  
Hi,

At this time the arrange method preserves the current placement of container's children. You could temporarily remove the child nodes to arrange them too:

Code
Select All
Array.forEach(diagram.nodes, function (node)
{
	if (node.container)
	{
		node.temp_ctr = node.container;
		node.container.remove(node);
	}
});
diagram.arrange(layout);
Array.forEach(diagram.nodes, function (node)
{
	if (node.temp_ctr)
	{
		node.temp_ctr.add(node);
		delete node.temp_ctr;
	}
});
Array.forEach(diagram.nodes, function (node)
{
	if (node.children)
		node.resizeToFitChildren(true);
});
diagram.arrange(layout);
 



I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Layout issue with container children
Reply #2 - Nov 6th, 2013 at 8:25am
Print Post  
Hi Stoyan,

I tried this , but i am facing one issue.

The children inside the container is having more space between each other. Coz of this the parent container is having a large size. Can we re-size the container to just fit the children.

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Layout issue with container children
Reply #3 - Nov 7th, 2013 at 9:58am
Print Post  
Hi,

There will be more space if the container's children are not connected by links; diagram.arrange() will not try to keep them close to each other in that case. We should have the function for arranging containers ready in a few days.

Stoyan
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Layout issue with container children
Reply #4 - Nov 7th, 2013 at 2:20pm
Print Post  
Hi Stoyan,

Yes that is the exact scenario. Waiting for the fix. Thanks in advance.

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Kiran B
Full Member
***
Offline


I Love MindFusion!

Posts: 102
Joined: Apr 19th, 2013
Re: Layout issue with container children
Reply #5 - Nov 19th, 2013 at 9:13am
Print Post  
Hi Stoyan,

Is there any update for this?

Thanks
Kiran B
  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Layout issue with container children
Reply #6 - Nov 19th, 2013 at 12:27pm
Print Post  
Hi,

Try this preview version:
https://mindfusion.eu/_beta/jsdiag_ctrlayout.zip

You can now call ContainerNode.arrange(layout) to arrange the content of individual containers. Call it from a loop for all containers before Diagram.arrange() if you need to arrange both containers' children and the overall diagram.

I hope that helps,
Stoyan
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint