Skip to content

Instantly share code, notes, and snippets.

@gelicia
Created October 18, 2013 17:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gelicia/7045226 to your computer and use it in GitHub Desktop.
Save gelicia/7045226 to your computer and use it in GitHub Desktop.
helping ukmeth0d
[ { "action_name" : "successful_pass",
"id" : "9392",
"league" : { "name" : "Bundesliga",
"season" : "2013/2014"
},
"match" : { "away_score" : 3,
"away_squad" : "Hamburger SV",
"home_score" : 3,
"home_squad" : "FC Schalke 04",
"played_on" : 1376235000000
},
"minutes" : 93,
"occurences" : 3,
"period" : "SecondHalf",
"player_id" : "40236",
"player_name" : "Christian Clemens",
"squad" : "FC Schalke 04",
"timestamp" : 1376241690000,
"total_points" : 1500
},
{ "action_name" : "successful_pass",
"id" : "9352",
"league" : { "name" : "Bundesliga",
"season" : "2013/2014"
},
"match" : { "away_score" : 3,
"away_squad" : "Hamburger SV",
"home_score" : 3,
"home_squad" : "FC Schalke 04",
"played_on" : 1376235000000
},
"minutes" : 88,
"occurences" : 1,
"period" : "SecondHalf",
"player_id" : "40236",
"player_name" : "Christian Clemens",
"squad" : "FC Schalke 04",
"timestamp" : 1376241407000,
"total_points" : 500
},
{ "action_name" : "successful_pass",
"id" : "9322",
"league" : { "name" : "Bundesliga",
"season" : "2013/2014"
},
"match" : { "away_score" : 3,
"away_squad" : "Hamburger SV",
"home_score" : 3,
"home_squad" : "FC Schalke 04",
"played_on" : 1376235000000
},
"minutes" : 85,
"occurences" : 1,
"period" : "SecondHalf",
"player_id" : "40236",
"player_name" : "Christian Clemens",
"squad" : "FC Schalke 04",
"timestamp" : 1376241203000,
"total_points" : 500
},
{ "action_name" : "successful_duel",
"id" : "9305",
"league" : { "name" : "Bundesliga",
"season" : "2013/2014"
},
"match" : { "away_score" : 3,
"away_squad" : "Hamburger SV",
"home_score" : 3,
"home_squad" : "FC Schalke 04",
"played_on" : 1376235000000
},
"minutes" : 85,
"occurences" : 2,
"period" : "SecondHalf",
"player_id" : "40236",
"player_name" : "Christian Clemens",
"squad" : "FC Schalke 04",
"timestamp" : 1376241172000,
"total_points" : 6000
} ]
{"description":"helping ukmeth0d","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},"actions.json":{"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,"thumbnail":"http://i.imgur.com/1od2FJo.png"}
var data = tributary.actions
var nestedData = d3.nest()
.key(function(d){ return d.league.name + " " +
d.league.season + " " + d.match.away_squad + " " +
d.match.home_squad + " " + d.match.played_on + " " +
d.player_id;})
.rollup(function(actions){
return d3.sum(actions, function(d){return d.total_points;})
})
.entries(data)
console.log(nestedData);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment