使用mxgraph将容器内的元素连接到具有Layout的节点

时间:2018-11-01 16:27:48

标签: mxgraph jgrapht

我将分层布局用作页面的默认设置。并将节点彼此连接。现在,我想将“容器”节点内的元素直接连接到其他节点,从而将容器节点内的元素拖到容器中,而仅“布置”边缘和节点。

“ A”是我现在拥有的,我想像“ B”一样布局(带有边) 有可能吗?

(使用JS) enter image description here https://codepen.io/AmihaySchwarz/pen/vQEdra

    var v0 = graph.insertVertex(parent, null, 'Group', 30, 180, 80, 160);
    var v2_1 = graph.insertVertex(v0, null, 'v2_1', 10, 40, 60, 30);
    var v2_2 = graph.insertVertex(v0, null, 'v2_2', 10, 80, 60, 30);
    var v2_3 = graph.insertVertex(v0, null, 'v2_3', 10, 120, 60, 30);
    var v1_1 = graph.insertVertex(parent, null, 'v1_1', 40, 400, 80, 30);
    var v1_2 = graph.insertVertex(parent, null, 'v1_2', 50,450, 80, 30);
    var v1_3 = graph.insertVertex(parent, null, 'v1_3', 50,450, 80, 30);


              var e1 = graph.insertEdge(parent, null, '', v2_1, v1_1);
    var e2 = graph.insertEdge(parent, null, '', v2_2, v1_2);
    var e3 = graph.insertEdge(parent, null, '', v2_3, v1_3);

    var layout = new mxHierarchicalLayout(graph);
    //layout.moveParent = true;
    //layout.traverseAncestors = true;
   // layout.execute(parent,[v0,v1_1,v1_2,v1_3]);
      layout.execute(parent,[v2_1,v2_2,v2_3,v1_1,v1_2,v1_3]);

0 个答案:

没有答案