[英]Draw line in mxGraph with XML?
我使用mxGraph 编辑器的此示例
我正在尝试使用该库制作梯形图编辑器,因此我想绘制起点和终点线,但是我需要始终将它们全部作为图形区域的边界(每次都从编辑器开始) ,我该怎么做以及如何使它们可连接到元素?
有人可以帮忙吗?
编辑 :
这段代码画了一条线,然后用geometry属性定位它。
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);
为了将问题标记为“已回答”,以便其他人可以看到它:
做这个 :
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.