Skip to main content
🌍 Public

Share visualization

Send this visualization to others.

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

Public visualization

Viewing a saved revision (read-only)

d0f9c9f925294bc6b7d6b3fe8ab04429

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

0 stars1🌍 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.