Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic node gets out of canvas box (Read 3175 times)
liza
Full Member
***
Offline


I Love MindFusion!

Posts: 132
Joined: Apr 25th, 2019
node gets out of canvas box
Sep 5th, 2019 at 5:50am
Print Post  
Hi,
Sometimes my node became invisible because it gets out of the view. How I can set so that my diagram will alsowas be shown in the view. Please help.
  
Back to top
AIM  
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: node gets out of canvas box
Reply #1 - Sep 5th, 2019 at 6:36am
Print Post  
Hi,

You could call diagram.resizeToFitItems() after adding and arranging nodes to make diagram.Bounds large enough to contain them. If you enable Diagram.AutoResize, it should grow automatically to contain nodes drawn interactively by users.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
liza
Full Member
***
Offline


I Love MindFusion!

Posts: 132
Joined: Apr 25th, 2019
Re: node gets out of canvas box
Reply #2 - Sep 5th, 2019 at 6:56am
Print Post  
I tried this but it is creating a very small rectangle in which only my one node is visible not whole diagram. and When I use Diagram.AutoResize() it is saying is not a function . What should I do please help.
  
Back to top
AIM  
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: node gets out of canvas box
Reply #3 - Sep 5th, 2019 at 7:01am
Print Post  
It's a property you could set on server side, or otherwise call Diagram.setAutoResize on client side. If you need the diagram to only grow, you could check if diagram.getBounds() contains diagram.getContentBounds(), and if it doesn't do a union of the two rectangles and assign it back to Bounds.

Regards,
Slavcho
  
Back to top
 
IP Logged
 
liza
Full Member
***
Offline


I Love MindFusion!

Posts: 132
Joined: Apr 25th, 2019
Re: node gets out of canvas box
Reply #4 - Sep 16th, 2019 at 6:32am
Print Post  
can you please elaborate it how I can I use union and assign to bounds.
  
Back to top
AIM  
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3152
Joined: Oct 19th, 2005
Re: node gets out of canvas box
Reply #5 - Sep 16th, 2019 at 8:57am
Print Post  
like this -

Code
Select All
function growToFitItems(diagram)
{
	var margin = 10;
	var contentRect = diagram.getContentBounds();
	var diagRect = diagram.getBounds();
	if (contentRect.bottom() > diagRect.bottom() ||
		contentRect.right() > diagRect.right())
	{
		diagram.setBounds(
			diagRect.union(contentRect.inflate(margin)));
	}
} 



Regards,
Slavcho
  
Back to top
 
IP Logged
 
liza
Full Member
***
Offline


I Love MindFusion!

Posts: 132
Joined: Apr 25th, 2019
Re: node gets out of canvas box
Reply #6 - Sep 17th, 2019 at 5:28am
Print Post  
Thankyou its done, my height got increased but width by changing layout was again out of focus, so I set margin to 20 and it is fine now.
  
Back to top
AIM  
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint