Skip to content Skip to sidebar Skip to footer

Simple D3.js Pie Chart Transitions *without* Data Joins?

I'm working with a data set that's categorically identical from year to year, and I want to make a D3 pie chart with animated transitions from year to year. The data is in a 2-d ar

Solution 1:

Okay, I can see multiple issues/drawbacks with your approach.

1) In your code:

arcs.append("path")
    .attr("fill", function(d,i){
        return colors[i];
    })
    .attr("d", arc);

arc is a function call that you are making that doesn't actually exist in the code that you have shared with us, or you need to write. You have this arc function call multiple times, so this will need to be addressed.

2) I would check into using the .on("click", function(d,i) { do your transitions here in this function call }); method instead of setting the transition and attributes of each of the items. I have found that it makes the transition calls easier to manage if you start doing anything more fancy with the transitions. You can see an example of what I mean in the Chord Diagram at http://bl.ocks.org/mbostock/4062006

Hopefully this helps you out a bit.

Post a Comment for "Simple D3.js Pie Chart Transitions *without* Data Joins?"