Skip to content

Instantly share code, notes, and snippets.

@cpudney
Last active August 29, 2015 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cpudney/5e50d1db00f90542d415 to your computer and use it in GitHub Desktop.
Save cpudney/5e50d1db00f90542d415 to your computer and use it in GitHub Desktop.
D3.js Voronoi Line Selection
function lineChart() {
var margin = {top: 30, right: 300, bottom: 30, left: 30},
width = 1024,
height = 480,
xValue = function (d) {
return d[0];
},
yValue = function (d) {
return d[1];
},
labels = function (d) {
return d[2];
},
tag = function (d, i) {
return "tag_" + i;
},
xScale = d3.time.scale(),
yScale = d3.scale.linear(),
line = d3.svg.line().x(X).y(Y),
xAxis = d3.svg.axis().scale(xScale).orient("bottom").tickSize(6, 0),
yAxis = d3.svg.axis().scale(yScale).orient("left").tickSize(6, 0);
function chart(selection) {
selection.each(function (data) {
// Convert data to standard representation greedily;
// this is needed for non-deterministic accessors.
data = data.map(function (d, i) {
var x = xValue.call(data, d, i);
var y = yValue.call(data, d, i);
return {
label: labels.call(data, d, i),
data: x.map(function (d, i) {
return [x[i], y[i]];
})
};
});
// Concatenate x and y values (for scale definition).
var x = data.reduce(function (prev, cur, i, d) {
return prev.concat(cur.data.map(function (d) {
return d[0];
}))
}, []);
var y = data.reduce(function (prev, cur, i, d) {
return prev.concat(cur.data.map(function (d) {
return d[1];
}))
}, []);
// Update the x-scale.
xScale
.domain(d3.extent(x))
.range([0, width - margin.left - margin.right]);
// Update the y-scale.
yScale
.domain([0, d3.max(y)])
.range([height - margin.top - margin.bottom, 0]);
// Select the svg element, if it exists.
var svg = d3.select(this).selectAll("svg").data([1]);
// Otherwise, create the skeletal chart.
var gEnter = svg.enter().append("svg").append("g");
gEnter.append("g").attr("class", "x axis");
gEnter.append("g").attr("class", "y axis");
// Update the outer dimensions.
svg.attr("width", width)
.attr("height", height);
// Update the inner dimensions.
var g = svg.select("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
// Plot lines (base).
g.selectAll("path.results")
.data(data.map(function (d) {
return d.data;
}))
.enter()
.append("svg:path")
.attr("d", line);
// Replot lines (highlighted; in front of base).
g.selectAll("path.results")
.data(data.map(function (d) {
return d.data;
}))
.enter()
.append("svg:path")
.attr("class", "highlight")
.attr("id", tag)
.attr("d", line)
.style("opacity", 0.0)
.on("mouseover", function (d, i) {
d3.selectAll("#" + tag(d, i)).style("opacity", 1.0);
})
.on("mouseout", function (d, i) {
d3.selectAll("#" + tag(d, i)).style("opacity", 0.0);
});
// Plot labels.
g.selectAll("text.label.yaxis")
.data(data)
.enter()
.append("svg:text")
.attr("class", "label yaxis")
.attr("id", tag)
.attr("text-anchor", "start")
.style("opacity", 0.0)
.attr("dx", "1.0em")
.attr("dy", "0.3em")
.attr("x", xScale.range()[1])
.attr("y", function (d) {
var last = d.data.length - 1;
return last < 0 ? yScale.range[0] : Y(d.data[last]);
})
.text(function (d) {
return d.label;
});
// Update the x-axis.
g.select(".x.axis")
.attr("transform", "translate(0," + yScale.range()[0] + ")")
.call(xAxis);
// Update the y-axis.
g.select(".y.axis")
.attr("transform", "translate(" + xScale.range()[0] + ",0)")
.call(yAxis);
});
}
// The x-accessor for the path generator; xScale ∘ xValue.
function X(d) {
return xScale(d[0]);
}
// The x-accessor for the path generator; yScale ∘ yValue.
function Y(d) {
return yScale(d[1]);
}
chart.margin = function (_) {
if (!arguments.length) return margin;
margin = _;
return chart;
};
chart.width = function (_) {
if (!arguments.length) return width;
width = _;
return chart;
};
chart.height = function (_) {
if (!arguments.length) return height;
height = _;
return chart;
};
chart.x = function (_) {
if (!arguments.length) return xValue;
xValue = _;
return chart;
};
chart.y = function (_) {
if (!arguments.length) return yValue;
yValue = _;
return chart;
};
chart.labels = function (_) {
if (!arguments.length) return labels;
labels = _;
return chart;
};
return chart;
}
// Transform the raw data.
//
function transformData(data) {
// Year format.
var format = d3.time.format("%Y");
// Parse raw data -> x[].
var x = [];
data.forEach(function (d) {
// Process country record.
var usage = [];
var years = [];
var keys = Object.keys(d);
keys.forEach(function (k) {
if (k != 'Country') {
// Parse usage.
var use = +d[k];
if (use) {
years.push(format.parse(k));
usage.push(use);
}
}
});
x.push({
'Country': d.Country,
'Years': years,
'Usage': usage
});
});
return x;
}
// Call-back after reading data.
//
function display(error, data) {
if (error) {
console.log(error);
return;
}
//console.log(transformData(data));
var chart = lineChart()
.labels(function (d) {
return d.Country;
})
.x(function (d) {
return d.Years
})
.y(function (d) {
return d.Usage
});
d3.select("#chart").datum(transformData(data)).call(chart);
}
// Read the data file.
queue()
.defer(d3.csv, "Individuals_Internet_2000-2013.csv")
.await(display);
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>Global Internet Use 2000 – 2013</title>
<link href="style.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
</head>
<body>
<h1>Global Internet Use 2000 – 2013</h1>
<p class="instructions">
This chart visualizes ...
<a href="http://www.vislives.com/2015/02/triple-j-hottest-100-artists-1993-2014.html" target="_blank">More...</a>
</p>
<div id="chart"></div>
<p><a href="http://vislives.com/" target="_blank">Chris Pudney</a>, 2015<br/>
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by/4.0/">Creative Commons
Attribution 4.0 International License</a><br/>
<a rel="license" href="http://creativecommons.org/licenses/by/4.0/"><img alt="Creative Commons License"
style="border-width:0"
src="http://i.creativecommons.org/l/by/4.0/80x15.png"/></a>
</p>
<script src="chart.js" type="text/javascript"></script>
</body>
Country 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013
Afghanistan 0.0047225682 0.0045613952 0.0878912529 0.10580903 1.2241480837 2.1071236455 1.9 1.84 3.55 4 5 5.4545454545 5.9
Albania 0.1140973466 0.3257983771 0.3900812734 0.9719004152 2.4203877978 6.043890864 9.6099913158 15.0361154084 23.86 41.2 45 49 54.6559590399 60.1
Algeria 0.4917056791 0.6461140167 1.5916412604 2.1953597309 4.6344750878 5.843942092 7.3759849563 9.4511906256 10.18 11.23 12.5 14 15.2280267564 16.5
American Samoa
Andorra 10.5388356092 11.260468717 13.5464128764 26.8379543895 37.6057662175 48.9368469989 70.87 70.04 78.53 81 81 86.4344246167 94
Angola 0.1050455625 0.1360138674 0.2703767456 0.3706820652 0.464814618 1.1433668266 1.9076475072 3.2 4.6 6 10 14.776 16.9372101137 19.1
Anguilla 22.4054490052 25.8843830889 24.8036378669 24.5233763152 25.0436366396 29 36 41 44 48 49.6 53.64 59.2149831732 64.8
Antigua & Barbuda 6.482225737 8.8992855145 12.5 17.2286487817 24.2665437162 27 30 34 38 42 47 53 59 63.4
Argentina 7.0386830862 9.7808072853 10.8821243775 11.913696551 16.0366841055 17.7205833696 20.9272021036 25.9466329404 28.11262348 34 45 51 55.8 59.9
Armenia 1.3004700224 1.6310946668 1.9604050458 4.5752172248 4.8990085713 5.252983352 5.6317877773 6.0212533971 6.21 15.3 25 32 39.16 46.3
Aruba 15.442822948 17.1 18.8 20.8 23 25.4 28 30.9 52 58 62 69 74 78.9
Ascension 34.9378881988 38.1679389313 33 33 33 35 36 41.03
Australia 46.7561156117 52.689266431 63 66 69.45 71.67 74.25 76 79.4876977139 79 83
Austria 33.7301329517 39.1854501811 36.56 42.7 54.28 58 63.6 69.37 72.87 73.45 75.17 78.7399930987 80.029993917 80.6188
Azerbaijan 0.1477575756 0.3055646376 4.9997136781 8.0303753562 11.9921773344 14.54 17.08 27.4 46 50 54.2 58.7
Bahamas 8 11.8 18 20 22 25 26 27 31.54 33.88 43 65 71.7482028147 72
Bahrain 6.1537325465 15.0386342514 18.0507208881 21.5549449918 21.4586805077 21.3037335137 28.2439524318 32.91 51.95 53 55 76.9999665032 88 90
Bangladesh 0.0710394231 0.1298079739 0.1399202885 0.1638776655 0.1990363337 0.2416373256 1 1.8 2.5 3.1 3.7 5 5.75 6.5
Barbados 3.9736783546 11.9364503384 27.8363224241 39.689627116 49.8 52.5 55.3 58.2 61.4 64.7 68.1 71.7657 73.3298136924 75
Belarus 1.8603981262 4.3006160215 8.9509713147 16.2 19.7 23 27.43 31.8 39.6488956599 46.91 54.17
Belgium 29.4316916924 31.2883955057 46.33 49.97 53.86 55.82 59.72 64.44 66 70 75 81.6099959956 80.7199905482 82.1702
Belize 5.9638353027 5.6842512136 5.7936168826 9.2102886009 10.4016781374 10.86 11.31 11.73 14 18.7 25 31.7
Benin 0.2252478515 0.36341789 0.7029455951 0.9513271149 1.1825409652 1.2710314395 1.5378543462 1.79 1.85 2.24 3.13 4.1483230656 4.5 4.9
Bermuda 42.9498600153 47.5096998971 52.03159737 56.5220121836 60.9908670086 65.4470657899 69.8996551617 74.3505940303 82.3 83.25 84.21 88.336 91.2993045243 95.3
Bhutan 0.4009444469 0.8646285642 1.6758025838 2.4369123995 3.1569841961 3.8471067449 4.5183172582 5.92 6.55 7.17 13.6 21 25.43 29.9
Bolivia 1.4427635848 2.1204625341 3.117192947 3.5085964007 4.4399246012 5.2275839566 6.2006712547 10.4992443169 12.5 16.8 22.4 30 35.5 39.5
Bosnia and Herzegovina 1.0829607497 1.2005269513 2.6482679136 3.9650368339 15.4689716228 21.3267010008 25.1223856852 27.92 34.66 37.74 52 60 65.3560944773 67.9
Botswana 2.9026666218 3.430886787 3.3859223506 3.3451901741 3.3048892532 3.2625540361 4.2899329752 5.28 6.25 6.15 6 8 11.5 15
Brazil 2.8706851585 4.528494869 9.1494250856 13.2075861035 19.0736722744 21.0227472488 28.1783801798 30.88 33.83 39.22 40.65 45.69 48.56 51.6
British Virgin Islands 18.8857412653 36 37 32.5
Brunei Darussalam 8.9962845345 12.9177690823 15.3298798557 19.5950032207 29.7156041448 36.4663919476 42.1863491609 44.68 46 49 53 56 60.2730650423 64.5
Bulgaria 5.3709234691 7.6122977488 9.08 12.04 18.13 19.97 27.09 33.64 39.67 45 46.23 47.9799930506 51.8999876659 53.0615
Burkina Faso 0.0770801689 0.1577324647 0.2009925979 0.3734403032 0.4002952855 0.4699144887 0.6327075645 0.75 0.92 1.13 2.4 3 3.725034916 4.4
Burundi 0.0772484474 0.1060012454 0.1182284123 0.2012731967 0.3490604619 0.5421428658 0.6575925904 0.7 0.81 0.9 1 1.11 1.2199999448 1.3
Cambodia 0.0470226401 0.0769560556 0.2269832377 0.2605701976 0.3004366444 0.3173217811 0.4683567201 0.49 0.51 0.53 1.26 3.1 4.94 6
Cameroon 0.2521200777 0.2770513218 0.3608715843 0.5876226111 0.9760754155 1.4026542258 2.0287447915 2.93 3.4 3.84 4.3 5 5.6989872404 6.4
Canada 51.3 60.2 61.5932992682 64.2 65.9559634649 71.66 72.4 73.2 76.7 80.3 80.3 83 83 85.8
Cape Verde 1.8224438516 2.6853327127 3.518757175 4.3248853905 5.3188320696 6.0740871066 6.8089110075 8.2832198195 14 21 30 32 34.74 37.5
Cayman Islands 38.0343830823 44.5 52 61 64.5 66 69.46594499 74.1265306873 74.1
Central African Rep. 0.0533941742 0.0785434278 0.1285371165 0.1515633379 0.2234013955 0.2681956092 0.3111591732 0.375815961 1 1.8 2 2.2 3 3.5
Chad 0.0357070763 0.0459341344 0.1660696647 0.3203085554 0.360920107 0.3992577001 0.5810457642 0.8472245207 1.19 1.5 1.7 1.9 2.1000000001 2.3
Chile 16.6 19.1 22.1 25.4737788865 28.1779101232 31.1753470304 34.4977511736 35.9 37.3 41.56 45 52.2496072878 61.4181545578 66.5
China 1.7759132068 2.6396502149 4.5957043308 6.2 7.3 8.5232570027 10.5231526194 16 22.6 28.9 34.3 38.3 42.3001174856 45.8
Cocos Keeling Islands
Colombia 2.2075329926 2.8541999713 4.6 7.3889237105 9.118690303 11.0072638905 15.3416745366 21.8 25.6 30 36.5 40.3509157546 48.98 51.7
Comoros 0.2717406073 0.4430683725 0.554869675 0.8481893702 1.3273271779 2 2.2 2.5 3 3.5 5.1 5.5 5.9752963084 6.5
Congo (Dem. Rep.) 0.0059021137 0.0114757819 0.0927907025 0.1349148374 0.1962083752 0.2380377987 0.2960536103 0.37 0.44 0.56 0.72 1.2 1.6799610146 2.2
Congo (Rep.) 0.0263547321 0.0322236164 0.1572495172 0.4600141868 1.0775049296 1.4634200595 2.0079900794 2.7597043737 4.2875099028 4.5 5 5.6 6.1066950244 6.6
Costa Rica 5.8002530233 9.559482135 19.8948511346 20.3336148144 20.7923067056 22.07 25.1 28.4 32.29 34.33 36.5 39.2121959962 47.5 45.96
Côte d'Ivoire 0.2314616706 0.3957477022 0.4979293608 0.7586696295 0.8492824147 1.0392382051 1.5249007912 1.8 1.9 2 2.1 2.2 2.3789580299 2.6
Croatia 6.6448825437 11.5585731812 17.76 22.75 30.91 33.14 37.98 41.44 44.24 50.58 56.55 57.7899789891 61.9399731528 66.7476
Cuba 0.5411825488 1.0797517219 3.7705850377 5.2412690537 8.407984759 9.7380622078 11.1596013148 11.69 12.94 14.33 15.9 16.0172907996 25.6417038675 25.7089320853
Cyprus 15.255394371 18.8187590408 28.32 30.09 33.83 32.81 35.83 40.77 42.31 49.81 52.99 56.8598923504 60.6898684002 65.4548
Czech Republic 9.7805278883 14.6971721171 23.93 34.3 35.5 35.27 47.93 51.93 62.97 64.43 68.82 70.49 73.4300078241 74.1104
D.P.R. Korea 0 0 0 0 0 0 0 0 0 0 0 0 0
Denmark 39.1724308555 42.9575247202 64.25 76.26 80.93 82.74 86.65 85.03 85.02 86.84 88.72 89.8100133895 92.2600117153 94.6297
Djibouti 0.1945005284 0.343526263 0.4869717045 0.6259402294 0.7813171751 0.9536114493 1.2700411592 1.62 2.26 4 6.5 7 8.267232892 9.5
Dominica 8.8148441976 13.2452280387 18.4248927671 23.620419853 30.3196130922 38.5436432638 39.3981743035 40.2744630072 41.16 42.02 47.45 51.3135 55.1770141639 59
Dominican Rep. 3.7046923559 4.4293906967 6.8237257326 7.8983929372 8.8655534607 11.4831977789 14.8449283655 17.66 20.82 27.72 31.4 38 41.2 45.9
Ecuador 1.4621885356 2.6704436738 4.2607969152 4.4602283447 4.8344426376 5.994255161 7.2 10.8 18.8 24.6 29.03 31.3668083587 35.1351464546 40.3536842279
Egypt 0.6412650375 0.8389456115 2.7199997147 4.0378851071 11.92 12.75 13.66 16.03 18.01 25.69 31.42 39.83 44 49.56
El Salvador 1.1773972691 1.5 1.9 2.5 3.2 4.2 5.5 6.11 10.08 12.11 15.9 18.9 20.3213877242 23.1093
Equatorial Guinea 0.1323546651 0.1652604229 0.3211979972 0.520524272 0.8439302846 1.1497896706 1.2791935964 1.5571230594 1.82 2.13 6 11.5 13.9431821913 16.4
Eritrea 0.1367119411 0.1578152893 0.2270901376 0.41 0.47 0.54 0.61 0.7 0.8 0.9
Estonia 28.5769538106 31.5274897674 41.52 45.32 53.2 61.45 63.51 66.19 70.58 72.5 74.1 76.5 78.3899259259 80.0043
Ethiopia 0.0152637672 0.0371623811 0.0724022619 0.1058116588 0.1553345208 0.219659819 0.3105926569 0.37 0.45 0.54 0.75 1.1 1.4828101386 1.9
Falkland (Malvinas) Is. 58.6206896552 64.6038762326 64.1458474004 64.0161725067 67.3174015483 84.0053763441 87.1021775544 90.06 92.96 95.84 95.84 96.38 96.923042571 96.9
Faroe Islands 32.9163923634 43.2469835229 53.2992218314 58.9126409695 66.5335994677 67.9026317414 69.3594451244 75.98 75.57 75.18 75.2 80.7321728 85.3351892392 90
Fiji 1.496854734 1.8579785936 6.1526497001 6.7254347382 7.4129434854 8.4536366337 9.6000384002 10.8978310455 13 17 20 28 33.7423567521 37.1
Finland 37.2484617371 43.1053633522 62.43 69.22 72.39 74.48 79.66 80.78 83.67 82.49 86.89 88.7099949135 89.8799979742 91.5144
France 14.3079239431 26.3259035522 30.18 36.14 39.15 42.87 46.87 66.09 70.68 71.58 77.28 77.8199989927 81.44 81.9198
French Polynesia 6.3570635452 6.2515889455 8.2002164857 14.1242937853 17.8845374264 21.5421854743 25.1079642463 28.59 33.87 44.6 49 49 52.8766305868 56.8
Gabon 1.2161406183 1.3476202216 1.9395301062 2.6595865939 2.9790698004 4.8932647497 5.4892008028 5.7670045756 6.21 6.7 7.23 8 8.6167144892 9.2
Gambia 0.9217949191 1.3367911665 1.796779883 2.4367811931 3.3080034781 3.7990011388 5.2376911584 6.2050374185 6.88 7.63 9.2 10.8703 12.4492287209 14
Georgia 0.4847462985 0.9923444361 1.5878756298 2.5588164807 3.8862213535 6.0794576287 7.5268768449 8.26 10.01 20.07 26.9 31.52 36.94 43.1
Germany 30.2163466049 31.6509394163 48.82 55.9 64.73 68.71 72.16 75.16 78 79 82 81.269999536 82.3499984738 83.9614
Ghana 0.1536152976 0.2000080603 0.8302840338 1.193057911 1.7167977039 1.831197461 2.7231759731 3.85 4.27 5.44 7.8 14.11 12.3 12.3
Gibraltar 19.1316381249 21.171109436 23.6702397457 28.3257797921 32.8860826098 39.0701308849 45.2986475118 51.61 58 65.07 65 65 65.017
Greece 9.1388373078 10.935025808 14.67 17.8 21.42 24 32.25 35.88 38.2 42.4 44.4 51.6499951677 55.0699934418 59.8663
Greenland 31.7478112321 35.4641368916 44.1547890284 54.5342598294 56.0990147611 57.7034045009 59.3616872687 61.07 62.82 62.83 63 64 64.8960100996 65.8
Grenada 4.0639079915 5.1281039822 14.7588405455 18.6451821831 19.5706205844 20.487804878 21.3959911693 22.29 23.18 24.05 27 30 32 35
Guam 16.1131270423 25.3802275337 31.1922942556 33.7166817881 36.1617878388 38.5598775576 43.8514430048 46.1504736192 48.4187021509 50.642028382 54.04 57.7 61.5341593079 65.4
Guatemala 0.7123329045 1.7382017816 3.3917462702 4.5488549085 5.1 5.7 6.5 7.3 8.3 9.3 10.5 12.3 16 19.7
Guernsey 31.8979266348 44.4657880227 53.5714285714 59.1397849462 64.5161290323 73.571024335 83.6320191159 83.632
Guinea 0.0954249236 0.1755418685 0.4020227487 0.4509603708 0.5088193323 0.542254181 0.637492123 0.7800252791 0.92 0.94 1 1.3 1.4901443657 1.6
Guinea-Bissau 0.2301031706 0.2995691447 1.0229932344 1.3541974776 1.8081422034 1.9013653161 2.0571967045 2.2063022375 2.3548887109 2.3032805917 2.45 2.672 2.8939906209 3.1
Guyana 6.6114915657 13.2069864959 13.8 18.2 23.9 29.9 31 33 33
Haiti 0.2312707146 0.3408323262 0.8934329883 1.6473583456 5.4012619076 6.376201635 6.7960004805 7.2 7.6 8.1 8.37 9 9.8 10.6
Honduras 1.2038559989 1.4152819312 2.5974025974 4.8 5.6 6.5 7.8 9.4 9.6 9.8 11.09 15.9 18.12 17.8
Hong Kong, China 27.8277606813 38.671403231 43.0823830279 52.2000433497 56.3998803935 56.9 60.8 64.8 66.7 69.4 72 72.2 72.9 74.2
Hungary 6.9996763506 14.5285543028 16.67 21.63 27.74 38.97 47.06 53.3 61 62 65 68.0199878861 70.5799981538 72.6439
Iceland 44.4705338243 49.3929953676 79.12 83.14 83.88 87 89.51 90.6 91 93 93.39 94.8196868009 96.2097995546 96.5468
India 0.5275324499 0.660146377 1.5378755818 1.6864899706 1.9761364919 2.388075 2.8054998653 3.95 4.38 5.12 7.5 10.07 12.5800609139 15.1
Indonesia 0.9255638645 2.0186138595 2.134135733 2.3870197796 2.6002858763 3.6020247626 4.7648131337 5.7862747293 7.9174793849 6.92 10.92 11.11 14.7 15.82
Iran (I.R.) 0.93419002 1.4842213316 4.6261751149 6.933721953 7.49 8.1 8.76 9.47 10.24 11.07 14.7 21 27.5 31.4
Iraq 0.1 0.5 0.6 0.9 0.9 0.9523442438 0.93 1 1.06 2.5 5 7.1 9.2
Ireland 17.8504672406 23.1388121904 25.85 34.31 36.99 41.61 54.82 61.158324551 65.34 67.38 69.85 74.8899729671 76.9199925401 78.2477
Israel 20.8737899982 17.3786238639 17.764599063 19.593393658 22.7704855254 25.1940424217 27.8810744577 48.1280621948 59.39 63.12 67.5 68.8738779907 70.8 70.8
Italy 23.1108742441 27.2221169789 28.04 29.04 33.24 35 37.99 40.79 44.53 48.83 53.68 54.3899983019 55.8299979933 58.4593
Jamaica 3.1157780273 3.8630203875 6.1 7.8 10 12.8 16.4 21.1 23.6 24.3 27.67 37.4386134148 33.79 37.8
Japan 29.9907403589 38.5320608613 46.594201118 48.43526589 62.3939296327 66.9210661043 68.6852703214 74.3 75.4 78 78.21 79.0541135245 86.25 86.25
Jersey 9.2187139894 16.0576239304 19.4063926941 22.7272727273 30.6818181818 31.25 31.8181818182 32.3863636364 36 41.03
Jordan 2.6232754216 4.7057195809 6.0255324119 8.4660050162 11.6587413706 12.9328520458 13.8671087882 20 23 26 27.2 34.9 41 44.2
Kazakhstan 0.6685944026 1.006124211 1.6747709952 2.0004147527 2.650394657 2.9617074915 3.2683690512 4.02 11 18.2 31.6 50.6 53.3156691222 54
Kenya 0.3180597136 0.6197822662 1.2077738849 2.941902861 3.0235280421 3.1018977025 7.5337897198 7.95 8.67 10.04 14 28 32.1 39
Kiribati 1.785225474 2.3374589484 2.5 3 3.5 4 4.5 6 7 8.97 9.07 10 10.7467976842 11.5
Korea (Rep.) 44.7 56.6 59.4 65.5 72.7 73.5 78.1 78.8 81 81.6 83.7 83.7591201534 84.0732264957 84.77
Kuwait 6.7313957684 8.5517924343 10.2489679289 22.4029383805 22.927112036 25.9261083689 28.791197955 34.8 42 50.8 61.4 65.7690706867 70.45 75.46
Kyrgyzstan 1.0414011447 3.0029413272 2.99926518 3.9087662683 5.0903853073 10.5338013406 12.3069069959 14.03 15.7 17 18.4 20 21.72 23.4
Lao P.D.R. 0.1110440323 0.1816644607 0.2678992413 0.3339124664 0.3614344903 0.8503574903 1.1698934277 1.64 3.55 6 7 9 10.7476761891 12.5
Latvia 6.3190620827 7.2193458084 21.94 26.98 38.58 46 53.63 59.17 63.41 66.84 68.42 69.7499545592 73.1199437664 75.2344
Lebanon 7.9527437364 6.7832197753 7 8 9 10.14 15 18.74 22.53 30.14 43.68 52 61.2497857183 70.5
Lesotho 0.2118060704 0.2611500631 1.0839431374 1.5324965902 2.1755243393 2.5802454842 2.9797081872 3.4454312597 3.58 3.72 3.86 4.2248 4.58961763 5
Liberia 0.0177027057 0.0338122272 0.0327133071 0.0318689345 0.0310111848 0.5513765806 0.53 0.51 2.3 3 3.7941 4.6
Libya 0.1870426223 0.3665331753 2.2444182217 2.8145179874 3.5328381615 3.9177879771 4.3010517891 4.7219993785 9 10.8 14 14 16.5
Liechtenstein 36.5152298938 45.1168526484 59.470710675 58.8096918372 64.0074481394 63.371356147 64.2141613631 65.0802184432 70 75 80 85 89.4077 93.8
Lithuania 6.4270674948 7.1793569938 17.69 25.91 31.23 36.22 43.9 49.9 55.22 59.76 62.12 63.6399774002 67.2299893276 68.4529
Luxembourg 22.8873279731 36.1634225063 39.84 54.55 65.88 70 72.51 78.92 82.23 87.31 90.62 90.0298585647 91.9499237417 93.7765
Macao, China 13.6085897418 22.5212167701 25.1718801643 25.7421239826 31.4840973824 34.8629271734 46.4 47.327 49.24 54 55.198 60.2036967182 61.31 65.8
Madagascar 0.196394691 0.2225115862 0.3397201546 0.4232524193 0.5253536549 0.5677218022 0.6075522389 0.65 1.65 1.63 1.7 1.9 2.0549 2.2
Malawi 0.1267809448 0.1640207253 0.2150947265 0.2788151163 0.347505335 0.3844893341 0.4251374896 0.9658647366 0.7 1.07 2.26 3.33 4.3506 5.4
Malaysia 21.3847311645 26.6959725007 32.3382043389 34.9711523397 42.2522656295 48.629170246 51.6379889864 55.7 55.8 55.9 56.3 61 65.8 66.97
Maldives 2.2038729394 3.6172906493 5.3477651689 5.9765928499 6.5882548753 6.869605067 11.0363527829 16.3 23.2 24.8 26.53 34 38.9301 44.1
Mali 0.142545755 0.1858974133 0.2270455785 0.3103644432 0.4328196399 0.507063136 0.7296272808 0.81 1.57 1.8 1.9 2 2.1689 2.3
Malta 13.1137087111 17.8778483243 28.92 31.64 34.62 41.24 40.41 46.9 50.08 58.86 63 68.0198237885 68.1998742929 68.9138
Marshall Islands 1.5342717962 1.7066140777 2.3354445752 2.5697503671 3.5997768138 3.8787023977 3.7955902143 3.95 4.6 5.6 7 8.06 10 11.7
Mauritania 0.1920314624 0.261448552 0.3632294146 0.4240048958 0.4814704382 0.6699664749 0.9796612527 1.4336131959 1.87 2.28 4 4.5 5.3691 6.2
Mauritius 7.281535115 8.7809040189 10.2526246719 12.1871062041 13.6890885885 15.1722287525 16.7 20.22 21.81 22.51 28.33 34.95 35.42 39
Mayotte 1.2115338018
Mexico 5.0813841534 7.0380231165 11.9 12.9 14.1 17.21 19.52 20.81 21.71 26.34 31.05 37.1762954125 39.75 43.46
Micronesia 3.7348621369 4.6605271988 5.5700997048 9.2325021004 11.0178673082 11.8813690993 12.7503392501 13.6211327334 14.49 15.35 20 22.8 25.974423003 27.8
Moldova 1.2828464167 1.4878129522 3.7872427989 7.4075445842 10.6293908417 14.6302704552 19.6206477052 20.45 23.39 27.5 32.3 38 43.37 48.8
Monaco 42.184863446 46.646142364 48.047117173 49.4911689195 52.4901966839 55.4648260561 61.4760397135 64.3776824034 67.25 70.1 75 80.3 87 90.7
Mongolia 1.2556520036 1.6532382391 2.0395726035 9 9.8 10 10.2 12.4999911085 16.4 17.7
Montenegro 25.3500686036 27.1 28.9 30.8 32.9 35.1 37.5 35.611541246 56.8387825491 56.8
Montserrat 25.9112109173 20.4255319149 20.32 20.26 35 54.5509955303 54.6
Morocco 0.6937912448 1.371438101 2.3732531924 3.3533666812 11.607934773 15.084444524 19.7711915653 21.5 33.1 41.3 52 46.107482597 55.4160531915 56
Mozambique 0.10959253 0.1600319466 0.2596126113 0.4195388439 0.6794478354 0.8543571181 0.842954488 0.91 1.56 2.68 4.17 4.3 4.8491 5.4
Myanmar 0.0002892774 0.0004264935 0.0240641491 0.024337392 0.0652388555 0.1820483311 0.2171284451 0.22 0.22 0.25 0.98 1.0691 1.2
Namibia 1.6447395473 2.4169794417 2.6336997688 3.3598398855 3.8047156153 4.0100466444 4.3988706473 4.8356107783 5.3290037721 6.5 11.6 12 12.9414 13.9
Nauru 2.9871552325 54
Nepal 0.2046516837 0.2400153034 0.3129560601 0.382810917 0.4498436512 0.8265512659 1.1413891639 1.41 1.73 1.97 7.93 9 11.1493 13.3
Neth. Antilles
Netherlands 43.9843513731 49.3730621073 61.29 64.35 68.52 81 83.7 85.82 87.42 89.63 90.72 91.4199957622 92.8599923595 93.9564
New Caledonia 13.9395488233 18.2371097828 22.3897974171 26.4083344704 30.2980462088 32.3590147532 33.5157146807 35.05 34.51 33.99 42 50 58 66
New Zealand 47.3795565432 53.2410152941 59.0807532813 60.9625398664 61.8476278106 62.720212369 69 69.76 72.03 79.7 80.46 81.23 82 82.78
Nicaragua 0.9802164867 1.4487994282 1.7147295843 1.8804125324 2.3206646086 2.5663511766 2.8055730627 3.9 5.3 7.3 10 10.6 13.5 15.5
Niger 0.0362612938 0.1051854314 0.1271524688 0.1556987037 0.1899337337 0.2213413515 0.2940339771 0.3903906198 0.7 0.76 0.83 1.3 1.4077 1.7
Nigeria 0.0640808079 0.0899013705 0.3204619755 0.5585762449 1.2861376413 3.549155718 5.545036083 6.77 15.86 20 24 28.43 32.8 38
Niue 26.5111346766 32.6619488296 39.1498881432 43.1282346176 47.3372781065 51.703163017 56.25 61.0147719974 65.9195781147 74.4752877454 76.97 79.56 82.2245316335 86.9
Norfolk Islands
Northern Marianas
Norway 52 64 72.84 78.13 77.69 81.99 82.55 86.93 90.57 92.08 93.39 93.4899826515 94.6499780533 95.0534
Oman 3.5204214165 5.8938415215 6.8733960392 7.2557429454 6.7588521702 6.6835814202 8.2997166725 16.68 20 26.8 35.8278 48 60 66.45
Pakistan 1.3185507793 2.5774267368 5.0411581259 6.1643209853 6.3323290983 6.5 6.8 7 7.5 8 9 9.96 10.9
Palau 20.2439394706 21.6015271777 26.9703326341
Palestine 1.1113062071 1.8368548392 3.1000922351 4.1306163563 4.400904826 16.005 18.41 21.176 24.358 32.23 37.4 41.08 43.4 46.6
Panama 6.5547964773 7.2683998779 8.5180778152 9.9874240772 11.1408625409 11.4840092783 17.3495661696 22.29 33.82 39.08 40.1 42.7 40.301895221 42.9
Papua New Guinea 0.8352493024 0.9041035452 1.3216569349 1.374404668 1.5079127723 1.7161904756 1.7544872607 1.7905593614 1.15 1.61 1.28 2 3.5 6.5
Paraguay 0.7476307115 1.0987938357 1.7949695977 2.1119420821 3.4524384314 7.9070078614 7.9620738839 11.21 14.27 18.9 19.8 24.7635158794 29.34 36.9
Peru 3.0764306114 7.5787629572 8.9669491704 11.6 14.1 17.1 20.7 25.2 30.57 31.4 34.77 36.01 38.2 39.2
Philippines 1.9822531961 2.5240056601 4.3322757464 4.8576722671 5.2436284522 5.3976363294 5.7405863253 5.97 6.22 9 25 29 36.2351 37
Poland 7.2854287081 9.9006697074 21.15 24.87 32.53 38.81 44.58 48.6 53.13 58.97 62.32 61.949998969 62.3099972715 62.8492
Portugal 16.4304676924 18.0871365595 19.37 29.67 31.78 34.99 38.01 42.09 44.13 48.27 53.3 55.2499968797 60.3399974868 62.0956
Puerto Rico 10.4746482089 15.6300309162 17.5476475655 19.7070256578 22.1307382347 23.4000504487 25.4424182103 27.86 38 41.5 45.3 48 68.9999826014 73.9
Qatar 4.8636791788 6.1702685609 10.2261289281 19.242336421 20.7016478512 24.7334937811 28.9741127136 37 44.3 53.1 69 69 69.3 85.3
Romania 3.6137172914 4.538669029 6.58 8.9 15 21.5 24.66 28.3 32.42 36.6 39.93 40.009996781 45.8799942529 49.7645
Russian Federation 1.977230109 2.9443677866 4.128271818 8.2988606155 12.8593889008 15.2266731977 18.0232774617 24.66 26.83 29 43 49 63.8 61.4
Rwanda 0.0628314595 0.2406724098 0.2927847188 0.3569184673 0.4308542434 0.5560411648 2.1153871783 4.5 7.7 8 7 8.0238542769 8.7
S. Tomé & Principe 4.6385168164 6.3109178879 7.5806651689 10.161844307 13.3228526892 13.7594842159 14.1820197775 14.5904831987 15.48 16.41 18.75 20.1612 21.5724 23
Samoa 0.5663925327 1.6899028306 2.2448326758 2.7996304488 3.0755294104 3.3525921125 4.4691738732 4.7499832354 5.0316153162 6 7 11 12.92249 15.3
San Marino 48.7994953056 50.3416690899 50.8348399447 50.0034530387 50.5663430421 50.2595641967 50.2086593636 50.3648221089 54.52 54.21 49.6 50.8826 50.8
Saudi Arabia 2.2106918091 4.6810531658 6.3847050196 8.0015828909 10.234532997 12.7050359883 19.4595543514 30 36 38 41 47.5 54 60.5
Senegal 0.4039674859 0.9837940588 1.0064545367 2.1014364299 4.3860239801 4.7866840831 5.6117386522 7.7 10.6 14.5 16 17.5 19.2036 20.9
Serbia 23.5 26.3 27.2 33.15 35.6 38.1 40.9 42.2 48.1 51.5
Seychelles 7.3956291832 11.01510293 14.304170831 14.5925043169 24.272139225 25.4132681463 34.9519711707 38.38 40.44 41 43.16400446 47.076 50.4
Sierra Leone 0.1182542457 0.1602644455 0.1761989568 0.1901732817 0.2030076806 0.2153916103 0.2276694672 0.2398346985 0.25 0.26 0.58 0.9 1.3 1.7
Singapore 36 41.6704251756 47 53.8379432882 62 61 59 69.9 69 69 71 71 72 73
Slovakia 9.4268032006 12.5283218485 40.14 43.04 52.89 55.19 56.08 61.8 66.05 70 75.71 74.4399971747 76.7099901181 77.8826
Slovenia 15.110259564 30.1759104701 27.8388854181 31.854793012 40.81 46.81 54.01 56.74 58 64 70 67.3399948092 68.3499745288 72.6756
Solomon Islands 0.4812968061 0.4685519636 0.5019198434 0.5556098819 0.6496726733 0.8443075728 1.6463479886 2 3 4 5 6 6.9974 8
Somalia 0.02 0.0790391787 0.1156142134 0.3761980025 1.0534547436 1.0773278391 1.1002163681 1.1222356216 1.1426873722 1.1606105425 1.25 1.3767 1.5
South Africa 5.348559732 6.3466193184 6.7103224371 7.0076917261 8.4251186825 7.4885425299 7.6071396748 8.0653751736 8.43 10 24 33.97 41 48.9
South Sudan
Spain 13.624960809 18.1487226903 20.39 39.93 44.01 47.88 50.37 55.11 59.6 62.4 65.8 67.6 69.809999942 71.5719
Sri Lanka 0.6474100109 0.7938218644 1.0504227059 1.4585802284 1.4461599804 1.7920467939 2.537566129 3.88 5.8 8.78 12 15 18.2854 21.9
St. Helena 5.92183182 7.9888156581 10.1255569056 12.3380629241 14.6229371214 15.9100551549 17.2265288544 18.57 18.82 19.07 24.94 33 37.6
St. Kitts and Nevis 5.8628102404 7.7147265558 21.1523817582 22.9697842928 24.7376775444 34 49 52 60 69 76 77.6 79.3488989553 80
St. Lucia 5.0904833414 8.1818639545 14.6418357747 20.9824734633 21.3952123628 21.5675829464 24.5 27.9 32 36 43.3 45 34.82 35.2
St. Pierre & Miquelon
St. Vincent and the Grenadines 3.2450374106 5.0948097783 5.5495948796 6.4622741666 7.371165842 9.1982780823 12 16 21 31 38.5 43.01 47.52 52
Sudan 0.0257850325 0.1401852245 0.4394776391 0.5384717032 0.7915616154 1.292040678 8.66 16.7 17.3039131781 21 22.7
Suriname 2.5064110523 3.0644483887 4.161568745 4.7198753953 6.0760478144 6.4030862876 9.4996269417 14.11 21.06 31.36 31.59 32 34.6812 37.4
Swaziland 0.9261917773 1.2815900505 1.8162038071 2.4370738506 3.2286850732 3.6969610729 3.6965387891 4.1 6.85 8.94 11.04 18.13 20.7817825773 24.7
Sweden 45.6876522122 51.7656649373 70.57 79.13 83.89 84.83 87.76 82.01 90 91 90 92.7699860554 93.1799880065 94.7836
Switzerland 47.1 55.1 61.4 65.1 67.8 70.1 75.7 77.2 79.2 81.3 83.9 85.1930281805 85.2 86.7
Syria 0.1816985801 0.35375913 2.0931010186 3.3979726136 4.3215937779 5.6481060488 7.8325515689 11.5 14 17.3 20.7 22.5 24.3001 26.2
Taiwan, Province of China 28.1011454494 34.9020386361 47.6004912087 51.9364510186 53.8143344639 58.014931928 63.6842105263 64.45 65.84 69.9 71.5 72 75.9908 80
Tajikistan 0.0485995946 0.0512591325 0.055462827 0.0645837772 0.0774799071 0.2986900237 3.7724062067 7.197619518 8.78 10.07 11.55 13.03 14.51 16
Tanzania 0.1171944401 0.1713003507 0.2224844139 0.6769628565 0.877574971 1.1 1.3 1.6 1.9 2.4 2.9 3.5 3.95 4.4
TFYR Macedonia 2.4855663164 3.4681846085 17.33 19.07 24.44 26.45 28.62 36.3 46.04 51.77 51.9 56.7 57.449947313 61.2
Thailand 3.6890412794 5.556326121 7.5312503349 9.2990272381 10.6773033237 15.0260043589 17.1607147169 20.03 18.2 20.1 22.4 23.6699256187 26.46 28.94
Timor-Leste 0 0.0990317678 0.1166282765 0.1409587639 0.1638768156 0.1852515098 0.21 0.9 0.9147 1.1
Togo 0.8 0.9 1 1.2 1.5 1.8 2 2.2 2.4 2.6 3 3.5 4 4.5
Tokelau 1.4958863126
Tonga 2.4343980444 2.8253718391 2.9072973163 2.9858173675 3.9523738946 4.9077827619 5.8539440948 7.179865329 8.1107699438 10 16 25 34.8609 35
Trinidad & Tobago 7.721411474 15.3846272189 21.9986754804 25.9717641092 27.0242700783 28.9767124327 30.0037485792 32.3 34.8 44.3 48.5 55.2 59.5162 63.8
Tunisia 2.750740293 4.2979660347 5.2528872955 6.4908457953 8.5288177516 9.6550865422 12.9864086534 17.1 27.53 34.07 36.8 39.1 41.4416 43.8
Turkey 3.7616850351 5.1894814608 11.38 12.33 14.58 15.46 18.24 28.63 34.37 36.4 39.82 43.0657104309 45.13 46.25
Turkmenistan 0.1332821826 0.1752095177 0.3021320162 0.4251826319 0.7540539827 0.9972565585 1.3195731181 1.4063606881 1.75 1.95 3 5 7.1958 9.6
Turks & Caicos Is.
Tuvalu 5.2416395849 10 15 20 25 30 35 37
Uganda 0.1637140631 0.2379450872 0.384093505 0.4648498401 0.7199706799 1.7422055032 2.5293630383 3.6719653507 7.9 9.78 12.5 13.01354333 14.6896 16.2
Ukraine 0.716183762 1.2387595475 1.8738851164 3.1481275882 3.4894778813 3.7497644147 4.5061245636 6.55 11 17.9 23.3 28.7082628401 35.27 41.8
United Arab Emirates 23.6253008752 26.271754201 28.316485311 29.4779534121 30.1312961695 40 52 61 63 64 68 78 84.9999915049 88
United Kingdom 26.8217543509 33.4810948744 56.48 64.82 65.61 70 68.82 75.09 78.39 83.56 85 85.3799985496 87.4799984242 89.8441
United States 43.0791626375 49.0808315897 58.7854038837 61.6971171244 64.758256476 67.968052915 68.93119327 75 74 71 71.69 69.7294607619 79.3 84.2
Uruguay 10.539057748 11.1214376833 11.4194701967 15.937136716 17.0630983404 20.0881895579 29.4 34 39.3 41.8 46.4 51.4046610564 54.4537686807 58.1
Uzbekistan 0.4843473077 0.5975679939 1.0819397425 1.9125951778 2.5937254208 3.3435098883 6.3883219671 7.4906046814 9.0801145235 17.0582162104 20 30.2 36.5213 38.2
Vanuatu 2.1083368912 2.8305722388 3.5100387107 3.9032958454 4.7466026192 5.0823338077 5.8505850585 6.8 7.2691199234 7.5 8 9.2 10.598 11.3
Vatican
Venezuela 3.3595974645 4.6360009478 4.9104463272 7.4999634652 8.4044695924 12.5529979098 15.2247114772 20.83 25.88 32.7 37.37 40.22 49.050083073 54.9
Viet Nam 0.2542482758 1.2656512361 1.8549992359 3.7802808137 7.6424085284 12.7399292907 17.2545617187 20.755444768 23.92 26.55 30.65 35.07 39.49 43.9
Virgin Islands (US) 13.8150805419 18.3757660397 27.4944323774 27.4290729888 27.377008788 27.3443196733 27.3326105376 27.3393358364 27.3617774211 27.3965096847 31.22 35.6 40.5479 45.3
Wallis and Futuna 4.7680675703 5.0926869016 5.4178518218 5.7416914347 6.0597899273 6.704210244 7.3333333333 7.95 8.22 6.76 8.16 8.68 8.95
Yemen 0.0825003865 0.0908024587 0.5187960321 0.6047341004 0.8812229887 1.0485979342 1.247824049 5.01 6.89 9.96 12.35 14.905 17.4465 20
Zambia 0.1910716425 0.2331295563 0.4777509069 0.9804830394 2.0135495322 2.8517522613 4.1599133939 4.87 5.55 6.31 10 11.5 13.4682 15.4
Zimbabwe 0.4014335352 0.7998460456 3.9943561346 6.3947864585 6.5640450271 8.0159780888 9.7918415019 10.85 11.4 11.36 11.5 15.7 17.09 18.5
body {
font-size: 12px;
font-family: "Helvetica Neue", Helvetica, sans-serif;
}
p.instructions {
width: 500px;
}
line.axis {
stroke: #cccccc;
}
path {
stroke: #cccccc;
fill: none;
}
path.highlight {
stroke: red;
fill: none;
}
#tooltip {
position: absolute;
width: auto;
height: auto;
padding: 10px;
background-color: white;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
pointer-events: none;
}
#tooltip.hidden {
display: none;
}
#tooltip p {
margin: 0;
color: black;
font-family: sans-serif;
font-size: 16px;
line-height: 20px;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment