Two levels of nesting
See it running at http://bl.ocks.org/3096857
Two levels of nesting
See it running at http://bl.ocks.org/3096857
<html> | |
<head> | |
<title>D3 Nested Nest Example</title> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
</head> | |
<body> | |
<script> | |
d3.csv("./nest2.csv", function(csv_data){ | |
var nested_data = d3.nest() | |
.key(function(d) { return d.region; }) | |
.key(function(d) { return d.country; }) | |
.entries(csv_data); | |
console.debug(nested_data); | |
alert(JSON.stringify(nested_data)); | |
}); | |
</script> | |
</body> | |
</html> | |
id | region | country | us_country_code | iso2_code | main_trade-group | imports_to | exports_from | total_trade | group | trade_balance | year | |
---|---|---|---|---|---|---|---|---|---|---|---|---|
1 | Africa | Algeria | 7210 | DZ | OPEC | 15455.9 | 1101.9 | 16557.8 | high | -14354 | 2006 | |
2 | Africa | Algeria | 7210 | DZ | OPEC | 17816.1 | 1652.4 | 19468.5 | high | -16163.6 | 2007 | |
3 | Africa | Germany | 7210 | DZ | OPEC | 17816.1 | 1652.4 | 19468.5 | high | -16163.6 | 2007 | |
4 | German | Algeria | 7210 | DZ | OPEC | 15455.9 | 1101.9 | 16557.8 | high | -14354 | 2006 |