再次修改这个问题,因为在新版本的库d3(3.0.3)中解决方法不起作用,所以再次来请教一下,不胜感激。
这是库 d3 (3.0.3) 的新代码:
https://gist.github.com/4495104 http://bl.ocks.org/4495104/e7a7589098140dff36df7ab2a824d71072bc3be4
根据我的工作,错误应该在“491”行。
// Reset the domain relative to the current zoom offsets.
x.domain(x0.range().map(function(x) {
return (x - translate[0]) / scale;
}).map(x0.invert));
我们用 改变x.domain
每一秒setInterval
,因为我们想要生成背景移动的外观,但是每次运行事件d3.behavior.zoom()
(缩放或平移)时,都会x.domain
自动切换到初始值。在下一个链接中,您可以查看问题。