Stop Force setup on d3js and start free drag and drop nodes

I use a force mockup to represent a directional unweighted network. My inspiration comes from the following example: http://bl.ocks.org/mbostock/1153292

enter image description here

Since my own data is really a mess, I would like to stop the layout and move the nodes by dragging them manually. I would also like the node movement not to change the position of others. And it is necessary that the links get longer in order to get to the node that has been moved.

Is there an easy way to do this?

+7
source share
2 answers
+6
source
function nameOfFunction () { d3.selectAll(".classOfYourNodes").each( function(d) { d.fixed = true; } ) } 

The .each method calls an anonymous function, which in this case sets the fixed attribute to true for each node within the selection.

Edit: The above refers to your comment about wanting to stop all nodes and not have the simulation continue when you drag the node, as the call to force.stop () does.

0
source

All Articles