Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic How would I set a minimum size for the canvas without distorting shapes? (Read 1858 times)
twojtylak
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Joined: Jan 9th, 2019
How would I set a minimum size for the canvas without distorting shapes?
Nov 4th, 2019 at 3:06pm
Print Post  
Hello!

I have a spot on a page in our web app that houses the canvas for our diagramming. I need the canvas to fill that spot, but also allow overflow if the diagram becomes too big.

The issue I am having is that setting a minimum width of 100% on the canvas causes the shapes to scale with the width of the canvas. I don't want that. I want the shapes to stay the same size.

Also, when using Diagram.create() on my canvas element, it seems to always set the size of the canvas to 793x1122 even when explicitly putting a width and height on it.

Is there a way to stop it from changing the size to 793x1122 and is there a way to make the canvas have a minimum width?
  
Back to top
 
IP Logged
 
Slavcho
YaBB Moderator
*****
Offline


tech.support

Posts: 3380
Joined: Oct 19th, 2005
Re: How would I set a minimum size for the canvas without distorting shapes?
Reply #1 - Nov 4th, 2019 at 3:40pm
Print Post  
Hi,

The Canvas' width and height are set to that of diagram's Bounds value, which supposedly has an A4 size by default. You can control the canvas size only by calling diagram.Bounds(new MindFusion.Drawing.Rect(...)).

In order to fill a part of the page, try creating an overflowing div occupying the space with the canvas element inside. You could call diagram.zoomToFit() if you want the shapes to zoom proportionally and fill the entire viewport, e.g. calling it from a page loaded or window resized handler.

Regards,
Slavcho
Mindfusion
  
Back to top
 
IP Logged
 
twojtylak
YaBB Newbies
*
Offline


I Love MindFusion!

Posts: 9
Joined: Jan 9th, 2019
Re: How would I set a minimum size for the canvas without distorting shapes?
Reply #2 - Nov 4th, 2019 at 9:04pm
Print Post  
Thanks for the response!

I don't want the shapes to zoom. I want them to stay the same size regardless of the size of the canvas.

It seems like what I'll need to do is check the size of the diagram whenever there's an update and if it is less than the size of the canvas' minimum dimensions, reset the canvas dimensions to be its minimum size.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint