Quantcast
Channel: GoJS - Northwoods Software
Viewing all articles
Browse latest Browse all 7069

The diagram location is always top center

$
0
0

@v.programmer wrote:

I use the following settings to initiate a diagram:

this.packageDiagram.initialDocumentSpot = go.Spot.TopCenter;
this.packageDiagram.initialViewportSpot = go.Spot.TopCenter;

My model is added after the diagram layout has loaded. When adding it, I add a location to each node and simply increase the “y” coordinate so that the nodes do not “stick” to each other.

Node height - 20, indent - 10

My location looks like this:

node1 - loc: “0, 0”
node2 - loc: “0, 30”
node3 - loc: “0, 60”

In order to align the diagram, I execute the following code:

this.packageDiagram.alignDocument(go.Spot.TopCenter, go.Spot.TopCenter);
this.packageDiagram.requestUpdate();

Since other elements or a decrease in the size of the browser can change the size of the diagram, I need to call the alignDocument function and the requestUpdate function each time.

In order to determine that the resizing has occurred, I listen to the diagram event - ViewportBoundsChanged and when it occurs, I call the following code:

this.packageDiagram.alignDocument(go.Spot.TopCenter, go.Spot.TopCenter);
this.packageDiagram.requestUpdate();

This works well, but I can’t use a scroll on the diagram, because when I move it, ViewportBoundsChanged is called and the code is executed to align the diagram.

Is there a way to make it work in a different way and also get a workable scroll?

Posts: 2

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 7069

Trending Articles