Pie (donut) chart segment order in D3
In d3 V4 this is also valid syntax (without the .layout
):
d3.pie()
.value(function(d) { return d.value; })
.sort(null)
d3 automatically sorts by value for pie charts. Luckily, disabling sorting is quite easy, just use the sort(null)
method on thedonut
function, i.e.:
var donut = d3.layout.pie().value(function(d){
return d.itemValue;
}).sort(null);
Here's a fiddle.