Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically add nodes or edges #22

Open
alexfrancavilla opened this issue Jul 1, 2013 · 1 comment
Open

Dynamically add nodes or edges #22

alexfrancavilla opened this issue Jul 1, 2013 · 1 comment

Comments

@alexfrancavilla
Copy link

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?

@monomon
Copy link
Contributor

monomon commented Jul 3, 2013

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants