is it possible to keep the top node in the top center?
If I use myDiagram.centerRect(node.actualBounds); it keeps the node in the center but not at the top.
I want to keep Stella Payne Diaz node in the top center. I have used org chart assitant example
Please help me
If you set Diagram.contentAlignment to
go.Spot.Top, it will center the document at the top of the viewport.
However, your “Stella Payne Diaz” node isn’t in the horizontal middle of the document area, so centering that area will not horizontally center that root node in the viewport.
If you set the Diagram.scrollMargin to be big enough, you should be able to compute and set the Diagram.position so that the root node is at the horizontal center of the area.
Thank you for your reply.
I set the diagram scroll margin too big. but how can I calculate it dynamically?
Half the Diagram.viewportBounds.size would be OK, I think, for your case.
Setting the Diagram.position would be something like:
const vb = myDiagram.viewportBounds;
myDiagram.scrollMargin = new go.Margin(vb.height/2, vb.width/2);
const node = . . .; // the root node or whichever node you want to put at the top
myDiagram.position = new go.Point(node.actualBounds.centerX - vb.width/2, node.actualBounds.top - myDiagram.padding.top);
Yes, it’s working now. Thanks a lot