我使用这个 mxGraph 编辑器的例子
我正在尝试使用该库来制作梯形图编辑器,所以我想绘制起点和终点线,但我需要它们作为图表区域从左到右的边界(每次都从编辑器开始) ,我该怎么做?如何让它们连接到元素?
有人可以帮忙吗?
编辑:
这段代码画了一条线,然后我用几何属性定位它。
var xml = "<root>"+
"<MyObject id=\"2\">"+
"<mxCell style=\"strokeColor=black;fillColor=black\" parent=\"1\" vertex=\"1\" type = 'startLine'>"+
"<mxGeometry x=\"0\" y=\"0\" width=\"2\" height=\"119\" as=\"geometry\"/>"+
"</mxCell></MyObject></root>";
doc = mxUtils.parseXml(xml),
codec = new mxCodec(doc),
elt = doc.documentElement.firstChild,
cells = [];
while (elt != null){
cells.push(codec.decodeCell(elt));
elt.setAttribute('attribute1', 'value1');
$this.editor.graph.refresh();
elt = elt.nextSibling;
}
$this.editor.graph.addCells(cells);