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

How to update/redraw graph? #67

Open
adamlawrencium opened this issue May 18, 2017 · 2 comments
Open

How to update/redraw graph? #67

adamlawrencium opened this issue May 18, 2017 · 2 comments

Comments

@adamlawrencium
Copy link

I'm trying to make a dynamic graph that updates every few seconds.
What I'd ideally want is something like this:

    var G = new jsnx.Graph();

    G.addNode(0);
    jsnx.draw(G, {
        element: '#canvas',
        weighted: true,
        edgeStyle: {
            'stroke-width': 10
        }
    });

    var i = 1;
    setInterval(function () {
      G.addNode(i);
      i++;
      jsnx.redraw();
    }, 2000);

But I get a Uncaught TypeError: jsnx.redraw is not a function error.
Otherwise I have to draw() every time I update the graph, which doesn't look good at all...

Anyone know a way to do this?

@adamlawrencium
Copy link
Author

adamlawrencium commented May 18, 2017

Actually just figured it out.

* @param {?boolean=} optBind Set to true to automatically update
says that if you add a true option to .draw(), it'll automatically update the graph:

    jsnx.draw(G, {
        element: '#canvas',
        weighted: true,
        edgeStyle: {
            'stroke-width': 10
        }
    }, true
);

Maybe the website should include this to help people who are just getting started with JSNetworkX

@talhajunaidd
Copy link

It is on website
http://jsnetworkx.org/api/#/v/v0.3.4/draw

image

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

No branches or pull requests

2 participants