Reputation: 2087
I'm trying to add a new icon in my existing vertex/vertices programmatically using mxCellOverlay
and addCellOverlay
. How do I get all my vertices I have in my workeditor xml so I can pass it in addCellOverlay
parameter, like the example below.
var overlay = new mxCellOverlay(new mxImage('editors/images/overlays/check.png',
16, 16), 'Overlay tooltip');
graph.addCellOverlay(allMyVertices, overlay);
reference: http://jgraph.github.io/mxgraph/javascript/examples/fixedicon.html
If I add this code in the fixedIcon.html (line 72) afer var v1
it gives me a new tick/check icon.
var overlay = new mxCellOverlay(new mxImage('editors/images/overlays/check.png',
16, 16), 'Overlay tooltip');
graph.addCellOverlay(v1, overlay);
Upvotes: 0
Views: 2364
Reputation: 324
If you only want to get the vertices (not edges) of one level, I would suggest mxGraph.getChildVertices
instead of mxgraph.getCells
. But you have to pass the parent mxCell to the function. You will then get all child vertices of this cell. E. g. if you want to add an overlay to all vertices of the default parent you could do something like this:
var overlay = new mxCellOverlay(new mxImage('editors/images/overlays/check.png', 16, 16), 'Overlay tooltip');
var parent = graph.getDefaultParent();
var vertices = graph.getChildVertices(parent);
graph.addCellOverlay(vertices, overlay);
Of course, a recursive implementation would be possible, if you want all vertices of every level.
For further informations: https://jgraph.github.io/mxgraph/docs/js-api/files/view/mxGraph-js.html#mxGraph.getChildVertices
Upvotes: 2
Reputation: 116
Here is :
mxGraph.prototype.getCells = function(x,y,width,height,parent,result);
Upvotes: 0