Pan & Zoom I
A canvas displays a phyllotaxis pattern of 2,000 points, which can be panned and zoomed interactively. Using d3.zoom, the current transform is applied directly to the canvas context via translate and scale, redrawing all points on each zoom event. The data is generated procedurally with a phyllotaxis function, and the view is transformed rather than the data itself.
AI-generated descriptionThis example demonstrates using d3-zoom to enable interactive panning and zooming of a Canvas element. The current zoom transform is applied to the Canvas using context.translate and context.scale. This technique is similar to applying an SVG transform. An alternate zooming strategy is to transform the data rather than the view; this lets you customize the display on zoom, such as rendering circles that are the same size regardless of scale.