vis.js网络:与节点数有关的分层布局问题

问题描述 投票:1回答:1

我遇到一个“奇怪的”问题,我无法通过查看[[vis.js文档来解决。我创建了一个具有固定层次结构的网络,该层次结构为每个节点定义了特定级别。节点总数51。其结果是:enter image description here

如果我在网络方案的底部添加了另一个节点(共52个),则布局会发生更改,节点的空间布置将完全移动,尝试填充空白,如下所示:enter image description here

我尝试了几种选择,但均未成功。这些是我目前正在使用的选项:

options = { layout: { improvedLayout: false, hierarchical: { enabled: true, levelSeparation: 150, nodeSpacing: 110, treeSpacing: 200, blockShifting: false, edgeMinimization: true, parentCentralization: true, direction: "LR", sortMethod: "directed", shakeTowards: "roots" } }, interaction:{ tooltipDelay: 100 }, edges: { font: { size: 0 } }, nodes: { shape: 'circle' }, physics: false };
希望您能给我一些建议。谢谢!
javascript layout vis.js hierarchical vis.js-network
1个回答
0
投票
您可以尝试在选项对象的布局中添加randonSeed。

layout: { randomSeed: 1, improvedLayout: false, hierarchical: { enabled: true, levelSeparation: 150, nodeSpacing: 110, treeSpacing: 200, blockShifting: false, edgeMinimization: true, parentCentralization: true, direction: "LR", sortMethod: "directed", shakeTowards: "roots" } }

您可以更改数字(randomSeed:

1),直到获得所需的布局。希望会有所帮助。

© www.soinside.com 2019 - 2024. All rights reserved.