Skip to content

Instantly share code, notes, and snippets.

@karmi
Created April 8, 2012 21:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save karmi/2339918 to your computer and use it in GitHub Desktop.
Save karmi/2339918 to your computer and use it in GitHub Desktop.
Life Expectancy Slope Graph [WIP]
(function(){if (!Date.now) Date.now = function() {
return +new Date;
};
try {
document.createElement("div").style.setProperty("opacity", 0, "");
} catch (error) {
var d3_style_prototype = CSSStyleDeclaration.prototype,
d3_style_setProperty = d3_style_prototype.setProperty;
d3_style_prototype.setProperty = function(name, value, priority) {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
d3 = {version: "2.8.1"}; // semver
function d3_class(ctor, properties) {
try {
for (var key in properties) {
Object.defineProperty(ctor.prototype, key, {
value: properties[key],
enumerable: false
});
}
} catch (e) {
ctor.prototype = properties;
}
}
var d3_array = d3_arraySlice; // conversion for NodeLists
function d3_arrayCopy(pseudoarray) {
var i = -1, n = pseudoarray.length, array = [];
while (++i < n) array.push(pseudoarray[i]);
return array;
}
function d3_arraySlice(pseudoarray) {
return Array.prototype.slice.call(pseudoarray);
}
try {
d3_array(document.documentElement.childNodes)[0].nodeType;
} catch(e) {
d3_array = d3_arrayCopy;
}
var d3_arraySubclass = [].__proto__?
// Until ECMAScript supports array subclassing, prototype injection works well.
function(array, prototype) {
array.__proto__ = prototype;
}:
// And if your browser doesn't support __proto__, we'll use direct extension.
function(array, prototype) {
for (var property in prototype) array[property] = prototype[property];
};
d3.map = function(object) {
var map = new d3_Map;
for (var key in object) map.set(key, object[key]);
return map;
};
function d3_Map() {}
d3_class(d3_Map, {
has: function(key) {
return d3_map_prefix + key in this;
},
get: function(key) {
return this[d3_map_prefix + key];
},
set: function(key, value) {
return this[d3_map_prefix + key] = value;
},
remove: function(key) {
key = d3_map_prefix + key;
return key in this && delete this[key];
},
keys: function() {
var keys = [];
this.forEach(function(key) { keys.push(key); });
return keys;
},
values: function() {
var values = [];
this.forEach(function(key, value) { values.push(value); });
return values;
},
entries: function() {
var entries = [];
this.forEach(function(key, value) { entries.push({key: key, value: value}); });
return entries;
},
forEach: function(f) {
for (var key in this) {
if (key.charCodeAt(0) === d3_map_prefixCode) {
f.call(this, key.substring(1), this[key]);
}
}
}
});
var d3_map_prefix = "\0", // prevent collision with built-ins
d3_map_prefixCode = d3_map_prefix.charCodeAt(0);
function d3_this() {
return this;
}
d3.functor = function(v) {
return typeof v === "function" ? v : function() { return v; };
};
// Copies a variable number of methods from source to target.
d3.rebind = function(target, source) {
var i = 1, n = arguments.length, method;
while (++i < n) target[method = arguments[i]] = d3_rebind(target, source, source[method]);
return target;
};
// Method is assumed to be a standard D3 getter-setter:
// If passed with no arguments, gets the value.
// If passed with arguments, sets the value and returns the target.
function d3_rebind(target, source, method) {
return function() {
var value = method.apply(source, arguments);
return arguments.length ? target : value;
};
}
d3.ascending = function(a, b) {
return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN;
};
d3.descending = function(a, b) {
return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN;
};
d3.mean = function(array, f) {
var n = array.length,
a,
m = 0,
i = -1,
j = 0;
if (arguments.length === 1) {
while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j;
} else {
while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j;
}
return j ? m : undefined;
};
d3.median = function(array, f) {
if (arguments.length > 1) array = array.map(f);
array = array.filter(d3_number);
return array.length ? d3.quantile(array.sort(d3.ascending), .5) : undefined;
};
d3.min = function(array, f) {
var i = -1,
n = array.length,
a,
b;
if (arguments.length === 1) {
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
while (++i < n) if ((b = array[i]) != null && a > b) a = b;
} else {
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
while (++i < n) if ((b = f.call(array, array[i], i)) != null && a > b) a = b;
}
return a;
};
d3.max = function(array, f) {
var i = -1,
n = array.length,
a,
b;
if (arguments.length === 1) {
while (++i < n && ((a = array[i]) == null || a != a)) a = undefined;
while (++i < n) if ((b = array[i]) != null && b > a) a = b;
} else {
while (++i < n && ((a = f.call(array, array[i], i)) == null || a != a)) a = undefined;
while (++i < n) if ((b = f.call(array, array[i], i)) != null && b > a) a = b;
}
return a;
};
d3.extent = function(array, f) {
var i = -1,
n = array.length,
a,
b,
c;
if (arguments.length === 1) {
while (++i < n && ((a = c = array[i]) == null || a != a)) a = c = undefined;
while (++i < n) if ((b = array[i]) != null) {
if (a > b) a = b;
if (c < b) c = b;
}
} else {
while (++i < n && ((a = c = f.call(array, array[i], i)) == null || a != a)) a = undefined;
while (++i < n) if ((b = f.call(array, array[i], i)) != null) {
if (a > b) a = b;
if (c < b) c = b;
}
}
return [a, c];
};
d3.random = {
normal: function(mean, deviation) {
if (arguments.length < 2) deviation = 1;
if (arguments.length < 1) mean = 0;
return function() {
var x, y, r;
do {
x = Math.random() * 2 - 1;
y = Math.random() * 2 - 1;
r = x * x + y * y;
} while (!r || r > 1);
return mean + deviation * x * Math.sqrt(-2 * Math.log(r) / r);
};
}
};
function d3_number(x) {
return x != null && !isNaN(x);
}
d3.sum = function(array, f) {
var s = 0,
n = array.length,
a,
i = -1;
if (arguments.length === 1) {
while (++i < n) if (!isNaN(a = +array[i])) s += a;
} else {
while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a;
}
return s;
};
// R-7 per <http://en.wikipedia.org/wiki/Quantile>
d3.quantile = function(values, p) {
var H = (values.length - 1) * p + 1,
h = Math.floor(H),
v = values[h - 1],
e = H - h;
return e ? v + e * (values[h] - v) : v;
};
d3.transpose = function(matrix) {
return d3.zip.apply(d3, matrix);
};
d3.zip = function() {
if (!(n = arguments.length)) return [];
for (var i = -1, m = d3.min(arguments, d3_zipLength), zips = new Array(m); ++i < m;) {
for (var j = -1, n, zip = zips[i] = new Array(n); ++j < n;) {
zip[j] = arguments[j][i];
}
}
return zips;
};
function d3_zipLength(d) {
return d.length;
}
d3.bisector = function(f) {
return {
left: function(a, x, lo, hi) {
if (arguments.length < 3) lo = 0;
if (arguments.length < 4) hi = a.length;
while (lo < hi) {
var mid = lo + hi >> 1;
if (f.call(a, a[mid], mid) < x) lo = mid + 1;
else hi = mid;
}
return lo;
},
right: function(a, x, lo, hi) {
if (arguments.length < 3) lo = 0;
if (arguments.length < 4) hi = a.length;
while (lo < hi) {
var mid = lo + hi >> 1;
if (x < f.call(a, a[mid], mid)) hi = mid;
else lo = mid + 1;
}
return lo;
}
};
};
var d3_bisector = d3.bisector(function(d) { return d; });
d3.bisectLeft = d3_bisector.left;
d3.bisect = d3.bisectRight = d3_bisector.right;
d3.first = function(array, f) {
var i = 0,
n = array.length,
a = array[0],
b;
if (arguments.length === 1) f = d3.ascending;
while (++i < n) {
if (f.call(array, a, b = array[i]) > 0) {
a = b;
}
}
return a;
};
d3.last = function(array, f) {
var i = 0,
n = array.length,
a = array[0],
b;
if (arguments.length === 1) f = d3.ascending;
while (++i < n) {
if (f.call(array, a, b = array[i]) <= 0) {
a = b;
}
}
return a;
};
d3.nest = function() {
var nest = {},
keys = [],
sortKeys = [],
sortValues,
rollup;
function map(array, depth) {
if (depth >= keys.length) return rollup
? rollup.call(nest, array) : (sortValues
? array.sort(sortValues)
: array);
var i = -1,
n = array.length,
key = keys[depth++],
keyValue,
object,
valuesByKey = new d3_Map,
values,
o = {};
while (++i < n) {
if (values = valuesByKey.get(keyValue = key(object = array[i]))) {
values.push(object);
} else {
valuesByKey.set(keyValue, [object]);
}
}
valuesByKey.forEach(function(keyValue) {
o[keyValue] = map(valuesByKey.get(keyValue), depth);
});
return o;
}
function entries(map, depth) {
if (depth >= keys.length) return map;
var a = [],
sortKey = sortKeys[depth++],
key;
for (key in map) {
a.push({key: key, values: entries(map[key], depth)});
}
if (sortKey) a.sort(function(a, b) {
return sortKey(a.key, b.key);
});
return a;
}
nest.map = function(array) {
return map(array, 0);
};
nest.entries = function(array) {
return entries(map(array, 0), 0);
};
nest.key = function(d) {
keys.push(d);
return nest;
};
// Specifies the order for the most-recently specified key.
// Note: only applies to entries. Map keys are unordered!
nest.sortKeys = function(order) {
sortKeys[keys.length - 1] = order;
return nest;
};
// Specifies the order for leaf values.
// Applies to both maps and entries array.
nest.sortValues = function(order) {
sortValues = order;
return nest;
};
nest.rollup = function(f) {
rollup = f;
return nest;
};
return nest;
};
d3.keys = function(map) {
var keys = [];
for (var key in map) keys.push(key);
return keys;
};
d3.values = function(map) {
var values = [];
for (var key in map) values.push(map[key]);
return values;
};
d3.entries = function(map) {
var entries = [];
for (var key in map) entries.push({key: key, value: map[key]});
return entries;
};
d3.permute = function(array, indexes) {
var permutes = [],
i = -1,
n = indexes.length;
while (++i < n) permutes[i] = array[indexes[i]];
return permutes;
};
d3.merge = function(arrays) {
return Array.prototype.concat.apply([], arrays);
};
d3.split = function(array, f) {
var arrays = [],
values = [],
value,
i = -1,
n = array.length;
if (arguments.length < 2) f = d3_splitter;
while (++i < n) {
if (f.call(values, value = array[i], i)) {
values = [];
} else {
if (!values.length) arrays.push(values);
values.push(value);
}
}
return arrays;
};
function d3_splitter(d) {
return d == null;
}
function d3_collapse(s) {
return s.replace(/(^\s+)|(\s+$)/g, "").replace(/\s+/g, " ");
}
d3.range = function(start, stop, step) {
if (arguments.length < 3) {
step = 1;
if (arguments.length < 2) {
stop = start;
start = 0;
}
}
if ((stop - start) / step === Infinity) throw new Error("infinite range");
var range = [],
k = d3_range_integerScale(Math.abs(step)),
i = -1,
j;
start *= k, stop *= k, step *= k;
if (step < 0) while ((j = start + step * ++i) > stop) range.push(j / k);
else while ((j = start + step * ++i) < stop) range.push(j / k);
return range;
};
function d3_range_integerScale(x) {
var k = 1;
while (x * k % 1) k *= 10;
return k;
}
d3.requote = function(s) {
return s.replace(d3_requote_re, "\\$&");
};
var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
d3.round = function(x, n) {
return n
? Math.round(x * (n = Math.pow(10, n))) / n
: Math.round(x);
};
d3.xhr = function(url, mime, callback) {
var req = new XMLHttpRequest;
if (arguments.length < 3) callback = mime, mime = null;
else if (mime && req.overrideMimeType) req.overrideMimeType(mime);
req.open("GET", url, true);
if (mime) req.setRequestHeader("Accept", mime);
req.onreadystatechange = function() {
if (req.readyState === 4) callback(req.status < 300 ? req : null);
};
req.send(null);
};
d3.text = function(url, mime, callback) {
function ready(req) {
callback(req && req.responseText);
}
if (arguments.length < 3) {
callback = mime;
mime = null;
}
d3.xhr(url, mime, ready);
};
d3.json = function(url, callback) {
d3.text(url, "application/json", function(text) {
callback(text ? JSON.parse(text) : null);
});
};
d3.html = function(url, callback) {
d3.text(url, "text/html", function(text) {
if (text != null) { // Treat empty string as valid HTML.
var range = document.createRange();
range.selectNode(document.body);
text = range.createContextualFragment(text);
}
callback(text);
});
};
d3.xml = function(url, mime, callback) {
function ready(req) {
callback(req && req.responseXML);
}
if (arguments.length < 3) {
callback = mime;
mime = null;
}
d3.xhr(url, mime, ready);
};
var d3_nsPrefix = {
svg: "http://www.w3.org/2000/svg",
xhtml: "http://www.w3.org/1999/xhtml",
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
d3.ns = {
prefix: d3_nsPrefix,
qualify: function(name) {
var i = name.indexOf(":"),
prefix = name;
if (i >= 0) {
prefix = name.substring(0, i);
name = name.substring(i + 1);
}
return d3_nsPrefix.hasOwnProperty(prefix)
? {space: d3_nsPrefix[prefix], local: name}
: name;
}
};
d3.dispatch = function() {
var dispatch = new d3_dispatch,
i = -1,
n = arguments.length;
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
return dispatch;
};
function d3_dispatch() {}
d3_dispatch.prototype.on = function(type, listener) {
var i = type.indexOf("."),
name = "";
// Extract optional namespace, e.g., "click.foo"
if (i > 0) {
name = type.substring(i + 1);
type = type.substring(0, i);
}
return arguments.length < 2
? this[type].on(name)
: this[type].on(name, listener);
};
function d3_dispatch_event(dispatch) {
var listeners = [],
listenerByName = new d3_Map;
function event() {
var z = listeners, // defensive reference
i = -1,
n = z.length,
l;
while (++i < n) if (l = z[i].on) l.apply(this, arguments);
return dispatch;
}
event.on = function(name, listener) {
var l = listenerByName.get(name),
i;
// return the current listener, if any
if (arguments.length < 2) return l && l.on;
// remove the old listener, if any (with copy-on-write)
if (l) {
l.on = null;
listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1));
listenerByName.remove(name);
}
// add the new listener, if any
if (listener) listeners.push(listenerByName.set(name, {on: listener}));
return dispatch;
};
return event;
}
// TODO align
d3.format = function(specifier) {
var match = d3_format_re.exec(specifier),
fill = match[1] || " ",
sign = match[3] || "",
zfill = match[5],
width = +match[6],
comma = match[7],
precision = match[8],
type = match[9],
scale = 1,
suffix = "",
integer = false;
if (precision) precision = +precision.substring(1);
if (zfill) {
fill = "0"; // TODO align = "=";
if (comma) width -= Math.floor((width - 1) / 4);
}
switch (type) {
case "n": comma = true; type = "g"; break;
case "%": scale = 100; suffix = "%"; type = "f"; break;
case "p": scale = 100; suffix = "%"; type = "r"; break;
case "d": integer = true; precision = 0; break;
case "s": scale = -1; type = "r"; break;
}
// If no precision is specified for r, fallback to general notation.
if (type == "r" && !precision) type = "g";
type = d3_format_types.get(type) || d3_format_typeDefault;
return function(value) {
// Return the empty string for floats formatted as ints.
if (integer && (value % 1)) return "";
// Convert negative to positive, and record the sign prefix.
var negative = (value < 0) && (value = -value) ? "\u2212" : sign;
// Apply the scale, computing it from the value's exponent for si format.
if (scale < 0) {
var prefix = d3.formatPrefix(value, precision);
value *= prefix.scale;
suffix = prefix.symbol;
} else {
value *= scale;
}
// Convert to the desired precision.
value = type(value, precision);
// If the fill character is 0, the sign and group is applied after the fill.
if (zfill) {
var length = value.length + negative.length;
if (length < width) value = new Array(width - length + 1).join(fill) + value;
if (comma) value = d3_format_group(value);
value = negative + value;
}
// Otherwise (e.g., space-filling), the sign and group is applied before.
else {
if (comma) value = d3_format_group(value);
value = negative + value;
var length = value.length;
if (length < width) value = new Array(width - length + 1).join(fill) + value;
}
return value + suffix;
};
};
// [[fill]align][sign][#][0][width][,][.precision][type]
var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/;
var d3_format_types = d3.map({
g: function(x, p) { return x.toPrecision(p); },
e: function(x, p) { return x.toExponential(p); },
f: function(x, p) { return x.toFixed(p); },
r: function(x, p) { return d3.round(x, p = d3_format_precision(x, p)).toFixed(Math.max(0, Math.min(20, p))); }
});
function d3_format_precision(x, p) {
return p - (x ? 1 + Math.floor(Math.log(x + Math.pow(10, 1 + Math.floor(Math.log(x) / Math.LN10) - p)) / Math.LN10) : 1);
}
function d3_format_typeDefault(x) {
return x + "";
}
// Apply comma grouping for thousands.
function d3_format_group(value) {
var i = value.lastIndexOf("."),
f = i >= 0 ? value.substring(i) : (i = value.length, ""),
t = [];
while (i > 0) t.push(value.substring(i -= 3, i + 3));
return t.reverse().join(",") + f;
}
var d3_formatPrefixes = ["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(d3_formatPrefix);
d3.formatPrefix = function(value, precision) {
var i = 0;
if (value) {
if (value < 0) value *= -1;
if (precision) value = d3.round(value, d3_format_precision(value, precision));
i = 1 + Math.floor(1e-12 + Math.log(value) / Math.LN10);
i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3));
}
return d3_formatPrefixes[8 + i / 3];
};
function d3_formatPrefix(d, i) {
return {
scale: Math.pow(10, (8 - i) * 3),
symbol: d
};
}
/*
* TERMS OF USE - EASING EQUATIONS
*
* Open source under the BSD License.
*
* Copyright 2001 Robert Penner
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* - Neither the name of the author nor the names of contributors may be used to
* endorse or promote products derived from this software without specific
* prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
var d3_ease_quad = d3_ease_poly(2),
d3_ease_cubic = d3_ease_poly(3),
d3_ease_default = function() { return d3_ease_identity; };
var d3_ease = d3.map({
linear: d3_ease_default,
poly: d3_ease_poly,
quad: function() { return d3_ease_quad; },
cubic: function() { return d3_ease_cubic; },
sin: function() { return d3_ease_sin; },
exp: function() { return d3_ease_exp; },
circle: function() { return d3_ease_circle; },
elastic: d3_ease_elastic,
back: d3_ease_back,
bounce: function() { return d3_ease_bounce; }
});
var d3_ease_mode = d3.map({
"in": d3_ease_identity,
"out": d3_ease_reverse,
"in-out": d3_ease_reflect,
"out-in": function(f) { return d3_ease_reflect(d3_ease_reverse(f)); }
});
d3.ease = function(name) {
var i = name.indexOf("-"),
t = i >= 0 ? name.substring(0, i) : name,
m = i >= 0 ? name.substring(i + 1) : "in";
t = d3_ease.get(t) || d3_ease_default;
m = d3_ease_mode.get(m) || d3_ease_identity;
return d3_ease_clamp(m(t.apply(null, Array.prototype.slice.call(arguments, 1))));
};
function d3_ease_clamp(f) {
return function(t) {
return t <= 0 ? 0 : t >= 1 ? 1 : f(t);
};
}
function d3_ease_reverse(f) {
return function(t) {
return 1 - f(1 - t);
};
}
function d3_ease_reflect(f) {
return function(t) {
return .5 * (t < .5 ? f(2 * t) : (2 - f(2 - 2 * t)));
};
}
function d3_ease_identity(t) {
return t;
}
function d3_ease_poly(e) {
return function(t) {
return Math.pow(t, e);
};
}
function d3_ease_sin(t) {
return 1 - Math.cos(t * Math.PI / 2);
}
function d3_ease_exp(t) {
return Math.pow(2, 10 * (t - 1));
}
function d3_ease_circle(t) {
return 1 - Math.sqrt(1 - t * t);
}
function d3_ease_elastic(a, p) {
var s;
if (arguments.length < 2) p = 0.45;
if (arguments.length < 1) { a = 1; s = p / 4; }
else s = p / (2 * Math.PI) * Math.asin(1 / a);
return function(t) {
return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * Math.PI / p);
};
}
function d3_ease_back(s) {
if (!s) s = 1.70158;
return function(t) {
return t * t * ((s + 1) * t - s);
};
}
function d3_ease_bounce(t) {
return t < 1 / 2.75 ? 7.5625 * t * t
: t < 2 / 2.75 ? 7.5625 * (t -= 1.5 / 2.75) * t + .75
: t < 2.5 / 2.75 ? 7.5625 * (t -= 2.25 / 2.75) * t + .9375
: 7.5625 * (t -= 2.625 / 2.75) * t + .984375;
}
d3.event = null;
function d3_eventCancel() {
d3.event.stopPropagation();
d3.event.preventDefault();
}
function d3_eventSource() {
var e = d3.event, s;
while (s = e.sourceEvent) e = s;
return e;
}
// Like d3.dispatch, but for custom events abstracting native UI events. These
// events have a target component (such as a brush), a target element (such as
// the svg:g element containing the brush) and the standard arguments `d` (the
// target element's data) and `i` (the selection index of the target element).
function d3_eventDispatch(target) {
var dispatch = new d3_dispatch,
i = 0,
n = arguments.length;
while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch);
// Creates a dispatch context for the specified `thiz` (typically, the target
// DOM element that received the source event) and `argumentz` (typically, the
// data `d` and index `i` of the target element). The returned function can be
// used to dispatch an event to any registered listeners; the function takes a
// single argument as input, being the event to dispatch. The event must have
// a "type" attribute which corresponds to a type registered in the
// constructor. This context will automatically populate the "sourceEvent" and
// "target" attributes of the event, as well as setting the `d3.event` global
// for the duration of the notification.
dispatch.of = function(thiz, argumentz) {
return function(e1) {
try {
var e0 =
e1.sourceEvent = d3.event;
e1.target = target;
d3.event = e1;
dispatch[e1.type].apply(thiz, argumentz);
} finally {
d3.event = e0;
}
};
};
return dispatch;
}
d3.interpolate = function(a, b) {
var i = d3.interpolators.length, f;
while (--i >= 0 && !(f = d3.interpolators[i](a, b)));
return f;
};
d3.interpolateNumber = function(a, b) {
b -= a;
return function(t) { return a + b * t; };
};
d3.interpolateRound = function(a, b) {
b -= a;
return function(t) { return Math.round(a + b * t); };
};
d3.interpolateString = function(a, b) {
var m, // current match
i, // current index
j, // current index (for coallescing)
s0 = 0, // start index of current string prefix
s1 = 0, // end index of current string prefix
s = [], // string constants and placeholders
q = [], // number interpolators
n, // q.length
o;
// Reset our regular expression!
d3_interpolate_number.lastIndex = 0;
// Find all numbers in b.
for (i = 0; m = d3_interpolate_number.exec(b); ++i) {
if (m.index) s.push(b.substring(s0, s1 = m.index));
q.push({i: s.length, x: m[0]});
s.push(null);
s0 = d3_interpolate_number.lastIndex;
}
if (s0 < b.length) s.push(b.substring(s0));
// Find all numbers in a.
for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) {
o = q[i];
if (o.x == m[0]) { // The numbers match, so coallesce.
if (o.i) {
if (s[o.i + 1] == null) { // This match is followed by another number.
s[o.i - 1] += o.x;
s.splice(o.i, 1);
for (j = i + 1; j < n; ++j) q[j].i--;
} else { // This match is followed by a string, so coallesce twice.
s[o.i - 1] += o.x + s[o.i + 1];
s.splice(o.i, 2);
for (j = i + 1; j < n; ++j) q[j].i -= 2;
}
} else {
if (s[o.i + 1] == null) { // This match is followed by another number.
s[o.i] = o.x;
} else { // This match is followed by a string, so coallesce twice.
s[o.i] = o.x + s[o.i + 1];
s.splice(o.i + 1, 1);
for (j = i + 1; j < n; ++j) q[j].i--;
}
}
q.splice(i, 1);
n--;
i--;
} else {
o.x = d3.interpolateNumber(parseFloat(m[0]), parseFloat(o.x));
}
}
// Remove any numbers in b not found in a.
while (i < n) {
o = q.pop();
if (s[o.i + 1] == null) { // This match is followed by another number.
s[o.i] = o.x;
} else { // This match is followed by a string, so coallesce twice.
s[o.i] = o.x + s[o.i + 1];
s.splice(o.i + 1, 1);
}
n--;
}
// Special optimization for only a single match.
if (s.length === 1) {
return s[0] == null ? q[0].x : function() { return b; };
}
// Otherwise, interpolate each of the numbers and rejoin the string.
return function(t) {
for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t);
return s.join("");
};
};
d3.interpolateTransform = function(a, b) {
var s = [], // string constants and placeholders
q = [], // number interpolators
n,
A = d3.transform(a),
B = d3.transform(b),
ta = A.translate,
tb = B.translate,
ra = A.rotate,
rb = B.rotate,
wa = A.skew,
wb = B.skew,
ka = A.scale,
kb = B.scale;
if (ta[0] != tb[0] || ta[1] != tb[1]) {
s.push("translate(", null, ",", null, ")");
q.push({i: 1, x: d3.interpolateNumber(ta[0], tb[0])}, {i: 3, x: d3.interpolateNumber(ta[1], tb[1])});
} else if (tb[0] || tb[1]) {
s.push("translate(" + tb + ")");
} else {
s.push("");
}
if (ra != rb) {
q.push({i: s.push(s.pop() + "rotate(", null, ")") - 2, x: d3.interpolateNumber(ra, rb)});
} else if (rb) {
s.push(s.pop() + "rotate(" + rb + ")");
}
if (wa != wb) {
q.push({i: s.push(s.pop() + "skewX(", null, ")") - 2, x: d3.interpolateNumber(wa, wb)});
} else if (wb) {
s.push(s.pop() + "skewX(" + wb + ")");
}
if (ka[0] != kb[0] || ka[1] != kb[1]) {
n = s.push(s.pop() + "scale(", null, ",", null, ")");
q.push({i: n - 4, x: d3.interpolateNumber(ka[0], kb[0])}, {i: n - 2, x: d3.interpolateNumber(ka[1], kb[1])});
} else if (kb[0] != 1 || kb[1] != 1) {
s.push(s.pop() + "scale(" + kb + ")");
}
n = q.length;
return function(t) {
var i = -1, o;
while (++i < n) s[(o = q[i]).i] = o.x(t);
return s.join("");
};
};
d3.interpolateRgb = function(a, b) {
a = d3.rgb(a);
b = d3.rgb(b);
var ar = a.r,
ag = a.g,
ab = a.b,
br = b.r - ar,
bg = b.g - ag,
bb = b.b - ab;
return function(t) {
return "#"
+ d3_rgb_hex(Math.round(ar + br * t))
+ d3_rgb_hex(Math.round(ag + bg * t))
+ d3_rgb_hex(Math.round(ab + bb * t));
};
};
// interpolates HSL space, but outputs RGB string (for compatibility)
d3.interpolateHsl = function(a, b) {
a = d3.hsl(a);
b = d3.hsl(b);
var h0 = a.h,
s0 = a.s,
l0 = a.l,
h1 = b.h - h0,
s1 = b.s - s0,
l1 = b.l - l0;
return function(t) {
return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t).toString();
};
};
d3.interpolateArray = function(a, b) {
var x = [],
c = [],
na = a.length,
nb = b.length,
n0 = Math.min(a.length, b.length),
i;
for (i = 0; i < n0; ++i) x.push(d3.interpolate(a[i], b[i]));
for (; i < na; ++i) c[i] = a[i];
for (; i < nb; ++i) c[i] = b[i];
return function(t) {
for (i = 0; i < n0; ++i) c[i] = x[i](t);
return c;
};
};
d3.interpolateObject = function(a, b) {
var i = {},
c = {},
k;
for (k in a) {
if (k in b) {
i[k] = d3_interpolateByName(k)(a[k], b[k]);
} else {
c[k] = a[k];
}
}
for (k in b) {
if (!(k in a)) {
c[k] = b[k];
}
}
return function(t) {
for (k in i) c[k] = i[k](t);
return c;
};
}
var d3_interpolate_number = /[-+]?(?:\d*\.?\d+)(?:[eE][-+]?\d+)?/g;
function d3_interpolateByName(n) {
return n == "transform"
? d3.interpolateTransform
: d3.interpolate;
}
d3.interpolators = [
d3.interpolateObject,
function(a, b) { return (b instanceof Array) && d3.interpolateArray(a, b); },
function(a, b) { return (typeof a === "string" || typeof b === "string") && d3.interpolateString(a + "", b + ""); },
function(a, b) { return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(a, b); },
function(a, b) { return !isNaN(a = +a) && !isNaN(b = +b) && d3.interpolateNumber(a, b); }
];
function d3_uninterpolateNumber(a, b) {
b = b - (a = +a) ? 1 / (b - a) : 0;
return function(x) { return (x - a) * b; };
}
function d3_uninterpolateClamp(a, b) {
b = b - (a = +a) ? 1 / (b - a) : 0;
return function(x) { return Math.max(0, Math.min(1, (x - a) * b)); };
}
d3.rgb = function(r, g, b) {
return arguments.length === 1
? (r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b)
: d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb))
: d3_rgb(~~r, ~~g, ~~b);
};
function d3_rgb(r, g, b) {
return new d3_Rgb(r, g, b);
}
function d3_Rgb(r, g, b) {
this.r = r;
this.g = g;
this.b = b;
}
d3_Rgb.prototype.brighter = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
var r = this.r,
g = this.g,
b = this.b,
i = 30;
if (!r && !g && !b) return d3_rgb(i, i, i);
if (r && r < i) r = i;
if (g && g < i) g = i;
if (b && b < i) b = i;
return d3_rgb(
Math.min(255, Math.floor(r / k)),
Math.min(255, Math.floor(g / k)),
Math.min(255, Math.floor(b / k)));
};
d3_Rgb.prototype.darker = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_rgb(
Math.floor(k * this.r),
Math.floor(k * this.g),
Math.floor(k * this.b));
};
d3_Rgb.prototype.hsl = function() {
return d3_rgb_hsl(this.r, this.g, this.b);
};
d3_Rgb.prototype.toString = function() {
return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
};
function d3_rgb_hex(v) {
return v < 0x10
? "0" + Math.max(0, v).toString(16)
: Math.min(255, v).toString(16);
}
function d3_rgb_parse(format, rgb, hsl) {
var r = 0, // red channel; int in [0, 255]
g = 0, // green channel; int in [0, 255]
b = 0, // blue channel; int in [0, 255]
m1, // CSS color specification match
m2, // CSS color specification type (e.g., rgb)
name;
/* Handle hsl, rgb. */
m1 = /([a-z]+)\((.*)\)/i.exec(format);
if (m1) {
m2 = m1[2].split(",");
switch (m1[1]) {
case "hsl": {
return hsl(
parseFloat(m2[0]), // degrees
parseFloat(m2[1]) / 100, // percentage
parseFloat(m2[2]) / 100 // percentage
);
}
case "rgb": {
return rgb(
d3_rgb_parseNumber(m2[0]),
d3_rgb_parseNumber(m2[1]),
d3_rgb_parseNumber(m2[2])
);
}
}
}
/* Named colors. */
if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b);
/* Hexadecimal colors: #rgb and #rrggbb. */
if (format != null && format.charAt(0) === "#") {
if (format.length === 4) {
r = format.charAt(1); r += r;
g = format.charAt(2); g += g;
b = format.charAt(3); b += b;
} else if (format.length === 7) {
r = format.substring(1, 3);
g = format.substring(3, 5);
b = format.substring(5, 7);
}
r = parseInt(r, 16);
g = parseInt(g, 16);
b = parseInt(b, 16);
}
return rgb(r, g, b);
}
function d3_rgb_hsl(r, g, b) {
var min = Math.min(r /= 255, g /= 255, b /= 255),
max = Math.max(r, g, b),
d = max - min,
h,
s,
l = (max + min) / 2;
if (d) {
s = l < .5 ? d / (max + min) : d / (2 - max - min);
if (r == max) h = (g - b) / d + (g < b ? 6 : 0);
else if (g == max) h = (b - r) / d + 2;
else h = (r - g) / d + 4;
h *= 60;
} else {
s = h = 0;
}
return d3_hsl(h, s, l);
}
function d3_rgb_parseNumber(c) { // either integer or percentage
var f = parseFloat(c);
return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f;
}
var d3_rgb_names = d3.map({
aliceblue: "#f0f8ff",
antiquewhite: "#faebd7",
aqua: "#00ffff",
aquamarine: "#7fffd4",
azure: "#f0ffff",
beige: "#f5f5dc",
bisque: "#ffe4c4",
black: "#000000",
blanchedalmond: "#ffebcd",
blue: "#0000ff",
blueviolet: "#8a2be2",
brown: "#a52a2a",
burlywood: "#deb887",
cadetblue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
cornflowerblue: "#6495ed",
cornsilk: "#fff8dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkblue: "#00008b",
darkcyan: "#008b8b",
darkgoldenrod: "#b8860b",
darkgray: "#a9a9a9",
darkgreen: "#006400",
darkgrey: "#a9a9a9",
darkkhaki: "#bdb76b",
darkmagenta: "#8b008b",
darkolivegreen: "#556b2f",
darkorange: "#ff8c00",
darkorchid: "#9932cc",
darkred: "#8b0000",
darksalmon: "#e9967a",
darkseagreen: "#8fbc8f",
darkslateblue: "#483d8b",
darkslategray: "#2f4f4f",
darkslategrey: "#2f4f4f",
darkturquoise: "#00ced1",
darkviolet: "#9400d3",
deeppink: "#ff1493",
deepskyblue: "#00bfff",
dimgray: "#696969",
dimgrey: "#696969",
dodgerblue: "#1e90ff",
firebrick: "#b22222",
floralwhite: "#fffaf0",
forestgreen: "#228b22",
fuchsia: "#ff00ff",
gainsboro: "#dcdcdc",
ghostwhite: "#f8f8ff",
gold: "#ffd700",
goldenrod: "#daa520",
gray: "#808080",
green: "#008000",
greenyellow: "#adff2f",
grey: "#808080",
honeydew: "#f0fff0",
hotpink: "#ff69b4",
indianred: "#cd5c5c",
indigo: "#4b0082",
ivory: "#fffff0",
khaki: "#f0e68c",
lavender: "#e6e6fa",
lavenderblush: "#fff0f5",
lawngreen: "#7cfc00",
lemonchiffon: "#fffacd",
lightblue: "#add8e6",
lightcoral: "#f08080",
lightcyan: "#e0ffff",
lightgoldenrodyellow: "#fafad2",
lightgray: "#d3d3d3",
lightgreen: "#90ee90",
lightgrey: "#d3d3d3",
lightpink: "#ffb6c1",
lightsalmon: "#ffa07a",
lightseagreen: "#20b2aa",
lightskyblue: "#87cefa",
lightslategray: "#778899",
lightslategrey: "#778899",
lightsteelblue: "#b0c4de",
lightyellow: "#ffffe0",
lime: "#00ff00",
limegreen: "#32cd32",
linen: "#faf0e6",
magenta: "#ff00ff",
maroon: "#800000",
mediumaquamarine: "#66cdaa",
mediumblue: "#0000cd",
mediumorchid: "#ba55d3",
mediumpurple: "#9370db",
mediumseagreen: "#3cb371",
mediumslateblue: "#7b68ee",
mediumspringgreen: "#00fa9a",
mediumturquoise: "#48d1cc",
mediumvioletred: "#c71585",
midnightblue: "#191970",
mintcream: "#f5fffa",
mistyrose: "#ffe4e1",
moccasin: "#ffe4b5",
navajowhite: "#ffdead",
navy: "#000080",
oldlace: "#fdf5e6",
olive: "#808000",
olivedrab: "#6b8e23",
orange: "#ffa500",
orangered: "#ff4500",
orchid: "#da70d6",
palegoldenrod: "#eee8aa",
palegreen: "#98fb98",
paleturquoise: "#afeeee",
palevioletred: "#db7093",
papayawhip: "#ffefd5",
peachpuff: "#ffdab9",
peru: "#cd853f",
pink: "#ffc0cb",
plum: "#dda0dd",
powderblue: "#b0e0e6",
purple: "#800080",
red: "#ff0000",
rosybrown: "#bc8f8f",
royalblue: "#4169e1",
saddlebrown: "#8b4513",
salmon: "#fa8072",
sandybrown: "#f4a460",
seagreen: "#2e8b57",
seashell: "#fff5ee",
sienna: "#a0522d",
silver: "#c0c0c0",
skyblue: "#87ceeb",
slateblue: "#6a5acd",
slategray: "#708090",
slategrey: "#708090",
snow: "#fffafa",
springgreen: "#00ff7f",
steelblue: "#4682b4",
tan: "#d2b48c",
teal: "#008080",
thistle: "#d8bfd8",
tomato: "#ff6347",
turquoise: "#40e0d0",
violet: "#ee82ee",
wheat: "#f5deb3",
white: "#ffffff",
whitesmoke: "#f5f5f5",
yellow: "#ffff00",
yellowgreen: "#9acd32"
});
d3_rgb_names.forEach(function(key, value) {
d3_rgb_names.set(key, d3_rgb_parse(value, d3_rgb, d3_hsl_rgb));
});
d3.hsl = function(h, s, l) {
return arguments.length === 1
? (h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l)
: d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl))
: d3_hsl(+h, +s, +l);
};
function d3_hsl(h, s, l) {
return new d3_Hsl(h, s, l);
}
function d3_Hsl(h, s, l) {
this.h = h;
this.s = s;
this.l = l;
}
d3_Hsl.prototype.brighter = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, this.l / k);
};
d3_Hsl.prototype.darker = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, k * this.l);
};
d3_Hsl.prototype.rgb = function() {
return d3_hsl_rgb(this.h, this.s, this.l);
};
d3_Hsl.prototype.toString = function() {
return this.rgb().toString();
};
function d3_hsl_rgb(h, s, l) {
var m1,
m2;
/* Some simple corrections for h, s and l. */
h = h % 360; if (h < 0) h += 360;
s = s < 0 ? 0 : s > 1 ? 1 : s;
l = l < 0 ? 0 : l > 1 ? 1 : l;
/* From FvD 13.37, CSS Color Module Level 3 */
m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
m1 = 2 * l - m2;
function v(h) {
if (h > 360) h -= 360;
else if (h < 0) h += 360;
if (h < 60) return m1 + (m2 - m1) * h / 60;
if (h < 180) return m2;
if (h < 240) return m1 + (m2 - m1) * (240 - h) / 60;
return m1;
}
function vv(h) {
return Math.round(v(h) * 255);
}
return d3_rgb(vv(h + 120), vv(h), vv(h - 120));
}
function d3_selection(groups) {
d3_arraySubclass(groups, d3_selectionPrototype);
return groups;
}
var d3_select = function(s, n) { return n.querySelector(s); },
d3_selectAll = function(s, n) { return n.querySelectorAll(s); },
d3_selectRoot = document.documentElement,
d3_selectMatcher = d3_selectRoot.matchesSelector || d3_selectRoot.webkitMatchesSelector || d3_selectRoot.mozMatchesSelector || d3_selectRoot.msMatchesSelector || d3_selectRoot.oMatchesSelector,
d3_selectMatches = function(n, s) { return d3_selectMatcher.call(n, s); };
// Prefer Sizzle, if available.
if (typeof Sizzle === "function") {
d3_select = function(s, n) { return Sizzle(s, n)[0]; };
d3_selectAll = function(s, n) { return Sizzle.uniqueSort(Sizzle(s, n)); };
d3_selectMatches = Sizzle.matchesSelector;
}
var d3_selectionPrototype = [];
d3.selection = function() {
return d3_selectionRoot;
};
d3.selection.prototype = d3_selectionPrototype;
d3_selectionPrototype.select = function(selector) {
var subgroups = [],
subgroup,
subnode,
group,
node;
if (typeof selector !== "function") selector = d3_selection_selector(selector);
for (var j = -1, m = this.length; ++j < m;) {
subgroups.push(subgroup = []);
subgroup.parentNode = (group = this[j]).parentNode;
for (var i = -1, n = group.length; ++i < n;) {
if (node = group[i]) {
subgroup.push(subnode = selector.call(node, node.__data__, i));
if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
} else {
subgroup.push(null);
}
}
}
return d3_selection(subgroups);
};
function d3_selection_selector(selector) {
return function() {
return d3_select(selector, this);
};
}
d3_selectionPrototype.selectAll = function(selector) {
var subgroups = [],
subgroup,
node;
if (typeof selector !== "function") selector = d3_selection_selectorAll(selector);
for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
if (node = group[i]) {
subgroups.push(subgroup = d3_array(selector.call(node, node.__data__, i)));
subgroup.parentNode = node;
}
}
}
return d3_selection(subgroups);
};
function d3_selection_selectorAll(selector) {
return function() {
return d3_selectAll(selector, this);
};
}
d3_selectionPrototype.attr = function(name, value) {
name = d3.ns.qualify(name);
// If no value is specified, return the first value.
if (arguments.length < 2) {
var node = this.node();
return name.local
? node.getAttributeNS(name.space, name.local)
: node.getAttribute(name);
}
function attrNull() {
this.removeAttribute(name);
}
function attrNullNS() {
this.removeAttributeNS(name.space, name.local);
}
function attrConstant() {
this.setAttribute(name, value);
}
function attrConstantNS() {
this.setAttributeNS(name.space, name.local, value);
}
function attrFunction() {
var x = value.apply(this, arguments);
if (x == null) this.removeAttribute(name);
else this.setAttribute(name, x);
}
function attrFunctionNS() {
var x = value.apply(this, arguments);
if (x == null) this.removeAttributeNS(name.space, name.local);
else this.setAttributeNS(name.space, name.local, x);
}
return this.each(value == null
? (name.local ? attrNullNS : attrNull) : (typeof value === "function"
? (name.local ? attrFunctionNS : attrFunction)
: (name.local ? attrConstantNS : attrConstant)));
};
d3_selectionPrototype.classed = function(name, value) {
var names = name.split(d3_selection_classedWhitespace),
n = names.length,
i = -1;
if (arguments.length > 1) {
while (++i < n) d3_selection_classed.call(this, names[i], value);
return this;
} else {
while (++i < n) if (!d3_selection_classed.call(this, names[i])) return false;
return true;
}
};
var d3_selection_classedWhitespace = /\s+/g;
function d3_selection_classed(name, value) {
var re = new RegExp("(^|\\s+)" + d3.requote(name) + "(\\s+|$)", "g");
// If no value is specified, return the first value.
if (arguments.length < 2) {
var node = this.node();
if (c = node.classList) return c.contains(name);
var c = node.className;
re.lastIndex = 0;
return re.test(c.baseVal != null ? c.baseVal : c);
}
function classedAdd() {
if (c = this.classList) return c.add(name);
var c = this.className,
cb = c.baseVal != null,
cv = cb ? c.baseVal : c;
re.lastIndex = 0;
if (!re.test(cv)) {
cv = d3_collapse(cv + " " + name);
if (cb) c.baseVal = cv;
else this.className = cv;
}
}
function classedRemove() {
if (c = this.classList) return c.remove(name);
var c = this.className,
cb = c.baseVal != null,
cv = cb ? c.baseVal : c;
cv = d3_collapse(cv.replace(re, " "));
if (cb) c.baseVal = cv;
else this.className = cv;
}
function classedFunction() {
(value.apply(this, arguments)
? classedAdd
: classedRemove).call(this);
}
return this.each(typeof value === "function"
? classedFunction : value
? classedAdd
: classedRemove);
}
d3_selectionPrototype.style = function(name, value, priority) {
if (arguments.length < 3) priority = "";
// If no value is specified, return the first value.
if (arguments.length < 2) return window
.getComputedStyle(this.node(), null)
.getPropertyValue(name);
function styleNull() {
this.style.removeProperty(name);
}
function styleConstant() {
this.style.setProperty(name, value, priority);
}
function styleFunction() {
var x = value.apply(this, arguments);
if (x == null) this.style.removeProperty(name);
else this.style.setProperty(name, x, priority);
}
return this.each(value == null
? styleNull : (typeof value === "function"
? styleFunction : styleConstant));
};
d3_selectionPrototype.property = function(name, value) {
// If no value is specified, return the first value.
if (arguments.length < 2) return this.node()[name];
function propertyNull() {
delete this[name];
}
function propertyConstant() {
this[name] = value;
}
function propertyFunction() {
var x = value.apply(this, arguments);
if (x == null) delete this[name];
else this[name] = x;
}
return this.each(value == null
? propertyNull : (typeof value === "function"
? propertyFunction : propertyConstant));
};
d3_selectionPrototype.text = function(value) {
return arguments.length < 1
? this.node().textContent : this.each(typeof value === "function"
? function() { var v = value.apply(this, arguments); this.textContent = v == null ? "" : v; } : value == null
? function() { this.textContent = ""; }
: function() { this.textContent = value; });
};
d3_selectionPrototype.html = function(value) {
return arguments.length < 1
? this.node().innerHTML : this.each(typeof value === "function"
? function() { var v = value.apply(this, arguments); this.innerHTML = v == null ? "" : v; } : value == null
? function() { this.innerHTML = ""; }
: function() { this.innerHTML = value; });
};
// TODO append(node)?
// TODO append(function)?
d3_selectionPrototype.append = function(name) {
name = d3.ns.qualify(name);
function append() {
return this.appendChild(document.createElementNS(this.namespaceURI, name));
}
function appendNS() {
return this.appendChild(document.createElementNS(name.space, name.local));
}
return this.select(name.local ? appendNS : append);
};
// TODO insert(node, function)?
// TODO insert(function, string)?
// TODO insert(function, function)?
d3_selectionPrototype.insert = function(name, before) {
name = d3.ns.qualify(name);
function insert() {
return this.insertBefore(
document.createElementNS(this.namespaceURI, name),
d3_select(before, this));
}
function insertNS() {
return this.insertBefore(
document.createElementNS(name.space, name.local),
d3_select(before, this));
}
return this.select(name.local ? insertNS : insert);
};
// TODO remove(selector)?
// TODO remove(node)?
// TODO remove(function)?
d3_selectionPrototype.remove = function() {
return this.each(function() {
var parent = this.parentNode;
if (parent) parent.removeChild(this);
});
};
d3_selectionPrototype.data = function(value, key) {
var i = -1,
n = this.length,
group,
node;
// If no value is specified, return the first value.
if (!arguments.length) {
value = new Array(n = (group = this[0]).length);
while (++i < n) {
if (node = group[i]) {
value[i] = node.__data__;
}
}
return value;
}
function bind(group, groupData) {
var i,
n = group.length,
m = groupData.length,
n0 = Math.min(n, m),
n1 = Math.max(n, m),
updateNodes = [],
enterNodes = [],
exitNodes = [],
node,
nodeData;
if (key) {
var nodeByKeyValue = new d3_Map,
keyValues = [],
keyValue,
j = groupData.length;
for (i = -1; ++i < n;) {
keyValue = key.call(node = group[i], node.__data__, i);
if (nodeByKeyValue.has(keyValue)) {
exitNodes[j++] = node; // duplicate key
} else {
nodeByKeyValue.set(keyValue, node);
}
keyValues.push(keyValue);
}
for (i = -1; ++i < m;) {
keyValue = key.call(groupData, nodeData = groupData[i], i)
if (nodeByKeyValue.has(keyValue)) {
updateNodes[i] = node = nodeByKeyValue.get(keyValue);
node.__data__ = nodeData;
enterNodes[i] = exitNodes[i] = null;
} else {
enterNodes[i] = d3_selection_dataNode(nodeData);
updateNodes[i] = exitNodes[i] = null;
}
nodeByKeyValue.remove(keyValue);
}
for (i = -1; ++i < n;) {
if (nodeByKeyValue.has(keyValues[i])) {
exitNodes[i] = group[i];
}
}
} else {
for (i = -1; ++i < n0;) {
node = group[i];
nodeData = groupData[i];
if (node) {
node.__data__ = nodeData;
updateNodes[i] = node;
enterNodes[i] = exitNodes[i] = null;
} else {
enterNodes[i] = d3_selection_dataNode(nodeData);
updateNodes[i] = exitNodes[i] = null;
}
}
for (; i < m; ++i) {
enterNodes[i] = d3_selection_dataNode(groupData[i]);
updateNodes[i] = exitNodes[i] = null;
}
for (; i < n1; ++i) {
exitNodes[i] = group[i];
enterNodes[i] = updateNodes[i] = null;
}
}
enterNodes.update
= updateNodes;
enterNodes.parentNode
= updateNodes.parentNode
= exitNodes.parentNode
= group.parentNode;
enter.push(enterNodes);
update.push(updateNodes);
exit.push(exitNodes);
}
var enter = d3_selection_enter([]),
update = d3_selection([]),
exit = d3_selection([]);
if (typeof value === "function") {
while (++i < n) {
bind(group = this[i], value.call(group, group.parentNode.__data__, i));
}
} else {
while (++i < n) {
bind(group = this[i], value);
}
}
update.enter = function() { return enter; };
update.exit = function() { return exit; };
return update;
};
function d3_selection_dataNode(data) {
return {__data__: data};
}
d3_selectionPrototype.datum =
d3_selectionPrototype.map = function(value) {
return arguments.length < 1
? this.property("__data__")
: this.property("__data__", value);
};
d3_selectionPrototype.filter = function(filter) {
var subgroups = [],
subgroup,
group,
node;
if (typeof filter !== "function") filter = d3_selection_filter(filter);
for (var j = 0, m = this.length; j < m; j++) {
subgroups.push(subgroup = []);
subgroup.parentNode = (group = this[j]).parentNode;
for (var i = 0, n = group.length; i < n; i++) {
if ((node = group[i]) && filter.call(node, node.__data__, i)) {
subgroup.push(node);
}
}
}
return d3_selection(subgroups);
};
function d3_selection_filter(selector) {
return function() {
return d3_selectMatches(this, selector);
};
}
d3_selectionPrototype.order = function() {
for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = group.length - 1, next = group[i], node; --i >= 0;) {
if (node = group[i]) {
if (next && next !== node.nextSibling) next.parentNode.insertBefore(node, next);
next = node;
}
}
}
return this;
};
d3_selectionPrototype.sort = function(comparator) {
comparator = d3_selection_sortComparator.apply(this, arguments);
for (var j = -1, m = this.length; ++j < m;) this[j].sort(comparator);
return this.order();
};
function d3_selection_sortComparator(comparator) {
if (!arguments.length) comparator = d3.ascending;
return function(a, b) {
return comparator(a && a.__data__, b && b.__data__);
};
}
// type can be namespaced, e.g., "click.foo"
// listener can be null for removal
d3_selectionPrototype.on = function(type, listener, capture) {
if (arguments.length < 3) capture = false;
// parse the type specifier
var name = "__on" + type, i = type.indexOf(".");
if (i > 0) type = type.substring(0, i);
// if called with only one argument, return the current listener
if (arguments.length < 2) return (i = this.node()[name]) && i._;
// remove the old event listener, and add the new event listener
return this.each(function(d, i) {
var node = this,
o = node[name];
// remove the old listener, if any (using the previously-set capture)
if (o) {
node.removeEventListener(type, o, o.$);
delete node[name];
}
// add the new listener, if any (remembering the capture flag)
if (listener) {
node.addEventListener(type, node[name] = l, l.$ = capture);
l._ = listener; // stash the unwrapped listener for get
}
// wrapped event listener that preserves i
function l(e) {
var o = d3.event; // Events can be reentrant (e.g., focus).
d3.event = e;
try {
listener.call(node, node.__data__, i);
} finally {
d3.event = o;
}
}
});
};
d3_selectionPrototype.each = function(callback) {
for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
var node = group[i];
if (node) callback.call(node, node.__data__, i, j);
}
}
return this;
};
//
// Note: assigning to the arguments array simultaneously changes the value of
// the corresponding argument!
//
// TODO The `this` argument probably shouldn't be the first argument to the
// callback, anyway, since it's redundant. However, that will require a major
// version bump due to backwards compatibility, so I'm not changing it right
// away.
//
d3_selectionPrototype.call = function(callback) {
callback.apply(this, (arguments[0] = this, arguments));
return this;
};
d3_selectionPrototype.empty = function() {
return !this.node();
};
d3_selectionPrototype.node = function(callback) {
for (var j = 0, m = this.length; j < m; j++) {
for (var group = this[j], i = 0, n = group.length; i < n; i++) {
var node = group[i];
if (node) return node;
}
}
return null;
};
d3_selectionPrototype.transition = function() {
var subgroups = [],
subgroup,
node;
for (var j = -1, m = this.length; ++j < m;) {
subgroups.push(subgroup = []);
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
subgroup.push((node = group[i]) ? {node: node, delay: d3_transitionDelay, duration: d3_transitionDuration} : null);
}
}
return d3_transition(subgroups, d3_transitionId || ++d3_transitionNextId, Date.now());
};
var d3_selectionRoot = d3_selection([[document]]);
d3_selectionRoot[0].parentNode = d3_selectRoot;
// TODO fast singleton implementation!
// TODO select(function)
d3.select = function(selector) {
return typeof selector === "string"
? d3_selectionRoot.select(selector)
: d3_selection([[selector]]); // assume node
};
// TODO selectAll(function)
d3.selectAll = function(selector) {
return typeof selector === "string"
? d3_selectionRoot.selectAll(selector)
: d3_selection([d3_array(selector)]); // assume node[]
};
function d3_selection_enter(selection) {
d3_arraySubclass(selection, d3_selection_enterPrototype);
return selection;
}
var d3_selection_enterPrototype = [];
d3.selection.enter = d3_selection_enter;
d3.selection.enter.prototype = d3_selection_enterPrototype;
d3_selection_enterPrototype.append = d3_selectionPrototype.append;
d3_selection_enterPrototype.insert = d3_selectionPrototype.insert;
d3_selection_enterPrototype.empty = d3_selectionPrototype.empty;
d3_selection_enterPrototype.node = d3_selectionPrototype.node;
d3_selection_enterPrototype.select = function(selector) {
var subgroups = [],
subgroup,
subnode,
upgroup,
group,
node;
for (var j = -1, m = this.length; ++j < m;) {
upgroup = (group = this[j]).update;
subgroups.push(subgroup = []);
subgroup.parentNode = group.parentNode;
for (var i = -1, n = group.length; ++i < n;) {
if (node = group[i]) {
subgroup.push(upgroup[i] = subnode = selector.call(group.parentNode, node.__data__, i));
subnode.__data__ = node.__data__;
} else {
subgroup.push(null);
}
}
}
return d3_selection(subgroups);
};
function d3_transition(groups, id, time) {
d3_arraySubclass(groups, d3_transitionPrototype);
var tweens = new d3_Map,
event = d3.dispatch("start", "end"),
ease = d3_transitionEase;
groups.id = id;
groups.time = time;
groups.tween = function(name, tween) {
if (arguments.length < 2) return tweens.get(name);
if (tween == null) tweens.remove(name);
else tweens.set(name, tween);
return groups;
};
groups.ease = function(value) {
if (!arguments.length) return ease;
ease = typeof value === "function" ? value : d3.ease.apply(d3, arguments);
return groups;
};
groups.each = function(type, listener) {
if (arguments.length < 2) return d3_transition_each.call(groups, type);
event.on(type, listener);
return groups;
};
d3.timer(function(elapsed) {
groups.each(function(d, i, j) {
var tweened = [],
node = this,
delay = groups[j][i].delay,
duration = groups[j][i].duration,
lock = node.__transition__ || (node.__transition__ = {active: 0, count: 0});
++lock.count;
delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time);
function start(elapsed) {
if (lock.active > id) return stop();
lock.active = id;
tweens.forEach(function(key, value) {
if (tween = value.call(node, d, i)) {
tweened.push(tween);
}
});
event.start.call(node, d, i);
if (!tick(elapsed)) d3.timer(tick, 0, time);
return 1;
}
function tick(elapsed) {
if (lock.active !== id) return stop();
var t = (elapsed - delay) / duration,
e = ease(t),
n = tweened.length;
while (n > 0) {
tweened[--n].call(node, e);
}
if (t >= 1) {
stop();
d3_transitionId = id;
event.end.call(node, d, i);
d3_transitionId = 0;
return 1;
}
}
function stop() {
if (!--lock.count) delete node.__transition__;
return 1;
}
});
return 1;
}, 0, time);
return groups;
}
var d3_transitionRemove = {};
function d3_transitionNull(d, i, a) {
return a != "" && d3_transitionRemove;
}
function d3_transitionTween(name, b) {
var interpolate = d3_interpolateByName(name);
function transitionFunction(d, i, a) {
var v = b.call(this, d, i);
return v == null
? a != "" && d3_transitionRemove
: a != v && interpolate(a, v);
}
function transitionString(d, i, a) {
return a != b && interpolate(a, b);
}
return typeof b === "function" ? transitionFunction
: b == null ? d3_transitionNull
: (b += "", transitionString);
}
var d3_transitionPrototype = [],
d3_transitionNextId = 0,
d3_transitionId = 0,
d3_transitionDefaultDelay = 0,
d3_transitionDefaultDuration = 250,
d3_transitionDefaultEase = d3.ease("cubic-in-out"),
d3_transitionDelay = d3_transitionDefaultDelay,
d3_transitionDuration = d3_transitionDefaultDuration,
d3_transitionEase = d3_transitionDefaultEase;
d3_transitionPrototype.call = d3_selectionPrototype.call;
d3.transition = function(selection) {
return arguments.length
? (d3_transitionId ? selection.transition() : selection)
: d3_selectionRoot.transition();
};
d3.transition.prototype = d3_transitionPrototype;
d3_transitionPrototype.select = function(selector) {
var subgroups = [],
subgroup,
subnode,
node;
if (typeof selector !== "function") selector = d3_selection_selector(selector);
for (var j = -1, m = this.length; ++j < m;) {
subgroups.push(subgroup = []);
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
if ((node = group[i]) && (subnode = selector.call(node.node, node.node.__data__, i))) {
if ("__data__" in node.node) subnode.__data__ = node.node.__data__;
subgroup.push({node: subnode, delay: node.delay, duration: node.duration});
} else {
subgroup.push(null);
}
}
}
return d3_transition(subgroups, this.id, this.time).ease(this.ease());
};
d3_transitionPrototype.selectAll = function(selector) {
var subgroups = [],
subgroup,
subnodes,
node;
if (typeof selector !== "function") selector = d3_selection_selectorAll(selector);
for (var j = -1, m = this.length; ++j < m;) {
for (var group = this[j], i = -1, n = group.length; ++i < n;) {
if (node = group[i]) {
subnodes = selector.call(node.node, node.node.__data__, i);
subgroups.push(subgroup = []);
for (var k = -1, o = subnodes.length; ++k < o;) {
subgroup.push({node: subnodes[k], delay: node.delay, duration: node.duration});
}
}
}
}
return d3_transition(subgroups, this.id, this.time).ease(this.ease());
};
d3_transitionPrototype.attr = function(name, value) {
return this.attrTween(name, d3_transitionTween(name, value));
};
d3_transitionPrototype.attrTween = function(nameNS, tween) {
var name = d3.ns.qualify(nameNS);
function attrTween(d, i) {
var f = tween.call(this, d, i, this.getAttribute(name));
return f === d3_transitionRemove
? (this.removeAttribute(name), null)
: f && function(t) { this.setAttribute(name, f(t)); };
}
function attrTweenNS(d, i) {
var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
return f === d3_transitionRemove
? (this.removeAttributeNS(name.space, name.local), null)
: f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); };
}
return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
};
d3_transitionPrototype.style = function(name, value, priority) {
if (arguments.length < 3) priority = "";
return this.styleTween(name, d3_transitionTween(name, value), priority);
};
d3_transitionPrototype.styleTween = function(name, tween, priority) {
if (arguments.length < 3) priority = "";
return this.tween("style." + name, function(d, i) {
var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name));
return f === d3_transitionRemove
? (this.style.removeProperty(name), null)
: f && function(t) { this.style.setProperty(name, f(t), priority); };
});
};
d3_transitionPrototype.text = function(value) {
return this.tween("text", function(d, i) {
this.textContent = typeof value === "function"
? value.call(this, d, i)
: value;
});
};
d3_transitionPrototype.remove = function() {
return this.each("end.transition", function() {
var p;
if (!this.__transition__ && (p = this.parentNode)) p.removeChild(this);
});
};
d3_transitionPrototype.delay = function(value) {
var groups = this;
return groups.each(typeof value === "function"
? function(d, i, j) { groups[j][i].delay = value.apply(this, arguments) | 0; }
: (value = value | 0, function(d, i, j) { groups[j][i].delay = value; }));
};
d3_transitionPrototype.duration = function(value) {
var groups = this;
return groups.each(typeof value === "function"
? function(d, i, j) { groups[j][i].duration = Math.max(1, value.apply(this, arguments) | 0); }
: (value = Math.max(1, value | 0), function(d, i, j) { groups[j][i].duration = value; }));
};
function d3_transition_each(callback) {
var id = d3_transitionId,
ease = d3_transitionEase,
delay = d3_transitionDelay,
duration = d3_transitionDuration;
d3_transitionId = this.id;
d3_transitionEase = this.ease();
for (var j = 0, m = this.length; j < m; j++) {
for (var group = this[j], i = 0, n = group.length; i < n; i++) {
var node = group[i];
if (node) {
d3_transitionDelay = this[j][i].delay;
d3_transitionDuration = this[j][i].duration;
callback.call(node = node.node, node.__data__, i, j);
}
}
}
d3_transitionId = id;
d3_transitionEase = ease;
d3_transitionDelay = delay;
d3_transitionDuration = duration;
return this;
}
d3_transitionPrototype.transition = function() {
return this.select(d3_this);
};
var d3_timer_queue = null,
d3_timer_interval, // is an interval (or frame) active?
d3_timer_timeout; // is a timeout active?
// The timer will continue to fire until callback returns true.
d3.timer = function(callback, delay, then) {
var found = false,
t0,
t1 = d3_timer_queue;
if (arguments.length < 3) {
if (arguments.length < 2) delay = 0;
else if (!isFinite(delay)) return;
then = Date.now();
}
// See if the callback's already in the queue.
while (t1) {
if (t1.callback === callback) {
t1.then = then;
t1.delay = delay;
found = true;
break;
}
t0 = t1;
t1 = t1.next;
}
// Otherwise, add the callback to the queue.
if (!found) d3_timer_queue = {
callback: callback,
then: then,
delay: delay,
next: d3_timer_queue
};
// Start animatin'!
if (!d3_timer_interval) {
d3_timer_timeout = clearTimeout(d3_timer_timeout);
d3_timer_interval = 1;
d3_timer_frame(d3_timer_step);
}
}
function d3_timer_step() {
var elapsed,
now = Date.now(),
t1 = d3_timer_queue;
while (t1) {
elapsed = now - t1.then;
if (elapsed >= t1.delay) t1.flush = t1.callback(elapsed);
t1 = t1.next;
}
var delay = d3_timer_flush() - now;
if (delay > 24) {
if (isFinite(delay)) {
clearTimeout(d3_timer_timeout);
d3_timer_timeout = setTimeout(d3_timer_step, delay);
}
d3_timer_interval = 0;
} else {
d3_timer_interval = 1;
d3_timer_frame(d3_timer_step);
}
}
d3.timer.flush = function() {
var elapsed,
now = Date.now(),
t1 = d3_timer_queue;
while (t1) {
elapsed = now - t1.then;
if (!t1.delay) t1.flush = t1.callback(elapsed);
t1 = t1.next;
}
d3_timer_flush();
};
// Flush after callbacks, to avoid concurrent queue modification.
function d3_timer_flush() {
var t0 = null,
t1 = d3_timer_queue,
then = Infinity;
while (t1) {
if (t1.flush) {
t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
} else {
then = Math.min(then, t1.then + t1.delay);
t1 = (t0 = t1).next;
}
}
return then;
}
var d3_timer_frame = window.requestAnimationFrame
|| window.webkitRequestAnimationFrame
|| window.mozRequestAnimationFrame
|| window.oRequestAnimationFrame
|| window.msRequestAnimationFrame
|| function(callback) { setTimeout(callback, 17); };
d3.transform = function(string) {
var g = document.createElementNS(d3.ns.prefix.svg, "g"),
identity = {a: 1, b: 0, c: 0, d: 1, e: 0, f: 0};
return (d3.transform = function(string) {
g.setAttribute("transform", string);
var t = g.transform.baseVal.consolidate();
return new d3_transform(t ? t.matrix : identity);
})(string);
};
// Compute x-scale and normalize the first row.
// Compute shear and make second row orthogonal to first.
// Compute y-scale and normalize the second row.
// Finally, compute the rotation.
function d3_transform(m) {
var r0 = [m.a, m.b],
r1 = [m.c, m.d],
kx = d3_transformNormalize(r0),
kz = d3_transformDot(r0, r1),
ky = d3_transformNormalize(d3_transformCombine(r1, r0, -kz)) || 0;
if (r0[0] * r1[1] < r1[0] * r0[1]) {
r0[0] *= -1;
r0[1] *= -1;
kx *= -1;
kz *= -1;
}
this.rotate = (kx ? Math.atan2(r0[1], r0[0]) : Math.atan2(-r1[0], r1[1])) * d3_transformDegrees;
this.translate = [m.e, m.f];
this.scale = [kx, ky];
this.skew = ky ? Math.atan2(kz, ky) * d3_transformDegrees : 0;
};
d3_transform.prototype.toString = function() {
return "translate(" + this.translate
+ ")rotate(" + this.rotate
+ ")skewX(" + this.skew
+ ")scale(" + this.scale
+ ")";
};
function d3_transformDot(a, b) {
return a[0] * b[0] + a[1] * b[1];
}
function d3_transformNormalize(a) {
var k = Math.sqrt(d3_transformDot(a, a));
if (k) {
a[0] /= k;
a[1] /= k;
}
return k;
}
function d3_transformCombine(a, b, k) {
a[0] += k * b[0];
a[1] += k * b[1];
return a;
}
var d3_transformDegrees = 180 / Math.PI;
d3.mouse = function(container) {
return d3_mousePoint(container, d3_eventSource());
};
// https://bugs.webkit.org/show_bug.cgi?id=44083
var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0;
function d3_mousePoint(container, e) {
var svg = container.ownerSVGElement || container;
if (svg.createSVGPoint) {
var point = svg.createSVGPoint();
if ((d3_mouse_bug44083 < 0) && (window.scrollX || window.scrollY)) {
svg = d3.select(document.body)
.append("svg")
.style("position", "absolute")
.style("top", 0)
.style("left", 0);
var ctm = svg[0][0].getScreenCTM();
d3_mouse_bug44083 = !(ctm.f || ctm.e);
svg.remove();
}
if (d3_mouse_bug44083) {
point.x = e.pageX;
point.y = e.pageY;
} else {
point.x = e.clientX;
point.y = e.clientY;
}
point = point.matrixTransform(container.getScreenCTM().inverse());
return [point.x, point.y];
}
var rect = container.getBoundingClientRect();
return [e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop];
};
d3.touches = function(container, touches) {
if (arguments.length < 2) touches = d3_eventSource().touches;
return touches ? d3_array(touches).map(function(touch) {
var point = d3_mousePoint(container, touch);
point.identifier = touch.identifier;
return point;
}) : [];
};
function d3_noop() {}
d3.scale = {};
function d3_scaleExtent(domain) {
var start = domain[0], stop = domain[domain.length - 1];
return start < stop ? [start, stop] : [stop, start];
}
function d3_scaleRange(scale) {
return scale.rangeExtent ? scale.rangeExtent() : d3_scaleExtent(scale.range());
}
function d3_scale_nice(domain, nice) {
var i0 = 0,
i1 = domain.length - 1,
x0 = domain[i0],
x1 = domain[i1],
dx;
if (x1 < x0) {
dx = i0; i0 = i1; i1 = dx;
dx = x0; x0 = x1; x1 = dx;
}
if (dx = x1 - x0) {
nice = nice(dx);
domain[i0] = nice.floor(x0);
domain[i1] = nice.ceil(x1);
}
return domain;
}
function d3_scale_niceDefault() {
return Math;
}
d3.scale.linear = function() {
return d3_scale_linear([0, 1], [0, 1], d3.interpolate, false);
};
function d3_scale_linear(domain, range, interpolate, clamp) {
var output,
input;
function rescale() {
var linear = Math.min(domain.length, range.length) > 2 ? d3_scale_polylinear : d3_scale_bilinear,
uninterpolate = clamp ? d3_uninterpolateClamp : d3_uninterpolateNumber;
output = linear(domain, range, uninterpolate, interpolate);
input = linear(range, domain, uninterpolate, d3.interpolate);
return scale;
}
function scale(x) {
return output(x);
}
// Note: requires range is coercible to number!
scale.invert = function(y) {
return input(y);
};
scale.domain = function(x) {
if (!arguments.length) return domain;
domain = x.map(Number);
return rescale();
};
scale.range = function(x) {
if (!arguments.length) return range;
range = x;
return rescale();
};
scale.rangeRound = function(x) {
return scale.range(x).interpolate(d3.interpolateRound);
};
scale.clamp = function(x) {
if (!arguments.length) return clamp;
clamp = x;
return rescale();
};
scale.interpolate = function(x) {
if (!arguments.length) return interpolate;
interpolate = x;
return rescale();
};
scale.ticks = function(m) {
return d3_scale_linearTicks(domain, m);
};
scale.tickFormat = function(m) {
return d3_scale_linearTickFormat(domain, m);
};
scale.nice = function() {
d3_scale_nice(domain, d3_scale_linearNice);
return rescale();
};
scale.copy = function() {
return d3_scale_linear(domain, range, interpolate, clamp);
};
return rescale();
}
function d3_scale_linearRebind(scale, linear) {
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
}
function d3_scale_linearNice(dx) {
dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
return {
floor: function(x) { return Math.floor(x / dx) * dx; },
ceil: function(x) { return Math.ceil(x / dx) * dx; }
};
}
function d3_scale_linearTickRange(domain, m) {
var extent = d3_scaleExtent(domain),
span = extent[1] - extent[0],
step = Math.pow(10, Math.floor(Math.log(span / m) / Math.LN10)),
err = m / span * step;
// Filter ticks to get closer to the desired count.
if (err <= .15) step *= 10;
else if (err <= .35) step *= 5;
else if (err <= .75) step *= 2;
// Round start and stop values to step interval.
extent[0] = Math.ceil(extent[0] / step) * step;
extent[1] = Math.floor(extent[1] / step) * step + step * .5; // inclusive
extent[2] = step;
return extent;
}
function d3_scale_linearTicks(domain, m) {
return d3.range.apply(d3, d3_scale_linearTickRange(domain, m));
}
function d3_scale_linearTickFormat(domain, m) {
return d3.format(",." + Math.max(0, -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01)) + "f");
}
function d3_scale_bilinear(domain, range, uninterpolate, interpolate) {
var u = uninterpolate(domain[0], domain[1]),
i = interpolate(range[0], range[1]);
return function(x) {
return i(u(x));
};
}
function d3_scale_polylinear(domain, range, uninterpolate, interpolate) {
var u = [],
i = [],
j = 0,
k = Math.min(domain.length, range.length) - 1;
// Handle descending domains.
if (domain[k] < domain[0]) {
domain = domain.slice().reverse();
range = range.slice().reverse();
}
while (++j <= k) {
u.push(uninterpolate(domain[j - 1], domain[j]));
i.push(interpolate(range[j - 1], range[j]));
}
return function(x) {
var j = d3.bisect(domain, x, 1, k) - 1;
return i[j](u[j](x));
};
}
d3.scale.log = function() {
return d3_scale_log(d3.scale.linear(), d3_scale_logp);
};
function d3_scale_log(linear, log) {
var pow = log.pow;
function scale(x) {
return linear(log(x));
}
scale.invert = function(x) {
return pow(linear.invert(x));
};
scale.domain = function(x) {
if (!arguments.length) return linear.domain().map(pow);
log = x[0] < 0 ? d3_scale_logn : d3_scale_logp;
pow = log.pow;
linear.domain(x.map(log));
return scale;
};
scale.nice = function() {
linear.domain(d3_scale_nice(linear.domain(), d3_scale_niceDefault));
return scale;
};
scale.ticks = function() {
var extent = d3_scaleExtent(linear.domain()),
ticks = [];
if (extent.every(isFinite)) {
var i = Math.floor(extent[0]),
j = Math.ceil(extent[1]),
u = pow(extent[0]),
v = pow(extent[1]);
if (log === d3_scale_logn) {
ticks.push(pow(i));
for (; i++ < j;) for (var k = 9; k > 0; k--) ticks.push(pow(i) * k);
} else {
for (; i < j; i++) for (var k = 1; k < 10; k++) ticks.push(pow(i) * k);
ticks.push(pow(i));
}
for (i = 0; ticks[i] < u; i++) {} // strip small values
for (j = ticks.length; ticks[j - 1] > v; j--) {} // strip big values
ticks = ticks.slice(i, j);
}
return ticks;
};
scale.tickFormat = function(n, format) {
if (arguments.length < 2) format = d3_scale_logFormat;
if (arguments.length < 1) return format;
var k = n / scale.ticks().length,
f = log === d3_scale_logn ? (e = -1e-12, Math.floor) : (e = 1e-12, Math.ceil),
e;
return function(d) {
return d / pow(f(log(d) + e)) < k ? format(d) : "";
};
};
scale.copy = function() {
return d3_scale_log(linear.copy(), log);
};
return d3_scale_linearRebind(scale, linear);
}
var d3_scale_logFormat = d3.format(".0e");
function d3_scale_logp(x) {
return Math.log(x < 0 ? 0 : x) / Math.LN10;
}
function d3_scale_logn(x) {
return -Math.log(x > 0 ? 0 : -x) / Math.LN10;
}
d3_scale_logp.pow = function(x) {
return Math.pow(10, x);
};
d3_scale_logn.pow = function(x) {
return -Math.pow(10, -x);
};
d3.scale.pow = function() {
return d3_scale_pow(d3.scale.linear(), 1);
};
function d3_scale_pow(linear, exponent) {
var powp = d3_scale_powPow(exponent),
powb = d3_scale_powPow(1 / exponent);
function scale(x) {
return linear(powp(x));
}
scale.invert = function(x) {
return powb(linear.invert(x));
};
scale.domain = function(x) {
if (!arguments.length) return linear.domain().map(powb);
linear.domain(x.map(powp));
return scale;
};
scale.ticks = function(m) {
return d3_scale_linearTicks(scale.domain(), m);
};
scale.tickFormat = function(m) {
return d3_scale_linearTickFormat(scale.domain(), m);
};
scale.nice = function() {
return scale.domain(d3_scale_nice(scale.domain(), d3_scale_linearNice));
};
scale.exponent = function(x) {
if (!arguments.length) return exponent;
var domain = scale.domain();
powp = d3_scale_powPow(exponent = x);
powb = d3_scale_powPow(1 / exponent);
return scale.domain(domain);
};
scale.copy = function() {
return d3_scale_pow(linear.copy(), exponent);
};
return d3_scale_linearRebind(scale, linear);
}
function d3_scale_powPow(e) {
return function(x) {
return x < 0 ? -Math.pow(-x, e) : Math.pow(x, e);
};
}
d3.scale.sqrt = function() {
return d3.scale.pow().exponent(.5);
};
d3.scale.ordinal = function() {
return d3_scale_ordinal([], {t: "range", x: []});
};
function d3_scale_ordinal(domain, ranger) {
var index,
range,
rangeBand;
function scale(x) {
return range[((index.get(x) || index.set(x, domain.push(x))) - 1) % range.length];
}
function steps(start, step) {
return d3.range(domain.length).map(function(i) { return start + step * i; });
}
scale.domain = function(x) {
if (!arguments.length) return domain;
domain = [];
index = new d3_Map;
var i = -1, n = x.length, xi;
while (++i < n) if (!index.has(xi = x[i])) index.set(xi, domain.push(xi));
return scale[ranger.t](ranger.x, ranger.p);
};
scale.range = function(x) {
if (!arguments.length) return range;
range = x;
rangeBand = 0;
ranger = {t: "range", x: x};
return scale;
};
scale.rangePoints = function(x, padding) {
if (arguments.length < 2) padding = 0;
var start = x[0],
stop = x[1],
step = (stop - start) / (domain.length - 1 + padding);
range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step);
rangeBand = 0;
ranger = {t: "rangePoints", x: x, p: padding};
return scale;
};
scale.rangeBands = function(x, padding) {
if (arguments.length < 2) padding = 0;
var reverse = x[1] < x[0],
start = x[reverse - 0],
stop = x[1 - reverse],
step = (stop - start) / (domain.length + padding);
range = steps(start + step * padding, step);
if (reverse) range.reverse();
rangeBand = step * (1 - padding);
ranger = {t: "rangeBands", x: x, p: padding};
return scale;
};
scale.rangeRoundBands = function(x, padding) {
if (arguments.length < 2) padding = 0;
var reverse = x[1] < x[0],
start = x[reverse - 0],
stop = x[1 - reverse],
step = Math.floor((stop - start) / (domain.length + padding)),
error = stop - start - (domain.length - padding) * step;
range = steps(start + Math.round(error / 2), step);
if (reverse) range.reverse();
rangeBand = Math.round(step * (1 - padding));
ranger = {t: "rangeRoundBands", x: x, p: padding};
return scale;
};
scale.rangeBand = function() {
return rangeBand;
};
scale.rangeExtent = function() {
return d3_scaleExtent(ranger.x);
};
scale.copy = function() {
return d3_scale_ordinal(domain, ranger);
};
return scale.domain(domain);
}
/*
* This product includes color specifications and designs developed by Cynthia
* Brewer (http://colorbrewer.org/). See lib/colorbrewer for more information.
*/
d3.scale.category10 = function() {
return d3.scale.ordinal().range(d3_category10);
};
d3.scale.category20 = function() {
return d3.scale.ordinal().range(d3_category20);
};
d3.scale.category20b = function() {
return d3.scale.ordinal().range(d3_category20b);
};
d3.scale.category20c = function() {
return d3.scale.ordinal().range(d3_category20c);
};
var d3_category10 = [
"#1f77b4", "#ff7f0e", "#2ca02c", "#d62728", "#9467bd",
"#8c564b", "#e377c2", "#7f7f7f", "#bcbd22", "#17becf"
];
var d3_category20 = [
"#1f77b4", "#aec7e8",
"#ff7f0e", "#ffbb78",
"#2ca02c", "#98df8a",
"#d62728", "#ff9896",
"#9467bd", "#c5b0d5",
"#8c564b", "#c49c94",
"#e377c2", "#f7b6d2",
"#7f7f7f", "#c7c7c7",
"#bcbd22", "#dbdb8d",
"#17becf", "#9edae5"
];
var d3_category20b = [
"#393b79", "#5254a3", "#6b6ecf", "#9c9ede",
"#637939", "#8ca252", "#b5cf6b", "#cedb9c",
"#8c6d31", "#bd9e39", "#e7ba52", "#e7cb94",
"#843c39", "#ad494a", "#d6616b", "#e7969c",
"#7b4173", "#a55194", "#ce6dbd", "#de9ed6"
];
var d3_category20c = [
"#3182bd", "#6baed6", "#9ecae1", "#c6dbef",
"#e6550d", "#fd8d3c", "#fdae6b", "#fdd0a2",
"#31a354", "#74c476", "#a1d99b", "#c7e9c0",
"#756bb1", "#9e9ac8", "#bcbddc", "#dadaeb",
"#636363", "#969696", "#bdbdbd", "#d9d9d9"
];
d3.scale.quantile = function() {
return d3_scale_quantile([], []);
};
function d3_scale_quantile(domain, range) {
var thresholds;
function rescale() {
var k = 0,
n = domain.length,
q = range.length;
thresholds = [];
while (++k < q) thresholds[k - 1] = d3.quantile(domain, k / q);
return scale;
}
function scale(x) {
if (isNaN(x = +x)) return NaN;
return range[d3.bisect(thresholds, x)];
}
scale.domain = function(x) {
if (!arguments.length) return domain;
domain = x.filter(function(d) { return !isNaN(d); }).sort(d3.ascending);
return rescale();
};
scale.range = function(x) {
if (!arguments.length) return range;
range = x;
return rescale();
};
scale.quantiles = function() {
return thresholds;
};
scale.copy = function() {
return d3_scale_quantile(domain, range); // copy on write!
};
return rescale();
}
d3.scale.quantize = function() {
return d3_scale_quantize(0, 1, [0, 1]);
};
function d3_scale_quantize(x0, x1, range) {
var kx, i;
function scale(x) {
return range[Math.max(0, Math.min(i, Math.floor(kx * (x - x0))))];
}
function rescale() {
kx = range.length / (x1 - x0);
i = range.length - 1;
return scale;
}
scale.domain = function(x) {
if (!arguments.length) return [x0, x1];
x0 = +x[0];
x1 = +x[x.length - 1];
return rescale();
};
scale.range = function(x) {
if (!arguments.length) return range;
range = x;
return rescale();
};
scale.copy = function() {
return d3_scale_quantize(x0, x1, range); // copy on write
};
return rescale();
}
d3.scale.identity = function() {
return d3_scale_identity([0, 1]);
};
function d3_scale_identity(domain) {
function identity(x) { return +x; }
identity.invert = identity;
identity.domain = identity.range = function(x) {
if (!arguments.length) return domain;
domain = x.map(identity);
return identity;
};
identity.ticks = function(m) {
return d3_scale_linearTicks(domain, m);
};
identity.tickFormat = function(m) {
return d3_scale_linearTickFormat(domain, m);
};
identity.copy = function() {
return d3_scale_identity(domain);
};
return identity;
}
d3.svg = {};
d3.svg.arc = function() {
var innerRadius = d3_svg_arcInnerRadius,
outerRadius = d3_svg_arcOuterRadius,
startAngle = d3_svg_arcStartAngle,
endAngle = d3_svg_arcEndAngle;
function arc() {
var r0 = innerRadius.apply(this, arguments),
r1 = outerRadius.apply(this, arguments),
a0 = startAngle.apply(this, arguments) + d3_svg_arcOffset,
a1 = endAngle.apply(this, arguments) + d3_svg_arcOffset,
da = (a1 < a0 && (da = a0, a0 = a1, a1 = da), a1 - a0),
df = da < Math.PI ? "0" : "1",
c0 = Math.cos(a0),
s0 = Math.sin(a0),
c1 = Math.cos(a1),
s1 = Math.sin(a1);
return da >= d3_svg_arcMax
? (r0
? "M0," + r1
+ "A" + r1 + "," + r1 + " 0 1,1 0," + (-r1)
+ "A" + r1 + "," + r1 + " 0 1,1 0," + r1
+ "M0," + r0
+ "A" + r0 + "," + r0 + " 0 1,0 0," + (-r0)
+ "A" + r0 + "," + r0 + " 0 1,0 0," + r0
+ "Z"
: "M0," + r1
+ "A" + r1 + "," + r1 + " 0 1,1 0," + (-r1)
+ "A" + r1 + "," + r1 + " 0 1,1 0," + r1
+ "Z")
: (r0
? "M" + r1 * c0 + "," + r1 * s0
+ "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1
+ "L" + r0 * c1 + "," + r0 * s1
+ "A" + r0 + "," + r0 + " 0 " + df + ",0 " + r0 * c0 + "," + r0 * s0
+ "Z"
: "M" + r1 * c0 + "," + r1 * s0
+ "A" + r1 + "," + r1 + " 0 " + df + ",1 " + r1 * c1 + "," + r1 * s1
+ "L0,0"
+ "Z");
}
arc.innerRadius = function(v) {
if (!arguments.length) return innerRadius;
innerRadius = d3.functor(v);
return arc;
};
arc.outerRadius = function(v) {
if (!arguments.length) return outerRadius;
outerRadius = d3.functor(v);
return arc;
};
arc.startAngle = function(v) {
if (!arguments.length) return startAngle;
startAngle = d3.functor(v);
return arc;
};
arc.endAngle = function(v) {
if (!arguments.length) return endAngle;
endAngle = d3.functor(v);
return arc;
};
arc.centroid = function() {
var r = (innerRadius.apply(this, arguments)
+ outerRadius.apply(this, arguments)) / 2,
a = (startAngle.apply(this, arguments)
+ endAngle.apply(this, arguments)) / 2 + d3_svg_arcOffset;
return [Math.cos(a) * r, Math.sin(a) * r];
};
return arc;
};
var d3_svg_arcOffset = -Math.PI / 2,
d3_svg_arcMax = 2 * Math.PI - 1e-6;
function d3_svg_arcInnerRadius(d) {
return d.innerRadius;
}
function d3_svg_arcOuterRadius(d) {
return d.outerRadius;
}
function d3_svg_arcStartAngle(d) {
return d.startAngle;
}
function d3_svg_arcEndAngle(d) {
return d.endAngle;
}
function d3_svg_line(projection) {
var x = d3_svg_lineX,
y = d3_svg_lineY,
interpolate = d3_svg_lineInterpolatorDefault,
interpolator = d3_svg_lineInterpolators.get(interpolate),
tension = .7;
function line(d) {
return d.length < 1 ? null : "M" + interpolator(projection(d3_svg_linePoints(this, d, x, y)), tension);
}
line.x = function(v) {
if (!arguments.length) return x;
x = v;
return line;
};
line.y = function(v) {
if (!arguments.length) return y;
y = v;
return line;
};
line.interpolate = function(v) {
if (!arguments.length) return interpolate;
if (!d3_svg_lineInterpolators.has(v += "")) v = d3_svg_lineInterpolatorDefault;
interpolator = d3_svg_lineInterpolators.get(interpolate = v);
return line;
};
line.tension = function(v) {
if (!arguments.length) return tension;
tension = v;
return line;
};
return line;
}
d3.svg.line = function() {
return d3_svg_line(Object);
};
// Converts the specified array of data into an array of points
// (x-y tuples), by evaluating the specified `x` and `y` functions on each
// data point. The `this` context of the evaluated functions is the specified
// "self" object; each function is passed the current datum and index.
function d3_svg_linePoints(self, d, x, y) {
var points = [],
i = -1,
n = d.length,
fx = typeof x === "function",
fy = typeof y === "function",
value;
if (fx && fy) {
while (++i < n) points.push([
x.call(self, value = d[i], i),
y.call(self, value, i)
]);
} else if (fx) {
while (++i < n) points.push([x.call(self, d[i], i), y]);
} else if (fy) {
while (++i < n) points.push([x, y.call(self, d[i], i)]);
} else {
while (++i < n) points.push([x, y]);
}
return points;
}
// The default `x` property, which references d[0].
function d3_svg_lineX(d) {
return d[0];
}
// The default `y` property, which references d[1].
function d3_svg_lineY(d) {
return d[1];
}
var d3_svg_lineInterpolatorDefault = "linear";
// The various interpolators supported by the `line` class.
var d3_svg_lineInterpolators = d3.map({
"linear": d3_svg_lineLinear,
"step-before": d3_svg_lineStepBefore,
"step-after": d3_svg_lineStepAfter,
"basis": d3_svg_lineBasis,
"basis-open": d3_svg_lineBasisOpen,
"basis-closed": d3_svg_lineBasisClosed,
"bundle": d3_svg_lineBundle,
"cardinal": d3_svg_lineCardinal,
"cardinal-open": d3_svg_lineCardinalOpen,
"cardinal-closed": d3_svg_lineCardinalClosed,
"monotone": d3_svg_lineMonotone
});
// Linear interpolation; generates "L" commands.
function d3_svg_lineLinear(points) {
var i = 0,
n = points.length,
p = points[0],
path = [p[0], ",", p[1]];
while (++i < n) path.push("L", (p = points[i])[0], ",", p[1]);
return path.join("");
}
// Step interpolation; generates "H" and "V" commands.
function d3_svg_lineStepBefore(points) {
var i = 0,
n = points.length,
p = points[0],
path = [p[0], ",", p[1]];
while (++i < n) path.push("V", (p = points[i])[1], "H", p[0]);
return path.join("");
}
// Step interpolation; generates "H" and "V" commands.
function d3_svg_lineStepAfter(points) {
var i = 0,
n = points.length,
p = points[0],
path = [p[0], ",", p[1]];
while (++i < n) path.push("H", (p = points[i])[0], "V", p[1]);
return path.join("");
}
// Open cardinal spline interpolation; generates "C" commands.
function d3_svg_lineCardinalOpen(points, tension) {
return points.length < 4
? d3_svg_lineLinear(points)
: points[1] + d3_svg_lineHermite(points.slice(1, points.length - 1),
d3_svg_lineCardinalTangents(points, tension));
}
// Closed cardinal spline interpolation; generates "C" commands.
function d3_svg_lineCardinalClosed(points, tension) {
return points.length < 3
? d3_svg_lineLinear(points)
: points[0] + d3_svg_lineHermite((points.push(points[0]), points),
d3_svg_lineCardinalTangents([points[points.length - 2]]
.concat(points, [points[1]]), tension));
}
// Cardinal spline interpolation; generates "C" commands.
function d3_svg_lineCardinal(points, tension, closed) {
return points.length < 3
? d3_svg_lineLinear(points)
: points[0] + d3_svg_lineHermite(points,
d3_svg_lineCardinalTangents(points, tension));
}
// Hermite spline construction; generates "C" commands.
function d3_svg_lineHermite(points, tangents) {
if (tangents.length < 1
|| (points.length != tangents.length
&& points.length != tangents.length + 2)) {
return d3_svg_lineLinear(points);
}
var quad = points.length != tangents.length,
path = "",
p0 = points[0],
p = points[1],
t0 = tangents[0],
t = t0,
pi = 1;
if (quad) {
path += "Q" + (p[0] - t0[0] * 2 / 3) + "," + (p[1] - t0[1] * 2 / 3)
+ "," + p[0] + "," + p[1];
p0 = points[1];
pi = 2;
}
if (tangents.length > 1) {
t = tangents[1];
p = points[pi];
pi++;
path += "C" + (p0[0] + t0[0]) + "," + (p0[1] + t0[1])
+ "," + (p[0] - t[0]) + "," + (p[1] - t[1])
+ "," + p[0] + "," + p[1];
for (var i = 2; i < tangents.length; i++, pi++) {
p = points[pi];
t = tangents[i];
path += "S" + (p[0] - t[0]) + "," + (p[1] - t[1])
+ "," + p[0] + "," + p[1];
}
}
if (quad) {
var lp = points[pi];
path += "Q" + (p[0] + t[0] * 2 / 3) + "," + (p[1] + t[1] * 2 / 3)
+ "," + lp[0] + "," + lp[1];
}
return path;
}
// Generates tangents for a cardinal spline.
function d3_svg_lineCardinalTangents(points, tension) {
var tangents = [],
a = (1 - tension) / 2,
p0,
p1 = points[0],
p2 = points[1],
i = 1,
n = points.length;
while (++i < n) {
p0 = p1;
p1 = p2;
p2 = points[i];
tangents.push([a * (p2[0] - p0[0]), a * (p2[1] - p0[1])]);
}
return tangents;
}
// B-spline interpolation; generates "C" commands.
function d3_svg_lineBasis(points) {
if (points.length < 3) return d3_svg_lineLinear(points);
var i = 1,
n = points.length,
pi = points[0],
x0 = pi[0],
y0 = pi[1],
px = [x0, x0, x0, (pi = points[1])[0]],
py = [y0, y0, y0, pi[1]],
path = [x0, ",", y0];
d3_svg_lineBasisBezier(path, px, py);
while (++i < n) {
pi = points[i];
px.shift(); px.push(pi[0]);
py.shift(); py.push(pi[1]);
d3_svg_lineBasisBezier(path, px, py);
}
i = -1;
while (++i < 2) {
px.shift(); px.push(pi[0]);
py.shift(); py.push(pi[1]);
d3_svg_lineBasisBezier(path, px, py);
}
return path.join("");
}
// Open B-spline interpolation; generates "C" commands.
function d3_svg_lineBasisOpen(points) {
if (points.length < 4) return d3_svg_lineLinear(points);
var path = [],
i = -1,
n = points.length,
pi,
px = [0],
py = [0];
while (++i < 3) {
pi = points[i];
px.push(pi[0]);
py.push(pi[1]);
}
path.push(d3_svg_lineDot4(d3_svg_lineBasisBezier3, px)
+ "," + d3_svg_lineDot4(d3_svg_lineBasisBezier3, py));
--i; while (++i < n) {
pi = points[i];
px.shift(); px.push(pi[0]);
py.shift(); py.push(pi[1]);
d3_svg_lineBasisBezier(path, px, py);
}
return path.join("");
}
// Closed B-spline interpolation; generates "C" commands.
function d3_svg_lineBasisClosed(points) {
var path,
i = -1,
n = points.length,
m = n + 4,
pi,
px = [],
py = [];
while (++i < 4) {
pi = points[i % n];
px.push(pi[0]);
py.push(pi[1]);
}
path = [
d3_svg_lineDot4(d3_svg_lineBasisBezier3, px), ",",
d3_svg_lineDot4(d3_svg_lineBasisBezier3, py)
];
--i; while (++i < m) {
pi = points[i % n];
px.shift(); px.push(pi[0]);
py.shift(); py.push(pi[1]);
d3_svg_lineBasisBezier(path, px, py);
}
return path.join("");
}
function d3_svg_lineBundle(points, tension) {
var n = points.length - 1,
x0 = points[0][0],
y0 = points[0][1],
dx = points[n][0] - x0,
dy = points[n][1] - y0,
i = -1,
p,
t;
while (++i <= n) {
p = points[i];
t = i / n;
p[0] = tension * p[0] + (1 - tension) * (x0 + t * dx);
p[1] = tension * p[1] + (1 - tension) * (y0 + t * dy);
}
return d3_svg_lineBasis(points);
}
// Returns the dot product of the given four-element vectors.
function d3_svg_lineDot4(a, b) {
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3];
}
// Matrix to transform basis (b-spline) control points to bezier
// control points. Derived from FvD 11.2.8.
var d3_svg_lineBasisBezier1 = [0, 2/3, 1/3, 0],
d3_svg_lineBasisBezier2 = [0, 1/3, 2/3, 0],
d3_svg_lineBasisBezier3 = [0, 1/6, 2/3, 1/6];
// Pushes a "C" Bézier curve onto the specified path array, given the
// two specified four-element arrays which define the control points.
function d3_svg_lineBasisBezier(path, x, y) {
path.push(
"C", d3_svg_lineDot4(d3_svg_lineBasisBezier1, x),
",", d3_svg_lineDot4(d3_svg_lineBasisBezier1, y),
",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, x),
",", d3_svg_lineDot4(d3_svg_lineBasisBezier2, y),
",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, x),
",", d3_svg_lineDot4(d3_svg_lineBasisBezier3, y));
}
// Computes the slope from points p0 to p1.
function d3_svg_lineSlope(p0, p1) {
return (p1[1] - p0[1]) / (p1[0] - p0[0]);
}
// Compute three-point differences for the given points.
// http://en.wikipedia.org/wiki/Cubic_Hermite_spline#Finite_difference
function d3_svg_lineFiniteDifferences(points) {
var i = 0,
j = points.length - 1,
m = [],
p0 = points[0],
p1 = points[1],
d = m[0] = d3_svg_lineSlope(p0, p1);
while (++i < j) {
m[i] = d + (d = d3_svg_lineSlope(p0 = p1, p1 = points[i + 1]));
}
m[i] = d;
return m;
}
// Interpolates the given points using Fritsch-Carlson Monotone cubic Hermite
// interpolation. Returns an array of tangent vectors. For details, see
// http://en.wikipedia.org/wiki/Monotone_cubic_interpolation
function d3_svg_lineMonotoneTangents(points) {
var tangents = [],
d,
a,
b,
s,
m = d3_svg_lineFiniteDifferences(points),
i = -1,
j = points.length - 1;
// The first two steps are done by computing finite-differences:
// 1. Compute the slopes of the secant lines between successive points.
// 2. Initialize the tangents at every point as the average of the secants.
// Then, for each segment…
while (++i < j) {
d = d3_svg_lineSlope(points[i], points[i + 1]);
// 3. If two successive yk = y{k + 1} are equal (i.e., d is zero), then set
// mk = m{k + 1} = 0 as the spline connecting these points must be flat to
// preserve monotonicity. Ignore step 4 and 5 for those k.
if (Math.abs(d) < 1e-6) {
m[i] = m[i + 1] = 0;
} else {
// 4. Let ak = mk / dk and bk = m{k + 1} / dk.
a = m[i] / d;
b = m[i + 1] / d;
// 5. Prevent overshoot and ensure monotonicity by restricting the
// magnitude of vector <ak, bk> to a circle of radius 3.
s = a * a + b * b;
if (s > 9) {
s = d * 3 / Math.sqrt(s);
m[i] = s * a;
m[i + 1] = s * b;
}
}
}
// Compute the normalized tangent vector from the slopes. Note that if x is
// not monotonic, it's possible that the slope will be infinite, so we protect
// against NaN by setting the coordinate to zero.
i = -1; while (++i <= j) {
s = (points[Math.min(j, i + 1)][0] - points[Math.max(0, i - 1)][0])
/ (6 * (1 + m[i] * m[i]));
tangents.push([s || 0, m[i] * s || 0]);
}
return tangents;
}
function d3_svg_lineMonotone(points) {
return points.length < 3
? d3_svg_lineLinear(points)
: points[0] +
d3_svg_lineHermite(points, d3_svg_lineMonotoneTangents(points));
}
d3.svg.line.radial = function() {
var line = d3_svg_line(d3_svg_lineRadial);
line.radius = line.x, delete line.x;
line.angle = line.y, delete line.y;
return line;
};
function d3_svg_lineRadial(points) {
var point,
i = -1,
n = points.length,
r,
a;
while (++i < n) {
point = points[i];
r = point[0];
a = point[1] + d3_svg_arcOffset;
point[0] = r * Math.cos(a);
point[1] = r * Math.sin(a);
}
return points;
}
function d3_svg_area(projection) {
var x0 = d3_svg_lineX,
x1 = d3_svg_lineX,
y0 = 0,
y1 = d3_svg_lineY,
interpolate,
i0,
i1,
tension = .7;
function area(d) {
if (d.length < 1) return null;
var points0 = d3_svg_linePoints(this, d, x0, y0),
points1 = d3_svg_linePoints(this, d, x0 === x1 ? d3_svg_areaX(points0) : x1, y0 === y1 ? d3_svg_areaY(points0) : y1);
return "M" + i0(projection(points1), tension)
+ "L" + i1(projection(points0.reverse()), tension)
+ "Z";
}
area.x = function(x) {
if (!arguments.length) return x1;
x0 = x1 = x;
return area;
};
area.x0 = function(x) {
if (!arguments.length) return x0;
x0 = x;
return area;
};
area.x1 = function(x) {
if (!arguments.length) return x1;
x1 = x;
return area;
};
area.y = function(y) {
if (!arguments.length) return y1;
y0 = y1 = y;
return area;
};
area.y0 = function(y) {
if (!arguments.length) return y0;
y0 = y;
return area;
};
area.y1 = function(y) {
if (!arguments.length) return y1;
y1 = y;
return area;
};
area.interpolate = function(x) {
if (!arguments.length) return interpolate;
if (!d3_svg_lineInterpolators.has(x += "")) x = d3_svg_lineInterpolatorDefault;
i0 = d3_svg_lineInterpolators.get(interpolate = x);
i1 = i0.reverse || i0;
return area;
};
area.tension = function(x) {
if (!arguments.length) return tension;
tension = x;
return area;
};
return area.interpolate("linear");
}
d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
d3.svg.area = function() {
return d3_svg_area(Object);
};
function d3_svg_areaX(points) {
return function(d, i) {
return points[i][0];
};
}
function d3_svg_areaY(points) {
return function(d, i) {
return points[i][1];
};
}
d3.svg.area.radial = function() {
var area = d3_svg_area(d3_svg_lineRadial);
area.radius = area.x, delete area.x;
area.innerRadius = area.x0, delete area.x0;
area.outerRadius = area.x1, delete area.x1;
area.angle = area.y, delete area.y;
area.startAngle = area.y0, delete area.y0;
area.endAngle = area.y1, delete area.y1;
return area;
};
d3.svg.chord = function() {
var source = d3_svg_chordSource,
target = d3_svg_chordTarget,
radius = d3_svg_chordRadius,
startAngle = d3_svg_arcStartAngle,
endAngle = d3_svg_arcEndAngle;
// TODO Allow control point to be customized.
function chord(d, i) {
var s = subgroup(this, source, d, i),
t = subgroup(this, target, d, i);
return "M" + s.p0
+ arc(s.r, s.p1, s.a1 - s.a0) + (equals(s, t)
? curve(s.r, s.p1, s.r, s.p0)
: curve(s.r, s.p1, t.r, t.p0)
+ arc(t.r, t.p1, t.a1 - t.a0)
+ curve(t.r, t.p1, s.r, s.p0))
+ "Z";
}
function subgroup(self, f, d, i) {
var subgroup = f.call(self, d, i),
r = radius.call(self, subgroup, i),
a0 = startAngle.call(self, subgroup, i) + d3_svg_arcOffset,
a1 = endAngle.call(self, subgroup, i) + d3_svg_arcOffset;
return {
r: r,
a0: a0,
a1: a1,
p0: [r * Math.cos(a0), r * Math.sin(a0)],
p1: [r * Math.cos(a1), r * Math.sin(a1)]
};
}
function equals(a, b) {
return a.a0 == b.a0 && a.a1 == b.a1;
}
function arc(r, p, a) {
return "A" + r + "," + r + " 0 " + +(a > Math.PI) + ",1 " + p;
}
function curve(r0, p0, r1, p1) {
return "Q 0,0 " + p1;
}
chord.radius = function(v) {
if (!arguments.length) return radius;
radius = d3.functor(v);
return chord;
};
chord.source = function(v) {
if (!arguments.length) return source;
source = d3.functor(v);
return chord;
};
chord.target = function(v) {
if (!arguments.length) return target;
target = d3.functor(v);
return chord;
};
chord.startAngle = function(v) {
if (!arguments.length) return startAngle;
startAngle = d3.functor(v);
return chord;
};
chord.endAngle = function(v) {
if (!arguments.length) return endAngle;
endAngle = d3.functor(v);
return chord;
};
return chord;
};
function d3_svg_chordSource(d) {
return d.source;
}
function d3_svg_chordTarget(d) {
return d.target;
}
function d3_svg_chordRadius(d) {
return d.radius;
}
function d3_svg_chordStartAngle(d) {
return d.startAngle;
}
function d3_svg_chordEndAngle(d) {
return d.endAngle;
}
d3.svg.diagonal = function() {
var source = d3_svg_chordSource,
target = d3_svg_chordTarget,
projection = d3_svg_diagonalProjection;
function diagonal(d, i) {
var p0 = source.call(this, d, i),
p3 = target.call(this, d, i),
m = (p0.y + p3.y) / 2,
p = [p0, {x: p0.x, y: m}, {x: p3.x, y: m}, p3];
p = p.map(projection);
return "M" + p[0] + "C" + p[1] + " " + p[2] + " " + p[3];
}
diagonal.source = function(x) {
if (!arguments.length) return source;
source = d3.functor(x);
return diagonal;
};
diagonal.target = function(x) {
if (!arguments.length) return target;
target = d3.functor(x);
return diagonal;
};
diagonal.projection = function(x) {
if (!arguments.length) return projection;
projection = x;
return diagonal;
};
return diagonal;
};
function d3_svg_diagonalProjection(d) {
return [d.x, d.y];
}
d3.svg.diagonal.radial = function() {
var diagonal = d3.svg.diagonal(),
projection = d3_svg_diagonalProjection,
projection_ = diagonal.projection;
diagonal.projection = function(x) {
return arguments.length
? projection_(d3_svg_diagonalRadialProjection(projection = x))
: projection;
};
return diagonal;
};
function d3_svg_diagonalRadialProjection(projection) {
return function() {
var d = projection.apply(this, arguments),
r = d[0],
a = d[1] + d3_svg_arcOffset;
return [r * Math.cos(a), r * Math.sin(a)];
};
}
d3.svg.mouse = d3.mouse;
d3.svg.touches = d3.touches;
d3.svg.symbol = function() {
var type = d3_svg_symbolType,
size = d3_svg_symbolSize;
function symbol(d, i) {
return (d3_svg_symbols.get(type.call(this, d, i))
|| d3_svg_symbolCircle)
(size.call(this, d, i));
}
symbol.type = function(x) {
if (!arguments.length) return type;
type = d3.functor(x);
return symbol;
};
// size of symbol in square pixels
symbol.size = function(x) {
if (!arguments.length) return size;
size = d3.functor(x);
return symbol;
};
return symbol;
};
function d3_svg_symbolSize() {
return 64;
}
function d3_svg_symbolType() {
return "circle";
}
function d3_svg_symbolCircle(size) {
var r = Math.sqrt(size / Math.PI);
return "M0," + r
+ "A" + r + "," + r + " 0 1,1 0," + (-r)
+ "A" + r + "," + r + " 0 1,1 0," + r
+ "Z";
}
// TODO cross-diagonal?
var d3_svg_symbols = d3.map({
"circle": d3_svg_symbolCircle,
"cross": function(size) {
var r = Math.sqrt(size / 5) / 2;
return "M" + -3 * r + "," + -r
+ "H" + -r
+ "V" + -3 * r
+ "H" + r
+ "V" + -r
+ "H" + 3 * r
+ "V" + r
+ "H" + r
+ "V" + 3 * r
+ "H" + -r
+ "V" + r
+ "H" + -3 * r
+ "Z";
},
"diamond": function(size) {
var ry = Math.sqrt(size / (2 * d3_svg_symbolTan30)),
rx = ry * d3_svg_symbolTan30;
return "M0," + -ry
+ "L" + rx + ",0"
+ " 0," + ry
+ " " + -rx + ",0"
+ "Z";
},
"square": function(size) {
var r = Math.sqrt(size) / 2;
return "M" + -r + "," + -r
+ "L" + r + "," + -r
+ " " + r + "," + r
+ " " + -r + "," + r
+ "Z";
},
"triangle-down": function(size) {
var rx = Math.sqrt(size / d3_svg_symbolSqrt3),
ry = rx * d3_svg_symbolSqrt3 / 2;
return "M0," + ry
+ "L" + rx +"," + -ry
+ " " + -rx + "," + -ry
+ "Z";
},
"triangle-up": function(size) {
var rx = Math.sqrt(size / d3_svg_symbolSqrt3),
ry = rx * d3_svg_symbolSqrt3 / 2;
return "M0," + -ry
+ "L" + rx +"," + ry
+ " " + -rx + "," + ry
+ "Z";
}
});
d3.svg.symbolTypes = d3_svg_symbols.keys();
var d3_svg_symbolSqrt3 = Math.sqrt(3),
d3_svg_symbolTan30 = Math.tan(30 * Math.PI / 180);
d3.svg.axis = function() {
var scale = d3.scale.linear(),
orient = "bottom",
tickMajorSize = 6,
tickMinorSize = 6,
tickEndSize = 6,
tickPadding = 3,
tickArguments_ = [10],
tickValues = null,
tickFormat_,
tickSubdivide = 0;
function axis(g) {
g.each(function() {
var g = d3.select(this);
// Ticks, or domain values for ordinal scales.
var ticks = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments_) : scale.domain()) : tickValues,
tickFormat = tickFormat_ == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments_) : String) : tickFormat_;
// Minor ticks.
var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide),
subtick = g.selectAll(".minor").data(subticks, String),
subtickEnter = subtick.enter().insert("line", "g").attr("class", "tick minor").style("opacity", 1e-6),
subtickExit = d3.transition(subtick.exit()).style("opacity", 1e-6).remove(),
subtickUpdate = d3.transition(subtick).style("opacity", 1);
// Major ticks.
var tick = g.selectAll("g").data(ticks, String),
tickEnter = tick.enter().insert("g", "path").style("opacity", 1e-6),
tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(),
tickUpdate = d3.transition(tick).style("opacity", 1),
tickTransform;
// Domain.
var range = d3_scaleRange(scale),
path = g.selectAll(".domain").data([0]),
pathEnter = path.enter().append("path").attr("class", "domain"),
pathUpdate = d3.transition(path);
// Stash a snapshot of the new scale, and retrieve the old snapshot.
var scale1 = scale.copy(),
scale0 = this.__chart__ || scale1;
this.__chart__ = scale1;
tickEnter.append("line").attr("class", "tick");
tickEnter.append("text");
tickUpdate.select("text").text(tickFormat);
switch (orient) {
case "bottom": {
tickTransform = d3_svg_axisX;
subtickEnter.attr("y2", tickMinorSize);
subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize);
tickEnter.select("line").attr("y2", tickMajorSize);
tickEnter.select("text").attr("y", Math.max(tickMajorSize, 0) + tickPadding);
tickUpdate.select("line").attr("x2", 0).attr("y2", tickMajorSize);
tickUpdate.select("text").attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding).attr("dy", ".71em").attr("text-anchor", "middle");
pathUpdate.attr("d", "M" + range[0] + "," + tickEndSize + "V0H" + range[1] + "V" + tickEndSize);
break;
}
case "top": {
tickTransform = d3_svg_axisX;
subtickEnter.attr("y2", -tickMinorSize);
subtickUpdate.attr("x2", 0).attr("y2", -tickMinorSize);
tickEnter.select("line").attr("y2", -tickMajorSize);
tickEnter.select("text").attr("y", -(Math.max(tickMajorSize, 0) + tickPadding));
tickUpdate.select("line").attr("x2", 0).attr("y2", -tickMajorSize);
tickUpdate.select("text").attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("dy", "0em").attr("text-anchor", "middle");
pathUpdate.attr("d", "M" + range[0] + "," + -tickEndSize + "V0H" + range[1] + "V" + -tickEndSize);
break;
}
case "left": {
tickTransform = d3_svg_axisY;
subtickEnter.attr("x2", -tickMinorSize);
subtickUpdate.attr("x2", -tickMinorSize).attr("y2", 0);
tickEnter.select("line").attr("x2", -tickMajorSize);
tickEnter.select("text").attr("x", -(Math.max(tickMajorSize, 0) + tickPadding));
tickUpdate.select("line").attr("x2", -tickMajorSize).attr("y2", 0);
tickUpdate.select("text").attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0).attr("dy", ".32em").attr("text-anchor", "end");
pathUpdate.attr("d", "M" + -tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + -tickEndSize);
break;
}
case "right": {
tickTransform = d3_svg_axisY;
subtickEnter.attr("x2", tickMinorSize);
subtickUpdate.attr("x2", tickMinorSize).attr("y2", 0);
tickEnter.select("line").attr("x2", tickMajorSize);
tickEnter.select("text").attr("x", Math.max(tickMajorSize, 0) + tickPadding);
tickUpdate.select("line").attr("x2", tickMajorSize).attr("y2", 0);
tickUpdate.select("text").attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0).attr("dy", ".32em").attr("text-anchor", "start");
pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize);
break;
}
}
// For quantitative scales:
// - enter new ticks from the old scale
// - exit old ticks to the new scale
if (scale.ticks) {
tickEnter.call(tickTransform, scale0);
tickUpdate.call(tickTransform, scale1);
tickExit.call(tickTransform, scale1);
subtickEnter.call(tickTransform, scale0);
subtickUpdate.call(tickTransform, scale1);
subtickExit.call(tickTransform, scale1);
}
// For ordinal scales:
// - any entering ticks are undefined in the old scale
// - any exiting ticks are undefined in the new scale
// Therefore, we only need to transition updating ticks.
else {
var dx = scale1.rangeBand() / 2, x = function(d) { return scale1(d) + dx; };
tickEnter.call(tickTransform, x);
tickUpdate.call(tickTransform, x);
}
});
}
axis.scale = function(x) {
if (!arguments.length) return scale;
scale = x;
return axis;
};
axis.orient = function(x) {
if (!arguments.length) return orient;
orient = x;
return axis;
};
axis.ticks = function() {
if (!arguments.length) return tickArguments_;
tickArguments_ = arguments;
return axis;
};
axis.tickValues = function(x) {
if (!arguments.length) return tickValues;
tickValues = x;
return axis;
};
axis.tickFormat = function(x) {
if (!arguments.length) return tickFormat_;
tickFormat_ = x;
return axis;
};
axis.tickSize = function(x, y, z) {
if (!arguments.length) return tickMajorSize;
var n = arguments.length - 1;
tickMajorSize = +x;
tickMinorSize = n > 1 ? +y : tickMajorSize;
tickEndSize = n > 0 ? +arguments[n] : tickMajorSize;
return axis;
};
axis.tickPadding = function(x) {
if (!arguments.length) return tickPadding;
tickPadding = +x;
return axis;
};
axis.tickSubdivide = function(x) {
if (!arguments.length) return tickSubdivide;
tickSubdivide = +x;
return axis;
};
return axis;
};
function d3_svg_axisX(selection, x) {
selection.attr("transform", function(d) { return "translate(" + x(d) + ",0)"; });
}
function d3_svg_axisY(selection, y) {
selection.attr("transform", function(d) { return "translate(0," + y(d) + ")"; });
}
function d3_svg_axisSubdivide(scale, ticks, m) {
subticks = [];
if (m && ticks.length > 1) {
var extent = d3_scaleExtent(scale.domain()),
subticks,
i = -1,
n = ticks.length,
d = (ticks[1] - ticks[0]) / ++m,
j,
v;
while (++i < n) {
for (j = m; --j > 0;) {
if ((v = +ticks[i] - j * d) >= extent[0]) {
subticks.push(v);
}
}
}
for (--i, j = 0; ++j < m && (v = +ticks[i] + j * d) < extent[1];) {
subticks.push(v);
}
}
return subticks;
}
d3.svg.brush = function() {
var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"),
x = null, // x-scale, optional
y = null, // y-scale, optional
resizes = d3_svg_brushResizes[0],
extent = [[0, 0], [0, 0]], // [x0, y0], [x1, y1], in pixels (integers)
extentDomain; // the extent in data space, lazily created
function brush(g) {
g.each(function() {
var g = d3.select(this),
bg = g.selectAll(".background").data([0]),
fg = g.selectAll(".extent").data([0]),
tz = g.selectAll(".resize").data(resizes, String),
e;
// Prepare the brush container for events.
g
.style("pointer-events", "all")
.on("mousedown.brush", brushstart)
.on("touchstart.brush", brushstart);
// An invisible, mouseable area for starting a new brush.
bg.enter().append("rect")
.attr("class", "background")
.style("visibility", "hidden")
.style("cursor", "crosshair");
// The visible brush extent; style this as you like!
fg.enter().append("rect")
.attr("class", "extent")
.style("cursor", "move");
// More invisible rects for resizing the extent.
tz.enter().append("g")
.attr("class", function(d) { return "resize " + d; })
.style("cursor", function(d) { return d3_svg_brushCursor[d]; })
.append("rect")
.attr("x", function(d) { return /[ew]$/.test(d) ? -3 : null; })
.attr("y", function(d) { return /^[ns]/.test(d) ? -3 : null; })
.attr("width", 6)
.attr("height", 6)
.style("visibility", "hidden");
// Show or hide the resizers.
tz.style("display", brush.empty() ? "none" : null);
// Remove any superfluous resizers.
tz.exit().remove();
// Initialize the background to fill the defined range.
// If the range isn't defined, you can post-process.
if (x) {
e = d3_scaleRange(x);
bg.attr("x", e[0]).attr("width", e[1] - e[0]);
redrawX(g);
}
if (y) {
e = d3_scaleRange(y);
bg.attr("y", e[0]).attr("height", e[1] - e[0]);
redrawY(g);
}
redraw(g);
});
}
function redraw(g) {
g.selectAll(".resize").attr("transform", function(d) {
return "translate(" + extent[+/e$/.test(d)][0] + "," + extent[+/^s/.test(d)][1] + ")";
});
}
function redrawX(g) {
g.select(".extent").attr("x", extent[0][0]);
g.selectAll(".extent,.n>rect,.s>rect").attr("width", extent[1][0] - extent[0][0]);
}
function redrawY(g) {
g.select(".extent").attr("y", extent[0][1]);
g.selectAll(".extent,.e>rect,.w>rect").attr("height", extent[1][1] - extent[0][1]);
}
function brushstart() {
var target = this,
eventTarget = d3.select(d3.event.target),
event_ = event.of(target, arguments),
g = d3.select(target),
resizing = eventTarget.datum(),
resizingX = !/^(n|s)$/.test(resizing) && x,
resizingY = !/^(e|w)$/.test(resizing) && y,
dragging = eventTarget.classed("extent"),
center,
origin = mouse(),
offset;
var w = d3.select(window)
.on("mousemove.brush", brushmove)
.on("mouseup.brush", brushend)
.on("touchmove.brush", brushmove)
.on("touchend.brush", brushend)
.on("keydown.brush", keydown)
.on("keyup.brush", keyup);
// If the extent was clicked on, drag rather than brush;
// store the point between the mouse and extent origin instead.
if (dragging) {
origin[0] = extent[0][0] - origin[0];
origin[1] = extent[0][1] - origin[1];
}
// If a resizer was clicked on, record which side is to be resized.
// Also, set the origin to the opposite side.
else if (resizing) {
var ex = +/w$/.test(resizing),
ey = +/^n/.test(resizing);
offset = [extent[1 - ex][0] - origin[0], extent[1 - ey][1] - origin[1]];
origin[0] = extent[ex][0];
origin[1] = extent[ey][1];
}
// If the ALT key is down when starting a brush, the center is at the mouse.
else if (d3.event.altKey) center = origin.slice();
// Propagate the active cursor to the body for the drag duration.
g.style("pointer-events", "none").selectAll(".resize").style("display", null);
d3.select("body").style("cursor", eventTarget.style("cursor"));
// Notify listeners.
event_({type: "brushstart"});
brushmove();
d3_eventCancel();
function mouse() {
var touches = d3.event.changedTouches;
return touches ? d3.touches(target, touches)[0] : d3.mouse(target);
}
function keydown() {
if (d3.event.keyCode == 32) {
if (!dragging) {
center = null;
origin[0] -= extent[1][0];
origin[1] -= extent[1][1];
dragging = 2;
}
d3_eventCancel();
}
}
function keyup() {
if (d3.event.keyCode == 32 && dragging == 2) {
origin[0] += extent[1][0];
origin[1] += extent[1][1];
dragging = 0;
d3_eventCancel();
}
}
function brushmove() {
var point = mouse(),
moved = false;
// Preserve the offset for thick resizers.
if (offset) {
point[0] += offset[0];
point[1] += offset[1];
}
if (!dragging) {
// If needed, determine the center from the current extent.
if (d3.event.altKey) {
if (!center) center = [(extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2];
// Update the origin, for when the ALT key is released.
origin[0] = extent[+(point[0] < center[0])][0];
origin[1] = extent[+(point[1] < center[1])][1];
}
// When the ALT key is released, we clear the center.
else center = null;
}
// Update the brush extent for each dimension.
if (resizingX && move1(point, x, 0)) {
redrawX(g);
moved = true;
}
if (resizingY && move1(point, y, 1)) {
redrawY(g);
moved = true;
}
// Final redraw and notify listeners.
if (moved) {
redraw(g);
event_({type: "brush", mode: dragging ? "move" : "resize"});
}
}
function move1(point, scale, i) {
var range = d3_scaleRange(scale),
r0 = range[0],
r1 = range[1],
position = origin[i],
size = extent[1][i] - extent[0][i],
min,
max;
// When dragging, reduce the range by the extent size and position.
if (dragging) {
r0 -= position;
r1 -= size + position;
}
// Clamp the point so that the extent fits within the range extent.
min = Math.max(r0, Math.min(r1, point[i]));
// Compute the new extent bounds.
if (dragging) {
max = (min += position) + size;
} else {
// If the ALT key is pressed, then preserve the center of the extent.
if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min));
// Compute the min and max of the position and point.
if (position < min) {
max = min;
min = position;
} else {
max = position;
}
}
// Update the stored bounds.
if (extent[0][i] !== min || extent[1][i] !== max) {
extentDomain = null;
extent[0][i] = min;
extent[1][i] = max;
return true;
}
}
function brushend() {
brushmove();
// reset the cursor styles
g.style("pointer-events", "all").selectAll(".resize").style("display", brush.empty() ? "none" : null);
d3.select("body").style("cursor", null);
w .on("mousemove.brush", null)
.on("mouseup.brush", null)
.on("touchmove.brush", null)
.on("touchend.brush", null)
.on("keydown.brush", null)
.on("keyup.brush", null);
event_({type: "brushend"});
d3_eventCancel();
}
}
brush.x = function(z) {
if (!arguments.length) return x;
x = z;
resizes = d3_svg_brushResizes[!x << 1 | !y]; // fore!
return brush;
};
brush.y = function(z) {
if (!arguments.length) return y;
y = z;
resizes = d3_svg_brushResizes[!x << 1 | !y]; // fore!
return brush;
};
brush.extent = function(z) {
var x0, x1, y0, y1, t;
// Invert the pixel extent to data-space.
if (!arguments.length) {
z = extentDomain || extent;
if (x) {
x0 = z[0][0], x1 = z[1][0];
if (!extentDomain) {
x0 = extent[0][0], x1 = extent[1][0];
if (x.invert) x0 = x.invert(x0), x1 = x.invert(x1);
if (x1 < x0) t = x0, x0 = x1, x1 = t;
}
}
if (y) {
y0 = z[0][1], y1 = z[1][1];
if (!extentDomain) {
y0 = extent[0][1], y1 = extent[1][1];
if (y.invert) y0 = y.invert(y0), y1 = y.invert(y1);
if (y1 < y0) t = y0, y0 = y1, y1 = t;
}
}
return x && y ? [[x0, y0], [x1, y1]] : x ? [x0, x1] : y && [y0, y1];
}
// Scale the data-space extent to pixels.
extentDomain = [[0, 0], [0, 0]];
if (x) {
x0 = z[0], x1 = z[1];
if (y) x0 = x0[0], x1 = x1[0];
extentDomain[0][0] = x0, extentDomain[1][0] = x1;
if (x.invert) x0 = x(x0), x1 = x(x1);
if (x1 < x0) t = x0, x0 = x1, x1 = t;
extent[0][0] = x0 | 0, extent[1][0] = x1 | 0;
}
if (y) {
y0 = z[0], y1 = z[1];
if (x) y0 = y0[1], y1 = y1[1];
extentDomain[0][1] = y0, extentDomain[1][1] = y1;
if (y.invert) y0 = y(y0), y1 = y(y1);
if (y1 < y0) t = y0, y0 = y1, y1 = t;
extent[0][1] = y0 | 0, extent[1][1] = y1 | 0;
}
return brush;
};
brush.clear = function() {
extentDomain = null;
extent[0][0] =
extent[0][1] =
extent[1][0] =
extent[1][1] = 0;
return brush;
};
brush.empty = function() {
return (x && extent[0][0] === extent[1][0])
|| (y && extent[0][1] === extent[1][1]);
};
return d3.rebind(brush, event, "on");
};
var d3_svg_brushCursor = {
n: "ns-resize",
e: "ew-resize",
s: "ns-resize",
w: "ew-resize",
nw: "nwse-resize",
ne: "nesw-resize",
se: "nwse-resize",
sw: "nesw-resize"
};
var d3_svg_brushResizes = [
["n", "e", "s", "w", "nw", "ne", "se", "sw"],
["e", "w"],
["n", "s"],
[]
];
d3.behavior = {};
// TODO Track touch points by identifier.
d3.behavior.drag = function() {
var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"),
origin = null;
function drag() {
this.on("mousedown.drag", mousedown)
.on("touchstart.drag", mousedown);
}
function mousedown() {
var target = this,
event_ = event.of(target, arguments),
eventTarget = d3.event.target,
offset,
origin_ = point(),
moved = 0;
var w = d3.select(window)
.on("mousemove.drag", dragmove)
.on("touchmove.drag", dragmove)
.on("mouseup.drag", dragend, true)
.on("touchend.drag", dragend, true);
if (origin) {
offset = origin.apply(target, arguments);
offset = [offset.x - origin_[0], offset.y - origin_[1]];
} else {
offset = [0, 0];
}
event_({type: "dragstart"});
function point() {
var p = target.parentNode,
t = d3.event.changedTouches;
return t ? d3.touches(p, t)[0] : d3.mouse(p);
}
function dragmove() {
if (!target.parentNode) return dragend(); // target removed from DOM
var p = point(),
dx = p[0] - origin_[0],
dy = p[1] - origin_[1];
moved |= dx | dy;
origin_ = p;
d3_eventCancel();
event_({type: "drag", x: p[0] + offset[0], y: p[1] + offset[1], dx: dx, dy: dy});
}
function dragend() {
event_({type: "dragend"});
// if moved, prevent the mouseup (and possibly click) from propagating
if (moved) {
d3_eventCancel();
if (d3.event.target === eventTarget) w.on("click.drag", click, true);
}
w .on("mousemove.drag", null)
.on("touchmove.drag", null)
.on("mouseup.drag", null)
.on("touchend.drag", null);
}
// prevent the subsequent click from propagating (e.g., for anchors)
function click() {
d3_eventCancel();
w.on("click.drag", null);
}
}
drag.origin = function(x) {
if (!arguments.length) return origin;
origin = x;
return drag;
};
return d3.rebind(drag, event, "on");
};
d3.behavior.zoom = function() {
var translate = [0, 0],
translate0, // translate when we started zooming (to avoid drift)
scale = 1,
scale0, // scale when we started touching
scaleExtent = d3_behavior_zoomInfinity,
event = d3_eventDispatch(zoom, "zoom"),
x0,
x1,
y0,
y1,
touchtime; // time of last touchstart (to detect double-tap)
function zoom() {
this
.on("mousedown.zoom", mousedown)
.on("mousewheel.zoom", mousewheel)
.on("mousemove.zoom", mousemove)
.on("DOMMouseScroll.zoom", mousewheel)
.on("dblclick.zoom", dblclick)
.on("touchstart.zoom", touchstart)
.on("touchmove.zoom", touchmove)
.on("touchend.zoom", touchstart);
}
zoom.translate = function(x) {
if (!arguments.length) return translate;
translate = x.map(Number);
return zoom;
};
zoom.scale = function(x) {
if (!arguments.length) return scale;
scale = +x;
return zoom;
};
zoom.scaleExtent = function(x) {
if (!arguments.length) return scaleExtent;
scaleExtent = x == null ? d3_behavior_zoomInfinity : x.map(Number);
return zoom;
};
zoom.x = function(z) {
if (!arguments.length) return x1;
x1 = z;
x0 = z.copy();
return zoom;
};
zoom.y = function(z) {
if (!arguments.length) return y1;
y1 = z;
y0 = z.copy();
return zoom;
};
function location(p) {
return [(p[0] - translate[0]) / scale, (p[1] - translate[1]) / scale];
}
function point(l) {
return [l[0] * scale + translate[0], l[1] * scale + translate[1]];
}
function scaleTo(s) {
scale = Math.max(scaleExtent[0], Math.min(scaleExtent[1], s));
}
function translateTo(p, l) {
l = point(l);
translate[0] += p[0] - l[0];
translate[1] += p[1] - l[1];
}
function dispatch(event) {
if (x1) x1.domain(x0.range().map(function(x) { return (x - translate[0]) / scale; }).map(x0.invert));
if (y1) y1.domain(y0.range().map(function(y) { return (y - translate[1]) / scale; }).map(y0.invert));
d3.event.preventDefault();
event({type: "zoom", scale: scale, translate: translate});
}
function mousedown() {
var target = this,
event_ = event.of(target, arguments),
eventTarget = d3.event.target,
moved = 0,
w = d3.select(window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup),
l = location(d3.mouse(target));
window.focus();
d3_eventCancel();
function mousemove() {
moved = 1;
translateTo(d3.mouse(target), l);
dispatch(event_);
}
function mouseup() {
if (moved) d3_eventCancel();
w.on("mousemove.zoom", null).on("mouseup.zoom", null);
if (moved && d3.event.target === eventTarget) w.on("click.zoom", click);
}
function click() {
d3_eventCancel();
w.on("click.zoom", null);
}
}
function mousewheel() {
if (!translate0) translate0 = location(d3.mouse(this));
scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * scale);
translateTo(d3.mouse(this), translate0);
dispatch(event.of(this, arguments));
}
function mousemove() {
translate0 = null;
}
function dblclick() {
var p = d3.mouse(this), l = location(p);
scaleTo(d3.event.shiftKey ? scale / 2 : scale * 2);
translateTo(p, l);
dispatch(event.of(this, arguments));
}
function touchstart() {
var touches = d3.touches(this),
now = Date.now();
scale0 = scale;
translate0 = {};
touches.forEach(function(t) { translate0[t.identifier] = location(t); });
d3_eventCancel();
if ((touches.length === 1) && (now - touchtime < 500)) { // dbltap
var p = touches[0], l = location(touches[0]);
scaleTo(scale * 2);
translateTo(p, l);
dispatch(event.of(this, arguments));
}
touchtime = now;
}
function touchmove() {
var touches = d3.touches(this),
p0 = touches[0],
l0 = translate0[p0.identifier];
if (p1 = touches[1]) {
var p1, l1 = translate0[p1.identifier];
p0 = [(p0[0] + p1[0]) / 2, (p0[1] + p1[1]) / 2];
l0 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
scaleTo(d3.event.scale * scale0);
}
translateTo(p0, l0);
dispatch(event.of(this, arguments));
}
return d3.rebind(zoom, event, "on");
};
var d3_behavior_zoomDiv, // for interpreting mousewheel events
d3_behavior_zoomInfinity = [0, Infinity]; // default scale extent
function d3_behavior_zoomDelta() {
// mousewheel events are totally broken!
// https://bugs.webkit.org/show_bug.cgi?id=40441
// not only that, but Chrome and Safari differ in re. to acceleration!
if (!d3_behavior_zoomDiv) {
d3_behavior_zoomDiv = d3.select("body").append("div")
.style("visibility", "hidden")
.style("top", 0)
.style("height", 0)
.style("width", 0)
.style("overflow-y", "scroll")
.append("div")
.style("height", "2000px")
.node().parentNode;
}
var e = d3.event, delta;
try {
d3_behavior_zoomDiv.scrollTop = 1000;
d3_behavior_zoomDiv.dispatchEvent(e);
delta = 1000 - d3_behavior_zoomDiv.scrollTop;
} catch (error) {
delta = e.wheelDelta || (-e.detail * 5);
}
return delta;
}
d3.layout = {};
// Implements hierarchical edge bundling using Holten's algorithm. For each
// input link, a path is computed that travels through the tree, up the parent
// hierarchy to the least common ancestor, and then back down to the destination
// node. Each path is simply an array of nodes.
d3.layout.bundle = function() {
return function(links) {
var paths = [],
i = -1,
n = links.length;
while (++i < n) paths.push(d3_layout_bundlePath(links[i]));
return paths;
};
};
function d3_layout_bundlePath(link) {
var start = link.source,
end = link.target,
lca = d3_layout_bundleLeastCommonAncestor(start, end),
points = [start];
while (start !== lca) {
start = start.parent;
points.push(start);
}
var k = points.length;
while (end !== lca) {
points.splice(k, 0, end);
end = end.parent;
}
return points;
}
function d3_layout_bundleAncestors(node) {
var ancestors = [],
parent = node.parent;
while (parent != null) {
ancestors.push(node);
node = parent;
parent = parent.parent;
}
ancestors.push(node);
return ancestors;
}
function d3_layout_bundleLeastCommonAncestor(a, b) {
if (a === b) return a;
var aNodes = d3_layout_bundleAncestors(a),
bNodes = d3_layout_bundleAncestors(b),
aNode = aNodes.pop(),
bNode = bNodes.pop(),
sharedNode = null;
while (aNode === bNode) {
sharedNode = aNode;
aNode = aNodes.pop();
bNode = bNodes.pop();
}
return sharedNode;
}
d3.layout.chord = function() {
var chord = {},
chords,
groups,
matrix,
n,
padding = 0,
sortGroups,
sortSubgroups,
sortChords;
function relayout() {
var subgroups = {},
groupSums = [],
groupIndex = d3.range(n),
subgroupIndex = [],
k,
x,
x0,
i,
j;
chords = [];
groups = [];
// Compute the sum.
k = 0, i = -1; while (++i < n) {
x = 0, j = -1; while (++j < n) {
x += matrix[i][j];
}
groupSums.push(x);
subgroupIndex.push(d3.range(n));
k += x;
}
// Sort groups…
if (sortGroups) {
groupIndex.sort(function(a, b) {
return sortGroups(groupSums[a], groupSums[b]);
});
}
// Sort subgroups…
if (sortSubgroups) {
subgroupIndex.forEach(function(d, i) {
d.sort(function(a, b) {
return sortSubgroups(matrix[i][a], matrix[i][b]);
});
});
}
// Convert the sum to scaling factor for [0, 2pi].
// TODO Allow start and end angle to be specified.
// TODO Allow padding to be specified as percentage?
k = (2 * Math.PI - padding * n) / k;
// Compute the start and end angle for each group and subgroup.
// Note: Opera has a bug reordering object literal properties!
x = 0, i = -1; while (++i < n) {
x0 = x, j = -1; while (++j < n) {
var di = groupIndex[i],
dj = subgroupIndex[di][j],
v = matrix[di][dj],
a0 = x,
a1 = x += v * k;
subgroups[di + "-" + dj] = {
index: di,
subindex: dj,
startAngle: a0,
endAngle: a1,
value: v
};
}
groups.push({
index: di,
startAngle: x0,
endAngle: x,
value: (x - x0) / k
});
x += padding;
}
// Generate chords for each (non-empty) subgroup-subgroup link.
i = -1; while (++i < n) {
j = i - 1; while (++j < n) {
var source = subgroups[i + "-" + j],
target = subgroups[j + "-" + i];
if (source.value || target.value) {
chords.push(source.value < target.value
? {source: target, target: source}
: {source: source, target: target});
}
}
}
if (sortChords) resort();
}
function resort() {
chords.sort(function(a, b) {
return sortChords(
(a.source.value + a.target.value) / 2,
(b.source.value + b.target.value) / 2);
});
}
chord.matrix = function(x) {
if (!arguments.length) return matrix;
n = (matrix = x) && matrix.length;
chords = groups = null;
return chord;
};
chord.padding = function(x) {
if (!arguments.length) return padding;
padding = x;
chords = groups = null;
return chord;
};
chord.sortGroups = function(x) {
if (!arguments.length) return sortGroups;
sortGroups = x;
chords = groups = null;
return chord;
};
chord.sortSubgroups = function(x) {
if (!arguments.length) return sortSubgroups;
sortSubgroups = x;
chords = null;
return chord;
};
chord.sortChords = function(x) {
if (!arguments.length) return sortChords;
sortChords = x;
if (chords) resort();
return chord;
};
chord.chords = function() {
if (!chords) relayout();
return chords;
};
chord.groups = function() {
if (!groups) relayout();
return groups;
};
return chord;
};
// A rudimentary force layout using Gauss-Seidel.
d3.layout.force = function() {
var force = {},
event = d3.dispatch("start", "tick", "end"),
size = [1, 1],
drag,
alpha,
friction = .9,
linkDistance = d3_layout_forceLinkDistance,
linkStrength = d3_layout_forceLinkStrength,
charge = -30,
gravity = .1,
theta = .8,
interval,
nodes = [],
links = [],
distances,
strengths,
charges;
function repulse(node) {
return function(quad, x1, y1, x2, y2) {
if (quad.point !== node) {
var dx = quad.cx - node.x,
dy = quad.cy - node.y,
dn = 1 / Math.sqrt(dx * dx + dy * dy);
/* Barnes-Hut criterion. */
if ((x2 - x1) * dn < theta) {
var k = quad.charge * dn * dn;
node.px -= dx * k;
node.py -= dy * k;
return true;
}
if (quad.point && isFinite(dn)) {
var k = quad.pointCharge * dn * dn;
node.px -= dx * k;
node.py -= dy * k;
}
}
return !quad.charge;
};
}
force.tick = function() {
// simulated annealing, basically
if ((alpha *= .99) < .005) {
event.end({type: "end", alpha: alpha = 0});
return true;
}
var n = nodes.length,
m = links.length,
q,
i, // current index
o, // current object
s, // current source
t, // current target
l, // current distance
k, // current force
x, // x-distance
y; // y-distance
// gauss-seidel relaxation for links
for (i = 0; i < m; ++i) {
o = links[i];
s = o.source;
t = o.target;
x = t.x - s.x;
y = t.y - s.y;
if (l = (x * x + y * y)) {
l = alpha * strengths[i] * ((l = Math.sqrt(l)) - distances[i]) / l;
x *= l;
y *= l;
t.x -= x * (k = s.weight / (t.weight + s.weight));
t.y -= y * k;
s.x += x * (k = 1 - k);
s.y += y * k;
}
}
// apply gravity forces
if (k = alpha * gravity) {
x = size[0] / 2;
y = size[1] / 2;
i = -1; if (k) while (++i < n) {
o = nodes[i];
o.x += (x - o.x) * k;
o.y += (y - o.y) * k;
}
}
// compute quadtree center of mass and apply charge forces
if (charge) {
d3_layout_forceAccumulate(q = d3.geom.quadtree(nodes), alpha, charges);
i = -1; while (++i < n) {
if (!(o = nodes[i]).fixed) {
q.visit(repulse(o));
}
}
}
// position verlet integration
i = -1; while (++i < n) {
o = nodes[i];
if (o.fixed) {
o.x = o.px;
o.y = o.py;
} else {
o.x -= (o.px - (o.px = o.x)) * friction;
o.y -= (o.py - (o.py = o.y)) * friction;
}
}
event.tick({type: "tick", alpha: alpha});
};
force.nodes = function(x) {
if (!arguments.length) return nodes;
nodes = x;
return force;
};
force.links = function(x) {
if (!arguments.length) return links;
links = x;
return force;
};
force.size = function(x) {
if (!arguments.length) return size;
size = x;
return force;
};
force.linkDistance = function(x) {
if (!arguments.length) return linkDistance;
linkDistance = d3.functor(x);
return force;
};
// For backwards-compatibility.
force.distance = force.linkDistance;
force.linkStrength = function(x) {
if (!arguments.length) return linkStrength;
linkStrength = d3.functor(x);
return force;
};
force.friction = function(x) {
if (!arguments.length) return friction;
friction = x;
return force;
};
force.charge = function(x) {
if (!arguments.length) return charge;
charge = typeof x === "function" ? x : +x;
return force;
};
force.gravity = function(x) {
if (!arguments.length) return gravity;
gravity = x;
return force;
};
force.theta = function(x) {
if (!arguments.length) return theta;
theta = x;
return force;
};
force.alpha = function(x) {
if (!arguments.length) return alpha;
if (alpha) { // if we're already running
if (x > 0) alpha = x; // we might keep it hot
else alpha = 0; // or, next tick will dispatch "end"
} else if (x > 0) { // otherwise, fire it up!
event.start({type: "start", alpha: alpha = x});
d3.timer(force.tick);
}
return force;
};
force.start = function() {
var i,
j,
n = nodes.length,
m = links.length,
w = size[0],
h = size[1],
neighbors,
o;
for (i = 0; i < n; ++i) {
(o = nodes[i]).index = i;
o.weight = 0;
}
distances = [];
strengths = [];
for (i = 0; i < m; ++i) {
o = links[i];
if (typeof o.source == "number") o.source = nodes[o.source];
if (typeof o.target == "number") o.target = nodes[o.target];
distances[i] = linkDistance.call(this, o, i);
strengths[i] = linkStrength.call(this, o, i);
++o.source.weight;
++o.target.weight;
}
for (i = 0; i < n; ++i) {
o = nodes[i];
if (isNaN(o.x)) o.x = position("x", w);
if (isNaN(o.y)) o.y = position("y", h);
if (isNaN(o.px)) o.px = o.x;
if (isNaN(o.py)) o.py = o.y;
}
charges = [];
if (typeof charge === "function") {
for (i = 0; i < n; ++i) {
charges[i] = +charge.call(this, nodes[i], i);
}
} else {
for (i = 0; i < n; ++i) {
charges[i] = charge;
}
}
// initialize node position based on first neighbor
function position(dimension, size) {
var neighbors = neighbor(i),
j = -1,
m = neighbors.length,
x;
while (++j < m) if (!isNaN(x = neighbors[j][dimension])) return x;
return Math.random() * size;
}
// initialize neighbors lazily
function neighbor() {
if (!neighbors) {
neighbors = [];
for (j = 0; j < n; ++j) {
neighbors[j] = [];
}
for (j = 0; j < m; ++j) {
var o = links[j];
neighbors[o.source.index].push(o.target);
neighbors[o.target.index].push(o.source);
}
}
return neighbors[i];
}
return force.resume();
};
force.resume = function() {
return force.alpha(.1);
};
force.stop = function() {
return force.alpha(0);
};
// use `node.call(force.drag)` to make nodes draggable
force.drag = function() {
if (!drag) drag = d3.behavior.drag()
.origin(Object)
.on("dragstart", dragstart)
.on("drag", d3_layout_forceDrag)
.on("dragend", d3_layout_forceDragEnd);
this.on("mouseover.force", d3_layout_forceDragOver)
.on("mouseout.force", d3_layout_forceDragOut)
.call(drag);
};
function dragstart(d) {
d3_layout_forceDragOver(d3_layout_forceDragNode = d);
d3_layout_forceDragForce = force;
}
return d3.rebind(force, event, "on");
};
var d3_layout_forceDragForce,
d3_layout_forceDragNode;
function d3_layout_forceDragOver(d) {
d.fixed |= 2;
}
function d3_layout_forceDragOut(d) {
if (d !== d3_layout_forceDragNode) d.fixed &= 1;
}
function d3_layout_forceDragEnd() {
d3_layout_forceDragNode.fixed &= 1;
d3_layout_forceDragForce = d3_layout_forceDragNode = null;
}
function d3_layout_forceDrag() {
d3_layout_forceDragNode.px = d3.event.x;
d3_layout_forceDragNode.py = d3.event.y;
d3_layout_forceDragForce.resume(); // restart annealing
}
function d3_layout_forceAccumulate(quad, alpha, charges) {
var cx = 0,
cy = 0;
quad.charge = 0;
if (!quad.leaf) {
var nodes = quad.nodes,
n = nodes.length,
i = -1,
c;
while (++i < n) {
c = nodes[i];
if (c == null) continue;
d3_layout_forceAccumulate(c, alpha, charges);
quad.charge += c.charge;
cx += c.charge * c.cx;
cy += c.charge * c.cy;
}
}
if (quad.point) {
// jitter internal nodes that are coincident
if (!quad.leaf) {
quad.point.x += Math.random() - .5;
quad.point.y += Math.random() - .5;
}
var k = alpha * charges[quad.point.index];
quad.charge += quad.pointCharge = k;
cx += k * quad.point.x;
cy += k * quad.point.y;
}
quad.cx = cx / quad.charge;
quad.cy = cy / quad.charge;
}
function d3_layout_forceLinkDistance(link) {
return 20;
}
function d3_layout_forceLinkStrength(link) {
return 1;
}
d3.layout.partition = function() {
var hierarchy = d3.layout.hierarchy(),
size = [1, 1]; // width, height
function position(node, x, dx, dy) {
var children = node.children;
node.x = x;
node.y = node.depth * dy;
node.dx = dx;
node.dy = dy;
if (children && (n = children.length)) {
var i = -1,
n,
c,
d;
dx = node.value ? dx / node.value : 0;
while (++i < n) {
position(c = children[i], x, d = c.value * dx, dy);
x += d;
}
}
}
function depth(node) {
var children = node.children,
d = 0;
if (children && (n = children.length)) {
var i = -1,
n;
while (++i < n) d = Math.max(d, depth(children[i]));
}
return 1 + d;
}
function partition(d, i) {
var nodes = hierarchy.call(this, d, i);
position(nodes[0], 0, size[0], size[1] / depth(nodes[0]));
return nodes;
}
partition.size = function(x) {
if (!arguments.length) return size;
size = x;
return partition;
};
return d3_layout_hierarchyRebind(partition, hierarchy);
};
d3.layout.pie = function() {
var value = Number,
sort = d3_layout_pieSortByValue,
startAngle = 0,
endAngle = 2 * Math.PI;
function pie(data, i) {
// Compute the numeric values for each data element.
var values = data.map(function(d, i) { return +value.call(pie, d, i); });
// Compute the start angle.
var a = +(typeof startAngle === "function"
? startAngle.apply(this, arguments)
: startAngle);
// Compute the angular scale factor: from value to radians.
var k = ((typeof endAngle === "function"
? endAngle.apply(this, arguments)
: endAngle) - startAngle)
/ d3.sum(values);
// Optionally sort the data.
var index = d3.range(data.length);
if (sort != null) index.sort(sort === d3_layout_pieSortByValue
? function(i, j) { return values[j] - values[i]; }
: function(i, j) { return sort(data[i], data[j]); });
// Compute the arcs!
// They are stored in the original data's order.
var arcs = [];
index.forEach(function(i) {
arcs[i] = {
data: data[i],
value: d = values[i],
startAngle: a,
endAngle: a += d * k
};
});
return arcs;
}
/**
* Specifies the value function *x*, which returns a nonnegative numeric value
* for each datum. The default value function is `Number`. The value function
* is passed two arguments: the current datum and the current index.
*/
pie.value = function(x) {
if (!arguments.length) return value;
value = x;
return pie;
};
/**
* Specifies a sort comparison operator *x*. The comparator is passed two data
* elements from the data array, a and b; it returns a negative value if a is
* less than b, a positive value if a is greater than b, and zero if a equals
* b.
*/
pie.sort = function(x) {
if (!arguments.length) return sort;
sort = x;
return pie;
};
/**
* Specifies the overall start angle of the pie chart. Defaults to 0. The
* start angle can be specified either as a constant or as a function; in the
* case of a function, it is evaluated once per array (as opposed to per
* element).
*/
pie.startAngle = function(x) {
if (!arguments.length) return startAngle;
startAngle = x;
return pie;
};
/**
* Specifies the overall end angle of the pie chart. Defaults to 2Ï€. The
* end angle can be specified either as a constant or as a function; in the
* case of a function, it is evaluated once per array (as opposed to per
* element).
*/
pie.endAngle = function(x) {
if (!arguments.length) return endAngle;
endAngle = x;
return pie;
};
return pie;
};
var d3_layout_pieSortByValue = {};
// data is two-dimensional array of x,y; we populate y0
d3.layout.stack = function() {
var values = Object,
order = d3_layout_stackOrderDefault,
offset = d3_layout_stackOffsetZero,
out = d3_layout_stackOut,
x = d3_layout_stackX,
y = d3_layout_stackY;
function stack(data, index) {
// Convert series to canonical two-dimensional representation.
var series = data.map(function(d, i) {
return values.call(stack, d, i);
});
// Convert each series to canonical [[x,y]] representation.
var points = series.map(function(d, i) {
return d.map(function(v, i) {
return [x.call(stack, v, i), y.call(stack, v, i)];
});
});
// Compute the order of series, and permute them.
var orders = order.call(stack, points, index);
series = d3.permute(series, orders);
points = d3.permute(points, orders);
// Compute the baseline…
var offsets = offset.call(stack, points, index);
// And propagate it to other series.
var n = series.length,
m = series[0].length,
i,
j,
o;
for (j = 0; j < m; ++j) {
out.call(stack, series[0][j], o = offsets[j], points[0][j][1]);
for (i = 1; i < n; ++i) {
out.call(stack, series[i][j], o += points[i - 1][j][1], points[i][j][1]);
}
}
return data;
}
stack.values = function(x) {
if (!arguments.length) return values;
values = x;
return stack;
};
stack.order = function(x) {
if (!arguments.length) return order;
order = typeof x === "function" ? x : d3_layout_stackOrders.get(x) || d3_layout_stackOrderDefault;
return stack;
};
stack.offset = function(x) {
if (!arguments.length) return offset;
offset = typeof x === "function" ? x : d3_layout_stackOffsets.get(x) || d3_layout_stackOffsetZero;
return stack;
};
stack.x = function(z) {
if (!arguments.length) return x;
x = z;
return stack;
};
stack.y = function(z) {
if (!arguments.length) return y;
y = z;
return stack;
};
stack.out = function(z) {
if (!arguments.length) return out;
out = z;
return stack;
};
return stack;
}
function d3_layout_stackX(d) {
return d.x;
}
function d3_layout_stackY(d) {
return d.y;
}
function d3_layout_stackOut(d, y0, y) {
d.y0 = y0;
d.y = y;
}
var d3_layout_stackOrders = d3.map({
"inside-out": function(data) {
var n = data.length,
i,
j,
max = data.map(d3_layout_stackMaxIndex),
sums = data.map(d3_layout_stackReduceSum),
index = d3.range(n).sort(function(a, b) { return max[a] - max[b]; }),
top = 0,
bottom = 0,
tops = [],
bottoms = [];
for (i = 0; i < n; ++i) {
j = index[i];
if (top < bottom) {
top += sums[j];
tops.push(j);
} else {
bottom += sums[j];
bottoms.push(j);
}
}
return bottoms.reverse().concat(tops);
},
"reverse": function(data) {
return d3.range(data.length).reverse();
},
"default": d3_layout_stackOrderDefault
});
var d3_layout_stackOffsets = d3.map({
"silhouette": function(data) {
var n = data.length,
m = data[0].length,
sums = [],
max = 0,
i,
j,
o,
y0 = [];
for (j = 0; j < m; ++j) {
for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
if (o > max) max = o;
sums.push(o);
}
for (j = 0; j < m; ++j) {
y0[j] = (max - sums[j]) / 2;
}
return y0;
},
"wiggle": function(data) {
var n = data.length,
x = data[0],
m = x.length,
max = 0,
i,
j,
k,
s1,
s2,
s3,
dx,
o,
o0,
y0 = [];
y0[0] = o = o0 = 0;
for (j = 1; j < m; ++j) {
for (i = 0, s1 = 0; i < n; ++i) s1 += data[i][j][1];
for (i = 0, s2 = 0, dx = x[j][0] - x[j - 1][0]; i < n; ++i) {
for (k = 0, s3 = (data[i][j][1] - data[i][j - 1][1]) / (2 * dx); k < i; ++k) {
s3 += (data[k][j][1] - data[k][j - 1][1]) / dx;
}
s2 += s3 * data[i][j][1];
}
y0[j] = o -= s1 ? s2 / s1 * dx : 0;
if (o < o0) o0 = o;
}
for (j = 0; j < m; ++j) y0[j] -= o0;
return y0;
},
"expand": function(data) {
var n = data.length,
m = data[0].length,
k = 1 / n,
i,
j,
o,
y0 = [];
for (j = 0; j < m; ++j) {
for (i = 0, o = 0; i < n; i++) o += data[i][j][1];
if (o) for (i = 0; i < n; i++) data[i][j][1] /= o;
else for (i = 0; i < n; i++) data[i][j][1] = k;
}
for (j = 0; j < m; ++j) y0[j] = 0;
return y0;
},
"zero": d3_layout_stackOffsetZero
});
function d3_layout_stackOrderDefault(data) {
return d3.range(data.length);
}
function d3_layout_stackOffsetZero(data) {
var j = -1,
m = data[0].length,
y0 = [];
while (++j < m) y0[j] = 0;
return y0;
}
function d3_layout_stackMaxIndex(array) {
var i = 1,
j = 0,
v = array[0][1],
k,
n = array.length;
for (; i < n; ++i) {
if ((k = array[i][1]) > v) {
j = i;
v = k;
}
}
return j;
}
function d3_layout_stackReduceSum(d) {
return d.reduce(d3_layout_stackSum, 0);
}
function d3_layout_stackSum(p, d) {
return p + d[1];
}
d3.layout.histogram = function() {
var frequency = true,
valuer = Number,
ranger = d3_layout_histogramRange,
binner = d3_layout_histogramBinSturges;
function histogram(data, i) {
var bins = [],
values = data.map(valuer, this),
range = ranger.call(this, values, i),
thresholds = binner.call(this, range, values, i),
bin,
i = -1,
n = values.length,
m = thresholds.length - 1,
k = frequency ? 1 : 1 / n,
x;
// Initialize the bins.
while (++i < m) {
bin = bins[i] = [];
bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]);
bin.y = 0;
}
// Fill the bins, ignoring values outside the range.
i = -1; while(++i < n) {
x = values[i];
if ((x >= range[0]) && (x <= range[1])) {
bin = bins[d3.bisect(thresholds, x, 1, m) - 1];
bin.y += k;
bin.push(data[i]);
}
}
return bins;
}
// Specifies how to extract a value from the associated data. The default
// value function is `Number`, which is equivalent to the identity function.
histogram.value = function(x) {
if (!arguments.length) return valuer;
valuer = x;
return histogram;
};
// Specifies the range of the histogram. Values outside the specified range
// will be ignored. The argument `x` may be specified either as a two-element
// array representing the minimum and maximum value of the range, or as a
// function that returns the range given the array of values and the current
// index `i`. The default range is the extent (minimum and maximum) of the
// values.
histogram.range = function(x) {
if (!arguments.length) return ranger;
ranger = d3.functor(x);
return histogram;
};
// Specifies how to bin values in the histogram. The argument `x` may be
// specified as a number, in which case the range of values will be split
// uniformly into the given number of bins. Or, `x` may be an array of
// threshold values, defining the bins; the specified array must contain the
// rightmost (upper) value, thus specifying n + 1 values for n bins. Or, `x`
// may be a function which is evaluated, being passed the range, the array of
// values, and the current index `i`, returning an array of thresholds. The
// default bin function will divide the values into uniform bins using
// Sturges' formula.
histogram.bins = function(x) {
if (!arguments.length) return binner;
binner = typeof x === "number"
? function(range) { return d3_layout_histogramBinFixed(range, x); }
: d3.functor(x);
return histogram;
};
// Specifies whether the histogram's `y` value is a count (frequency) or a
// probability (density). The default value is true.
histogram.frequency = function(x) {
if (!arguments.length) return frequency;
frequency = !!x;
return histogram;
};
return histogram;
};
function d3_layout_histogramBinSturges(range, values) {
return d3_layout_histogramBinFixed(range, Math.ceil(Math.log(values.length) / Math.LN2 + 1));
}
function d3_layout_histogramBinFixed(range, n) {
var x = -1,
b = +range[0],
m = (range[1] - b) / n,
f = [];
while (++x <= n) f[x] = m * x + b;
return f;
}
function d3_layout_histogramRange(values) {
return [d3.min(values), d3.max(values)];
}
d3.layout.hierarchy = function() {
var sort = d3_layout_hierarchySort,
children = d3_layout_hierarchyChildren,
value = d3_layout_hierarchyValue;
// Recursively compute the node depth and value.
// Also converts the data representation into a standard hierarchy structure.
function recurse(data, depth, nodes) {
var childs = children.call(hierarchy, data, depth),
node = d3_layout_hierarchyInline ? data : {data: data};
node.depth = depth;
nodes.push(node);
if (childs && (n = childs.length)) {
var i = -1,
n,
c = node.children = [],
v = 0,
j = depth + 1;
while (++i < n) {
d = recurse(childs[i], j, nodes);
d.parent = node;
c.push(d);
v += d.value;
}
if (sort) c.sort(sort);
if (value) node.value = v;
} else if (value) {
node.value = +value.call(hierarchy, data, depth) || 0;
}
return node;
}
// Recursively re-evaluates the node value.
function revalue(node, depth) {
var children = node.children,
v = 0;
if (children && (n = children.length)) {
var i = -1,
n,
j = depth + 1;
while (++i < n) v += revalue(children[i], j);
} else if (value) {
v = +value.call(hierarchy, d3_layout_hierarchyInline ? node : node.data, depth) || 0;
}
if (value) node.value = v;
return v;
}
function hierarchy(d) {
var nodes = [];
recurse(d, 0, nodes);
return nodes;
}
hierarchy.sort = function(x) {
if (!arguments.length) return sort;
sort = x;
return hierarchy;
};
hierarchy.children = function(x) {
if (!arguments.length) return children;
children = x;
return hierarchy;
};
hierarchy.value = function(x) {
if (!arguments.length) return value;
value = x;
return hierarchy;
};
// Re-evaluates the `value` property for the specified hierarchy.
hierarchy.revalue = function(root) {
revalue(root, 0);
return root;
};
return hierarchy;
};
// A method assignment helper for hierarchy subclasses.
function d3_layout_hierarchyRebind(object, hierarchy) {
d3.rebind(object, hierarchy, "sort", "children", "value");
// Add an alias for links, for convenience.
object.links = d3_layout_hierarchyLinks;
// If the new API is used, enabling inlining.
object.nodes = function(d) {
d3_layout_hierarchyInline = true;
return (object.nodes = object)(d);
};
return object;
}
function d3_layout_hierarchyChildren(d) {
return d.children;
}
function d3_layout_hierarchyValue(d) {
return d.value;
}
function d3_layout_hierarchySort(a, b) {
return b.value - a.value;
}
// Returns an array source+target objects for the specified nodes.
function d3_layout_hierarchyLinks(nodes) {
return d3.merge(nodes.map(function(parent) {
return (parent.children || []).map(function(child) {
return {source: parent, target: child};
});
}));
}
// For backwards-compatibility, don't enable inlining by default.
var d3_layout_hierarchyInline = false;
d3.layout.pack = function() {
var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort),
size = [1, 1];
function pack(d, i) {
var nodes = hierarchy.call(this, d, i),
root = nodes[0];
// Recursively compute the layout.
root.x = 0;
root.y = 0;
d3_layout_packTree(root);
// Scale the layout to fit the requested size.
var w = size[0],
h = size[1],
k = 1 / Math.max(2 * root.r / w, 2 * root.r / h);
d3_layout_packTransform(root, w / 2, h / 2, k);
return nodes;
}
pack.size = function(x) {
if (!arguments.length) return size;
size = x;
return pack;
};
return d3_layout_hierarchyRebind(pack, hierarchy);
};
function d3_layout_packSort(a, b) {
return a.value - b.value;
}
function d3_layout_packInsert(a, b) {
var c = a._pack_next;
a._pack_next = b;
b._pack_prev = a;
b._pack_next = c;
c._pack_prev = b;
}
function d3_layout_packSplice(a, b) {
a._pack_next = b;
b._pack_prev = a;
}
function d3_layout_packIntersects(a, b) {
var dx = b.x - a.x,
dy = b.y - a.y,
dr = a.r + b.r;
return dr * dr - dx * dx - dy * dy > .001; // within epsilon
}
function d3_layout_packCircle(nodes) {
var xMin = Infinity,
xMax = -Infinity,
yMin = Infinity,
yMax = -Infinity,
n = nodes.length,
a, b, c, j, k;
function bound(node) {
xMin = Math.min(node.x - node.r, xMin);
xMax = Math.max(node.x + node.r, xMax);
yMin = Math.min(node.y - node.r, yMin);
yMax = Math.max(node.y + node.r, yMax);
}
// Create node links.
nodes.forEach(d3_layout_packLink);
// Create first node.
a = nodes[0];
a.x = -a.r;
a.y = 0;
bound(a);
// Create second node.
if (n > 1) {
b = nodes[1];
b.x = b.r;
b.y = 0;
bound(b);
// Create third node and build chain.
if (n > 2) {
c = nodes[2];
d3_layout_packPlace(a, b, c);
bound(c);
d3_layout_packInsert(a, c);
a._pack_prev = c;
d3_layout_packInsert(c, b);
b = a._pack_next;
// Now iterate through the rest.
for (var i = 3; i < n; i++) {
d3_layout_packPlace(a, b, c = nodes[i]);
// Search for the closest intersection.
var isect = 0, s1 = 1, s2 = 1;
for (j = b._pack_next; j !== b; j = j._pack_next, s1++) {
if (d3_layout_packIntersects(j, c)) {
isect = 1;
break;
}
}
if (isect == 1) {
for (k = a._pack_prev; k !== j._pack_prev; k = k._pack_prev, s2++) {
if (d3_layout_packIntersects(k, c)) {
break;
}
}
}
// Update node chain.
if (isect) {
if (s1 < s2 || (s1 == s2 && b.r < a.r)) d3_layout_packSplice(a, b = j);
else d3_layout_packSplice(a = k, b);
i--;
} else {
d3_layout_packInsert(a, c);
b = c;
bound(c);
}
}
}
}
// Re-center the circles and return the encompassing radius.
var cx = (xMin + xMax) / 2,
cy = (yMin + yMax) / 2,
cr = 0;
for (var i = 0; i < n; i++) {
var node = nodes[i];
node.x -= cx;
node.y -= cy;
cr = Math.max(cr, node.r + Math.sqrt(node.x * node.x + node.y * node.y));
}
// Remove node links.
nodes.forEach(d3_layout_packUnlink);
return cr;
}
function d3_layout_packLink(node) {
node._pack_next = node._pack_prev = node;
}
function d3_layout_packUnlink(node) {
delete node._pack_next;
delete node._pack_prev;
}
function d3_layout_packTree(node) {
var children = node.children;
if (children && children.length) {
children.forEach(d3_layout_packTree);
node.r = d3_layout_packCircle(children);
} else {
node.r = Math.sqrt(node.value);
}
}
function d3_layout_packTransform(node, x, y, k) {
var children = node.children;
node.x = (x += k * node.x);
node.y = (y += k * node.y);
node.r *= k;
if (children) {
var i = -1, n = children.length;
while (++i < n) d3_layout_packTransform(children[i], x, y, k);
}
}
function d3_layout_packPlace(a, b, c) {
var db = a.r + c.r,
dx = b.x - a.x,
dy = b.y - a.y;
if (db && (dx || dy)) {
var da = b.r + c.r,
dc = Math.sqrt(dx * dx + dy * dy),
cos = Math.max(-1, Math.min(1, (db * db + dc * dc - da * da) / (2 * db * dc))),
theta = Math.acos(cos),
x = cos * (db /= dc),
y = Math.sin(theta) * db;
c.x = a.x + x * dx + y * dy;
c.y = a.y + x * dy - y * dx;
} else {
c.x = a.x + db;
c.y = a.y;
}
}
// Implements a hierarchical layout using the cluster (or dendrogram)
// algorithm.
d3.layout.cluster = function() {
var hierarchy = d3.layout.hierarchy().sort(null).value(null),
separation = d3_layout_treeSeparation,
size = [1, 1]; // width, height
function cluster(d, i) {
var nodes = hierarchy.call(this, d, i),
root = nodes[0],
previousNode,
x = 0,
kx,
ky;
// First walk, computing the initial x & y values.
d3_layout_treeVisitAfter(root, function(node) {
var children = node.children;
if (children && children.length) {
node.x = d3_layout_clusterX(children);
node.y = d3_layout_clusterY(children);
} else {
node.x = previousNode ? x += separation(node, previousNode) : 0;
node.y = 0;
previousNode = node;
}
});
// Compute the left-most, right-most, and depth-most nodes for extents.
var left = d3_layout_clusterLeft(root),
right = d3_layout_clusterRight(root),
x0 = left.x - separation(left, right) / 2,
x1 = right.x + separation(right, left) / 2;
// Second walk, normalizing x & y to the desired size.
d3_layout_treeVisitAfter(root, function(node) {
node.x = (node.x - x0) / (x1 - x0) * size[0];
node.y = (1 - (root.y ? node.y / root.y : 1)) * size[1];
});
return nodes;
}
cluster.separation = function(x) {
if (!arguments.length) return separation;
separation = x;
return cluster;
};
cluster.size = function(x) {
if (!arguments.length) return size;
size = x;
return cluster;
};
return d3_layout_hierarchyRebind(cluster, hierarchy);
};
function d3_layout_clusterY(children) {
return 1 + d3.max(children, function(child) {
return child.y;
});
}
function d3_layout_clusterX(children) {
return children.reduce(function(x, child) {
return x + child.x;
}, 0) / children.length;
}
function d3_layout_clusterLeft(node) {
var children = node.children;
return children && children.length ? d3_layout_clusterLeft(children[0]) : node;
}
function d3_layout_clusterRight(node) {
var children = node.children, n;
return children && (n = children.length) ? d3_layout_clusterRight(children[n - 1]) : node;
}
// Node-link tree diagram using the Reingold-Tilford "tidy" algorithm
d3.layout.tree = function() {
var hierarchy = d3.layout.hierarchy().sort(null).value(null),
separation = d3_layout_treeSeparation,
size = [1, 1]; // width, height
function tree(d, i) {
var nodes = hierarchy.call(this, d, i),
root = nodes[0];
function firstWalk(node, previousSibling) {
var children = node.children,
layout = node._tree;
if (children && (n = children.length)) {
var n,
firstChild = children[0],
previousChild,
ancestor = firstChild,
child,
i = -1;
while (++i < n) {
child = children[i];
firstWalk(child, previousChild);
ancestor = apportion(child, previousChild, ancestor);
previousChild = child;
}
d3_layout_treeShift(node);
var midpoint = .5 * (firstChild._tree.prelim + child._tree.prelim);
if (previousSibling) {
layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
layout.mod = layout.prelim - midpoint;
} else {
layout.prelim = midpoint;
}
} else {
if (previousSibling) {
layout.prelim = previousSibling._tree.prelim + separation(node, previousSibling);
}
}
}
function secondWalk(node, x) {
node.x = node._tree.prelim + x;
var children = node.children;
if (children && (n = children.length)) {
var i = -1,
n;
x += node._tree.mod;
while (++i < n) {
secondWalk(children[i], x);
}
}
}
function apportion(node, previousSibling, ancestor) {
if (previousSibling) {
var vip = node,
vop = node,
vim = previousSibling,
vom = node.parent.children[0],
sip = vip._tree.mod,
sop = vop._tree.mod,
sim = vim._tree.mod,
som = vom._tree.mod,
shift;
while (vim = d3_layout_treeRight(vim), vip = d3_layout_treeLeft(vip), vim && vip) {
vom = d3_layout_treeLeft(vom);
vop = d3_layout_treeRight(vop);
vop._tree.ancestor = node;
shift = vim._tree.prelim + sim - vip._tree.prelim - sip + separation(vim, vip);
if (shift > 0) {
d3_layout_treeMove(d3_layout_treeAncestor(vim, node, ancestor), node, shift);
sip += shift;
sop += shift;
}
sim += vim._tree.mod;
sip += vip._tree.mod;
som += vom._tree.mod;
sop += vop._tree.mod;
}
if (vim && !d3_layout_treeRight(vop)) {
vop._tree.thread = vim;
vop._tree.mod += sim - sop;
}
if (vip && !d3_layout_treeLeft(vom)) {
vom._tree.thread = vip;
vom._tree.mod += sip - som;
ancestor = node;
}
}
return ancestor;
}
// Initialize temporary layout variables.
d3_layout_treeVisitAfter(root, function(node, previousSibling) {
node._tree = {
ancestor: node,
prelim: 0,
mod: 0,
change: 0,
shift: 0,
number: previousSibling ? previousSibling._tree.number + 1 : 0
};
});
// Compute the layout using Buchheim et al.'s algorithm.
firstWalk(root);
secondWalk(root, -root._tree.prelim);
// Compute the left-most, right-most, and depth-most nodes for extents.
var left = d3_layout_treeSearch(root, d3_layout_treeLeftmost),
right = d3_layout_treeSearch(root, d3_layout_treeRightmost),
deep = d3_layout_treeSearch(root, d3_layout_treeDeepest),
x0 = left.x - separation(left, right) / 2,
x1 = right.x + separation(right, left) / 2,
y1 = deep.depth || 1;
// Clear temporary layout variables; transform x and y.
d3_layout_treeVisitAfter(root, function(node) {
node.x = (node.x - x0) / (x1 - x0) * size[0];
node.y = node.depth / y1 * size[1];
delete node._tree;
});
return nodes;
}
tree.separation = function(x) {
if (!arguments.length) return separation;
separation = x;
return tree;
};
tree.size = function(x) {
if (!arguments.length) return size;
size = x;
return tree;
};
return d3_layout_hierarchyRebind(tree, hierarchy);
};
function d3_layout_treeSeparation(a, b) {
return a.parent == b.parent ? 1 : 2;
}
// function d3_layout_treeSeparationRadial(a, b) {
// return (a.parent == b.parent ? 1 : 2) / a.depth;
// }
function d3_layout_treeLeft(node) {
var children = node.children;
return children && children.length ? children[0] : node._tree.thread;
}
function d3_layout_treeRight(node) {
var children = node.children,
n;
return children && (n = children.length) ? children[n - 1] : node._tree.thread;
}
function d3_layout_treeSearch(node, compare) {
var children = node.children;
if (children && (n = children.length)) {
var child,
n,
i = -1;
while (++i < n) {
if (compare(child = d3_layout_treeSearch(children[i], compare), node) > 0) {
node = child;
}
}
}
return node;
}
function d3_layout_treeRightmost(a, b) {
return a.x - b.x;
}
function d3_layout_treeLeftmost(a, b) {
return b.x - a.x;
}
function d3_layout_treeDeepest(a, b) {
return a.depth - b.depth;
}
function d3_layout_treeVisitAfter(node, callback) {
function visit(node, previousSibling) {
var children = node.children;
if (children && (n = children.length)) {
var child,
previousChild = null,
i = -1,
n;
while (++i < n) {
child = children[i];
visit(child, previousChild);
previousChild = child;
}
}
callback(node, previousSibling);
}
visit(node, null);
}
function d3_layout_treeShift(node) {
var shift = 0,
change = 0,
children = node.children,
i = children.length,
child;
while (--i >= 0) {
child = children[i]._tree;
child.prelim += shift;
child.mod += shift;
shift += child.shift + (change += child.change);
}
}
function d3_layout_treeMove(ancestor, node, shift) {
ancestor = ancestor._tree;
node = node._tree;
var change = shift / (node.number - ancestor.number);
ancestor.change += change;
node.change -= change;
node.shift += shift;
node.prelim += shift;
node.mod += shift;
}
function d3_layout_treeAncestor(vim, node, ancestor) {
return vim._tree.ancestor.parent == node.parent
? vim._tree.ancestor
: ancestor;
}
// Squarified Treemaps by Mark Bruls, Kees Huizing, and Jarke J. van Wijk
// Modified to support a target aspect ratio by Jeff Heer
d3.layout.treemap = function() {
var hierarchy = d3.layout.hierarchy(),
round = Math.round,
size = [1, 1], // width, height
padding = null,
pad = d3_layout_treemapPadNull,
sticky = false,
stickies,
ratio = 0.5 * (1 + Math.sqrt(5)); // golden ratio
// Compute the area for each child based on value & scale.
function scale(children, k) {
var i = -1,
n = children.length,
child,
area;
while (++i < n) {
area = (child = children[i]).value * (k < 0 ? 0 : k);
child.area = isNaN(area) || area <= 0 ? 0 : area;
}
}
// Recursively arranges the specified node's children into squarified rows.
function squarify(node) {
var children = node.children;
if (children && children.length) {
var rect = pad(node),
row = [],
remaining = children.slice(), // copy-on-write
child,
best = Infinity, // the best row score so far
score, // the current row score
u = Math.min(rect.dx, rect.dy), // initial orientation
n;
scale(remaining, rect.dx * rect.dy / node.value);
row.area = 0;
while ((n = remaining.length) > 0) {
row.push(child = remaining[n - 1]);
row.area += child.area;
if ((score = worst(row, u)) <= best) { // continue with this orientation
remaining.pop();
best = score;
} else { // abort, and try a different orientation
row.area -= row.pop().area;
position(row, u, rect, false);
u = Math.min(rect.dx, rect.dy);
row.length = row.area = 0;
best = Infinity;
}
}
if (row.length) {
position(row, u, rect, true);
row.length = row.area = 0;
}
children.forEach(squarify);
}
}
// Recursively resizes the specified node's children into existing rows.
// Preserves the existing layout!
function stickify(node) {
var children = node.children;
if (children && children.length) {
var rect = pad(node),
remaining = children.slice(), // copy-on-write
child,
row = [];
scale(remaining, rect.dx * rect.dy / node.value);
row.area = 0;
while (child = remaining.pop()) {
row.push(child);
row.area += child.area;
if (child.z != null) {
position(row, child.z ? rect.dx : rect.dy, rect, !remaining.length);
row.length = row.area = 0;
}
}
children.forEach(stickify);
}
}
// Computes the score for the specified row, as the worst aspect ratio.
function worst(row, u) {
var s = row.area,
r,
rmax = 0,
rmin = Infinity,
i = -1,
n = row.length;
while (++i < n) {
if (!(r = row[i].area)) continue;
if (r < rmin) rmin = r;
if (r > rmax) rmax = r;
}
s *= s;
u *= u;
return s
? Math.max((u * rmax * ratio) / s, s / (u * rmin * ratio))
: Infinity;
}
// Positions the specified row of nodes. Modifies `rect`.
function position(row, u, rect, flush) {
var i = -1,
n = row.length,
x = rect.x,
y = rect.y,
v = u ? round(row.area / u) : 0,
o;
if (u == rect.dx) { // horizontal subdivision
if (flush || v > rect.dy) v = rect.dy; // over+underflow
while (++i < n) {
o = row[i];
o.x = x;
o.y = y;
o.dy = v;
x += o.dx = Math.min(rect.x + rect.dx - x, v ? round(o.area / v) : 0);
}
o.z = true;
o.dx += rect.x + rect.dx - x; // rounding error
rect.y += v;
rect.dy -= v;
} else { // vertical subdivision
if (flush || v > rect.dx) v = rect.dx; // over+underflow
while (++i < n) {
o = row[i];
o.x = x;
o.y = y;
o.dx = v;
y += o.dy = Math.min(rect.y + rect.dy - y, v ? round(o.area / v) : 0);
}
o.z = false;
o.dy += rect.y + rect.dy - y; // rounding error
rect.x += v;
rect.dx -= v;
}
}
function treemap(d) {
var nodes = stickies || hierarchy(d),
root = nodes[0];
root.x = 0;
root.y = 0;
root.dx = size[0];
root.dy = size[1];
if (stickies) hierarchy.revalue(root);
scale([root], root.dx * root.dy / root.value);
(stickies ? stickify : squarify)(root);
if (sticky) stickies = nodes;
return nodes;
}
treemap.size = function(x) {
if (!arguments.length) return size;
size = x;
return treemap;
};
treemap.padding = function(x) {
if (!arguments.length) return padding;
function padFunction(node) {
var p = x.call(treemap, node, node.depth);
return p == null
? d3_layout_treemapPadNull(node)
: d3_layout_treemapPad(node, typeof p === "number" ? [p, p, p, p] : p);
}
function padConstant(node) {
return d3_layout_treemapPad(node, x);
}
var type;
pad = (padding = x) == null ? d3_layout_treemapPadNull
: (type = typeof x) === "function" ? padFunction
: type === "number" ? (x = [x, x, x, x], padConstant)
: padConstant;
return treemap;
};
treemap.round = function(x) {
if (!arguments.length) return round != Number;
round = x ? Math.round : Number;
return treemap;
};
treemap.sticky = function(x) {
if (!arguments.length) return sticky;
sticky = x;
stickies = null;
return treemap;
};
treemap.ratio = function(x) {
if (!arguments.length) return ratio;
ratio = x;
return treemap;
};
return d3_layout_hierarchyRebind(treemap, hierarchy);
};
function d3_layout_treemapPadNull(node) {
return {x: node.x, y: node.y, dx: node.dx, dy: node.dy};
}
function d3_layout_treemapPad(node, padding) {
var x = node.x + padding[3],
y = node.y + padding[0],
dx = node.dx - padding[1] - padding[3],
dy = node.dy - padding[0] - padding[2];
if (dx < 0) { x += dx / 2; dx = 0; }
if (dy < 0) { y += dy / 2; dy = 0; }
return {x: x, y: y, dx: dx, dy: dy};
}
d3.csv = function(url, callback) {
d3.text(url, "text/csv", function(text) {
callback(text && d3.csv.parse(text));
});
};
d3.csv.parse = function(text) {
var header;
return d3.csv.parseRows(text, function(row, i) {
if (i) {
var o = {}, j = -1, m = header.length;
while (++j < m) o[header[j]] = row[j];
return o;
} else {
header = row;
return null;
}
});
};
d3.csv.parseRows = function(text, f) {
var EOL = {}, // sentinel value for end-of-line
EOF = {}, // sentinel value for end-of-file
rows = [], // output rows
re = /\r\n|[,\r\n]/g, // field separator regex
n = 0, // the current line number
t, // the current token
eol; // is the current token followed by EOL?
re.lastIndex = 0; // work-around bug in FF 3.6
/** @private Returns the next token. */
function token() {
if (re.lastIndex >= text.length) return EOF; // special case: end of file
if (eol) { eol = false; return EOL; } // special case: end of line
// special case: quotes
var j = re.lastIndex;
if (text.charCodeAt(j) === 34) {
var i = j;
while (i++ < text.length) {
if (text.charCodeAt(i) === 34) {
if (text.charCodeAt(i + 1) !== 34) break;
i++;
}
}
re.lastIndex = i + 2;
var c = text.charCodeAt(i + 1);
if (c === 13) {
eol = true;
if (text.charCodeAt(i + 2) === 10) re.lastIndex++;
} else if (c === 10) {
eol = true;
}
return text.substring(j + 1, i).replace(/""/g, "\"");
}
// common case
var m = re.exec(text);
if (m) {
eol = m[0].charCodeAt(0) !== 44;
return text.substring(j, m.index);
}
re.lastIndex = text.length;
return text.substring(j);
}
while ((t = token()) !== EOF) {
var a = [];
while ((t !== EOL) && (t !== EOF)) {
a.push(t);
t = token();
}
if (f && !(a = f(a, n++))) continue;
rows.push(a);
}
return rows;
};
d3.csv.format = function(rows) {
return rows.map(d3_csv_formatRow).join("\n");
};
function d3_csv_formatRow(row) {
return row.map(d3_csv_formatValue).join(",");
}
function d3_csv_formatValue(text) {
return /[",\n]/.test(text)
? "\"" + text.replace(/\"/g, "\"\"") + "\""
: text;
}
d3.geo = {};
var d3_geo_radians = Math.PI / 180;
// TODO clip input coordinates on opposite hemisphere
d3.geo.azimuthal = function() {
var mode = "orthographic", // or stereographic, gnomonic, equidistant or equalarea
origin,
scale = 200,
translate = [480, 250],
x0,
y0,
cy0,
sy0;
function azimuthal(coordinates) {
var x1 = coordinates[0] * d3_geo_radians - x0,
y1 = coordinates[1] * d3_geo_radians,
cx1 = Math.cos(x1),
sx1 = Math.sin(x1),
cy1 = Math.cos(y1),
sy1 = Math.sin(y1),
cc = mode !== "orthographic" ? sy0 * sy1 + cy0 * cy1 * cx1 : null,
c,
k = mode === "stereographic" ? 1 / (1 + cc)
: mode === "gnomonic" ? 1 / cc
: mode === "equidistant" ? (c = Math.acos(cc), c ? c / Math.sin(c) : 0)
: mode === "equalarea" ? Math.sqrt(2 / (1 + cc))
: 1,
x = k * cy1 * sx1,
y = k * (sy0 * cy1 * cx1 - cy0 * sy1);
return [
scale * x + translate[0],
scale * y + translate[1]
];
}
azimuthal.invert = function(coordinates) {
var x = (coordinates[0] - translate[0]) / scale,
y = (coordinates[1] - translate[1]) / scale,
p = Math.sqrt(x * x + y * y),
c = mode === "stereographic" ? 2 * Math.atan(p)
: mode === "gnomonic" ? Math.atan(p)
: mode === "equidistant" ? p
: mode === "equalarea" ? 2 * Math.asin(.5 * p)
: Math.asin(p),
sc = Math.sin(c),
cc = Math.cos(c);
return [
(x0 + Math.atan2(x * sc, p * cy0 * cc + y * sy0 * sc)) / d3_geo_radians,
Math.asin(cc * sy0 - (p ? (y * sc * cy0) / p : 0)) / d3_geo_radians
];
};
azimuthal.mode = function(x) {
if (!arguments.length) return mode;
mode = x + "";
return azimuthal;
};
azimuthal.origin = function(x) {
if (!arguments.length) return origin;
origin = x;
x0 = origin[0] * d3_geo_radians;
y0 = origin[1] * d3_geo_radians;
cy0 = Math.cos(y0);
sy0 = Math.sin(y0);
return azimuthal;
};
azimuthal.scale = function(x) {
if (!arguments.length) return scale;
scale = +x;
return azimuthal;
};
azimuthal.translate = function(x) {
if (!arguments.length) return translate;
translate = [+x[0], +x[1]];
return azimuthal;
};
return azimuthal.origin([0, 0]);
};
// Derived from Tom Carden's Albers implementation for Protovis.
// http://gist.github.com/476238
// http://mathworld.wolfram.com/AlbersEqual-AreaConicProjection.html
d3.geo.albers = function() {
var origin = [-98, 38],
parallels = [29.5, 45.5],
scale = 1000,
translate = [480, 250],
lng0, // d3_geo_radians * origin[0]
n,
C,
p0;
function albers(coordinates) {
var t = n * (d3_geo_radians * coordinates[0] - lng0),
p = Math.sqrt(C - 2 * n * Math.sin(d3_geo_radians * coordinates[1])) / n;
return [
scale * p * Math.sin(t) + translate[0],
scale * (p * Math.cos(t) - p0) + translate[1]
];
}
albers.invert = function(coordinates) {
var x = (coordinates[0] - translate[0]) / scale,
y = (coordinates[1] - translate[1]) / scale,
p0y = p0 + y,
t = Math.atan2(x, p0y),
p = Math.sqrt(x * x + p0y * p0y);
return [
(lng0 + t / n) / d3_geo_radians,
Math.asin((C - p * p * n * n) / (2 * n)) / d3_geo_radians
];
};
function reload() {
var phi1 = d3_geo_radians * parallels[0],
phi2 = d3_geo_radians * parallels[1],
lat0 = d3_geo_radians * origin[1],
s = Math.sin(phi1),
c = Math.cos(phi1);
lng0 = d3_geo_radians * origin[0];
n = .5 * (s + Math.sin(phi2));
C = c * c + 2 * n * s;
p0 = Math.sqrt(C - 2 * n * Math.sin(lat0)) / n;
return albers;
}
albers.origin = function(x) {
if (!arguments.length) return origin;
origin = [+x[0], +x[1]];
return reload();
};
albers.parallels = function(x) {
if (!arguments.length) return parallels;
parallels = [+x[0], +x[1]];
return reload();
};
albers.scale = function(x) {
if (!arguments.length) return scale;
scale = +x;
return albers;
};
albers.translate = function(x) {
if (!arguments.length) return translate;
translate = [+x[0], +x[1]];
return albers;
};
return reload();
};
// A composite projection for the United States, 960x500. The set of standard
// parallels for each region comes from USGS, which is published here:
// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers
// TODO allow the composite projection to be rescaled?
d3.geo.albersUsa = function() {
var lower48 = d3.geo.albers();
var alaska = d3.geo.albers()
.origin([-160, 60])
.parallels([55, 65]);
var hawaii = d3.geo.albers()
.origin([-160, 20])
.parallels([8, 18]);
var puertoRico = d3.geo.albers()
.origin([-60, 10])
.parallels([8, 18]);
function albersUsa(coordinates) {
var lon = coordinates[0],
lat = coordinates[1];
return (lat > 50 ? alaska
: lon < -140 ? hawaii
: lat < 21 ? puertoRico
: lower48)(coordinates);
}
albersUsa.scale = function(x) {
if (!arguments.length) return lower48.scale();
lower48.scale(x);
alaska.scale(x * .6);
hawaii.scale(x);
puertoRico.scale(x * 1.5);
return albersUsa.translate(lower48.translate());
};
albersUsa.translate = function(x) {
if (!arguments.length) return lower48.translate();
var dz = lower48.scale() / 1000,
dx = x[0],
dy = x[1];
lower48.translate(x);
alaska.translate([dx - 400 * dz, dy + 170 * dz]);
hawaii.translate([dx - 190 * dz, dy + 200 * dz]);
puertoRico.translate([dx + 580 * dz, dy + 430 * dz]);
return albersUsa;
};
return albersUsa.scale(lower48.scale());
};
d3.geo.bonne = function() {
var scale = 200,
translate = [480, 250],
x0, // origin longitude in radians
y0, // origin latitude in radians
y1, // parallel latitude in radians
c1; // cot(y1)
function bonne(coordinates) {
var x = coordinates[0] * d3_geo_radians - x0,
y = coordinates[1] * d3_geo_radians - y0;
if (y1) {
var p = c1 + y1 - y, E = x * Math.cos(y) / p;
x = p * Math.sin(E);
y = p * Math.cos(E) - c1;
} else {
x *= Math.cos(y);
y *= -1;
}
return [
scale * x + translate[0],
scale * y + translate[1]
];
}
bonne.invert = function(coordinates) {
var x = (coordinates[0] - translate[0]) / scale,
y = (coordinates[1] - translate[1]) / scale;
if (y1) {
var c = c1 + y, p = Math.sqrt(x * x + c * c);
y = c1 + y1 - p;
x = x0 + p * Math.atan2(x, c) / Math.cos(y);
} else {
y *= -1;
x /= Math.cos(y);
}
return [
x / d3_geo_radians,
y / d3_geo_radians
];
};
// 90° for Werner, 0° for Sinusoidal
bonne.parallel = function(x) {
if (!arguments.length) return y1 / d3_geo_radians;
c1 = 1 / Math.tan(y1 = x * d3_geo_radians);
return bonne;
};
bonne.origin = function(x) {
if (!arguments.length) return [x0 / d3_geo_radians, y0 / d3_geo_radians];
x0 = x[0] * d3_geo_radians;
y0 = x[1] * d3_geo_radians;
return bonne;
};
bonne.scale = function(x) {
if (!arguments.length) return scale;
scale = +x;
return bonne;
};
bonne.translate = function(x) {
if (!arguments.length) return translate;
translate = [+x[0], +x[1]];
return bonne;
};
return bonne.origin([0, 0]).parallel(45);
};
d3.geo.equirectangular = function() {
var scale = 500,
translate = [480, 250];
function equirectangular(coordinates) {
var x = coordinates[0] / 360,
y = -coordinates[1] / 360;
return [
scale * x + translate[0],
scale * y + translate[1]
];
}
equirectangular.invert = function(coordinates) {
var x = (coordinates[0] - translate[0]) / scale,
y = (coordinates[1] - translate[1]) / scale;
return [
360 * x,
-360 * y
];
};
equirectangular.scale = function(x) {
if (!arguments.length) return scale;
scale = +x;
return equirectangular;
};
equirectangular.translate = function(x) {
if (!arguments.length) return translate;
translate = [+x[0], +x[1]];
return equirectangular;
};
return equirectangular;
};
d3.geo.mercator = function() {
var scale = 500,
translate = [480, 250];
function mercator(coordinates) {
var x = coordinates[0] / 360,
y = -(Math.log(Math.tan(Math.PI / 4 + coordinates[1] * d3_geo_radians / 2)) / d3_geo_radians) / 360;
return [
scale * x + translate[0],
scale * Math.max(-.5, Math.min(.5, y)) + translate[1]
];
}
mercator.invert = function(coordinates) {
var x = (coordinates[0] - translate[0]) / scale,
y = (coordinates[1] - translate[1]) / scale;
return [
360 * x,
2 * Math.atan(Math.exp(-360 * y * d3_geo_radians)) / d3_geo_radians - 90
];
};
mercator.scale = function(x) {
if (!arguments.length) return scale;
scale = +x;
return mercator;
};
mercator.translate = function(x) {
if (!arguments.length) return translate;
translate = [+x[0], +x[1]];
return mercator;
};
return mercator;
};
function d3_geo_type(types, defaultValue) {
return function(object) {
return object && types.hasOwnProperty(object.type) ? types[object.type](object) : defaultValue;
};
}
/**
* Returns a function that, given a GeoJSON object (e.g., a feature), returns
* the corresponding SVG path. The function can be customized by overriding the
* projection. Point features are mapped to circles with a default radius of
* 4.5px; the radius can be specified either as a constant or a function that
* is evaluated per object.
*/
d3.geo.path = function() {
var pointRadius = 4.5,
pointCircle = d3_path_circle(pointRadius),
projection = d3.geo.albersUsa();
function path(d, i) {
if (typeof pointRadius === "function") {
pointCircle = d3_path_circle(pointRadius.apply(this, arguments));
}
return pathType(d) || null;
}
function project(coordinates) {
return projection(coordinates).join(",");
}
var pathType = d3_geo_type({
FeatureCollection: function(o) {
var path = [],
features = o.features,
i = -1, // features.index
n = features.length;
while (++i < n) path.push(pathType(features[i].geometry));
return path.join("");
},
Feature: function(o) {
return pathType(o.geometry);
},
Point: function(o) {
return "M" + project(o.coordinates) + pointCircle;
},
MultiPoint: function(o) {
var path = [],
coordinates = o.coordinates,
i = -1, // coordinates.index
n = coordinates.length;
while (++i < n) path.push("M", project(coordinates[i]), pointCircle);
return path.join("");
},
LineString: function(o) {
var path = ["M"],
coordinates = o.coordinates,
i = -1, // coordinates.index
n = coordinates.length;
while (++i < n) path.push(project(coordinates[i]), "L");
path.pop();
return path.join("");
},
MultiLineString: function(o) {
var path = [],
coordinates = o.coordinates,
i = -1, // coordinates.index
n = coordinates.length,
subcoordinates, // coordinates[i]
j, // subcoordinates.index
m; // subcoordinates.length
while (++i < n) {
subcoordinates = coordinates[i];
j = -1;
m = subcoordinates.length;
path.push("M");
while (++j < m) path.push(project(subcoordinates[j]), "L");
path.pop();
}
return path.join("");
},
Polygon: function(o) {
var path = [],
coordinates = o.coordinates,
i = -1, // coordinates.index
n = coordinates.length,
subcoordinates, // coordinates[i]
j, // subcoordinates.index
m; // subcoordinates.length
while (++i < n) {
subcoordinates = coordinates[i];
j = -1;
if ((m = subcoordinates.length - 1) > 0) {
path.push("M");
while (++j < m) path.push(project(subcoordinates[j]), "L");
path[path.length - 1] = "Z";
}
}
return path.join("");
},
MultiPolygon: function(o) {
var path = [],
coordinates = o.coordinates,
i = -1, // coordinates index
n = coordinates.length,
subcoordinates, // coordinates[i]
j, // subcoordinates index
m, // subcoordinates.length
subsubcoordinates, // subcoordinates[j]
k, // subsubcoordinates index
p; // subsubcoordinates.length
while (++i < n) {
subcoordinates = coordinates[i];
j = -1;
m = subcoordinates.length;
while (++j < m) {
subsubcoordinates = subcoordinates[j];
k = -1;
if ((p = subsubcoordinates.length - 1) > 0) {
path.push("M");
while (++k < p) path.push(project(subsubcoordinates[k]), "L");
path[path.length - 1] = "Z";
}
}
}
return path.join("");
},
GeometryCollection: function(o) {
var path = [],
geometries = o.geometries,
i = -1, // geometries index
n = geometries.length;
while (++i < n) path.push(pathType(geometries[i]));
return path.join("");
}
});
var areaType = path.area = d3_geo_type({
FeatureCollection: function(o) {
var area = 0,
features = o.features,
i = -1, // features.index
n = features.length;
while (++i < n) area += areaType(features[i]);
return area;
},
Feature: function(o) {
return areaType(o.geometry);
},
Polygon: function(o) {
return polygonArea(o.coordinates);
},
MultiPolygon: function(o) {
var sum = 0,
coordinates = o.coordinates,
i = -1, // coordinates index
n = coordinates.length;
while (++i < n) sum += polygonArea(coordinates[i]);
return sum;
},
GeometryCollection: function(o) {
var sum = 0,
geometries = o.geometries,
i = -1, // geometries index
n = geometries.length;
while (++i < n) sum += areaType(geometries[i]);
return sum;
}
}, 0);
function polygonArea(coordinates) {
var sum = area(coordinates[0]), // exterior ring
i = 0, // coordinates.index
n = coordinates.length;
while (++i < n) sum -= area(coordinates[i]); // holes
return sum;
}
function polygonCentroid(coordinates) {
var polygon = d3.geom.polygon(coordinates[0].map(projection)), // exterior ring
area = polygon.area(),
centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1),
x = centroid[0],
y = centroid[1],
z = area,
i = 0, // coordinates index
n = coordinates.length;
while (++i < n) {
polygon = d3.geom.polygon(coordinates[i].map(projection)); // holes
area = polygon.area();
centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1);
x -= centroid[0];
y -= centroid[1];
z -= area;
}
return [x, y, 6 * z]; // weighted centroid
}
var centroidType = path.centroid = d3_geo_type({
// TODO FeatureCollection
// TODO Point
// TODO MultiPoint
// TODO LineString
// TODO MultiLineString
// TODO GeometryCollection
Feature: function(o) {
return centroidType(o.geometry);
},
Polygon: function(o) {
var centroid = polygonCentroid(o.coordinates);
return [centroid[0] / centroid[2], centroid[1] / centroid[2]];
},
MultiPolygon: function(o) {
var area = 0,
coordinates = o.coordinates,
centroid,
x = 0,
y = 0,
z = 0,
i = -1, // coordinates index
n = coordinates.length;
while (++i < n) {
centroid = polygonCentroid(coordinates[i]);
x += centroid[0];
y += centroid[1];
z += centroid[2];
}
return [x / z, y / z];
}
});
function area(coordinates) {
return Math.abs(d3.geom.polygon(coordinates.map(projection)).area());
}
path.projection = function(x) {
projection = x;
return path;
};
path.pointRadius = function(x) {
if (typeof x === "function") pointRadius = x;
else {
pointRadius = +x;
pointCircle = d3_path_circle(pointRadius);
}
return path;
};
return path;
};
function d3_path_circle(radius) {
return "m0," + radius
+ "a" + radius + "," + radius + " 0 1,1 0," + (-2 * radius)
+ "a" + radius + "," + radius + " 0 1,1 0," + (+2 * radius)
+ "z";
}
/**
* Given a GeoJSON object, returns the corresponding bounding box. The bounding
* box is represented by a two-dimensional array: [[left, bottom], [right,
* top]], where left is the minimum longitude, bottom is the minimum latitude,
* right is maximum longitude, and top is the maximum latitude.
*/
d3.geo.bounds = function(feature) {
var left = Infinity,
bottom = Infinity,
right = -Infinity,
top = -Infinity;
d3_geo_bounds(feature, function(x, y) {
if (x < left) left = x;
if (x > right) right = x;
if (y < bottom) bottom = y;
if (y > top) top = y;
});
return [[left, bottom], [right, top]];
};
function d3_geo_bounds(o, f) {
if (d3_geo_boundsTypes.hasOwnProperty(o.type)) d3_geo_boundsTypes[o.type](o, f);
}
var d3_geo_boundsTypes = {
Feature: d3_geo_boundsFeature,
FeatureCollection: d3_geo_boundsFeatureCollection,
GeometryCollection: d3_geo_boundsGeometryCollection,
LineString: d3_geo_boundsLineString,
MultiLineString: d3_geo_boundsMultiLineString,
MultiPoint: d3_geo_boundsLineString,
MultiPolygon: d3_geo_boundsMultiPolygon,
Point: d3_geo_boundsPoint,
Polygon: d3_geo_boundsPolygon
};
function d3_geo_boundsFeature(o, f) {
d3_geo_bounds(o.geometry, f);
}
function d3_geo_boundsFeatureCollection(o, f) {
for (var a = o.features, i = 0, n = a.length; i < n; i++) {
d3_geo_bounds(a[i].geometry, f);
}
}
function d3_geo_boundsGeometryCollection(o, f) {
for (var a = o.geometries, i = 0, n = a.length; i < n; i++) {
d3_geo_bounds(a[i], f);
}
}
function d3_geo_boundsLineString(o, f) {
for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
f.apply(null, a[i]);
}
}
function d3_geo_boundsMultiLineString(o, f) {
for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
for (var b = a[i], j = 0, m = b.length; j < m; j++) {
f.apply(null, b[j]);
}
}
}
function d3_geo_boundsMultiPolygon(o, f) {
for (var a = o.coordinates, i = 0, n = a.length; i < n; i++) {
for (var b = a[i][0], j = 0, m = b.length; j < m; j++) {
f.apply(null, b[j]);
}
}
}
function d3_geo_boundsPoint(o, f) {
f.apply(null, o.coordinates);
}
function d3_geo_boundsPolygon(o, f) {
for (var a = o.coordinates[0], i = 0, n = a.length; i < n; i++) {
f.apply(null, a[i]);
}
}
// TODO breakAtDateLine?
d3.geo.circle = function() {
var origin = [0, 0],
degrees = 90 - 1e-2,
radians = degrees * d3_geo_radians,
arc = d3.geo.greatArc().target(Object);
function circle() {
// TODO render a circle as a Polygon
}
function visible(point) {
return arc.distance(point) < radians;
}
circle.clip = function(d) {
arc.source(typeof origin === "function" ? origin.apply(this, arguments) : origin);
return clipType(d);
};
var clipType = d3_geo_type({
FeatureCollection: function(o) {
var features = o.features.map(clipType).filter(Object);
return features && (o = Object.create(o), o.features = features, o);
},
Feature: function(o) {
var geometry = clipType(o.geometry);
return geometry && (o = Object.create(o), o.geometry = geometry, o);
},
Point: function(o) {
return visible(o.coordinates) && o;
},
MultiPoint: function(o) {
var coordinates = o.coordinates.filter(visible);
return coordinates.length && {
type: o.type,
coordinates: coordinates
};
},
LineString: function(o) {
var coordinates = clip(o.coordinates);
return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o);
},
MultiLineString: function(o) {
var coordinates = o.coordinates.map(clip).filter(function(d) { return d.length; });
return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o);
},
Polygon: function(o) {
var coordinates = o.coordinates.map(clip);
return coordinates[0].length && (o = Object.create(o), o.coordinates = coordinates, o);
},
MultiPolygon: function(o) {
var coordinates = o.coordinates.map(function(d) { return d.map(clip); }).filter(function(d) { return d[0].length; });
return coordinates.length && (o = Object.create(o), o.coordinates = coordinates, o);
},
GeometryCollection: function(o) {
var geometries = o.geometries.map(clipType).filter(Object);
return geometries.length && (o = Object.create(o), o.geometries = geometries, o);
}
});
function clip(coordinates) {
var i = -1,
n = coordinates.length,
clipped = [],
p0,
p1,
p2,
d0,
d1;
while (++i < n) {
d1 = arc.distance(p2 = coordinates[i]);
if (d1 < radians) {
if (p1) clipped.push(d3_geo_greatArcInterpolate(p1, p2)((d0 - radians) / (d0 - d1)));
clipped.push(p2);
p0 = p1 = null;
} else {
p1 = p2;
if (!p0 && clipped.length) {
clipped.push(d3_geo_greatArcInterpolate(clipped[clipped.length - 1], p1)((radians - d0) / (d1 - d0)));
p0 = p1;
}
}
d0 = d1;
}
if (p1 && clipped.length) {
d1 = arc.distance(p2 = clipped[0]);
clipped.push(d3_geo_greatArcInterpolate(p1, p2)((d0 - radians) / (d0 - d1)));
}
return resample(clipped);
}
// Resample coordinates, creating great arcs between each.
function resample(coordinates) {
var i = 0,
n = coordinates.length,
j,
m,
resampled = n ? [coordinates[0]] : coordinates,
resamples,
origin = arc.source();
while (++i < n) {
resamples = arc.source(coordinates[i - 1])(coordinates[i]).coordinates;
for (j = 0, m = resamples.length; ++j < m;) resampled.push(resamples[j]);
}
arc.source(origin);
return resampled;
}
circle.origin = function(x) {
if (!arguments.length) return origin;
origin = x;
return circle;
};
circle.angle = function(x) {
if (!arguments.length) return degrees;
radians = (degrees = +x) * d3_geo_radians;
return circle;
};
// Precision is specified in degrees.
circle.precision = function(x) {
if (!arguments.length) return arc.precision();
arc.precision(x);
return circle;
};
return circle;
}
d3.geo.greatArc = function() {
var source = d3_geo_greatArcSource,
target = d3_geo_greatArcTarget,
precision = 6 * d3_geo_radians;
function greatArc() {
var a = typeof source === "function" ? source.apply(this, arguments) : source,
b = typeof target === "function" ? target.apply(this, arguments) : target,
i = d3_geo_greatArcInterpolate(a, b),
dt = precision / i.d,
t = 0,
coordinates = [a];
while ((t += dt) < 1) coordinates.push(i(t));
coordinates.push(b);
return {
type: "LineString",
coordinates: coordinates
};
}
// Length returned in radians; multiply by radius for distance.
greatArc.distance = function() {
var a = typeof source === "function" ? source.apply(this, arguments) : source,
b = typeof target === "function" ? target.apply(this, arguments) : target;
return d3_geo_greatArcInterpolate(a, b).d;
};
greatArc.source = function(x) {
if (!arguments.length) return source;
source = x;
return greatArc;
};
greatArc.target = function(x) {
if (!arguments.length) return target;
target = x;
return greatArc;
};
// Precision is specified in degrees.
greatArc.precision = function(x) {
if (!arguments.length) return precision / d3_geo_radians;
precision = x * d3_geo_radians;
return greatArc;
};
return greatArc;
};
function d3_geo_greatArcSource(d) {
return d.source;
}
function d3_geo_greatArcTarget(d) {
return d.target;
}
function d3_geo_greatArcInterpolate(a, b) {
var x0 = a[0] * d3_geo_radians, cx0 = Math.cos(x0), sx0 = Math.sin(x0),
y0 = a[1] * d3_geo_radians, cy0 = Math.cos(y0), sy0 = Math.sin(y0),
x1 = b[0] * d3_geo_radians, cx1 = Math.cos(x1), sx1 = Math.sin(x1),
y1 = b[1] * d3_geo_radians, cy1 = Math.cos(y1), sy1 = Math.sin(y1),
d = interpolate.d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0)))),
sd = Math.sin(d);
// From http://williams.best.vwh.net/avform.htm#Intermediate
function interpolate(t) {
var A = Math.sin(d - (t *= d)) / sd,
B = Math.sin(t) / sd,
x = A * cy0 * cx0 + B * cy1 * cx1,
y = A * cy0 * sx0 + B * cy1 * sx1,
z = A * sy0 + B * sy1;
return [
Math.atan2(y, x) / d3_geo_radians,
Math.atan2(z, Math.sqrt(x * x + y * y)) / d3_geo_radians
];
}
return interpolate;
}
d3.geo.greatCircle = d3.geo.circle;
d3.geom = {};
/**
* Computes a contour for a given input grid function using the <a
* href="http://en.wikipedia.org/wiki/Marching_squares">marching
* squares</a> algorithm. Returns the contour polygon as an array of points.
*
* @param grid a two-input function(x, y) that returns true for values
* inside the contour and false for values outside the contour.
* @param start an optional starting point [x, y] on the grid.
* @returns polygon [[x1, y1], [x2, y2], …]
*/
d3.geom.contour = function(grid, start) {
var s = start || d3_geom_contourStart(grid), // starting point
c = [], // contour polygon
x = s[0], // current x position
y = s[1], // current y position
dx = 0, // next x direction
dy = 0, // next y direction
pdx = NaN, // previous x direction
pdy = NaN, // previous y direction
i = 0;
do {
// determine marching squares index
i = 0;
if (grid(x-1, y-1)) i += 1;
if (grid(x, y-1)) i += 2;
if (grid(x-1, y )) i += 4;
if (grid(x, y )) i += 8;
// determine next direction
if (i === 6) {
dx = pdy === -1 ? -1 : 1;
dy = 0;
} else if (i === 9) {
dx = 0;
dy = pdx === 1 ? -1 : 1;
} else {
dx = d3_geom_contourDx[i];
dy = d3_geom_contourDy[i];
}
// update contour polygon
if (dx != pdx && dy != pdy) {
c.push([x, y]);
pdx = dx;
pdy = dy;
}
x += dx;
y += dy;
} while (s[0] != x || s[1] != y);
return c;
};
// lookup tables for marching directions
var d3_geom_contourDx = [1, 0, 1, 1,-1, 0,-1, 1,0, 0,0,0,-1, 0,-1,NaN],
d3_geom_contourDy = [0,-1, 0, 0, 0,-1, 0, 0,1,-1,1,1, 0,-1, 0,NaN];
function d3_geom_contourStart(grid) {
var x = 0,
y = 0;
// search for a starting point; begin at origin
// and proceed along outward-expanding diagonals
while (true) {
if (grid(x,y)) {
return [x,y];
}
if (x === 0) {
x = y + 1;
y = 0;
} else {
x = x - 1;
y = y + 1;
}
}
}
/**
* Computes the 2D convex hull of a set of points using Graham's scanning
* algorithm. The algorithm has been implemented as described in Cormen,
* Leiserson, and Rivest's Introduction to Algorithms. The running time of
* this algorithm is O(n log n), where n is the number of input points.
*
* @param vertices [[x1, y1], [x2, y2], …]
* @returns polygon [[x1, y1], [x2, y2], …]
*/
d3.geom.hull = function(vertices) {
if (vertices.length < 3) return [];
var len = vertices.length,
plen = len - 1,
points = [],
stack = [],
i, j, h = 0, x1, y1, x2, y2, u, v, a, sp;
// find the starting ref point: leftmost point with the minimum y coord
for (i=1; i<len; ++i) {
if (vertices[i][1] < vertices[h][1]) {
h = i;
} else if (vertices[i][1] == vertices[h][1]) {
h = (vertices[i][0] < vertices[h][0] ? i : h);
}
}
// calculate polar angles from ref point and sort
for (i=0; i<len; ++i) {
if (i === h) continue;
y1 = vertices[i][1] - vertices[h][1];
x1 = vertices[i][0] - vertices[h][0];
points.push({angle: Math.atan2(y1, x1), index: i});
}
points.sort(function(a, b) { return a.angle - b.angle; });
// toss out duplicate angles
a = points[0].angle;
v = points[0].index;
u = 0;
for (i=1; i<plen; ++i) {
j = points[i].index;
if (a == points[i].angle) {
// keep angle for point most distant from the reference
x1 = vertices[v][0] - vertices[h][0];
y1 = vertices[v][1] - vertices[h][1];
x2 = vertices[j][0] - vertices[h][0];
y2 = vertices[j][1] - vertices[h][1];
if ((x1*x1 + y1*y1) >= (x2*x2 + y2*y2)) {
points[i].index = -1;
} else {
points[u].index = -1;
a = points[i].angle;
u = i;
v = j;
}
} else {
a = points[i].angle;
u = i;
v = j;
}
}
// initialize the stack
stack.push(h);
for (i=0, j=0; i<2; ++j) {
if (points[j].index !== -1) {
stack.push(points[j].index);
i++;
}
}
sp = stack.length;
// do graham's scan
for (; j<plen; ++j) {
if (points[j].index === -1) continue; // skip tossed out points
while (!d3_geom_hullCCW(stack[sp-2], stack[sp-1], points[j].index, vertices)) {
--sp;
}
stack[sp++] = points[j].index;
}
// construct the hull
var poly = [];
for (i=0; i<sp; ++i) {
poly.push(vertices[stack[i]]);
}
return poly;
}
// are three points in counter-clockwise order?
function d3_geom_hullCCW(i1, i2, i3, v) {
var t, a, b, c, d, e, f;
t = v[i1]; a = t[0]; b = t[1];
t = v[i2]; c = t[0]; d = t[1];
t = v[i3]; e = t[0]; f = t[1];
return ((f-b)*(c-a) - (d-b)*(e-a)) > 0;
}
// Note: requires coordinates to be counterclockwise and convex!
d3.geom.polygon = function(coordinates) {
coordinates.area = function() {
var i = 0,
n = coordinates.length,
a = coordinates[n - 1][0] * coordinates[0][1],
b = coordinates[n - 1][1] * coordinates[0][0];
while (++i < n) {
a += coordinates[i - 1][0] * coordinates[i][1];
b += coordinates[i - 1][1] * coordinates[i][0];
}
return (b - a) * .5;
};
coordinates.centroid = function(k) {
var i = -1,
n = coordinates.length,
x = 0,
y = 0,
a,
b = coordinates[n - 1],
c;
if (!arguments.length) k = -1 / (6 * coordinates.area());
while (++i < n) {
a = b;
b = coordinates[i];
c = a[0] * b[1] - b[0] * a[1];
x += (a[0] + b[0]) * c;
y += (a[1] + b[1]) * c;
}
return [x * k, y * k];
};
// The Sutherland-Hodgman clipping algorithm.
coordinates.clip = function(subject) {
var input,
i = -1,
n = coordinates.length,
j,
m,
a = coordinates[n - 1],
b,
c,
d;
while (++i < n) {
input = subject.slice();
subject.length = 0;
b = coordinates[i];
c = input[(m = input.length) - 1];
j = -1;
while (++j < m) {
d = input[j];
if (d3_geom_polygonInside(d, a, b)) {
if (!d3_geom_polygonInside(c, a, b)) {
subject.push(d3_geom_polygonIntersect(c, d, a, b));
}
subject.push(d);
} else if (d3_geom_polygonInside(c, a, b)) {
subject.push(d3_geom_polygonIntersect(c, d, a, b));
}
c = d;
}
a = b;
}
return subject;
};
return coordinates;
};
function d3_geom_polygonInside(p, a, b) {
return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]);
}
// Intersect two infinite lines cd and ab.
function d3_geom_polygonIntersect(c, d, a, b) {
var x1 = c[0], x2 = d[0], x3 = a[0], x4 = b[0],
y1 = c[1], y2 = d[1], y3 = a[1], y4 = b[1],
x13 = x1 - x3,
x21 = x2 - x1,
x43 = x4 - x3,
y13 = y1 - y3,
y21 = y2 - y1,
y43 = y4 - y3,
ua = (x43 * y13 - y43 * x13) / (y43 * x21 - x43 * y21);
return [x1 + ua * x21, y1 + ua * y21];
}
// Adapted from Nicolas Garcia Belmonte's JIT implementation:
// http://blog.thejit.org/2010/02/12/voronoi-tessellation/
// http://blog.thejit.org/assets/voronoijs/voronoi.js
// See lib/jit/LICENSE for details.
// Notes:
//
// This implementation does not clip the returned polygons, so if you want to
// clip them to a particular shape you will need to do that either in SVG or by
// post-processing with d3.geom.polygon's clip method.
//
// If any vertices are coincident or have NaN positions, the behavior of this
// method is undefined. Most likely invalid polygons will be returned. You
// should filter invalid points, and consolidate coincident points, before
// computing the tessellation.
/**
* @param vertices [[x1, y1], [x2, y2], …]
* @returns polygons [[[x1, y1], [x2, y2], …], …]
*/
d3.geom.voronoi = function(vertices) {
var polygons = vertices.map(function() { return []; });
d3_voronoi_tessellate(vertices, function(e) {
var s1,
s2,
x1,
x2,
y1,
y2;
if (e.a === 1 && e.b >= 0) {
s1 = e.ep.r;
s2 = e.ep.l;
} else {
s1 = e.ep.l;
s2 = e.ep.r;
}
if (e.a === 1) {
y1 = s1 ? s1.y : -1e6;
x1 = e.c - e.b * y1;
y2 = s2 ? s2.y : 1e6;
x2 = e.c - e.b * y2;
} else {
x1 = s1 ? s1.x : -1e6;
y1 = e.c - e.a * x1;
x2 = s2 ? s2.x : 1e6;
y2 = e.c - e.a * x2;
}
var v1 = [x1, y1],
v2 = [x2, y2];
polygons[e.region.l.index].push(v1, v2);
polygons[e.region.r.index].push(v1, v2);
});
// Reconnect the polygon segments into counterclockwise loops.
return polygons.map(function(polygon, i) {
var cx = vertices[i][0],
cy = vertices[i][1];
polygon.forEach(function(v) {
v.angle = Math.atan2(v[0] - cx, v[1] - cy);
});
return polygon.sort(function(a, b) {
return a.angle - b.angle;
}).filter(function(d, i) {
return !i || (d.angle - polygon[i - 1].angle > 1e-10);
});
});
};
var d3_voronoi_opposite = {"l": "r", "r": "l"};
function d3_voronoi_tessellate(vertices, callback) {
var Sites = {
list: vertices
.map(function(v, i) {
return {
index: i,
x: v[0],
y: v[1]
};
})
.sort(function(a, b) {
return a.y < b.y ? -1
: a.y > b.y ? 1
: a.x < b.x ? -1
: a.x > b.x ? 1
: 0;
}),
bottomSite: null
};
var EdgeList = {
list: [],
leftEnd: null,
rightEnd: null,
init: function() {
EdgeList.leftEnd = EdgeList.createHalfEdge(null, "l");
EdgeList.rightEnd = EdgeList.createHalfEdge(null, "l");
EdgeList.leftEnd.r = EdgeList.rightEnd;
EdgeList.rightEnd.l = EdgeList.leftEnd;
EdgeList.list.unshift(EdgeList.leftEnd, EdgeList.rightEnd);
},
createHalfEdge: function(edge, side) {
return {
edge: edge,
side: side,
vertex: null,
"l": null,
"r": null
};
},
insert: function(lb, he) {
he.l = lb;
he.r = lb.r;
lb.r.l = he;
lb.r = he;
},
leftBound: function(p) {
var he = EdgeList.leftEnd;
do {
he = he.r;
} while (he != EdgeList.rightEnd && Geom.rightOf(he, p));
he = he.l;
return he;
},
del: function(he) {
he.l.r = he.r;
he.r.l = he.l;
he.edge = null;
},
right: function(he) {
return he.r;
},
left: function(he) {
return he.l;
},
leftRegion: function(he) {
return he.edge == null
? Sites.bottomSite
: he.edge.region[he.side];
},
rightRegion: function(he) {
return he.edge == null
? Sites.bottomSite
: he.edge.region[d3_voronoi_opposite[he.side]];
}
};
var Geom = {
bisect: function(s1, s2) {
var newEdge = {
region: {"l": s1, "r": s2},
ep: {"l": null, "r": null}
};
var dx = s2.x - s1.x,
dy = s2.y - s1.y,
adx = dx > 0 ? dx : -dx,
ady = dy > 0 ? dy : -dy;
newEdge.c = s1.x * dx + s1.y * dy
+ (dx * dx + dy * dy) * .5;
if (adx > ady) {
newEdge.a = 1;
newEdge.b = dy / dx;
newEdge.c /= dx;
} else {
newEdge.b = 1;
newEdge.a = dx / dy;
newEdge.c /= dy;
}
return newEdge;
},
intersect: function(el1, el2) {
var e1 = el1.edge,
e2 = el2.edge;
if (!e1 || !e2 || (e1.region.r == e2.region.r)) {
return null;
}
var d = (e1.a * e2.b) - (e1.b * e2.a);
if (Math.abs(d) < 1e-10) {
return null;
}
var xint = (e1.c * e2.b - e2.c * e1.b) / d,
yint = (e2.c * e1.a - e1.c * e2.a) / d,
e1r = e1.region.r,
e2r = e2.region.r,
el,
e;
if ((e1r.y < e2r.y) ||
(e1r.y == e2r.y && e1r.x < e2r.x)) {
el = el1;
e = e1;
} else {
el = el2;
e = e2;
}
var rightOfSite = (xint >= e.region.r.x);
if ((rightOfSite && (el.side === "l")) ||
(!rightOfSite && (el.side === "r"))) {
return null;
}
return {
x: xint,
y: yint
};
},
rightOf: function(he, p) {
var e = he.edge,
topsite = e.region.r,
rightOfSite = (p.x > topsite.x);
if (rightOfSite && (he.side === "l")) {
return 1;
}
if (!rightOfSite && (he.side === "r")) {
return 0;
}
if (e.a === 1) {
var dyp = p.y - topsite.y,
dxp = p.x - topsite.x,
fast = 0,
above = 0;
if ((!rightOfSite && (e.b < 0)) ||
(rightOfSite && (e.b >= 0))) {
above = fast = (dyp >= e.b * dxp);
} else {
above = ((p.x + p.y * e.b) > e.c);
if (e.b < 0) {
above = !above;
}
if (!above) {
fast = 1;
}
}
if (!fast) {
var dxs = topsite.x - e.region.l.x;
above = (e.b * (dxp * dxp - dyp * dyp)) <
(dxs * dyp * (1 + 2 * dxp / dxs + e.b * e.b));
if (e.b < 0) {
above = !above;
}
}
} else /* e.b == 1 */ {
var yl = e.c - e.a * p.x,
t1 = p.y - yl,
t2 = p.x - topsite.x,
t3 = yl - topsite.y;
above = (t1 * t1) > (t2 * t2 + t3 * t3);
}
return he.side === "l" ? above : !above;
},
endPoint: function(edge, side, site) {
edge.ep[side] = site;
if (!edge.ep[d3_voronoi_opposite[side]]) return;
callback(edge);
},
distance: function(s, t) {
var dx = s.x - t.x,
dy = s.y - t.y;
return Math.sqrt(dx * dx + dy * dy);
}
};
var EventQueue = {
list: [],
insert: function(he, site, offset) {
he.vertex = site;
he.ystar = site.y + offset;
for (var i=0, list=EventQueue.list, l=list.length; i<l; i++) {
var next = list[i];
if (he.ystar > next.ystar ||
(he.ystar == next.ystar &&
site.x > next.vertex.x)) {
continue;
} else {
break;
}
}
list.splice(i, 0, he);
},
del: function(he) {
for (var i=0, ls=EventQueue.list, l=ls.length; i<l && (ls[i] != he); ++i) {}
ls.splice(i, 1);
},
empty: function() { return EventQueue.list.length === 0; },
nextEvent: function(he) {
for (var i=0, ls=EventQueue.list, l=ls.length; i<l; ++i) {
if (ls[i] == he) return ls[i+1];
}
return null;
},
min: function() {
var elem = EventQueue.list[0];
return {
x: elem.vertex.x,
y: elem.ystar
};
},
extractMin: function() {
return EventQueue.list.shift();
}
};
EdgeList.init();
Sites.bottomSite = Sites.list.shift();
var newSite = Sites.list.shift(), newIntStar;
var lbnd, rbnd, llbnd, rrbnd, bisector;
var bot, top, temp, p, v;
var e, pm;
while (true) {
if (!EventQueue.empty()) {
newIntStar = EventQueue.min();
}
if (newSite && (EventQueue.empty()
|| newSite.y < newIntStar.y
|| (newSite.y == newIntStar.y
&& newSite.x < newIntStar.x))) { //new site is smallest
lbnd = EdgeList.leftBound(newSite);
rbnd = EdgeList.right(lbnd);
bot = EdgeList.rightRegion(lbnd);
e = Geom.bisect(bot, newSite);
bisector = EdgeList.createHalfEdge(e, "l");
EdgeList.insert(lbnd, bisector);
p = Geom.intersect(lbnd, bisector);
if (p) {
EventQueue.del(lbnd);
EventQueue.insert(lbnd, p, Geom.distance(p, newSite));
}
lbnd = bisector;
bisector = EdgeList.createHalfEdge(e, "r");
EdgeList.insert(lbnd, bisector);
p = Geom.intersect(bisector, rbnd);
if (p) {
EventQueue.insert(bisector, p, Geom.distance(p, newSite));
}
newSite = Sites.list.shift();
} else if (!EventQueue.empty()) { //intersection is smallest
lbnd = EventQueue.extractMin();
llbnd = EdgeList.left(lbnd);
rbnd = EdgeList.right(lbnd);
rrbnd = EdgeList.right(rbnd);
bot = EdgeList.leftRegion(lbnd);
top = EdgeList.rightRegion(rbnd);
v = lbnd.vertex;
Geom.endPoint(lbnd.edge, lbnd.side, v);
Geom.endPoint(rbnd.edge, rbnd.side, v);
EdgeList.del(lbnd);
EventQueue.del(rbnd);
EdgeList.del(rbnd);
pm = "l";
if (bot.y > top.y) {
temp = bot;
bot = top;
top = temp;
pm = "r";
}
e = Geom.bisect(bot, top);
bisector = EdgeList.createHalfEdge(e, pm);
EdgeList.insert(llbnd, bisector);
Geom.endPoint(e, d3_voronoi_opposite[pm], v);
p = Geom.intersect(llbnd, bisector);
if (p) {
EventQueue.del(llbnd);
EventQueue.insert(llbnd, p, Geom.distance(p, bot));
}
p = Geom.intersect(bisector, rrbnd);
if (p) {
EventQueue.insert(bisector, p, Geom.distance(p, bot));
}
} else {
break;
}
}//end while
for (lbnd = EdgeList.right(EdgeList.leftEnd);
lbnd != EdgeList.rightEnd;
lbnd = EdgeList.right(lbnd)) {
callback(lbnd.edge);
}
}
/**
* @param vertices [[x1, y1], [x2, y2], …]
* @returns triangles [[[x1, y1], [x2, y2], [x3, y3]], …]
*/
d3.geom.delaunay = function(vertices) {
var edges = vertices.map(function() { return []; }),
triangles = [];
// Use the Voronoi tessellation to determine Delaunay edges.
d3_voronoi_tessellate(vertices, function(e) {
edges[e.region.l.index].push(vertices[e.region.r.index]);
});
// Reconnect the edges into counterclockwise triangles.
edges.forEach(function(edge, i) {
var v = vertices[i],
cx = v[0],
cy = v[1];
edge.forEach(function(v) {
v.angle = Math.atan2(v[0] - cx, v[1] - cy);
});
edge.sort(function(a, b) {
return a.angle - b.angle;
});
for (var j = 0, m = edge.length - 1; j < m; j++) {
triangles.push([v, edge[j], edge[j + 1]]);
}
});
return triangles;
};
// Constructs a new quadtree for the specified array of points. A quadtree is a
// two-dimensional recursive spatial subdivision. This implementation uses
// square partitions, dividing each square into four equally-sized squares. Each
// point exists in a unique node; if multiple points are in the same position,
// some points may be stored on internal nodes rather than leaf nodes. Quadtrees
// can be used to accelerate various spatial operations, such as the Barnes-Hut
// approximation for computing n-body forces, or collision detection.
d3.geom.quadtree = function(points, x1, y1, x2, y2) {
var p,
i = -1,
n = points.length;
// Type conversion for deprecated API.
if (n && isNaN(points[0].x)) points = points.map(d3_geom_quadtreePoint);
// Allow bounds to be specified explicitly.
if (arguments.length < 5) {
if (arguments.length === 3) {
y2 = x2 = y1;
y1 = x1;
} else {
x1 = y1 = Infinity;
x2 = y2 = -Infinity;
// Compute bounds.
while (++i < n) {
p = points[i];
if (p.x < x1) x1 = p.x;
if (p.y < y1) y1 = p.y;
if (p.x > x2) x2 = p.x;
if (p.y > y2) y2 = p.y;
}
// Squarify the bounds.
var dx = x2 - x1,
dy = y2 - y1;
if (dx > dy) y2 = y1 + dx;
else x2 = x1 + dy;
}
}
// Recursively inserts the specified point p at the node n or one of its
// descendants. The bounds are defined by [x1, x2] and [y1, y2].
function insert(n, p, x1, y1, x2, y2) {
if (isNaN(p.x) || isNaN(p.y)) return; // ignore invalid points
if (n.leaf) {
var v = n.point;
if (v) {
// If the point at this leaf node is at the same position as the new
// point we are adding, we leave the point associated with the
// internal node while adding the new point to a child node. This
// avoids infinite recursion.
if ((Math.abs(v.x - p.x) + Math.abs(v.y - p.y)) < .01) {
insertChild(n, p, x1, y1, x2, y2);
} else {
n.point = null;
insertChild(n, v, x1, y1, x2, y2);
insertChild(n, p, x1, y1, x2, y2);
}
} else {
n.point = p;
}
} else {
insertChild(n, p, x1, y1, x2, y2);
}
}
// Recursively inserts the specified point p into a descendant of node n. The
// bounds are defined by [x1, x2] and [y1, y2].
function insertChild(n, p, x1, y1, x2, y2) {
// Compute the split point, and the quadrant in which to insert p.
var sx = (x1 + x2) * .5,
sy = (y1 + y2) * .5,
right = p.x >= sx,
bottom = p.y >= sy,
i = (bottom << 1) + right;
// Recursively insert into the child node.
n.leaf = false;
n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode());
// Update the bounds as we recurse.
if (right) x1 = sx; else x2 = sx;
if (bottom) y1 = sy; else y2 = sy;
insert(n, p, x1, y1, x2, y2);
}
// Create the root node.
var root = d3_geom_quadtreeNode();
root.add = function(p) {
insert(root, p, x1, y1, x2, y2);
};
root.visit = function(f) {
d3_geom_quadtreeVisit(f, root, x1, y1, x2, y2);
};
// Insert all points.
points.forEach(root.add);
return root;
};
function d3_geom_quadtreeNode() {
return {
leaf: true,
nodes: [],
point: null
};
}
function d3_geom_quadtreeVisit(f, node, x1, y1, x2, y2) {
if (!f(node, x1, y1, x2, y2)) {
var sx = (x1 + x2) * .5,
sy = (y1 + y2) * .5,
children = node.nodes;
if (children[0]) d3_geom_quadtreeVisit(f, children[0], x1, y1, sx, sy);
if (children[1]) d3_geom_quadtreeVisit(f, children[1], sx, y1, x2, sy);
if (children[2]) d3_geom_quadtreeVisit(f, children[2], x1, sy, sx, y2);
if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2);
}
}
function d3_geom_quadtreePoint(p) {
return {
x: p[0],
y: p[1]
};
}
d3.time = {};
var d3_time = Date;
function d3_time_utc() {
this._ = new Date(arguments.length > 1
? Date.UTC.apply(this, arguments)
: arguments[0]);
}
d3_time_utc.prototype = {
getDate: function() { return this._.getUTCDate(); },
getDay: function() { return this._.getUTCDay(); },
getFullYear: function() { return this._.getUTCFullYear(); },
getHours: function() { return this._.getUTCHours(); },
getMilliseconds: function() { return this._.getUTCMilliseconds(); },
getMinutes: function() { return this._.getUTCMinutes(); },
getMonth: function() { return this._.getUTCMonth(); },
getSeconds: function() { return this._.getUTCSeconds(); },
getTime: function() { return this._.getTime(); },
getTimezoneOffset: function() { return 0; },
valueOf: function() { return this._.valueOf(); },
setDate: function() { d3_time_prototype.setUTCDate.apply(this._, arguments); },
setDay: function() { d3_time_prototype.setUTCDay.apply(this._, arguments); },
setFullYear: function() { d3_time_prototype.setUTCFullYear.apply(this._, arguments); },
setHours: function() { d3_time_prototype.setUTCHours.apply(this._, arguments); },
setMilliseconds: function() { d3_time_prototype.setUTCMilliseconds.apply(this._, arguments); },
setMinutes: function() { d3_time_prototype.setUTCMinutes.apply(this._, arguments); },
setMonth: function() { d3_time_prototype.setUTCMonth.apply(this._, arguments); },
setSeconds: function() { d3_time_prototype.setUTCSeconds.apply(this._, arguments); },
setTime: function() { d3_time_prototype.setTime.apply(this._, arguments); }
};
var d3_time_prototype = Date.prototype;
d3.time.format = function(template) {
var n = template.length;
function format(date) {
var string = [],
i = -1,
j = 0,
c,
f;
while (++i < n) {
if (template.charCodeAt(i) == 37) {
string.push(
template.substring(j, i),
(f = d3_time_formats[c = template.charAt(++i)])
? f(date) : c);
j = i + 1;
}
}
string.push(template.substring(j, i));
return string.join("");
}
format.parse = function(string) {
var d = {y: 1900, m: 0, d: 1, H: 0, M: 0, S: 0, L: 0},
i = d3_time_parse(d, template, string, 0);
if (i != string.length) return null;
// The am-pm flag is 0 for AM, and 1 for PM.
if ("p" in d) d.H = d.H % 12 + d.p * 12;
var date = new d3_time();
date.setFullYear(d.y, d.m, d.d);
date.setHours(d.H, d.M, d.S, d.L);
return date;
};
format.toString = function() {
return template;
};
return format;
};
function d3_time_parse(date, template, string, j) {
var c,
p,
i = 0,
n = template.length,
m = string.length;
while (i < n) {
if (j >= m) return -1;
c = template.charCodeAt(i++);
if (c == 37) {
p = d3_time_parsers[template.charAt(i++)];
if (!p || ((j = p(date, string, j)) < 0)) return -1;
} else if (c != string.charCodeAt(j++)) {
return -1;
}
}
return j;
}
var d3_time_zfill2 = d3.format("02d"),
d3_time_zfill3 = d3.format("03d"),
d3_time_zfill4 = d3.format("04d"),
d3_time_sfill2 = d3.format("2d");
var d3_time_formats = {
a: function(d) { return d3_time_weekdays[d.getDay()].substring(0, 3); },
A: function(d) { return d3_time_weekdays[d.getDay()]; },
b: function(d) { return d3_time_months[d.getMonth()].substring(0, 3); },
B: function(d) { return d3_time_months[d.getMonth()]; },
c: d3.time.format("%a %b %e %H:%M:%S %Y"),
d: function(d) { return d3_time_zfill2(d.getDate()); },
e: function(d) { return d3_time_sfill2(d.getDate()); },
H: function(d) { return d3_time_zfill2(d.getHours()); },
I: function(d) { return d3_time_zfill2(d.getHours() % 12 || 12); },
j: function(d) { return d3_time_zfill3(1 + d3.time.dayOfYear(d)); },
L: function(d) { return d3_time_zfill3(d.getMilliseconds()); },
m: function(d) { return d3_time_zfill2(d.getMonth() + 1); },
M: function(d) { return d3_time_zfill2(d.getMinutes()); },
p: function(d) { return d.getHours() >= 12 ? "PM" : "AM"; },
S: function(d) { return d3_time_zfill2(d.getSeconds()); },
U: function(d) { return d3_time_zfill2(d3.time.sundayOfYear(d)); },
w: function(d) { return d.getDay(); },
W: function(d) { return d3_time_zfill2(d3.time.mondayOfYear(d)); },
x: d3.time.format("%m/%d/%y"),
X: d3.time.format("%H:%M:%S"),
y: function(d) { return d3_time_zfill2(d.getFullYear() % 100); },
Y: function(d) { return d3_time_zfill4(d.getFullYear() % 10000); },
Z: d3_time_zone,
"%": function(d) { return "%"; }
};
var d3_time_parsers = {
a: d3_time_parseWeekdayAbbrev,
A: d3_time_parseWeekday,
b: d3_time_parseMonthAbbrev,
B: d3_time_parseMonth,
c: d3_time_parseLocaleFull,
d: d3_time_parseDay,
e: d3_time_parseDay,
H: d3_time_parseHour24,
I: d3_time_parseHour24,
// j: function(d, s, i) { /*TODO day of year [001,366] */ return i; },
L: d3_time_parseMilliseconds,
m: d3_time_parseMonthNumber,
M: d3_time_parseMinutes,
p: d3_time_parseAmPm,
S: d3_time_parseSeconds,
// U: function(d, s, i) { /*TODO week number (sunday) [00,53] */ return i; },
// w: function(d, s, i) { /*TODO weekday [0,6] */ return i; },
// W: function(d, s, i) { /*TODO week number (monday) [00,53] */ return i; },
x: d3_time_parseLocaleDate,
X: d3_time_parseLocaleTime,
y: d3_time_parseYear,
Y: d3_time_parseFullYear
// ,
// Z: function(d, s, i) { /*TODO time zone */ return i; },
// "%": function(d, s, i) { /*TODO literal % */ return i; }
};
// Note: weekday is validated, but does not set the date.
function d3_time_parseWeekdayAbbrev(date, string, i) {
return d3_time_weekdayAbbrevRe.test(string.substring(i, i += 3)) ? i : -1;
}
// Note: weekday is validated, but does not set the date.
function d3_time_parseWeekday(date, string, i) {
d3_time_weekdayRe.lastIndex = 0;
var n = d3_time_weekdayRe.exec(string.substring(i, i + 10));
return n ? i += n[0].length : -1;
}
var d3_time_weekdayAbbrevRe = /^(?:sun|mon|tue|wed|thu|fri|sat)/i,
d3_time_weekdayRe = /^(?:Sunday|Monday|Tuesday|Wednesday|Thursday|Friday|Saturday)/i;
d3_time_weekdays = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"];
function d3_time_parseMonthAbbrev(date, string, i) {
var n = d3_time_monthAbbrevLookup.get(string.substring(i, i += 3).toLowerCase());
return n == null ? -1 : (date.m = n, i);
}
var d3_time_monthAbbrevLookup = d3.map({
jan: 0,
feb: 1,
mar: 2,
apr: 3,
may: 4,
jun: 5,
jul: 6,
aug: 7,
sep: 8,
oct: 9,
nov: 10,
dec: 11
});
function d3_time_parseMonth(date, string, i) {
d3_time_monthRe.lastIndex = 0;
var n = d3_time_monthRe.exec(string.substring(i, i + 12));
return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1;
}
var d3_time_monthRe = /^(?:January|February|March|April|May|June|July|August|September|October|November|December)/ig;
var d3_time_monthLookup = d3.map({
january: 0,
february: 1,
march: 2,
april: 3,
may: 4,
june: 5,
july: 6,
august: 7,
september: 8,
october: 9,
november: 10,
december: 11
});
var d3_time_months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
];
function d3_time_parseLocaleFull(date, string, i) {
return d3_time_parse(date, d3_time_formats.c.toString(), string, i);
}
function d3_time_parseLocaleDate(date, string, i) {
return d3_time_parse(date, d3_time_formats.x.toString(), string, i);
}
function d3_time_parseLocaleTime(date, string, i) {
return d3_time_parse(date, d3_time_formats.X.toString(), string, i);
}
function d3_time_parseFullYear(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 4));
return n ? (date.y = +n[0], i += n[0].length) : -1;
}
function d3_time_parseYear(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 2));
return n ? (date.y = d3_time_century() + +n[0], i += n[0].length) : -1;
}
function d3_time_century() {
return ~~(new Date().getFullYear() / 1000) * 1000;
}
function d3_time_parseMonthNumber(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 2));
return n ? (date.m = n[0] - 1, i += n[0].length) : -1;
}
function d3_time_parseDay(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 2));
return n ? (date.d = +n[0], i += n[0].length) : -1;
}
// Note: we don't validate that the hour is in the range [0,23] or [1,12].
function d3_time_parseHour24(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 2));
return n ? (date.H = +n[0], i += n[0].length) : -1;
}
function d3_time_parseMinutes(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 2));
return n ? (date.M = +n[0], i += n[0].length) : -1;
}
function d3_time_parseSeconds(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 2));
return n ? (date.S = +n[0], i += n[0].length) : -1;
}
function d3_time_parseMilliseconds(date, string, i) {
d3_time_numberRe.lastIndex = 0;
var n = d3_time_numberRe.exec(string.substring(i, i + 3));
return n ? (date.L = +n[0], i += n[0].length) : -1;
}
// Note: we don't look at the next directive.
var d3_time_numberRe = /\s*\d+/;
function d3_time_parseAmPm(date, string, i) {
var n = d3_time_amPmLookup.get(string.substring(i, i += 2).toLowerCase());
return n == null ? -1 : (date.p = n, i);
}
var d3_time_amPmLookup = d3.map({
am: 0,
pm: 1
});
// TODO table of time zone offset names?
function d3_time_zone(d) {
var z = d.getTimezoneOffset(),
zs = z > 0 ? "-" : "+",
zh = ~~(Math.abs(z) / 60),
zm = Math.abs(z) % 60;
return zs + d3_time_zfill2(zh) + d3_time_zfill2(zm);
}
d3.time.format.utc = function(template) {
var local = d3.time.format(template);
function format(date) {
try {
d3_time = d3_time_utc;
var utc = new d3_time();
utc._ = date;
return local(utc);
} finally {
d3_time = Date;
}
}
format.parse = function(string) {
try {
d3_time = d3_time_utc;
var date = local.parse(string);
return date && date._;
} finally {
d3_time = Date;
}
};
format.toString = local.toString;
return format;
};
var d3_time_formatIso = d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");
d3.time.format.iso = Date.prototype.toISOString ? d3_time_formatIsoNative : d3_time_formatIso;
function d3_time_formatIsoNative(date) {
return date.toISOString();
}
d3_time_formatIsoNative.parse = function(string) {
return new Date(string);
};
d3_time_formatIsoNative.toString = d3_time_formatIso.toString;
function d3_time_interval(local, step, number) {
function round(date) {
var d0 = local(date), d1 = offset(d0, 1);
return date - d0 < d1 - date ? d0 : d1;
}
function ceil(date) {
step(date = local(new d3_time(date - 1)), 1);
return date;
}
function offset(date, k) {
step(date = new d3_time(+date), k);
return date;
}
function range(t0, t1, dt) {
var time = ceil(t0), times = [];
if (dt > 1) {
while (time < t1) {
if (!(number(time) % dt)) times.push(new Date(+time));
step(time, 1);
}
} else {
while (time < t1) times.push(new Date(+time)), step(time, 1);
}
return times;
}
function range_utc(t0, t1, dt) {
try {
d3_time = d3_time_utc;
var utc = new d3_time_utc();
utc._ = t0;
return range(utc, t1, dt);
} finally {
d3_time = Date;
}
}
local.floor = local;
local.round = round;
local.ceil = ceil;
local.offset = offset;
local.range = range;
var utc = local.utc = d3_time_interval_utc(local);
utc.floor = utc;
utc.round = d3_time_interval_utc(round);
utc.ceil = d3_time_interval_utc(ceil);
utc.offset = d3_time_interval_utc(offset);
utc.range = range_utc;
return local;
}
function d3_time_interval_utc(method) {
return function(date, k) {
try {
d3_time = d3_time_utc;
var utc = new d3_time_utc();
utc._ = date;
return method(utc, k)._;
} finally {
d3_time = Date;
}
};
}
d3.time.second = d3_time_interval(function(date) {
return new d3_time(Math.floor(date / 1e3) * 1e3);
}, function(date, offset) {
date.setTime(date.getTime() + Math.floor(offset) * 1e3); // DST breaks setSeconds
}, function(date) {
return date.getSeconds();
});
d3.time.seconds = d3.time.second.range;
d3.time.seconds.utc = d3.time.second.utc.range;
d3.time.minute = d3_time_interval(function(date) {
return new d3_time(Math.floor(date / 6e4) * 6e4);
}, function(date, offset) {
date.setTime(date.getTime() + Math.floor(offset) * 6e4); // DST breaks setMinutes
}, function(date) {
return date.getMinutes();
});
d3.time.minutes = d3.time.minute.range;
d3.time.minutes.utc = d3.time.minute.utc.range;
d3.time.hour = d3_time_interval(function(date) {
var timezone = date.getTimezoneOffset() / 60;
return new d3_time((Math.floor(date / 36e5 - timezone) + timezone) * 36e5);
}, function(date, offset) {
date.setTime(date.getTime() + Math.floor(offset) * 36e5); // DST breaks setHours
}, function(date) {
return date.getHours();
});
d3.time.hours = d3.time.hour.range;
d3.time.hours.utc = d3.time.hour.utc.range;
d3.time.day = d3_time_interval(function(date) {
return new d3_time(date.getFullYear(), date.getMonth(), date.getDate());
}, function(date, offset) {
date.setDate(date.getDate() + offset);
}, function(date) {
return date.getDate() - 1;
});
d3.time.days = d3.time.day.range;
d3.time.days.utc = d3.time.day.utc.range;
d3.time.dayOfYear = function(date) {
var year = d3.time.year(date);
return Math.floor((date - year) / 864e5 - (date.getTimezoneOffset() - year.getTimezoneOffset()) / 1440);
};
d3_time_weekdays.forEach(function(day, i) {
day = day.toLowerCase();
i = 7 - i;
var interval = d3.time[day] = d3_time_interval(function(date) {
(date = d3.time.day(date)).setDate(date.getDate() - (date.getDay() + i) % 7);
return date;
}, function(date, offset) {
date.setDate(date.getDate() + Math.floor(offset) * 7);
}, function(date) {
var day = d3.time.year(date).getDay();
return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7) - (day !== i);
});
d3.time[day + "s"] = interval.range;
d3.time[day + "s"].utc = interval.utc.range;
d3.time[day + "OfYear"] = function(date) {
var day = d3.time.year(date).getDay();
return Math.floor((d3.time.dayOfYear(date) + (day + i) % 7) / 7);
};
});
d3.time.week = d3.time.sunday;
d3.time.weeks = d3.time.sunday.range;
d3.time.weeks.utc = d3.time.sunday.utc.range;
d3.time.weekOfYear = d3.time.sundayOfYear;
d3.time.month = d3_time_interval(function(date) {
return new d3_time(date.getFullYear(), date.getMonth(), 1);
}, function(date, offset) {
date.setMonth(date.getMonth() + offset);
}, function(date) {
return date.getMonth();
});
d3.time.months = d3.time.month.range;
d3.time.months.utc = d3.time.month.utc.range;
d3.time.year = d3_time_interval(function(date) {
return new d3_time(date.getFullYear(), 0, 1);
}, function(date, offset) {
date.setFullYear(date.getFullYear() + offset);
}, function(date) {
return date.getFullYear();
});
d3.time.years = d3.time.year.range;
d3.time.years.utc = d3.time.year.utc.range;
function d3_time_scale(linear, methods, format) {
function scale(x) {
return linear(x);
}
scale.invert = function(x) {
return d3_time_scaleDate(linear.invert(x));
};
scale.domain = function(x) {
if (!arguments.length) return linear.domain().map(d3_time_scaleDate);
linear.domain(x);
return scale;
};
scale.nice = function(m) {
var extent = d3_time_scaleExtent(scale.domain());
return scale.domain([m.floor(extent[0]), m.ceil(extent[1])]);
};
scale.ticks = function(m, k) {
var extent = d3_time_scaleExtent(scale.domain());
if (typeof m !== "function") {
var span = extent[1] - extent[0],
target = span / m,
i = d3.bisect(d3_time_scaleSteps, target);
if (i == d3_time_scaleSteps.length) return methods.year(extent, m);
if (!i) return linear.ticks(m).map(d3_time_scaleDate);
if (Math.log(target / d3_time_scaleSteps[i - 1]) < Math.log(d3_time_scaleSteps[i] / target)) --i;
m = methods[i];
k = m[1];
m = m[0].range;
}
return m(extent[0], new Date(+extent[1] + 1), k); // inclusive upper bound
};
scale.tickFormat = function() {
return format;
};
scale.copy = function() {
return d3_time_scale(linear.copy(), methods, format);
};
// TOOD expose d3_scale_linear_rebind?
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
}
// TODO expose d3_scaleExtent?
function d3_time_scaleExtent(domain) {
var start = domain[0], stop = domain[domain.length - 1];
return start < stop ? [start, stop] : [stop, start];
}
function d3_time_scaleDate(t) {
return new Date(t);
}
function d3_time_scaleFormat(formats) {
return function(date) {
var i = formats.length - 1, f = formats[i];
while (!f[1](date)) f = formats[--i];
return f[0](date);
};
}
function d3_time_scaleSetYear(y) {
var d = new Date(y, 0, 1);
d.setFullYear(y); // Y2K fail
return d;
}
function d3_time_scaleGetYear(d) {
var y = d.getFullYear(),
d0 = d3_time_scaleSetYear(y),
d1 = d3_time_scaleSetYear(y + 1);
return y + (d - d0) / (d1 - d0);
}
var d3_time_scaleSteps = [
1e3, // 1-second
5e3, // 5-second
15e3, // 15-second
3e4, // 30-second
6e4, // 1-minute
3e5, // 5-minute
9e5, // 15-minute
18e5, // 30-minute
36e5, // 1-hour
108e5, // 3-hour
216e5, // 6-hour
432e5, // 12-hour
864e5, // 1-day
1728e5, // 2-day
6048e5, // 1-week
2592e6, // 1-month
7776e6, // 3-month
31536e6 // 1-year
];
var d3_time_scaleLocalMethods = [
[d3.time.second, 1],
[d3.time.second, 5],
[d3.time.second, 15],
[d3.time.second, 30],
[d3.time.minute, 1],
[d3.time.minute, 5],
[d3.time.minute, 15],
[d3.time.minute, 30],
[d3.time.hour, 1],
[d3.time.hour, 3],
[d3.time.hour, 6],
[d3.time.hour, 12],
[d3.time.day, 1],
[d3.time.day, 2],
[d3.time.week, 1],
[d3.time.month, 1],
[d3.time.month, 3],
[d3.time.year, 1]
];
var d3_time_scaleLocalFormats = [
[d3.time.format("%Y"), function(d) { return true; }],
[d3.time.format("%B"), function(d) { return d.getMonth(); }],
[d3.time.format("%b %d"), function(d) { return d.getDate() != 1; }],
[d3.time.format("%a %d"), function(d) { return d.getDay() && d.getDate() != 1; }],
[d3.time.format("%I %p"), function(d) { return d.getHours(); }],
[d3.time.format("%I:%M"), function(d) { return d.getMinutes(); }],
[d3.time.format(":%S"), function(d) { return d.getSeconds(); }],
[d3.time.format(".%L"), function(d) { return d.getMilliseconds(); }]
];
var d3_time_scaleLinear = d3.scale.linear(),
d3_time_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats);
d3_time_scaleLocalMethods.year = function(extent, m) {
return d3_time_scaleLinear.domain(extent.map(d3_time_scaleGetYear)).ticks(m).map(d3_time_scaleSetYear);
};
d3.time.scale = function() {
return d3_time_scale(d3.scale.linear(), d3_time_scaleLocalMethods, d3_time_scaleLocalFormat);
};
var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) {
return [m[0].utc, m[1]];
});
var d3_time_scaleUTCFormats = [
[d3.time.format.utc("%Y"), function(d) { return true; }],
[d3.time.format.utc("%B"), function(d) { return d.getUTCMonth(); }],
[d3.time.format.utc("%b %d"), function(d) { return d.getUTCDate() != 1; }],
[d3.time.format.utc("%a %d"), function(d) { return d.getUTCDay() && d.getUTCDate() != 1; }],
[d3.time.format.utc("%I %p"), function(d) { return d.getUTCHours(); }],
[d3.time.format.utc("%I:%M"), function(d) { return d.getUTCMinutes(); }],
[d3.time.format.utc(":%S"), function(d) { return d.getUTCSeconds(); }],
[d3.time.format.utc(".%L"), function(d) { return d.getUTCMilliseconds(); }]
];
var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats);
function d3_time_scaleUTCSetYear(y) {
var d = new Date(Date.UTC(y, 0, 1));
d.setUTCFullYear(y); // Y2K fail
return d;
}
function d3_time_scaleUTCGetYear(d) {
var y = d.getUTCFullYear(),
d0 = d3_time_scaleUTCSetYear(y),
d1 = d3_time_scaleUTCSetYear(y + 1);
return y + (d - d0) / (d1 - d0);
}
d3_time_scaleUTCMethods.year = function(extent, m) {
return d3_time_scaleLinear.domain(extent.map(d3_time_scaleUTCGetYear)).ticks(m).map(d3_time_scaleUTCSetYear);
};
d3.time.scale.utc = function() {
return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat);
};
})();
<!DOCTYPE html>
<html>
<head>
<title>Life Expectancy Slope Graph: 1960 &ndash; 2011</title>
<script src="d3.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
body { color: #444; background: #f3f3f3; font: normal 12px "Adobe Garamond Pro", "Palatino", serif; margin: 2em; }
header { margin: 0 0 20px 220px; border-bottom: 1px solid #6c6c6c; width: 360px; position: relative; }
h1 { font-size: 28px; font-weight: normal; text-shadow: #fff 0 1px 0; margin: 0 0 0 0; padding: 0; }
small { color: #a3a3a3; font-size: 12px; position: absolute; bottom: -1.8em; left: 0;}
a { color: #a3a3a3; }
span.label_year:hover { cursor: ew-resize; }
text.label { fill: #444; }
text.label.start { text-anchor: end; }
line.slope { stroke: #444; stroke-width: 1; }
.missing text.label { display: none; }
.missing line.slope { display: none; }
.over text.label { fill: #bb2629; }
.over line.slope { stroke: #bb2629; stroke-width: 2; }
</style>
</head>
<body>
<header>
<h1 title="Move your mouse over years to change range...">
Life Expectancy <span class="label_year" id="from">1960</span>
&ndash;
<span class="label_year" id="to">2009</span>
</h1>
<small>With data from <a href="http://data.worldbank.org/indicator/SP.DYN.LE00.IN">WorldBank</a></small>
</header>
<div id="chart"></div>
</body>
<script>
d3.csv("life-expectancy-full.csv", function(csv) {
data = csv;
// console.log("CSV", csv);
var
// Extract years from the dataset
years = d3.keys(csv[0]).filter( function(d) { return d.match(/^\d/) }), // Return numerical keys
// Extract names of countries from the dataset
countries = csv.map( function(d) { return d["Country Name"] }),
// Set "from" and "to" years to display
from = years[0],
to = years[years.length-1],
// Return true for countries without start/end values
missing = function(d) { return !d.start || !d.end; },
font_size = 12,
margin = 20,
width = 800,
height = countries.length * font_size + margin,
chart = d3.select("#chart").append("svg")
.attr("width", width)
.attr("height", height);
// Scales
var y = d3.scale.linear()
.domain([0, countries.length])
.range([margin, height]);
var slope = d3.scale.linear()
.domain( [83, 29] )
.range([margin, height]);
var year_scale = d3.scale.linear()
.domain([ parseInt(d3.first(years)), parseInt(d3.last(years)) ])
.clamp(true);
// Update the chart graphics based on new data for selected year
var update = function( from, to ) {
var
// Extract country names and start/end values from the dataset
data = csv
.map( function(d) {
var r = {
label: d["Country Name"],
start: parseFloat(d[from]),
end: parseFloat(d[to])
};
// console.log(r);
return r;
})
// Sort in descending order
.sort( function(a,b) {
return d3.max([a.start, a.end]) > d3.max([b.start, b.end]) ?
-1 :
d3.max([a.start, a.end]) < d3.max([b.start, b.end]) ?
1 : 0;
} ),
// Compute the minimum and maximum value in the dataset
extent = [ csv.map(function(d) {
return d3.entries(d)
.filter(function(d) { return d.key.match(/^\d/) })
.map(function(d) { return d.value })
}) ];
// Countries
var country = chart.selectAll("g.country")
.data( data );
country
.enter()
.append("g")
.attr("class", "country");
country
.classed("missing", function(d) { return missing(d); });
country
.on("mouseover", function(d,i) { return d3.select(this).classed("over", true); })
.on("mouseout", function(d,i) { return d3.select(this).classed("over", false); });
// ** Left column
var left_column = country
.selectAll("text.label.start")
.data( function(d) { return [d]; } );
left_column
.enter()
.append("text")
.classed("label start", true)
.attr("xml:space", "preserve")
.style("font-size", font_size)
.attr("x", 200)
.attr("y", 0);
left_column
.attr("y", function(d,i) { return slope(d.start); })
.text(function(d) { return d.label+ " " + d3.round(d.start, 1); });
// ** Right column
var right_column = country
.selectAll("text.label.end")
.data( function(d) { return [d]; } );
right_column
.enter()
.append("text")
.classed("label end", true)
.attr("xml:space", "preserve")
.style("font-size", font_size)
.attr("x", width-200)
.attr("y", 0);
right_column
.attr("y", function(d,i) { return slope(d.end); })
.text(function(d) { return d3.round(d.end, 1) + " " + d.label; });
// ** Slope lines
var line = country
.selectAll("line.slope")
.data( function(d) { return [d]; } );
line
.enter()
.append("line")
.attr("x1", 210)
.attr("x2", width-210)
.attr("opacity", 0)
.attr("y1", 0)
.attr("y2", 0);
line
.classed("slope", function(d) { return d.start || d.end; })
.attr("opacity", 1)
.attr("y1", function(d,i) { return d.start && d.end ? Math.round( slope(d.start) - font_size/2 + 2) : null; })
.attr("y2", function(d,i) { return d.start && d.end ? Math.round( slope(d.end) - font_size/2 + 2) : null; });
return chart;
};
// Change year range
//
d3.selectAll(".label_year")
.on("mousemove", function() {
var $this = d3.select(this),
box = $this.node();
value = d3.round(year_scale.range([2, box.offsetWidth-2]).invert(d3.mouse(this)[0]))
d3.select(this).text(value)
if ( d3.select("#from").text() > d3.select("#to").text() ) {
d3.select("#from").text( d3.select("#to").text() )
}
if ( d3.select("#to").text() < d3.select("#from").text() ) {
d3.select("#to").text( d3.select("#from") )
}
return update( d3.select("#from").text(), d3.select("#to").text() );
});
return update( d3.first(years), d3.last(years) );
});
</script>
</html>
We can make this file beautiful and searchable if this error is corrected: It looks like row 5 should actually have 52 columns, instead of 50. in line 4.
Country Name,Country Code,1960,1961,1962,1963,1964,1965,1966,1967,1968,1969,1970,1971,1972,1973,1974,1975,1976,1977,1978,1979,1980,1981,1982,1983,1984,1985,1986,1987,1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009
Afghanistan,AFG,31.132097561,31.4752926829,31.8320243902,32.2042682927,32.5910487805,32.9898780488,33.3967317073,33.8091463415,34.2230731707,34.6375121951,35.0559756098,35.4814146341,35.9168780488,36.3613170732,36.8107317073,37.2571219512,37.6909756098,38.1062926829,38.4965853659,38.8618536585,39.2041219512,39.5269512195,39.8398292683,40.1492439024,40.4586829268,40.7705853659,41.0848780488,41.399,41.7109268293,42.021195122,42.3293658537,42.636,42.9397317073,43.242097561,43.5426585366,43.840902439,44.136804878,44.429804878,44.7213414634,45.0098536585,45.2928536585,45.5672682927,45.8331463415,46.0924390244,46.351195122,46.6164146341,46.899097561,47.2053170732,47.5385609756,47.8988536585
Albania,ALB,62.2543658537,63.2734634146,64.1623414634,64.887097561,65.4376829268,65.8294390244,66.1000731707,66.311804878,66.5164390244,66.7384634146,66.9894390244,67.2655121951,67.5444634146,67.8135121951,68.0722682927,68.3258292683,68.5777073171,68.8343414634,69.0996341463,69.3770731707,69.6740487805,70.0004634146,70.3512439024,70.7154146341,71.0764878049,71.3975853659,71.6373658537,71.7749268293,71.8093658537,71.7542195122,71.6454390244,71.5314878049,71.4652195122,71.487,71.6177317073,71.8702926829,72.2410731707,72.6960731707,73.197804878,73.7218292683,74.2387317073,74.7236585366,75.1612195122,75.5420243902,75.8591219512,76.112,76.3096341463,76.4734146341,76.6207560976,76.761097561
Algeria,DZA,46.9853902439,47.5183658537,48.0688536585,48.6398292683,49.230804878,49.8382926829,50.4543414634,51.0729268293,51.6895853659,52.3027804878,52.9180243902,53.5412926829,54.1790731707,54.8353170732,55.5095121951,56.1955609756,56.8833902439,57.5654878049,58.2408780488,58.9140731707,59.6036829268,60.3363170732,61.1255609756,61.9685121951,62.8491707317,63.736,64.5879512195,65.366902439,66.0462682927,66.6150731707,67.0717804878,67.4289756098,67.719195122,67.976,68.2178780488,68.4658780488,68.7344878049,69.0256585366,69.3383658537,69.6730487805,70.0241707317,70.3811219512,70.729902439,71.059,71.364902439,71.6461463415,71.9052926829,72.150902439,72.3890487805,72.6227560976
American Samoa,ASM,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Andorra,AND,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Angola,AGO,32.9853414634,33.3862195122,33.787097561,34.1879512195,34.5883170732,34.9891707317,35.3915121951,35.7958536585,36.201195122,36.6060487805,37.0114146341,37.4192926829,37.8262195122,38.2276585366,38.6156585366,38.9792439024,39.305,39.5854146341,39.8194390244,40.0089756098,40.161804878,40.2902195122,40.4100487805,40.5297804878,40.6554878049,40.7803414634,40.8905609756,40.9779756098,41.041804878,41.0912439024,41.1414146341,41.2088780488,41.3145365854,41.478195122,41.7162195122,42.0509268293,42.5016097561,43.0616341463,43.7143170732,44.439097561,45.2049268293,45.9733170732,46.7119268293,47.3933658537,48.0037073171,48.5384390244,49.0071463415,49.4352926829,49.8474146341,50.2510243902
Antigua and Barbuda,ATG,62.3536585366,,,,,,,,,,66.8536585366,,,,,,,,,,,,72.2480487805,,,,,73.0082926829,,,,,74.2463414634,,,,,74.7317073171,,,,,75.2804878049,,,,,,,
Argentina,ARG,65.1751463415,65.2966341463,65.3892439024,65.4655365854,65.5390731707,65.6258780488,65.7409512195,65.8882439024,66.0722195122,66.2933170732,66.5485121951,66.8302926829,67.1246097561,67.4204390244,67.7132682927,68.0030731707,68.2918292683,68.5840487805,68.8812439024,69.1794390244,69.4696097561,69.7417804878,69.9904390244,70.2121219512,70.4093170732,70.5865121951,70.7537073171,70.9223902439,71.1005365854,71.2921707317,71.4982926829,71.7179268293,71.9440731707,72.1717560976,72.3984390244,72.6236341463,72.8462926829,73.0673902439,73.2864634146,73.5034634146,73.7179756098,73.9295121951,74.1386097561,74.3442926829,74.5455853659,74.7414634146,74.9314390244,75.1149756098,75.2925365854,75.464097561
Armenia,ARM,65.8539512195,66.2754634146,66.7014878049,67.1300243902,67.558097561,67.9847317073,68.4093902439,68.8266341463,69.2264146341,69.5987073171,69.9244390244,70.1830487805,70.3675121951,70.4793170732,70.5239756098,70.5275121951,70.5234634146,70.5364146341,70.576,70.6352926829,70.680097561,70.6587317073,70.5352195122,70.2919268293,69.9390487805,69.5044146341,69.0312195122,68.5769268293,68.1938536585,67.9126097561,67.7572439024,67.7360731707,67.8285365854,68.0127560976,68.2789268293,68.6204634146,69.0294390244,69.4916341463,69.9855365854,70.4924878049,70.9894390244,71.4580487805,71.8896097561,72.2783902439,72.6164146341,72.9007073171,73.1342195122,73.3278292683,73.4959512195,73.6455365854
Aruba,ABW,65.5693658537,65.9880243902,66.3655365854,66.7139756098,67.0442926829,67.3697560976,67.699,68.0346829268,68.3771463415,68.7284146341,69.0861463415,69.446097561,69.7986585366,70.1396585366,70.4652926829,70.777804878,71.0808292683,71.3777073171,71.6697804878,71.9528536585,72.2201463415,72.4623414634,72.673195122,72.8490243902,72.9897560976,73.0979756098,73.1793658537,73.2427073171,73.2962439024,73.3444878049,73.3899756098,73.4331219512,73.4717560976,73.5053170732,73.5357560976,73.5636097561,73.5894390244,73.614804878,73.6422926829,73.6753902439,73.720097561,73.7823902439,73.864195122,73.966,74.0877560976,74.2249756098,74.3741463415,74.5282926829,74.6819268293,74.8315365854
Australia,AUS,70.8170731707,70.9731707317,70.9424390244,70.9117073171,70.8809756098,70.8502439024,70.8195121951,70.8692682927,70.9190243902,70.9687804878,71.0185365854,71.0682926829,71.4575609756,71.8468292683,72.236097561,72.6253658537,73.0146341463,73.3443902439,73.6741463415,74.003902439,74.3336585366,74.6634146341,74.9048780488,75.1463414634,75.387804878,75.6292682927,75.8707317073,76.1517073171,76.4326829268,76.7136585366,76.9946341463,77.2756097561,77.3780487805,77.8780487805,77.8780487805,77.8292682927,78.0780487805,78.4804878049,78.6317073171,78.9317073171,79.2341463415,79.6341463415,79.9365853659,80.2390243902,80.4902439024,80.8414634146,81.0414634146,81.2926829268,81.3951219512,81.543902439
Austria,AUT,68.5856097561,69.5773170732,69.3095121951,69.4436585366,69.9219512195,69.722195122,70.0458536585,69.917804878,70.0575609756,69.8331707317,69.8907317073,70.0692682927,70.4136585366,70.9792682927,70.9624390244,71.0841463415,71.5512195122,71.8953658537,71.9670731707,72.2873170732,72.4236585366,72.7580487805,72.8970731707,72.9685365854,73.5275609756,73.7451219512,74.2229268293,74.6692682927,75.1441463415,75.2480487805,75.53,75.567804878,75.8553658537,76.1063414634,76.4570731707,76.7156097561,76.9836585366,77.3875609756,77.5731707317,77.7756097561,78.0268292683,78.5268292683,78.6780487805,78.6317073171,79.1804878049,79.3317073171,79.8317073171,79.9829268293,80.2341463415,80.0829268293
Azerbaijan,AZE,60.8362439024,61.2391707317,61.6445853659,62.052,62.4574146341,62.8618292683,63.2672682927,63.6687317073,64.0567073171,64.4186829268,64.7346097561,64.9814390244,65.1481219512,65.2341707317,65.2435853659,65.1874390244,65.0822926829,64.9532195122,64.8287560976,64.7279512195,64.6813170732,64.7164390244,64.8307317073,65.008097561,65.225902439,65.4277804878,65.5413414634,65.5259268293,65.3691463415,65.0892682927,64.7463658537,64.4241463415,64.2072439024,64.1540243902,64.2815853659,64.5758292683,64.994,65.4623902439,65.9233658537,66.3554878049,66.7572195122,67.1476829268,67.5548536585,67.9943170732,68.457195122,68.9227317073,69.3614146341,69.7486585366,70.0678536585,70.3176341463
"Bahamas, The",BHS,63.2249268293,63.5934878049,63.9529512195,64.3053170732,64.6497073171,64.9793170732,65.2869512195,65.5636585366,65.8051219512,66.0115853659,66.182902439,66.3227073171,66.4389756098,66.5426585366,66.6439512195,66.7560487805,66.8890731707,67.0490243902,67.2374390244,67.4533658537,67.6973658537,67.9644634146,68.245097561,68.5236585366,68.7896097561,69.0233658537,69.203902439,69.3271219512,69.3984634146,69.426804878,69.4370487805,69.4571219512,69.515,69.6311707317,69.813097561,70.0563658537,70.3480487805,70.6627073171,70.9828536585,71.3034390244,71.6282926829,71.9696829268,72.3384878049,72.7371707317,73.1578292683,73.5836585366,73.9919268293,74.3654390244,74.6938536585,74.9752682927
Bahrain,BHR,51.779804878,53.2025853659,54.6219756098,56.0134390244,57.3574146341,58.634804878,59.8335121951,60.9560243902,62.0038536585,62.9744634146,63.8683902439,64.6892195122,65.4454878049,66.1482682927,66.8015609756,67.4118780488,67.9806585366,68.508902439,68.9990487805,69.4530731707,69.8744878049,70.2622926829,70.6175121951,70.9411463415,71.2357317073,71.5017560976,71.7397073171,71.9515853659,72.1399268293,72.3097073171,72.4649512195,72.6096829268,72.7473902439,72.881097561,73.013804878,73.1470243902,73.2802439024,73.4134634146,73.5431707317,73.6713658537,73.7960731707,73.9182926829,74.0375365854,74.1552926829,74.2715365854,74.3877317073,74.5078292683,74.6312926829,74.7586097561,74.8897804878
Bangladesh,BGD,47.7585365854,48.2351219512,48.801902439,49.4155365854,49.9818536585,50.2293902439,49.8322439024,48.6670487805,46.7816097561,44.3662926829,41.8859512195,39.9328780488,38.969902439,39.2523658537,40.7877560976,43.3347804878,46.445097561,49.5304146341,52.1278780488,54.0466341463,55.2358536585,55.8089268293,56.080195122,56.3081219512,56.581902439,56.9524146341,57.4232195122,57.9363658537,58.4469756098,58.9580731707,59.4711463415,59.9897073171,60.5147317073,61.0467317073,61.5832195122,62.1226829268,62.6621219512,63.1965609756,63.7219756098,64.233902439,64.7303414634,65.2083170732,65.6683170732,66.1098536585,66.5313658537,66.9322926829,67.3100731707,67.6666585366,68.0040243902,68.3252195122
Barbados,BRB,64.4752682927,65.0817804878,65.610804878,66.0707804878,66.4747073171,66.8380243902,67.1742439024,67.4968780488,67.8174634146,68.145,68.4875121951,68.8485121951,69.22,69.5960243902,69.9716097561,70.3433170732,70.703195122,71.0482682927,71.375,71.6823902439,71.9743658537,72.2553902439,72.5323902439,72.8072926829,73.0805365854,73.347097561,73.6034634146,73.8416341463,74.0576585366,74.2505365854,74.4172682927,74.5583658537,74.6783414634,74.7822439024,74.8740731707,74.9593658537,75.0426341463,75.1273902439,75.2156341463,75.3094146341,75.4082682927,75.5086829268,75.608195122,75.7052926829,75.8015365854,75.9009512195,76.0085609756,76.1293658537,76.2643658537,76.4130243902
Belarus,BLR,68.2738780488,68.5559268293,68.8120487805,69.0442195122,69.2564390244,69.458195122,69.6619756098,69.8737560976,70.0934634146,70.3150487805,70.5228780488,70.695804878,70.8183170732,70.8809268293,70.8837317073,70.8328780488,70.7385853659,70.6220243902,70.5043658537,70.4017073171,70.3346585366,70.324804878,70.3704878049,70.4620243902,70.5851707317,70.9926829268,71.5495121951,70.9902439024,71.3414634146,71.587804878,70.8365853659,70.3780487805,70.0219512195,68.9707317073,68.7682926829,68.4609756098,68.612195122,68.4609756098,68.4073170732,67.9073170732,68.912195122,68.5073170732,68.056097561,68.5536585366,68.956097561,68.8512195122,69.4048780488,70.2034146341,70.456097561,70.4073170732
Belgium,BEL,70.0703414634,70.0862195122,70.1012439024,70.1314634146,70.1894390244,70.2821463415,70.4085365854,70.558,70.7229756098,70.8994146341,71.0863170732,71.280195122,71.4810731707,71.6864878049,71.8959512195,72.1065365854,72.3162682927,72.5256585366,72.7377073171,72.9543902439,73.1846341463,73.4373414634,73.7164878049,74.021,74.3438536585,74.6710487805,74.9856097561,75.2725609756,75.5230243902,75.7365609756,75.9682926829,76.0707317073,76.2707317073,76.3170731707,76.5707317073,76.6682926829,76.9219512195,77.2219512195,77.8731707317,78.0707317073,78.1731707317,78.4731707317,78.5756097561,78.7292682927,78.8780487805,79.3276414634,79.7772365854,79.5341463415,79.4829268293,79.7365853659
Belize,BLZ,60.8958536585,61.391804878,61.8984878049,62.4154390244,62.9436097561,63.4774146341,64.0121707317,64.5417317073,65.0579756098,65.5598780488,66.0439512195,66.5127560976,66.9684390244,67.4126097561,67.845804878,68.2665609756,68.6743658537,69.068195122,69.4454878049,69.8057560976,70.147,70.4672926829,70.767097561,71.0464146341,71.305195122,71.543804878,71.7636097561,71.9660731707,72.1526829268,72.3260487805,72.486804878,72.6361707317,72.7738536585,72.901,73.0197317073,73.1276097561,73.2211463415,73.3007073171,73.3726341463,73.4443170732,73.5311219512,73.6489268293,73.8086341463,74.0136585366,74.2599268293,74.5368780488,74.827,75.1118536585,75.3775121951,75.6185121951
Benin,BEN,35.5763414634,35.8840487805,36.1792439024,36.4723414634,36.7753170732,37.1129756098,37.5101219512,37.9781707317,38.5196585366,39.1287317073,39.790097561,40.4805609756,41.170902439,41.8348780488,42.4575853659,43.0276097561,43.5434146341,44.0172926829,44.4575365854,44.8685121951,45.2471219512,45.5922682927,45.905902439,46.1964634146,46.4748536585,46.7579756098,47.0637804878,47.4027560976,47.7804878049,48.1980487805,48.6485365854,49.1231219512,49.6033902439,50.0734634146,50.5224146341,50.9412682927,51.3245121951,51.6740731707,51.9958292683,52.2917560976,52.5653414634,52.819097561,53.0615121951,53.3014878049,53.5489512195,53.8137317073,54.1066829268,54.4307317073,54.7873170732,55.1734146341
Bermuda,BMU,,,,,,68.897804878,,,,,70.29,,,,,,,,,,72.3046341463,,,,,,,,,,,74.0295121951,,,,,,,,,77.8648780488,,,,,78.5767073171,78.7190731707,78.8614390244,79.003804878,79.1461707317
Bhutan,BTN,37.0762682927,37.3144878049,37.5782195122,37.8669512195,38.1816829268,38.5209268293,38.8856585366,39.2753658537,39.6885609756,40.1257317073,40.5863658537,41.072,41.5821219512,42.1157560976,42.6708780488,43.2459756098,43.8425365854,44.4570487805,45.086,45.7233902439,46.3592195122,46.9834878049,47.5907073171,48.1824146341,48.7621219512,49.3393658537,49.9257073171,50.5361463415,51.1797073171,51.8628780488,52.5896341463,53.3589512195,54.1637804878,54.9941219512,55.8469756098,56.7233902439,57.6294390244,58.5621463415,59.5100487805,60.456097561,61.3742195122,62.2373170732,63.026804878,63.7316097561,64.3482195122,64.8806341463,65.3423902439,65.759097561,66.1513170732,66.5320487805
Bolivia,BOL,42.6520487805,42.9612926829,43.2725365854,43.5867804878,43.9035121951,44.2182195122,44.523902439,44.8220487805,45.1181707317,45.422804878,45.7510243902,46.1218780488,46.548902439,47.0406341463,47.6000731707,48.2261707317,48.9148536585,49.6480731707,50.4087804878,51.1849268293,51.9635609756,52.7382439024,53.5039756098,54.2558292683,54.9867317073,55.6896829268,56.3630731707,57.0088780488,57.6285121951,58.2189268293,58.7780731707,59.3024146341,59.7934634146,60.2537804878,60.6863902439,61.0958780488,61.4872926829,61.8657317073,62.2357560976,62.6008780488,62.9636829268,63.3241707317,63.678804878,64.0275121951,64.3692926829,64.7040487805,65.0302195122,65.3477317073,65.658097561,65.9638536585
Bosnia and Herzegovina,BIH,60.2073658537,60.8818536585,61.5188292683,62.1247804878,62.7057560976,63.2692926829,63.8224634146,64.3673414634,64.9074146341,65.4456829268,65.9866097561,66.5321219512,67.0786585366,67.6176341463,68.1404634146,68.6315853659,69.071902439,69.4529268293,69.7717317073,70.0324146341,70.2735853659,70.5480731707,70.8754878049,71.2393658537,71.5952926829,71.7950731707,71.6509268293,71.0824146341,70.1033658537,68.8140243902,67.4668536585,66.3856829268,65.829,65.9418536585,66.7302439024,68.068195122,69.714195122,71.3479512195,72.7164878049,73.714,74.3081219512,74.5531707317,74.6153658537,74.6348780488,74.6596341463,74.7236341463,74.8343658537,74.9686097561,75.1063170732,75.2504390244
Botswana,BWA,50.5372439024,50.8976341463,51.2455365854,51.5844146341,51.9217560976,52.2675365854,52.6327073171,53.0262439024,53.4566341463,53.9278780488,54.4444634146,55.0094146341,55.6137317073,56.246,56.8957317073,57.5469756098,58.1867560976,58.803097561,59.3890243902,59.9385609756,60.4592195122,60.9659512195,61.4692682927,61.9666585366,62.4456341463,62.9001463415,63.324195122,63.6917804878,63.9629756098,64.0963902439,64.0171707317,63.648,62.966,61.9767073171,60.7116341463,59.197804878,57.4776585366,55.6515365854,53.8417073171,52.1589512195,50.7654878049,49.8115609756,49.3375365854,49.3273414634,49.7374878049,50.4465609756,51.2843170732,52.0689512195,52.6636829268,53.0115365854
Brazil,BRA,54.4922195122,54.9587317073,55.4117560976,55.8482439024,56.2676341463,56.6708292683,57.0592439024,57.4393658537,57.8137317073,58.1863902439,58.561,58.938804878,59.3203902439,59.704804878,60.0944390244,60.4885121951,60.8866585366,61.2885853659,61.6921707317,62.0954390244,62.4965853659,62.8944390244,63.287902439,63.6762926829,64.0597560976,64.4393414634,64.8164878049,65.1934634146,65.5726097561,65.9543658537,66.3407317073,66.7342439024,67.1334146341,67.536804878,67.9408780488,68.3406341463,68.7315609756,69.109097561,69.4712439024,69.8144634146,70.1382682927,70.4396341463,70.724097561,70.9961463415,71.2617804878,71.5295365854,71.8109268293,72.1099512195,72.427097561,72.759804878
Brunei Darussalam,BRN,62.3364634146,62.8772682927,63.4029756098,63.9135853659,64.4106097561,64.8935853659,65.362,65.816902439,66.258804878,66.6882195122,67.1051463415,67.5096097561,67.903097561,68.2850731707,68.6580731707,69.0215853659,69.376097561,69.7221219512,70.0611463415,70.3926829268,70.7172195122,71.0357560976,71.3482926829,71.6538292683,71.9543658537,72.248902439,72.5384390244,72.8234878049,73.1040487805,73.381097561,73.6536585366,73.9232195122,74.1887804878,74.4508292683,74.7098780488,74.9674146341,75.2239268293,75.480902439,75.7363658537,75.9883414634,76.2323414634,76.464902439,76.6810487805,76.880804878,77.0626341463,77.2285853659,77.3806097561,77.524195122,77.6622926829,77.7979268293
Bulgaria,BGR,69.2475609756,70.1956097561,69.4919512195,70.3092682927,71.1212195122,71.293902439,71.2234146341,70.413902439,71.2251219512,70.43,71.2563414634,70.8736585366,70.8995121951,71.342195122,71.2080487805,71.0497560976,71.3948780488,70.816097561,71.1846341463,71.3082926829,71.1575609756,71.5719512195,71.186097561,71.3863414634,71.4997560976,71.2280487805,71.7307317073,71.5268292683,71.6043902439,71.7224390244,71.6414634146,71.5609756098,71.4943902439,71.3468292683,71.2087804878,71.0534146341,70.8973170732,70.3512195122,71.0609756098,71.412195122,71.6634146341,71.7682926829,71.8658536585,72.0658536585,72.5634146341,72.5609756098,72.612195122,72.6634146341,72.9634146341,73.412195122
Burkina Faso,BFA,35.8631463415,36.3746097561,36.8775609756,37.3750243902,37.8664878049,38.3574390244,38.8508780488,39.3498292683,39.8567560976,40.3736829268,40.9011219512,41.4385609756,41.9839756098,42.5334146341,43.0833658537,43.634804878,44.1902682927,44.7462195122,45.296195122,45.8301463415,46.3316097561,46.7850487805,47.1799512195,47.5113414634,47.7782195122,47.9815853659,48.1284390244,48.2338292683,48.3152195122,48.3846341463,48.4530487805,48.5274146341,48.6117317073,48.7100243902,48.8308292683,48.9797560976,49.1594390244,49.3699756098,49.6103414634,49.8854878049,50.2012926829,50.5655609756,50.9776341463,51.4323658537,51.9222195122,52.435195122,52.957902439,53.4769512195,53.9824878049,54.4660487805
Burundi,BDI,41.2365365854,41.5484634146,41.8668780488,42.1882926829,42.5067073171,42.8061463415,43.0675853659,43.2835121951,43.4539756098,43.5884390244,43.7059268293,43.8344390244,43.9979756098,44.2140243902,44.4880487805,44.822,45.2102926829,45.628902439,46.0538292683,46.4671219512,46.8593170732,47.2255121951,47.559804878,47.8462926829,48.0625121951,48.1605609756,48.0869512195,47.8301463415,47.4061219512,46.849804878,46.2271463415,45.6215365854,45.1109512195,44.7537560976,44.5784634146,44.5885121951,44.7584146341,45.0267073171,45.3384390244,45.6705609756,46.0050487805,46.3363902439,46.6730731707,47.0215609756,47.3803658537,47.7514634146,48.1388780488,48.5466341463,48.9757560976,49.4212682927
Cambodia,KHM,42.4041463415,42.894902439,43.4316829268,43.9905121951,44.5283902439,44.9758536585,45.2554146341,45.3065853659,45.0818536585,44.5562195122,43.6327073171,42.2078536585,40.3466097561,38.2119268293,36.011195122,34.1257317073,32.9853414634,32.840902439,33.789902439,35.7894146341,38.6240731707,41.9405853659,45.2767317073,48.251195122,50.6716097561,52.4350243902,53.570902439,54.2961463415,54.7996341463,55.1478536585,55.3972926829,55.5814634146,55.7143902439,55.8160487805,55.9238536585,56.0652682927,56.2572682927,56.4922682927,56.7671463415,57.0888292683,57.4641463415,57.8964634146,58.3752195122,58.8894390244,59.4286341463,59.9793902439,60.5283170732,61.0645853659,61.5808536585,62.072195122
Cameroon,CMR,41.5237560976,41.9653414634,42.4059512195,42.8435609756,43.2786585366,43.7151707317,44.1585121951,44.6136341463,45.0845609756,45.5717804878,46.0763902439,46.599,47.1336829268,47.6740487805,48.2146097561,48.7498780488,49.275804878,49.7883414634,50.280902439,50.7484634146,51.1865365854,51.5930731707,51.9681219512,52.307195122,52.6052926829,52.8563902439,53.054,53.196097561,53.2797317073,53.3008780488,53.253097561,53.127902439,52.9293170732,52.6668780488,52.3505609756,51.991902439,51.599902439,51.1915365854,50.7867560976,50.4065121951,50.0712682927,49.7929756098,49.578097561,49.4355609756,49.3748536585,49.4124146341,49.5611707317,49.8151707317,50.160902439,50.5829268293
Canada,CAN,71.1331707317,71.346097561,71.3670731707,71.3807317073,71.7763414634,71.872195122,72.0043902439,72.207804878,72.3534146341,72.5014634146,72.7004878049,73.0292682927,72.933902439,73.1626829268,73.2375609756,73.5217073171,73.856097561,74.2156097561,74.5297560976,74.8663414634,75.0780487805,75.4785365854,75.6804878049,76.0363414634,76.3175609756,76.3034146341,76.44,76.7395121951,76.8092682927,77.0656097561,77.3770731707,77.5534146341,77.3207317073,77.6851219512,77.8619512195,77.9775609756,78.2304878049,78.4804878049,78.6624390244,78.8829268293,79.2365853659,79.487804878,79.5902439024,79.8390243902,80.1414634146,80.2926829268,80.643902439,80.8043902439,80.9648780488,80.6617804878
Cape Verde,CPV,48.672,48.9037804878,49.1239512195,49.3410243902,49.5701707317,49.8411463415,50.1907804878,50.6387317073,51.1940243902,51.8530487805,52.5990243902,53.405097561,54.2333902439,55.0495365854,55.8353414634,56.5782439024,57.2783170732,57.9487804878,58.5987804878,59.2298292683,59.8433414634,60.439195122,61.0173170732,61.5797073171,62.1265121951,62.6583170732,63.1733170732,63.672195122,64.156195122,64.6254878049,65.0802195122,65.5195121951,65.9453170732,66.3601219512,66.7704390244,67.1823170732,67.603195122,68.0370487805,68.487804878,68.9563902439,69.4482682927,69.9698536585,70.5136585366,71.0676341463,71.6177804878,72.1406585366,72.6103414634,73.0108536585,73.336195122,73.586804878
Cayman Islands,CYM,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Central African Republic,CAF,36.4826341463,36.8957073171,37.3187804878,37.7603414634,38.2253658537,38.7263658537,39.2737560976,39.8715609756,40.5182682927,41.2093902439,41.9419268293,42.7114634146,43.503,44.2975609756,45.0796585366,45.8327560976,46.5462926829,47.2112195122,47.8185365854,48.3547804878,48.8095365854,49.1763414634,49.4568292683,49.6525365854,49.7640243902,49.7922926829,49.7393170732,49.6130487805,49.4179756098,49.1595609756,48.8288780488,48.4149756098,47.9173902439,47.3506097561,46.7385853659,46.1062926829,45.4801707317,44.8916341463,44.3725609756,43.9533414634,43.6633658537,43.5235365854,43.5288292683,43.672195122,43.9461219512,44.3475609756,44.8675121951,45.4825365854,46.1632439024,46.8837073171
Chad,TCD,40.2428292683,40.6212682927,41.0037073171,41.3896341463,41.7775853659,42.162,42.5374146341,42.9022926829,43.2546585366,43.5964878049,43.9302926829,44.2620731707,44.5968292683,44.9415853659,45.2998780488,45.6787560976,46.0847560976,46.5154146341,46.9647073171,47.4276585366,47.8966829268,48.3657560976,48.822804878,49.2557804878,49.650195122,49.9915609756,50.2684146341,50.4772926829,50.6157560976,50.683804878,50.6799268293,50.607097561,50.4757804878,50.2989512195,50.088097561,49.8497317073,49.5858536585,49.3045121951,49.0171707317,48.7388292683,48.4889756098,48.2825853659,48.1295853659,48.0359756098,48.0112439024,48.0588536585,48.1812926829,48.3685853659,48.6057560976,48.8853170732
Channel Islands,CHI,70.6397804878,70.7344146341,70.830097561,70.9333170732,71.0475853659,71.1719268293,71.2993414634,71.4218536585,71.5359756098,71.6407073171,71.7390487805,71.836,71.9380487805,72.0501707317,72.1773658537,72.3246097561,72.493902439,72.6852439024,72.8931219512,73.1160243902,73.3449512195,73.5739268293,73.7959268293,74.0064634146,74.2065365854,74.3981219512,74.5877317073,74.7818292683,74.9854634146,75.1985853659,75.4182439024,75.6369268293,75.8496829268,76.053,76.2473902439,76.4373414634,76.629902439,76.8315365854,77.0472195122,77.2779268293,77.5241219512,77.7852682927,78.0538536585,78.3238292683,78.590195122,78.8448780488,79.082902439,79.3007560976,79.4984634146,79.6755365854
Chile,CHL,57.0162926829,57.4063414634,57.8295609756,58.2884146341,58.7809512195,59.3026829268,59.8456097561,60.403195122,60.9709512195,61.5472926829,62.1367073171,62.7466097561,63.3829756098,64.0492682927,64.743,65.4621463415,66.2067317073,66.9663170732,67.7274634146,68.4757317073,69.1917317073,69.8580731707,70.4637804878,71.0063658537,71.4847804878,71.905,72.2789512195,72.6234878049,72.9555121951,73.281902439,73.6035609756,73.9164146341,74.2139512195,74.495195122,74.7656829268,75.0414634146,75.3396341463,75.669804878,76.0330243902,76.4228292683,76.8217317073,77.2072195122,77.5552195122,77.8511707317,78.0895853659,78.2749756098,78.4158536585,78.5342682927,78.6472195122,78.7627073171
China,CHN,43.4578780488,43.7722926829,44.704195122,46.3235121951,48.5743902439,51.2869268293,54.2011219512,57.0098780488,59.4668536585,61.4486585366,62.9022439024,63.8667317073,64.5144390244,64.9957804878,65.3712682927,65.6915609756,65.9844390244,66.2510731707,66.495804878,66.7389268293,66.993804878,67.2629268293,67.534902439,67.7998536585,68.0592682927,68.3131463415,68.5594878049,68.7973170732,69.0271219512,69.2469268293,69.4597317073,69.6640243902,69.8618292683,70.0546341463,70.2429268293,70.4247317073,70.5990243902,70.7663170732,70.927097561,71.0833902439,71.2417073171,71.4055365854,71.5794390244,71.7648780488,71.9623414634,72.1713170732,72.3897317073,72.6125853659,72.8353414634,73.0565121951
Colombia,COL,56.7129268293,57.2438780488,57.7348536585,58.1958292683,58.6337560976,59.0520487805,59.4480731707,59.8197804878,60.1686585366,60.5027317073,60.8316829268,61.1642439024,61.5095609756,61.8756341463,62.2693902439,62.7040243902,63.1896097561,63.7223902439,64.2897317073,64.8772195122,65.4611463415,66.0129756098,66.512195122,66.943097561,67.2982926829,67.5755853659,67.7796341463,67.9340487805,68.061097561,68.1778292683,68.3055365854,68.4601219512,68.649,68.874902439,69.1393414634,69.4366829268,69.7576097561,70.0852439024,70.405195122,70.7118292683,71.0009756098,71.2736585366,71.5340243902,71.7882195122,72.0367804878,72.2797804878,72.5187560976,72.7537804878,72.9843414634,73.2099756098
Comoros,COM,43.4419512195,43.8381463415,44.2339756098,44.6288780488,45.0247073171,45.4262926829,45.843902439,46.2819512195,46.7409756098,47.2185365854,47.7073170732,48.196097561,48.6736585366,49.1326829268,49.5707317073,49.9868292683,50.3863414634,50.7775609756,51.1668292683,51.5580487805,51.9551707317,52.3626585366,52.7775853659,53.196,53.6109268293,54.014902439,54.396,54.7462439024,55.0631463415,55.346195122,55.5994146341,55.8292439024,56.0481219512,56.2645365854,56.4844390244,56.709804878,56.9421463415,57.1764634146,57.4112926829,57.645097561,57.8764390244,58.099804878,58.3172195122,58.5316585366,58.7480731707,58.9784146341,59.2370731707,59.53,59.8611707317,60.2290731707
"Congo, Dem. Rep.",COD,41.0180487805,41.2335365854,41.4515121951,41.678,41.918,42.1804878049,42.4744878049,42.7969756098,43.1419512195,43.4999268293,43.856902439,44.1933902439,44.4953902439,44.753902439,44.9674390244,45.1399756098,45.2845121951,45.4160731707,45.5481219512,45.6846585366,45.8246829268,45.963195122,46.090195122,46.2006829268,46.2936585366,46.3786585366,46.4681707317,46.5677073171,46.6737804878,46.775902439,46.8400731707,46.8238292683,46.7076341463,46.4925121951,46.199902439,45.878804878,45.5966829268,45.4100243902,45.3557804878,45.4424146341,45.651902439,45.942195122,46.253804878,46.5412439024,46.7870243902,46.9916829268,47.1687560976,47.3492926829,47.5573414634,47.7969268293
"Congo, Rep.",COG,48.5835609756,49.2295121951,49.8399756098,50.4104390244,50.9404390244,51.4295121951,51.8817317073,52.3031463415,52.7002682927,53.0775853659,53.4365853659,53.7786829268,54.1023414634,54.409,54.700097561,54.9791707317,55.249195122,55.5117073171,55.7642439024,56.0052926829,56.2368292683,56.4593414634,56.6682926829,56.8532195122,57.0031219512,57.0941219512,57.1017560976,57.015097561,56.8356829268,56.5735121951,56.2465609756,55.8807804878,55.5086097561,55.1599268293,54.8562195122,54.6093902439,54.4214634146,54.2834146341,54.1882439024,54.140902439,54.1458536585,54.2130487805,54.3414878049,54.5296585366,54.7726097561,55.0648536585,55.4014390244,55.7704146341,56.1593414634,56.5587560976
Costa Rica,CRI,61.6029512195,62.1742926829,62.7389512195,63.292902439,63.8366585366,64.3662195122,64.8801463415,65.3809512195,65.8722439024,66.3585609756,66.8489756098,67.3510243902,67.8722195122,68.414097561,68.9766585366,69.5594146341,70.1623658537,70.7754634146,71.3866829268,71.9839756098,72.5508292683,73.0736829268,73.5440487805,73.9583902439,74.3177073171,74.624,74.8857804878,75.1170487805,75.3323414634,75.5396585366,75.747,75.9568536585,76.1692195122,76.3815853659,76.5954390244,76.808804878,77.0216585366,77.2295121951,77.4303658537,77.6227317073,77.8040731707,77.9749268293,78.1347560976,78.2855853659,78.4284146341,78.5642439024,78.6950731707,78.8214146341,78.9462682927,79.0691707317
Cote d'Ivoire,CIV,40.424195122,40.5932926829,40.7545365854,40.9189268293,41.1034146341,41.3368292683,41.6504878049,42.0622439024,42.5785365854,43.1974146341,43.9085365854,44.6926097561,45.5173902439,46.3500487805,47.1681219512,47.9595609756,48.7207560976,49.4540243902,50.1547073171,50.8107804878,51.4042439024,51.9206585366,52.352097561,52.6931707317,52.9404146341,53.0898536585,53.1439756098,53.1137804878,53.0142439024,52.8558536585,52.6441463415,52.3796341463,52.0708292683,51.732195122,51.3852195122,51.0513658537,50.7471219512,50.4899268293,50.2942195122,50.178902439,50.1608780488,50.2505609756,50.4438780488,50.7328292683,51.1113902439,51.5755609756,52.1183658537,52.7258780488,53.3777073171,54.055902439
Croatia,HRV,65.9691219512,66.4139512195,66.8070487805,67.1524146341,67.4566097561,67.7277073171,67.9763170732,68.21,68.4373658537,68.6644634146,68.8978536585,69.1415853659,69.3906341463,69.6368780488,69.8752195122,70.0019512195,70.4553658537,70.7443902439,70.5387804878,70.4273170732,70.1753658537,70.3443902439,70.4826829268,70.2748780488,70.2185365854,70.886097561,71.4190243902,71.4702439024,71.4882926829,71.8446341463,72.1704878049,72.1853658537,71.2414634146,71.5224390244,71.8034146341,72.0843902439,72.3653658537,72.4951219512,72.3170731707,72.6419512195,72.807804878,74.5129268293,74.7173170732,74.613902439,75.5202439024,75.2446341463,75.8368292683,75.7056097561,75.912195122,76.1682926829
Cuba,CUB,63.6626585366,64.2764390244,64.9006829268,65.535902439,66.1755853659,66.8127317073,67.4373658537,68.0409756098,68.6170487805,69.1616097561,69.6756341463,70.1656341463,70.636097561,71.0925365854,71.5319756098,71.9519268293,72.3454878049,72.7066341463,73.0308536585,73.3161219512,73.5623414634,73.767902439,73.9392195122,74.0802682927,74.1970731707,74.2882195122,74.3513414634,74.3905609756,74.4129512195,74.4300487805,74.459804878,74.5215853659,74.6253170732,74.776902439,74.9738536585,75.2067560976,75.4572439024,75.7064146341,75.9403414634,76.158,76.365804878,76.5796341463,76.8153414634,77.0808292683,77.374097561,77.683195122,77.993195122,78.2852439024,78.5474146341,78.7732195122
Curacao,CUW,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Cyprus,CYP,69.5906097561,69.9255365854,70.2499756098,70.5644390244,70.8693902439,71.1653414634,71.4527804878,71.7322439024,72.0042195122,72.2686829268,72.5266585366,72.7776341463,73.0211219512,73.2575853659,73.4875609756,73.7115365854,73.9295121951,74.142,74.349,74.5514878049,74.7484878049,74.9424878049,75.1314878049,75.3154878049,75.4959756098,75.6729512195,75.8459268293,76.0153902439,76.1818292683,76.3442682927,76.5047073171,76.6621219512,76.8160487805,76.9679756098,77.115902439,77.2623170732,77.4057560976,77.5471707317,77.686097561,77.8235121951,77.9569268293,78.0853414634,78.2092682927,78.330195122,78.450097561,78.5739512195,78.7087317073,78.857902439,79.0214634146,79.1969512195
Czech Republic,CZE,70.3487804878,70.5126829268,69.7868292683,70.3043902439,70.4595121951,70.1631707317,70.3848780488,70.2641463415,69.8407317073,69.3670731707,69.4402439024,69.6770731707,70.1765853659,70.0226829268,70.0865853659,70.4146341463,70.5326829268,70.5734146341,70.643902439,70.7495121951,70.2780487805,70.722195122,70.807804878,70.5914634146,70.8375609756,71.0463414634,70.9973170732,71.4456097561,71.6414634146,71.6756097561,71.383902439,71.8982926829,72.2717073171,72.767804878,72.9726829268,73.0748780488,73.7146341463,73.8248780488,74.5146341463,74.6682926829,74.9682926829,75.1731707317,75.2219512195,75.1707317073,75.7219512195,75.9243902439,76.5243902439,76.7243902439,76.9756097561,77.0780487805
Denmark,DNK,72.1765853659,72.4382926829,72.3197560976,72.4004878049,72.4851219512,72.3707317073,72.4441463415,72.922195122,73.1214634146,73.2209756098,73.3434146341,73.4146341463,73.4390243902,73.682195122,73.8082926829,74.0751219512,73.7397560976,74.6324390244,74.3929268293,74.2192682927,74.1017073171,74.2304878049,74.5512195122,74.4204878049,74.562195122,74.4275609756,74.5797560976,74.6912195122,74.7717073171,74.7997560976,74.8053658537,75.157804878,75.1941463415,75.1168292683,75.3751219512,75.2126829268,75.5914634146,75.9451219512,76.1390243902,76.3414634146,76.5926829268,76.7926829268,76.8951219512,77.143902439,77.4926829268,77.843902439,78.0951219512,78.1951219512,78.4463414634,78.5975609756
Djibouti,DJI,38.536,39.0096829268,39.4818292683,39.954902439,40.4289268293,40.9033658537,41.3787804878,41.8531707317,42.325097561,42.7925609756,43.2540731707,43.7041463415,44.1437804878,44.5749756098,45.0016829268,45.4339268293,45.8856585366,46.3633902439,46.866097561,47.3872439024,47.9128536585,48.421902439,48.8978780488,49.3273170732,49.7062195122,50.0376097561,50.328,50.594902439,50.8533414634,51.108804878,51.3663170732,51.6243658537,51.8804146341,52.1314878049,52.3790731707,52.624195122,52.8653902439,53.1036585366,53.3435121951,53.5894146341,53.8503414634,54.1347560976,54.4471219512,54.7893902439,55.1590243902,55.5500243902,55.9528536585,56.3565365854,56.755097561,57.1450487805
Dominica,DMA,,,,,,,,,,,,,,,,,,,,,,,71.4634146341,,,,,71.9634146341,,,,,73.9512195122,,,,,75.9512195122,,,,,76.5975609756,,,,,,,
Dominican Republic,DOM,51.7907560976,52.5177317073,53.2322439024,53.9332682927,54.6213170732,55.2943414634,55.9543170732,56.5992195122,57.2300487805,57.8433170732,58.4365853659,59.0063902439,59.5522682927,60.0717804878,60.5663902439,61.032097561,61.4673658537,61.8746097561,62.2597804878,62.6318292683,63.001195122,63.3813414634,63.7797317073,64.2024390244,64.6514634146,65.1303170732,65.6355365854,66.158195122,66.6848536585,67.2051463415,67.704195122,68.1671463415,68.5885365854,68.9648780488,69.2971219512,69.5917317073,69.8596097561,70.1156097561,70.3715609756,70.6308292683,70.8937073171,71.1545365854,71.4053170732,71.6406097561,71.863,72.0766829268,72.2879268293,72.5044634146,72.7289512195,72.9619756098
Ecuador,ECU,53.1200487805,53.7563658537,54.350097561,54.8917560976,55.3798292683,55.8198292683,56.2207804878,56.6017073171,56.9821219512,57.3705365854,57.7759268293,58.1997804878,58.6400731707,59.0947804878,59.5683902439,60.0643658537,60.587195122,61.1363902439,61.7104634146,62.3059512195,62.9199268293,63.5484146341,64.1849756098,64.8221463415,65.4534390244,66.0708292683,66.6697804878,67.2482195122,67.8061463415,68.3415365854,68.8568780488,69.3557317073,69.842097561,70.3200243902,70.7894878049,71.252,71.7094634146,72.1573902439,72.5912682927,73.0061463415,73.3920487805,73.7380731707,74.040804878,74.2992439024,74.5164146341,74.6992926829,74.8578292683,75.0049512195,75.1505853659,75.302195122
"Egypt, Arab Rep.",EGY,45.9335609756,46.3473658537,46.7697073171,47.2011219512,47.6440731707,48.0955609756,48.555097561,49.0196341463,49.4891463415,49.9655853659,50.4523902439,50.9545121951,51.4764146341,52.019097561,52.581097561,53.1604634146,53.7532682927,54.354097561,54.956,55.5565365854,56.150195122,56.7335121951,57.3074146341,57.8743658537,58.4373170732,59.0012195122,59.571,60.1521463415,60.7506341463,61.3685121951,62.0128292683,62.6876585366,63.3895853659,64.1127073171,64.8499756098,65.5934634146,66.3355853659,67.0653170732,67.7735853659,68.4493658537,69.0826585366,69.6674390244,70.2032439024,70.6915609756,71.1338780488,71.5286829268,71.8789756098,72.1922195122,72.4754390244,72.7341219512
El Salvador,SLV,51.2914878049,52.0206585366,52.7113170732,53.3589512195,53.959,54.5099756098,55.0123170732,55.4679756098,55.8788780488,56.2429756098,56.5555853659,56.8096341463,57.0045365854,57.1433658537,57.2321219512,57.2617317073,57.2160731707,57.1092926829,56.9737804878,56.8539756098,56.8276097561,56.9774390244,57.3509268293,57.9682926829,58.8220487805,59.887,61.1142926829,62.4146341463,63.7012682927,64.9131707317,65.9908536585,66.8924634146,67.6225121951,68.1965609756,68.6201219512,68.913804878,69.1112926829,69.2559512195,69.3890487805,69.5332439024,69.7016097561,69.8956829268,70.0988292683,70.2999756098,70.4996341463,70.698804878,70.9004878049,71.1041707317,71.3108780488,71.5206097561
Equatorial Guinea,GNQ,36.7330487805,37.0324878049,37.3319268293,37.6313414634,37.9312682927,38.2311707317,38.5315853659,38.833,39.1364390244,39.4398780488,39.7438536585,40.0468536585,40.3473658537,40.6473902439,40.946902439,41.2463658537,41.5477804878,41.853097561,42.1638292683,42.483,42.8141707317,43.1603902439,43.5227073171,43.9001707317,44.2897560976,44.6929268293,45.1081463415,45.5308292683,45.9539512195,46.3684634146,46.7654390244,47.1348536585,47.4722926829,47.7722926829,48.0313902439,48.2426097561,48.4,48.5115365854,48.587195122,48.6409512195,48.6902682927,48.7555609756,48.8517804878,48.9889268293,49.1719268293,49.4002926829,49.6655121951,49.9526341463,50.2472195122,50.5447560976
Eritrea,ERI,39.1062682927,39.5283658537,39.9479756098,40.364097561,40.7772439024,41.192902439,41.6175609756,42.0502439024,42.4864634146,42.914195122,43.317,43.6743658537,43.9723170732,44.2003414634,44.355902439,44.4299512195,44.4174634146,44.3363658537,44.2151707317,44.0823414634,43.9783658537,43.9432926829,44.0036097561,44.177902439,44.4786829268,44.9069756098,45.449804878,46.0761707317,46.7580731707,47.4790243902,48.2335365854,49.0215853659,49.8426585366,50.6922439024,51.5528780488,52.4046097561,53.227,54.0065365854,54.7357560976,55.4075853659,56.0249756098,56.5942926829,57.1324634146,57.6539268293,58.1626829268,58.6642682927,59.1577317073,59.6392195122,60.1052682927,60.5569268293
Estonia,EST,68.5777317073,68.839195122,69.0655365854,69.2643658537,69.4392195122,69.5965121951,69.739097561,69.8632682927,69.9672926829,70.048097561,70.0985609756,70.1076341463,70.0723902439,69.9939268293,69.8793170732,69.7346341463,69.5699756098,69.4014390244,69.2441707317,69.1132682927,69.0330487805,68.9780487805,69.1268292683,69.3756097561,69.2780487805,69.3804878049,70.0853658537,70.643902439,70.6975609756,70.0390243902,69.4756097561,69.3731707317,68.8634146341,67.9097560976,66.5,67.543902439,69.612195122,69.8097560976,69.3585365854,70.0634146341,70.4170731707,70.2585365854,70.9048780488,71.3170731707,71.9097560976,72.5682926829,72.6914634146,72.8146341463,73.7707317073,74.8243902439
Ethiopia,ETH,38.4057073171,39.0686341463,39.6971463415,40.2757804878,40.7955365854,41.2524390244,41.6514634146,42.0075609756,42.3342195122,42.637902439,42.9285853659,43.2147317073,43.4958536585,43.7659268293,44.0164634146,44.217,44.3290487805,44.3381463415,44.251804878,44.0935121951,43.9142439024,43.7784634146,43.7421463415,43.8422439024,44.0902682927,44.4752195122,44.9641219512,45.5015365854,46.0399512195,46.557902439,47.0453902439,47.502902439,47.9489512195,48.398,48.8530487805,49.3136341463,49.7752682927,50.2389512195,50.7086829268,51.1929268293,51.7101219512,52.2822195122,52.9186829268,53.618,54.3706585366,55.1566585366,55.9515609756,56.7239268293,57.4507804878,58.1181707317
Faeroe Islands,FRO,,,,,,,,,,,,,,74.4975609756,,,,,75.9853658537,,,,,76.2219512195,75.8780487805,75.7731707317,75.4634146341,75.6097560976,75.7634146341,75.9073170732,76.0097560976,76.4609756098,76.7195121951,76.9146341463,77.1195121951,77.4682926829,77.7609756098,77.812195122,78.1731707317,78.6219512195,78.5829268293,78.743902439,79.0975609756,79.0951219512,78.8414634146,79.1829268293,79.4829268293,79.6317073171,79.9804878049,
Fiji,FJI,55.9504146341,56.3856341463,56.8113658537,57.227097561,57.6333170732,58.0315365854,58.4217317073,58.803902439,59.1775365854,59.5436585366,59.9007560976,60.2468536585,60.5824634146,60.9075609756,61.2226341463,61.530097561,61.8309268293,62.1290487805,62.4244634146,62.7176585366,63.0091463415,63.2964634146,63.5786829268,63.8533414634,64.1199756098,64.379097561,64.6297073171,64.8732926829,65.1113414634,65.3438536585,65.5708536585,65.7933170732,66.0112439024,66.2241463415,66.4335365854,66.638902439,66.8402439024,67.0375609756,67.2308536585,67.4201219512,67.6073170732,67.792902439,67.9773658537,68.1602682927,68.3406585366,68.5152439024,68.679195122,68.8316341463,68.9715853659,69.1020243902
Finland,FIN,68.8197560976,68.8441463415,68.577804878,69.0126829268,69.2209756098,68.977804878,69.4770731707,69.6665853659,69.6163414634,69.5034146341,70.1795121951,70.0175609756,70.7073170732,71.2236585366,71.1348780488,71.6736585366,71.8129268293,72.3502439024,72.8970731707,73.1553658537,73.44,73.7465853659,74.2980487805,74.2009756098,74.5190243902,74.2229268293,74.56,74.5919512195,74.5770731707,74.792195122,74.8131707317,75.2275609756,75.4553658537,75.7051219512,76.3956097561,76.4095121951,76.6934146341,76.8785365854,77.0907317073,77.2912195122,77.4658536585,77.9658536585,78.1195121951,78.3682926829,78.7146341463,78.8170731707,79.2146341463,79.2634146341,79.5682926829,79.7195121951
France,FRA,69.8682926829,70.1170731707,70.3146341463,70.5146341463,70.6634146341,70.812195122,70.9609756098,71.1609756098,71.3097560976,71.4585365854,71.6585365854,71.9073170732,72.1073170732,72.356097561,72.6048780488,72.8536585366,73.1024390244,73.3512195122,73.6024390244,73.8512195122,74.0512195122,74.3,74.5,74.8,75,75.3,75.6,75.8,76.1,76.3487804878,76.6,76.8487804878,77.1,77.3,77.6487804878,77.7512195122,77.9536585366,78.3048780488,78.456097561,78.6073170732,78.9585365854,79.0585365854,79.2609756098,79.2634146341,80.1634146341,80.1146341463,80.5146341463,80.8146341463,80.8682926829,81.0682926829
French Polynesia,PYF,56.329902439,56.7528780488,57.1358292683,57.5097073171,57.8945365854,58.2984146341,58.7184634146,59.1347804878,59.5324146341,59.9102926829,60.2612926829,60.577195122,60.8628292683,61.1305853659,61.3984146341,61.7008536585,62.0785121951,62.5510487805,63.1216341463,63.7818292683,64.4997073171,65.2317804878,65.93,66.5583414634,67.1023414634,67.5615365854,67.9504634146,68.3041219512,68.6475121951,68.9900731707,69.3337804878,69.6715365854,69.9952682927,70.2994390244,70.5870243902,70.8675121951,71.1503902439,71.4447560976,71.7561219512,72.0825365854,72.4210731707,72.7642926829,73.1012195122,73.4222926829,73.7225121951,73.9987560976,74.2494146341,74.4788780488,74.691097561,74.8895853659
Gabon,GAB,39.5681707317,39.9256341463,40.370097561,40.9200731707,41.5785365854,42.3355121951,43.1694878049,44.0414634146,44.9199268293,45.7884146341,46.6358780488,47.4603658537,48.2733658537,49.0828780488,49.8903902439,50.699902439,51.5149268293,52.3379268293,53.1674146341,54.0018780488,54.8438292683,55.6982682927,56.5577073171,57.4076341463,58.229097561,58.995097561,59.6776585366,60.2577804878,60.7234878049,61.0672682927,61.2891219512,61.3965365854,61.4129756098,61.3609512195,61.2554878049,61.0976097561,60.8794390244,60.6049512195,60.2926829268,59.9720487805,59.6909512195,59.4977804878,59.423902439,59.4837560976,59.681804878,60.0055853659,60.4271707317,60.8991463415,61.3811219512,61.8491219512
"Gambia, The",GMB,33.5446341463,33.7785609756,34.0109756098,34.255902439,34.5303414634,34.868804878,35.3063170732,35.8623658537,36.5429756098,37.3421463415,38.2423658537,39.2116097561,40.2113902439,41.2051707317,42.1739512195,43.1097317073,44.0165121951,44.9092926829,45.7965853659,46.6738780488,47.5411707317,48.3959756098,49.2307804878,50.0315853659,50.7813658537,51.4521219512,52.0128292683,52.4534634146,52.7760487805,52.9915609756,53.1250487805,53.209,53.2834634146,53.3804390244,53.5204634146,53.7135365854,53.9596341463,54.2402682927,54.5374146341,54.8450731707,55.1567560976,55.4654878049,55.7687560976,56.0655609756,56.3548536585,56.6400731707,56.9266585366,57.2200487805,57.5242439024,57.8382195122
Georgia,GEO,63.4277073171,63.8277073171,64.2297073171,64.6337073171,65.0357073171,65.4297073171,65.8107073171,66.1737073171,66.5167073171,66.8397073171,67.1497073171,67.4566829268,67.7671707317,68.0801463415,68.3911219512,68.6816097561,68.9301463415,69.1222439024,69.2523658537,69.3270487805,69.3627804878,69.3865609756,69.4243658537,69.4941707317,69.5999268293,69.7340731707,69.8805121951,70.0147073171,70.1217073171,70.1985609756,70.2478780488,70.2768292683,70.3020487805,70.3386097561,70.3965121951,70.4902682927,70.6292926829,70.8139512195,71.0381219512,71.293195122,71.563097561,71.8267317073,72.0686341463,72.2758292683,72.4473414634,72.5887804878,72.7142439024,72.8413414634,72.9846341463,73.1471463415
Germany,DEU,69.6202926829,69.8263902439,70.010097561,70.1719512195,70.3119512195,70.4261463415,70.5085609756,70.5621463415,70.5928780488,70.6126585366,70.640902439,70.6964634146,70.7942682927,70.941804878,71.1411219512,71.3867804878,71.6664634146,71.961804878,72.2559268293,72.5423658537,72.8186341463,73.089195122,73.3614146341,73.6377073171,73.917,74.1917317073,74.4533170732,74.6962682927,74.9186097561,75.1228780488,75.3161219512,75.3195121951,75.8195121951,75.8707317073,76.2707317073,76.4219512195,76.6731707317,77.0731707317,77.4756097561,77.7268292683,77.9268292683,78.3292682927,78.2292682927,78.3804878049,78.6804878049,78.9317073171,79.1317073171,79.5341463415,79.7365853659,79.8365853659
Ghana,GHA,45.9767073171,46.3184390244,46.613804878,46.8717804878,47.1062682927,47.3360243902,47.5802195122,47.8522439024,48.1615121951,48.5126585366,48.9089512195,49.3447317073,49.8064146341,50.2777560976,50.747902439,51.2058536585,51.6409756098,52.05,52.4317073171,52.7855121951,53.1104390244,53.4090731707,53.6894634146,53.9646585366,54.2455365854,54.5554146341,54.9205609756,55.3458536585,55.8246829268,56.3380487805,56.8430243902,57.2862926829,57.6300487805,57.8559512195,57.9690731707,57.9929268293,57.9684878049,57.9551219512,58.0012439024,58.134804878,58.3822439024,58.7555365854,59.232195122,59.7857317073,60.3966097561,61.0383170732,61.6813658537,62.3002439024,62.8735121951,63.3881707317
Gibraltar,GIB,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Greece,GRC,68.7255609756,69.0507560976,69.367902439,69.6779756098,69.9830243902,70.2825609756,70.5771463415,70.8652926829,71.1465121951,71.4227560976,71.694,71.9611463415,72.2271463415,72.4914634146,72.7565609756,73.0244634146,73.2956585366,73.5717073171,73.8512195122,74.1327073171,74.4152926829,74.6970487805,74.976,75.2491707317,75.5145121951,75.7699756098,76.016,76.2514878049,76.4773658537,76.687804878,76.9390243902,77.1365853659,77.3829268293,77.3902439024,77.6390243902,77.5853658537,77.6853658537,78.1365853659,77.8390243902,77.987804878,77.887804878,78.387804878,78.6414634146,78.8414634146,79.0390243902,79.2390243902,79.4390243902,79.4390243902,79.9390243902,80.187804878
Greenland,GRL,,,,,,,,,,,,,,,,,,,63.4146341463,,,,,,,,,,,,,,65.3414634146,,,,,65.2853658537,65.3365853659,65.4390243902,65.9268292683,66.9268292683,68.8634146341,,,,,68.4390243902,68.3541463415,
Grenada,GRD,63.1079268293,63.2096341463,63.3108292683,63.4125365854,63.5132195122,63.6144146341,63.715097561,63.8157804878,63.9164390244,64.0171219512,64.117804878,64.218,64.3186829268,64.4183902439,64.5185853659,64.6137804878,64.698902439,64.7744878049,64.8455365854,64.920097561,65.0093170732,65.1253170732,65.2791707317,65.4833658537,65.7467804878,66.0871707317,66.517195122,67.0341463415,67.6214146341,68.2620731707,68.9273658537,69.583195122,70.2019268293,70.7642926829,71.2583170732,71.6853658537,72.0596829268,72.4058780488,72.7436829268,73.0774634146,73.4077073171,73.727,74.0265121951,74.2989512195,74.5443414634,74.7642682927,74.9627560976,75.1467560976,75.3217804878,75.4923414634
Guam,GUM,61.2263414634,61.7252926829,62.219195122,62.707,63.1862439024,63.6574146341,64.1190243902,64.5715853659,65.0141463415,65.4467073171,65.8673170732,66.2754878049,66.6707317073,67.0530487805,67.4224390244,67.778902439,68.1224146341,68.4544390244,68.7754878049,69.0875121951,69.3905365854,69.6865365854,69.9755365854,70.2585365854,70.5355365854,70.8075365854,71.0755365854,71.3375365854,71.5935365854,71.8435365854,72.0855365854,72.3200487805,72.5460487805,72.7625609756,72.9715609756,73.1750731707,73.3745609756,73.5725365854,73.77,73.9679512195,74.1653902439,74.360804878,74.5532195122,74.7411219512,74.9240487805,75.1039512195,75.2823902439,75.4598292683,75.637804878,75.8167804878
Guatemala,GTM,45.7452926829,46.2756585366,46.8214634146,47.3812195122,47.9553902439,48.5534878049,49.1869512195,49.8602682927,50.5709512195,51.3064878049,52.047902439,52.7732195122,53.4604878049,54.0957317073,54.6724390244,55.1896097561,55.6522439024,56.080804878,56.4922682927,56.8986585366,57.312,57.7413170732,58.1876341463,58.6529756098,59.1393658537,59.6447804878,60.165195122,60.6946097561,61.2254878049,61.7563658537,62.2866829268,62.8184634146,63.3537073171,63.8934634146,64.4368292683,64.9863902439,65.543804878,66.1061463415,66.6674146341,67.2181219512,67.7441707317,68.2289512195,68.6623170732,69.0421219512,69.367804878,69.6478536585,69.8947317073,70.1250487805,70.3523414634,70.5846341463
Guinea,GIN,32.3641219512,32.4533170732,32.534097561,32.6103902439,32.6901707317,32.7882682927,32.9195365854,33.0958780488,33.3252682927,33.6122439024,33.9579268293,34.3585121951,34.8026585366,35.2765609756,35.7712682927,36.2787317073,36.7919512195,37.3077317073,37.8224878049,38.3326585366,38.8347317073,39.3296829268,39.8195609756,40.3074146341,40.7927073171,41.2764878049,41.7607317073,42.2454634146,42.7276829268,43.2059268293,43.6706829268,44.1099512195,44.5217560976,44.9085853659,45.2789512195,45.6518536585,46.0488292683,46.4883414634,46.978902439,47.522,48.1101463415,48.7298292683,49.3570243902,49.9737317073,50.5689512195,51.1356585366,51.6733658537,52.1885609756,52.6872439024,53.1699268293
Guinea-Bissau,GNB,34.5066829268,34.7786341463,35.0500731707,35.3200243902,35.5899756098,35.8594146341,36.1298780488,36.4003414634,36.6718292683,36.942804878,37.208804878,37.4623170732,37.7023170732,37.931804878,38.156804878,38.3902926829,38.6502926829,38.9472926829,39.284804878,39.6582926829,40.0567317073,40.4640487805,40.8587560976,41.2253414634,41.5543170732,41.8407560976,42.084195122,42.2952195122,42.4848780488,42.6596829268,42.8241463415,42.9847560976,43.1449756098,43.3102439024,43.4850243902,43.6752926829,43.8855121951,44.115195122,44.3603170732,44.6193658537,44.8848780488,45.1468536585,45.398804878,45.6397804878,45.8732439024,46.1096585366,46.3619756098,46.6426829268,46.9592682927,47.3132439024
Guyana,GUY,52.7795853659,53.1506585366,53.4889512195,53.7988780488,54.0868536585,54.3697073171,54.6652195122,54.9852682927,55.3372439024,55.7216097561,56.1304878049,56.5515365854,56.9659512195,57.3602926829,57.7275609756,58.0670487805,58.3825365854,58.683804878,58.9757804878,59.257,59.5235853659,59.7682439024,59.9857560976,60.1744146341,60.3373902439,60.4773414634,60.598804878,60.7122439024,60.8275853659,60.9543414634,61.1014634146,61.2744390244,61.4771707317,61.7111219512,61.9812195122,62.2924878049,62.6478780488,63.0444390244,63.4786341463,63.9464390244,64.4482682927,64.9855609756,65.5517560976,66.1368780488,66.7268780488,67.3033170732,67.8472195122,68.3481707317,68.7992195122,69.1978780488
Haiti,HTI,42.0826829268,42.6555609756,43.2229512195,43.7843414634,44.3347804878,44.8677560976,45.3738536585,45.8480487805,46.2898536585,46.699195122,47.0819756098,47.4440731707,47.7953902439,48.1459268293,48.502195122,48.8693414634,49.252,49.6458292683,50.0499756098,50.4619512195,50.8797317073,51.2982682927,51.7144146341,52.1255609756,52.5321707317,52.9377073171,53.3497317073,53.7707560976,54.2033170732,54.6443902439,55.0904146341,55.534804878,55.9715365854,56.3900731707,56.7854146341,57.1460731707,57.4610731707,57.7314878049,57.9648780488,58.1718536585,58.3720731707,58.5897073171,58.8432926829,59.1417804878,59.4880731707,59.8734390244,60.2810731707,60.6877317073,61.0747804878,61.4346829268
Honduras,HND,46.2103170732,46.9036341463,47.5879756098,48.2558780488,48.9017804878,49.523195122,50.1205853659,50.7029512195,51.2782926829,51.855097561,52.439902439,53.0417317073,53.664097561,54.3095365854,54.9800487805,55.6771219512,56.3982682927,57.1379512195,57.8896829268,58.6494146341,59.4186829268,60.2024878049,60.9993414634,61.8017317073,62.5981463415,63.3675365854,64.0883902439,64.7471463415,65.3383170732,65.8643902439,66.3393902439,66.7858536585,67.2273414634,67.6783658537,68.1419268293,68.607,69.0545365854,69.464,69.8213658537,70.1256829268,70.3820243902,70.6009756098,70.8026097561,71.0034634146,71.2120487805,71.4388536585,71.6898292683,71.958902439,72.2409756098,72.532
"Hong Kong SAR, China",HKG,66.9997073171,67.5793658537,68.130097561,68.6434390244,69.1183658537,69.5553902439,69.9614878049,70.3466097561,70.7202439024,71.0878536585,71.4524390244,71.4585365854,71.456097561,72.1097560976,72.612195122,73.3682926829,72.8195121951,73.3195121951,73.5756097561,73.6731707317,74.6731707317,75.3243902439,75.4292682927,75.2756097561,76.0292682927,76.4341463415,76.6853658537,76.8829268293,77.0829268293,77.0292682927,77.3804878049,77.8829268293,77.6780487805,78.0317073171,78.5292682927,78.6829268293,79.6268292683,80.1268292683,80.1317073171,80.3829268293,80.8780487805,81.4243902439,81.4780487805,81.3292682927,81.7804878049,81.5804878049,82.3756097561,82.3756097561,82.3397560976,82.7243902439
Hungary,HUN,68.0031707317,68.936097561,67.8658536585,68.8741463415,69.3809756098,69.0712195122,69.8224390244,69.4070731707,69.2302439024,69.3146341463,69.1646341463,69.0524390244,69.6646341463,69.5180487805,69.2480487805,69.29,69.5731707317,69.8480487805,69.393902439,69.6153658537,69.0617073171,69.1392682927,69.357804878,68.9736585366,69.0258536585,68.972195122,69.1734146341,69.6512195122,70.0234146341,69.4617073171,69.3156097561,69.3770731707,69.1170731707,69.1012195122,69.4697560976,69.7917073171,70.3287804878,70.7024390244,70.557804878,70.6770731707,71.2463414634,72.2487804878,72.3487804878,72.3,72.6487804878,72.6487804878,73.0975609756,73.1512195122,73.7024390244,73.9048780488
Iceland,ISL,73.4267073171,73.495,73.5418536585,73.5732926829,73.5958292683,73.612902439,73.6238780488,73.634195122,73.6532926829,73.6912439024,73.7731463415,73.9227073171,74.1490731707,74.4478292683,74.8069756098,75.1988780488,75.5878780488,75.9402926829,76.2330243902,76.4561219512,76.6127804878,76.7202682927,76.807804878,76.899,77.0063170732,77.138097561,77.2960731707,77.4724390244,77.6579756098,77.8490731707,78.0327317073,78.1965121951,78.335097561,78.4476829268,78.5428292683,78.637097561,78.7540243902,78.9116097561,79.1182926829,79.3725609756,79.6608536585,80.1,80.4487804878,80.6585365854,80.9073170732,81.1024390244,81.156097561,81.1073170732,81.2585365854,81.456097561
India,IND,42.4455853659,43.0957073171,43.7577560976,44.4287560976,45.1082195122,45.7901707317,46.4716341463,47.1486097561,47.8195365854,48.4839268293,49.1476341463,49.820097561,50.5047317073,51.1985609756,51.8961463415,52.5806097561,53.2365853659,53.8482195122,54.4056585366,54.9049268293,55.3470731707,55.7375853659,56.0903658537,56.4197560976,56.7326585366,57.0319268293,57.3173658537,57.5884390244,57.847097561,58.0993902439,58.3528536585,58.6156829268,58.8925121951,59.1864878049,59.4991707317,59.8315609756,60.1786097561,60.5357317073,60.8953414634,61.2558780488,61.6138780488,61.9687804878,62.3211219512,62.6709512195,63.0193170732,63.3672439024,63.716804878,64.0685365854,64.4229512195,64.7785609756
Indonesia,IDN,45.0732682927,45.8273658537,46.5567073171,47.2617560976,47.9435365854,48.6076585366,49.2582439024,49.9034390244,50.5468536585,51.1890243902,51.8299756098,52.4671463415,53.0944390244,53.708804878,54.3071707317,54.8905365854,55.4574146341,56.0097804878,56.5497073171,57.0761463415,57.5911219512,58.0936097561,58.584097561,59.0631219512,59.5306341463,59.9866585366,60.431195122,60.8652195122,61.2882682927,61.700804878,62.1038536585,62.496902439,62.8804634146,63.2545365854,63.6206097561,63.9777073171,64.327804878,64.6694390244,65.0035609756,65.3307073171,65.6463658537,65.9490731707,66.237804878,66.5165365854,66.7912439024,67.0733658537,67.3768292683,67.7095853659,68.0751463415,68.4709756098
"Iran, Islamic Rep.",IRN,44.5774390244,45.340804878,46.0850731707,46.8112682927,47.5189756098,48.2023414634,48.8555609756,49.4762195122,50.0688292683,50.641902439,51.2456829268,51.9446585366,52.7490487805,53.6267073171,54.5114146341,55.2263658537,55.5519512195,55.3815609756,54.71,53.6256097561,52.3442439024,51.154902439,50.3404146341,50.1057560976,50.5314390244,51.635097561,53.3405609756,55.4142195122,57.6270731707,59.8407073171,61.9104634146,63.7254878049,65.2640487805,66.5198536585,67.4774878049,68.1544634146,68.603195122,68.9196585366,69.1880243902,69.4518292683,69.7396585366,70.0585365854,70.3867804878,70.7073902439,71.0224634146,71.333097561,71.6384634146,71.9346341463,72.2196585366,72.4920731707
Iraq,IRQ,48.8539268293,49.9329268293,50.9767560976,51.983902439,52.949902439,53.8707804878,54.7395853659,55.5559268293,56.3164390244,57.0212195122,57.6951219512,58.372195122,59.0554390244,59.7204634146,60.3228780488,60.7249512195,60.7581463415,60.36,59.5591463415,58.4581219512,57.2847073171,56.3282195122,55.8321219512,55.9501707317,56.7224146341,58.1053170732,59.960195122,62.0253658537,64.0624878049,65.9364146341,67.534195122,68.7992682927,69.7719268293,70.496097561,70.9761707317,71.2347073171,71.3117804878,71.2642439024,71.1406585366,70.9688780488,70.7434878049,70.4345853659,70.0258780488,69.526097561,68.9787804878,68.4636341463,68.071804878,67.8640731707,67.8711219512,68.0915121951
Ireland,IRL,69.6917560976,69.9041219512,70.0879756098,70.249804878,70.3945853659,70.5252926829,70.6414146341,70.7435121951,70.8330731707,70.9151219512,70.9962195122,71.0813658537,71.1745853659,71.2808780488,71.4032926829,71.5462926829,71.7128780488,71.9000487805,72.1047560976,72.3230243902,72.5493658537,72.7777804878,73.0037804878,73.2223902439,73.4345853659,73.640902439,73.848804878,74.0633170732,74.2864390244,74.5156097561,74.7413170732,74.9505365854,75.1362439024,75.2964390244,75.4376341463,75.5708536585,75.7853658537,75.9697560976,76.1953658537,76.0736585366,76.5407317073,77.1397560976,77.6365853659,77.9175609756,78.1985365854,78.4795121951,78.7604878049,79.0414634146,79.1414634146,79.5
Isle of Man,IMN,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,76.5292682927,,,,,,,,77.9658536585,,,,,,,
Israel,ISR,,72.0065853659,72.112195122,,,,72.2856097561,71.5097560976,71.0565853659,70.9704878049,71.2134146341,71.7190243902,71.0780487805,71.6934146341,71.6617073171,72.0451219512,72.956097561,72.9585365854,73.2073170732,73.5073170732,73.8756097561,74.2609756098,74.1097560976,74.4585365854,74.8073170732,75.2073170732,74.956097561,75.2585365854,74.4365853659,76.3073170732,76.6073170732,76.7585365854,76.5048780488,77.1536585366,77.4024390244,77.4512195122,78.1048780488,78,78.1487804878,78.6585365854,78.9536585366,79.4073170732,79.4512195122,79.6487804878,80.1463414634,80.1512195122,80.3048780488,80.6048780488,81.0024390244,81.5536585366
Italy,ITA,69.123902439,69.7602439024,69.1497560976,69.2480487805,70.3117073171,70.1717073171,70.926097561,70.9565853659,70.78,70.8119512195,71.5587804878,71.8068292683,72.0753658537,72.0263414634,72.7343902439,72.6473170732,72.9919512195,73.3646341463,73.6931707317,74.0026829268,73.9431707317,74.353902439,74.8146341463,74.6402439024,75.3895121951,75.4953658537,75.8107317073,76.2251219512,76.4056097561,76.8048780488,76.8590243902,76.8780487805,77.237804878,77.51,77.7497560976,78.0143902439,78.3319512195,78.6285365854,78.4268292683,78.8268292683,79.4268292683,79.8292682927,79.9780487805,79.9317073171,80.7292682927,80.5804878049,81.1317073171,81.2853658537,81.3853658537,81.4365853659
Jamaica,JAM,64.1918292683,64.7592195122,65.2797804878,65.754,66.1878536585,66.5848292683,66.9498292683,67.2888536585,67.6063414634,67.9067560976,68.1910487805,68.4577073171,68.7057317073,68.9351463415,69.1494634146,69.3587317073,69.5725121951,69.7953414634,70.0262195122,70.2601463415,70.4855365854,70.6883414634,70.854,70.9734146341,71.0425609756,71.0593658537,71.0263170732,70.9564390244,70.862804878,70.7555121951,70.6456341463,70.538804878,70.4415853659,70.359097561,70.2983902439,70.2634634146,70.2552682927,70.2712926829,70.3109512195,70.3762682927,70.4722926829,70.6056097561,70.7762439024,70.982195122,71.2184390244,71.4794146341,71.7560731707,72.040804878,72.3230243902,72.5946585366
Japan,JPN,67.666097561,68.31,68.5948780488,69.6580487805,70.1324390244,70.2019512195,70.9865853659,71.2765853659,71.6112195122,71.8387804878,71.9502439024,72.8829268293,73.5065853659,73.7575609756,74.393902439,75.0573170732,75.4568292683,75.8982926829,76.0382926829,76.3375609756,76.0917073171,76.4143902439,76.9229268293,76.9614634146,77.3653658537,77.6504878049,78.0646341463,78.4836585366,78.3992682927,78.8180487805,78.8368292683,79.1007317073,79.153902439,79.2936585366,79.6870731707,79.5363414634,80.2002439024,80.4241463415,80.5014634146,80.5707317073,81.076097561,81.4170731707,81.5634146341,81.76,82.0302439024,81.9251219512,82.3219512195,82.5070731707,82.5875609756,82.9314634146
Jordan,JOR,53.8540487805,54.5577804878,55.2555609756,55.952902439,56.6522682927,57.3571707317,58.068097561,58.7840731707,59.5006097561,60.2162195122,60.927902439,61.6336585366,62.33,63.0123902439,63.6753902439,64.3139512195,64.9226097561,65.5008536585,66.0467073171,66.5586829268,67.0367804878,67.4825609756,67.8975121951,68.2876341463,68.6533902439,68.9977560976,69.3221707317,69.6275853659,69.9139512195,70.1832682927,70.4345121951,70.6672195122,70.8804146341,71.0741219512,71.2508292683,71.4124878049,71.561097561,71.6986097561,71.8290243902,71.9533170732,72.0750243902,72.1926585366,72.3077804878,72.4203658537,72.5314634146,72.6450243902,72.7635121951,72.8869268293,73.0162195122,73.1509512195
Kazakhstan,KAZ,58.3035609756,58.7155609756,59.1315609756,59.5495609756,59.9655609756,60.3775609756,60.7795609756,61.1655609756,61.5335609756,61.8795609756,62.1975609756,62.4845609756,62.7415609756,62.9765609756,63.1935609756,63.4055365854,63.6214390244,63.8522926829,64.103097561,64.3779512195,66.6243902439,66.706097561,66.787804878,67.662195122,68.5365853659,68.5365853659,68.9134146341,69.2902439024,68.8487804878,68.2902439024,68.3365853659,67.9829268293,67.7317073171,66.7268292683,65.6731707317,64.9195121951,64.1097560976,64.4634146341,64.5609756098,65.5195121951,65.5170731707,65.7682926829,65.9682926829,65.8658536585,65.887804878,65.9097560976,66.1609756098,66.5048780488,67.0219512195,68.4292682927
Kenya,KEN,46.3624146341,47.013,47.6522439024,48.2697560976,48.8605853659,49.4287560976,49.9816829268,50.5332439024,51.0918536585,51.6609756098,52.2365853659,52.8142439024,53.3859512195,53.9457560976,54.4921463415,55.0311219512,55.5726829268,56.120804878,56.6719512195,57.2165853659,57.7401707317,58.2286585366,58.6625121951,59.0272682927,59.3103902439,59.5099268293,59.6303414634,59.6787317073,59.6561463415,59.5526829268,59.3399512195,58.9795853659,58.4631219512,57.7995853659,57.0174634146,56.1492195122,55.2363170732,54.3371219512,53.5119756098,52.8132195122,52.2996341463,52.0180731707,51.9659512195,52.1272439024,52.4839268293,53.0095609756,53.662195122,54.3860243902,55.1242195122,55.8393658537
Kiribati,KIR,,,,,,,,,,,,,,,,,,,,,,,51.9048780488,,,,,54.6951219512,,,,,58.1951219512,,,59.4390243902,,60.4390243902,,,59.5365853659,,62.8243902439,,,60.9487804878,,,,
"Korea, Dem. Rep.",PRK,55.2211707317,55.7175853659,56.217804878,56.7392439024,57.2963658537,57.9020731707,58.564804878,59.2750487805,60.019902439,60.7909512195,61.5753414634,62.3602195122,63.1322195122,63.8760243902,64.5797317073,65.2314390244,65.8242195122,66.3624878049,66.8511707317,67.2932195122,67.6986341463,68.082902439,68.4544390244,68.8146097561,69.1592439024,69.4930731707,69.8172926829,70.114804878,70.3551219512,70.5028292683,70.4662682927,70.1393170732,69.4963414634,68.5706097561,67.4401707317,66.271902439,65.2720731707,64.601804878,64.3568292683,64.5495609756,65.1105121951,65.8982682927,66.7150731707,67.4055853659,67.9053658537,68.1954878049,68.3080243902,68.3409268293,68.374097561,68.4323902439
"Korea, Rep.",KOR,52.9987317073,53.7346829268,54.4830731707,55.2453902439,56.0216341463,56.8217560976,57.6582195122,58.5300243902,59.4276829268,60.3317317073,61.2072682927,62.4436585366,62.8365853659,63.2295121951,63.5926829268,63.9558536585,64.3017073171,64.6475609756,64.971097561,65.2946341463,65.8019512195,66.3092682927,66.7742682927,67.2392682927,67.886097561,68.5329268293,69.171097561,69.8092682927,70.3343902439,70.8595121951,71.2948780488,71.7302439024,72.206097561,72.6819512195,73.0381707317,73.3943902439,73.821097561,74.247804878,74.8106097561,75.3734146341,75.8554878049,76.3375609756,76.823902439,77.2602439024,77.8465853659,78.4326829268,78.9692682927,79.3495121951,79.8326829268,80.2973170732
Kosovo,KSV,,,,,,,,,,,,,,,,,,,,,,65.9326829268,66.1626829268,66.3826829268,66.597804878,66.8129268293,67.0180487805,67.2131707317,67.3982926829,67.5785365854,67.7587804878,67.9290243902,68.0892682927,68.2495121951,68.4,68.5451219512,68.6856097561,68.8209756098,68.9512195122,66.9512195122,67.9512195122,67.9475609756,67.9387804878,68.1895121951,68.4402439024,68.6909756098,68.9368292683,69.1824390244,69.4180487805,69.6487804878
Kuwait,KWT,61.4006829268,62.0518292683,62.6799756098,63.2836097561,63.8632439024,64.4188780488,64.949,65.4546341463,65.935804878,66.3945365854,66.8323658537,67.2523170732,67.6563902439,68.0461219512,68.4235121951,68.7905609756,69.1467804878,69.4926341463,69.8265853659,70.148097561,70.4567073171,70.7508292683,71.0304878049,71.2941463415,71.5412926829,71.7718780488,71.984902439,72.1808780488,72.3617804878,72.528097561,72.6818536585,72.8225365854,72.9526585366,73.0737317073,73.1872439024,73.2942195122,73.3956585366,73.4910487805,73.5823902439,73.6697073171,73.7524878049,73.8307804878,73.9035609756,73.9738292683,74.0425853659,74.1132926829,74.191902439,74.279902439,74.3782926829,74.4875609756
Kyrgyz Republic,KGZ,56.1123414634,56.5483414634,56.9863414634,57.4263414634,57.8653414634,58.2973414634,58.7193414634,59.1263414634,59.5143414634,59.8813414634,60.2213414634,60.5303414634,60.8103414634,61.0663414634,61.3053414634,61.5363170732,61.7677317073,62.0095853659,62.269902439,62.5532439024,62.8702439024,63.2290487805,63.6237317073,64.0422682927,64.4696341463,64.8821219512,65.2545121951,65.5676097561,65.8097804878,67.9073170732,68.2975609756,68.5512195122,68.1024390244,67.1926829268,66.0390243902,65.7902439024,66.543902439,66.8926829268,67.0512195122,67.0024390244,68.5585365854,68.7073170732,68.1073170732,68.256097561,68.1536585366,67.956097561,67.6951219512,67.8951219512,68.4512195122,69.1024390244
Lao PDR,LAO,43.9777317073,44.1842926829,44.3913658537,44.5979512195,44.8050487805,45.0111463415,45.2157317073,45.4183170732,45.6203902439,45.8244634146,46.0325365854,46.2486585366,46.4748292683,46.7140731707,46.9683170732,47.2365365854,47.5161707317,47.8056585366,48.1074878049,48.4241707317,48.7622195122,49.1267073171,49.5226829268,49.9567073171,50.4327804878,50.9574146341,51.5365609756,52.1676829268,52.8442682927,53.5602682927,54.3082195122,55.0806097561,55.8664878049,56.6543658537,57.4307560976,58.1821463415,58.8955853659,59.5695609756,60.2065609756,60.8110731707,61.3946097561,61.9781707317,62.5752439024,63.1923170732,63.8258536585,64.4622682927,65.0805121951,65.6595609756,66.1843902439,66.6515121951
Latvia,LVA,69.7868292683,70.0324390244,69.4304878049,69.8290243902,71.0280487805,70.7265853659,70.7073170732,70.393902439,70.0429268293,69.7968292683,69.8353658537,70.1646341463,69.8787804878,69.8134146341,69.7409756098,68.9253658537,69.047804878,69.1046341463,68.987804878,68.4956097561,68.8085365854,68.7863414634,69.3282926829,69.1190243902,69.1629268293,69.2914634146,70.6224390244,70.6929268293,70.6153658537,70.1553658537,69.2731707317,69.0324390244,68.396097561,66.7226829268,65.6643902439,66.3912195122,68.7765853659,69.3492682927,69.012195122,69.7429268293,70.3146341463,70.7609756098,70.9609756098,71.2658536585,72.0268292683,71.356097561,70.8658536585,71.0195121951,72.4195121951,73.0804878049
Lebanon,LBN,60.9993414634,61.4943658537,61.9509512195,62.3720487805,62.7621707317,63.128804878,63.4799268293,63.8185365854,64.148097561,64.468097561,64.7725365854,65.0518536585,65.2990731707,65.511195122,65.6907560976,65.8452926829,65.9838536585,66.1184634146,66.2586585366,66.4099756098,66.5743902439,66.7488536585,66.9278536585,67.1083902439,67.2909756098,67.4817073171,67.6866829268,67.9094634146,68.1510487805,68.4069268293,68.6720243902,68.9362195122,69.1904390244,69.4275121951,69.6444146341,69.8400731707,70.0154878049,70.177195122,70.3317560976,70.4836829268,70.6370243902,70.7953170732,70.9590731707,71.1293414634,71.3066585366,71.4895121951,71.6764146341,71.8628536585,72.0473170732,72.2297804878
Lesotho,LSO,46.5009512195,46.9849756098,47.3924878049,47.7164878049,47.9614878049,48.1404878049,48.273,48.3900731707,48.5211707317,48.684804878,48.8984634146,49.1701219512,49.4942682927,49.8653902439,50.2839512195,50.7529756098,51.2734146341,51.8383170732,52.4336585366,53.0474634146,53.6587317073,54.2439756098,54.7937073171,55.3014390244,55.7686585366,56.2383414634,56.7723902439,57.3918292683,58.0727073171,58.7561463415,59.3268536585,59.642,59.5982682927,59.1357804878,58.2461219512,56.9378780488,55.2516097561,53.3281707317,51.3218292683,49.3578292683,47.5863658537,46.1355853659,45.0547804878,44.3637560976,44.075902439,44.1711707317,44.5901219512,45.2150243902,45.9315609756,46.6693658537
Liberia,LBR,37.6482682927,38.0174634146,38.3846585366,38.7503414634,39.1145121951,39.478195122,39.8434390244,40.2097317073,40.5765853659,40.9434878049,41.3114146341,41.6853414634,42.0617317073,42.4340487805,42.7902682927,43.1158780488,43.3923902439,43.6087804878,43.7576097561,43.8373902439,43.8481707317,43.7965365854,43.6984878049,43.5695609756,43.4202439024,43.2535121951,43.0683414634,42.8656585366,42.6559268293,42.4556341463,42.276804878,42.1279512195,42.0236097561,41.987804878,42.0485853659,42.247,42.6270731707,43.1993414634,43.9587560976,44.8887560976,45.9643170732,47.1488292683,48.3872195122,49.6259268293,50.8233658537,51.9430243902,52.9628292683,53.8888536585,54.7276341463,55.479195122
Libya,LBY,46.6787317073,47.1752195122,47.6686829268,48.160097561,48.6494634146,49.1322682927,49.6000243902,50.0557560976,50.5074634146,50.9696829268,51.4664390244,52.0247560976,52.6626097561,53.3880243902,54.2004878049,55.093,56.0490487805,57.0401219512,58.0401707317,59.0341463415,60.0124634146,60.9770487805,61.9303414634,62.8713658537,63.7896585366,64.6663170732,65.4834390244,66.2321707317,66.9110731707,67.522195122,68.0800243902,68.605,69.1180243902,69.6310487805,70.1460731707,70.6531219512,71.1337804878,71.568097561,71.9441219512,72.2628536585,72.5307560976,72.762804878,72.9769268293,73.1895609756,73.407195122,73.6352926829,73.8693658537,74.1029268293,74.329,74.5455609756
Liechtenstein,LIE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Lithuania,LTU,69.8473170732,70.1026829268,69.0953658537,70.2043902439,71.5090243902,71.3251219512,71.5202439024,71.603902439,71.3136585366,70.9285365854,70.8043902439,71.7353658537,71.0246341463,71.332195122,71.2441463415,70.8673170732,70.9580487805,70.8095121951,70.6046341463,70.482195122,70.482195122,70.4607317073,70.8368292683,70.777804878,70.32,70.5012195122,72.0807317073,71.9346341463,71.762195122,71.4253658537,71.1607317073,70.3641463415,70.2343902439,68.9104878049,68.5302439024,69.0063414634,70.1080487805,70.9090243902,71.2195121951,71.5707317073,72.0195121951,71.6585365854,71.7609756098,72.0609756098,71.9609756098,71.2536585366,71.056097561,70.9,71.812195122,72.9146341463
Luxembourg,LUX,68.3215609756,68.6125853659,68.8736585366,69.0993170732,69.2879756098,69.4386341463,69.5537073171,69.6441463415,69.7204390244,69.7930731707,69.8755609756,69.977902439,70.1051463415,70.2614146341,70.4477804878,70.6633902439,70.9039268293,71.1594390244,71.421902439,71.6892682927,71.9602682927,72.2386585366,72.5257073171,72.8232926829,73.1264390244,73.4333170732,73.7366829268,74.0328536585,74.3185121951,74.5916829268,74.8532926829,75.4634146341,75.7707317073,75.712195122,76.3707317073,76.512195122,76.5195121951,76.8804878049,77.0170731707,77.7707317073,77.8731707317,77.8243902439,78.2016268293,78.5788609756,78.956097561,79.3333341463,79.7105682927,80.087804878,80.087804878,80.087804878
"Macao SAR, China",MAC,65.0418292683,65.5554390244,66.0570731707,66.5467317073,67.0239268293,67.4896585366,67.9424390244,68.3837804878,68.8141219512,69.2330243902,69.6424390244,70.0413902439,70.4308780488,70.8113902439,71.1824146341,71.5459756098,71.9010487805,72.2481463415,72.5867560976,72.9193902439,73.2440487805,73.5617073171,73.8723902439,74.1765853659,74.4732926829,74.7650243902,75.0507560976,75.3310243902,75.6058292683,75.8756341463,76.1404390244,76.4002682927,76.655097561,76.9054390244,77.1502682927,77.391097561,77.6284390244,77.8612926829,78.0901707317,78.3155609756,78.5369756098,78.7523902439,78.9612926829,79.1662195122,79.3686341463,79.5745853659,79.7915853659,80.0226829268,80.2673414634,80.5210487805
"Macedonia, FYR",MKD,60.721195122,61.3476341463,61.9580731707,62.5559512195,63.1442439024,63.7218292683,64.2841463415,64.8276829268,65.3479512195,65.847,66.3329268293,66.8173170732,67.304804878,67.7919756098,68.266902439,68.7046097561,69.0705609756,69.3457317073,69.5265365854,69.6209756098,69.6565853659,69.671902439,69.7059268293,69.7896341463,69.9329512195,70.1342439024,70.3758292683,70.629097561,70.8685609756,71.0867317073,71.2797804878,71.4514146341,71.6113414634,71.7686829268,71.9269512195,72.0875121951,72.250195122,72.4147560976,72.5796097561,72.7442195122,72.9102195122,73.0763170732,73.2426829268,73.4099756098,73.5771707317,73.7457073171,73.9169268293,74.0906097561,74.2671219512,74.4438780488
Madagascar,MDG,39.8808780488,40.2799756098,40.6787073171,41.0800243902,41.4828780488,41.8886585366,42.2947317073,42.6995609756,43.1021219512,43.5024390244,43.8996097561,44.2952682927,44.6895609756,45.0855853659,45.484902439,45.8969756098,46.3337560976,46.7951219512,47.2734878049,47.7558292683,48.2081219512,48.5883902439,48.8771707317,49.0729756098,49.1927804878,49.2735365854,49.3677073171,49.5282195122,49.7985853659,50.199804878,50.7423902439,51.4204146341,52.1973902439,53.0399268293,53.9310243902,54.8547317073,55.8030731707,56.7700487805,57.7461219512,58.7162926829,59.6745609756,60.6209268293,61.5513658537,62.4573170732,63.3207804878,64.1121707317,64.8014390244,65.3755609756,65.8355365854,66.1913658537
Malawi,MWI,37.7736341463,37.9981463415,38.2131707317,38.4202195122,38.6242926829,38.840902439,39.0900487805,39.3847073171,39.7298780488,40.1225609756,40.5492195122,40.9903902439,41.4235365854,41.8341707317,42.2147804878,42.5688292683,42.9088292683,43.2492439024,43.6011219512,43.9639268293,44.336195122,44.7113902439,45.0775609756,45.4247317073,45.7464390244,46.041195122,46.3110243902,46.5564390244,46.776,46.9612439024,47.0942682927,47.1501463415,47.1224146341,47.0175853659,46.8521707317,46.6426829268,46.4121463415,46.1964634146,46.0350243902,45.9636829268,46.0297317073,46.2764878049,46.7073170732,47.3086341463,48.062902439,48.9380487805,49.8891463415,50.8623170732,51.8047317073,52.6809512195
Malaysia,MYS,59.4188292683,59.9167560976,60.4054878049,60.8855609756,61.3559756098,61.8162926829,62.2650487805,62.7017804878,63.1270487805,63.5398536585,63.9407073171,64.3306341463,64.709097561,65.0780731707,65.4375853659,65.7871219512,66.128195122,66.459804878,66.7829512195,67.0966341463,67.4028536585,67.7011219512,67.9913902439,68.274195122,68.5505121951,68.8198536585,69.0827073171,69.3375853659,69.5864878049,69.8294146341,70.0653658537,70.2958292683,70.5208292683,70.7398536585,70.9538780488,71.1634390244,71.3685121951,71.569097561,71.7647073171,71.9563414634,72.1424878049,72.3211219512,72.4922682927,72.657902439,72.8215609756,72.9882926829,73.1666097561,73.3590487805,73.5681219512,73.790804878
Maldives,MDV,37.4779512195,37.9720731707,38.5128780488,39.1092439024,39.7611463415,40.462,41.1993414634,41.9546585366,42.7125121951,43.465902439,44.2064146341,44.9276097561,45.6390243902,46.3516585366,47.0744390244,47.8337804878,48.6560731707,49.554195122,50.5270487805,51.5615853659,52.6288292683,53.688902439,54.7048536585,55.6512195122,56.5183658537,57.3080731707,58.034,58.729,59.4245853659,60.1373414634,60.8846341463,61.6763414634,62.5114146341,63.3861219512,64.2990731707,65.2537317073,66.2518536585,67.2816097561,68.3257317073,69.3642195122,70.3741219512,71.3306829268,72.2180731707,73.0244146341,73.7431463415,74.3711463415,74.9126829268,75.3870243902,75.8110487805,76.1956585366
Mali,MLI,30.310804878,30.4661463415,30.6864634146,30.9827560976,31.3545609756,31.7974146341,32.297804878,32.8352682927,33.3882682927,33.9453170732,34.4959512195,35.0361219512,35.5683414634,36.0956341463,36.6154390244,37.126804878,37.6302195122,38.1276829268,38.6226829268,39.1152439024,39.6098292683,40.1114390244,40.6205609756,41.133195122,41.6433170732,42.1429268293,42.6170243902,43.058097561,43.4621463415,43.828195122,44.1622195122,44.4742682927,44.7753170732,45.0768780488,45.3839512195,45.6975121951,46.0130487805,46.3265365854,46.6339756098,46.9383902439,47.2432682927,47.5526585366,47.873097561,48.2075853659,48.5576341463,48.926195122,49.3112439024,49.7107560976,50.120195122,50.5360487805
Malta,MLT,67.6017804878,67.9027073171,68.2047804878,68.504902439,68.7999756098,69.0864634146,69.3663658537,69.6402195122,69.9115853659,70.1789512195,70.4433170732,70.7047073171,70.9626097561,71.2185121951,71.4709268293,71.7208536585,71.9687804878,72.213195122,72.4556097561,72.6950243902,72.9324390244,73.1668292683,73.3987560976,73.6286829268,73.8551219512,74.0805609756,74.3035121951,74.5244634146,74.742902439,74.9603414634,75.1757804878,75.390195122,75.8334146341,76.6024390244,76.9,77.143902439,77.2902439024,77.4365853659,77.1804878049,77.1487804878,78.2,78.4414634146,78.0926829268,78.3512195122,78.5536585366,79.5048780488,78.5487804878,79.443902439,79.4317073171,79.8951219512
Marshall Islands,MHL,,,,,,,,,,,,,,,,,,,,,,,,,,,,72.1414634146,,,,,,,,,,,,67.5048780488,65.2390243902,,,,,,,,,
Mauritania,MRT,42.231902439,42.605902439,42.963902439,43.3129268293,43.6629268293,44.0384390244,44.4654390244,44.9609268293,45.5293902439,46.1673414634,46.8583170732,47.5782926829,48.296804878,48.9883658537,49.6409756098,50.2526341463,50.8308292683,51.3910487805,51.9422926829,52.4800487805,52.994804878,53.4715609756,53.8998292683,54.2725853659,54.5918536585,54.8636097561,55.1013658537,55.3196341463,55.5294146341,55.736195122,55.9369756098,56.1267317073,56.296,56.4392439024,56.5569756098,56.6527073171,56.7314634146,56.8007560976,56.8660731707,56.9314146341,56.9947804878,57.0501707317,57.0950487805,57.1329268293,57.1737560976,57.2310243902,57.326195122,57.4702682927,57.6682439024,57.9196341463
Mauritius,MUS,58.7538780488,59.7629268293,60.6444146341,61.3761707317,61.9525365854,62.3724634146,62.6484878049,62.820195122,62.9336097561,63.0216585366,63.119,63.2572195122,63.4482439024,63.6997317073,64.0200731707,64.4150487805,64.884097561,65.4028780488,65.9427804878,66.4832926829,66.9879756098,67.4235853659,67.7751707317,68.042,68.2298536585,68.3667317073,68.4949512195,68.653097561,68.864097561,69.1300731707,69.4048780488,69.956097561,70.0585365854,70.1073170732,70.1585365854,70.3258536585,70.3229268293,70.4048780488,70.6073170732,70.9609756098,71.6634146341,71.7658536585,71.9658536585,72.121300813,72.2767479675,72.432195122,72.432195122,72.5707317073,72.5707317073,72.8824390244
Mayotte,MYT,55.9545853659,56.859097561,57.7182439024,58.5376097561,59.3227317073,60.0761463415,60.7998292683,61.4937317073,62.1582926829,62.7964878049,63.4113170732,64.0022682927,64.5703658537,65.1175853659,65.6459268293,66.1563902439,66.6494634146,67.1266585366,67.5884634146,68.0363902439,68.4713902439,68.8934878049,69.3041707317,69.7034146341,70.0922439024,70.4711219512,70.8415853659,71.2026097561,71.5557073171,71.9013658537,72.240097561,72.5713902439,72.8967317073,73.2151219512,73.5280731707,73.8355853659,74.1376341463,74.4332439024,74.724902439,75.0111219512,75.2959268293,75.5823170732,75.8708292683,76.1594146341,76.4415121951,76.7090487805,76.9493902439,77.1559756098,77.3262926829,77.462804878
Mexico,MEX,57.0351219512,57.6296829268,58.1572926829,58.6219512195,59.0366097561,59.4147317073,59.7742195122,60.1305121951,60.5005365854,60.8957804878,61.3266585366,61.7976341463,62.3012439024,62.8285853659,63.3737560976,63.9288536585,64.4854878049,65.033804878,65.5673902439,66.0808536585,66.5718536585,67.0399512195,67.491097561,67.9302439024,68.3588780488,68.778902439,69.1917073171,69.5982195122,69.9993170732,70.3959512195,70.791097561,71.1863414634,71.5817073171,71.974195122,72.3622195122,72.7376341463,73.0942926829,73.4260487805,73.7318780488,74.0132439024,74.2742439024,74.5204634146,74.7620731707,75.0047317073,75.25,75.498902439,75.7499756098,75.9971463415,76.2363414634,76.4655609756
"Micronesia, Fed. Sts.",FSM,57.5865853659,57.9855853659,58.3835853659,58.7815853659,59.1795853659,59.5785853659,59.9815853659,60.3875853659,60.7975853659,61.2115853659,61.6335853659,62.0705853659,62.5205853659,62.9755853659,63.4265853659,63.8545853659,64.2395853659,64.5675853659,64.8335853659,65.0365853659,65.1835853659,65.2895853659,65.3735853659,65.4535853659,65.5395853659,65.6365853659,65.7455853659,65.8585853659,65.9725853659,66.0845853659,66.1975853659,66.3101219512,66.4226585366,66.5357073171,66.6482439024,66.7597560976,66.8677073171,66.9716097561,67.072902439,67.1726341463,67.2737317073,67.3792682927,67.4937317073,67.6171463415,67.7525121951,67.8998536585,68.0591707317,68.2274878049,68.4027560976,68.5830487805
Moldova,MDA,61.8030243902,62.1663414634,62.5347560976,62.9067073171,63.2756341463,63.6314390244,63.9605853659,64.2495365854,64.4922926829,64.6848536585,64.825195122,64.9178536585,64.9733658537,65.003804878,65.0157317073,65.0076829268,64.973804878,64.9165609756,64.8479756098,64.7855365854,64.7687073171,64.8414634146,65.0227073171,65.3133414634,65.6957804878,66.1324390244,66.5687073171,66.949097561,67.2321219512,67.3992926829,67.4436829268,67.3723902439,67.2274878049,67.0511219512,66.8693902439,66.7158780488,66.6181219512,66.5851463415,66.6219268293,66.7269756098,66.8882682927,67.0808292683,67.2790731707,67.4624634146,67.6264634146,67.7795365854,67.9386829268,68.123902439,68.3486585366,68.6114390244
Monaco,MCO,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Mongolia,MNG,48.6804390244,49.6091463415,50.5082439024,51.3525121951,52.1263170732,52.8291463415,53.474097561,54.082902439,54.6687560976,55.2267073171,55.7422682927,56.1934390244,56.5631707317,56.8453902439,57.0445853659,57.1662926829,57.2229756098,57.2396585366,57.2453658537,57.2655853659,57.332902439,57.4783658537,57.709,58.0192439024,58.4,58.826,59.2624390244,59.6711707317,60.0257317073,60.3167560976,60.5382682927,60.6984146341,60.8246341463,60.9470243902,61.0843902439,61.2615609756,61.4990731707,61.8036097561,62.1757560976,62.6165121951,63.1213414634,63.6819756098,64.2769268293,64.8824390244,65.4808780488,66.0523658537,66.5792682927,67.0575609756,67.4862439024,67.8641219512
Montenegro,MNE,62.4055365854,62.8882682927,63.4125853659,63.984,64.6034878049,65.2685609756,65.9736341463,66.702195122,67.4377317073,68.1667804878,68.8773902439,69.5611463415,70.213097561,70.8292926829,71.3997804878,71.9150731707,72.3666585366,72.757,73.0890243902,73.369195122,73.6019756098,73.793902439,73.9569268293,74.1024634146,74.2423902439,74.3909756098,74.563,74.7598780488,74.9750731707,75.2006829268,75.4203170732,75.6126341463,75.7574390244,75.8410243902,75.8576341463,75.8041219512,75.6843170732,75.5166829268,75.3196585366,75.1070487805,74.8900243902,74.6751707317,74.4695853659,74.282902439,74.1264878049,74.0152682927,73.9623658537,73.9695365854,74.0335853659,74.1500731707
Morocco,MAR,46.6150731707,47.109097561,47.5995853659,48.0875121951,48.573902439,49.0587317073,49.5425365854,50.027804878,50.5155853659,51.0078536585,51.5046341463,52.0029268293,52.504195122,53.0134634146,53.5382439024,54.0935609756,54.6979268293,55.3593902439,56.0754390244,56.8390731707,57.6312439024,58.4294390244,59.2085853659,59.950195122,60.644195122,61.2901219512,61.8944634146,62.4732439024,63.04,63.5982439024,64.146,64.6802682927,65.1965853659,65.6904390244,66.1623414634,66.6133170732,67.0483658537,67.47,67.8811707317,68.283902439,68.6751463415,69.0548780488,69.4195853659,69.7672439024,70.0998780488,70.4174634146,70.7235365854,71.0191219512,71.3077560976,71.5894146341
Mozambique,MOZ,35.0037073171,35.4667560976,35.9122682927,36.3387804878,36.7487560976,37.1482195122,37.5436829268,37.9436829268,38.3536829268,38.7757317073,39.2158292683,39.6799756098,40.1611463415,40.6478780488,41.1261463415,41.575,41.9699756098,42.2955609756,42.5442682927,42.7135609756,42.805902439,42.8267317073,42.7990243902,42.7487073171,42.6967804878,42.6627317073,42.6620731707,42.7028292683,42.7945365854,42.9466829268,43.1762682927,43.4966829268,43.9004634146,44.3696341463,44.8847560976,45.4109512195,45.9108292683,46.3554878049,46.7275365854,47.0209756098,47.2378536585,47.3956585366,47.5267804878,47.6621219512,47.8196097561,48.0171463415,48.2651463415,48.5605853659,48.8983902439,49.2780243902
Myanmar,MMR,42.7107804878,43.3217317073,43.9551707317,44.6325609756,45.3634390244,46.1428292683,46.9522682927,47.758804878,48.5374146341,49.2781219512,49.9803902439,50.6556829268,51.3139268293,51.9601219512,52.5852439024,53.1732682927,53.7022439024,54.1567073171,54.5291463415,54.8216097561,55.0355853659,55.1745853659,55.264097561,55.3321219512,55.4036341463,55.5146585366,55.6961707317,55.962195122,56.3167073171,56.7567073171,57.2737073171,57.8447073171,58.4377317073,59.0207560976,59.5732926829,60.0783414634,60.5264146341,60.9234878049,61.2765853659,61.5871463415,61.8557073171,62.0837804878,62.2828292683,62.4668292683,62.6517073171,62.8588780488,63.1112195122,63.4181707317,63.7817560976,64.1995121951
Namibia,NAM,46.8803902439,47.499195122,48.101097561,48.6860731707,49.2571463415,49.8152682927,50.3649268293,50.9090243902,51.4495609756,51.9894878049,52.5273170732,53.0635609756,53.5962439024,54.1233902439,54.646,55.1675609756,55.6940731707,56.226,56.7603414634,57.2896341463,57.802902439,58.2871707317,58.7314878049,59.1283658537,59.4723414634,59.7694146341,60.0290487805,60.2602439024,60.466,60.6428780488,60.7774146341,60.8552195122,60.8613170732,60.7862439024,60.6280243902,60.3607317073,59.957902439,59.4344878049,58.8318536585,58.2058536585,57.6577317073,57.3012195122,57.2016585366,57.3889512195,57.8535853659,58.5441219512,59.3742682927,60.2232682927,60.9893414634,61.6185853659
Nepal,NPL,38.4940487805,38.8414634146,39.2014146341,39.5749268293,39.9640487805,40.3703902439,40.7950731707,41.2376097561,41.6975121951,42.1737317073,42.6666341463,43.175097561,43.6979512195,44.233097561,44.7784878049,45.3301219512,45.8885365854,46.4513658537,47.0167073171,47.5845853659,48.1546097561,48.7263170732,49.3022195122,49.8817317073,50.465804878,51.0498292683,51.6306341463,52.2066341463,52.7817317073,53.3614390244,53.9567317073,54.5807073171,55.2424878049,55.9456829268,56.6893658537,57.4686341463,58.2735121951,59.09,59.906097561,60.715804878,61.5216341463,62.3326097561,63.1536585366,63.9802926829,64.7989512195,65.5865853659,66.3151463415,66.966097561,67.5279512195,68.0016829268
Netherlands,NLD,73.3926829268,73.6526829268,73.323902439,73.3370731707,73.7041463415,73.5687804878,73.5129268293,73.8041463415,73.6126829268,73.5395121951,73.5856097561,73.8095121951,73.7270731707,74.143902439,74.5368292683,74.4987804878,74.6470731707,75.2214634146,75.1451219512,75.606097561,75.7431707317,75.9343902439,75.9885365854,76.1641463415,76.2331707317,76.2846341463,76.2704878049,76.7051219512,76.8902439024,76.7341463415,76.8780487805,77,77.2170731707,76.9165853659,77.3751219512,77.4046341463,77.4356097561,77.7943902439,77.8829268293,77.8365853659,77.987804878,78.1902439024,78.2926829268,78.4926829268,79.0951219512,79.3463414634,79.6975609756,80.0975609756,80.2512195122,80.5487804878
New Caledonia,NCL,58.6390243902,59.0390243902,59.4390243902,59.887804878,60.3365853659,60.7853658537,61.2341463415,61.6829268293,62.1317073171,62.5804878049,63.0292682927,63.4780487805,63.9268292683,64.3756097561,64.8243902439,65.2731707317,65.7219512195,66.1707317073,66.3036585366,66.4365853659,66.5695121951,66.7024390244,68.3170731707,68.4666666667,68.6162601626,68.7658536585,69.4134146341,70.0609756098,70.2024390244,70.343902439,70.4853658537,70.3585365854,71.512195122,71.656097561,70.6731707317,72.0097560976,71.9975609756,71.7390243902,74.3756097561,73.8756097561,74.9195121951,74.8317073171,75.1024390244,75.2707317073,75.5146341463,75.1682926829,76.4609756098,75.9463414634,76.1151219512,76.283902439
New Zealand,NZL,71.2365853659,70.9853658537,71.2317073171,71.2804878049,71.3292682927,71.2268292683,71.1243902439,71.4731707317,71.1243902439,71.4731707317,71.2731707317,71.7731707317,71.8292682927,71.6682926829,71.9243902439,72.2195121951,72.4219512195,72.1682926829,73.0195121951,73.0682926829,72.8292682927,73.6219512195,73.7243902439,73.7756097561,74.3707317073,73.8292682927,74.1219512195,74.1780487805,74.4243902439,74.8243902439,75.3780487805,76.0317073171,76.1243902439,76.4341463415,76.8829268293,76.7341463415,76.787804878,77.3341463415,78.0853658537,77.8902439024,78.6365853659,78.6926829268,78.8463414634,79.1463414634,79.5487804878,79.8512195122,80.0487804878,80.1512195122,80.3512195122,80.292195122
Nicaragua,NIC,46.9109512195,47.5733658537,48.2362439024,48.898097561,49.5589512195,50.2228536585,50.8933414634,51.569902439,52.2509512195,52.929902439,53.5980487805,54.2446585366,54.8616097561,55.4423414634,55.9833902439,56.4802926829,56.930195122,57.3408292683,57.7244390244,58.0932439024,58.4604390244,58.839097561,59.2408292683,59.6766097561,60.1555853659,60.6908536585,61.2935853659,61.9561707317,62.666,63.4078780488,64.1580243902,64.8876829268,65.5775609756,66.2114634146,66.7857073171,67.304195122,67.781902439,68.2414878049,68.7016585366,69.1685365854,69.6457317073,70.130902439,70.6141707317,71.0855853659,71.5397804878,71.972804878,72.379195122,72.7593902439,73.110804878,73.4344390244
Niger,NER,37.8972439024,37.9237073171,37.9491707317,37.9746341463,38.0026097561,38.0335853659,38.0695609756,38.1120487805,38.1610487805,38.2185365854,38.2870487805,38.3670487805,38.4605365854,38.5650243902,38.6809756098,38.8074146341,38.9433170732,39.0861707317,39.234,39.384804878,39.5295853659,39.6613902439,39.7782195122,39.8870731707,39.996,40.1184390244,40.2694146341,40.4634146341,40.715902439,41.0353902439,41.4328536585,41.9133170732,42.4687560976,43.088195122,43.7621219512,44.4775121951,45.2253414634,45.9906097561,46.7603414634,47.5220243902,48.2666829268,48.9908292683,49.6960243902,50.3822682927,51.0435609756,51.672902439,52.2652682927,52.8181463415,53.3344878049,53.8158292683
Nigeria,NGA,38.4964878049,38.8726097561,39.2456829268,39.6162439024,39.9862926829,40.3594390244,40.7417804878,41.1363658537,41.5412195122,41.9537804878,42.3694634146,42.7811219512,43.1811707317,43.5619756098,43.9185121951,44.2473170732,44.5479268293,44.8234634146,45.0735365854,45.2966341463,45.4882682927,45.643902439,45.7625121951,45.8440487805,45.8905365854,45.9040243902,45.8875609756,45.8466829268,45.7884146341,45.719804878,45.6373414634,45.5345365854,45.4153658537,45.2902682927,45.1797317073,45.1157073171,45.1332195122,45.2537073171,45.4861463415,45.8295365854,46.2723170732,46.7914634146,47.3504878049,47.9163658537,48.4726097561,49.0047073171,49.5106585366,49.9994878049,50.4797317073,50.9494146341
Northern Mariana Islands,MNP,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Norway,NOR,73.5497560976,73.5504878049,73.4480487805,73.0775609756,73.5958536585,73.7231707317,73.9953658537,74.0665853659,73.9419512195,73.6634146341,74.0880487805,74.1792682927,74.3446341463,74.442195122,74.7536585366,74.8175609756,75.0395121951,75.3868292683,75.4185365854,75.413902439,75.6717073171,75.8690243902,76.0109756098,76.0668292683,76.2243902439,75.9168292683,76.2412195122,76.0817073171,76.2204878049,76.5004878049,76.5373170732,76.9807317073,77.1843902439,77.1517073171,77.6897560976,77.7365853659,78.1504878049,78.1426829268,78.3292682927,78.2829268293,78.6341463415,78.7853658537,78.987804878,79.3902439024,79.8414634146,80.0414634146,80.343902439,80.3951219512,80.5926829268,80.7951219512
Oman,OMN,42.2736097561,42.9303414634,43.6146097561,44.328902439,45.0767560976,45.8641707317,46.6986585366,47.5802439024,48.5074146341,49.4746829268,50.4735121951,51.4934146341,52.5243414634,53.5567804878,54.5852439024,55.6087073171,56.6297073171,57.6532195122,58.6852682927,59.7223414634,60.7683902439,61.8253902439,62.8887804878,63.9511219512,65.0034146341,66.0387317073,67.0516829268,68.031804878,68.9666341463,69.8407073171,70.6329512195,71.3212926829,71.9016585366,72.3749756098,72.7477317073,73.0430243902,73.2905365854,73.5148292683,73.730804878,73.9382682927,74.1102926829,74.2058536585,74.1956585366,74.0730731707,73.8551707317,73.5847073171,73.3175853659,73.1088780488,72.9986097561,73.004097561
Pakistan,PAK,46.6427560976,47.3273658537,48.004,48.6746585366,49.3373658537,49.9961219512,50.6504634146,51.3013658537,51.9462926829,52.5806829268,53.2014634146,53.8020487805,54.3793658537,54.9284146341,55.4466829268,55.9317073171,56.3830487805,56.8043170732,57.1975853659,57.5674146341,57.9148292683,58.2423658537,58.5519756098,58.8481463415,59.1338780488,59.4131707317,59.6880487805,59.961,60.2305121951,60.4990731707,60.767195122,61.0333414634,61.2950243902,61.5517317073,61.8019756098,62.0457317073,62.282,62.5123170732,62.7351707317,62.9525365854,63.1619512195,63.3623902439,63.5533658537,63.7388536585,63.920804878,64.1046829268,64.2974390244,64.5025365854,64.7219512195,64.9552195122
Palau,PLW,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,69.0692682927,,,,,71.8446341463,,,,,70.4936585366,,,,,69.1292682927,,,,
Panama,PAN,60.7899756098,61.2834878049,61.7543902439,62.211195122,62.6613902439,63.1089512195,63.5538292683,63.994,64.4284390244,64.8606585366,65.2996097561,65.7527804878,66.2227073171,66.7094390244,67.2090243902,67.7130487805,68.2125609756,68.6956341463,69.1523170732,69.5761707317,69.9607073171,70.3029512195,70.6083414634,70.8833902439,71.1310731707,71.3569268293,71.5674390244,71.767097561,71.9614390244,72.1544634146,72.3481707317,72.541097561,72.7317560976,72.9176097561,73.1011219512,73.2832195122,73.4658536585,73.6514634146,73.84,74.030902439,74.2231463415,74.4137317073,74.5996585366,74.78,74.9542682927,75.1244878049,75.2922195122,75.4594878049,75.6293170732,75.8012439024
Papua New Guinea,PNG,38.4622439024,39.0595121951,39.7173902439,40.4378780488,41.2164878049,42.037195122,42.8795609756,43.7174878049,44.530902439,45.3082195122,46.0409268293,46.7274634146,47.3813170732,48.0148292683,48.6373658537,49.2705121951,49.9388536585,50.6492926829,51.3934634146,52.1527073171,52.8837073171,53.5312926829,54.0581219512,54.4456341463,54.7004390244,54.8522682927,54.9490731707,55.0516097561,55.202804878,55.4220243902,55.7093414634,56.0470731707,56.399195122,56.7384634146,57.0559268293,57.3519512195,57.6308536585,57.9062926829,58.1895121951,58.4848780488,58.7957804878,59.1247560976,59.468902439,59.8253170732,60.1925365854,60.5666097561,60.9445609756,61.323902439,61.7011707317,62.073902439
Paraguay,PRY,63.6422195122,63.8663414634,64.0785365854,64.2727804878,64.4470487805,64.6032682927,64.7502926829,64.8986097561,65.0556585366,65.2214634146,65.3941219512,65.5677317073,65.734902439,65.8907317073,66.0327804878,66.1625121951,66.2814146341,66.393902439,66.5048780488,66.6158292683,66.7257317073,66.8340731707,66.9393902439,67.042195122,67.1454634146,67.2522439024,67.3690487805,67.4988780488,67.6427560976,67.8011707317,67.9726097561,68.1505365854,68.3314634146,68.5123658537,68.6937560976,68.8802195122,69.079804878,69.2955609756,69.5309756098,69.7825365854,70.045195122,70.3093414634,70.5663902439,70.809804878,71.0385609756,71.2526585366,71.4571707317,71.6586585366,71.8617073171,72.0683170732
Peru,PER,47.6432439024,48.1867560976,48.7038780488,49.194097561,49.665902439,50.1412439024,50.6550243902,51.2297073171,51.8782195122,52.5965365854,53.368195122,54.1637073171,54.9481463415,55.6955365854,56.3939512195,57.0433658537,57.6527804878,58.2421707317,58.8300243902,59.4203658537,60.016195122,60.618,61.2188292683,61.8131707317,62.3980487805,62.9690487805,63.5216585366,64.0544390244,64.5678536585,65.0643902439,65.5495121951,66.0281707317,66.508804878,66.9933902439,67.4853902439,67.9847804878,68.492097561,69.0008780488,69.5046341463,69.9989268293,70.4762682927,70.9307073171,71.3592439024,71.7593902439,72.1286829268,72.4666097561,72.772195122,73.0503902439,73.3057073171,73.5430731707
Philippines,PHL,57.81,58.1193658537,58.4254634146,58.7292195122,59.0301707317,59.3278292683,59.6217804878,59.910097561,60.1933902439,60.4707073171,60.7420731707,61.0070243902,61.2660243902,61.5205609756,61.7701219512,62.0152439024,62.2548780488,62.4905609756,62.7212682927,62.9474878049,63.1697317073,63.387,63.599804878,63.8091219512,64.0134634146,64.2143414634,64.4112195122,64.6036097561,64.7925365854,64.9779512195,65.1593902439,65.3373658537,65.5123658537,65.6843902439,65.8529512195,66.0185365854,66.1806341463,66.3397560976,66.4953902439,66.6480243902,66.7951463415,66.9342439024,67.063804878,67.1893658537,67.3139512195,67.4471463415,67.6,67.780097561,67.9889268293,68.2255121951
Poland,POL,67.6804878049,67.7780487805,67.4268292683,68.3756097561,68.6292682927,69.4292682927,69.8268292683,69.4243902439,70.2195121951,69.7195121951,69.8682926829,69.612195122,70.6658536585,70.6634146341,71.1170731707,70.5609756098,70.656097561,70.4024390244,70.3512195122,70.7512195122,70.0975609756,71.0512195122,71.1024390244,71,70.8,70.5487804878,70.8487804878,70.8975609756,71.3317073171,71.043902439,70.8902439024,70.587804878,71.0902439024,71.5951219512,71.6951219512,71.8926829268,72.2463414634,72.6463414634,72.9975609756,73.043902439,73.7487804878,74.2,74.4975609756,74.5975609756,74.8463414634,74.9951219512,75.143902439,75.243902439,75.543902439,75.6951219512
Portugal,PRT,63.0365853659,63.4655609756,63.8908780488,64.3105609756,64.723195122,65.1288536585,65.5266829268,65.9187804878,66.3066341463,66.6917317073,67.0731707317,66.7707317073,68.3243902439,67.5243902439,68.0195121951,68.3097560976,68.8609756098,70.012195122,70.3170731707,71.1682926829,71.2146341463,71.6146341463,72.4146341463,72.2658536585,72.5146341463,72.8146341463,73.2658536585,73.6658536585,73.7146341463,74.2658536585,73.9658536585,74.0146341463,74.312195122,74.512195122,74.9146341463,75.312195122,75.2609756098,75.412195122,75.712195122,75.9634146341,76.3146341463,76.8146341463,77.0658536585,77.2195121951,77.6707317073,78.0707317073,78.4195121951,78.3219512195,78.5243902439,78.7268292683
Puerto Rico,PRI,68.930902439,69.1459512195,69.3397317073,69.5408292683,69.771195122,70.0392195122,70.345195122,70.668,70.9915365854,71.3113414634,71.6235853659,71.9269512195,72.2211707317,72.5028780488,72.7680731707,73.0092682927,73.2213902439,73.4002439024,73.5490731707,73.6707073171,73.7759268293,73.877,73.9843658537,74.1015121951,74.2259756098,74.3442926829,74.4375121951,74.489902439,74.4967073171,74.4636829268,74.3985853659,74.3151463415,74.2374878049,74.1916585366,74.1976829268,74.2885853659,74.4918292683,74.8102195122,75.2295121951,75.731,76.6892682927,77.0668292683,77.7604878049,78.0712195122,78.1758536585,78.296097561,78.4163414634,78.4258536585,78.5589268293,78.8069756098
Qatar,QAT,59.756902439,60.4215365854,61.0786585366,61.7257804878,62.3633902439,62.9949756098,63.6235609756,64.2536341463,64.8857317073,65.5183414634,66.1484390244,66.7710487805,67.3811219512,67.9721707317,68.5381707317,69.0741463415,69.5755609756,70.0424390244,70.4762926829,70.878097561,71.2498780488,71.5961463415,71.9208780488,72.229097561,72.525804878,72.813,73.0916829268,73.3628536585,73.6245121951,73.8801463415,74.1287804878,74.3713902439,74.6084878049,74.8385853659,75.0631463415,75.2827317073,75.495804878,75.7043902439,75.9079756098,76.1070731707,76.303195122,76.4963902439,76.6876341463,76.8763902439,77.0636097561,77.2476829268,77.4284878049,77.6044390244,77.7745121951,77.939195122
Romania,ROU,65.7178780488,66.2206341463,66.6350487805,66.9541219512,67.183902439,67.3455609756,67.472804878,67.601804878,67.7581707317,67.9524390244,68.1825853659,68.5041463415,68.4702439024,69.0056097561,69.4997560976,69.613902439,69.6987804878,69.7419512195,69.4804878049,69.1531707317,69.0909756098,69.3682926829,69.5317073171,69.7263414634,69.6587804878,69.7068292683,69.4963414634,69.2268292683,69.3880487805,69.5307317073,69.7412195122,69.7843902439,69.7843902439,69.5634146341,69.5097560976,69.456097561,69.1048780488,69.0048780488,69.8073170732,70.512195122,71.1634146341,71.1609756098,71.0097560976,71.3097560976,71.5942756098,71.878895122,72.1634146341,72.5658536585,72.5658536585,73.3097560976
Russian Federation,RUS,67.4099268293,67.8127073171,68.1415121951,68.3854634146,68.5416097561,68.6180243902,68.6316585366,68.6064634146,68.5628780488,68.5098536585,68.1336585366,68.3765853659,68.3085365854,68.2946341463,68.3202439024,67.723902439,67.4875609756,67.3763414634,67.3909756098,67.1143902439,67.033902439,67.263902439,67.806097561,67.6526829268,67.2026829268,67.8568292683,69.3897560976,69.44,69.4643902439,69.1717073171,68.9024390244,68.4743902439,66.8731707317,64.9358536585,64.4670731707,65.2212195122,66.1941463415,66.9507317073,66.783902439,66.0436585366,65.3414634146,65.487804878,65.0853658537,65.0075609756,65.4212195122,65.47,66.6431707317,67.4975609756,67.8487804878,68.6048780488
Rwanda,RWA,42.224902439,42.5193658537,42.803804878,43.0752439024,43.3286585366,43.5580731707,43.7564634146,43.9233658537,44.0632926829,44.1827560976,44.2832926829,44.367902439,44.4476341463,44.5419268293,44.671804878,44.897195122,45.2865609756,45.8508536585,46.5635609756,47.3656585366,48.2001463415,49.002097561,49.6565365854,50.0319756098,50.0053902439,49.2796585366,47.5376097561,44.766195122,41.1419756098,36.9656097561,32.8269756098,29.4400487805,27.3345853659,26.8187073171,27.9363414634,30.4731707317,33.975804878,37.764195122,41.2739268293,44.234804878,46.5102195122,48.1367073171,49.3775853659,50.449097561,51.3964146341,52.2476341463,53.0063902439,53.6597317073,54.206195122,54.665804878
Samoa,WSM,49.9695121951,50.4695121951,50.9695121951,51.4695121951,51.9695121951,52.4695121951,52.9695121951,53.4695121951,53.9695121951,54.4695121951,54.9695121951,55.4695121951,55.9695121951,56.4695121951,56.9695121951,57.4695121951,57.9695121951,58.4695121951,58.9695121951,59.4695121951,59.9695121951,60.4685121951,60.9665121951,61.4645121951,61.9625121951,62.463,62.969,63.4809756098,63.9989512195,64.5194146341,65.0404146341,65.5589512195,66.0700243902,66.5691463415,67.051804878,67.5150243902,67.9542682927,68.3705365854,68.764804878,69.1370487805,69.487804878,69.8200731707,70.1358292683,70.4396097561,70.7323902439,71.0157073171,71.2905365854,71.5563658537,71.8137073171,72.0635609756
San Marino,SMR,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,79.1195121951,79.4731707317,80.1731707317,80.5243902439,80.6195121951,80.9731707317,81.1195121951,81.2195121951,81.7219512195,81.9756097561,82.1804878049,82.506097561,82.8317073171,82.9955432373
Sao Tome and Principe,STP,50.4869756098,51.0757560976,51.6565853659,52.2224390244,52.7668536585,53.2827804878,53.7661463415,54.2194390244,54.649195122,55.0609756098,55.4714634146,55.8963658537,56.3463170732,56.820804878,57.311804878,57.8001219512,58.2605365854,58.6682926829,59.0096829268,59.281097561,59.4880243902,59.644,59.772195122,59.8947317073,60.021195122,60.1581219512,60.3070243902,60.4598780488,60.6122195122,60.764,60.9157560976,61.0669756098,61.2176341463,61.3667317073,61.5152682927,61.6612439024,61.8036341463,61.9429756098,62.0802682927,62.2175365854,62.3577804878,62.5045365854,62.6613170732,62.8296097561,63.0109268293,63.2062682927,63.4161219512,63.6389512195,63.8697560976,64.1075365854
Saudi Arabia,SAU,44.8748780488,45.4835365854,46.1121707317,46.7667560976,47.4528292683,48.1773658537,48.9463658537,49.7578536585,50.610902439,51.5030487805,52.4329268293,53.4006829268,54.3988292683,55.4173902439,56.4452682927,57.4718292683,58.4888536585,59.4896829268,60.4641463415,61.4031707317,62.2977073171,63.1418292683,63.9366341463,64.6837560976,65.3832439024,66.037195122,66.6506341463,67.2295609756,67.7765121951,68.292,68.7704878049,69.2054878049,69.5909512195,69.9278780488,70.2197804878,70.4726829268,70.6956097561,70.8991219512,71.0942682927,71.2890731707,71.492097561,71.7079512195,71.9351219512,72.1710243902,72.4151219512,72.6647804878,72.9158292683,73.1631219512,73.4020731707,73.6321707317
Senegal,SEN,38.933,39.0632682927,39.1810487805,39.2948292683,39.4161219512,39.5534146341,39.7147317073,39.9055365854,40.1353658537,40.412195122,40.7495365854,41.1554146341,41.6312926829,42.1732195122,42.7781463415,43.4430731707,44.1640243902,44.9289756098,45.721902439,46.5268292683,47.3332682927,48.1312195122,48.9146829268,49.6721707317,50.389195122,51.0477317073,51.6332682927,52.1423170732,52.5778292683,52.9438536585,53.2483414634,53.501804878,53.7242439024,53.9326829268,54.1421219512,54.3630731707,54.6045365854,54.8635365854,55.1385609756,55.4311219512,55.7392439024,56.0584390244,56.3826585366,56.7074146341,57.0291707317,57.3493414634,57.6678780488,57.9872195122,58.3093658537,58.6323170732
Serbia,SRB,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,71.487804878,,,,,,72.0390243902,,,72.1365853659,72.1853658537,72.2853658537,72.4365853659,72.5829268293,72.6341463415,73.1551219512,73.3829268293,73.6365853659,73.6853658537
Seychelles,SYC,,,,,,,,,,,,,,,,,,,,,,,68.6829268293,,,,,69.7319512195,,,,,70.6707317073,,,,,71.4146341463,,,,,72.9536585366,71.0292682927,72.6097560976,72.1317073171,72.2170731707,73.1926829268,73.1634146341,73.0341463415
Sierra Leone,SLE,31.4612195122,31.7149512195,31.9848292683,32.2758292683,32.5924146341,32.938,33.3124878049,33.7167804878,34.1538536585,34.6286585366,35.152195122,35.7394878049,36.3916097561,37.1046829268,37.8687804878,38.6890487805,39.574195122,40.5012439024,41.4286585366,42.3038536585,43.0436585366,43.5598292683,43.8061463415,43.7664146341,43.4455853659,42.8720731707,42.095902439,41.2107560976,40.3103414634,39.4623414634,38.7214634146,38.1223902439,37.6632439024,37.3456341463,37.1876097561,37.2087073171,37.4188780488,37.7990243902,38.3254878049,38.9746829268,39.7315853659,40.5776829268,41.4894390244,42.4307804878,43.3686097561,44.2602439024,45.0730243902,45.7958780488,46.4252682927,46.9576829268
Singapore,SGP,65.6598292683,66.087195122,66.4322439024,66.700804878,66.9102195122,67.085804878,67.2559512195,67.4457317073,67.6737317073,67.9510731707,68.2814146341,68.66,69.0659756098,69.4784634146,69.8854634146,70.2714146341,70.6211463415,70.9319756098,71.2072195122,71.452804878,71.6817560976,71.9121463415,72.1640487805,72.4510487805,72.782097561,73.1641463415,73.5991219512,74.0744146341,74.5734634146,75.0827317073,75.582195122,76.0513414634,76.4787560976,76.857,76.2975609756,76.3951219512,76.7463414634,77.0487804878,77.4,77.5512195122,78.0512195122,78.3512195122,78.6951219512,79.0390243902,79.4902439024,79.9902439024,80.1414634146,80.4414634146,80.7902439024,81.2926829268
Sint Maarten (Dutch part),SXM,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Slovak Republic,SVK,69.9837073171,70.2945609756,70.501195122,70.6125853659,70.6432926829,70.6113170732,70.5327073171,70.4280243902,70.3173414634,70.2172195122,70.1442439024,70.1084390244,70.1053658537,70.1289756098,70.1782926829,70.2462926829,70.3234146341,70.3990731707,70.4662682927,70.5209512195,70.4085365854,70.6292682927,70.6890243902,70.4790243902,70.7509756098,70.7346341463,71.0212195122,71.0887804878,71.207804878,71.0263414634,70.9326829268,70.8829268293,71.7951219512,72.4487804878,72.3,72.2536585366,72.6536585366,72.7048780488,72.5512195122,72.9024390244,73.0512195122,73.4024390244,73.6048780488,73.6048780488,73.9585365854,73.9048780488,74.2048780488,74.2073170732,74.7048780488,74.9097560976
Slovenia,SVN,68.9780487805,68.9780487805,68.9780487805,68.6219512195,68.6634146341,68.3658536585,69.012195122,69.3658536585,68.9170731707,68.3609756098,68.6097560976,68.8341463415,69.0585365854,69.4048780488,70.1609756098,70.3585365854,70.3073170732,70.556097561,70.7024390244,70.8536585366,71.1048780488,71.2048780488,71.0536585366,70.5414634146,70.9024390244,71.3512195122,71.8024390244,72.0024390244,72.4463414634,72.7048780488,73.2048780488,73.3536585366,73.3048780488,73.2536585366,73.4048780488,73.9585365854,74.4585365854,74.7073170732,74.8073170732,75.0097560976,75.412195122,75.7585365854,76.0073170732,76.8585365854,77.2073170732,77.612195122,78.0865853659,78.5609756098,78.7658536585,78.9707317073
Solomon Islands,SLB,49.3817073171,49.8817073171,50.3817073171,50.8817073171,51.3817073171,51.8817073171,52.3817073171,52.8817073171,53.3817073171,53.8817073171,54.3877073171,54.9066829268,55.4386341463,55.977097561,56.5105609756,57.0305365854,57.5290243902,57.9895609756,58.3896585366,58.7073658537,58.8907317073,58.8833658537,58.6787560976,58.3013902439,57.7946829268,57.2450487805,56.7538536585,56.4109756098,56.2772926829,56.3777317073,56.7047560976,57.2138536585,57.8211219512,58.4545853659,59.0837317073,59.6959512195,60.2965853659,60.9086097561,61.5436341463,62.1908780488,62.8342439024,63.4531463415,64.0339268293,64.5672195122,65.0495365854,65.4876585366,65.8927317073,66.2837804878,66.6734634146,67.0671219512
Somalia,SOM,35.9853414634,36.3862195122,36.7866097561,37.1875121951,37.587902439,37.990804878,38.4017073171,38.8196097561,39.2405121951,39.6594146341,40.0603170732,40.4272195122,40.7501463415,41.0290731707,41.2695121951,41.4879512195,41.705902439,41.9443414634,42.2197804878,42.5387073171,42.9156341463,43.3615609756,43.8604878049,44.3784146341,44.8818780488,45.2923658537,45.5224146341,45.5355365854,45.3382195122,44.9679512195,44.5211707317,44.1238536585,43.8934634146,43.9059512195,44.1848536585,44.7121707317,45.4279268293,46.2216829268,46.9949756098,47.6993414634,48.2957804878,48.7663658537,49.1375365854,49.4362926829,49.6735853659,49.8668780488,50.038097561,50.2111707317,50.4051219512,50.630902439
South Africa,ZAF,49.0362926829,49.429804878,49.8132926829,50.1957560976,50.5817560976,50.9718292683,51.3630243902,51.7494146341,52.126,52.4932682927,52.8506829268,53.1966585366,53.5346341463,53.8720487805,54.215902439,54.579195122,54.9769512195,55.4147317073,55.8950731707,56.4135121951,56.9700243902,57.5596097561,58.1657560976,58.7679268293,59.3457073171,59.8850731707,60.3760243902,60.8071463415,61.1624878049,61.4186097561,61.5496097561,61.5315365854,61.3569268293,61.0248536585,60.5388292683,59.8874146341,59.0627073171,58.0911219512,57.0176097561,55.8925365854,54.7763170732,53.7273170732,52.7924146341,52.0134390244,51.4252439024,51.0596829268,50.9296585366,51.0036585366,51.2402195122,51.6113170732
South Sudan,SSD,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,61.512195122,
Spain,ESP,69.1092682927,69.4804878049,69.5190243902,69.6812195122,70.3997560976,70.8092682927,71.0551219512,71.2529268293,71.537804878,71.0575609756,72.0273170732,71.6302439024,72.8180487805,72.6107317073,72.9697560976,73.3187804878,73.6426829268,74.1319512195,74.2956097561,74.8187804878,75.3492682927,75.5285365854,76.1341463415,75.9090243902,76.2953658537,76.2595121951,76.5104878049,76.7280487805,76.7470731707,76.8136585366,76.8375609756,76.9712195122,77.41,77.5465853659,77.9014634146,77.9807317073,78.1204878049,78.6041463415,78.6658536585,78.7170731707,78.9658536585,79.3682926829,79.5682926829,79.6195121951,79.8707317073,80.1707317073,80.8219512195,80.8731707317,81.1756097561,81.4756097561
Sri Lanka,LKA,57.8603414634,58.2009756098,58.5498292683,58.9289268293,59.3502439024,59.823097561,60.3497804878,60.9135365854,61.501097561,62.1028536585,62.7087804878,63.3099512195,63.8984878049,64.4704146341,65.0226829268,65.5611463415,66.0986585366,66.6420731707,67.1882926829,67.7247804878,68.2219268293,68.6451219512,68.972,69.1948292683,69.319902439,69.3727317073,69.393804878,69.422,69.481902439,69.5780487805,69.6786829268,69.7313902439,69.6991219512,69.5779756098,69.3952682927,69.2288536585,69.1782439024,69.3162439024,69.6771463415,70.2517073171,70.9842926829,71.783804878,72.543902439,73.1815609756,73.6651463415,73.9893414634,74.1826341463,74.3120731707,74.4332682927,74.5666097561
St. Kitts and Nevis,KNA,,,,,,,,,,,,,,,,,,,,,,,63.9512195122,,,,,65.9512195122,,,,,67.9512195122,,,,,70.0363414634,,,,,71.3365853659,,,,,,,
St. Lucia,LCA,57.6486829268,58.1795121951,58.7473902439,59.3482682927,59.9751707317,60.616,61.2557317073,61.8823170732,62.4852439024,63.0605121951,63.6061463415,64.1272439024,64.6343658537,65.1370243902,65.6412439024,66.1578780488,66.7007560976,67.2688292683,67.8516585366,68.4338780488,68.9843902439,69.4666097561,69.8558536585,70.1427073171,70.3306097561,70.4397317073,70.5056097561,70.5652195122,70.6492195122,70.766,70.9086585366,71.4414634146,71.5780487805,71.6317073171,72.187804878,71.4341463415,71.5487804878,71.76,71.4536585366,71.3048780488,71.1056097561,73.9543902439,73.7073170732,73.7414634146,73.2429268293,72.7392682927,73.4165365854,73.7232195122,73.999195122,74.2380731707
St. Martin (French part),MAF,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
St. Vincent and the Grenadines,VCT,54.0289268293,54.878097561,55.7307317073,56.5523170732,57.315902439,57.9989512195,58.5920243902,59.1135853659,59.5846829268,60.0182926829,60.4384878049,60.8723170732,61.3367804878,61.843804878,62.3928536585,62.9752439024,63.570804878,64.1529512195,64.703097561,65.2117804878,65.6770243902,66.1064390244,66.512195122,66.9049756098,67.2868780488,67.6569756098,68.0143414634,68.3534146341,68.6697073171,68.9592195122,69.2184146341,69.4427317073,69.6311219512,69.7876341463,69.9158292683,70.0184146341,70.100195122,70.1682439024,70.2315853659,70.2980731707,70.3769512195,70.4773658537,70.6014390244,70.7479268293,70.9167073171,71.1057804878,71.3077804878,71.5154634146,71.721097561,71.9212682927
Sudan,SDN,41.5859268293,41.853902439,42.147902439,42.468902439,42.8159268293,43.1844634146,43.5700243902,43.9640731707,44.3611463415,44.7582195122,45.1552926829,45.5543902439,45.9584878049,46.3695853659,46.7866829268,47.2092682927,47.6353170732,48.0623170732,48.4857804878,48.900195122,49.2990487805,49.6753658537,50.0251463415,50.3514146341,50.6571707317,50.9499268293,51.240195122,51.5384390244,51.852195122,52.1844390244,52.5306585366,52.8822926829,53.2303658537,53.5743658537,53.9213658537,54.2909756098,54.7103414634,55.1925121951,55.7400243902,56.3422682927,56.974097561,57.6002682927,58.1875853659,58.7119268293,59.1647804878,59.5482439024,59.8764390244,60.1786097561,60.4779268293,60.7854634146
Suriname,SUR,59.6706341463,60.038,60.3999512195,60.7619512195,61.1274878049,61.4989512195,61.8726829268,62.242097561,62.6007073171,62.9465365854,63.2722682927,63.5756341463,63.8558292683,64.1153902439,64.358804878,64.5963414634,64.8382195122,65.0941707317,65.3650243902,65.6482926829,65.9350731707,66.2125853659,66.466097561,66.685902439,66.8701219512,67.0183414634,67.1371463415,67.237902439,67.3295121951,67.4158780488,67.4989268293,67.5770487805,67.6476585366,67.709195122,67.762097561,67.8058536585,67.8359756098,67.8555121951,67.8710487805,67.8926341463,67.9352926829,68.0176097561,68.1495853659,68.3342439024,68.5695609756,68.8470487805,69.1536829268,69.4684146341,69.7757073171,70.0670243902
Swaziland,SWZ,44.2387804878,44.5348780488,44.8194634146,45.1005609756,45.3886585366,45.7012439024,46.052804878,46.452804878,46.9052682927,47.4107073171,47.9616341463,48.547097561,49.1506341463,49.7592195122,50.3673902439,50.9770731707,51.595195122,52.230195122,52.8840731707,53.5508780488,54.226195122,54.9031707317,55.5703902439,56.2119268293,56.8127804878,57.3743902439,57.9046097561,58.3988292683,58.8319756098,59.1685365854,59.3440487805,59.2925853659,58.9767804878,58.3847317073,57.5235121951,56.3937317073,55.008,53.441804878,51.7945365854,50.1620731707,48.6702195122,47.4397560976,46.5279756098,45.9617317073,45.7469756098,45.860195122,46.2394878049,46.7695121951,47.3419268293,47.8888292683
Sweden,SWE,73.0056097561,73.4743902439,73.3504878049,73.5553658537,73.7331707317,73.8617073171,74.0785365854,74.1224390244,73.9729268293,74.0848780488,74.6492682927,74.623902439,74.7180487805,74.8673170732,74.9804878049,74.9846341463,74.9692682927,75.3797560976,75.4690243902,75.5241463415,75.7409756098,76.026097561,76.3273170732,76.5517073171,76.8158536585,76.667804878,76.9312195122,77.092195122,76.9792682927,77.7268292683,77.5368292683,77.6668292683,77.9987804878,78.0604878049,78.6502439024,78.7404878049,78.9590243902,79.1975609756,79.3390243902,79.4414634146,79.643902439,79.7951219512,79.8463414634,80.0951219512,80.4975609756,80.5463414634,80.7487804878,80.9,81.1,81.3512195122
Switzerland,CHE,71.3134146341,71.6448780488,71.196097561,71.1875609756,72.077804878,72.2017073171,72.3356097561,72.6365853659,72.5902439024,72.6126829268,73.0202439024,73.1307317073,73.6443902439,73.9409756098,74.2870731707,74.6656097561,74.7853658537,75.2380487805,75.1873170732,75.466097561,75.4592682927,75.6931707317,76.033902439,76.0312195122,76.6085365854,76.7336585366,76.8990243902,77.1975609756,77.2265853659,77.4212195122,77.2424390244,77.5146341463,77.806097561,78.0853658537,78.35,78.4170731707,78.896097561,79.0795121951,79.3243902439,79.5804878049,79.6804878049,80.1804878049,80.3853658537,80.5365853659,81.087804878,81.2365853659,81.4902439024,81.7414634146,81.9926829268,82.043902439
Syrian Arab Republic,SYR,52.7317317073,53.4194878049,54.115195122,54.8193414634,55.5324390244,56.2569756098,56.9949756098,57.7449756098,58.5025121951,59.2610487805,60.0121219512,60.7451463415,61.4536585366,62.1331219512,62.7805609756,63.3964878049,63.9849268293,64.5544390244,65.1125121951,65.6606829268,66.2019512195,66.7373414634,67.263804878,67.7803170732,68.2858780488,68.7804390244,69.265,69.7375365854,70.1965365854,70.6399512195,71.0647560976,71.4674146341,71.8469268293,72.2017804878,72.5319756098,72.8355365854,73.1129512195,73.3662682927,73.6000243902,73.8162195122,74.0188780488,74.2120243902,74.3976585366,74.5782682927,74.7548536585,74.9284146341,75.096902439,75.2587804878,75.4126097561,75.5603414634
Tajikistan,TJK,56.1694146341,56.5784878049,56.9900487805,57.4041219512,57.8167073171,58.2242926829,58.6234146341,59.0080487805,59.3757073171,59.7223902439,60.044097561,60.3388536585,60.6091463415,60.8569268293,61.085195122,61.2963170732,61.4952195122,61.6858292683,61.8711707317,62.0547560976,62.2442682927,62.4504146341,62.6693170732,62.8919756098,63.1067804878,63.279902439,63.3748780488,63.372902439,63.2733902439,63.0904146341,62.8568536585,62.6176341463,62.419804878,62.3032682927,62.2857073171,62.3746097561,62.5613170732,62.8129512195,63.1042682927,63.4207073171,63.7553414634,64.1048536585,64.469902439,64.8474878049,65.2295365854,65.6078536585,65.9736829268,66.3237804878,66.6559756098,66.9676829268
Tanzania,TZA,43.6538780488,43.9072926829,44.1622439024,44.4237073171,44.6977073171,44.9887317073,45.2972926829,45.6208536585,45.9594146341,46.3114634146,46.684,47.082,47.5044634146,47.9453902439,48.393804878,48.8352439024,49.2502439024,49.6273170732,49.9549756098,50.2287073171,50.4534390244,50.6406097561,50.8036829268,50.9506341463,51.0769756098,51.1667560976,51.1955609756,51.1489756098,51.0260731707,50.8364390244,50.5971463415,50.3292439024,50.0647073171,49.8359756098,49.6660243902,49.5737560976,49.5676341463,49.6445365854,49.8008536585,50.0409756098,50.3732926829,50.8047317073,51.3282682927,51.9353902439,52.6116097561,53.3469268293,54.1293658537,54.9425121951,55.7694390244,56.5897317073
Thailand,THA,55.299195122,55.8388292683,56.3500243902,56.8322926829,57.289195122,57.7241463415,58.1445365854,58.5582682927,58.9752439024,59.4010243902,59.8366585366,60.2802926829,60.7300731707,61.1890243902,61.665195122,62.1719756098,62.7232195122,63.3282926829,63.9911463415,64.7112682927,65.4977804878,66.3608536585,67.2846341463,68.2397073171,69.1920487805,70.0900487805,70.8770731707,71.5204146341,72.0009512195,72.3136341463,72.4709268293,72.4997804878,72.4528780488,72.3788536585,72.3063902439,72.2611707317,72.2539268293,72.2792926829,72.3302926829,72.4094634146,72.5152195122,72.6414390244,72.7769268293,72.9154634146,73.0529512195,73.1887804878,73.3254146341,73.465902439,73.6132682927,73.7680243902
Timor-Leste,TLS,33.7271219512,34.2275609756,34.7290487805,35.2315365854,35.7334878049,36.272902439,36.8947804878,37.5966097561,38.3358780488,39.0415121951,39.5288780488,39.5752439024,39.088097561,38.0825121951,36.6681463415,35.1138536585,33.7726097561,32.943195122,32.8137804878,33.4203414634,34.6581463415,36.2978292683,38.012902439,39.5505121951,40.8125121951,41.781902439,42.5282439024,43.2143414634,43.9674146341,44.8200487805,45.785804878,46.850195122,47.9631463415,49.0801219512,50.1846341463,51.2641707317,52.3147560976,53.3393902439,54.3345121951,55.2896585366,56.1902439024,57.0217804878,57.7802195122,58.4655365854,59.0822682927,59.6383414634,60.1463170732,60.6236585366,61.0859512195,61.5421707317
Togo,TGO,39.5561219512,40.1329268293,40.7076829268,41.2794146341,41.848097561,42.4177804878,42.9909756098,43.5687073171,44.1484634146,44.7257560976,45.2925609756,45.8383658537,46.357097561,46.8437804878,47.2973902439,47.7214146341,48.1203902439,48.5033414634,48.8797804878,49.2512195122,49.6226829268,49.9946829268,50.364195122,50.7277317073,51.0847804878,51.4338780488,51.7729512195,52.1015365854,52.4151463415,52.7132682927,52.9919756098,53.246804878,53.4782682927,53.6878780488,53.8771707317,54.050097561,54.2111707317,54.3658536585,54.5170731707,54.6672926829,54.8094878049,54.934097561,55.0386341463,55.1265609756,55.2083658537,55.304,55.4374390244,55.626195122,55.8803170732,56.202804878
Tonga,TON,61.3645365854,61.7327073171,62.0972926829,62.4587560976,62.8151463415,63.1679756098,63.5183170732,63.8672439024,64.2122682927,64.552902439,64.885097561,65.204804878,65.5079756098,65.7950487805,66.0660243902,66.3233902439,66.5711463415,66.8153658537,67.0585609756,67.3032682927,67.55,67.7997317073,68.0494878049,68.2952926829,68.5336585366,68.7596585366,68.965902439,69.1519268293,69.315195122,69.4576829268,69.5823170732,69.6930487805,69.7972195122,69.9007317073,70.0064634146,70.1192682927,70.2385121951,70.3636829268,70.4928536585,70.6250731707,70.7609268293,70.8990487805,71.0391219512,71.179804878,71.3202682927,71.4596585366,71.599097561,71.7380487805,71.8764878049,72.0138780488
Trinidad and Tobago,TTO,63.2135365854,63.7634146341,64.2196829268,64.5683902439,64.8120487805,64.9621219512,65.0429756098,65.0904878049,65.1375121951,65.2029756098,65.3004146341,65.4343902439,65.5954878049,65.7741463415,65.9692926829,66.178195122,66.3975609756,66.6232682927,66.8492439024,67.0715365854,67.2882926829,67.4997073171,67.7046097561,67.9037317073,68.0937560976,68.2733414634,68.4405121951,68.5936829268,68.7312439024,68.8501463415,68.9447804878,69.0125609756,69.0518536585,69.0621463415,69.0458780488,68.997097561,68.912902439,68.7973658537,68.6610487805,68.5199756098,68.3956097561,68.3143902439,68.2902195122,68.3330487805,68.4433170732,68.6135121951,68.8291219512,69.0661463415,69.3051463415,69.536097561
Tunisia,TUN,48.335804878,48.823804878,49.305804878,49.783804878,50.265804878,50.7588536585,51.273,51.8182682927,52.4015853659,53.0273658537,53.7004146341,54.4230243902,55.1885609756,55.988,56.8168536585,57.6712195122,58.550804878,59.4478292683,60.353,61.2514146341,62.1231707317,62.9487560976,63.7185609756,64.4295365854,65.0841463415,65.6948780488,66.2822195122,66.8676829268,67.4637560976,68.070902439,70.3073170732,70.5073170732,70.756097561,70.7536585366,70.9536585366,71.3536585366,71.5536585366,71.9024390244,72.0512195122,72.5,72.6,72.8487804878,73,73.0512195122,73.3024390244,73.5024390244,73.9,74.2024390244,74.3024390244,74.4512195122
Turkey,TUR,48.2708536585,48.3524390244,48.4239756098,48.4900243902,48.5616341463,48.6563170732,48.792097561,48.984902439,49.2452439024,49.5811219512,49.9940731707,50.482097561,51.0307317073,51.6254634146,52.2582926829,52.9227073171,53.6161707317,54.3351707317,55.0736829268,55.8211707317,56.5696097561,57.3119756098,58.0432682927,58.7590243902,59.454195122,60.1213658537,60.7555121951,61.3601707317,61.9408780488,62.5041463415,63.0604634146,63.6228292683,64.2007560976,64.8002195122,65.4236585366,66.073097561,66.7459756098,67.432804878,68.1190487805,68.7947317073,69.4468780488,70.064,70.6391463415,71.1683170732,71.6480487805,72.0778536585,72.4627317073,72.8106585366,73.1296341463,73.4246341463
Turkmenistan,TKM,54.443804878,54.855804878,55.271804878,55.689804878,56.105804878,56.517804878,56.919804878,57.305804878,57.673804878,58.019804878,58.337804878,58.624804878,58.883804878,59.118804878,59.337804878,59.550804878,59.7717804878,60.0072439024,60.2637073171,60.5411707317,60.836195122,61.1438536585,61.4511707317,61.7455853659,62.0150487805,62.2463902439,62.4244146341,62.5465121951,62.6201219512,62.6523170732,62.6627073171,62.6730487805,62.7055365854,62.7733658537,62.882097561,63.0307317073,63.2077560976,63.3954878049,63.5772439024,63.7454634146,63.8955121951,64.0257804878,64.1412439024,64.2479512195,64.3469268293,64.4383170732,64.5212195122,64.5983170732,64.6757073171,64.7599512195
Turks and Caicos Islands,TCA,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Tuvalu,TUV,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
Uganda,UGA,43.9785609756,44.5325365854,45.0845609756,45.6336585366,46.1803170732,46.7390243902,47.3297560976,47.9569756098,48.6076585366,49.2582926829,49.8633902439,50.3689756098,50.7375609756,50.9521463415,51.0112195122,50.9377804878,50.7717804878,50.5667073171,50.3685121951,50.1981707317,50.0716097561,49.9922195122,49.9355121951,49.8720243902,49.7853658537,49.6386341463,49.3904634146,49.028,48.553902439,47.9867560976,47.3567317073,46.7023658537,46.0791463415,45.5394878049,45.1223658537,44.8652926829,44.7917560976,44.890195122,45.1448780488,45.5481463415,46.0916829268,46.7667317073,47.5431219512,48.3852439024,49.2575121951,50.1239268293,50.9530731707,51.7296829268,52.4399756098,53.0705853659
Ukraine,UKR,69.895804878,70.2282195122,70.4919512195,70.6855609756,70.811097561,70.8651219512,70.8441219512,70.7536829268,70.6054146341,70.4114634146,70.1869512195,69.945,69.6997317073,69.4647073171,69.2560243902,69.0827560976,68.9518780488,68.8593414634,68.8046341463,68.789804878,68.8275121951,68.9320243902,69.0993658537,69.3138780488,69.5518292683,69.7732439024,69.9320731707,70.4951219512,70.4975609756,70.5390243902,70.1365853659,68.8780487805,68.8780487805,67.8780487805,67.8731707317,67.1170731707,67.3107317073,67.2953658537,67.9682926829,68.193902439,67.8634146341,68.2870731707,68.2756097561,68.2107317073,68.1853658537,67.9568292683,68.0775609756,68.222195122,68.2514634146,69.19
United Arab Emirates,ARE,51.6086829268,52.6601463415,53.7608292683,54.901195122,56.0662439024,57.2364146341,58.3916585366,59.5129268293,60.5826829268,61.5878780488,62.5194878049,63.373,64.1599512195,64.8883170732,65.5626341463,66.1853902439,66.7605853659,67.2912439024,67.7853658537,68.2474634146,68.6840487805,69.0996097561,69.4961463415,69.8756829268,70.241195122,70.5941707317,70.9336341463,71.2575365854,71.566902439,71.8612439024,72.1435365854,72.4153170732,72.6785853659,72.9353414634,73.187097561,73.4348536585,73.680097561,73.9208292683,74.1570487805,74.3887317073,74.615902439,74.8370731707,75.0522195122,75.2608780488,75.4639756098,75.6604634146,75.851804878,76.0384390244,76.2213414634,76.3995609756
United Kingdom,GBR,71.1268292683,70.8780487805,70.9268292683,70.8268292683,71.6243902439,71.6243902439,71.5731707317,72.1243902439,71.7243902439,71.7219512195,71.9731707317,72.2731707317,72.1243902439,72.3243902439,72.5243902439,72.7243902439,72.7756097561,73.2243902439,73.1756097561,73.2756097561,73.6756097561,74.0268292683,74.1780487805,74.3780487805,74.7780487805,74.6292682927,74.9292682927,75.2804878049,75.3804878049,75.5829268293,75.8804878049,76.0829268293,76.4341463415,76.3853658537,76.8853658537,76.8365853659,77.087804878,77.2109756098,77.1902439024,77.3902439024,77.7414634146,77.9926829268,78.143902439,78.4463414634,78.7463414634,79.0487804878,79.2487804878,79.4487804878,79.6,80.0512195122
United States,USA,69.7707317073,70.2707317073,70.1195121951,69.9170731707,70.1658536585,70.2146341463,70.212195122,70.5609756098,69.9512195122,70.5073170732,70.8073170732,71.1073170732,71.156097561,71.356097561,71.956097561,72.6048780488,72.856097561,73.256097561,73.356097561,73.8048780488,73.6585365854,74.0073170732,74.3609756098,74.4634146341,74.5634146341,74.5634146341,74.6146341463,74.7658536585,74.7658536585,75.0170731707,75.2146341463,75.3658536585,75.642195122,75.4195121951,75.5743902439,75.6219512195,75.9965853659,76.4292682927,76.5804878049,76.5829268293,76.6365853659,76.7365853659,76.8365853659,76.987804878,77.3390243902,77.3390243902,77.587804878,77.8390243902,77.9390243902,78.0902439024
Uruguay,URY,67.811,68.0239756098,68.205902439,68.3477560976,68.449,68.511195122,68.5403170732,68.5494146341,68.5540243902,68.5641463415,68.5887317073,68.6342682927,68.7037073171,68.7970487805,68.9193170732,69.0725609756,69.2608292683,69.4781463415,69.7190731707,69.978097561,70.2482195122,70.521902439,70.7925853659,71.0552439024,71.304804878,71.5367560976,71.7494878049,71.9460487805,72.1319756098,72.309804878,72.4846829268,72.6637073171,72.85,73.047097561,73.2565365854,73.4762682927,73.5280487805,73.6634146341,73.9541463415,74.153902439,74.8868292683,74.872195122,74.8363414634,74.8768292683,75.2163414634,75.6092682927,75.7297560976,75.8551219512,75.9807317073,76.1112195122
Uzbekistan,UZB,58.8901463415,59.3021463415,59.7176585366,60.1351707317,60.5511707317,60.962195122,61.3627317073,61.7482439024,62.1147804878,62.459804878,62.7768292683,63.0628536585,63.3208780488,63.554902439,63.7724390244,63.9844390244,64.2033902439,64.4377804878,64.6931463415,64.9690243902,65.2665121951,65.5867317073,65.9157560976,66.2370731707,66.5341463415,66.7763902439,66.9336341463,66.9942682927,66.9611707317,66.8472926829,66.6821219512,66.5067317073,66.3602195122,66.2741707317,66.2601219512,66.3176097561,66.4326341463,66.574195122,66.7147560976,66.8443170732,66.9508780488,67.0289268293,67.0859756098,67.131,67.1720487805,67.2225853659,67.2981707317,67.4112926829,67.5669756098,67.7647073171
Vanuatu,VUT,46.4874878049,47.088097561,47.688195122,48.2872926829,48.8868292683,49.4847804878,50.0831219512,50.6818292683,51.2809268293,51.879902439,52.479804878,53.0796341463,53.6794390244,54.2792682927,54.8786097561,55.4799756098,56.0883170732,56.703097561,57.3223658537,57.939195122,58.5427073171,59.1205609756,59.6648780488,60.1721219512,60.6422682927,61.082195122,61.5022195122,61.9146341463,62.3317560976,62.7580243902,63.1968536585,63.6477804878,64.1034146341,64.5593414634,65.0121463415,65.4593414634,65.8994878049,66.330097561,66.751195122,67.1598292683,67.555,67.9357073171,68.3014634146,68.6542439024,68.9935609756,69.320902439,69.6377804878,69.9446585366,70.2435853659,70.5350243902
"Venezuela, RB",VEN,58.5186829268,59.0864390244,59.6514634146,60.2112439024,60.7652926829,61.3086585366,61.8398780488,62.3565121951,62.8601463415,63.3513414634,63.8346585366,64.3171463415,64.801804878,65.2896341463,65.7766341463,66.2543170732,66.7116341463,67.1395609756,67.5330731707,67.892195122,68.2224878049,68.535,68.8403170732,69.1463902439,69.4542195122,69.7622195122,70.0633170732,70.3483902439,70.6123658537,70.850195122,71.0623658537,71.2493658537,71.4157560976,71.7695121951,72.1231707317,72.1695121951,72.3795121951,72.5695121951,72.7292682927,72.8641463415,73.2695121951,73.4292682927,73.6292682927,72.7829268293,72.977804878,73.1726829268,73.3675609756,73.5624390244,73.7575609756,73.9424390244
Vietnam,VNM,44.162097561,44.6906341463,45.2356829268,45.7892439024,46.3357804878,46.830804878,47.220804878,47.4837560976,47.6256829268,47.6755853659,47.6914634146,47.7492682927,47.9240487805,48.2728780488,48.8243902439,49.599804878,50.5958780488,51.7577073171,53.0233170732,54.3471707317,55.6710731707,56.9382926829,58.1200243902,59.2005365854,60.1716829268,61.054902439,61.8932439024,62.7363170732,63.6157560976,64.536097561,65.4783658537,66.411097561,67.2927560976,68.0933414634,68.8048292683,69.4316829268,69.9898536585,70.5063170732,71.0015609756,71.4826097561,71.9455121951,72.3813170732,72.777097561,73.125902439,73.4317804878,73.6997317073,73.9407560976,74.1653414634,74.3854634146,74.6055853659
Virgin Islands (U.S.),VIR,63.7302195122,64.1015609756,64.4625609756,64.8287560976,65.2101219512,65.6116097561,66.0325853659,66.4624634146,66.8927073171,67.320804878,67.7448292683,68.1648780488,68.5805609756,68.9904878049,69.3911707317,69.7781707317,70.1449512195,70.4909268293,70.8165365854,71.1251707317,71.425195122,71.7264634146,72.0364634146,72.3616341463,72.7020487805,73.0557317073,73.4168292683,73.7759512195,74.1262926829,74.4644390244,74.788,75.0990243902,75.4005121951,75.694902439,75.982195122,76.262902439,76.5365609756,76.8025609756,77.0592926829,77.3061707317,77.5756585366,77.8451463415,78.1146341463,78.2513821138,78.3881300813,78.5248780488,78.6597560976,78.7943902439,78.9447804878,79.0698292683
West Bank and Gaza,PSE,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,68.0477317073,68.3919756098,68.7226829268,69.0443658537,69.3604878049,69.6675609756,69.9606097561,70.2336097561,70.482097561,70.7060487805,70.9079512195,71.0903170732,71.2606341463,71.4238780488,71.5855853659,71.7492682927,71.9189268293,72.0935853659,72.2727560976,72.4569512195
"Yemen, Rep.",YEM,37.7865609756,38.0583658537,38.3271707317,38.5944634146,38.8607560976,39.1160487805,39.3488292683,39.5601219512,39.764902439,39.983195122,40.2549756098,40.6207317073,41.1089756098,41.736195122,42.503902439,43.4045853659,44.4197804878,45.508,46.6262195122,47.7434878049,48.8352682927,49.8860731707,50.8928780488,51.846195122,52.731,53.5273170732,54.2196341463,54.8104634146,55.3092926829,55.7256585366,56.0690243902,56.353902439,56.6032926829,56.8416585366,57.0915365854,57.378902439,57.7237804878,58.1306829268,58.5965853659,59.1194878049,59.6898536585,60.2931463415,60.9068536585,61.5119512195,62.0954390244,62.6493170732,63.1706097561,63.6653414634,64.1395609756,64.5937560976
Zambia,ZMB,45.109804878,45.4875121951,45.8531707317,46.2082439024,46.557195122,46.9105365854,47.2827560976,47.6809268293,48.1055365854,48.5531463415,49.0147317073,49.4778292683,49.9254146341,50.3410243902,50.7141707317,51.0413658537,51.3256341463,51.57,51.7729268293,51.9259512195,52.0180243902,52.0375853659,51.9751463415,51.820195122,51.564804878,51.1885365854,50.6705121951,50.0168292683,49.2465121951,48.3896097561,47.4806341463,46.560097561,45.6693902439,44.8484146341,44.1265609756,43.5152682927,43.0084878049,42.5896097561,42.2550731707,42.0212195122,41.9298780488,42.0308292683,42.3425365854,42.8585609756,43.5549512195,44.3843658537,45.2885121951,46.1976341463,47.0524390244,47.8145365854
Zimbabwe,ZWE,51.5424634146,51.9149512195,52.277902439,52.6293170732,52.9716585366,53.3039512195,53.6277073171,53.9454390244,54.2611707317,54.578902439,54.9026585366,55.2354146341,55.579195122,55.9379756098,56.3142682927,56.7170243902,57.1557317073,57.6293902439,58.13,58.6460487805,59.1740487805,59.7104878049,60.2358780488,60.7227804878,61.1367804878,61.4474146341,61.6287073171,61.6577560976,61.5086341463,61.1514634146,60.5289268293,59.5817073171,58.3153414634,56.770804878,55.0080243902,53.0983902439,51.1242682927,49.188902439,47.3995609756,45.8474878049,44.6179756098,43.7684390244,43.2847804878,43.1434878049,43.3369756098,43.8615853659,44.7017804878,45.7970731707,47.0706097561,48.4504878049
task :default => :run
# Serving files via Rack
desc "Serve the files via Rack and Thin"
task :run => [:dependencies] do
port = ENV['PORT'] || 8000
puts "Launching local webserver at <http://localhost:#{port}> ...", "-"*80
begin
Thin::Logging.silent = true
Thin::Server.start port, lambda { |env|
if env['PATH_INFO'] == '/'
[200, {'Content-Type' => 'text/html'}, File.new('index.html')]
else
Rack::Directory.new('.').(env)
end
}
rescue Exception => e
if e.message =~ /no acceptor/
puts "[!] Port #{port} not available, trying next one...", ""
port += 1
puts "Launching local webserver at <http://localhost:#{port}> ...", "-"*80
retry
end
raise
end
end
task :dependencies do
%w| rack thin |.each do |lib|
begin
require lib
rescue LoadError
puts "[!] Required gem '#{lib}' not found, please install it with:", "",
" $ gem install #{lib}", "",
"-"*80
raise
end
end
end
# Stepping through the tutorial
begin
require 'term/ansicolor'
class String
include Term::ANSIColor
end
rescue LoadError
class String
def black; self; end
def on_green; self; end
def on_yellow; self; end
end
end
_ = '-'*80
desc "List the steps of this tutorial"
task :steps do
puts _, "Steps of this tutorial", _
current = GitSteps.current_step
GitSteps.steps.each_with_index do |step, i|
is_current = step.sha == current.sha ? "*" : " "
puts "#{is_current} #{(i+1).to_s.rjust(3).bold} | #{step.subject.gsub(/^\[\d+\] /, '')}"
end; puts
end
desc "Display current step"
task :step => [:check] do
step = GitSteps.current_step
puts _, "#{step.sha} | #{step.subject.bold}",
_, "#{step.body}"
end
desc "Start the tutorial or switch back to first step"
task :start => [:check] do
puts _, "Starting the tutorial with the first step".white.on_magenta, _
step = GitSteps.steps.first
puts "#{step.sha} | #{step.subject.bold}",
"#{step.body}"
exec "git checkout #{step.sha} > /dev/null 2>&1 "
end
desc "Step to the next step of tutorial"
task :next => [:check] do
if step = GitSteps.next_step
puts _, "#{step.sha} | #{step.subject.bold}",
_, "#{step.body}"
exec "git checkout #{step.sha} > /dev/null 2>&1 "
else
puts "You have reached the end of the tutorial".white.on_green,
"Start again with: rake start"
end
end
desc "Step to the previous step of tutorial"
task :previous => [:check] do
if step = GitSteps.previous_step
puts _, "#{step.sha} | #{step.subject.bold}",
_, "#{step.body}"
exec "git checkout #{step.sha} > /dev/null 2>&1 "
else
puts "You are at the beginning of the tutorial".white.on_green,
"Follow the tutorial with: rake next"
end
end
desc "Show differences between the current step and the previous step"
task :diff do
current = GitSteps.current_step
previous = GitSteps.previous_step
(puts "[!] Cannot find previous step".white.on_red; exit(1)) unless previous
puts _, "Previous : #{previous.subject}",
"Current : #{current.subject}", _
exec "git diff --color --ignore-all-space --minimal HEAD^ HEAD | cat"
end
desc "Reset the tutorial and switch to master branch"
task :reset => [:check] do
exec "git checkout master > /dev/null"
end
task :check do
if `which git` == ''
puts "[!] ERROR: You need Git installed to step through the tutorial.".white.on_red
exit(1)
end
end
module GitSteps
class Commit
attr_reader :sha, :subject, :body
def initialize(commit)
@sha, @subject = commit.split('|||', 2)
@body = %x[git log -n 1 --format='%b' #{sha}].chomp
end
def step?; subject =~ /^\[\d+\]/; end
end
def steps
%x[git log --reverse --format='%h|||%s' master]
.chomp
.split("\n")
.map { |commit| Commit.new(commit) }
.select { |commit| commit.step? }
end
def current_step
Commit.new( %x[git log -n 1--reverse --format='%h|||%s'].chomp )
end
def next_step
steps.select { |step| step.subject > current_step.subject }.first
end
def previous_step
steps.select { |step| step.subject < current_step.subject }.last
end
extend self
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment