Hi,
Sorting a pie chart's Arc's, by value, is pretty straight forward...
var pie = d3.layout.pie()
.value(function(d) { return +d.value; })
.sort(function(a, b) { return b.value - a.value; }); // Sort arcs by size. Loses order of input.
So is "not sorting"
var pie = d3.layout.pie()
.value(function(d) { return +d.count; })
.sort(null); // No sortying by arc size. Maintains order of input.
If I have an input parameter called "sort", where "0 = No Sort" and "1 = Sort", what do you think is the most elegant way to write a function that sorts only on if "sort = 1", to pass into the callback for the ".sort" property?
I'm struggling with the syntax to be able to pass in "sort" along with "a" and "b", simultaneously, as variables that would allow for, both, sort and no-sort situations.
Thanks for any help you can offer.
Frank