Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Diagram sizing & screen resolution (Read 2942 times)
Al
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Sep 3rd, 2014
Diagram sizing & screen resolution
Sep 8th, 2014 at 9:42am
Print Post  
Hi, I have my diagram in the container as below where the div is sized on page load:

Code (Javascript)
Select All
    <div id="diagramContainer" style="font-family: arial; font-size: 12px; width=100%; overflow:scroll;" >
        <canvas id="diagram" >
        </canvas>
    </div>

    <script>
        document.getElementById("diagramContainer").style.height = (document.body.clientHeight - 80) + 'px';
        document.getElementById("diagramContainer").style.width = (document.body.clientWidth - 20) + 'px';
    </script>
 



I have removed all of my other code so after page load I do:

Code (Javascript)
Select All
diagram = Diagram.create($("#diagram")[0]);
 



And I get a diagram of some default size:

Code (Javascript)
Select All
diagram.getBounds()
c.Rect {x: 0, y: 0, width: 210, height: 297, transform: MindFusion.Drawing.Matrix…}
 



But after '$(document).ready(function () ' is finished, I end up with a massive diagram canvas much larger than the sizr above (no arrange or auto-resize etc).
If I try to diagram.setBounds() it becomes even more massive.

After some investigation it looks like the behaviour is caused by screen resolution. if I do diagram.setBounds(new Rect(0,0,100,100)) then my canvas gets set to 377x377 and doing diagram.getBounds still returns 100x100. 
Basically I want to size my canvas to be the same as it's containing div - what would be the best way here?
« Last Edit: Sep 8th, 2014 at 10:49am by Al »  
Back to top
 
IP Logged
 
Al
Junior Member
**
Offline


I Love MindFusion!

Posts: 56
Joined: Sep 3rd, 2014
Re: Diagram sizing & screen resolution
Reply #1 - Sep 8th, 2014 at 11:02am
Print Post  
I got the answer from another post on this forum:

Code (Javascript)
Select All
width = diagram.clientToDocLength(widthPx);
height = diagram.clientToDocLength(heightPx);
diagram.setBounds(new Rect(0, 0, width, height));
 

  
Back to top
 
IP Logged
 
Stoyo
God Member
*****
Offline


MindFusion support

Posts: 13230
Joined: Jul 20th, 2005
Re: Diagram sizing & screen resolution
Reply #2 - Sep 8th, 2014 at 11:38am
Print Post  
Right, the default unit is millimeter. You can change it to pixel by calling diagram.setMeasureUnit(), but then you might also have to change many other size- and length- related property values.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint