Skip to content

Instantly share code, notes, and snippets.

@yan2014
Last active November 17, 2015 19:17
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 yan2014/fd8ce631121b048002aa to your computer and use it in GitHub Desktop.
Save yan2014/fd8ce631121b048002aa to your computer and use it in GitHub Desktop.
Week12: Scrollytelling
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<html>
<head>
<title>Scrolling Sections</title>
<link rel="stylesheet" href="main.css" />
</head>
<body>
<body>
<div class="container">
<div id='graphic'>
<div id='sections'>
<section class="step">
<!-- case 0 -->
<div class="title">Child Deaths</div>
Under 5 mortality rates across the world are decreasing from 1990 to 2015.
</section>
<section class="step">
<!-- case 1 -->
<div class="title">Child Deaths Overtime</div>
But the changing patterns are different in different countries.
</section>
<section class="step">
<!-- case 2 -->
<div class="title">Korea DPR</div>
For instance, Korea DPR.
</section>
<section class="step">
<!-- case 3 -->
<div class="title">Brazil</div>
For instance, Brazil.
</section>
<section class="step">
<!-- case 4-->
<div class="title">Pakistan</div>
For instance, Pakistan.
</section>
</div>
<div id="tooltip" class="tooltip">
<h3 class="name"></h3>
<hr>
<div data-metric="urban" class="line">
<div class="urban symbol"></div>Mortality Rate
<div class="urban val"></div>
</div>
</div>
<div id='vis'>
<div class="year">
<input id="slider" type="range" min="1990" max="2015" value="2015" step="1" />
<span id="range">2015</span>
</div>
</div>
<div id='vis1'>
</div>
</div>
<div id="extra-space">
</div>
</div>
</div>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script type="text/javascript" src="https://mkfreeman.github.io/scrolling/js/scroller.js"></script>
<script src="map_chart.js"></script>
<script src="line_chart.js"></script>
<script src="scroller_settings.js"></script>
<script>
onload = function() {
var $ = function(id) { return document.getElementById(id); };
$('slider').oninput = function() { $('range').innerHTML = this.value; };
$('slider').oninput();
};
</script>
</body>
</html>
.axis path,
.axis line {
fill: none;
stroke: none;
shape-rendering: crispEdges;
}
path.line {
fill: none;
stroke-width: 1px;
stroke-opacity: 80%;
}
.line.normal {
stroke: gray;
}
.line.unfocused{
stroke-opacity: 10%;
}
.countries path.focused {
fill: orange;
}
.container {
width: 1290px;
margin: auto;
}
.year{
position: absolute;
top: -33px;
left: 20px;
}
#graphic {
padding-top: 60px;
}
#sections {
position: relative;
display: inline-block;
width: 250px;
top: 0px;
z-index: 90;
padding-bottom: 250px;
}
.step {
margin-bottom: 300px;
font-family: "TiemposTextWeb-Regular","Georgia";
font-size: 16px;
line-height: 23px;
color: #767678;
}
#sections .title {
font-family: Arial,Helvetica,"san-serif";
font-size: 16px;
font-weight: bold;
margin-bottom: 2px;
color: #262626;
line-height: 1.2em;
}
#extra-space {
height: 300px;
}
#vis {
display: inline-block;
position: fixed;
top: 60px;
z-index: 1;
margin-left: 0;
font-size: 10px;
}
.tooltip {
position: absolute;
z-index: 10;
text-align: left;
width: 170px;
padding: 10px;
font-size: 10px;
font-family: Helvetica, sans-serif;
background: #ffffff;
pointer-events: none;
opacity: 0;
}
.tooltip h3 {
font-size: 12px; margin: 0 0 7px 0;
line-height: 1.2em;
}
div.tooltip .line { clear: both; margin-top: 3px; font-size: 11px; }
div.tooltip .symbol { float: left; width: 6px; height: 6px; margin: 3px 4px 0 0; }
div.tooltip .val { float: right; width: 25px; text-align: center; margin-right: 4px; background: none; }
.overlay {
fill: none;
pointer-events: all;
}
.button {
fill: #000;
}
.scalebutton {
cursor: pointer;
}
.countries {
stroke: #fff;
stroke-linejoin: round;
}
.countries path.selected {
stroke: #000;
stroke-width: 0.5px;
}
.clr { clear: both; }
var width = 1000,
height = 700,
center = [width / 2, height / 2],
defaultFill = "#e0e0e0";//between gray and white
var color = d3.scale.linear().range(["#deebf7", "#3182bd"]).interpolate(d3.interpolateLab);
var countryById = d3.map();
var projection = d3.geo.mercator()
.scale(200)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
var zoom = d3.behavior.zoom()
.scaleExtent([1, 8])
.on("zoom", move);
var svg = d3.select("#vis").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.call(zoom);
svg.on("wheel.zoom", null);
svg.on("mousewheel.zoom", null);
var g = svg.append("g");
var tooltip = d3.select("#tooltip")
.attr("class", "tooltip")
.style("opacity", 0);
var CURR_SELECT = "urban";
var flexible="Y2015";
function ready(world, stunting) {
console.log(world);
color.domain([0,73.1]);
g.append("g")
.attr("class", "countries")
.selectAll("path")
.data(topojson.feature(world, world.objects.units).features)
.enter().append("path")
.attr("d", path)
.attr("class",function(d){return d.id;})
.on("mouseover", mouseover)
.on("mouseout", function() {
d3.select(this).classed("selected", false);
tooltip.transition().duration(300)
.style("opacity", 0);
})
.attr("fill",function(d) {
return color(getColor(d,flexible));
});
make_buttons(); // create the zoom buttons
d3.selectAll("input").on("change", function change() {
flexible = "Y"+this.value;
updateMap(world, stunting,flexible);
});
}
function updateMap(world, stunting,flexible){
d3.selectAll("path")
.attr("fill",function(d) {
return color(getColor(d,flexible));
});
}
function make_buttons() {
// Zoom buttons actually manually constructed, not images
svg.selectAll(".scalebutton")
.data(['zoom_in', 'zoom_out'])
.enter()
.append("g")
.attr("id", function(d){return d;}) // id is the zoom_in and zoom_out
.attr("class", "scalebutton")
.attr({x: 20, width: 20, height: 20})
.append("rect")
.attr("y", function(d,i) { return 20 + 25*i })
.attr({x: 20, width: 20, height: 20})
// Plus button
svg.select("#zoom_in")
.append("line")
.attr({x1: 25, y1: 30, x2: 35, y2: 30 })
.attr("stroke", "#fff")
.attr("stroke-width", "2px");
svg.select("#zoom_in")
.append("line")
.attr({x1: 30, y1: 25, x2: 30, y2: 35 })
.attr("stroke", "#fff")
.attr("stroke-width", "2px");
// Minus button
svg.select("#zoom_out")
.append("line")
.attr({x1: 25, y1: 55, x2: 35, y2: 55 })
.attr("stroke", "#fff")
.attr("stroke-width", "2px");
svg.selectAll(".scalebutton")
.on("click", function() {
d3.event.preventDefault();
var scale = zoom.scale(),
extent = zoom.scaleExtent(),
translate = zoom.translate(),
x = translate[0], y = translate[1],
factor = (this.id === 'zoom_in') ? 2 : 1/2,
target_scale = scale * factor;
var clamped_target_scale = Math.max(extent[0], Math.min(extent[1], target_scale));
if (clamped_target_scale != target_scale){
target_scale = clamped_target_scale;
factor = target_scale / scale;
}
// Center each vector, stretch, then put back
x = (x - center[0]) * factor + center[0];
y = (y - center[1]) * factor + center[1];
// Transition to the new view over 350ms
d3.transition().duration(350).tween("zoom", function () {
var interpolate_scale = d3.interpolate(scale, target_scale),
interpolate_trans = d3.interpolate(translate, [x,y]);
return function (t) {
zoom.scale(interpolate_scale(t))
.translate(interpolate_trans(t));
svg.call(zoom.event);
};
});
});
}
function mouseover(d){
d3.select(this).classed("selected", true);
tooltip.transition().duration(100)
.style("opacity", 1);
tooltip
.style("top", (d3.event.pageY - 10) + "px" )
.style("left", (d3.event.pageX + 10) + "px");
tooltip.selectAll(".symbol").style("opacity", "0");
tooltip.selectAll(".val").style("font-weight", "normal");
tooltip.selectAll(".val").style("color", "darkgray");
tooltip.select(".symbol." + CURR_SELECT).style("opacity", "1");
tooltip.select(".val." + CURR_SELECT).style({
"font-weight": "bolder",
"color": "black"
});
if (countryById.get(d.id)) {
tooltip.select(".name").text(countryById.get(d.id)['Country']);
tooltip.select(".urban.val").text(d3.round(countryById.get(d.id)[flexible])+"%");
} else {
tooltip.select(".name").text("No data for " + d.properties.name);
tooltip.select(".urban.val").text("NA");
}
} // end mouseover
function getColor(d,flexible) {
var dataRow = countryById.get(d.id);
if (dataRow) {
return dataRow[flexible];
} else {
return 0;
}
}
function zoomIn() {
zoom.scale(zoom.scale()*2);
move();
}
function move() {
var t = d3.event.translate,
s = d3.event.scale;
t[0] = Math.min(width * (s - 1), Math.max(width * (1 - s), t[0]));
t[1] = Math.min(height * (s - 1), Math.max(height * (1 - s), t[1]));
zoom.translate(t);
g.style("stroke-width", 1 / s).attr("transform", "translate(" + t + ")scale(" + s + ")");
}
/**
* scroller - handles the details
* of figuring out which section
* the user is currently scrolled
* to.
*
*/
function scroller() {
var windowHeight;
var container = d3.select('body');
// Set height
var height = $('.step:last').height()
var marginBottom = parseInt($('.step:last').css('margin-bottom'))
var newHeight = $(window).height() - height - marginBottom
$('.step:last').height(newHeight)
console.log('height ', height, ' new height ', newHeight)
// event dispatcher
var dispatch = d3.dispatch("active", "progress");
// d3 selection of all the
// text sections that will
// be scrolled through
var sections = null;
// array that will hold the
// y coordinate of each section
// that is scrolled through
var sectionPositions = [];
var currentIndex = -1;
// y coordinate of
var containerStart = 0;
/**
* scroll - constructor function.
* Sets up scroller to monitor
* scrolling of els selection.
*
* @param els - d3 selection of
* elements that will be scrolled
* through by user.
*/
function scroll(els) {
sections = els;
// when window is scrolled call
// position. When it is resized
// call resize.
d3.select(window)
.on("scroll.scroller", position)
.on("resize.scroller", resize);
// manually call resize
// initially to setup
// scroller.
resize();
// hack to get position
// to be called once for
// the scroll position on
// load.
d3.timer(function() {
position();
return true;
});
}
/**
* resize - called initially and
* also when page is resized.
* Resets the sectionPositions
*
*/
function resize() {
// sectionPositions will be each sections
// starting position relative to the top
// of the first section.
sectionPositions = [];
var startPos;
sections.each(function(d,i) {
var top = this.getBoundingClientRect().top;
if(i === 0) {
startPos = top;
}
sectionPositions.push(top - startPos);
});
containerStart = container.node().getBoundingClientRect().top + window.pageYOffset;
}
/**
* position - get current users position.
* if user has scrolled to new section,
* dispatch active event with new section
* index.
*
*/
function position() {
var pos = window.pageYOffset - 10 - containerStart;
var sectionIndex = d3.bisect(sectionPositions, pos);
sectionIndex = Math.min(sections.size() - 1, sectionIndex);
if (currentIndex !== sectionIndex) {
dispatch.active(sectionIndex);
currentIndex = sectionIndex;
}
var prevIndex = Math.max(sectionIndex - 1, 0);
var prevTop = sectionPositions[prevIndex];
var progress = (pos - prevTop) / (sectionPositions[sectionIndex] - prevTop);
dispatch.progress(currentIndex, progress);
}
/**
* container - get/set the parent element
* of the sections. Useful for if the
* scrolling doesn't start at the very top
* of the page.
*
* @param value - the new container value
*/
scroll.container = function(value) {
if (arguments.length === 0) {
return container;
}
container = value;
return scroll;
};
// Update function
scroll.update = function(action) {
if (arguments.length === 0) {
return update;
}
scroll.on('active', function(index) {
// highlight current step text
d3.selectAll('.step')
.style('opacity', function(d,i) { return i == index ? 1 : 0.1; });
action(index)
});
return scroll;
};
//
// allows us to bind to scroller events
// which will interally be handled by
// the dispatcher.
d3.rebind(scroll, dispatch, "on");
return scroll;
}
ISO Country Y1990 Y1991 Y1992 Y1993 Y1994 Y1995 Y1996 Y1997 Y1998 Y1999 Y2000 Y2001 Y2002 Y2003 Y2004 Y2005 Y2006 Y2007 Y2008 Y2009 Y2010 Y2011 Y2012 Y2013 Y2014 Y2015
AFG Afghanistan 52.8 51.9 50.9 49.9 49.1 48.2 47.5 47 46.1 45.6 45.2 44.5 43.9 43.2 42.5 41.7 41 40.4 39.8 39.1 38.7 38.1 37.4 36.8 36.1 35.5
ALB Albania 13.4 13.2 13 12.9 12.9 12.7 12.5 12.3 11.9 11.7 11.3 11 10.7 10.3 9.8 9.4 8.9 8.5 8.2 7.9 7.5 7.2 7 6.8 6.5 6.2
DZA Algeria 22.4 22.1 22 21.8 21.7 21.5 21.3 21.1 21 21 21 20.9 20.7 20.4 20 19.5 18.8 18.2 17.5 17 16.5 16.2 15.9 15.7 15.6 15.5
AND Andorra 4.3 4 3.7 3.4 3.2 3 2.8 2.6 2.4 2.3 2.2 2.1 2.1 2 2 1.9 1.9 1.8 1.8 1.7 1.7 1.6 1.6 1.5 1.5 1.4
AGO Angola 59.1 59.2 59.4 59.4 59.3 59.4 59.5 59.4 58.9 58.7 58.4 58.2 57.5 57.2 56.7 56.1 55.5 55 54.1 53.4 52.6 51.9 51.1 50.4 49.6 48.7
ATG Antigua & Barbuda 14.7 14.1 13.5 12.9 12.3 11.7 11.2 10.7 10.3 9.9 9.4 9 8.6 8.2 7.9 7.5 7.2 6.9 6.6 6.3 6 5.8 5.5 5.3 5.1 4.9
ARG Argentina 15.4 15 14.7 14.4 14 13.3 12.6 12 11.5 11.3 11.3 11.1 10.6 10 9.5 9.2 8.8 8.5 8.1 7.8 7.5 7.2 7 6.8 6.5 6.3
ARM Armenia 23 22.5 21.9 21.2 20.5 19.8 19.1 18.3 17.5 16.7 15.9 15.1 14.4 13.7 13 12.4 11.8 11.1 10.6 10 9.5 9.1 8.6 8.2 7.7 7.4
AUS Australia 4.6 4.4 4.2 4 3.9 3.7 3.7 3.6 3.6 3.5 3.5 3.5 3.4 3.4 3.3 3.3 3.2 3.1 3 2.9 2.8 2.6 2.5 2.4 2.3 2.2
AUT Austria 4.6 4.4 4.2 4 3.7 3.5 3.4 3.2 3.2 3.1 3.1 3.1 3 3 2.9 2.8 2.8 2.7 2.6 2.6 2.5 2.4 2.4 2.3 2.2 2.1
AZE Azerbaijan 35.9 36.2 36.6 37 37.3 37.4 37.1 36.6 35.8 34.7 33.4 32.1 30.6 29.2 27.8 26.6 25.4 24.4 23.4 22.5 21.7 21 20.4 19.7 18.9 18.2
BHS Bahamas 14 13.3 12.6 12 11.4 10.7 10.2 9.6 9.2 8.9 8.7 8.6 8.6 8.6 8.7 8.7 8.6 8.5 8.4 8.2 8 7.8 7.5 7.3 7.1 6.9
BHR Bahrain 15.2 14.5 13.5 12.3 10.9 9.5 8.2 7 6.1 5.3 4.7 4.2 3.7 3.2 2.8 2.4 2.1 1.8 1.6 1.5 1.4 1.3 1.2 1.2 1.1 1.1
BGD Bangladesh 63.4 61 58.7 56.4 54 51.8 49.6 47.7 45.9 44.2 42.6 41 39.6 38.2 36.8 35.5 34.2 32.8 31.5 30.2 28.9 27.6 26.3 25.2 24.2 23.3
BRB Barbados 11.6 11 10.4 9.9 9.5 9.2 8.9 8.7 8.6 8.6 8.7 8.8 9.2 9.5 9.8 10 9.9 9.8 9.5 9.3 9.1 8.9 8.7 8.4 8.2 8
BLR Belarus 9.3 9.2 9.3 9.5 9.6 9.7 9.8 9.5 9 8.3 7.4 6.6 5.9 5.3 4.7 4.2 3.7 3.2 2.8 2.5 2.3 2.2 2.1 2 1.9 1.9
BEL Belgium 4.6 4.4 4.2 4.1 3.9 3.8 3.6 3.5 3.3 3.1 3 2.9 2.8 2.8 2.7 2.6 2.6 2.5 2.4 2.4 2.3 2.3 2.3 2.2 2.2 2.2
BLZ Belize 18.9 18.2 17.4 16.6 15.8 15.1 14.5 13.9 13.4 13 12.6 12.2 11.8 11.5 11.2 11 10.7 10.4 10.1 9.9 9.6 9.4 9.1 8.9 8.6 8.3
BEN Benin 46.3 45.4 44.4 43.6 42.9 42.3 41.9 41.4 40.9 40.3 39.6 38.6 37.8 36.9 36.1 35.5 35 34.5 34.1 33.8 33.5 33.3 32.9 32.6 32.2 31.8
BTN Bhutan 44 42.9 42 40.8 39.7 38.5 37.4 36.2 35.1 33.9 32.7 31.8 30.7 29.8 28.8 27.7 26.6 25.5 24.4 23.3 22.2 21.3 20.4 19.7 19.1 18.3
BOL Bolivia 42 40.9 39.9 39 38.1 37 35.6 34 32.5 31 29.9 29 28.4 28 27.6 27.1 26.3 25.3 24.4 23.4 22.6 21.9 21.2 20.7 20.1 19.6
BIH Bosnia & Herzegovina 11.3 11.1 10.9 10.5 10 9.5 9 8.4 7.8 7.2 6.6 6.1 5.7 5.4 5.2 5.1 5.1 5.1 5.1 5.2 5.1 5 4.7 4.5 4.2 4
BWA Botswana 25.9 25.7 25.4 25.2 25 24.7 24.4 24.2 24 23.9 24 24.3 24.7 25.1 25.4 25.5 25.5 25.3 25 24.6 24.2 23.7 23.3 22.9 22.4 21.9
BRA Brazil 24.3 23.3 22.4 21.5 20.7 20 19.3 18.5 17.8 17 16 14.9 13.9 13 12.2 11.5 10.8 10.4 10.3 10.5 10.7 10.8 10.7 10.3 9.6 8.9
BRN Brunei 6.4 6.2 6 5.8 5.6 5.4 5.2 5.1 5 4.9 4.9 4.9 4.9 4.9 4.9 4.9 4.9 4.8 4.7 4.7 4.6 4.5 4.4 4.3 4.3 4.3
BGR Bulgaria 11.6 11.9 12.1 12.2 12.2 12.2 12.3 12.3 12.2 11.8 11.3 10.8 10.3 9.8 9.2 8.6 8.1 7.7 7.4 7.2 7.1 6.8 6.5 6.2 5.9 5.6
BFA Burkina Faso 46.3 45.8 45.4 45 44.6 44.3 44 43.8 43.5 43 42.4 41.7 40.8 39.6 38.3 36.7 35.2 33.9 32.7 31.6 30.4 29.4 28.6 27.9 27.2 26.7
BDI Burundi 42 42.1 42.1 42 41.9 41.7 41.3 40.9 40.5 39.9 39.4 38.9 38.3 37.7 36.9 36 35.2 34.2 33.3 32.3 31.7 31 30.4 29.8 29.3 28.6
KHM Cambodia 40.7 40.3 40 40 39.9 39.9 39.8 39.5 38.8 37.6 36.1 34.2 32 30.1 28.3 26.8 25.5 24.3 23.1 21.9 20.7 19.4 18.2 16.9 15.7 14.8
CMR Cameroon 40.7 40.5 40.4 40.2 40 39.7 39.3 38.6 37.5 36.1 34.7 33.5 32.5 31.7 31.1 30.7 30.2 29.6 29 28.5 28.1 27.5 26.9 26.5 26.1 25.7
CAN Canada 4.4 4.3 4.2 4.1 4.1 4.1 4 3.9 3.8 3.7 3.7 3.8 3.8 3.9 4 4 4 3.9 3.8 3.8 3.7 3.6 3.5 3.4 3.3 3.2
CPV Cape Verde 22.1 22.1 22 22 22 21.7 21.3 20.6 19.6 18.5 17.3 15.9 14.8 14.2 13.9 13.8 13.9 14 14.1 14.1 13.9 13.7 13.3 12.9 12.6 12.2
CAF Central African Republic 51.3 51 50.6 50.3 49.9 49.7 49.5 49.3 49.2 49.1 49 48.9 48.7 48.5 48.4 48.1 47.9 47.8 47.4 47 46.4 45.7 44.9 44.2 43.3 42.6
TCD Chad 53.9 52.9 52 51.3 50.8 50.4 49.8 49.2 48.3 47.4 46.7 46.2 45.8 45.5 45.2 44.8 44.5 44.1 43.7 43.1 42.5 41.8 41.1 40.5 39.9 39.3
CHL Chile 8.6 8 7.4 7.1 6.8 6.5 6.4 6.3 6.2 6 5.7 5.5 5.3 5.3 5.4 5.4 5.5 5.5 5.5 5.5 5.4 5.4 5.3 5.2 5.1 4.9
CHN China 29.7 29.7 29.4 28.8 28 26.9 25.7 24.4 23.3 22.2 21.2 20.1 18.6 17.1 15.5 14 12.6 11.3 10.1 9.1 8.2 7.5 6.9 6.3 5.9 5.5
COL Colombia 17.9 17.6 17.2 16.8 16.3 15.9 15.4 14.9 14.4 14 13.5 13.1 12.7 12.3 12 11.7 11.4 11 10.7 10.4 10 9.7 9.4 9.1 8.8 8.5
COM Comoros 50.1 48.3 46.7 45.6 44.7 44 43.6 43 42.6 42.2 41.8 41.8 41.6 41.3 40.9 40.7 40.2 39.7 38.9 38.2 37.6 36.9 36.2 35.5 34.7 34
COG Congo 29.1 29.3 29.7 30.2 30.8 31.5 32.1 32.7 33.2 33.3 33.2 32.7 31.9 30.9 29.6 28.4 27.1 25.7 24.4 23.1 21.9 20.9 19.9 19.2 18.6 18
COD Congo DR 41.6 41.3 41 40.7 40.4 40.2 40 39.8 39.3 39 38.7 38.4 38 37.6 37.1 36.5 35.7 35 34.3 33.6 32.9 32.3 31.7 31.2 30.6 30.1
COK Cook Islands 13.2 13 12.8 12.6 12.2 11.8 11.3 10.7 10.1 9.6 9.1 8.6 8.2 7.8 7.4 7 6.6 6.2 5.9 5.6 5.3 5.1 4.9 4.7 4.5 4.4
CRI Costa Rica 8.9 8.8 8.8 8.8 8.7 8.6 8.5 8.4 8.2 8 7.7 7.4 7.2 7.1 7 7 6.9 6.8 6.7 6.6 6.6 6.5 6.5 6.4 6.3 6.2
CIV Cote d Ivoire 50.5 50.4 50.6 50.9 51.1 51.3 51.3 51.1 50.8 50.4 49.9 49.3 48.7 47.9 47.1 46.1 45.2 44.2 43.4 42.6 41.8 41 40.2 39.4 38.6 37.9
HRV Croatia 8.1 8 7.8 7.4 6.9 6.4 6 5.7 5.7 5.7 5.5 5.3 5 4.7 4.5 4.2 4 3.9 3.8 3.7 3.5 3.3 3.1 2.9 2.7 2.6
CUB Cuba 6.7 6.4 6.2 6 5.9 5.6 5.2 4.7 4.3 4.2 4.2 4.1 4 3.8 3.6 3.4 3.2 3.1 2.9 2.8 2.7 2.6 2.5 2.4 2.4 2.3
CYP Cyprus 5.6 5.5 5.3 5.1 4.8 4.5 4.2 4 3.7 3.5 3.2 3 2.8 2.6 2.5 2.4 2.3 2.2 2.1 2 1.9 1.8 1.7 1.6 1.5 1.5
CZE Czech Republic 10.3 9.7 8.9 8.1 7.3 6.5 5.8 5.2 4.6 4.2 3.9 3.7 3.5 3.4 3.3 3.1 3 2.8 2.7 2.5 2.4 2.3 2.1 2 1.9 1.8
DNK Denmark 4.4 4.2 4.1 4 3.9 3.8 3.8 3.7 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.1 3 2.9 2.9 2.8 2.8 2.7 2.7 2.6 2.6 2.5
DJI Djibouti 49.8 49.3 49 48.6 48 47.4 46.7 46 45.2 44.7 44.1 43.6 43 42.3 41.7 41.1 40.4 39.7 39 38.2 37.4 36.7 35.9 35.2 34.2 33.4
DMA Dominica 10.5 10.5 10.7 10.8 10.9 10.9 11 11.1 11.1 11.2 11.2 11.2 11.2 11.2 11.3 11.5 11.8 12.2 12.7 13.2 13.9 14.6 15.1 15.5 15.6 15.6
DOM Dominican Republic 24.6 24.2 23.9 23.7 23.7 23.7 23.8 24 24.1 24.1 24.1 24 23.9 23.8 23.7 23.8 23.8 23.9 23.8 23.7 23.5 23.3 23 22.6 22.1 21.7
ECU Ecuador 24.2 23.4 22.6 21.9 21.2 20.4 19.7 19.1 18.5 17.9 17.3 16.7 16.1 15.6 15.1 14.6 14.2 13.8 13.4 13 12.6 12.2 11.8 11.4 11.1 10.8
EGY Egypt 33.4 32 30.7 29.4 28.1 26.9 25.9 24.9 24 23.1 22.3 21.5 20.8 20.2 19.5 19 18.4 17.6 16.9 16.2 15.5 14.9 14.3 13.8 13.3 12.8
SLV El Salvador 22.5 21.8 21 20.2 19.3 18.4 17.5 16.7 15.9 15.3 14.4 13.6 12.9 12.3 11.8 11.3 10.9 10.6 10.3 10 9.8 9.5 9.2 8.9 8.6 8.3
GNQ Equatorial Guinea 50.6 49.8 49.4 48.9 48.1 47.6 47 46.2 45.7 45.3 44.8 44 43.3 42.6 41.8 40.8 39.7 38.6 37.8 37.1 36.4 35.7 35.1 34.4 33.7 33.1
ERI Eritrea 33.6 32.8 32.2 31.7 31.1 30.4 29.5 28.6 27.7 26.9 26.3 25.7 25.2 24.7 24.1 23.4 22.9 22.2 21.6 21.1 20.5 20 19.6 19.2 18.8 18.4
EST Estonia 13.8 13.4 12.8 12.1 11.3 10.3 9.3 8.3 7.5 6.8 6.3 5.7 5.3 4.8 4.4 4 3.7 3.4 3.1 2.8 2.5 2.3 2 1.8 1.7 1.5
ETH Ethiopia 60.9 60 58.9 57.5 56.1 54.7 53.2 51.8 50.5 49.5 48.4 47.2 45.9 44.4 42.7 40.9 39 37.3 35.5 33.9 32.5 31.4 30.4 29.3 28.5 27.7
FSM Federated States of Micronesia 26.2 26 25.9 26 26 26.1 26.3 26.3 26.2 26 25.7 25.3 25 24.5 24 23.5 23 22.6 22.1 21.7 21.2 20.7 20.2 19.7 19.2 18.8
FJI Fiji 17 16.5 16 15.6 15.2 14.9 14.7 14.4 14.2 14.1 13.9 13.7 13.5 13.2 12.9 12.5 11.8 11.1 10.7 10.4 10.3 10.3 10.2 10 9.8 9.6
FIN Finland 3.9 3.7 3.6 3.4 3.2 3.1 2.9 2.8 2.7 2.6 2.5 2.4 2.3 2.2 2.2 2.1 2 2 1.9 1.8 1.7 1.6 1.5 1.4 1.3 1.3
FRA France 3.6 3.4 3.2 3.1 3.1 3.1 3.1 3 2.9 2.8 2.8 2.7 2.7 2.6 2.5 2.4 2.3 2.3 2.3 2.3 2.3 2.2 2.2 2.3 2.3 2.2
GAB Gabon 31.7 31.6 31.4 31.2 31 30.7 30.5 30.3 30.1 30 29.8 29.6 29.3 28.8 28.5 28.2 27.8 27.4 27 26.4 25.9 25.3 24.7 24.2 23.8 23.2
GMB Gambia The 50.7 49.8 48.5 47.5 46.7 45.7 44.8 44.1 43.3 42.5 41.7 40.6 39.9 39.1 38.4 37.3 36.2 35.3 34.6 33.9 33.2 32.7 32.1 31.4 30.7 29.9
GEO Georgia 24.7 24.7 24.6 24.5 24.2 23.9 23.6 23.1 22.4 21.8 21 20 18.7 17.4 16.1 14.8 13.7 12.6 11.6 10.8 10 9.3 8.7 8.2 7.6 7.2
DEU Germany 3.4 3.5 3.5 3.3 3.2 3.1 3 2.9 2.9 2.8 2.8 2.7 2.7 2.7 2.6 2.6 2.6 2.5 2.4 2.4 2.3 2.3 2.3 2.2 2.2 2.1
GHA Ghana 42.3 41.4 40.7 40.1 39.6 39.2 38.7 38.2 37.8 37.1 36.4 35.7 34.9 34.4 33.9 33.6 33.4 33.1 32.8 32.4 31.9 31.2 30.5 29.7 29 28.3
GRC Greece 9.5 9 8.6 8.4 8.1 7.8 7.5 7.1 6.6 6.1 5.6 5.1 4.7 4.3 3.9 3.6 3.4 3.2 3.1 3.1 3 3 3 3 3 2.9
GRD Grenada 13.2 12.6 11.8 11 10.1 9.3 8.7 8.2 7.9 7.8 7.7 7.6 7.5 7.5 7.4 7.3 7.2 7.1 7 6.9 6.8 6.7 6.5 6.4 6.2 6
GTM Guatemala 29 28 27.1 26.3 25.4 24.6 23.8 23.1 22.4 21.6 21 20.3 19.6 19.1 18.5 17.9 17.5 17 16.6 16.2 15.8 15.3 14.8 14.3 13.8 13.4
GIN Guinea 62.9 61.6 60.5 59.8 59.3 58.7 57.7 56.2 54 51.1 48.3 46.1 44.5 43.3 42.1 40.9 39.4 37.7 36.4 35.3 34.6 33.9 33.2 32.6 31.8 31.3
GNB Guinea-Bissau 65.4 64.7 64.2 63.6 62.6 61.6 60.6 59.5 58.3 57.1 55.7 54.6 53.6 52.5 51.9 51.1 50.4 49.3 48.2 46.9 45.5 44.2 42.8 41.6 40.6 39.7
GUY Guyana 30.1 30 29.8 29.5 29.2 28.8 28.4 27.9 27.3 26.6 26 25.5 25.1 24.8 24.6 24.4 24.2 24.1 24.1 24 23.9 23.8 23.7 23.5 23.2 22.8
HTI Haiti 39.2 37.5 36.2 35.2 34.3 33.6 32.8 32.1 31.5 31 30.6 30.3 30.2 30.2 30.1 29.8 29.4 29 28.5 28.1 29.9 27.3 26.9 26.5 26 25.4
HND Honduras 21.6 20.8 20.1 19.6 19.2 18.9 18.7 18.5 18.5 17.9 17.6 17.3 17 16.5 16.1 15.7 15.3 14.8 14.3 13.7 13.1 12.6 12.2 11.8 11.4 11
HUN Hungary 13.6 12.8 11.9 10.8 9.9 9.1 8.5 8.1 7.7 7.4 7 6.6 6.1 5.7 5.3 5 4.8 4.6 4.4 4.2 4 3.9 3.8 3.7 3.6 3.5
ISL Iceland 3.5 3.3 3.1 3 2.8 2.7 2.6 2.5 2.3 2.2 2.1 2 1.8 1.7 1.6 1.5 1.4 1.3 1.3 1.2 1.2 1.1 1.1 1 1 0.9
IND India 57.4 56.1 54.8 53.7 52.5 51.4 50.3 49 47.8 46.5 45.1 43.7 42.3 40.9 39.5 38.3 37.1 36 34.9 33.8 32.7 31.6 30.6 29.5 28.6 27.7
IDN Indonesia 30.3 29.6 28.9 28.2 27.4 26.5 25.6 24.7 23.9 23.1 22.3 21.6 20.9 20.3 19.8 19.2 18.6 18.1 17.6 17.1 16.4 15.7 15.1 14.5 14 13.5
IRN Iran 26.5 25.6 24.8 24 23.3 22.6 22 21.3 20.6 19.9 19.2 18.4 17.5 16.8 16 15.3 14.6 13.9 13.1 12.4 11.7 11.2 10.7 10.2 9.8 9.5
IRQ Iraq 27.1 26.6 26.2 25.9 25.6 25.3 25.1 24.9 24.7 24.5 24.3 24 23.7 23.4 23 22.6 22.3 21.9 21.5 21.1 20.7 20.4 20 19.5 19 18.4
IRL Ireland 4.7 4.6 4.5 4.4 4.3 4.2 4.1 4.1 4.1 4.1 4 3.9 3.7 3.5 3.2 3 2.8 2.6 2.5 2.5 2.5 2.5 2.5 2.4 2.3 2.3
ISR Israel 6.3 5.9 5.5 5.1 4.7 4.5 4.2 4 3.8 3.7 3.6 3.5 3.3 3.2 2.9 2.7 2.5 2.5 2.4 2.4 2.4 2.4 2.3 2.3 2.2 2.1
ITA Italy 6.4 6.1 5.6 5.3 5 4.7 4.5 4.2 3.9 3.7 3.4 3.2 3.1 2.9 2.8 2.7 2.6 2.5 2.5 2.5 2.4 2.4 2.3 2.2 2.1 2.1
JAM Jamaica 20.6 20.3 20 19.7 19.3 18.9 18.6 18.3 17.9 17.5 17 16.5 16 15.5 15.1 14.7 14.5 14.3 14 13.7 13.5 13.1 12.7 12.4 12 11.6
JPN Japan 2.5 2.5 2.4 2.3 2.2 2.2 2.1 2 1.9 1.8 1.8 1.7 1.7 1.6 1.5 1.4 1.3 1.3 1.2 1.2 1.1 1 1 1 1 0.9
JOR Jordan 20.2 19.7 19.3 18.9 18.5 18.1 17.8 17.5 17.3 17 16.6 16.3 15.9 15.4 15 14.5 14.1 13.6 13.3 12.9 12.5 12.1 11.7 11.3 11 10.6
KAZ Kazakhstan 22.3 22.3 22.4 22.7 22.9 22.8 22.6 22.2 21.5 20.9 20.1 19.4 18.6 17.9 17.2 16.2 15.1 14 12.9 11.8 10.7 9.8 8.9 8.1 7.5 7
KEN Kenya 27.4 27.2 27.2 27.1 27.1 27.3 27.6 28 28.4 28.8 29.1 29.3 29.3 29.3 29.2 29 28.5 28 27.3 26.6 25.9 25.1 24.3 23.6 22.9 22.2
KIR Kiribati 36.1 35.2 34.4 33.7 33.1 32.5 31.9 31.1 30.4 29.7 28.9 28.2 27.5 26.9 26.5 26.2 26 26 26 25.9 25.7 25.3 24.9 24.6 24.1 23.7
PRK Korea DPR 21.9 23.7 25.7 27.8 29.5 30.9 31.7 31.7 30.9 29.4 27.3 24.8 22.3 20.2 18.7 17.7 17.4 17.4 17.5 17.3 16.9 16.2 15.5 14.8 14.1 13.5
KOR Korea Rep 2.7 2.5 2.4 2.2 2.1 1.9 1.8 1.8 1.9 2.1 2.4 2.7 2.9 2.9 2.7 2.5 2.2 2 1.9 1.8 1.7 1.7 1.7 1.7 1.7 1.6
KWT Kuwait 10.4 9.9 9.4 8.9 8.5 8.1 7.7 7.3 7 6.7 6.5 6.4 6.2 6 5.9 5.9 5.8 5.7 5.4 5.1 4.6 4.2 3.8 3.6 3.4 3.2
KGZ Kyrgyzstan 25.2 25.5 25.6 25.6 25.5 25.1 24.4 23.7 23.1 22.3 21.8 21.2 20.7 20.3 20 19.8 19.5 19 18.4 17.3 16.1 14.8 13.7 12.8 12.1 11.5
LAO Lao PDR 54.7 53.5 52.2 51 49.8 48.6 47.4 46.4 45.3 44.4 43.3 42.3 41.4 40.3 39.3 38.3 37.2 36.3 35.3 34.5 33.6 32.7 32 31.3 30.7 30.1
LVA Latvia 12 13.7 15 15.9 16.2 15.9 15.2 14 12.7 11.5 10.4 9.7 9.1 8.6 8.2 7.9 7.5 7.2 6.9 6.6 6.3 6 5.8 5.6 5.4 5.2
LBN Lebanon 20.8 19.6 18.5 17.5 16.5 15.6 14.8 14 13.3 12.6 11.8 11.2 10.4 9.7 9 8.3 7.6 7.1 6.6 6.2 5.9 5.6 5.4 5.2 5 4.8
LSO Lesotho 40.3 40.6 40.8 40.8 40.8 40.7 40.4 39.9 39.2 38.5 37.7 37 36.4 35.9 35.5 35.2 34.8 34.7 34.7 34.7 34.8 34.7 34.3 33.9 33.4 32.7
LBR Liberia 57 55.5 54.3 52.9 52 51.1 50.3 49.1 47.4 45.6 43.7 41.7 39.7 37.9 36.2 34.5 32.9 31.3 29.9 28.6 27.6 26.8 26 25.3 24.7 24.1
LBY Libya 20.9 20.3 19.6 19.1 18.5 17.9 17.2 16.6 16.1 15.6 15.1 14.7 14.2 13.7 13.1 12.4 11.7 10.8 10.1 9.5 8.9 8.5 8.1 7.8 7.5 7.2
LTU Lithuania 9.5 11.1 12.5 12.8 11.3 9.3 7.8 6.8 6.2 5.8 5.5 5.3 5.2 5.2 5.2 5.1 4.8 4.4 4.1 3.7 3.4 3.2 2.9 2.7 2.6 2.5
LUX Luxembourg 4.3 4 3.8 3.6 3.4 3.2 3 2.8 2.7 2.6 2.4 2.3 2.2 2 1.9 1.8 1.6 1.5 1.4 1.3 1.2 1.1 1.1 1 1 0.9
MKD Macedonia 17.3 16.4 15.6 14.6 13.6 12.6 11.6 10.9 10.3 9.7 9.2 8.7 8.5 8.5 8.8 8.9 8.7 8.4 7.9 7.3 6.5 5.6 4.8 4.2 3.8 3.5
MDG Madagascar 40.2 39.6 39.1 38.5 37.9 37.1 36.2 35.2 34.1 32.9 31.7 30.6 29.5 28.4 27.4 26.4 25.5 24.6 23.7 22.9 22.3 21.7 21.1 20.5 20.1 19.7
MWI Malawi 48.6 47.1 45.7 44.4 43.4 42.6 41.8 40.8 39.5 37.8 35.8 33.7 31.7 30 28.6 27.7 27 26.7 26.5 26.2 25.7 24.9 24 23.2 22.4 21.8
MYS Malaysia 9 8.5 8.1 7.7 7.4 7.1 6.8 6.6 6.2 5.8 5.3 4.9 4.6 4.4 4.3 4.2 4.2 4.3 4.4 4.3 4.3 4.2 4.1 4.1 4 3.9
MDV Maldives 42.9 41.7 40.4 39 37.7 36.1 34.4 32.4 30.4 28.1 25.7 23.2 20.8 18.1 15.7 13.6 11.8 10.4 9.2 8.2 7.4 6.7 6.1 5.6 5.2 4.9
MLI Mali 73.1 71.4 69.8 68.9 67.8 66.5 64.8 63 61.1 59.1 56.8 54.4 52.3 50.6 49.2 47.7 46.4 45.1 43.9 43 42.1 41.1 40.2 39.4 38.6 37.8
MLT Malta 7.5 7.3 7.1 6.8 6.6 6.4 6.1 5.8 5.6 5.4 5.2 5 4.9 4.8 4.7 4.7 4.6 4.6 4.6 4.6 4.6 4.5 4.5 4.5 4.4 4.4
MHL Marshall Islands 19.7 19.2 18.7 18.2 17.9 17.7 17.7 17.9 18.2 18.4 18.5 18.5 18.4 18.2 18.1 18.1 18 17.9 17.9 17.8 17.7 17.6 17.5 17.2 17 16.7
MRT Mauritania 45.9 45.2 44.7 44.3 44.3 44.3 44.2 44 43.7 43.3 43 42.7 42.6 42.5 42.4 42.1 41.8 41.1 40.5 39.9 39.1 38.3 37.7 36.9 36.3 35.7
MUS Mauritius 14.6 14.1 13.9 14 14.4 15 15.5 15.5 14.8 13.6 12.3 11 10.2 9.9 9.8 9.9 10 9.9 9.6 9.3 9.1 9.1 9 8.9 8.7 8.4
MEX Mexico 20.6 19.4 18.3 17.2 16.2 15.3 14.2 13.1 12 11 10.1 9.3 8.6 8.1 7.9 7.8 7.5 6.9 6.6 6.9 7.7 8.2 8.1 7.7 7.4 7
MDA Moldova 18.6 18.9 19.6 20.4 21.4 22.3 23 23.3 23.1 22.3 20.7 18.9 17.1 15.6 14.5 13.8 13.3 13.2 13.1 13 12.9 12.8 12.6 12.4 12.1 11.9
MCO Monaco 4.2 4 3.8 3.7 3.5 3.4 3.2 3.1 3 2.9 2.8 2.7 2.6 2.5 2.5 2.4 2.4 2.3 2.3 2.2 2.2 2.1 2.1 2 2 1.9
MNG Mongolia 31.8 31.9 31.8 31.7 31.4 30.9 30 29 27.9 26.8 25.7 24.6 23.5 22.3 21.2 20.1 19.2 18.2 17.2 16 14.9 13.9 13 12.3 11.7 11.1
MNE Montenegro 10.9 10.4 10.1 10 9.9 9.8 9.8 9.7 9.5 9.3 9 8.7 8.3 7.8 7.4 6.8 6.4 5.9 5.4 5 4.5 4.1 3.8 3.5 3.3 3.1
MAR Morocco 36.5 35.6 34.7 33.9 33 32.1 31.1 30.1 29.2 28.3 27.5 26.9 26.2 25.5 24.9 24.3 23.8 23.2 22.6 21.9 21.1 20.3 19.6 18.9 18.2 17.6
MOZ Mozambique 61.5 60.5 59.6 58.4 57.1 55.5 53.8 51.6 49.1 46.6 44.1 41.9 39.8 38.1 36.6 35.2 34.1 33.1 32.3 31.4 30.6 29.8 29.1 28.4 27.8 27.1
MMR Myanmar 46.6 46 45.2 44.3 43.4 42.3 41.2 40.2 39.3 38.3 37.3 36.5 35.6 34.9 34.2 33.5 32.8 32.1 31.7 30.5 29.7 29 28.4 27.7 27 26.4
NAM Namibia 27.7 27 26.1 25.2 24.3 23.3 22.5 21.7 21 20.3 19.6 18.9 18.3 17.8 17.4 17.1 17 17.1 17.1 17.1 17.1 16.9 16.7 16.4 16.1 15.9
NRU Nauru 28.8 28.3 27.7 27.3 26.9 26.7 26.4 25.9 25.5 25.1 24.8 24.6 24.5 24.5 24.5 24.5 24.5 24.6 24.7 24.6 24.6 24.2 23.8 23.5 23.1 22.7
NPL Nepal 58.5 56.2 54 51.9 49.8 47.7 45.8 44 42.4 40.8 39.3 37.8 36.5 35.1 33.8 32.5 31.3 30.1 29 27.8 26.7 25.6 24.7 23.8 23 22.2
NLD Netherlands 4.6 4.5 4.4 4.3 4.2 4.1 4 3.9 3.9 3.9 3.8 3.8 3.7 3.6 3.5 3.4 3.3 3.2 3 2.9 2.8 2.7 2.6 2.5 2.4 2.4
NZL New Zealand 4.3 4.2 4 3.8 3.6 3.5 3.5 3.5 3.5 3.5 3.5 3.4 3.4 3.3 3.2 3.1 3 3 3.1 3.2 3.3 3.4 3.3 3.3 3.2 3.1
NIC Nicaragua 23.5 22.8 22.2 21.6 21 20.3 19.7 19 18.5 17.8 17.2 16.7 16.2 15.7 15 14.4 13.8 13.3 12.7 12.3 11.8 11.4 11 10.6 10.3 9.8
NER Niger 54.5 53.6 52.7 51.6 50.3 49.2 48 46.9 45.8 44.6 43.4 42.1 40.7 39.3 37.9 36.6 35.4 34.2 33 31.9 30.8 29.8 28.9 28.1 27.3 26.8
NGA Nigeria 50.4 50.7 51.1 51.3 51.4 51.4 51.1 50.7 50.1 49.3 48.3 47.2 46.1 45 43.8 42.7 41.6 40.7 39.8 39 38.2 37.4 36.5 35.8 35 34.3
NIU Niue 7.5 7.9 8.3 8.7 9.2 9.7 10.2 10.7 11.2 11.9 12.5 13.2 13.8 14.5 14.9 15.1 15.1 15 14.8 14.6 14.3 13.9 13.5 13.2 12.8 12.5
NOR Norway 4 3.8 3.6 3.4 3.2 3.1 2.9 2.8 2.8 2.7 2.7 2.6 2.5 2.4 2.4 2.3 2.2 2.1 2 1.9 1.9 1.8 1.7 1.6 1.6 1.5
OMN Oman 17.3 16 14.6 13.3 12.1 11 10.2 9.4 8.7 8.1 7.5 7 6.6 6.2 6 5.8 5.6 5.5 5.4 5.3 5.3 5.3 5.3 5.3 5.3 5.2
PAK Pakistan 64.3 65.4 66.4 67.1 67 66.4 65.5 64.5 63.2 61.8 60.4 59 57.8 56.3 54.8 53.4 52.5 51.8 51.2 50.6 50 49.2 48.4 47.4 46.6 45.5
PLW Palau 19.3 18.9 18.5 18.1 17.6 17 16.5 16 15.5 15 14.6 14.1 13.7 13.3 12.8 12.5 12 11.6 11.3 10.9 10.6 10.2 9.9 9.6 9.3 9
PAN Panama 17.4 17 16.6 16.3 16.1 15.9 15.7 15.5 15.3 15 14.7 14.4 14 13.7 13.3 13 12.6 12.3 12 11.6 11.3 10.9 10.6 10.2 9.9 9.6
PNG Papua New Guinea 31.8 31.6 31.4 31.3 31.1 30.9 30.8 30.6 30.4 30.2 30.1 29.9 29.8 29.7 29.5 29.2 28.9 28.5 28.1 27.7 27.1 26.5 26 25.4 24.9 24.5
PRY Paraguay 22.7 22.1 21.6 21 20.5 19.9 19.5 19.1 18.6 18.3 17.7 17.2 16.7 16.3 15.8 15.4 14.9 14.4 13.9 13.5 13 12.6 12.2 11.8 11.4 10.9
PER Peru 27.8 26.8 25.9 24.8 23.6 22.3 20.8 19.3 18 16.8 15.8 15 14.3 13.6 13 12.5 12 11.6 11.1 10.7 10.2 9.8 9.4 8.9 8.6 8.2
PHL Philippines 19.6 19 18.5 18.1 17.8 17.5 17.3 17.1 17 16.9 16.8 16.7 16.6 16.4 16.2 16 15.7 15.4 15 14.6 14.3 14 13.7 13.3 12.9 12.6
POL Poland 11.1 10.7 10.5 10.5 10.4 9.7 8.8 7.8 6.9 6.2 5.8 5.4 5.2 5 4.8 4.6 4.4 4.2 4 3.8 3.6 3.4 3.3 3.2 3.2 3.1
PRT Portugal 7.2 6.6 6 5.5 5.1 4.7 4.3 4 3.8 3.5 3.4 3.2 3 2.8 2.6 2.3 2.2 2.1 2.1 2.1 2.1 2.1 2.1 2.1 2 2
QAT Qatar 11.3 10.6 9.9 9.3 8.8 8.3 7.9 7.5 7.2 6.8 6.5 6.2 6 5.7 5.5 5.2 5 4.9 4.8 4.6 4.5 4.4 4.3 4.1 4 3.8
ROU Romania 13.5 13.4 13.3 13.3 13.2 13.1 13.1 13.1 13.1 13.1 13.1 13 13 12.8 12.3 11.7 10.9 10 9.2 8.5 7.9 7.4 7.1 6.8 6.5 6.3
RUS Russian Federation 14 14 14 14.2 14.3 14.3 14.1 13.8 13.5 13.1 12.5 11.9 11.2 10.5 9.7 9 8.3 7.7 7.2 6.7 6.3 6 5.7 5.4 5.2 5
RWA Rwanda 40.8 41.2 42 43.3 46 46.1 45.4 45.8 45.6 44 42.3 40.3 38 35.7 33.4 31.2 29.5 28 26.7 25.5 24.3 22.9 21.6 20.4 19.5 18.7
KNA Saint Kitts & Nevis 17.5 16.7 16 15.4 14.9 14.3 13.8 13.2 12.6 12.1 11.6 11.1 10.7 10.3 9.9 9.5 9.1 8.8 8.4 8.1 7.8 7.5 7.2 7 6.8 6.5
LCA Saint Lucia 12.8 12.4 12.1 11.8 11.5 11.2 11.1 11 11 11.1 11.2 11.3 11.3 11.3 11.2 11.2 11.1 10.9 10.8 10.6 10.5 10.2 10 9.8 9.5 9.3
WSM Samoa 16.7 16.2 15.7 15.1 14.5 14 13.5 13 12.6 12.1 11.7 11.4 11.1 10.8 10.6 10.5 10.4 10.3 10.2 10.2 10.2 10.1 10 9.9 9.7 9.5
SMR San Marino 6.6 5.8 4.9 3.9 3.1 2.4 2 1.7 1.5 1.4 1.3 1.2 1.2 1.1 1 1 1 1 0.9 0.9 0.8 0.8 0.8 0.7 0.7 0.7
STP Sao Tome & Principe 28.4 28.2 28 27.7 27.3 26.9 26.3 25.9 25.5 25.1 24.5 23.9 23.3 22.7 22.2 21.6 21 20.5 20 19.5 19 18.6 18.2 17.8 17.5 17.1
SAU Saudi Arabia 22.3 20.9 19.6 18.5 17.2 16 15.1 14.2 13.5 12.9 12.4 11.9 11.6 11.2 10.9 10.7 10.5 10.2 9.9 9.6 9.3 9 8.7 8.5 8.2 7.9
SEN Senegal 40.2 40 39.9 40 40.1 40.3 40.4 40.3 40.1 39.6 38.9 37.9 36.7 35.4 34 32.5 31 29.6 28.1 26.8 25.5 24.3 23.2 22.2 21.5 20.8
SRB Serbia 17.5 16 15 14.3 13.5 12.2 10.8 9.5 8.6 8 7.7 7.5 7.1 6.6 6 5.5 5.2 5.1 5 4.9 4.8 4.7 4.5 4.4 4.3 4.2
SYC Seychelles 11.3 10.8 10.4 10.1 9.8 9.5 9.3 9.2 9.2 9.2 9.2 9.2 9.2 9.2 9.1 9.1 9.1 9 9 9 9 9 9 8.9 8.8 8.6
SLE Sierra Leone 53.9 54 53.8 53.6 53.4 53 52.4 51.8 51.4 50.8 50.1 49.4 48.7 48.2 47.5 46.7 45.7 44.6 43.3 42 40.7 39.4 38.2 37 35.8 34.9
SGP Singapore 4 3.5 3.1 2.7 2.4 2.3 2.1 2 1.9 1.8 1.6 1.5 1.4 1.3 1.3 1.3 1.2 1.2 1.2 1.2 1.1 1.1 1.1 1.1 1.1 1
SVK Slovakia 12.5 12 11.5 11 10.5 9.9 9.3 8.8 8.2 7.7 7.3 6.9 6.6 6.2 5.9 5.6 5.4 5.3 5.2 5.1 5 4.9 4.7 4.6 4.4 4.2
SVN Slovenia 5.7 5.3 4.9 4.6 4.3 4 3.8 3.7 3.5 3.4 3.3 3.1 3 2.8 2.6 2.5 2.3 2.2 2.1 1.9 1.8 1.7 1.6 1.5 1.5 1.4
SLB Solomon Islands 16 15.6 15.3 15 14.8 14.6 14.6 14.6 14.6 14.4 14.4 14.3 14.2 14.3 14.3 14.4 14.5 14.5 14.3 14 13.8 13.5 13.2 12.9 12.5 12.2
SOM Somalia 45.1 44.6 44.5 44.1 44.1 44.2 44.2 44.2 44.2 44.4 44.5 44.9 45.2 45.4 45.4 45.3 45.2 44.8 44.3 43.6 43 42.4 41.9 41.2 40.5 39.7
ZAF South Africa 20.4 20 19.5 19.2 18.8 18.4 17.9 17.4 16.9 16.4 16 15.5 15.1 14.6 14.2 13.7 13.2 12.8 12.3 11.9 11.7 11.5 11.3 11.2 11.1 11
SSD South Sudan 66.7 66.1 65.4 64.6 63.7 63.1 62.1 61.1 60.1 58.8 57.5 56 54.4 53 51.6 50.1 48.6 47.3 46 44.8 43.7 42.7 41.8 41 40.1 39.3
ESP Spain 7.1 6.7 6.4 6 5.6 5.2 4.9 4.6 4.3 4.1 4 4 3.9 3.8 3.7 3.5 3.4 3.2 3.1 3.1 3 3 3 2.9 2.8 2.8
LKA Sri Lanka 14.3 14.2 14 13.7 13.2 12.6 12.1 11.5 11 10.5 10.1 9.8 9.6 9.4 9.4 8.7 8.2 7.7 7.2 6.8 6.4 6.1 5.9 5.7 5.6 5.4
VCT St Vincent & the Grenadines 13 12.9 12.8 12.8 12.8 12.9 13 13.2 13.3 13.4 13.5 13.6 13.7 13.8 13.8 13.8 13.7 13.6 13.5 13.3 13.1 12.8 12.5 12.2 11.8 11.5
PSE State of Palestine 22.1 21.5 20.8 20.1 19.5 18.9 18.4 17.7 17.2 16.7 16.4 16.1 15.8 15.6 15.3 14.9 14.5 14.2 13.9 13.6 13.4 13.1 12.8 12.4 12.1 11.8
SDN Sudan 40.7 40.1 39.5 39 38.4 37.9 37.4 37 36.5 36.1 35.6 35.1 34.6 34 33.6 33.2 32.9 32.8 32.6 32.4 32.2 31.8 31.4 30.9 30.4 29.8
SUR Suriname 23.3 22.8 22.3 21.9 21.4 21 20.5 20.1 19.6 19.1 18.6 18 17.3 16.8 16.3 15.9 15.4 14.9 14.4 13.9 13.5 13 12.6 12.2 11.8 11.5
SWZ Swaziland 22.1 22.2 22.3 22.4 22.5 22.5 22.5 22.4 22.2 21.8 21.3 20.6 19.8 19 18.3 17.8 17.4 17.1 16.9 16.8 16.6 16.3 15.7 15.1 14.6 14.2
SWE Sweden 3.5 3.4 3.2 3 2.9 2.7 2.5 2.4 2.4 2.3 2.3 2.3 2.2 2.1 2 1.9 1.8 1.8 1.7 1.6 1.6 1.6 1.6 1.6 1.6 1.6
CHE Switzerland 3.9 3.8 3.6 3.5 3.5 3.4 3.4 3.4 3.4 3.5 3.5 3.5 3.4 3.4 3.3 3.3 3.3 3.3 3.2 3.2 3.1 3 3 2.9 2.8 2.7
SYR Syria 16.6 16.1 15.7 15.1 14.7 14.3 13.9 13.6 13.2 12.8 12.4 12 11.6 11.2 10.7 10.3 9.9 9.5 9.1 8.7 8.4 8.1 7.8 7.6 7.3 7
TJK Tajikistan 32.3 32.3 32.5 32.7 32.8 32.5 32.2 31.9 31.4 30.9 30.1 29.2 28.4 27.5 26.4 25.6 24.9 24.4 23.9 23.3 22.8 22.3 21.8 21.4 20.9 20.5
TZA Tanzania 39.5 38.8 38.1 37.5 36.8 36.2 35.5 34.8 34 33.1 32 30.8 29.6 28.4 27.3 26.2 25.2 24.1 23.2 22.3 21.5 20.9 20.3 19.8 19.3 18.8
THA Thailand 20.4 19.5 18.5 17.5 16.6 15.9 15.2 14.5 13.9 13.3 12.7 12.1 11.5 11 10.5 10 9.5 9.1 8.8 8.4 8.1 7.8 7.5 7.3 7 6.7
TLS Timor Leste 55.9 54.4 52.7 50.8 48.8 46.6 44.6 42.8 40.9 39.1 37.4 35.7 34.1 32.6 31.3 29.9 28.8 27.8 26.9 26.2 25.3 24.7 24 23.4 22.9 22.3
TGO Togo 43.4 42.6 42 41.3 40.5 39.8 39 38.2 37.5 36.8 36 35.3 34.6 34 33.4 32.7 32 31.2 30.4 29.8 29.2 28.7 28.2 27.7 27.2 26.7
TON Tonga 10.1 9.7 9.3 9 8.7 8.5 8.3 8.1 7.9 7.8 7.6 7.4 7.3 7.2 7.1 7.1 7.1 7.1 7.1 7.1 7.2 7.3 7.3 7.2 7.1 6.9
TTO Trinidad & Tobago 19.9 19.5 19.3 19.2 19 18.9 18.9 18.8 18.8 18.8 18.7 18.6 18.5 18.2 17.8 17.4 17.1 16.6 16.2 15.8 15.3 14.9 14.5 14 13.6 13.2
TUN Tunisia 27.7 27.1 26.5 25.8 25 24.1 23.1 22 20.8 19.7 18.4 17.2 16.1 15.1 14.3 13.4 12.6 11.9 11.3 10.6 10.1 9.6 9.2 8.8 8.5 8.2
TUR Turkey 32.7 31.4 30 28.7 27.3 26 24.7 23.5 22.3 21.2 20.1 19 18 16.8 15.6 14.5 13.5 12.6 11.7 10.8 10.1 9.3 8.7 8.1 7.5 7.1
TKM Turkmenistan 30.1 30.9 31.5 32 32.3 32.3 32.2 32 31.6 31.1 30.6 30.2 29.7 29.1 28.5 28 27.5 26.9 26.3 25.9 25.3 24.8 24.3 23.7 23.2 22.6
TUV Tuvalu 30 29.8 29.5 29.1 28.6 28 27.5 26.9 26.3 25.7 25.3 25.1 24.8 24.5 24.1 23.6 23.2 22.7 22.1 21.4 20.8 20.2 19.5 18.9 18.3 17.6
UGA Uganda 38.5 37.2 36.1 35.3 34.9 34.6 34.4 34.1 33.8 33.2 32.5 31.6 30.5 29.4 28.3 27.3 26.3 25.2 24.1 23.1 22.1 21.2 20.4 19.7 19.2 18.7
UKR Ukraine 12.1 12 12.1 12.2 12.4 12.6 12.6 12.4 12.1 11.7 11.2 10.6 10.1 9.6 9.1 8.8 8.5 8.2 7.8 7.5 7.1 6.8 6.4 6.1 5.7 5.5
ARE United Arab Emirates 8.2 7.9 7.6 7.3 6.9 6.6 6.4 6.2 6 5.8 5.6 5.5 5.4 5.2 5.1 5 4.9 4.7 4.6 4.5 4.3 4.1 4 3.8 3.6 3.5
GBR United Kingdom 4.5 4.4 4.4 4.3 4.2 4.1 4 3.9 3.9 3.8 3.8 3.7 3.6 3.6 3.5 3.5 3.4 3.3 3.2 3.1 3 2.9 2.8 2.7 2.5 2.4
USA United States of America 5.8 5.6 5.4 5.2 5.1 5 4.9 4.8 4.7 4.6 4.6 4.6 4.6 4.6 4.5 4.5 4.4 4.3 4.3 4.2 4.1 4 3.9 3.8 3.7 3.6
URY Uruguay 12.2 11.9 11.6 11.2 10.8 10.3 9.6 9.1 8.7 8.5 8.4 8.3 8.2 8 7.7 7.4 7 6.6 6.4 6.2 6.1 5.9 5.8 5.5 5.3 5.1
UZB Uzbekistan 30.9 30.7 30.7 30.6 30.5 30.4 30.3 30 29.8 29.5 29 28.5 27.9 27.4 26.6 26 25.4 24.9 24.3 23.7 23.1 22.6 22.1 21.5 20.9 20.4
VUT Vanuatu 16.3 15.7 15.1 14.5 14 13.6 13.3 13.1 12.7 12.5 12.2 12 11.9 11.8 11.9 12 12 12.1 12.1 12.1 12.1 12.1 12.1 12 11.8 11.6
VEN Venezuela 13 13.5 14 14.1 13.8 13.3 13 12.9 12.7 12.4 12 11.6 11.1 10.5 9.8 9.3 9.4 9.7 10.1 10.2 10.1 9.9 9.7 9.5 9.2 8.9
VNM Vietnam 23.9 23.5 23.1 22.4 21.7 20.8 19.9 18.9 17.7 16.7 15.7 14.8 13.9 13.3 12.9 12.6 12.5 12.5 12.7 12.8 12.8 12.7 12.4 12.1 11.7 11.4
YEM Yemen 44 43.1 42.3 41.6 41.1 40.8 40.4 39.9 39.2 38.4 37.4 36.3 35.2 34.1 33 31.9 30.8 29.7 28.6 27.5 26.4 25.4 24.4 23.6 22.8 22.1
ZMB Zambia 36.2 35.7 35.1 34.6 34.4 34.4 34.6 34.9 35 35 34.5 33.6 32.3 30.7 29.3 28 27.1 26.5 26 25.6 25 24.4 23.5 22.8 22 21.4
ZWE Zimbabwe 22 21.3 20.8 20.5 20.4 20.3 20.4 20.5 20.6 20.7 21 21.4 21.8 22.2 22.6 23.1 23.7 24.3 24.8 25.2 25.3 25.1 24.8 24.4 23.9 23.5
d3.selection.prototype.moveToFront = function() {
return this.each(function(){
this.parentNode.appendChild(this);
});
};
var settings = {
// could be used to save settings for styling things.
}
function focus_country(country) {
d3.selectAll("path").classed("focused", false);
if (country) {
var line = d3.select("." + country);
line.classed("focused", true);
line.moveToFront();
}
}
// ******* Change the showX and showY function for some cases ********
var update = function(value) {
var country = null;
switch(value) {
case 0:
console.log("in case", value);
country = null;
case 1:
console.log("in case", value);
country = null;
break;
case 2:
console.log("in case 2");
country = "PRK";
break;
case 3:
console.log("in case 3");
country = "BRA";
break;
case 4:
console.log("in case 4");
country = "PAK";
break;
default:
country = null;
focus_country(country);
break;
}
focus_country(country); // this applies a highlight on a country.
}
// setup scroll functionality
function display(error, world,stunting) {
if (error) {
console.log(error);
} else {
ready(world,stunting);
var scroll = scroller()
.container(d3.select('#graphic'));
// pass in .step selection as the steps
scroll(d3.selectAll('.step'));
// Pass the update function to the scroll object
scroll.update(update)
}
}
function typeAndSet(d) {
d.Y1990=+d.Y1990;d.Y1991=+d.Y1991;d.Y1992=+d.Y1992;d.Y1993=+d.Y1993;d.Y1994=+d.Y1994;d.Y1995=+d.Y1995;d.Y1996=+d.Y1996;d.Y1997=+d.Y1997;d.Y1998=+d.Y1998;d.Y1999=+d.Y1999;
d.Y2000=+d.Y2000;d.Y2001=+d.Y2001;d.Y2002=+d.Y2002;d.Y2003=+d.Y2003;d.Y2004=+d.Y2004;d.Y2005=+d.Y2005;d.Y2006=+d.Y2006;d.Y2007=+d.Y2007;d.Y2008=+d.Y2008;d.Y2009=+d.Y2009;
d.Y2010=+d.Y2010;d.Y2011=+d.Y2011;d.Y2012=+d.Y2012;d.Y2013=+d.Y2013;d.Y2014=+d.Y2014;d.Y2015=+d.Y2015;
countryById.set(d.ISO, d);
return d;
}
queue()
.defer(d3.json, "countries.json")
.defer(d3.csv, "NeonatalRate.csv", typeAndSet)
.await(display);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment