dracula
dracula copied to clipboard
Dynamically add nodes or edges
Hi, I need to dynamically add stuff to the canvas but all aproaches I try fail.
$('#asd').click(function() {
ggg.addEdge("A3-1","S1", { });
});
Also tried to clear the existing canvas and redraw it entirely (failed also)
$('#asd').click(function() {
$('#canvas').html('');
ggg.addEdge("A3-1","S1", { });
var layouter = new Graph.Layout.Spring(ggg);
var renderer = new Graph.Renderer.Raphael('canvas', ggg, width, height);
});
The nodes are correct and adding the edge on initialization works fine, is this a bug in dracula?
Seems correct to me... is there a specific reason why you are passing the empty object as third argument? No time to try this right now, but try removing it.
Also, if I remember correctly I had to manually redraw the edges right after adding them:
for (var i = 0; i < g.graph.edges.length; i++) {
g.drawEdge(g.graph.edges[i]);
}
Let me know if this works.