vis.js-重新加入时层次结构重叠的边缘

时间:2019-02-21 18:05:22

标签: vis.js

使用vis.js

 function draw() {
    destroy();
    nodes = [];
    edges = [];

    var model = { "nodes": [{ "id": 1, "label": "1. First", "level": 0 }, { "id": 2, "label": "2. Second", "level": 1 }, { "id": 3, "label": "3. Third.", "level": 2 }, { "id": 4, "label": "4. Forth", "level": 3 }, { "id": 5, "label": "5. Fith", "level": 4 }], "edges": [{ "from": 1, "to": 2 }, { "from": 2, "to": 3 }, { "from": 3, "to": 4 }, { "from": 4, "to": 5 }, { "from": 2, "to": 4 }] };
    nodes = model.nodes;
    edges = model.edges;

    // create a network
    var container = document.getElementById('mynetwork');
    var data = {
        nodes: nodes,
        edges: edges
    };

    var options = {          
        layout: {
            hierarchical: {                  
                direction: "UD"             
            }
        }     
    };
    network = new vis.Network(container, data, options);
}

这是我期望的:

Expected

但是我却得到了:

Unexpected

“ 3”位于中间,其边缘重叠2到4。

方向很重要1必须在顶部,5在底部。

任何建议如何防止这种重叠?

0 个答案:

没有答案