Skip to main content
100%

Zoom Transitions

✓ Published0🌍 Public
Mmbostock
Last edited Aug 12, 2019
Created on May 18, 2016

A thousand points arranged in a phyllotaxis spiral zoom smoothly between random targets. Every 2.5 seconds, the d3-zoom transform animates to center a newly selected point, shown in red, at the viewport’s center. The example uses d3.zoom’s `transform` method within a d3.transition, rendering the points to a Canvas 2D context via the `zoom` event handler.

AI-generated description

This example demonstrates smooth zoom transitions using d3-zoom. Every 2.5 seconds, a point is randomly selected, and the transform to position the selected point at the center of the viewport is computed:

function transform() {
  return d3.zoomIdentity
      .translate(width / 2, height / 2)
      .scale(8)
      .translate(-point[0], -point[1]);
}

Then, transition.call is used to invoke zoom.transform with the new transform, initiating a smooth zoom transition from the current transform.

gpl-3.0 Licensed

Similar vizzes