Skip to main content
100%

Force Dragging III

✓ Published0🌍 Public
Mmbostock
Last edited Jul 4, 2016
Created on May 11, 2016

This example shows an interactive force-directed graph of character co-occurrence in *Les Misérables*, rendered as nodes and links on a Canvas. Users can click and drag any node to reposition it, which temporarily fixes that node to the pointer and reheats the simulation. The code uses d3.forceSimulation with link, charge, and center forces, while d3.drag handles the drag gesture. Data comes from the bundled miserables.json file, and the visualization redraws on each simulation tick.

AI-generated description

This example demonstrates applying d3-drag to a force-directed graph computed using d3-force. When the drag gesture starts, the targeted 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.

Compare to the SVG version.

gpl-3.0 Licensed

Similar vizzes