liveBook · Manning

scaleExtent()

As explained in D3.js in Action, Third Edition

scaleExtent() is a D3 zoom behavior method that gets or sets the minimum and maximum allowed scale factors.

scaleExtent() limits how far users can zoom a D3 visualization. Pass an array containing the minimum and maximum scale factors, such as [1, 5] for 100% through 500% zoom. section 13.3

Constrain a world map

Configure the zoom behavior with .scaleExtent([1, 5]) so the map cannot shrink below its initial size or enlarge beyond five times that size. Pair this with translateExtent() to keep the map within useful boundaries. section 13.3

How D3.js in Action, Third Edition covers it

How deep it goes
Defines minimum and maximum scale values, but does not explain accessor internals.
Examples
Uses a world map configured with scaleExtent([1, 5]) and a matching translation extent.
What it assumes
Assumes a zoom behavior attached to an SVG map or container.
What you can do after
Operate/configure a D3 zoom behavior with explicit minimum and maximum scale factors.
How it connects
Connects zoom behavior with translation extent, transforms, SVG containers, and reset controls.

Related concepts

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.