Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var x0 = d3.scale.linear().domain(…).range(…), // initial scale
- x = x0.copy(); // copy to use for axes and zoom behaviour
- setInterval(function() {
- var translate = zoom.translate(),
- scale = zoom.scale(),
- xd = x0.domain(),
- dx = 1;
- // Set a new x-domain: offset by dx.
- x0.domain([xd[0] += dx, xd[1] += dx]);
- // Set the zoom x-domain (this resets the domain at zoom scale=1).
- zoom.x(x.domain(xd));
- // Reset the domain relative to the current zoom offsets.
- x.domain(x0.range().map(function(x) {
- return (x - translate[0]) / scale;
- }).map(x0.invert));
- }, 1e3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement