Note that there are some explanatory texts on larger screens.

plurals
  1. POReplacing contents of HTML canvas with Springy force-directed graph
    primarykey
    data
    text
    <p>I have a nice force-directed graph using the <a href="http://getspringy.com/" rel="nofollow">Springy</a> force-directed graph layout library. I've discovered that when I replace the graph with another via ajax (e.g., after the user has changed some settings), both graphs occupy the same canvas.</p> <p><strong>What I'm looking for:</strong> I need to get rid of the old graph completely, so the new graph is the only one present in the canvas.</p> <p>Here's a simplified usecase jsfiddle: <a href="http://jsfiddle.net/XPAqX/" rel="nofollow">http://jsfiddle.net/XPAqX/</a></p> <pre><code>// make a new graph var graph = new Springy.Graph(); // make some nodes var spruce = graph.newNode({label: 'Norway Spruce'}); var fir = graph.newNode({label: 'Sicilian Fir'}); // connect them with an edge graph.newEdge(spruce, fir); $('#my_canvas').springy({ graph: graph, nodeSelected: function(node) { alert(node.data.label); } }); //now, I let the user update the dataset with ajax and re-render the graph. graph = null; graph = new Springy.Graph(); // make some nodes var kittens = graph.newNode({label: 'Furry Baby Cats'}); var puppies = graph.newNode({label: 'Fluffy Baby Dogs'}); // connect them with an edge graph.newEdge(kittens,puppies); $('#my_canvas').springy({ graph: graph }); </code></pre> <p>Quick note: cross-posted as an issue on the springy github, no answers yet though: <a href="https://github.com/dhotson/springy/issues/47" rel="nofollow">https://github.com/dhotson/springy/issues/47</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload