0
我在D3.js工作,并试图了解nested selections和general update pattern。D3.js:嵌套选择?
我的数据是这样的:
var data1 = [
{ 'name': 'LHR', 'position': 1, 'flights': [1,10,12,14,3] },
{ 'name': 'LAX', 'position': 2, 'flights': [3,6,12,6,3] },
{ 'name': 'SFO', 'position': 3, 'flights': [2,8,17,18,5] }
];
渲染SVG是这样的:
<g class="airport LAX">
<text class="LAX legend" x="250" y="40" dy=".2em">LAX</text>
<circle class="flight" cx="20" cy="16" r="3"></circle>
<circle class="flight" cx="40" cy="22" r="3"></circle>
<circle class="flight" cx="60" cy="34" r="3"></circle>
<circle class="flight" cx="80" cy="22" r="3"></circle>
<circle class="flight" cx="100" cy="16" r="3"></circle>
</g>
而且我想正在添加,更新和删除文本和圆形元素的平滑过渡 - 从图表顶部出现的新元素,更新的元素平滑移动,删除掉图表底部的元素。
这是到目前为止我的代码:http://jsfiddle.net/kqxhj/5/
我可以转换新的和更新的元素。但我不能这样做,因为某些原因,就是让exit
选择这些元素很好地删除它们。
我怎样才能得到exit
选择这些圆圈和文本元素,这样我就可以平滑地过渡不送图形的底部?
真棒,谢谢!之前没有看到过像这样的“延迟”。我注意到一个单独的问题,即如果连续两次单击按钮,转换就会中断。不过,我已经把它写成了一个单独的问题。 http://stackoverflow.com/questions/16335781/d3-js-stop-transitions-being-interrupted – Richard 2013-05-02 10:31:27