Skip to main content
100%

Force Dragging I

✓ Published0🌍 Public
ZZoeLeBlanc
Last edited Feb 22, 2018
Created on Feb 21, 2018

This example demonstrates applying d3-drag to a force-directed graph computed using d3-force. The network shows character relationships from Les Misérables, rendered as SVG circles connected by lines. When a drag gesture starts on a node, that node is fixed to the pointer position via the simulation’s `fx` and `fy` properties, and the simulation’s target alpha is raised to 0.3 to “heat” the layout while interacting. Releasing the node removes the fixed position and resets the target alpha to zero.

AI-generated description

This example demonstrates applying d3-drag to a force-directed graph computed using d3-force. When the drag gesture starts, the targetted node is fixed to the pointer; it is released when the gesture ends. In addition, the simulation is temporarily “heated” during interaction by setting the target alpha to a non-zero value.

If desired, you could refine this technique by also fixing nodes on mouseover, and releasing them on mouseout. (However, if there’s an active drag gesture during mouseout, you wouldn’t want to release the node until the gesture finishes.)

Compare to the Canvas version.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/2675ff61ea5e063ede2b5d63c08020c7'>Force Dragging I</a>

gpl-3.0 Licensed

Similar vizzes