score:5

Accepted answer

You can aggregate the data per month using this code:

var aggregated = d3.nest()
               .key(function(d) { return (new Date(+d.x * 1000)).getMonth(); })
               .rollup(function(d) { return d3.sum(d, function(e) { return +e.y; }); })
               .entries(data)
               .map(function(d) { return {x: +d.key, y: d.values}; });

Updated jsfiddle here. Note that I also changed the time unit for the axis -- you might need to play around with it a bit to make it show the labels you want.

score:0

If you don't want to use d3 to transform the data, you can always opt to use underscorejs. It's very easy to understand and useful in most javascript projects. I did exactly the same in this screencast on rickshaw: http://tagtree.tv/d3-with-rickshaw-and-angular


Related Query