zoomToFit taking scrollMargin into account

I am using the scrollToFit to zoom out of the view and fit the whole diagram.

Here is the exact code I call:

    diagram.alignDocument(go.Spot.Center, go.Spot.Center);

I think it is working quite good, only problem I see is that it is not taking the scrollMargin set to 100 into account because I would expect it to zoom a little bit further out.

Current behavior:

You can see that the top buttons are overlapping the diagram. You can see from the scrolling bar on the side, that I could now scroll up a little bit (e.g. by calling diagram.alignDocument(go.Spot.Top, go.Spot.Center);) but then not the whole diagram will be inside the view.

Expected behavior:

I would expect it to be zoomed out a little bit further so that the scrollMargin at the top and bottom would fit.

If one has set Diagram.scrollMargin to a non-zero Margin, I would expect to see scrollbar(s) even though the user can just see all of the Nodes and Links within the viewport.

Maybe you want to set Diagram.padding instead?

I’m not sure why after the call to zoomToFit you can’t see all of each Node.

you are right, increasing the padding did the trick. I removed the scrollMargin completely. thank you for the quick help!