Limiting domain when zooming or panning

527 views
Skip to first unread message

Nils

unread,
Apr 30, 2012, 10:18:21 AM4/30/12
to d3...@googlegroups.com
I have implemented a simple line chart that can be zoomed and panned based on Stephen Bannasch's excellent example (http://bl.ocks.org/1182434).

The domain of my data is [0, n] in the x dimension. How can I limit zooming and panning to this domain using the built-in zoom behavior (i.e. using mousewheel events)? I want to prevent users from panning past 0 on the lower end or n on the upper end, for example they should never be able to see negative values on the x-axis, and want to limit zooming to the same window. 

The examples that I found using extent( [...],[...],[...] ) based on Jason Davies work no longer seem to work in version 2.9.1. Unfortunately, zoom behavior is one of the few features not documented in the otherwise outstanding API documentation.

Any pointers are welcome.

Thanks in advance,
Nils

Nils

unread,
May 8, 2012, 9:28:21 AM5/8/12
to d3...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages