liveBook · Manning

D3.zoomIdentity

As explained in D3.js in Action, Third Edition

d3.zoomIdentity is the D3 constant representing an identity transformation with unit scale and zero translation.

d3.zoomIdentity represents the identity transformation: scale 1, or 100%, with horizontal and vertical translations of 0. Applying it returns a visualization to its initial position and size. section 13.3

Resetting a zoomed map

Attach a click listener to the Reset Zoom button and pass d3.zoomIdentity to the zoom handler’s transform() accessor. The map then reverts to its initial state. The zoom event can check k, x, and y to hide the reset button when they return to 1, 0, and 0. section 13.3

How D3.js in Action, Third Edition covers it

How deep it goes
Defines scale and translation values and demonstrates reset wiring, without descending into transformation internals.
Examples
Uses a world map with a Reset Zoom button that restores the initial view.
What you can do after
Apply it via d3-zoom to restore a visualization’s identity transform after interaction.
How it connects
Connects zooming and panning with transformations, zoom events, and reset controls.

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.