Skip to main content
100%

Pan & Zoom II

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

This example demonstrates a pan-and-zoom interface for a dataset of 2,000 points arranged in a phyllotaxis pattern, drawn on a Canvas. On zoom, the circles retain a constant pixel radius rather than scaling with the data. The implementation uses `d3.zoom` to handle user interaction and applies the transform via `transform.apply` to each point in `drawPoints`, while `d3.event.transform` supplies the current transformation during the zoom event. The `context.arc` method renders each point individually.

AI-generated description

This examples demonstrates using transform.apply to apply the zoom behavior’s transform to data, rather than using a Canvas transform. This is typically slower, but it lets you customize the display on zoom, such as rendering circles that are the same size regardless of scale. This technique is similar to repositioning SVG elements on zoom.

gpl-3.0 Licensed

Similar vizzes