Hello,
I have a problem in resizing the canvas element of the main diagram.
In my HTML code, I have a button that resize the width of the div element of my diagram. In the HTML, the diagram is defined just as:
In my Javascript code, my diagram is defined as follows:
myDiagram = $(go.Diagram, “myDiagram”,
{
allowDrop: true, // accept drops from palette
initialContentAlignment: go.Spot.Center, // Center Diagram contents
“linkingTool.linkValidation”: sameLevel, // links cannot go outside or inside a group (macro activity)
“relinkingTool.linkValidation”: sameLevel,
“undoManager.isEnabled”: true // enable Ctrl-Z to undo and Ctrl-Y to redo
});
myDiagram.model = $(go.GraphLinksModel,
{
linkFromPortIdProperty: “fromPort”,
linkToPortIdProperty: “toPort”
});
After clicking in that button, a right menu is collapsed. So, the diagram should expand to fill the empty space left by the right menu. I have this Javascript code that is run after clicking in that button:
$(’#right_menu’).hide(100, function()
{
$(’#MenuAndDiagram’).animate({width: “92%”}, {duration: 200});
$(’#right_menu’).toggleClass(‘opened’);
});
"#right_menu" is a div in the right side of the diagram (the right menu). “#MenuAndDiagram” is a div where it is the diagram and a menuBar at the top. The “myDiagram” element has a CSS width of 100%, so it is automatically updated.
Looking to the inspector menu of Chrome, I’ve noticed that the width of the (inside “#myDiagram”) is not updated after I update the width of the diagram. Because of this, the diagram don’t expand correctly. Just if I click in the diagram and I try to drag the background, the updates its size.
I’ve looked to the documentation and tried several functions such as:
myDiagram.delayInitialization();
myDiagram.rebuildParts();
myDiagram.updateAllTargetBindings();
myDiagram.computeBounds();
myDiagram.requestUpdate();
But nothing worked.
I’ve also tried these proprieties in defining the diagram:
autoScale: go.Diagram.UniformToFill,
initialAutoScale: : go.Diagram.UniformToFill,
But it didn’t work, also.
Can you please help me? If it is necessary any further information please say to me. I am portuguese so, sorry if I’m not clear. If I’m not clear, please ask me :)