Skip to main content
100%

Force move 400 dots in 10 buildings

✓ Published0🌍 Public
PPhilippe Rivière
Last edited Oct 2, 2016
Created on Sep 29, 2016

Four hundred colored dots, each assigned to one of ten randomly placed building centers, are drawn on a Canvas as they converge into ten distinct clusters. A custom force named `shape` pulls each node toward its building’s center, while `d3.forceCollide` keeps the circles from overlapping. The simulation runs via `d3.forceSimulation`, with each tick redrawing the canvas using `fillStyle` and `arc` calls. The color scale `d3.scaleOrdinal` with `schemeCategory10` distinguishes the groups by building.

AI-generated description

This example uses d3.forceCollide to prevent circles from overlapping.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/31ce330646fa8bcb7289ff3b97aab3f5'>Collision Detection</a>

See also Bounded Force Layout - very tightly packed.

forked from <a href='http://bl.ocks.org/Fil/'>Fil</a>'s block: <a href='http://bl.ocks.org/Fil/69f1d5f68099bf6350ed42aed0941e5c'>Collision Detection in a tight square</a>

gpl-3.0 Licensed

Similar vizzes