mbostock/d3 — pull request #2019 by lebolo (2014-09-12 21:20:42+00:00)
Title: Add xExtent and yExtent to d3.behavior.zoom (fixes #1084)

All of this code was contributed by @mhsmith (https://github.com/mbostock/d3/pull/1299) and reimplemented for the latest d3 version by @lebolo.

These limit all actions to ensure the domain of the corresponding scale always stays within the given extent. As well as panning, zooming actions may also be limited in the zoom-out direction. If more than one of `scaleExtent`, `xExtent` and `yExtent` are provided, the effective bottom end of the scale extent will be the most restrictive of the three.

If `scaleExtent` and `x/yExtent` cannot be satisfied simultaneously (i.e. the lower scale limit implied by `x/yExtent` is above the `scaleExtent`), then `x/yExtent` will take priority.

Simple example: http://bl.ocks.org/mhsmith/5732011
Example with discontinuous and log scales: http://bl.ocks.org/mhsmith/5734904