Friday, June 10, 2016

How to add <text> and <line> elements to mxGraph graph

Leave a Comment

I need to add custom <line> and <text> elements to SVG that is rendered by the mxGraph library.

Does anyone know how to do it (or is it possible at all)?

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

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

1 Answers

Answers 1

I've found a workaround for this by creating a text element (label) with 0-length vertex. See 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); 

But, it's still quite bad solution for me.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment