May 2019
Beginner to intermediate
650 pages
14h 50m
English
Dragging the node to a position doesn't keep it there forever, since the simulation is still running and its x and y coordinates are still being modified. But you can override that behavior by setting the final coordinates in the fx and fy properties (fixed coordinates) instead of x and y (see Force/Interactive/3-drag-fix.html):
d3.drag().on('drag', function(d) { d.fx = d3.event.x; d.fy = d3.event.y; console.log(sim.alpha())})
If any of fx or fy properties is present in a node, the simulation will copy their values to x and y, ignoring vx and vy. Now if you drag a node, it remains in its final position and no longer is affected by the rest of the simulation. You can then move all nodes to any position you wish. ...
Read now
Unlock full access