Skip to main content
100%

Force Dragging II

✓ Published0🌍 Public
AAjayyy
Last edited Jun 29, 2018
Created on Jun 29, 2018

This example demonstrates draggable circles with collision detection, rendered on a Canvas using D3 v4. The simulation is driven by `d3.forceSimulation` with `d3.forceCollide`, updating 324 circles on each tick to redraw them via the canvas 2D context. Users can drag any circle, which sets fixed positions (`fx`, `fy`) during the interaction, while the physics engine resolves overlaps. The code uses `d3.drag` for pointer handling and relies on `simulation.find` to identify the circle under the cursor.

AI-generated description

This example demonstrates using d3.drag with d3.forceCollide to implement draggable circles with collision detection.

forked from <a href='http://bl.ocks.org/mbostock/'>mbostock</a>'s block: <a href='http://bl.ocks.org/mbostock/2990a882e007f8384b04827617752738'>Force Dragging II</a>

mit Licensed

Similar vizzes