Skip to content

Instantly share code, notes, and snippets.

@noellethenerd noellethenerd/.block
Created Jan 15, 2019

Embed
What would you like to do?
WDVP Challenge 2019
license: mit
HPI Rank Country Region Average Life Expectancy Average Wellbeing (0-10) Happy Life Years Footprint Inequality of Outcomes Inequality-adjusted Life Expectancy Inequality-adjusted Wellbeing Happy Planet Index GDP/capita ($PPP) Population GINI index governmentEffectiveness governmentIntegrityScore
110 Afghanistan Middle East and North Africa 59.7 3.8 12.4 0.8 43% 38.3 3.4 20.2 $691 29,726,803 Data unavailable -1.3 8.5
13 Albania Post-communist 77.3 5.5 34.4 2.2 17% 69.7 5.1 36.8 $4,247 2,900,489 29.0 0.1 16.3
30 Algeria Middle East and North Africa 74.3 5.6 30.5 2.1 24% 60.5 5.2 33.3 $5,584 37,439,427 Data unavailable -0.6 11.2
19 Argentina Americas 75.9 6.5 40.2 3.1 16% 68.3 6.0 35.2 $14,357 42,095,224 42.5 0.2 6.6
73 Armenia Post-communist 74.4 4.3 24.0 2.2 22% 66.9 3.7 25.7 $3,566 2,978,339 30.5 -0.1 16.8
105 Australia Asia Pacific 82.1 7.2 53.1 9.3 8% 78.6 6.9 21.2 $67,646 22,728,254 Data unavailable 1.5 5.7
43 Austria Europe 81.0 7.4 54.4 6.1 7% 78.0 7.1 30.5 $48,324 8,429,991 30.5 1.5 6.1
8 Bangladesh Asia Pacific 70.8 4.7 23.3 0.7 27% 56.6 4.3 38.4 $859 155,257,387 Data unavailable -0.7 4.1
102 Belarus Post-communist 70.9 5.7 34.0 5.1 13% 66.7 5.3 21.7 $6,722 9,464,000 26.0 -0.4 0.5
87 Belgium Europe 80.4 6.9 49.5 7.4 9% 77.2 6.6 23.7 $44,731 11,128,246 27.6 1.2 8.3
27 Belize Americas 69.8 6.1 34.2 2.5 18% 61.7 5.7 33.8 $4,674 336,707 Data unavailable -0.6 11
137 Benin Sub Saharan Africa 59.2 3.2 9.9 1.4 44% 37.3 2.8 13.4 $808 10,049,792 Data unavailable -0.6 1
56 Bhutan Asia Pacific 68.7 5.6 27.4 2.3 27% 54.5 5.2 28.6 $2,452 743,711 38.7 0.6 2.4
92 Bolivia Americas 67.5 6.0 25.6 3.0 35% 47.9 5.5 23.3 $2,645 10,238,762 46.7 -0.4 3.7
76 Bosnia and Herzegovina Post-communist 76.2 4.8 28.6 3.1 19% 71.1 4.2 25.3 $4,495 3,828,419 Data unavailable -0.5 25.8
126 Botswana Sub Saharan Africa 64.2 4.8 21.3 3.8 28% 50.8 4.3 16.6 $6,936 2,132,822 Data unavailable 0.4 18.4
23 Brazil Americas 73.9 6.9 39.0 3.1 22% 63.3 6.3 34.3 $12,157 202,401,584 52.7 -0.3 11.5
109 Bulgaria Post-communist 73.9 4.2 24.0 3.3 19% 68.1 3.7 20.4 $7,333 7,305,888 36.0 0.3 8
119 Burkina Faso Sub Saharan Africa 58.0 4.0 12.6 1.2 43% 36.5 3.6 17.9 $673 16,590,813 Data unavailable -0.6 3
131 Burundi Sub Saharan Africa 55.8 3.4 9.5 0.8 48% 33.0 3.0 15.6 $244 10,124,572 Data unavailable -1.3 1.6
74 Cambodia Asia Pacific 67.5 3.9 18.2 1.2 28% 54.2 3.5 25.6 $946 14,832,255 30.8 -0.7 0.3
124 Cameroon Sub Saharan Africa 54.6 4.2 11.6 1.2 47% 33.1 3.7 16.7 $1,222 21,659,488 Data unavailable -0.8 4.5
85 Canada Americas 81.7 7.4 53.9 8.2 9% 77.8 7.1 23.9 $52,738 34,751,476 Data unavailable 1.9 7.1
140 Chad Sub Saharan Africa 50.8 4.0 9.6 1.5 51% 27.3 3.7 12.8 $973 12,715,465 Data unavailable -1.5 5.8
35 Chile Americas 81.1 6.6 44.7 4.4 14% 74.9 6.1 31.7 $15,253 17,388,437 Data unavailable 0.9 6.6
72 China Asia Pacific 75.4 5.1 30.6 3.4 17% 68.6 4.6 25.7 $6,265 1,350,695,000 Data unavailable 0.4 4.6
3 Colombia Americas 73.7 6.4 35.1 1.9 24% 63.1 5.7 40.7 $7,885 46,881,018 53.5 -0.1 9.9
93 Comoros Sub Saharan Africa 62.6 4.0 15.4 1.0 36% 43.3 3.7 23.1 $750 733,661 Data unavailable -1.6 20
1 Costa Rica Americas 79.1 7.3 48.2 2.8 15% 72.6 6.8 44.7 $9,733 4,654,148 48.6 0.3 9
135 Cote d'Ivoire Sub Saharan Africa 50.8 3.8 10.3 1.3 45% 30.6 3.5 14.4 $1,281 21,102,641 Data unavailable -0.7 9.3
47 Croatia Post-communist 77.0 6.0 39.6 3.9 12% 73.5 5.5 30.2 $13,236 4,267,558 Data unavailable 0.6 13.5
41 Cyprus Europe 79.8 6.2 42.3 4.2 12% 76.6 5.7 30.7 $28,868 1,129,303 34.3 0.9 11.7
64 Czech Republic Post-communist 78.2 6.3 43.4 5.2 9% 75.5 5.9 27.3 $19,641 10,510,785 26.1 1 4
32 Denmark Europe 79.8 7.5 54.4 5.5 7% 76.8 7.2 32.7 $57,636 5,591,572 29.1 1.8 6.1
127 Djibouti Sub Saharan Africa 61.3 4.4 15.1 2.2 42% 41.4 3.8 16.4 $1,587 853,069 45.1 -1 6.6
45 Dominican Republic Americas 73.1 4.8 23.7 1.5 30% 60.8 4.1 30.3 $5,967 10,155,036 45.7 -0.4 14.4
10 Ecuador Americas 75.4 6.0 34.3 2.2 22% 64.1 5.5 37.0 $5,702 15,419,493 46.6 -0.3 5.4
86 Egypt Middle East and North Africa 70.7 4.2 21.8 2.2 23% 61.3 3.7 23.8 $3,226 85,660,902 Data unavailable -0.6 12
17 El Salvador Americas 72.5 5.9 32.2 2.1 22% 62.5 5.3 35.6 $3,922 6,072,233 41.8 -0.4 6.3
118 Estonia Post-communist 76.2 5.4 35.0 6.9 12% 72.6 5.0 17.9 $17,491 1,322,696 33.2 1.1 6.9
66 Ethiopia Sub Saharan Africa 62.8 4.6 17.8 1.0 36% 43.8 4.2 26.7 $470 92,191,211 Data unavailable -0.7 5.7
37 Finland Europe 80.4 7.4 54.6 5.9 6% 77.6 7.2 31.3 $47,416 5,413,971 27.1 1.9 9
44 France Europe 81.8 6.6 48.1 5.1 9% 78.5 6.3 30.4 $40,850 65,639,975 33.1 1.4 10
120 Gabon Sub Saharan Africa 63.3 4.0 15.4 2.0 36% 45.8 3.5 17.5 $10,642 1,613,489 Data unavailable -0.9 18.5
40 Georgia Post-communist 74.6 4.3 24.7 1.6 20% 66.9 3.8 31.1 $4,143 3,825,000 41.4 0.6 11.6
49 Germany Europe 80.6 6.7 48.2 5.3 8% 77.6 6.4 29.8 $44,011 80,425,823 Data unavailable 1.7 4.3
104 Ghana Sub Saharan Africa 61.0 5.1 18.8 2.0 38% 42.2 4.6 21.4 $1,642 25,544,565 Data unavailable -0.1 5.8
89 Greece Europe 80.5 5.1 33.3 4.4 16% 77.6 4.5 23.6 $22,243 11,045,011 36.7 0.3 23.9
26 Guatemala Americas 71.4 5.9 29.6 1.9 27% 59.2 5.2 34.2 $3,279 15,368,759 Data unavailable -0.6 2.4
129 Guinea Sub Saharan Africa 57.7 3.7 11.8 1.4 42% 37.2 3.3 15.9 $487 11,628,767 33.7 -1 6.8
57 Haiti Americas 62.1 4.4 16.5 0.6 37% 42.9 4.0 28.6 $767 10,288,828 60.8 -2.1 13.2
65 Honduras Americas 72.8 4.6 22.1 1.7 31% 58.5 3.9 27.2 $2,395 7,736,131 57.4 -0.5 6.3
123 Hong Kong Asia Pacific 83.6 5.5 40.1 8.8 10% 81.3 5.1 16.8 $36,708 7,154,600 Data unavailable #N/A #N/A
69 Hungary Post-communist 74.9 4.7 28.7 2.9 15% 70.9 4.2 26.4 $12,820 9,920,362 30.6 0.5 5.2
39 Iceland Europe 82.2 7.6 58.0 6.4 5% 79.8 7.4 31.1 $44,259 320,716 26.9 1.5 3.8
50 India Asia Pacific 67.3 4.6 20.4 1.2 31% 51.1 4.2 29.2 $1,450 1,263,589,639 Data unavailable 0.1 3.5
16 Indonesia Asia Pacific 68.5 5.4 28.4 1.6 21% 57.2 5.1 35.7 $3,701 248,037,853 Data unavailable 0 5.6
84 Iran Middle East and North Africa 74.8 4.6 25.4 2.8 23% 66.9 4.0 24.0 $7,711 76,156,975 Data unavailable -0.2 11.3
67 Iraq Middle East and North Africa 69.0 4.7 22.8 1.9 27% 55.6 4.3 26.5 $6,649 32,780,975 29.5 -1.3 16
48 Ireland Europe 80.5 7.0 50.3 5.6 8% 77.5 6.7 30.0 $48,977 4,586,897 32.5 1.3 8.1
54 Israel Middle East and North Africa 81.9 7.1 52.5 6.2 8% 78.7 6.8 28.8 $32,819 7,910,500 Data unavailable 1.4 5.6
60 Italy Europe 82.7 5.8 41.1 4.6 12% 80.2 5.3 28.1 $34,844 59,539,717 35.2 0.5 11.5
11 Jamaica Americas 75.3 5.6 31.9 1.9 21% 66.3 5.0 36.9 $5,446 2,707,805 Data unavailable 0.5 13.3
58 Japan Asia Pacific 83.2 6.0 44.0 5.0 9% 80.6 5.6 28.3 $46,679 127,561,489 Data unavailable 1.6 3.1
114 Kazakhstan Post-communist 68.6 5.8 31.7 5.6 18% 60.7 5.4 19.1 $12,120 16,791,425 27.4 0 5.2
83 Kenya Sub Saharan Africa 60.3 4.5 16.2 1.0 38% 41.0 4.1 24.2 $1,185 42,542,978 Data unavailable -0.3 11
31 Kyrgyzstan Post-communist 69.7 5.2 28.7 1.9 18% 60.2 4.9 33.1 $1,178 5,607,200 27.4 -0.7 7.7
121 Latvia Post-communist 73.6 5.1 31.2 6.3 14% 68.7 4.7 17.1 $13,775 2,034,319 35.5 0.9 9.9
100 Lebanon Middle East and North Africa 78.8 4.6 28.2 3.8 19% 73.1 4.0 21.9 $9,729 4,440,728 Data unavailable -0.5 6.8
125 Lesotho Sub Saharan Africa 48.9 4.9 13.4 1.7 42% 32.6 4.3 16.7 $1,159 2,057,331 Data unavailable -0.9 27.4
96 Liberia Sub Saharan Africa 60.2 4.4 15.7 1.2 38% 40.3 4.1 22.2 $414 4,190,155 Data unavailable -1.4 4
107 Lithuania Post-communist 72.8 5.8 36.4 5.8 11% 68.8 5.4 21.0 $14,343 2,987,773 35.2 1 9.2
139 Luxembourg Europe 81.1 7.0 51.7 15.8 7% 79.0 6.7 13.2 $105,447 530,946 34.8 1.7 5.9
90 Macedonia Post-communist 75.1 4.6 27.2 3.3 18% 69.4 4.1 23.4 $4,710 2,069,270 Data unavailable 0.1 26.7
98 Malawi Sub Saharan Africa 60.1 4.3 13.7 0.8 45% 40.4 3.5 22.1 $270 15,700,436 Data unavailable -0.7 6.7
46 Malaysia Asia Pacific 74.4 5.9 38.3 3.7 10% 69.5 5.7 30.3 $10,835 29,021,940 Data unavailable 0.8 3.3
53 Malta Europe 80.2 6.0 40.8 4.4 13% 76.6 5.5 29.0 $21,176 419,455 Data unavailable 1 5.3
117 Mauritania Sub Saharan Africa 62.6 4.7 18.0 2.5 37% 41.5 4.5 18.0 $1,283 3,777,067 Data unavailable -0.7 11.7
63 Mauritius Sub Saharan Africa 74.0 5.5 33.1 3.5 17% 66.7 5.1 27.4 $9,114 1,255,882 35.8 0.9 7.8
2 Mexico Americas 76.4 7.3 44.3 2.9 19% 66.3 6.8 40.7 $9,703 122,070,963 48.1 0 4
136 Mongolia Asia Pacific 68.6 4.9 25.3 6.1 22% 56.9 4.6 14.3 $4,377 2,808,339 33.8 -0.3 6.7
78 Montenegro Post-communist 75.8 5.2 32.1 3.8 16% 71.8 4.6 25.1 $6,587 620,601 32.2 0.2 17.5
33 Morocco Middle East and North Africa 73.4 5.0 26.7 1.7 25% 61.6 4.5 32.7 $2,931 32,984,190 Data unavailable -0.2 10
88 Mozambique Sub Saharan Africa 54.3 5.0 15.0 0.9 43% 34.5 4.5 23.7 $565 25,732,928 Data unavailable -0.9 24.4
81 Myanmar Asia Pacific 65.5 4.4 18.8 1.4 32% 48.4 4.0 24.7 $1,421 52,543,841 Data unavailable -1.1 0.8
103 Namibia Sub Saharan Africa 64.0 4.7 21.3 2.5 26% 50.1 4.4 21.6 $5,680 2,291,645 Data unavailable 0.2 25.6
42 Nepal Asia Pacific 68.8 4.2 20.2 1.0 27% 55.3 3.8 30.5 $685 27,500,515 Data unavailable -0.9 3.2
18 Netherlands Europe 81.2 7.5 57.0 5.3 4% 78.2 7.5 35.3 $49,475 16,754,962 28.0 1.9 6.2
38 New Zealand Asia Pacific 81.4 7.2 52.7 5.6 8% 77.7 6.9 31.3 $39,505 4,408,100 Data unavailable 1.8 5.2
7 Nicaragua Americas 74.3 5.4 29.2 1.4 25% 63.4 4.8 38.7 $1,780 5,877,034 Data unavailable -0.6 5.9
122 Niger Sub Saharan Africa 60.0 3.8 13.1 1.6 40% 38.9 3.5 16.8 $394 17,635,782 Data unavailable -0.7 2.6
95 Nigeria Sub Saharan Africa 52.1 5.5 15.5 1.2 44% 30.9 5.2 22.2 $2,740 168,240,403 Data unavailable -1 5
12 Norway Europe 81.3 7.7 57.1 5.0 7% 78.6 7.4 36.8 $101,564 5,018,573 25.9 2 4.8
106 Oman Middle East and North Africa 76.3 6.9 44.5 7.5 13% 70.9 6.4 21.1 $21,534 3,545,192 Data unavailable 0.2 17.5
36 Pakistan Asia Pacific 65.7 5.1 19.5 0.8 40% 44.1 4.6 31.5 $1,266 177,392,252 Data unavailable -0.6 5.9
22 Palestine Middle East and North Africa 72.6 4.6 24.5 1.2 24% 62.6 4.1 34.5 $2,783 4,046,901 Data unavailable #N/A #N/A
6 Panama Americas 77.2 6.9 42.1 2.8 19% 68.3 6.3 39.5 $10,139 3,743,761 51.9 0 5.8
91 Paraguay Americas 72.6 5.8 31.8 4.2 22% 59.4 5.5 23.3 $3,858 6,379,162 48.2 -0.8 5.4
21 Peru Americas 74.1 5.8 32.9 2.3 21% 63.5 5.3 34.6 $6,389 30,158,768 45.1 -0.1 4.9
20 Philippines Asia Pacific 67.9 5.0 24.1 1.1 26% 56.9 4.4 35.0 $2,605 96,017,322 43.0 -0.1 5.9
62 Poland Post-communist 76.9 5.9 39.2 4.4 11% 72.9 5.5 27.5 $13,142 38,063,164 32.4 0.6 6.2
79 Portugal Europe 80.3 5.0 32.3 3.9 16% 77.2 4.3 24.8 $20,577 10,514,844 36.0 1.3 11.2
115 Republic of Congo Sub Saharan Africa 61.0 3.9 13.6 1.3 40% 42.0 3.4 18.8 $3,191 4,286,188 Data unavailable #N/A #N/A
55 Romania Post-communist 74.3 5.2 30.1 2.7 19% 68.1 4.6 28.8 $8,577 20,058,035 27.3 -0.2 6.4
116 Russia Post-communist 69.5 5.6 31.7 5.7 16% 63.4 5.2 18.7 $14,079 143,201,676 41.6 -0.1 5.7
111 Rwanda Sub Saharan Africa 63.1 3.3 12.4 0.9 37% 44.3 3.0 19.6 $667 10,817,350 Data unavailable 0.3 2.5
101 Senegal Sub Saharan Africa 65.4 3.7 15.5 1.2 33% 49.1 3.3 21.9 $1,019 13,780,108 Data unavailable -0.3 9.5
52 Serbia Post-communist 74.5 5.2 30.3 2.7 19% 68.6 4.6 29.0 $5,659 7,199,077 Data unavailable 0.2 16.5
133 Sierra Leone Sub Saharan Africa 49.8 4.5 10.8 1.2 50% 28.2 4.0 15.3 $619 6,043,157 Data unavailable -1.2 3
59 Slovakia Post-communist 75.9 5.9 37.9 4.1 13% 71.9 5.4 28.2 $17,207 5,407,579 26.1 0.8 10
82 Slovenia Post-communist 80.0 6.1 42.6 5.8 10% 77.1 5.7 24.6 $22,478 2,057,159 25.6 1.2 8.7
128 South Africa Sub Saharan Africa 56.3 5.1 18.5 3.3 33% 41.8 4.6 15.9 $7,592 52,341,695 Data unavailable 0.3 25.9
80 South Korea Asia Pacific 81.3 6.0 42.2 5.7 11% 78.3 5.5 24.8 $24,454 50,004,441 Data unavailable #N/A #N/A
15 Spain Europe 82.2 6.3 45.3 3.7 10% 79.3 5.9 36.0 $28,648 46,773,055 35.9 1 19.4
28 Sri Lanka Asia Pacific 74.6 4.2 24.9 1.3 17% 68.6 3.8 33.8 $3,351 20,424,000 38.6 -0.2 5
75 Suriname Americas 70.8 6.3 35.2 4.3 19% 61.2 5.9 25.4 $9,422 528,535 Data unavailable -0.6 10
132 Swaziland Sub Saharan Africa 48.9 4.9 13.6 2.0 41% 31.8 4.4 15.5 $3,989 1,231,694 Data unavailable #N/A #N/A
61 Sweden Europe 81.8 7.6 57.4 7.3 6% 79.1 7.4 28.0 $57,134 9,519,374 27.3 1.8 7.1
24 Switzerland Europe 82.6 7.8 59.3 5.8 6% 79.4 7.6 34.3 $83,209 7,996,861 31.6 2.1 4.6
113 Syria Middle East and North Africa 70.4 3.2 14.7 1.5 30% 60.2 2.6 19.1 $2,080 21,427,155 Data unavailable -1.8 14.3
25 Tajikistan Post-communist 69.0 4.5 22.2 0.9 26% 53.0 4.3 34.2 $962 7,930,929 Data unavailable -1.1 10.8
97 Tanzania Sub Saharan Africa 63.5 4.0 16.2 1.3 33% 47.7 3.6 22.1 $828 48,645,709 Data unavailable -0.6 2.6
9 Thailand Asia Pacific 74.1 6.3 38.6 2.7 15% 66.3 6.0 37.3 $5,918 67,164,130 39.3 0.4 0.6
138 Togo Sub Saharan Africa 58.6 2.9 9.0 1.1 43% 39.6 2.4 13.2 $580 6,745,581 Data unavailable -1.1 6.8
130 Trinidad and Tobago Americas 70.1 6.4 34.4 7.9 21% 58.4 6.0 15.7 $18,322 1,341,579 Data unavailable 0.3 3.9
71 Tunisia Middle East and North Africa 74.6 4.5 25.2 2.3 22% 65.5 4.0 26.2 $4,188 10,777,500 Data unavailable -0.1 14.8
68 Turkey Middle East and North Africa 74.7 5.3 31.2 3.3 19% 66.2 4.9 26.4 $10,646 74,099,255 40.2 0.1 10.3
134 Turkmenistan Post-communist 65.3 5.5 24.0 5.5 31% 48.3 5.1 14.6 $6,798 5,172,941 Data unavailable -1.2 8.6
112 Uganda Sub Saharan Africa 57.1 4.3 13.8 1.2 41% 36.8 3.9 19.4 $656 35,400,620 42.4 -0.6 2.3
70 Ukraine Post-communist 70.3 5.0 28.3 2.8 17% 64.2 4.6 26.4 $3,855 45,593,300 24.7 -0.5 8.9
34 United Kingdom Europe 80.4 6.9 49.1 4.9 9% 76.8 6.6 31.9 $41,295 63,700,300 32.6 1.4 4.8
108 United States of America Americas 78.8 7.0 46.8 8.2 13% 74.0 6.5 20.7 $51,457 314,112,078 Data unavailable #N/A #N/A
14 Uruguay Americas 76.9 6.4 39.4 2.9 18% 69.6 5.8 36.1 $15,128 3,396,753 41.3 0.4 8.2
51 Uzbekistan Post-communist 68.2 6.0 27.9 2.3 30% 51.6 5.6 29.1 $1,719 29,774,500 Data unavailable -0.6 8.9
4 Vanuatu Asia Pacific 71.3 6.5 34.9 1.9 22% 60.3 5.9 40.6 $3,158 247,498 Data unavailable -0.9 5.4
29 Venezuela Americas 73.9 7.1 41.5 3.6 19% 65.5 6.5 33.6 $12,772 29,854,238 Data unavailable -1.4 6.9
5 Vietnam Asia Pacific 75.5 5.5 32.8 1.7 19% 64.8 5.2 40.3 $1,755 88,809,200 38.7 0 2.2
94 Yemen Middle East and North Africa 63.3 4.1 15.2 1.0 39% 44.7 3.6 22.8 $1,289 24,882,792 Data unavailable -1.9 17.1
77 Zambia Sub Saharan Africa 58.4 5.0 16.7 1.0 41% 38.7 4.5 25.2 $1,687 14,786,581 Data unavailable -0.6 7.5
99 Zimbabwe Sub Saharan Africa 53.7 5.0 16.4 1.4 37% 36.9 4.6 22.1 $851 14,565,482 Data unavailable -1.2 5.1
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>World Data Viz Challenge</title>
<script src="https://d3js.org/d3.v5.min.js"></script>
</head>
<body>
<center>
<h1>Ecological Footprints
in Order of Government Effectiveness
</h1>
Ecological Footprint (gha/capita) data from <a href = "http://happyplanetindex.org/countries">Happy Planet Index (2016)</a><br>
Government Effectiveness data from <a href = "http://info.worldbank.org/governance/wgi/#reports">Worldwide Governance Indicators</a><br>
<div id="wdvp-div"></div>
<script src="wdvp-challenge.js"></script>
</body>
</html>
d3.csv('data-viz-challenge.csv').then(d => {
const dat = d.map(d => ({
country: d.Country,
footprintGHDPP: Number(d.Footprint.replace(/[^\d.-]/g, '')),
population: Number(d.Population.replace(/[^\d.-]/g, '')),
govEffectiveness: Number(d.governmentEffectiveness.replace(/[^\d.-]/g, '')),
integrity: Number(d.governmentIntegrityScore.replace(/[^\d.-]/g, '')),
}));
const data = dat.map(d => ({
country: d.country,
population: d.population,
footprint: d.footprintGHDPP,
govEffectiveness: d.govEffectiveness,
integrity: d.integrity,
}))
data.sort((obj1, obj2) => obj1.footprint - obj2.footprint);
console.log(data);
const height = 14;
const yScale = d3.scaleBand()
.padding(0.2)
.domain(data.map(d => d.country))
.range(5000, 0);
const yAxis = d3.axisLeft(yScale);
const svg = d3.select('#wdvp-div')
.append('svg')
.attr('width', 1000)
.attr('height', 5000)
.selectAll('g')
.data(data, d => d ? d.country : this.innerText)
.enter()
.append('g')
.attr('transform', (d, i) => 'translate(0, ' + i*(height+2) + ')')
// .call(yAxis)
;
svg.append('rect')
.attr('height', `${height}px`)
.attr('width', d => Number((d.govEffectiveness)+3)*100)
.style('fill', 'lightgreen')
.style('stroke', 'black')
.style('stroke-width', 1);
svg.append('text')
.attr('y', 13)
.attr('x', d => Number((d.govEffectiveness)+3)*100 + 5)
.attr('font-size', 12)
.text(d => d.country)
.style('text-transform', 'uppercase')
;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.