All examples By author By category About

cmdoptesc

JavaScript D3: Arc tween transitions using attrTween and attr methods

D3: Arcs Tweening Animation

view on bl.ocks.org

Click on the grey circles. The green arcs will transition using attr, whereas the red ones will use the attrTween method.

If you have not seen/read Bostock's arc tween example, it's probably the best place to start. Secondly, I've posted up a basic example of drawing static, concentric arcs (gist), which might be helpful before adding on tweens/animations.

Below is some annotated source code from my experience playing with arcs. The biggest issue I came across was understanding the role of the arcTween helper function in relation to attrTween. Unlike attr, which takes a value as its second argument, attrTween requires a helper function, arcTween, which will be called during the intermediary animation ticks. This method was used for my muniNow project (git).

Countless credit goes to Mike Bostock for all of his wonderful resources.

If you have any questions, please feel free to leave a comment on the Gist.

Cheers, al lin, aug. 2013