Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

d3 force graph: sticky nodes

I would like to add a behavior to a force directed graph layout in D3 in such a way that once dropped, a dragged-and-dropped svg node sticks in its place, no longer changing position no matter what else happens in the graph. I have done some reading about this API but I can't figure out a way to get that one working.

The problem I am trying to solve is allowing a user to "pick apart" a complex force graph.

like image 870
James Orr Avatar asked Sep 19 '12 14:09

James Orr


1 Answers

Set the fixed property of the node to true on mousedown.

node.on("mousedown", function(d) { d.fixed = true; });

For example: http://bl.ocks.org/3750558

like image 73
mbostock Avatar answered Nov 05 '22 16:11

mbostock