jgraph - mxGraph cell resize and graph layout -


i'm having problems resizing cells , built-in mxgraph layouts. if put cell on canvas, , try resize it, pixel, grows huge, 50000px x 30000px, streches whole canvas, , of course unusable. if load graph xml file database, can resize cells without problems.

similar thing happens built in layouts. i'd use compact tree layout (the reason beacuse aligns whole horizontal). when draw graph , try use layout, graph goes wild, streching 50000px x 30000 px (example dimensions, scroll tiny can barely aim mouse). if load graph xml database, compact tree layout works perfect. add cell in it, , try use compact tree layout again, goes wild, again.

i use absolute positioning div holds canvas, same on example here (http://jgraph.github.io/mxgraph/javascript/examples/editors/workfloweditor.html)

this css , html :

<head> <style type="text/css">  #graphcontainer {     background: url('../../resources/jgraph/src/images/grid.gif');     left: 20px;     right: 20px;     top: 65px;     bottom: 20px;     position: absolute;     border: 1px solid #f2f2f2;     white-space: nowrap;     font-family: arial;     font-size: 8pt;     display: block; }  </style> </head> <body>  <div id="graphcontainer"></div>  <script>     $(document).ready(function(){         mc.init(document.getelementbyid('graphcontainer'));     }); </script> </body> </html> 

and javascript graph initialization (along couple of events, beacuse i'm not sure if problem):

mxconnectionhandler.prototype.connectimage = new mximage('../../resources/jgraph/src/images/connector.gif', 14, 14);  if (!mxclient.isbrowsersupported()) { mxutils.error('browser not supported!', 200, false); } else {   var root = new mxcell(); root.insert(new mxcell()); var model = new mxgraphmodel(root);  if (mxclient.is_quirks) {     document.body.style.overflow = 'hidden';     new mxdivresizer(graphcontainer); }  var editor = new mxeditor(); editor.setgraphcontainer(graphcontainer); editor.readgraphmodel(model); var graph = editor.graph; graph.setconnectable(true); new mxrubberband(graph);  /* code adding toolbar, excluded example */   //code writing out node name graph.convertvaluetostring = function(cell) {     if (mxutils.isnode(cell.value))     {         var outvalue = cell.value.getattribute('nodename');         if (outvalue != null && outvalue.length > 0)         {             return outvalue;         }         return '';     }     return ''; };  //defining on select event graph.getselectionmodel().addlistener(mxevent.change, function(sender, evt) {     events.cellselectionchanged(graph, graph.getselectioncell());        });  //triggering on select event  events.cellselectionchanged(graph);  //cells added event graph.addlistener(mxevent.cells_added, function(sender, evt) {      var vertex = evt.getproperties().cells[0];     if(vertex.isvertex()){          var decoder = new mxcodec();         var nodemodel = decoder.decode(vertex.value);                         if(nodemodel.type=='node' || nodemodel.type=='branch'){             utils.changecellattribute(vertex, 'nodename', 'node_' + vertex.id);                          }else if(nodemodel.type=='start'){             utils.changecellattribute(vertex, 'nodename', 'start');         }else if(nodemodel.type=='end'){             utils.changecellattribute(vertex, 'nodename', 'end');                            }else if(nodemodel.type=='form'){             utils.changecellattribute(vertex, 'nodename', 'form');                           }      } });  //on connect event  graph.connectionhandler.addlistener(mxevent.connect, function(sender, evt){       var model = graph.getmodel();     var edge = evt.getproperty('cell');       var source = model.getterminal(edge, true);       var target = model.getterminal(edge, false); });  

}

any thoughts problem might be?

solution:

complete graph , cell configuration loaded database (in example), including width , height cells.

the problem adding toolbar items cell types, more precise, dropped cell default width , height. said loading configuration database, string-ified, width , height.

they both had cast javascript number object resize , layout behave properly.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -