However, if I select the second tab, ‘Simple Graph’, and then switch back to the first ‘Graph’ tab, the graph size becomes too small. Please check the attached screenshot. This issue occurs vice versa for the other tab as well.
That’s very odd – I’m guessing that when you switch tabs you are reinitializing the diagram, when you clearly don’t want to do that.
For example, if you look at the different “tabs” of Palettes in the Planogram sample, Planogram | GoJS, you can zoom in or out or scroll around in one Palette, switch to another Palette and do stuff, and then switch back again and the old Palette’s view hasn’t changed.
How are tabs implemented in your app? When the user switches tabs, is the HTML element in the old tab removed from the DOM? Or is it given zero size? Either one of those might be causing the Diagram to change its state. Certainly when the Diagram’s HTMLDivElement changes size the Diagram will think it needs to change size too, and that might cause it to scroll. It depends on how you have initialized the Diagram, including whatever behavior you may have implemented in some of its DiagramEvent listeners.
I suppose you could set a breakpoint in a “ViewportBoundsChanged” DiagramEvent listener so that you’ll know after the viewport has changed. But you probably won’t be able to look up the stack to find the cause of the change.