Skip to content

Instantly share code, notes, and snippets.

@ianmackinnon
Forked from mbostock/.block
Last active December 31, 2015 08:29
Show Gist options
  • Save ianmackinnon/7960580 to your computer and use it in GitHub Desktop.
Save ianmackinnon/7960580 to your computer and use it in GitHub Desktop.
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 2.
{
"AD": 83608,
"AE": 400502660,
"AF": 52981686,
"AG": null,
"AL": 742884,
"AM": 19590,
"AO": 162001,
"AR": 7973424,
"AT": 47959571,
"AU": 240665017,
"AW": null,
"AZ": 6209245,
"BA": 794124,
"BB": 40500,
"BD": 2207641,
"BE": 39104118,
"BF": 2247837,
"BG": 33028342,
"BH": 13412614,
"BJ": 33944,
"BM": 3531,
"BN": 52189201,
"BO": 1950,
"BR": 74846702,
"BS": 10387,
"BT": null,
"BW": 1998976,
"BY": 399684,
"BZ": null,
"CA": 117592986,
"CD": 10610,
"CF": 2685623,
"CG": 1827999,
"CH": 103764026,
"CI": null,
"CL": 93444843,
"CM": 335926,
"CN": 69510882,
"CO": 107300615,
"CR": 228313,
"CU": 44924,
"CV": 30500,
"CY": 6493961,
"CZ": 159955753,
"DE": 296497171,
"DJ": 420900,
"DK": 100796624,
"DO": 1024529,
"DZ": 105856181,
"EC": 17447785,
"EE": 34571782,
"EG": 73112188,
"ER": null,
"ES": 170871543,
"ET": 1907406,
"FI": 102139058,
"FK": null,
"FR": 125536663,
"GB": 500248543,
"GE": 4630262,
"GH": null,
"GI": null,
"GL": 42560,
"GM": null,
"GN": null,
"GQ": 2643397,
"GR": 70916553,
"GT": 3393,
"GY": 3900,
"HK": 103611,
"HN": 572099,
"HR": 11775182,
"HT": 8950,
"HU": 8284157,
"ID": 92089079,
"IE": 14448478,
"IL": 52781687,
"IN": 455812582,
"IQ": 37692376,
"IS": 1455223,
"IT": 154873477,
"JM": null,
"JO": 12243303,
"JP": 26131783,
"KE": 12104116,
"KG": 101792,
"KH": 3290239,
"KR": 106465900,
"KW": 52728209,
"KY": null,
"KZ": 12891145,
"LA": null,
"LB": 1485545,
"LC": 20712,
"LI": 312826,
"LK": 1581454,
"LR": 12577,
"LS": null,
"LT": 4109833,
"LU": 16862107,
"LV": 6417983,
"LY": 100871872,
"MA": 209884670,
"MD": 748105,
"ME": 1038162,
"MG": null,
"MK": 958975,
"ML": 673508,
"MM": null,
"MN": null,
"MO": 54040,
"MR": 6348607,
"MT": 1055295,
"MU": 63560,
"MW": 369744,
"MX": 171558127,
"MY": 34443972,
"MZ": null,
"NA": 238956,
"NC": 133389,
"NE": 5785,
"NG": 19276214,
"NI": null,
"NL": 350767391,
"NO": 70018159,
"NP": null,
"NZ": 2764025,
"OM": 247478992,
"PA": 429814,
"PE": 42881270,
"PG": 8851,
"PH": 1049074,
"PK": 248028945,
"PL": 54755304,
"PT": 195398043,
"PY": 234022,
"QA": 39012592,
"RO": 8758145,
"RS": 13999429,
"RU": 54544991,
"RW": null,
"SA": 748983844,
"SB": null,
"SC": 3800,
"SD": 141850,
"SE": 53788976,
"SG": 119637964,
"SH": null,
"SI": 17419876,
"SK": 14405252,
"SL": null,
"SM": 317,
"SN": 175530,
"SO": 28504,
"SR": 16560,
"ST": 36206,
"SV": 1954352,
"SY": null,
"SZ": null,
"TD": 2781026,
"TG": 35331,
"TH": 73305438,
"TJ": 1777158,
"TL": null,
"TM": 4039720,
"TN": 5182048,
"TR": 79319798,
"TT": 667260,
"TW": 15555413,
"TZ": 371955,
"UA": 11533812,
"UG": 1502410,
"US": 776549968,
"UY": 5518942,
"UZ": null,
"VE": 283425495,
"VG": null,
"VN": 7896715,
"YE": 103123565,
"ZA": 141028817,
"ZM": 40876,
"ZW": null
}
<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: #fcfcfa;
}
.stroke {
fill: none;
stroke: #000;
stroke-width: 3px;
}
.fill {
fill: #fff;
}
.graticule {
fill: none;
stroke: #777;
stroke-width: .5px;
stroke-opacity: .5;
}
.land {
fill: #222;
}
.boundary {
fill: none;
stroke: #fff;
stroke-width: .5px;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/d3.geo.projection.v0.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var valuesUrl2011 = "https://gist.github.com/ianmackinnon/7960580/raw/101f76c9d175725c0215a604abb1111d33a144ba/2011.csv";
var width = 960,
height = 580;
var color = d3.scale.category10();
var projection = d3.geo.kavrayskiy7()
.scale(170)
.translate([width / 2, height / 2])
.precision(.1);
var path = d3.geo.path()
.projection(projection);
var graticule = d3.geo.graticule();
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
svg.append("defs").append("path")
.datum({type: "Sphere"})
.attr("id", "sphere")
.attr("d", path);
svg.append("use")
.attr("class", "stroke")
.attr("xlink:href", "#sphere");
svg.append("use")
.attr("class", "fill")
.attr("xlink:href", "#sphere");
svg.append("path")
.datum(graticule)
.attr("class", "graticule")
.attr("d", path);
d3.json("/mbostock/raw/4090846/world-50m.json", function(error, world) {
var countries = topojson.feature(world, world.objects.countries).features,
neighbors = topojson.neighbors(world.objects.countries.geometries);
d3.json(valuesUrl2011, function(error, values) {
svg.selectAll(".country")
.data(countries)
.enter().insert("path", ".graticule")
.attr("class", "country")
.attr("d", path)
.style("fill", function(d, i) { return color(d.color = d3.max(neighbors[i], function(n) { return countries[n].color; }) + 1 | 0); });
svg.insert("path", ".graticule")
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; }))
.attr("class", "boundary")
.attr("d", path);
}
});
d3.select(self.frameElement).style("height", height + "px");
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment