Zoom + Pan
✓ Published0🌍 Public
Mmbostock
Last edited Apr 9, 2020
Created on Apr 9, 2015
A grid of axes fills the viewport, with white gridlines on a gray background. Two buttons, "Zoom In" and "Zoom Out," trigger programmatic zooming. The view uses `d3.behavior.zoom` to manage pan and zoom state, with `d3.scale.linear` and `d3.svg.axis` for the axes. Clicking a button adjusts the zoom scale and translates to keep the center point fixed, then animates the transition with `svg.transition().duration(750)`, calling the zoom event to re-render the axes.
AI-generated descriptionA variation of programmatic zoom where buttons can be used to zoom-in or zoom-out around the current center of the viewport.
gpl-3.0 Licensed