Skip to main content
100%

Zoomable and Draggable Circles with D3-Drag and D3-Zoom

✓ Published1🌍 Public
AAl Piepho
Last edited Mar 4, 2024
Created on Mar 3, 2024

This example demonstrates draggable and zoomable circles, where users can reposition individual circles by dragging and pan or scale the entire scene via zoom interactions. It visualizes six colored circles, each with a fixed position, radius, and fill color. The implementation uses D3’s `drag` and `zoom` behaviors, with the state managed through a `setState` callback that updates circle coordinates during drag and applies a transform to a parent group element during zoom. The rendering uses D3’s `select`, `selectAll`, `join`, and `attr` methods, with a light green background.

AI-generated description

Draggable circles using d3-drag.

MIT Licensed

Similar vizzes