All examples By author By category About

mbostock

Pan & Zoom I

This 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.