Skip to main content
100%

Zoom Center

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Aug 13, 2013

By setting the zoom behavior's center, this example fixes the focal point of mousewheel zooming to the center of the canvas, rather than the default cursor position. A set of concentric circles, generated from a range of radii, shows the zoom transformation clearly. The visualization uses `d3.behavior.zoom` with an explicit `.center` array and redraws a group container on each zoom event. The SVG renders the axis circles and a red center marker, with the D3 v3 library handling the interaction and scaling.

AI-generated description

By setting zoom.center, you can control the focal point of the zoom behavior on mousewheel. The default zoom.center is null, which sets the focal point to the current mouse position. In this example, the center is instead fixed to the center of the canvas, such that on zoom, the center of the canvas stays fixed.

gpl-3.0 Licensed

Similar vizzes