Skip to main content
Public

Share visualization

Loading preview…

Zoomable Circles & Pan with D3-Zoom

vizhub.com

Shared links may look like this on X, LinkedIn, Slack, and Discord.

Before sharing, review the publishing checklist.

Choose how to deliver this visualization

LinkedIn caption

LinkedIn may not keep text supplied by the share sheet. Copy the caption and paste it into the post if needed. You can tag the VizHub company page when posting.

More options

Embed on a websiteCopy iframe embed code
Download & exportPNG, HTML, source ZIP

Zoomable Circles & Pan with D3-Zoom

0
DDonald Bagwell
Last edited Sep 2, 2024
Created on Sep 2, 2024

This visualization demonstrates a zoomable and pannable SVG canvas containing six colored circles of varying sizes and positions. The example uses the `d3-zoom` library's `zoom` function, which is applied to the SVG element to handle mouse interactions. A `transform` state, updated via a zoom event callback, is applied to a group element containing all circles, allowing the entire set to be panned and scaled smoothly. The circle data, including x, y, radius, and fill color, is hardcoded in the JavaScript.

AI-generated description

A demonstration of how to add panning and zooming using d3-zoom.

Challenge

  • Use this technique to add zooming to a visualization you created, such as a map

Comments

Sign in to join the discussion.

MIT Licensed