I'd like to sort the outer ring of my d3 sunburst by year not by value, so it's in chronological order. Here is my code:
d3.csv("etds.csv", function(error, dataset) {
var hierarchy = {
key: "ETD",
values: d3.nest()
.key(function(d) { return d.college; })
.key(function(d) { return d.dept; })
.sortKeys(d3.ascending).key(function(d) { return +d.year; })
.rollup(function(leaves) {
return leaves.length;
})
.entries(dataset)
};
The ".sortKeys(d3.ascending)" is being ignored. The outer ring is still arranged by value.
Sample CSV:
college,dept,year,url
College of Education, Health & Human Development,Education.,2011
College of Letters & Science,Earth Sciences.,2010
College of Letters & Science,Microbiology & Immunology.,2004
College of Letters & Science,Ecology.,1984
College of Letters & Science,Chemistry & Biochemistry.,2008
College of Letters & Science,Mathematical Sciences.,2011
College of Agriculture,Land Resources & Environmental Sciences.,2009
College of Agriculture,Agricultural Economics & Economics.,1996
College of Letters & Science,English.,2007
Update: Tried this:
.sort(function(a, b){ return d3.descending(b.values,a.values); })
Updated my plunker
It seems that this may be the offending code. I'm not sure how to alter it to get what I'm looking for the outer ring is chronological by year but the values are all screwed up if I change d.values to d.key, see inline comment.
var partition = d3.layout.partition()
.children(function(d) {
return Array.isArray(d.values) ?
d.values : null;
})
.value(function(d) {
return d.values; //d.key sorts by year in outer ring
});
This code is from Chapter 7 of jsDataV.is related GitHub
Updated my plunker