-
-
Save mbostock/844752 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script type="text/javascript" src="https://github.com/mbostock/d3/raw/v1.2.1/d3.js"></script> | |
</head> | |
<body> | |
<table id="countries"> | |
</table> | |
<script type="text/javascript"> | |
d3.json("sample.json", function(json) { | |
var data = d3.nest() | |
.key(function(d) { return d.Country; }) | |
.map(json); | |
d3.select("#countries") | |
.selectAll("tr") | |
.data(d3.entries(data)) | |
.enter().append("tr") | |
.selectAll("td") | |
.data(function(d) { return d.value; }) | |
.enter().append("td") | |
.text(function(d) { return d.Country + " - " + d.Aspect + ": " + d.Value; }); | |
}); | |
</script> | |
</body> | |
</html> |
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
[ | |
{"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