D3 in Depth. Zoom and pan
There’s three steps to add zoom and pan behaviour to an element:
- call
d3.zoom()to create a zoom behaviour function - add an event handler that gets called when a zoom or pan event occurs. The event handler receives a transform which can be applied to chart elements
- attach the zoom behaviour to an element that receives the zoom and pan gestures