问题描述
我有一个相当简单的节点层次结构,但是当vis.js绘制它们时,每个级别上的节点顺序都没有多大意义-交叉边缘很多(截图:默认布局)
I have a fairly simple hierarchical structure of nodes, but when vis.js draws them, the order of nodes on each level doesn't make much sense - there are a lot of crossed edges (screenshot: Default Layout )
我希望获得与此处给出的布局相似的布局:预期的布局
I am hoping to get a layout similar to that given here:Expected Layout
我的vis.js选项如下;
My vis.js options are as follows;
{
"layout": {
"hierarchical": {
"direction": "LR",
"sortMethod": "directed",
"nodeSpacing": 200,
"treeSpacing": 400
}
},
"edges": {
"smooth": {
"type": "continuous"
}
},
"nodes": {
"physics": false
}
};
产生这种排序的布局的最佳方法是什么?
What is the best method to produce this sorted layout?
推荐答案
我建议您尝试启用物理学,以理清交叉的边缘等.
I suggest your try enabling physics, which will sort out the edges crossing, etc.
但是,在分层布局中,最好通过捕获如下所示的'stabilizationIterationsDone'事件来禁用引擎,使其在第一次迭代后失效:
However, in hierarchical layout, it's a good idea to disable the engine once it's done the first iterations by catching the 'stabilizationIterationsDone' event as follows:
network.on("stabilizationIterationsDone", function(){
network.setOptions( { physics: false } );
});
这篇关于vis.js分层布局中的级别排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!