How can I transition arc angles, initially defined by d3.svg.arc()
, back to their original values when using d3.layout.partition
?
I am trying to store the initial startAngle and endAngle values d.x
and d.dx
somewhere so that I can transition back to them at a later state. However, I do not know:
- At what point
d.x
andd.dx
are initialized, whether ind3.svg.arc()
or when the arc paths are actually appended. - How to bind
d.x
andd.dx
to the elements when I am using a partition to render them.
Normally I might bind the initial startAngle and endAngle to the elements with datum()
. I believe I am looking for something similar to:
selectAll('path').data(function(d) {
return partition.values({
'initialStart': d.x,
'initialEnd': d.dx
}).nodes(d)
});
In principle this is the same as transitioning pie charts, where you need a custom tween function to get the animation right. For this it is necessary to save the original value in a separate attribute -- in your case you can do the same thing.
Attributes are set when the layout is run; this is completely independent of the rendering and appending elements to the DOM.