Created
October 4, 2015 21:08
-
-
Save jowang0319/8d39dff5d4b070cbbac2 to your computer and use it in GitHub Desktop.
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 | literacyRate | infantMortalityRate | primaryCompletionRate | |
---|---|---|---|---|
Afghanistan | 75.1 | |||
Albania | 14.8 | |||
Algeria | 23.5 | 92.51422882 | ||
American Samoa | ||||
Andorra | 2.5 | |||
Angola | 109.6 | 40.14783859 | ||
Antigua and Barbuda | 7.7 | 101.913269 | ||
Arab World | 85.73280327 | 32.28170265 | 82.6985321 | |
Argentina | 13 | 108.2583084 | ||
Armenia | 16.1 | |||
Aruba | 99.32309723 | 97.84075928 | ||
Australia | 4.1 | |||
Austria | 3.6 | 98.25421143 | ||
Azerbaijan | 99.93333435 | 33.9 | 88.97885132 | |
Bahamas, The | 11.4 | 94.85346985 | ||
Bahrain | 97.58233643 | 7.1 | ||
Bangladesh | 39.2 | 70.49899292 | ||
Barbados | 13.6 | 105.7491302 | ||
Belarus | 4.7 | |||
Belgium | 3.6 | 92.26545715 | ||
Belize | 16.3 | 106.4534378 | ||
Benin | 71 | 55.96918106 | ||
Bermuda | 100 | |||
Bhutan | 34.1 | 96.35308838 | ||
Bolivia | 36.8 | 93.15220642 | ||
Bosnia and Herzegovina | 6.4 | |||
Botswana | 39.8 | |||
Brazil | 98.31874084 | 14.8 | ||
Brunei Darussalam | 7.7 | 107.7526398 | ||
Bulgaria | 11.2 | 105.6320572 | ||
Burkina Faso | 69.7 | 44.06893921 | ||
Burundi | 63.8 | 49.01374054 | ||
Cabo Verde | 23.3 | 99.34114075 | ||
Cambodia | 36.7 | 91.68153381 | ||
Cameroon | 76.42093658 | 66.2 | 64.20378876 | |
Canada | 4.9 | |||
Caribbean small states | 97.32386544 | 18.79682905 | 93.10451508 | |
Cayman Islands | ||||
Central African Republic | 26.97132492 | 101.7 | 30.18457031 | |
Central Europe and the Baltics | 99.4862221 | 6.746707521 | 97.32325745 | |
Chad | 93.6 | 23.49278069 | ||
Channel Islands | ||||
Chile | 7.6 | |||
China | 99.59304047 | 13.5 | ||
Colombia | 98.51719666 | 15.9 | 114.7272415 | |
Comoros | 63.1 | |||
Congo, Dem. Rep. | 84.8 | 54.9679184 | ||
Congo, Rep. | 42.2 | 67.22634888 | ||
Costa Rica | 8.9 | 96.96784973 | ||
Cote d'Ivoire | 76.9 | |||
Croatia | 4.6 | 91.38627625 | ||
Cuba | 4.9 | 98.75244904 | ||
Curacao | ||||
Cyprus | 3 | 100.8589172 | ||
Czech Republic | 3.4 | 108.9190521 | ||
Denmark | 3.3 | 99.38253021 | ||
Djibouti | 62.2 | |||
Dominica | 17.2 | 81.2397995 | ||
Dominican Republic | 97.88348389 | 27.9 | 90.24506378 | |
East Asia & Pacific (all income levels) | 98.82029344 | 18.21170719 | 104.9947891 | |
East Asia & Pacific (developing only) | 98.77596097 | 19.2 | 105.3598938 | |
Ecuador | 98.85409546 | 21.3 | 102.9539413 | |
Egypt, Arab Rep. | 84.30692291 | 24.3 | 104.3540802 | |
El Salvador | 96.38574219 | 17.1 | 95.06249237 | |
Equatorial Guinea | 78.9 | 52.63772964 | ||
Eritrea | 39.4 | |||
Estonia | 3.6 | 95.33157349 | ||
Ethiopia | 50.8 | |||
Euro area | 99.76138261 | 3.648834541 | 99.43891907 | |
Europe & Central Asia (all income levels) | 99.65629415 | 11.81721227 | 98.18402863 | |
Europe & Central Asia (developing only) | 99.39817955 | 21.6 | 97.7919693 | |
European Union | 99.73616732 | 4.307984234 | 98.63733673 | |
Faeroe Islands | ||||
Fiji | 20.3 | |||
Finland | 2.5 | 98.33461761 | ||
Fragile and conflict affected situations | 72.02169762 | 63.47283877 | 63.00351334 | |
France | 3.5 | |||
French Polynesia | ||||
Gabon | 42.8 | |||
Gambia, The | 51.7 | 74.75131226 | ||
Georgia | 14.9 | 115.7588501 | ||
Germany | 3.5 | 101.2165985 | ||
Ghana | 83.23452759 | 50.2 | ||
Greece | 4.1 | 100.1779633 | ||
Greenland | ||||
Grenada | 11.9 | 103.2128525 | ||
Guam | ||||
Guatemala | 28.4 | 83.1153183 | ||
Guinea | 21.79673195 | 71.2 | 47.99417114 | |
Guinea-Bissau | 73.4 | 56.68780136 | ||
Guyana | 33.5 | 94.93670654 | ||
Haiti | 85.5 | |||
Heavily indebted poor countries (HIPC) | 62.91764932 | 62.77097202 | 60.06468582 | |
High income | 99.58746003 | 6.6 | 98.66924286 | |
High income: nonOECD | 99.37660303 | 12.12297896 | 99.07261658 | |
High income: OECD | 4.67132275 | 98.5482254 | ||
Honduras | 95.87750244 | 20.7 | 101.2355728 | |
Hong Kong SAR, China | ||||
Hungary | 5.7 | 97.97763824 | ||
Iceland | 1.9 | 96.57407379 | ||
India | 46.3 | |||
Indonesia | 27.4 | |||
Iran, Islamic Rep. | 16.4 | 103.7376785 | ||
Iraq | 30 | |||
Ireland | 3.5 | |||
Isle of Man | ||||
Israel | 3.7 | 102.1928177 | ||
Italy | 3.4 | 102.0077362 | ||
Jamaica | 15.5 | |||
Japan | 2.4 | 100.7415771 | ||
Jordan | 98.76634979 | 17.8 | ||
Kazakhstan | 19.3 | 102.8035431 | ||
Kenya | 42.4 | |||
Kiribati | 48.3 | |||
Korea, Dem. Rep. | 24.8 | |||
Korea, Rep. | 3.5 | 99.34158325 | ||
Kosovo | ||||
Kuwait | 9.2 | |||
Kyrgyz Republic | 26.5 | 96.63749695 | ||
Lao PDR | 59 | 80.04451752 | ||
Latin America & Caribbean (all income levels) | 97.9224739 | 17.94407555 | 99.55323792 | |
Latin America & Caribbean (developing only) | 97.72093445 | 19 | 99.40028381 | |
Latvia | 8.2 | 93.99823761 | ||
Least developed countries: UN classification | 68.62561698 | 60.45701568 | 62.68008804 | |
Lebanon | 8.7 | 85.45307922 | ||
Lesotho | 75.2 | 83.16015625 | ||
Liberia | 65.2 | |||
Libya | 14.3 | |||
Liechtenstein | 106.6350708 | |||
Lithuania | 5.6 | 104.6726608 | ||
Low & middle income | 86.66901169 | 42 | 89.70928192 | |
Low income | 62.75344779 | 63 | 60.56679916 | |
Lower middle income | 82.54701873 | 47.4 | 89.37412262 | |
Luxembourg | 1.9 | 84.83126831 | ||
Macao SAR, China | ||||
Macedonia, FYR | 8.7 | |||
Madagascar | 42.1 | 71.21040344 | ||
Malawi | 69.98173523 | 57.5 | 69.04071045 | |
Malaysia | 98.45825958 | 6.8 | ||
Maldives | 11.2 | |||
Mali | 33.94570923 | 82.9 | 54.84397888 | |
Malta | 5.6 | 92.55635834 | ||
Marshall Islands | 31.8 | |||
Mauritania | 70.1 | |||
Mauritius | 13.3 | 103.2394791 | ||
Mexico | 98.49213409 | 14.4 | 93.99691772 | |
Micronesia, Fed. Sts. | 32.9 | |||
Middle East & North Africa (all income levels) | 90.31021106 | 23.06400438 | 90.55309296 | |
Middle East & North Africa (developing only) | 89.34293515 | 24.4 | 89.31517792 | |
Middle income | 89.57047568 | 37.4 | 94.43700409 | |
Moldova | 14.7 | 92.65367889 | ||
Monaco | 3.2 | |||
Mongolia | 98.90873718 | 25 | ||
Montenegro | 6.3 | |||
Morocco | 28.5 | 81.36979675 | ||
Mozambique | 71.9 | 55.10712814 | ||
Myanmar | 45.8 | 96.7735672 | ||
Namibia | 37.5 | 84.64054108 | ||
Nepal | 36.3 | |||
Netherlands | 3.7 | |||
New Caledonia | ||||
New Zealand | 5.1 | |||
Nicaragua | 22 | 83.41893768 | ||
Niger | 66.1 | 35.13595963 | ||
Nigeria | 81.5 | 71.52314758 | ||
North America | 6.181439234 | |||
Northern Mariana Islands | ||||
Norway | 2.6 | 99.28981018 | ||
OECD members | 7.157264734 | 97.92749023 | ||
Oman | 98.16507721 | 10 | ||
Other small states | 85.73547333 | 52.34126856 | 78.68188477 | |
Pacific island small states | 24.06919415 | 97.89498901 | ||
Pakistan | 62.29837418 | 73.5 | 60.26723862 | |
Palau | 16.6 | |||
Panama | 97.33686829 | 17 | 92.00022888 | |
Papua New Guinea | 50.3 | |||
Paraguay | 98.7288208 | 20.4 | 91.25849152 | |
Peru | 16.3 | 99.42054749 | ||
Philippines | 24.9 | |||
Poland | 5 | 95.08609009 | ||
Portugal | 3.1 | |||
Puerto Rico | 98.85419464 | |||
Qatar | 98.26115417 | 7.7 | ||
Romania | 12.1 | 94.20201874 | ||
Russian Federation | 99.75802612 | 10.3 | ||
Rwanda | 77.97246552 | 43.8 | 56.17655945 | |
Samoa | 16 | 106.3937378 | ||
San Marino | 3.1 | 107.2847672 | ||
Sao Tome and Principe | 39.8 | 92.48233795 | ||
Saudi Arabia | 14.7 | |||
Senegal | 46.7 | 59.05258179 | ||
Serbia | 6.6 | 96.60488129 | ||
Seychelles | 99.38307953 | 12.2 | ||
Sierra Leone | 107 | |||
Singapore | 99.76667023 | 2.2 | ||
Sint Maarten (Dutch part) | ||||
Slovak Republic | 7 | 101.559082 | ||
Slovenia | 2.7 | 96.07079315 | ||
Small states | 88.62132259 | 44.94544617 | 83.22514343 | |
Solomon Islands | 26.6 | |||
Somalia | 97.8 | |||
South Africa | 98.90136719 | 38.2 | ||
South Asia | 79.08750414 | 49.8 | 89.69166565 | |
South Sudan | 70.6 | |||
Spain | 99.68635559 | 3.9 | 102.5851898 | |
Sri Lanka | 98.588974 | 9.4 | 98.58200073 | |
St. Kitts and Nevis | 10 | 88.65545654 | ||
St. Lucia | 14.1 | |||
St. Martin (French part) | ||||
St. Vincent and the Grenadines | 18.6 | 91.5860672 | ||
Sub-Saharan Africa (all income levels) | 65.79828414 | 65.95886707 | 64.56603241 | |
Sub-Saharan Africa (developing only) | 65.76738698 | 65.8 | 64.57215118 | |
Sudan | 53.3 | 54.22645187 | ||
Suriname | 98.80215454 | 22.1 | ||
Swaziland | 94.74848938 | 59.1 | 77.93898773 | |
Sweden | 2.5 | 96.4311676 | ||
Switzerland | 3.9 | 97.53890228 | ||
Syrian Arab Republic | 13.2 | 103.6311188 | ||
Taiwan, China | ||||
Tajikistan | 44.7 | 99.74043274 | ||
Tanzania | 72.77099609 | 42.4 | 91.73339081 | |
Thailand | 96.55204773 | 12.5 | ||
Timor-Leste | 78.56843567 | 53.1 | 64.73622131 | |
Togo | 59.3 | 61.80672836 | ||
Tonga | 15 | |||
Trinidad and Tobago | 21 | 94.9871521 | ||
Tunisia | 96.09355927 | 14.9 | 101.6530685 | |
Turkey | 97.19732666 | 16.4 | 99.48298645 | |
Turkmenistan | 50.4 | |||
Turks and Caicos Islands | ||||
Tuvalu | 26.3 | |||
Uganda | 85.47146606 | 49.5 | 54.80828094 | |
Ukraine | 10.1 | 98.89807129 | ||
United Arab Emirates | 7.3 | 96.26954651 | ||
United Kingdom | 4.4 | |||
United States | 6.3 | |||
Upper middle income | 98.35555107 | 18.9 | 102.92276 | |
Uruguay | 99.22541046 | 10.6 | 103.9940109 | |
Uzbekistan | 39.6 | 90.97830963 | ||
Vanuatu | 23.9 | 86.75198364 | ||
Venezuela, RB | 14.3 | 94.65075684 | ||
Vietnam | 19.8 | |||
Virgin Islands (U.S.) | ||||
West Bank and Gaza | 99.27404022 | 20.2 | 91.8777771 | |
World | 88.53919102 | 37.5 | 90.90634918 | |
Yemen, Rep. | 42.4 | 54.44889832 | ||
Zambia | 52.9 | 105.4886475 | ||
Zimbabwe | 55.8 |
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 | infantMortalityRate | primaryCompletionRate | |
---|---|---|---|
Algeria | 23.5 | 92.51422882 | |
Angola | 109.6 | 40.14783859 | |
Antigua and Barbuda | 7.7 | 101.913269 | |
Arab World | 32.28170265 | 82.6985321 | |
Argentina | 13 | 108.2583084 | |
Austria | 3.6 | 98.25421143 | |
Azerbaijan | 33.9 | 88.97885132 | |
Bahamas, The | 11.4 | 94.85346985 | |
Bangladesh | 39.2 | 70.49899292 | |
Barbados | 13.6 | 105.7491302 | |
Belgium | 3.6 | 92.26545715 | |
Belize | 16.3 | 106.4534378 | |
Benin | 71 | 55.96918106 | |
Bhutan | 34.1 | 96.35308838 | |
Bolivia | 36.8 | 93.15220642 | |
Brunei Darussalam | 7.7 | 107.7526398 | |
Bulgaria | 11.2 | 105.6320572 | |
Burkina Faso | 69.7 | 44.06893921 | |
Burundi | 63.8 | 49.01374054 | |
Cabo Verde | 23.3 | 99.34114075 | |
Cambodia | 36.7 | 91.68153381 | |
Cameroon | 66.2 | 64.20378876 | |
Caribbean small states | 18.79682905 | 93.10451508 | |
Central African Republic | 101.7 | 30.18457031 | |
Central Europe and the Baltics | 6.746707521 | 97.32325745 | |
Chad | 93.6 | 23.49278069 | |
Colombia | 15.9 | 114.7272415 | |
Congo, Dem. Rep. | 84.8 | 54.9679184 | |
Congo, Rep. | 42.2 | 67.22634888 | |
Costa Rica | 8.9 | 96.96784973 | |
Croatia | 4.6 | 91.38627625 | |
Cuba | 4.9 | 98.75244904 | |
Cyprus | 3 | 100.8589172 | |
Czech Republic | 3.4 | 108.9190521 | |
Denmark | 3.3 | 99.38253021 | |
Dominica | 17.2 | 81.2397995 | |
Dominican Republic | 27.9 | 90.24506378 | |
East Asia & Pacific (all income levels) | 18.21170719 | 104.9947891 | |
East Asia & Pacific (developing only) | 19.2 | 105.3598938 | |
Ecuador | 21.3 | 102.9539413 | |
Egypt, Arab Rep. | 24.3 | 104.3540802 | |
El Salvador | 17.1 | 95.06249237 | |
Equatorial Guinea | 78.9 | 52.63772964 | |
Estonia | 3.6 | 95.33157349 | |
Euro area | 3.648834541 | 99.43891907 | |
Europe & Central Asia (all income levels) | 11.81721227 | 98.18402863 | |
Europe & Central Asia (developing only) | 21.6 | 97.7919693 | |
European Union | 4.307984234 | 98.63733673 | |
Finland | 2.5 | 98.33461761 | |
Fragile and conflict affected situations | 63.47283877 | 63.00351334 | |
Gambia, The | 51.7 | 74.75131226 | |
Georgia | 14.9 | 115.7588501 | |
Germany | 3.5 | 101.2165985 | |
Greece | 4.1 | 100.1779633 | |
Grenada | 11.9 | 103.2128525 | |
Guatemala | 28.4 | 83.1153183 | |
Guinea | 71.2 | 47.99417114 | |
Guinea-Bissau | 73.4 | 56.68780136 | |
Guyana | 33.5 | 94.93670654 | |
Heavily indebted poor countries (HIPC) | 62.77097202 | 60.06468582 | |
High income | 6.6 | 98.66924286 | |
High income: nonOECD | 12.12297896 | 99.07261658 | |
High income: OECD | 4.67132275 | 98.5482254 | |
Honduras | 20.7 | 101.2355728 | |
Hungary | 5.7 | 97.97763824 | |
Iceland | 1.9 | 96.57407379 | |
Iran, Islamic Rep. | 16.4 | 103.7376785 | |
Israel | 3.7 | 102.1928177 | |
Italy | 3.4 | 102.0077362 | |
Japan | 2.4 | 100.7415771 | |
Kazakhstan | 19.3 | 102.8035431 | |
Korea, Rep. | 3.5 | 99.34158325 | |
Kyrgyz Republic | 26.5 | 96.63749695 | |
Lao PDR | 59 | 80.04451752 | |
Latin America & Caribbean (all income levels) | 17.94407555 | 99.55323792 | |
Latin America & Caribbean (developing only) | 19 | 99.40028381 | |
Latvia | 8.2 | 93.99823761 | |
Least developed countries: UN classification | 60.45701568 | 62.68008804 | |
Lebanon | 8.7 | 85.45307922 | |
Lesotho | 75.2 | 83.16015625 | |
Liechtenstein | 106.6350708 | ||
Lithuania | 5.6 | 104.6726608 | |
Low & middle income | 42 | 89.70928192 | |
Low income | 63 | 60.56679916 | |
Lower middle income | 47.4 | 89.37412262 | |
Luxembourg | 1.9 | 84.83126831 | |
Madagascar | 42.1 | 71.21040344 | |
Malawi | 57.5 | 69.04071045 | |
Mali | 82.9 | 54.84397888 | |
Malta | 5.6 | 92.55635834 | |
Mauritius | 13.3 | 103.2394791 | |
Mexico | 14.4 | 93.99691772 | |
Middle East & North Africa (all income levels) | 23.06400438 | 90.55309296 | |
Middle East & North Africa (developing only) | 24.4 | 89.31517792 | |
Middle income | 37.4 | 94.43700409 | |
Moldova | 14.7 | 92.65367889 | |
Morocco | 28.5 | 81.36979675 | |
Mozambique | 71.9 | 55.10712814 | |
Myanmar | 45.8 | 96.7735672 | |
Namibia | 37.5 | 84.64054108 | |
Nicaragua | 22 | 83.41893768 | |
Niger | 66.1 | 35.13595963 | |
Nigeria | 81.5 | 71.52314758 | |
Norway | 2.6 | 99.28981018 | |
OECD members | 7.157264734 | 97.92749023 | |
Other small states | 52.34126856 | 78.68188477 | |
Pacific island small states | 24.06919415 | 97.89498901 | |
Pakistan | 73.5 | 60.26723862 | |
Panama | 17 | 92.00022888 | |
Paraguay | 20.4 | 91.25849152 | |
Peru | 16.3 | 99.42054749 | |
Poland | 5 | 95.08609009 | |
Romania | 12.1 | 94.20201874 | |
Rwanda | 43.8 | 56.17655945 | |
Samoa | 16 | 106.3937378 | |
San Marino | 3.1 | 107.2847672 | |
Sao Tome and Principe | 39.8 | 92.48233795 | |
Senegal | 46.7 | 59.05258179 | |
Serbia | 6.6 | 96.60488129 | |
Slovak Republic | 7 | 101.559082 | |
Slovenia | 2.7 | 96.07079315 | |
Small states | 44.94544617 | 83.22514343 | |
South Asia | 49.8 | 89.69166565 | |
Spain | 3.9 | 102.5851898 | |
Sri Lanka | 9.4 | 98.58200073 | |
St. Kitts and Nevis | 10 | 88.65545654 | |
St. Vincent and the Grenadines | 18.6 | 91.5860672 | |
Sub-Saharan Africa (all income levels) | 65.95886707 | 64.56603241 | |
Sub-Saharan Africa (developing only) | 65.8 | 64.57215118 | |
Sudan | 53.3 | 54.22645187 | |
Swaziland | 59.1 | 77.93898773 | |
Sweden | 2.5 | 96.4311676 | |
Switzerland | 3.9 | 97.53890228 | |
Syrian Arab Republic | 13.2 | 103.6311188 | |
Tajikistan | 44.7 | 99.74043274 | |
Tanzania | 42.4 | 91.73339081 | |
Timor-Leste | 53.1 | 64.73622131 | |
Togo | 59.3 | 61.80672836 | |
Trinidad and Tobago | 21 | 94.9871521 | |
Tunisia | 14.9 | 101.6530685 | |
Turkey | 16.4 | 99.48298645 | |
Uganda | 49.5 | 54.80828094 | |
Ukraine | 10.1 | 98.89807129 | |
United Arab Emirates | 7.3 | 96.26954651 | |
Upper middle income | 18.9 | 102.92276 | |
Uruguay | 10.6 | 103.9940109 | |
Uzbekistan | 39.6 | 90.97830963 | |
Vanuatu | 23.9 | 86.75198364 | |
Venezuela, RB | 14.3 | 94.65075684 | |
West Bank and Gaza | 20.2 | 91.8777771 | |
World | 37.5 | 90.90634918 | |
Yemen, Rep. | 42.4 | 54.44889832 | |
Zambia | 52.9 | 105.4886475 |
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> | |
<!-- A modified example from Scott Murray's Knight d3 course. --> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Formatting Ticks</title> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script> | |
<style type="text/css"> | |
body { | |
background-color: white; | |
font-family: Helvetica, Arial, sans-serif; | |
} | |
.wrapper { | |
margin: auto; | |
width: 700px; | |
margin-top:50px; | |
} | |
h1 { | |
font-size: 28px; | |
margin: 0; | |
} | |
p { | |
font-size: 15px; | |
margin: 10px 0 0 0; | |
} | |
svg { | |
background-color: white; | |
} | |
circle:hover { | |
fill: rgba(51,51,153,0.5); | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: black; | |
shape-rendering: crispEdges; | |
} | |
.axis text { | |
font-family: sans-serif; | |
font-size: 11px; | |
} | |
.tooltip { | |
position: absolute; | |
z-index: 10; | |
} | |
.tooltip p { | |
background-color: rgba(0,153,255,0.8); | |
border-radius: 0px 10px 10px; | |
border: white 2px solid; | |
padding: 5px; | |
color: white; | |
} | |
</style> | |
</head> | |
<body> | |
<div class="wrapper"> | |
<h1>Does Female Education Help Decreasing the Infant Mortality Rate?</h1> | |
<p><strong>Introduction:</strong> | |
Educated girls tend to marry later, and to have a better and healthier family. Bellow shows the relationship between the completion of primary school of women and the infant mortality rate.</p> | |
<p><strong>Source: </strong><a href="http://data.worldbank.org/">World Bank</a>, 2010</p> | |
<div id = "svg"></div> | |
<script type="text/javascript"> | |
var width = 700; | |
var height = 600; | |
var margin = {top:20,right:10,bottom:50,left:50}; | |
var dotRadius = 6; | |
var xScale = d3.scale.linear() | |
.range([ margin.left, width - margin.right - margin.left ]); | |
var yScale = d3.scale.linear() | |
.range([ height - margin.bottom, margin.top ]); | |
var xAxis = d3.svg.axis() | |
.scale(xScale) | |
.orient("bottom") | |
.ticks(5); | |
var yAxis = d3.svg.axis() | |
.scale(yScale) | |
.orient("left") | |
.ticks(6); | |
var svg = d3.select("#svg") | |
.append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var tooltip = d3.select("body") | |
.append("div") | |
.attr("class","tooltip"); | |
d3.csv("data.csv", function(data) { | |
xScale.domain([ | |
d3.min(data,function(d){ | |
return +d.infantMortalityRate; | |
}) - 2, | |
d3.max(data,function(d){ | |
return +d.infantMortalityRate; | |
}) | |
]); | |
yScale.domain([ | |
d3.min(data,function(d){ | |
return + d.primaryCompletionRate; | |
}) - 2, | |
d3.max(data,function(d){ | |
return + d.primaryCompletionRate; | |
}) | |
]); | |
var circles = svg.selectAll("circle") | |
.data(data) | |
.enter() | |
.append("circle"); | |
circles.attr("class","dots") | |
circles.attr("cx", function(d) { | |
return xScale(d.infantMortalityRate); | |
}) | |
.attr("cy", function(d) { | |
return yScale(d.primaryCompletionRate); | |
}) | |
.attr("r", dotRadius) | |
.attr("fill",function(d){ | |
if (d.country === "World"){ | |
return "rgba(255,0,153,0.5)"; | |
} else { | |
return "rgba(0,153,255,0.5)"; | |
} | |
}) | |
.append("title") | |
circles | |
.on("mouseover", mouseoverFunc) | |
.on("mousemove", mousemoveFunc) | |
.on("mouseout", mouseoutFunc); | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + (height - margin.bottom) + ")") | |
.call(xAxis); | |
svg.append("g") | |
.attr("class", "y axis") | |
.attr("transform", "translate(" + margin.left + ",0)") | |
.call(yAxis) | |
.selectAll("text") | |
.attr("transform","rotate(-50)") | |
.attr("dy","-.8em") | |
.attr("dx",".5em"); | |
svg.append("text") | |
.attr("x", width/2 ) | |
.attr("y", height - 10 ) | |
.style("text-anchor", "middle") | |
.text("Infant Mortality Rate"); | |
svg.append("text") | |
.attr("y", 0 ) | |
.attr("x", - height/2) | |
.style("text-anchor", "middle") | |
.text("Female Primary School Completion Rate") | |
.attr("transform", "rotate(-90)") | |
.attr("dy", "1em"); | |
}); | |
function mouseoverFunc(d){ | |
return tooltip | |
.style("display",null) | |
.html("<p>Country: " + d.country + | |
"<br>Infant Mortality Rate: " + d.infantMortalityRate | |
+ "‰<br>Female Primary Completion Rate: " + d.primaryCompletionRate + "‰</p>"); | |
} | |
function mousemoveFunc(d){ | |
return tooltip | |
.style("top",(d3.event.pageY - 10) + "px") | |
.style("left",(d3.event.pageX + 10) + "px"); | |
} | |
function mouseoutFunc(d){ | |
return tooltip | |
.style("display","none"); | |
} | |
</script> | |
</div><!-- wrapper --> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment