2

我需要向mxGraph 库呈现的 SVG添加自定义<line>和元素。<text>

有谁知道怎么做(或者有可能)?

http://www.w3schools.com/svg/svg_line.asp

http://www.w3schools.com/svg/svg_text.asp

4

2 回答 2

1

我通过创建一个长度为 0 的顶点的文本元素(标签)找到了解决方法。见http://jgraph.github.io/mxgraph/javascript/examples/labels.html

var v1 = graph.insertVertex(parent, null, 'vertexLabelsMovable', 20, 20, 80, 30);
// Places sublabels inside the vertex
var label11 = graph.insertVertex(v1, null, 'Label1', 0.5, 1, 0, 0, null, true);
var label12 = graph.insertVertex(v1, null, 'Label2', 0.5, 0, 0, 0, null, true);

但是,这对我来说仍然是一个非常糟糕的解决方案。

于 2016-06-05T16:55:21.803 回答
0
this.addEntry('vertical Line', mxUtils.bind(this, function() {
        var cell = new mxCell('', new mxGeometry(0, 0, 10, 160), 'line;strokeWidth=2;direction=south;html=1;');
        cell.vertex = true;
        this.graph.setAttributeForCell(cell, 'placeholders', '1');
        this.graph.setAttributeForCell(cell, 'capacity', '0');

        return this.createVertexTemplateFromCells([cell], cell.geometry.width, cell.geometry.height, 'Vertical Line');
    }))

竖线代码

于 2017-09-20T04:54:17.117 回答