Skip to main content
100%

Zoom + Pan

✓ Published0🌍 Public
Mmbostock
Last edited Feb 9, 2016
Created on Oct 15, 2012

This example demonstrates how to pan and zoom a chart using D3.js v3. It renders an SVG with axes and a filled background rectangle, using linear scales for the x- and y- dimensions. The `d3.behavior.zoom` API links the zoom behavior to the scales, allowing mouse wheel and drag interactions to rescale the axes. When zooming occurs, the axes are redrawn to reflect the updated scale ranges. The code sets a zoom scale extent between 1 and 32, and uses `d3.svg.axis` to produce the tick marks and grid lines.

AI-generated description

An example of d3.behavior.zoom applied using x- and y-scales. This example can be extended with programmatic control to animate between preset views.

gpl-3.0 Licensed

Similar vizzes