Data from the World Bank (download). Uses d3js.
Created
November 30, 2012 23:35
-
-
Save tmcw/4179511 to your computer and use it in GitHub Desktop.
Country Populations
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> | |
<meta charset="utf-8"> | |
<style> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
.bar { | |
fill: steelblue; | |
} | |
.x.axis path { | |
display: none; | |
} | |
.legend line { | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
<script> | |
var width = 960, | |
height = 500, | |
radius = Math.min(width, height) / 2; | |
var color = d3.scale.ordinal() | |
.range(["#98abc5", "#8a89a6", "#7b6888", "#6b486b", "#a05d56", "#d0743c", "#ff8c00"]); | |
var arc = d3.svg.arc() | |
.outerRadius(radius - 10) | |
.innerRadius(radius - 100); | |
var pie = d3.layout.pie() | |
.sort(null) | |
.value(function(d) { return d.pop; }); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.append("g") | |
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); | |
var tooltip = svg.append('g') | |
.attr('transform', 'translate(' + 0 + ',' + 0 + ')') | |
.append('text') | |
.attr('text-anchor', 'middle'); | |
svg | |
.on('mouseover', function() { | |
var d = d3.select(d3.event.target); | |
if (d) d = d.data()[0]; | |
if (d && d.data && d.data.Economy) tooltip.text(d.data.Economy + ': ' + | |
d3.format(',')(d.data.pop) + ' (' + (100 * d.data.pop / total).toFixed(1) + '%)'); | |
}) | |
.on('mouseout', function() { | |
tooltip.text(''); | |
}) | |
d3.csv("pop.csv", function(error, data) { | |
data.forEach(function(d) { | |
d.pop = +(d.pop.replace(/\,/g, '')) * 1000; | |
}); | |
total = data.reduce(function(mem, d) { | |
return mem + d.pop; | |
}, 0); | |
var g = svg.selectAll(".arc") | |
.data(pie(data)) | |
.enter().append("g") | |
.attr('title', function(d) { return d.data.Country; }) | |
.attr("class", "arc"); | |
g.append("path") | |
.attr("d", arc) | |
.style("fill", function(d) { return color(d.data.Country); }); | |
g.append("text") | |
.attr("transform", function(d) { return "translate(" + arc.centroid(d) + ")"; }) | |
.attr("dy", ".35em") | |
.style("text-anchor", "middle") | |
.text(function(d) { | |
return (d.endAngle - d.startAngle > 0.1) ? d.data.Country : ''; | |
}); | |
}); | |
</script> |
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 | Ranking | Economy | pop | ||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
CHN | 1 | China | 1,344,130 | ||||||||
IND | 2 | India | 1,241,492 | ||||||||
USA | 3 | United States | 311,592 | ||||||||
IDN | 4 | Indonesia | 242,326 | ||||||||
BRA | 5 | Brazil | 196,655 | ||||||||
PAK | 6 | Pakistan | 176,745 | ||||||||
NGA | 7 | Nigeria | 162,471 | ||||||||
BGD | 8 | Bangladesh | 150,494 | ||||||||
RUS | 9 | Russian Federation | 141,930 | ||||||||
JPN | 10 | Japan | 127,817 | ||||||||
MEX | 11 | Mexico | 114,793 | ||||||||
PHL | 12 | Philippines | 94,852 | ||||||||
VNM | 13 | Vietnam | 87,840 | ||||||||
ETH | 14 | Ethiopia | 84,734 | ||||||||
EGY | 15 | Egypt, Arab Rep. | 82,537 | ||||||||
DEU | 16 | Germany | 81,726 | ||||||||
IRN | 17 | Iran, Islamic Rep. | 74,799 | ||||||||
TUR | 18 | Turkey | 73,640 | ||||||||
THA | 19 | Thailand | 69,519 | ||||||||
ZAR | 20 | Congo, Dem. Rep. | 67,758 | ||||||||
FRA | 21 | France | 65,437 | ||||||||
GBR | 22 | United Kingdom | 62,641 | ||||||||
ITA | 23 | Italy | 60,770 | ||||||||
ZAF | 24 | South Africa | 50,587 | ||||||||
KOR | 25 | Korea, Rep. | 49,779 | ||||||||
MMR | 26 | Myanmar | 48,337 | ||||||||
COL | 27 | Colombia | 46,927 | ||||||||
ESP | 28 | Spain | 46,235 | ||||||||
TZA | 29 | Tanzania | 46,218 | ||||||||
UKR | 30 | Ukraine | 45,706 | ||||||||
KEN | 31 | Kenya | 41,610 | ||||||||
ARG | 32 | Argentina | 40,765 | ||||||||
POL | 33 | Poland | 38,216 | ||||||||
DZA | 34 | Algeria | 35,980 | ||||||||
AFG | 35 | Afghanistan | 35,320 | ||||||||
UGA | 36 | Uganda | 34,509 | ||||||||
CAN | 37 | Canada | 34,483 | ||||||||
SDN | 38 | Sudan | 34,318 | ||||||||
IRQ | 39 | Iraq | 32,962 | ||||||||
MAR | 40 | Morocco | 32,273 | ||||||||
NPL | 41 | Nepal | 30,486 | ||||||||
PER | 42 | Peru | 29,400 | ||||||||
UZB | 43 | Uzbekistan | 29,341 | ||||||||
VEN | 44 | Venezuela, RB | 29,278 | ||||||||
MYS | 45 | Malaysia | 28,859 | ||||||||
SAU | 46 | Saudi Arabia | 28,083 | ||||||||
GHA | 47 | Ghana | 24,966 | ||||||||
YEM | 48 | Yemen, Rep. | 24,800 | ||||||||
PRK | 49 | Korea, Dem. Rep. | 24,451 | ||||||||
MOZ | 50 | Mozambique | 23,930 | ||||||||
AUS | 51 | Australia | 22,621 | ||||||||
ROM | 52 | Romania | 21,390 | ||||||||
MDG | 53 | Madagascar | 21,315 | ||||||||
LKA | 54 | Sri Lanka | 20,869 | ||||||||
SYR | 55 | Syrian Arab Republic | 20,820 | ||||||||
CIV | 56 | Côte d'Ivoire | 20,153 | ||||||||
CMR | 57 | Cameroon | 20,030 | ||||||||
AGO | 58 | Angola | 19,618 | ||||||||
CHL | 59 | Chile | 17,270 | ||||||||
BFA | 60 | Burkina Faso | 16,968 | ||||||||
NLD | 61 | Netherlands | 16,696 | ||||||||
KAZ | 62 | Kazakhstan | 16,558 | ||||||||
NER | 63 | Niger | 16,069 | ||||||||
MLI | 64 | Mali | 15,840 | ||||||||
MWI | 65 | Malawi | 15,381 | ||||||||
GTM | 66 | Guatemala | 14,757 | ||||||||
ECU | 67 | Ecuador | 14,666 | ||||||||
KHM | 68 | Cambodia | 14,305 | ||||||||
ZMB | 69 | Zambia | 13,475 | ||||||||
SEN | 70 | Senegal | 12,768 | ||||||||
ZWE | 71 | Zimbabwe | 12,754 | ||||||||
TCD | 72 | Chad | 11,525 | ||||||||
GRC | 73 | Greece | 11,304 | ||||||||
CUB | 74 | Cuba | 11,254 | ||||||||
BEL | 75 | Belgium | 11,008 | ||||||||
RWA | 76 | Rwanda | 10,943 | ||||||||
TUN | 77 | Tunisia | 10,674 | ||||||||
PRT | 78 | Portugal | 10,637 | ||||||||
CZE | 79 | Czech Republic | 10,546 | ||||||||
SSD | 80 | South Sudan | 10,314 | ||||||||
GIN | 81 | Guinea | 10,222 | ||||||||
HTI | 82 | Haiti | 10,124 | ||||||||
BOL | 83 | Bolivia | 10,088 | ||||||||
DOM | 84 | Dominican Republic | 10,056 | ||||||||
HUN | 85 | Hungary | 9,971 | ||||||||
SOM | 86 | Somalia | 9,557 | ||||||||
BLR | 87 | Belarus | 9,473 | ||||||||
SWE | 88 | Sweden | 9,453 | ||||||||
AZE | 89 | Azerbaijan | 9,168 | ||||||||
BEN | 90 | Benin | 9,100 | ||||||||
BDI | 91 | Burundi | 8,575 | ||||||||
AUT | 92 | Austria | 8,419 | ||||||||
CHE | 93 | Switzerland | 7,907 | ||||||||
ARE | 94 | United Arab Emirates | 7,891 | ||||||||
ISR | 95 | Israel | 7,766 | ||||||||
HND | 96 | Honduras | 7,755 | ||||||||
BGR | 97 | Bulgaria | 7,476 | ||||||||
SRB | 98 | Serbia | 7,261 | ||||||||
HKG | 99 | Hong Kong SAR, China | 7,072 | ||||||||
PNG | 100 | Papua New Guinea | 7,014 | ||||||||
TJK | 101 | Tajikistan | 6,977 | ||||||||
PRY | 102 | Paraguay | 6,568 | ||||||||
LBY | 103 | Libya | 6,423 | ||||||||
LAO | 104 | Lao PDR | 6,288 | ||||||||
SLV | 105 | El Salvador | 6,227 | ||||||||
JOR | 106 | Jordan | 6,181 | ||||||||
TGO | 107 | Togo | 6,155 | ||||||||
SLE | 108 | Sierra Leone | 5,997 | ||||||||
NIC | 109 | Nicaragua | 5,870 | ||||||||
DNK | 110 | Denmark | 5,574 | ||||||||
KGZ | 111 | Kyrgyz Republic | 5,507 | ||||||||
SVK | 112 | Slovak Republic | 5,440 | ||||||||
ERI | 113 | Eritrea | 5,415 | ||||||||
FIN | 114 | Finland | 5,387 | ||||||||
SGP | 115 | Singapore | 5,184 | ||||||||
TKM | 116 | Turkmenistan | 5,105 | ||||||||
NOR | 117 | Norway | 4,952 | ||||||||
CRI | 118 | Costa Rica | 4,727 | ||||||||
IRL | 119 | Ireland | 4,487 | ||||||||
CAF | 120 | Central African Republic | 4,487 | ||||||||
GEO | 121 | Georgia | 4,486 | a | |||||||
HRV | 122 | Croatia | 4,407 | ||||||||
NZL | 123 | New Zealand | 4,405 | ||||||||
LBN | 124 | Lebanon | 4,259 | ||||||||
COG | 125 | Congo, Rep. | 4,140 | ||||||||
LBR | 126 | Liberia | 4,129 | ||||||||
WBG | 127 | West Bank and Gaza | 4,019 | ||||||||
BIH | 128 | Bosnia and Herzegovina | 3,752 | ||||||||
PRI | 129 | Puerto Rico | 3,707 | ||||||||
PAN | 130 | Panama | 3,571 | ||||||||
MDA | 131 | Moldova | 3,559 | b | |||||||
MRT | 132 | Mauritania | 3,542 | ||||||||
URY | 133 | Uruguay | 3,369 | ||||||||
ALB | 134 | Albania | 3,216 | ||||||||
LTU | 135 | Lithuania | 3,203 | ||||||||
ARM | 136 | Armenia | 3,100 | ||||||||
OMN | 137 | Oman | 2,846 | ||||||||
KWT | 138 | Kuwait | 2,818 | ||||||||
MNG | 139 | Mongolia | 2,800 | ||||||||
JAM | 140 | Jamaica | 2,709 | ||||||||
NAM | 141 | Namibia | 2,324 | ||||||||
LVA | 142 | Latvia | 2,220 | ||||||||
LSO | 143 | Lesotho | 2,194 | ||||||||
MKD | 144 | Macedonia, FYR | 2,064 | ||||||||
SVN | 145 | Slovenia | 2,052 | ||||||||
BWA | 146 | Botswana | 2,031 | ||||||||
QAT | 147 | Qatar | 1,870 | ||||||||
KSV | 148 | Kosovo | 1,794 | ||||||||
GMB | 149 | Gambia, The | 1,776 | ||||||||
GNB | 150 | Guinea-Bissau | 1,547 | ||||||||
GAB | 151 | Gabon | 1,534 | ||||||||
TTO | 152 | Trinidad and Tobago | 1,346 | ||||||||
EST | 153 | Estonia | 1,340 | ||||||||
BHR | 154 | Bahrain | 1,324 | ||||||||
MUS | 155 | Mauritius | 1,286 | ||||||||
TMP | 156 | Timor-Leste | 1,176 | ||||||||
CYP | 157 | Cyprus | 1,117 | ||||||||
SWZ | 158 | Swaziland | 1,068 | ||||||||
DJI | 159 | Djibouti | 906 | ||||||||
FJI | 160 | Fiji | 868 | ||||||||
GUY | 161 | Guyana | 756 | ||||||||
COM | 162 | Comoros | 754 | ||||||||
BTN | 163 | Bhutan | 738 | ||||||||
GNQ | 164 | Equatorial Guinea | 720 | ||||||||
MNE | 165 | Montenegro | 632 | ||||||||
MAC | 166 | Macao SAR, China | 556 | ||||||||
SLB | 167 | Solomon Islands | 552 | ||||||||
SUR | 168 | Suriname | 529 | ||||||||
LUX | 169 | Luxembourg | 517 | ||||||||
CPV | 170 | Cape Verde | 501 | ||||||||
MLT | 171 | Malta | 419 | ||||||||
BRN | 172 | Brunei Darussalam | 406 | ||||||||
BLZ | 173 | Belize | 357 | ||||||||
BHS | 174 | Bahamas, The | 347 | ||||||||
MDV | 175 | Maldives | 320 | ||||||||
ISL | 176 | Iceland | 319 | ||||||||
BRB | 177 | Barbados | 274 | ||||||||
PYF | 178 | French Polynesia | 274 | ||||||||
NCL | 179 | New Caledonia | 249 | ||||||||
VUT | 180 | Vanuatu | 246 | ||||||||
WSM | 181 | Samoa | 184 | ||||||||
GUM | 182 | Guam | 182 | ||||||||
LCA | 183 | St. Lucia | 176 | ||||||||
STP | 184 | São Tomé and Principe | 169 | ||||||||
CHI | 185 | Channel Islands | 154 | ||||||||
CUW | 186 | Curaçao | 146 | ||||||||
FSM | 187 | Micronesia, Fed. Sts. | 112 | ||||||||
VIR | 188 | Virgin Islands (U.S.) | 110 | ||||||||
VCT | 189 | St. Vincent and the Grenadines | 109 | ||||||||
ABW | 190 | Aruba | 108 | ||||||||
GRD | 191 | Grenada | 105 | ||||||||
TON | 192 | Tonga | 105 | ||||||||
KIR | 193 | Kiribati | 101 | ||||||||
ATG | 194 | Antigua and Barbuda | 90 | ||||||||
ADO | 195 | Andorra | 86 | ||||||||
SYC | 196 | Seychelles | 86 | ||||||||
IMY | 197 | Isle of Man | 83 | ||||||||
ASM | 198 | American Samoa | 70 | ||||||||
DMA | 199 | Dominica | 68 | ||||||||
BMU | 200 | Bermuda | 65 | ||||||||
MNP | 201 | Northern Mariana Islands | 61 | ||||||||
GRL | 202 | Greenland | 57 | ||||||||
CYM | 203 | Cayman Islands | 57 | ||||||||
MHL | 204 | Marshall Islands | 55 | ||||||||
KNA | 205 | St. Kitts and Nevis | 53 | ||||||||
FRO | 206 | Faeroe Islands | 49 | ||||||||
TCA | 207 | Turks and Caicos Islands | 39 | ||||||||
SXM | 208 | Sint Maarten (Dutch part) | 37 | ||||||||
LIE | 209 | Liechtenstein | 36 | ||||||||
MCO | 210 | Monaco | 35 | ||||||||
SMR | 211 | San Marino | 32 | ||||||||
MAF | 212 | St. Martin (French part) | 31 | ||||||||
PLW | 213 | Palau | 21 | ||||||||
TUV | 214 | Tuvalu | 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment