Skip to content

Instantly share code, notes, and snippets.

@TheoLeanse
Last active August 29, 2015 14:12
Show Gist options
  • Save TheoLeanse/a9c8868ad385d08732bb to your computer and use it in GitHub Desktop.
Save TheoLeanse/a9c8868ad385d08732bb to your computer and use it in GitHub Desktop.
Interactive Small Multiple Choropleth Maps

Mapping the global distribution of the world's most powerful supercomputers, 2005-14. Figures are in Rmax, the maximal LINPACK performance achieved, as used by Top500 to rank supercomputing power.

Data from www.top500.org

Please feel free to use your cursor to explore the numbers behind the map more closely.

Country Date Rmax
Australia 01/06/05 19592.09
Australia 01/11/05 34460.26
Australia 01/06/06 31023.06
Australia 01/11/06 20670.9
Australia 01/06/07 22522.5
Australia 01/11/07 8974
Australia 01/06/08 9239
Australia 01/11/08 21905.7
Australia 01/06/09 21905.7
Australia 01/11/09 21905.7
Australia 01/06/10 49590
Australia 01/11/10 315738.7
Australia 01/06/11 400405.9
Australia 01/11/11 353753.52
Australia 01/06/12 1162576.32
Australia 01/11/12 2196914.32
Australia 01/06/13 2056248.82
Australia 01/11/13 2180150.82
Australia 01/06/14 2472258.6
Australia 01/11/14 4635447.6
Austria 01/06/09 117786.6
Austria 01/11/09 219920.3
Austria 01/06/10 62876.2
Austria 01/11/10 35480
Austria 01/06/11 188670
Austria 01/11/11 205970
Austria 01/06/12 152900
Austria 01/11/12 152900
Austria 01/06/13 152900
Austria 01/11/13 152900
Austria 01/06/14 152900
Austria 01/11/14 596010
Belarus 01/06/05 2032
Belarus 01/11/05 2032
Belarus 01/06/06 2032
Belgium 01/11/05 4650.8
Belgium 01/06/06 4650.8
Belgium 01/11/06 4492.8
Belgium 01/06/07 22401.8
Belgium 01/11/07 7596.8
Belgium 01/06/08 21088.5
Belgium 01/11/08 35432
Belgium 01/06/09 22731
Belgium 01/11/09 22731
Belgium 01/11/10 83840
Belgium 01/06/11 83840
Belgium 01/11/11 64597
Belgium 01/06/12 216944.9
Belgium 01/11/12 152347.9
Belgium 01/06/13 152347.9
Belgium 01/11/13 152347.9
Belgium 01/06/14 319820.9
Belgium 01/11/14 201374
Brazil 01/06/05 12408.56
Brazil 01/11/05 12408.56
Brazil 01/06/06 13160
Brazil 01/11/06 13668.38
Brazil 01/06/07 10722
Brazil 01/11/07 6210
Brazil 01/06/08 16240
Brazil 01/11/08 31778.5
Brazil 01/11/09 64630
Brazil 01/06/10 64630
Brazil 01/11/10 269730
Brazil 01/06/11 269730
Brazil 01/11/11 269730
Brazil 01/06/12 530330
Brazil 01/11/12 465700
Brazil 01/06/13 626000
Brazil 01/11/13 626000
Brazil 01/06/14 1031365
Brazil 01/11/14 1031365
Bulgaria 01/11/05 1860.4
Bulgaria 01/11/08 23415
Bulgaria 01/06/09 23415
Bulgaria 01/11/09 23862
Canada 01/06/05 23503
Canada 01/11/05 22048
Canada 01/06/06 35274
Canada 01/11/06 37316.6
Canada 01/06/07 54818.1
Canada 01/11/07 32139.7
Canada 01/06/08 22864.18
Canada 01/11/08 70479.1
Canada 01/06/09 358740.6
Canada 01/11/09 439783
Canada 01/06/10 403950.3
Canada 01/11/10 422401.2
Canada 01/06/11 640128.7
Canada 01/11/11 1249486.5
Canada 01/06/12 1424183.6
Canada 01/11/12 1858445.7
Canada 01/06/13 1772008.7
Canada 01/11/13 2077841.5
Canada 01/06/14 1959749.8
Canada 01/11/14 1903949.8
China 01/06/05 53479.3
China 01/11/05 59541.85
China 01/06/06 94175.85
China 01/11/06 72192.16
China 01/06/07 96403
China 01/11/07 87176.1
China 01/06/08 140311.3
China 01/11/08 520961.6
China 01/06/09 788125.1
China 01/11/09 1379876.9
China 01/06/10 2992629.8
China 01/11/10 5688792
China 01/06/11 7136315.4
China 01/11/11 10489499.07
China 01/06/12 11397100.01
China 01/11/12 12349895.38
China 01/06/13 47485017.68
China 01/11/13 48549092.87
China 01/06/14 52129820.68
China 01/11/14 52105183.3
Cyprus 01/06/08 9243.89
Denmark 01/11/05 2791
Denmark 01/06/06 2791
Denmark 01/11/06 2791
Denmark 01/11/07 5949.4
Denmark 01/11/08 46472.2
Denmark 01/06/10 81761.1
Denmark 01/11/10 82587
Denmark 01/06/11 198407.8
Denmark 01/11/11 213464
Denmark 01/06/12 162098
Denmark 01/11/12 162098
Denmark 01/06/13 162098
Denmark 01/11/13 162098
Denmark 01/06/14 162098
Denmark 01/11/14 572878
Egypt 01/06/05 1417.92
Egypt 01/11/07 9949
Egypt 01/06/08 9949
Finland 01/06/05 1170
Finland 01/11/05 1710.15
Finland 01/11/06 8200.2
Finland 01/06/07 21233.2
Finland 01/11/07 43986.9
Finland 01/06/08 26795.8
Finland 01/11/08 76510
Finland 01/06/09 76510
Finland 01/11/09 103047.2
Finland 01/06/10 130788.2
Finland 01/11/10 76510
Finland 01/06/11 117857.9
Finland 01/11/11 76510
Finland 01/06/12 76510
Finland 01/11/12 437691
Finland 01/06/13 378000
Finland 01/11/13 378000
Finland 01/06/14 378000
Finland 01/11/14 1870548
France 01/06/05 19785.21
France 01/11/05 23512.48
France 01/06/06 67406.39
France 01/11/06 99870.5
France 01/06/07 156089.18
France 01/11/07 222555.22
France 01/06/08 711649.89
France 01/11/08 886782.1
France 01/06/09 1004742.8
France 01/11/09 1214250
France 01/06/10 1706870.1
France 01/11/10 2874899
France 01/06/11 3180743.8
France 01/11/11 3709337.4
France 01/06/12 6358046.4
France 01/11/12 6413594.4
France 01/06/13 8938486.2
France 01/11/13 9489912.4
France 01/06/14 11236984.81
France 01/11/14 14120724.1
Germany 01/06/05 80481.74
Germany 01/11/05 71303.26
Germany 01/06/06 96858.21
Germany 01/11/06 145407.44
Germany 01/06/07 249836.2
Germany 01/11/07 536463.7
Germany 01/06/08 963465.350000001
Germany 01/11/08 803761
Germany 01/06/09 2113109.8
Germany 01/11/09 2288765.9
Germany 01/06/10 2248464
Germany 01/11/10 2721354.4
Germany 01/06/11 3242111.1
Germany 01/11/11 3631255.33
Germany 01/06/12 8133773.67
Germany 01/11/12 10178295.84
Germany 01/06/13 11351753.71
Germany 01/11/13 13696833.5
Germany 01/06/14 14809560
Germany 01/11/14 20090183
Hong Kong 01/06/05 1186.19
Hong Kong 01/06/09 17380
Hong Kong 01/11/09 32325
Hong Kong 01/06/10 32325
Hong Kong 01/11/10 32325
Hong Kong 01/06/13 234248
Hong Kong 01/11/13 352937
Hong Kong 01/06/14 234248
Hong Kong 01/11/14 234248
Hungary 01/11/14 197210
India 01/06/05 13995.48
India 01/11/05 11378.88
India 01/06/06 36839.24
India 01/11/06 34162.36
India 01/06/07 45696.6
India 01/11/07 194523.69
India 01/06/08 189853.75
India 01/11/08 259394.2
India 01/06/09 247285.4
India 01/11/09 199257.1
India 01/06/10 283379.9
India 01/11/10 257243
India 01/06/11 187910
India 01/11/11 187910
India 01/06/12 787651.6
India 01/11/12 1167757.8
India 01/06/13 2690461
India 01/11/13 3040297
India 01/06/14 2898744.8
India 01/11/14 3137691.8
Indonesia 01/11/05 1788.8
Indonesia 01/06/07 8021
Indonesia 01/11/07 8021
Ireland 01/11/05 5515
Ireland 01/06/06 5515
Ireland 01/11/06 3142
Ireland 01/06/08 11710
Ireland 01/11/08 25110
Ireland 01/06/09 25110
Ireland 01/11/09 25110
Ireland 01/06/10 25110
Ireland 01/11/10 36560
Ireland 01/06/11 40495
Ireland 01/11/11 194814
Ireland 01/06/12 194814
Ireland 01/11/13 268565
Ireland 01/06/14 140446
Israel 01/06/05 14721.19
Israel 01/11/05 23514.01
Israel 01/06/06 25275.62
Israel 01/11/06 7510
Israel 01/11/08 24670
Israel 01/06/09 24670
Israel 01/11/09 49340
Israel 01/06/10 49340
Israel 01/06/11 135360.6
Israel 01/11/11 213056.56
Israel 01/06/12 213056.56
Israel 01/11/12 77696
Israel 01/06/13 283965
Israel 01/11/13 314055.65
Israel 01/06/14 347685
Israel 01/11/14 347685
Italy 01/06/05 20064.33
Italy 01/11/05 14536.83
Italy 01/06/06 19728.67
Italy 01/11/06 39171.74
Italy 01/06/07 36604.2
Italy 01/11/07 69111.58
Italy 01/06/08 99980
Italy 01/11/08 182434.2
Italy 01/06/09 186239.4
Italy 01/11/09 200688.7
Italy 01/06/10 281510.6
Italy 01/11/10 254075.8
Italy 01/06/11 471746.5
Italy 01/11/11 426219
Italy 01/06/12 2485851.21
Italy 01/11/12 2424814.39
Italy 01/06/13 2422982
Italy 01/11/13 2665609.34
Italy 01/06/14 5537409.34
Italy 01/11/14 5430931.34
Japan 01/06/05 128625.8
Japan 01/11/05 130523.98
Japan 01/06/06 260088.85
Japan 01/11/06 286673.51
Japan 01/06/07 285611.05
Japan 01/11/07 291118.05
Japan 01/06/08 550864.8
Japan 01/11/08 522980.8
Japan 01/06/09 873109
Japan 01/11/09 994211
Japan 01/06/10 1252711
Japan 01/11/10 2903675.8
Japan 01/06/11 11182236.4
Japan 01/11/11 14224106.39
Japan 01/06/12 18011149.3
Japan 01/11/12 19448399
Japan 01/06/13 20307189
Japan 01/11/13 22472218
Japan 01/06/14 23941240.44
Japan 01/11/14 25027460.14
South Korea 01/06/05 28866.75
South Korea 01/11/05 31599.1
South Korea 01/06/06 27121.3
South Korea 01/11/06 33715.3
South Korea 01/06/07 35313.3
South Korea 01/11/07 15706
South Korea 01/06/08 16990
South Korea 01/11/08 16990
South Korea 01/11/09 298170
South Korea 01/06/10 274800
South Korea 01/11/10 907600
South Korea 01/06/11 950833
South Korea 01/11/11 907600
South Korea 01/06/12 907600
South Korea 01/11/12 1014400
South Korea 01/06/13 1014400
South Korea 01/11/13 1258060.1
South Korea 01/06/14 2112514.1
South Korea 01/11/14 2527211.7
Luxembourg 01/11/07 7776.1
Malaysia 01/06/06 3521.48
Malaysia 01/11/06 12124.66
Malaysia 01/06/07 32202.21
Malaysia 01/11/07 27693.98
Malaysia 01/06/08 21022
Malaysia 01/11/08 20442.4
Malaysia 01/06/09 20442.4
Malaysia 01/11/09 20442.4
Malaysia 01/06/14 201940.5
Malaysia 01/11/14 201940.5
Mexico 01/06/05 8618.6
Mexico 01/11/05 6078
Mexico 01/11/06 5090
Mexico 01/06/07 9794
Mexico 01/11/08 18480
Mexico 01/06/09 18480
Mexico 01/11/12 92282.1
Netherlands 01/06/05 33320.37
Netherlands 01/11/05 33320.37
Netherlands 01/06/06 33484.5
Netherlands 01/11/06 31113.5
Netherlands 01/06/07 75637
Netherlands 01/11/07 65154.2
Netherlands 01/06/08 109568
Netherlands 01/11/08 111505.7
Netherlands 01/06/09 111505.7
Netherlands 01/11/09 110652.7
Netherlands 01/06/10 137902.7
Netherlands 01/11/10 83202.7
Netherlands 01/06/11 50923.9
Netherlands 01/06/13 258034
Netherlands 01/11/13 511071
Netherlands 01/06/14 1005526.7
Netherlands 01/11/14 1835372.7
New Zealand 01/06/05 7807
New Zealand 01/11/05 9882.65
New Zealand 01/06/06 9882.65
New Zealand 01/11/06 3755
New Zealand 01/06/07 9433
New Zealand 01/11/07 9433
New Zealand 01/06/08 75871.3
New Zealand 01/11/08 109109.2
New Zealand 01/06/09 157639
New Zealand 01/11/09 233222
New Zealand 01/06/10 211316.3
New Zealand 01/11/10 157639
Norway 01/11/05 4024.8
Norway 01/11/06 17472.71
Norway 01/06/07 13767.41
Norway 01/11/07 28238.71
Norway 01/06/08 68734.9
Norway 01/11/08 72454
Norway 01/06/09 72454
Norway 01/11/09 72454
Norway 01/06/10 72454
Norway 01/11/10 107747.5
Norway 01/06/11 40590
Norway 01/06/12 735400
Norway 01/11/12 735400
Norway 01/06/13 735400
Norway 01/11/13 735400
Norway 01/06/14 735400
Norway 01/11/14 735400
Philippines 01/06/07 6240
Poland 01/11/07 6356.15
Poland 01/06/08 62015.7
Poland 01/11/08 116998.7
Poland 01/06/09 99961.5
Poland 01/11/09 81391.5
Poland 01/06/10 169040.2
Poland 01/11/10 285440.5
Poland 01/06/11 315074.7
Poland 01/11/11 439119
Poland 01/06/12 474237
Poland 01/11/12 589563
Poland 01/06/13 561203
Poland 01/11/13 455909
Poland 01/06/14 455909
Poland 01/11/14 455909
Portugal 01/06/05 1210
Russia 01/06/05 7851.6
Russia 01/11/05 5355
Russia 01/06/06 6645.53
Russia 01/11/06 9704.53
Russia 01/06/07 31164.53
Russia 01/11/07 82615.43
Russia 01/06/08 164627.7
Russia 01/11/08 222968.1
Russia 01/06/09 261682.1
Russia 01/11/09 646245.5
Russia 01/06/10 814710.1
Russia 01/11/10 867729.7
Russia 01/06/11 1341585.7
Russia 01/11/11 1043069.2
Russia 01/06/12 1293026.7
Russia 01/11/12 1990634
Russia 01/06/13 2012186
Russia 01/11/13 1846612.8
Russia 01/06/14 2046482.8
Russia 01/11/14 4883085.8
Saudi Arabia 01/06/10 310864.9
Saudi Arabia 01/11/10 437434.9
Saudi Arabia 01/06/11 359240
Saudi Arabia 01/11/11 317470
Saudi Arabia 01/06/12 317470
Saudi Arabia 01/11/12 719300
Saudi Arabia 01/06/13 1272515
Saudi Arabia 01/11/13 1165315
Saudi Arabia 01/06/14 1981893.6
Saudi Arabia 01/11/14 1981893.6
Saudia Arabia 01/06/05 9299.86
Saudia Arabia 01/11/05 11965.7
Saudia Arabia 01/06/06 11965.7
Saudia Arabia 01/11/06 11965.7
Saudia Arabia 01/06/07 9216
Saudia Arabia 01/06/09 224875.9
Saudia Arabia 01/11/09 310864.9
Singapore 01/06/05 1191.2
Singapore 01/06/06 6324.3
Singapore 01/11/06 6324.3
Singapore 01/06/07 11600
Singapore 01/11/07 7739.17
Singapore 01/06/09 22801
Singapore 01/11/09 23482
Singapore 01/06/10 32540
Singapore 01/11/10 64957.4
Singapore 01/06/11 94073
Singapore 01/11/11 52633
Singapore 01/06/12 67771.5
Slovak Republic 01/06/12 76533
Slovak Republic 01/11/12 76533
Slovenia 01/06/08 35078.1
Slovenia 01/11/08 36752.5
Slovenia 01/06/09 36752.5
Slovenia 01/11/09 36752.5
Slovenia 01/06/10 36752.5
Slovenia 01/11/10 36752.5
South Africa 01/06/05 2848.1
South Africa 01/11/05 1716.5
South Africa 01/06/06 2204.9
South Africa 01/11/06 5696
South Africa 01/06/07 5591
South Africa 01/11/08 23415
South Africa 01/11/09 25440
South Africa 01/06/10 25440
South Africa 01/11/11 61330
South Africa 01/06/12 61330
Spain 01/06/05 32432
Spain 01/11/05 29770.6
Spain 01/06/06 27910
Spain 01/11/06 91600.2
Spain 01/06/07 97617
Spain 01/11/07 137451.95
Spain 01/06/08 133161.2
Spain 01/11/08 153201.3
Spain 01/06/09 163416.3
Spain 01/11/09 205897.2
Spain 01/06/10 138513
Spain 01/11/10 138513
Spain 01/06/11 135860
Spain 01/11/11 239060
Spain 01/06/12 313449
Spain 01/11/12 740085
Spain 01/06/13 1126860
Spain 01/11/13 1199031
Spain 01/06/14 1199031
Spain 01/11/14 1199031
Sweden 01/06/05 7239
Sweden 01/11/05 4999
Sweden 01/06/06 4999
Sweden 01/11/06 4999
Sweden 01/06/07 50932
Sweden 01/11/07 186176.5
Sweden 01/06/08 268278.5
Sweden 01/11/08 274790.9
Sweden 01/06/09 343447
Sweden 01/11/09 300733.5
Sweden 01/06/10 416016.1
Sweden 01/11/10 367030
Sweden 01/06/11 489530
Sweden 01/11/11 396460
Sweden 01/06/12 528360
Sweden 01/11/12 993201.6
Sweden 01/06/13 1161292.6
Sweden 01/11/13 1067766.7
Sweden 01/06/14 812531
Sweden 01/11/14 2382972
Switzerland 01/06/05 25008
Switzerland 01/11/05 34368
Switzerland 01/06/06 36636
Switzerland 01/11/06 47682
Switzerland 01/06/07 60251
Switzerland 01/11/07 74568.46
Switzerland 01/06/08 80899
Switzerland 01/11/08 81565
Switzerland 01/06/09 184945
Switzerland 01/11/09 346885
Switzerland 01/06/10 346885
Switzerland 01/11/10 317895
Switzerland 01/06/11 317895
Switzerland 01/11/11 409690
Switzerland 01/06/12 316200
Switzerland 01/11/12 978980
Switzerland 01/06/13 1405767
Switzerland 01/11/13 7765418
Switzerland 01/06/14 7959572
Switzerland 01/11/14 8904372
Taiwan 01/06/05 4088.7
Taiwan 01/11/05 7561.6
Taiwan 01/06/06 7561.6
Taiwan 01/11/06 5534.6
Taiwan 01/06/07 66680
Taiwan 01/11/07 102966.35
Taiwan 01/06/08 45677
Taiwan 01/11/08 33592
Taiwan 01/06/09 19910
Taiwan 01/06/11 220504.4
Taiwan 01/11/11 247530
Taiwan 01/06/12 340955.2
Taiwan 01/11/12 356625.2
Taiwan 01/06/13 177100
Taiwan 01/11/13 177100
Taiwan 01/06/14 177100
Taiwan 01/11/14 177100
Turkey 01/11/06 3288.1
Turkey 01/06/07 6067
Turkey 01/11/07 13806.17
Turkey 01/06/10 26783.6
United Arab Emirates 01/11/06 4713
United Arab Emirates 01/06/07 4713
United Arab Emirates 01/06/12 69359.1
England 01/06/05 85558.87
England 01/11/05 124409.32
England 01/06/06 137861.61
England 01/11/06 186419.69
England 01/06/07 326240.22
England 01/11/07 512400.11
England 01/06/08 822304.67
England 01/11/08 921810.1
England 01/06/09 1248013.3
England 01/11/09 1569089.3
England 01/06/10 1785454.4
England 01/11/10 1550664.8
England 01/06/11 1872107.4
England 01/11/11 2771502.98
England 01/06/12 6633642.5
England 01/11/12 7260688.38
England 01/06/13 8082236.56
England 01/11/13 9058328.5
England 01/06/14 14871213.14
England 01/11/14 15366533.16
USA 01/06/05 1045715.68
USA 01/11/05 1569869.79
USA 01/06/06 1779116.76
USA 01/11/06 2270990.47
USA 01/06/07 3079488.55
USA 01/11/07 4164312.4
USA 01/06/08 7012533.44
USA 01/11/08 11181164.5
USA 01/06/09 13720810.2
USA 01/11/09 16416075.5
USA 01/06/10 17969274.7
USA 01/11/10 22295273.6
USA 01/06/11 25265849.4
USA 01/11/11 31674460.73
USA 01/06/12 59975467.14
USA 01/11/12 89105144.74
USA 01/06/13 106833637.96
USA 01/11/13 118261596.09
USA 01/06/14 122452335.88
USA 01/11/14 136696801.55
Venezuela 01/06/05 1198.1
Vietnam 01/06/07 4680
<!DOCTYPE html>
<html lang='en'>
<head>
<meta charset="utf-8">
<title>Small Multiple Choropleth Maps</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<style>
html,
body {
margin: 25;
padding: 0;
}
#vis {
width: 100%;
/*max-width: 960px;*/
margin: 0 auto;
}
#vis div {
float: left;
position: relative;
}
#vis path {
fill: #2ca25f;
stroke: #FFF;
stroke-width: 1px;
}
#vis p.legend {
width: 100%;
text-align: center;
position: absolute;
bottom: 0;
left: 0;
font-weight: bold;
font-size: 11px;
}
</style>
</head>
<body>
<div id='vis'></div>
<script>
var Vis = (function(d3) {
var geojson;
queue()
.defer(d3.json, 'world_countries.json')
.defer(d3.csv, 'country_date_rmax.csv')
.await(visualise);
var width = 400,
height = 250;
var projection = d3.geo.mercator().scale(80).translate([170, 140]),
path = d3.geo.path().projection(projection);
opacity = d3.scale.linear()
.domain([1170, 136696801.55])
.range([0.2, 1]);
function visualise(error, countries, data) {
var visualisationWrapper = d3.select('#vis');
var nested = d3.nest()
.key(function(d) {
return d.Date; // munges the data, grouping entries by date
})
.rollup(function(leaves) { //leaves will be array of data objects
var result = d3.set()
leaves.forEach(function(d) {
result[d.Country] = +d.Rmax; // add value in form Country: Rmax(int)
})
return result
})
.entries(data) // this returns an object. can get Country with nested[0].values[0].Country and Rmax with nested[0].values[0].Rmax -- both strings
//what do we want to feed the forEach method? work this out then use .rollup to spit that out as our nested object
nested.forEach(function(data, i) { // for each row of data, makes a div and calls createMap. But we want to do this with each year, instead.
//debugger; //only for years that equal or greater than 2011
if (data.key == "01/06/11" || data.key == "01/11/11" || data.key == "01/06/12" || data.key == "01/11/12" || data.key == "01/06/13" || data.key == "01/11/13" || data.key == "01/06/14" || data.key == "01/11/14") {
// simply appends a div of prespecified dimensions to the container for each map
var wrapper = visualisationWrapper
.append('div')
.style({
width: width + 'px',
height: height + 'px'
});
// each bit of nested that .forEach spools over needs to
createMap(wrapper, countries, data) // calls create map for each row of the original data... so need to munge this down. countries is the geoJSON, data is the CSV
};
});
}
//what do we need to pass createMap?? the wrapper; that's OK. the countries (geoJSON); that's OK, too. The data needs to be
function createMap(wrapper, geo, data) {
wrapper.append('p')
.text(data.key)
.attr('class', 'legend');
var svg = wrapper.append('svg')
.attr({
width: width,
height: height
});
function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}
svg.selectAll('path')
.data(geo.features)
.enter()
.append('path')
.attr('d', path)
.style('opacity', function(d) { // need to dig rmax out of each country and
//if d.properties.name is in data.values, then set var value to its value
var value = data.values[d.properties.name]// is this right?
if (typeof value == 'number' || value instanceof Number) { // if value is string, return opacity(value), else, return opaciy(0)
return opacity(value);
} else {
return opacity(0.7);
}
})
.attr('class', function(d) { //class of country
return d.properties.name.toLowerCase();
})
.on('mouseenter', function(d, i) {
notify('.' + d.properties.name.toLowerCase(), 'select')
})
.on('mouseleave', function(d) {
notify('.' + d.properties.name.toLowerCase(), 'unselect')
})
.on('select', function(self) {
var geoData = self.data();
self.node().parentNode.parentNode.getElementsByTagName('p')[0].innerHTML = geoData[0].properties.name + ": " + numberWithCommas(data.values[geoData[0].properties.name]);
})
.on('unselect', function(self) {
self.node().parentNode.parentNode.getElementsByTagName('p')[0].innerHTML = data.key;
});
function notify(selector, eventName) {
d3.selectAll(selector)[0].forEach(function(el, i) {
var shape = d3.select(el);
shape.on(eventName)(shape);
});
};
}
})(d3);
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment