I have a dc.js ordinal chart whose x-axis consists of things like \'Cosmetics\' and the y-axis is the number of sales. I want to sort the chart by sales decreasing, however
This is the hack I ended up doing. Be aware that it could have performance issues on large data sets as all() is faster than top(Infinity). For some reason I couldn't get Gordon's answer to work, but in theory it should.
On my group I specified an order function
group.order(function(p) {
return p.myfield;
});
Then because all() doesn't use the order function I overrode the default all function
group.all = function() {
return group.top(Infinity);
}
And then on my chart I had to specify an order function
chart.ordering(function(d){
return -d.value.myfield
}); // order by myfield descending