如何在定向力图D3中动画节点?

时间:2015-06-30 12:27:09

标签: javascript animation d3.js

我尝试在D3中使用定向力图,这个代码超过here

这就是我想要实现的目标:

基于stage: true,动画应该发生。例如,在上面的代码中,前两个标签的stagetrue

 var nodes = [
        {label: '1st stage', x:   constant, y: 215 , width:70,height:50 , color :color , stage: true },
        {label: '2nd stage', x: constant + 150 , y: 215 ,width:80,height:50 ,color :color, stage: true },
   . . . 

所以动画应该像“第一阶段矩形变大,标记为绿色和箭头动画,下一个矩形相同的动画,如果stage为真。”

目前我正在通过矩形上的click模仿此过程,该矩形检查stage并呈现绿色。但是这个过程现在需要成为一个动画。

我希望这些线条标记为箭头,我试过这个:

var link = svg.selectAll('.link')
    .data(links)
    .enter().append('line')
    .attr('class', 'link')
    .attr("stroke-width", "10")
    .style("opacity", "1.2")
    .style("marker-end",  "url(#suit)")

但是线条显示仍然是法线,但不是箭头。

我该如何做这些动画和箭头?

0 个答案:

没有答案