vis-network中,层级布局中水平顺序是如何确定的?
In vis-network, how is horizontal order determined in hierarchical layout?
在this example中,"level"
用于控制节点放置的垂直位置(假设hierarchical.direction
为up-down
)。
但是,我没有找到如何为同一层级 上的节点设置水平顺序。比如我想把node 6
放在node 1
前面,请问有什么办法吗?
我的理解是水平顺序纯粹由节点插入顺序决定,对吗?
根据https://github.com/visjs/vis-network/issues/926,顺序是non-deterministic。引用:
Q: I didn't find how to set the horizontal order for nodes on the same hierarchy. For example, if I want to put node 6
in front of node 1
, is there a way to do it?
A: As far as the public API goes: No, the order is not guaranteed in any way, do not rely on it, it may change with any new release or between browsers.
Q: My understanding is that the horizontal order is purely determined by node insertion order, is it correct?
A: As far as the CURRENT implementation and decent browsers go: Yes.
只是想补充一点,如果您要通过用户交互动态生成节点和边,并希望确保节点和边的顺序正确,可以采用以下方法:
用户交互后,首先通过clear
method, then use add
清除节点和边,以按所需的插入顺序添加最新的节点和边。
在this example中,"level"
用于控制节点放置的垂直位置(假设hierarchical.direction
为up-down
)。
但是,我没有找到如何为同一层级 上的节点设置水平顺序。比如我想把node 6
放在node 1
前面,请问有什么办法吗?
我的理解是水平顺序纯粹由节点插入顺序决定,对吗?
根据https://github.com/visjs/vis-network/issues/926,顺序是non-deterministic。引用:
Q: I didn't find how to set the horizontal order for nodes on the same hierarchy. For example, if I want to put
node 6
in front ofnode 1
, is there a way to do it?A: As far as the public API goes: No, the order is not guaranteed in any way, do not rely on it, it may change with any new release or between browsers.
Q: My understanding is that the horizontal order is purely determined by node insertion order, is it correct?
A: As far as the CURRENT implementation and decent browsers go: Yes.
只是想补充一点,如果您要通过用户交互动态生成节点和边,并希望确保节点和边的顺序正确,可以采用以下方法:
用户交互后,首先通过clear
method, then use add
清除节点和边,以按所需的插入顺序添加最新的节点和边。