更新时间:2023-02-03 11:36:30
(1)您可以通过 nodes.lock()
锁定节点以使其位置不变。
(1) You can lock a node to make its position immutable, via nodes.lock()
.
(2)您可以通过 eles.layout()
在图形的子集上运行布局以排除某些元素。
(2) You can run a layout on a subset of the graph to exclude certain elements, via eles.layout()
.
这两种策略都可以通用,也可以串联使用。
Either of these strategies can be used in general, or they can be used in tandem.
情况下,听起来您应该使用(1)。
For your case, it sounds like you should use (1).
但是,请注意,这并不总是能带来良好的结果。您可能会过度约束系统。如果您希望获得良好的布局效果,则***像在Stephan T.的建议中那样在所有内容上运行布局而不锁定。
Note, however, that this won't always give a good result. You could over-constrain the system. If you want a good layout result, it's probably best to just run the layout on everything without locking, as Stephan T. suggested.