Skip to content

Instantly share code, notes, and snippets.

Last active August 29, 2015 14:07
What would you like to do?
d3.nest example
// Insert this at the top of the process() function
// This part just converts the flat objec to a flat array, nothing fancy
var flatty = [];
_.each(data, function(obj, key) {
if ( key !== 'keys' ) { flatty.push(obj); }
var nested_data = d3.nest() // create the nest object
// this is the top level groupby
// I'm just using the momen() function to conver the StartTime into the day of the month
.key(function(entry){ return moment(entry.StartTime).date() })
// this is the subgroup below the day of the month
.key(function(entry){ return entry.Sponsor })
// This is the third level where it's grouped by Task
.key(function(entry){ return entry.Task })
// I have no idea why the data is inserted last
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment