[ Launch: Nest Example ] c2b9e87acf6ed8b3a2d2 by axelson
-
-
Save axelson/c2b9e87acf6ed8b3a2d2 to your computer and use it in GitHub Desktop.
Nest Example
This file contains 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
{"description":"Nest Example","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"test.js":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true,"thumbnail":"http://i.imgur.com/GTa7eE4.png"} |
This file contains 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
var data = [{year: 2007, sub: 'MATH', school: 'Iolani', sgp: 50, poor: 10}, | |
{year: 2007, sub: 'READ', school: 'Iolani', sgp: 20, poor: 5}]; | |
var by_school = d3.nest() | |
.key(function(d) { return d.school; }) | |
.entries(data) | |
var by_school_w_rollup = d3.nest() | |
.key(function(d) { return d.school; }) | |
.rollup(function(values) { | |
return {sgp: d3.mean(values, function(d) { return d.sgp; }), | |
poor: d3.mean(values, function(d) { return d.poor; })}; | |
}); | |
console.log('by school2: ' + JSON.stringify(by_school_w_rollup)); | |
d3.select('svg').append('text') | |
.text(JSON.stringify(by_school)) | |
.attr('x', 100) | |
.attr('y', 100); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment