Skip to content

Instantly share code, notes, and snippets.

@pfloh
Created September 29, 2015 08:26
Show Gist options
  • Save pfloh/f7d6d9874a15405faf15 to your computer and use it in GitHub Desktop.
Save pfloh/f7d6d9874a15405faf15 to your computer and use it in GitHub Desktop.
Number of Refugees to 1 USD GDP per Capita - Exc. 4
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Number of Refugees to 1 USD GDP per Capita</title>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<style type="text/css">
body {
background-color: white;
font-family: Helvetica, Arial, sans-serif;
}
h2 {
font-size: 22px;
margin: 0;
}
p {
font-size: 14px;
margin: 10px 0 0 0;
}
svg {
background-color: white;
}
rect:hover {
fill: steelblue;
}
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
.axis text {
font-family: sans-serif;
font-size: 11px;
}
.y.axis path,
.y.axis line {
opacity: 0;
}
</style>
</head>
<body>
<h2>Number of Refugees to 1 USD GDP per Capita</h2>
<p>Relative to the sizes of their economies the burdens carried by poor countries like Ethiopia and Pakistan are greatest (Source: <a href="http://unhcr.org/54aa91d89.html">UNHCR</a>, data: end of 2014) </p>
<script type="text/javascript">
var w = 1400;
var h = 2000;
var padding = [ 0, 10, 30, 220 ]; //Top, right, bottom, left
var widthScale = d3.scale.linear()
.range([ 0, w - padding[1] - padding[3] ]);
var heightScale = d3.scale.ordinal()
.rangeRoundBands([ padding[0], h - padding[2] ], 0.1);
var xAxis = d3.svg.axis()
.scale(widthScale)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(heightScale)
.orient("left");
var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);
d3.csv("RefugeeHostcountries_final.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(+a.RefugeesToGDPPerCapita, +b.RefugeesToGDPPerCapita);
});
widthScale.domain([ 0, d3.max(data, function(d) {
return +d.RefugeesToGDPPerCapita;
}) ]);
heightScale.domain(data.map(function(d) { return d.CountryOrTerritoryOfAsylum; } ));
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect");
rects.attr("x", padding[3])
.attr("y", function(d) {
return heightScale(d.CountryOrTerritoryOfAsylum);
})
.attr("width", function(d) {
return widthScale(d.RefugeesToGDPPerCapita);
})
.attr("height", heightScale.rangeBand())
.attr("fill", "darkgreen")
.append("title")
.text(function(d) {
return d.CountryOrTerritoryOfAsylum + "'s # of Refugees To GDP per capita is " + d.RefugeesToGDPPerCapita;
});
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(" + padding[3] + "," + (h - padding[2]) + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + padding[3] + ",0)")
.call(yAxis);
});
</script>
</body>
</html>
CountryOrTerritoryOfAsylum RefugeesToGDPPerCapita RefugeesTo1000Inhabitants RefugeesTo1000km2
Afghanistan 155.07 9.6 468.33
Albania 0.01 0.03 3.63
Algeria 6.81 2.36 40.58
Angola 1.95 0.7 12.36
Argentina 0.15 0.08 1.26
Armenia 2.17 5.91 595.87
Australia 0.77 1.51 4.62
Austria 1.2 6.52 664.26
Azerbaijan 0.07 0.14 15.07
Bahrain 0.01 0.23 499.2
Bangladesh 69.05 1.47 1699.28
Belarus 0.05 0.1 4.48
Belgium 0.68 2.62 954.84
Benin 0.22 0.04 3.58
Bolivia (Plurinational State of) 0.12 0.07 0.7
Bosnia and Herzegovina 0.69 1.8 134.63
Botswana 0.16 1.3 4.56
Brazil 0.46 0.04 0.88
Bulgaria 0.62 1.54 99.64
Burkina Faso 18.96 1.83 115.67
Burundi 66.06 5.05 1955.67
Cameroon 89.69 11.57 564
Canada 3.33 4.2 15.18
Central African Rep. 12.69 1.63 12.35
Chad 202.82 34.28 355.37
Chile 0.08 0.1 2.34
China 23.82 0.22 32.11
Congo, Rep. of 8.93 12.03 159.78
Costa Rica 1.44 4.2 403.33
C&Ocirc;te d'Ivoire 0.56 0.09 5.96
Croatia 0.04 0.17 12.86
Cyprus 0.22 4.45 552.79
Czech Rep. 0.11 0.29 39.92
Dem. Rep. of the Congo 148.86 1.73 51.22
Denmark 0.4 3.15 402.28
Djibouti 6.35 23.17 943.43
Dominican Rep. 0.05 0.06 12.58
Ecuador 10.84 7.64 474.65
Egypt 20.87 2.83 239.88
Eritrea 2.43 0.44 23.52
Ethiopia 440.27 6.83 582.91
Finland 0.29 2.17 35.26
France 6.32 3.9 460.89
Gabon 0.05 0.59 3.81
Gambia 7.15 6.08 1071.05
Georgia 0.11 0.2 12.27
Germany 4.82 2.63 609.47
Ghana 4.5 0.7 76.95
Greece 0.4 0.93 77.86
Guatemala 0.02 0.01 1.5
Guinea 7.04 0.73 35.65
Guinea-Bissau 6.08 4.97 254.61
Hungary 0.12 0.29 30.88
India 34.36 0.16 63.27
Indonesia 0.4 0.02 2.25
Iran, Islamic Rep. of 57.75 12.51 605.04
Iraq 18.04 7.8 612.47
Ireland 0.12 1.25 84.18
Israel 1.16 5.08 1905.94
Italy 2.69 1.53 311.21
Japan 0.07 0.02 6.85
Jordan 61.67 87.16 7259.6
Kazakhstan 0.03 0.04 0.24
Kenya 189.66 12.11 942.86
Kuwait 0.01 0.18 35.48
Kyrgyzstan 0.14 0.09 2.42
Latvia 0.01 0.09 2.85
Lebanon 70.67 232.39 111738.96
Lesotho 0.02 0.02 1.44
Liberia 45.86 8.78 400.82
Libya 1.79 4.47 17.27
Lithuania 0.04 0.33 15.58
Luxembourg 0.01 2.06 424.2
Malawi 7.2 0.35 49.57
Malaysia 4.02 3.29 300.08
Mali 8.78 0.96 12.11
Malta 0.19 14.17 19472.84
Mauritania 19.44 18.98 72.47
Mexico 0.11 0.01 0.94
Montenegro 0.43 10.39 470.31
Morocco 0.16 0.04 2.99
Mozambique 3.86 0.17 5.75
Namibia 0.18 0.75 2.14
Nepal 16.2 1.37 261.37
Netherlands 1.74 4.91 2350.06
New Zealand 0.04 0.3 5
Nicaragua 0.06 0.05 2.16
Niger 80.59 4.2 65.53
Nigeria 0.21 0.01 1.36
Norway 0.69 9.24 147.4
Pakistan 315.9 8.13 1716.92
Panama 0.89 4.4 229.17
Papua New Guinea 3.93 1.27 20.48
Paraguay 0.02 0.02 0.38
Peru 0.11 0.04 1
Poland 0.63 0.41 50.65
Portugal 0.03 0.07 7.61
Rep. of Korea 0.03 0.02 11.86
Rep. of Moldova 0.07 0.1 9.94
Romania 0.12 0.1 9.19
Russian Federation 9.42 1.65 13.96
Rwanda 47.51 6.1 2915.71
Saudi Arabia 0.01 0.02 0.29
Senegal 6.18 0.98 72.28
Serbia and Kosovo (S/RES/1244 (1999)) 4.34 4.62 428.02
Sierra Leone 0.67 0.22 18.89
Slovakia 0.03 0.15 16.33
Slovenia 0.01 0.12 12.68
South Africa 8.46 2.11 91.8
South Sudan 112.04 21.14 383.96
Spain 0.17 0.12 11.48
Sri Lanka 0.05 0.02 7.65
Sudan 67.69 7.17 147.31
Swaziland 0.08 0.41 29.73
Sweden 3.06 14.77 318.42
Switzerland 1.08 7.68 1521.68
Syrian Arab Rep. 24.04 6.78 800.19
Tajikistan 0.76 0.24 14.27
Thailand 8.88 1.94 251.96
Former Yugoslav Republic of Macedonia 0.07 0.42 34.84
Togo 15.08 3.11 380.22
Tunisia 0.08 0.08 5.8
Turkey 79.82 20.93 2033.28
Uganda 194.73 9.92 1590.68
Ukraine 0.39 0.07 5.37
United Arab Emirates 0.01 0.04 5.3
United Kingdom 2.92 1.85 480.36
United Rep. of Tanzania 35.34 1.74 93.56
United States of America 4.95 0.83 28.72
Uruguay 0.01 0.08 1.53
Venezuela (Bolivarian Rep. of) 9.94 5.63 189.7
Yemen 62.1 10.32 611.96
Zambia 6.29 1.7 33.92
Zimbabwe 3.27 0.42 15.51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment