Skip to main content
100%

Force Dragging I

✓ Published0🌍 Public
Aakollegger
Last edited Aug 25, 2017
Created on Aug 25, 2017

A force-directed graph of character co-occurrences in Les Misérables, rendered as SVG circles and lines, demonstrates applying d3-drag to a d3-force simulation. Dragging a node fixes it to the pointer by setting its x and y coordinates, while the simulation’s alpha target is temporarily increased to reheat the layout; releasing the node unfixes it and cools the simulation. The graph uses d3.v4 and the GPL-3.0 license.

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