Skip to content
Create a gist now

Instantly share code, notes, and snippets.

d3 data array to summary object (e.g., "SELECT x, count(*) FROM y GROUP BY x")
// This may not be the most efficient way to do this, but it's pretty clean
var yourObject = d3.nest()
.key(function(d) { return d; })
.rollup(function(d) { return d.length; })
// e.g.,
// var input = ["this","is","a","test","for","this","method"];
// var output = {"this":2,"is":1,"a":1,"test":1,"for":1,"method":1}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.