0
我使用分層佈局作爲我的頁面的默認值。我想使用一些頂點(「2」)作爲其他元素的容器(「2.1」...「2.3」)。結合mxGraph中的佈局
我該如何做到這一點?
var graph = new mxGraph(document.getElementById('graphContainer'));
var layout = new mxHierarchicalLayout(graph);
graph.getModel().beginUpdate();
try {
var parent = graph.getDefaultParent();
var v0 = graph.insertVertex(parent, null, "0", 0, 0, 240, 30);
var v1 = graph.insertVertex(parent, null, "1", 0, 0, 240, 30);
graph.insertEdge(parent, null, null, v0, v1);
var v2 = this.graph.insertVertex(parent, null, "2", 0, 0, 240, 30, 'o1');
graph.insertEdge(parent, null, null, v1, v2);
graph.insertVertex(v2, null, "2.1", 0, 0, 220, 30);
graph.insertVertex(v2, null, "2.2", 0, 0, 220, 30);
graph.insertVertex(v2, null, "2.3", 0, 0, 220, 30);
var v3 = this.graph.insertVertex(parent, null, "3", 0, 0, 240, 30);
graph.insertEdge(parent, null, null, v1, v3);
layout.execute(parent);
} finally {
graph.getModel().endUpdate();
}
<script src="http://jgraph.github.io/mxgraph/javascript/src/js/mxClient.js"></script>
<div id="graphContainer" />
我試圖在layout.execute後用建議的開關畫'2.1'...'2.3'。它效果更好,但並不像預期的那樣。位置得到了改善,但它仍然沒有調整競爭者('2')的大小。另外,很難將我的邏輯分開,並將主分層圖與孩子分開繪製。 – aholub7x