Skip to content

Instantly share code, notes, and snippets.

@eric
Created March 15, 2012 21:57
Show Gist options
  • Save eric/2047251 to your computer and use it in GitHub Desktop.
Save eric/2047251 to your computer and use it in GitHub Desktop.
process = (data) ->
keyMaker = (d) ->
time = d.time
if time not instanceof Date
time = new Date(time * 1000)
+d3.time.day.floor(time) / 1000
nestedData = d3.nest()
.key(keyMaker)
.rollup((v) -> d3.sum(v, (d) -> d.value))
.sortKeys(d3.ascending)
.entries(data)
nestedData.map (d) -> time: new Date(d.key * 1000), value: d.values
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment