Created
October 23, 2012 19:40
-
-
Save kardeiz/3941080 to your computer and use it in GitHub Desktop.
d3 data array to summary object (e.g., "SELECT x, count(*) FROM y GROUP BY x")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; }) | |
.map(yourArray); | |
// 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