Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 02:03
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mbostock/5912673 to your computer and use it in GitHub Desktop.
Extradition Treaties
license: gpl-3.0

A choropleth showing which countries have bilateral extradition treaties with the United States, in response to The Guardian’s interactive guide to extraditions. Countries with older bilateral extradition treaties are shown in purple, while countries with younger treaties are shown in orange. Countries without bilateral extradition treaties are shown in gray.

This gives a quicker overview of which countries have bilateral agreements with the United States, though on the other hand, many tiny nations with such agreements are invisible in this map.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
body {
background: #fcfcfa;
}
.stroke {
fill: none;
stroke: #000;
stroke-width: 3px;
}
.fill {
fill: #fff;
}
.land {
fill: #ddd;
}
.boundary {
fill: none;
stroke: #fff;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script src="//d3js.org/d3.geo.projection.v0.min.js"></script>
<script src="//d3js.org/queue.v1.min.js"></script>
<script src="//d3js.org/topojson.v1.min.js"></script>
<script>
var parseDate = d3.time.format("%Y-%m-%d").parse,
formatDate = d3.time.format("%x");
var width = 960,
height = 500;
var projection = d3.geo.naturalEarth()
.scale(167)
.translate([width / 2, height / 2])
.precision(.1);
var color = d3.scale.linear()
.domain([new Date(1900, 0, 1), new Date(2000, 0, 1)])
.range(["purple", "orange"])
.clamp(true)
.interpolate(d3.interpolateHcl);
var path = d3.geo.path()
.projection(projection);
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");
queue()
.defer(d3.json, "/mbostock/raw/4090846/world-50m.json")
.defer(d3.tsv, "treaties.tsv", type)
.await(ready);
function ready(error, world, treaties) {
if (error) throw error;
var treatiesById = d3.nest()
.key(function(d) { return d.id; })
.sortValues(function(a, b) { return a.date - b.date; })
.map(treaties, d3.map);
var country = svg.insert("g", ".graticule")
.attr("class", "land")
.selectAll("path")
.data(topojson.feature(world, world.objects.countries).features)
.enter().append("path")
.attr("d", path);
country.filter(function(d) { return d.id === 840; })
.style("fill", "#000")
.append("title")
.text("United States");
country.filter(function(d) { return treatiesById.has(d.id); })
.style("fill", function(d) { return color(treatiesById.get(d.id)[0].date); })
.append("title")
.text(function(d) {
var treaties = treatiesById.get(d.id);
return treaties[0].name + "\n" + treaties.map(function(d) { return formatDate(d.date); }).join("\n");
});
svg.insert("path", ".graticule")
.datum(topojson.mesh(world, world.objects.countries, function(a, b) { return a !== b; }))
.attr("class", "boundary")
.attr("d", path);
}
function type(d) {
d.id = +d.id;
d.date = parseDate(d.date);
return d;
}
d3.select(self.frameElement).style("height", height + "px");
</script>
We can make this file beautiful and searchable if this error is corrected: It looks like row 51 should actually have 3 columns, instead of 2. in line 50.
name date id
Albania 1935-11-14 8
Anguilla 1977-01-21 660
Antigua and Barbuda 1999-07-01 28
Argentina 2000-06-15 32
Australia 1976-05-08 36
Australia 1992-12-21 36
Austria 2000-01-01 40
Austria 2010-02-01 40
Bahamas 1994-09-22 44
Barbados 2000-03-03 52
Belgium 1997-09-01 56
Belgium 2010-02-01 56
Belize 2001-03-27 84
Bermuda 1977-01-21 60
Bolivia 1996-11-21 68
Bosnia and Herzegovina 1902-06-12 70
Brazil 1964-12-17 76
Brazil 1964-12-17 76
British Virgin Islands 1977-01-21 92
Bulgaria 2009-05-21 100
Burma 1941-11-01 104
Canada 1976-03-22 124
Canada 1976-03-22 124
Canada 1991-11-26 124
Canada 2003-04-30 124
Cayman Islands 1977-01-21 136
Chile 1902-06-26 152
Colombia 1982-03-04 170
Congo 1911-07-27 178
Congo 1929-05-19 178
Congo 1936-09-24 178
Costa Rica 1991-10-11 188
Croatia 1902-06-12 191
Cuba 1905-03-02 192
Cuba 1926-06-18 192
Cyprus 1999-09-14 196
Cyprus 2010-02-01 196
Czech Republic 1926-03-29 203
Czech Republic 1935-08-28 203
Czech Republic 2010-02-01 203
Denmark 1974-07-31 208
Denmark 2010-02-01 208
Dominica 2000-05-25 212
Dominican Republic 1910-08-02 214
Ecuador 1873-11-12 218
Ecuador 1941-05-29 218
Egypt 1875-04-22 818
El Salvador 1911-07-10 222
Estonia 2009-04-07 233
European Union 2010-02-01
Falkland Islands 1977-01-21 238
Fiji 1935-06-24 242
Fiji 1973-08-17 242
Finland 1980-05-11 246
Finland 2010-02-01 246
France 2002-02-01 250
France 2002-02-01 250
Gambia 1935-06-24 270
Germany 1980-08-29 276
Germany 1993-03-11 276
Germany 2010-02-01 276
Ghana 1935-06-24 288
Gibraltar 1977-01-21 292
Greece 1932-11-01 300
Greece 1937-09-02 300
Greece 2010-02-01 300
Grenada 1999-09-14 308
Guatemala 1903-08-15 320
Guatemala 1941-03-13 320
Guyana 1935-06-24 328
Haiti 1905-06-28 332
Honduras 1912-07-10 340
Honduras 1928-06-05 340
Hong Kong 1998-01-21 344
Hungary 1997-03-18 348
Hungary 2010-02-01 348
Iceland 1902-04-16 352
Iceland 1906-02-19 352
India 1999-07-21 356
Iraq 1936-04-23 368
Ireland 1984-12-15 372
Ireland 2010-02-01 372
Isle of Man 1977-01-21 833
Israel 1963-12-05 376
Israel 2007-01-10 376
Italy 1984-09-24 380
Italy 2010-02-01 380
Jamaica 1991-07-07 388
Japan 1980-03-26 392
Jordan 1995-07-29 400
Kenya 1935-06-24 404
Kenya 1965-08-19 404
Kiribati 1977-01-21 296
Latvia 2009-04-15 428
Lesotho 1935-06-24 426
Liberia 1939-11-21 430
Liechtenstein 1937-06-28 438
Lithuania 2003-03-31 440
Lithuania 2010-02-01 440
Luxembourg 2002-02-01 442
Luxembourg 2010-02-01 442
Malawi 1935-06-24 454
Malawi 1967-04-04 454
Malaysia 1997-06-02 458
Malta 2009-07-01 470
Mauritius 1935-06-24 480
Mexico 1980-01-25 484
Mexico 2001-05-21 484
Monaco 1940-03-28 492
Montserrat 1977-01-21 500
Nauru 1935-06-24 520
Netherlands 1983-09-15 528
Netherlands 2010-02-01 528
New Zealand 1970-12-08 554
Nicaragua 1907-07-14 558
Nigeria 1935-06-24 566
Norway 1980-03-07 578
Pakistan 1935-06-24 586
Panama 1905-05-08 591
Papua New Guinea 1935-06-24 598
Papua New Guinea 1988-02-23 598
Paraguay 2001-03-09 600
Peru 2003-08-25 604
Philippines 1996-11-22 608
Poland 1999-09-17 616
Poland 2010-02-01 616
Portugal 1908-11-14 620
Portugal 2010-02-01 620
Romania 2009-05-08 642
San Marino 1908-07-08 674
San Marino 1935-06-28 674
Seychelles 1935-06-24 690
Sierra Leone 1935-06-24 694
Singapore 1935-06-24 702
Singapore 1969-06-10 702
Slovakia 1935-03-29 703
Slovakia 1935-08-28 703
Slovakia 2010-02-01 703
Slovenia 1902-06-12 705
Slovenia 2010-02-01 705
Solomon Islands 1977-01-21 90
South Africa 2001-06-25 710
South Korea 1999-12-20 410
Spain 1971-06-16 724
Spain 1978-06-02 724
Spain 1993-07-02 724
Spain 1999-07-25 724
Spain 2010-02-01 724
Sri Lanka 2001-01-12 144
St. Helena 1977-01-21 654
St. Kitts and Nevis 2000-02-23 659
St. Lucia 2000-02-02 662
St. Vincent and the Grenadines 1999-09-08 670
Suriname 1889-07-11 740
Suriname 1904-08-28 740
Swaziland 1935-06-24 748
Swaziland 1970-07-28 748
Sweden 1963-12-03 752
Sweden 1984-09-24 752
Sweden 2010-02-01 752
Switzerland 1997-09-10 756
Tanzania 1935-06-24 834
Tanzania 1965-12-06 834
Thailand 1991-05-17 764
Tonga 1935-06-24 776
Tonga 1977-04-13 776
Trinidad and Tobago 1999-11-29 780
Turkey 1981-01-01 792
Turks and Caicos 1977-01-21 796
Tuvalu 1977-01-21 798
United Kingdom 2003-11-20 826
United Kingdom 2007-04-26 826
United Kingdom 2010-02-01 826
Uruguay 1984-04-11 858
Venezuela 1923-04-14 862
Zambia 1935-06-24 894
Zimbabwe 2000-04-26 716
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment