Transition partition arcs back to original angles

178 views Asked by At

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:

  1. At what point d.x and d.dx are initialized, whether in d3.svg.arc() or when the arc paths are actually appended.
  2. How to bind d.x and d.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)
    });
1

There are 1 answers

0
Lars Kotthoff On BEST ANSWER

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.