Zoom to fit does not centre the diagram always

Hi Team,

I was trying to use the zoomtofit() API, and observed the diagram does not fit to the centre always. Is there a way to achieve the centered position w.r.t viewport, whenever zoomtofit is called?

I believe it doesn’t have to be centered, as long as it’s completely within the viewport.
Could you please show both before and after screenshots?
Are you calling CommandHandler.zoomToFit or Diagram.zoomToFit?

We are calling diagram.zoomtofit(). I agree its completely within the viewport, but there is a lacking of consistency, on how the fit diagram is repositioned. Instead of always being centered, the diagram fit is to the nearest viewport bounds.
We wanted to achieve centering always when zoomtofit is called.

Have you tried calling Diagram.alignDocument Diagram | GoJS API afterwards?

I have now used alignDocument with Spot.Center and it works how I need. Thanks a lot for suggesting :)