Skip to main content
100%

d3-force-attract: mouse attract II

✓ Published0🌍 Public
FFrissAnalytics
Last edited Oct 1, 2018
Created on Dec 8, 2016

Fifty circles with randomized positions and radii are rendered as an SVG. The visualization demonstrates a multi-force physics simulation where a force-based layout continuously attracts the circles toward the current mouse location while a separate collision force keeps them from overlapping. The example uses `d3.forceSimulation()` and `d3.forceAttract()` from the d3-force-attract library, with per-node attract strength defined via the `inertia` property. A mouse-move event updates the attract target and restarts the simulation, updating circle positions on each tick.

AI-generated description

Example illustrating the use of d3-force-attract with a dynamic attract target and a collision force.

forked from <a href='http://bl.ocks.org/ericsoco/'>ericsoco</a>'s block: <a href='http://bl.ocks.org/ericsoco/6e0573860e7f6655cee885d8b1b84065'>d3-force-attract II</a>

mit Licensed

Similar vizzes