Is it possible to have dynamic height on canvas?

Hi there,

i’m wondering, is it possible to set height to canvas dynamically?

What i want to do is to set the height of the canvas to a number that all the diagram will be visible but without just zoom out the diagram.

Is this possible somehow?

Yes, it is possible. But are you sure that you want to do that?

Try adding this DiagramEvent listener:

          "InitialLayoutCompleted": function(e) {
            var dia = e.diagram;
            // add height for horizontal scrollbar
   = (dia.documentBounds.height + 24) + "px";

That’s in an initialization of the Diagram using GraphObject.make, but you could add that listener programmatically by calling Diagram.addDiagramListener.

Thx ;) It worked!