我按照圈子的例子:
我在下面创建了一个圆圈,我希望进行不透明度转换,因为随着数据集的更新,圆圈将开始一个接一个地出现。例如,如果数据长度是5,则出现圆圈1,然后是圆圈2,最后是圆圈5。如果数据被更新为长度为2,则出现圆圈1,然后出现圆圈2。我该怎么做?到目前为止,transition()统一地作用于数据集。
circle.enter().append("circle")
.attr("class", "dot");
// Update (set the dynamic properties of the elements)
circle
.attr("r", 5)
.attr("cy", 20)
.attr("cx", function(d,i){return i*50;})
.attr("fill", "red");
svg.selectAll("circle")
.style("opacity", 0)
.transition()
.duration(1000)
.style("opacity", 1);
问题:
为“过渡”选择中的每个元素设置延迟。
解:
使用delay()
与function(d, i)
说明:
您必须在以下位置添加transition()
:
.delay(function(d,i){ return i * someNumber })
其中someNumber是每个元素的延迟(以毫秒为单位)。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句