Skip to content

Instantly share code, notes, and snippets.


mbostock/.block Secret

Last active May 22, 2019 12:02
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<table id="countries"></table>
<script src="//"></script>
d3.json("sample.json", function(error, json) {
if (error) throw error;
var data = d3.nest()
.key(function(d) { return d.Country.toLowerCase(); })
var tr ="#countries")
.text(function(d) { return d.key; });
.data(function(d) { return d.value; })
.text(function(d) { return d.Aspect + ": " + d.Value; });
{"Country": "France", "Aspect": "Cost_of_Living", "Value": 55},
{"Country": "France", "Aspect": "Leisure_&_Culture", "Value": 81},
{"Country": "France", "Aspect": "Economy", "Value": 69},
{"Country": "France", "Aspect": "Environment", "Value": 72},
{"Country": "France", "Aspect": "Freedom", "Value": 100},
{"Country": "France", "Aspect": "Health", "Value": 100},
{"Country": "France", "Aspect": "Infrastructure", "Value": 92},
{"Country": "France", "Aspect": "Risk_&_Safety", "Value": 100},
{"Country": "France", "Aspect": "Climate", "Value": 87},
{"Country": "France", "Aspect": "Final", "Value": 82},
{"Country": "Australia", "Aspect": "Cost_of_Living", "Value": 56},
{"Country": "Australia", "Aspect": "Leisure_&_Culture", "Value": 82},
{"Country": "Australia", "Aspect": "Economy", "Value": 71},
{"Country": "Australia", "Aspect": "Environment", "Value": 76},
{"Country": "Australia", "Aspect": "Freedom", "Value": 100},
{"Country": "Australia", "Aspect": "Health", "Value": 87},
{"Country": "Australia", "Aspect": "Infrastructure", "Value": 92},
{"Country": "Australia", "Aspect": "Risk_&_Safety", "Value": 100},
{"Country": "Australia", "Aspect": "Climate", "Value": 87},
{"Country": "Australia", "Aspect": "Final", "Value": 81},
{"Country": "Switzerland", "Aspect": "Cost_of_Living", "Value": 41},
{"Country": "Switzerland", "Aspect": "Leisure_&_Culture", "Value": 86},
{"Country": "Switzerland", "Aspect": "Economy", "Value": 79},
{"Country": "Switzerland", "Aspect": "Environment", "Value": 78},
{"Country": "Switzerland", "Aspect": "Freedom", "Value": 100},
{"Country": "Switzerland", "Aspect": "Health", "Value": 95},
{"Country": "Switzerland", "Aspect": "Infrastructure", "Value": 96},
{"Country": "Switzerland", "Aspect": "Risk_&_Safety", "Value": 100},
{"Country": "Switzerland", "Aspect": "Climate", "Value": 77},
{"Country": "Switzerland", "Aspect": "Final", "Value": 81}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment