There is a problem when I layout my Diagram. My Diagram has some nodes without links, when I use ForceDirectedLayout ,the seperate nodes all too far from others, so that my diagram can’t be viewed well,who can resolve this problem?thank u.
Reduce the ForceDirectedLayout.defaultElectricalCharge and infinityDistance.
More advanced: you could also impose an electric field around the area to push the nodes away from a boundary.
Another idea: don’t use ForceDirectedLayout on disconnected nodes at all. Define a custom ForceDirectedLayout that operates normally only on connected nodes and lays out explicitly those disconnected nodes in a grid. I should be able to find an example of that later today, if you like.
[EDIT: ArrangingForceDirectedLayout has been subsumed by the ArrangingLayout extension in v2.1.23.]
I suggest that you use the ArrangingLayout extension.
It is demonstrated at: Arranging Layout of the Class Hierarchy
It is defined at: https://gojs.net/latest/extensions/ArrangingLayout.js
It is documented at: ArrangingLayout | GoJS API
In your case you’ll want to set ArrangingLayout.primaryLayout to be your ForceDirectedLayout. Disconnected nodes it will automatically arrange along the bottom of the document by a GridLayout.
thank you walter, your replay resolved my problem well.Have a nice day, thank you very much!