diff --git a/awx/ui/static/js/app.js b/awx/ui/static/js/app.js index 2068fd544a..13bec9fed3 100644 --- a/awx/ui/static/js/app.js +++ b/awx/ui/static/js/app.js @@ -585,10 +585,6 @@ var tower = angular.module('Tower', [ $log.debug('Job summary_complete ' + data.unified_job_id); $rootScope.$emit('JobSummaryComplete', data); }); - sock.on("schedule_change", function(data) { - $log.debug('schedule changed to ' + data.status); - $rootScope.$emit('ScheduleChange', data); - }); } openSocket(); diff --git a/awx/ui/static/js/controllers/Home.js b/awx/ui/static/js/controllers/Home.js index 4b74d4cd3f..20b4796733 100644 --- a/awx/ui/static/js/controllers/Home.js +++ b/awx/ui/static/js/controllers/Home.js @@ -94,6 +94,16 @@ export function Home($scope, $compile, $routeParams, $rootScope, $location, $log $scope.graphData = graphData; + var cleanupJobListener = + $rootScope.$on('DataReceived:JobStatusGraph', function(e, data) { + $scope.graphData.jobStatus = data; + }); + + $scope.$on('$destroy', function() { + cleanupJobListener(); + }); + + DashboardJobs({ scope: $scope, target: 'dash-jobs-list', diff --git a/awx/ui/static/js/directives/host-count-graph.js b/awx/ui/static/js/directives/host-count-graph.js index a9ea758e04..b9041fd53a 100644 --- a/awx/ui/static/js/directives/host-count-graph.js +++ b/awx/ui/static/js/directives/host-count-graph.js @@ -82,7 +82,7 @@ function HostCountGraph(adjustGraphSize, $window) { .margin({top: 15, right: 75, bottom: 40, left: 85}) .x(function(d,i) { return i ;}) .useInteractiveGuideline(true) //We want nice looking tooltips and a guideline! - .transitionDuration(350) //how fast do you want the lines to transition? + .duration(350) //how fast do you want the lines to transition? .showLegend(true) //Show the legend, allowing users to turn on/off line series. .showYAxis(true) //Show the y-axis .showXAxis(true) //Show the x-axis diff --git a/awx/ui/static/js/directives/host-status-graph.js b/awx/ui/static/js/directives/host-status-graph.js index b94e392f0e..9bc7136128 100644 --- a/awx/ui/static/js/directives/host-status-graph.js +++ b/awx/ui/static/js/directives/host-status-graph.js @@ -58,28 +58,28 @@ function HostStatusGraph($compile, $window) { ]; host_pie_chart = nv.models.pieChart() - .margin({top: 5, right: 75, bottom: 25, left: 85}) - .x(function(d) { return d.label; }) - .y(function(d) { return d.value; }) - .showLabels(true) - .labelThreshold(0.01) - .tooltipContent(function(x, y) { - return ''+x+''+ '

' + Math.floor(y.replace(',','')) + ' Hosts ' + '

'; - }) - .color(['#00aa00', '#aa0000']); - - host_pie_chart.pie.pieLabelsOutside(true).labelType("percent"); + .margin({top: 5, right: 75, bottom: 25, left: 85}) + .x(function(d) { return d.label; }) + .y(function(d) { return d.value; }) + .showLabels(true) + .growOnHover(false) + .labelThreshold(0.01) + .tooltipContent(function(x, y) { + return ''+x+''+ '

' + Math.floor(y.replace(',','')) + ' Hosts ' + '

'; + }) + .labelType("percent") + .color(['#00aa00', '#aa0000']); d3.select(element.find('svg')[0]) - .datum(data) - .transition().duration(350) - .call(host_pie_chart) - .style({ - "font-family": 'Open Sans', - "font-style": "normal", - "font-weight":400, - "src": "url(/static/fonts/OpenSans-Regular.ttf)" - }); + .datum(data) + .transition().duration(350) + .call(host_pie_chart) + .style({ + "font-family": 'Open Sans', + "font-style": "normal", + "font-weight":400, + "src": "url(/static/fonts/OpenSans-Regular.ttf)" + }); adjustGraphSize(); return host_pie_chart; diff --git a/awx/ui/static/js/directives/job-status-graph.js b/awx/ui/static/js/directives/job-status-graph.js index 97010587d6..7b54e1e8e0 100644 --- a/awx/ui/static/js/directives/job-status-graph.js +++ b/awx/ui/static/js/directives/job-status-graph.js @@ -9,9 +9,12 @@ export default JobStatusGraph ]; -function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustGraphSize) { +function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustGraphSize, graphDataService) { return { restrict: 'E', + scope: { + data: '=' + }, templateUrl: '/static/partials/job_status_graph.html', link: link }; @@ -22,13 +25,22 @@ function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustG scope.period="month"; scope.jobType="all"; - scope.$watch(attr.data, function(value) { + scope.$watch('data', function(value) { if (value) { - createGraph(value, scope.period, scope.jobType); + createGraph(scope.period, scope.jobType, value); } - }); + }, true); - function createGraph(data, period, jobtype){ + function recreateGraph(period, jobType) { + graphDataService.get(period, jobType) + .then(function(data) { + scope.data = data; + scope.period = period; + scope.jobType = jobType; + }); + } + + function createGraph(period, jobtype, data){ scope.period = period; scope.jobType = jobtype; @@ -96,7 +108,7 @@ function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustG period = this.getAttribute("id"); $('#period-dropdown').replaceWith(""+this.text+"\n"); - createGraph(data, period, job_type); + recreateGraph(period, job_type); }); //On click, update with new data @@ -105,7 +117,7 @@ function JobStatusGraph($rootScope, $compile , $location, $window, Wait, adjustG job_type = this.getAttribute("id"); $('#type-dropdown').replaceWith(""+this.text+"\n"); - createGraph(data, period, job_type); + recreateGraph(period, job_type); }); adjustGraphSize(job_status_chart, element); diff --git a/awx/ui/static/js/widgets/DashboardJobs.js b/awx/ui/static/js/widgets/DashboardJobs.js index b3db9e1c45..ac6621a0e9 100644 --- a/awx/ui/static/js/widgets/DashboardJobs.js +++ b/awx/ui/static/js/widgets/DashboardJobs.js @@ -48,6 +48,10 @@ angular.module('DashboardJobsWidget', ['RestServices', 'Utilities']) e.html(html); $compile(e)(scope); + $rootScope.$on('JobStatusChange', function() { + jobs_scope.refreshJobs(); + }); + if (scope.removeListLoaded) { scope.removeListLoaded(); } diff --git a/awx/ui/static/lib/d3/.bower.json b/awx/ui/static/lib/d3/.bower.json index f7a98ba00b..e817cf278c 100644 --- a/awx/ui/static/lib/d3/.bower.json +++ b/awx/ui/static/lib/d3/.bower.json @@ -1,6 +1,6 @@ { "name": "d3", - "version": "3.5.3", + "version": "3.3.13", "main": "d3.js", "scripts": [ "d3.js" @@ -10,12 +10,11 @@ ".git", ".gitignore", ".npmignore", - ".spmignore", ".travis.yml", "Makefile", "bin", "component.json", - "composer.json", + "index-browserify.js", "index.js", "lib", "node_modules", @@ -24,13 +23,13 @@ "test" ], "homepage": "https://github.com/mbostock/d3", - "_release": "3.5.3", + "_release": "3.3.13", "_resolution": { "type": "version", - "tag": "v3.5.3", - "commit": "ac59002a6229317a684743f26c3b4b55fc25b569" + "tag": "v3.3.13", + "commit": "fe09f453a8e1c93891cde2d1067b7334ab692f9c" }, "_source": "git://github.com/mbostock/d3.git", - "_target": "*", + "_target": "~3.3.13", "_originalSource": "d3" } \ No newline at end of file diff --git a/awx/ui/static/lib/d3/LICENSE b/awx/ui/static/lib/d3/LICENSE index 83013469b9..0bc47f33ef 100644 --- a/awx/ui/static/lib/d3/LICENSE +++ b/awx/ui/static/lib/d3/LICENSE @@ -1,4 +1,4 @@ -Copyright (c) 2010-2014, Michael Bostock +Copyright (c) 2013, Michael Bostock All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/awx/ui/static/lib/d3/bower.json b/awx/ui/static/lib/d3/bower.json index f07197e3d0..ab206b42b1 100644 --- a/awx/ui/static/lib/d3/bower.json +++ b/awx/ui/static/lib/d3/bower.json @@ -1,6 +1,6 @@ { "name": "d3", - "version": "3.5.3", + "version": "3.3.13", "main": "d3.js", "scripts": [ "d3.js" @@ -10,12 +10,11 @@ ".git", ".gitignore", ".npmignore", - ".spmignore", ".travis.yml", "Makefile", "bin", "component.json", - "composer.json", + "index-browserify.js", "index.js", "lib", "node_modules", diff --git a/awx/ui/static/lib/d3/d3.js b/awx/ui/static/lib/d3/d3.js index 81e459fe9c..16087fd1af 100644 --- a/awx/ui/static/lib/d3/d3.js +++ b/awx/ui/static/lib/d3/d3.js @@ -1,6 +1,6 @@ -!function() { +d3 = function() { var d3 = { - version: "3.5.3" + version: "3.3.13" }; if (!Date.now) Date.now = function() { return +new Date(); @@ -32,26 +32,19 @@ d3_style_setProperty.call(this, name, value + "", priority); }; } - d3.ascending = d3_ascending; - function d3_ascending(a, b) { + 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.min = function(array, f) { var i = -1, n = array.length, a, b; if (arguments.length === 1) { - while (++i < n) if ((b = array[i]) != null && b >= b) { - a = b; - break; - } + 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) if ((b = f.call(array, array[i], i)) != null && b >= b) { - a = b; - break; - } + 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; @@ -59,16 +52,10 @@ d3.max = function(array, f) { var i = -1, n = array.length, a, b; if (arguments.length === 1) { - while (++i < n) if ((b = array[i]) != null && b >= b) { - a = b; - break; - } + 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) if ((b = f.call(array, array[i], i)) != null && b >= b) { - a = b; - break; - } + 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; @@ -76,19 +63,13 @@ d3.extent = function(array, f) { var i = -1, n = array.length, a, b, c; if (arguments.length === 1) { - while (++i < n) if ((b = array[i]) != null && b >= b) { - a = c = b; - break; - } + 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) if ((b = f.call(array, array[i], i)) != null && b >= b) { - a = c = b; - break; - } + 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; @@ -96,76 +77,44 @@ } return [ a, c ]; }; - function d3_number(x) { - return x === null ? NaN : +x; - } - function d3_numeric(x) { - return !isNaN(x); - } d3.sum = function(array, f) { var s = 0, n = array.length, a, i = -1; if (arguments.length === 1) { - while (++i < n) if (d3_numeric(a = +array[i])) s += a; + while (++i < n) if (!isNaN(a = +array[i])) s += a; } else { - while (++i < n) if (d3_numeric(a = +f.call(array, array[i], i))) s += a; + while (++i < n) if (!isNaN(a = +f.call(array, array[i], i))) s += a; } return s; }; + function d3_number(x) { + return x != null && !isNaN(x); + } d3.mean = function(array, f) { - var s = 0, n = array.length, a, i = -1, j = n; + var n = array.length, a, m = 0, i = -1, j = 0; if (arguments.length === 1) { - while (++i < n) if (d3_numeric(a = d3_number(array[i]))) s += a; else --j; + while (++i < n) if (d3_number(a = array[i])) m += (a - m) / ++j; } else { - while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) s += a; else --j; + while (++i < n) if (d3_number(a = f.call(array, array[i], i))) m += (a - m) / ++j; } - if (j) return s / j; + return j ? m : undefined; }; 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.median = function(array, f) { - var numbers = [], n = array.length, a, i = -1; - if (arguments.length === 1) { - while (++i < n) if (d3_numeric(a = d3_number(array[i]))) numbers.push(a); - } else { - while (++i < n) if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) numbers.push(a); - } - if (numbers.length) return d3.quantile(numbers.sort(d3_ascending), .5); + 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.variance = function(array, f) { - var n = array.length, m = 0, a, d, s = 0, i = -1, j = 0; - if (arguments.length === 1) { - while (++i < n) { - if (d3_numeric(a = d3_number(array[i]))) { - d = a - m; - m += d / ++j; - s += d * (a - m); - } - } - } else { - while (++i < n) { - if (d3_numeric(a = d3_number(f.call(array, array[i], i)))) { - d = a - m; - m += d / ++j; - s += d * (a - m); - } - } - } - if (j > 1) return s / (j - 1); - }; - d3.deviation = function() { - var v = d3.variance.apply(this, arguments); - return v ? Math.sqrt(v) : v; - }; - function d3_bisector(compare) { + 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 (compare(a[mid], x) < 0) lo = mid + 1; else hi = mid; + if (f.call(a, a[mid], mid) < x) lo = mid + 1; else hi = mid; } return lo; }, @@ -174,29 +123,22 @@ if (arguments.length < 4) hi = a.length; while (lo < hi) { var mid = lo + hi >>> 1; - if (compare(a[mid], x) > 0) hi = mid; else lo = mid + 1; + if (x < f.call(a, a[mid], mid)) hi = mid; else lo = mid + 1; } return lo; } }; - } - var d3_bisect = d3_bisector(d3_ascending); - d3.bisectLeft = d3_bisect.left; - d3.bisect = d3.bisectRight = d3_bisect.right; - d3.bisector = function(f) { - return d3_bisector(f.length === 1 ? function(d, x) { - return d3_ascending(f(d), x); - } : f); }; - d3.shuffle = function(array, i0, i1) { - if ((m = arguments.length) < 3) { - i1 = array.length; - if (m < 2) i0 = 0; - } - var m = i1 - i0, t, i; + var d3_bisector = d3.bisector(function(d) { + return d; + }); + d3.bisectLeft = d3_bisector.left; + d3.bisect = d3.bisectRight = d3_bisector.right; + d3.shuffle = function(array) { + var m = array.length, t, i; while (m) { i = Math.random() * m-- | 0; - t = array[m + i0], array[m + i0] = array[i + i0], array[i + i0] = t; + t = array[m], array[m] = array[i], array[i] = t; } return array; }; @@ -277,86 +219,72 @@ return k; } function d3_class(ctor, properties) { - for (var key in properties) { - Object.defineProperty(ctor.prototype, key, { - value: properties[key], - enumerable: false - }); + try { + for (var key in properties) { + Object.defineProperty(ctor.prototype, key, { + value: properties[key], + enumerable: false + }); + } + } catch (e) { + ctor.prototype = properties; } } - d3.map = function(object, f) { + d3.map = function(object) { var map = new d3_Map(); - if (object instanceof d3_Map) { - object.forEach(function(key, value) { - map.set(key, value); - }); - } else if (Array.isArray(object)) { - var i = -1, n = object.length, o; - if (arguments.length === 1) while (++i < n) map.set(i, object[i]); else while (++i < n) map.set(f.call(object, o = object[i], i), o); - } else { - for (var key in object) map.set(key, object[key]); - } + if (object instanceof d3_Map) object.forEach(function(key, value) { + map.set(key, value); + }); else for (var key in object) map.set(key, object[key]); return map; }; - function d3_Map() { - this._ = Object.create(null); - } - var d3_map_proto = "__proto__", d3_map_zero = "\x00"; + function d3_Map() {} d3_class(d3_Map, { - has: d3_map_has, + has: function(key) { + return d3_map_prefix + key in this; + }, get: function(key) { - return this._[d3_map_escape(key)]; + return this[d3_map_prefix + key]; }, set: function(key, value) { - return this._[d3_map_escape(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; }, - remove: d3_map_remove, - keys: d3_map_keys, values: function() { var values = []; - for (var key in this._) values.push(this._[key]); + this.forEach(function(key, value) { + values.push(value); + }); return values; }, entries: function() { var entries = []; - for (var key in this._) entries.push({ - key: d3_map_unescape(key), - value: this._[key] + this.forEach(function(key, value) { + entries.push({ + key: key, + value: value + }); }); return entries; }, - size: d3_map_size, - empty: d3_map_empty, forEach: function(f) { - for (var key in this._) f.call(this, d3_map_unescape(key), this._[key]); + for (var key in this) { + if (key.charCodeAt(0) === d3_map_prefixCode) { + f.call(this, key.substring(1), this[key]); + } + } } }); - function d3_map_escape(key) { - return (key += "") === d3_map_proto || key[0] === d3_map_zero ? d3_map_zero + key : key; - } - function d3_map_unescape(key) { - return (key += "")[0] === d3_map_zero ? key.slice(1) : key; - } - function d3_map_has(key) { - return d3_map_escape(key) in this._; - } - function d3_map_remove(key) { - return (key = d3_map_escape(key)) in this._ && delete this._[key]; - } - function d3_map_keys() { - var keys = []; - for (var key in this._) keys.push(d3_map_unescape(key)); - return keys; - } - function d3_map_size() { - var size = 0; - for (var key in this._) ++size; - return size; - } - function d3_map_empty() { - for (var key in this._) return false; - return true; - } + var d3_map_prefix = "\x00", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); d3.nest = function() { var nest = {}, keys = [], sortKeys = [], sortValues, rollup; function map(mapType, array, depth) { @@ -425,21 +353,32 @@ if (array) for (var i = 0, n = array.length; i < n; ++i) set.add(array[i]); return set; }; - function d3_Set() { - this._ = Object.create(null); - } + function d3_Set() {} d3_class(d3_Set, { - has: d3_map_has, - add: function(key) { - this._[d3_map_escape(key += "")] = true; - return key; + has: function(value) { + return d3_map_prefix + value in this; + }, + add: function(value) { + this[d3_map_prefix + value] = true; + return value; + }, + remove: function(value) { + value = d3_map_prefix + value; + return value in this && delete this[value]; + }, + values: function() { + var values = []; + this.forEach(function(value) { + values.push(value); + }); + return values; }, - remove: d3_map_remove, - values: d3_map_keys, - size: d3_map_size, - empty: d3_map_empty, forEach: function(f) { - for (var key in this._) f.call(this, d3_map_unescape(key)); + for (var value in this) { + if (value.charCodeAt(0) === d3_map_prefixCode) { + f.call(this, value.substring(1)); + } + } } }); d3.behavior = {}; @@ -456,7 +395,7 @@ } function d3_vendorSymbol(object, name) { if (name in object) return name; - name = name.charAt(0).toUpperCase() + name.slice(1); + name = name.charAt(0).toUpperCase() + name.substring(1); for (var i = 0, n = d3_vendorPrefixes.length; i < n; ++i) { var prefixName = d3_vendorPrefixes[i] + name; if (prefixName in object) return prefixName; @@ -473,8 +412,8 @@ d3_dispatch.prototype.on = function(type, listener) { var i = type.indexOf("."), name = ""; if (i >= 0) { - name = type.slice(i + 1); - type = type.slice(0, i); + name = type.substring(i + 1); + type = type.substring(0, i); } if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); if (arguments.length === 2) { @@ -549,14 +488,16 @@ return n.querySelector(s); }, d3_selectAll = function(s, n) { return n.querySelectorAll(s); - }, d3_selectMatcher = d3_documentElement.matches || d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) { + }, d3_selectMatcher = d3_documentElement[d3_vendorSymbol(d3_documentElement, "matchesSelector")], d3_selectMatches = function(n, s) { return d3_selectMatcher.call(n, s); }; if (typeof Sizzle === "function") { d3_select = function(s, n) { return Sizzle(s, n)[0] || null; }; - d3_selectAll = Sizzle; + d3_selectAll = function(s, n) { + return Sizzle.uniqueSort(Sizzle(s, n)); + }; d3_selectMatches = Sizzle.matchesSelector; } d3.selection = function() { @@ -615,8 +556,8 @@ qualify: function(name) { var i = name.indexOf(":"), prefix = name; if (i >= 0) { - prefix = name.slice(0, i); - name = name.slice(i + 1); + prefix = name.substring(0, i); + name = name.substring(i + 1); } return d3_nsPrefix.hasOwnProperty(prefix) ? { space: d3_nsPrefix[prefix], @@ -684,7 +625,7 @@ return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); } function d3_selection_classes(name) { - return (name + "").trim().split(/^|\s+/); + return name.trim().split(/^|\s+/); } function d3_selection_classed(name, value) { name = d3_selection_classes(name).map(d3_selection_classedName); @@ -800,12 +741,11 @@ }); }; d3_selectionPrototype.remove = function() { - return this.each(d3_selectionRemove); + return this.each(function() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); + }); }; - function d3_selectionRemove() { - var parent = this.parentNode; - if (parent) parent.removeChild(this); - } d3_selectionPrototype.data = function(value, key) { var i = -1, n = this.length, group, node; if (!arguments.length) { @@ -820,26 +760,29 @@ function bind(group, groupData) { var i, n = group.length, m = groupData.length, n0 = Math.min(n, m), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; if (key) { - var nodeByKeyValue = new d3_Map(), keyValues = new Array(n), keyValue; + var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue; for (i = -1; ++i < n; ) { - if (nodeByKeyValue.has(keyValue = key.call(node = group[i], node.__data__, i))) { + keyValue = key.call(node = group[i], node.__data__, i); + if (nodeByKeyValue.has(keyValue)) { exitNodes[i] = node; } else { nodeByKeyValue.set(keyValue, node); } - keyValues[i] = keyValue; + keyValues.push(keyValue); } for (i = -1; ++i < m; ) { - if (!(node = nodeByKeyValue.get(keyValue = key.call(groupData, nodeData = groupData[i], i)))) { - enterNodes[i] = d3_selection_dataNode(nodeData); - } else if (node !== true) { + keyValue = key.call(groupData, nodeData = groupData[i], i); + if (node = nodeByKeyValue.get(keyValue)) { updateNodes[i] = node; node.__data__ = nodeData; + } else if (!dataByKeyValue.has(keyValue)) { + enterNodes[i] = d3_selection_dataNode(nodeData); } - nodeByKeyValue.set(keyValue, true); + dataByKeyValue.set(keyValue, nodeData); + nodeByKeyValue.remove(keyValue); } for (i = -1; ++i < n; ) { - if (nodeByKeyValue.get(keyValues[i]) !== true) { + if (nodeByKeyValue.has(keyValues[i])) { exitNodes[i] = group[i]; } } @@ -929,7 +872,7 @@ return this.order(); }; function d3_selection_sortComparator(comparator) { - if (!arguments.length) comparator = d3_ascending; + if (!arguments.length) comparator = d3.ascending; return function(a, b) { return a && b ? comparator(a.__data__, b.__data__) : !a - !b; }; @@ -966,7 +909,7 @@ }; d3_selectionPrototype.size = function() { var n = 0; - d3_selection_each(this, function() { + this.each(function() { ++n; }); return n; @@ -1014,6 +957,29 @@ return node; }; } + d3_selectionPrototype.transition = function() { + var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = d3_transitionInherit || { + time: Date.now(), + ease: d3_ease_cubicInOut, + delay: 0, + duration: 250 + }; + 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]) d3_transitionNode(node, i, id, transition); + subgroup.push(node); + } + } + return d3_transition(subgroups, id); + }; + d3_selectionPrototype.interrupt = function() { + return this.each(d3_selection_interrupt); + }; + function d3_selection_interrupt() { + var lock = this.__transition__; + if (lock) ++lock.active; + } d3.select = function(node) { var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ]; group.parentNode = d3_documentElement; @@ -1040,7 +1006,7 @@ }; function d3_selection_on(type, listener, capture) { var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; - if (i > 0) type = type.slice(0, i); + if (i > 0) type = type.substring(0, i); var filter = d3_selection_onFilters.get(type); if (filter) type = filter, wrap = d3_selection_onFilter; function onRemove() { @@ -1107,9 +1073,9 @@ w.on(name, null); if (d3_event_dragSelect) style[d3_event_dragSelect] = select; if (suppressClick) { - var off = function() { + function off() { w.on(click, null); - }; + } w.on(click, function() { d3_eventPreventDefault(); off(); @@ -1148,51 +1114,55 @@ var rect = container.getBoundingClientRect(); return [ e.clientX - rect.left - container.clientLeft, e.clientY - rect.top - container.clientTop ]; } - d3.touch = function(container, touches, identifier) { - if (arguments.length < 3) identifier = touches, touches = d3_eventSource().changedTouches; - if (touches) for (var i = 0, n = touches.length, touch; i < n; ++i) { - if ((touch = touches[i]).identifier === identifier) { - return d3_mousePoint(container, touch); - } - } + 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; + }) : []; }; d3.behavior.drag = function() { - var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, d3_behavior_dragMouseSubject, "mousemove", "mouseup"), touchstart = dragstart(d3_behavior_dragTouchId, d3.touch, d3_behavior_dragTouchSubject, "touchmove", "touchend"); + var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null, mousedown = dragstart(d3_noop, d3.mouse, "mousemove", "mouseup"), touchstart = dragstart(touchid, touchposition, "touchmove", "touchend"); function drag() { this.on("mousedown.drag", mousedown).on("touchstart.drag", touchstart); } - function dragstart(id, position, subject, move, end) { + function touchid() { + return d3.event.changedTouches[0].identifier; + } + function touchposition(parent, id) { + return d3.touches(parent).filter(function(p) { + return p.identifier === id; + })[0]; + } + function dragstart(id, position, move, end) { return function() { - var that = this, target = d3.event.target, parent = that.parentNode, dispatch = event.of(that, arguments), dragged = 0, dragId = id(), dragName = ".drag" + (dragId == null ? "" : "-" + dragId), dragOffset, dragSubject = d3.select(subject()).on(move + dragName, moved).on(end + dragName, ended), dragRestore = d3_event_dragSuppress(), position0 = position(parent, dragId); + var target = this, parent = target.parentNode, event_ = event.of(target, arguments), eventTarget = d3.event.target, eventId = id(), drag = eventId == null ? "drag" : "drag-" + eventId, origin_ = position(parent, eventId), dragged = 0, offset, w = d3.select(d3_window).on(move + "." + drag, moved).on(end + "." + drag, ended), dragRestore = d3_event_dragSuppress(); if (origin) { - dragOffset = origin.apply(that, arguments); - dragOffset = [ dragOffset.x - position0[0], dragOffset.y - position0[1] ]; + offset = origin.apply(target, arguments); + offset = [ offset.x - origin_[0], offset.y - origin_[1] ]; } else { - dragOffset = [ 0, 0 ]; + offset = [ 0, 0 ]; } - dispatch({ + event_({ type: "dragstart" }); function moved() { - var position1 = position(parent, dragId), dx, dy; - if (!position1) return; - dx = position1[0] - position0[0]; - dy = position1[1] - position0[1]; + var p = position(parent, eventId), dx = p[0] - origin_[0], dy = p[1] - origin_[1]; dragged |= dx | dy; - position0 = position1; - dispatch({ + origin_ = p; + event_({ type: "drag", - x: position1[0] + dragOffset[0], - y: position1[1] + dragOffset[1], + x: p[0] + offset[0], + y: p[1] + offset[1], dx: dx, dy: dy }); } function ended() { - if (!position(parent, dragId)) return; - dragSubject.on(move + dragName, null).on(end + dragName, null); - dragRestore(dragged && d3.event.target === target); - dispatch({ + w.on(move + "." + drag, null).on(end + "." + drag, null); + dragRestore(dragged && d3.event.target === eventTarget); + event_({ type: "dragend" }); } @@ -1205,30 +1175,10 @@ }; return d3.rebind(drag, event, "on"); }; - function d3_behavior_dragTouchId() { - return d3.event.changedTouches[0].identifier; - } - function d3_behavior_dragTouchSubject() { - return d3.event.target; - } - function d3_behavior_dragMouseSubject() { - return d3_window; - } - 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; - }) : []; - }; - var ε = 1e-6, ε2 = ε * ε, π = Math.PI, τ = 2 * π, τε = τ - ε, halfπ = π / 2, d3_radians = π / 180, d3_degrees = 180 / π; + var π = Math.PI, τ = 2 * π, halfπ = π / 2, ε = 1e-6, ε2 = ε * ε, d3_radians = π / 180, d3_degrees = 180 / π; function d3_sgn(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; } - function d3_cross2d(a, b, c) { - return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); - } function d3_acos(x) { return x > 1 ? 0 : x < -1 ? π : Math.acos(x); } @@ -1267,13 +1217,13 @@ x: 0, y: 0, k: 1 - }, translate0, center0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, duration = 250, zooming = 0, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; + }, translate0, center, size = [ 960, 500 ], scaleExtent = d3_behavior_zoomInfinity, mousedown = "mousedown.zoom", mousemove = "mousemove.zoom", mouseup = "mouseup.zoom", mousewheelTimer, touchstart = "touchstart.zoom", touchtime, event = d3_eventDispatch(zoom, "zoomstart", "zoom", "zoomend"), x0, x1, y0, y1; function zoom(g) { - g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); + g.on(mousedown, mousedowned).on(d3_behavior_zoomWheel + ".zoom", mousewheeled).on(mousemove, mousewheelreset).on("dblclick.zoom", dblclicked).on(touchstart, touchstarted); } zoom.event = function(g) { g.each(function() { - var dispatch = event.of(this, arguments), view1 = view; + var event_ = event.of(this, arguments), view1 = view; if (d3_transitionInheritId) { d3.select(this).transition().each("start.zoom", function() { view = this.__chart__ || { @@ -1281,9 +1231,9 @@ y: 0, k: 1 }; - zoomstarted(dispatch); + zoomstarted(event_); }).tween("zoom:zoom", function() { - var dx = size[0], dy = size[1], cx = center0 ? center0[0] : dx / 2, cy = center0 ? center0[1] : dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]); + var dx = size[0], dy = size[1], cx = dx / 2, cy = dy / 2, i = d3.interpolateZoom([ (cx - view.x) / view.k, (cy - view.y) / view.k, dx / view.k ], [ (cx - view1.x) / view1.k, (cy - view1.y) / view1.k, dx / view1.k ]); return function(t) { var l = i(t), k = dx / l[2]; this.__chart__ = view = { @@ -1291,18 +1241,16 @@ y: cy - l[1] * k, k: k }; - zoomed(dispatch); + zoomed(event_); }; - }).each("interrupt.zoom", function() { - zoomended(dispatch); }).each("end.zoom", function() { - zoomended(dispatch); + zoomended(event_); }); } else { this.__chart__ = view; - zoomstarted(dispatch); - zoomed(dispatch); - zoomended(dispatch); + zoomstarted(event_); + zoomed(event_); + zoomended(event_); } }); }; @@ -1341,11 +1289,6 @@ size = _ && [ +_[0], +_[1] ]; return zoom; }; - zoom.duration = function(_) { - if (!arguments.length) return duration; - duration = +_; - return zoom; - }; zoom.x = function(z) { if (!arguments.length) return x1; x1 = z; @@ -1382,18 +1325,6 @@ view.x += p[0] - l[0]; view.y += p[1] - l[1]; } - function zoomTo(that, p, l, k) { - that.__chart__ = { - x: view.x, - y: view.y, - k: view.k - }; - scaleTo(Math.pow(2, k)); - translateTo(center0 = p, l); - that = d3.select(that); - if (duration > 0) that = that.transition().duration(duration); - that.call(zoom.event); - } function rescale() { if (x1) x1.domain(x0.range().map(function(x) { return (x - view.x) / view.k; @@ -1402,47 +1333,46 @@ return (y - view.y) / view.k; }).map(y0.invert)); } - function zoomstarted(dispatch) { - if (!zooming++) dispatch({ + function zoomstarted(event) { + event({ type: "zoomstart" }); } - function zoomed(dispatch) { + function zoomed(event) { rescale(); - dispatch({ + event({ type: "zoom", scale: view.k, translate: [ view.x, view.y ] }); } - function zoomended(dispatch) { - if (!--zooming) dispatch({ + function zoomended(event) { + event({ type: "zoomend" }); - center0 = null; } function mousedowned() { - var that = this, target = d3.event.target, dispatch = event.of(that, arguments), dragged = 0, subject = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), location0 = location(d3.mouse(that)), dragRestore = d3_event_dragSuppress(); - d3_selection_interrupt.call(that); - zoomstarted(dispatch); + var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, dragged = 0, w = d3.select(d3_window).on(mousemove, moved).on(mouseup, ended), l = location(d3.mouse(target)), dragRestore = d3_event_dragSuppress(); + d3_selection_interrupt.call(target); + zoomstarted(event_); function moved() { dragged = 1; - translateTo(d3.mouse(that), location0); - zoomed(dispatch); + translateTo(d3.mouse(target), l); + zoomed(event_); } function ended() { - subject.on(mousemove, null).on(mouseup, null); - dragRestore(dragged && d3.event.target === target); - zoomended(dispatch); + w.on(mousemove, d3_window === target ? mousewheelreset : null).on(mouseup, null); + dragRestore(dragged && d3.event.target === eventTarget); + zoomended(event_); } } function touchstarted() { - var that = this, dispatch = event.of(that, arguments), locations0 = {}, distance0 = 0, scale0, zoomName = ".zoom-" + d3.event.changedTouches[0].identifier, touchmove = "touchmove" + zoomName, touchend = "touchend" + zoomName, targets = [], subject = d3.select(that), dragRestore = d3_event_dragSuppress(); + var target = this, event_ = event.of(target, arguments), locations0 = {}, distance0 = 0, scale0, eventId = d3.event.changedTouches[0].identifier, touchmove = "touchmove.zoom-" + eventId, touchend = "touchend.zoom-" + eventId, w = d3.select(d3_window).on(touchmove, moved).on(touchend, ended), t = d3.select(target).on(mousedown, null).on(touchstart, started), dragRestore = d3_event_dragSuppress(); + d3_selection_interrupt.call(target); started(); - zoomstarted(dispatch); - subject.on(mousedown, null).on(touchstart, started); + zoomstarted(event_); function relocate() { - var touches = d3.touches(that); + var touches = d3.touches(target); scale0 = view.k; touches.forEach(function(t) { if (t.identifier in locations0) locations0[t.identifier] = location(t); @@ -1450,9 +1380,6 @@ return touches; } function started() { - var target = d3.event.target; - d3.select(target).on(touchmove, moved).on(touchend, ended); - targets.push(target); var changed = d3.event.changedTouches; for (var i = 0, n = changed.length; i < n; ++i) { locations0[changed[i].identifier] = null; @@ -1460,9 +1387,11 @@ var touches = relocate(), now = Date.now(); if (touches.length === 1) { if (now - touchtime < 500) { - var p = touches[0]; - zoomTo(that, p, locations0[p.identifier], Math.floor(Math.log(view.k) / Math.LN2) + 1); + var p = touches[0], l = locations0[p.identifier]; + scaleTo(view.k * 2); + translateTo(p, l); d3_eventPreventDefault(); + zoomed(event_); } touchtime = now; } else if (touches.length > 1) { @@ -1471,8 +1400,7 @@ } } function moved() { - var touches = d3.touches(that), p0, l0, p1, l1; - d3_selection_interrupt.call(that); + var touches = d3.touches(target), p0, l0, p1, l1; for (var i = 0, n = touches.length; i < n; ++i, l1 = null) { p1 = touches[i]; if (l1 = locations0[p1.identifier]) { @@ -1488,7 +1416,7 @@ } touchtime = null; translateTo(p0, l0); - zoomed(dispatch); + zoomed(event_); } function ended() { if (d3.event.touches.length) { @@ -1500,28 +1428,37 @@ return void relocate(); } } - d3.selectAll(targets).on(zoomName, null); - subject.on(mousedown, mousedowned).on(touchstart, touchstarted); + w.on(touchmove, null).on(touchend, null); + t.on(mousedown, mousedowned).on(touchstart, touchstarted); dragRestore(); - zoomended(dispatch); + zoomended(event_); } } function mousewheeled() { - var dispatch = event.of(this, arguments); - if (mousewheelTimer) clearTimeout(mousewheelTimer); else translate0 = location(center0 = center || d3.mouse(this)), - d3_selection_interrupt.call(this), zoomstarted(dispatch); + var event_ = event.of(this, arguments); + if (mousewheelTimer) clearTimeout(mousewheelTimer); else d3_selection_interrupt.call(this), + zoomstarted(event_); mousewheelTimer = setTimeout(function() { mousewheelTimer = null; - zoomended(dispatch); + zoomended(event_); }, 50); d3_eventPreventDefault(); + var point = center || d3.mouse(this); + if (!translate0) translate0 = location(point); scaleTo(Math.pow(2, d3_behavior_zoomDelta() * .002) * view.k); - translateTo(center0, translate0); - zoomed(dispatch); + translateTo(point, translate0); + zoomed(event_); + } + function mousewheelreset() { + translate0 = null; } function dblclicked() { - var p = d3.mouse(this), k = Math.log(view.k) / Math.LN2; - zoomTo(this, p, location(p), d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1); + var event_ = event.of(this, arguments), p = d3.mouse(this), l = location(p), k = Math.log(view.k) / Math.LN2; + zoomstarted(event_); + scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1)); + translateTo(p, l); + zoomed(event_); + zoomended(event_); } return d3.rebind(zoom, event, "on"); }; @@ -1533,23 +1470,29 @@ }, "mousewheel") : (d3_behavior_zoomDelta = function() { return -d3.event.detail; }, "MozMousePixelScroll"); - d3.color = d3_color; - function d3_color() {} - d3_color.prototype.toString = function() { + function d3_Color() {} + d3_Color.prototype.toString = function() { return this.rgb() + ""; }; - d3.hsl = d3_hsl; + 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 this instanceof d3_hsl ? void (this.h = +h, this.s = +s, this.l = +l) : arguments.length < 2 ? h instanceof d3_hsl ? new d3_hsl(h.h, h.s, h.l) : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl) : new d3_hsl(h, s, l); + return new d3_Hsl(h, s, l); } - var d3_hslPrototype = d3_hsl.prototype = new d3_color(); + function d3_Hsl(h, s, l) { + this.h = h; + this.s = s; + this.l = l; + } + var d3_hslPrototype = d3_Hsl.prototype = new d3_Color(); d3_hslPrototype.brighter = function(k) { k = Math.pow(.7, arguments.length ? k : 1); - return new d3_hsl(this.h, this.s, this.l / k); + return d3_hsl(this.h, this.s, this.l / k); }; d3_hslPrototype.darker = function(k) { k = Math.pow(.7, arguments.length ? k : 1); - return new d3_hsl(this.h, this.s, k * this.l); + return d3_hsl(this.h, this.s, k * this.l); }; d3_hslPrototype.rgb = function() { return d3_hsl_rgb(this.h, this.s, this.l); @@ -1571,18 +1514,25 @@ function vv(h) { return Math.round(v(h) * 255); } - return new d3_rgb(vv(h + 120), vv(h), vv(h - 120)); + return d3_rgb(vv(h + 120), vv(h), vv(h - 120)); } - d3.hcl = d3_hcl; + d3.hcl = function(h, c, l) { + return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l); + }; function d3_hcl(h, c, l) { - return this instanceof d3_hcl ? void (this.h = +h, this.c = +c, this.l = +l) : arguments.length < 2 ? h instanceof d3_hcl ? new d3_hcl(h.h, h.c, h.l) : h instanceof d3_lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : new d3_hcl(h, c, l); + return new d3_Hcl(h, c, l); } - var d3_hclPrototype = d3_hcl.prototype = new d3_color(); + function d3_Hcl(h, c, l) { + this.h = h; + this.c = c; + this.l = l; + } + var d3_hclPrototype = d3_Hcl.prototype = new d3_Color(); d3_hclPrototype.brighter = function(k) { - return new d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); + return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); }; d3_hclPrototype.darker = function(k) { - return new d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); + return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); }; d3_hclPrototype.rgb = function() { return d3_hcl_lab(this.h, this.c, this.l).rgb(); @@ -1590,20 +1540,27 @@ function d3_hcl_lab(h, c, l) { if (isNaN(h)) h = 0; if (isNaN(c)) c = 0; - return new d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); + return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); } - d3.lab = d3_lab; + d3.lab = function(l, a, b) { + return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b); + }; function d3_lab(l, a, b) { - return this instanceof d3_lab ? void (this.l = +l, this.a = +a, this.b = +b) : arguments.length < 2 ? l instanceof d3_lab ? new d3_lab(l.l, l.a, l.b) : l instanceof d3_hcl ? d3_hcl_lab(l.h, l.c, l.l) : d3_rgb_lab((l = d3_rgb(l)).r, l.g, l.b) : new d3_lab(l, a, b); + return new d3_Lab(l, a, b); + } + function d3_Lab(l, a, b) { + this.l = l; + this.a = a; + this.b = b; } var d3_lab_K = 18; var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; - var d3_labPrototype = d3_lab.prototype = new d3_color(); + var d3_labPrototype = d3_Lab.prototype = new d3_Color(); d3_labPrototype.brighter = function(k) { - return new d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); + return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); }; d3_labPrototype.darker = function(k) { - return new d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); + return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); }; d3_labPrototype.rgb = function() { return d3_lab_rgb(this.l, this.a, this.b); @@ -1613,10 +1570,10 @@ x = d3_lab_xyz(x) * d3_lab_X; y = d3_lab_xyz(y) * d3_lab_Y; z = d3_lab_xyz(z) * d3_lab_Z; - return new d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); + return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); } function d3_lab_hcl(l, a, b) { - return l > 0 ? new d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : new d3_hcl(NaN, NaN, l); + return l > 0 ? d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : d3_hcl(NaN, NaN, l); } function d3_lab_xyz(x) { return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; @@ -1627,29 +1584,36 @@ function d3_xyz_rgb(r) { return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); } - d3.rgb = d3_rgb; - function d3_rgb(r, g, b) { - return this instanceof d3_rgb ? void (this.r = ~~r, this.g = ~~g, this.b = ~~b) : arguments.length < 2 ? r instanceof d3_rgb ? new d3_rgb(r.r, r.g, r.b) : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb) : new d3_rgb(r, g, 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_rgbNumber(value) { - return new d3_rgb(value >> 16, value >> 8 & 255, value & 255); + return d3_rgb(value >> 16, value >> 8 & 255, value & 255); } function d3_rgbString(value) { return d3_rgbNumber(value) + ""; } - var d3_rgbPrototype = d3_rgb.prototype = new d3_color(); + 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; + } + var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color(); d3_rgbPrototype.brighter = function(k) { k = Math.pow(.7, arguments.length ? k : 1); var r = this.r, g = this.g, b = this.b, i = 30; - if (!r && !g && !b) return new d3_rgb(i, i, i); + 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 new d3_rgb(Math.min(255, r / k), Math.min(255, g / k), Math.min(255, b / k)); + return d3_rgb(Math.min(255, ~~(r / k)), Math.min(255, ~~(g / k)), Math.min(255, ~~(b / k))); }; d3_rgbPrototype.darker = function(k) { k = Math.pow(.7, arguments.length ? k : 1); - return new d3_rgb(k * this.r, k * this.g, k * this.b); + return d3_rgb(~~(k * this.r), ~~(k * this.g), ~~(k * this.b)); }; d3_rgbPrototype.hsl = function() { return d3_rgb_hsl(this.r, this.g, this.b); @@ -1661,7 +1625,7 @@ return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); } function d3_rgb_parse(format, rgb, hsl) { - var r = 0, g = 0, b = 0, m1, m2, color; + var r = 0, g = 0, b = 0, m1, m2, name; m1 = /([a-z]+)\((.*)\)/i.exec(format); if (m1) { m2 = m1[2].split(","); @@ -1677,20 +1641,23 @@ } } } - if (color = d3_rgb_names.get(format)) return rgb(color.r, color.g, color.b); - if (format != null && format.charAt(0) === "#" && !isNaN(color = parseInt(format.slice(1), 16))) { + if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b); + if (format != null && format.charAt(0) === "#") { if (format.length === 4) { - r = (color & 3840) >> 4; - r = r >> 4 | r; - g = color & 240; - g = g >> 4 | g; - b = color & 15; - b = b << 4 | b; + r = format.charAt(1); + r += r; + g = format.charAt(2); + g += g; + b = format.charAt(3); + b += b; } else if (format.length === 7) { - r = (color & 16711680) >> 16; - g = (color & 65280) >> 8; - b = color & 255; + 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); } @@ -1704,7 +1671,7 @@ h = NaN; s = l > 0 && l < 1 ? 0 : h; } - return new d3_hsl(h, s, l); + return d3_hsl(h, s, l); } function d3_rgb_lab(r, g, b) { r = d3_rgb_xyz(r); @@ -1897,7 +1864,7 @@ }; function respond() { var status = request.status, result; - if (!status && d3_xhrHasResponse(request) || status >= 200 && status < 300 || status === 304) { + if (!status && request.responseText || status >= 200 && status < 300 || status === 304) { try { result = response.call(xhr, request); } catch (e) { @@ -1969,10 +1936,6 @@ callback(error == null ? request : null); } : callback; } - function d3_xhrHasResponse(request) { - var type = request.responseType; - return type && type !== "text" ? request.response : request.responseText; - } d3.dsv = function(delimiter, mimeType) { var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); function dsv(url, row, callback) { @@ -2025,7 +1988,7 @@ } else if (c === 10) { eol = true; } - return text.slice(j + 1, i).replace(/""/g, '"'); + return text.substring(j + 1, i).replace(/""/g, '"'); } while (I < N) { var c = text.charCodeAt(I++), k = 1; @@ -2033,9 +1996,9 @@ eol = true; if (text.charCodeAt(I) === 10) ++I, ++k; } else if (c !== delimiterCode) continue; - return text.slice(j, I - k); + return text.substring(j, I - k); } - return text.slice(j); + return text.substring(j); } while ((t = token()) !== EOF) { var a = []; @@ -2043,7 +2006,7 @@ a.push(t); t = token(); } - if (f && (a = f(a, n++)) == null) continue; + if (f && !(a = f(a, n++))) continue; rows.push(a); } return rows; @@ -2137,12 +2100,7 @@ d3_timer_queueTail = t0; return time; } - function d3_format_precision(x, p) { - return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); - } - d3.round = function(x, n) { - return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); - }; + var d3_format_decimalPoint = ".", d3_format_thousandsSeparator = ",", d3_format_grouping = [ 3, 3 ], d3_format_currencySymbol = "$"; 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; @@ -2150,7 +2108,7 @@ 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 - 1) / 3) * 3)); + i = Math.max(-24, Math.min(24, Math.floor((i <= 0 ? i + 1 : i - 1) / 3) * 3)); } return d3_formatPrefixes[8 + i / 3]; }; @@ -2165,97 +2123,79 @@ symbol: d }; } - function d3_locale_numberFormat(locale) { - var locale_decimal = locale.decimal, locale_thousands = locale.thousands, locale_grouping = locale.grouping, locale_currency = locale.currency, formatGroup = locale_grouping && locale_thousands ? function(value, width) { - var i = value.length, t = [], j = 0, g = locale_grouping[0], length = 0; - while (i > 0 && g > 0) { - if (length + g + 1 > width) g = Math.max(1, width - length); - t.push(value.substring(i -= g, i + g)); - if ((length += g + 1) > width) break; - g = locale_grouping[j = (j + 1) % locale_grouping.length]; + d3.round = function(x, n) { + return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); + }; + d3.format = function(specifier) { + var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "", symbol = match[4] || "", 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" && align === "=") { + zfill = fill = "0"; + 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 "b": + case "o": + case "x": + case "X": + if (symbol === "#") symbol = "0" + type.toLowerCase(); + + case "c": + case "d": + integer = true; + precision = 0; + break; + + case "s": + scale = -1; + type = "r"; + break; + } + if (symbol === "#") symbol = ""; else if (symbol === "$") symbol = d3_format_currencySymbol; + if (type == "r" && !precision) type = "g"; + if (precision != null) { + if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); + } + type = d3_format_types.get(type) || d3_format_typeDefault; + var zcomma = zfill && comma; + return function(value) { + if (integer && value % 1) return ""; + var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign; + if (scale < 0) { + var prefix = d3.formatPrefix(value, precision); + value = prefix.scale(value); + suffix = prefix.symbol; + } else { + value *= scale; } - return t.reverse().join(locale_thousands); - } : d3_identity; - return function(specifier) { - var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "-", symbol = match[4] || "", zfill = match[5], width = +match[6], comma = match[7], precision = match[8], type = match[9], scale = 1, prefix = "", suffix = "", integer = false, exponent = true; - if (precision) precision = +precision.substring(1); - if (zfill || fill === "0" && align === "=") { - zfill = fill = "0"; - align = "="; - } - 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 "b": - case "o": - case "x": - case "X": - if (symbol === "#") prefix = "0" + type.toLowerCase(); - - case "c": - exponent = false; - - case "d": - integer = true; - precision = 0; - break; - - case "s": - scale = -1; - type = "r"; - break; - } - if (symbol === "$") prefix = locale_currency[0], suffix = locale_currency[1]; - if (type == "r" && !precision) type = "g"; - if (precision != null) { - if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); - } - type = d3_format_types.get(type) || d3_format_typeDefault; - var zcomma = zfill && comma; - return function(value) { - var fullSuffix = suffix; - if (integer && value % 1) return ""; - var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign === "-" ? "" : sign; - if (scale < 0) { - var unit = d3.formatPrefix(value, precision); - value = unit.scale(value); - fullSuffix = unit.symbol + suffix; - } else { - value *= scale; - } - value = type(value, precision); - var i = value.lastIndexOf("."), before, after; - if (i < 0) { - var j = exponent ? value.lastIndexOf("e") : -1; - if (j < 0) before = value, after = ""; else before = value.substring(0, j), after = value.substring(j); - } else { - before = value.substring(0, i); - after = locale_decimal + value.substring(i + 1); - } - if (!zfill && comma) before = formatGroup(before, Infinity); - var length = prefix.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; - if (zcomma) before = formatGroup(padding + before, padding.length ? width - after.length : Infinity); - negative += prefix; - value = before + after; - return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + fullSuffix; - }; + value = type(value, precision); + var i = value.lastIndexOf("."), before = i < 0 ? value : value.substring(0, i), after = i < 0 ? "" : d3_format_decimalPoint + value.substring(i + 1); + if (!zfill && comma) before = d3_format_group(before); + var length = symbol.length + before.length + after.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; + if (zcomma) before = d3_format_group(padding + before); + negative += symbol; + value = before + after; + return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + suffix; }; - } + }; var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i; var d3_format_types = d3.map({ b: function(x) { @@ -2286,522 +2226,24 @@ return (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); } }); + function d3_format_precision(x, p) { + return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); + } function d3_format_typeDefault(x) { return x + ""; } - var d3_time = d3.time = {}, d3_date = Date; - function d3_date_utc() { - this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); - } - d3_date_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; - 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_date(date - 1)), 1); - return date; - } - function offset(date, k) { - step(date = new d3_date(+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_date = d3_date_utc; - var utc = new d3_date_utc(); - utc._ = t0; - return range(utc, t1, dt); - } finally { - d3_date = 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_date = d3_date_utc; - var utc = new d3_date_utc(); - utc._ = date; - return method(utc, k)._; - } finally { - d3_date = Date; + var d3_format_group = d3_identity; + if (d3_format_grouping) { + var d3_format_groupingLength = d3_format_grouping.length; + d3_format_group = function(value) { + var i = value.length, t = [], j = 0, g = d3_format_grouping[0]; + while (i > 0 && g > 0) { + t.push(value.substring(i -= g, i + g)); + g = d3_format_grouping[j = (j + 1) % d3_format_groupingLength]; } + return t.reverse().join(d3_format_thousandsSeparator); }; } - d3_time.year = d3_time_interval(function(date) { - date = d3_time.day(date); - date.setMonth(0, 1); - return date; - }, 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; - d3_time.day = d3_time_interval(function(date) { - var day = new d3_date(2e3, 0); - day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); - return day; - }, 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 - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); - }; - [ "sunday", "monday", "tuesday", "wednesday", "thursday", "friday", "saturday" ].forEach(function(day, i) { - 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; - function d3_locale_timeFormat(locale) { - var locale_dateTime = locale.dateTime, locale_date = locale.date, locale_time = locale.time, locale_periods = locale.periods, locale_days = locale.days, locale_shortDays = locale.shortDays, locale_months = locale.months, locale_shortMonths = locale.shortMonths; - function d3_time_format(template) { - var n = template.length; - function format(date) { - var string = [], i = -1, j = 0, c, p, f; - while (++i < n) { - if (template.charCodeAt(i) === 37) { - string.push(template.slice(j, i)); - if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); - if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); - string.push(c); - j = i + 1; - } - } - string.push(template.slice(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, - Z: null - }, i = d3_time_parse(d, template, string, 0); - if (i != string.length) return null; - if ("p" in d) d.H = d.H % 12 + d.p * 12; - var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)(); - if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) { - date.setFullYear(d.y, 0, 1); - date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); - } else date.setFullYear(d.y, d.m, d.d); - date.setHours(d.H + (d.Z / 100 | 0), d.M + d.Z % 100, d.S, d.L); - return localZ ? date._ : date; - }; - format.toString = function() { - return template; - }; - return format; - } - function d3_time_parse(date, template, string, j) { - var c, p, t, i = 0, n = template.length, m = string.length; - while (i < n) { - if (j >= m) return -1; - c = template.charCodeAt(i++); - if (c === 37) { - t = template.charAt(i++); - p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t]; - if (!p || (j = p(date, string, j)) < 0) return -1; - } else if (c != string.charCodeAt(j++)) { - return -1; - } - } - return j; - } - d3_time_format.utc = function(template) { - var local = d3_time_format(template); - function format(date) { - try { - d3_date = d3_date_utc; - var utc = new d3_date(); - utc._ = date; - return local(utc); - } finally { - d3_date = Date; - } - } - format.parse = function(string) { - try { - d3_date = d3_date_utc; - var date = local.parse(string); - return date && date._; - } finally { - d3_date = Date; - } - }; - format.toString = local.toString; - return format; - }; - d3_time_format.multi = d3_time_format.utc.multi = d3_time_formatMulti; - var d3_time_periodLookup = d3.map(), d3_time_dayRe = d3_time_formatRe(locale_days), d3_time_dayLookup = d3_time_formatLookup(locale_days), d3_time_dayAbbrevRe = d3_time_formatRe(locale_shortDays), d3_time_dayAbbrevLookup = d3_time_formatLookup(locale_shortDays), d3_time_monthRe = d3_time_formatRe(locale_months), d3_time_monthLookup = d3_time_formatLookup(locale_months), d3_time_monthAbbrevRe = d3_time_formatRe(locale_shortMonths), d3_time_monthAbbrevLookup = d3_time_formatLookup(locale_shortMonths); - locale_periods.forEach(function(p, i) { - d3_time_periodLookup.set(p.toLowerCase(), i); - }); - var d3_time_formats = { - a: function(d) { - return locale_shortDays[d.getDay()]; - }, - A: function(d) { - return locale_days[d.getDay()]; - }, - b: function(d) { - return locale_shortMonths[d.getMonth()]; - }, - B: function(d) { - return locale_months[d.getMonth()]; - }, - c: d3_time_format(locale_dateTime), - d: function(d, p) { - return d3_time_formatPad(d.getDate(), p, 2); - }, - e: function(d, p) { - return d3_time_formatPad(d.getDate(), p, 2); - }, - H: function(d, p) { - return d3_time_formatPad(d.getHours(), p, 2); - }, - I: function(d, p) { - return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); - }, - j: function(d, p) { - return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3); - }, - L: function(d, p) { - return d3_time_formatPad(d.getMilliseconds(), p, 3); - }, - m: function(d, p) { - return d3_time_formatPad(d.getMonth() + 1, p, 2); - }, - M: function(d, p) { - return d3_time_formatPad(d.getMinutes(), p, 2); - }, - p: function(d) { - return locale_periods[+(d.getHours() >= 12)]; - }, - S: function(d, p) { - return d3_time_formatPad(d.getSeconds(), p, 2); - }, - U: function(d, p) { - return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2); - }, - w: function(d) { - return d.getDay(); - }, - W: function(d, p) { - return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2); - }, - x: d3_time_format(locale_date), - X: d3_time_format(locale_time), - y: function(d, p) { - return d3_time_formatPad(d.getFullYear() % 100, p, 2); - }, - Y: function(d, p) { - return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); - }, - Z: d3_time_zone, - "%": function() { - 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: d3_time_parseDayOfYear, - L: d3_time_parseMilliseconds, - m: d3_time_parseMonthNumber, - M: d3_time_parseMinutes, - p: d3_time_parseAmPm, - S: d3_time_parseSeconds, - U: d3_time_parseWeekNumberSunday, - w: d3_time_parseWeekdayNumber, - W: d3_time_parseWeekNumberMonday, - x: d3_time_parseLocaleDate, - X: d3_time_parseLocaleTime, - y: d3_time_parseYear, - Y: d3_time_parseFullYear, - Z: d3_time_parseZone, - "%": d3_time_parseLiteralPercent - }; - function d3_time_parseWeekdayAbbrev(date, string, i) { - d3_time_dayAbbrevRe.lastIndex = 0; - var n = d3_time_dayAbbrevRe.exec(string.slice(i)); - return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function d3_time_parseWeekday(date, string, i) { - d3_time_dayRe.lastIndex = 0; - var n = d3_time_dayRe.exec(string.slice(i)); - return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function d3_time_parseMonthAbbrev(date, string, i) { - d3_time_monthAbbrevRe.lastIndex = 0; - var n = d3_time_monthAbbrevRe.exec(string.slice(i)); - return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - function d3_time_parseMonth(date, string, i) { - d3_time_monthRe.lastIndex = 0; - var n = d3_time_monthRe.exec(string.slice(i)); - return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; - } - 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_parseAmPm(date, string, i) { - var n = d3_time_periodLookup.get(string.slice(i, i += 2).toLowerCase()); - return n == null ? -1 : (date.p = n, i); - } - return d3_time_format; - } - var d3_time_formatPads = { - "-": "", - _: " ", - "0": "0" - }, d3_time_numberRe = /^\s*\d+/, d3_time_percentRe = /^%/; - function d3_time_formatPad(value, fill, width) { - var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; - return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); - } - function d3_time_formatRe(names) { - return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); - } - function d3_time_formatLookup(names) { - var map = new d3_Map(), i = -1, n = names.length; - while (++i < n) map.set(names[i].toLowerCase(), i); - return map; - } - function d3_time_parseWeekdayNumber(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.slice(i, i + 1)); - return n ? (date.w = +n[0], i + n[0].length) : -1; - } - function d3_time_parseWeekNumberSunday(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.slice(i)); - return n ? (date.U = +n[0], i + n[0].length) : -1; - } - function d3_time_parseWeekNumberMonday(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.slice(i)); - return n ? (date.W = +n[0], i + n[0].length) : -1; - } - function d3_time_parseFullYear(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.slice(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.slice(i, i + 2)); - return n ? (date.y = d3_time_expandYear(+n[0]), i + n[0].length) : -1; - } - function d3_time_parseZone(date, string, i) { - return /^[+-]\d{4}$/.test(string = string.slice(i, i + 5)) ? (date.Z = -string, - i + 5) : -1; - } - function d3_time_expandYear(d) { - return d + (d > 68 ? 1900 : 2e3); - } - function d3_time_parseMonthNumber(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.slice(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.slice(i, i + 2)); - return n ? (date.d = +n[0], i + n[0].length) : -1; - } - function d3_time_parseDayOfYear(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.slice(i, i + 3)); - return n ? (date.j = +n[0], i + n[0].length) : -1; - } - function d3_time_parseHour24(date, string, i) { - d3_time_numberRe.lastIndex = 0; - var n = d3_time_numberRe.exec(string.slice(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.slice(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.slice(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.slice(i, i + 3)); - return n ? (date.L = +n[0], i + n[0].length) : -1; - } - function d3_time_zone(d) { - var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = abs(z) / 60 | 0, zm = abs(z) % 60; - return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); - } - function d3_time_parseLiteralPercent(date, string, i) { - d3_time_percentRe.lastIndex = 0; - var n = d3_time_percentRe.exec(string.slice(i, i + 1)); - return n ? i + n[0].length : -1; - } - function d3_time_formatMulti(formats) { - var n = formats.length, i = -1; - while (++i < n) formats[i][0] = this(formats[i][0]); - return function(date) { - var i = 0, f = formats[i]; - while (!f[1](date)) f = formats[++i]; - return f[0](date); - }; - } - d3.locale = function(locale) { - return { - numberFormat: d3_locale_numberFormat(locale), - timeFormat: d3_locale_timeFormat(locale) - }; - }; - var d3_locale_enUS = d3.locale({ - decimal: ".", - thousands: ",", - grouping: [ 3 ], - currency: [ "$", "" ], - dateTime: "%a %b %e %X %Y", - date: "%m/%d/%Y", - time: "%H:%M:%S", - periods: [ "AM", "PM" ], - days: [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], - shortDays: [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], - months: [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], - shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] - }); - d3.format = d3_locale_enUS.numberFormat; d3.geo = {}; function d3_adder() {} d3_adder.prototype = { @@ -2921,7 +2363,7 @@ function nextPoint(λ, φ) { λ *= d3_radians; φ = φ * d3_radians / 2 + π / 4; - var dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ); + var dλ = λ - λ0, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(dλ), v = k * Math.sin(dλ); d3_geo_areaRingSum.add(Math.atan2(v, u)); λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; } @@ -3177,15 +2619,6 @@ d3_geo_centroidPointXYZ(x0, y0, z0); } } - function d3_geo_compose(a, b) { - function compose(x, y) { - return x = a(x, y), b(x[0], x[1]); - } - if (a.invert && b.invert) compose.invert = function(x, y) { - return x = b.invert(x, y), x && a.invert(x[0], x[1]); - }; - return compose; - } function d3_true() { return true; } @@ -3280,6 +2713,7 @@ clip.lineEnd = ringEnd; segments = []; polygon = []; + listener.polygonStart(); }, polygonEnd: function() { clip.point = point; @@ -3288,15 +2722,13 @@ segments = d3.merge(segments); var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon); if (segments.length) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener); } else if (clipStartInside) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; listener.lineStart(); interpolate(null, null, 1, listener); listener.lineEnd(); } - if (polygonStarted) listener.polygonEnd(), polygonStarted = false; + listener.polygonEnd(); segments = polygon = null; }, sphere: function() { @@ -3324,7 +2756,7 @@ line.lineEnd(); } var segments; - var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring; + var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygon, ring; function pointRing(λ, φ) { ring.push([ λ, φ ]); var point = rotate(λ, φ); @@ -3345,12 +2777,9 @@ if (clean & 1) { segment = ringSegments[0]; var n = segment.length - 1, i = -1, point; - if (n > 0) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; - listener.lineStart(); - while (++i < n) listener.point((point = segment[i])[0], point[1]); - listener.lineEnd(); - } + listener.lineStart(); + while (++i < n) listener.point((point = segment[i])[0], point[1]); + listener.lineEnd(); return; } if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); @@ -3386,6 +2815,35 @@ function d3_geo_clipSort(a, b) { return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]); } + function d3_geo_pointInPolygon(point, polygon) { + var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; + d3_geo_areaRingSum.reset(); + for (var i = 0, n = polygon.length; i < n; ++i) { + var ring = polygon[i], m = ring.length; + if (!m) continue; + var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; + while (true) { + if (j === m) j = 0; + point = ring[j]; + var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, antimeridian = abs(dλ) > π, k = sinφ0 * sinφ; + d3_geo_areaRingSum.add(Math.atan2(k * Math.sin(dλ), cosφ0 * cosφ + k * Math.cos(dλ))); + polarAngle += antimeridian ? dλ + (dλ >= 0 ? τ : -τ) : dλ; + if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { + var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); + d3_geo_cartesianNormalize(arc); + var intersection = d3_geo_cartesianCross(meridianNormal, arc); + d3_geo_cartesianNormalize(intersection); + var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); + if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { + winding += antimeridian ^ dλ >= 0 ? 1 : -1; + } + } + if (!j++) break; + λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; + } + } + return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; + } var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]); function d3_geo_clipAntimeridianLine(listener) { var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; @@ -3453,35 +2911,6 @@ listener.point(to[0], to[1]); } } - function d3_geo_pointInPolygon(point, polygon) { - var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; - d3_geo_areaRingSum.reset(); - for (var i = 0, n = polygon.length; i < n; ++i) { - var ring = polygon[i], m = ring.length; - if (!m) continue; - var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; - while (true) { - if (j === m) j = 0; - point = ring[j]; - var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ; - d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ))); - polarAngle += antimeridian ? dλ + sdλ * τ : dλ; - if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { - var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); - d3_geo_cartesianNormalize(arc); - var intersection = d3_geo_cartesianCross(meridianNormal, arc); - d3_geo_cartesianNormalize(intersection); - var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); - if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { - winding += antimeridian ^ dλ >= 0 ? 1 : -1; - } - } - if (!j++) break; - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; - } - } - return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < 0) ^ winding & 1; - } function d3_geo_clipCircle(radius) { var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]); @@ -3688,15 +3117,18 @@ for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { b = v[j]; if (a[1] <= y) { - if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn; + if (b[1] > y && isLeft(a, b, p) > 0) ++wn; } else { - if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn; + if (b[1] <= y && isLeft(a, b, p) < 0) --wn; } a = b; } } return wn !== 0; } + function isLeft(a, b, c) { + return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); + } function interpolate(from, to, direction, listener) { var a = 0, a1 = 0; if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { @@ -3784,6 +3216,15 @@ return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; } } + function d3_geo_compose(a, b) { + function compose(x, y) { + return x = a(x, y), b(x[0], x[1]); + } + if (a.invert && b.invert) compose.invert = function(x, y) { + return x = b.invert(x, y), x && a.invert(x[0], x[1]); + }; + return compose; + } function d3_geo_conic(projectAt) { var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1); p.parallels = function(_) { @@ -4055,7 +3496,7 @@ result: d3_noop }; function point(x, y) { - context.moveTo(x + pointRadius, y); + context.moveTo(x, y); context.arc(x, y, pointRadius, 0, τ); } function pointLineStart(x, y) { @@ -4646,12 +4087,7 @@ }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n; if (!n) return d3_geo_mercator; function forward(λ, φ) { - if (F > 0) { - if (φ < -halfπ + ε) φ = -halfπ + ε; - } else { - if (φ > halfπ - ε) φ = halfπ - ε; - } - var ρ = F / Math.pow(t(φ), n); + var ρ = abs(abs(φ) - halfπ) < ε ? 0 : F / Math.pow(t(φ), n); return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ]; } forward.invert = function(x, y) { @@ -4741,13 +4177,13 @@ (d3.geo.transverseMercator = function() { var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate; projection.center = function(_) { - return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]); + return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ -_[1], _[0] ]); }; projection.rotate = function(_) { return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), [ _[0], _[1], _[2] - 90 ]); }; - return rotate([ 0, 0, 90 ]); + return projection.rotate([ 0, 0 ]); }).raw = d3_geo_transverseMercator; d3.geom = {}; function d3_geom_pointX(d) { @@ -4761,17 +4197,65 @@ if (arguments.length) return hull(vertices); function hull(data) { if (data.length < 3) return []; - var fx = d3_functor(x), fy = d3_functor(y), i, n = data.length, points = [], flippedPoints = []; - for (i = 0; i < n; i++) { - points.push([ +fx.call(this, data[i], i), +fy.call(this, data[i], i), i ]); + var fx = d3_functor(x), fy = d3_functor(y), n = data.length, vertices, plen = n - 1, points = [], stack = [], d, i, j, h = 0, x1, y1, x2, y2, u, v, a, sp; + if (fx === d3_geom_pointX && y === d3_geom_pointY) vertices = data; else for (i = 0, + vertices = []; i < n; ++i) { + vertices.push([ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]); } - points.sort(d3_geom_hullOrder); - for (i = 0; i < n; i++) flippedPoints.push([ points[i][0], -points[i][1] ]); - var upper = d3_geom_hullUpper(points), lower = d3_geom_hullUpper(flippedPoints); - var skipLeft = lower[0] === upper[0], skipRight = lower[lower.length - 1] === upper[upper.length - 1], polygon = []; - for (i = upper.length - 1; i >= 0; --i) polygon.push(data[points[upper[i]][2]]); - for (i = +skipLeft; i < lower.length - skipRight; ++i) polygon.push(data[points[lower[i]][2]]); - return polygon; + for (i = 1; i < n; ++i) { + if (vertices[i][1] < vertices[h][1] || vertices[i][1] == vertices[h][1] && vertices[i][0] < vertices[h][0]) h = i; + } + for (i = 0; i < n; ++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; + }); + 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) { + 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; + continue; + } else { + points[u].index = -1; + } + } + a = points[i].angle; + u = i; + v = j; + } + 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; + for (;j < plen; ++j) { + if (points[j].index < 0) continue; + while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) { + --sp; + } + stack[sp++] = points[j].index; + } + var poly = []; + for (i = sp - 1; i >= 0; --i) poly.push(data[stack[i]]); + return poly; } hull.x = function(_) { return arguments.length ? (x = _, hull) : x; @@ -4781,16 +4265,18 @@ }; return hull; }; - function d3_geom_hullUpper(points) { - var n = points.length, hull = [ 0, 1 ], hs = 2; - for (var i = 2; i < n; i++) { - while (hs > 1 && d3_cross2d(points[hull[hs - 2]], points[hull[hs - 1]], points[i]) <= 0) --hs; - hull[hs++] = i; - } - return hull.slice(0, hs); - } - function d3_geom_hullOrder(a, b) { - return a[0] - b[0] || a[1] - b[1]; + 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; } d3.geom.polygon = function(coordinates) { d3_subclass(coordinates, d3_geom_polygonPrototype); @@ -5563,11 +5049,11 @@ } } function insertChild(n, d, x, y, x1, y1, x2, y2) { - var xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym, i = below << 1 | right; + var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = x >= sx, bottom = y >= sy, i = (bottom << 1) + right; n.leaf = false; n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); - if (right) x1 = xm; else x2 = xm; - if (below) y1 = ym; else y2 = ym; + if (right) x1 = sx; else x2 = sx; + if (bottom) y1 = sy; else y2 = sy; insert(n, d, x, y, x1, y1, x2, y2); } var root = d3_geom_quadtreeNode(); @@ -5577,9 +5063,6 @@ root.visit = function(f) { d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); }; - root.find = function(point) { - return d3_geom_quadtreeFind(root, point[0], point[1], x1_, y1_, x2_, y2_); - }; i = -1; if (x1 == null) { while (++i < n) { @@ -5633,42 +5116,6 @@ if (children[3]) d3_geom_quadtreeVisit(f, children[3], sx, sy, x2, y2); } } - function d3_geom_quadtreeFind(root, x, y, x0, y0, x3, y3) { - var minDistance2 = Infinity, closestPoint; - (function find(node, x1, y1, x2, y2) { - if (x1 > x3 || y1 > y3 || x2 < x0 || y2 < y0) return; - if (point = node.point) { - var point, dx = x - point[0], dy = y - point[1], distance2 = dx * dx + dy * dy; - if (distance2 < minDistance2) { - var distance = Math.sqrt(minDistance2 = distance2); - x0 = x - distance, y0 = y - distance; - x3 = x + distance, y3 = y + distance; - closestPoint = point; - } - } - var children = node.nodes, xm = (x1 + x2) * .5, ym = (y1 + y2) * .5, right = x >= xm, below = y >= ym; - for (var i = below << 1 | right, j = i + 4; i < j; ++i) { - if (node = children[i & 3]) switch (i & 3) { - case 0: - find(node, x1, y1, xm, ym); - break; - - case 1: - find(node, xm, y1, x2, ym); - break; - - case 2: - find(node, x1, ym, xm, y2); - break; - - case 3: - find(node, xm, ym, x2, y2); - break; - } - } - })(root, x0, y0, x3, y3); - return closestPoint; - } d3.interpolateRgb = d3_interpolateRgb; function d3_interpolateRgb(a, b) { a = d3.rgb(a); @@ -5700,45 +5147,78 @@ } d3.interpolateNumber = d3_interpolateNumber; function d3_interpolateNumber(a, b) { - a = +a, b = +b; + b -= a = +a; return function(t) { - return a * (1 - t) + b * t; + return a + b * t; }; } d3.interpolateString = d3_interpolateString; function d3_interpolateString(a, b) { - var bi = d3_interpolate_numberA.lastIndex = d3_interpolate_numberB.lastIndex = 0, am, bm, bs, i = -1, s = [], q = []; + var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o; a = a + "", b = b + ""; - while ((am = d3_interpolate_numberA.exec(a)) && (bm = d3_interpolate_numberB.exec(b))) { - if ((bs = bm.index) > bi) { - bs = b.slice(bi, bs); - if (s[i]) s[i] += bs; else s[++i] = bs; - } - if ((am = am[0]) === (bm = bm[0])) { - if (s[i]) s[i] += bm; else s[++i] = bm; + d3_interpolate_number.lastIndex = 0; + 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)); + for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { + o = q[i]; + if (o.x == m[0]) { + if (o.i) { + if (s[o.i + 1] == null) { + s[o.i - 1] += o.x; + s.splice(o.i, 1); + for (j = i + 1; j < n; ++j) q[j].i--; + } else { + 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) { + s[o.i] = o.x; + } else { + 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 { - s[++i] = null; - q.push({ - i: i, - x: d3_interpolateNumber(am, bm) - }); + o.x = d3_interpolateNumber(parseFloat(m[0]), parseFloat(o.x)); } - bi = d3_interpolate_numberB.lastIndex; } - if (bi < b.length) { - bs = b.slice(bi); - if (s[i]) s[i] += bs; else s[++i] = bs; + while (i < n) { + o = q.pop(); + if (s[o.i + 1] == null) { + s[o.i] = o.x; + } else { + s[o.i] = o.x + s[o.i + 1]; + s.splice(o.i + 1, 1); + } + n--; } - return s.length < 2 ? q[0] ? (b = q[0].x, function(t) { - return b(t) + ""; - }) : function() { - return b; - } : (b = q.length, function(t) { - for (var i = 0, o; i < b; ++i) s[(o = q[i]).i] = o.x(t); + if (s.length === 1) { + return s[0] == null ? (o = q[0].x, function(t) { + return o(t) + ""; + }) : function() { + return b; + }; + } + return function(t) { + for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t); return s.join(""); - }); + }; } - var d3_interpolate_numberA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, d3_interpolate_numberB = new RegExp(d3_interpolate_numberA.source, "g"); + var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; d3.interpolate = d3_interpolate; function d3_interpolate(a, b) { var i = d3.interpolators.length, f; @@ -5747,7 +5227,7 @@ } d3.interpolators = [ function(a, b) { var t = typeof b; - return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_color ? d3_interpolateRgb : Array.isArray(b) ? d3_interpolateArray : t === "object" && isNaN(b) ? d3_interpolateObject : d3_interpolateNumber)(a, b); + return (t === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_Color ? d3_interpolateRgb : t === "object" ? Array.isArray(b) ? d3_interpolateArray : d3_interpolateObject : d3_interpolateNumber)(a, b); } ]; d3.interpolateArray = d3_interpolateArray; function d3_interpolateArray(a, b) { @@ -5796,7 +5276,7 @@ } }); d3.ease = function(name) { - var i = name.indexOf("-"), t = i >= 0 ? name.slice(0, i) : name, m = i >= 0 ? name.slice(i + 1) : "in"; + 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_identity; return d3_ease_clamp(m(t.apply(null, d3_arraySlice.call(arguments, 1)))); @@ -6001,15 +5481,15 @@ }; } function d3_uninterpolateNumber(a, b) { - b = (b -= a = +a) || 1 / b; + b = b - (a = +a) ? 1 / (b - a) : 0; return function(x) { - return (x - a) / b; + return (x - a) * b; }; } function d3_uninterpolateClamp(a, b) { - b = (b -= a = +a) || 1 / b; + b = b - (a = +a) ? 1 / (b - a) : 0; return function(x) { - return Math.max(0, Math.min(1, (x - a) / b)); + return Math.max(0, Math.min(1, (x - a) * b)); }; } d3.layout = {}; @@ -6167,21 +5647,19 @@ return chord; }; 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, chargeDistance2 = d3_layout_forceChargeDistance2, gravity = .1, theta2 = .64, nodes = [], links = [], distances, strengths, charges; + 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, nodes = [], links = [], distances, strengths, charges; function repulse(node) { return function(quad, x1, _, x2) { if (quad.point !== node) { - var dx = quad.cx - node.x, dy = quad.cy - node.y, dw = x2 - x1, dn = dx * dx + dy * dy; - if (dw * dw / theta2 < dn) { - if (dn < chargeDistance2) { - var k = quad.charge / dn; - node.px -= dx * k; - node.py -= dy * k; - } + var dx = quad.cx - node.x, dy = quad.cy - node.y, dn = 1 / Math.sqrt(dx * dx + dy * dy); + if ((x2 - x1) * dn < theta) { + var k = quad.charge * dn * dn; + node.px -= dx * k; + node.py -= dy * k; return true; } - if (quad.point && dn && dn < chargeDistance2) { - var k = quad.pointCharge / dn; + if (quad.point && isFinite(dn)) { + var k = quad.pointCharge * dn * dn; node.px -= dx * k; node.py -= dy * k; } @@ -6285,19 +5763,14 @@ charge = typeof x === "function" ? x : +x; return force; }; - force.chargeDistance = function(x) { - if (!arguments.length) return Math.sqrt(chargeDistance2); - chargeDistance2 = 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 Math.sqrt(theta2); - theta2 = x * x; + if (!arguments.length) return theta; + theta = +x; return force; }; force.alpha = function(x) { @@ -6415,33 +5888,44 @@ quad.cx = cx / quad.charge; quad.cy = cy / quad.charge; } - var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1, d3_layout_forceChargeDistance2 = Infinity; + var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1; d3.layout.hierarchy = function() { var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; - function hierarchy(root) { - var stack = [ root ], nodes = [], node; - root.depth = 0; - while ((node = stack.pop()) != null) { - nodes.push(node); - if ((childs = children.call(hierarchy, node, node.depth)) && (n = childs.length)) { - var n, childs, child; - while (--n >= 0) { - stack.push(child = childs[n]); - child.parent = node; - child.depth = node.depth + 1; - } - if (value) node.value = 0; - node.children = childs; - } else { - if (value) node.value = +value.call(hierarchy, node, node.depth) || 0; - delete node.children; + function recurse(node, depth, nodes) { + var childs = children.call(hierarchy, node, depth); + node.depth = depth; + nodes.push(node); + if (childs && (n = childs.length)) { + var i = -1, n, c = node.children = new Array(n), v = 0, j = depth + 1, d; + while (++i < n) { + d = c[i] = recurse(childs[i], j, nodes); + d.parent = node; + v += d.value; + } + if (sort) c.sort(sort); + if (value) node.value = v; + } else { + delete node.children; + if (value) { + node.value = +value.call(hierarchy, node, depth) || 0; } } - d3_layout_hierarchyVisitAfter(root, function(node) { - var childs, parent; - if (sort && (childs = node.children)) childs.sort(sort); - if (value && (parent = node.parent)) parent.value += node.value; - }); + return node; + } + 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, node, depth) || 0; + } + if (value) node.value = v; + return v; + } + function hierarchy(d) { + var nodes = []; + recurse(d, 0, nodes); return nodes; } hierarchy.sort = function(x) { @@ -6460,16 +5944,7 @@ return hierarchy; }; hierarchy.revalue = function(root) { - if (value) { - d3_layout_hierarchyVisitBefore(root, function(node) { - if (node.children) node.value = 0; - }); - d3_layout_hierarchyVisitAfter(root, function(node) { - var parent; - if (!node.children) node.value = +value.call(hierarchy, node, node.depth) || 0; - if (parent = node.parent) parent.value += node.value; - }); - } + revalue(root, 0); return root; }; return hierarchy; @@ -6480,29 +5955,6 @@ object.links = d3_layout_hierarchyLinks; return object; } - function d3_layout_hierarchyVisitBefore(node, callback) { - var nodes = [ node ]; - while ((node = nodes.pop()) != null) { - callback(node); - if ((children = node.children) && (n = children.length)) { - var n, children; - while (--n >= 0) nodes.push(children[n]); - } - } - } - function d3_layout_hierarchyVisitAfter(node, callback) { - var nodes = [ node ], nodes2 = []; - while ((node = nodes.pop()) != null) { - nodes2.push(node); - if ((children = node.children) && (n = children.length)) { - var i = -1, n, children; - while (++i < n) nodes.push(children[i]); - } - } - while ((node = nodes2.pop()) != null) { - callback(node); - } - } function d3_layout_hierarchyChildren(d) { return d.children; } @@ -6560,50 +6012,49 @@ return d3_layout_hierarchyRebind(partition, hierarchy); }; d3.layout.pie = function() { - var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ, padAngle = 0; + var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = τ; function pie(data) { - var n = data.length, values = data.map(function(d, i) { + var values = data.map(function(d, i) { return +value.call(pie, d, i); - }), a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle), da = (typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a, p = Math.min(Math.abs(da) / n, +(typeof padAngle === "function" ? padAngle.apply(this, arguments) : padAngle)), pa = p * (da < 0 ? -1 : 1), k = (da - n * pa) / d3.sum(values), index = d3.range(n), arcs = [], v; + }); + var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle); + var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values); + 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]); }); + var arcs = []; index.forEach(function(i) { + var d; arcs[i] = { data: data[i], - value: v = values[i], + value: d = values[i], startAngle: a, - endAngle: a += v * k + pa, - padAngle: p + endAngle: a += d * k }; }); return arcs; } - pie.value = function(_) { + pie.value = function(x) { if (!arguments.length) return value; - value = _; + value = x; return pie; }; - pie.sort = function(_) { + pie.sort = function(x) { if (!arguments.length) return sort; - sort = _; + sort = x; return pie; }; - pie.startAngle = function(_) { + pie.startAngle = function(x) { if (!arguments.length) return startAngle; - startAngle = _; + startAngle = x; return pie; }; - pie.endAngle = function(_) { + pie.endAngle = function(x) { if (!arguments.length) return endAngle; - endAngle = _; - return pie; - }; - pie.padAngle = function(_) { - if (!arguments.length) return padAngle; - padAngle = _; + endAngle = x; return pie; }; return pie; @@ -6612,7 +6063,6 @@ d3.layout.stack = function() { var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; function stack(data, index) { - if (!(n = data.length)) return data; var series = data.map(function(d, i) { return values.call(stack, d, i); }); @@ -6625,7 +6075,7 @@ series = d3.permute(series, orders); points = d3.permute(points, orders); var offsets = offset.call(stack, points, index); - var m = series[0].length, n, i, j, o; + 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) { @@ -6820,6 +6270,185 @@ function d3_layout_histogramRange(values) { return [ d3.min(values), d3.max(values) ]; } + d3.layout.tree = function() { + var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; + 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; + } + 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 + }; + }); + firstWalk(root); + secondWalk(root, -root._tree.prelim); + 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; + d3_layout_treeVisitAfter(root, nodeSize ? function(node) { + node.x *= size[0]; + node.y = node.depth * size[1]; + delete node._tree; + } : 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 nodeSize ? null : size; + nodeSize = (size = x) == null; + return tree; + }; + tree.nodeSize = function(x) { + if (!arguments.length) return nodeSize ? size : null; + nodeSize = (size = x) != null; + return tree; + }; + return d3_layout_hierarchyRebind(tree, hierarchy); + }; + function d3_layout_treeSeparation(a, b) { + return a.parent == b.parent ? 1 : 2; + } + 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; + } d3.layout.pack = function() { var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ], radius; function pack(d, i) { @@ -6827,17 +6456,17 @@ return radius; }; root.x = root.y = 0; - d3_layout_hierarchyVisitAfter(root, function(d) { + d3_layout_treeVisitAfter(root, function(d) { d.r = +r(d.value); }); - d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); + d3_layout_treeVisitAfter(root, d3_layout_packSiblings); if (padding) { var dr = padding * (radius ? 1 : Math.max(2 * root.r / w, 2 * root.r / h)) / 2; - d3_layout_hierarchyVisitAfter(root, function(d) { + d3_layout_treeVisitAfter(root, function(d) { d.r += dr; }); - d3_layout_hierarchyVisitAfter(root, d3_layout_packSiblings); - d3_layout_hierarchyVisitAfter(root, function(d) { + d3_layout_treeVisitAfter(root, d3_layout_packSiblings); + d3_layout_treeVisitAfter(root, function(d) { d.r -= dr; }); } @@ -6974,158 +6603,11 @@ c.y = a.y; } } - d3.layout.tree = function() { - var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = null; - function tree(d, i) { - var nodes = hierarchy.call(this, d, i), root0 = nodes[0], root1 = wrapTree(root0); - d3_layout_hierarchyVisitAfter(root1, firstWalk), root1.parent.m = -root1.z; - d3_layout_hierarchyVisitBefore(root1, secondWalk); - if (nodeSize) d3_layout_hierarchyVisitBefore(root0, sizeNode); else { - var left = root0, right = root0, bottom = root0; - d3_layout_hierarchyVisitBefore(root0, function(node) { - if (node.x < left.x) left = node; - if (node.x > right.x) right = node; - if (node.depth > bottom.depth) bottom = node; - }); - var tx = separation(left, right) / 2 - left.x, kx = size[0] / (right.x + separation(right, left) / 2 + tx), ky = size[1] / (bottom.depth || 1); - d3_layout_hierarchyVisitBefore(root0, function(node) { - node.x = (node.x + tx) * kx; - node.y = node.depth * ky; - }); - } - return nodes; - } - function wrapTree(root0) { - var root1 = { - A: null, - children: [ root0 ] - }, queue = [ root1 ], node1; - while ((node1 = queue.pop()) != null) { - for (var children = node1.children, child, i = 0, n = children.length; i < n; ++i) { - queue.push((children[i] = child = { - _: children[i], - parent: node1, - children: (child = children[i].children) && child.slice() || [], - A: null, - a: null, - z: 0, - m: 0, - c: 0, - s: 0, - t: null, - i: i - }).a = child); - } - } - return root1.children[0]; - } - function firstWalk(v) { - var children = v.children, siblings = v.parent.children, w = v.i ? siblings[v.i - 1] : null; - if (children.length) { - d3_layout_treeShift(v); - var midpoint = (children[0].z + children[children.length - 1].z) / 2; - if (w) { - v.z = w.z + separation(v._, w._); - v.m = v.z - midpoint; - } else { - v.z = midpoint; - } - } else if (w) { - v.z = w.z + separation(v._, w._); - } - v.parent.A = apportion(v, w, v.parent.A || siblings[0]); - } - function secondWalk(v) { - v._.x = v.z + v.parent.m; - v.m += v.parent.m; - } - function apportion(v, w, ancestor) { - if (w) { - var vip = v, vop = v, vim = w, vom = vip.parent.children[0], sip = vip.m, sop = vop.m, sim = vim.m, som = vom.m, 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.a = v; - shift = vim.z + sim - vip.z - sip + separation(vim._, vip._); - if (shift > 0) { - d3_layout_treeMove(d3_layout_treeAncestor(vim, v, ancestor), v, shift); - sip += shift; - sop += shift; - } - sim += vim.m; - sip += vip.m; - som += vom.m; - sop += vop.m; - } - if (vim && !d3_layout_treeRight(vop)) { - vop.t = vim; - vop.m += sim - sop; - } - if (vip && !d3_layout_treeLeft(vom)) { - vom.t = vip; - vom.m += sip - som; - ancestor = v; - } - } - return ancestor; - } - function sizeNode(node) { - node.x *= size[0]; - node.y = node.depth * size[1]; - } - tree.separation = function(x) { - if (!arguments.length) return separation; - separation = x; - return tree; - }; - tree.size = function(x) { - if (!arguments.length) return nodeSize ? null : size; - nodeSize = (size = x) == null ? sizeNode : null; - return tree; - }; - tree.nodeSize = function(x) { - if (!arguments.length) return nodeSize ? size : null; - nodeSize = (size = x) == null ? null : sizeNode; - return tree; - }; - return d3_layout_hierarchyRebind(tree, hierarchy); - }; - function d3_layout_treeSeparation(a, b) { - return a.parent == b.parent ? 1 : 2; - } - function d3_layout_treeLeft(v) { - var children = v.children; - return children.length ? children[0] : v.t; - } - function d3_layout_treeRight(v) { - var children = v.children, n; - return (n = children.length) ? children[n - 1] : v.t; - } - function d3_layout_treeMove(wm, wp, shift) { - var change = shift / (wp.i - wm.i); - wp.c -= change; - wp.s += shift; - wm.c += change; - wp.z += shift; - wp.m += shift; - } - function d3_layout_treeShift(v) { - var shift = 0, change = 0, children = v.children, i = children.length, w; - while (--i >= 0) { - w = children[i]; - w.z += shift; - w.m += shift; - shift += w.s + (change += w.c); - } - } - function d3_layout_treeAncestor(vim, v, ancestor) { - return vim.a.parent === v.parent ? vim.a : ancestor; - } d3.layout.cluster = function() { var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ], nodeSize = false; function cluster(d, i) { var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; - d3_layout_hierarchyVisitAfter(root, function(node) { + d3_layout_treeVisitAfter(root, function(node) { var children = node.children; if (children && children.length) { node.x = d3_layout_clusterX(children); @@ -7137,7 +6619,7 @@ } }); 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; - d3_layout_hierarchyVisitAfter(root, nodeSize ? function(node) { + d3_layout_treeVisitAfter(root, nodeSize ? function(node) { node.x = (node.x - root.x) * size[0]; node.y = (root.y - node.y) * size[1]; } : function(node) { @@ -7516,24 +6998,9 @@ } function d3_scale_linearTickFormat(domain, m, format) { var range = d3_scale_linearTickRange(domain, m); - if (format) { - var match = d3_format_re.exec(format); - match.shift(); - if (match[8] === "s") { - var prefix = d3.formatPrefix(Math.max(abs(range[0]), abs(range[1]))); - if (!match[7]) match[7] = "." + d3_scale_linearPrecision(prefix.scale(range[2])); - match[8] = "f"; - format = d3.format(match.join("")); - return function(d) { - return format(prefix.scale(d)) + prefix.symbol; - }; - } - if (!match[7]) match[7] = "." + d3_scale_linearFormatPrecision(match[8], range); - format = match.join(""); - } else { - format = ",." + d3_scale_linearPrecision(range[2]) + "f"; - } - return d3.format(format); + return d3.format(format ? format.replace(d3_format_re, function(a, b, c, d, e, f, g, h, i, j) { + return [ b, c, d, e, f, g, h, i || "." + d3_scale_linearFormatPrecision(j, range), j ].join(""); + }) : ",." + d3_scale_linearPrecision(range[2]) + "f"); } var d3_scale_linearFormatSignificant = { s: 1, @@ -7547,7 +7014,7 @@ } function d3_scale_linearFormatPrecision(type, range) { var p = d3_scale_linearPrecision(range[2]); - return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(abs(range[0]), abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2; + return type in d3_scale_linearFormatSignificant ? Math.abs(p - d3_scale_linearPrecision(Math.max(Math.abs(range[0]), Math.abs(range[1])))) + +(type !== "e") : p - (type === "%") * 2; } d3.scale.log = function() { return d3_scale_log(d3.scale.linear().domain([ 0, 1 ]), 10, true, [ 1, 10 ]); @@ -7675,7 +7142,7 @@ function d3_scale_ordinal(domain, ranger) { var index, range, rangeBand; function scale(x) { - return range[((index.get(x) || (ranger.t === "range" ? index.set(x, domain.push(x)) : NaN)) - 1) % range.length]; + return range[((index.get(x) || ranger.t === "range" && index.set(x, domain.push(x))) - 1) % range.length]; } function steps(start, step) { return d3.range(domain.length).map(function(i) { @@ -7702,9 +7169,8 @@ }; scale.rangePoints = function(x, padding) { if (arguments.length < 2) padding = 0; - var start = x[0], stop = x[1], step = domain.length < 2 ? (start = (start + stop) / 2, - 0) : (stop - start) / (domain.length - 1 + padding); - range = steps(start + step * padding / 2, step); + var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding); + range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); rangeBand = 0; ranger = { t: "rangePoints", @@ -7712,18 +7178,6 @@ }; return scale; }; - scale.rangeRoundPoints = function(x, padding) { - if (arguments.length < 2) padding = 0; - var start = x[0], stop = x[1], step = domain.length < 2 ? (start = stop = Math.round((start + stop) / 2), - 0) : (stop - start) / (domain.length - 1 + padding) | 0; - range = steps(start + Math.round(step * padding / 2 + (stop - start - (domain.length - 1 + padding) * step) / 2), step); - rangeBand = 0; - ranger = { - t: "rangeRoundPoints", - a: arguments - }; - return scale; - }; scale.rangeBands = function(x, padding, outerPadding) { if (arguments.length < 2) padding = 0; if (arguments.length < 3) outerPadding = padding; @@ -7740,8 +7194,8 @@ scale.rangeRoundBands = function(x, padding, outerPadding) { if (arguments.length < 2) padding = 0; if (arguments.length < 3) outerPadding = padding; - var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)); - range = steps(start + Math.round((stop - start - (domain.length - padding) * step) / 2), step); + var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), 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 = { @@ -7793,7 +7247,9 @@ } scale.domain = function(x) { if (!arguments.length) return domain; - domain = x.map(d3_number).filter(d3_numeric).sort(d3_ascending); + domain = x.filter(function(d) { + return !isNaN(d); + }).sort(d3.ascending); return rescale(); }; scale.range = function(x) { @@ -7898,86 +7354,12 @@ return identity; } d3.svg = {}; - function d3_zero() { - return 0; - } d3.svg.arc = function() { - var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, cornerRadius = d3_zero, padRadius = d3_svg_arcAuto, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle, padAngle = d3_svg_arcPadAngle; + var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; function arc() { - var r0 = Math.max(0, +innerRadius.apply(this, arguments)), r1 = Math.max(0, +outerRadius.apply(this, arguments)), a0 = startAngle.apply(this, arguments) - halfπ, a1 = endAngle.apply(this, arguments) - halfπ, da = Math.abs(a1 - a0), cw = a0 > a1 ? 0 : 1; - if (r1 < r0) rc = r1, r1 = r0, r0 = rc; - if (da >= τε) return circleSegment(r1, cw) + (r0 ? circleSegment(r0, 1 - cw) : "") + "Z"; - var rc, cr, rp, ap, p0 = 0, p1 = 0, x0, y0, x1, y1, x2, y2, x3, y3, path = []; - if (ap = (+padAngle.apply(this, arguments) || 0) / 2) { - rp = padRadius === d3_svg_arcAuto ? Math.sqrt(r0 * r0 + r1 * r1) : +padRadius.apply(this, arguments); - if (!cw) p1 *= -1; - if (r1) p1 = d3_asin(rp / r1 * Math.sin(ap)); - if (r0) p0 = d3_asin(rp / r0 * Math.sin(ap)); - } - if (r1) { - x0 = r1 * Math.cos(a0 + p1); - y0 = r1 * Math.sin(a0 + p1); - x1 = r1 * Math.cos(a1 - p1); - y1 = r1 * Math.sin(a1 - p1); - var l1 = Math.abs(a1 - a0 - 2 * p1) <= π ? 0 : 1; - if (p1 && d3_svg_arcSweep(x0, y0, x1, y1) === cw ^ l1) { - var h1 = (a0 + a1) / 2; - x0 = r1 * Math.cos(h1); - y0 = r1 * Math.sin(h1); - x1 = y1 = null; - } - } else { - x0 = y0 = 0; - } - if (r0) { - x2 = r0 * Math.cos(a1 - p0); - y2 = r0 * Math.sin(a1 - p0); - x3 = r0 * Math.cos(a0 + p0); - y3 = r0 * Math.sin(a0 + p0); - var l0 = Math.abs(a0 - a1 + 2 * p0) <= π ? 0 : 1; - if (p0 && d3_svg_arcSweep(x2, y2, x3, y3) === 1 - cw ^ l0) { - var h0 = (a0 + a1) / 2; - x2 = r0 * Math.cos(h0); - y2 = r0 * Math.sin(h0); - x3 = y3 = null; - } - } else { - x2 = y2 = 0; - } - if ((rc = Math.min(Math.abs(r1 - r0) / 2, +cornerRadius.apply(this, arguments))) > .001) { - cr = r0 < r1 ^ cw ? 0 : 1; - var oc = x3 == null ? [ x2, y2 ] : x1 == null ? [ x0, y0 ] : d3_geom_polygonIntersect([ x0, y0 ], [ x3, y3 ], [ x1, y1 ], [ x2, y2 ]), ax = x0 - oc[0], ay = y0 - oc[1], bx = x1 - oc[0], by = y1 - oc[1], kc = 1 / Math.sin(Math.acos((ax * bx + ay * by) / (Math.sqrt(ax * ax + ay * ay) * Math.sqrt(bx * bx + by * by))) / 2), lc = Math.sqrt(oc[0] * oc[0] + oc[1] * oc[1]); - if (x1 != null) { - var rc1 = Math.min(rc, (r1 - lc) / (kc + 1)), t30 = d3_svg_arcCornerTangents(x3 == null ? [ x2, y2 ] : [ x3, y3 ], [ x0, y0 ], r1, rc1, cw), t12 = d3_svg_arcCornerTangents([ x1, y1 ], [ x2, y2 ], r1, rc1, cw); - if (rc === rc1) { - path.push("M", t30[0], "A", rc1, ",", rc1, " 0 0,", cr, " ", t30[1], "A", r1, ",", r1, " 0 ", 1 - cw ^ d3_svg_arcSweep(t30[1][0], t30[1][1], t12[1][0], t12[1][1]), ",", cw, " ", t12[1], "A", rc1, ",", rc1, " 0 0,", cr, " ", t12[0]); - } else { - path.push("M", t30[0], "A", rc1, ",", rc1, " 0 1,", cr, " ", t12[0]); - } - } else { - path.push("M", x0, ",", y0); - } - if (x3 != null) { - var rc0 = Math.min(rc, (r0 - lc) / (kc - 1)), t03 = d3_svg_arcCornerTangents([ x0, y0 ], [ x3, y3 ], r0, -rc0, cw), t21 = d3_svg_arcCornerTangents([ x2, y2 ], x1 == null ? [ x0, y0 ] : [ x1, y1 ], r0, -rc0, cw); - if (rc === rc0) { - path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t21[1], "A", r0, ",", r0, " 0 ", cw ^ d3_svg_arcSweep(t21[1][0], t21[1][1], t03[1][0], t03[1][1]), ",", 1 - cw, " ", t03[1], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); - } else { - path.push("L", t21[0], "A", rc0, ",", rc0, " 0 0,", cr, " ", t03[0]); - } - } else { - path.push("L", x2, ",", y2); - } - } else { - path.push("M", x0, ",", y0); - if (x1 != null) path.push("A", r1, ",", r1, " 0 ", l1, ",", cw, " ", x1, ",", y1); - path.push("L", x2, ",", y2); - if (x3 != null) path.push("A", r0, ",", r0, " 0 ", l0, ",", 1 - cw, " ", x3, ",", y3); - } - path.push("Z"); - return path.join(""); - } - function circleSegment(r1, cw) { - return "M0," + r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + -r1 + "A" + r1 + "," + r1 + " 0 1," + cw + " 0," + r1; + 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 < π ? "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; @@ -7989,16 +7371,6 @@ outerRadius = d3_functor(v); return arc; }; - arc.cornerRadius = function(v) { - if (!arguments.length) return cornerRadius; - cornerRadius = d3_functor(v); - return arc; - }; - arc.padRadius = function(v) { - if (!arguments.length) return padRadius; - padRadius = v == d3_svg_arcAuto ? d3_svg_arcAuto : d3_functor(v); - return arc; - }; arc.startAngle = function(v) { if (!arguments.length) return startAngle; startAngle = d3_functor(v); @@ -8009,18 +7381,13 @@ endAngle = d3_functor(v); return arc; }; - arc.padAngle = function(v) { - if (!arguments.length) return padAngle; - padAngle = 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 - halfπ; + 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_arcAuto = "auto"; + var d3_svg_arcOffset = -halfπ, d3_svg_arcMax = τ - ε; function d3_svg_arcInnerRadius(d) { return d.innerRadius; } @@ -8033,17 +7400,6 @@ function d3_svg_arcEndAngle(d) { return d.endAngle; } - function d3_svg_arcPadAngle(d) { - return d && d.padAngle; - } - function d3_svg_arcSweep(x0, y0, x1, y1) { - return (x0 - x1) * y0 - (y0 - y1) * x0 > 0 ? 0 : 1; - } - function d3_svg_arcCornerTangents(p0, p1, r1, rc, cw) { - var x01 = p0[0] - p1[0], y01 = p0[1] - p1[1], lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), ox = lo * y01, oy = -lo * x01, x1 = p0[0] + ox, y1 = p0[1] + oy, x2 = p1[0] + ox, y2 = p1[1] + oy, x3 = (x1 + x2) / 2, y3 = (y1 + y2) / 2, dx = x2 - x1, dy = y2 - y1, d2 = dx * dx + dy * dy, r = r1 - rc, D = x1 * y2 - x2 * y1, d = (dy < 0 ? -1 : 1) * Math.sqrt(r * r * d2 - D * D), cx0 = (D * dy - dx * d) / d2, cy0 = (-D * dx - dy * d) / d2, cx1 = (D * dy + dx * d) / d2, cy1 = (-D * dx + dy * d) / d2, dx0 = cx0 - x3, dy0 = cy0 - y3, dx1 = cx1 - x3, dy1 = cy1 - y3; - if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; - return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ]; - } function d3_svg_line(projection) { var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; function line(data) { @@ -8134,7 +7490,7 @@ return path.join(""); } function d3_svg_lineCardinalOpen(points, tension) { - return points.length < 4 ? d3_svg_lineLinear(points) : points[1] + d3_svg_lineHermite(points.slice(1, -1), d3_svg_lineCardinalTangents(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)); } function d3_svg_lineCardinalClosed(points, tension) { return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite((points.push(points[0]), @@ -8304,7 +7660,7 @@ while (++i < n) { point = points[i]; r = point[0]; - a = point[1] - halfπ; + a = point[1] + d3_svg_arcOffset; point[0] = r * Math.cos(a); point[1] = r * Math.sin(a); } @@ -8405,7 +7761,7 @@ 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) - halfπ, a1 = endAngle.call(self, subgroup, i) - halfπ; + 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, @@ -8495,7 +7851,7 @@ }; function d3_svg_diagonalRadialProjection(projection) { return function() { - var d = projection.apply(this, arguments), r = d[0], a = d[1] - halfπ; + var d = projection.apply(this, arguments), r = d[0], a = d[1] + d3_svg_arcOffset; return [ r * Math.cos(a), r * Math.sin(a) ]; }; } @@ -8551,39 +7907,8 @@ }); d3.svg.symbolTypes = d3_svg_symbols.keys(); var d3_svg_symbolSqrt3 = Math.sqrt(3), d3_svg_symbolTan30 = Math.tan(30 * d3_radians); - d3_selectionPrototype.transition = function(name) { - var id = d3_transitionInheritId || ++d3_transitionId, ns = d3_transitionNamespace(name), subgroups = [], subgroup, node, transition = d3_transitionInherit || { - time: Date.now(), - ease: d3_ease_cubicInOut, - delay: 0, - duration: 250 - }; - 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]) d3_transitionNode(node, i, ns, id, transition); - subgroup.push(node); - } - } - return d3_transition(subgroups, ns, id); - }; - d3_selectionPrototype.interrupt = function(name) { - return this.each(name == null ? d3_selection_interrupt : d3_selection_interruptNS(d3_transitionNamespace(name))); - }; - var d3_selection_interrupt = d3_selection_interruptNS(d3_transitionNamespace()); - function d3_selection_interruptNS(ns) { - return function() { - var lock, active; - if ((lock = this[ns]) && (active = lock[lock.active])) { - if (--lock.count) delete lock[lock.active]; else delete this[ns]; - lock.active += .5; - active.event && active.event.interrupt.call(this, this.__data__, active.index); - } - }; - } - function d3_transition(groups, ns, id) { + function d3_transition(groups, id) { d3_subclass(groups, d3_transitionPrototype); - groups.namespace = ns; groups.id = id; return groups; } @@ -8592,44 +7917,44 @@ d3_transitionPrototype.empty = d3_selectionPrototype.empty; d3_transitionPrototype.node = d3_selectionPrototype.node; d3_transitionPrototype.size = d3_selectionPrototype.size; - d3.transition = function(selection, name) { - return selection && selection.transition ? d3_transitionInheritId ? selection.transition(name) : selection : d3_selectionRoot.transition(selection); + d3.transition = function(selection) { + return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition(); }; d3.transition.prototype = d3_transitionPrototype; d3_transitionPrototype.select = function(selector) { - var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnode, node; + var id = this.id, subgroups = [], subgroup, subnode, node; 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.__data__, i, j))) { if ("__data__" in node) subnode.__data__ = node.__data__; - d3_transitionNode(subnode, i, ns, id, node[ns][id]); + d3_transitionNode(subnode, i, id, node.__transition__[id]); subgroup.push(subnode); } else { subgroup.push(null); } } } - return d3_transition(subgroups, ns, id); + return d3_transition(subgroups, id); }; d3_transitionPrototype.selectAll = function(selector) { - var id = this.id, ns = this.namespace, subgroups = [], subgroup, subnodes, node, subnode, transition; + var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition; 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]) { - transition = node[ns][id]; + transition = node.__transition__[id]; subnodes = selector.call(node, node.__data__, i, j); subgroups.push(subgroup = []); for (var k = -1, o = subnodes.length; ++k < o; ) { - if (subnode = subnodes[k]) d3_transitionNode(subnode, k, ns, id, transition); + if (subnode = subnodes[k]) d3_transitionNode(subnode, k, id, transition); subgroup.push(subnode); } } } } - return d3_transition(subgroups, ns, id); + return d3_transition(subgroups, id); }; d3_transitionPrototype.filter = function(filter) { var subgroups = [], subgroup, group, node; @@ -8642,23 +7967,23 @@ } } } - return d3_transition(subgroups, this.namespace, this.id); + return d3_transition(subgroups, this.id); }; d3_transitionPrototype.tween = function(name, tween) { - var id = this.id, ns = this.namespace; - if (arguments.length < 2) return this.node()[ns][id].tween.get(name); + var id = this.id; + if (arguments.length < 2) return this.node().__transition__[id].tween.get(name); return d3_selection_each(this, tween == null ? function(node) { - node[ns][id].tween.remove(name); + node.__transition__[id].tween.remove(name); } : function(node) { - node[ns][id].tween.set(name, tween); + node.__transition__[id].tween.set(name, tween); }); }; function d3_transition_tween(groups, name, value, tween) { - var id = groups.id, ns = groups.namespace; + var id = groups.id; return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { - node[ns][id].tween.set(name, tween(value.call(node, node.__data__, i, j))); + node.__transition__[id].tween.set(name, tween(value.call(node, node.__data__, i, j))); } : (value = tween(value), function(node) { - node[ns][id].tween.set(name, value); + node.__transition__[id].tween.set(name, value); })); } d3_transitionPrototype.attr = function(nameNS, value) { @@ -8750,84 +8075,71 @@ }; } d3_transitionPrototype.remove = function() { - var ns = this.namespace; return this.each("end.transition", function() { var p; - if (this[ns].count < 2 && (p = this.parentNode)) p.removeChild(this); + if (this.__transition__.count < 2 && (p = this.parentNode)) p.removeChild(this); }); }; d3_transitionPrototype.ease = function(value) { - var id = this.id, ns = this.namespace; - if (arguments.length < 1) return this.node()[ns][id].ease; + var id = this.id; + if (arguments.length < 1) return this.node().__transition__[id].ease; if (typeof value !== "function") value = d3.ease.apply(d3, arguments); return d3_selection_each(this, function(node) { - node[ns][id].ease = value; + node.__transition__[id].ease = value; }); }; d3_transitionPrototype.delay = function(value) { - var id = this.id, ns = this.namespace; - if (arguments.length < 1) return this.node()[ns][id].delay; + var id = this.id; return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node[ns][id].delay = +value.call(node, node.__data__, i, j); + node.__transition__[id].delay = +value.call(node, node.__data__, i, j); } : (value = +value, function(node) { - node[ns][id].delay = value; + node.__transition__[id].delay = value; })); }; d3_transitionPrototype.duration = function(value) { - var id = this.id, ns = this.namespace; - if (arguments.length < 1) return this.node()[ns][id].duration; + var id = this.id; return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node[ns][id].duration = Math.max(1, value.call(node, node.__data__, i, j)); + node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j)); } : (value = Math.max(1, value), function(node) { - node[ns][id].duration = value; + node.__transition__[id].duration = value; })); }; d3_transitionPrototype.each = function(type, listener) { - var id = this.id, ns = this.namespace; + var id = this.id; if (arguments.length < 2) { var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; - try { - d3_transitionInheritId = id; - d3_selection_each(this, function(node, i, j) { - d3_transitionInherit = node[ns][id]; - type.call(node, node.__data__, i, j); - }); - } finally { - d3_transitionInherit = inherit; - d3_transitionInheritId = inheritId; - } + d3_transitionInheritId = id; + d3_selection_each(this, function(node, i, j) { + d3_transitionInherit = node.__transition__[id]; + type.call(node, node.__data__, i, j); + }); + d3_transitionInherit = inherit; + d3_transitionInheritId = inheritId; } else { d3_selection_each(this, function(node) { - var transition = node[ns][id]; - (transition.event || (transition.event = d3.dispatch("start", "end", "interrupt"))).on(type, listener); + var transition = node.__transition__[id]; + (transition.event || (transition.event = d3.dispatch("start", "end"))).on(type, listener); }); } return this; }; d3_transitionPrototype.transition = function() { - var id0 = this.id, id1 = ++d3_transitionId, ns = this.namespace, subgroups = [], subgroup, group, node, transition; + var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition; for (var j = 0, m = this.length; j < m; j++) { subgroups.push(subgroup = []); for (var group = this[j], i = 0, n = group.length; i < n; i++) { if (node = group[i]) { - transition = node[ns][id0]; - d3_transitionNode(node, i, ns, id1, { - time: transition.time, - ease: transition.ease, - delay: transition.delay + transition.duration, - duration: transition.duration - }); + transition = Object.create(node.__transition__[id0]); + transition.delay += transition.duration; + d3_transitionNode(node, i, id1, transition); } subgroup.push(node); } } - return d3_transition(subgroups, ns, id1); + return d3_transition(subgroups, id1); }; - function d3_transitionNamespace(name) { - return name == null ? "__transition__" : "__transition_" + name + "__"; - } - function d3_transitionNode(node, i, ns, id, inherit) { - var lock = node[ns] || (node[ns] = { + function d3_transitionNode(node, i, id, inherit) { + var lock = node.__transition__ || (node.__transition__ = { active: 0, count: 0 }), transition = lock[id]; @@ -8836,53 +8148,43 @@ transition = lock[id] = { tween: new d3_Map(), time: time, - delay: inherit.delay, - duration: inherit.duration, ease: inherit.ease, - index: i + delay: inherit.delay, + duration: inherit.duration }; - inherit = null; ++lock.count; d3.timer(function(elapsed) { - var delay = transition.delay, duration, ease, timer = d3_timer_active, tweened = []; + var d = node.__data__, ease = transition.ease, delay = transition.delay, duration = transition.duration, timer = d3_timer_active, tweened = []; timer.t = delay + time; if (delay <= elapsed) return start(elapsed - delay); timer.c = start; function start(elapsed) { if (lock.active > id) return stop(); - var active = lock[lock.active]; - if (active) { - --lock.count; - delete lock[lock.active]; - active.event && active.event.interrupt.call(node, node.__data__, active.index); - } lock.active = id; - transition.event && transition.event.start.call(node, node.__data__, i); + transition.event && transition.event.start.call(node, d, i); transition.tween.forEach(function(key, value) { - if (value = value.call(node, node.__data__, i)) { + if (value = value.call(node, d, i)) { tweened.push(value); } }); - ease = transition.ease; - duration = transition.duration; d3.timer(function() { timer.c = tick(elapsed || 1) ? d3_true : tick; return 1; }, 0, time); } function tick(elapsed) { - if (lock.active !== id) return 1; + if (lock.active !== id) return stop(); var t = elapsed / duration, e = ease(t), n = tweened.length; while (n > 0) { tweened[--n].call(node, e); } if (t >= 1) { - transition.event && transition.event.end.call(node, node.__data__, i); + transition.event && transition.event.end.call(node, d, i); return stop(); } } function stop() { - if (--lock.count) delete lock[id]; else delete node[ns]; + if (--lock.count) delete lock[id]; else delete node.__transition__; return 1; } }, 0, time); @@ -8894,25 +8196,61 @@ g.each(function() { var g = d3.select(this); var scale0 = this.__chart__ || scale, scale1 = this.__chart__ = scale.copy(); - var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick.order()).style("opacity", 1), tickSpacing = Math.max(innerTickSize, 0) + tickPadding, tickTransform; + var ticks = tickValues == null ? scale1.ticks ? scale1.ticks.apply(scale1, tickArguments_) : scale1.domain() : tickValues, tickFormat = tickFormat_ == null ? scale1.tickFormat ? scale1.tickFormat.apply(scale1, tickArguments_) : d3_identity : tickFormat_, tick = g.selectAll(".tick").data(ticks, scale1), tickEnter = tick.enter().insert("g", ".domain").attr("class", "tick").style("opacity", ε), tickExit = d3.transition(tick.exit()).style("opacity", ε).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform; var range = d3_scaleRange(scale1), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), d3.transition(path)); tickEnter.append("line"); tickEnter.append("text"); - var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"), sign = orient === "top" || orient === "left" ? -1 : 1, x1, x2, y1, y2; - if (orient === "bottom" || orient === "top") { - tickTransform = d3_svg_axisX, x1 = "x", y1 = "y", x2 = "x2", y2 = "y2"; - text.attr("dy", sign < 0 ? "0em" : ".71em").style("text-anchor", "middle"); - pathUpdate.attr("d", "M" + range[0] + "," + sign * outerTickSize + "V0H" + range[1] + "V" + sign * outerTickSize); - } else { - tickTransform = d3_svg_axisY, x1 = "y", y1 = "x", x2 = "y2", y2 = "x2"; - text.attr("dy", ".32em").style("text-anchor", sign < 0 ? "end" : "start"); - pathUpdate.attr("d", "M" + sign * outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + sign * outerTickSize); + var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); + switch (orient) { + case "bottom": + { + tickTransform = d3_svg_axisX; + lineEnter.attr("y2", innerTickSize); + textEnter.attr("y", Math.max(innerTickSize, 0) + tickPadding); + lineUpdate.attr("x2", 0).attr("y2", innerTickSize); + textUpdate.attr("x", 0).attr("y", Math.max(innerTickSize, 0) + tickPadding); + text.attr("dy", ".71em").style("text-anchor", "middle"); + pathUpdate.attr("d", "M" + range[0] + "," + outerTickSize + "V0H" + range[1] + "V" + outerTickSize); + break; + } + + case "top": + { + tickTransform = d3_svg_axisX; + lineEnter.attr("y2", -innerTickSize); + textEnter.attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); + lineUpdate.attr("x2", 0).attr("y2", -innerTickSize); + textUpdate.attr("x", 0).attr("y", -(Math.max(innerTickSize, 0) + tickPadding)); + text.attr("dy", "0em").style("text-anchor", "middle"); + pathUpdate.attr("d", "M" + range[0] + "," + -outerTickSize + "V0H" + range[1] + "V" + -outerTickSize); + break; + } + + case "left": + { + tickTransform = d3_svg_axisY; + lineEnter.attr("x2", -innerTickSize); + textEnter.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)); + lineUpdate.attr("x2", -innerTickSize).attr("y2", 0); + textUpdate.attr("x", -(Math.max(innerTickSize, 0) + tickPadding)).attr("y", 0); + text.attr("dy", ".32em").style("text-anchor", "end"); + pathUpdate.attr("d", "M" + -outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + -outerTickSize); + break; + } + + case "right": + { + tickTransform = d3_svg_axisY; + lineEnter.attr("x2", innerTickSize); + textEnter.attr("x", Math.max(innerTickSize, 0) + tickPadding); + lineUpdate.attr("x2", innerTickSize).attr("y2", 0); + textUpdate.attr("x", Math.max(innerTickSize, 0) + tickPadding).attr("y", 0); + text.attr("dy", ".32em").style("text-anchor", "start"); + pathUpdate.attr("d", "M" + outerTickSize + "," + range[0] + "H0V" + range[1] + "H" + outerTickSize); + break; + } } - lineEnter.attr(y2, sign * innerTickSize); - textEnter.attr(y1, sign * tickSpacing); - lineUpdate.attr(x2, 0).attr(y2, sign * innerTickSize); - textUpdate.attr(x1, 0).attr(y1, sign * tickSpacing); if (scale1.rangeBand) { var x = scale1, dx = x.rangeBand() / 2; scale0 = scale1 = function(d) { @@ -8921,10 +8259,10 @@ } else if (scale0.rangeBand) { scale0 = scale1; } else { - tickExit.call(tickTransform, scale1, scale0); + tickExit.call(tickTransform, scale1); } - tickEnter.call(tickTransform, scale0, scale1); - tickUpdate.call(tickTransform, scale1, scale1); + tickEnter.call(tickTransform, scale0); + tickUpdate.call(tickTransform, scale1); }); } axis.scale = function(x) { @@ -8985,16 +8323,14 @@ bottom: 1, left: 1 }; - function d3_svg_axisX(selection, x0, x1) { + function d3_svg_axisX(selection, x) { selection.attr("transform", function(d) { - var v0 = x0(d); - return "translate(" + (isFinite(v0) ? v0 : x1(d)) + ",0)"; + return "translate(" + x(d) + ",0)"; }); } - function d3_svg_axisY(selection, y0, y1) { + function d3_svg_axisY(selection, y) { selection.attr("transform", function(d) { - var v0 = y0(d); - return "translate(0," + (isFinite(v0) ? v0 : y1(d)) + ")"; + return "translate(0," + y(d) + ")"; }); } d3.svg.brush = function() { @@ -9287,8 +8623,491 @@ sw: "nesw-resize" }; var d3_svg_brushResizes = [ [ "n", "e", "s", "w", "nw", "ne", "se", "sw" ], [ "e", "w" ], [ "n", "s" ], [] ]; - var d3_time_format = d3_time.format = d3_locale_enUS.timeFormat; - var d3_time_formatUtc = d3_time_format.utc; + var d3_time = d3.time = {}, d3_date = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; + function d3_date_utc() { + this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); + } + d3_date_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; + var d3_time_formatDateTime = "%a %b %e %X %Y", d3_time_formatDate = "%m/%d/%Y", d3_time_formatTime = "%H:%M:%S"; + var d3_time_days = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], d3_time_dayAbbreviations = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], d3_time_monthAbbreviations = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; + 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_date(date - 1)), 1); + return date; + } + function offset(date, k) { + step(date = new d3_date(+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_date = d3_date_utc; + var utc = new d3_date_utc(); + utc._ = t0; + return range(utc, t1, dt); + } finally { + d3_date = 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_date = d3_date_utc; + var utc = new d3_date_utc(); + utc._ = date; + return method(utc, k)._; + } finally { + d3_date = Date; + } + }; + } + d3_time.year = d3_time_interval(function(date) { + date = d3_time.day(date); + date.setMonth(0, 1); + return date; + }, 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; + d3_time.day = d3_time_interval(function(date) { + var day = new d3_date(2e3, 0); + day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); + return day; + }, 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 - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); + }; + d3_time_daySymbols.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.format = d3_time_format; + function d3_time_format(template) { + var n = template.length; + function format(date) { + var string = [], i = -1, j = 0, c, p, f; + while (++i < n) { + if (template.charCodeAt(i) === 37) { + string.push(template.substring(j, i)); + if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); + if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); + string.push(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, + Z: null + }, i = d3_time_parse(d, template, string, 0); + if (i != string.length) return null; + if ("p" in d) d.H = d.H % 12 + d.p * 12; + var localZ = d.Z != null && d3_date !== d3_date_utc, date = new (localZ ? d3_date_utc : d3_date)(); + if ("j" in d) date.setFullYear(d.y, 0, d.j); else if ("w" in d && ("W" in d || "U" in d)) { + date.setFullYear(d.y, 0, 1); + date.setFullYear(d.y, 0, "W" in d ? (d.w + 6) % 7 + d.W * 7 - (date.getDay() + 5) % 7 : d.w + d.U * 7 - (date.getDay() + 6) % 7); + } else date.setFullYear(d.y, d.m, d.d); + date.setHours(d.H + Math.floor(d.Z / 100), d.M + d.Z % 100, d.S, d.L); + return localZ ? date._ : date; + }; + format.toString = function() { + return template; + }; + return format; + } + function d3_time_parse(date, template, string, j) { + var c, p, t, i = 0, n = template.length, m = string.length; + while (i < n) { + if (j >= m) return -1; + c = template.charCodeAt(i++); + if (c === 37) { + t = template.charAt(i++); + p = d3_time_parsers[t in d3_time_formatPads ? template.charAt(i++) : t]; + if (!p || (j = p(date, string, j)) < 0) return -1; + } else if (c != string.charCodeAt(j++)) { + return -1; + } + } + return j; + } + function d3_time_formatRe(names) { + return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); + } + function d3_time_formatLookup(names) { + var map = new d3_Map(), i = -1, n = names.length; + while (++i < n) map.set(names[i].toLowerCase(), i); + return map; + } + function d3_time_formatPad(value, fill, width) { + var sign = value < 0 ? "-" : "", string = (sign ? -value : value) + "", length = string.length; + return sign + (length < width ? new Array(width - length + 1).join(fill) + string : string); + } + var d3_time_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayLookup = d3_time_formatLookup(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(d3_time_dayAbbreviations), d3_time_dayAbbrevLookup = d3_time_formatLookup(d3_time_dayAbbreviations), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevRe = d3_time_formatRe(d3_time_monthAbbreviations), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_monthAbbreviations), d3_time_percentRe = /^%/; + var d3_time_formatPads = { + "-": "", + _: " ", + "0": "0" + }; + var d3_time_formats = { + a: function(d) { + return d3_time_dayAbbreviations[d.getDay()]; + }, + A: function(d) { + return d3_time_days[d.getDay()]; + }, + b: function(d) { + return d3_time_monthAbbreviations[d.getMonth()]; + }, + B: function(d) { + return d3_time_months[d.getMonth()]; + }, + c: d3_time_format(d3_time_formatDateTime), + d: function(d, p) { + return d3_time_formatPad(d.getDate(), p, 2); + }, + e: function(d, p) { + return d3_time_formatPad(d.getDate(), p, 2); + }, + H: function(d, p) { + return d3_time_formatPad(d.getHours(), p, 2); + }, + I: function(d, p) { + return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); + }, + j: function(d, p) { + return d3_time_formatPad(1 + d3_time.dayOfYear(d), p, 3); + }, + L: function(d, p) { + return d3_time_formatPad(d.getMilliseconds(), p, 3); + }, + m: function(d, p) { + return d3_time_formatPad(d.getMonth() + 1, p, 2); + }, + M: function(d, p) { + return d3_time_formatPad(d.getMinutes(), p, 2); + }, + p: function(d) { + return d.getHours() >= 12 ? "PM" : "AM"; + }, + S: function(d, p) { + return d3_time_formatPad(d.getSeconds(), p, 2); + }, + U: function(d, p) { + return d3_time_formatPad(d3_time.sundayOfYear(d), p, 2); + }, + w: function(d) { + return d.getDay(); + }, + W: function(d, p) { + return d3_time_formatPad(d3_time.mondayOfYear(d), p, 2); + }, + x: d3_time_format(d3_time_formatDate), + X: d3_time_format(d3_time_formatTime), + y: function(d, p) { + return d3_time_formatPad(d.getFullYear() % 100, p, 2); + }, + Y: function(d, p) { + return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); + }, + Z: d3_time_zone, + "%": function() { + 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: d3_time_parseDayOfYear, + L: d3_time_parseMilliseconds, + m: d3_time_parseMonthNumber, + M: d3_time_parseMinutes, + p: d3_time_parseAmPm, + S: d3_time_parseSeconds, + U: d3_time_parseWeekNumberSunday, + w: d3_time_parseWeekdayNumber, + W: d3_time_parseWeekNumberMonday, + x: d3_time_parseLocaleDate, + X: d3_time_parseLocaleTime, + y: d3_time_parseYear, + Y: d3_time_parseFullYear, + Z: d3_time_parseZone, + "%": d3_time_parseLiteralPercent + }; + function d3_time_parseWeekdayAbbrev(date, string, i) { + d3_time_dayAbbrevRe.lastIndex = 0; + var n = d3_time_dayAbbrevRe.exec(string.substring(i)); + return n ? (date.w = d3_time_dayAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function d3_time_parseWeekday(date, string, i) { + d3_time_dayRe.lastIndex = 0; + var n = d3_time_dayRe.exec(string.substring(i)); + return n ? (date.w = d3_time_dayLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function d3_time_parseWeekdayNumber(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 1)); + return n ? (date.w = +n[0], i + n[0].length) : -1; + } + function d3_time_parseWeekNumberSunday(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i)); + return n ? (date.U = +n[0], i + n[0].length) : -1; + } + function d3_time_parseWeekNumberMonday(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i)); + return n ? (date.W = +n[0], i + n[0].length) : -1; + } + function d3_time_parseMonthAbbrev(date, string, i) { + d3_time_monthAbbrevRe.lastIndex = 0; + var n = d3_time_monthAbbrevRe.exec(string.substring(i)); + return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + function d3_time_parseMonth(date, string, i) { + d3_time_monthRe.lastIndex = 0; + var n = d3_time_monthRe.exec(string.substring(i)); + return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i + n[0].length) : -1; + } + 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_expandYear(+n[0]), i + n[0].length) : -1; + } + function d3_time_parseZone(date, string, i) { + return /^[+-]\d{4}$/.test(string = string.substring(i, i + 5)) ? (date.Z = +string, + i + 5) : -1; + } + function d3_time_expandYear(d) { + return d + (d > 68 ? 1900 : 2e3); + } + 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; + } + function d3_time_parseDayOfYear(date, string, i) { + d3_time_numberRe.lastIndex = 0; + var n = d3_time_numberRe.exec(string.substring(i, i + 3)); + return n ? (date.j = +n[0], i + n[0].length) : -1; + } + 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; + } + 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 + }); + function d3_time_zone(d) { + var z = d.getTimezoneOffset(), zs = z > 0 ? "-" : "+", zh = ~~(abs(z) / 60), zm = abs(z) % 60; + return zs + d3_time_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); + } + function d3_time_parseLiteralPercent(date, string, i) { + d3_time_percentRe.lastIndex = 0; + var n = d3_time_percentRe.exec(string.substring(i, i + 1)); + return n ? i + n[0].length : -1; + } + d3_time_format.utc = d3_time_formatUtc; + function d3_time_formatUtc(template) { + var local = d3_time_format(template); + function format(date) { + try { + d3_date = d3_date_utc; + var utc = new d3_date(); + utc._ = date; + return local(utc); + } finally { + d3_date = Date; + } + } + format.parse = function(string) { + try { + d3_date = d3_date_utc; + var date = local.parse(string); + return date && date._; + } finally { + d3_date = Date; + } + }; + format.toString = local.toString; + return format; + } var d3_time_formatIso = d3_time_formatUtc("%Y-%m-%dT%H:%M:%S.%LZ"); d3_time_format.iso = Date.prototype.toISOString && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso; function d3_time_formatIsoNative(date) { @@ -9391,55 +9210,64 @@ 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); + }; + } var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; 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_scaleLocalFormat = d3_time_format.multi([ [ ".%L", function(d) { - return d.getMilliseconds(); - } ], [ ":%S", function(d) { - return d.getSeconds(); - } ], [ "%I:%M", function(d) { - return d.getMinutes(); - } ], [ "%I %p", function(d) { - return d.getHours(); - } ], [ "%a %d", function(d) { - return d.getDay() && d.getDate() != 1; - } ], [ "%b %d", function(d) { - return d.getDate() != 1; - } ], [ "%B", function(d) { + var d3_time_scaleLocalFormats = [ [ d3_time_format("%Y"), d3_true ], [ d3_time_format("%B"), function(d) { return d.getMonth(); - } ], [ "%Y", d3_true ] ]); - var d3_time_scaleMilliseconds = { - range: function(start, stop, step) { - return d3.range(Math.ceil(start / step) * step, +stop, step).map(d3_time_scaleDate); - }, - floor: d3_identity, - ceil: d3_identity - }; + } ], [ 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_scaleLocalFormat = d3_time_scaleFormat(d3_time_scaleLocalFormats); d3_time_scaleLocalMethods.year = d3_time.year; 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) { + var d3_time_scaleMilliseconds = { + range: function(start, stop, step) { + return d3.range(+start, +stop, step).map(d3_time_scaleDate); + }, + floor: d3_identity, + ceil: d3_identity + }; + var d3_time_scaleUTCMethods = d3_time_scaleLocalMethods.map(function(m) { return [ m[0].utc, m[1] ]; }); - var d3_time_scaleUtcFormat = d3_time_formatUtc.multi([ [ ".%L", function(d) { - return d.getUTCMilliseconds(); - } ], [ ":%S", function(d) { - return d.getUTCSeconds(); - } ], [ "%I:%M", function(d) { - return d.getUTCMinutes(); - } ], [ "%I %p", function(d) { - return d.getUTCHours(); - } ], [ "%a %d", function(d) { - return d.getUTCDay() && d.getUTCDate() != 1; - } ], [ "%b %d", function(d) { - return d.getUTCDate() != 1; - } ], [ "%B", function(d) { + var d3_time_scaleUTCFormats = [ [ d3_time_formatUtc("%Y"), d3_true ], [ d3_time_formatUtc("%B"), function(d) { return d.getUTCMonth(); - } ], [ "%Y", d3_true ] ]); - d3_time_scaleUtcMethods.year = d3_time.year.utc; + } ], [ d3_time_formatUtc("%b %d"), function(d) { + return d.getUTCDate() != 1; + } ], [ d3_time_formatUtc("%a %d"), function(d) { + return d.getUTCDay() && d.getUTCDate() != 1; + } ], [ d3_time_formatUtc("%I %p"), function(d) { + return d.getUTCHours(); + } ], [ d3_time_formatUtc("%I:%M"), function(d) { + return d.getUTCMinutes(); + } ], [ d3_time_formatUtc(":%S"), function(d) { + return d.getUTCSeconds(); + } ], [ d3_time_formatUtc(".%L"), function(d) { + return d.getUTCMilliseconds(); + } ] ]; + var d3_time_scaleUTCFormat = d3_time_scaleFormat(d3_time_scaleUTCFormats); + d3_time_scaleUTCMethods.year = d3_time.year.utc; d3_time.scale.utc = function() { - return d3_time_scale(d3.scale.linear(), d3_time_scaleUtcMethods, d3_time_scaleUtcFormat); + return d3_time_scale(d3.scale.linear(), d3_time_scaleUTCMethods, d3_time_scaleUTCFormat); }; d3.text = d3_xhrType(function(request) { return request.responseText; @@ -9461,6 +9289,5 @@ d3.xml = d3_xhrType(function(request) { return request.responseXML; }); - if (typeof define === "function" && define.amd) define(d3); else if (typeof module === "object" && module.exports) module.exports = d3; - this.d3 = d3; + return d3; }(); \ No newline at end of file diff --git a/awx/ui/static/lib/d3/d3.min.js b/awx/ui/static/lib/d3/d3.min.js index e3ee0f9118..dba599303c 100644 --- a/awx/ui/static/lib/d3/d3.min.js +++ b/awx/ui/static/lib/d3/d3.min.js @@ -1,5 +1,5 @@ -!function(){function n(n,t){return t>n?-1:n>t?1:n>=t?0:0/0}function t(n){return null===n?0/0:+n}function e(n){return!isNaN(n)}function r(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function u(n){return n.length}function i(n){for(var t=1;n*t%1;)t*=10;return t}function o(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function a(){this._=Object.create(null)}function c(n){return(n+="")===da||n[0]===ma?ma+n:n}function l(n){return(n+="")[0]===ma?n.slice(1):n}function s(n){return c(n)in this._}function f(n){return(n=c(n))in this._&&delete this._[n]}function h(){var n=[];for(var t in this._)n.push(l(t));return n}function g(){var n=0;for(var t in this._)++n;return n}function p(){for(var n in this._)return!1;return!0}function v(){this._=Object.create(null)}function d(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function m(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=ya.length;r>e;++e){var u=ya[e]+t;if(u in n)return u}}function y(){}function M(){}function x(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function O(n){return xa(n,Aa),n}function Y(n){var t,e;return function(r,u,i){var o,a=n[i].update,c=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var l=Ca.get(n);return l&&(n=l,c=V),a?t?u:r:t?y:i}function Z(n,t){return function(e){var r=ta.event;ta.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ta.event=r}}}function V(n,t){var e=Z(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function X(){var n=".dragsuppress-"+ ++qa,t="click"+n,e=ta.select(oa).on("touchmove"+n,b).on("dragstart"+n,b).on("selectstart"+n,b);if(za){var r=ia.style,u=r[za];r[za]="none"}return function(i){if(e.on(n,null),za&&(r[za]=u),i){var o=function(){e.on(t,null)};e.on(t,function(){b(),o()},!0),setTimeout(o,0)}}}function $(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>La&&(oa.scrollX||oa.scrollY)){e=ta.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var u=e[0][0].getScreenCTM();La=!(u.f||u.e),e.remove()}return La?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}function B(){return ta.event.changedTouches[0].identifier}function W(){return ta.event.target}function J(){return oa}function G(n){return n>0?1:0>n?-1:0}function K(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function Q(n){return n>1?0:-1>n?Da:Math.acos(n)}function nt(n){return n>1?ja:-1>n?-ja:Math.asin(n)}function tt(n){return((n=Math.exp(n))-1/n)/2}function et(n){return((n=Math.exp(n))+1/n)/2}function rt(n){return((n=Math.exp(2*n))-1)/(n+1)}function ut(n){return(n=Math.sin(n/2))*n}function it(){}function ot(n,t,e){return this instanceof ot?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ot?new ot(n.h,n.s,n.l):xt(""+n,bt,ot):new ot(n,t,e)}function at(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new dt(u(n+120),u(n),u(n-120))}function ct(n,t,e){return this instanceof ct?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof ct?new ct(n.h,n.c,n.l):n instanceof st?ht(n.l,n.a,n.b):ht((n=_t((n=ta.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new ct(n,t,e)}function lt(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new st(e,Math.cos(n*=Fa)*t,Math.sin(n)*t)}function st(n,t,e){return this instanceof st?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof st?new st(n.l,n.a,n.b):n instanceof ct?lt(n.h,n.c,n.l):_t((n=dt(n)).r,n.g,n.b):new st(n,t,e)}function ft(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=gt(u)*Ja,r=gt(r)*Ga,i=gt(i)*Ka,new dt(vt(3.2404542*u-1.5371385*r-.4985314*i),vt(-.969266*u+1.8760108*r+.041556*i),vt(.0556434*u-.2040259*r+1.0572252*i))}function ht(n,t,e){return n>0?new ct(Math.atan2(e,t)*Ha,Math.sqrt(t*t+e*e),n):new ct(0/0,0/0,n)}function gt(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function pt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function vt(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function dt(n,t,e){return this instanceof dt?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof dt?new dt(n.r,n.g,n.b):xt(""+n,dt,at):new dt(n,t,e)}function mt(n){return new dt(n>>16,255&n>>8,255&n)}function yt(n){return mt(n)+""}function Mt(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function xt(n,t,e){var r,u,i,o=0,a=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(St(u[0]),St(u[1]),St(u[2]))}return(i=tc.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,c=15&i,c=c<<4|c):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,c=255&i)),t(o,a,c))}function bt(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,c=(o+i)/2;return a?(u=.5>c?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=0/0,u=c>0&&1>c?0:r),new ot(r,u,c)}function _t(n,t,e){n=wt(n),t=wt(t),e=wt(e);var r=pt((.4124564*n+.3575761*t+.1804375*e)/Ja),u=pt((.2126729*n+.7151522*t+.072175*e)/Ga),i=pt((.0193339*n+.119192*t+.9503041*e)/Ka);return st(116*u-16,500*(r-u),200*(u-i))}function wt(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function St(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function kt(n){return"function"==typeof n?n:function(){return n}}function Et(n){return n}function At(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Nt(t,e,n,r)}}function Nt(n,t,e,r){function u(){var n,t=c.status;if(!t&&zt(c)||t>=200&&300>t||304===t){try{n=e.call(i,c)}catch(r){return o.error.call(i,r),void 0}o.load.call(i,n)}else o.error.call(i,c)}var i={},o=ta.dispatch("beforesend","progress","load","error"),a={},c=new XMLHttpRequest,l=null;return!oa.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=u:c.onreadystatechange=function(){c.readyState>3&&u()},c.onprogress=function(n){var t=ta.event;ta.event=n;try{o.progress.call(i,c)}finally{ta.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(l=n,i):l},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(ra(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),c.setRequestHeader)for(var s in a)c.setRequestHeader(s,a[s]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=l&&(c.responseType=l),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},ta.rebind(i,o,"on"),null==r?i:i.get(Ct(r))}function Ct(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function zt(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qt(){var n=Lt(),t=Tt()-n;t>24?(isFinite(t)&&(clearTimeout(ic),ic=setTimeout(qt,t)),uc=0):(uc=1,ac(qt))}function Lt(){var n=Date.now();for(oc=ec;oc;)n>=oc.t&&(oc.f=oc.c(n-oc.t)),oc=oc.n;return n}function Tt(){for(var n,t=ec,e=1/0;t;)t.f?t=n?n.n=t.n:ec=t.n:(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function Pt(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],o=0,a=r[0],c=0;u>0&&a>0&&(c+a+1>t&&(a=Math.max(1,t-c)),i.push(n.substring(u-=a,u+a)),!((c+=a+1)>t));)a=r[o=(o+1)%r.length];return i.reverse().join(e)}:Et;return function(n){var e=lc.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",c=e[4]||"",l=e[5],s=+e[6],f=e[7],h=e[8],g=e[9],p=1,v="",d="",m=!1,y=!0;switch(h&&(h=+h.substring(1)),(l||"0"===r&&"="===o)&&(l=r="0",o="="),g){case"n":f=!0,g="g";break;case"%":p=100,d="%",g="f";break;case"p":p=100,d="%",g="r";break;case"b":case"o":case"x":case"X":"#"===c&&(v="0"+g.toLowerCase());case"c":y=!1;case"d":m=!0,h=0;break;case"s":p=-1,g="r"}"$"===c&&(v=u[0],d=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):("e"==g||"f"==g)&&(h=Math.max(0,Math.min(20,h)))),g=sc.get(g)||Ut;var M=l&&f;return function(n){var e=d;if(m&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>p){var c=ta.formatPrefix(n,h);n=c.scale(n),e=c.symbol+d}else n*=p;n=g(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=y?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!l&&f&&(x=i(x,1/0));var S=v.length+x.length+b.length+(M?0:u.length),k=s>S?new Array(S=s-S+1).join(r):"";return M&&(x=i(k+x,k.length?s-b.length:1/0)),u+=v,n=x+b,("<"===o?u+n+k:">"===o?k+u+n:"^"===o?k.substring(0,S>>=1)+u+n+k.substring(S):u+(M?n:k+n))+e}}}function Ut(n){return n+""}function jt(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Ft(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new hc(e-1)),1),e}function i(n,e){return t(n=new hc(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{hc=jt;var r=new jt;return r._=n,o(r,t,e)}finally{hc=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var c=n.utc=Ht(n);return c.floor=c,c.round=Ht(r),c.ceil=Ht(u),c.offset=Ht(i),c.range=a,n}function Ht(n){return function(t,e){try{hc=jt;var r=new jt;return r._=t,n(r,e)._}finally{hc=Date}}}function Ot(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,c=0;++aa;){if(r>=l)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=C[o in pc?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){E.lastIndex=0;var r=E.exec(t.slice(e));return r?(n.m=A.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,N.c.toString(),t,r)}function c(n,t,r){return e(n,N.x.toString(),t,r)}function l(n,t,r){return e(n,N.X.toString(),t,r)}function s(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var f=n.dateTime,h=n.date,g=n.time,p=n.periods,v=n.days,d=n.shortDays,m=n.months,y=n.shortMonths;t.utc=function(n){function e(n){try{hc=jt;var t=new hc;return t._=n,r(t)}finally{hc=Date}}var r=t(n);return e.parse=function(n){try{hc=jt;var t=r.parse(n);return t&&t._}finally{hc=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ae;var M=ta.map(),x=It(v),b=Zt(v),_=It(d),w=Zt(d),S=It(m),k=Zt(m),E=It(y),A=Zt(y);p.forEach(function(n,t){M.set(n.toLowerCase(),t)});var N={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return y[n.getMonth()]},B:function(n){return m[n.getMonth()]},c:t(f),d:function(n,t){return Yt(n.getDate(),t,2)},e:function(n,t){return Yt(n.getDate(),t,2)},H:function(n,t){return Yt(n.getHours(),t,2)},I:function(n,t){return Yt(n.getHours()%12||12,t,2)},j:function(n,t){return Yt(1+fc.dayOfYear(n),t,3)},L:function(n,t){return Yt(n.getMilliseconds(),t,3)},m:function(n,t){return Yt(n.getMonth()+1,t,2)},M:function(n,t){return Yt(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return Yt(n.getSeconds(),t,2)},U:function(n,t){return Yt(fc.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Yt(fc.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return Yt(n.getFullYear()%100,t,2)},Y:function(n,t){return Yt(n.getFullYear()%1e4,t,4)},Z:ie,"%":function(){return"%"}},C={a:r,A:u,b:i,B:o,c:a,d:Qt,e:Qt,H:te,I:te,j:ne,L:ue,m:Kt,M:ee,p:s,S:re,U:Xt,w:Vt,W:$t,x:c,X:l,y:Wt,Y:Bt,Z:Jt,"%":oe};return t}function Yt(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function It(n){return new RegExp("^(?:"+n.map(ta.requote).join("|")+")","i")}function Zt(n){for(var t=new a,e=-1,r=n.length;++e68?1900:2e3)}function Kt(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Qt(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function ne(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function te(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function ee(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function re(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ue(n,t,e){vc.lastIndex=0;var r=vc.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ie(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=0|va(t)/60,u=va(t)%60;return e+Yt(r,"0",2)+Yt(u,"0",2)}function oe(n,t,e){dc.lastIndex=0;var r=dc.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ae(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,c=Math.cos(t),l=Math.sin(t),s=i*l,f=u*c+s*Math.cos(a),h=s*o*Math.sin(a);_c.add(Math.atan2(h,f)),r=n,u=c,i=l}var t,e,r,u,i;wc.point=function(o,a){wc.point=n,r=(t=o)*Fa,u=Math.cos(a=(e=a)*Fa/2+Da/4),i=Math.sin(a)},wc.lineEnd=function(){n(t,e)}}function pe(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function ve(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function de(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function me(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function ye(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function Me(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function xe(n){return[Math.atan2(n[1],n[0]),nt(n[2])]}function be(n,t){return va(n[0]-t[0])a;++a)u.point((e=n[a])[0],e[1]);return u.lineEnd(),void 0}var c=new qe(e,n,null,!0),l=new qe(e,null,c,!1);c.o=l,i.push(c),o.push(l),c=new qe(r,n,null,!1),l=new qe(r,null,c,!0),c.o=l,i.push(c),o.push(l)}}),o.sort(t),ze(i),ze(o),i.length){for(var a=0,c=e,l=o.length;l>a;++a)o[a].e=c=!c;for(var s,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;s=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var a=0,l=s.length;l>a;++a)u.point((f=s[a])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){s=g.p.z;for(var a=s.length-1;a>=0;--a)u.point((f=s[a])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,s=g.z,p=!p}while(!g.v);u.lineEnd()}}}function ze(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r0){for(b||(i.polygonStart(),b=!0),i.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Te))}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:o,lineStart:c,lineEnd:l,polygonStart:function(){y.point=s,y.lineStart=f,y.lineEnd=h,g=[],p=[]},polygonEnd:function(){y.point=o,y.lineStart=c,y.lineEnd=l,g=ta.merge(g);var n=Fe(m,p);g.length?(b||(i.polygonStart(),b=!0),Ce(g,De,n,e,i)):n&&(b||(i.polygonStart(),b=!0),i.lineStart(),e(null,null,1,i),i.lineEnd()),b&&(i.polygonEnd(),b=!1),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},M=Re(),x=t(M),b=!1;return y}}function Te(n){return n.length>1}function Re(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:y,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function De(n,t){return((n=n.x)[0]<0?n[1]-ja-Ta:ja-n[1])-((t=t.x)[0]<0?t[1]-ja-Ta:ja-t[1])}function Pe(n){var t,e=0/0,r=0/0,u=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(i,o){var a=i>0?Da:-Da,c=va(i-e);va(c-Da)0?ja:-ja),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(i,r),t=0):u!==a&&c>=Da&&(va(e-u)Ta?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*o)):(t+r)/2}function je(n,t,e,r){var u;if(null==n)u=e*ja,r.point(-Da,u),r.point(0,u),r.point(Da,u),r.point(Da,0),r.point(Da,-u),r.point(0,-u),r.point(-Da,-u),r.point(-Da,0),r.point(-Da,u);else if(va(n[0]-t[0])>Ta){var i=n[0]a;++a){var l=t[a],s=l.length;if(s)for(var f=l[0],h=f[0],g=f[1]/2+Da/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===s&&(d=0),n=l[d];var m=n[0],y=n[1]/2+Da/4,M=Math.sin(y),x=Math.cos(y),b=m-h,_=b>=0?1:-1,w=_*b,S=w>Da,k=p*M;if(_c.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),i+=S?b+_*Pa:b,S^h>=e^m>=e){var E=de(pe(f),pe(n));Me(E);var A=de(u,E);Me(A);var N=(S^b>=0?-1:1)*nt(A[2]);(r>N||r===N&&(E[0]||E[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=m,p=M,v=x,f=n}}return(-Ta>i||Ta>i&&0>_c)^1&o}function He(n){function t(n,t){return Math.cos(n)*Math.cos(t)>i}function e(n){var e,i,c,l,s;return{lineStart:function(){l=c=!1,s=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=o?v?0:u(f,h):v?u(f+(0>f?Da:-Da),h):0;if(!e&&(l=c=v)&&n.lineStart(),v!==c&&(g=r(e,p),(be(e,g)||be(p,g))&&(p[0]+=Ta,p[1]+=Ta,v=t(p[0],p[1]))),v!==c)s=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(a&&e&&o^v){var m;d&i||!(m=r(p,e,!0))||(s=0,o?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&be(e,p)||n.point(p[0],p[1]),e=p,c=v,i=d},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return s|(l&&c)<<1}}}function r(n,t,e){var r=pe(n),u=pe(t),o=[1,0,0],a=de(r,u),c=ve(a,a),l=a[0],s=c-l*l;if(!s)return!e&&n;var f=i*c/s,h=-i*l/s,g=de(o,a),p=ye(o,f),v=ye(a,h);me(p,v);var d=g,m=ve(p,d),y=ve(d,d),M=m*m-y*(ve(p,p)-1);if(!(0>M)){var x=Math.sqrt(M),b=ye(d,(-m-x)/y);if(me(b,p),b=xe(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],E=t[1];w>S&&(_=w,w=S,S=_);var A=S-w,N=va(A-Da)A;if(!N&&k>E&&(_=k,k=E,E=_),C?N?k+E>0^b[1]<(va(b[0]-w)Da^(w<=b[0]&&b[0]<=S)){var z=ye(d,(-m+x)/y);return me(z,p),[b,xe(z)]}}}function u(t,e){var r=o?n:Da-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),o=i>0,a=va(i)>Ta,c=gr(n,6*Fa);return Le(t,e,c,o?[0,-n]:[-Da,n-Da])}function Oe(n,t,e,r){return function(u){var i,o=u.a,a=u.b,c=o.x,l=o.y,s=a.x,f=a.y,h=0,g=1,p=s-c,v=f-l;if(i=n-c,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-c,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-l,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-l,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:c+h*p,y:l+h*v}),1>g&&(u.b={x:c+g*p,y:l+g*v}),u}}}}}}function Ye(n,t,e,r){function u(r,u){return va(r[0]-n)0?0:3:va(r[0]-e)0?2:1:va(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return o(n.x,t.x)}function o(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function c(n){for(var t=0,e=d.length,r=n[1],u=0;e>u;++u)for(var i,o=1,a=d[u],c=a.length,l=a[0];c>o;++o)i=a[o],l[1]<=r?i[1]>r&&K(l,i,n)>0&&++t:i[1]<=r&&K(l,i,n)<0&&--t,l=i;return 0!==t}function l(i,a,c,l){var s=0,f=0;if(null==i||(s=u(i,c))!==(f=u(a,c))||o(i,a)<0^c>0){do l.point(0===s||3===s?n:e,s>1?r:t);while((s=(s+c+4)%4)!==f)}else l.point(a[0],a[1])}function s(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function f(n,t){s(n,t)&&a.point(n,t)}function h(){C.point=p,d&&d.push(m=[]),S=!0,w=!1,b=_=0/0}function g(){v&&(p(y,M),x&&w&&A.rejoin(),v.push(A.buffer())),C.point=f,w&&a.lineEnd()}function p(n,t){n=Math.max(-Uc,Math.min(Uc,n)),t=Math.max(-Uc,Math.min(Uc,t));var e=s(n,t);if(d&&m.push([n,t]),S)y=n,M=t,x=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};N(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,m,y,M,x,b,_,w,S,k,E=a,A=Re(),N=Oe(n,t,e,r),C={point:f,lineStart:h,lineEnd:g,polygonStart:function(){a=A,v=[],d=[],k=!0},polygonEnd:function(){a=E,v=ta.merge(v);var t=c([n,r]),e=k&&t,u=v.length;(e||u)&&(a.polygonStart(),e&&(a.lineStart(),l(null,null,1,a),a.lineEnd()),u&&Ce(v,i,t,l,a),a.polygonEnd()),v=d=m=null}};return C}}function Ie(n){var t=0,e=Da/3,r=ir(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*Da/180,e=n[1]*Da/180):[180*(t/Da),180*(e/Da)]},u}function Ze(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),o-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),o=Math.sqrt(i)/u;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/u,nt((i-(n*n+e*e)*u*u)/(2*u))]},e}function Ve(){function n(n,t){Fc+=u*n-r*t,r=n,u=t}var t,e,r,u;Zc.point=function(i,o){Zc.point=n,t=r=i,e=u=o},Zc.lineEnd=function(){n(t,e)}}function Xe(n,t){Hc>n&&(Hc=n),n>Yc&&(Yc=n),Oc>t&&(Oc=t),t>Ic&&(Ic=t)}function $e(){function n(n,t){o.push("M",n,",",t,i)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function u(){o.push("Z")}var i=Be(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return i=Be(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Be(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function We(n,t){Ec+=n,Ac+=t,++Nc}function Je(){function n(n,r){var u=n-t,i=r-e,o=Math.sqrt(u*u+i*i);Cc+=o*(t+n)/2,zc+=o*(e+r)/2,qc+=o,We(t=n,e=r)}var t,e;Xc.point=function(r,u){Xc.point=n,We(t=r,e=u)}}function Ge(){Xc.point=We}function Ke(){function n(n,t){var e=n-r,i=t-u,o=Math.sqrt(e*e+i*i);Cc+=o*(r+n)/2,zc+=o*(u+t)/2,qc+=o,o=u*n-r*t,Lc+=o*(r+n),Tc+=o*(u+t),Rc+=3*o,We(r=n,u=t)}var t,e,r,u;Xc.point=function(i,o){Xc.point=n,We(t=r=i,e=u=o)},Xc.lineEnd=function(){n(t,e)}}function Qe(n){function t(t,e){n.moveTo(t+o,e),n.arc(t,e,o,0,Pa)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function u(){a.point=t}function i(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:u,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=u,a.point=t},pointRadius:function(n){return o=n,a},result:y};return a}function nr(n){function t(n){return(a?r:e)(n)}function e(t){return rr(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=0/0,S.point=i,t.lineStart()}function i(e,r){var i=pe([e,r]),o=n(e,r);u(M,x,y,b,_,w,M=o[0],x=o[1],y=e,b=i[0],_=i[1],w=i[2],a,t),t.point(M,x)}function o(){S.point=e,t.lineEnd()}function c(){r(),S.point=l,S.lineEnd=s}function l(n,t){i(f=n,h=t),g=M,p=x,v=b,d=_,m=w,S.point=i}function s(){u(M,x,y,b,_,w,g,p,f,v,d,m,a,t),S.lineEnd=o,o()}var f,h,g,p,v,d,m,y,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=c},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,a,c,l,s,f,h,g,p,v,d,m){var y=s-t,M=f-e,x=y*y+M*M;if(x>4*i&&d--){var b=a+g,_=c+p,w=l+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),E=va(va(w)-1)i||va((y*z+M*q)/x-.5)>.3||o>a*g+c*p+l*v)&&(u(t,e,r,a,c,l,N,C,E,b/=S,_/=S,w,d,m),m.point(N,C),u(N,C,E,b,_,w,s,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*Fa),a=16;return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function tr(n){var t=nr(function(t,e){return n([t*Ha,e*Ha])});return function(n){return or(t(n))}}function er(n){this.stream=n}function rr(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function ur(n){return ir(function(){return n})()}function ir(n){function t(n){return n=a(n[0]*Fa,n[1]*Fa),[n[0]*h+c,l-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(l-n[1])/h),n&&[n[0]*Ha,n[1]*Ha]}function r(){a=Ae(o=lr(m,y,M),i);var n=i(v,d);return c=g-n[0]*h,l=p+n[1]*h,u()}function u(){return s&&(s.valid=!1,s=null),t}var i,o,a,c,l,s,f=nr(function(n,t){return n=i(n,t),[n[0]*h+c,l-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,y=0,M=0,x=Pc,b=Et,_=null,w=null;return t.stream=function(n){return s&&(s.valid=!1),s=or(x(o,f(b(n)))),s.valid=!0,s},t.clipAngle=function(n){return arguments.length?(x=null==n?(_=n,Pc):He((_=+n)*Fa),u()):_},t.clipExtent=function(n){return arguments.length?(w=n,b=n?Ye(n[0][0],n[0][1],n[1][0],n[1][1]):Et,u()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*Fa,d=n[1]%360*Fa,r()):[v*Ha,d*Ha]},t.rotate=function(n){return arguments.length?(m=n[0]%360*Fa,y=n[1]%360*Fa,M=n.length>2?n[2]%360*Fa:0,r()):[m*Ha,y*Ha,M*Ha]},ta.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function or(n){return rr(n,function(t,e){n.point(t*Fa,e*Fa)})}function ar(n,t){return[n,t]}function cr(n,t){return[n>Da?n-Pa:-Da>n?n+Pa:n,t]}function lr(n,t,e){return n?t||e?Ae(fr(n),hr(t,e)):fr(n):t||e?hr(t,e):cr}function sr(n){return function(t,e){return t+=n,[t>Da?t-Pa:-Da>t?t+Pa:t,e]}}function fr(n){var t=sr(n);return t.invert=sr(-n),t}function hr(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*r+a*u;return[Math.atan2(c*i-s*o,a*r-l*u),nt(s*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,l=Math.sin(t),s=l*i-c*o;return[Math.atan2(c*i+l*o,a*r+s*u),nt(s*r-a*u)]},e}function gr(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=pr(e,u),i=pr(e,i),(o>0?i>u:u>i)&&(u+=o*Pa)):(u=n+o*Pa,i=n-.5*c);for(var l,s=u;o>0?s>i:i>s;s-=c)a.point((l=xe([e,-r*Math.cos(s),-r*Math.sin(s)]))[0],l[1])}}function pr(n,t){var e=pe(t);e[0]-=n,Me(e);var r=Q(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Ta)%(2*Math.PI)}function vr(n,t,e){var r=ta.range(n,t-Ta,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function dr(n,t,e){var r=ta.range(n,t-Ta,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function mr(n){return n.source}function yr(n){return n.target}function Mr(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),l=u*Math.sin(n),s=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(ut(r-t)+u*o*ut(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*s,u=e*l+t*f,o=e*i+t*a;return[Math.atan2(u,r)*Ha,Math.atan2(o,Math.sqrt(r*r+u*u))*Ha]}:function(){return[n*Ha,t*Ha]};return p.distance=h,p}function xr(){function n(n,u){var i=Math.sin(u*=Fa),o=Math.cos(u),a=va((n*=Fa)-t),c=Math.cos(a);$c+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Bc.point=function(u,i){t=u*Fa,e=Math.sin(i*=Fa),r=Math.cos(i),Bc.point=n},Bc.lineEnd=function(){Bc.point=Bc.lineEnd=y}}function br(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asin(r&&e*i/r)]},e}function _r(n,t){function e(n,t){o>0?-ja+Ta>t&&(t=-ja+Ta):t>ja-Ta&&(t=ja-Ta);var e=o/Math.pow(u(t),i);return[e*Math.sin(i*n),o-e*Math.cos(i*n)]}var r=Math.cos(n),u=function(n){return Math.tan(Da/4+n/2)},i=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(u(t)/u(n)),o=r*Math.pow(u(n),i)/i;return i?(e.invert=function(n,t){var e=o-t,r=G(i)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/i,2*Math.atan(Math.pow(o/r,1/i))-ja]},e):Sr}function wr(n,t){function e(n,t){var e=i-t;return[e*Math.sin(u*n),i-e*Math.cos(u*n)]}var r=Math.cos(n),u=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),i=r/u+n;return va(u)u;u++){for(;r>1&&K(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function zr(n,t){return n[0]-t[0]||n[1]-t[1]}function qr(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Lr(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,c=n[1],l=e[1],s=t[1]-c,f=r[1]-l,h=(a*(c-l)-f*(u-i))/(f*o-a*s);return[u+h*o,c+h*s]}function Tr(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Rr(){tu(this),this.edge=this.site=this.circle=null}function Dr(n){var t=ol.pop()||new Rr;return t.site=n,t}function Pr(n){Xr(n),rl.remove(n),ol.push(n),tu(n)}function Ur(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];Pr(n);for(var c=i;c.circle&&va(e-c.circle.x)s;++s)l=a[s],c=a[s-1],Kr(l.edge,c.site,l.site,u);c=a[0],l=a[f-1],l.edge=Jr(c.site,l.site,null,u),Vr(c),Vr(l)}function jr(n){for(var t,e,r,u,i=n.x,o=n.y,a=rl._;a;)if(r=Fr(a,o)-i,r>Ta)a=a.L;else{if(u=i-Hr(a,o),!(u>Ta)){r>-Ta?(t=a.P,e=a):u>-Ta?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var c=Dr(n);if(rl.insert(t,c),t||e){if(t===e)return Xr(t),e=Dr(t.site),rl.insert(c,e),c.edge=e.edge=Jr(t.site,c.site),Vr(t),Vr(e),void 0;if(!e)return c.edge=Jr(t.site,c.site),void 0;Xr(t),Xr(e);var l=t.site,s=l.x,f=l.y,h=n.x-s,g=n.y-f,p=e.site,v=p.x-s,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,M=v*v+d*d,x={x:(d*y-g*M)/m+s,y:(h*M-v*y)/m+f};Kr(e.edge,l,p,x),c.edge=Jr(l,n,null,x),e.edge=Jr(n,p,null,x),Vr(t),Vr(e)}}function Fr(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-1/0;e=o.site;var a=e.x,c=e.y,l=c-t;if(!l)return a;var s=a-r,f=1/i-1/l,h=s/l;return f?(-h+Math.sqrt(h*h-2*f*(s*s/(-2*l)-c+l/2+u-i/2)))/f+r:(r+a)/2}function Hr(n,t){var e=n.N;if(e)return Fr(e,t);var r=n.site;return r.y===t?r.x:1/0}function Or(n){this.site=n,this.edges=[]}function Yr(n){for(var t,e,r,u,i,o,a,c,l,s,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=el,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(a=i.edges,c=a.length,o=0;c>o;)s=a[o].end(),r=s.x,u=s.y,l=a[++o%c].start(),t=l.x,e=l.y,(va(r-t)>Ta||va(u-e)>Ta)&&(a.splice(o,0,new Qr(Gr(i.site,s,va(r-f)Ta?{x:f,y:va(t-f)Ta?{x:va(e-p)Ta?{x:h,y:va(t-h)Ta?{x:va(e-g)=-Ra)){var g=c*c+l*l,p=s*s+f*f,v=(f*g-l*p)/h,d=(c*p-s*g)/h,f=d+a,m=al.pop()||new Zr;m.arc=n,m.site=u,m.x=v+o,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,M=il._;M;)if(m.yd||d>=a)return;if(h>p){if(i){if(i.y>=l)return}else i={x:d,y:c};e={x:d,y:l}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=l)return}else i={x:(c-u)/r,y:c};e={x:(l-u)/r,y:l}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi||f>o||r>h||u>g)){if(p=n.point){var p,v=t-p[0],d=e-p[1],m=v*v+d*d;if(c>m){var y=Math.sqrt(c=m);r=t-y,u=e-y,i=t+y,o=e+y,a=p}}for(var M=n.nodes,x=.5*(s+h),b=.5*(f+g),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:l(n,s,f,x,b);break;case 1:l(n,x,f,h,b);break;case 2:l(n,s,b,x,g);break;case 3:l(n,x,b,h,g)}}}(n,r,u,i,o),a}function gu(n,t){n=ta.rgb(n),t=ta.rgb(t);var e=n.r,r=n.g,u=n.b,i=t.r-e,o=t.g-r,a=t.b-u;return function(n){return"#"+Mt(Math.round(e+i*n))+Mt(Math.round(r+o*n))+Mt(Math.round(u+a*n))}}function pu(n,t){var e,r={},u={};for(e in n)e in t?r[e]=mu(n[e],t[e]):u[e]=n[e];for(e in t)e in n||(u[e]=t[e]);return function(n){for(e in r)u[e]=r[e](n);return u}}function vu(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function du(n,t){var e,r,u,i=ll.lastIndex=sl.lastIndex=0,o=-1,a=[],c=[];for(n+="",t+="";(e=ll.exec(n))&&(r=sl.exec(t));)(u=r.index)>i&&(u=t.slice(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,c.push({i:o,x:vu(e,r)})),i=sl.lastIndex;return ir;++r)a[(e=c[r]).i]=e.x(n);return a.join("")})}function mu(n,t){for(var e,r=ta.interpolators.length;--r>=0&&!(e=ta.interpolators[r](n,t)););return e}function yu(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(mu(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function Mu(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function xu(n){return function(t){return 1-n(1-t)}}function bu(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function _u(n){return n*n}function wu(n){return n*n*n}function Su(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function ku(n){return function(t){return Math.pow(t,n)}}function Eu(n){return 1-Math.cos(n*ja)}function Au(n){return Math.pow(2,10*(n-1))}function Nu(n){return 1-Math.sqrt(1-n*n)}function Cu(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Pa*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Pa/t)}}function zu(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function qu(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Lu(n,t){n=ta.hcl(n),t=ta.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return lt(e+i*n,r+o*n,u+a*n)+""}}function Tu(n,t){n=ta.hsl(n),t=ta.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return at(e+i*n,r+o*n,u+a*n)+""}}function Ru(n,t){n=ta.lab(n),t=ta.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return ft(e+i*n,r+o*n,u+a*n)+""}}function Du(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Pu(n){var t=[n.a,n.b],e=[n.c,n.d],r=ju(t),u=Uu(t,e),i=ju(Fu(e,t,-u))||0;t[0]*e[1]180?s+=360:s-l>180&&(l+=360),u.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:vu(l,s)})):s&&r.push(r.pop()+"rotate("+s+")"),f!=h?u.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:vu(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),u.push({i:e-4,x:vu(g[0],p[0])},{i:e-2,x:vu(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=u.length,function(n){for(var t,i=-1;++i=0;)e.push(u[r])}function Qu(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function si(n){return n.reduce(fi,0)}function fi(n,t){return n+t[1]}function hi(n,t){return gi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function gi(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function pi(n){return[ta.min(n),ta.max(n)]}function vi(n,t){return n.value-t.value}function di(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function mi(n,t){n._pack_next=t,t._pack_prev=n}function yi(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function Mi(n){function t(n){s=Math.min(n.x-n.r,s),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(l=e.length)){var e,r,u,i,o,a,c,l,s=1/0,f=-1/0,h=1/0,g=-1/0;if(e.forEach(xi),r=e[0],r.x=-r.r,r.y=0,t(r),l>1&&(u=e[1],u.x=u.r,u.y=0,t(u),l>2))for(i=e[2],wi(r,u,i),t(i),di(r,i),r._pack_prev=i,di(i,u),u=r._pack_next,o=3;l>o;o++){wi(r,u,i=e[o]);var p=0,v=1,d=1;for(a=u._pack_next;a!==u;a=a._pack_next,v++)if(yi(a,i)){p=1;break}if(1==p)for(c=r._pack_prev;c!==a._pack_prev&&!yi(c,i);c=c._pack_prev,d++);p?(d>v||v==d&&u.ro;o++)i=e[o],i.x-=m,i.y-=y,M=Math.max(M,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=M,e.forEach(bi)}}function xi(n){n._pack_next=n._pack_prev=n}function bi(n){delete n._pack_next,delete n._pack_prev}function _i(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Ci(n,t,e){return n.a.parent===t.parent?n.a:e}function zi(n){return 1+ta.max(n,function(n){return n.y})}function qi(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Li(n){var t=n.children;return t&&t.length?Li(t[0]):n}function Ti(n){var t,e=n.children;return e&&(t=e.length)?Ti(e[t-1]):n}function Ri(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Di(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function Pi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Ui(n){return n.rangeExtent?n.rangeExtent():Pi(n.range())}function ji(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function Fi(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Hi(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:bl}function Oi(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Oi:ji,c=r?Yu:Ou;return o=u(n,t,c,e),a=u(t,n,c,mu),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(Du)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return Xi(n,t)},i.tickFormat=function(t,e){return $i(n,t,e)},i.nice=function(t){return Zi(n,t),u()},i.copy=function(){return Yi(n,t,e,r)},u()}function Ii(n,t){return ta.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Zi(n,t){return Fi(n,Hi(Vi(n,t)[2]))}function Vi(n,t){null==t&&(t=10);var e=Pi(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function Xi(n,t){return ta.range.apply(ta,Vi(n,t))}function $i(n,t,e){var r=Vi(n,t);if(e){var u=lc.exec(e);if(u.shift(),"s"===u[8]){var i=ta.formatPrefix(Math.max(va(r[0]),va(r[1])));return u[7]||(u[7]="."+Bi(i.scale(r[2]))),u[8]="f",e=ta.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Wi(u[8],r)),e=u.join("")}else e=",."+Bi(r[2])+"f";return ta.format(e)}function Bi(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Wi(n,t){var e=Bi(t[2]);return n in _l?Math.abs(e-Bi(Math.max(va(t[0]),va(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Ji(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=Fi(r.map(u),e?Math:Sl);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=Pi(r),o=[],a=n[0],c=n[1],l=Math.floor(u(a)),s=Math.ceil(u(c)),f=t%1?2:t;if(isFinite(s-l)){if(e){for(;s>l;l++)for(var h=1;f>h;h++)o.push(i(l)*h);o.push(i(l))}else for(o.push(i(l));l++0;h--)o.push(i(l)*h);for(l=0;o[l]c;s--);o=o.slice(l,s)}return o},o.tickFormat=function(n,t){if(!arguments.length)return wl;arguments.length<2?t=wl:"function"!=typeof t&&(t=ta.format(t));var r,a=Math.max(.1,n/o.ticks().length),c=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(c(u(n)+r))<=a?t(n):""}},o.copy=function(){return Ji(n.copy(),t,e,r)},Ii(o,n)}function Gi(n,t,e){function r(t){return n(u(t))}var u=Ki(t),i=Ki(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return Xi(e,n)},r.tickFormat=function(n,t){return $i(e,n,t)},r.nice=function(n){return r.domain(Zi(e,n))},r.exponent=function(o){return arguments.length?(u=Ki(t=o),i=Ki(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Gi(n.copy(),t,e)},Ii(r,n)}function Ki(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Qi(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):0/0))-1)%i.length]}function r(t,e){return ta.range(n.length).map(function(n){return t+e*n})}var u,i,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new a;for(var i,o=-1,c=r.length;++on?[0/0,0/0]:[n>0?a[n-1]:r[0],nt?0/0:t/i+n,[t,t+1/i]},r.copy=function(){return to(n,t,e)},u()}function eo(n,t){function e(e){return e>=e?t[ta.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return eo(n,t)},e}function ro(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Xi(n,t)},t.tickFormat=function(t,e){return $i(n,t,e)},t.copy=function(){return ro(n)},t}function uo(){return 0}function io(n){return n.innerRadius}function oo(n){return n.outerRadius}function ao(n){return n.startAngle}function co(n){return n.endAngle}function lo(n){return n&&n.padAngle}function so(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function fo(n,t,e,r,u){var i=n[0]-t[0],o=n[1]-t[1],a=(u?r:-r)/Math.sqrt(i*i+o*o),c=a*o,l=-a*i,s=n[0]+c,f=n[1]+l,h=t[0]+c,g=t[1]+l,p=(s+h)/2,v=(f+g)/2,d=h-s,m=g-f,y=d*d+m*m,M=e-r,x=s*g-h*f,b=(0>m?-1:1)*Math.sqrt(M*M*y-x*x),_=(x*m-d*b)/y,w=(-x*d-m*b)/y,S=(x*m+d*b)/y,k=(-x*d+m*b)/y,E=_-p,A=w-v,N=S-p,C=k-v;return E*E+A*A>N*N+C*C&&(_=S,w=k),[[_-c,w-l],[_*e/M,w*e/M]]}function ho(n){function t(t){function o(){l.push("M",i(n(s),a))}for(var c,l=[],s=[],f=-1,h=t.length,g=kt(e),p=kt(r);++f1&&u.push("H",r[0]),u.join("")}function mo(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[c],c++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var l=2;l9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=c;)u=(n[Math.min(c,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function To(n){return n.length<3?go(n):n[0]+_o(n,Lo(n))}function Ro(n){for(var t,e,r,u=-1,i=n.length;++ur)return s();var u=i[i.active];u&&(--i.count,delete i[i.active],u.event&&u.event.interrupt.call(n,n.__data__,u.index)),i.active=r,o.event&&o.event.start.call(n,n.__data__,t),o.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&v.push(r)}),h=o.ease,f=o.duration,ta.timer(function(){return p.c=l(e||1)?Ne:l,1},0,c)}function l(e){if(i.active!==r)return 1;for(var u=e/f,a=h(u),c=v.length;c>0;)v[--c].call(n,a);return u>=1?(o.event&&o.event.end.call(n,n.__data__,t),s()):void 0}function s(){return--i.count?delete i[r]:delete n[e],1}var f,h,g=o.delay,p=oc,v=[];return p.t=g+c,u>=g?a(u-g):(p.c=a,void 0)},0,c)}}function Bo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Wo(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function Jo(n){return n.toISOString()}function Go(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=ta.bisect(Wl,u);return i==Wl.length?[t.year,Vi(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Wl[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Ko(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Ko(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Pi(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Ko(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Go(n.copy(),t,e)},Ii(r,n)}function Ko(n){return new Date(n)}function Qo(n){return JSON.parse(n.responseText)}function na(n){var t=ua.createRange();return t.selectNode(ua.body),t.createContextualFragment(n.responseText)}var ta={version:"3.5.3"};Date.now||(Date.now=function(){return+new Date});var ea=[].slice,ra=function(n){return ea.call(n)},ua=document,ia=ua.documentElement,oa=window;try{ra(ia.childNodes)[0].nodeType}catch(aa){ra=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}try{ua.createElement("div").style.setProperty("opacity",0,"")}catch(ca){var la=oa.Element.prototype,sa=la.setAttribute,fa=la.setAttributeNS,ha=oa.CSSStyleDeclaration.prototype,ga=ha.setProperty;la.setAttribute=function(n,t){sa.call(this,n,t+"")},la.setAttributeNS=function(n,t,e){fa.call(this,n,t,e+"")},ha.setProperty=function(n,t,e){ga.call(this,n,t+"",e)}}ta.ascending=n,ta.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},ta.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ur&&(e=r)}else{for(;++u=r){e=r;break}for(;++ur&&(e=r)}return e},ta.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ue&&(e=r)}else{for(;++u=r){e=r;break}for(;++ue&&(e=r)}return e},ta.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},ta.sum=function(n,t){var r,u=0,i=n.length,o=-1;if(1===arguments.length)for(;++o1?c/(s-1):void 0},ta.deviation=function(){var n=ta.variance.apply(this,arguments);return n?Math.sqrt(n):n};var pa=r(n);ta.bisectLeft=pa.left,ta.bisect=ta.bisectRight=pa.right,ta.bisector=function(t){return r(1===t.length?function(e,r){return n(t(e),r)}:t)},ta.shuffle=function(n,t,e){(i=arguments.length)<3&&(e=n.length,2>i&&(t=0));for(var r,u,i=e-t;i;)u=0|Math.random()*i--,r=n[i+t],n[i+t]=n[u+t],n[u+t]=r;return n},ta.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ta.pairs=function(n){for(var t,e=0,r=n.length-1,u=n[0],i=new Array(0>r?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},ta.zip=function(){if(!(r=arguments.length))return[];for(var n=-1,t=ta.min(arguments,u),e=new Array(t);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var va=Math.abs;ta.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),1/0===(t-n)/e)throw new Error("infinite range");var r,u=[],o=i(va(e)),a=-1;if(n*=o,t*=o,e*=o,0>e)for(;(r=n+e*++a)>t;)u.push(r/o);else for(;(r=n+e*++a)=i.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,s,f,h,g=-1,p=o.length,v=i[c++],d=new a;++g=i.length)return n;var r=[],u=o[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(ta.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return o[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},ta.set=function(n){var t=new v;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},o(v,{has:s,add:function(n){return this._[c(n+="")]=!0,n},remove:f,values:h,size:g,empty:p,forEach:function(n){for(var t in this._)n.call(this,l(t))}}),ta.behavior={},ta.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ta.event=null,ta.requote=function(n){return n.replace(Ma,"\\$&")};var Ma=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,xa={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},ba=function(n,t){return t.querySelector(n)},_a=function(n,t){return t.querySelectorAll(n)},wa=ia.matches||ia[m(ia,"matchesSelector")],Sa=function(n,t){return wa.call(n,t)};"function"==typeof Sizzle&&(ba=function(n,t){return Sizzle(n,t)[0]||null},_a=Sizzle,Sa=Sizzle.matchesSelector),ta.selection=function(){return Na};var ka=ta.selection.prototype=[];ka.select=function(n){var t,e,r,u,i=[];n=k(n);for(var o=-1,a=this.length;++o=0&&(e=n.slice(0,t),n=n.slice(t+1)),Ea.hasOwnProperty(e)?{space:Ea[e],local:n}:n}},ka.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ta.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(A(t,n[t]));return this}return this.each(A(n,t))},ka.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=z(n)).length,u=-1;if(t=e.classList){for(;++ur){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(T(e,n[e],t));return this}if(2>r)return oa.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(T(n,t,e))},ka.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(R(t,n[t]));return this}return this.each(R(n,t))},ka.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},ka.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},ka.append=function(n){return n=D(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},ka.insert=function(n,t){return n=D(n),t=k(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},ka.remove=function(){return this.each(P)},ka.data=function(n,t){function e(n,e){var r,u,i,o=n.length,f=e.length,h=Math.min(o,f),g=new Array(f),p=new Array(f),v=new Array(o);if(t){var d,m=new a,y=new Array(o);for(r=-1;++rr;++r)p[r]=U(e[r]);for(;o>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,c.push(p),l.push(g),s.push(v)}var r,u,i=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return S(u)},ka.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},ka.sort=function(n){n=F.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},ka.size=function(){var n=0;return H(this,function(){++n}),n};var Aa=[];ta.selection.enter=O,ta.selection.enter.prototype=Aa,Aa.append=ka.append,Aa.empty=ka.empty,Aa.node=ka.node,Aa.call=ka.call,Aa.size=ka.size,Aa.select=function(n){for(var t,e,r,u,i,o=[],a=-1,c=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(I(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(I(n,t,e))};var Ca=ta.map({mouseenter:"mouseover",mouseleave:"mouseout"});Ca.forEach(function(n){"on"+n in ua&&Ca.remove(n)});var za="onselectstart"in ua?null:m(ia.style,"userSelect"),qa=0;ta.mouse=function(n){return $(n,_())};var La=/WebKit/.test(oa.navigator.userAgent)?-1:0;ta.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=_().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return $(n,r)},ta.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",i)}function t(n,t,u,i,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],p|=n|e,M=r,g({type:"drag",x:r[0]+l[0],y:r[1]+l[1],dx:n,dy:e}))}function c(){t(h,v)&&(m.on(i+d,null).on(o+d,null),y(p&&ta.event.target===f),g({type:"dragend"}))}var l,s=this,f=ta.event.target,h=s.parentNode,g=e.of(s,arguments),p=0,v=n(),d=".drag"+(null==v?"":"-"+v),m=ta.select(u()).on(i+d,a).on(o+d,c),y=X(),M=t(h,v);r?(l=r.apply(s,arguments),l=[l.x-M[0],l.y-M[1]]):l=[0,0],g({type:"dragstart"})}}var e=w(n,"drag","dragstart","dragend"),r=null,u=t(y,ta.mouse,J,"mousemove","mouseup"),i=t(B,ta.touch,W,"touchmove","touchend");return n.origin=function(t){return arguments.length?(r=t,n):r},ta.rebind(n,e,"on")},ta.touches=function(n,t){return arguments.length<2&&(t=_().touches),t?ra(t).map(function(t){var e=$(n,t);return e.identifier=t.identifier,e}):[]};var Ta=1e-6,Ra=Ta*Ta,Da=Math.PI,Pa=2*Da,Ua=Pa-Ta,ja=Da/2,Fa=Da/180,Ha=180/Da,Oa=Math.SQRT2,Ya=2,Ia=4;ta.interpolateZoom=function(n,t){function e(n){var t=n*y;if(m){var e=et(v),o=i/(Ya*h)*(e*rt(Oa*t+v)-tt(v));return[r+o*l,u+o*s,i*e/et(Oa*t+v)]}return[r+n*l,u+n*s,i*Math.exp(Oa*t)]}var r=n[0],u=n[1],i=n[2],o=t[0],a=t[1],c=t[2],l=o-r,s=a-u,f=l*l+s*s,h=Math.sqrt(f),g=(c*c-i*i+Ia*f)/(2*i*Ya*h),p=(c*c-i*i-Ia*f)/(2*c*Ya*h),v=Math.log(Math.sqrt(g*g+1)-g),d=Math.log(Math.sqrt(p*p+1)-p),m=d-v,y=(m||Math.log(c/i))/Oa;return e.duration=1e3*y,e},ta.behavior.zoom=function(){function n(n){n.on(z,s).on(Xa+".zoom",h).on("dblclick.zoom",g).on(T,f)}function t(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function e(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function r(n){k.k=Math.max(A[0],Math.min(A[1],n))}function u(n,t){t=e(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function i(t,e,i,o){t.__chart__={x:k.x,y:k.y,k:k.k},r(Math.pow(2,o)),u(v=e,i),t=ta.select(t),N>0&&(t=t.transition().duration(N)),t.call(n.event)}function o(){x&&x.domain(M.range().map(function(n){return(n-k.x)/k.k}).map(M.invert)),S&&S.domain(_.range().map(function(n){return(n-k.y)/k.k}).map(_.invert))}function a(n){C++||n({type:"zoomstart"})}function c(n){o(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function l(n){--C||n({type:"zoomend"}),v=null}function s(){function n(){s=1,u(ta.mouse(r),h),c(o)}function e(){f.on(q,null).on(L,null),g(s&&ta.event.target===i),l(o)}var r=this,i=ta.event.target,o=R.of(r,arguments),s=0,f=ta.select(oa).on(q,n).on(L,e),h=t(ta.mouse(r)),g=X();Fl.call(r),a(o)}function f(){function n(){var n=ta.touches(p);return g=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=t(n))}),n}function e(){var t=ta.event.target;ta.select(t).on(x,o).on(_,h),w.push(t);for(var e=ta.event.changedTouches,r=0,u=e.length;u>r;++r)d[e[r].identifier]=null;var a=n(),c=Date.now();if(1===a.length){if(500>c-y){var l=a[0];i(p,l,d[l.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),b()}y=c}else if(a.length>1){var l=a[0],s=a[1],f=l[0]-s[0],g=l[1]-s[1];m=f*f+g*g}}function o(){var n,t,e,i,o=ta.touches(p);Fl.call(p);for(var a=0,l=o.length;l>a;++a,i=null)if(e=o[a],i=d[e.identifier]){if(t)break;n=e,t=i}if(i){var s=(s=e[0]-n[0])*s+(s=e[1]-n[1])*s,f=m&&Math.sqrt(s/m);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+i[0])/2,(t[1]+i[1])/2],r(f*g)}y=null,u(n,t),c(v)}function h(){if(ta.event.touches.length){for(var t=ta.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var u in d)return void n()}ta.selectAll(w).on(M,null),S.on(z,s).on(T,f),E(),l(v)}var g,p=this,v=R.of(p,arguments),d={},m=0,M=".zoom-"+ta.event.changedTouches[0].identifier,x="touchmove"+M,_="touchend"+M,w=[],S=ta.select(p),E=X();e(),a(v),S.on(z,null).on(T,e)}function h(){var n=R.of(this,arguments);m?clearTimeout(m):(p=t(v=d||ta.mouse(this)),Fl.call(this),a(n)),m=setTimeout(function(){m=null,l(n)},50),b(),r(Math.pow(2,.002*Za())*k.k),u(v,p),c(n)}function g(){var n=ta.mouse(this),e=Math.log(k.k)/Math.LN2;i(this,n,t(n),ta.event.shiftKey?Math.ceil(e)-1:Math.floor(e)+1)}var p,v,d,m,y,M,x,_,S,k={x:0,y:0,k:1},E=[960,500],A=Va,N=250,C=0,z="mousedown.zoom",q="mousemove.zoom",L="mouseup.zoom",T="touchstart.zoom",R=w(n,"zoomstart","zoom","zoomend");return n.event=function(n){n.each(function(){var n=R.of(this,arguments),t=k;Ul?ta.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},a(n)}).tween("zoom:zoom",function(){var e=E[0],r=E[1],u=v?v[0]:e/2,i=v?v[1]:r/2,o=ta.interpolateZoom([(u-k.x)/k.k,(i-k.y)/k.k,e/k.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=k={x:u-r[0]*a,y:i-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){l(n)}).each("end.zoom",function(){l(n)}):(this.__chart__=k,a(n),c(n),l(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},o(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:+t},o(),n):k.k},n.scaleExtent=function(t){return arguments.length?(A=null==t?Va:[+t[0],+t[1]],n):A},n.center=function(t){return arguments.length?(d=t&&[+t[0],+t[1]],n):d},n.size=function(t){return arguments.length?(E=t&&[+t[0],+t[1]],n):E},n.duration=function(t){return arguments.length?(N=+t,n):N},n.x=function(t){return arguments.length?(x=t,M=t.copy(),k={x:0,y:0,k:1},n):x},n.y=function(t){return arguments.length?(S=t,_=t.copy(),k={x:0,y:0,k:1},n):S},ta.rebind(n,R,"on")};var Za,Va=[0,1/0],Xa="onwheel"in ua?(Za=function(){return-ta.event.deltaY*(ta.event.deltaMode?120:1)},"wheel"):"onmousewheel"in ua?(Za=function(){return ta.event.wheelDelta},"mousewheel"):(Za=function(){return-ta.event.detail},"MozMousePixelScroll");ta.color=it,it.prototype.toString=function(){return this.rgb()+""},ta.hsl=ot;var $a=ot.prototype=new it;$a.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,this.l/n)},$a.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ot(this.h,this.s,n*this.l)},$a.rgb=function(){return at(this.h,this.s,this.l)},ta.hcl=ct;var Ba=ct.prototype=new it;Ba.brighter=function(n){return new ct(this.h,this.c,Math.min(100,this.l+Wa*(arguments.length?n:1)))},Ba.darker=function(n){return new ct(this.h,this.c,Math.max(0,this.l-Wa*(arguments.length?n:1)))},Ba.rgb=function(){return lt(this.h,this.c,this.l).rgb()},ta.lab=st;var Wa=18,Ja=.95047,Ga=1,Ka=1.08883,Qa=st.prototype=new it;Qa.brighter=function(n){return new st(Math.min(100,this.l+Wa*(arguments.length?n:1)),this.a,this.b)},Qa.darker=function(n){return new st(Math.max(0,this.l-Wa*(arguments.length?n:1)),this.a,this.b)},Qa.rgb=function(){return ft(this.l,this.a,this.b)},ta.rgb=dt;var nc=dt.prototype=new it;nc.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new dt(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new dt(u,u,u)},nc.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new dt(n*this.r,n*this.g,n*this.b)},nc.hsl=function(){return bt(this.r,this.g,this.b)},nc.toString=function(){return"#"+Mt(this.r)+Mt(this.g)+Mt(this.b)};var tc=ta.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});tc.forEach(function(n,t){tc.set(n,mt(t))}),ta.functor=kt,ta.xhr=At(Et),ta.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=Nt(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),c=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(s>=l)return o;if(u)return u=!1,i;var t=s;if(34===n.charCodeAt(t)){for(var e=t;e++s;){var r=n.charCodeAt(s++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(s)&&(++s,++a);else if(r!==c)continue;return n.slice(t,s-a)}return n.slice(t)}for(var r,u,i={},o={},a=[],l=n.length,s=0,f=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,f++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new v,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},ta.csv=ta.dsv(",","text/csv"),ta.tsv=ta.dsv(" ","text/tab-separated-values");var ec,rc,uc,ic,oc,ac=oa[m(oa,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ta.timer=function(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,f:!1,n:null};rc?rc.n=i:ec=i,rc=i,uc||(ic=clearTimeout(ic),uc=1,ac(qt))},ta.timer.flush=function(){Lt(),Tt()},ta.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var cc=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Dt);ta.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=ta.round(n,Rt(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),cc[8+e/3]};var lc=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,sc=ta.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ta.round(n,Rt(n,t))).toFixed(Math.max(0,Math.min(20,Rt(n*(1+1e-15),t))))}}),fc=ta.time={},hc=Date;jt.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(){gc.setUTCDate.apply(this._,arguments)},setDay:function(){gc.setUTCDay.apply(this._,arguments)},setFullYear:function(){gc.setUTCFullYear.apply(this._,arguments)},setHours:function(){gc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){gc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){gc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){gc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){gc.setUTCSeconds.apply(this._,arguments)},setTime:function(){gc.setTime.apply(this._,arguments)}};var gc=Date.prototype;fc.year=Ft(function(n){return n=fc.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),fc.years=fc.year.range,fc.years.utc=fc.year.utc.range,fc.day=Ft(function(n){var t=new hc(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),fc.days=fc.day.range,fc.days.utc=fc.day.utc.range,fc.dayOfYear=function(n){var t=fc.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=fc[n]=Ft(function(n){return(n=fc.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=fc.year(n).getDay();return Math.floor((fc.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});fc[n+"s"]=e.range,fc[n+"s"].utc=e.utc.range,fc[n+"OfYear"]=function(n){var e=fc.year(n).getDay();return Math.floor((fc.dayOfYear(n)+(e+t)%7)/7)}}),fc.week=fc.sunday,fc.weeks=fc.sunday.range,fc.weeks.utc=fc.sunday.utc.range,fc.weekOfYear=fc.sundayOfYear;var pc={"-":"",_:" ",0:"0"},vc=/^\s*\d+/,dc=/^%/;ta.locale=function(n){return{numberFormat:Pt(n),timeFormat:Ot(n)}};var mc=ta.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ta.format=mc.numberFormat,ta.geo={},ce.prototype={s:0,t:0,add:function(n){le(n,this.t,yc),le(yc.s,this.s,this),this.s?this.t+=yc.t:this.s=yc.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var yc=new ce;ta.geo.stream=function(n,t){n&&Mc.hasOwnProperty(n.type)?Mc[n.type](n,t):se(n,t)};var Mc={Feature:function(n,t){se(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*Da+n:n,wc.lineStart=wc.lineEnd=wc.point=y}};ta.geo.bounds=function(){function n(n,t){M.push(x=[s=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=pe([t*Fa,e*Fa]);if(m){var u=de(m,r),i=[u[1],-u[0],0],o=de(i,u);Me(o),o=xe(o);var c=t-p,l=c>0?1:-1,v=o[0]*Ha*l,d=va(c)>180;if(d^(v>l*p&&l*t>v)){var y=o[1]*Ha;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>l*p&&l*t>v)){var y=-o[1]*Ha;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t):h>=s?(s>t&&(s=t),t>h&&(h=t)):t>p?a(s,t)>a(s,h)&&(h=t):a(t,h)>a(s,h)&&(s=t)}else n(t,e);m=r,p=t}function e(){b.point=t}function r(){x[0]=s,x[1]=h,b.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=va(r)>180?r+(r>0?360:-360):r}else v=n,d=e;wc.point(n,e),t(n,e)}function i(){wc.lineStart()}function o(){u(v,d),wc.lineEnd(),va(y)>Ta&&(s=-(h=180)),x[0]=s,x[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function l(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:n_c?(s=-(h=180),f=-(g=90)):y>Ta?g=90:-Ta>y&&(f=-90),x[0]=s,x[1]=h}};return function(n){g=h=-(s=f=1/0),M=[],ta.geo.stream(n,b);var t=M.length;if(t){M.sort(c);for(var e,r=1,u=M[0],i=[u];t>r;++r)e=M[r],l(e[0],u)||l(e[1],u)?(a(u[0],e[1])>a(u[0],u[1])&&(u[1]=e[1]),a(e[0],u[1])>a(u[0],u[1])&&(u[0]=e[0])):i.push(u=e);for(var o,e,p=-1/0,t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(o=a(u[1],e[0]))>p&&(p=o,s=e[0],h=u[1])}return M=x=null,1/0===s||1/0===f?[[0/0,0/0],[0/0,0/0]]:[[s,f],[h,g]]}}(),ta.geo.centroid=function(n){Sc=kc=Ec=Ac=Nc=Cc=zc=qc=Lc=Tc=Rc=0,ta.geo.stream(n,Dc);var t=Lc,e=Tc,r=Rc,u=t*t+e*e+r*r;return Ra>u&&(t=Cc,e=zc,r=qc,Ta>kc&&(t=Ec,e=Ac,r=Nc),u=t*t+e*e+r*r,Ra>u)?[0/0,0/0]:[Math.atan2(e,t)*Ha,nt(r/Math.sqrt(u))*Ha]};var Sc,kc,Ec,Ac,Nc,Cc,zc,qc,Lc,Tc,Rc,Dc={sphere:y,point:_e,lineStart:Se,lineEnd:ke,polygonStart:function(){Dc.lineStart=Ee},polygonEnd:function(){Dc.lineStart=Se}},Pc=Le(Ne,Pe,je,[-Da,-Da/2]),Uc=1e9;ta.geo.clipExtent=function(){var n,t,e,r,u,i,o={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(a){return arguments.length?(i=Ye(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),u&&(u.valid=!1,u=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(ta.geo.conicEqualArea=function(){return Ie(Ze)}).raw=Ze,ta.geo.albers=function(){return ta.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ta.geo.albersUsa=function(){function n(n){var i=n[0],o=n[1];return t=null,e(i,o),t||(r(i,o),t)||u(i,o),t}var t,e,r,u,i=ta.geo.albers(),o=ta.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ta.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?o:u>=.166&&.234>u&&r>=-.214&&-.115>r?a:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),a.precision(t),n):i.precision()},n.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),a.scale(t),n.translate(i.translate())):i.scale()},n.translate=function(t){if(!arguments.length)return i.translate();var l=i.scale(),s=+t[0],f=+t[1];return e=i.translate(t).clipExtent([[s-.455*l,f-.238*l],[s+.455*l,f+.238*l]]).stream(c).point,r=o.translate([s-.307*l,f+.201*l]).clipExtent([[s-.425*l+Ta,f+.12*l+Ta],[s-.214*l-Ta,f+.234*l-Ta]]).stream(c).point,u=a.translate([s-.205*l,f+.212*l]).clipExtent([[s-.214*l+Ta,f+.166*l+Ta],[s-.115*l-Ta,f+.234*l-Ta]]).stream(c).point,n},n.scale(1070)};var jc,Fc,Hc,Oc,Yc,Ic,Zc={point:y,lineStart:y,lineEnd:y,polygonStart:function(){Fc=0,Zc.lineStart=Ve},polygonEnd:function(){Zc.lineStart=Zc.lineEnd=Zc.point=y,jc+=va(Fc/2)}},Vc={point:Xe,lineStart:y,lineEnd:y,polygonStart:y,polygonEnd:y},Xc={point:We,lineStart:Je,lineEnd:Ge,polygonStart:function(){Xc.lineStart=Ke},polygonEnd:function(){Xc.point=We,Xc.lineStart=Je,Xc.lineEnd=Ge}};ta.geo.path=function(){function n(n){return n&&("function"==typeof a&&i.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=u(i)),ta.geo.stream(n,o)),i.result()}function t(){return o=null,n}var e,r,u,i,o,a=4.5;return n.area=function(n){return jc=0,ta.geo.stream(n,u(Zc)),jc},n.centroid=function(n){return Ec=Ac=Nc=Cc=zc=qc=Lc=Tc=Rc=0,ta.geo.stream(n,u(Xc)),Rc?[Lc/Rc,Tc/Rc]:qc?[Cc/qc,zc/qc]:Nc?[Ec/Nc,Ac/Nc]:[0/0,0/0]},n.bounds=function(n){return Yc=Ic=-(Hc=Oc=1/0),ta.geo.stream(n,u(Vc)),[[Hc,Oc],[Yc,Ic]]},n.projection=function(n){return arguments.length?(u=(e=n)?n.stream||tr(n):Et,t()):e},n.context=function(n){return arguments.length?(i=null==(r=n)?new $e:new Qe(n),"function"!=typeof a&&i.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),n):a},n.projection(ta.geo.albersUsa()).context(null)},ta.geo.transform=function(n){return{stream:function(t){var e=new er(t);for(var r in n)e[r]=n[r];return e}}},er.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ta.geo.projection=ur,ta.geo.projectionMutator=ir,(ta.geo.equirectangular=function(){return ur(ar)}).raw=ar.invert=ar,ta.geo.rotation=function(n){function t(t){return t=n(t[0]*Fa,t[1]*Fa),t[0]*=Ha,t[1]*=Ha,t}return n=lr(n[0]%360*Fa,n[1]*Fa,n.length>2?n[2]*Fa:0),t.invert=function(t){return t=n.invert(t[0]*Fa,t[1]*Fa),t[0]*=Ha,t[1]*=Ha,t},t},cr.invert=ar,ta.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=lr(-n[0]*Fa,-n[1]*Fa,0).invert,u=[];return e(null,null,1,{point:function(n,e){u.push(n=t(n,e)),n[0]*=Ha,n[1]*=Ha}}),{type:"Polygon",coordinates:[u]}}var t,e,r=[0,0],u=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=gr((t=+r)*Fa,u*Fa),n):t},n.precision=function(r){return arguments.length?(e=gr(t*Fa,(u=+r)*Fa),n):u},n.angle(90)},ta.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Fa,u=n[1]*Fa,i=t[1]*Fa,o=Math.sin(r),a=Math.cos(r),c=Math.sin(u),l=Math.cos(u),s=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((e=f*o)*e+(e=l*s-c*f*a)*e),c*s+l*f*a)},ta.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ta.range(Math.ceil(i/d)*d,u,d).map(h).concat(ta.range(Math.ceil(l/m)*m,c,m).map(g)).concat(ta.range(Math.ceil(r/p)*p,e,p).filter(function(n){return va(n%d)>Ta}).map(s)).concat(ta.range(Math.ceil(a/v)*v,o,v).filter(function(n){return va(n%m)>Ta}).map(f))}var e,r,u,i,o,a,c,l,s,f,h,g,p=10,v=p,d=90,m=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(g(c).slice(1),h(u).reverse().slice(1),g(l).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(i=+t[0][0],u=+t[1][0],l=+t[0][1],c=+t[1][1],i>u&&(t=i,i=u,u=t),l>c&&(t=l,l=c,c=t),n.precision(y)):[[i,l],[u,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(y)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.minorStep=function(t){return arguments.length?(p=+t[0],v=+t[1],n):[p,v]},n.precision=function(t){return arguments.length?(y=+t,s=vr(a,o,90),f=dr(r,e,y),h=vr(l,c,90),g=dr(i,u,y),n):y},n.majorExtent([[-180,-90+Ta],[180,90-Ta]]).minorExtent([[-180,-80-Ta],[180,80+Ta]])},ta.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||u.apply(this,arguments)]}}var t,e,r=mr,u=yr;return n.distance=function(){return ta.geo.distance(t||r.apply(this,arguments),e||u.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(u=t,e="function"==typeof t?null:t,n):u},n.precision=function(){return arguments.length?n:0},n},ta.geo.interpolate=function(n,t){return Mr(n[0]*Fa,n[1]*Fa,t[0]*Fa,t[1]*Fa)},ta.geo.length=function(n){return $c=0,ta.geo.stream(n,Bc),$c};var $c,Bc={sphere:y,point:y,lineStart:xr,lineEnd:y,polygonStart:y,polygonEnd:y},Wc=br(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ta.geo.azimuthalEqualArea=function(){return ur(Wc)}).raw=Wc;var Jc=br(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},Et);(ta.geo.azimuthalEquidistant=function(){return ur(Jc)}).raw=Jc,(ta.geo.conicConformal=function(){return Ie(_r)}).raw=_r,(ta.geo.conicEquidistant=function(){return Ie(wr)}).raw=wr;var Gc=br(function(n){return 1/n},Math.atan);(ta.geo.gnomonic=function(){return ur(Gc)}).raw=Gc,Sr.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-ja]},(ta.geo.mercator=function(){return kr(Sr)}).raw=Sr;var Kc=br(function(){return 1},Math.asin);(ta.geo.orthographic=function(){return ur(Kc)}).raw=Kc;var Qc=br(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ta.geo.stereographic=function(){return ur(Qc)}).raw=Qc,Er.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-ja]},(ta.geo.transverseMercator=function(){var n=kr(Er),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Er,ta.geom={},ta.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=kt(e),i=kt(r),o=n.length,a=[],c=[];for(t=0;o>t;t++)a.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(a.sort(zr),t=0;o>t;t++)c.push([a[t][0],-a[t][1]]);var l=Cr(a),s=Cr(c),f=s[0]===l[0],h=s[s.length-1]===l[l.length-1],g=[];for(t=l.length-1;t>=0;--t)g.push(n[a[l[t]][2]]);for(t=+f;t=r&&l.x<=i&&l.y>=u&&l.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];s.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/Ta)*Ta,y:Math.round(o(n,t)/Ta)*Ta,i:t}})}var r=Ar,u=Nr,i=r,o=u,a=cl;return n?t(n):(t.links=function(n){return iu(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return iu(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(Ir),c=-1,l=a.length,s=a[l-1].edge,f=s.l===o?s.r:s.l;++c=l,h=r>=s,g=h<<1|f;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=su()),f?u=l:a=l,h?o=s:c=s,i(n,t,e,r,u,o,a,c)}var s,f,h,g,p,v,d,m,y,M=kt(a),x=kt(c);if(null!=t)v=t,d=e,m=r,y=u;else if(m=y=-(v=d=1/0),f=[],h=[],p=n.length,o)for(g=0;p>g;++g)s=n[g],s.xm&&(m=s.x),s.y>y&&(y=s.y),f.push(s.x),h.push(s.y);else for(g=0;p>g;++g){var b=+M(s=n[g],g),_=+x(s,g);v>b&&(v=b),d>_&&(d=_),b>m&&(m=b),_>y&&(y=_),f.push(b),h.push(_)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=su();if(k.add=function(n){i(k,n,+M(n,++g),+x(n,g),v,d,m,y)},k.visit=function(n){fu(n,k,v,d,m,y)},k.find=function(n){return hu(k,n[0],n[1],v,d,m,y)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=hl.get(e)||fl,r=gl.get(r)||Et,Mu(r(e.apply(null,ea.call(arguments,1))))},ta.interpolateHcl=Lu,ta.interpolateHsl=Tu,ta.interpolateLab=Ru,ta.interpolateRound=Du,ta.transform=function(n){var t=ua.createElementNS(ta.ns.prefix.svg,"g");return(ta.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Pu(e?e.matrix:pl)})(n)},Pu.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var pl={a:1,b:0,c:0,d:1,e:0,f:0};ta.interpolateTransform=Hu,ta.layout={},ta.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/d){if(p>c){var l=t.charge/c;n.px-=i*l,n.py-=o*l}return!0}if(t.point&&c&&p>c){var l=t.pointCharge/c;n.px-=i*l,n.py-=o*l}}return!t.charge}}function t(n){n.px=ta.event.x,n.py=ta.event.y,a.resume()}var e,r,u,i,o,a={},c=ta.dispatch("start","tick","end"),l=[1,1],s=.9,f=vl,h=dl,g=-30,p=ml,v=.1,d=.64,m=[],y=[];return a.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,a,f,h,p,d,M,x,b=m.length,_=y.length;for(e=0;_>e;++e)a=y[e],f=a.source,h=a.target,M=h.x-f.x,x=h.y-f.y,(p=M*M+x*x)&&(p=r*i[e]*((p=Math.sqrt(p))-u[e])/p,M*=p,x*=p,h.x-=M*(d=f.weight/(h.weight+f.weight)),h.y-=x*d,f.x+=M*(d=1-d),f.y+=x*d);if((d=r*v)&&(M=l[0]/2,x=l[1]/2,e=-1,d))for(;++e0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),ta.timer(a.tick)),a):r},a.start=function(){function n(n,r){if(!e){for(e=new Array(c),a=0;c>a;++a)e[a]=[];for(a=0;l>a;++a){var u=y[a];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var i,o=e[t],a=-1,l=o.length;++at;++t)(r=m[t]).index=t,r.weight=0;for(t=0;s>t;++t)r=y[t],"number"==typeof r.source&&(r.source=m[r.source]),"number"==typeof r.target&&(r.target=m[r.target]),++r.source.weight,++r.target.weight;for(t=0;c>t;++t)r=m[t],isNaN(r.x)&&(r.x=n("x",p)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof f)for(t=0;s>t;++t)u[t]=+f.call(this,y[t],t);else for(t=0;s>t;++t)u[t]=f;if(i=[],"function"==typeof h)for(t=0;s>t;++t)i[t]=+h.call(this,y[t],t);else for(t=0;s>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,m[t],t);else for(t=0;c>t;++t)o[t]=g;return a.resume()},a.resume=function(){return a.alpha(.1)},a.stop=function(){return a.alpha(0)},a.drag=function(){return e||(e=ta.behavior.drag().origin(Et).on("dragstart.force",Xu).on("drag.force",t).on("dragend.force",$u)),arguments.length?(this.on("mouseover.force",Bu).on("mouseout.force",Wu).call(e),void 0):e},ta.rebind(a,c,"on")};var vl=20,dl=1,ml=1/0;ta.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(l=e.call(n,i,i.depth))&&(c=l.length)){for(var c,l,s;--c>=0;)o.push(s=l[c]),s.parent=i,s.depth=i.depth+1;r&&(i.value=0),i.children=l}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return Qu(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=ei,e=ni,r=ti;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(Ku(t,function(n){n.children&&(n.value=0)}),Qu(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ta.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,c,l=-1;for(r=t.value?r/t.value:0;++lf?-1:1),p=(f-c*g)/ta.sum(l),v=ta.range(c),d=[];return null!=e&&v.sort(e===yl?function(n,t){return l[t]-l[n]}:function(n,t){return e(o[n],o[t])}),v.forEach(function(n){d[n]={data:o[n],value:a=l[n],startAngle:s,endAngle:s+=a*p+g,padAngle:h}}),d}var t=Number,e=yl,r=0,u=Pa,i=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(u=t,n):u},n.padAngle=function(t){return arguments.length?(i=t,n):i},n};var yl={};ta.layout.stack=function(){function n(a,c){if(!(h=a.length))return a;var l=a.map(function(e,r){return t.call(n,e,r)}),s=l.map(function(t){return t.map(function(t,e){return[i.call(n,t,e),o.call(n,t,e)]})}),f=e.call(n,s,c);l=ta.permute(l,f),s=ta.permute(s,f);var h,g,p,v,d=r.call(n,s,c),m=l[0].length;for(p=0;m>p;++p)for(u.call(n,l[0][p],v=d[p],s[0][p][1]),g=1;h>g;++g)u.call(n,l[g][p],v+=s[g-1][p][1],s[g][p][1]);return a}var t=Et,e=ai,r=ci,u=oi,i=ui,o=ii;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:Ml.get(t)||ai,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:xl.get(t)||ci,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var Ml=ta.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(li),i=n.map(si),o=ta.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,c=0,l=[],s=[];for(t=0;r>t;++t)e=o[t],c>a?(a+=i[e],l.push(e)):(c+=i[e],s.push(e));return s.reverse().concat(l)},reverse:function(n){return ta.range(n.length).reverse()},"default":ai}),xl=ta.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,c=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)c[e]=(a-o[e])/2;return c},wiggle:function(n){var t,e,r,u,i,o,a,c,l,s=n.length,f=n[0],h=f.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(t=0,u=0;s>t;++t)u+=n[t][e][1];for(t=0,i=0,a=f[e][0]-f[e-1][0];s>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=c-=u?i/u*a:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:ci});ta.layout.histogram=function(){function n(n,i){for(var o,a,c=[],l=n.map(e,this),s=r.call(this,l,i),f=u.call(this,s,l,i),i=-1,h=l.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=s[0]&&a<=s[1]&&(o=c[ta.bisect(f,a,1,g)-1],o.y+=p,o.push(n[i]));return c}var t=!0,e=Number,r=pi,u=hi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=kt(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return gi(n,t)}:kt(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ta.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],c=u[0],l=u[1],s=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Qu(a,function(n){n.r=+s(n.value)}),Qu(a,Mi),r){var f=r*(t?1:Math.max(2*a.r/c,2*a.r/l))/2;Qu(a,function(n){n.r+=f}),Qu(a,Mi),Qu(a,function(n){n.r-=f})}return _i(a,c/2,l/2,t?1:1/Math.max(2*a.r/c,2*a.r/l)),o}var t,e=ta.layout.hierarchy().sort(vi),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Gu(n,e)},ta.layout.tree=function(){function n(n,u){var s=o.call(this,n,u),f=s[0],h=t(f);if(Qu(h,e),h.parent.m=-h.z,Ku(h,r),l)Ku(f,i);else{var g=f,p=f,v=f;Ku(f,function(n){n.xp.x&&(p=n),n.depth>v.depth&&(v=n)});var d=a(g,p)/2-g.x,m=c[0]/(p.x+a(p,g)/2+d),y=c[1]/(v.depth||1);Ku(f,function(n){n.x=(n.x+d)*m,n.y=n.depth*y})}return s}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Ni(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,c=u.parent.children[0],l=u.m,s=i.m,f=o.m,h=c.m;o=Ei(o),u=ki(u),o&&u;)c=ki(c),i=Ei(i),i.a=n,r=o.z+f-u.z-l+a(o._,u._),r>0&&(Ai(Ci(o,n,e),n,r),l+=r,s+=r),f+=o.m,l+=u.m,h+=c.m,s+=i.m;o&&!Ei(i)&&(i.t=o,i.m+=f-s),u&&!ki(c)&&(c.t=u,c.m+=l-h,e=n)}return e}function i(n){n.x*=c[0],n.y=n.depth*c[1]}var o=ta.layout.hierarchy().sort(null).value(null),a=Si,c=[1,1],l=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(l=null==(c=t)?i:null,n):l?null:c},n.nodeSize=function(t){return arguments.length?(l=null==(c=t)?null:i,n):l?c:null},Gu(n,o)},ta.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),c=a[0],l=0;Qu(c,function(n){var t=n.children;t&&t.length?(n.x=qi(t),n.y=zi(t)):(n.x=o?l+=e(n,o):0,n.y=0,o=n)});var s=Li(c),f=Ti(c),h=s.x-e(s,f)/2,g=f.x+e(f,s)/2;return Qu(c,u?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),a}var t=ta.layout.hierarchy().sort(null).value(null),e=Si,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Gu(n,t)},ta.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,c,l=f(e),s=[],h=i.slice(),p=1/0,v="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(n(h,l.dx*l.dy/e.value),s.area=0;(c=h.length)>0;)s.push(o=h[c-1]),s.area+=o.area,"squarify"!==g||(a=r(s,v))<=p?(h.pop(),p=a):(s.area-=s.pop().area,u(s,v,l,!1),v=Math.min(l.dx,l.dy),s.length=s.area=0,p=1/0);s.length&&(u(s,v,l,!0),s.length=s.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=f(t),a=r.slice(),c=[];for(n(a,o.dx*o.dy/t.value),c.area=0;i=a.pop();)c.push(i),c.area+=i.area,null!=i.z&&(u(c,i.z?o.dx:o.dy,o,!a.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,l=e.y,s=t?c(n.area/t):0;if(t==e.dx){for((r||s>e.dy)&&(s=e.dy);++ie.dx)&&(s=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=ta.random.normal.apply(ta,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ta.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ta.scale={};var bl={floor:Et,ceil:Et};ta.scale.linear=function(){return Yi([0,1],[0,1],mu,!1)};var _l={s:1,g:1,p:1,r:1,e:1};ta.scale.log=function(){return Ji(ta.scale.linear().domain([0,1]),10,!0,[1,10])};var wl=ta.format(".0e"),Sl={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ta.scale.pow=function(){return Gi(ta.scale.linear(),1,[0,1])},ta.scale.sqrt=function(){return ta.scale.pow().exponent(.5)},ta.scale.ordinal=function(){return Qi([],{t:"range",a:[[]]})},ta.scale.category10=function(){return ta.scale.ordinal().range(kl)},ta.scale.category20=function(){return ta.scale.ordinal().range(El)},ta.scale.category20b=function(){return ta.scale.ordinal().range(Al)},ta.scale.category20c=function(){return ta.scale.ordinal().range(Nl)};var kl=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(yt),El=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(yt),Al=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(yt),Nl=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(yt);ta.scale.quantile=function(){return no([],[])},ta.scale.quantize=function(){return to(0,1,[0,1])},ta.scale.threshold=function(){return eo([.5],[0,1])},ta.scale.identity=function(){return ro([0,1])},ta.svg={},ta.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),l=Math.max(0,+r.apply(this,arguments)),s=o.apply(this,arguments)-ja,f=a.apply(this,arguments)-ja,h=Math.abs(f-s),g=s>f?0:1;if(n>l&&(p=l,l=n,n=p),h>=Ua)return t(l,g)+(n?t(n,1-g):"")+"Z";var p,v,d,m,y,M,x,b,_,w,S,k,E=0,A=0,N=[];if((m=(+c.apply(this,arguments)||0)/2)&&(d=i===Cl?Math.sqrt(n*n+l*l):+i.apply(this,arguments),g||(A*=-1),l&&(A=nt(d/l*Math.sin(m))),n&&(E=nt(d/n*Math.sin(m)))),l){y=l*Math.cos(s+A),M=l*Math.sin(s+A),x=l*Math.cos(f-A),b=l*Math.sin(f-A);var C=Math.abs(f-s-2*A)<=Da?0:1;if(A&&so(y,M,x,b)===g^C){var z=(s+f)/2;y=l*Math.cos(z),M=l*Math.sin(z),x=b=null}}else y=M=0;if(n){_=n*Math.cos(f-E),w=n*Math.sin(f-E),S=n*Math.cos(s+E),k=n*Math.sin(s+E);var q=Math.abs(s-f+2*E)<=Da?0:1;if(E&&so(_,w,S,k)===1-g^q){var L=(s+f)/2;_=n*Math.cos(L),w=n*Math.sin(L),S=k=null}}else _=w=0;if((p=Math.min(Math.abs(l-n)/2,+u.apply(this,arguments)))>.001){v=l>n^g?0:1;var T=null==S?[_,w]:null==x?[y,M]:Lr([y,M],[S,k],[x,b],[_,w]),R=y-T[0],D=M-T[1],P=x-T[0],U=b-T[1],j=1/Math.sin(Math.acos((R*P+D*U)/(Math.sqrt(R*R+D*D)*Math.sqrt(P*P+U*U)))/2),F=Math.sqrt(T[0]*T[0]+T[1]*T[1]);if(null!=x){var H=Math.min(p,(l-F)/(j+1)),O=fo(null==S?[_,w]:[S,k],[y,M],l,H,g),Y=fo([x,b],[_,w],l,H,g);p===H?N.push("M",O[0],"A",H,",",H," 0 0,",v," ",O[1],"A",l,",",l," 0 ",1-g^so(O[1][0],O[1][1],Y[1][0],Y[1][1]),",",g," ",Y[1],"A",H,",",H," 0 0,",v," ",Y[0]):N.push("M",O[0],"A",H,",",H," 0 1,",v," ",Y[0])}else N.push("M",y,",",M);if(null!=S){var I=Math.min(p,(n-F)/(j-1)),Z=fo([y,M],[S,k],n,-I,g),V=fo([_,w],null==x?[y,M]:[x,b],n,-I,g);p===I?N.push("L",V[0],"A",I,",",I," 0 0,",v," ",V[1],"A",n,",",n," 0 ",g^so(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",I,",",I," 0 0,",v," ",Z[0]):N.push("L",V[0],"A",I,",",I," 0 0,",v," ",Z[0])}else N.push("L",_,",",w)}else N.push("M",y,",",M),null!=x&&N.push("A",l,",",l," 0 ",C,",",g," ",x,",",b),N.push("L",_,",",w),null!=S&&N.push("A",n,",",n," 0 ",q,",",1-g," ",S,",",k);return N.push("Z"),N.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=io,r=oo,u=uo,i=Cl,o=ao,a=co,c=lo;return n.innerRadius=function(t){return arguments.length?(e=kt(t),n):e},n.outerRadius=function(t){return arguments.length?(r=kt(t),n):r},n.cornerRadius=function(t){return arguments.length?(u=kt(t),n):u},n.padRadius=function(t){return arguments.length?(i=t==Cl?Cl:kt(t),n):i},n.startAngle=function(t){return arguments.length?(o=kt(t),n):o},n.endAngle=function(t){return arguments.length?(a=kt(t),n):a},n.padAngle=function(t){return arguments.length?(c=kt(t),n):c},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-ja;return[Math.cos(t)*n,Math.sin(t)*n]},n};var Cl="auto";ta.svg.line=function(){return ho(Et)};var zl=ta.map({linear:go,"linear-closed":po,step:vo,"step-before":mo,"step-after":yo,basis:So,"basis-open":ko,"basis-closed":Eo,bundle:Ao,cardinal:bo,"cardinal-open":Mo,"cardinal-closed":xo,monotone:To});zl.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var ql=[0,2/3,1/3,0],Ll=[0,1/3,2/3,0],Tl=[0,1/6,2/3,1/6];ta.svg.line.radial=function(){var n=ho(Ro);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},mo.reverse=yo,yo.reverse=mo,ta.svg.area=function(){return Do(Et)},ta.svg.area.radial=function(){var n=Do(Ro);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ta.svg.chord=function(){function n(n,a){var c=t(this,i,n,a),l=t(this,o,n,a);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?u(c.r,c.p1,c.r,c.p0):u(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+u(l.r,l.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=c.call(n,u,r)-ja,s=l.call(n,u,r)-ja;return{r:i,a0:o,a1:s,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(s),i*Math.sin(s)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Da)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=mr,o=yr,a=Po,c=ao,l=co;return n.radius=function(t){return arguments.length?(a=kt(t),n):a},n.source=function(t){return arguments.length?(i=kt(t),n):i},n.target=function(t){return arguments.length?(o=kt(t),n):o},n.startAngle=function(t){return arguments.length?(c=kt(t),n):c},n.endAngle=function(t){return arguments.length?(l=kt(t),n):l},n},ta.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,c=[i,{x:i.x,y:a},{x:o.x,y:a},o];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=mr,e=yr,r=Uo;return n.source=function(e){return arguments.length?(t=kt(e),n):t},n.target=function(t){return arguments.length?(e=kt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ta.svg.diagonal.radial=function(){var n=ta.svg.diagonal(),t=Uo,e=n.projection;return n.projection=function(n){return arguments.length?e(jo(t=n)):t},n},ta.svg.symbol=function(){function n(n,r){return(Rl.get(t.call(this,n,r))||Oo)(e.call(this,n,r))}var t=Ho,e=Fo;return n.type=function(e){return arguments.length?(t=kt(e),n):t},n.size=function(t){return arguments.length?(e=kt(t),n):e},n};var Rl=ta.map({circle:Oo,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Pl)),e=t*Pl;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/Dl),e=t*Dl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/Dl),e=t*Dl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ta.svg.symbolTypes=Rl.keys();var Dl=Math.sqrt(3),Pl=Math.tan(30*Fa);ka.transition=function(n){for(var t,e,r=Ul||++Ol,u=Xo(n),i=[],o=jl||{time:Date.now(),ease:Su,delay:0,duration:250},a=-1,c=this.length;++ai;i++){u.push(t=[]);for(var e=this[i],a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return Io(u,this.namespace,this.id)},Hl.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):H(this,null==t?function(t){t[r][e].tween.remove(n)}:function(u){u[r][e].tween.set(n,t)})},Hl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Hu:mu,a=ta.ns.qualify(n);return Zo(this,"attr."+n,t,a.local?i:u)},Hl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=ta.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Hl.style=function(n,t,e){function r(){this.style.removeProperty(n)}function u(t){return null==t?r:(t+="",function(){var r,u=oa.getComputedStyle(this,null).getPropertyValue(n);return u!==t&&(r=mu(u,t),function(t){this.style.setProperty(n,r(t),e)})})}var i=arguments.length;if(3>i){if("string"!=typeof n){2>i&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}return Zo(this,"style."+n,t,u)},Hl.styleTween=function(n,t,e){function r(r,u){var i=t.call(this,r,u,oa.getComputedStyle(this,null).getPropertyValue(n));return i&&function(t){this.style.setProperty(n,i(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},Hl.text=function(n){return Zo(this,"text",n,Vo)},Hl.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Hl.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ta.ease.apply(ta,arguments)),H(this,function(r){r[e][t].ease=n}))},Hl.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:H(this,"function"==typeof n?function(r,u,i){r[e][t].delay=+n.call(r,r.__data__,u,i)}:(n=+n,function(r){r[e][t].delay=n}))},Hl.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:H(this,"function"==typeof n?function(r,u,i){r[e][t].duration=Math.max(1,n.call(r,r.__data__,u,i))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Hl.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var u=jl,i=Ul;try{Ul=e,H(this,function(t,u,i){jl=t[r][e],n.call(t,t.__data__,u,i)})}finally{jl=u,Ul=i}}else H(this,function(u){var i=u[r][e];(i.event||(i.event=ta.dispatch("start","end","interrupt"))).on(n,t)});return this},Hl.transition=function(){for(var n,t,e,r,u=this.id,i=++Ol,o=this.namespace,a=[],c=0,l=this.length;l>c;c++){a.push(n=[]);for(var t=this[c],s=0,f=t.length;f>s;s++)(e=t[s])&&(r=e[o][u],$o(e,s,o,i,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Io(a,o,i)},ta.svg.axis=function(){function n(n){n.each(function(){var n,l=ta.select(this),s=this.__chart__||e,f=this.__chart__=e.copy(),h=null==c?f.ticks?f.ticks.apply(f,a):f.domain():c,g=null==t?f.tickFormat?f.tickFormat.apply(f,a):Et:t,p=l.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Ta),d=ta.transition(p.exit()).style("opacity",Ta).remove(),m=ta.transition(p.order()).style("opacity",1),y=Math.max(u,0)+o,M=Ui(f),x=l.selectAll(".domain").data([0]),b=(x.enter().append("path").attr("class","domain"),ta.transition(x));v.append("line"),v.append("text");var _,w,S,k,E=v.select("line"),A=m.select("line"),N=p.select("text").text(g),C=v.select("text"),z=m.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Bo,_="x",S="y",w="x2",k="y2",N.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),b.attr("d","M"+M[0]+","+q*i+"V0H"+M[1]+"V"+q*i)):(n=Wo,_="y",S="x",w="y2",k="x2",N.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),b.attr("d","M"+q*i+","+M[0]+"H0V"+M[1]+"H"+q*i)),E.attr(k,q*u),C.attr(S,q*y),A.attr(w,0).attr(k,q*u),z.attr(_,0).attr(S,q*y),f.rangeBand){var L=f,T=L.rangeBand()/2;s=f=function(n){return L(n)+T}}else s.rangeBand?s=f:d.call(n,f,s);v.call(n,s,f),m.call(n,f,f)})}var t,e=ta.scale.linear(),r=Yl,u=6,i=6,o=3,a=[10],c=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Il?t+"":Yl,n):r},n.ticks=function(){return arguments.length?(a=arguments,n):a},n.tickValues=function(t){return arguments.length?(c=t,n):c},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Yl="bottom",Il={top:1,right:1,bottom:1,left:1};ta.svg.brush=function(){function n(i){i.each(function(){var i=ta.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=i.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),i.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=i.selectAll(".resize").data(p,Et);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return Zl[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var s,f=ta.transition(i),h=ta.transition(o);c&&(s=Ui(c),h.attr("x",s[0]).attr("width",s[1]-s[0]),e(f)),l&&(s=Ui(l),h.attr("y",s[0]).attr("height",s[1]-s[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+f[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function r(n){n.select(".extent").attr("y",f[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1]-f[0])}function u(){function u(){32==ta.event.keyCode&&(N||(y=null,z[0]-=s[1],z[1]-=f[1],N=2),b())}function p(){32==ta.event.keyCode&&2==N&&(z[0]+=s[1],z[1]+=f[1],N=0,b())}function v(){var n=ta.mouse(x),u=!1;M&&(n[0]+=M[0],n[1]+=M[1]),N||(ta.event.altKey?(y||(y=[(s[0]+s[1])/2,(f[0]+f[1])/2]),z[0]=s[+(n[0]p?(u=r,r=p):u=p),v[0]!=r||v[1]!=u?(e?o=null:i=null,v[0]=r,v[1]=u,!0):void 0}function m(){v(),S.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ta.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),C(),w({type:"brushend"})}var y,M,x=this,_=ta.select(ta.event.target),w=a.of(x,arguments),S=ta.select(x),k=_.datum(),E=!/^(n|s)$/.test(k)&&c,A=!/^(e|w)$/.test(k)&&l,N=_.classed("extent"),C=X(),z=ta.mouse(x),q=ta.select(oa).on("keydown.brush",u).on("keyup.brush",p);if(ta.event.changedTouches?q.on("touchmove.brush",v).on("touchend.brush",m):q.on("mousemove.brush",v).on("mouseup.brush",m),S.interrupt().selectAll("*").interrupt(),N)z[0]=s[0]-z[0],z[1]=f[0]-z[1];else if(k){var L=+/w$/.test(k),T=+/^n/.test(k);M=[s[1-L]-z[0],f[1-T]-z[1]],z[0]=s[L],z[1]=f[T]}else ta.event.altKey&&(y=z.slice());S.style("pointer-events","none").selectAll(".resize").style("display",null),ta.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),v()}var i,o,a=w(n,"brushstart","brush","brushend"),c=null,l=null,s=[0,0],f=[0,0],h=!0,g=!0,p=Vl[0];return n.event=function(n){n.each(function(){var n=a.of(this,arguments),t={x:s,y:f,i:i,j:o},e=this.__chart__||t;this.__chart__=t,Ul?ta.select(this).transition().each("start.brush",function(){i=e.i,o=e.j,s=e.x,f=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=yu(s,t.x),r=yu(f,t.y);return i=o=null,function(u){s=t.x=e(u),f=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=t.i,o=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,p=Vl[!c<<1|!l],n):c},n.y=function(t){return arguments.length?(l=t,p=Vl[!c<<1|!l],n):l},n.clamp=function(t){return arguments.length?(c&&l?(h=!!t[0],g=!!t[1]):c?h=!!t:l&&(g=!!t),n):c&&l?[h,g]:c?h:l?g:null},n.extent=function(t){var e,r,u,a,h;return arguments.length?(c&&(e=t[0],r=t[1],l&&(e=e[0],r=r[0]),i=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(h=e,e=r,r=h),(e!=s[0]||r!=s[1])&&(s=[e,r])),l&&(u=t[0],a=t[1],c&&(u=u[1],a=a[1]),o=[u,a],l.invert&&(u=l(u),a=l(a)),u>a&&(h=u,u=a,a=h),(u!=f[0]||a!=f[1])&&(f=[u,a])),n):(c&&(i?(e=i[0],r=i[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(h=e,e=r,r=h))),l&&(o?(u=o[0],a=o[1]):(u=f[0],a=f[1],l.invert&&(u=l.invert(u),a=l.invert(a)),u>a&&(h=u,u=a,a=h))),c&&l?[[e,u],[r,a]]:c?[e,r]:l&&[u,a])},n.clear=function(){return n.empty()||(s=[0,0],f=[0,0],i=o=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!l&&f[0]==f[1]},ta.rebind(n,a,"on")};var Zl={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Vl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Xl=fc.format=mc.timeFormat,$l=Xl.utc,Bl=$l("%Y-%m-%dT%H:%M:%S.%LZ");Xl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Jo:Bl,Jo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Jo.toString=Bl.toString,fc.second=Ft(function(n){return new hc(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),fc.seconds=fc.second.range,fc.seconds.utc=fc.second.utc.range,fc.minute=Ft(function(n){return new hc(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),fc.minutes=fc.minute.range,fc.minutes.utc=fc.minute.utc.range,fc.hour=Ft(function(n){var t=n.getTimezoneOffset()/60;return new hc(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),fc.hours=fc.hour.range,fc.hours.utc=fc.hour.utc.range,fc.month=Ft(function(n){return n=fc.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),fc.months=fc.month.range,fc.months.utc=fc.month.utc.range;var Wl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Jl=[[fc.second,1],[fc.second,5],[fc.second,15],[fc.second,30],[fc.minute,1],[fc.minute,5],[fc.minute,15],[fc.minute,30],[fc.hour,1],[fc.hour,3],[fc.hour,6],[fc.hour,12],[fc.day,1],[fc.day,2],[fc.week,1],[fc.month,1],[fc.month,3],[fc.year,1]],Gl=Xl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Ne]]),Kl={range:function(n,t,e){return ta.range(Math.ceil(n/e)*e,+t,e).map(Ko)},floor:Et,ceil:Et};Jl.year=fc.year,fc.scale=function(){return Go(ta.scale.linear(),Jl,Gl)};var Ql=Jl.map(function(n){return[n[0].utc,n[1]]}),ns=$l.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Ne]]);Ql.year=fc.year.utc,fc.scale.utc=function(){return Go(ta.scale.linear(),Ql,ns)},ta.text=At(function(n){return n.responseText}),ta.json=function(n,t){return Nt(n,"application/json",Qo,t)},ta.html=function(n,t){return Nt(n,"text/html",na,t)},ta.xml=At(function(n){return n.responseXML}),"function"==typeof define&&define.amd?define(ta):"object"==typeof module&&module.exports&&(module.exports=ta),this.d3=ta}(); \ No newline at end of file +d3=function(){function n(n){return null!=n&&!isNaN(n)}function t(n){return n.length}function e(n){for(var t=1;n*t%1;)t*=10;return t}function r(n,t){try{for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}catch(r){n.prototype=t}}function u(){}function i(){}function o(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function a(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.substring(1);for(var e=0,r=fa.length;r>e;++e){var u=fa[e]+t;if(u in n)return u}}function c(){}function s(){}function l(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function L(n){return ga(n,Ma),n}function T(n){var t,e;return function(r,u,i){var o,a=n[i].update,c=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.substring(0,a));var l=ba.get(n);return l&&(n=l,s=D),a?t?u:r:t?c:i}function R(n,t){return function(e){var r=Bo.event;Bo.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{Bo.event=r}}}function D(n,t){var e=R(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function P(){var n=".dragsuppress-"+ ++Sa,t="click"+n,e=Bo.select(Qo).on("touchmove"+n,f).on("dragstart"+n,f).on("selectstart"+n,f);if(wa){var r=Ko.style,u=r[wa];r[wa]="none"}return function(i){function o(){e.on(t,null)}e.on(n,null),wa&&(r[wa]=u),i&&(e.on(t,function(){f(),o()},!0),setTimeout(o,0))}}function U(n,t){t.changedTouches&&(t=t.changedTouches[0]);var e=n.ownerSVGElement||n;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>ka&&(Qo.scrollX||Qo.scrollY)){e=Bo.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var u=e[0][0].getScreenCTM();ka=!(u.f||u.e),e.remove()}return ka?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}var i=n.getBoundingClientRect();return[t.clientX-i.left-n.clientLeft,t.clientY-i.top-n.clientTop]}function j(n){return n>0?1:0>n?-1:0}function H(n){return n>1?0:-1>n?Ea:Math.acos(n)}function F(n){return n>1?Ca:-1>n?-Ca:Math.asin(n)}function O(n){return((n=Math.exp(n))-1/n)/2}function Y(n){return((n=Math.exp(n))+1/n)/2}function I(n){return((n=Math.exp(2*n))-1)/(n+1)}function Z(n){return(n=Math.sin(n/2))*n}function V(){}function X(n,t,e){return new $(n,t,e)}function $(n,t,e){this.h=n,this.s=t,this.l=e}function B(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,at(u(n+120),u(n),u(n-120))}function W(n,t,e){return new J(n,t,e)}function J(n,t,e){this.h=n,this.c=t,this.l=e}function G(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),K(e,Math.cos(n*=Ta)*t,Math.sin(n)*t)}function K(n,t,e){return new Q(n,t,e)}function Q(n,t,e){this.l=n,this.a=t,this.b=e}function nt(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=et(u)*Ya,r=et(r)*Ia,i=et(i)*Za,at(ut(3.2404542*u-1.5371385*r-.4985314*i),ut(-.969266*u+1.8760108*r+.041556*i),ut(.0556434*u-.2040259*r+1.0572252*i))}function tt(n,t,e){return n>0?W(Math.atan2(e,t)*qa,Math.sqrt(t*t+e*e),n):W(0/0,0/0,n)}function et(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function rt(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function ut(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function it(n){return at(n>>16,255&n>>8,255&n)}function ot(n){return it(n)+""}function at(n,t,e){return new ct(n,t,e)}function ct(n,t,e){this.r=n,this.g=t,this.b=e}function st(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function lt(n,t,e){var r,u,i,o=0,a=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(n))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(pt(u[0]),pt(u[1]),pt(u[2]))}return(i=$a.get(n))?t(i.r,i.g,i.b):(null!=n&&"#"===n.charAt(0)&&(4===n.length?(o=n.charAt(1),o+=o,a=n.charAt(2),a+=a,c=n.charAt(3),c+=c):7===n.length&&(o=n.substring(1,3),a=n.substring(3,5),c=n.substring(5,7)),o=parseInt(o,16),a=parseInt(a,16),c=parseInt(c,16)),t(o,a,c))}function ft(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,c=(o+i)/2;return a?(u=.5>c?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=0/0,u=c>0&&1>c?0:r),X(r,u,c)}function ht(n,t,e){n=gt(n),t=gt(t),e=gt(e);var r=rt((.4124564*n+.3575761*t+.1804375*e)/Ya),u=rt((.2126729*n+.7151522*t+.072175*e)/Ia),i=rt((.0193339*n+.119192*t+.9503041*e)/Za);return K(116*u-16,500*(r-u),200*(u-i))}function gt(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function pt(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function vt(n){return"function"==typeof n?n:function(){return n}}function dt(n){return n}function mt(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),yt(t,e,n,r)}}function yt(n,t,e,r){function u(){var n,t=c.status;if(!t&&c.responseText||t>=200&&300>t||304===t){try{n=e.call(i,c)}catch(r){return o.error.call(i,r),void 0}o.load.call(i,n)}else o.error.call(i,c)}var i={},o=Bo.dispatch("beforesend","progress","load","error"),a={},c=new XMLHttpRequest,s=null;return!Qo.XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(n)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=u:c.onreadystatechange=function(){c.readyState>3&&u()},c.onprogress=function(n){var t=Bo.event;Bo.event=n;try{o.progress.call(i,c)}finally{Bo.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(s=n,i):s},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(Jo(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),c.setRequestHeader)for(var l in a)c.setRequestHeader(l,a[l]);return null!=t&&c.overrideMimeType&&c.overrideMimeType(t),null!=s&&(c.responseType=s),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,c),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},Bo.rebind(i,o,"on"),null==r?i:i.get(xt(r))}function xt(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function Mt(){var n=_t(),t=bt()-n;t>24?(isFinite(t)&&(clearTimeout(Ga),Ga=setTimeout(Mt,t)),Ja=0):(Ja=1,Qa(Mt))}function _t(){var n=Date.now();for(Ka=Ba;Ka;)n>=Ka.t&&(Ka.f=Ka.c(n-Ka.t)),Ka=Ka.n;return n}function bt(){for(var n,t=Ba,e=1/0;t;)t.f?t=n?n.n=t.n:Ba=t.n:(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function St(n,t){return t-(n?Math.ceil(Math.log(n)/Math.LN10):1)}function kt(n){return n+""}function Et(){}function At(n,t,e){var r=e.s=n+t,u=r-n,i=r-u;e.t=n-i+(t-u)}function Ct(n,t){n&&fc.hasOwnProperty(n.type)&&fc[n.type](n,t)}function Nt(n,t,e){var r,u=-1,i=n.length-e;for(t.lineStart();++ua;++a)u.point((e=n[a])[0],e[1]);return u.lineEnd(),void 0}var c=new Bt(e,n,null,!0),s=new Bt(e,null,c,!1);c.o=s,i.push(c),o.push(s),c=new Bt(r,n,null,!1),s=new Bt(r,null,c,!0),c.o=s,i.push(c),o.push(s)}}),o.sort(t),$t(i),$t(o),i.length){for(var a=0,c=e,s=o.length;s>a;++a)o[a].e=c=!c;for(var l,f,h=i[0];;){for(var g=h,p=!0;g.v;)if((g=g.n)===h)return;l=g.z,u.lineStart();do{if(g.v=g.o.v=!0,g.e){if(p)for(var a=0,s=l.length;s>a;++a)u.point((f=l[a])[0],f[1]);else r(g.x,g.n.x,1,u);g=g.n}else{if(p){l=g.p.z;for(var a=l.length-1;a>=0;--a)u.point((f=l[a])[0],f[1])}else r(g.x,g.p.x,-1,u);g=g.p}g=g.o,l=g.z,p=!p}while(!g.v);u.lineEnd()}}}function $t(n){if(t=n.length){for(var t,e,r=0,u=n[0];++r1&&2&t&&e.push(e.pop().concat(e.shift())),g.push(e.filter(Jt))}}var g,p,v,d=t(i),m=u.invert(r[0],r[1]),y={point:o,lineStart:c,lineEnd:s,polygonStart:function(){y.point=l,y.lineStart=f,y.lineEnd=h,g=[],p=[],i.polygonStart()},polygonEnd:function(){y.point=o,y.lineStart=c,y.lineEnd=s,g=Bo.merge(g);var n=Qt(m,p);g.length?Xt(g,Kt,n,e,i):n&&(i.lineStart(),e(null,null,1,i),i.lineEnd()),i.polygonEnd(),g=p=null},sphere:function(){i.polygonStart(),i.lineStart(),e(null,null,1,i),i.lineEnd(),i.polygonEnd()}},x=Gt(),M=t(x);return y}}function Jt(n){return n.length>1}function Gt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:c,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Kt(n,t){return((n=n.x)[0]<0?n[1]-Ca-Na:Ca-n[1])-((t=t.x)[0]<0?t[1]-Ca-Na:Ca-t[1])}function Qt(n,t){var e=n[0],r=n[1],u=[Math.sin(e),-Math.cos(e),0],i=0,o=0;gc.reset();for(var a=0,c=t.length;c>a;++a){var s=t[a],l=s.length;if(l)for(var f=s[0],h=f[0],g=f[1]/2+Ea/4,p=Math.sin(g),v=Math.cos(g),d=1;;){d===l&&(d=0),n=s[d];var m=n[0],y=n[1]/2+Ea/4,x=Math.sin(y),M=Math.cos(y),_=m-h,b=ca(_)>Ea,w=p*x;if(gc.add(Math.atan2(w*Math.sin(_),v*M+w*Math.cos(_))),i+=b?_+(_>=0?Aa:-Aa):_,b^h>=e^m>=e){var S=Rt(qt(f),qt(n));Ut(S);var k=Rt(u,S);Ut(k);var E=(b^_>=0?-1:1)*F(k[2]);(r>E||r===E&&(S[0]||S[1]))&&(o+=b^_>=0?1:-1)}if(!d++)break;h=m,p=x,v=M,f=n}}return(-Na>i||Na>i&&0>gc)^1&o}function ne(n){var t,e=0/0,r=0/0,u=0/0;return{lineStart:function(){n.lineStart(),t=1},point:function(i,o){var a=i>0?Ea:-Ea,c=ca(i-e);ca(c-Ea)0?Ca:-Ca),n.point(u,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(i,r),t=0):u!==a&&c>=Ea&&(ca(e-u)Na?Math.atan((Math.sin(t)*(i=Math.cos(r))*Math.sin(e)-Math.sin(r)*(u=Math.cos(t))*Math.sin(n))/(u*i*o)):(t+r)/2}function ee(n,t,e,r){var u;if(null==n)u=e*Ca,r.point(-Ea,u),r.point(0,u),r.point(Ea,u),r.point(Ea,0),r.point(Ea,-u),r.point(0,-u),r.point(-Ea,-u),r.point(-Ea,0),r.point(-Ea,u);else if(ca(n[0]-t[0])>Na){var i=n[0]i}function e(n){var e,i,c,s,l;return{lineStart:function(){s=c=!1,l=1},point:function(f,h){var g,p=[f,h],v=t(f,h),d=o?v?0:u(f,h):v?u(f+(0>f?Ea:-Ea),h):0;if(!e&&(s=c=v)&&n.lineStart(),v!==c&&(g=r(e,p),(Ht(e,g)||Ht(p,g))&&(p[0]+=Na,p[1]+=Na,v=t(p[0],p[1]))),v!==c)l=0,v?(n.lineStart(),g=r(p,e),n.point(g[0],g[1])):(g=r(e,p),n.point(g[0],g[1]),n.lineEnd()),e=g;else if(a&&e&&o^v){var m;d&i||!(m=r(p,e,!0))||(l=0,o?(n.lineStart(),n.point(m[0][0],m[0][1]),n.point(m[1][0],m[1][1]),n.lineEnd()):(n.point(m[1][0],m[1][1]),n.lineEnd(),n.lineStart(),n.point(m[0][0],m[0][1])))}!v||e&&Ht(e,p)||n.point(p[0],p[1]),e=p,c=v,i=d},lineEnd:function(){c&&n.lineEnd(),e=null},clean:function(){return l|(s&&c)<<1}}}function r(n,t,e){var r=qt(n),u=qt(t),o=[1,0,0],a=Rt(r,u),c=zt(a,a),s=a[0],l=c-s*s;if(!l)return!e&&n;var f=i*c/l,h=-i*s/l,g=Rt(o,a),p=Pt(o,f),v=Pt(a,h);Dt(p,v);var d=g,m=zt(p,d),y=zt(d,d),x=m*m-y*(zt(p,p)-1);if(!(0>x)){var M=Math.sqrt(x),_=Pt(d,(-m-M)/y);if(Dt(_,p),_=jt(_),!e)return _;var b,w=n[0],S=t[0],k=n[1],E=t[1];w>S&&(b=w,w=S,S=b);var A=S-w,C=ca(A-Ea)A;if(!C&&k>E&&(b=k,k=E,E=b),N?C?k+E>0^_[1]<(ca(_[0]-w)Ea^(w<=_[0]&&_[0]<=S)){var L=Pt(d,(-m+M)/y);return Dt(L,p),[_,jt(L)]}}}function u(t,e){var r=o?n:Ea-n,u=0;return-r>t?u|=1:t>r&&(u|=2),-r>e?u|=4:e>r&&(u|=8),u}var i=Math.cos(n),o=i>0,a=ca(i)>Na,c=Te(n,6*Ta);return Wt(t,e,c,o?[0,-n]:[-Ea,n-Ea])}function ue(n,t,e,r){return function(u){var i,o=u.a,a=u.b,c=o.x,s=o.y,l=a.x,f=a.y,h=0,g=1,p=l-c,v=f-s;if(i=n-c,p||!(i>0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-c,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-s,v||!(i>0)){if(i/=v,0>v){if(h>i)return;g>i&&(g=i)}else if(v>0){if(i>g)return;i>h&&(h=i)}if(i=r-s,v||!(0>i)){if(i/=v,0>v){if(i>g)return;i>h&&(h=i)}else if(v>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:c+h*p,y:s+h*v}),1>g&&(u.b={x:c+g*p,y:s+g*v}),u}}}}}}function ie(n,t,e,r){function u(r,u){return ca(r[0]-n)0?0:3:ca(r[0]-e)0?2:1:ca(r[1]-t)0?1:0:u>0?3:2}function i(n,t){return o(n.x,t.x)}function o(n,t){var e=u(n,1),r=u(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function c(n){for(var t=0,e=m.length,r=n[1],u=0;e>u;++u)for(var i,o=1,a=m[u],c=a.length,l=a[0];c>o;++o)i=a[o],l[1]<=r?i[1]>r&&s(l,i,n)>0&&++t:i[1]<=r&&s(l,i,n)<0&&--t,l=i;return 0!==t}function s(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(e[0]-n[0])*(t[1]-n[1])}function l(i,a,c,s){var l=0,f=0;if(null==i||(l=u(i,c))!==(f=u(a,c))||o(i,a)<0^c>0){do s.point(0===l||3===l?n:e,l>1?r:t);while((l=(l+c+4)%4)!==f)}else s.point(a[0],a[1])}function f(u,i){return u>=n&&e>=u&&i>=t&&r>=i}function h(n,t){f(n,t)&&a.point(n,t)}function g(){L.point=v,m&&m.push(y=[]),k=!0,S=!1,b=w=0/0}function p(){d&&(v(x,M),_&&S&&C.rejoin(),d.push(C.buffer())),L.point=h,S&&a.lineEnd()}function v(n,t){n=Math.max(-Cc,Math.min(Cc,n)),t=Math.max(-Cc,Math.min(Cc,t));var e=f(n,t);if(m&&y.push([n,t]),k)x=n,M=t,_=e,k=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&S)a.point(n,t);else{var r={a:{x:b,y:w},b:{x:n,y:t}};N(r)?(S||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),E=!1):e&&(a.lineStart(),a.point(n,t),E=!1)}b=n,w=t,S=e}var d,m,y,x,M,_,b,w,S,k,E,A=a,C=Gt(),N=ue(n,t,e,r),L={point:h,lineStart:g,lineEnd:p,polygonStart:function(){a=C,d=[],m=[],E=!0},polygonEnd:function(){a=A,d=Bo.merge(d);var t=c([n,r]),e=E&&t,u=d.length;(e||u)&&(a.polygonStart(),e&&(a.lineStart(),l(null,null,1,a),a.lineEnd()),u&&Xt(d,i,t,l,a),a.polygonEnd()),d=m=y=null}};return L}}function oe(n,t){function e(e,r){return e=n(e,r),t(e[0],e[1])}return n.invert&&t.invert&&(e.invert=function(e,r){return e=t.invert(e,r),e&&n.invert(e[0],e[1])}),e}function ae(n){var t=0,e=Ea/3,r=we(n),u=r(t,e);return u.parallels=function(n){return arguments.length?r(t=n[0]*Ea/180,e=n[1]*Ea/180):[180*(t/Ea),180*(e/Ea)]},u}function ce(n,t){function e(n,t){var e=Math.sqrt(i-2*u*Math.sin(t))/u;return[e*Math.sin(n*=u),o-e*Math.cos(n)]}var r=Math.sin(n),u=(r+Math.sin(t))/2,i=1+r*(2*u-r),o=Math.sqrt(i)/u;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/u,F((i-(n*n+e*e)*u*u)/(2*u))]},e}function se(){function n(n,t){Lc+=u*n-r*t,r=n,u=t}var t,e,r,u;Dc.point=function(i,o){Dc.point=n,t=r=i,e=u=o},Dc.lineEnd=function(){n(t,e)}}function le(n,t){Tc>n&&(Tc=n),n>zc&&(zc=n),qc>t&&(qc=t),t>Rc&&(Rc=t)}function fe(){function n(n,t){o.push("M",n,",",t,i)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function u(){o.push("Z")}var i=he(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return i=he(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function he(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function ge(n,t){mc+=n,yc+=t,++xc}function pe(){function n(n,r){var u=n-t,i=r-e,o=Math.sqrt(u*u+i*i);Mc+=o*(t+n)/2,_c+=o*(e+r)/2,bc+=o,ge(t=n,e=r)}var t,e;Uc.point=function(r,u){Uc.point=n,ge(t=r,e=u)}}function ve(){Uc.point=ge}function de(){function n(n,t){var e=n-r,i=t-u,o=Math.sqrt(e*e+i*i);Mc+=o*(r+n)/2,_c+=o*(u+t)/2,bc+=o,o=u*n-r*t,wc+=o*(r+n),Sc+=o*(u+t),kc+=3*o,ge(r=n,u=t)}var t,e,r,u;Uc.point=function(i,o){Uc.point=n,ge(t=r=i,e=u=o)},Uc.lineEnd=function(){n(t,e)}}function me(n){function t(t,e){n.moveTo(t,e),n.arc(t,e,o,0,Aa)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function u(){a.point=t}function i(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:u,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=u,a.point=t},pointRadius:function(n){return o=n,a},result:c};return a}function ye(n){function t(n){return(a?r:e)(n)}function e(t){return _e(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){x=0/0,S.point=i,t.lineStart()}function i(e,r){var i=qt([e,r]),o=n(e,r);u(x,M,y,_,b,w,x=o[0],M=o[1],y=e,_=i[0],b=i[1],w=i[2],a,t),t.point(x,M)}function o(){S.point=e,t.lineEnd()}function c(){r(),S.point=s,S.lineEnd=l}function s(n,t){i(f=n,h=t),g=x,p=M,v=_,d=b,m=w,S.point=i}function l(){u(x,M,y,_,b,w,g,p,f,v,d,m,a,t),S.lineEnd=o,o()}var f,h,g,p,v,d,m,y,x,M,_,b,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=c},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function u(t,e,r,a,c,s,l,f,h,g,p,v,d,m){var y=l-t,x=f-e,M=y*y+x*x;if(M>4*i&&d--){var _=a+g,b=c+p,w=s+v,S=Math.sqrt(_*_+b*b+w*w),k=Math.asin(w/=S),E=ca(ca(w)-1)i||ca((y*L+x*T)/M-.5)>.3||o>a*g+c*p+s*v)&&(u(t,e,r,a,c,s,C,N,E,_/=S,b/=S,w,d,m),m.point(C,N),u(C,N,E,_,b,w,l,f,h,g,p,v,d,m))}}var i=.5,o=Math.cos(30*Ta),a=16;return t.precision=function(n){return arguments.length?(a=(i=n*n)>0&&16,t):Math.sqrt(i)},t}function xe(n){var t=ye(function(t,e){return n([t*qa,e*qa])});return function(n){return Se(t(n))}}function Me(n){this.stream=n}function _e(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function be(n){return we(function(){return n})()}function we(n){function t(n){return n=a(n[0]*Ta,n[1]*Ta),[n[0]*h+c,s-n[1]*h]}function e(n){return n=a.invert((n[0]-c)/h,(s-n[1])/h),n&&[n[0]*qa,n[1]*qa]}function r(){a=oe(o=Ae(m,y,x),i);var n=i(v,d);return c=g-n[0]*h,s=p+n[1]*h,u()}function u(){return l&&(l.valid=!1,l=null),t}var i,o,a,c,s,l,f=ye(function(n,t){return n=i(n,t),[n[0]*h+c,s-n[1]*h]}),h=150,g=480,p=250,v=0,d=0,m=0,y=0,x=0,M=Ac,_=dt,b=null,w=null;return t.stream=function(n){return l&&(l.valid=!1),l=Se(M(o,f(_(n)))),l.valid=!0,l},t.clipAngle=function(n){return arguments.length?(M=null==n?(b=n,Ac):re((b=+n)*Ta),u()):b},t.clipExtent=function(n){return arguments.length?(w=n,_=n?ie(n[0][0],n[0][1],n[1][0],n[1][1]):dt,u()):w},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(g=+n[0],p=+n[1],r()):[g,p]},t.center=function(n){return arguments.length?(v=n[0]%360*Ta,d=n[1]%360*Ta,r()):[v*qa,d*qa]},t.rotate=function(n){return arguments.length?(m=n[0]%360*Ta,y=n[1]%360*Ta,x=n.length>2?n[2]%360*Ta:0,r()):[m*qa,y*qa,x*qa]},Bo.rebind(t,f,"precision"),function(){return i=n.apply(this,arguments),t.invert=i.invert&&e,r()}}function Se(n){return _e(n,function(t,e){n.point(t*Ta,e*Ta)})}function ke(n,t){return[n,t]}function Ee(n,t){return[n>Ea?n-Aa:-Ea>n?n+Aa:n,t]}function Ae(n,t,e){return n?t||e?oe(Ne(n),Le(t,e)):Ne(n):t||e?Le(t,e):Ee}function Ce(n){return function(t,e){return t+=n,[t>Ea?t-Aa:-Ea>t?t+Aa:t,e]}}function Ne(n){var t=Ce(n);return t.invert=Ce(-n),t}function Le(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,s=Math.sin(t),l=s*r+a*u;return[Math.atan2(c*i-l*o,a*r-s*u),F(l*i+c*o)]}var r=Math.cos(n),u=Math.sin(n),i=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,c=Math.sin(n)*e,s=Math.sin(t),l=s*i-c*o;return[Math.atan2(c*i+s*o,a*r+l*u),F(l*r-a*u)]},e}function Te(n,t){var e=Math.cos(n),r=Math.sin(n);return function(u,i,o,a){var c=o*t;null!=u?(u=qe(e,u),i=qe(e,i),(o>0?i>u:u>i)&&(u+=o*Aa)):(u=n+o*Aa,i=n-.5*c);for(var s,l=u;o>0?l>i:i>l;l-=c)a.point((s=jt([e,-r*Math.cos(l),-r*Math.sin(l)]))[0],s[1])}}function qe(n,t){var e=qt(t);e[0]-=n,Ut(e);var r=H(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Na)%(2*Math.PI)}function ze(n,t,e){var r=Bo.range(n,t-Na,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function Re(n,t,e){var r=Bo.range(n,t-Na,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function De(n){return n.source}function Pe(n){return n.target}function Ue(n,t,e,r){var u=Math.cos(t),i=Math.sin(t),o=Math.cos(r),a=Math.sin(r),c=u*Math.cos(n),s=u*Math.sin(n),l=o*Math.cos(e),f=o*Math.sin(e),h=2*Math.asin(Math.sqrt(Z(r-t)+u*o*Z(e-n))),g=1/Math.sin(h),p=h?function(n){var t=Math.sin(n*=h)*g,e=Math.sin(h-n)*g,r=e*c+t*l,u=e*s+t*f,o=e*i+t*a;return[Math.atan2(u,r)*qa,Math.atan2(o,Math.sqrt(r*r+u*u))*qa]}:function(){return[n*qa,t*qa]};return p.distance=h,p}function je(){function n(n,u){var i=Math.sin(u*=Ta),o=Math.cos(u),a=ca((n*=Ta)-t),c=Math.cos(a);jc+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*i-e*o*c)*a),e*i+r*o*c),t=n,e=i,r=o}var t,e,r;Hc.point=function(u,i){t=u*Ta,e=Math.sin(i*=Ta),r=Math.cos(i),Hc.point=n},Hc.lineEnd=function(){Hc.point=Hc.lineEnd=c}}function He(n,t){function e(t,e){var r=Math.cos(t),u=Math.cos(e),i=n(r*u);return[i*u*Math.sin(t),i*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),u=t(r),i=Math.sin(u),o=Math.cos(u);return[Math.atan2(n*i,r*o),Math.asin(r&&e*i/r)]},e}function Fe(n,t){function e(n,t){var e=ca(ca(t)-Ca)0}function Be(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function We(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,c=n[1],s=e[1],l=t[1]-c,f=r[1]-s,h=(a*(c-s)-f*(u-i))/(f*o-a*l);return[u+h*o,c+h*l]}function Je(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Ge(){yr(this),this.edge=this.site=this.circle=null}function Ke(n){var t=Gc.pop()||new Ge;return t.site=n,t}function Qe(n){sr(n),Bc.remove(n),Gc.push(n),yr(n)}function nr(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];Qe(n);for(var c=i;c.circle&&ca(e-c.circle.x)l;++l)s=a[l],c=a[l-1],vr(s.edge,c.site,s.site,u);c=a[0],s=a[f-1],s.edge=gr(c.site,s.site,null,u),cr(c),cr(s)}function tr(n){for(var t,e,r,u,i=n.x,o=n.y,a=Bc._;a;)if(r=er(a,o)-i,r>Na)a=a.L;else{if(u=i-rr(a,o),!(u>Na)){r>-Na?(t=a.P,e=a):u>-Na?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var c=Ke(n);if(Bc.insert(t,c),t||e){if(t===e)return sr(t),e=Ke(t.site),Bc.insert(c,e),c.edge=e.edge=gr(t.site,c.site),cr(t),cr(e),void 0;if(!e)return c.edge=gr(t.site,c.site),void 0;sr(t),sr(e);var s=t.site,l=s.x,f=s.y,h=n.x-l,g=n.y-f,p=e.site,v=p.x-l,d=p.y-f,m=2*(h*d-g*v),y=h*h+g*g,x=v*v+d*d,M={x:(d*y-g*x)/m+l,y:(h*x-v*y)/m+f};vr(e.edge,s,p,M),c.edge=gr(s,n,null,M),e.edge=gr(n,p,null,M),cr(t),cr(e)}}function er(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-1/0;e=o.site;var a=e.x,c=e.y,s=c-t;if(!s)return a;var l=a-r,f=1/i-1/s,h=l/s;return f?(-h+Math.sqrt(h*h-2*f*(l*l/(-2*s)-c+s/2+u-i/2)))/f+r:(r+a)/2}function rr(n,t){var e=n.N;if(e)return er(e,t);var r=n.site;return r.y===t?r.x:1/0}function ur(n){this.site=n,this.edges=[]}function ir(n){for(var t,e,r,u,i,o,a,c,s,l,f=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],v=$c,d=v.length;d--;)if(i=v[d],i&&i.prepare())for(a=i.edges,c=a.length,o=0;c>o;)l=a[o].end(),r=l.x,u=l.y,s=a[++o%c].start(),t=s.x,e=s.y,(ca(r-t)>Na||ca(u-e)>Na)&&(a.splice(o,0,new dr(pr(i.site,l,ca(r-f)Na?{x:f,y:ca(t-f)Na?{x:ca(e-p)Na?{x:h,y:ca(t-h)Na?{x:ca(e-g)=-La)){var g=c*c+s*s,p=l*l+f*f,v=(f*g-s*p)/h,d=(c*p-l*g)/h,f=d+a,m=Kc.pop()||new ar;m.arc=n,m.site=u,m.x=v+o,m.y=f+Math.sqrt(v*v+d*d),m.cy=f,n.circle=m;for(var y=null,x=Jc._;x;)if(m.yd||d>=a)return;if(h>p){if(i){if(i.y>=s)return}else i={x:d,y:c};e={x:d,y:s}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=s)return}else i={x:(c-u)/r,y:c};e={x:(s-u)/r,y:s}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xr;++r)if(o=l[r],o.x==e[0]){if(o.i)if(null==s[o.i+1])for(s[o.i-1]+=o.x,s.splice(o.i,1),u=r+1;i>u;++u)l[u].i--;else for(s[o.i-1]+=o.x+s[o.i+1],s.splice(o.i,2),u=r+1;i>u;++u)l[u].i-=2;else if(null==s[o.i+1])s[o.i]=o.x;else for(s[o.i]=o.x+s[o.i+1],s.splice(o.i+1,1),u=r+1;i>u;++u)l[u].i--;l.splice(r,1),i--,r--}else o.x=Tr(parseFloat(e[0]),parseFloat(o.x));for(;i>r;)o=l.pop(),null==s[o.i+1]?s[o.i]=o.x:(s[o.i]=o.x+s[o.i+1],s.splice(o.i+1,1)),i--;return 1===s.length?null==s[0]?(o=l[0].x,function(n){return o(n)+""}):function(){return t}:function(n){for(r=0;i>r;++r)s[(o=l[r]).i]=o.x(n);return s.join("")}}function zr(n,t){for(var e,r=Bo.interpolators.length;--r>=0&&!(e=Bo.interpolators[r](n,t)););return e}function Rr(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(zr(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function Dr(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function Pr(n){return function(t){return 1-n(1-t)}}function Ur(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function jr(n){return n*n}function Hr(n){return n*n*n}function Fr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Or(n){return function(t){return Math.pow(t,n)}}function Yr(n){return 1-Math.cos(n*Ca)}function Ir(n){return Math.pow(2,10*(n-1))}function Zr(n){return 1-Math.sqrt(1-n*n)}function Vr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Aa*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Aa/t)}}function Xr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function $r(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Br(n,t){n=Bo.hcl(n),t=Bo.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return G(e+i*n,r+o*n,u+a*n)+""}}function Wr(n,t){n=Bo.hsl(n),t=Bo.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return B(e+i*n,r+o*n,u+a*n)+""}}function Jr(n,t){n=Bo.lab(n),t=Bo.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return nt(e+i*n,r+o*n,u+a*n)+""}}function Gr(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function Kr(n){var t=[n.a,n.b],e=[n.c,n.d],r=nu(t),u=Qr(t,e),i=nu(tu(e,t,-u))||0;t[0]*e[1]180?l+=360:l-s>180&&(s+=360),u.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:Tr(s,l)})):l&&r.push(r.pop()+"rotate("+l+")"),f!=h?u.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:Tr(f,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),u.push({i:e-4,x:Tr(g[0],p[0])},{i:e-2,x:Tr(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=u.length,function(n){for(var t,i=-1;++ie;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function Su(n){return n.reduce(ku,0)}function ku(n,t){return n+t[1]}function Eu(n,t){return Au(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function Au(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function Cu(n){return[Bo.min(n),Bo.max(n)]}function Nu(n,t){return n.parent==t.parent?1:2}function Lu(n){var t=n.children;return t&&t.length?t[0]:n._tree.thread}function Tu(n){var t,e=n.children;return e&&(t=e.length)?e[t-1]:n._tree.thread}function qu(n,t){var e=n.children;if(e&&(u=e.length))for(var r,u,i=-1;++i0&&(n=r);return n}function zu(n,t){return n.x-t.x}function Ru(n,t){return t.x-n.x}function Du(n,t){return n.depth-t.depth}function Pu(n,t){function e(n,r){var u=n.children;if(u&&(o=u.length))for(var i,o,a=null,c=-1;++c=0;)t=u[i]._tree,t.prelim+=e,t.mod+=e,e+=t.shift+(r+=t.change)}function ju(n,t,e){n=n._tree,t=t._tree;var r=e/(t.number-n.number);n.change+=r,t.change-=r,t.shift+=e,t.prelim+=e,t.mod+=e}function Hu(n,t,e){return n._tree.ancestor.parent==t.parent?n._tree.ancestor:e}function Fu(n,t){return n.value-t.value}function Ou(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Yu(n,t){n._pack_next=t,t._pack_prev=n}function Iu(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function Zu(n){function t(n){l=Math.min(n.x-n.r,l),f=Math.max(n.x+n.r,f),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(s=e.length)){var e,r,u,i,o,a,c,s,l=1/0,f=-1/0,h=1/0,g=-1/0;if(e.forEach(Vu),r=e[0],r.x=-r.r,r.y=0,t(r),s>1&&(u=e[1],u.x=u.r,u.y=0,t(u),s>2))for(i=e[2],Bu(r,u,i),t(i),Ou(r,i),r._pack_prev=i,Ou(i,u),u=r._pack_next,o=3;s>o;o++){Bu(r,u,i=e[o]);var p=0,v=1,d=1;for(a=u._pack_next;a!==u;a=a._pack_next,v++)if(Iu(a,i)){p=1;break}if(1==p)for(c=r._pack_prev;c!==a._pack_prev&&!Iu(c,i);c=c._pack_prev,d++);p?(d>v||v==d&&u.ro;o++)i=e[o],i.x-=m,i.y-=y,x=Math.max(x,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=x,e.forEach(Xu)}}function Vu(n){n._pack_next=n._pack_prev=n}function Xu(n){delete n._pack_next,delete n._pack_prev}function $u(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++iu&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function ti(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function ei(n){return n.rangeExtent?n.rangeExtent():ti(n.range())}function ri(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function ui(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function ii(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:ls}function oi(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?oi:ri,c=r?uu:ru;return o=u(n,t,c,e),a=u(t,n,c,zr),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(Gr)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return fi(n,t)},i.tickFormat=function(t,e){return hi(n,t,e)},i.nice=function(t){return si(n,t),u()},i.copy=function(){return ai(n,t,e,r)},u()}function ci(n,t){return Bo.rebind(n,t,"range","rangeRound","interpolate","clamp")}function si(n,t){return ui(n,ii(li(n,t)[2]))}function li(n,t){null==t&&(t=10);var e=ti(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function fi(n,t){return Bo.range.apply(Bo,li(n,t))}function hi(n,t,e){var r=li(n,t);return Bo.format(e?e.replace(ic,function(n,t,e,u,i,o,a,c,s,l){return[t,e,u,i,o,a,c,s||"."+pi(l,r),l].join("")}):",."+gi(r[2])+"f")}function gi(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function pi(n,t){var e=gi(t[2]);return n in fs?Math.abs(e-gi(Math.max(Math.abs(t[0]),Math.abs(t[1]))))+ +("e"!==n):e-2*("%"===n)}function vi(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=ui(r.map(u),e?Math:gs);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=ti(r),o=[],a=n[0],c=n[1],s=Math.floor(u(a)),l=Math.ceil(u(c)),f=t%1?2:t;if(isFinite(l-s)){if(e){for(;l>s;s++)for(var h=1;f>h;h++)o.push(i(s)*h);o.push(i(s))}else for(o.push(i(s));s++0;h--)o.push(i(s)*h);for(s=0;o[s]c;l--);o=o.slice(s,l)}return o},o.tickFormat=function(n,t){if(!arguments.length)return hs;arguments.length<2?t=hs:"function"!=typeof t&&(t=Bo.format(t));var r,a=Math.max(.1,n/o.ticks().length),c=e?(r=1e-12,Math.ceil):(r=-1e-12,Math.floor);return function(n){return n/i(c(u(n)+r))<=a?t(n):""}},o.copy=function(){return vi(n.copy(),t,e,r)},ci(o,n)}function di(n,t,e){function r(t){return n(u(t))}var u=mi(t),i=mi(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return fi(e,n)},r.tickFormat=function(n,t){return hi(e,n,t)},r.nice=function(n){return r.domain(si(e,n))},r.exponent=function(o){return arguments.length?(u=mi(t=o),i=mi(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return di(n.copy(),t,e)},ci(r,n)}function mi(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function yi(n,t){function e(e){return o[((i.get(e)||"range"===t.t&&i.set(e,n.push(e)))-1)%o.length]}function r(t,e){return Bo.range(n.length).map(function(n){return t+e*n})}var i,o,a;return e.domain=function(r){if(!arguments.length)return n;n=[],i=new u;for(var o,a=-1,c=r.length;++ae?[0/0,0/0]:[e>0?u[e-1]:n[0],et?0/0:t/i+n,[t,t+1/i]},r.copy=function(){return Mi(n,t,e)},u()}function _i(n,t){function e(e){return e>=e?t[Bo.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return _i(n,t)},e}function bi(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return fi(n,t)},t.tickFormat=function(t,e){return hi(n,t,e)},t.copy=function(){return bi(n)},t}function wi(n){return n.innerRadius}function Si(n){return n.outerRadius}function ki(n){return n.startAngle}function Ei(n){return n.endAngle}function Ai(n){function t(t){function o(){s.push("M",i(n(l),a))}for(var c,s=[],l=[],f=-1,h=t.length,g=vt(e),p=vt(r);++f1&&u.push("H",r[0]),u.join("")}function Ti(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[c],c++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var s=2;s9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=c;)u=(n[Math.min(c,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function $i(n){return n.length<3?Ci(n):n[0]+Pi(n,Xi(n))}function Bi(n){for(var t,e,r,u=-1,i=n.length;++ue?s():(i.active=e,o.event&&o.event.start.call(n,l,t),o.tween.forEach(function(e,r){(r=r.call(n,l,t))&&v.push(r)}),Bo.timer(function(){return p.c=c(r||1)?Vt:c,1},0,a),void 0)}function c(r){if(i.active!==e)return s();for(var u=r/g,a=f(u),c=v.length;c>0;)v[--c].call(n,a);return u>=1?(o.event&&o.event.end.call(n,l,t),s()):void 0}function s(){return--i.count?delete i[e]:delete n.__transition__,1}var l=n.__data__,f=o.ease,h=o.delay,g=o.duration,p=Ka,v=[];return p.t=h+a,r>=h?u(r-h):(p.c=u,void 0)},0,a)}}function oo(n,t){n.attr("transform",function(n){return"translate("+t(n)+",0)"})}function ao(n,t){n.attr("transform",function(n){return"translate(0,"+t(n)+")"})}function co(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function so(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new Ps(e-1)),1),e}function i(n,e){return t(n=new Ps(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{Ps=co;var r=new co;return r._=n,o(r,t,e)}finally{Ps=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var c=n.utc=lo(n);return c.floor=c,c.round=lo(r),c.ceil=lo(u),c.offset=lo(i),c.range=a,n}function lo(n){return function(t,e){try{Ps=co;var r=new co;return r._=t,n(r,e)._}finally{Ps=Date}}}function fo(n){function t(t){for(var r,u,i,o=[],a=-1,c=0;++aa;){if(r>=s)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=rl[o in tl?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function go(n){return new RegExp("^(?:"+n.map(Bo.requote).join("|")+")","i")}function po(n){for(var t=new u,e=-1,r=n.length;++en?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function mo(n,t,e){Bs.lastIndex=0;var r=Bs.exec(t.substring(e));return r?(n.w=Ws.get(r[0].toLowerCase()),e+r[0].length):-1}function yo(n,t,e){Xs.lastIndex=0;var r=Xs.exec(t.substring(e));return r?(n.w=$s.get(r[0].toLowerCase()),e+r[0].length):-1}function xo(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+1));return r?(n.w=+r[0],e+r[0].length):-1}function Mo(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e));return r?(n.U=+r[0],e+r[0].length):-1}function _o(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e));return r?(n.W=+r[0],e+r[0].length):-1}function bo(n,t,e){Ks.lastIndex=0;var r=Ks.exec(t.substring(e));return r?(n.m=Qs.get(r[0].toLowerCase()),e+r[0].length):-1}function wo(n,t,e){Js.lastIndex=0;var r=Js.exec(t.substring(e));return r?(n.m=Gs.get(r[0].toLowerCase()),e+r[0].length):-1}function So(n,t,e){return ho(n,el.c.toString(),t,e)}function ko(n,t,e){return ho(n,el.x.toString(),t,e)}function Eo(n,t,e){return ho(n,el.X.toString(),t,e)}function Ao(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+4));return r?(n.y=+r[0],e+r[0].length):-1}function Co(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+2));return r?(n.y=Lo(+r[0]),e+r[0].length):-1}function No(n,t,e){return/^[+-]\d{4}$/.test(t=t.substring(e,e+5))?(n.Z=+t,e+5):-1}function Lo(n){return n+(n>68?1900:2e3)}function To(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function qo(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function zo(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function Ro(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function Do(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function Po(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function Uo(n,t,e){ul.lastIndex=0;var r=ul.exec(t.substring(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function jo(n,t,e){var r=il.get(t.substring(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}function Ho(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=~~(ca(t)/60),u=ca(t)%60;return e+vo(r,"0",2)+vo(u,"0",2)}function Fo(n,t,e){nl.lastIndex=0;var r=nl.exec(t.substring(e,e+1));return r?e+r[0].length:-1}function Oo(n){function t(n){try{Ps=co;var t=new Ps;return t._=n,e(t)}finally{Ps=Date}}var e=fo(n);return t.parse=function(n){try{Ps=co;var t=e.parse(n);return t&&t._}finally{Ps=Date}},t.toString=e.toString,t}function Yo(n){return n.toISOString()}function Io(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=Bo.bisect(al,u);return i==al.length?[t.year,li(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/al[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Zo(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Zo(+t+1);return t}}:n))},r.ticks=function(n,t){var e=ti(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Zo(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Io(n.copy(),t,e)},ci(r,n)}function Zo(n){return new Date(n)}function Vo(n){return function(t){for(var e=n.length-1,r=n[e];!r[1](t);)r=n[--e];return r[0](t)}}function Xo(n){return JSON.parse(n.responseText)}function $o(n){var t=Go.createRange();return t.selectNode(Go.body),t.createContextualFragment(n.responseText)}var Bo={version:"3.3.13"};Date.now||(Date.now=function(){return+new Date});var Wo=[].slice,Jo=function(n){return Wo.call(n)},Go=document,Ko=Go.documentElement,Qo=window;try{Jo(Ko.childNodes)[0].nodeType}catch(na){Jo=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}try{Go.createElement("div").style.setProperty("opacity",0,"")}catch(ta){var ea=Qo.Element.prototype,ra=ea.setAttribute,ua=ea.setAttributeNS,ia=Qo.CSSStyleDeclaration.prototype,oa=ia.setProperty;ea.setAttribute=function(n,t){ra.call(this,n,t+"")},ea.setAttributeNS=function(n,t,e){ua.call(this,n,t,e+"")},ia.setProperty=function(n,t,e){oa.call(this,n,t+"",e)}}Bo.ascending=function(n,t){return t>n?-1:n>t?1:n>=t?0:0/0},Bo.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:0/0},Bo.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ur&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ur&&(e=r)}return e},Bo.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=e);)e=void 0;for(;++ue&&(e=r)}else{for(;++u=e);)e=void 0;for(;++ue&&(e=r)}return e},Bo.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=e);)e=u=void 0;for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=e);)e=void 0;for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},Bo.sum=function(n,t){var e,r=0,u=n.length,i=-1;if(1===arguments.length)for(;++i1&&(t=t.map(e)),t=t.filter(n),t.length?Bo.quantile(t.sort(Bo.ascending),.5):void 0},Bo.bisector=function(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n.call(t,t[i],i)r;){var i=r+u>>>1;er?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},Bo.zip=function(){if(!(u=arguments.length))return[];for(var n=-1,e=Bo.min(arguments,t),r=new Array(e);++n=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var ca=Math.abs;Bo.range=function(n,t,r){if(arguments.length<3&&(r=1,arguments.length<2&&(t=n,n=0)),1/0===(t-n)/r)throw new Error("infinite range");var u,i=[],o=e(ca(r)),a=-1;if(n*=o,t*=o,r*=o,0>r)for(;(u=n+r*++a)>t;)i.push(u/o);else for(;(u=n+r*++a)=o.length)return r?r.call(i,a):e?a.sort(e):a;for(var s,l,f,h,g=-1,p=a.length,v=o[c++],d=new u;++g=o.length)return n;var r=[],u=a[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,i={},o=[],a=[];return i.map=function(t,e){return n(e,t,0)},i.entries=function(e){return t(n(Bo.map,e,0),0)},i.key=function(n){return o.push(n),i},i.sortKeys=function(n){return a[o.length-1]=n,i},i.sortValues=function(n){return e=n,i},i.rollup=function(n){return r=n,i},i},Bo.set=function(n){var t=new i;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},r(i,{has:function(n){return sa+n in this},add:function(n){return this[sa+n]=!0,n},remove:function(n){return n=sa+n,n in this&&delete this[n]},values:function(){var n=[];return this.forEach(function(t){n.push(t)}),n},forEach:function(n){for(var t in this)t.charCodeAt(0)===la&&n.call(this,t.substring(1))}}),Bo.behavior={},Bo.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.substring(e+1),n=n.substring(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},Bo.event=null,Bo.requote=function(n){return n.replace(ha,"\\$&")};var ha=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ga={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},pa=function(n,t){return t.querySelector(n)},va=function(n,t){return t.querySelectorAll(n)},da=Ko[a(Ko,"matchesSelector")],ma=function(n,t){return da.call(n,t)};"function"==typeof Sizzle&&(pa=function(n,t){return Sizzle(n,t)[0]||null},va=function(n,t){return Sizzle.uniqueSort(Sizzle(n,t))},ma=Sizzle.matchesSelector),Bo.selection=function(){return _a};var ya=Bo.selection.prototype=[];ya.select=function(n){var t,e,r,u,i=[];n=v(n);for(var o=-1,a=this.length;++o=0&&(e=n.substring(0,t),n=n.substring(t+1)),xa.hasOwnProperty(e)?{space:xa[e],local:n}:n}},ya.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=Bo.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(m(t,n[t]));return this}return this.each(m(n,t))},ya.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=M(n)).length,u=-1;if(t=e.classList){for(;++ur){if("string"!=typeof n){2>r&&(t="");for(e in n)this.each(w(e,n[e],t));return this}if(2>r)return Qo.getComputedStyle(this.node(),null).getPropertyValue(n);e=""}return this.each(w(n,t,e))},ya.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(S(t,n[t]));return this}return this.each(S(n,t))},ya.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},ya.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},ya.append=function(n){return n=k(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},ya.insert=function(n,t){return n=k(n),t=v(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},ya.remove=function(){return this.each(function(){var n=this.parentNode;n&&n.removeChild(this)})},ya.data=function(n,t){function e(n,e){var r,i,o,a=n.length,f=e.length,h=Math.min(a,f),g=new Array(f),p=new Array(f),v=new Array(a);if(t){var d,m=new u,y=new u,x=[];for(r=-1;++rr;++r)p[r]=E(e[r]);for(;a>r;++r)v[r]=n[r]}p.update=g,p.parentNode=g.parentNode=v.parentNode=n.parentNode,c.push(p),s.push(g),l.push(v)}var r,i,o=-1,a=this.length;if(!arguments.length){for(n=new Array(a=(r=this[0]).length);++oi;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return p(u)},ya.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},ya.sort=function(n){n=C.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},ya.size=function(){var n=0;return this.each(function(){++n}),n};var Ma=[];Bo.selection.enter=L,Bo.selection.enter.prototype=Ma,Ma.append=ya.append,Ma.empty=ya.empty,Ma.node=ya.node,Ma.call=ya.call,Ma.size=ya.size,Ma.select=function(n){for(var t,e,r,u,i,o=[],a=-1,c=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(z(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(z(n,t,e))};var ba=Bo.map({mouseenter:"mouseover",mouseleave:"mouseout"});ba.forEach(function(n){"on"+n in Go&&ba.remove(n)});var wa="onselectstart"in Go?null:a(Ko.style,"userSelect"),Sa=0;Bo.mouse=function(n){return U(n,h())};var ka=/WebKit/.test(Qo.navigator.userAgent)?-1:0;Bo.touches=function(n,t){return arguments.length<2&&(t=h().touches),t?Jo(t).map(function(t){var e=U(n,t);return e.identifier=t.identifier,e}):[]},Bo.behavior.drag=function(){function n(){this.on("mousedown.drag",o).on("touchstart.drag",a)}function t(){return Bo.event.changedTouches[0].identifier}function e(n,t){return Bo.touches(n).filter(function(n){return n.identifier===t})[0]}function r(n,t,e,r){return function(){function o(){var n=t(l,g),e=n[0]-v[0],r=n[1]-v[1];d|=e|r,v=n,f({type:"drag",x:n[0]+c[0],y:n[1]+c[1],dx:e,dy:r})}function a(){m.on(e+"."+p,null).on(r+"."+p,null),y(d&&Bo.event.target===h),f({type:"dragend"})}var c,s=this,l=s.parentNode,f=u.of(s,arguments),h=Bo.event.target,g=n(),p=null==g?"drag":"drag-"+g,v=t(l,g),d=0,m=Bo.select(Qo).on(e+"."+p,o).on(r+"."+p,a),y=P();i?(c=i.apply(s,arguments),c=[c.x-v[0],c.y-v[1]]):c=[0,0],f({type:"dragstart"})}}var u=g(n,"drag","dragstart","dragend"),i=null,o=r(c,Bo.mouse,"mousemove","mouseup"),a=r(t,e,"touchmove","touchend");return n.origin=function(t){return arguments.length?(i=t,n):i},Bo.rebind(n,u,"on")};var Ea=Math.PI,Aa=2*Ea,Ca=Ea/2,Na=1e-6,La=Na*Na,Ta=Ea/180,qa=180/Ea,za=Math.SQRT2,Ra=2,Da=4;Bo.interpolateZoom=function(n,t){function e(n){var t=n*y;if(m){var e=Y(v),o=i/(Ra*h)*(e*I(za*t+v)-O(v));return[r+o*s,u+o*l,i*e/Y(za*t+v)]}return[r+n*s,u+n*l,i*Math.exp(za*t)]}var r=n[0],u=n[1],i=n[2],o=t[0],a=t[1],c=t[2],s=o-r,l=a-u,f=s*s+l*l,h=Math.sqrt(f),g=(c*c-i*i+Da*f)/(2*i*Ra*h),p=(c*c-i*i-Da*f)/(2*c*Ra*h),v=Math.log(Math.sqrt(g*g+1)-g),d=Math.log(Math.sqrt(p*p+1)-p),m=d-v,y=(m||Math.log(c/i))/za;return e.duration=1e3*y,e},Bo.behavior.zoom=function(){function n(n){n.on(A,s).on(ja+".zoom",h).on(C,p).on("dblclick.zoom",v).on(L,l)}function t(n){return[(n[0]-S.x)/S.k,(n[1]-S.y)/S.k]}function e(n){return[n[0]*S.k+S.x,n[1]*S.k+S.y]}function r(n){S.k=Math.max(E[0],Math.min(E[1],n))}function u(n,t){t=e(t),S.x+=n[0]-t[0],S.y+=n[1]-t[1]}function i(){_&&_.domain(M.range().map(function(n){return(n-S.x)/S.k}).map(M.invert)),w&&w.domain(b.range().map(function(n){return(n-S.y)/S.k}).map(b.invert))}function o(n){n({type:"zoomstart"})}function a(n){i(),n({type:"zoom",scale:S.k,translate:[S.x,S.y]})}function c(n){n({type:"zoomend"})}function s(){function n(){l=1,u(Bo.mouse(r),h),a(i)}function e(){f.on(C,Qo===r?p:null).on(N,null),g(l&&Bo.event.target===s),c(i)}var r=this,i=T.of(r,arguments),s=Bo.event.target,l=0,f=Bo.select(Qo).on(C,n).on(N,e),h=t(Bo.mouse(r)),g=P();q.call(r),o(i)}function l(){function n(){var n=Bo.touches(p);return g=S.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=t(n))}),n}function e(){for(var t=Bo.event.changedTouches,e=0,i=t.length;i>e;++e)d[t[e].identifier]=null;var o=n(),c=Date.now();if(1===o.length){if(500>c-x){var s=o[0],l=d[s.identifier];r(2*S.k),u(s,l),f(),a(v)}x=c}else if(o.length>1){var s=o[0],h=o[1],g=s[0]-h[0],p=s[1]-h[1];m=g*g+p*p}}function i(){for(var n,t,e,i,o=Bo.touches(p),c=0,s=o.length;s>c;++c,i=null)if(e=o[c],i=d[e.identifier]){if(t)break;n=e,t=i}if(i){var l=(l=e[0]-n[0])*l+(l=e[1]-n[1])*l,f=m&&Math.sqrt(l/m);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+i[0])/2,(t[1]+i[1])/2],r(f*g)}x=null,u(n,t),a(v)}function h(){if(Bo.event.touches.length){for(var t=Bo.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var u in d)return void n()}b.on(M,null).on(_,null),w.on(A,s).on(L,l),k(),c(v)}var g,p=this,v=T.of(p,arguments),d={},m=0,y=Bo.event.changedTouches[0].identifier,M="touchmove.zoom-"+y,_="touchend.zoom-"+y,b=Bo.select(Qo).on(M,i).on(_,h),w=Bo.select(p).on(A,null).on(L,e),k=P();q.call(p),e(),o(v)}function h(){var n=T.of(this,arguments);y?clearTimeout(y):(q.call(this),o(n)),y=setTimeout(function(){y=null,c(n)},50),f();var e=m||Bo.mouse(this);d||(d=t(e)),r(Math.pow(2,.002*Pa())*S.k),u(e,d),a(n)}function p(){d=null}function v(){var n=T.of(this,arguments),e=Bo.mouse(this),i=t(e),s=Math.log(S.k)/Math.LN2;o(n),r(Math.pow(2,Bo.event.shiftKey?Math.ceil(s)-1:Math.floor(s)+1)),u(e,i),a(n),c(n)}var d,m,y,x,M,_,b,w,S={x:0,y:0,k:1},k=[960,500],E=Ua,A="mousedown.zoom",C="mousemove.zoom",N="mouseup.zoom",L="touchstart.zoom",T=g(n,"zoomstart","zoom","zoomend");return n.event=function(n){n.each(function(){var n=T.of(this,arguments),t=S;ks?Bo.select(this).transition().each("start.zoom",function(){S=this.__chart__||{x:0,y:0,k:1},o(n)}).tween("zoom:zoom",function(){var e=k[0],r=k[1],u=e/2,i=r/2,o=Bo.interpolateZoom([(u-S.x)/S.k,(i-S.y)/S.k,e/S.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),c=e/r[2];this.__chart__=S={x:u-r[0]*c,y:i-r[1]*c,k:c},a(n)}}).each("end.zoom",function(){c(n)}):(this.__chart__=S,o(n),a(n),c(n))})},n.translate=function(t){return arguments.length?(S={x:+t[0],y:+t[1],k:S.k},i(),n):[S.x,S.y]},n.scale=function(t){return arguments.length?(S={x:S.x,y:S.y,k:+t},i(),n):S.k},n.scaleExtent=function(t){return arguments.length?(E=null==t?Ua:[+t[0],+t[1]],n):E},n.center=function(t){return arguments.length?(m=t&&[+t[0],+t[1]],n):m},n.size=function(t){return arguments.length?(k=t&&[+t[0],+t[1]],n):k},n.x=function(t){return arguments.length?(_=t,M=t.copy(),S={x:0,y:0,k:1},n):_},n.y=function(t){return arguments.length?(w=t,b=t.copy(),S={x:0,y:0,k:1},n):w},Bo.rebind(n,T,"on")};var Pa,Ua=[0,1/0],ja="onwheel"in Go?(Pa=function(){return-Bo.event.deltaY*(Bo.event.deltaMode?120:1)},"wheel"):"onmousewheel"in Go?(Pa=function(){return Bo.event.wheelDelta},"mousewheel"):(Pa=function(){return-Bo.event.detail},"MozMousePixelScroll");V.prototype.toString=function(){return this.rgb()+""},Bo.hsl=function(n,t,e){return 1===arguments.length?n instanceof $?X(n.h,n.s,n.l):lt(""+n,ft,X):X(+n,+t,+e)};var Ha=$.prototype=new V;Ha.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),X(this.h,this.s,this.l/n)},Ha.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),X(this.h,this.s,n*this.l)},Ha.rgb=function(){return B(this.h,this.s,this.l)},Bo.hcl=function(n,t,e){return 1===arguments.length?n instanceof J?W(n.h,n.c,n.l):n instanceof Q?tt(n.l,n.a,n.b):tt((n=ht((n=Bo.rgb(n)).r,n.g,n.b)).l,n.a,n.b):W(+n,+t,+e)};var Fa=J.prototype=new V;Fa.brighter=function(n){return W(this.h,this.c,Math.min(100,this.l+Oa*(arguments.length?n:1)))},Fa.darker=function(n){return W(this.h,this.c,Math.max(0,this.l-Oa*(arguments.length?n:1)))},Fa.rgb=function(){return G(this.h,this.c,this.l).rgb()},Bo.lab=function(n,t,e){return 1===arguments.length?n instanceof Q?K(n.l,n.a,n.b):n instanceof J?G(n.l,n.c,n.h):ht((n=Bo.rgb(n)).r,n.g,n.b):K(+n,+t,+e)};var Oa=18,Ya=.95047,Ia=1,Za=1.08883,Va=Q.prototype=new V;Va.brighter=function(n){return K(Math.min(100,this.l+Oa*(arguments.length?n:1)),this.a,this.b)},Va.darker=function(n){return K(Math.max(0,this.l-Oa*(arguments.length?n:1)),this.a,this.b)},Va.rgb=function(){return nt(this.l,this.a,this.b)},Bo.rgb=function(n,t,e){return 1===arguments.length?n instanceof ct?at(n.r,n.g,n.b):lt(""+n,at,B):at(~~n,~~t,~~e)};var Xa=ct.prototype=new V;Xa.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),at(Math.min(255,~~(t/n)),Math.min(255,~~(e/n)),Math.min(255,~~(r/n)))):at(u,u,u)},Xa.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),at(~~(n*this.r),~~(n*this.g),~~(n*this.b))},Xa.hsl=function(){return ft(this.r,this.g,this.b)},Xa.toString=function(){return"#"+st(this.r)+st(this.g)+st(this.b)};var $a=Bo.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});$a.forEach(function(n,t){$a.set(n,it(t))}),Bo.functor=vt,Bo.xhr=mt(dt),Bo.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=yt(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function o(t){return t.map(a).join(n)}function a(n){return c.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var c=new RegExp('["'+n+"\n]"),s=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=new Function("d","return {"+n.map(function(n,t){return JSON.stringify(n)+": d["+t+"]"}).join(",")+"}");r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(l>=c)return o;if(u)return u=!1,i;var t=l;if(34===n.charCodeAt(t)){for(var e=t;e++l;){var r=n.charCodeAt(l++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(l)&&(++l,++a);else if(r!==s)continue;return n.substring(t,l-a)}return n.substring(t)}for(var r,u,i={},o={},a=[],c=n.length,l=0,f=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();(!t||(h=t(h,f++)))&&a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new i,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(a).join(n)].concat(t.map(function(t){return u.map(function(n){return a(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(o).join("\n")},e},Bo.csv=Bo.dsv(",","text/csv"),Bo.tsv=Bo.dsv(" ","text/tab-separated-values");var Ba,Wa,Ja,Ga,Ka,Qa=Qo[a(Qo,"requestAnimationFrame")]||function(n){setTimeout(n,17)};Bo.timer=function(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,f:!1,n:null};Wa?Wa.n=i:Ba=i,Wa=i,Ja||(Ga=clearTimeout(Ga),Ja=1,Qa(Mt))},Bo.timer.flush=function(){_t(),bt()};var nc=".",tc=",",ec=[3,3],rc="$",uc=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(wt);Bo.formatPrefix=function(n,t){var e=0;return n&&(0>n&&(n*=-1),t&&(n=Bo.round(n,St(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((0>=e?e+1:e-1)/3)))),uc[8+e/3]},Bo.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)},Bo.format=function(n){var t=ic.exec(n),e=t[1]||" ",r=t[2]||">",u=t[3]||"",i=t[4]||"",o=t[5],a=+t[6],c=t[7],s=t[8],l=t[9],f=1,h="",g=!1;switch(s&&(s=+s.substring(1)),(o||"0"===e&&"="===r)&&(o=e="0",r="=",c&&(a-=Math.floor((a-1)/4))),l){case"n":c=!0,l="g";break;case"%":f=100,h="%",l="f";break;case"p":f=100,h="%",l="r";break;case"b":case"o":case"x":case"X":"#"===i&&(i="0"+l.toLowerCase());case"c":case"d":g=!0,s=0;break;case"s":f=-1,l="r"}"#"===i?i="":"$"===i&&(i=rc),"r"!=l||s||(l="g"),null!=s&&("g"==l?s=Math.max(1,Math.min(21,s)):("e"==l||"f"==l)&&(s=Math.max(0,Math.min(20,s)))),l=oc.get(l)||kt;var p=o&&c;return function(n){if(g&&n%1)return"";var t=0>n||0===n&&0>1/n?(n=-n,"-"):u;if(0>f){var v=Bo.formatPrefix(n,s);n=v.scale(n),h=v.symbol}else n*=f;n=l(n,s);var d=n.lastIndexOf("."),m=0>d?n:n.substring(0,d),y=0>d?"":nc+n.substring(d+1);!o&&c&&(m=ac(m));var x=i.length+m.length+y.length+(p?0:t.length),M=a>x?new Array(x=a-x+1).join(e):"";return p&&(m=ac(M+m)),t+=i,n=m+y,("<"===r?t+n+M:">"===r?M+t+n:"^"===r?M.substring(0,x>>=1)+t+n+M.substring(x):t+(p?n:M+n))+h}};var ic=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,oc=Bo.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=Bo.round(n,St(n,t))).toFixed(Math.max(0,Math.min(20,St(n*(1+1e-15),t))))}}),ac=dt;if(ec){var cc=ec.length;ac=function(n){for(var t=n.length,e=[],r=0,u=ec[0];t>0&&u>0;)e.push(n.substring(t-=u,t+u)),u=ec[r=(r+1)%cc];return e.reverse().join(tc)}}Bo.geo={},Et.prototype={s:0,t:0,add:function(n){At(n,this.t,sc),At(sc.s,this.s,this),this.s?this.t+=sc.t:this.s=sc.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var sc=new Et;Bo.geo.stream=function(n,t){n&&lc.hasOwnProperty(n.type)?lc[n.type](n,t):Ct(n,t)};var lc={Feature:function(n,t){Ct(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,u=e.length;++rn?4*Ea+n:n,pc.lineStart=pc.lineEnd=pc.point=c}};Bo.geo.bounds=function(){function n(n,t){x.push(M=[l=n,h=n]),f>t&&(f=t),t>g&&(g=t)}function t(t,e){var r=qt([t*Ta,e*Ta]);if(m){var u=Rt(m,r),i=[u[1],-u[0],0],o=Rt(i,u);Ut(o),o=jt(o);var c=t-p,s=c>0?1:-1,v=o[0]*qa*s,d=ca(c)>180;if(d^(v>s*p&&s*t>v)){var y=o[1]*qa;y>g&&(g=y)}else if(v=(v+360)%360-180,d^(v>s*p&&s*t>v)){var y=-o[1]*qa;f>y&&(f=y)}else f>e&&(f=e),e>g&&(g=e);d?p>t?a(l,t)>a(l,h)&&(h=t):a(t,h)>a(l,h)&&(l=t):h>=l?(l>t&&(l=t),t>h&&(h=t)):t>p?a(l,t)>a(l,h)&&(h=t):a(t,h)>a(l,h)&&(l=t)}else n(t,e);m=r,p=t}function e(){_.point=t}function r(){M[0]=l,M[1]=h,_.point=n,m=null}function u(n,e){if(m){var r=n-p;y+=ca(r)>180?r+(r>0?360:-360):r}else v=n,d=e;pc.point(n,e),t(n,e)}function i(){pc.lineStart()}function o(){u(v,d),pc.lineEnd(),ca(y)>Na&&(l=-(h=180)),M[0]=l,M[1]=h,m=null}function a(n,t){return(t-=n)<0?t+360:t}function c(n,t){return n[0]-t[0]}function s(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:ngc?(l=-(h=180),f=-(g=90)):y>Na?g=90:-Na>y&&(f=-90),M[0]=l,M[1]=h}};return function(n){g=h=-(l=f=1/0),x=[],Bo.geo.stream(n,_);var t=x.length;if(t){x.sort(c);for(var e,r=1,u=x[0],i=[u];t>r;++r)e=x[r],s(e[0],u)||s(e[1],u)?(a(u[0],e[1])>a(u[0],u[1])&&(u[1]=e[1]),a(e[0],u[1])>a(u[0],u[1])&&(u[0]=e[0])):i.push(u=e);for(var o,e,p=-1/0,t=i.length-1,r=0,u=i[t];t>=r;u=e,++r)e=i[r],(o=a(u[1],e[0]))>p&&(p=o,l=e[0],h=u[1])}return x=M=null,1/0===l||1/0===f?[[0/0,0/0],[0/0,0/0]]:[[l,f],[h,g]]}}(),Bo.geo.centroid=function(n){vc=dc=mc=yc=xc=Mc=_c=bc=wc=Sc=kc=0,Bo.geo.stream(n,Ec);var t=wc,e=Sc,r=kc,u=t*t+e*e+r*r;return La>u&&(t=Mc,e=_c,r=bc,Na>dc&&(t=mc,e=yc,r=xc),u=t*t+e*e+r*r,La>u)?[0/0,0/0]:[Math.atan2(e,t)*qa,F(r/Math.sqrt(u))*qa]};var vc,dc,mc,yc,xc,Mc,_c,bc,wc,Sc,kc,Ec={sphere:c,point:Ft,lineStart:Yt,lineEnd:It,polygonStart:function(){Ec.lineStart=Zt},polygonEnd:function(){Ec.lineStart=Yt}},Ac=Wt(Vt,ne,ee,[-Ea,-Ea/2]),Cc=1e9;Bo.geo.clipExtent=function(){var n,t,e,r,u,i,o={stream:function(n){return u&&(u.valid=!1),u=i(n),u.valid=!0,u},extent:function(a){return arguments.length?(i=ie(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),u&&(u.valid=!1,u=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(Bo.geo.conicEqualArea=function(){return ae(ce)}).raw=ce,Bo.geo.albers=function(){return Bo.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},Bo.geo.albersUsa=function(){function n(n){var i=n[0],o=n[1];return t=null,e(i,o),t||(r(i,o),t)||u(i,o),t}var t,e,r,u,i=Bo.geo.albers(),o=Bo.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=Bo.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),c={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=i.scale(),e=i.translate(),r=(n[0]-e[0])/t,u=(n[1]-e[1])/t;return(u>=.12&&.234>u&&r>=-.425&&-.214>r?o:u>=.166&&.234>u&&r>=-.214&&-.115>r?a:i).invert(n)},n.stream=function(n){var t=i.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,u){t.point(n,u),e.point(n,u),r.point(n,u)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(i.precision(t),o.precision(t),a.precision(t),n):i.precision()},n.scale=function(t){return arguments.length?(i.scale(t),o.scale(.35*t),a.scale(t),n.translate(i.translate())):i.scale()},n.translate=function(t){if(!arguments.length)return i.translate();var s=i.scale(),l=+t[0],f=+t[1];return e=i.translate(t).clipExtent([[l-.455*s,f-.238*s],[l+.455*s,f+.238*s]]).stream(c).point,r=o.translate([l-.307*s,f+.201*s]).clipExtent([[l-.425*s+Na,f+.12*s+Na],[l-.214*s-Na,f+.234*s-Na]]).stream(c).point,u=a.translate([l-.205*s,f+.212*s]).clipExtent([[l-.214*s+Na,f+.166*s+Na],[l-.115*s-Na,f+.234*s-Na]]).stream(c).point,n},n.scale(1070)};var Nc,Lc,Tc,qc,zc,Rc,Dc={point:c,lineStart:c,lineEnd:c,polygonStart:function(){Lc=0,Dc.lineStart=se},polygonEnd:function(){Dc.lineStart=Dc.lineEnd=Dc.point=c,Nc+=ca(Lc/2)}},Pc={point:le,lineStart:c,lineEnd:c,polygonStart:c,polygonEnd:c},Uc={point:ge,lineStart:pe,lineEnd:ve,polygonStart:function(){Uc.lineStart=de},polygonEnd:function(){Uc.point=ge,Uc.lineStart=pe,Uc.lineEnd=ve}};Bo.geo.path=function(){function n(n){return n&&("function"==typeof a&&i.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=u(i)),Bo.geo.stream(n,o)),i.result()}function t(){return o=null,n}var e,r,u,i,o,a=4.5;return n.area=function(n){return Nc=0,Bo.geo.stream(n,u(Dc)),Nc},n.centroid=function(n){return mc=yc=xc=Mc=_c=bc=wc=Sc=kc=0,Bo.geo.stream(n,u(Uc)),kc?[wc/kc,Sc/kc]:bc?[Mc/bc,_c/bc]:xc?[mc/xc,yc/xc]:[0/0,0/0]},n.bounds=function(n){return zc=Rc=-(Tc=qc=1/0),Bo.geo.stream(n,u(Pc)),[[Tc,qc],[zc,Rc]]},n.projection=function(n){return arguments.length?(u=(e=n)?n.stream||xe(n):dt,t()):e},n.context=function(n){return arguments.length?(i=null==(r=n)?new fe:new me(n),"function"!=typeof a&&i.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(i.pointRadius(+t),+t),n):a},n.projection(Bo.geo.albersUsa()).context(null)},Bo.geo.transform=function(n){return{stream:function(t){var e=new Me(t);for(var r in n)e[r]=n[r];return e}}},Me.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart() +},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},Bo.geo.projection=be,Bo.geo.projectionMutator=we,(Bo.geo.equirectangular=function(){return be(ke)}).raw=ke.invert=ke,Bo.geo.rotation=function(n){function t(t){return t=n(t[0]*Ta,t[1]*Ta),t[0]*=qa,t[1]*=qa,t}return n=Ae(n[0]%360*Ta,n[1]*Ta,n.length>2?n[2]*Ta:0),t.invert=function(t){return t=n.invert(t[0]*Ta,t[1]*Ta),t[0]*=qa,t[1]*=qa,t},t},Ee.invert=ke,Bo.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=Ae(-n[0]*Ta,-n[1]*Ta,0).invert,u=[];return e(null,null,1,{point:function(n,e){u.push(n=t(n,e)),n[0]*=qa,n[1]*=qa}}),{type:"Polygon",coordinates:[u]}}var t,e,r=[0,0],u=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=Te((t=+r)*Ta,u*Ta),n):t},n.precision=function(r){return arguments.length?(e=Te(t*Ta,(u=+r)*Ta),n):u},n.angle(90)},Bo.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Ta,u=n[1]*Ta,i=t[1]*Ta,o=Math.sin(r),a=Math.cos(r),c=Math.sin(u),s=Math.cos(u),l=Math.sin(i),f=Math.cos(i);return Math.atan2(Math.sqrt((e=f*o)*e+(e=s*l-c*f*a)*e),c*l+s*f*a)},Bo.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return Bo.range(Math.ceil(i/d)*d,u,d).map(h).concat(Bo.range(Math.ceil(s/m)*m,c,m).map(g)).concat(Bo.range(Math.ceil(r/p)*p,e,p).filter(function(n){return ca(n%d)>Na}).map(l)).concat(Bo.range(Math.ceil(a/v)*v,o,v).filter(function(n){return ca(n%m)>Na}).map(f))}var e,r,u,i,o,a,c,s,l,f,h,g,p=10,v=p,d=90,m=360,y=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(i).concat(g(c).slice(1),h(u).reverse().slice(1),g(s).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(i=+t[0][0],u=+t[1][0],s=+t[0][1],c=+t[1][1],i>u&&(t=i,i=u,u=t),s>c&&(t=s,s=c,c=t),n.precision(y)):[[i,s],[u,c]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(y)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],m=+t[1],n):[d,m]},n.minorStep=function(t){return arguments.length?(p=+t[0],v=+t[1],n):[p,v]},n.precision=function(t){return arguments.length?(y=+t,l=ze(a,o,90),f=Re(r,e,y),h=ze(s,c,90),g=Re(i,u,y),n):y},n.majorExtent([[-180,-90+Na],[180,90-Na]]).minorExtent([[-180,-80-Na],[180,80+Na]])},Bo.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||u.apply(this,arguments)]}}var t,e,r=De,u=Pe;return n.distance=function(){return Bo.geo.distance(t||r.apply(this,arguments),e||u.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(u=t,e="function"==typeof t?null:t,n):u},n.precision=function(){return arguments.length?n:0},n},Bo.geo.interpolate=function(n,t){return Ue(n[0]*Ta,n[1]*Ta,t[0]*Ta,t[1]*Ta)},Bo.geo.length=function(n){return jc=0,Bo.geo.stream(n,Hc),jc};var jc,Hc={sphere:c,point:c,lineStart:je,lineEnd:c,polygonStart:c,polygonEnd:c},Fc=He(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(Bo.geo.azimuthalEqualArea=function(){return be(Fc)}).raw=Fc;var Oc=He(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},dt);(Bo.geo.azimuthalEquidistant=function(){return be(Oc)}).raw=Oc,(Bo.geo.conicConformal=function(){return ae(Fe)}).raw=Fe,(Bo.geo.conicEquidistant=function(){return ae(Oe)}).raw=Oe;var Yc=He(function(n){return 1/n},Math.atan);(Bo.geo.gnomonic=function(){return be(Yc)}).raw=Yc,Ye.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Ca]},(Bo.geo.mercator=function(){return Ie(Ye)}).raw=Ye;var Ic=He(function(){return 1},Math.asin);(Bo.geo.orthographic=function(){return be(Ic)}).raw=Ic;var Zc=He(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(Bo.geo.stereographic=function(){return be(Zc)}).raw=Zc,Ze.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Ca]},(Bo.geo.transverseMercator=function(){var n=Ie(Ze),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[-n[1],n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},n.rotate([0,0])}).raw=Ze,Bo.geom={},Bo.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u,i,o,a,c,s,l,f,h,g,p,v=vt(e),d=vt(r),m=n.length,y=m-1,x=[],M=[],_=0;if(v===Ve&&r===Xe)t=n;else for(i=0,t=[];m>i;++i)t.push([+v.call(this,u=n[i],i),+d.call(this,u,i)]);for(i=1;m>i;++i)(t[i][1]i;++i)i!==_&&(c=t[i][1]-t[_][1],a=t[i][0]-t[_][0],x.push({angle:Math.atan2(c,a),index:i}));for(x.sort(function(n,t){return n.angle-t.angle}),g=x[0].angle,h=x[0].index,f=0,i=1;y>i;++i){if(o=x[i].index,g==x[i].angle){if(a=t[h][0]-t[_][0],c=t[h][1]-t[_][1],s=t[o][0]-t[_][0],l=t[o][1]-t[_][1],a*a+c*c>=s*s+l*l){x[i].index=-1;continue}x[f].index=-1}g=x[i].angle,f=i,h=o}for(M.push(_),i=0,o=0;2>i;++o)x[o].index>-1&&(M.push(x[o].index),i++);for(p=M.length;y>o;++o)if(!(x[o].index<0)){for(;!$e(M[p-2],M[p-1],x[o].index,t);)--p;M[p++]=x[o].index}var b=[];for(i=p-1;i>=0;--i)b.push(n[M[i]]);return b}var e=Ve,r=Xe;return arguments.length?t(n):(t.x=function(n){return arguments.length?(e=n,t):e},t.y=function(n){return arguments.length?(r=n,t):r},t)},Bo.geom.polygon=function(n){return ga(n,Vc),n};var Vc=Bo.geom.polygon.prototype=[];Vc.area=function(){for(var n,t=-1,e=this.length,r=this[e-1],u=0;++t=r&&s.x<=i&&s.y>=u&&s.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];l.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/Na)*Na,y:Math.round(o(n,t)/Na)*Na,i:t}})}var r=Ve,u=Xe,i=r,o=u,a=Qc;return n?t(n):(t.links=function(n){return br(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return br(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(or),c=-1,s=a.length,l=a[s-1].edge,f=l.l===o?l.r:l.l;++c=s,h=r>=l,g=(h<<1)+f;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=Ar()),f?u=s:a=s,h?o=l:c=l,i(n,t,e,r,u,o,a,c)}var l,f,h,g,p,v,d,m,y,x=vt(a),M=vt(c);if(null!=t)v=t,d=e,m=r,y=u;else if(m=y=-(v=d=1/0),f=[],h=[],p=n.length,o)for(g=0;p>g;++g)l=n[g],l.xm&&(m=l.x),l.y>y&&(y=l.y),f.push(l.x),h.push(l.y);else for(g=0;p>g;++g){var _=+x(l=n[g],g),b=+M(l,g);v>_&&(v=_),d>b&&(d=b),_>m&&(m=_),b>y&&(y=b),f.push(_),h.push(b)}var w=m-v,S=y-d;w>S?y=d+w:m=v+S;var k=Ar();if(k.add=function(n){i(k,n,+x(n,++g),+M(n,g),v,d,m,y)},k.visit=function(n){Cr(n,k,v,d,m,y)},g=-1,null==t){for(;++g=0?n.substring(0,t):n,r=t>=0?n.substring(t+1):"in";return e=es.get(e)||ts,r=rs.get(r)||dt,Dr(r(e.apply(null,Wo.call(arguments,1))))},Bo.interpolateHcl=Br,Bo.interpolateHsl=Wr,Bo.interpolateLab=Jr,Bo.interpolateRound=Gr,Bo.transform=function(n){var t=Go.createElementNS(Bo.ns.prefix.svg,"g");return(Bo.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new Kr(e?e.matrix:us)})(n)},Kr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var us={a:1,b:0,c:0,d:1,e:0,f:0};Bo.interpolateTransform=eu,Bo.layout={},Bo.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++e(u-e)*a){var c=t.charge*a*a;return n.px-=i*c,n.py-=o*c,!0}if(t.point&&isFinite(a)){var c=t.pointCharge*a*a;n.px-=i*c,n.py-=o*c}}return!t.charge}}function t(n){n.px=Bo.event.x,n.py=Bo.event.y,a.resume()}var e,r,u,i,o,a={},c=Bo.dispatch("start","tick","end"),s=[1,1],l=.9,f=is,h=os,g=-30,p=.1,v=.8,d=[],m=[];return a.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var t,e,a,f,h,v,y,x,M,_=d.length,b=m.length;for(e=0;b>e;++e)a=m[e],f=a.source,h=a.target,x=h.x-f.x,M=h.y-f.y,(v=x*x+M*M)&&(v=r*i[e]*((v=Math.sqrt(v))-u[e])/v,x*=v,M*=v,h.x-=x*(y=f.weight/(h.weight+f.weight)),h.y-=M*y,f.x+=x*(y=1-y),f.y+=M*y);if((y=r*p)&&(x=s[0]/2,M=s[1]/2,e=-1,y))for(;++e<_;)a=d[e],a.x+=(x-a.x)*y,a.y+=(M-a.y)*y;if(g)for(hu(t=Bo.geom.quadtree(d),r,o),e=-1;++e<_;)(a=d[e]).fixed||t.visit(n(a));for(e=-1;++e<_;)a=d[e],a.fixed?(a.x=a.px,a.y=a.py):(a.x-=(a.px-(a.px=a.x))*l,a.y-=(a.py-(a.py=a.y))*l);c.tick({type:"tick",alpha:r})},a.nodes=function(n){return arguments.length?(d=n,a):d},a.links=function(n){return arguments.length?(m=n,a):m},a.size=function(n){return arguments.length?(s=n,a):s},a.linkDistance=function(n){return arguments.length?(f="function"==typeof n?n:+n,a):f},a.distance=a.linkDistance,a.linkStrength=function(n){return arguments.length?(h="function"==typeof n?n:+n,a):h},a.friction=function(n){return arguments.length?(l=+n,a):l},a.charge=function(n){return arguments.length?(g="function"==typeof n?n:+n,a):g},a.gravity=function(n){return arguments.length?(p=+n,a):p},a.theta=function(n){return arguments.length?(v=+n,a):v},a.alpha=function(n){return arguments.length?(n=+n,r?r=n>0?n:0:n>0&&(c.start({type:"start",alpha:r=n}),Bo.timer(a.tick)),a):r},a.start=function(){function n(n,r){if(!e){for(e=new Array(c),a=0;c>a;++a)e[a]=[];for(a=0;s>a;++a){var u=m[a];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var i,o=e[t],a=-1,s=o.length;++at;++t)(r=d[t]).index=t,r.weight=0;for(t=0;l>t;++t)r=m[t],"number"==typeof r.source&&(r.source=d[r.source]),"number"==typeof r.target&&(r.target=d[r.target]),++r.source.weight,++r.target.weight;for(t=0;c>t;++t)r=d[t],isNaN(r.x)&&(r.x=n("x",p)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof f)for(t=0;l>t;++t)u[t]=+f.call(this,m[t],t);else for(t=0;l>t;++t)u[t]=f;if(i=[],"function"==typeof h)for(t=0;l>t;++t)i[t]=+h.call(this,m[t],t);else for(t=0;l>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,d[t],t);else for(t=0;c>t;++t)o[t]=g;return a.resume()},a.resume=function(){return a.alpha(.1)},a.stop=function(){return a.alpha(0)},a.drag=function(){return e||(e=Bo.behavior.drag().origin(dt).on("dragstart.force",cu).on("drag.force",t).on("dragend.force",su)),arguments.length?(this.on("mouseover.force",lu).on("mouseout.force",fu).call(e),void 0):e},Bo.rebind(a,c,"on")};var is=20,os=1;Bo.layout.hierarchy=function(){function n(t,o,a){var c=u.call(e,t,o);if(t.depth=o,a.push(t),c&&(s=c.length)){for(var s,l,f=-1,h=t.children=new Array(s),g=0,p=o+1;++fg;++g)for(u.call(n,s[0][g],p=v[g],l[0][g][1]),h=1;d>h;++h)u.call(n,s[h][g],p+=l[h-1][g][1],l[h][g][1]);return a}var t=dt,e=_u,r=bu,u=Mu,i=yu,o=xu;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:cs.get(t)||_u,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:ss.get(t)||bu,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var cs=Bo.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(wu),i=n.map(Su),o=Bo.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,c=0,s=[],l=[];for(t=0;r>t;++t)e=o[t],c>a?(a+=i[e],s.push(e)):(c+=i[e],l.push(e));return l.reverse().concat(s)},reverse:function(n){return Bo.range(n.length).reverse()},"default":_u}),ss=Bo.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,c=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)c[e]=(a-o[e])/2;return c},wiggle:function(n){var t,e,r,u,i,o,a,c,s,l=n.length,f=n[0],h=f.length,g=[];for(g[0]=c=s=0,e=1;h>e;++e){for(t=0,u=0;l>t;++t)u+=n[t][e][1];for(t=0,i=0,a=f[e][0]-f[e-1][0];l>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=c-=u?i/u*a:0,s>c&&(s=c)}for(e=0;h>e;++e)g[e]-=s;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:bu});Bo.layout.histogram=function(){function n(n,i){for(var o,a,c=[],s=n.map(e,this),l=r.call(this,s,i),f=u.call(this,l,s,i),i=-1,h=s.length,g=f.length-1,p=t?1:1/h;++i0)for(i=-1;++i=l[0]&&a<=l[1]&&(o=c[Bo.bisect(f,a,1,g)-1],o.y+=p,o.push(n[i]));return c}var t=!0,e=Number,r=Cu,u=Eu;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=vt(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return Au(n,t)}:vt(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},Bo.layout.tree=function(){function n(n,i){function o(n,t){var r=n.children,u=n._tree;if(r&&(i=r.length)){for(var i,a,s,l=r[0],f=l,h=-1;++h0&&(ju(Hu(a,n,r),n,u),s+=u,l+=u),f+=a._tree.mod,s+=i._tree.mod,h+=c._tree.mod,l+=o._tree.mod;a&&!Tu(o)&&(o._tree.thread=a,o._tree.mod+=f-l),i&&!Lu(c)&&(c._tree.thread=i,c._tree.mod+=s-h,r=n)}return r}var s=t.call(this,n,i),l=s[0];Pu(l,function(n,t){n._tree={ancestor:n,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),o(l),a(l,-l._tree.prelim);var f=qu(l,Ru),h=qu(l,zu),g=qu(l,Du),p=f.x-e(f,h)/2,v=h.x+e(h,f)/2,d=g.depth||1;return Pu(l,u?function(n){n.x*=r[0],n.y=n.depth*r[1],delete n._tree}:function(n){n.x=(n.x-p)/(v-p)*r[0],n.y=n.depth/d*r[1],delete n._tree}),s}var t=Bo.layout.hierarchy().sort(null).value(null),e=Nu,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},gu(n,t)},Bo.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],c=u[0],s=u[1],l=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,Pu(a,function(n){n.r=+l(n.value)}),Pu(a,Zu),r){var f=r*(t?1:Math.max(2*a.r/c,2*a.r/s))/2;Pu(a,function(n){n.r+=f}),Pu(a,Zu),Pu(a,function(n){n.r-=f})}return $u(a,c/2,s/2,t?1:1/Math.max(2*a.r/c,2*a.r/s)),o}var t,e=Bo.layout.hierarchy().sort(Fu),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},gu(n,e)},Bo.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),c=a[0],s=0;Pu(c,function(n){var t=n.children;t&&t.length?(n.x=Ju(t),n.y=Wu(t)):(n.x=o?s+=e(n,o):0,n.y=0,o=n)});var l=Gu(c),f=Ku(c),h=l.x-e(l,f)/2,g=f.x+e(f,l)/2;return Pu(c,u?function(n){n.x=(n.x-c.x)*r[0],n.y=(c.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(c.y?n.y/c.y:1))*r[1]}),a}var t=Bo.layout.hierarchy().sort(null).value(null),e=Nu,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},gu(n,t)},Bo.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,c,s=f(e),l=[],h=i.slice(),p=1/0,v="slice"===g?s.dx:"dice"===g?s.dy:"slice-dice"===g?1&e.depth?s.dy:s.dx:Math.min(s.dx,s.dy);for(n(h,s.dx*s.dy/e.value),l.area=0;(c=h.length)>0;)l.push(o=h[c-1]),l.area+=o.area,"squarify"!==g||(a=r(l,v))<=p?(h.pop(),p=a):(l.area-=l.pop().area,u(l,v,s,!1),v=Math.min(s.dx,s.dy),l.length=l.area=0,p=1/0);l.length&&(u(l,v,s,!0),l.length=l.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=f(t),a=r.slice(),c=[];for(n(a,o.dx*o.dy/t.value),c.area=0;i=a.pop();)c.push(i),c.area+=i.area,null!=i.z&&(u(c,i.z?o.dx:o.dy,o,!a.length),c.length=c.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,s=e.y,l=t?c(n.area/t):0;if(t==e.dx){for((r||l>e.dy)&&(l=e.dy);++ie.dx)&&(l=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=Bo.random.normal.apply(Bo,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=Bo.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},Bo.scale={};var ls={floor:dt,ceil:dt};Bo.scale.linear=function(){return ai([0,1],[0,1],zr,!1)};var fs={s:1,g:1,p:1,r:1,e:1};Bo.scale.log=function(){return vi(Bo.scale.linear().domain([0,1]),10,!0,[1,10])};var hs=Bo.format(".0e"),gs={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};Bo.scale.pow=function(){return di(Bo.scale.linear(),1,[0,1])},Bo.scale.sqrt=function(){return Bo.scale.pow().exponent(.5)},Bo.scale.ordinal=function(){return yi([],{t:"range",a:[[]]})},Bo.scale.category10=function(){return Bo.scale.ordinal().range(ps)},Bo.scale.category20=function(){return Bo.scale.ordinal().range(vs)},Bo.scale.category20b=function(){return Bo.scale.ordinal().range(ds)},Bo.scale.category20c=function(){return Bo.scale.ordinal().range(ms)};var ps=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(ot),vs=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(ot),ds=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(ot),ms=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(ot);Bo.scale.quantile=function(){return xi([],[])},Bo.scale.quantize=function(){return Mi(0,1,[0,1])},Bo.scale.threshold=function(){return _i([.5],[0,1])},Bo.scale.identity=function(){return bi([0,1])},Bo.svg={},Bo.svg.arc=function(){function n(){var n=t.apply(this,arguments),i=e.apply(this,arguments),o=r.apply(this,arguments)+ys,a=u.apply(this,arguments)+ys,c=(o>a&&(c=o,o=a,a=c),a-o),s=Ea>c?"0":"1",l=Math.cos(o),f=Math.sin(o),h=Math.cos(a),g=Math.sin(a);return c>=xs?n?"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"M0,"+n+"A"+n+","+n+" 0 1,0 0,"+-n+"A"+n+","+n+" 0 1,0 0,"+n+"Z":"M0,"+i+"A"+i+","+i+" 0 1,1 0,"+-i+"A"+i+","+i+" 0 1,1 0,"+i+"Z":n?"M"+i*l+","+i*f+"A"+i+","+i+" 0 "+s+",1 "+i*h+","+i*g+"L"+n*h+","+n*g+"A"+n+","+n+" 0 "+s+",0 "+n*l+","+n*f+"Z":"M"+i*l+","+i*f+"A"+i+","+i+" 0 "+s+",1 "+i*h+","+i*g+"L0,0"+"Z"}var t=wi,e=Si,r=ki,u=Ei;return n.innerRadius=function(e){return arguments.length?(t=vt(e),n):t},n.outerRadius=function(t){return arguments.length?(e=vt(t),n):e},n.startAngle=function(t){return arguments.length?(r=vt(t),n):r},n.endAngle=function(t){return arguments.length?(u=vt(t),n):u},n.centroid=function(){var n=(t.apply(this,arguments)+e.apply(this,arguments))/2,i=(r.apply(this,arguments)+u.apply(this,arguments))/2+ys;return[Math.cos(i)*n,Math.sin(i)*n]},n};var ys=-Ca,xs=Aa-Na;Bo.svg.line=function(){return Ai(dt)};var Ms=Bo.map({linear:Ci,"linear-closed":Ni,step:Li,"step-before":Ti,"step-after":qi,basis:ji,"basis-open":Hi,"basis-closed":Fi,bundle:Oi,cardinal:Di,"cardinal-open":zi,"cardinal-closed":Ri,monotone:$i});Ms.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var _s=[0,2/3,1/3,0],bs=[0,1/3,2/3,0],ws=[0,1/6,2/3,1/6];Bo.svg.line.radial=function(){var n=Ai(Bi);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},Ti.reverse=qi,qi.reverse=Ti,Bo.svg.area=function(){return Wi(dt)},Bo.svg.area.radial=function(){var n=Wi(Bi);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},Bo.svg.chord=function(){function n(n,a){var c=t(this,i,n,a),s=t(this,o,n,a);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,s)?u(c.r,c.p1,c.r,c.p0):u(c.r,c.p1,s.r,s.p0)+r(s.r,s.p1,s.a1-s.a0)+u(s.r,s.p1,c.r,c.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=c.call(n,u,r)+ys,l=s.call(n,u,r)+ys;return{r:i,a0:o,a1:l,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(l),i*Math.sin(l)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Ea)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=De,o=Pe,a=Ji,c=ki,s=Ei;return n.radius=function(t){return arguments.length?(a=vt(t),n):a},n.source=function(t){return arguments.length?(i=vt(t),n):i},n.target=function(t){return arguments.length?(o=vt(t),n):o},n.startAngle=function(t){return arguments.length?(c=vt(t),n):c},n.endAngle=function(t){return arguments.length?(s=vt(t),n):s},n},Bo.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,c=[i,{x:i.x,y:a},{x:o.x,y:a},o];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var t=De,e=Pe,r=Gi;return n.source=function(e){return arguments.length?(t=vt(e),n):t},n.target=function(t){return arguments.length?(e=vt(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},Bo.svg.diagonal.radial=function(){var n=Bo.svg.diagonal(),t=Gi,e=n.projection;return n.projection=function(n){return arguments.length?e(Ki(t=n)):t},n},Bo.svg.symbol=function(){function n(n,r){return(Ss.get(t.call(this,n,r))||to)(e.call(this,n,r))}var t=no,e=Qi;return n.type=function(e){return arguments.length?(t=vt(e),n):t},n.size=function(t){return arguments.length?(e=vt(t),n):e},n};var Ss=Bo.map({circle:to,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Cs)),e=t*Cs;return"M0,"+-t+"L"+e+",0"+" 0,"+t+" "+-e+",0"+"Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z" +},"triangle-down":function(n){var t=Math.sqrt(n/As),e=t*As/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/As),e=t*As/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});Bo.svg.symbolTypes=Ss.keys();var ks,Es,As=Math.sqrt(3),Cs=Math.tan(30*Ta),Ns=[],Ls=0;Ns.call=ya.call,Ns.empty=ya.empty,Ns.node=ya.node,Ns.size=ya.size,Bo.transition=function(n){return arguments.length?ks?n.transition():n:_a.transition()},Bo.transition.prototype=Ns,Ns.select=function(n){var t,e,r,u=this.id,i=[];n=v(n);for(var o=-1,a=this.length;++oi;i++){u.push(t=[]);for(var e=this[i],a=0,c=e.length;c>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return eo(u,this.id)},Ns.tween=function(n,t){var e=this.id;return arguments.length<2?this.node().__transition__[e].tween.get(n):N(this,null==t?function(t){t.__transition__[e].tween.remove(n)}:function(r){r.__transition__[e].tween.set(n,t)})},Ns.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?eu:zr,a=Bo.ns.qualify(n);return ro(this,"attr."+n,t,a.local?i:u)},Ns.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=Bo.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Ns.style=function(n,t,e){function r(){this.style.removeProperty(n)}function u(t){return null==t?r:(t+="",function(){var r,u=Qo.getComputedStyle(this,null).getPropertyValue(n);return u!==t&&(r=zr(u,t),function(t){this.style.setProperty(n,r(t),e)})})}var i=arguments.length;if(3>i){if("string"!=typeof n){2>i&&(t="");for(e in n)this.style(e,n[e],t);return this}e=""}return ro(this,"style."+n,t,u)},Ns.styleTween=function(n,t,e){function r(r,u){var i=t.call(this,r,u,Qo.getComputedStyle(this,null).getPropertyValue(n));return i&&function(t){this.style.setProperty(n,i(t),e)}}return arguments.length<3&&(e=""),this.tween("style."+n,r)},Ns.text=function(n){return ro(this,"text",n,uo)},Ns.remove=function(){return this.each("end.transition",function(){var n;this.__transition__.count<2&&(n=this.parentNode)&&n.removeChild(this)})},Ns.ease=function(n){var t=this.id;return arguments.length<1?this.node().__transition__[t].ease:("function"!=typeof n&&(n=Bo.ease.apply(Bo,arguments)),N(this,function(e){e.__transition__[t].ease=n}))},Ns.delay=function(n){var t=this.id;return N(this,"function"==typeof n?function(e,r,u){e.__transition__[t].delay=+n.call(e,e.__data__,r,u)}:(n=+n,function(e){e.__transition__[t].delay=n}))},Ns.duration=function(n){var t=this.id;return N(this,"function"==typeof n?function(e,r,u){e.__transition__[t].duration=Math.max(1,n.call(e,e.__data__,r,u))}:(n=Math.max(1,n),function(e){e.__transition__[t].duration=n}))},Ns.each=function(n,t){var e=this.id;if(arguments.length<2){var r=Es,u=ks;ks=e,N(this,function(t,r,u){Es=t.__transition__[e],n.call(t,t.__data__,r,u)}),Es=r,ks=u}else N(this,function(r){var u=r.__transition__[e];(u.event||(u.event=Bo.dispatch("start","end"))).on(n,t)});return this},Ns.transition=function(){for(var n,t,e,r,u=this.id,i=++Ls,o=[],a=0,c=this.length;c>a;a++){o.push(n=[]);for(var t=this[a],s=0,l=t.length;l>s;s++)(e=t[s])&&(r=Object.create(e.__transition__[u]),r.delay+=r.duration,io(e,s,i,r)),n.push(e)}return eo(o,i)},Bo.svg.axis=function(){function n(n){n.each(function(){var n,s=Bo.select(this),l=this.__chart__||e,f=this.__chart__=e.copy(),h=null==c?f.ticks?f.ticks.apply(f,a):f.domain():c,g=null==t?f.tickFormat?f.tickFormat.apply(f,a):dt:t,p=s.selectAll(".tick").data(h,f),v=p.enter().insert("g",".domain").attr("class","tick").style("opacity",Na),d=Bo.transition(p.exit()).style("opacity",Na).remove(),m=Bo.transition(p).style("opacity",1),y=ei(f),x=s.selectAll(".domain").data([0]),M=(x.enter().append("path").attr("class","domain"),Bo.transition(x));v.append("line"),v.append("text");var _=v.select("line"),b=m.select("line"),w=p.select("text").text(g),S=v.select("text"),k=m.select("text");switch(r){case"bottom":n=oo,_.attr("y2",u),S.attr("y",Math.max(u,0)+o),b.attr("x2",0).attr("y2",u),k.attr("x",0).attr("y",Math.max(u,0)+o),w.attr("dy",".71em").style("text-anchor","middle"),M.attr("d","M"+y[0]+","+i+"V0H"+y[1]+"V"+i);break;case"top":n=oo,_.attr("y2",-u),S.attr("y",-(Math.max(u,0)+o)),b.attr("x2",0).attr("y2",-u),k.attr("x",0).attr("y",-(Math.max(u,0)+o)),w.attr("dy","0em").style("text-anchor","middle"),M.attr("d","M"+y[0]+","+-i+"V0H"+y[1]+"V"+-i);break;case"left":n=ao,_.attr("x2",-u),S.attr("x",-(Math.max(u,0)+o)),b.attr("x2",-u).attr("y2",0),k.attr("x",-(Math.max(u,0)+o)).attr("y",0),w.attr("dy",".32em").style("text-anchor","end"),M.attr("d","M"+-i+","+y[0]+"H0V"+y[1]+"H"+-i);break;case"right":n=ao,_.attr("x2",u),S.attr("x",Math.max(u,0)+o),b.attr("x2",u).attr("y2",0),k.attr("x",Math.max(u,0)+o).attr("y",0),w.attr("dy",".32em").style("text-anchor","start"),M.attr("d","M"+i+","+y[0]+"H0V"+y[1]+"H"+i)}if(f.rangeBand){var E=f,A=E.rangeBand()/2;l=f=function(n){return E(n)+A}}else l.rangeBand?l=f:d.call(n,f);v.call(n,l),m.call(n,f)})}var t,e=Bo.scale.linear(),r=Ts,u=6,i=6,o=3,a=[10],c=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in qs?t+"":Ts,n):r},n.ticks=function(){return arguments.length?(a=arguments,n):a},n.tickValues=function(t){return arguments.length?(c=t,n):c},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Ts="bottom",qs={top:1,right:1,bottom:1,left:1};Bo.svg.brush=function(){function n(i){i.each(function(){var i=Bo.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=i.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),i.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=i.selectAll(".resize").data(d,dt);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return zs[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var l,f=Bo.transition(i),h=Bo.transition(o);c&&(l=ei(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),e(f)),s&&(l=ei(s),h.attr("y",l[0]).attr("height",l[1]-l[0]),r(f)),t(f)})}function t(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+l[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function e(n){n.select(".extent").attr("x",l[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",l[1]-l[0])}function r(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function u(){function u(){32==Bo.event.keyCode&&(C||(x=null,L[0]-=l[1],L[1]-=h[1],C=2),f())}function g(){32==Bo.event.keyCode&&2==C&&(L[0]+=l[1],L[1]+=h[1],C=0,f())}function d(){var n=Bo.mouse(_),u=!1;M&&(n[0]+=M[0],n[1]+=M[1]),C||(Bo.event.altKey?(x||(x=[(l[0]+l[1])/2,(h[0]+h[1])/2]),L[0]=l[+(n[0]f?(u=r,r=f):u=f),g[0]!=r||g[1]!=u?(e?o=null:i=null,g[0]=r,g[1]=u,!0):void 0}function y(){d(),S.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),Bo.select("body").style("cursor",null),T.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),N(),w({type:"brushend"})}var x,M,_=this,b=Bo.select(Bo.event.target),w=a.of(_,arguments),S=Bo.select(_),k=b.datum(),E=!/^(n|s)$/.test(k)&&c,A=!/^(e|w)$/.test(k)&&s,C=b.classed("extent"),N=P(),L=Bo.mouse(_),T=Bo.select(Qo).on("keydown.brush",u).on("keyup.brush",g);if(Bo.event.changedTouches?T.on("touchmove.brush",d).on("touchend.brush",y):T.on("mousemove.brush",d).on("mouseup.brush",y),S.interrupt().selectAll("*").interrupt(),C)L[0]=l[0]-L[0],L[1]=h[0]-L[1];else if(k){var q=+/w$/.test(k),z=+/^n/.test(k);M=[l[1-q]-L[0],h[1-z]-L[1]],L[0]=l[q],L[1]=h[z]}else Bo.event.altKey&&(x=L.slice());S.style("pointer-events","none").selectAll(".resize").style("display",null),Bo.select("body").style("cursor",b.style("cursor")),w({type:"brushstart"}),d()}var i,o,a=g(n,"brushstart","brush","brushend"),c=null,s=null,l=[0,0],h=[0,0],p=!0,v=!0,d=Rs[0];return n.event=function(n){n.each(function(){var n=a.of(this,arguments),t={x:l,y:h,i:i,j:o},e=this.__chart__||t;this.__chart__=t,ks?Bo.select(this).transition().each("start.brush",function(){i=e.i,o=e.j,l=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=Rr(l,t.x),r=Rr(h,t.y);return i=o=null,function(u){l=t.x=e(u),h=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){i=t.i,o=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,d=Rs[!c<<1|!s],n):c},n.y=function(t){return arguments.length?(s=t,d=Rs[!c<<1|!s],n):s},n.clamp=function(t){return arguments.length?(c&&s?(p=!!t[0],v=!!t[1]):c?p=!!t:s&&(v=!!t),n):c&&s?[p,v]:c?p:s?v:null},n.extent=function(t){var e,r,u,a,f;return arguments.length?(c&&(e=t[0],r=t[1],s&&(e=e[0],r=r[0]),i=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(f=e,e=r,r=f),(e!=l[0]||r!=l[1])&&(l=[e,r])),s&&(u=t[0],a=t[1],c&&(u=u[1],a=a[1]),o=[u,a],s.invert&&(u=s(u),a=s(a)),u>a&&(f=u,u=a,a=f),(u!=h[0]||a!=h[1])&&(h=[u,a])),n):(c&&(i?(e=i[0],r=i[1]):(e=l[0],r=l[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(f=e,e=r,r=f))),s&&(o?(u=o[0],a=o[1]):(u=h[0],a=h[1],s.invert&&(u=s.invert(u),a=s.invert(a)),u>a&&(f=u,u=a,a=f))),c&&s?[[e,u],[r,a]]:c?[e,r]:s&&[u,a])},n.clear=function(){return n.empty()||(l=[0,0],h=[0,0],i=o=null),n},n.empty=function(){return!!c&&l[0]==l[1]||!!s&&h[0]==h[1]},Bo.rebind(n,a,"on")};var zs={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Rs=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Ds=Bo.time={},Ps=Date,Us=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];co.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(){js.setUTCDate.apply(this._,arguments)},setDay:function(){js.setUTCDay.apply(this._,arguments)},setFullYear:function(){js.setUTCFullYear.apply(this._,arguments)},setHours:function(){js.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){js.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){js.setUTCMinutes.apply(this._,arguments)},setMonth:function(){js.setUTCMonth.apply(this._,arguments)},setSeconds:function(){js.setUTCSeconds.apply(this._,arguments)},setTime:function(){js.setTime.apply(this._,arguments)}};var js=Date.prototype,Hs="%a %b %e %X %Y",Fs="%m/%d/%Y",Os="%H:%M:%S",Ys=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],Is=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],Zs=["January","February","March","April","May","June","July","August","September","October","November","December"],Vs=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];Ds.year=so(function(n){return n=Ds.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),Ds.years=Ds.year.range,Ds.years.utc=Ds.year.utc.range,Ds.day=so(function(n){var t=new Ps(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),Ds.days=Ds.day.range,Ds.days.utc=Ds.day.utc.range,Ds.dayOfYear=function(n){var t=Ds.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},Us.forEach(function(n,t){n=n.toLowerCase(),t=7-t;var e=Ds[n]=so(function(n){return(n=Ds.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=Ds.year(n).getDay();return Math.floor((Ds.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});Ds[n+"s"]=e.range,Ds[n+"s"].utc=e.utc.range,Ds[n+"OfYear"]=function(n){var e=Ds.year(n).getDay();return Math.floor((Ds.dayOfYear(n)+(e+t)%7)/7)}}),Ds.week=Ds.sunday,Ds.weeks=Ds.sunday.range,Ds.weeks.utc=Ds.sunday.utc.range,Ds.weekOfYear=Ds.sundayOfYear,Ds.format=fo;var Xs=go(Ys),$s=po(Ys),Bs=go(Is),Ws=po(Is),Js=go(Zs),Gs=po(Zs),Ks=go(Vs),Qs=po(Vs),nl=/^%/,tl={"-":"",_:" ",0:"0"},el={a:function(n){return Is[n.getDay()]},A:function(n){return Ys[n.getDay()]},b:function(n){return Vs[n.getMonth()]},B:function(n){return Zs[n.getMonth()]},c:fo(Hs),d:function(n,t){return vo(n.getDate(),t,2)},e:function(n,t){return vo(n.getDate(),t,2)},H:function(n,t){return vo(n.getHours(),t,2)},I:function(n,t){return vo(n.getHours()%12||12,t,2)},j:function(n,t){return vo(1+Ds.dayOfYear(n),t,3)},L:function(n,t){return vo(n.getMilliseconds(),t,3)},m:function(n,t){return vo(n.getMonth()+1,t,2)},M:function(n,t){return vo(n.getMinutes(),t,2)},p:function(n){return n.getHours()>=12?"PM":"AM"},S:function(n,t){return vo(n.getSeconds(),t,2)},U:function(n,t){return vo(Ds.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return vo(Ds.mondayOfYear(n),t,2)},x:fo(Fs),X:fo(Os),y:function(n,t){return vo(n.getFullYear()%100,t,2)},Y:function(n,t){return vo(n.getFullYear()%1e4,t,4)},Z:Ho,"%":function(){return"%"}},rl={a:mo,A:yo,b:bo,B:wo,c:So,d:qo,e:qo,H:Ro,I:Ro,j:zo,L:Uo,m:To,M:Do,p:jo,S:Po,U:Mo,w:xo,W:_o,x:ko,X:Eo,y:Co,Y:Ao,Z:No,"%":Fo},ul=/^\s*\d+/,il=Bo.map({am:0,pm:1});fo.utc=Oo;var ol=Oo("%Y-%m-%dT%H:%M:%S.%LZ");fo.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?Yo:ol,Yo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},Yo.toString=ol.toString,Ds.second=so(function(n){return new Ps(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),Ds.seconds=Ds.second.range,Ds.seconds.utc=Ds.second.utc.range,Ds.minute=so(function(n){return new Ps(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),Ds.minutes=Ds.minute.range,Ds.minutes.utc=Ds.minute.utc.range,Ds.hour=so(function(n){var t=n.getTimezoneOffset()/60;return new Ps(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),Ds.hours=Ds.hour.range,Ds.hours.utc=Ds.hour.utc.range,Ds.month=so(function(n){return n=Ds.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),Ds.months=Ds.month.range,Ds.months.utc=Ds.month.utc.range;var al=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],cl=[[Ds.second,1],[Ds.second,5],[Ds.second,15],[Ds.second,30],[Ds.minute,1],[Ds.minute,5],[Ds.minute,15],[Ds.minute,30],[Ds.hour,1],[Ds.hour,3],[Ds.hour,6],[Ds.hour,12],[Ds.day,1],[Ds.day,2],[Ds.week,1],[Ds.month,1],[Ds.month,3],[Ds.year,1]],sl=[[fo("%Y"),Vt],[fo("%B"),function(n){return n.getMonth()}],[fo("%b %d"),function(n){return 1!=n.getDate()}],[fo("%a %d"),function(n){return n.getDay()&&1!=n.getDate()}],[fo("%I %p"),function(n){return n.getHours()}],[fo("%I:%M"),function(n){return n.getMinutes()}],[fo(":%S"),function(n){return n.getSeconds()}],[fo(".%L"),function(n){return n.getMilliseconds()}]],ll=Vo(sl);cl.year=Ds.year,Ds.scale=function(){return Io(Bo.scale.linear(),cl,ll)};var fl={range:function(n,t,e){return Bo.range(+n,+t,e).map(Zo)},floor:dt,ceil:dt},hl=cl.map(function(n){return[n[0].utc,n[1]]}),gl=[[Oo("%Y"),Vt],[Oo("%B"),function(n){return n.getUTCMonth()}],[Oo("%b %d"),function(n){return 1!=n.getUTCDate()}],[Oo("%a %d"),function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],[Oo("%I %p"),function(n){return n.getUTCHours()}],[Oo("%I:%M"),function(n){return n.getUTCMinutes()}],[Oo(":%S"),function(n){return n.getUTCSeconds()}],[Oo(".%L"),function(n){return n.getUTCMilliseconds()}]],pl=Vo(gl);return hl.year=Ds.year.utc,Ds.scale.utc=function(){return Io(Bo.scale.linear(),hl,pl)},Bo.text=mt(function(n){return n.responseText}),Bo.json=function(n,t){return yt(n,"application/json",Xo,t)},Bo.html=function(n,t){return yt(n,"text/html",$o,t)},Bo.xml=mt(function(n){return n.responseXML}),Bo}(); \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/.gitignore b/awx/ui/static/lib/novus-nvd3/.gitignore deleted file mode 100755 index 99eb693b6b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/.gitignore +++ /dev/null @@ -1,27 +0,0 @@ - -# Jekyll Files # -################ -_site - - -# Random Files # -################ -*.swp -*~ -*.log - - -# Private Test Data # -##################### -*REALDATA* - - -# OS generated files # -###################### -.DS_Store* -ehthumbs.db -Icon? -Thumbs.db -# nodejs packages # -###################### -node_modules diff --git a/awx/ui/static/lib/novus-nvd3/.jshintrc b/awx/ui/static/lib/novus-nvd3/.jshintrc deleted file mode 100755 index 66d7029b1c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/.jshintrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "asi": true -} diff --git a/awx/ui/static/lib/novus-nvd3/GruntFile.js b/awx/ui/static/lib/novus-nvd3/GruntFile.js deleted file mode 100755 index b6ed18aed2..0000000000 --- a/awx/ui/static/lib/novus-nvd3/GruntFile.js +++ /dev/null @@ -1,106 +0,0 @@ -module.exports = function(grunt) { - - //Project configuration. - grunt.initConfig({ - pkg: grunt.file.readJSON('package.json'), - concat: { - options: { - separator: '' - }, - dist: { - src: [ - 'src/intro.js', - 'src/core.js', - 'src/interactiveLayer.js', - 'src/tooltip.js', - 'src/utils.js', - 'src/models/axis.js', - 'src/models/historicalBar.js', - 'src/models/bullet.js', - 'src/models/bulletChart.js', - 'src/models/cumulativeLineChart.js', - 'src/models/discreteBar.js', - 'src/models/discreteBarChart.js', - 'src/models/distribution.js', - 'src/models/historicalBar.js', - 'src/models/historicalBarChart.js', - 'src/models/indentedTree.js', - 'src/models/legend.js', - 'src/models/line.js', - 'src/models/lineChart.js', - 'src/models/linePlusBarChart.js', - 'src/models/lineWithFocusChart.js', - 'src/models/linePlusBarWithFocusChart.js', - 'src/models/multiBar.js', - 'src/models/multiBarChart.js', - 'src/models/multiBarHorizontal.js', - 'src/models/multiBarHorizontalChart.js', - 'src/models/multiChart.js', - 'src/models/ohlcBar.js', - 'src/models/pie.js', - 'src/models/pieChart.js', - 'src/models/scatter.js', - 'src/models/scatterChart.js', - 'src/models/scatterPlusLineChart.js', - 'src/models/sparkline.js', - 'src/models/sparklinePlus.js', - 'src/models/stackedArea.js', - 'src/models/stackedAreaChart.js', - 'src/outro.js' - ], - dest: 'nv.d3.js' - } - }, - uglify: { - options: { - banner: '/*! <%= pkg.name %> - v<%= pkg.version %> - ' + - '<%= grunt.template.today("yyyy-mm-dd") %> */' - }, - js: { - files: { - 'nv.d3.min.js': ['nv.d3.js'] - } - } - }, - jshint: { - foo: { - src: "src/**/*.js" - }, - options: { - jshintrc: '.jshintrc' - } - }, - watch: { - js: { - files: ["src/**/*.js"], - tasks: ['concat'] - } - }, - copy: { - css: { - files: [ - { src: 'src/nv.d3.css', dest: 'nv.d3.css' } - ] - } - }, - cssmin: { - dist: { - files: { - 'nv.d3.min.css' : ['nv.d3.css'] - } - } - } - }); - - grunt.loadNpmTasks('grunt-contrib-watch'); - grunt.loadNpmTasks('grunt-contrib-concat'); - grunt.loadNpmTasks('grunt-contrib-jshint'); - grunt.loadNpmTasks('grunt-contrib-uglify'); - grunt.loadNpmTasks('grunt-contrib-copy'); - grunt.loadNpmTasks('grunt-contrib-cssmin'); - - grunt.registerTask('default', ['concat', 'copy']); - grunt.registerTask('production', ['concat', 'uglify', 'copy', 'cssmin']); - grunt.registerTask('release', ['production']); - grunt.registerTask('lint', ['jshint']); -}; diff --git a/awx/ui/static/lib/novus-nvd3/LICENSE.md b/awx/ui/static/lib/novus-nvd3/LICENSE.md deleted file mode 100755 index 82bfea0caa..0000000000 --- a/awx/ui/static/lib/novus-nvd3/LICENSE.md +++ /dev/null @@ -1,49 +0,0 @@ - -##nvd3.js License - -Copyright (c) 2011, 2012 [Novus Partners, Inc.][novus] - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. - -[novus]: https://www.novus.com/ - - - -##d3.js License - -Copyright (c) 2012, Michael Bostock -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. - -* The name Michael Bostock may not 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 MICHAEL BOSTOCK 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. diff --git a/awx/ui/static/lib/novus-nvd3/Makefile b/awx/ui/static/lib/novus-nvd3/Makefile deleted file mode 100755 index a234fed8bb..0000000000 --- a/awx/ui/static/lib/novus-nvd3/Makefile +++ /dev/null @@ -1,72 +0,0 @@ -JS_FILES = \ - src/intro.js \ - src/core.js \ - src/interactiveLayer.js \ - src/tooltip.js \ - src/utils.js \ - src/models/axis.js \ - src/models/bullet.js \ - src/models/bulletChart.js \ - src/models/cumulativeLineChart.js \ - src/models/discreteBar.js \ - src/models/discreteBarChart.js \ - src/models/distribution.js \ - src/models/historicalBar.js \ - src/models/historicalBarChart.js \ - src/models/indentedTree.js \ - src/models/legend.js \ - src/models/line.js \ - src/models/lineChart.js \ - src/models/linePlusBarChart.js \ - src/models/lineWithFocusChart.js \ - src/models/linePlusBarWithFocusChart.js \ - src/models/multiBar.js \ - src/models/multiBarChart.js \ - src/models/multiBarHorizontal.js \ - src/models/multiBarHorizontalChart.js \ - src/models/multiChart.js \ - src/models/ohlcBar.js \ - src/models/pie.js \ - src/models/pieChart.js \ - src/models/scatter.js \ - src/models/scatterChart.js \ - src/models/scatterPlusLineChart.js \ - src/models/sparkline.js \ - src/models/sparklinePlus.js \ - src/models/stackedArea.js \ - src/models/stackedAreaChart.js \ - src/outro.js -CSS_FILES = \ - src/nv.d3.css - -JS_COMPILER = \ - uglifyjs - -CSS_COMPILER = \ - cssmin - -all: nv.d3.js nv.d3.min.js nv.d3.css nv.d3.min.css -nv.d3.js: $(JS_FILES) -nv.d3.min.js: $(JS_FILES) -nv.d3.css: $(CSS_FILES) -nv.d3.min.css: $(CSS_FILES) - -nv.d3.js: Makefile - rm -f $@ - cat $(filter %.js,$^) >> $@ - -nv.d3.css: Makefile - rm -f $@ - cat $(filter %.css,$^) >> $@ - -%.min.js:: Makefile - rm -f $@ - $(JS_COMPILER) nv.d3.js >> $@ - -%.min.css:: Makefile - rm -f $@ - $(CSS_COMPILER) nv.d3.css >> $@ - - -clean: - rm -rf nv.d3*.js nv.d3*.css diff --git a/awx/ui/static/lib/novus-nvd3/README.md b/awx/ui/static/lib/novus-nvd3/README.md deleted file mode 100755 index a0de8ef987..0000000000 --- a/awx/ui/static/lib/novus-nvd3/README.md +++ /dev/null @@ -1,97 +0,0 @@ -# MAJOR REFACTOR - -As of mid April, 2014, NVD3 is undergoing a major internal refactoring. While we wanted to make it in such a way that it would be a perfectly backwards compatible minor version release, we cannot do so. There are a half-dozen side and corner cases in the current code base, that, while we could call them "bugs", are just poorly implemented features. Because of this, we are announcing heavy development on the 2.0 NVD3 line, which will bring a sane internal structure and numerous API and development enhancements. - -The code is on the branch at [refactor/2.0.0-dev](https://github.com/novus/nvd3/tree/refactor/2.0.0-dev). It is currently about 4/5ths functional, and we are working through finishing the tests for the last few parameters. The commonly used charts are there, and any outstanding or new pull requests will need to rebase and target that. Of course, if you want to implement some of those features, that would also be great! - -For more information on the refactored architecture and approach, please see the recent blog posts on [architecture](http://nvd3.org/blog/2014/03/architecture/) and [chart drawing lifecycle](http://nvd3.org/blog/2014/03/nvd3-chart-drawing-lifecycle/). - -For now, any users of NVD3 still get 1.1.15-beta. - -# NVD3 - v1.1.15-beta -## Release notes for version 1.1.15 beta -* Various fixes across the board - -## Overview -A reusable chart library for d3.js. - -NVD3 may change from its current state, but will always try to follow the style of d3.js. - -You can also check out the [examples page](http://nvd3.org/ghpages/examples.html). -**Note:** The examples on nvd3.org are outdated. For examples on how to use the latest NVD3, please checkout the **examples/** directory in the repository. - ---- - -# Current development focus - -- Getting documentation up. -- Unifying common API functions between charts. -- Bug fixes that come up. - ---- - -# Installation Instructions - -`d3.v3.js` is a dependency of `nv.d3.js`. Be sure to include in in your project, then: -Add a script tag to include `nv.d3.js` OR `nv.d3.min.js` in your project. -Also add a link to the `nv.d3.css` file. - -See wiki -> Documentation for more detail - ---- - -If one of [the existing models](https://github.com/novus/nvd3/tree/master/src/models) doesn't meet your needs, fork the project, implement the model and an example using it, send us a pull request, for consideration for inclusion in the project. - -We cannot honor all pull requests, but we will review all of them. - -Please do not aggregate pull requests. Aggregated pull requests are actually more difficult to review. - -We are currently changing our branch structure so that master will be gauranteed stable. In addition, there is now a "development" branch. This branch reflects the latest changes to NVD3 and is not necessarily stable. - ---- - -## Minifying your fork: - -### Using Make -The Makefile requires [UglifyJS](https://github.com/mishoo/UglifyJS) and [CSSMin](https://github.com/jbleuzen/node-cssmin) - -The easiest way to install UglifyJS and CSSMin is via npm. Run `npm install -g uglify-js cssmin`. After installing verify the setup by running `uglifyjs --version` and `cssmin --help`. - -Once you have the `uglifyjs` and `cssmin` commands available, running `make` from your -fork's root directory will rebuild both `nv.d3.js` and `nv.d3.min.js`. - - make # build nv.d3.js and nv.d3.css and minify - make nv.d3.js # Build nv.d3.js - make nv.d3.min.js # Minify nv.d3.js into nv.d3.min.js - make nv.d3.css # Build nv.d3.css - make nv.d3.min.css # Minify nv.d3.css into nv.d3.min.css - make clean # Delete nv.d3.*js and nv.d3.*css - - -*Without UglifyJS or CSSMin, you won't get the minified versions when running make.** - -### Using Grunt - -You can use grunt instead of makefile to build js file. See more about [grunt](http://gruntjs.com/). -***[Nodejs](http://nodejs.org/) must be installed before you can use grunt.*** -Run `npm install` in root dir to install grunt and it's dependencies. - -Then, you can use these commands: - - grunt # build nv.d3.js - grunt production # build nv.d3.js and nv.d3.min.js - grunt watch # watch file changes in src/, and rebuild nv.d3.js, it's very helpful when delevop NVD3 - grunt lint # run jshint on src/**/*.js - -**We ask that you DO NOT minify pull requests... -If you need to minify please build pull request in separate branch, and -merge and minify in your master. - -## Supported Browsers -NVD3 runs best on WebKit based browsers. - -* **Google Chrome: latest version (preferred)** -* **Opera 15+ (preferred)** -* Safari: latest version -* Firefox: latest version -* Internet Explorer: 9 and 10 diff --git a/awx/ui/static/lib/novus-nvd3/build.bat b/awx/ui/static/lib/novus-nvd3/build.bat deleted file mode 100755 index de98b5a346..0000000000 --- a/awx/ui/static/lib/novus-nvd3/build.bat +++ /dev/null @@ -1,6 +0,0 @@ -@echo off -copy src\intro.js /B + src\core.js /B + src\tooltip.js /B temp1.js /B -copy src\models\*.js /B temp2.js /B -copy temp1.js /B + temp2.js /B + src\outro.js /B nv.d3.js /B -del temp1.js -del temp2.js diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/bar.html b/awx/ui/static/lib/novus-nvd3/deprecated/bar.html deleted file mode 100755 index f25e177bd1..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/bar.html +++ /dev/null @@ -1,198 +0,0 @@ - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/bar.js b/awx/ui/static/lib/novus-nvd3/deprecated/bar.js deleted file mode 100755 index 3aa38e76a5..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/bar.js +++ /dev/null @@ -1,250 +0,0 @@ - -nv.models.bar = function() { - var margin = {top: 20, right: 10, bottom: 80, left: 60}, - width = 960, - height = 500, - animate = 500, - label ='label', - rotatedLabel = true, - showLabels = true, - id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one - color = d3.scale.category20(), - field ='y', - title = ''; - - var x = d3.scale.ordinal(), - y = d3.scale.linear(), - xAxis = d3.svg.axis().scale(x).orient('bottom'), - yAxis = d3.svg.axis().scale(y).orient('left'), - dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'tooltipShow', 'tooltipHide'); - - - function chart(selection) { - selection.each(function(data) { - x .domain(data.map(function(d,i) { return d[label]; })) - .rangeRoundBands([0, width - margin.left - margin.right], .1); - - - var min = d3.min(data, function(d) { return d[field] }); - var max = d3.max(data, function(d) { return d[field] }); - var x0 = Math.max(-min, max); - var x1 = -x0; - - // If we have no negative values, then lets stack this with just positive bars - if (min >= 0) x1 = 0; - - y .domain([x1, x0]) - .range([height - margin.top - margin.bottom, 0]) - .nice(); - - xAxis.ticks( width / 100 ); - yAxis.ticks( height / 36 ).tickSize(-(width - margin.right - margin.left), 0); - - var parent = d3.select(this) - .on("click", function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - var wrap = parent.selectAll('g.wrap').data([data]); - var gEnter = wrap.enter(); - gEnter.append("text") - .attr("class", "title") - .attr("dy", ".91em") - .attr("text-anchor", "start") - .text(title); - gEnter = gEnter.append('g').attr('class', 'nvd3 wrap').attr('id','wrap-'+id).append('g'); - - - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'bars'); - - - wrap.attr('width', width) - .attr('height', height); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var bars = wrap.select('.bars').selectAll('.bar') - .data(function(d) { return d; }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('svg:rect') - .attr('class', function(d) { return d[field] < 0 ? "bar negative" : "bar positive"}) - .attr("fill", function(d, i) { return color(i); }) - .attr('x', 0 ) - .on('mouseover', function(d,i){ - d3.select(this).classed('hover', true); - dispatch.tooltipShow({ - label: d[label], - value: d[field], - data: d, - index: i, - // TODO: Calculate the center to the bar - pos: [d3.event.pageX, d3.event.pageY], - id: id - }); - - }) - .on('mouseout', function(d,i){ - d3.select(this).classed('hover', false); - dispatch.tooltipHide({ - label: d[label], - value: d[field], - data: d, - index: i, - id: id - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - label: d[label], - value: d[field], - data: d, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - label: d[label], - value: d[field], - data: d, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - - bars - .attr('class', function(d) { return d[field] < 0 ? "bar negative" : "bar positive"}) - .attr('transform', function(d,i) { return 'translate(' + x(d[label]) + ',0)'; }) - .attr('width', x.rangeBand ) - .order() - .transition() - .duration(animate) - .attr('y', function(d) { return y(Math.max(0, d[field])); }) - .attr('height', function(d) { return Math.abs(y(d[field]) - y(0)); }); - - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .call(xAxis); - - - if (rotatedLabel) { - g.select('.x.axis').selectAll('text').attr('text-anchor','start').attr("transform", function(d) { - return "rotate(35)translate(" + this.getBBox().height/2 + "," + '0' + ")"; - }); - } - if (!showLabels) { - g.select('.x.axis').selectAll('text').attr('fill', 'rgba(0,0,0,0)'); - g.select('.x.axis').selectAll('line').attr('style', 'opacity: 0'); - } - /*else { - g.select('.x.axis').selectAll('text').attr('fill', 'rgba(0,0,0,1)'); - g.select('.x.axis').selectAll('line').attr('style', 'opacity: 1'); - }*/ - - - - g.select('.y.axis') - .call(yAxis); - }); - - return chart; - } - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - if (margin.left + margin.right + 20 > _) - width = margin.left + margin.right + 20; // Min width - else - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - if (margin.top + margin.bottom + 20 > _) - height = margin.top + margin.bottom + 20; // Min height - else - height = _; - return chart; - }; - - chart.animate = function(_) { - if (!arguments.length) return animate; - animate = _; - return chart; - }; - - chart.labelField = function(_) { - if (!arguments.length) return (label); - label = _; - return chart; - }; - - chart.dataField = function(_) { - if (!arguments.length) return (field); - field = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.rotatedLabel = function(_) { - if (!arguments.length) return rotatedLabel; - rotatedLabel = _; - return chart; - }; - - chart.showLabels = function(_) { - if (!arguments.length) return (showLabels); - showLabels = _; - return chart; - }; - - chart.title = function(_) { - if (!arguments.length) return (title); - title = _; - return chart; - }; - - chart.xaxis = {}; - // Expose the x-axis' tickFormat method. - d3.rebind(chart.xaxis, xAxis, 'tickFormat'); - - chart.yaxis = {}; - // Expose the y-axis' tickFormat method. - d3.rebind(chart.yaxis, yAxis, 'tickFormat'); - - chart.dispatch = dispatch; - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/charts/cumulativeLineChart.js b/awx/ui/static/lib/novus-nvd3/deprecated/charts/cumulativeLineChart.js deleted file mode 100755 index 43022ccb81..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/charts/cumulativeLineChart.js +++ /dev/null @@ -1,174 +0,0 @@ - -// This technique works AS IS for month end data points -// In fact, this works for any series where each value is evenly spaced, -// and every series starts at the same value and is 1 to 1 -// In other words, values at the same index, need to have the same x value -// for all series -// -// TODO: now that tooltips don't use jquery, could likely get rid of the charts -// collection by simply adding some optional functionality to the model -nv.charts.cumulativeLineChartDaily = function() { - var selector = null, - data = [], - duration = 500, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }; - - - var graph = nv.models.cumulativeLine() - .x(function(d,i) { return i }) - .color(d3.scale.category10().range()), - showTooltip = function(e) { - var offsetElement = document.getElementById(selector.substr(1)), - left = e.pos[0] + offsetElement.offsetLeft, - top = e.pos[1] + offsetElement.offsetTop, - formatX = graph.xAxis.tickFormat(), - formatY = graph.yAxis.tickFormat(), - x = formatX(graph.x()(e, e.pointIndex)), - //x = formatX(graph.x()(e.point)), - y = formatY(graph.y()(e.point)), - content = tooltip(e.series.key, x, y, e, graph); - - nv.tooltip.show([left, top], content); - }; - - //setting component defaults - //graph.xAxis.tickFormat(d3.format(',r')); - graph.xAxis.tickFormat(function(d) { - //return d3.time.format('%x')(new Date(d)) - return d3.time.format('%x')(new Date(data[0].values[d].x)) - }); - - //graph.yAxis.tickFormat(d3.format(',.2f')); - graph.yAxis.tickFormat(d3.format(',.2%')); - - - //TODO: consider a method more similar to how the models are built - function chart() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); //consider using transition chaining like in the models - - return chart; - } - - - // This should always only be called once, then update should be used after, - // in which case should consider the 'd3 way' and merge this with update, - // but simply do this on enter... will try another example the d3 way - chart.build = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - nv.addGraph({ - generate: function() { - var container = d3.select(selector), - width = function() { return parseInt(container.style('width')) }, - height = function() { return parseInt(container.style('height')) }, - svg = container.append('svg'); - - graph - .width(width) - .height(height); - - svg - .attr('width', width()) - .attr('height', height()) - .datum(data) - .transition().duration(duration).call(graph); - - return graph; - }, - callback: function(graph) { - graph.dispatch.on('tooltipShow', showTooltip); - graph.dispatch.on('tooltipHide', nv.tooltip.cleanup); - - //TODO: fix issue of multiple graphs failing on resize - //TODO: create resize queue and have nv core handle resize instead of binding all to window resize - window.onresize = - function() { - // now that width and height are functions, should be automatic..of course you can always override them - d3.select(selector + ' svg') - .attr('width', graph.width()()) //need to set SVG dimensions, chart is not aware of the SVG component - .attr('height', graph.height()()) - .call(graph); - }; - } - }); - - return chart; - }; - - - /* - // moved to chart() - chart.update = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); - - return chart; - }; - */ - - chart.data = function(_) { - if (!arguments.length) return data; - data = _; - return chart; - }; - - chart.selector = function(_) { - if (!arguments.length) return selector; - selector = _; - return chart; - }; - - chart.duration = function(_) { - if (!arguments.length) return duration; - duration = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.xTickFormat = function(_) { - if (!arguments.length) return graph.xAxis.tickFormat(); - graph.xAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return graph.yAxis.tickFormat(); - graph.yAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.xAxisLabel = function(_) { - if (!arguments.length) return graph.xAxis.axisLabel(); - graph.xAxis.axisLabel(_); - return chart; - }; - - chart.yAxisLabel = function(_) { - if (!arguments.length) return graph.yAxis.axisLabel(); - graph.yAxis.axisLabel(_); - return chart; - }; - - d3.rebind(chart, graph, 'x', 'y'); - - chart.graph = graph; // Give direct access for getter/setters, and dispatchers - - return chart; -}; - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/charts/discreteBarChart.js b/awx/ui/static/lib/novus-nvd3/deprecated/charts/discreteBarChart.js deleted file mode 100755 index db22ca34ab..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/charts/discreteBarChart.js +++ /dev/null @@ -1,157 +0,0 @@ - -nv.charts.discreteBar = function() { - var selector = null, - data = [], - duration = 500, - tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' - }; - - - var graph = nv.models.discreteBarWithAxes(), - showTooltip = function(e) { - var offsetElement = document.getElementById(selector.substr(1)), - left = e.pos[0] + offsetElement.offsetLeft, - top = e.pos[1] + offsetElement.offsetTop, - formatY = graph.yAxis.tickFormat(), //Assumes using same format as axis, can customize to show higher precision, etc. - formatX = graph.xAxis.tickFormat(), - x = formatX(graph.x()(e.point)), - y = formatY(graph.y()(e.point)), - content = tooltip(e.series.key, x, y, e, graph); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); - }; - - //setting component defaults - graph.xAxis.tickFormat(function(d) { return d }); - graph.yAxis.tickFormat(d3.format(',.f')); - - - //TODO: consider a method more similar to how the models are built - function chart() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); //consider using transition chaining like in the models - - return chart; - } - - - // This should always only be called once, then update should be used after, - // in which case should consider the 'd3 way' and merge this with update, - // but simply do this on enter... should try anoter example that way - chart.build = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - nv.addGraph({ - generate: function() { - var container = d3.select(selector), - width = function() { return parseInt(container.style('width')) }, - height = function() { return parseInt(container.style('height')) }, - svg = container.append('svg'); - - graph - .width(width) - .height(height); - - svg - .attr('width', width()) - .attr('height', height()) - .datum(data) - .transition().duration(duration).call(graph); - - return graph; - }, - callback: function(graph) { - graph.dispatch.on('tooltipShow', showTooltip); - graph.dispatch.on('tooltipHide', nv.tooltip.cleanup); - - //TODO: create resize queue and have nv core handle resize instead of binding all to window resize - nv.utils.windowResize( - function() { - // now that width and height are functions, should be automatic..of course you can always override them - d3.select(selector + ' svg') - .attr('width', graph.width()()) //need to set SVG dimensions, chart is not aware of the SVG component - .attr('height', graph.height()()) - .transition().duration(duration).call(graph); - //.call(graph); - } - ); - } - }); - - return chart; - }; - - - /* - // moved to chart() - chart.update = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); - - return chart; - }; - */ - - chart.data = function(_) { - if (!arguments.length) return data; - data = _; - return chart; - }; - - chart.selector = function(_) { - if (!arguments.length) return selector; - selector = _; - return chart; - }; - - chart.duration = function(_) { - if (!arguments.length) return duration; - duration = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.xTickFormat = function(_) { - if (!arguments.length) return graph.xAxis.tickFormat(); - graph.xAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return graph.yAxis.tickFormat(); - graph.yAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.xAxisLabel = function(_) { - if (!arguments.length) return graph.xAxis.axisLabel(); - graph.xAxis.axisLabel(_); - return chart; - }; - - chart.yAxisLabel = function(_) { - if (!arguments.length) return graph.yAxis.axisLabel(); - graph.yAxis.axisLabel(_); - return chart; - }; - - d3.rebind(chart, graph, 'x', 'y', 'staggerLabels'); - - chart.graph = graph; // Give direct access for getter/setters, and dispatchers - - return chart; -}; - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/charts/lineChart.js b/awx/ui/static/lib/novus-nvd3/deprecated/charts/lineChart.js deleted file mode 100755 index 35da87e495..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/charts/lineChart.js +++ /dev/null @@ -1,159 +0,0 @@ - -// This is an attempt to make an extremely easy to use chart that is ready to go, -// basically the chart models with the extra glue... Queuing, tooltips, automatic resize, etc. -// I may make these more specific, like 'time series line with month end data points', etc. -// or may make yet another layer of abstraction... common settings. -nv.charts.line = function() { - var selector = null, - data = [], - duration = 500, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }; - - - var graph = nv.models.lineWithLegend(), - showTooltip = function(e) { - var offsetElement = document.getElementById(selector.substr(1)), - left = e.pos[0] + offsetElement.offsetLeft, - top = e.pos[1] + offsetElement.offsetTop, - formatX = graph.xAxis.tickFormat(), - formatY = graph.yAxis.tickFormat(), - x = formatX(graph.x()(e.point)), - y = formatY(graph.y()(e.point)), - content = tooltip(e.series.key, x, y, e, graph); - - nv.tooltip.show([left, top], content); - }; - - //setting component defaults - graph.xAxis.tickFormat(d3.format(',r')); - graph.yAxis.tickFormat(d3.format(',.2f')); - - - //TODO: consider a method more similar to how the models are built - function chart() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); //consider using transition chaining like in the models - - return chart; - } - - - // This should always only be called once, then update should be used after, - // in which case should consider the 'd3 way' and merge this with update, - // but simply do this on enter... should try anoter example that way - chart.build = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - nv.addGraph({ - generate: function() { - var container = d3.select(selector), - width = function() { return parseInt(container.style('width')) }, - height = function() { return parseInt(container.style('height')) }, - svg = container.append('svg'); - - graph - .width(width) - .height(height); - - svg - .attr('width', width()) - .attr('height', height()) - .datum(data) - .transition().duration(duration).call(graph); - - return graph; - }, - callback: function(graph) { - graph.dispatch.on('tooltipShow', showTooltip); - graph.dispatch.on('tooltipHide', nv.tooltip.cleanup); - - //TODO: create resize queue and have nv core handle resize instead of binding all to window resize - window.onresize = - function() { - // now that width and height are functions, should be automatic..of course you can always override them - d3.select(selector + ' svg') - .attr('width', graph.width()()) //need to set SVG dimensions, chart is not aware of the SVG component - .attr('height', graph.height()()) - .call(graph); - }; - } - }); - - return chart; - }; - - - /* - // moved to chart() - chart.update = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); - - return chart; - }; - */ - - chart.data = function(_) { - if (!arguments.length) return data; - data = _; - return chart; - }; - - chart.selector = function(_) { - if (!arguments.length) return selector; - selector = _; - return chart; - }; - - chart.duration = function(_) { - if (!arguments.length) return duration; - duration = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.xTickFormat = function(_) { - if (!arguments.length) return graph.xAxis.tickFormat(); - graph.xAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return graph.yAxis.tickFormat(); - graph.yAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.xAxisLabel = function(_) { - if (!arguments.length) return graph.xAxis.axisLabel(); - graph.xAxis.axisLabel(_); - return chart; - }; - - chart.yAxisLabel = function(_) { - if (!arguments.length) return graph.yAxis.axisLabel(); - graph.yAxis.axisLabel(_); - return chart; - }; - - d3.rebind(chart, graph, 'x', 'y'); - - chart.graph = graph; // Give direct access for getter/setters, and dispatchers - - return chart; -}; - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/charts/lineChartDaily.js b/awx/ui/static/lib/novus-nvd3/deprecated/charts/lineChartDaily.js deleted file mode 100755 index 592a285117..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/charts/lineChartDaily.js +++ /dev/null @@ -1,168 +0,0 @@ - -// This is an attempt to make an extremely easy to use chart that is ready to go, -// basically the chart models with the extra glue... Queuing, tooltips, automatic resize, etc. -// I may make these more specific, like 'time series line with month end data points', etc. -// or may make yet another layer of abstraction... common settings. -nv.charts.lineChartDaily = function() { - var selector = null, - data = [], - duration = 500, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }; - - - var graph = nv.models.lineWithLegend() - .x(function(d,i) { return i }), - showTooltip = function(e) { - var offsetElement = document.getElementById(selector.substr(1)), - left = e.pos[0] + offsetElement.offsetLeft, - top = e.pos[1] + offsetElement.offsetTop, - formatX = graph.xAxis.tickFormat(), - formatY = graph.yAxis.tickFormat(), - x = formatX(graph.x()(e, e.pointIndex)), - //x = formatX(graph.x()(e.point)), - y = formatY(graph.y()(e.point)), - content = tooltip(e.series.key, x, y, e, graph); - - nv.tooltip.show([left, top], content); - }; - - //setting component defaults - //graph.xAxis.tickFormat(d3.format(',r')); - graph.xAxis.tickFormat(function(d) { - //return d3.time.format('%x')(new Date(d)) - //log(d, data[0].values[d]); - return d3.time.format('%x')(new Date(data[0].values[d].x)) - }); - - //graph.yAxis.tickFormat(d3.format(',.2f')); - graph.yAxis.tickFormat(d3.format(',.2%')); - - - //TODO: consider a method more similar to how the models are built - function chart() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); //consider using transition chaining like in the models - - return chart; - } - - - // This should always only be called once, then update should be used after, - // in which case should consider the 'd3 way' and merge this with update, - // but simply do this on enter... should try anoter example that way - chart.build = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - nv.addGraph({ - generate: function() { - var container = d3.select(selector), - width = function() { return parseInt(container.style('width')) }, - height = function() { return parseInt(container.style('height')) }, - svg = container.append('svg'); - - graph - .width(width) - .height(height); - - svg - .attr('width', width()) - .attr('height', height()) - .datum(data) - .transition().duration(duration).call(graph); - - return graph; - }, - callback: function(graph) { - graph.dispatch.on('tooltipShow', showTooltip); - graph.dispatch.on('tooltipHide', nv.tooltip.cleanup); - - //TODO: create resize queue and have nv core handle resize instead of binding all to window resize - window.onresize = - function() { - // now that width and height are functions, should be automatic..of course you can always override them - d3.select(selector + ' svg') - .attr('width', graph.width()()) //need to set SVG dimensions, chart is not aware of the SVG component - .attr('height', graph.height()()) - .call(graph); - }; - } - }); - - return chart; - }; - - - /* - // moved to chart() - chart.update = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); - - return chart; - }; - */ - - chart.data = function(_) { - if (!arguments.length) return data; - data = _; - return chart; - }; - - chart.selector = function(_) { - if (!arguments.length) return selector; - selector = _; - return chart; - }; - - chart.duration = function(_) { - if (!arguments.length) return duration; - duration = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.xTickFormat = function(_) { - if (!arguments.length) return graph.xAxis.tickFormat(); - graph.xAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return graph.yAxis.tickFormat(); - graph.yAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.xAxisLabel = function(_) { - if (!arguments.length) return graph.xAxis.axisLabel(); - graph.xAxis.axisLabel(_); - return chart; - }; - - chart.yAxisLabel = function(_) { - if (!arguments.length) return graph.yAxis.axisLabel(); - graph.yAxis.axisLabel(_); - return chart; - }; - - d3.rebind(chart, graph, 'x', 'y'); - - chart.graph = graph; // Give direct access for getter/setters, and dispatchers - - return chart; -}; - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/charts/stackedAreaChart.js b/awx/ui/static/lib/novus-nvd3/deprecated/charts/stackedAreaChart.js deleted file mode 100755 index 8444bbbd77..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/charts/stackedAreaChart.js +++ /dev/null @@ -1,177 +0,0 @@ - -/*** - * This chart treats the X position as the INDEX, not the value - * Each series at the same index MUST be the same x value for a valid representation - * This is needed specifically for daily data where the gap between Friday and Monday - * should be equal to the gap from Monday to Tuesday. (and of course, holidays can be - * omitted without issue, as long as ALL series omit the same days). - * An intentional side effect is that ALL ticks will land on actual data points, - * so this visualization can also be used for Month End data points, showing Month End - * ticks on the X axis - ***/ - -nv.charts.stackedAreaChart = function() { - var selector = null, - data = [], - duration = 500, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }; - - - var graph = nv.models.stackedAreaWithLegend() - .x(function(d,i) { return i }), - showTooltip = function(e) { - var offsetElement = document.getElementById(selector.substr(1)), - left = e.pos[0] + offsetElement.offsetLeft, - top = e.pos[1] + offsetElement.offsetTop, - formatX = graph.xAxis.tickFormat(), - formatY = graph.yAxis.tickFormat(), - x = formatX(graph.x()(e, e.pointIndex)), - //x = formatX(graph.x()(e.point)), - y = formatY(graph.y()(e.point)), - content = tooltip(e.series.key, x, y, e, graph); - - nv.tooltip.show([left, top], content); - }; - - //setting component defaults - //graph.xAxis.tickFormat(d3.format(',r')); - graph.xAxis.tickFormat(function(d) { - //return d3.time.format('%x')(new Date(d)) - //log(d, data[0].values[d]); - return d3.time.format('%x')(new Date(data[0].values[d].x)) - }); - - //graph.yAxis.tickFormat(d3.format(',.2f')); - graph.yAxis.tickFormat(d3.format(',.2%')); - - - //TODO: consider a method more similar to how the models are built - function chart() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration) - .call(graph); //consider using transition chaining like in the models - - return chart; - } - - - // This should always only be called once, then update should be used after, - // in which case should consider the 'd3 way' and merge this with update, - // but simply do this on enter... should try anoter example that way - chart.build = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - nv.addGraph({ - generate: function() { - var container = d3.select(selector), - width = function() { return parseInt(container.style('width')) }, - height = function() { return parseInt(container.style('height')) }, - svg = container.append('svg'); - - graph - .width(width) - .height(height); - - svg - .attr('width', width()) - .attr('height', height()) - .datum(data) - .transition().duration(duration) - .call(graph); - - return graph; - }, - callback: function(graph) { - graph.dispatch.on('tooltipShow', showTooltip); - graph.dispatch.on('tooltipHide', nv.tooltip.cleanup); - - //TODO: create resize queue and have nv core handle resize instead of binding all to window resize - window.onresize = - function() { - // now that width and height are functions, should be automatic..of course you can always override them - d3.select(selector + ' svg') - .attr('width', graph.width()()) //need to set SVG dimensions, chart is not aware of the SVG component - .attr('height', graph.height()()) - .call(graph); - }; - } - }); - - return chart; - }; - - - /* - // moved to chart() - chart.update = function() { - if (!selector || !data.length) return chart; //do nothing if you have nothing to work with - - d3.select(selector).select('svg') - .datum(data) - .transition().duration(duration).call(graph); - - return chart; - }; - */ - - chart.data = function(_) { - if (!arguments.length) return data; - data = _; - return chart; - }; - - chart.selector = function(_) { - if (!arguments.length) return selector; - selector = _; - return chart; - }; - - chart.duration = function(_) { - if (!arguments.length) return duration; - duration = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.xTickFormat = function(_) { - if (!arguments.length) return graph.xAxis.tickFormat(); - graph.xAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return graph.yAxis.tickFormat(); - graph.yAxis.tickFormat(typeof _ === 'function' ? _ : d3.format(_)); - return chart; - }; - - chart.xAxisLabel = function(_) { - if (!arguments.length) return graph.xAxis.axisLabel(); - graph.xAxis.axisLabel(_); - return chart; - }; - - chart.yAxisLabel = function(_) { - if (!arguments.length) return graph.yAxis.axisLabel(); - graph.yAxis.axisLabel(_); - return chart; - }; - - d3.rebind(chart, graph, 'x', 'y'); - - chart.graph = graph; // Give direct access for getter/setters, and dispatchers - - return chart; -}; - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/cumulativeLine.html b/awx/ui/static/lib/novus-nvd3/deprecated/cumulativeLine.html deleted file mode 100755 index 0a7bab8b94..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/cumulativeLine.html +++ /dev/null @@ -1,171 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/cumulativeLine.js b/awx/ui/static/lib/novus-nvd3/deprecated/cumulativeLine.js deleted file mode 100755 index 127d9407d7..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/cumulativeLine.js +++ /dev/null @@ -1,334 +0,0 @@ - -nv.models.cumulativeLine = function() { - var margin = {top: 30, right: 20, bottom: 30, left: 60}, - getWidth = function() { return 960 }, - getHeight = function() { return 500 }, - color = d3.scale.category20().range(), - dotRadius = function() { return 2.5 }, - getX = function(d) { return d.x }, - getY = function(d) { return d.y }, - id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one - showRescaleToggle = true, - rescaleY = true; - - var x = d3.scale.linear(), - dx = d3.scale.linear(), - y = d3.scale.linear(), - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis = nv.models.axis().scale(y).orient('left'), - legend = nv.models.legend().height(30), - controls = nv.models.legend().height(30), - lines = nv.models.line(), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'), - index = {i: 0, x: 0}; - - //TODO: let user select default - var controlsData = [ - { key: 'Re-scale y-axis' } - ]; - - var indexDrag = d3.behavior.drag() - .on('dragstart', dragStart) - .on('drag', dragMove) - .on('dragend', dragEnd); - - function dragStart(d,i) {} - - function dragMove(d,i) { - d.x += d3.event.dx; - d.i = Math.round(dx.invert(d.x)); - - //d3.transition(d3.select('.chart-' + id)).call(chart); - d3.select(this).attr("transform", "translate(" + dx(d.i) + ",0)"); - } - - function dragEnd(d,i) { - d3.transition(d3.select('.chart-' + id)).call(chart); - } - - - function chart(selection) { - selection.each(function(data) { - var width = getWidth(), - height = getHeight(), - availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom; - - var series = indexify(index.i, data); - - var seriesData = series - .filter(function(d) { return !rescaleY || !d.disabled }) // only filter out if rescaling y axis - .map(function(d) { return d.values }); - - - x .domain(d3.extent(d3.merge(seriesData), function(d) { return d.x } )) - .range([0, availableWidth]); - - dx .domain([0, data[0].values.length - 1]) //Assumes all series have same length - .range([0, availableWidth]) - .clamp(true); - - y .domain(d3.extent(d3.merge(seriesData), function(d) { return d.y } )) - .range([availableHeight, 0]); - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled })) - - - var wrap = d3.select(this).classed('chart-' + id, true).selectAll('g.wrap').data([series]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 cumulativeLine').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'linesWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - gEnter.append('g').attr('class', 'controlsWrap'); - - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - legend.width(width/2 - margin.right); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') - .call(legend); - - if (showRescaleToggle) { - controls.width(140).color(['#444', '#444', '#444']); - g.select('.controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - - var linesWrap = g.select('.linesWrap') - .datum(series.filter(function(d) { return !d.disabled })) - - - d3.transition(linesWrap).call(lines); - - - var indexLine = linesWrap.selectAll('.indexLine') - .data([index]); - indexLine.enter().append('rect').attr('class', 'indexLine') - .attr('width', 3) - .attr('x', -2) - .attr('fill', 'red') - .attr('fill-opacity', .5) - .call(indexDrag) - - indexLine - .attr("transform", function(d) { return "translate(" + dx(d.i) + ",0)" }) - .attr('height', availableHeight) - - - xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks( height / 36 ) - .tickSize(-availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - - - // ********** EVENT LISTENERS ********** - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - - /* - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); - */ - - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - rescaleY = !d.disabled; - - //console.log(d,i,arguments); - - selection.transition().call(chart); - }); - - - - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - }); - - return chart; - } - - - - // ********** FUNCTIONS ********** - - /* Normalize the data according to an index point. */ - function indexify(idx, data) { - return data.map(function(line, i) { - var v = getY(line.values[idx], idx); - - return { - key: line.key, - values: line.values.map(function(point, pointIndex) { - return {'x': getX(point, pointIndex), 'y': (getY(point, pointIndex) - v) / (1 + v) }; - }), - disabled: line.disabled, - hover: line.hover - /* - if (v < -.9) { - //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically currect till it hits 100) - } - */ - }; - }); - }; - - - - - // ********** PUBLIC ACCESSORS ********** - - chart.dispatch = dispatch; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - //lines.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - //lines.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - /* - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - */ - - chart.width = function(_) { - if (!arguments.length) return getWidth; - getWidth = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return getHeight; - getHeight = d3.functor(_); - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - return chart; - }; - - chart.dotRadius = function(_) { - if (!arguments.length) return dotRadius; - dotRadius = d3.functor(_); - lines.dotRadius = _; - return chart; - }; - - chart.showRescaleToggle = function(_) { - if (!arguments.length) return showRescaleToggle; - showRescaleToggle = _; - return chart; - }; - - - // Expose the x-axis' tickFormat method. - //chart.xAxis = {}; - //d3.rebind(chart.xAxis, xAxis, 'tickFormat'); - chart.xAxis = xAxis; - - // Expose the y-axis' tickFormat method. - //chart.yAxis = {}; - //d3.rebind(chart.yAxis, yAxis, 'tickFormat'); - chart.yAxis = yAxis; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarChartWithEnabledTooltip.html b/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarChartWithEnabledTooltip.html deleted file mode 100755 index f23732ccc0..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarChartWithEnabledTooltip.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - -
- -
- -
- -
- - - - - - - - - - \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarChartWithEnabledTooltip.js b/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarChartWithEnabledTooltip.js deleted file mode 100755 index d4465cac52..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarChartWithEnabledTooltip.js +++ /dev/null @@ -1,222 +0,0 @@ - -nv.models.discreteBarChart = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - width = null, - height = null, - color = d3.scale.category20().range(), - staggerLabels = false, - tooltips = true, - tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' - }; - - - var discretebar = nv.models.discreteBar(), - x = discretebar.xScale(), - y = discretebar.yScale(), - xAxis = nv.models.axis().scale(x).orient('bottom').highlightZero(false).showMaxMin(false), - yAxis = nv.models.axis().scale(y).orient('left'), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - xAxis.tickFormat(function(d) { return d }); - yAxis.tickFormat(d3.format(',.1f')); - - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(discretebar.x()(e.point)), - y = yAxis.tickFormat()(discretebar.y()(e.point)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - - //TODO: let user select default - var controlsData = [ - { key: 'Grouped' }, - { key: 'Stacked', disabled: true } - ]; - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - discretebar - .width(availableWidth) - .height(availableHeight); - - - var wrap = container.selectAll('g.wrap.discreteBarWithAxes').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 discreteBarWithAxes').append('g'); - var defsEnter = gEnter.append('defs'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'barsWrap'); - - - - var g = wrap.select('g'); - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - var barsWrap = g.select('.barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - - d3.transition(barsWrap).call(discretebar); - - - defsEnter.append('clipPath') - .attr('id', 'x-label-clip-' + discretebar.id()) - .append('rect') - - g.select('#x-label-clip-' + discretebar.id() + ' rect') - .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1)) - .attr('height', 16) - .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 )); - - /* - var evenLabelClips = defsEnter.append('clipPath') - .attr('id', 'x-label-clip-even-' + discretebar.id()) - .selectAll('rect') - .data(function(d) { return d[0].values.filter(function(d,i) { return i % 2 === 0 }) }); - - evenLabelClips.enter().append('rect') - .attr('width', x.rangeBand()) - .attr('height', 32) - .attr('y', y.range()[0]) - .attr('x', function(d,i) { return x(discretebar.x()(d,i)) }); - - var oddLabelClips = defsEnter.append('clipPath') - .attr('id', 'x-label-clip-odd-' + discretebar.id()) - .selectAll('rect') - .data(function(d) { return d[0].values.filter(function(d,i) { return i % 2 === 1 }) }); - - oddLabelClips.enter().append('rect') - .attr('width', x.rangeBand()) - .attr('height', 16) - .attr('y', y.range()[0] + 16 + (staggerLabels ? 12: 0)) - .attr('x', function(d,i) { return x(discretebar.x()(d,i)) }); - */ - - - - xAxis - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + (y.range()[0] + (discretebar.showValues() ? 16 : 0)) + ')') - //d3.transition(g.select('.x.axis')) - g.select('.x.axis').transition().duration(0) - .call(xAxis); - - - var xTicks = g.select('.x.axis').selectAll('g'); - - if (staggerLabels) - xTicks - .selectAll('text') - .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '0' : '12') + ')' }) - - xTicks - .selectAll('text') - .attr('clip-path', function(d,i,j) { return 'url(#x-label-clip-' + discretebar.id() + ')' }); - - - yAxis - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - discretebar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above? - - discretebar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); - - - //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection) - chart.update = function() { selection.transition().call(chart); }; - chart.container = this; // I need a reference to the container in order to have outside code check if the chart is visible or not - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.discretebar = discretebar; // really just makign the accessible for discretebar.dispatch, may rethink slightly - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - discretebar.color(_); - return chart; - }; - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarWithAxes.html b/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarWithAxes.html deleted file mode 100755 index fc7ef62112..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarWithAxes.html +++ /dev/null @@ -1,172 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarWithAxes.js b/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarWithAxes.js deleted file mode 100755 index 558efaf51a..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/discreteBarWithAxes.js +++ /dev/null @@ -1,152 +0,0 @@ - -nv.models.discreteBarWithAxes = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - width = function() { return 960 }, - height = function() { return 500 }, - color = d3.scale.category20().range(), - staggerLabels = false; - - var discretebar = nv.models.discreteBar(), - x = discretebar.xScale(), - y = discretebar.yScale(), - xAxis = nv.models.axis().scale(x).orient('bottom').highlightZero(false), - yAxis = nv.models.axis().scale(y).orient('left'), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - //TODO: let user select default - var controlsData = [ - { key: 'Grouped' }, - { key: 'Stacked', disabled: true } - ]; - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width() - margin.left - margin.right, - availableHeight = height() - margin.top - margin.bottom; - - var seriesData = data.filter(function(d) { return !d.disabled }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: discretebar.x()(d,i), y: discretebar.y()(d,i) } - }) - }); - - - - discretebar - .width(availableWidth) - .height(availableHeight); - - - var wrap = d3.select(this).selectAll('g.wrap.discreteBarWithAxes').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 discreteBarWithAxes').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'barsWrap'); - - - - var g = wrap.select('g'); - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - var barsWrap = g.select('.barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - - d3.transition(barsWrap).call(discretebar); - - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - - var xTicks = g.select('.x.axis').selectAll('g'); - - if (staggerLabels) - xTicks - .selectAll('text') - .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '0' : '12') + ')' }) - - /* - xTicks.filter(function(d,i) { - return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0; - }) - .selectAll('line, text') - .style('opacity', 0) - */ - - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - discretebar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - discretebar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = d3.functor(_); - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - discretebar.color(_); - return chart; - }; - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineChart-old.html b/awx/ui/static/lib/novus-nvd3/deprecated/lineChart-old.html deleted file mode 100755 index 84f0c70526..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineChart-old.html +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineChartDaily.html b/awx/ui/static/lib/novus-nvd3/deprecated/lineChartDaily.html deleted file mode 100755 index 2ef0954483..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineChartDaily.html +++ /dev/null @@ -1,109 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/linePlusBar.html b/awx/ui/static/lib/novus-nvd3/deprecated/linePlusBar.html deleted file mode 100755 index a64ec4bfe0..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/linePlusBar.html +++ /dev/null @@ -1,173 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/linePlusBar.js b/awx/ui/static/lib/novus-nvd3/deprecated/linePlusBar.js deleted file mode 100755 index c5c690af05..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/linePlusBar.js +++ /dev/null @@ -1,250 +0,0 @@ - -nv.models.linePlusBar = function() { - var margin = {top: 30, right: 60, bottom: 50, left: 60}, - getWidth = function() { return 960 }, - getHeight = function() { return 500 }, - dotRadius = function() { return 2.5 }, - getX = function(d) { return d.x }, - getY = function(d) { return d.y }, - color = d3.scale.category20().range(), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - var x = d3.scale.linear(), - y1 = d3.scale.linear(), - y2 = d3.scale.linear(), - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis1 = nv.models.axis().scale(y1).orient('left'), - yAxis2 = nv.models.axis().scale(y2).orient('right'), - legend = nv.models.legend().height(30), - lines = nv.models.line(), - bars = nv.models.historicalBar(); - - - function chart(selection) { - selection.each(function(data) { - var width = getWidth(), - height = getHeight(), - availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom; - - var series1 = data.filter(function(d) { return !d.disabled && d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - var series2 = data.filter(function(d) { return !d.disabled && !d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) - .range([0, availableWidth]); - - y1 .domain(d3.extent(d3.merge(series1), function(d) { return d.y } )) - .range([availableHeight, 0]); - - y2 .domain(d3.extent(d3.merge(series2), function(d) { return d.y } )) - .range([availableHeight, 0]); - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })) - - bars - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })) - - - var wrap = d3.select(this).selectAll('g.wrap.linePlusBar').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 linePlusBar').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y1 axis'); - gEnter.append('g').attr('class', 'y2 axis'); - gEnter.append('g').attr('class', 'barsWrap'); - gEnter.append('g').attr('class', 'linesWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - legend.width(width/2 - margin.right); - - g.select('.legendWrap') - .datum(data.map(function(series) { - series.key = series.key + (series.bar ? ' (left axis)' : ' (right axis)'); - return series; - })) - .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') - .call(legend); - - - var barsData = data.filter(function(d) { return !d.disabled && d.bar }); - - var barsWrap = g.select('.barsWrap') - .datum(barsData.length ? barsData : [{values:[]}]) - //.datum(data.filter(function(d) { return !d.disabled && d.bar })) - - var linesWrap = g.select('.linesWrap') - .datum(data.filter(function(d) { return !d.disabled && !d.bar })) - - - d3.transition(barsWrap).call(bars); - d3.transition(linesWrap).call(lines); - - - xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis1 - .domain(y1.domain()) - .range(y1.range()) - .ticks( height / 36 ) - .tickSize(-availableWidth, 0); - - d3.transition(g.select('.y1.axis')) - .call(yAxis1); - - yAxis2 - .domain(y2.domain()) - .range(y2.range()) - .ticks( height / 36 ) - .tickSize(series1.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.y2.axis') - .attr('transform', 'translate(' + x.range()[1] + ',0)'); - - d3.transition(g.select('.y2.axis')) - .call(yAxis2); - - }); - - return chart; - } - - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.bars = bars; - chart.xAxis = xAxis; - chart.yAxis1 = yAxis1; - chart.yAxis2 = yAxis2; - - //d3.rebind(chart, lines, 'interactive'); - //consider rebinding x and y as well - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - bars.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - bars.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return getWidth; - getWidth = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return getHeight; - getHeight = d3.functor(_); - return chart; - }; - - chart.dotRadius = function(_) { - if (!arguments.length) return dotRadius; - dotRadius = d3.functor(_); - lines.dotRadius = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - return chart; - }; - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFocus.html b/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFocus.html deleted file mode 100755 index c845bcf823..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFocus.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFocus.js b/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFocus.js deleted file mode 100755 index e359fff528..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFocus.js +++ /dev/null @@ -1,354 +0,0 @@ - -nv.models.lineWithFocus = function() { - var margin = {top: 30, right: 20, bottom: 30, left: 60}, - margin2 = {top: 0, right: 20, bottom: 20, left: 60}, - width = 960, - height = 500, - height1 = 400, - height2 = 100, - color = d3.scale.category20().range(), - getX = function(d) { return d.x }, - getY = function(d) { return d.y }, - id = Math.floor(Math.random() * 10000); //Create semi-unique ID incase user doesn't select one - - var x = d3.scale.linear(), - y = d3.scale.linear(), - x2 = d3.scale.linear(), - y2 = d3.scale.linear(), - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis = nv.models.axis().scale(y).orient('left'), - xAxis2 = nv.models.axis().scale(x2).orient('bottom'), - yAxis2 = nv.models.axis().scale(y2).orient('left'), - legend = nv.models.legend().height(30), - focus = nv.models.line().clipEdge(true), - context = nv.models.line().interactive(false), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'), - brush = d3.svg.brush() - .x(x2); - - - //var wrap, gEnter, g, focus, focusLines, contextWrap, focusWrap, contextLines; //brought all variables to this scope for use within brush function... is this a bad idea? - - //var seriesData; //Temporarily bringing this data to this scope.... may be bad idea (same with above).. may need to rethink brushing - - function chart(selection) { - selection.each(function(data) { - var seriesData = data.filter(function(d) { return !d.disabled }) - .map(function(d) { return d.values }), - availableWidth = width - margin.left - margin.right, - availableHeight1 = height1 - margin.top - margin.bottom, - availableHeight2 = height2 - margin2.top - margin2.bottom; - - x2 .domain(d3.extent(d3.merge(seriesData), getX )) - .range([0, availableWidth]); - y2 .domain(d3.extent(d3.merge(seriesData), getY )) - .range([availableHeight2, 0]); - - x .domain(brush.empty() ? x2.domain() : brush.extent()) - .range([0, availableWidth]); - y .domain(y2.domain()) - .range([availableHeight1, 0]); - - brush.on('brush', onBrush); - - focus - .width(availableWidth) - .height(availableHeight1) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled })) - - context - .width(availableWidth) - .height(availableHeight2) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled })) - - - updateFocus(); - - - var wrap = d3.select(this).selectAll('g.wrap').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithFocus').append('g'); - - gEnter.append('g').attr('class', 'focus'); - gEnter.append('g').attr('class', 'context'); - gEnter.append('g').attr('class', 'legendWrap'); - - - - var g = wrap.select('g') - //.attr('transform', 'translate(0,0)'); - - - - - // ********** LEGEND ********** - - legend.width(width/2 - margin.right); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',0)') - .call(legend); - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - - - - // ********** FOCUS ********** - - var focusWrap = g.select('.focus') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - gEnter.select('.focus').append('g').attr('class', 'x axis'); - gEnter.select('.focus').append('g').attr('class', 'y axis'); - gEnter.select('.focus').append('g').attr('class', 'focusLines'); - - - var focusLines = focusWrap.select('.focusLines') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(focusLines).call(focus); - - - xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-(availableHeight1), 0); - - focusWrap.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks( height / 36 ) - .tickSize(-(availableWidth), 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - - // ********** CONTEXT ********** - - var contextWrap = g.select('.context') - .attr('transform', 'translate(' + margin2.left + ',' + height1 + ')'); - - gEnter.select('.context').append('g').attr('class', 'x2 axis'); - gEnter.select('.context').append('g').attr('class', 'y2 axis'); - gEnter.select('.context').append('g').attr('class', 'contextLines'); - gEnter.select('.context').append('g').attr('class', 'x brush') - .attr('class', 'x brush') - .call(brush) - .selectAll('rect') - .attr('y', -5) - .attr('height', height2 + 4); - - var contextLines = contextWrap.select('.contextLines') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(contextLines).call(context); - - - xAxis2 - .domain(x2.domain()) - .range(x2.range()) - .ticks( width / 100 ) - .tickSize(-(availableHeight2), 0); - - contextWrap.select('.x2.axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); - d3.transition(contextWrap.select('.x2.axis')) - .call(xAxis2); - - - yAxis2 - .domain(y2.domain()) - .range(y2.range()) - .ticks( availableHeight2 / 24 ) - .tickSize(-(availableWidth), 0); - - contextWrap.select('.y2.axis'); - - d3.transition(contextWrap.select('.y2.axis')) - .call(yAxis2); - - - - - - - // ********** EVENT LISTENERS ********** - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - -/* - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); -*/ - - focus.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); - }); - focus.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - - - - function onBrush() { - updateFocus(); - - focusLines.call(focus) - wrap.select('.x.axis').call(xAxis); - wrap.select('.y.axis').call(yAxis); - } - - function updateFocus() { - var yDomain = brush.empty() ? y2.domain() : d3.extent(d3.merge(seriesData).filter(function(d) { - return getX(d) >= brush.extent()[0] && getX(d) <= brush.extent()[1]; - }), getY); //This doesn't account for the 1 point before and the 1 point after the domain. Would fix, but likely need to change entire methodology here - - if (typeof yDomain[0] == 'undefined') yDomain = y2.domain(); //incase the brush doesn't cover a single point - - - x.domain(brush.empty() ? x2.domain() : brush.extent()); - y.domain(yDomain); - - //TODO: Rethink this... performance is horrible, likely need to cut off focus data to within the range - // If I limit the data for focusLines would want to include 1 point before and after the extent, - // Need to figure out an optimized way to accomplish this. - // ***One concern is to try not to make the assumption that all lines are of the same length, and - // points with the same index have the same x value (while this is true in our test cases, may - // not always be) - - focus.xDomain(x.domain()); - focus.yDomain(y.domain()); - } - - - }); - - return chart; - } - - - - // ********** FUNCTIONS ********** - - - - - // ********** PUBLIC ACCESSORS ********** - - chart.dispatch = dispatch; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - focus.x(_); - context.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - focus.y(_); - context.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - height1 = _ - height2; - return chart; - }; - - chart.contextHeight = function(_) { - if (!arguments.length) return height2; - height2 = _; - height1 = height - _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - - // Chart has multiple similar Axes, to prevent code duplication, probably need to link all axis functions manually like below - chart.xTickFormat = function(_) { - if (!arguments.length) return x.tickFormat(); - xAxis.tickFormat(_); - xAxis2.tickFormat(_); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return y.tickFormat(); - yAxis.tickFormat(_); - yAxis2.tickFormat(_); - return chart; - }; - - - - //TODO: allow for both focus and context axes to be linked - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFourAxes.html b/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFourAxes.html deleted file mode 100755 index 736b57197a..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFourAxes.html +++ /dev/null @@ -1,144 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFourAxes.js b/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFourAxes.js deleted file mode 100755 index f42c77332e..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithFourAxes.js +++ /dev/null @@ -1,218 +0,0 @@ - -nv.models.lineWithLegend = function() { - var margin = {top: 60, right: 60, bottom: 40, left: 60}, - getWidth = function() { return 960 }, - getHeight = function() { return 500 }, - dotRadius = function() { return 2.5 }, - getX = function(d) { return d.x }, - getY = function(d) { return d.y }, - color = d3.scale.category20().range(), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - var x = d3.scale.linear(), - y = d3.scale.linear(), - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis = nv.models.axis().scale(y).orient('left'), - x2Axis = nv.models.axis().scale(x).orient('top'), - y2Axis = nv.models.axis().scale(y).orient('right'), - legend = nv.models.legend().height(30), - lines = nv.models.line(); - - - function chart(selection) { - selection.each(function(data) { - var width = getWidth(), - height = getHeight(), - availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom; - - var series = data.filter(function(d) { return !d.disabled }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - x .domain(d3.extent(d3.merge(series), function(d) { return d.x } )) - .range([0, availableWidth]); - - y .domain(d3.extent(d3.merge(series), function(d) { return d.y } )) - .range([availableHeight, 0]); - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled })) - - - var wrap = d3.select(this).selectAll('g.wrap').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithLegend').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'x2 axis'); - gEnter.append('g').attr('class', 'y2 axis'); - gEnter.append('g').attr('class', 'linesWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - -/* - // - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); -*/ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height() + 20; // 20 is for the x2 axis... this should be done in a better place, but just doing this to show the 4 axes in an example - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - legend.width(width/2 - margin.right); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') - .call(legend); - - - var linesWrap = g.select('.linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - - d3.transition(linesWrap).call(lines); - - - xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks( height / 36 ) - .tickSize(-availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - x2Axis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-availableHeight, 0); - - d3.transition(g.select('.x2.axis')) - .call(x2Axis); - - y2Axis - .domain(y.domain()) - .range(y.range()) - .ticks( height / 36 ) - .tickSize(-availableWidth, 0); - - g.select('.y2.axis') - .attr('transform', 'translate('+ x.range()[1] + ',0)'); - d3.transition(g.select('.y2.axis')) - .call(y2Axis); - }); - - return chart; - } - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, lines, 'interactive'); - //consider rebinding x and y as well - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return getWidth; - getWidth = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return getHeight; - getHeight = d3.functor(_); - return chart; - }; - - chart.dotRadius = function(_) { - if (!arguments.length) return dotRadius; - dotRadius = d3.functor(_); - lines.dotRadius = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithLegend.html b/awx/ui/static/lib/novus-nvd3/deprecated/lineWithLegend.html deleted file mode 100755 index 9aa9fab6e3..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithLegend.html +++ /dev/null @@ -1,142 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithLegend.js b/awx/ui/static/lib/novus-nvd3/deprecated/lineWithLegend.js deleted file mode 100755 index edd5aef2c7..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/lineWithLegend.js +++ /dev/null @@ -1,176 +0,0 @@ - -nv.models.lineWithLegend = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - color = d3.scale.category20().range(), - width, height; - - var lines = nv.models.line(), - //x = d3.scale.linear(), - //y = d3.scale.linear(), - x = lines.xScale(), - y = lines.yScale(), - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis = nv.models.axis().scale(y).orient('left'), - legend = nv.models.legend().height(30), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - - function chart(selection) { - selection.each(function(data) { - - var availableWidth = (width || parseInt(d3.select(this).style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(d3.select(this).style('height')) || 400) - - margin.top - margin.bottom; - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled })); - - - var wrap = d3.select(this).selectAll('g.wrap.lineWithLegend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 lineWithLegend').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'linesWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - - legend.width(availableWidth / 2); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')') - .call(legend); - - - - var linesWrap = g.select('.linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(linesWrap).call(lines); - - - - xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - -/* - // - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); -*/ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - }); - - - // If the legend changed the margin's height, need to recalc positions... should think of a better way to prevent duplicate work - if (margin.top != legend.height()) - chart(selection); - - - return chart; - } - - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - //width = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - //height = d3.functor(_); - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/monthendAxis.html b/awx/ui/static/lib/novus-nvd3/deprecated/monthendAxis.html deleted file mode 100755 index fafd7020bf..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/monthendAxis.html +++ /dev/null @@ -1,99 +0,0 @@ - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarHorizontalWithLegend.html b/awx/ui/static/lib/novus-nvd3/deprecated/multiBarHorizontalWithLegend.html deleted file mode 100755 index 297244efee..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarHorizontalWithLegend.html +++ /dev/null @@ -1,258 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarHorizontalWithLegend.js b/awx/ui/static/lib/novus-nvd3/deprecated/multiBarHorizontalWithLegend.js deleted file mode 100755 index ab2087be66..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarHorizontalWithLegend.js +++ /dev/null @@ -1,226 +0,0 @@ - -nv.models.multiBarHorizontalWithLegend = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - width = function() { return 960 }, - height = function() { return 500 }, - color = d3.scale.category20().range(), - showControls = true; - - //var x = d3.scale.linear(), - var x = d3.scale.ordinal(), - y = d3.scale.linear(), - xAxis = nv.models.axis().scale(x).orient('left').highlightZero(false), - yAxis = nv.models.axis().scale(y).orient('bottom'), - legend = nv.models.legend().height(30), - controls = nv.models.legend().height(30), - multibar = nv.models.multiBarHorizontal().stacked(false), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - //TODO: let user select default - var controlsData = [ - { key: 'Grouped' }, - { key: 'Stacked', disabled: true }, - ]; - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width() - margin.left - margin.right, - availableHeight = height() - margin.top - margin.bottom, - seriesData; - - if (multibar.stacked()) { - seriesData = data.filter(function(d) { return !d.disabled }) - .reduce(function(prev, curr, index) { //sum up all the y's - curr.values.forEach(function(d,i) { - if (!index) prev[i] = {x: multibar.x()(d,i), y:0}; - prev[i].y += multibar.y()(d,i); - }); - return prev; - }, []); - } else { - seriesData = data.filter(function(d) { return !d.disabled }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: multibar.x()(d,i), y: multibar.y()(d,i) } - }) - }); - } - - - x .domain(d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands([0, availableHeight], .1); - - y .domain(d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(multibar.forceY) )) - .range([0, availableWidth]); - - multibar - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % 10]; - }).filter(function(d,i) { return !data[i].disabled })) - - - - var wrap = d3.select(this).selectAll('g.wrap').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiBarHorizontalWithLegend').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'linesWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - gEnter.append('g').attr('class', 'controlsWrap'); - - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - legend.width(availableWidth / 2); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')') - .call(legend); - - if (showControls) { - controls.width(180).color(['#444', '#444', '#444']); - g.select('.controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - - var linesWrap = g.select('.linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - - d3.transition(linesWrap).call(multibar); - - - xAxis - .scale(x) - .ticks( availableHeight / 24 ) - .tickSize(-availableWidth, 0); - - //g.select('.x.axis') - //.attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - var xTicks = g.select('.x.axis').selectAll('g'); - - xTicks - .selectAll('line, text') - .style('opacity', 1) - - xTicks.filter(function(d,i) { - return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0; - }) - .selectAll('line, text') - .style('opacity', 0) - - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight, 0); - - g.select('.y.axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Grouped': - multibar.stacked(false); - break; - case 'Stacked': - multibar.stacked(true); - break; - } - - selection.transition().call(chart); - }); - - - multibar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - multibar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = d3.functor(_); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarWithLegend.html b/awx/ui/static/lib/novus-nvd3/deprecated/multiBarWithLegend.html deleted file mode 100755 index 2942b9fb72..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarWithLegend.html +++ /dev/null @@ -1,162 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarWithLegend.js b/awx/ui/static/lib/novus-nvd3/deprecated/multiBarWithLegend.js deleted file mode 100755 index 2d3d406766..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/multiBarWithLegend.js +++ /dev/null @@ -1,249 +0,0 @@ - -nv.models.multiBarWithLegend = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - width = function() { return 960 }, - height = function() { return 500 }, - color = d3.scale.category20().range(), - showControls = true, - showLegend = true; - - //var x = d3.scale.linear(), - var x = d3.scale.ordinal(), - y = d3.scale.linear(), - xAxis = nv.models.axis().scale(x).orient('bottom').highlightZero(false), - yAxis = nv.models.axis().scale(y).orient('left'), - legend = nv.models.legend().height(30), - controls = nv.models.legend().height(30), - multibar = nv.models.multiBar().stacked(false), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - //TODO: let user select default - var controlsData = [ - { key: 'Grouped' }, - { key: 'Stacked', disabled: true } - ]; - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width() - margin.left - margin.right, - availableHeight = height() - margin.top - margin.bottom, - seriesData; - - if (multibar.stacked()) { - seriesData = data.filter(function(d) { return !d.disabled }) - .reduce(function(prev, curr, index) { //sum up all the y's - curr.values.forEach(function(d,i) { - if (!index) prev[i] = {x: multibar.x()(d,i), y:0}; - prev[i].y += multibar.y()(d,i); - }); - return prev; - }, []); - } else { - seriesData = data.filter(function(d) { return !d.disabled }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: multibar.x()(d,i), y: multibar.y()(d,i) } - }) - }); - } - - - //x .domain(d3.extent(d3.merge(seriesData).map(function(d) { return d.x }).concat(multibar.forceX) )) - //.range([0, availableWidth]); - - x .domain(d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands([0, availableWidth], .1); - //.rangeRoundBands([0, availableWidth], .1); - - y .domain(d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(multibar.forceY) )) - .range([availableHeight, 0]); - - multibar - .width(availableWidth) - .height(availableHeight) - //.xDomain(x.domain()) - //.yDomain(y.domain()) - .color(data.map(function(d,i) { - return d.color || color[i % 20]; - }).filter(function(d,i) { return !data[i].disabled })) - - - - var wrap = d3.select(this).selectAll('g.wrap.multiBarWithLegend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiBarWithLegend').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'linesWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - gEnter.append('g').attr('class', 'controlsWrap'); - - - - var g = wrap.select('g'); - - - if (showLegend) { - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - legend.width(availableWidth / 2); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')') - .call(legend); - } - - if (showControls) { - controls.width(180).color(['#444', '#444', '#444']); - g.select('.controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - var linesWrap = g.select('.linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - - d3.transition(linesWrap).call(multibar); - - - xAxis - .scale(x) - //.domain(x.domain()) - //.range(x.range()) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - var xTicks = g.select('.x.axis').selectAll('g'); - - xTicks - .selectAll('line, text') - .style('opacity', 1) - - xTicks.filter(function(d,i) { - return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0; - }) - .selectAll('line, text') - .style('opacity', 0) - - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Grouped': - multibar.stacked(false); - break; - case 'Stacked': - multibar.stacked(true); - break; - } - - selection.transition().call(chart); - }); - - - multibar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - multibar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'forceX', 'forceY', 'clipEdge', 'id', 'stacked'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = d3.functor(_); - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/pie.js b/awx/ui/static/lib/novus-nvd3/deprecated/pie.js deleted file mode 100755 index 7c2f785a56..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/pie.js +++ /dev/null @@ -1,263 +0,0 @@ - -nv.models.pie = function() { - var margin = {top: 20, right: 20, bottom: 20, left: 20}, - width = 500, - height = 500, - animate = 2000, - radius = Math.min(width-(margin.right+margin.left), height-(margin.top+margin.bottom)) / 2, - label ='label', - field ='y', - id = Math.floor(Math.random() * 10000), //Create semi-unique ID in case user doesn't select one - color = d3.scale.category20(), - showLabels = true, - donut = false, - title = ''; - - var lastWidth = 0, - lastHeight = 0; - - - var dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'tooltipShow', 'tooltipHide'); - - function chart(selection) { - selection.each(function(data) { - - var svg = d3.select(this) - .on("click", function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - - var background = svg.selectAll('svg.margin').data([data]); - var parent = background.enter(); - parent.append("text") - .attr("class", "title") - .attr("dy", ".91em") - .attr("text-anchor", "start") - .text(title); - parent.append('svg') - .attr('class','margin') - .attr('x', margin.left) - .attr('y', margin.top) - .style('overflow','visible'); - - var wrap = background.selectAll('g.wrap').data([data]); - wrap.exit().remove(); - var wEnter = wrap.enter(); - - wEnter - .append('g') - .attr('class', 'wrap') - .attr('id','wrap-'+id) - .append('g') - .attr('class', 'pie'); - - - - wrap - .attr('width', width) //-(margin.left+margin.right)) - .attr('height', height) //-(margin.top+margin.bottom)) - .attr("transform", "translate(" + radius + "," + radius + ")"); - - - - - var arc = d3.svg.arc() - .outerRadius((radius-(radius / 5))); - - if (donut) arc.innerRadius(radius / 2); - - - // Setup the Pie chart and choose the data element - var pie = d3.layout.pie() - .value(function (d) { return d[field]; }); - - var slices = background.select('.pie').selectAll(".slice") - .data(pie); - - slices.exit().remove(); - - var ae = slices.enter().append("svg:g") - .attr("class", "slice") - .on('mouseover', function(d,i){ - d3.select(this).classed('hover', true); - dispatch.tooltipShow({ - label: d.data[label], - value: d.data[field], - data: d.data, - index: i, - pos: [d3.event.pageX, d3.event.pageY], - id: id - }); - - }) - .on('mouseout', function(d,i){ - d3.select(this).classed('hover', false); - dispatch.tooltipHide({ - label: d.data[label], - value: d.data[field], - data: d.data, - index: i, - id: id - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - label: d.data[label], - value: d.data[field], - data: d.data, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - label: d.data[label], - value: d.data[field], - data: d.data, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - var paths = ae.append("svg:path") - .attr('class','path') - .attr("fill", function(d, i) { return color(i); }); - //.attr('d', arc); - - slices.select('.path') - .attr('d', arc) - .transition() - .ease("bounce") - .duration(animate) - .attrTween("d", tweenPie); - - if (showLabels) { - // This does the normal label - ae.append("text"); - - slices.select("text") - .transition() - .duration(animate) - .ease('bounce') - .attr("transform", function(d) { - d.outerRadius = radius + 10; // Set Outer Coordinate - d.innerRadius = radius + 15; // Set Inner Coordinate - return "translate(" + arc.centroid(d) + ")"; - }) - .attr("text-anchor", "middle") //center the text on it's origin - .style("font", "bold 12px Arial") - .text(function(d, i) { return d.data[label]; }); - } - - - // Computes the angle of an arc, converting from radians to degrees. - function angle(d) { - var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90; - return a > 90 ? a - 180 : a; - } - - - - - - function tweenPie(b) { - b.innerRadius = 0; - var i = d3.interpolate({startAngle: 0, endAngle: 0}, b); - return function(t) { - return arc(i(t)); - }; - } - - - }); - - return chart; - } - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - if (margin.left + margin.right + 20 > _) { - width = margin.left + margin.right + 20; // Min width - } else { - width = _; - } - radius = Math.min(width-(margin.left+margin.right), height-(margin.top+margin.bottom)) / 2; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - if (margin.top + margin.bottom + 20 > _) { - height = margin.top + margin.bottom + 20; // Min height - } else { - height = _; - } - radius = Math.min(width-(margin.left+margin.right), height-(margin.top+margin.bottom)) / 2; - return chart; - }; - - chart.animate = function(_) { - if (!arguments.length) return animate; - animate = _; - return chart; - }; - - chart.labelField = function(_) { - if (!arguments.length) return (label); - label = _; - return chart; - }; - - chart.dataField = function(_) { - if (!arguments.length) return (field); - field = _; - return chart; - }; - - chart.showLabels = function(_) { - if (!arguments.length) return (showLabels); - showLabels = _; - return chart; - }; - - chart.donut = function(_) { - if (!arguments.length) return (donut); - donut = _; - return chart; - }; - - chart.title = function(_) { - if (!arguments.length) return (title); - title = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.dispatch = dispatch; - - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/scatterChart.html b/awx/ui/static/lib/novus-nvd3/deprecated/scatterChart.html deleted file mode 100755 index 7bb78ae565..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/scatterChart.html +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - -
-
- -
-
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/scatterChart.js b/awx/ui/static/lib/novus-nvd3/deprecated/scatterChart.js deleted file mode 100755 index 224dee8f78..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/scatterChart.js +++ /dev/null @@ -1,293 +0,0 @@ -nv.models.scatterChart = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - width = null, - height = null, - color = d3.scale.category20().range(), - showDistX = false, - showDistY = false, - showLegend = true, - tooltips = true, - tooltipX = function(key, x, y) { return '' + x + '' }, - tooltipY = function(key, x, y) { return '' + y + '' }, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }; - - - var scatter = nv.models.scatter(), - x = scatter.xScale(), - y = scatter.yScale(), - xAxis = nv.models.axis().orient('bottom').scale(x).tickPadding(10), - yAxis = nv.models.axis().orient('left').scale(y).tickPadding(10), - legend = nv.models.legend().height(30), - distX = nv.models.distribution().axis('x').scale(x), - distY = nv.models.distribution().axis('y').scale(y), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'), - x0, y0; //TODO: abstract distribution component and have old scales stored there - - var showTooltip = function(e, offsetElement) { - //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) - - //var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - //top = e.pos[1] + ( offsetElement.offsetTop || 0), - var leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), - leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), - topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point)), - yVal = yAxis.tickFormat()(scatter.y()(e.point)), - contentX = tooltipX(e.series.key, xVal, yVal, e, chart), - contentY = tooltipY(e.series.key, xVal, yVal, e, chart); - //content = tooltip(e.series.key, xVal, yVal, e, chart); - - nv.tooltip.show([leftX, topX], contentX, 'n', 1); - nv.tooltip.show([leftY, topY], contentY, 'e', 1); - //nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); - }; - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection) - chart.update = function() { container.transition().call(chart) }; - - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - - x0 = x0 || scatter.xScale(); - y0 = y0 || scatter.yScale(); - - - - var wrap = container.selectAll('g.wrap.scatterChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 scatterChart chart-' + scatter.id()).append('g'); - - gEnter.append('g').attr('class', 'legendWrap'); - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'scatterWrap'); - gEnter.append('g').attr('class', 'distWrap'); - - var g = wrap.select('g') - - if (showLegend) { - legend.width( availableWidth / 2 ); - - wrap.select('.legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.legendWrap') - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')'); - } - - - scatter - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled })) - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var scatterWrap = wrap.select('.scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })); - d3.transition(scatterWrap).call(scatter); - - - xAxis - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight , 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - - yAxis - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - distX - .width(availableWidth) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.distWrap').append('g') - .attr('class', 'distributionX') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - g.select('.distributionX') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - - - distY - .width(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.distWrap').append('g') - .attr('class', 'distributionY') - .attr('transform', 'translate(-' + distY.size() + ',0)'); - g.select('.distributionY') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - - - - legend.dispatch.on('legendClick', function(d,i, that) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - chart.update(); - }); - - /* - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); - */ - - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .distx-' + e.pointIndex) - .attr('y1', e.pos[1] - availableHeight); - d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .disty-' + e.pointIndex) - .attr('x2', e.pos[0] + distX.size()); - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above? - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - - d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .distx-' + e.pointIndex) - .attr('y1', 0); - d3.select('.chart-' + scatter.id() + ' .series-' + e.seriesIndex + ' .disty-' + e.pointIndex) - .attr('x2', distY.size()); - }); - if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); - - - //store old scales for use in transitions on update, to animate from old to new positions, and sizes - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, scatter, 'interactive', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'fisheye', 'fisheyeRadius'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - distX.color(_); - distY.color(_); - return chart; - }; - - chart.showDistX = function(_) { - if (!arguments.length) return showDistX; - showDistX = _; - return chart; - }; - - chart.showDistY = function(_) { - if (!arguments.length) return showDistY; - showDistY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/scatterFisheyeChart.js b/awx/ui/static/lib/novus-nvd3/deprecated/scatterFisheyeChart.js deleted file mode 100755 index d996355923..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/scatterFisheyeChart.js +++ /dev/null @@ -1,418 +0,0 @@ - -nv.models.scatterFisheyeChart = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - width = null, - height = null, - color = nv.utils.defaultColor(), - showDistX = false, - showDistY = false, - showLegend = true, - showControls = true, - fisheye = 0, - tooltips = true, - tooltipX = function(key, x, y) { return '' + x + '' }, - tooltipY = function(key, x, y) { return '' + y + '' }, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }, - noData = "No Data Available." - ; - - var x = d3.fisheye.scale(d3.scale.linear).distortion(0), - y = d3.fisheye.scale(d3.scale.linear).distortion(0); - - var scatter = nv.models.scatter().xScale(x).yScale(y), - //x = scatter.xScale(), - //y = scatter.yScale(), - xAxis = nv.models.axis().orient('bottom').scale(x).tickPadding(10), - yAxis = nv.models.axis().orient('left').scale(y).tickPadding(10), - legend = nv.models.legend().height(30), - controls = nv.models.legend().height(30), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'), - x0, y0; //TODO: abstract distribution component and have old scales stored there - - var showTooltip = function(e, offsetElement) { - //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) - - //var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - //top = e.pos[1] + ( offsetElement.offsetTop || 0), - var leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), - leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), - topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), - yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)), - contentX = tooltipX(e.series.key, xVal, yVal, e, chart), - contentY = tooltipY(e.series.key, xVal, yVal, e, chart); - //content = tooltip(e.series.key, xVal, yVal, e, chart); - - nv.tooltip.show([leftX, topX], contentX, 'n', 1, offsetElement); - nv.tooltip.show([leftY, topY], contentY, 'e', 1, offsetElement); - //nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's'); - }; - - var controlsData = [ - { key: 'Magnify', disabled: true } - ]; - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - //TODO: decide if this makes sense to add into all the models for ease of updating (updating without needing the selection) - chart.update = function() { selection.transition().call(chart) }; - - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - container.append('text') - .attr('class', 'nvd3 nv-noData') - .attr('x', availableWidth / 2) - .attr('y', availableHeight / 2) - .attr('dy', '-.7em') - .style('text-anchor', 'middle') - .text(noData); - return chart; - } else { - container.select('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - - x0 = x0 || scatter.xScale(); - y0 = y0 || scatter.yScale(); - - - var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()).append('g'); - - - gEnter.append('rect') - .attr('class', 'nvd3 nv-background') - .attr('width', availableWidth) - .attr('height', availableHeight); - - - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - //gEnter.append('g').attr('class', 'nv-distWrap'); - - var g = wrap.select('g') - - if (showLegend) { - legend.width( availableWidth / 2 ); - - wrap.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')'); - } - - - scatter - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - - if (showControls) { - controls.width(180).color(['#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var scatterWrap = wrap.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })); - d3.transition(scatterWrap).call(scatter); - - - xAxis - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight , 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - - - yAxis - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-y.nv-axis')) - .call(yAxis); - - - - - //TODO abstract Distribution into its own component - if ( showDistX || showDistY) { - var distWrap = scatterWrap.selectAll('g.nv-distribution') - .data(function(d) { return d }, function(d) { return d.key }); - - distWrap.enter().append('g').attr('class', function(d,i) { return 'nv-distribution nv-series-' + i }) - - distWrap.style('stroke', function(d,i) { return color.filter(function(d,i) { return data[i] && !data[i].disabled })[i % color.length] }) - } - - if (showDistX) { - var distX = distWrap.selectAll('line.nv-distX') - .data(function(d) { return d.values }) - distX.enter().append('line') - .attr('x1', function(d,i) { return x0(scatter.x()(d,i)) }) - .attr('x2', function(d,i) { return x0(scatter.x()(d,i)) }) - //d3.transition(distX.exit()) - d3.transition(distWrap.exit().selectAll('line.nv-distX')) - .attr('x1', function(d,i) { return x(scatter.x()(d,i)) }) - .attr('x2', function(d,i) { return x(scatter.x()(d,i)) }) - .remove(); - distX - .attr('class', function(d,i) { return 'nv-distX nv-distX-' + i }) - .attr('y1', y.range()[0]) - .attr('y2', y.range()[0] + 8); - d3.transition(distX) - .attr('x1', function(d,i) { return x(scatter.x()(d,i)) }) - .attr('x2', function(d,i) { return x(scatter.x()(d,i)) }) - } - - - if (showDistY) { - var distY = distWrap.selectAll('line.nv-distY') - .data(function(d) { return d.values }) - distY.enter().append('line') - .attr('y1', function(d,i) { return y0(scatter.y()(d,i)) }) - .attr('y2', function(d,i) { return y0(scatter.y()(d,i)) }); - //d3.transition(distY.exit()) - d3.transition(distWrap.exit().selectAll('line.nv-distY')) - .attr('y1', function(d,i) { return y(scatter.y()(d,i)) }) - .attr('y2', function(d,i) { return y(scatter.y()(d,i)) }) - .remove(); - distY - .attr('class', function(d,i) { return 'nv-distY nv-distY-' + i }) - .attr('x1', x.range()[0]) - .attr('x2', x.range()[0] - 8) - d3.transition(distY) - .attr('y1', function(d,i) { return y(scatter.y()(d,i)) }) - .attr('y2', function(d,i) { return y(scatter.y()(d,i)) }); - } - - - - - legend.dispatch.on('legendClick', function(d,i, that) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.nv-series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart) - }); - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - fisheye = d.disabled ? 0 : 2.5; - g.select('.nv-background').style('pointer-events', d.disabled ? 'none' : 'all'); - scatter.interactive(d.disabled); - tooltips = d.disabled; - - if (d.disabled) { - x.distortion(fisheye).focus(0); - y.distortion(fisheye).focus(0); - - scatterWrap.call(scatter); - g.select('.nv-x.nv-axis').call(xAxis); - g.select('.nv-y.nv-axis').call(yAxis); - } - - selection.transition().call(chart); - }); - - /* - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); - */ - - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - //scatterWrap.select('.series-' + e.seriesIndex + ' .distX-' + e.pointIndex) - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distX-' + e.pointIndex) - .attr('y1', e.pos[1]); - //scatterWrap.select('.series-' + e.seriesIndex + ' .distY-' + e.pointIndex) - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distY-' + e.pointIndex) - .attr('x1', e.pos[0]); - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - //if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, container[0][0].parentNode) } ); // TODO: maybe merge with above? - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - - //scatterWrap.select('.series-' + e.seriesIndex + ' .distX-' + e.pointIndex) - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distX-' + e.pointIndex) - .attr('y1', y.range()[0]); - //scatterWrap.select('.series-' + e.seriesIndex + ' .distY-' + e.pointIndex) - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distY-' + e.pointIndex) - .attr('x1', x.range()[0]); - }); - dispatch.on('tooltipHide', nv.tooltip.cleanup); - - - - //TODO: get distributions to work with fisheye - g.select('.nv-background').on('mousemove', updateFisheye); - g.select('.nv-point-paths').on('mousemove', updateFisheye); - - function updateFisheye() { - var mouse = d3.mouse(this); - x.distortion(fisheye).focus(mouse[0]); - y.distortion(fisheye).focus(mouse[1]); - - scatterWrap.call(scatter); - g.select('.nv-x.nv-axis').call(xAxis); - g.select('.nv-y.nv-axis').call(yAxis); - } - - //store old scales for use in transitions on update, to animate from old to new positions, and sizes - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, scatter, 'interactive', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'fisheye', 'fisheyeRadius'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showDistX = function(_) { - if (!arguments.length) return showDistX; - showDistX = _; - return chart; - }; - - chart.showDistY = function(_) { - if (!arguments.length) return showDistY; - showDistY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.fisheye = function(_) { - if (!arguments.length) return fisheye; - fisheye = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/scatterWithLegend.html b/awx/ui/static/lib/novus-nvd3/deprecated/scatterWithLegend.html deleted file mode 100755 index 24cb22bced..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/scatterWithLegend.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - - -
-
- -
-
- - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/scatterWithLegend.js b/awx/ui/static/lib/novus-nvd3/deprecated/scatterWithLegend.js deleted file mode 100755 index 8434523f76..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/scatterWithLegend.js +++ /dev/null @@ -1,261 +0,0 @@ - -nv.models.scatterWithLegend = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - width = function() { return 960 }, //TODO: should probably make this consistent... or maybe constant in the models, closure in the charts - height = function() { return 500 }, - xAxisLabelText = false, - yAxisLabelText = false, - showDistX = false, - showDistY = false, - color = d3.scale.category20().range(); - - var xAxis = nv.models.axis().orient('bottom').tickPadding(10), - yAxis = nv.models.axis().orient('left').tickPadding(10), - legend = nv.models.legend().height(30), - scatter = nv.models.scatter(), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'), - x, y, x0, y0; - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width() - margin.left - margin.right, - availableHeight = height() - margin.top - margin.bottom; - - x0 = x0 || scatter.xScale(); - y0 = y0 || scatter.yScale(); - - - - var wrap = d3.select(this).selectAll('g.wrap.scatterWithLegend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 scatterWithLegend').append('g'); - - gEnter.append('g').attr('class', 'legendWrap'); - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'scatterWrap'); - //gEnter.append('g').attr('class', 'distWrap'); - - - - scatter - .width(availableWidth) - .height(availableHeight) - //.xDomain(x.domain()) - //.yDomain(y.domain()) - .color(data.map(function(d,i) { - return d.color || color[i % 20]; - }).filter(function(d,i) { return !data[i].disabled })) - - var scatterWrap = wrap.select('.scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })); - - d3.transition(scatterWrap).call(scatter); - - - x = scatter.xScale(); - y = scatter.yScale(); - - xAxis.scale(x); - yAxis.scale(y); - - - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - //TODO: Fix height issue on first render if legend height is larger than margin.top, NEED TO FIX EVERY MODEL WITH A LEGEND - margin.top = legend.height(); - - var g = wrap.select('g') - .attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - legend.width(availableWidth / 2); - - wrap.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')') - .call(legend); - - - - - if ( showDistX || showDistY) { - var distWrap = scatterWrap.selectAll('g.distribution') - .data(function(d) { return d }, function(d) { return d.key }); - - distWrap.enter().append('g').attr('class', function(d,i) { return 'distribution series-' + i }) - - distWrap.style('stroke', function(d,i) { return color.filter(function(d,i) { return data[i] && !data[i].disabled })[i % 10] }) - } - - if (showDistX) { - var distX = distWrap.selectAll('line.distX') - .data(function(d) { return d.values }) - distX.enter().append('line') - .attr('x1', function(d,i) { return x0(scatter.x()(d,i)) }) - .attr('x2', function(d,i) { return x0(scatter.x()(d,i)) }) - //d3.transition(distX.exit()) - d3.transition(distWrap.exit().selectAll('line.distX')) - .attr('x1', function(d,i) { return x(scatter.x()(d,i)) }) - .attr('x2', function(d,i) { return x(scatter.x()(d,i)) }) - .remove(); - distX - .attr('class', function(d,i) { return 'distX distX-' + i }) - .attr('y1', y.range()[0]) - .attr('y2', y.range()[0] + 8); - d3.transition(distX) - .attr('x1', function(d,i) { return x(scatter.x()(d,i)) }) - .attr('x2', function(d,i) { return x(scatter.x()(d,i)) }) - } - - - if (showDistY) { - var distY = distWrap.selectAll('line.distY') - .data(function(d) { return d.values }) - distY.enter().append('line') - .attr('y1', function(d,i) { return y0(scatter.y()(d,i)) }) - .attr('y2', function(d,i) { return y0(scatter.y()(d,i)) }); - //d3.transition(distY.exit()) - d3.transition(distWrap.exit().selectAll('line.distY')) - .attr('y1', function(d,i) { return y(scatter.y()(d,i)) }) - .attr('y2', function(d,i) { return y(scatter.y()(d,i)) }) - .remove(); - distY - .attr('class', function(d,i) { return 'distY distY-' + i }) - .attr('x1', x.range()[0]) - .attr('x2', x.range()[0] - 8) - d3.transition(distY) - .attr('y1', function(d,i) { return y(scatter.y()(d,i)) }) .attr('y2', function(d,i) { return y(scatter.y()(d,i)) }); - } - - - xAxis - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight , 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - - d3.transition(g.select('.x.axis')) - .call(xAxis); - - - yAxis - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - - legend.dispatch.on('legendClick', function(d,i, that) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart) - }); - - /* - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); - */ - - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow({ - point: e.point, - series: e.series, - pos: [e.pos[0] + margin.left, e.pos[1] + margin.top], - seriesIndex: e.seriesIndex, - pointIndex: e.pointIndex - }); - - scatterWrap.select('.series-' + e.seriesIndex + ' .distX-' + e.pointIndex) - .attr('y1', e.pos[1]); - scatterWrap.select('.series-' + e.seriesIndex + ' .distY-' + e.pointIndex) - .attr('x1', e.pos[0]); - }); - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - - scatterWrap.select('.series-' + e.seriesIndex + ' .distX-' + e.pointIndex) - .attr('y1', y.range()[0]); - scatterWrap.select('.series-' + e.seriesIndex + ' .distY-' + e.pointIndex) - .attr('x1', x.range()[0]); - }); - - - //store old scales for use in transitions on update, to animate from old to new positions, and sizes - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, scatter, 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius'); - - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = d3.functor(_); - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - return chart; - }; - - chart.showDistX = function(_) { - if (!arguments.length) return showDistX; - showDistX = _; - return chart; - }; - - chart.showDistY = function(_) { - if (!arguments.length) return showDistY; - showDistY = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/stackedArea.js b/awx/ui/static/lib/novus-nvd3/deprecated/stackedArea.js deleted file mode 100755 index c5851cbda7..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/stackedArea.js +++ /dev/null @@ -1,286 +0,0 @@ - -nv.models.stackedArea = function() { - //Default Settings - var margin = {top: 0, right: 0, bottom: 0, left: 0}, - width = 960, - height = 500, - color = d3.scale.category20().range(), // array of colors to be used in order - id = Math.floor(Math.random() * 100000), //Create semi-unique ID incase user doesn't selet one - getX = function(d) { return d.x }, // accessor to get the x value from a data point - getY = function(d) { return d.y }, // accessor to get the y value from a data point - style = 'stack', - offset = 'zero', - order = 'default', - clipEdge = false; // if true, masks lines within x and y scale - -/************************************ - * offset: - * 'wiggle' (stream) - * 'zero' (stacked) - * 'expand' (normalize to 100%) - * 'silhouette' (simple centered) - * - * order: - * 'inside-out' (stream) - * 'default' (input order) - ************************************/ - - var scatter= nv.models.scatter() - .size(2.2) // default size - .sizeDomain([2.5]), //set to speed up calculation, needs to be unset if there is a cstom size accessor - x = scatter.xScale(), - y = scatter.yScale(), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'areaClick', 'areaMouseover', 'areaMouseout'); - - function chart(selection) { - selection.each(function(data) { - // Need to leave data alone to switch between stacked, stream, and expanded - var dataCopy = JSON.parse(JSON.stringify(data)), - availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom; - - //TODO: try to get rid of the need for copying the data, and use the data directly - - //console.log(dataCopy); - dataCopy = dataCopy.map(function(series,i) { - if (series.disabled) - series.values = series.values.map(function(d,i) { - d._y = d.y || d._y; - d.y = 0; //TODO: need to use value from getY, not always d.y - return d - }); - return series; - }); - - - //TODO: deal with negative stacked charts - - //compute the data based on offset and order (calc's y0 for every point) - dataCopy = d3.layout.stack() - .offset(offset) - .order(order) - .values(function(d){ return d.values }) - .y(getY) - (dataCopy); - - - - var wrap = d3.select(this).selectAll('g.wrap.stackedarea').data([dataCopy]); - var wrapEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 stackedarea'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'areaWrap'); - - - scatter - .width(availableWidth) - .height(availableHeight) - //.x(getX) - .y(function(d) { return d.y + d.y0 }) // TODO: allow for getY to be other than d.y - .forceY([0]) - .color(dataCopy.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !dataCopy[i].disabled })); - - gEnter.append('g').attr('class', 'scatterWrap'); - var scatterWrap= g.select('.scatterWrap') - .datum(dataCopy.filter(function(d) { return !d.disabled })) - - d3.transition(scatterWrap).call(scatter); - - - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - defsEnter.append('clipPath') - .attr('id', 'edge-clip-' + id) - .append('rect'); - - wrap.select('#edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#edge-clip-' + id + ')' : ''); - - - - - var area = d3.svg.area() - .x(function(d,i) { return x(scatter.x()(d,i)) }) - .y0(function(d) { return y(d.y0) }) - .y1(function(d) { return y(d.y + d.y0) }); - - var zeroArea = d3.svg.area() - .x(function(d,i) { return x(scatter.x()(d,i)) }) - .y0(function(d) { return y(d.y0) }) - .y1(function(d) { return y(d.y0) }); - - - var path = g.select('.areaWrap').selectAll('path.area') - .data(function(d) { return d }); - //.data(function(d) { return d }, function(d) { return d.key }); - path.enter().append('path').attr('class', function(d,i) { return 'area area-' + i }) - .on('mouseover', function(d,i) { - d3.select(this).classed('hover', true); - dispatch.areaMouseover({ - point: d, - series: d.key, - //pos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top], - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: i - //pointIndex: d.point - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.areaMouseout({ - point: d, - series: d.key, - //pos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top], - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: i - //pointIndex: d.point - }); - }) - .on('click', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.areaClick({ - point: d, - series: d.key, - //pos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top], - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: i - //pointIndex: d.point - }); - }) - d3.transition(path.exit()) - .attr('d', function(d,i) { return zeroArea(d.values,i) }) // TODO: fix this so transition is still fluid - .remove(); - path - .style('fill', function(d,i){ return d.color || color[i % color.length] }) - .style('stroke', function(d,i){ return d.color || color[i % color.length] }); - d3.transition(path) - .attr('d', function(d,i) { return area(d.values,i) }) - - - scatter.dispatch.on('elementClick.area', function(e) { - dispatch.areaClick(e); - }) - scatter.dispatch.on('elementMouseover.area', function(e) { - g.select('.area-' + e.seriesIndex).classed('hover', true); - }); - scatter.dispatch.on('elementMouseout.area', function(e) { - g.select('.area-' + e.seriesIndex).classed('hover', false); - }); - - }); - - - return chart; - } - - - chart.dispatch = dispatch; - chart.scatter = scatter; - - d3.rebind(chart, scatter, 'x', 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius'); - - /* - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); - scatter.x(_); - return chart; - }; - */ - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - //scatter.y(_); - return chart; - } - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - return chart; - }; - - chart.offset = function(_) { - if (!arguments.length) return offset; - offset = _; - return chart; - }; - - chart.order = function(_) { - if (!arguments.length) return order; - order = _; - return chart; - }; - - //shortcut for offset + order - chart.style = function(_) { - if (!arguments.length) return style; - style = _; - - switch (style) { - case 'stack': - offset = 'zero'; - order = 'default'; - break; - case 'stream': - offset = 'wiggle'; - order = 'inside-out'; - break; - case 'expand': - offset = 'expand'; - order = 'default'; - break; - } - - return chart; - }; - - - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaChart.html b/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaChart.html deleted file mode 100755 index 340d74201a..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaChart.html +++ /dev/null @@ -1,183 +0,0 @@ - - - - - - - - -
- -
- -
- -
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaChart_old.html b/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaChart_old.html deleted file mode 100755 index e344992801..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaChart_old.html +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - -
-
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaWithLegend.html b/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaWithLegend.html deleted file mode 100755 index 35ddf5fe5b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaWithLegend.html +++ /dev/null @@ -1,222 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaWithLegend.js b/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaWithLegend.js deleted file mode 100755 index a7b98137a3..0000000000 --- a/awx/ui/static/lib/novus-nvd3/deprecated/stackedAreaWithLegend.js +++ /dev/null @@ -1,297 +0,0 @@ - -nv.models.stackedAreaWithLegend = function() { - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - getWidth = function() { return 960 }, - getHeight = function() { return 500 }, - color = d3.scale.category20().range(), - showControls = true, - showLegend = true; - - var x = d3.scale.linear(), - y = d3.scale.linear(), - getX = function(d) { return d.x }, - getY = function(d) { return d.y }, - xAxis = nv.models.axis().scale(x).orient('bottom'), - yAxis = nv.models.axis().scale(y).orient('left'), - legend = nv.models.legend().height(30), - controls = nv.models.legend().height(30), - stacked = nv.models.stackedArea(), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - //TODO: let user select default - var controlsData = [ - { key: 'Stacked' }, - { key: 'Stream', disabled: true }, - { key: 'Expanded', disabled: true } - ]; - - - function chart(selection) { - selection.each(function(data) { - var width = getWidth(), - height = getHeight(), - availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom; - - var seriesData = data.filter(function(d) { return !d.disabled }) - .reduce(function(prev, curr, index) { //sum up all the y's - curr.values.forEach(function(d,i) { - if (!index) prev[i] = {x: getX(d,i), y:0}; - prev[i].y += getY(d,i); - }); - return prev; - }, []); - - - x .domain(d3.extent(d3.merge(seriesData), function(d) { return d.x } )) - .range([0, availableWidth]); - - y .domain(stacked.offset() == 'zero' ? - [0, d3.max(seriesData, function(d) { return d.y } )] : - [0, 1] // 0 - 100% - ) - .range([availableHeight, 0]); - - stacked - .width(availableWidth) - .height(availableHeight) - //.color(color) - .color(data.map(function(d,i) { - return d.color || color[i % 20]; - }).filter(function(d,i) { return !data[i].disabled })) - - - var wrap = d3.select(this).selectAll('g.wrap.stackedAreaWithLegend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 stackedAreaWithLegend').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y axis'); - gEnter.append('g').attr('class', 'stackedWrap'); - gEnter.append('g').attr('class', 'legendWrap'); - gEnter.append('g').attr('class', 'controlsWrap'); - - - var g = wrap.select('g'); - - - if (showLegend) { - //TODO: margins should be adjusted based on what components are used: axes, axis labels, legend - margin.top = legend.height(); - - legend - .width(width/2 - margin.right) - .color(color); - - g.select('.legendWrap') - .datum(data) - .attr('transform', 'translate(' + (width/2 - margin.left) + ',' + (-margin.top) +')') - .call(legend); - } - - - if (showControls) { - controls.width(280).color(['#444', '#444', '#444']); - g.select('.controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var stackedWrap = g.select('.stackedWrap') - .datum(data); - d3.transition(stackedWrap).call(stacked); - - - xAxis - .domain(x.domain()) - .range(x.range()) - .ticks( width / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis - .domain(y.domain()) - .range(y.range()) - .ticks(stacked.offset() == 'wiggle' ? 0 : height / 36) - .tickSize(-availableWidth, 0) - .tickFormat(stacked.offset() == 'zero' ? d3.format(',.2f') : d3.format('%')); //TODO: stacked format should be set by caller - - d3.transition(g.select('.y.axis')) - .call(yAxis); - - - - //TODO: FIX Logic error, screws up when series are disabled by clicking legend, then series are desiabled by clicking the area - stacked.dispatch.on('areaClick.toggle', function(e) { - if (data.filter(function(d) { return !d.disabled }).length === 1) - data = data.map(function(d) { - if (d.disabled) - d.values.map(function(p) { p.y = p._y || p.y; return p }); // .... - - d.disabled = false; - - return d - }); - else - data = data.map(function(d,i) { - if (!d.disabled && i !== e.seriesIndex) - d.values.map(function(p) { p._y = p.y; p.y = 0; return p }); //TODO: need to use value from getY, not always d.y - - if (d.disabled && i === e.seriesIndex) - d.values.map(function(p) { p.y = p._y || p.y; return p }); // .... - - d.disabled = (i != e.seriesIndex); - - return d - }); - - selection.transition().call(chart); - }); - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (d.disabled) - d.values.map(function(p) { p._y = p.y; p.y = 0; return p }); //TODO: need to use value from getY, not always d.y - else - d.values.map(function(p) { p.y = p._y; return p }); // .... - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - d.values.map(function(p) { p.y = p._y; return p }); // .... - return d; - }); - } - - selection.transition().call(chart); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Stacked': - stacked.style('stack'); - break; - case 'Stream': - stacked.style('stream'); - break; - case 'Expanded': - stacked.style('expand'); - break; - } - - selection.transition().call(chart); - }); - - - /* - legend.dispatch.on('legendMouseover', function(d, i) { - d.hover = true; - selection.transition().call(chart) - }); - - legend.dispatch.on('legendMouseout', function(d, i) { - d.hover = false; - selection.transition().call(chart) - }); - */ - - stacked.dispatch.on('tooltipShow', function(e) { - //disable tooltips when value ~= 0 - //// TODO: consider removing points from voronoi that have 0 value instead of this hack - if (!Math.round(getY(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range - setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); - return false; - } - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - stacked.dispatch.on('tooltipHide', function(e) { - dispatch.tooltipHide(e); - }); - }); - - - - /* - // If the legend changed the margin's height, need to recalc positions... should think of a better way to prevent duplicate work - if (margin.top != legend.height()) - chart(selection); - */ - - - return chart; - } - - - chart.dispatch = dispatch; - chart.stacked = stacked; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, stacked, 'interactive', 'offset', 'order', 'style', 'clipEdge', 'size', 'forceX', 'forceY', 'forceSize'); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); //not used locally, so could jsut be a rebind - stacked.x(getX); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - stacked.y(getY); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return getWidth; - getWidth = d3.functor(_); - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return getHeight; - getHeight = d3.functor(_); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/examples/bullet.html b/awx/ui/static/lib/novus-nvd3/examples/bullet.html deleted file mode 100755 index f18bc8f1f1..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/bullet.html +++ /dev/null @@ -1,97 +0,0 @@ - - - - - - -




- - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/bulletChart.html b/awx/ui/static/lib/novus-nvd3/examples/bulletChart.html deleted file mode 100755 index 7c5cd9848c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/bulletChart.html +++ /dev/null @@ -1,116 +0,0 @@ - - - - - - -




- -Normal Bullet Chart - - -Bullet Chart with Custom Labels - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/crossfilter.html b/awx/ui/static/lib/novus-nvd3/examples/crossfilter.html deleted file mode 100755 index ce22807434..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/crossfilter.html +++ /dev/null @@ -1,167 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/crossfilterWithDimentions.html b/awx/ui/static/lib/novus-nvd3/examples/crossfilterWithDimentions.html deleted file mode 100755 index cff2a6be14..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/crossfilterWithDimentions.html +++ /dev/null @@ -1,180 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/crossfilterWithTables.html b/awx/ui/static/lib/novus-nvd3/examples/crossfilterWithTables.html deleted file mode 100755 index 95abd99115..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/crossfilterWithTables.html +++ /dev/null @@ -1,288 +0,0 @@ - - - - - - - - -
- -
-
-

Stream #1

-
-
-

Stream #2

-
-
-

Stream #3

-
- - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/cumulativeLineChart.html b/awx/ui/static/lib/novus-nvd3/examples/cumulativeLineChart.html deleted file mode 100755 index a0c4b58242..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/cumulativeLineChart.html +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - -
-
- Chart with new tooltips and guide line (with-transitions) - -
-
- Chart with old tooltips (with-transitions) - -
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/discreteBarChart.html b/awx/ui/static/lib/novus-nvd3/examples/discreteBarChart.html deleted file mode 100755 index 5381f3639d..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/discreteBarChart.html +++ /dev/null @@ -1,117 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/historicalBar.html b/awx/ui/static/lib/novus-nvd3/examples/historicalBar.html deleted file mode 100755 index 49a075a38a..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/historicalBar.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/historicalBarChart.html b/awx/ui/static/lib/novus-nvd3/examples/historicalBarChart.html deleted file mode 100755 index c196391c37..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/historicalBarChart.html +++ /dev/null @@ -1,106 +0,0 @@ - - - - - - -
- -
- - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/horizon.html b/awx/ui/static/lib/novus-nvd3/examples/horizon.html deleted file mode 100755 index 8c49bdbeb5..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/horizon.html +++ /dev/null @@ -1,163 +0,0 @@ - - - - - - -
- -
- - - 1 -
-
- -
- - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/images/grey-minus.png b/awx/ui/static/lib/novus-nvd3/examples/images/grey-minus.png deleted file mode 100755 index f1e6768d42..0000000000 Binary files a/awx/ui/static/lib/novus-nvd3/examples/images/grey-minus.png and /dev/null differ diff --git a/awx/ui/static/lib/novus-nvd3/examples/images/grey-plus.png b/awx/ui/static/lib/novus-nvd3/examples/images/grey-plus.png deleted file mode 100755 index 10b73a5178..0000000000 Binary files a/awx/ui/static/lib/novus-nvd3/examples/images/grey-plus.png and /dev/null differ diff --git a/awx/ui/static/lib/novus-nvd3/examples/images/nvd3_sampleLineChart1.png b/awx/ui/static/lib/novus-nvd3/examples/images/nvd3_sampleLineChart1.png deleted file mode 100755 index 05d7ef2ac3..0000000000 Binary files a/awx/ui/static/lib/novus-nvd3/examples/images/nvd3_sampleLineChart1.png and /dev/null differ diff --git a/awx/ui/static/lib/novus-nvd3/examples/indentedtree.html b/awx/ui/static/lib/novus-nvd3/examples/indentedtree.html deleted file mode 100755 index a5a1a06a99..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/indentedtree.html +++ /dev/null @@ -1,127 +0,0 @@ - - - - - - -
- - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/index.html b/awx/ui/static/lib/novus-nvd3/examples/index.html deleted file mode 100755 index 658924854b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/index.html +++ /dev/null @@ -1,98 +0,0 @@ - - -NVD3 Examples List - - -

NVD3 Examples List

- - - - - - \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/examples/legend.html b/awx/ui/static/lib/novus-nvd3/examples/legend.html deleted file mode 100755 index b5211ab060..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/legend.html +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/line.html b/awx/ui/static/lib/novus-nvd3/examples/line.html deleted file mode 100755 index 917437e3f2..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/line.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/lineChart.html b/awx/ui/static/lib/novus-nvd3/examples/lineChart.html deleted file mode 100755 index 5e6e56d57f..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/lineChart.html +++ /dev/null @@ -1,132 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/lineChartSVGResize.html b/awx/ui/static/lib/novus-nvd3/examples/lineChartSVGResize.html deleted file mode 100755 index 51d81758ad..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/lineChartSVGResize.html +++ /dev/null @@ -1,151 +0,0 @@ - - - - - - - -
- Zoom In Zoom Out -
- -
- -
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/linePlusBarChart.html b/awx/ui/static/lib/novus-nvd3/examples/linePlusBarChart.html deleted file mode 100755 index 2b6aa15c3e..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/linePlusBarChart.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/linePlusBarWithFocusChart.html b/awx/ui/static/lib/novus-nvd3/examples/linePlusBarWithFocusChart.html deleted file mode 100755 index 4eac5d8dd2..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/linePlusBarWithFocusChart.html +++ /dev/null @@ -1,129 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/lineWithFisheyeChart.html b/awx/ui/static/lib/novus-nvd3/examples/lineWithFisheyeChart.html deleted file mode 100755 index e0818502df..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/lineWithFisheyeChart.html +++ /dev/null @@ -1,101 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/lineWithFocusChart.html b/awx/ui/static/lib/novus-nvd3/examples/lineWithFocusChart.html deleted file mode 100755 index c5278a139a..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/lineWithFocusChart.html +++ /dev/null @@ -1,87 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/multiBar.html b/awx/ui/static/lib/novus-nvd3/examples/multiBar.html deleted file mode 100755 index f00de237e9..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/multiBar.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/multiBarChart.html b/awx/ui/static/lib/novus-nvd3/examples/multiBarChart.html deleted file mode 100755 index 55e30102db..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/multiBarChart.html +++ /dev/null @@ -1,105 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/multiBarHorizontalChart.html b/awx/ui/static/lib/novus-nvd3/examples/multiBarHorizontalChart.html deleted file mode 100755 index 515726351e..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/multiBarHorizontalChart.html +++ /dev/null @@ -1,389 +0,0 @@ - - - - - - - - -
- -
- - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/multiChart.html b/awx/ui/static/lib/novus-nvd3/examples/multiChart.html deleted file mode 100755 index 3bfa6930b7..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/multiChart.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - -
- -
- - - - - - - - - - - - - - \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/examples/nations.json b/awx/ui/static/lib/novus-nvd3/examples/nations.json deleted file mode 100755 index c9e730c6cb..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/nations.json +++ /dev/null @@ -1 +0,0 @@ -[{"name":"Angola","region":"Sub-Saharan Africa","income":[[1800,359.93],[1820,359.93],[1913,556.12],[1950,3363.02],[1951,3440.9],[1952,3520.61],[1953,3598.81],[1954,3450.82],[1955,3672.08],[1956,3549.04],[1957,3827.94],[1958,3966.42],[1959,3917.76],[1960,4006.21],[1961,4463.83],[1962,4269.28],[1963,4413.6],[1964,4826.49],[1965,5102.21],[1966,5308.14],[1967,5522.78],[1968,5346.63],[1969,5408.12],[1970,5651.88],[1971,5526.21],[1972,5473.29],[1973,5722.02],[1974,5470.21],[1975,3430.85],[1976,3050.32],[1977,3008.65],[1978,3070.82],[1979,3064.89],[1980,3074.75],[1981,2953.41],[1982,2756.95],[1983,2584.56],[1984,2527.47],[1985,2492.83],[1986,2220.61],[1987,2430.21],[1988,2728.53],[1989,2730.56],[1990,2777.42],[1991,2730.85],[1992,2627.85],[1993,1869.92],[1994,1851.45],[1995,1989.02],[1996,2157.35],[1997,2277.14],[1998,2384.48],[1999,2417.18],[2000,2446.65],[2001,2479.69],[2002,2773.29],[2003,2785.39],[2004,3007.11],[2005,3533],[2006,4069.56],[2007,4755.46],[2008,5228.74],[2009,5055.59]],"population":[[1800,1567028],[1820,1567028],[1940,3738000],[1950,4117617],[1951,4173095],[1952,4232095],[1953,4293840],[1954,4357527],[1955,4423223],[1956,4490992],[1957,4561361],[1958,4635885],[1959,4714676],[1960,4797344],[1961,4752489],[1962,4826015],[1963,4919586],[1964,5026044],[1965,5134818],[1966,5201250],[1967,5247469],[1968,5350384],[1969,5471641],[1970,5605626],[1971,5752775],[1972,5894858],[1973,6025841],[1974,5986432],[1975,5884241],[1976,5942225],[1977,6162675],[1978,6285716],[1979,6451227],[1980,6741465],[1981,6877697],[1982,7016384],[1983,7238214],[1984,7439658],[1985,7581504],[1986,7744932],[1987,7874230],[1988,8018724],[1989,8148595],[1990,8290856],[1991,8490763],[1992,8735988],[1993,8961438],[1994,9170032],[1995,9421477],[1996,9660081],[1997,9875024],[1998,10071442],[1999,10263229],[2000,10442812],[2001,10623424],[2002,10866106],[2003,11186202],[2004,11521432],[2005,11827315],[2006,12127071],[2007,12420476],[2008,12707546]],"lifeExpectancy":[[1800,26.98],[1940,26.98],[1950,29.22],[1951,29.42],[1952,29.81],[1953,30.21],[1954,30.6],[1955,31],[1956,31.4],[1957,31.8],[1958,32.2],[1959,32.6],[1960,33],[1961,33.4],[1962,33.8],[1963,34.2],[1964,34.6],[1965,35],[1966,35.4],[1967,35.8],[1968,36.2],[1969,36.6],[1970,37],[1971,37.41],[1972,37.83],[1973,38.26],[1974,38.68],[1975,39.09],[1976,39.46],[1977,39.8],[1978,40.1],[1979,40.34],[1980,40.55],[1981,40.71],[1982,40.85],[1983,40.97],[1984,41.08],[1985,41.2],[1986,41.33],[1987,41.48],[1988,41.64],[1989,41.81],[1990,41.99],[1991,42.16],[1992,42.32],[1993,42.46],[1994,42.59],[1995,42.7],[1996,42.82],[1997,42.96],[1998,43.12],[1999,43.32],[2000,43.56],[2001,43.86],[2002,44.22],[2003,44.61],[2004,45.05],[2005,45.52],[2006,46.02],[2007,46.54],[2008,47.06],[2009,47.58]]},{"name":"Benin","region":"Sub-Saharan Africa","income":[[1800,553.72],[1820,553.72],[1913,855.53],[1950,1104.47],[1951,1083.57],[1952,1062.75],[1953,1012.84],[1954,1021.29],[1955,1000.66],[1956,980.06],[1957,959.6],[1958,974.04],[1959,988.88],[1960,996.93],[1961,1006.39],[1962,949.5],[1963,970.34],[1964,1012.25],[1965,1039.34],[1966,1051.67],[1967,1035.83],[1968,1048.78],[1969,1052.8],[1970,1047.17],[1971,1024.93],[1972,1085.8],[1973,1081.87],[1974,973.64],[1975,987.96],[1976,1002.19],[1977,1029.16],[1978,1032.01],[1979,1083.17],[1980,1154.23],[1981,1186.7],[1982,1277.9],[1983,1187.14],[1984,1243.82],[1985,1297.16],[1986,1285.08],[1987,1225.86],[1988,1222.9],[1989,1158.34],[1990,1165.47],[1991,1181.65],[1992,1191.21],[1993,1177.91],[1994,1168.53],[1995,1176.67],[1996,1202.15],[1997,1232.98],[1998,1251.88],[1999,1272.8],[2000,1307.57],[2001,1333.3],[2002,1372.88],[2003,1386.05],[2004,1389.13],[2005,1390],[2006,1402.94],[2007,1428.15],[2008,1459.07],[2009,1457.57]],"population":[[1800,636559],[1820,636559],[1950,1672661],[1951,1704916],[1952,1738315],[1953,1772899],[1954,1808895],[1955,1846175],[1956,1884978],[1957,1925173],[1958,1966816],[1959,2010163],[1960,2055083],[1961,2101846],[1962,2151895],[1963,2202775],[1964,2255760],[1965,2310714],[1966,2367951],[1967,2427334],[1968,2488957],[1969,2553162],[1970,2619809],[1971,2689271],[1972,2761407],[1973,2836325],[1974,2914439],[1975,2995605],[1976,3080268],[1977,3168267],[1978,3259760],[1979,3354798],[1980,3444361],[1981,3540043],[1982,3641603],[1983,3748839],[1984,3861680],[1985,3982013],[1986,4110035],[1987,4243788],[1988,4382448],[1989,4526250],[1990,4676077],[1991,4828814],[1992,4981671],[1993,5214220],[1994,5487359],[1995,5700089],[1996,5886094],[1997,6066080],[1998,6248686],[1999,6435871],[2000,6627964],[2001,6824931],[2002,7026113],[2003,7230693],[2004,7438437],[2005,7649360],[2006,7862944],[2007,8078314],[2008,8294941]],"lifeExpectancy":[[1800,31],[1944,31],[1950,36.53],[1951,36.73],[1952,37.15],[1953,37.58],[1954,38.01],[1955,38.45],[1956,38.9],[1957,39.35],[1958,39.8],[1959,40.26],[1960,40.72],[1961,41.18],[1962,41.64],[1963,42.1],[1964,42.55],[1965,43.01],[1966,43.47],[1967,43.95],[1968,44.43],[1969,44.93],[1970,45.45],[1971,45.99],[1972,46.55],[1973,47.12],[1974,47.69],[1975,48.25],[1976,48.79],[1977,49.29],[1978,49.75],[1979,50.17],[1980,50.54],[1981,50.87],[1982,51.15],[1983,51.42],[1984,51.68],[1985,51.94],[1986,52.24],[1987,52.57],[1988,52.95],[1989,53.37],[1990,53.84],[1991,54.34],[1992,54.86],[1993,55.38],[1994,55.89],[1995,56.38],[1996,56.84],[1997,57.26],[1998,57.64],[1999,58],[2000,58.34],[2001,58.68],[2002,59.02],[2003,59.38],[2004,59.77],[2005,60.17],[2006,60.6],[2007,61.03],[2008,61.47],[2009,61.89]]},{"name":"Botswana","region":"Sub-Saharan Africa","income":[[1800,407.36],[1820,407.36],[1913,629.4],[1950,825.25],[1951,840.94],[1952,851.24],[1953,865.86],[1954,880.5],[1955,893.58],[1956,905.91],[1957,918.23],[1958,929.05],[1959,944.14],[1960,953.26],[1961,971.44],[1962,983.65],[1963,999.69],[1964,1018.75],[1965,1034.37],[1966,1119.01],[1967,1214.71],[1968,1319.18],[1969,1424.21],[1970,1532.71],[1971,1769.34],[1972,2263.61],[1973,2658.43],[1974,3077.33],[1975,2897.18],[1976,3271.32],[1977,3214.86],[1978,3640.34],[1979,3818.4],[1980,4178.48],[1981,4399.13],[1982,4551.14],[1983,5079.53],[1984,5450.44],[1985,5656.04],[1986,5889.64],[1987,6205.88],[1988,6959.66],[1989,7619.62],[1990,7829.23],[1991,7964.58],[1992,7954.11],[1993,7860.65],[1994,7898.05],[1995,8030.48],[1996,8281.92],[1997,8647.14],[1998,8990.98],[1999,9416.67],[2000,10107.99],[2001,10543.61],[2002,11003.61],[2003,11391.09],[2004,11722.59],[2005,12057],[2006,12574.18],[2007,13010.7],[2008,13240.06],[2009,12282.28]],"population":[[1800,121000],[1904,121000],[1911,125000],[1921,153000],[1936,266000],[1946,296000],[1950,430413],[1951,436320],[1952,442308],[1953,448377],[1954,454640],[1955,461100],[1956,467765],[1957,474639],[1958,481731],[1959,489080],[1960,496695],[1961,504585],[1962,512764],[1963,521237],[1964,529966],[1965,538100],[1966,545965],[1967,553541],[1968,561941],[1969,571874],[1970,583999],[1971,599647],[1972,619351],[1973,643076],[1974,671769],[1975,704591],[1976,741273],[1977,781472],[1978,822247],[1979,862602],[1980,900476],[1981,934438],[1982,970347],[1983,1006466],[1984,1042702],[1985,1078902],[1986,1114934],[1987,1151184],[1988,1188137],[1989,1225684],[1990,1263643],[1991,1301796],[1992,1342614],[1993,1385749],[1994,1427426],[1995,1466989],[1996,1503652],[1997,1536536],[1998,1564950],[1999,1588505],[2000,1607069],[2001,1620848],[2002,1630347],[2003,1636213],[2004,1639231],[2005,1640115],[2006,1639833],[2007,1639131],[2008,1638393]],"lifeExpectancy":[[1800,33.6],[1945,33.6],[1950,46.82],[1951,47.02],[1952,47.43],[1953,47.84],[1954,48.25],[1955,48.65],[1956,49.05],[1957,49.45],[1958,49.85],[1959,50.23],[1960,50.61],[1961,50.98],[1962,51.33],[1963,51.68],[1964,52.02],[1965,52.37],[1966,52.74],[1967,53.13],[1968,53.57],[1969,54.04],[1970,54.56],[1971,55.13],[1972,55.75],[1973,56.39],[1974,57.04],[1975,57.7],[1976,58.33],[1977,58.93],[1978,59.48],[1979,59.99],[1980,60.46],[1981,60.92],[1982,61.38],[1983,61.85],[1984,62.31],[1985,62.77],[1986,63.23],[1987,63.65],[1988,64],[1989,64.22],[1990,64.24],[1991,63.97],[1992,63.38],[1993,62.47],[1994,61.26],[1995,59.76],[1996,57.98],[1997,56.05],[1998,54.08],[1999,52.21],[2000,50.65],[2001,49.59],[2002,49.11],[2003,49.22],[2004,49.87],[2005,50.92],[2006,52.17],[2007,53.39],[2008,54.4],[2009,55.12]]},{"name":"Burkina Faso","region":"Sub-Saharan Africa","income":[[1800,454.33],[1820,454.33],[1913,497.44],[1950,515.71],[1951,529.66],[1952,543.26],[1953,557.01],[1954,571.4],[1955,586.4],[1956,601.99],[1957,617.18],[1958,633.89],[1959,649.7],[1960,661.86],[1961,684.8],[1962,722.51],[1963,708.58],[1964,719.57],[1965,740.98],[1966,737.83],[1967,794.83],[1968,810.76],[1969,817.43],[1970,809.75],[1971,831.9],[1972,854.74],[1973,798.63],[1974,772.28],[1975,727.95],[1976,709.39],[1977,743.39],[1978,811.57],[1979,800.89],[1980,794.76],[1981,809.75],[1982,807.2],[1983,778.05],[1984,770.53],[1985,848.8],[1986,955.4],[1987,912.06],[1988,957.87],[1989,917.41],[1990,880.17],[1991,938.09],[1992,931.75],[1993,895.91],[1994,878.97],[1995,889.91],[1996,929.21],[1997,946.29],[1998,978.6],[1999,1009.59],[2000,1001.48],[2001,1029.97],[2002,1037.65],[2003,1080.53],[2004,1096.85],[2005,1140],[2006,1175.51],[2007,1189.88],[2008,1223.52],[2009,1234.42]],"population":[[1800,1665421],[1820,1665421],[1950,4376162],[1951,4422822],[1952,4469979],[1953,4517639],[1954,4565808],[1955,4614490],[1956,4663691],[1957,4713416],[1958,4763672],[1959,4814463],[1960,4865796],[1961,4890688],[1962,4919632],[1963,4952695],[1964,4989961],[1965,5031519],[1966,5077473],[1967,5127935],[1968,5183033],[1969,5242904],[1970,5303777],[1971,5366018],[1972,5433886],[1973,5507594],[1974,5587373],[1975,5673472],[1976,5764606],[1977,5889574],[1978,6023204],[1979,6165533],[1980,6315312],[1981,6471556],[1982,6634596],[1983,6804810],[1984,6982590],[1985,7168228],[1986,7367641],[1987,7586551],[1988,7824563],[1989,8076170],[1990,8335771],[1991,8603238],[1992,8878303],[1993,9159653],[1994,9467871],[1995,9772602],[1996,10060724],[1997,10352843],[1998,10652495],[1999,10975109],[2000,11308552],[2001,11732326],[2002,12251209],[2003,12705775],[2004,13092647],[2005,13491736],[2006,13902972],[2007,14326203],[2008,14761339]],"lifeExpectancy":[[1800,29.2],[1945,29.2],[1950,32.89],[1951,33.09],[1952,33.49],[1953,33.9],[1954,34.34],[1955,34.79],[1956,35.26],[1957,35.74],[1958,36.24],[1959,36.74],[1960,37.25],[1961,37.76],[1962,38.25],[1963,38.73],[1964,39.2],[1965,39.63],[1966,40.04],[1967,40.43],[1968,40.79],[1969,41.14],[1970,41.48],[1971,41.82],[1972,42.17],[1973,42.53],[1974,42.9],[1975,43.27],[1976,43.64],[1977,44],[1978,44.33],[1979,44.65],[1980,44.95],[1981,45.22],[1982,45.49],[1983,45.75],[1984,46.01],[1985,46.27],[1986,46.51],[1987,46.75],[1988,46.98],[1989,47.2],[1990,47.42],[1991,47.65],[1992,47.89],[1993,48.14],[1994,48.41],[1995,48.7],[1996,49.01],[1997,49.34],[1998,49.68],[1999,50.02],[2000,50.37],[2001,50.72],[2002,51.07],[2003,51.42],[2004,51.76],[2005,52.09],[2006,52.42],[2007,52.74],[2008,53.06],[2009,53.38]]},{"name":"Burundi","region":"Sub-Saharan Africa","income":[[1800,447.59],[1820,447.59],[1913,353.82],[1950,322.23],[1951,334.76],[1952,339.3],[1953,346.93],[1954,359.61],[1955,364.64],[1956,372],[1957,379.56],[1958,383.38],[1959,398.3],[1960,396.94],[1961,333.27],[1962,355.2],[1963,364.13],[1964,376.1],[1965,380.08],[1966,387.47],[1967,412.98],[1968,400.03],[1969,388.1],[1970,483.32],[1971,510.51],[1972,464.1],[1973,496.11],[1974,484.51],[1975,478.55],[1976,506.22],[1977,556.1],[1978,536.58],[1979,522.02],[1980,539.85],[1981,574.48],[1982,559.6],[1983,563.3],[1984,549.69],[1985,600.88],[1986,611.89],[1987,621.82],[1988,628.59],[1989,623.27],[1990,630.44],[1991,646.51],[1992,631.7],[1993,613.04],[1994,585.18],[1995,507.2],[1996,462.85],[1997,463.12],[1998,473.7],[1999,455.41],[2000,443.76],[2001,440.51],[2002,446.4],[2003,427.14],[2004,431.76],[2005,420.08],[2006,432.95],[2007,439.64],[2008,450.54],[2009,457.07]],"population":[[1800,899097],[1820,899097],[1950,2362522],[1951,2403682],[1952,2445618],[1953,2488348],[1954,2531886],[1955,2576249],[1956,2621454],[1957,2667518],[1958,2714458],[1959,2763722],[1960,2815405],[1961,2894153],[1962,2961915],[1963,3008458],[1964,3088827],[1965,3170653],[1966,3253610],[1967,3330989],[1968,3400775],[1969,3460144],[1970,3521913],[1971,3596811],[1972,3529983],[1973,3540066],[1974,3594958],[1975,3676308],[1976,3749077],[1977,3834415],[1978,3929974],[1979,4119789],[1980,4299555],[1981,4480338],[1982,4580410],[1983,4692262],[1984,4802889],[1985,4906862],[1986,5002688],[1987,5126023],[1988,5257314],[1989,5379124],[1990,5505113],[1991,5636676],[1992,5809236],[1993,5632915],[1994,5681513],[1995,6077812],[1996,6100754],[1997,6121610],[1998,6271409],[1999,6458283],[2000,6621126],[2001,6810307],[2002,7021078],[2003,7251827],[2004,7516212],[2005,7795426],[2006,8090068],[2007,8390505],[2008,8691005]],"lifeExpectancy":[[1800,31.5],[1945,31.5],[1950,38.42],[1951,38.58],[1952,38.88],[1953,39.18],[1954,39.49],[1955,39.79],[1956,40.08],[1957,40.38],[1958,40.68],[1959,40.98],[1960,41.29],[1961,41.61],[1962,41.93],[1963,42.25],[1964,42.57],[1965,42.87],[1966,43.13],[1967,43.35],[1968,43.53],[1969,43.66],[1970,43.78],[1971,43.91],[1972,44.07],[1973,44.28],[1974,44.55],[1975,44.87],[1976,45.24],[1977,45.63],[1978,46.02],[1979,46.4],[1980,46.76],[1981,47.11],[1982,47.44],[1983,47.75],[1984,48],[1985,48.15],[1986,48.13],[1987,47.91],[1988,47.52],[1989,46.97],[1990,46.36],[1991,45.76],[1992,45.27],[1993,44.96],[1994,44.85],[1995,44.95],[1996,45.23],[1997,45.61],[1998,46.03],[1999,46.47],[2000,46.9],[2001,47.33],[2002,47.77],[2003,48.22],[2004,48.69],[2005,49.15],[2006,49.61],[2007,50.06],[2008,50.51],[2009,50.95]]},{"name":"Cameroon","region":"Sub-Saharan Africa","income":[[1800,517.46],[1820,517.46],[1913,799.51],[1950,1117.97],[1951,1145.39],[1952,1172.67],[1953,1199.76],[1954,1227.65],[1955,1256.24],[1956,1284.39],[1957,1313.05],[1958,1342.09],[1959,1370.44],[1960,1386.31],[1961,1380.62],[1962,1399.61],[1963,1427.16],[1964,1452.69],[1965,1455.61],[1966,1495.91],[1967,1508.45],[1968,1575.87],[1969,1621],[1970,1635.98],[1971,1649.53],[1972,1684.15],[1973,1671.33],[1974,1706.3],[1975,1752.24],[1976,1739.5],[1977,1783.43],[1978,1824.31],[1979,1867.89],[1980,1989.19],[1981,2256.63],[1982,2367.98],[1983,2461.92],[1984,2575.35],[1985,2719.24],[1986,2824.45],[1987,2602.66],[1988,2411.32],[1989,2131.49],[1990,2036.08],[1991,1903.16],[1992,1793.16],[1993,1688.77],[1994,1603.04],[1995,1613.97],[1996,1652.43],[1997,1694.34],[1998,1736.44],[1999,1770.65],[2000,1803.44],[2001,1857.15],[2002,1934.01],[2003,1967.39],[2004,1997.11],[2005,1995],[2006,2003.19],[2007,2012.18],[2008,2013.83],[2009,1997.18]],"population":[[1800,1860054],[1820,1860054],[1926,2547668],[1931,3023000],[1936,3241694],[1950,4887591],[1951,4947090],[1952,5009067],[1953,5073595],[1954,5140805],[1955,5210832],[1956,5283822],[1957,5359923],[1958,5439350],[1959,5522218],[1960,5608760],[1961,5699165],[1962,5793633],[1963,5892378],[1964,5995682],[1965,6103788],[1966,6216951],[1967,6335506],[1968,6459744],[1969,6590041],[1970,6726733],[1971,6870244],[1972,7021028],[1973,7179499],[1974,7346174],[1975,7521530],[1976,7721125],[1977,7959865],[1978,8206825],[1979,8451209],[1980,8746201],[1981,9024472],[1982,9250831],[1983,9521511],[1984,9815056],[1985,10127591],[1986,10454538],[1987,10780667],[1988,11105864],[1989,11438491],[1990,11778594],[1991,12122404],[1992,12467171],[1993,12814205],[1994,13161203],[1995,13504356],[1996,13848792],[1997,14195809],[1998,14543246],[1999,14889962],[2000,15233673],[2001,15577246],[2002,15929988],[2003,16286408],[2004,16637276],[2005,16988132],[2006,17340702],[2007,17696293],[2008,18054929]],"lifeExpectancy":[[1800,28.75],[1931,28.75],[1945,28.75],[1950,37.85],[1951,38.01],[1952,38.34],[1953,38.69],[1954,39.06],[1955,39.43],[1956,39.83],[1957,40.24],[1958,40.66],[1959,41.09],[1960,41.53],[1961,41.98],[1962,42.42],[1963,42.86],[1964,43.3],[1965,43.74],[1966,44.17],[1967,44.61],[1968,45.05],[1969,45.49],[1970,45.94],[1971,46.38],[1972,46.82],[1973,47.26],[1974,47.7],[1975,48.16],[1976,48.66],[1977,49.2],[1978,49.79],[1979,50.42],[1980,51.08],[1981,51.76],[1982,52.44],[1983,53.09],[1984,53.69],[1985,54.2],[1986,54.61],[1987,54.9],[1988,55.08],[1989,55.14],[1990,55.08],[1991,54.91],[1992,54.66],[1993,54.34],[1994,53.98],[1995,53.59],[1996,53.18],[1997,52.75],[1998,52.31],[1999,51.9],[2000,51.52],[2001,51.19],[2002,50.93],[2003,50.74],[2004,50.64],[2005,50.62],[2006,50.7],[2007,50.87],[2008,51.1],[2009,51.39]]},{"name":"Cape Verde","region":"Sub-Saharan Africa","income":[[1800,340],[1820,340],[1821,341.4],[1822,342.8],[1823,344.22],[1824,345.63],[1825,347.05],[1826,348.48],[1827,349.92],[1828,351.36],[1829,352.8],[1830,354.26],[1831,355.71],[1832,357.18],[1833,358.65],[1834,360.12],[1835,361.61],[1836,363.1],[1837,364.59],[1838,366.09],[1839,367.6],[1840,369.11],[1841,370.63],[1842,372.15],[1843,373.69],[1844,375.22],[1845,376.77],[1846,378.32],[1847,379.88],[1848,381.44],[1849,383.01],[1850,384.59],[1851,386.17],[1852,387.76],[1853,389.35],[1854,390.96],[1855,392.57],[1856,394.18],[1857,395.8],[1858,397.43],[1859,399.07],[1860,400.71],[1861,402.36],[1862,404.02],[1863,405.68],[1864,407.35],[1865,409.03],[1866,410.71],[1867,412.4],[1868,414.1],[1869,415.8],[1870,417.51],[1871,419.23],[1872,420.96],[1873,422.69],[1874,424.43],[1875,426.18],[1876,427.93],[1877,429.69],[1878,431.46],[1879,433.24],[1880,435.02],[1881,436.81],[1882,438.61],[1883,440.41],[1884,442.23],[1885,444.05],[1886,445.87],[1887,447.71],[1888,449.55],[1889,451.4],[1890,453.26],[1891,455.13],[1892,457],[1893,458.88],[1894,460.77],[1895,462.67],[1896,464.57],[1897,466.48],[1898,468.4],[1899,470.33],[1900,472.27],[1901,474.21],[1902,476.16],[1903,478.12],[1904,480.09],[1905,482.06],[1906,484.05],[1907,486.04],[1908,488.04],[1909,490.05],[1910,492.07],[1911,494.09],[1912,496.13],[1913,498.17],[1914,500.22],[1915,502.28],[1916,504.35],[1917,506.42],[1918,508.51],[1919,510.6],[1920,512.7],[1921,514.81],[1922,516.93],[1923,519.06],[1924,521.19],[1925,523.34],[1926,525.49],[1927,527.66],[1928,529.83],[1929,532.01],[1930,534.2],[1931,536.4],[1932,538.6],[1933,540.82],[1934,543.05],[1935,545.28],[1936,547.53],[1937,549.78],[1938,552.04],[1939,554.31],[1940,556.6],[1941,558.89],[1942,561.19],[1943,563.5],[1944,565.82],[1945,568.15],[1946,570.48],[1947,572.83],[1948,575.19],[1949,577.56],[1950,579.93],[1951,587.25],[1952,594.73],[1953,602.33],[1954,593.9],[1955,596.83],[1956,604.27],[1957,583.63],[1958,578.66],[1959,627.09],[1960,654.58],[1961,676.65],[1962,695.81],[1963,712.76],[1964,727.65],[1965,741.25],[1966,754.17],[1967,765.83],[1968,776.91],[1969,787.69],[1970,798.3],[1971,730.46],[1972,691.52],[1973,682.07],[1974,660.05],[1975,676.79],[1976,671.08],[1977,667.78],[1978,730.72],[1979,801.76],[1980,1084.09],[1981,1165.56],[1982,1181.35],[1983,1274.12],[1984,1301.51],[1985,1391.73],[1986,1408.06],[1987,1481.04],[1988,1500.81],[1989,1554.99],[1990,1587.89],[1993,1524.74],[1994,1600.25],[1995,1700.27],[1996,1788.78],[1997,1902.83],[1998,2018.62],[1999,2168.69],[2000,2291.29],[2001,2406.57],[2002,2505.29],[2003,2600.55],[2004,2692.59],[2005,2831],[2006,3078.92],[2007,3274.76],[2008,3384.72],[2009,3456.14]],"population":[[1800,55716],[1820,55716],[1950,146403],[1951,150651],[1952,155037],[1953,159567],[1954,164262],[1955,169146],[1956,174228],[1957,179516],[1958,185020],[1959,190769],[1960,196768],[1961,203146],[1962,209878],[1963,216919],[1964,224264],[1965,231719],[1966,239230],[1967,246787],[1968,254303],[1969,261602],[1970,268867],[1971,273381],[1972,275392],[1973,277218],[1974,278617],[1975,280259],[1976,282516],[1977,285691],[1978,288855],[1979,292276],[1980,296042],[1981,300190],[1982,304586],[1983,309265],[1984,314237],[1985,319490],[1986,325009],[1987,330779],[1988,336773],[1989,342950],[1990,349264],[1991,355545],[1992,361638],[1993,367520],[1994,373163],[1995,378520],[1996,383584],[1997,388383],[1998,392941],[1999,397270],[2000,401343],[2001,405163],[2002,408760],[2003,412137],[2004,415294],[2005,418224],[2006,420979],[2007,423613],[2008,426113]],"lifeExpectancy":[[1800,33.8],[1935,33.8],[1950,47.32],[1951,47.63],[1952,48.22],[1953,48.79],[1954,49.32],[1955,49.82],[1956,50.29],[1957,50.74],[1958,51.16],[1959,51.57],[1960,51.98],[1961,52.4],[1962,52.83],[1963,53.28],[1964,53.75],[1965,54.23],[1966,54.71],[1967,55.18],[1968,55.63],[1969,56.06],[1970,56.48],[1971,56.88],[1972,57.3],[1973,57.73],[1974,58.18],[1975,58.67],[1976,59.18],[1977,59.73],[1978,60.3],[1979,60.89],[1980,61.47],[1981,62.03],[1982,62.57],[1983,63.08],[1984,63.54],[1985,63.98],[1986,64.38],[1987,64.78],[1988,65.17],[1989,65.55],[1990,65.93],[1991,66.3],[1992,66.65],[1993,66.97],[1994,67.28],[1995,67.57],[1996,67.84],[1997,68.12],[1998,68.4],[1999,68.68],[2000,68.98],[2001,69.28],[2002,69.59],[2003,69.9],[2004,70.21],[2005,70.52],[2006,70.82],[2007,71.11],[2008,71.4],[2009,71.68]]},{"name":"Chad","region":"Sub-Saharan Africa","income":[[1800,400.69],[1820,400.69],[1913,619.09],[1950,1127.84],[1951,1153.46],[1952,1178.67],[1953,1203.41],[1954,1229.37],[1955,1255.59],[1956,1281.99],[1957,1308.5],[1958,1335.84],[1959,1361.48],[1960,1348.77],[1961,1343.29],[1962,1389.82],[1963,1345.06],[1964,1285.51],[1965,1264.43],[1966,1215.21],[1967,1196.81],[1968,1165.85],[1969,1219.07],[1970,1215.75],[1971,1211.69],[1972,1104.1],[1973,1026.42],[1974,1140.6],[1975,1305.72],[1976,1255.78],[1977,1133.98],[1978,1100.92],[1979,855.79],[1980,804.73],[1981,794.8],[1982,797.91],[1983,886.92],[1984,896.32],[1985,1083.31],[1986,1010.52],[1987,952.39],[1988,1066.26],[1989,1097.79],[1990,999.11],[1991,1065.94],[1992,1058.06],[1993,1003.69],[1994,1023.26],[1995,995.98],[1996,995.1],[1997,1004.96],[1998,1048.81],[1999,1039.29],[2000,1017.03],[2001,1084.2],[2002,1156.18],[2003,1287.08],[2004,1669.42],[2005,1749],[2006,1708.94],[2007,1670.3],[2008,1622.41],[2009,1557.83]],"population":[[1800,1432000],[1936,1432000],[1950,2607769],[1951,2644428],[1952,2682462],[1953,2721913],[1954,2762828],[1955,2805256],[1956,2849247],[1957,2894855],[1958,2942133],[1959,2991261],[1960,3042303],[1961,3095331],[1962,3150417],[1963,3207638],[1964,3271357],[1965,3344639],[1966,3419602],[1967,3495967],[1968,3572528],[1969,3650046],[1970,3730240],[1971,3813207],[1972,3899068],[1973,3988497],[1974,4082064],[1975,4179837],[1976,4281867],[1977,4388260],[1978,4498511],[1979,4545410],[1980,4542002],[1981,4646494],[1982,4875118],[1983,5073154],[1984,5125782],[1985,5169374],[1986,5314060],[1987,5498955],[1988,5674660],[1989,5829327],[1990,6022856],[1991,6232340],[1992,6429417],[1993,6655731],[1994,6886696],[1995,7103883],[1996,7329462],[1997,7562011],[1998,7804481],[1999,8058514],[2000,8316481],[2001,8573507],[2002,8835739],[2003,9103618],[2004,9377194],[2005,9657069],[2006,9944201],[2007,10238807],[2008,10541156]],"lifeExpectancy":[[1800,30.9],[1945,30.9],[1950,37.39],[1951,37.56],[1952,37.91],[1953,38.27],[1954,38.62],[1955,38.98],[1956,39.34],[1957,39.7],[1958,40.06],[1959,40.42],[1960,40.79],[1961,41.16],[1962,41.53],[1963,41.9],[1964,42.27],[1965,42.65],[1966,43.03],[1967,43.42],[1968,43.82],[1969,44.21],[1970,44.61],[1971,44.98],[1972,45.35],[1973,45.69],[1974,46.03],[1975,46.36],[1976,46.69],[1977,47.05],[1978,47.43],[1979,47.84],[1980,48.26],[1981,48.7],[1982,49.14],[1983,49.56],[1984,49.96],[1985,50.31],[1986,50.61],[1987,50.85],[1988,51.04],[1989,51.16],[1990,51.21],[1991,51.2],[1992,51.14],[1993,51.03],[1994,50.88],[1995,50.68],[1996,50.45],[1997,50.18],[1998,49.89],[1999,49.59],[2000,49.3],[2001,49.03],[2002,48.81],[2003,48.63],[2004,48.52],[2005,48.48],[2006,48.51],[2007,48.61],[2008,48.76],[2009,48.97]]},{"name":"Comoros","region":"Sub-Saharan Africa","income":[[1800,800.61],[1820,800.61],[1913,973.4],[1950,1052.1],[1951,1090.85],[1952,1102.99],[1953,1122.69],[1954,1162.08],[1955,1174.15],[1956,1193.11],[1957,1211.15],[1958,1218.42],[1959,1260.08],[1960,1337.13],[1961,1320.49],[1962,1406.65],[1963,1666.01],[1964,1750.41],[1965,1714.18],[1966,1847.27],[1967,1876.03],[1968,1827.9],[1969,1807.69],[1970,1894.29],[1971,2167.2],[1972,1937.58],[1973,1669.69],[1974,1980.87],[1975,1509.81],[1976,1298.57],[1977,1172.6],[1978,1177.32],[1979,1170.84],[1980,1208.28],[1981,1247.48],[1982,1267.1],[1983,1283.26],[1984,1291.09],[1985,1296.92],[1986,1296.8],[1987,1315.98],[1988,1337.51],[1989,1303.55],[1990,1286.8],[1991,1183.07],[1992,1246.91],[1993,1247.05],[1994,1146.29],[1995,1209.23],[1996,1158.46],[1997,1173.62],[1998,1148.85],[1999,1137.89],[2000,1090.79],[2001,1083.42],[2002,1075.81],[2003,1070.95],[2004,1083.02],[2005,1063],[2006,1054.06],[2007,1037.46],[2008,1026.03],[2009,1016.42]],"population":[[1800,56346],[1820,56346],[1950,148057],[1951,150937],[1952,153936],[1953,157062],[1954,160318],[1955,163711],[1956,167245],[1957,170928],[1958,174766],[1959,178754],[1960,182899],[1961,187209],[1962,191689],[1963,196348],[1964,201208],[1965,206279],[1966,211571],[1967,217378],[1968,223443],[1969,229732],[1970,236252],[1971,243014],[1972,250027],[1973,257303],[1974,264851],[1975,272685],[1976,280815],[1977,304739],[1978,313970],[1979,323557],[1980,333513],[1981,340765],[1982,348643],[1983,356997],[1984,365813],[1985,375099],[1986,384862],[1987,395114],[1988,405874],[1989,417164],[1990,429010],[1991,441427],[1992,454429],[1993,468010],[1994,482162],[1995,496906],[1996,512197],[1997,527982],[1998,544267],[1999,561063],[2000,578400],[2001,596202],[2002,614382],[2003,632948],[2004,651901],[2005,671247],[2006,690948],[2007,710960],[2008,731281]],"lifeExpectancy":[[1800,32.1],[1945,32.1],[1950,40.1],[1951,40.25],[1952,40.55],[1953,40.87],[1954,41.2],[1955,41.55],[1956,41.91],[1957,42.28],[1958,42.66],[1959,43.05],[1960,43.45],[1961,43.85],[1962,44.24],[1963,44.64],[1964,45.04],[1965,45.44],[1966,45.86],[1967,46.3],[1968,46.75],[1969,47.23],[1970,47.72],[1971,48.21],[1972,48.68],[1973,49.14],[1974,49.58],[1975,50],[1976,50.4],[1977,50.79],[1978,51.18],[1979,51.57],[1980,51.96],[1981,52.35],[1982,52.73],[1983,53.11],[1984,53.49],[1985,53.89],[1986,54.32],[1987,54.78],[1988,55.29],[1989,55.85],[1990,56.43],[1991,57.04],[1992,57.64],[1993,58.24],[1994,58.82],[1995,59.37],[1996,59.9],[1997,60.41],[1998,60.9],[1999,61.38],[2000,61.85],[2001,62.31],[2002,62.76],[2003,63.2],[2004,63.64],[2005,64.08],[2006,64.51],[2007,64.94],[2008,65.36],[2009,65.77]]},{"name":"Congo, Dem. Rep.","region":"Sub-Saharan Africa","income":[[1800,394.03],[1820,394.03],[1913,608.8],[1950,665.38],[1951,729.1],[1952,780.54],[1953,809.04],[1954,841.4],[1955,856.8],[1956,896.38],[1957,905.86],[1958,861.47],[1959,872.68],[1960,873.47],[1961,762.12],[1962,896.31],[1963,915],[1964,872.83],[1965,861.88],[1966,897.08],[1967,861.59],[1968,871.21],[1969,925.06],[1970,897.41],[1971,928.83],[1972,904.9],[1973,955.92],[1974,961.96],[1975,888.5],[1976,814.53],[1977,795.76],[1978,727.85],[1979,703.98],[1980,698.67],[1981,696.07],[1982,673.75],[1983,665.85],[1984,683.46],[1985,665.88],[1986,676.35],[1987,672.77],[1988,655.34],[1989,630.56],[1990,595.59],[1991,527.67],[1992,465.07],[1993,395.61],[1994,373.44],[1995,367.22],[1996,362.19],[1997,343.52],[1998,335.86],[1999,316.71],[2000,292.45],[2001,281.91],[2002,287.38],[2003,299.49],[2004,314.52],[2005,330],[2006,338.29],[2007,348.98],[2008,359.38],[2009,358.8]],"population":[[1800,5163819],[1820,5163819],[1950,13568762],[1951,13831813],[1952,14100005],[1953,14373435],[1954,14657484],[1955,14952568],[1956,15259279],[1957,15577932],[1958,15909008],[1959,16253014],[1960,16610482],[1961,16964231],[1962,17486434],[1963,18027167],[1964,18432651],[1965,18855509],[1966,19343383],[1967,19941073],[1968,20570629],[1969,21178812],[1970,21780955],[1971,22385560],[1972,23007669],[1973,23668471],[1974,24327147],[1975,25027571],[1976,25737520],[1977,26480870],[1978,27314183],[1979,28201693],[1980,29010717],[1981,29806198],[1982,30646495],[1983,31444001],[1984,32337982],[1985,33340593],[1986,34372899],[1987,35481645],[1988,36632259],[1989,37814050],[1990,39064041],[1991,40388906],[1992,41672143],[1993,43055943],[1994,44539132],[1995,46343432],[1996,47265530],[1997,47798986],[1998,48877408],[1999,50400431],[2000,52021832],[2001,53682112],[2002,55379852],[2003,57124974],[2004,58919207],[2005,60764490],[2006,62660551],[2007,64606759],[2008,66604314]],"lifeExpectancy":[[1800,31.6],[1940,31.6],[1950,38.46],[1951,38.63],[1952,38.96],[1953,39.29],[1954,39.6],[1955,39.91],[1956,40.2],[1957,40.49],[1958,40.76],[1959,41.03],[1960,41.28],[1961,41.53],[1962,41.76],[1963,41.99],[1964,42.21],[1965,42.44],[1966,42.69],[1967,42.95],[1968,43.23],[1969,43.52],[1970,43.83],[1971,44.12],[1972,44.39],[1973,44.64],[1974,44.87],[1975,45.09],[1976,45.32],[1977,45.57],[1978,45.86],[1979,46.17],[1980,46.49],[1981,46.8],[1982,47.08],[1983,47.3],[1984,47.46],[1985,47.57],[1986,47.65],[1987,47.71],[1988,47.76],[1989,47.8],[1990,47.79],[1991,47.68],[1992,47.45],[1993,47.12],[1994,46.71],[1995,46.29],[1996,45.96],[1997,45.79],[1998,45.8],[1999,46],[2000,46.34],[2001,46.75],[2002,47.13],[2003,47.4],[2004,47.57],[2005,47.63],[2006,47.63],[2007,47.63],[2008,47.68],[2009,47.81]]},{"name":"Congo, Rep.","region":"Sub-Saharan Africa","income":[[1800,387.38],[1820,387.38],[1913,598.52],[1950,2045.71],[1951,2086.26],[1952,2125.62],[1953,2163.66],[1954,2202.17],[1955,2240.94],[1956,2277.93],[1957,2315.06],[1958,2352.14],[1959,2388.98],[1960,2416.97],[1961,2441.68],[1962,2464.78],[1963,2489.39],[1964,2513.69],[1965,2537.54],[1966,2606.33],[1967,2677.94],[1968,2749.04],[1969,2822.37],[1970,2896.11],[1971,3049.9],[1972,3213.15],[1973,3382.1],[1974,3557.86],[1975,3740.93],[1976,3654.71],[1977,3259.18],[1978,3113.91],[1979,3487.82],[1980,3968.45],[1981,4653.12],[1982,4879.51],[1983,4974.83],[1984,5137.42],[1985,4760.07],[1986,4302.47],[1987,4201.19],[1988,4080.9],[1989,4102.61],[1990,4066.16],[1991,4036.64],[1992,4016.24],[1993,3850.64],[1994,3523.16],[1995,3554.39],[1996,3596.92],[1997,3484.16],[1998,3516.06],[1999,3304.52],[2000,3423.52],[2001,3397.84],[2002,3484.06],[2003,3425.54],[2004,3455.04],[2005,3621],[2006,3738.39],[2007,3575.55],[2008,3668.41],[2009,3834.67]],"population":[[1800,314465],[1820,314465],[1950,826308],[1951,840223],[1952,854885],[1953,870325],[1954,886576],[1955,903672],[1956,921651],[1957,940458],[1958,960128],[1959,980700],[1960,1002214],[1961,1024609],[1962,1047924],[1963,1072198],[1964,1097474],[1965,1123795],[1966,1151207],[1967,1179760],[1968,1209505],[1969,1240372],[1970,1272408],[1971,1305794],[1972,1340458],[1973,1376455],[1974,1414408],[1975,1453638],[1976,1494409],[1977,1536769],[1978,1580775],[1979,1626497],[1980,1674005],[1981,1723397],[1982,1774735],[1983,1828053],[1984,1883386],[1985,1941071],[1986,2001363],[1987,2064095],[1988,2129084],[1989,2196100],[1990,2264842],[1991,2336155],[1992,2409073],[1993,2487553],[1994,2568840],[1995,2648529],[1996,2729757],[1997,2800947],[1998,2878481],[1999,2970784],[2000,3102404],[2001,3238410],[2002,3328795],[2003,3412576],[2004,3502035],[2005,3602269],[2006,3702314],[2007,3800610],[2008,3903318]],"lifeExpectancy":[[1800,32.7],[1945,32.7],[1950,41.21],[1951,41.62],[1952,42.42],[1953,43.21],[1954,43.98],[1955,44.73],[1956,45.47],[1957,46.18],[1958,46.89],[1959,47.57],[1960,48.24],[1961,48.9],[1962,49.54],[1963,50.17],[1964,50.79],[1965,51.41],[1966,52.02],[1967,52.62],[1968,53.22],[1969,53.82],[1970,54.42],[1971,55.01],[1972,55.61],[1973,56.19],[1974,56.76],[1975,57.31],[1976,57.83],[1977,58.34],[1978,58.8],[1979,59.23],[1980,59.6],[1981,59.91],[1982,60.15],[1983,60.33],[1984,60.43],[1985,60.44],[1986,60.37],[1987,60.21],[1988,59.98],[1989,59.66],[1990,59.26],[1991,58.76],[1992,58.16],[1993,57.5],[1994,56.8],[1995,56.09],[1996,55.41],[1997,54.8],[1998,54.28],[1999,53.87],[2000,53.58],[2001,53.39],[2002,53.29],[2003,53.24],[2004,53.24],[2005,53.28],[2006,53.35],[2007,53.46],[2008,53.59],[2009,53.75]]},{"name":"Cote d'Ivoire","region":"Sub-Saharan Africa","income":[[1800,549.19],[1820,549.19],[1913,848.53],[1950,1344.43],[1951,1366.57],[1952,1388.59],[1953,1410.48],[1954,1433.43],[1955,1455.9],[1956,1478.01],[1957,1500.9],[1958,1522.78],[1959,1537.94],[1960,1622.67],[1961,1714.79],[1962,1728.87],[1963,1935.62],[1964,2192.29],[1965,2055.67],[1966,2120.46],[1967,2052.05],[1968,2258.48],[1969,2245],[1970,2367.24],[1971,2364.51],[1972,2378.2],[1973,2453.1],[1974,2421.08],[1975,2324.96],[1976,2501.3],[1977,2517.74],[1978,2661.38],[1979,2608.89],[1980,2704.73],[1981,2695.54],[1982,2602.71],[1983,2411.97],[1984,2250.26],[1985,2279.11],[1986,2267.42],[1987,2156.96],[1988,2049.2],[1989,1972.84],[1990,1760.42],[1991,1692.62],[1992,1648.07],[1993,1598.85],[1994,1577.61],[1995,1640.62],[1996,1724],[1997,1786.27],[1998,1840.24],[1999,1830.03],[2000,1746.31],[2001,1710.01],[2002,1648.8],[2003,1587.23],[2004,1579.42],[2005,1575],[2006,1540.28],[2007,1519.12],[2008,1509.24],[2009,1520.23]],"population":[[1800,1088530],[1820,1088530],[1950,2860288],[1951,2918070],[1952,2977019],[1953,3037159],[1954,3098513],[1955,3164270],[1956,3231423],[1957,3300000],[1958,3373788],[1959,3463050],[1960,3576077],[1961,3700174],[1962,3832408],[1963,3985277],[1964,4148402],[1965,4326838],[1966,4526508],[1967,4744870],[1968,4983741],[1969,5234620],[1970,5503630],[1971,5786465],[1972,6071696],[1973,6351885],[1974,6621723],[1975,6888884],[1976,7170368],[1977,7459574],[1978,7756303],[1979,8061217],[1980,8375546],[1981,8697986],[1982,9025951],[1983,9360268],[1984,9701389],[1985,10049353],[1986,10403065],[1987,10761098],[1988,11122436],[1989,11484678],[1990,11981454],[1991,12461399],[1992,12772596],[1993,13139524],[1994,13582754],[1995,13988434],[1996,14336812],[1997,14625967],[1998,14878476],[1999,15200755],[2000,15563387],[2001,15909606],[2002,16252726],[2003,16595981],[2004,16944598],[2005,17298040],[2006,17654843],[2007,18013409],[2008,18373060]],"lifeExpectancy":[[1800,31.9],[1945,31.9],[1950,36.64],[1951,36.8],[1952,37.13],[1953,37.48],[1954,37.87],[1955,38.29],[1956,38.74],[1957,39.21],[1958,39.7],[1959,40.21],[1960,40.71],[1961,41.21],[1962,41.69],[1963,42.16],[1964,42.64],[1965,43.14],[1966,43.72],[1967,44.38],[1968,45.15],[1969,46.02],[1970,46.99],[1971,48.05],[1972,49.16],[1973,50.27],[1974,51.36],[1975,52.38],[1976,53.28],[1977,54.07],[1978,54.73],[1979,55.26],[1980,55.66],[1981,55.96],[1982,56.2],[1983,56.39],[1984,56.56],[1985,56.72],[1986,56.87],[1987,57.02],[1988,57.14],[1989,57.24],[1990,57.3],[1991,57.31],[1992,57.26],[1993,57.16],[1994,57],[1995,56.79],[1996,56.53],[1997,56.24],[1998,55.94],[1999,55.66],[2000,55.45],[2001,55.32],[2002,55.3],[2003,55.4],[2004,55.61],[2005,55.94],[2006,56.36],[2007,56.84],[2008,57.34],[2009,57.86]]},{"name":"Equatorial Guinea","region":"Sub-Saharan Africa","income":[[1800,379.13],[1820,379.13],[1913,361.54],[1950,354.77],[1951,368.45],[1952,375.64],[1953,385.57],[1954,401.06],[1955,407.34],[1956,418.34],[1957,426.1],[1958,433.52],[1959,451.56],[1960,490.52],[1961,529.99],[1962,582.84],[1963,661.42],[1964,752.29],[1965,844.87],[1966,869.18],[1967,915.6],[1968,935.83],[1969,896.39],[1970,860.36],[1971,779.61],[1972,672.41],[1973,700.14],[1974,741.54],[1975,850.5],[1976,954.17],[1977,958.57],[1978,1033.54],[1979,1012.78],[1980,970.46],[1981,935.92],[1982,927.83],[1983,917.08],[1984,1103.64],[1985,920.91],[1986,936.05],[1987,966.9],[1988,1010.4],[1989,1025.24],[1990,1027.71],[1991,1048.47],[1992,1132.06],[1993,1172.91],[1994,1201.49],[1995,1337.98],[1996,1684.68],[1997,2814.48],[1998,3349.46],[1999,4623.26],[2000,5240.45],[2001,7192.38],[2002,7703.5],[2003,8913.56],[2004,11487.29],[2005,11999],[2006,11807.73],[2007,13934.25],[2008,14988.85],[2009,15342.2]],"population":[[1800,80377],[1820,80377],[1920,112000],[1932,167000],[1942,171000],[1950,211204],[1951,214064],[1952,216964],[1953,219902],[1954,222880],[1955,225899],[1956,229383],[1957,232922],[1958,236514],[1959,240163],[1960,243867],[1961,248028],[1962,249220],[1963,250419],[1964,251623],[1965,252833],[1966,256349],[1967,259864],[1968,263377],[1969,266898],[1970,270435],[1971,273999],[1972,277603],[1973,271301],[1974,249952],[1975,213292],[1976,190808],[1977,192675],[1978,194597],[1979,221299],[1980,256009],[1981,271778],[1982,285483],[1983,299577],[1984,314447],[1985,324741],[1986,332827],[1987,341244],[1988,349968],[1989,359008],[1990,368379],[1991,378008],[1992,387838],[1993,397863],[1994,408095],[1995,418534],[1996,429158],[1997,439971],[1998,450938],[1999,462037],[2000,473216],[2001,484425],[2002,495627],[2003,506800],[2004,517927],[2005,529034],[2006,540109],[2007,551201],[2008,562339]],"lifeExpectancy":[[1800,29.8],[1945,29.8],[1950,33.88],[1951,34.03],[1952,34.33],[1953,34.63],[1954,34.93],[1955,35.23],[1956,35.53],[1957,35.83],[1958,36.13],[1959,36.43],[1960,36.73],[1961,37.03],[1962,37.33],[1963,37.63],[1964,37.93],[1965,38.24],[1966,38.54],[1967,38.84],[1968,39.14],[1969,39.44],[1970,39.74],[1971,40.05],[1972,40.35],[1973,40.65],[1974,40.95],[1975,41.25],[1976,41.55],[1977,41.85],[1978,42.17],[1979,42.48],[1980,42.81],[1981,43.16],[1982,43.52],[1983,43.89],[1984,44.27],[1985,44.67],[1986,45.08],[1987,45.5],[1988,45.92],[1989,46.34],[1990,46.74],[1991,47.13],[1992,47.48],[1993,47.8],[1994,48.09],[1995,48.32],[1996,48.49],[1997,48.61],[1998,48.68],[1999,48.72],[2000,48.74],[2001,48.77],[2002,48.82],[2003,48.92],[2004,49.08],[2005,49.29],[2006,49.57],[2007,49.89],[2008,50.25],[2009,50.64]]},{"name":"Eritrea","region":"Sub-Saharan Africa","income":[[1800,583.95],[1820,583.95],[1913,381.13],[1950,321.62],[1951,325.28],[1952,328.94],[1953,342.07],[1954,336.19],[1955,348.03],[1956,353.14],[1957,344.16],[1958,348.98],[1959,351.76],[1960,362.82],[1961,373.26],[1962,381],[1963,422.94],[1964,434.87],[1965,451.17],[1966,459.13],[1967,468.79],[1968,466.87],[1969,473.94],[1970,490.38],[1971,500.27],[1972,514.32],[1973,519.46],[1974,513.76],[1975,502.68],[1976,503.64],[1977,505.75],[1978,491.88],[1979,517.1],[1980,534.43],[1981,531.04],[1982,524.88],[1983,536.48],[1984,513.94],[1985,472.36],[1986,491.55],[1987,521.13],[1988,512.63],[1989,501.93],[1990,476.62],[1991,526.15],[1992,582.86],[1993,658.71],[1994,794.98],[1995,806.51],[1996,866.1],[1997,913.47],[1998,905.29],[1999,877.61],[2000,741.57],[2001,775.23],[2002,765.35],[2003,713.58],[2004,694.36],[2005,685],[2006,636.32],[2007,624.3],[2008,545.79],[2009,548.37]],"population":[[1800,205010],[1820,205010],[1950,1402510],[1951,1420279],[1952,1438760],[1953,1457971],[1954,1477939],[1955,1498684],[1956,1520231],[1957,1542611],[1958,1565847],[1959,1589868],[1960,1614698],[1961,1640231],[1962,1666618],[1963,1693045],[1964,1718392],[1965,1746439],[1966,1773393],[1967,1820319],[1968,1857075],[1969,2007110],[1970,2160460],[1971,2208336],[1972,2260187],[1973,2340837],[1974,2380509],[1975,2421037],[1976,2469199],[1977,2512642],[1978,2537978],[1979,2556806],[1980,2568741],[1981,2592782],[1982,2637297],[1983,2693884],[1984,2759280],[1985,2789056],[1986,2837875],[1987,2915959],[1988,2978325],[1989,2989759],[1990,2996243],[1991,3310098],[1992,3668440],[1993,3743948],[1994,3815601],[1995,3858978],[1996,3926212],[1997,4058319],[1998,4183431],[1999,4317425],[2000,4356581],[2001,4360461],[2002,4414865],[2003,4470145],[2004,4554408],[2005,4669638],[2006,4786994],[2007,4906585],[2008,5028475]],"lifeExpectancy":[[1800,30.2],[1945,30.2],[1950,35.08],[1951,35.29],[1952,35.72],[1953,36.14],[1954,36.56],[1955,36.99],[1956,37.41],[1957,37.84],[1958,38.26],[1959,38.69],[1960,39.11],[1961,39.53],[1962,39.95],[1963,40.37],[1964,40.78],[1965,41.19],[1966,41.61],[1967,42.04],[1968,42.47],[1969,42.89],[1970,43.3],[1971,43.66],[1972,43.98],[1973,44.23],[1974,44.42],[1975,44.53],[1976,44.54],[1977,44.47],[1978,44.35],[1979,44.19],[1980,44.05],[1981,43.97],[1982,43.99],[1983,44.13],[1984,44.41],[1985,44.82],[1986,45.36],[1987,45.98],[1988,46.65],[1989,47.36],[1990,48.09],[1991,48.87],[1992,49.68],[1993,50.53],[1994,51.4],[1995,52.27],[1996,53.11],[1997,53.9],[1998,54.65],[1999,55.33],[2000,55.94],[2001,56.5],[2002,57],[2003,57.48],[2004,57.93],[2005,58.37],[2006,58.8],[2007,59.21],[2008,59.62],[2009,60.03]]},{"name":"Ethiopia","region":"Sub-Saharan Africa","income":[[1800,619.21],[1820,619.21],[1913,415.14],[1950,354.09],[1951,358.12],[1952,362.15],[1953,376.6],[1954,370.13],[1955,383.17],[1956,388.79],[1957,378.9],[1958,384.21],[1959,387.26],[1960,399.45],[1961,410.94],[1962,419.46],[1963,465.63],[1964,478.77],[1965,496.71],[1966,505.48],[1967,516.12],[1968,514],[1969,521.78],[1970,539.88],[1971,550.77],[1972,566.24],[1973,571.9],[1974,565.62],[1975,553.43],[1976,554.48],[1977,556.81],[1978,541.54],[1979,569.31],[1980,588.38],[1981,584.64],[1982,577.86],[1983,590.64],[1984,565.82],[1985,520.04],[1986,541.17],[1987,573.74],[1988,564.37],[1989,552.6],[1990,524.74],[1991,489.83],[1992,421.35],[1993,462.36],[1994,460.14],[1995,471.41],[1996,512.79],[1997,515.89],[1998,481.46],[1999,496.87],[2000,512.36],[2001,537.42],[2002,530.05],[2003,498.42],[2004,549.6],[2005,591],[2006,642.27],[2007,699.61],[2008,757.88],[2009,812.16]],"population":[[1800,2948990],[1820,2948990],[1950,20174562],[1951,20511408],[1952,20860941],[1953,21223618],[1954,21599912],[1955,21990323],[1956,22395376],[1957,22815614],[1958,23251610],[1959,23702450],[1960,24168672],[1961,24648849],[1962,25145372],[1963,25659679],[1964,26192357],[1965,26740270],[1966,27307798],[1967,27860297],[1968,28451255],[1969,28962280],[1970,29468504],[1971,30099662],[1972,30770372],[1973,31445177],[1974,32199367],[1975,32975868],[1976,33824835],[1977,34617799],[1978,35216317],[1979,35664267],[1980,36036457],[1981,37056244],[1982,38111756],[1983,39204501],[1984,40072430],[1985,40698078],[1986,41662199],[1987,42999530],[1988,44606289],[1989,46396556],[1990,48197268],[1991,50274862],[1992,52088559],[1993,53446251],[1994,54954863],[1995,56628083],[1996,58283759],[1997,59861301],[1998,61436985],[1999,63054968],[2000,64690052],[2001,66308836],[2002,67946797],[2003,69628079],[2004,71336571],[2005,73053286],[2006,74777981],[2007,76511887],[2008,78254090]],"lifeExpectancy":[[1800,29.7],[1945,29.7],[1950,33.3],[1951,33.47],[1952,33.83],[1953,34.25],[1954,34.72],[1955,35.24],[1956,35.81],[1957,36.42],[1958,37.07],[1959,37.74],[1960,38.41],[1961,39.07],[1962,39.7],[1963,40.28],[1964,40.8],[1965,41.25],[1966,41.65],[1967,42.01],[1968,42.33],[1969,42.64],[1970,42.93],[1971,43.21],[1972,43.49],[1973,43.76],[1974,44.01],[1975,44.21],[1976,44.32],[1977,44.33],[1978,44.24],[1979,44.08],[1980,43.9],[1981,43.76],[1982,43.72],[1983,43.82],[1984,44.07],[1985,44.45],[1986,44.93],[1987,45.46],[1988,45.99],[1989,46.49],[1990,46.96],[1991,47.41],[1992,47.84],[1993,48.28],[1994,48.72],[1995,49.17],[1996,49.62],[1997,50.07],[1998,50.52],[1999,50.96],[2000,51.4],[2001,51.85],[2002,52.31],[2003,52.78],[2004,53.27],[2005,53.76],[2006,54.26],[2007,54.75],[2008,55.22],[2009,55.69]]},{"name":"Gabon","region":"Sub-Saharan Africa","income":[[1800,377.54],[1820,377.54],[1913,583.32],[1950,4041.34],[1951,4166.22],[1952,4293.48],[1953,4422.18],[1954,4556.15],[1955,4694.68],[1956,4833.63],[1957,4976.2],[1958,5121.54],[1959,5268.77],[1960,5440.07],[1961,6209.47],[1962,6631.46],[1963,6988.93],[1964,7256.21],[1965,7803.24],[1966,8093.55],[1967,8358.76],[1968,8486.71],[1969,9060.22],[1970,9691.64],[1971,10478.03],[1972,11401.95],[1973,12250.84],[1974,16647.43],[1975,19327.89],[1976,25536.95],[1977,21745.57],[1978,16084.69],[1979,15732.21],[1980,15696.83],[1981,16042.76],[1982,15113.36],[1983,15510.03],[1984,16193.67],[1985,15349.56],[1986,14768.66],[1987,11864.41],[1988,12980.29],[1989,13663.2],[1990,13944.56],[1991,14364.38],[1992,13522.16],[1993,13664.83],[1994,13792.03],[1995,14105.84],[1996,14258.12],[1997,14722.84],[1998,14894.74],[1999,13276.45],[2000,12764.05],[2001,12787.09],[2002,12521.71],[2003,12610.07],[2004,12568.46],[2005,12742],[2006,12577.37],[2007,12920.7],[2008,13075.4],[2009,12704.99]],"population":[[1800,158227],[1820,158227],[1950,415767],[1951,418227],[1952,420702],[1953,423276],[1954,425951],[1955,428772],[1956,431741],[1957,434904],[1958,438310],[1959,442007],[1960,446003],[1961,450485],[1962,455661],[1963,461357],[1964,467592],[1965,474386],[1966,481519],[1967,489004],[1968,496853],[1969,503763],[1970,514597],[1971,525927],[1972,537977],[1973,560622],[1974,597096],[1975,647426],[1976,687695],[1977,706367],[1978,726252],[1979,722642],[1980,713502],[1981,730507],[1982,753874],[1983,778618],[1984,804827],[1985,832590],[1986,858970],[1987,880397],[1988,899193],[1989,918253],[1990,937493],[1991,959814],[1992,985739],[1993,1012516],[1994,1040151],[1995,1068383],[1996,1096999],[1997,1126189],[1998,1156362],[1999,1194780],[2000,1235484],[2001,1268125],[2002,1299304],[2003,1331419],[2004,1363116],[2005,1394307],[2006,1424906],[2007,1454867],[2008,1484149]],"lifeExpectancy":[[1800,30.6],[1945,30.6],[1950,35.97],[1951,36.26],[1952,36.8],[1953,37.29],[1954,37.72],[1955,38.11],[1956,38.44],[1957,38.74],[1958,39.01],[1959,39.28],[1960,39.58],[1961,39.94],[1962,40.39],[1963,40.94],[1964,41.6],[1965,42.36],[1966,43.2],[1967,44.08],[1968,44.96],[1969,45.84],[1970,46.69],[1971,47.5],[1972,48.29],[1973,49.05],[1974,49.8],[1975,50.54],[1976,51.28],[1977,52.04],[1978,52.82],[1979,53.61],[1980,54.43],[1981,55.28],[1982,56.15],[1983,57.02],[1984,57.86],[1985,58.65],[1986,59.36],[1987,59.98],[1988,60.48],[1989,60.86],[1990,61.13],[1991,61.29],[1992,61.37],[1993,61.39],[1994,61.36],[1995,61.27],[1996,61.11],[1997,60.88],[1998,60.57],[1999,60.24],[2000,59.9],[2001,59.61],[2002,59.4],[2003,59.3],[2004,59.32],[2005,59.46],[2006,59.72],[2007,60.07],[2008,60.46],[2009,60.89]]},{"name":"Ghana","region":"Sub-Saharan Africa","income":[[1800,505.14],[1820,505.14],[1913,780.48],[1950,943.1],[1951,952.97],[1952,911.3],[1953,1010.36],[1954,1107.53],[1955,1008.52],[1956,1039.12],[1957,1043.56],[1958,998.03],[1959,1110.59],[1960,1158.85],[1961,1167.03],[1962,1190.04],[1963,1197.51],[1964,1189.01],[1965,1170.79],[1966,1138.51],[1967,1125.7],[1968,1108.41],[1969,1114.11],[1970,1197.15],[1971,1253.21],[1972,1178.22],[1973,1174.72],[1974,1223.12],[1975,1048.26],[1976,990.2],[1977,993.22],[1978,1059.27],[1979,1017.28],[1980,972.84],[1981,960.18],[1982,876.03],[1983,784.53],[1984,807.25],[1985,822.8],[1986,831.21],[1987,847.01],[1988,870.05],[1989,889.39],[1990,893.8],[1991,915.14],[1992,925.06],[1993,942.02],[1994,945.56],[1995,961.42],[1996,984.87],[1997,1005.25],[1998,1030.05],[1999,1052.28],[2000,1067.6],[2001,1088.32],[2002,1111.98],[2003,1143.69],[2004,1181.71],[2005,1225],[2006,1271.24],[2007,1309.88],[2008,1370.14],[2009,1382.95]],"population":[[1800,2016034],[1820,2016034],[1870,1579000],[1913,2043000],[1950,5297454],[1951,5436555],[1952,5581001],[1953,5731008],[1954,5886798],[1955,6048606],[1956,6216679],[1957,6391288],[1958,6572719],[1959,6761280],[1960,6958283],[1961,7153508],[1962,7355248],[1963,7563839],[1964,7781813],[1965,8009602],[1966,8245481],[1967,8490213],[1968,8744302],[1969,9009048],[1970,8788945],[1971,9065500],[1972,9354120],[1973,9649958],[1974,9905330],[1975,10118240],[1976,10333176],[1977,10538093],[1978,10720559],[1979,10878226],[1980,11015630],[1981,11176529],[1982,11400338],[1983,12150541],[1984,12829647],[1985,13224725],[1986,13776193],[1987,14168101],[1988,14568008],[1989,14975941],[1990,15399466],[1991,15837581],[1992,16278738],[1993,16784962],[1994,17274479],[1995,17669087],[1996,18041282],[1997,18418288],[1998,18819453],[1999,19232823],[2000,19657719],[2001,20093021],[2002,20550751],[2003,21019630],[2004,21483085],[2005,21946247],[2006,22409572],[2007,22873338],[2008,23336661]],"lifeExpectancy":[[1800,28],[1921,28],[1925,28],[1950,42.81],[1951,42.99],[1952,43.36],[1953,43.71],[1954,44.04],[1955,44.37],[1956,44.69],[1957,44.99],[1958,45.28],[1959,45.56],[1960,45.83],[1961,46.09],[1962,46.35],[1963,46.6],[1964,46.86],[1965,47.14],[1966,47.43],[1967,47.75],[1968,48.1],[1969,48.48],[1970,48.89],[1971,49.32],[1972,49.77],[1973,50.23],[1974,50.69],[1975,51.14],[1976,51.57],[1977,51.98],[1978,52.36],[1979,52.71],[1980,53.03],[1981,53.33],[1982,53.61],[1983,53.88],[1984,54.17],[1985,54.49],[1986,54.9],[1987,55.39],[1988,55.97],[1989,56.6],[1990,57.24],[1991,57.85],[1992,58.38],[1993,58.77],[1994,59.01],[1995,59.09],[1996,59.02],[1997,58.83],[1998,58.56],[1999,58.25],[2000,57.91],[2001,57.57],[2002,57.24],[2003,56.94],[2004,56.7],[2005,56.54],[2006,56.47],[2007,56.51],[2008,56.62],[2009,56.83]]},{"name":"Guinea","region":"Sub-Saharan Africa","income":[[1800,375.96],[1820,375.96],[1913,448.43],[1950,481],[1951,502.27],[1952,510.2],[1953,520.99],[1954,543.59],[1955,553.34],[1956,565.42],[1957,576.27],[1958,583.77],[1959,606.89],[1960,621.38],[1961,650.64],[1962,686.37],[1963,637.63],[1964,666.64],[1965,699.08],[1966,700.53],[1967,708.76],[1968,716.29],[1969,723.13],[1970,733.71],[1971,741.47],[1972,741.67],[1973,758.7],[1974,795.61],[1975,812.14],[1976,873.48],[1977,874.69],[1978,879.33],[1979,862.64],[1980,873.69],[1981,860.19],[1982,857.25],[1983,848.68],[1984,833.19],[1985,807.66],[1986,801.25],[1987,805.57],[1988,831.91],[1989,843.64],[1990,834.48],[1991,797.48],[1992,794.35],[1993,809.58],[1994,815.22],[1995,825.5],[1996,838.4],[1997,869.45],[1998,897.23],[1999,909.94],[2000,906.62],[2001,934.76],[2002,945.58],[2003,934.37],[2004,937.47],[2005,946],[2006,939.12],[2007,925.58],[2008,940.88],[2009,908.86]],"population":[[1800,983959],[1820,983959],[1950,2585509],[1951,2624584],[1952,2664249],[1953,2704514],[1954,2745388],[1955,2786879],[1956,2830712],[1957,2876726],[1958,2924954],[1959,2975408],[1960,3028117],[1961,3083075],[1962,3140003],[1963,3198659],[1964,3259080],[1965,3321330],[1966,3385447],[1967,3451418],[1968,3519302],[1969,3589194],[1970,3661175],[1971,3735240],[1972,3811387],[1973,3889716],[1974,3970332],[1975,4053377],[1976,4138911],[1977,4227026],[1978,4317827],[1979,4411454],[1980,4508009],[1981,4607654],[1982,4710497],[1983,4816673],[1984,5045067],[1985,5327721],[1986,5505366],[1987,5650262],[1988,5800268],[1989,5955501],[1990,6278696],[1991,6727693],[1992,6990574],[1993,7195158],[1994,7431162],[1995,7682082],[1996,7949756],[1997,8048834],[1998,8174290],[1999,8431352],[2000,8638858],[2001,8713005],[2002,8807818],[2003,9020431],[2004,9234177],[2005,9452670],[2006,9690222],[2007,9947814],[2008,10211437]],"lifeExpectancy":[[1800,29.5],[1945,29.5],[1950,34.62],[1951,34.69],[1952,34.84],[1953,35],[1954,35.17],[1955,35.35],[1956,35.54],[1957,35.75],[1958,35.96],[1959,36.18],[1960,36.42],[1961,36.66],[1962,36.91],[1963,37.17],[1964,37.45],[1965,37.72],[1966,38],[1967,38.28],[1968,38.56],[1969,38.85],[1970,39.16],[1971,39.49],[1972,39.85],[1973,40.26],[1974,40.69],[1975,41.16],[1976,41.64],[1977,42.12],[1978,42.6],[1979,43.08],[1980,43.54],[1981,43.99],[1982,44.43],[1983,44.87],[1984,45.32],[1985,45.78],[1986,46.25],[1987,46.74],[1988,47.24],[1989,47.75],[1990,48.27],[1991,48.79],[1992,49.28],[1993,49.76],[1994,50.23],[1995,50.69],[1996,51.15],[1997,51.64],[1998,52.15],[1999,52.7],[2000,53.27],[2001,53.86],[2002,54.46],[2003,55.05],[2004,55.64],[2005,56.21],[2006,56.76],[2007,57.31],[2008,57.84],[2009,58.35]]},{"name":"Guinea-Bissau","region":"Sub-Saharan Africa","income":[[1800,345],[1820,345],[1913,366.87],[1950,375.95],[1951,390.83],[1952,405.9],[1953,422.18],[1954,495.74],[1955,464.95],[1956,516.5],[1957,537.35],[1958,540.85],[1959,534.3],[1960,550.27],[1961,574.7],[1962,597.24],[1963,608.93],[1964,659.09],[1965,692.24],[1966,723.48],[1967,752.62],[1968,762.76],[1969,786.65],[1970,809.41],[1971,773.81],[1972,820.22],[1973,818.98],[1974,847.35],[1975,859.11],[1976,837.67],[1977,764.73],[1978,850.21],[1979,852.16],[1980,700.4],[1981,808.75],[1982,838.12],[1983,752.58],[1984,765.49],[1985,789.16],[1986,765.22],[1987,736.42],[1988,747.97],[1989,734.08],[1990,740.35],[1991,759.66],[1992,745.54],[1993,737.76],[1994,739.54],[1995,754.03],[1996,772.64],[1997,796.66],[1998,559.2],[1999,590.7],[2000,632.08],[2001,619.45],[2002,575.7],[2003,560.94],[2004,562.08],[2005,569],[2006,568.44],[2007,557.62],[2008,564.6],[2009,568.94]],"population":[[1800,218167],[1820,218167],[1950,573268],[1951,576948],[1952,580653],[1953,584381],[1954,588133],[1955,591909],[1956,596365],[1957,601095],[1958,606044],[1959,611217],[1960,616682],[1961,622070],[1962,627820],[1963,633939],[1964,610284],[1965,603780],[1966,598111],[1967,601287],[1968,611160],[1969,615749],[1970,620020],[1971,623282],[1972,625361],[1973,633266],[1974,640043],[1975,680919],[1976,732707],[1977,745228],[1978,758113],[1979,771376],[1980,789053],[1981,807257],[1982,825987],[1983,845212],[1984,864949],[1985,885234],[1986,906084],[1987,927524],[1988,949625],[1989,972421],[1990,995991],[1991,1020178],[1992,1050938],[1993,1084327],[1994,1116326],[1995,1143057],[1996,1165914],[1997,1193708],[1998,1221772],[1999,1249889],[2000,1278273],[2001,1305832],[2002,1332459],[2003,1359242],[2004,1386228],[2005,1413446],[2006,1442029],[2007,1472041],[2008,1502442]],"lifeExpectancy":[[1800,29.3],[1945,29.3],[1950,31.97],[1951,32.1],[1952,32.37],[1953,32.63],[1954,32.9],[1955,33.16],[1956,33.43],[1957,33.7],[1958,33.97],[1959,34.24],[1960,34.51],[1961,34.78],[1962,35.06],[1963,35.33],[1964,35.6],[1965,35.86],[1966,36.13],[1967,36.4],[1968,36.67],[1969,36.94],[1970,37.2],[1971,37.46],[1972,37.71],[1973,37.95],[1974,38.2],[1975,38.45],[1976,38.73],[1977,39.04],[1978,39.38],[1979,39.76],[1980,40.17],[1981,40.62],[1982,41.08],[1983,41.56],[1984,42.02],[1985,42.46],[1986,42.84],[1987,43.17],[1988,43.43],[1989,43.65],[1990,43.81],[1991,43.96],[1992,44.1],[1993,44.26],[1994,44.45],[1995,44.66],[1996,44.89],[1997,45.14],[1998,45.38],[1999,45.61],[2000,45.84],[2001,46.05],[2002,46.27],[2003,46.48],[2004,46.71],[2005,46.95],[2006,47.22],[2007,47.51],[2008,47.84],[2009,48.2]]},{"name":"Kenya","region":"Sub-Saharan Africa","income":[[1800,512.93],[1820,512.93],[1913,792.51],[1950,832.27],[1951,986.6],[1952,853.54],[1953,809.44],[1954,878.6],[1955,918.37],[1956,941.46],[1957,944.44],[1958,926.84],[1959,921.34],[1960,928.11],[1961,878.15],[1962,896.97],[1963,912.86],[1964,970.14],[1965,950.16],[1966,1038.15],[1967,1056.74],[1968,1096.54],[1969,1126.71],[1970,1170.44],[1971,1203.44],[1972,1222.36],[1973,1240.76],[1974,1255.49],[1975,1204.84],[1976,1206.85],[1977,1267.61],[1978,1328.72],[1979,1325.06],[1980,1344.17],[1981,1321.86],[1982,1348.23],[1983,1305.72],[1984,1279.51],[1985,1286.56],[1986,1330.65],[1987,1361.94],[1988,1396.42],[1989,1413.7],[1990,1429],[1991,1402.96],[1992,1341.92],[1993,1305.89],[1994,1309.87],[1995,1335.67],[1996,1361.07],[1997,1360.49],[1998,1355.29],[1999,1346.86],[2000,1318.49],[2001,1304.01],[2002,1287.51],[2003,1291.42],[2004,1317.47],[2005,1359],[2006,1419.87],[2007,1492.25],[2008,1488.42],[2009,1493.53]],"population":[[1800,2574000],[1921,2574000],[1931,3041000],[1949,5406000],[1950,6121184],[1951,6289336],[1952,6464046],[1953,6646268],[1954,6836360],[1955,7033999],[1956,7240247],[1957,7454779],[1958,7678739],[1959,7912591],[1960,8156827],[1961,8411966],[1962,8678557],[1963,8957178],[1964,9247518],[1965,9549179],[1966,9863639],[1967,10191512],[1968,10532389],[1969,10887934],[1970,11247182],[1971,11633030],[1972,12044785],[1973,12482054],[1974,12944287],[1975,13433414],[1976,13951436],[1977,14500404],[1978,15079690],[1979,15690251],[1980,16331401],[1981,16988530],[1982,17661452],[1983,18349550],[1984,19051861],[1985,19763285],[1986,20479093],[1987,21198082],[1988,21918633],[1989,22638202],[1990,23358413],[1991,24125055],[1992,25020539],[1993,25813694],[1994,26430941],[1995,27060142],[1996,27670930],[1997,28263827],[1998,28826109],[1999,29383563],[2000,29985839],[2001,30652299],[2002,31386842],[2003,32168495],[2004,32982109],[2005,33829590],[2006,34707817],[2007,35610177],[2008,36529155]],"lifeExpectancy":[[1800,25.5],[1922,25.5],[1927,23.92],[1937,26.37],[1945,28.82],[1950,41.57],[1951,41.72],[1952,42.06],[1953,42.44],[1954,42.87],[1955,43.35],[1956,43.87],[1957,44.44],[1958,45.04],[1959,45.67],[1960,46.32],[1961,46.96],[1962,47.6],[1963,48.21],[1964,48.8],[1965,49.36],[1966,49.92],[1967,50.47],[1968,51.02],[1969,51.59],[1970,52.16],[1971,52.74],[1972,53.31],[1973,53.86],[1974,54.41],[1975,54.95],[1976,55.49],[1977,56.04],[1978,56.6],[1979,57.16],[1980,57.69],[1981,58.17],[1982,58.59],[1983,58.92],[1984,59.17],[1985,59.35],[1986,59.5],[1987,59.63],[1988,59.74],[1989,59.83],[1990,59.84],[1991,59.72],[1992,59.43],[1993,58.95],[1994,58.29],[1995,57.47],[1996,56.52],[1997,55.5],[1998,54.51],[1999,53.58],[2000,52.82],[2001,52.28],[2002,51.98],[2003,51.91],[2004,52.08],[2005,52.46],[2006,53],[2007,53.63],[2008,54.3],[2009,54.95]]},{"name":"Lesotho","region":"Sub-Saharan Africa","income":[[1800,364],[1820,364],[1913,303.98],[1950,282.95],[1951,294.6],[1952,298.85],[1953,306.02],[1954,317.54],[1955,322.51],[1956,329.2],[1957,336],[1958,342.58],[1959,346.22],[1960,364.73],[1961,364.1],[1962,411.8],[1963,446.09],[1964,472.32],[1965,472.45],[1966,459.69],[1967,498.64],[1968,485.57],[1969,481.65],[1970,480.98],[1971,426.31],[1972,496.58],[1973,612.03],[1974,634.32],[1975,569.25],[1976,648.41],[1977,745.37],[1978,839.36],[1979,765.89],[1980,800.51],[1981,788.82],[1982,797.26],[1983,710.85],[1984,752.06],[1985,759.02],[1986,755.05],[1987,773.99],[1988,851.83],[1989,922.62],[1990,940.26],[1991,955.97],[1992,977.49],[1993,991.56],[1994,967.11],[1995,1067.93],[1996,1149.19],[1997,1186.15],[1998,1136.96],[1999,1153.3],[2000,1186.64],[2001,1221.48],[2002,1275.18],[2003,1311.24],[2004,1369.81],[2005,1415],[2006,1479.94],[2007,1488.72],[2008,1527.28],[2009,1521.4]],"population":[[1800,276361],[1820,276361],[1950,726182],[1951,737230],[1952,748747],[1953,760747],[1954,773249],[1955,786192],[1956,799548],[1957,813338],[1958,827697],[1959,842730],[1960,858551],[1961,875282],[1962,893143],[1963,912006],[1964,931826],[1965,952459],[1966,973983],[1967,996380],[1968,1019394],[1969,1043044],[1970,1067136],[1971,1091675],[1972,1116779],[1973,1142460],[1974,1168731],[1975,1195487],[1976,1222874],[1977,1251524],[1978,1281271],[1979,1312161],[1980,1344218],[1981,1377430],[1982,1411807],[1983,1447280],[1984,1483833],[1985,1521382],[1986,1559868],[1987,1599200],[1988,1639294],[1989,1680103],[1990,1721563],[1991,1762702],[1992,1803195],[1993,1843375],[1994,1882531],[1995,1919569],[1996,1953349],[1997,1982823],[1998,2007073],[1999,2025481],[2000,2037961],[2001,2044848],[2002,2046772],[2003,2044530],[2004,2039070],[2005,2031348],[2006,2022331],[2007,2012649],[2008,2002749]],"lifeExpectancy":[[1800,32.8],[1945,32.8],[1950,41.01],[1951,41.29],[1952,41.85],[1953,42.43],[1954,43.02],[1955,43.62],[1956,44.23],[1957,44.84],[1958,45.45],[1959,46.04],[1960,46.58],[1961,47.07],[1962,47.48],[1963,47.81],[1964,48.06],[1965,48.24],[1966,48.38],[1967,48.5],[1968,48.64],[1969,48.81],[1970,49.02],[1971,49.29],[1972,49.62],[1973,49.99],[1974,50.41],[1975,50.87],[1976,51.4],[1977,51.96],[1978,52.56],[1979,53.18],[1980,53.79],[1981,54.37],[1982,54.9],[1983,55.39],[1984,55.84],[1985,56.29],[1986,56.79],[1987,57.36],[1988,58.01],[1989,58.68],[1990,59.31],[1991,59.79],[1992,60.05],[1993,60],[1994,59.62],[1995,58.85],[1996,57.67],[1997,56.13],[1998,54.34],[1999,52.41],[2000,50.48],[2001,48.71],[2002,47.2],[2003,46.03],[2004,45.24],[2005,44.84],[2006,44.78],[2007,44.94],[2008,45.22],[2009,45.56]]},{"name":"Liberia","region":"Sub-Saharan Africa","income":[[1800,544.65],[1820,544.65],[1913,550.92],[1950,553.44],[1951,571.85],[1952,575.57],[1953,583.97],[1954,601.88],[1955,606.52],[1956,613.67],[1957,620.97],[1958,622.59],[1959,641.9],[1960,645.17],[1961,643.26],[1962,634.2],[1963,631.84],[1964,645.9],[1965,638.98],[1966,738.93],[1967,713.6],[1968,726.35],[1969,756.52],[1970,782.61],[1971,797.21],[1972,803.01],[1973,759.51],[1974,791],[1975,654.74],[1976,662.88],[1977,640.32],[1978,647.93],[1979,658.5],[1980,609.85],[1981,606.16],[1982,572.2],[1983,551.96],[1984,531.2],[1985,508.55],[1986,507.83],[1987,506.11],[1988,490.92],[1989,482.01],[1990,556.52],[1991,658.71],[1992,636.62],[1993,626.15],[1994,644.95],[1995,662.2],[1996,658.47],[1997,609.17],[1998,551.37],[1999,529.79],[2000,519.49],[2001,515.95],[2002,531.48],[2003,365.83],[2004,375.69],[2005,383],[2006,396.99],[2007,414.61],[2008,476.2],[2009,474.9]],"population":[[1800,313543],[1820,313543],[1950,823885],[1951,843231],[1952,863308],[1953,884145],[1954,905784],[1955,928269],[1956,951644],[1957,975950],[1958,1001227],[1959,1027507],[1960,1054837],[1961,1083250],[1962,1112796],[1963,1143525],[1964,1175491],[1965,1208749],[1966,1243371],[1967,1279406],[1968,1316907],[1969,1355941],[1970,1396565],[1971,1438780],[1972,1482628],[1973,1528162],[1974,1575442],[1975,1616410],[1976,1659105],[1977,1703617],[1978,1750011],[1979,1798417],[1980,1848979],[1981,1901768],[1982,1956875],[1983,2014375],[1984,2074333],[1985,2136793],[1986,2201806],[1987,2269414],[1988,2339630],[1989,2412315],[1990,2116666],[1991,1816959],[1992,1912974],[1993,1989395],[1994,1973706],[1995,1974588],[1996,2024800],[1997,2200725],[1998,2455238],[1999,2597815],[2000,2693780],[2001,2758041],[2002,2814651],[2003,2809784],[2004,2807259],[2005,2900269],[2006,3042004],[2007,3193942],[2008,3332483]],"lifeExpectancy":[[1800,31.1],[1945,31.1],[1950,35.89],[1951,36.12],[1952,36.59],[1953,37.05],[1954,37.51],[1955,37.97],[1956,38.42],[1957,38.88],[1958,39.33],[1959,39.78],[1960,40.22],[1961,40.66],[1962,41.1],[1963,41.53],[1964,41.95],[1965,42.38],[1966,42.79],[1967,43.21],[1968,43.62],[1969,44.03],[1970,44.44],[1971,44.86],[1972,45.29],[1973,45.73],[1974,46.15],[1975,46.55],[1976,46.9],[1977,47.18],[1978,47.39],[1979,47.53],[1980,47.59],[1981,47.57],[1982,47.52],[1983,47.44],[1984,47.37],[1985,47.35],[1986,47.39],[1987,47.53],[1988,47.76],[1989,48.08],[1990,48.5],[1991,49.01],[1992,49.57],[1993,50.16],[1994,50.77],[1995,51.38],[1996,51.99],[1997,52.61],[1998,53.23],[1999,53.84],[2000,54.44],[2001,55.02],[2002,55.57],[2003,56.09],[2004,56.58],[2005,57.04],[2006,57.48],[2007,57.9],[2008,58.31],[2009,58.71]]},{"name":"Madagascar","region":"Sub-Saharan Africa","income":[[1800,434.14],[1820,434.14],[1913,670.78],[1950,1383.73],[1951,1413.63],[1952,1443.01],[1953,1471.77],[1954,1501.17],[1955,1531.05],[1956,1560.03],[1957,1589.2],[1958,1618.5],[1959,1646.63],[1960,1637.51],[1961,1638.93],[1962,1643.39],[1963,1594.74],[1964,1624.24],[1965,1583.08],[1966,1581.86],[1967,1634.05],[1968,1707.7],[1969,1733.68],[1970,1784.13],[1971,1812.57],[1972,1748.56],[1973,1663.95],[1974,1657.87],[1975,1638.76],[1976,1547.31],[1977,1544.23],[1978,1465.12],[1979,1566.08],[1980,1535.57],[1981,1364.72],[1982,1302.88],[1983,1277.05],[1984,1196.06],[1985,1188.84],[1986,1163.5],[1987,1155.44],[1988,1140.36],[1989,1152.55],[1990,1163.04],[1991,1058.68],[1992,1040.68],[1993,1031.86],[1994,1001.87],[1995,989.14],[1996,980.06],[1997,986.3],[1998,994.3],[1999,1010.14],[2000,1027.09],[2001,1056.21],[2002,894.64],[2003,953.05],[2004,973.59],[2005,988],[2006,1009.65],[2007,1044.09],[2008,1088.44],[2009,1006.9]],"population":[[1820,1683000],[1950,4620437],[1951,4690031],[1952,4762912],[1953,4839248],[1954,4919118],[1955,5002657],[1956,5090058],[1957,5181679],[1958,5277482],[1959,5377583],[1960,5481721],[1961,5590111],[1962,5703324],[1963,5821158],[1964,5943744],[1965,6070004],[1966,6200000],[1967,6334556],[1968,6473179],[1969,6615873],[1970,6765644],[1971,6920494],[1972,7082430],[1973,7250455],[1974,7423573],[1975,7603790],[1976,7805271],[1977,8007166],[1978,8216944],[1979,8442496],[1980,8676821],[1981,8919844],[1982,9171477],[1983,9432079],[1984,9701947],[1985,9981292],[1986,10270192],[1987,10568642],[1988,10876604],[1989,11194241],[1990,11522099],[1991,11860473],[1992,12210395],[1993,12573284],[1994,12949727],[1995,13340359],[1996,13745709],[1997,14165114],[1998,14598047],[1999,15045015],[2000,15506472],[2001,15982563],[2002,16473477],[2003,16979744],[2004,17501871],[2005,18040341],[2006,18595469],[2007,19167654],[2008,19757525]],"lifeExpectancy":[[1800,30.5],[1945,30.5],[1950,35.75],[1951,35.98],[1952,36.45],[1953,36.91],[1954,37.36],[1955,37.8],[1956,38.23],[1957,38.64],[1958,39.05],[1959,39.46],[1960,39.85],[1961,40.25],[1962,40.65],[1963,41.05],[1964,41.45],[1965,41.85],[1966,42.25],[1967,42.65],[1968,43.05],[1969,43.45],[1970,43.84],[1971,44.24],[1972,44.63],[1973,45.02],[1974,45.42],[1975,45.83],[1976,46.27],[1977,46.73],[1978,47.2],[1979,47.68],[1980,48.13],[1981,48.51],[1982,48.8],[1983,49],[1984,49.12],[1985,49.21],[1986,49.32],[1987,49.52],[1988,49.84],[1989,50.28],[1990,50.84],[1991,51.48],[1992,52.15],[1993,52.81],[1994,53.43],[1995,54.01],[1996,54.54],[1997,55.05],[1998,55.54],[1999,56.03],[2000,56.51],[2001,56.99],[2002,57.48],[2003,57.96],[2004,58.45],[2005,58.93],[2006,59.42],[2007,59.89],[2008,60.36],[2009,60.81]]},{"name":"Malawi","region":"Sub-Saharan Africa","income":[[1800,360],[1820,360],[1913,354.6],[1950,352.47],[1951,360.94],[1952,369.17],[1953,377.47],[1954,385.81],[1955,384.81],[1956,408.52],[1957,416.37],[1958,422.15],[1959,427.44],[1960,428.7],[1961,439.6],[1962,427.9],[1963,409.48],[1964,390.22],[1965,431.95],[1966,463.44],[1967,495.51],[1968,476.61],[1969,493.75],[1970,488.72],[1971,544.85],[1972,584.62],[1973,616.28],[1974,638.79],[1975,643.6],[1976,649.7],[1977,663.22],[1978,703.63],[1979,715.76],[1980,700.07],[1981,645.55],[1982,632.8],[1983,640.17],[1984,649.03],[1985,678.85],[1986,656.77],[1987,635.52],[1988,610.94],[1989,605.5],[1990,602.72],[1991,630.14],[1992,563.2],[1993,607.6],[1994,555.37],[1995,653.33],[1996,685.08],[1997,692.28],[1998,696.47],[1999,705.88],[2000,713.78],[2001,667.79],[2002,665.42],[2003,674.88],[2004,691.85],[2005,691],[2006,769.2],[2007,763.3],[2008,818.38],[2009,866.35]],"population":[[1800,737000],[1901,737000],[1911,970000],[1921,1202000],[1926,1293000],[1931,1603000],[1945,2050000],[1950,2816600],[1951,2866038],[1952,2917802],[1953,2971986],[1954,3028691],[1955,3088155],[1956,3151911],[1957,3221238],[1958,3294697],[1959,3370054],[1960,3450444],[1961,3532056],[1962,3628608],[1963,3726394],[1964,3816197],[1965,3914095],[1966,4023000],[1967,4147252],[1968,4263813],[1969,4379269],[1970,4489313],[1971,4606268],[1972,4730997],[1973,4864937],[1974,5030764],[1975,5267679],[1976,5473443],[1977,5637246],[1978,5791837],[1979,5955844],[1980,6129035],[1981,6311339],[1982,6502825],[1983,6702443],[1984,6909279],[1985,7123455],[1986,7391617],[1987,7824747],[1988,8349217],[1989,8843826],[1990,9286655],[1991,9655208],[1992,10014249],[1993,10182205],[1994,9992214],[1995,9912344],[1996,10143562],[1997,10419991],[1998,10697625],[1999,10977362],[2000,11258163],[2001,11539920],[2002,11824495],[2003,12113276],[2004,12407373],[2005,12707464],[2006,13013926],[2007,13327079],[2008,13647273]],"lifeExpectancy":[[1800,30.3],[1945,30.3],[1950,35.96],[1951,36.03],[1952,36.17],[1953,36.32],[1954,36.49],[1955,36.68],[1956,36.89],[1957,37.1],[1958,37.33],[1959,37.56],[1960,37.8],[1961,38.02],[1962,38.24],[1963,38.45],[1964,38.65],[1965,38.87],[1966,39.11],[1967,39.4],[1968,39.74],[1969,40.13],[1970,40.56],[1971,41.01],[1972,41.47],[1973,41.92],[1974,42.36],[1975,42.78],[1976,43.19],[1977,43.59],[1978,44],[1979,44.41],[1980,44.81],[1981,45.2],[1982,45.56],[1983,45.91],[1984,46.25],[1985,46.61],[1986,47.01],[1987,47.48],[1988,48.03],[1989,48.63],[1990,49.28],[1991,49.94],[1992,50.57],[1993,51.14],[1994,51.6],[1995,51.92],[1996,52.04],[1997,51.96],[1998,51.73],[1999,51.38],[2000,50.99],[2001,50.66],[2002,50.46],[2003,50.44],[2004,50.64],[2005,51.06],[2006,51.66],[2007,52.37],[2008,53.12],[2009,53.88]]},{"name":"Mali","region":"Sub-Saharan Africa","income":[[1800,427.43],[1820,427.43],[1913,434.93],[1950,437.95],[1951,445.16],[1952,452.34],[1953,459.88],[1954,466.94],[1955,474.73],[1956,482.42],[1957,490.38],[1958,498.21],[1959,506.63],[1960,510.59],[1961,503.57],[1962,496.17],[1963,518.77],[1964,532.17],[1965,528.5],[1966,539.18],[1967,545.01],[1968,553.24],[1969,538.49],[1970,559.07],[1971,565.59],[1972,581.37],[1973,554.3],[1974,528.3],[1975,587.58],[1976,651.72],[1977,686.4],[1978,659.18],[1979,806.19],[1980,700.86],[1981,666.52],[1982,618.01],[1983,634.54],[1984,651.28],[1985,654.54],[1986,683.76],[1987,684.17],[1988,670.5],[1989,724.84],[1990,716.23],[1991,695.72],[1992,739.01],[1993,706.57],[1994,709.85],[1995,743.17],[1996,757.76],[1997,790.26],[1998,809.92],[1999,844.11],[2000,854.73],[2001,935.08],[2002,951.41],[2003,994.71],[2004,993.12],[2005,1027],[2006,1065.32],[2007,1084.97],[2008,1112.71],[2009,1136.17]],"population":[[1800,1403398],[1820,1403398],[1950,3687654],[1951,3762158],[1952,3838168],[1953,3915714],[1954,3994826],[1955,4075537],[1956,4157879],[1957,4241884],[1958,4327586],[1959,4415019],[1960,4504219],[1961,4595790],[1962,4690372],[1963,4788073],[1964,4889008],[1965,4993293],[1966,5101054],[1967,5212416],[1968,5327515],[1969,5446489],[1970,5569486],[1971,5696656],[1972,5828158],[1973,5964156],[1974,6104825],[1975,6250341],[1976,6400896],[1977,6491649],[1978,6578372],[1979,6672872],[1980,6774767],[1981,6883907],[1982,6998256],[1983,7116320],[1984,7238471],[1985,7365165],[1986,7496855],[1987,7634008],[1988,7777570],[1989,7927623],[1990,8083816],[1991,8247171],[1992,8416215],[1993,8591439],[1994,8774902],[1995,8967132],[1996,9172631],[1997,9384984],[1998,9605719],[1999,9834362],[2000,10072267],[2001,10321053],[2002,10580176],[2003,10848146],[2004,11126144],[2005,11415261],[2006,11716829],[2007,12031795],[2008,12360306]],"lifeExpectancy":[[1800,29.6],[1945,29.6],[1950,35.3],[1951,35.34],[1952,35.44],[1953,35.53],[1954,35.63],[1955,35.72],[1956,35.82],[1957,35.92],[1958,36.01],[1959,36.11],[1960,36.21],[1961,36.3],[1962,36.41],[1963,36.51],[1964,36.62],[1965,36.74],[1966,36.86],[1967,37],[1968,37.16],[1969,37.33],[1970,37.51],[1971,37.71],[1972,37.93],[1973,38.16],[1974,38.4],[1975,38.65],[1976,38.91],[1977,39.18],[1978,39.45],[1979,39.74],[1980,40.03],[1981,40.33],[1982,40.64],[1983,40.96],[1984,41.28],[1985,41.6],[1986,41.91],[1987,42.2],[1988,42.48],[1989,42.74],[1990,42.99],[1991,43.22],[1992,43.46],[1993,43.69],[1994,43.93],[1995,44.18],[1996,44.45],[1997,44.73],[1998,45.02],[1999,45.32],[2000,45.64],[2001,45.96],[2002,46.3],[2003,46.64],[2004,47],[2005,47.35],[2006,47.72],[2007,48.09],[2008,48.46],[2009,48.84]]},{"name":"Mauritania","region":"Sub-Saharan Africa","income":[[1800,374.38],[1820,374.38],[1913,578.45],[1950,702.93],[1951,723.07],[1952,743.12],[1953,763.01],[1954,783.4],[1955,804.2],[1956,825.35],[1957,846.12],[1958,866.47],[1959,887.9],[1960,946.38],[1961,1093.56],[1962,1055.9],[1963,978],[1964,1252.62],[1965,1406.61],[1966,1393.99],[1967,1421.15],[1968,1523.62],[1969,1476.67],[1970,1604.04],[1971,1593.13],[1972,1586.85],[1973,1462.95],[1974,1585.2],[1975,1457.61],[1976,1545.63],[1977,1497.49],[1978,1462.29],[1979,1498.6],[1980,1524.95],[1981,1547.7],[1982,1481.15],[1983,1516.61],[1984,1372.51],[1985,1376.16],[1986,1416.14],[1987,1421.6],[1988,1435.1],[1989,1448.61],[1990,1393.46],[1991,1389.87],[1992,1361.37],[1993,1380.38],[1994,1396.88],[1995,1422.19],[1996,1470.89],[1997,1483.14],[1998,1495.14],[1999,1510.81],[2000,1540.84],[2001,1561.91],[2002,1579.02],[2003,1619.47],[2004,1654.89],[2005,1691],[2006,1840.36],[2007,1815.61],[2008,1838.06],[2009,1775.87]],"population":[[1800,382696],[1820,382696],[1950,1005595],[1951,1013753],[1952,1022556],[1953,1032021],[1954,1042164],[1955,1053003],[1956,1064559],[1957,1076852],[1958,1089905],[1959,1103409],[1960,1117376],[1961,1131821],[1962,1146757],[1963,1162199],[1964,1178277],[1965,1195012],[1966,1212426],[1967,1230542],[1968,1249383],[1969,1269000],[1970,1289420],[1971,1310672],[1972,1332786],[1973,1355793],[1974,1379655],[1975,1404403],[1976,1430069],[1977,1456688],[1978,1485467],[1979,1516462],[1980,1549589],[1981,1584814],[1982,1622136],[1983,1661573],[1984,1703154],[1985,1746923],[1986,1792933],[1987,1841240],[1988,1891894],[1989,1937201],[1990,1984449],[1991,2041306],[1992,2119465],[1993,2205240],[1994,2279436],[1995,2341749],[1996,2388865],[1997,2444741],[1998,2515309],[1999,2590516],[2000,2667859],[2001,2747312],[2002,2828858],[2003,2912584],[2004,2998563],[2005,3086859],[2006,3177388],[2007,3270065],[2008,3364940]],"lifeExpectancy":[[1800,32],[1945,32],[1950,41.32],[1951,41.49],[1952,41.83],[1953,42.17],[1954,42.5],[1955,42.84],[1956,43.17],[1957,43.5],[1958,43.83],[1959,44.16],[1960,44.48],[1961,44.8],[1962,45.12],[1963,45.44],[1964,45.75],[1965,46.07],[1966,46.38],[1967,46.68],[1968,46.99],[1969,47.31],[1970,47.65],[1971,48.02],[1972,48.42],[1973,48.86],[1974,49.34],[1975,49.86],[1976,50.41],[1977,50.98],[1978,51.56],[1979,52.13],[1980,52.68],[1981,53.18],[1982,53.64],[1983,54.05],[1984,54.4],[1985,54.7],[1986,54.95],[1987,55.16],[1988,55.34],[1989,55.51],[1990,55.66],[1991,55.8],[1992,55.93],[1993,56.04],[1994,56.15],[1995,56.25],[1996,56.33],[1997,56.4],[1998,56.45],[1999,56.48],[2000,56.5],[2001,56.49],[2002,56.47],[2003,56.44],[2004,56.42],[2005,56.42],[2006,56.47],[2007,56.57],[2008,56.75],[2009,56.99]]},{"name":"Mauritius","region":"Sub-Saharan Africa","income":[[1800,799.61],[1820,799.61],[1913,1235.45],[1950,1937.84],[1951,1977.13],[1952,1967.96],[1953,1969.44],[1954,2013.47],[1955,2013.15],[1956,2018.86],[1957,2034.04],[1958,2031.19],[1959,2089.8],[1960,2161.31],[1961,2583.15],[1962,2529.07],[1963,2824.71],[1964,2555.21],[1965,2570.02],[1966,2419.02],[1967,2475.39],[1968,2262.62],[1969,2339.48],[1970,2292.46],[1971,2371.81],[1972,2575.48],[1973,2864.23],[1974,3129.06],[1975,3089.22],[1976,3542.22],[1977,3710.98],[1978,3785.22],[1979,3847.18],[1980,3398.74],[1981,3541.69],[1982,3688.04],[1983,3664.7],[1984,3799.59],[1985,4026.39],[1986,4386.07],[1987,4783.59],[1988,5062.21],[1989,5233.98],[1990,5547.92],[1991,5841.66],[1992,6058.25],[1993,6398.27],[1994,6617.21],[1995,6783.9],[1996,7068.83],[1997,7425.71],[1998,7804.35],[1999,8149.82],[2000,8290.95],[2001,8801.58],[2002,9021.82],[2003,9564.7],[2004,9931.83],[2005,10155],[2006,10469.25],[2007,10967.13],[2008,11330.3],[2009,11411.53]],"population":[[1850,181000],[1861,320000],[1871,330000],[1881,360000],[1891,371000],[1901,371000],[1911,369000],[1921,376000],[1931,393000],[1944,419000],[1950,481270],[1951,498593],[1952,516556],[1953,536057],[1954,553977],[1955,571669],[1956,591764],[1957,609816],[1958,627660],[1959,645313],[1960,663229],[1961,681284],[1962,701016],[1963,715140],[1964,736182],[1965,755528],[1966,774160],[1967,789309],[1968,804177],[1969,816027],[1970,829511],[1971,841079],[1972,851334],[1973,861239],[1974,873292],[1975,885461],[1976,897811],[1977,913025],[1978,929367],[1979,946640],[1980,963701],[1981,979050],[1982,992040],[1983,1002175],[1984,1012005],[1985,1021710],[1986,1032333],[1987,1042663],[1988,1052336],[1989,1062525],[1990,1073507],[1991,1084777],[1992,1096202],[1993,1107490],[1994,1117988],[1995,1128608],[1996,1139491],[1997,1149818],[1998,1159654],[1999,1169325],[2000,1179368],[2001,1189825],[2002,1200206],[2003,1210447],[2004,1220481],[2005,1230602],[2006,1240827],[2007,1250882],[2008,1260781]],"lifeExpectancy":[[1800,31.2],[1924,31.22],[1934,33.87],[1941,36.17],[1944,33.29],[1947,38.62],[1950,46.86],[1951,48.01],[1952,50.19],[1953,52.13],[1954,53.85],[1955,55.34],[1956,56.6],[1957,57.64],[1958,58.48],[1959,59.13],[1960,59.63],[1961,60],[1962,60.29],[1963,60.53],[1964,60.75],[1965,60.98],[1966,61.21],[1967,61.45],[1968,61.69],[1969,61.94],[1970,62.2],[1971,62.49],[1972,62.81],[1973,63.15],[1974,63.52],[1975,63.91],[1976,64.3],[1977,64.69],[1978,65.07],[1979,65.45],[1980,65.82],[1981,66.19],[1982,66.58],[1983,66.98],[1984,67.39],[1985,67.8],[1986,68.17],[1987,68.51],[1988,68.8],[1989,69.04],[1990,69.24],[1991,69.41],[1992,69.57],[1993,69.74],[1994,69.93],[1995,70.14],[1996,70.36],[1997,70.6],[1998,70.85],[1999,71.09],[2000,71.32],[2001,71.52],[2002,71.7],[2003,71.85],[2004,71.96],[2005,72.04],[2006,72.08],[2007,72.1],[2008,72.1],[2009,72.1]]},{"name":"Mayotte","region":"Sub-Saharan Africa","income":[[2005,9617.82]],"population":[[1800,8219],[1820,8219],[1950,21597],[1951,22099],[1952,22620],[1953,23161],[1954,23723],[1955,24307],[1956,24913],[1957,25543],[1958,26197],[1959,26876],[1960,27579],[1961,28308],[1962,29065],[1963,29849],[1964,30663],[1965,31507],[1966,32383],[1967,33338],[1968,34349],[1969,35403],[1970,36502],[1971,37648],[1972,38842],[1973,40089],[1974,41390],[1975,42747],[1976,44164],[1977,45644],[1978,47189],[1979,49517],[1980,51995],[1981,54629],[1982,57431],[1983,60414],[1984,63594],[1985,66849],[1986,70694],[1987,74877],[1988,79415],[1989,84326],[1990,89629],[1991,95267],[1992,101167],[1993,107320],[1994,113713],[1995,120330],[1996,127146],[1997,134133],[1998,141271],[1999,148538],[2000,155911],[2001,163366],[2002,170879],[2003,178437],[2004,186026],[2005,193633],[2006,201234],[2007,208807],[2008,216334]],"lifeExpectancy":[[1950,51.48],[1951,51.7],[1952,52.13],[1953,52.58],[1954,53.03],[1955,53.5],[1956,53.97],[1957,54.46],[1958,54.95],[1959,55.45],[1960,55.96],[1961,56.47],[1962,57],[1963,57.53],[1964,58.07],[1965,58.64],[1966,59.24],[1967,59.88],[1968,60.56],[1969,61.27],[1970,61.99],[1971,62.71],[1972,63.4],[1973,64.07],[1974,64.69],[1975,65.28],[1976,65.84],[1977,66.4],[1978,66.96],[1979,67.52],[1980,68.07],[1981,68.61],[1982,69.11],[1983,69.58],[1984,70.02],[1985,70.42],[1986,70.81],[1987,71.18],[1988,71.56],[1989,71.94],[1990,72.31],[1991,72.67],[1992,73.01],[1993,73.31],[1994,73.58],[1995,73.82],[1996,74.02],[1997,74.21],[1998,74.38],[1999,74.54],[2000,74.69],[2001,74.84],[2002,74.99],[2003,75.14],[2004,75.28],[2005,75.42],[2006,75.57],[2007,75.71],[2008,75.85],[2009,75.99]]},{"name":"Mozambique","region":"Sub-Saharan Africa","income":[[1800,358],[1820,358],[1913,422.15],[1950,450.75],[1951,459.52],[1952,468.53],[1953,476.86],[1954,479.86],[1955,500.62],[1956,494.02],[1957,495.59],[1958,509.18],[1959,526.05],[1960,527.87],[1961,531.89],[1962,556.69],[1963,525.45],[1964,536.63],[1965,537.25],[1966,542.48],[1967,566.67],[1968,615.9],[1969,673.31],[1970,693.12],[1971,722.14],[1972,724.92],[1973,744.86],[1974,669.69],[1975,558.21],[1976,514.84],[1977,502.32],[1978,491.17],[1979,483.07],[1980,485.37],[1981,483.81],[1982,462.21],[1983,422.85],[1984,406.6],[1985,366.02],[1986,369.16],[1987,389.88],[1988,424.48],[1989,443.13],[1990,443.24],[1991,455.44],[1992,410.9],[1993,430.19],[1994,428.72],[1995,419.87],[1996,435.93],[1997,472.35],[1998,519.32],[1999,545.8],[2000,542.81],[2001,601.17],[2002,633.62],[2003,671.77],[2004,710.42],[2005,743],[2006,774.48],[2007,814.58],[2008,852.43],[2009,888.65]],"population":[[1820,2096000],[1950,6250443],[1951,6345838],[1952,6446316],[1953,6552276],[1954,6663941],[1955,6781616],[1956,6906364],[1957,7038035],[1958,7176661],[1959,7321327],[1960,7472230],[1961,7627642],[1962,7788944],[1963,7957010],[1964,8127242],[1965,8301446],[1966,8486381],[1967,8680909],[1968,8883626],[1969,9092797],[1970,9304375],[1971,9539059],[1972,9809596],[1973,10087915],[1974,10370281],[1975,10432604],[1976,10769649],[1977,11127868],[1978,11466483],[1979,11828029],[1980,12102619],[1981,12363066],[1982,12587223],[1983,12772878],[1984,12923005],[1985,13062589],[1986,13142107],[1987,12891952],[1988,12517962],[1989,12474404],[1990,12655732],[1991,12920197],[1992,13160731],[1993,13664085],[1994,14740072],[1995,15697711],[1996,16192388],[1997,16603334],[1998,17003681],[1999,17392597],[2000,17768457],[2001,18129398],[2002,18473780],[2003,18800908],[2004,19111633],[2005,19406703],[2006,19686505],[2007,19951656],[2008,20203186]],"lifeExpectancy":[[1800,30.28],[1950,30.28],[1951,30.53],[1952,31.04],[1953,31.54],[1954,32.04],[1955,32.55],[1956,33.05],[1957,33.55],[1958,34.05],[1959,34.54],[1960,35.02],[1961,35.48],[1962,35.93],[1963,36.35],[1964,36.76],[1965,37.16],[1966,37.56],[1967,37.96],[1968,38.37],[1969,38.79],[1970,39.23],[1971,39.69],[1972,40.17],[1973,40.66],[1974,41.14],[1975,41.58],[1976,41.98],[1977,42.3],[1978,42.54],[1979,42.71],[1980,42.8],[1981,42.83],[1982,42.81],[1983,42.78],[1984,42.74],[1985,42.74],[1986,42.76],[1987,42.84],[1988,42.96],[1989,43.14],[1990,43.41],[1991,43.77],[1992,44.22],[1993,44.74],[1994,45.31],[1995,45.89],[1996,46.42],[1997,46.88],[1998,47.25],[1999,47.5],[2000,47.65],[2001,47.7],[2002,47.69],[2003,47.67],[2004,47.65],[2005,47.66],[2006,47.71],[2007,47.8],[2008,47.94],[2009,48.13]]},{"name":"Namibia","region":"Sub-Saharan Africa","income":[[1800,350],[1820,350],[1913,1382.86],[1950,2388.81],[1951,2406.47],[1952,2423.78],[1953,2458.45],[1954,2535.28],[1955,2555.54],[1956,2587.28],[1957,2621.45],[1958,2628.16],[1959,2711.34],[1960,2893.49],[1961,2852.45],[1962,3173.22],[1963,3402.72],[1964,3855.43],[1965,4010.17],[1966,4057.53],[1967,3793.69],[1968,3726.62],[1969,3756.41],[1970,3673.78],[1971,3665.84],[1972,3746.08],[1973,3762.12],[1974,3787.96],[1975,3687.59],[1976,3748.13],[1977,3876.49],[1978,4046.23],[1979,4095.71],[1980,4167.1],[1981,4231.42],[1982,4191.1],[1983,3956.89],[1984,3789.58],[1985,3696.11],[1986,3698.87],[1987,3693.73],[1988,3624.19],[1989,3719.25],[1990,3472.4],[1991,3568.87],[1992,3804.54],[1993,3626.94],[1994,3768.68],[1995,3823.11],[1996,3836.63],[1997,3899.52],[1998,3939.06],[1999,3989.97],[2000,4022.88],[2001,4023.14],[2002,4072.32],[2003,4169.68],[2004,4399.55],[2005,4547],[2006,4783.15],[2007,4956.93],[2008,5029.66],[2009,4952.26]],"population":[[1800,229000],[1921,229000],[1946,362000],[1950,463729],[1951,474595],[1952,485831],[1953,497453],[1954,509470],[1955,521903],[1956,534767],[1957,548080],[1958,561854],[1959,576077],[1960,590731],[1961,605831],[1962,621392],[1963,637428],[1964,653950],[1965,670981],[1966,688539],[1967,706640],[1968,725304],[1969,744618],[1970,764683],[1971,792629],[1972,821782],[1973,851258],[1974,882005],[1975,915325],[1976,950488],[1977,977026],[1978,997913],[1979,1027780],[1980,1058021],[1981,1074401],[1982,1099010],[1983,1134107],[1984,1169268],[1985,1203934],[1986,1240171],[1987,1278184],[1988,1332970],[1989,1409105],[1990,1471314],[1991,1513139],[1992,1554253],[1993,1597752],[1994,1642093],[1995,1686700],[1996,1731210],[1997,1774766],[1998,1816763],[1999,1858172],[2000,1905659],[2001,1947326],[2002,1972153],[2003,1993482],[2004,2014026],[2005,2030692],[2006,2044147],[2007,2055080],[2008,2063927]],"lifeExpectancy":[[1800,32.4],[1940,32.4],[1950,40.25],[1951,40.63],[1952,41.38],[1953,42.11],[1954,42.83],[1955,43.54],[1956,44.24],[1957,44.92],[1958,45.59],[1959,46.25],[1960,46.89],[1961,47.51],[1962,48.11],[1963,48.7],[1964,49.27],[1965,49.83],[1966,50.39],[1967,50.93],[1968,51.48],[1969,52.02],[1970,52.56],[1971,53.09],[1972,53.62],[1973,54.15],[1974,54.67],[1975,55.19],[1976,55.72],[1977,56.26],[1978,56.8],[1979,57.34],[1980,57.88],[1981,58.39],[1982,58.87],[1983,59.31],[1984,59.72],[1985,60.11],[1986,60.5],[1987,60.92],[1988,61.35],[1989,61.78],[1990,62.19],[1991,62.56],[1992,62.84],[1993,63.01],[1994,63.03],[1995,62.85],[1996,62.4],[1997,61.7],[1998,60.79],[1999,59.77],[2000,58.78],[2001,58.01],[2002,57.58],[2003,57.55],[2004,57.92],[2005,58.61],[2006,59.49],[2007,60.39],[2008,61.15],[2009,61.72]]},{"name":"Niger","region":"Sub-Saharan Africa","income":[[1800,371.26],[1820,371.26],[1913,573.63],[1950,732.21],[1951,747.18],[1952,761.88],[1953,776.29],[1954,791.06],[1955,806.11],[1956,820.73],[1957,835.52],[1958,850.43],[1959,865.4],[1960,902.91],[1961,921.45],[1962,997.77],[1963,1073.59],[1964,1053.89],[1965,1109.42],[1966,1072.44],[1967,1054.38],[1968,1040.13],[1969,987.35],[1970,995.55],[1971,1028.97],[1972,954.21],[1973,774.24],[1974,822.83],[1975,781.86],[1976,768.89],[1977,808.9],[1978,895.6],[1979,936.37],[1980,957.49],[1981,944.67],[1982,909.72],[1983,870.32],[1984,704.61],[1985,698.53],[1986,711.64],[1987,668.3],[1988,687.39],[1989,670.19],[1990,640.6],[1991,638.96],[1992,581.18],[1993,573.05],[1994,579.26],[1995,577.48],[1996,580.29],[1997,580.31],[1998,623.34],[1999,602.36],[2000,577.19],[2001,600.62],[2002,601.07],[2003,610.12],[2004,587.8],[2005,613],[2006,629.09],[2007,631.21],[2008,669.12],[2009,643.39]],"population":[[1800,1244861],[1820,1244861],[1950,3271073],[1951,3324164],[1952,3379468],[1953,3437066],[1954,3497045],[1955,3559494],[1956,3624507],[1957,3692184],[1958,3762630],[1959,3835954],[1960,3912663],[1961,3992502],[1962,4076008],[1963,4162926],[1964,4252122],[1965,4343664],[1966,4437620],[1967,4534062],[1968,4633063],[1969,4735173],[1970,4840501],[1971,4948667],[1972,5060262],[1973,5175408],[1974,5294763],[1975,5419038],[1976,5547894],[1977,5682086],[1978,5821985],[1979,5967481],[1980,6118518],[1981,6275098],[1982,6437188],[1983,6604789],[1984,6777992],[1985,6956968],[1986,7141829],[1987,7332638],[1988,7529666],[1989,7733615],[1990,7945137],[1991,8164668],[1992,8392818],[1993,8631131],[1994,8880037],[1995,9139044],[1996,9404073],[1997,9666252],[1998,9935490],[1999,10220540],[2000,10516111],[2001,10823004],[2002,11140655],[2003,11469579],[2004,11810183],[2005,12162856],[2006,12525094],[2007,12894865],[2008,13272679]],"lifeExpectancy":[[1800,30.8],[1945,30.8],[1950,37.1],[1951,37.12],[1952,37.16],[1953,37.21],[1954,37.26],[1955,37.3],[1956,37.35],[1957,37.4],[1958,37.44],[1959,37.49],[1960,37.54],[1961,37.59],[1962,37.64],[1963,37.68],[1964,37.74],[1965,37.79],[1966,37.85],[1967,37.91],[1968,37.98],[1969,38.05],[1970,38.14],[1971,38.23],[1972,38.33],[1973,38.44],[1974,38.56],[1975,38.68],[1976,38.82],[1977,38.96],[1978,39.1],[1979,39.26],[1980,39.42],[1981,39.58],[1982,39.76],[1983,39.94],[1984,40.13],[1985,40.34],[1986,40.56],[1987,40.79],[1988,41.05],[1989,41.32],[1990,41.62],[1991,41.95],[1992,42.29],[1993,42.67],[1994,43.08],[1995,43.52],[1996,44.01],[1997,44.55],[1998,45.14],[1999,45.76],[2000,46.41],[2001,47.08],[2002,47.75],[2003,48.41],[2004,49.05],[2005,49.67],[2006,50.26],[2007,50.84],[2008,51.4],[2009,51.95]]},{"name":"Nigeria","region":"Sub-Saharan Africa","income":[[1800,576.38],[1820,576.38],[1913,890.54],[1950,974.02],[1951,1026.05],[1952,1077.28],[1953,1080.04],[1954,1132.34],[1955,1134.59],[1956,1082.52],[1957,1100.59],[1958,1062.67],[1959,1083.06],[1960,1104.93],[1961,1115.22],[1962,1150.93],[1963,1228.98],[1964,1251.08],[1965,1303.64],[1966,1231.2],[1967,1014.51],[1968,978.68],[1969,1210.33],[1970,1542.25],[1971,1679.52],[1972,1698.39],[1973,1796.08],[1974,1947.97],[1975,1833.21],[1976,1971.99],[1977,1981.95],[1978,1807.02],[1979,1870.34],[1980,1843.34],[1981,1641.37],[1982,1576.97],[1983,1448.42],[1984,1358.55],[1985,1439.69],[1986,1434.08],[1987,1385.03],[1988,1481.38],[1989,1534.61],[1990,1571.11],[1991,1621.23],[1992,1619.85],[1993,1612.47],[1994,1561.22],[1995,1561.31],[1996,1619.42],[1997,1624.94],[1998,1613.59],[1999,1590.3],[2000,1619.12],[2001,1629.84],[2002,1615.29],[2003,1746.05],[2004,1807.34],[2005,1892],[2006,1955.68],[2007,2036.03],[2008,2100.11],[2009,2158.98]],"population":[[1800,12100855],[1820,12100855],[1921,18631000],[1931,19158000],[1950,31796939],[1951,32448689],[1952,33119096],[1953,33808763],[1954,34626706],[1955,35458978],[1956,36306207],[1957,37173340],[1958,38062768],[1959,38976103],[1960,39914593],[1961,40879339],[1962,41871351],[1963,42891491],[1964,43940734],[1965,45020052],[1966,46134375],[1967,47287752],[1968,48481074],[1969,49719289],[1970,51027516],[1971,52370604],[1972,53740085],[1973,55179709],[1974,56775644],[1975,58522112],[1976,60324738],[1977,62209173],[1978,64203864],[1979,66319068],[1980,68550274],[1981,70815282],[1982,73039376],[1983,74154971],[1984,75526667],[1985,77573154],[1986,79345497],[1987,81551520],[1988,83815330],[1989,86135468],[1990,88510354],[1991,90920655],[1992,93364244],[1993,95855030],[1994,98388477],[1995,100960105],[1996,103567064],[1997,106207839],[1998,108880275],[1999,111580397],[2000,114306700],[2001,117074880],[2002,119901274],[2003,122790463],[2004,125744458],[2005,128765768],[2006,131859731],[2007,135031164],[2008,138283240]],"lifeExpectancy":[[1800,30.4],[1945,30.4],[1950,35.59],[1951,35.7],[1952,35.92],[1953,36.14],[1954,36.38],[1955,36.62],[1956,36.86],[1957,37.11],[1958,37.37],[1959,37.63],[1960,37.89],[1961,38.14],[1962,38.39],[1963,38.63],[1964,38.87],[1965,39.1],[1966,39.33],[1967,39.56],[1968,39.8],[1969,40.07],[1970,40.37],[1971,40.74],[1972,41.17],[1973,41.67],[1974,42.22],[1975,42.78],[1976,43.32],[1977,43.81],[1978,44.22],[1979,44.54],[1980,44.76],[1981,44.88],[1982,44.93],[1983,44.95],[1984,44.93],[1985,44.89],[1986,44.83],[1987,44.76],[1988,44.69],[1989,44.61],[1990,44.55],[1991,44.51],[1992,44.5],[1993,44.53],[1994,44.59],[1995,44.7],[1996,44.86],[1997,45.07],[1998,45.32],[1999,45.6],[2000,45.9],[2001,46.2],[2002,46.5],[2003,46.77],[2004,47.03],[2005,47.27],[2006,47.49],[2007,47.71],[2008,47.93],[2009,48.17]]},{"name":"Reunion","region":"Sub-Saharan Africa","income":[[1800,692.33],[1820,692.33],[1913,1069.7],[1950,2637.69],[1951,2710.19],[1952,2718.89],[1953,2740.7],[1954,2801.73],[1955,2772.53],[1956,2781.87],[1957,2769.45],[1958,2764.12],[1959,2840.76],[1960,2969.28],[1961,3033.87],[1962,3173.72],[1963,3307.58],[1964,3469.5],[1965,3717.11],[1966,3845.99],[1967,4021.18],[1968,4202.49],[1969,4496.76],[1970,4591.19],[1971,4605.39],[1972,5047.66],[1973,5004.19],[1974,5231.8],[1975,5066.54],[1976,4457.05],[1977,4319.8],[1978,4614.38],[1979,4793.06],[1980,4887.45],[1981,4956.25],[1982,5267.22],[1983,5467.59],[1984,5428.2],[1985,5396.09],[1986,5363.43],[1987,5303.38],[1988,5508.86],[1989,5560.26],[1990,5980.27],[1991,6225.76],[1992,6101.26],[1993,5980.36],[1994,5863.97],[1995,5752.28],[1996,5939.19],[1997,6071.94],[1998,6037.73],[1999,6058.56],[2000,6084.03],[2001,6112.28],[2002,6316.17],[2003,6529.84],[2004,6796.21],[2005,7077.24],[2006,7375.61],[2007,7670.12]],"population":[[1800,92744],[1820,92744],[1950,243700],[1951,250700],[1952,257700],[1953,265500],[1954,274400],[1955,286100],[1956,296000],[1957,308700],[1958,317900],[1959,327200],[1960,337500],[1961,347900],[1962,358900],[1963,371000],[1964,383700],[1965,392900],[1966,403300],[1967,414024],[1968,425070],[1969,435564],[1970,444806],[1971,453345],[1972,461633],[1973,469368],[1974,475364],[1975,481100],[1976,486749],[1977,492095],[1978,497039],[1979,501979],[1980,507015],[1981,511650],[1982,517810],[1983,523170],[1984,532769],[1985,541776],[1986,551188],[1987,562035],[1988,573509],[1989,585202],[1990,597308],[1991,609686],[1992,622191],[1993,634769],[1994,647368],[1995,659938],[1996,672433],[1997,684810],[1998,697035],[1999,709083],[2000,720934],[2001,732570],[2002,743981],[2003,755171],[2004,766153],[2005,776948],[2006,787584],[2007,798094],[2008,808506]],"lifeExpectancy":[[1950,51.83],[1951,52.05],[1952,52.49],[1953,52.94],[1954,53.4],[1955,53.87],[1956,54.34],[1957,54.83],[1958,55.32],[1959,55.82],[1960,56.33],[1961,56.84],[1962,57.36],[1963,57.89],[1964,58.43],[1965,59],[1966,59.61],[1967,60.26],[1968,60.94],[1969,61.66],[1970,62.4],[1971,63.13],[1972,63.83],[1973,64.5],[1974,65.13],[1975,65.72],[1976,66.29],[1977,66.84],[1978,67.4],[1979,67.96],[1980,68.51],[1981,69.06],[1982,69.57],[1983,70.06],[1984,70.51],[1985,70.94],[1986,71.35],[1987,71.75],[1988,72.14],[1989,72.53],[1990,72.9],[1991,73.26],[1992,73.58],[1993,73.86],[1994,74.11],[1995,74.33],[1996,74.53],[1997,74.71],[1998,74.89],[1999,75.08],[2000,75.27],[2001,75.46],[2002,75.64],[2003,75.81],[2004,75.97],[2005,76.12],[2006,76.26],[2007,76.39],[2008,76.52],[2009,76.64]]},{"name":"Rwanda","region":"Sub-Saharan Africa","income":[[1800,369],[1820,369],[1913,438.93],[1950,470.31],[1951,487.82],[1952,493.32],[1953,502.1],[1954,519.56],[1955,524.69],[1956,532.76],[1957,540.29],[1958,542.88],[1959,560.7],[1960,564.22],[1961,537.5],[1962,597.47],[1963,525.43],[1964,451.85],[1965,471.62],[1966,490.59],[1967,510.96],[1968,531.62],[1969,572.58],[1970,616.38],[1971,605.84],[1972,590.58],[1973,591.25],[1974,602.09],[1975,692.82],[1976,658.96],[1977,670.08],[1978,711.13],[1979,753.51],[1980,818.71],[1981,843.68],[1982,881.57],[1983,902.56],[1984,840.84],[1985,856],[1986,879.87],[1987,847.99],[1988,793.55],[1989,786.33],[1990,760.74],[1991,708.92],[1992,737.07],[1993,660.82],[1994,382.44],[1995,581.39],[1996,622.92],[1997,589.94],[1998,643.74],[1999,677.54],[2000,704.04],[2001,734.98],[2002,785.65],[2003,774.07],[2004,785.77],[2005,813],[2006,866.95],[2007,895.97],[2008,975.75],[2009,995.27]],"population":[[1800,928368],[1820,928368],[1950,2439435],[1951,2485919],[1952,2534927],[1953,2586573],[1954,2640978],[1955,2698272],[1956,2758591],[1957,2822082],[1958,2888902],[1959,2958761],[1960,3031804],[1961,3045908],[1962,3051242],[1963,3129004],[1964,3183993],[1965,3264640],[1966,3358202],[1967,3451079],[1968,3547932],[1969,3656796],[1970,3769171],[1971,3880225],[1972,3992121],[1973,4109838],[1974,4226380],[1975,4356863],[1976,4502352],[1977,4657072],[1978,4818992],[1979,4975833],[1980,5138689],[1981,5310271],[1982,5507565],[1983,5701104],[1984,5860320],[1985,6009833],[1986,6166230],[1987,6349365],[1988,6552179],[1989,6745103],[1990,6923738],[1991,7110348],[1992,7290203],[1993,7456502],[1994,6417511],[1995,5706501],[1996,6002451],[1997,7212583],[1998,7197680],[1999,7358932],[2000,7507056],[2001,7673062],[2002,7852401],[2003,8042082],[2004,8238673],[2005,8440820],[2006,8648248],[2007,8860588],[2008,9077425]],"lifeExpectancy":[[1800,31.8],[1930,31.8],[1950,39.41],[1951,39.56],[1952,39.85],[1953,40.15],[1954,40.45],[1955,40.75],[1956,41.06],[1957,41.36],[1958,41.67],[1959,41.98],[1960,42.28],[1961,42.58],[1962,42.87],[1963,43.14],[1964,43.4],[1965,43.63],[1966,43.83],[1967,44.01],[1968,44.17],[1969,44.3],[1970,44.4],[1971,44.49],[1972,44.55],[1973,44.61],[1974,44.67],[1975,44.75],[1976,44.89],[1977,45.08],[1978,45.31],[1979,45.58],[1980,45.88],[1981,46.26],[1982,46.67],[1983,47],[1984,47.15],[1985,47.38],[1986,47.61],[1987,47.84],[1988,48.07],[1989,48.3],[1990,48.53],[1991,48.76],[1992,48.99],[1993,26.39],[1994,27.09],[1997,35.33],[1998,38.41],[1999,41.04],[2000,43.1],[2001,44.6],[2002,45.77],[2003,46.77],[2004,47.65],[2005,48.42],[2006,49.11],[2007,49.71],[2008,50.23],[2009,50.69]]},{"name":"Sao Tome and Principe","region":"Sub-Saharan Africa","income":[[1800,674.7],[1820,674.7],[1913,818.38],[1950,883.72],[1951,880.98],[1952,879.58],[1953,879.74],[1954,915.56],[1955,822.77],[1956,868.21],[1957,860.74],[1958,943.06],[1959,844.46],[1960,934.47],[1961,1004.73],[1962,1071.55],[1963,1136.31],[1964,1197.78],[1965,1254.59],[1966,1327.9],[1967,1384.84],[1968,1440.24],[1969,1496.12],[1970,1550.8],[1971,1597.29],[1972,1532.99],[1973,1459.78],[1974,1460.35],[1975,1531.24],[1976,1612.48],[1977,1737.56],[1978,1796.06],[1979,1947.86],[1980,2164.3],[1981,1530.25],[1982,1890.22],[1983,1687.83],[1984,1513.8],[1985,1601.21],[1986,1583.52],[1987,1516.53],[1988,1508.15],[1989,1498.63],[1990,1497],[1991,1458.63],[1992,1428.78],[1993,1406.6],[1994,1399.62],[1995,1382.99],[1996,1365.18],[1997,1339.08],[1998,1327.1],[1999,1321.09],[2000,1320.58],[2001,1331.58],[2002,1353.09],[2003,1396.44],[2004,1435.8],[2005,1460],[2006,1532.32],[2007,1598.38],[2008,1664.3],[2009,1703.43]],"population":[[1800,22731],[1820,22731],[1950,59730],[1951,59916],[1952,60011],[1953,60000],[1954,60006],[1955,60227],[1956,60797],[1957,61325],[1958,61683],[1959,62507],[1960,63403],[1961,64330],[1962,65345],[1963,66361],[1964,67452],[1965,68691],[1966,69766],[1967,70787],[1968,71804],[1969,72722],[1970,73631],[1971,74860],[1972,76595],[1973,78222],[1974,79667],[1975,81607],[1976,84176],[1977,86796],[1978,89367],[1979,91804],[1980,94071],[1981,96443],[1982,98593],[1983,100842],[1984,103184],[1985,105624],[1986,108165],[1987,110812],[1988,113570],[1989,116448],[1990,119453],[1991,122596],[1992,125911],[1993,129428],[1994,133152],[1995,137090],[1996,141246],[1997,145608],[1998,150169],[1999,154929],[2000,159883],[2001,165034],[2002,170372],[2003,175883],[2004,181565],[2005,187410],[2006,193413],[2007,199579],[2008,205901]],"lifeExpectancy":[[1950,45.62],[1951,45.82],[1952,46.23],[1953,46.67],[1954,47.14],[1955,47.63],[1956,48.15],[1957,48.69],[1958,49.25],[1959,49.83],[1960,50.42],[1961,51],[1962,51.59],[1963,52.15],[1964,52.7],[1965,53.23],[1966,53.72],[1967,54.19],[1968,54.64],[1969,55.07],[1970,55.49],[1971,55.9],[1972,56.31],[1973,56.72],[1974,57.13],[1975,57.54],[1976,57.95],[1977,58.35],[1978,58.75],[1979,59.14],[1980,59.51],[1981,59.86],[1982,60.2],[1983,60.51],[1984,60.82],[1985,61.1],[1986,61.37],[1987,61.63],[1988,61.87],[1989,62.09],[1990,62.3],[1991,62.48],[1992,62.64],[1993,62.78],[1994,62.91],[1995,63.02],[1996,63.14],[1997,63.27],[1998,63.42],[1999,63.59],[2000,63.78],[2001,63.99],[2002,64.21],[2003,64.45],[2004,64.69],[2005,64.92],[2006,65.16],[2007,65.4],[2008,65.63],[2009,65.86]]},{"name":"Senegal","region":"Sub-Saharan Africa","income":[[1800,420.73],[1820,420.73],[1913,650.06],[1950,1401],[1951,1426.07],[1952,1450.36],[1953,1473.8],[1954,1497.64],[1955,1521.72],[1956,1544.67],[1957,1567.65],[1958,1590.37],[1959,1611.7],[1960,1607.71],[1961,1641.12],[1962,1654.99],[1963,1677],[1964,1668.63],[1965,1681.15],[1966,1678.35],[1967,1612.4],[1968,1668.22],[1969,1515.4],[1970,1597.18],[1971,1547.21],[1972,1597.71],[1973,1463.61],[1974,1479.55],[1975,1553.67],[1976,1655.33],[1977,1561.77],[1978,1454.39],[1979,1508.72],[1980,1414.11],[1981,1360.07],[1982,1518.48],[1983,1509.42],[1984,1395.71],[1985,1404.61],[1986,1427.99],[1987,1441.72],[1988,1470.26],[1989,1402.53],[1990,1423.27],[1991,1376.72],[1992,1367.9],[1993,1301.36],[1994,1302.8],[1995,1333.03],[1996,1362.47],[1997,1392.37],[1998,1432.95],[1999,1466.61],[2000,1511.49],[2001,1542.03],[2002,1519.64],[2003,1579.91],[2004,1630.75],[2005,1676],[2006,1676.66],[2007,1715.54],[2008,1714.35],[2009,1700.05]],"population":[[1800,1009886],[1820,1009886],[1950,2653637],[1951,2703457],[1952,2755589],[1953,2810131],[1954,2867186],[1955,2926863],[1956,2989276],[1957,3054547],[1958,3123116],[1959,3194821],[1960,3269808],[1961,3348228],[1962,3430243],[1963,3516025],[1964,3636138],[1965,3743967],[1966,3856528],[1967,3965841],[1968,4073826],[1969,4192724],[1970,4317891],[1971,4450142],[1972,4588696],[1973,4727163],[1974,4872244],[1975,4989168],[1976,5100499],[1977,5260855],[1978,5426864],[1979,5598599],[1980,5776012],[1981,5959049],[1982,6147783],[1983,6342309],[1984,6542073],[1985,6746778],[1986,6956526],[1987,7171347],[1988,7391190],[1989,7615614],[1990,7844199],[1991,8076976],[1992,8307920],[1993,8540599],[1994,8778563],[1995,9025562],[1996,9280615],[1997,9535314],[1998,9794164],[1999,10057259],[2000,10324150],[2001,10595275],[2002,10870037],[2003,11147063],[2004,11426026],[2005,11706498],[2006,11987121],[2007,12267493],[2008,12548243]],"lifeExpectancy":[[1800,25.2],[1922,25.2],[1927,23.9],[1937,26.4],[1945,28.8],[1950,37.87],[1951,38.03],[1952,38.33],[1953,38.62],[1954,38.89],[1955,39.16],[1956,39.41],[1957,39.65],[1958,39.88],[1959,40.09],[1960,40.3],[1961,40.5],[1962,40.7],[1963,40.89],[1964,41.09],[1965,41.29],[1966,41.52],[1967,41.75],[1968,42.01],[1969,42.3],[1970,42.61],[1971,42.96],[1972,43.35],[1973,43.76],[1974,44.21],[1975,44.69],[1976,45.2],[1977,45.73],[1978,46.27],[1979,46.83],[1980,47.39],[1981,47.94],[1982,48.49],[1983,49.04],[1984,49.56],[1985,50.06],[1986,50.52],[1987,50.95],[1988,51.34],[1989,51.7],[1990,52.02],[1991,52.31],[1992,52.56],[1993,52.79],[1994,52.99],[1995,53.19],[1996,53.37],[1997,53.54],[1998,53.72],[1999,53.89],[2000,54.07],[2001,54.24],[2002,54.41],[2003,54.57],[2004,54.74],[2005,54.92],[2006,55.12],[2007,55.35],[2008,55.62],[2009,55.91]]},{"name":"Sierra Leone","region":"Sub-Saharan Africa","income":[[1800,508.4],[1820,508.4],[1913,785.51],[1950,828.88],[1951,864.62],[1952,879.79],[1953,901.45],[1954,939.54],[1955,959.27],[1956,981.97],[1957,1004.48],[1958,1018.62],[1959,1062.02],[1960,1080.7],[1961,1084.2],[1962,1116.64],[1963,1118.69],[1964,1114.89],[1965,1176.51],[1966,1232.61],[1967,1206.04],[1968,1304.02],[1969,1400.45],[1970,1425.83],[1971,1390.7],[1972,1353.76],[1973,1373.08],[1974,1405.55],[1975,1421.79],[1976,1353.94],[1977,1348.29],[1978,1326.87],[1979,1375.89],[1980,1412.69],[1981,1470.35],[1982,1465.01],[1983,1414.02],[1984,1402.52],[1985,1333.95],[1986,1258.36],[1987,1294.45],[1988,1298.33],[1989,1296.02],[1990,1297.16],[1991,1162.26],[1992,1068.7],[1993,1081.64],[1994,1094.22],[1995,969],[1996,719.36],[1997,574.65],[1998,558.42],[1999,510.42],[2000,517.67],[2001,578.72],[2002,699.49],[2003,723.63],[2004,753.56],[2005,790],[2006,826.04],[2007,856.97],[2008,881.48],[2009,893.6]],"population":[[1800,794264],[1820,794264],[1950,2087055],[1951,2114827],[1952,2143249],[1953,2172336],[1954,2202105],[1955,2232573],[1956,2263758],[1957,2295678],[1958,2328351],[1959,2361885],[1960,2396304],[1961,2431632],[1962,2467895],[1963,2505118],[1964,2543140],[1965,2581979],[1966,2621656],[1967,2662190],[1968,2703603],[1969,2745967],[1970,2789306],[1971,2833646],[1972,2879013],[1973,2925433],[1974,2973542],[1975,3027190],[1976,3083053],[1977,3140897],[1978,3200714],[1979,3262699],[1980,3327118],[1981,3394288],[1982,3464522],[1983,3538074],[1984,3615186],[1985,3695969],[1986,3780514],[1987,3868905],[1988,3961276],[1989,4057767],[1990,4220883],[1991,4333951],[1992,4260884],[1993,4214121],[1994,4311456],[1995,4381750],[1996,4438506],[1997,4578212],[1998,4672778],[1999,4698964],[2000,4808817],[2001,5080682],[2002,5359092],[2003,5564299],[2004,5732171],[2005,5867426],[2006,6005250],[2007,6144562],[2008,6286617]],"lifeExpectancy":[[1800,25.1],[1926,25.1],[1931,24.5],[1945,24.5],[1950,31.71],[1951,31.8],[1952,31.98],[1953,32.15],[1954,32.32],[1955,32.49],[1956,32.66],[1957,32.83],[1958,32.99],[1959,33.16],[1960,33.34],[1961,33.52],[1962,33.71],[1963,33.91],[1964,34.14],[1965,34.38],[1966,34.65],[1967,34.93],[1968,35.24],[1969,35.58],[1970,35.97],[1971,36.43],[1972,36.96],[1973,37.56],[1974,38.22],[1975,38.9],[1976,39.59],[1977,40.24],[1978,40.84],[1979,41.35],[1980,41.76],[1981,42.07],[1982,42.29],[1983,42.43],[1984,42.47],[1985,42.39],[1986,42.16],[1987,41.77],[1988,41.25],[1989,40.63],[1990,39.98],[1991,39.35],[1992,38.8],[1993,38.4],[1994,38.19],[1995,38.23],[1996,38.54],[1997,39.12],[1998,39.9],[1999,40.84],[2000,41.88],[2001,42.95],[2002,43.98],[2003,44.92],[2004,45.72],[2005,46.37],[2006,46.87],[2007,47.28],[2008,47.63],[2009,47.95]]},{"name":"Somalia","region":"Sub-Saharan Africa","income":[[1800,498.83],[1820,498.83],[1913,770.73],[1950,1079.21],[1951,1121.11],[1952,1135.75],[1953,1156.66],[1954,1200.56],[1955,1216.04],[1956,1236.83],[1957,1258.15],[1958,1267.28],[1959,1314.37],[1960,1304.43],[1961,1339.27],[1962,1369.49],[1963,1393.03],[1964,1216.29],[1965,1111.44],[1966,1241.97],[1967,1284.73],[1968,1278.43],[1969,1094.01],[1970,1162.59],[1971,1165.65],[1972,1254.58],[1973,1201.48],[1974,933.75],[1975,1227.29],[1976,1191.53],[1977,1450.99],[1978,1419.24],[1979,1206.31],[1980,1059.16],[1981,1136.58],[1982,1176.81],[1983,1037.61],[1984,1037.59],[1985,1080.05],[1986,1075.7],[1987,1093.24],[1988,1089.29],[1989,1112.25],[1990,1106.43],[1991,1030.38],[1992,926.96],[1993,933.06],[1994,942.53],[1995,952.5],[1996,956.1],[1997,930.6],[1998,902.11],[1999,891.91],[2000,881.51],[2001,868.92],[2002,882.08],[2003,895.72],[2004,914.04],[2005,932.96],[2006,935.96],[2007,939.53],[2008,943.04]],"population":[[1820,1000000],[1950,2437932],[1951,2481642],[1952,2526994],[1953,2574024],[1954,2622821],[1955,2673425],[1956,2725932],[1957,2780415],[1958,2836952],[1959,2895391],[1960,2955803],[1961,3016963],[1962,3080153],[1963,3145420],[1964,3212842],[1965,3282503],[1966,3354474],[1967,3428839],[1968,3505657],[1969,3584995],[1970,3666949],[1971,3751979],[1972,3840161],[1973,3931655],[1974,4027472],[1975,4127771],[1976,4237929],[1977,4353666],[1978,4677751],[1979,5308692],[1980,5790705],[1981,5824927],[1982,5828892],[1983,6002525],[1984,6207416],[1985,6445623],[1986,6699590],[1987,6921858],[1988,6900134],[1989,6748499],[1990,6675067],[1991,6448104],[1992,6099799],[1993,6059950],[1994,6177841],[1995,6291143],[1996,6460865],[1997,6633514],[1998,6843022],[1999,7043751],[2000,7253137],[2001,7488773],[2002,7753310],[2003,8025190],[2004,8304601],[2005,8591629],[2006,8863338],[2007,9118773],[2008,9379907]],"lifeExpectancy":[[1800,29.4],[1945,29.4],[1950,32.18],[1951,32.38],[1952,32.78],[1953,33.18],[1954,33.58],[1955,33.98],[1956,34.38],[1957,34.78],[1958,35.18],[1959,35.58],[1960,35.98],[1961,36.38],[1962,36.78],[1963,37.18],[1964,37.58],[1965,37.98],[1966,38.39],[1967,38.81],[1968,39.23],[1969,39.65],[1970,40.05],[1971,40.41],[1972,40.74],[1973,41.02],[1974,41.26],[1975,41.48],[1976,41.69],[1977,41.93],[1978,42.21],[1979,42.53],[1980,42.9],[1981,43.35],[1982,43.85],[1983,44.36],[1984,44.87],[1985,45.28],[1986,45.51],[1987,45.52],[1988,45.32],[1989,44.95],[1990,44.51],[1991,44.12],[1992,43.89],[1993,43.91],[1994,44.19],[1995,44.72],[1996,45.45],[1997,46.26],[1998,47.05],[1999,47.77],[2000,48.37],[2001,48.81],[2002,49.13],[2003,49.34],[2004,49.47],[2005,49.54],[2006,49.61],[2007,49.7],[2008,49.86],[2009,50.09]]},{"name":"South Africa","region":"Sub-Saharan Africa","income":[[1800,759.05],[1820,759.05],[1870,1569.68],[1911,2895.87],[1912,2905.27],[1913,2693.95],[1914,2543.25],[1915,2345.4],[1916,2337.68],[1917,2239.29],[1918,2263.96],[1919,2548.17],[1920,1939.11],[1921,2172.74],[1922,2287.39],[1923,2499.68],[1924,2627.12],[1925,2677.32],[1926,2751.35],[1927,2790.42],[1928,2867.08],[1929,2847.2],[1930,2783.61],[1931,2600.07],[1932,2528.04],[1933,2873.65],[1934,3035.38],[1935,3544.11],[1936,3837.86],[1937,3817.2],[1938,3882.67],[1939,4083.14],[1940,4134.38],[1941,4285.57],[1942,4222.72],[1943,4140.07],[1944,4178.71],[1945,4349.06],[1946,4538.22],[1947,4530.29],[1948,4760.18],[1949,4766.14],[1950,4575.12],[1951,4689.81],[1952,4725.3],[1953,4827.96],[1954,5065.89],[1955,5199.29],[1956,5370.01],[1957,5487.1],[1958,5510.16],[1959,5630.54],[1960,5545.68],[1961,5582.3],[1962,5768.73],[1963,6045.12],[1964,6380.02],[1965,6625.41],[1966,6773.61],[1967,7114.48],[1968,7256.58],[1969,7441.4],[1970,7668.61],[1971,7817.81],[1972,7765.96],[1973,7943.17],[1974,8249.3],[1975,8205.63],[1976,8211.03],[1977,8028.65],[1978,8099.64],[1979,8226.73],[1980,8577.42],[1981,8826.14],[1982,8568.27],[1983,8187.6],[1984,8389.87],[1985,8067.51],[1986,7859.35],[1987,7825.82],[1988,7965.5],[1989,7976.29],[1990,7786.88],[1991,7545.41],[1992,7225.07],[1993,7160],[1994,7236.9],[1995,7304.2],[1996,7454.42],[1997,7479.19],[1998,7339.96],[1999,7333.69],[2000,7454.45],[2001,7520.72],[2002,7710.95],[2003,7863.74],[2004,8154.74],[2005,8477],[2006,8857.05],[2007,9253.18],[2008,9428.79],[2009,9141.27]],"population":[[1820,1550000],[1870,2547000],[1913,6153000],[1950,13595840],[1951,13926314],[1952,14264935],[1953,14623631],[1954,14991553],[1955,15368551],[1956,15755233],[1957,16151549],[1958,16558044],[1959,16974984],[1960,17416653],[1961,17869991],[1962,18356657],[1963,18856708],[1964,19370514],[1965,19898242],[1966,20440487],[1967,20997321],[1968,21569468],[1969,22157355],[1970,22739921],[1971,23338080],[1972,23935810],[1973,24549294],[1974,25178954],[1975,25815144],[1976,26467896],[1977,27129932],[1978,27809087],[1979,28505816],[1980,29251588],[1981,30168679],[1982,31140029],[1983,32143960],[1984,33181594],[1985,34254092],[1986,35098897],[1987,35933379],[1988,36761065],[1989,37581427],[1990,38391094],[1991,39183648],[1992,39964159],[1993,40639384],[1994,41211897],[1995,41779149],[1996,42311979],[1997,42835005],[1998,43334603],[1999,43745636],[2000,44066197],[2001,44296012],[2002,44433622],[2003,44481901],[2004,44448470],[2005,44344136],[2006,44187637],[2007,43997828],[2008,43786115]],"lifeExpectancy":[[1800,33.5],[1930,33.5],[1950,43.55],[1951,43.94],[1952,44.69],[1953,45.4],[1954,46.06],[1955,46.66],[1956,47.22],[1957,47.74],[1958,48.21],[1959,48.64],[1960,49.05],[1961,49.44],[1962,49.82],[1963,50.19],[1964,50.57],[1965,50.96],[1966,51.35],[1967,51.73],[1968,52.1],[1969,52.47],[1970,52.82],[1971,53.17],[1972,53.51],[1973,53.85],[1974,54.2],[1975,54.56],[1976,54.94],[1977,55.36],[1978,55.81],[1979,56.28],[1980,56.79],[1981,57.33],[1982,57.89],[1983,58.45],[1984,58.99],[1985,59.51],[1986,60.01],[1987,60.46],[1988,60.85],[1989,61.16],[1990,61.38],[1991,61.47],[1992,61.43],[1993,61.25],[1994,60.94],[1995,60.45],[1996,59.78],[1997,58.93],[1998,57.95],[1999,56.87],[2000,55.77],[2001,54.7],[2002,53.72],[2003,52.9],[2004,52.25],[2005,51.8],[2006,51.57],[2007,51.5],[2008,51.56],[2009,51.72]]},{"name":"Sudan","region":"Sub-Saharan Africa","income":[[1800,484.74],[1820,484.74],[1913,748.95],[1950,1551.84],[1951,1582.37],[1952,1615.99],[1953,1646.64],[1954,1680.02],[1955,1714.45],[1956,1844.53],[1957,1770.34],[1958,1793.53],[1959,1952.43],[1960,1935.05],[1961,1882.94],[1962,1959.59],[1963,1852.46],[1964,1785.07],[1965,1860.81],[1966,1789.81],[1967,1688],[1968,1744.15],[1969,1802.85],[1970,1679.15],[1971,1745.17],[1972,1659.65],[1973,1473.99],[1974,1574.27],[1975,1720.49],[1976,1974.01],[1977,2202.99],[1978,2094.28],[1979,1808.21],[1980,1760.99],[1981,1739.51],[1982,1895.54],[1983,1811.71],[1984,1660.51],[1985,1495.82],[1986,1508.83],[1987,1507.82],[1988,1494.42],[1989,1574.46],[1990,1405.31],[1991,1458.84],[1992,1492.2],[1993,1495],[1994,1483.56],[1995,1488.27],[1996,1524.29],[1997,1632.21],[1998,1680.62],[1999,1758.2],[2000,1874.02],[2001,1933.19],[2002,1993.4],[2003,2077.55],[2004,2125.87],[2005,2249],[2006,2439.47],[2007,2619.28],[2008,2727.56],[2009,2778.61]],"population":[[1820,5156000],[1950,8051151],[1951,8274803],[1952,8504667],[1953,8740917],[1954,8983729],[1955,9233287],[1956,9489777],[1957,9753392],[1958,10024330],[1959,10302794],[1960,10588993],[1961,10882055],[1962,11183227],[1963,11492735],[1964,11800659],[1965,12085785],[1966,12376709],[1967,12716129],[1968,13058929],[1969,13402968],[1970,13787599],[1971,14182396],[1972,14597019],[1973,15113382],[1974,15571235],[1975,16056068],[1976,16570074],[1977,17104986],[1978,17712471],[1979,18386531],[1980,19063992],[1981,19701604],[1982,20367053],[1983,21750815],[1984,22542649],[1985,23454185],[1986,24171132],[1987,24725960],[1988,25240354],[1989,25837856],[1990,26627366],[1991,27445775],[1992,28227588],[1993,28963634],[1994,29771011],[1995,30567288],[1996,31307337],[1997,32160729],[1998,33108466],[1999,34085246],[2000,35079814],[2001,36080373],[2002,37090298],[2003,38114160],[2004,39148162],[2005,40187486],[2006,41236378],[2007,42292929],[2008,43354411]],"lifeExpectancy":[[1800,31.4],[1940,31.4],[1950,41.06],[1951,41.15],[1952,41.32],[1953,41.5],[1954,41.69],[1955,41.89],[1956,42.09],[1957,42.3],[1958,42.51],[1959,42.75],[1960,43],[1961,43.26],[1962,43.56],[1963,43.87],[1964,44.21],[1965,44.57],[1966,44.94],[1967,45.31],[1968,45.68],[1969,46.04],[1970,46.39],[1971,46.73],[1972,47.05],[1973,47.37],[1974,47.68],[1975,47.98],[1976,48.28],[1977,48.58],[1978,48.88],[1979,49.18],[1980,49.49],[1981,49.78],[1982,50.07],[1983,50.36],[1984,50.64],[1985,50.93],[1986,51.22],[1987,51.53],[1988,51.85],[1989,52.19],[1990,52.55],[1991,52.92],[1992,53.3],[1993,53.69],[1994,54.07],[1995,54.44],[1996,54.8],[1997,55.14],[1998,55.46],[1999,55.77],[2000,56.06],[2001,56.32],[2002,56.57],[2003,56.81],[2004,57.05],[2005,57.3],[2006,57.56],[2007,57.85],[2008,58.16],[2009,58.5]]},{"name":"Swaziland","region":"Sub-Saharan Africa","income":[[1800,414.04],[1820,414.04],[1913,639.72],[1950,1102.4],[1951,1139.3],[1952,1148.38],[1953,1165.39],[1954,1202.81],[1955,1211.97],[1956,1228.31],[1957,1244.71],[1958,1248.4],[1959,1288.37],[1960,1428.81],[1961,1571.42],[1962,1856.18],[1963,1913.56],[1964,2139.39],[1965,2410.44],[1966,2448.89],[1967,2613.1],[1968,2428.33],[1969,2464.78],[1970,3111.99],[1971,3080.01],[1972,3364.84],[1973,3451.35],[1974,3735.37],[1975,3763.75],[1976,3778.83],[1977,3781.41],[1978,3764.15],[1979,3701.56],[1980,3664.77],[1981,3793.14],[1982,3895.38],[1983,3782.51],[1984,3725.86],[1985,3817.84],[1986,3813.04],[1987,3984.84],[1988,3712.85],[1989,3787.6],[1990,3722.55],[1991,3646.2],[1992,3553.02],[1993,3561.05],[1994,3660.89],[1995,3771.59],[1996,3821.06],[1997,3876.77],[1998,3920.39],[1999,3989.51],[2000,4021.22],[2001,4046.53],[2002,4128.12],[2003,4206.8],[2004,4286.16],[2005,4384],[2006,4494.11],[2007,4632.83],[2008,4726.06],[2009,4728.18]],"population":[[1800,86000],[1904,86000],[1911,109000],[1921,113000],[1936,157000],[1946,188000],[1950,277384],[1951,283699],[1952,290243],[1953,297025],[1954,304057],[1955,311346],[1956,318904],[1957,326741],[1958,334837],[1959,343201],[1960,351842],[1961,360775],[1962,370006],[1963,379526],[1964,389347],[1965,399481],[1966,409941],[1967,420690],[1968,431797],[1969,443277],[1970,455145],[1971,467416],[1972,480105],[1973,493232],[1974,506812],[1975,520864],[1976,535618],[1977,551425],[1978,568333],[1979,588268],[1980,611447],[1981,631303],[1982,649901],[1983,672690],[1984,696870],[1985,722451],[1986,750707],[1987,779348],[1988,817085],[1989,851904],[1990,884616],[1991,925717],[1992,962344],[1993,991859],[1994,997652],[1995,1004849],[1996,1030651],[1997,1054486],[1998,1075900],[1999,1094429],[2000,1109750],[2001,1121699],[2002,1130269],[2003,1135657],[2004,1138171],[2005,1138227],[2006,1136334],[2007,1133066],[2008,1128814]],"lifeExpectancy":[[1800,32.3],[1945,32.3],[1950,40.5],[1951,40.74],[1952,41.21],[1953,41.66],[1954,42.09],[1955,42.5],[1956,42.89],[1957,43.26],[1958,43.61],[1959,43.94],[1960,44.26],[1961,44.56],[1962,44.84],[1963,45.13],[1964,45.42],[1965,45.73],[1966,46.09],[1967,46.49],[1968,46.95],[1969,47.46],[1970,48.01],[1971,48.6],[1972,49.2],[1973,49.81],[1974,50.42],[1975,51.03],[1976,51.65],[1977,52.29],[1978,52.95],[1979,53.63],[1980,54.33],[1981,55.04],[1982,55.75],[1983,56.45],[1984,57.13],[1985,57.78],[1986,58.42],[1987,59.04],[1988,59.63],[1989,60.14],[1990,60.53],[1991,60.76],[1992,60.77],[1993,60.55],[1994,60.06],[1995,59.25],[1996,58.05],[1997,56.52],[1998,54.71],[1999,52.74],[2000,50.75],[2001,48.91],[2002,47.33],[2003,46.13],[2004,45.34],[2005,44.99],[2006,45.03],[2007,45.34],[2008,45.8],[2009,46.36]]},{"name":"Tanzania","region":"Sub-Saharan Africa","income":[[1800,470.64],[1820,470.64],[1913,595.68],[1950,654.21],[1951,719.42],[1952,716.65],[1953,674.35],[1954,711.14],[1955,710.04],[1956,700.32],[1957,698.54],[1958,685.88],[1959,700.2],[1960,708.87],[1961,681.14],[1962,722],[1963,745.36],[1964,763.24],[1965,767.49],[1966,840.34],[1967,848.22],[1968,865.71],[1969,855.27],[1970,877.54],[1971,886.77],[1972,915.99],[1973,914.86],[1974,907.39],[1975,926.81],[1976,964.5],[1977,962.49],[1978,961.31],[1979,944.86],[1980,925.32],[1981,888.54],[1982,874.24],[1983,845.05],[1984,840.91],[1985,814.7],[1986,816.73],[1987,831.82],[1988,840.71],[1989,844.46],[1990,850.81],[1991,844.63],[1992,825.68],[1993,808.59],[1994,790.9],[1995,794.02],[1996,813.6],[1997,789.19],[1998,798.12],[1999,806.1],[2000,826.23],[2001,857.59],[2002,899.07],[2003,929.86],[2004,972.48],[2005,1018],[2006,1066.68],[2007,1120.51],[2008,1180.24],[2009,1220.25]],"population":[[1800,3019768],[1820,3019768],[1921,4314332],[1931,5299000],[1948,7740786],[1950,7934924],[1951,8124902],[1952,8322925],[1953,8529355],[1954,8745102],[1955,8970610],[1956,9206352],[1957,9452826],[1958,9710558],[1959,9978909],[1960,10259653],[1961,10555397],[1962,10863958],[1963,11185238],[1964,11521695],[1965,11870412],[1966,12231389],[1967,12607312],[1968,12988137],[1969,13389543],[1970,13806869],[1971,14236867],[1972,14706593],[1973,15201384],[1974,15681232],[1975,16147863],[1976,16625711],[1977,17129565],[1978,17647395],[1979,18174406],[1980,18715307],[1981,19273923],[1982,19844382],[1983,20437869],[1984,21050790],[1985,21677040],[1986,22328642],[1987,23040630],[1988,23760348],[1989,24447781],[1990,25137888],[1991,25853394],[1992,26605473],[1993,27493980],[1994,28556908],[1995,29470379],[1996,30055334],[1997,30686889],[1998,31467507],[1999,32245532],[2000,33065142],[2001,33831342],[2002,34593779],[2003,35354845],[2004,36070799],[2005,36766356],[2006,37445392],[2007,38139640],[2008,38858276]],"lifeExpectancy":[[1800,32.2],[1945,32.2],[1950,40.39],[1951,40.61],[1952,41.05],[1953,41.45],[1954,41.84],[1955,42.19],[1956,42.53],[1957,42.84],[1958,43.12],[1959,43.4],[1960,43.66],[1961,43.91],[1962,44.16],[1963,44.42],[1964,44.7],[1965,44.99],[1966,45.3],[1967,45.63],[1968,45.97],[1969,46.32],[1970,46.69],[1971,47.08],[1972,47.48],[1973,47.89],[1974,48.3],[1975,48.7],[1976,49.07],[1977,49.41],[1978,49.72],[1979,49.98],[1980,50.21],[1981,50.42],[1982,50.61],[1983,50.8],[1984,50.97],[1985,51.12],[1986,51.2],[1987,51.22],[1988,51.17],[1989,51.05],[1990,50.87],[1991,50.65],[1992,50.41],[1993,50.2],[1994,50.02],[1995,49.92],[1996,49.9],[1997,49.97],[1998,50.13],[1999,50.38],[2000,50.74],[2001,51.19],[2002,51.73],[2003,52.33],[2004,52.97],[2005,53.65],[2006,54.34],[2007,55.03],[2008,55.7],[2009,56.35]]},{"name":"Togo","region":"Sub-Saharan Africa","income":[[1800,535.59],[1820,535.59],[1913,827.52],[1950,832.05],[1951,846.17],[1952,859.81],[1953,872.92],[1954,886.24],[1955,899.68],[1956,913.16],[1957,925.91],[1958,937.89],[1959,950.54],[1960,1011.31],[1961,1054.67],[1962,1067.53],[1963,1092.43],[1964,1218.93],[1965,1350.38],[1966,1437.09],[1967,1477.6],[1968,1511.87],[1969,1631.71],[1970,1558.82],[1971,1631.68],[1972,1649.66],[1973,1546.84],[1974,1575.43],[1975,1530.1],[1976,1487.63],[1977,1532.78],[1978,1649.61],[1979,1707.47],[1980,1589.51],[1981,1446.7],[1982,1344.58],[1983,1228.04],[1984,1221.05],[1985,1234.15],[1986,1228.38],[1987,1202.2],[1988,1212.08],[1989,1213.3],[1990,1160.13],[1991,1113.67],[1992,1034.3],[1993,869.67],[1994,1014.99],[1995,1026.07],[1996,1073.78],[1997,982.29],[1998,932.92],[1999,933.17],[2000,890.36],[2001,871.57],[2002,886.22],[2003,907.24],[2004,903.34],[2005,888],[2006,900.26],[2007,895.17],[2008,888.41],[2009,888.01]],"population":[[1800,445985],[1820,445985],[1950,1171897],[1951,1194973],[1952,1219113],[1953,1244363],[1954,1270771],[1955,1298389],[1956,1327270],[1957,1357445],[1958,1388973],[1959,1421772],[1960,1455900],[1961,1491264],[1962,1528098],[1963,1566469],[1964,1606285],[1965,1647772],[1966,1690838],[1967,1735550],[1968,1781978],[1969,1830381],[1970,1964128],[1971,2009685],[1972,2056351],[1973,2104154],[1974,2153238],[1975,2203646],[1976,2255413],[1977,2308582],[1978,2363192],[1979,2420740],[1980,2481375],[1981,2555796],[1982,2644765],[1983,2738544],[1984,2836453],[1985,2938286],[1986,3044174],[1987,3154264],[1988,3268540],[1989,3385787],[1990,3504813],[1991,3625489],[1992,3747553],[1993,3726013],[1994,3750370],[1995,3965576],[1996,4157932],[1997,4320890],[1998,4454777],[1999,4582500],[2000,4711655],[2001,4843185],[2002,4977378],[2003,5114524],[2004,5255320],[2005,5399991],[2006,5548702],[2007,5701579],[2008,5858673]],"lifeExpectancy":[[1800,31.3],[1945,31.3],[1950,40.13],[1951,40.42],[1952,40.98],[1953,41.52],[1954,42.04],[1955,42.54],[1956,43.01],[1957,43.47],[1958,43.91],[1959,44.34],[1960,44.76],[1961,45.16],[1962,45.57],[1963,45.98],[1964,46.4],[1965,46.84],[1966,47.29],[1967,47.76],[1968,48.26],[1969,48.77],[1970,49.3],[1971,49.85],[1972,50.42],[1973,51],[1974,51.58],[1975,52.15],[1976,52.72],[1977,53.28],[1978,53.82],[1979,54.34],[1980,54.82],[1981,55.27],[1982,55.68],[1983,56.05],[1984,56.38],[1985,56.68],[1986,56.93],[1987,57.16],[1988,57.36],[1989,57.54],[1990,57.72],[1991,57.9],[1992,58.08],[1993,58.28],[1994,58.49],[1995,58.71],[1996,58.93],[1997,59.14],[1998,59.34],[1999,59.54],[2000,59.76],[2001,60],[2002,60.28],[2003,60.6],[2004,60.96],[2005,61.36],[2006,61.77],[2007,62.18],[2008,62.57],[2009,62.93]]},{"name":"Uganda","region":"Sub-Saharan Africa","income":[[1800,461.08],[1820,461.08],[1913,712.4],[1950,759.88],[1951,710.29],[1952,734.75],[1953,746.83],[1954,716.66],[1955,743.21],[1956,763.14],[1957,774.37],[1958,757.98],[1959,774.45],[1960,788.69],[1961,758.7],[1962,767.27],[1963,830.8],[1964,868.29],[1965,861.75],[1966,888.69],[1967,908.92],[1968,904.6],[1969,974.6],[1970,960.97],[1971,964.15],[1972,950.74],[1973,927.25],[1974,908.34],[1975,867.67],[1976,852.35],[1977,843.73],[1978,777.37],[1979,675.82],[1980,638.77],[1981,647.57],[1982,682.27],[1983,711.85],[1984,630.52],[1985,622.04],[1986,603.24],[1987,617.72],[1988,636.79],[1989,658.11],[1990,661.3],[1991,646.06],[1992,644.17],[1993,674.24],[1994,693.03],[1995,755.16],[1996,799.01],[1997,816.56],[1998,830.71],[1999,865.83],[2000,881.21],[2001,896.54],[2002,927.72],[2003,937.6],[2004,959.71],[2005,991],[2006,1059.73],[2007,1108.95],[2008,1163.64],[2009,1202.53]],"population":[[1800,2101397],[1820,2101397],[1911,2843000],[1921,2921000],[1931,3554000],[1948,4959000],[1950,5521758],[1951,5670970],[1952,5824797],[1953,5983396],[1954,6147541],[1955,6317454],[1956,6493361],[1957,6675501],[1958,6864123],[1959,7059486],[1960,7261862],[1961,7471533],[1962,7688797],[1963,7913960],[1964,8147346],[1965,8389294],[1966,8640153],[1967,8900294],[1968,9170101],[1969,9449977],[1970,9728111],[1971,9983229],[1972,10190285],[1973,10385004],[1974,10619695],[1975,10890181],[1976,11169608],[1977,11457758],[1978,11755730],[1979,12032167],[1980,12296592],[1981,12595972],[1982,12939400],[1983,13321200],[1984,13761689],[1985,14225933],[1986,14717932],[1987,15283050],[1988,15892811],[1989,16500123],[1990,17074034],[1991,17651716],[1992,18252190],[1993,18903138],[1994,19566609],[1995,20094075],[1996,20623835],[1997,21210254],[1998,21829118],[1999,22535846],[2000,23248553],[2001,23970202],[2002,24739869],[2003,25556448],[2004,26390258],[2005,27269482],[2006,28195754],[2007,29170398],[2008,30214531]],"lifeExpectancy":[[1800,25.3],[1922,25.3],[1927,23.9],[1937,26.4],[1945,28.8],[1950,39],[1951,39.24],[1952,39.73],[1953,40.23],[1954,40.74],[1955,41.25],[1956,41.78],[1957,42.32],[1958,42.86],[1959,43.41],[1960,43.97],[1961,44.52],[1962,45.07],[1963,45.62],[1964,46.16],[1965,46.72],[1966,47.31],[1967,47.94],[1968,48.59],[1969,49.23],[1970,49.84],[1971,50.34],[1972,50.71],[1973,50.92],[1974,50.98],[1975,50.9],[1976,50.73],[1977,50.53],[1978,50.32],[1979,50.15],[1980,50.04],[1981,49.98],[1982,49.96],[1983,49.95],[1984,49.93],[1985,49.86],[1986,49.7],[1987,49.42],[1988,49.01],[1989,48.5],[1990,47.91],[1991,47.27],[1992,46.65],[1993,46.09],[1994,45.64],[1995,45.34],[1996,45.22],[1997,45.26],[1998,45.46],[1999,45.81],[2000,46.31],[2001,46.95],[2002,47.7],[2003,48.52],[2004,49.38],[2005,50.25],[2006,51.11],[2007,51.94],[2008,52.73],[2009,53.47]]},{"name":"Zambia","region":"Sub-Saharan Africa","income":[[1800,364.46],[1820,364.46],[1913,563.12],[1950,1060.84],[1951,1103.66],[1952,1147.39],[1953,1192.69],[1954,1239.06],[1955,1180.94],[1956,1289.24],[1957,1311.96],[1958,1245.62],[1959,1468.11],[1960,1540.6],[1961,1505.53],[1962,1452.73],[1963,1447.58],[1964,1599.11],[1965,1841.72],[1966,1695.38],[1967,1777.08],[1968,1753.08],[1969,1695.41],[1970,1722.48],[1971,1672.76],[1972,1773.5],[1973,1704.46],[1974,1788.69],[1975,1670.52],[1976,1718.94],[1977,1588.69],[1978,1552.52],[1979,1461.38],[1980,1461.6],[1981,1502.69],[1982,1408.68],[1983,1329.5],[1984,1279.2],[1985,1258.79],[1986,1223.74],[1987,1213.32],[1988,1249.79],[1989,1226.43],[1990,1299.99],[1991,1264.81],[1992,1210.88],[1993,1261.3],[1994,1067.93],[1995,1017.79],[1996,1060.55],[1997,1071.35],[1998,1027.23],[1999,1025.58],[2000,1035.9],[2001,1059.73],[2002,1071.61],[2003,1105.23],[2004,1140.76],[2005,1175],[2006,1218.75],[2007,1333.61],[2008,1382.47],[2009,1442.06]],"population":[[1800,747000],[1904,747000],[1911,822000],[1921,984000],[1931,1345000],[1950,2553000],[1951,2611000],[1952,2672000],[1953,2734000],[1954,2800000],[1955,2869000],[1956,2941000],[1957,3016000],[1958,3094000],[1959,3173000],[1960,3254000],[1961,3337000],[1962,3421000],[1963,3508000],[1964,3599000],[1965,3694000],[1966,3794000],[1967,3900000],[1968,4009000],[1969,4123000],[1970,4251612],[1971,4376371],[1972,4506497],[1973,4642941],[1974,4784668],[1975,4923730],[1976,5067045],[1977,5216550],[1978,5371218],[1979,5531990],[1980,5699777],[1981,5884561],[1982,6100407],[1983,6337427],[1984,6563331],[1985,6779477],[1986,7022362],[1987,7272406],[1988,7502249],[1989,7722416],[1990,7941694],[1991,8162612],[1992,8381163],[1993,8593282],[1994,8800157],[1995,9001866],[1996,9201909],[1997,9417789],[1998,9636385],[1999,9863137],[2000,10116606],[2001,10373871],[2002,10595811],[2003,10799220],[2004,11025690],[2005,11261795],[2006,11502010],[2007,11746035],[2008,11993403]],"lifeExpectancy":[[1800,32.6],[1945,32.6],[1950,41.22],[1951,41.43],[1952,41.85],[1953,42.26],[1954,42.67],[1955,43.09],[1956,43.5],[1957,43.9],[1958,44.31],[1959,44.71],[1960,45.1],[1961,45.47],[1962,45.84],[1963,46.19],[1964,46.54],[1965,46.9],[1966,47.27],[1967,47.66],[1968,48.09],[1969,48.53],[1970,48.99],[1971,49.46],[1972,49.91],[1973,50.34],[1974,50.72],[1975,51.05],[1976,51.33],[1977,51.55],[1978,51.72],[1979,51.84],[1980,51.93],[1981,51.99],[1982,52.04],[1983,52.08],[1984,52.11],[1985,52.1],[1986,52.07],[1987,51.97],[1988,51.8],[1989,51.53],[1990,51.12],[1991,50.53],[1992,49.77],[1993,48.85],[1994,47.81],[1995,46.69],[1996,45.55],[1997,44.45],[1998,43.45],[1999,42.63],[2000,42.04],[2001,41.72],[2002,41.67],[2003,41.86],[2004,42.27],[2005,42.88],[2006,43.66],[2007,44.54],[2008,45.47],[2009,46.4]]},{"name":"Zimbabwe","region":"Sub-Saharan Africa","income":[[1800,372.82],[1820,372.82],[1913,387.64],[1950,393.7],[1951,405.39],[1952,406.88],[1953,426.64],[1954,433.72],[1955,454.05],[1956,500.9],[1957,518.76],[1958,509.09],[1959,519.6],[1960,526.78],[1961,536.66],[1962,527.27],[1963,506.09],[1964,535.49],[1965,552.37],[1966,543.32],[1967,569.8],[1968,561.22],[1969,609.82],[1970,720.26],[1971,760.02],[1972,799.36],[1973,804.19],[1974,801.62],[1975,787.31],[1976,762.17],[1977,685.59],[1978,692],[1979,679.95],[1980,727.55],[1981,790.3],[1982,788.86],[1983,771.84],[1984,728.37],[1985,749.91],[1986,742.3],[1987,706.16],[1988,744.46],[1989,768.28],[1990,761.5],[1991,782.09],[1992,693.42],[1993,686.67],[1994,719.99],[1995,717.36],[1996,781.5],[1997,792.45],[1998,806.31],[1999,792.76],[2000,745.77],[2001,719.96],[2002,672.04],[2003,598.24],[2004,571.74],[2005,538],[2006,517.35],[2007,498.8],[2008,426.62],[2009,443.74]],"population":[[1800,1085814],[1820,1085814],[1950,2853151],[1951,2950941],[1952,3080907],[1953,3190967],[1954,3307273],[1955,3409017],[1956,3529739],[1957,3646340],[1958,3764157],[1959,3886947],[1960,4010933],[1961,4140117],[1962,4277736],[1963,4412423],[1964,4537263],[1965,4685272],[1966,4835691],[1967,4995432],[1968,5171817],[1969,5352802],[1970,5514536],[1971,5684187],[1972,5861135],[1973,6001949],[1974,6172535],[1975,6341797],[1976,6496418],[1977,6642107],[1978,6767223],[1979,6887132],[1980,7169968],[1981,7429223],[1982,7636524],[1983,7928538],[1984,8241357],[1985,8560378],[1986,8876579],[1987,9216418],[1988,9560036],[1989,9867471],[1990,10152933],[1991,10429405],[1992,10704340],[1993,10950080],[1994,11049617],[1995,11111992],[1996,11260802],[1997,11404948],[1998,11534135],[1999,11649168],[2000,11751323],[2001,11844109],[2002,11926563],[2003,12004576],[2004,12083553],[2005,12160782],[2006,12236805],[2007,12311143],[2008,12382920]],"lifeExpectancy":[[1800,33.7],[1940,33.7],[1950,47.65],[1951,47.86],[1952,48.28],[1953,48.7],[1954,49.12],[1955,49.53],[1956,49.93],[1957,50.33],[1958,50.73],[1959,51.12],[1960,51.5],[1961,51.87],[1962,52.23],[1963,52.58],[1964,52.92],[1965,53.25],[1966,53.58],[1967,53.9],[1968,54.22],[1969,54.54],[1970,54.86],[1971,55.19],[1972,55.52],[1973,55.85],[1974,56.2],[1975,56.58],[1976,56.99],[1977,57.44],[1978,57.92],[1979,58.43],[1980,58.96],[1981,59.5],[1982,60.03],[1983,60.52],[1984,60.94],[1985,61.26],[1986,61.48],[1987,61.58],[1988,61.53],[1989,61.28],[1990,60.76],[1991,59.89],[1992,58.65],[1993,57.07],[1994,55.21],[1995,53.13],[1996,50.93],[1997,48.73],[1998,46.66],[1999,44.82],[2000,43.32],[2001,42.23],[2002,41.54],[2003,41.22],[2004,41.28],[2005,41.68],[2006,42.4],[2007,43.36],[2008,44.49],[2009,45.72]]},{"name":"Afghanistan","region":"South Asia","income":[[1800,472.05],[1820,472.05],[1913,638.38],[1950,757.32],[1951,766.75],[1952,779.45],[1953,812.86],[1954,815.36],[1955,816.41],[1956,837.07],[1957,820.85],[1958,849.74],[1959,856.23],[1960,868.5],[1961,857.36],[1962,853.1],[1963,849.44],[1964,846.27],[1965,845.22],[1966,833.61],[1967,836.2],[1968,845.08],[1969,837.62],[1970,833.32],[1971,773.7],[1972,739.98],[1973,803.49],[1974,825.58],[1975,846.44],[1976,866.19],[1977,786.11],[1978,827.09],[1979,809.07],[1980,810.43],[1981,896.86],[1982,978.01],[1983,1013.13],[1984,994.57],[1985,961.92],[1986,1030.89],[1987,852.4],[1988,770.01],[1989,751.44],[1990,709.5],[1991,705.45],[1992,649.34],[1993,558.85],[1994,500.45],[1995,601.87],[1996,617.91],[1997,635.34],[1998,653.3],[1999,670.99],[2000,663.91],[2001,595.04],[2002,726.73],[2003,785.13],[2004,804.72],[2005,874],[2006,910.38],[2007,1012.61],[2008,1019.36],[2009,1216.68]],"population":[[1800,3280000],[1820,3280000],[1870,4207000],[1913,5730000],[1950,8150368],[1951,8284473],[1952,8425333],[1953,8573217],[1954,8728408],[1955,8891209],[1956,9061938],[1957,9240934],[1958,9428556],[1959,9624606],[1960,9829450],[1961,10043473],[1962,10267083],[1963,10500711],[1964,10744167],[1965,10997885],[1966,11262324],[1967,11537966],[1968,11825320],[1969,12122740],[1970,12430623],[1971,12749385],[1972,13079460],[1973,13421301],[1974,13772076],[1975,14132019],[1976,14501369],[1977,14880372],[1978,15269281],[1979,15555612],[1980,15112149],[1981,13812973],[1982,12881816],[1983,12934937],[1984,13387737],[1985,13796928],[1986,13856100],[1987,13867957],[1988,14076478],[1989,14511868],[1990,14669339],[1991,14871963],[1992,16317921],[1993,18371583],[1994,19900668],[1995,20881480],[1996,21559923],[1997,22227415],[1998,22912814],[1999,23646128],[2000,23898198],[2001,23997412],[2002,25268405],[2003,27060359],[2004,28513677],[2005,29928987],[2006,31056997],[2007,31889923],[2008,32738376]],"lifeExpectancy":[[1800,28.21],[1950,28.21],[1951,28.36],[1952,28.65],[1953,28.95],[1954,29.25],[1955,29.55],[1956,29.85],[1957,30.16],[1958,30.48],[1959,30.8],[1960,31.13],[1961,31.47],[1962,31.82],[1963,32.2],[1964,32.58],[1965,32.98],[1966,33.38],[1967,33.79],[1968,34.2],[1969,34.61],[1970,35.03],[1971,35.46],[1972,35.91],[1973,36.37],[1974,36.85],[1975,37.31],[1976,37.77],[1977,38.2],[1978,38.59],[1979,38.94],[1980,39.25],[1981,39.52],[1982,39.76],[1983,39.98],[1984,40.19],[1985,40.39],[1986,40.58],[1987,40.77],[1988,40.96],[1989,41.15],[1990,41.32],[1991,41.46],[1992,41.58],[1993,41.67],[1994,41.72],[1995,41.75],[1996,41.76],[1997,41.75],[1998,41.75],[1999,41.77],[2000,41.83],[2001,41.93],[2002,42.09],[2003,42.3],[2004,42.57],[2005,42.88],[2006,43.23],[2007,43.58],[2008,43.94],[2009,44.3]]},{"name":"Bangladesh","region":"South Asia","income":[[1800,609],[1820,606],[1821,606],[1822,606],[1823,606],[1824,606],[1825,606],[1826,606],[1827,606],[1828,606],[1829,606],[1830,606],[1831,606],[1832,606],[1833,606],[1834,606],[1835,606],[1836,606],[1837,606],[1838,606],[1839,606],[1840,606],[1841,606],[1842,606],[1843,606],[1844,606],[1845,606],[1846,606],[1847,606],[1848,606],[1849,606],[1850,606],[1851,606],[1852,606],[1853,606],[1854,606],[1855,606],[1856,606],[1857,606],[1858,606],[1859,606],[1860,606],[1861,606],[1862,606],[1863,606],[1864,606],[1865,606],[1866,606],[1867,606],[1868,606],[1869,606],[1870,606],[1871,607],[1872,608],[1873,610],[1874,611],[1875,613],[1876,614],[1877,615],[1878,617],[1879,618],[1880,620],[1881,621],[1882,623],[1883,624],[1884,625],[1885,644],[1886,622],[1887,649],[1888,654],[1889,635],[1890,664],[1891,602],[1892,649],[1893,664],[1894,673],[1895,655],[1896,606],[1897,715],[1898,716],[1899,659],[1900,681],[1901,691],[1902,744],[1903,750],[1904,749],[1905,730],[1906,747],[1907,697],[1908,703],[1909,795],[1910,791],[1911,785],[1912,782],[1913,764],[1914,805],[1915,785],[1916,807],[1917,791],[1918,690],[1919,784],[1920,721],[1921,772],[1922,796],[1923,763],[1924,792],[1925,793],[1926,810],[1927,802],[1928,802],[1929,827],[1930,824],[1931,808],[1932,806],[1933,795],[1934,791],[1935,773],[1936,792],[1937,768],[1938,759],[1939,765],[1940,780],[1941,785],[1942,772],[1943,793],[1944,776],[1945,754],[1946,706],[1947,702],[1948,701],[1949,709],[1950,673],[1951,675],[1952,684],[1953,683],[1954,683],[1955,633],[1956,688],[1957,662],[1958,636],[1959,656],[1960,679],[1961,704],[1962,686],[1963,741],[1964,734],[1965,758],[1966,753],[1967,721],[1968,772],[1969,767],[1970,785],[1971,731],[1972,630],[1973,620],[1974,682],[1975,660],[1976,674],[1977,660],[1978,687],[1979,698],[1980,684],[1981,687],[1982,677],[1983,693],[1984,714],[1985,720],[1986,736],[1987,752],[1988,759],[1989,763],[1990,799],[1991,810],[1992,838],[1993,863],[1994,884],[1995,913],[1996,939],[1997,973],[1998,1005],[1999,1035],[2000,1075],[2001,1110],[2002,1136],[2003,1172],[2004,1221],[2005,1268],[2006,1326],[2007,1384],[2008,1441],[2009,1492]],"population":[[1820,20000000],[1870,24721000],[1913,31786000],[1929,34427000],[1941,41966000],[1946,41660000],[1950,45645964],[1951,46152281],[1952,46886859],[1953,47660488],[1954,48603271],[1955,49601520],[1956,50477738],[1957,51365468],[1958,52399182],[1959,53484608],[1960,54621538],[1961,55741313],[1962,56839289],[1963,58226108],[1964,59402546],[1965,60332117],[1966,61548117],[1967,62821884],[1968,64133002],[1969,65482564],[1970,67402621],[1971,69226511],[1972,70759295],[1973,72470813],[1974,74679411],[1975,76253310],[1976,77928480],[1977,80428306],[1978,82935511],[1979,85492214],[1980,88076996],[1981,90666000],[1982,93074406],[1983,95384346],[1984,97611763],[1985,99752733],[1986,101768861],[1987,103764241],[1988,105771136],[1989,107806550],[1990,109896945],[1991,111935847],[1992,113704579],[1993,115447696],[1994,117279697],[1995,119186448],[1996,121189286],[1997,123315288],[1998,125572731],[1999,127943283],[2000,130406594],[2001,132974813],[2002,135656790],[2003,138448210],[2004,141340476],[2005,144319628],[2006,147365352],[2007,150448339],[2008,153546901]],"lifeExpectancy":[[1800,25.5],[1876,25.5],[1886,23.2],[1896,22],[1906,21.5],[1926,24.9],[1950,36.75],[1951,36.94],[1952,37.32],[1953,37.69],[1954,38.05],[1955,38.41],[1956,38.77],[1957,39.12],[1958,39.48],[1959,39.84],[1960,40.21],[1961,40.6],[1962,41.01],[1963,41.44],[1964,41.88],[1965,42.33],[1966,42.75],[1967,43.13],[1968,43.47],[1969,43.77],[1970,44.03],[1971,44.25],[1972,44.46],[1973,44.68],[1974,44.92],[1975,45.2],[1976,45.56],[1977,45.98],[1978,46.48],[1979,47.05],[1980,47.67],[1981,48.32],[1982,48.99],[1983,49.65],[1984,50.3],[1985,50.92],[1986,51.52],[1987,52.12],[1988,52.72],[1989,53.34],[1990,53.98],[1991,54.64],[1992,55.34],[1993,56.06],[1994,56.8],[1995,57.56],[1996,58.32],[1997,59.09],[1998,59.84],[1999,60.58],[2000,61.29],[2001,61.99],[2002,62.67],[2003,63.33],[2004,63.97],[2005,64.58],[2006,65.15],[2007,65.67],[2008,66.14],[2009,66.56]]},{"name":"Bhutan","region":"South Asia","income":[[1800,539.56],[1820,539.56],[1950,683.5],[1970,835.91],[1971,828.28],[1972,807.62],[1973,789.32],[1974,799.54],[1975,745.32],[1976,783.53],[1977,816.31],[1978,845.46],[1979,858.09],[1980,874.57],[1981,948.71],[1982,946.81],[1983,999.68],[1984,1035.6],[1985,1064.85],[1986,1177.59],[1987,1494.29],[1988,1535.47],[1989,1615.41],[1990,1782.04],[1991,1804.67],[1992,1904.18],[1993,1989.17],[1994,2149.47],[1995,2317.07],[1996,2456.12],[1997,2561.51],[1998,2656.05],[1999,2790.21],[2000,2922.11],[2001,3045.89],[2002,3256.02],[2003,3406.36],[2004,3545.99],[2005,3694],[2006,3845.06],[2007,4520.52],[2008,4670.97],[2009,5053.83]],"population":[[1800,392287],[1820,392287],[1950,734000],[1951,745689],[1952,757716],[1953,770091],[1954,782825],[1955,796000],[1956,809486],[1957,823365],[1958,837649],[1959,852335],[1960,867000],[1961,882518],[1962,898475],[1963,914885],[1964,931782],[1965,950000],[1966,967932],[1967,986400],[1968,1005421],[1969,1025096],[1970,1045000],[1971,1066129],[1972,1087991],[1973,1110611],[1974,1133702],[1975,1157452],[1976,1181554],[1977,1205659],[1978,1230769],[1979,1255882],[1980,1281000],[1981,1306579],[1982,1333704],[1983,1362337],[1984,1392489],[1985,1424193],[1986,1457094],[1987,1490857],[1988,1525539],[1989,1561160],[1990,1597719],[1991,1635161],[1992,1673428],[1993,1712504],[1994,1752368],[1995,1793012],[1996,1834341],[1997,1876236],[1998,1918669],[1999,1961642],[2000,2005222],[2001,2049412],[2002,2094176],[2003,2139549],[2004,2185569],[2005,2232291],[2006,2279723],[2007,2327849],[2008,2376680]],"lifeExpectancy":[[1950,36.04],[1951,36.04],[1952,36.06],[1953,36.1],[1954,36.17],[1955,36.26],[1956,36.38],[1957,36.51],[1958,36.68],[1959,36.86],[1960,37.08],[1961,37.31],[1962,37.58],[1963,37.86],[1964,38.18],[1965,38.52],[1966,38.88],[1967,39.27],[1968,39.68],[1969,40.12],[1970,40.58],[1971,41.06],[1972,41.56],[1973,42.09],[1974,42.64],[1975,43.21],[1976,43.8],[1977,44.41],[1978,45.03],[1979,45.66],[1980,46.29],[1981,46.91],[1982,47.51],[1983,48.1],[1984,48.67],[1985,49.25],[1986,49.83],[1987,50.43],[1988,51.07],[1989,51.75],[1990,52.47],[1991,53.24],[1992,54.05],[1993,54.89],[1994,55.75],[1995,56.65],[1996,57.57],[1997,58.52],[1998,59.48],[1999,60.43],[2000,61.36],[2001,62.22],[2002,63],[2003,63.7],[2004,64.3],[2005,64.82],[2006,65.26],[2007,65.67],[2008,66.05],[2009,66.42]]},{"name":"India","region":"South Asia","income":[[1800,563],[1820,560],[1821,560],[1822,560],[1823,560],[1824,560],[1825,560],[1826,560],[1827,560],[1828,560],[1829,560],[1830,560],[1831,560],[1832,560],[1833,560],[1834,560],[1835,560],[1836,560],[1837,560],[1838,560],[1839,560],[1840,560],[1841,560],[1842,560],[1843,560],[1844,560],[1845,560],[1846,560],[1847,560],[1848,560],[1849,560],[1850,560],[1851,560],[1852,560],[1853,560],[1854,560],[1855,560],[1856,560],[1857,560],[1858,560],[1859,560],[1860,560],[1861,560],[1862,560],[1863,560],[1864,560],[1865,560],[1866,560],[1867,560],[1868,560],[1869,560],[1870,560],[1871,561],[1872,561],[1873,562],[1874,562],[1875,563],[1876,563],[1877,564],[1878,564],[1879,565],[1880,565],[1881,566],[1882,566],[1883,567],[1884,567],[1885,583],[1886,563],[1887,587],[1888,590],[1889,572],[1890,597],[1891,540],[1892,582],[1893,595],[1894,602],[1895,585],[1896,540],[1897,637],[1898,637],[1899,585],[1900,604],[1901,612],[1902,658],[1903,662],[1904,660],[1905,643],[1906,657],[1907,613],[1908,617],[1909,696],[1910,692],[1911,686],[1912,683],[1913,666],[1914,700],[1915,682],[1916,700],[1917,686],[1918,597],[1919,678],[1920,622],[1921,665],[1922,685],[1923,655],[1924,679],[1925,680],[1926,693],[1927,685],[1928,684],[1929,704],[1930,701],[1931,687],[1932,684],[1933,674],[1934,670],[1935,653],[1936,668],[1937,647],[1938,639],[1939,643],[1940,654],[1941,658],[1942,646],[1943,663],[1944,647],[1945,629],[1946,588],[1947,583],[1948,582],[1949,588],[1950,580],[1951,583],[1952,588],[1953,613],[1954,626],[1955,629],[1956,651],[1957,631],[1958,663],[1959,664],[1960,696],[1961,700],[1962,699],[1963,717],[1964,755],[1965,707],[1966,698],[1967,739],[1968,739],[1969,771],[1970,791],[1971,779],[1972,758],[1973,774],[1974,764],[1975,812],[1976,804],[1977,845],[1978,870],[1979,806],[1980,844],[1981,877],[1982,883],[1983,933],[1984,947],[1985,963],[1986,982],[1987,1001],[1988,1081],[1989,1127],[1990,1160],[1991,1150],[1992,1186],[1993,1227],[1994,1290],[1995,1354],[1996,1433],[1997,1475],[1998,1543],[1999,1607],[2000,1648],[2001,1714],[2002,1754],[2003,1872],[2004,1981],[2005,2126],[2006,2300],[2007,2478],[2008,2622],[2009,2731]],"population":[[1820,175349000],[1870,212189000],[1913,251906000],[1929,275861000],[1941,321565000],[1946,340857000],[1947,346000000],[1948,350000000],[1949,355000000],[1950,359000000],[1951,365000000],[1952,372000000],[1953,379000000],[1954,386000000],[1955,393000000],[1956,401000000],[1957,409000000],[1958,418000000],[1959,426000000],[1960,434000000],[1961,444000000],[1962,454000000],[1963,464000000],[1964,474000000],[1965,485000000],[1966,495000000],[1967,506000000],[1968,518000000],[1969,529000000],[1970,541000000],[1971,554000000],[1972,567000000],[1973,580000000],[1974,593000000],[1975,607000000],[1976,620000000],[1977,634000000],[1978,648000000],[1979,664000000],[1980,679000000],[1981,692000000],[1982,708000000],[1983,723000000],[1984,739000000],[1985,755000000],[1986,771000000],[1987,788000000],[1988,805000000],[1989,822000000],[1990,839000000],[1991,856000000],[1992,872000000],[1993,891000000],[1994,908000000],[1995,927000000],[1996,943000000],[1997,959000000],[1998,975000000],[1999,991691000],[2000,1007702000],[2001,1023590000],[2002,1034172547],[2003,1049700118],[2004,1065070607],[2005,1080264388],[2006,1095351995],[2007,1110396331],[2008,1125368288]],"lifeExpectancy":[[1800,25.4],[1881,25.44],[1891,24.27],[1901,23.49],[1905,23.98],[1911,23.15],[1915,24.02],[1921,24.86],[1925,27.61],[1931,29.31],[1935,30.95],[1941,32.59],[1945,35.03],[1950,36.8],[1951,37.08],[1952,37.65],[1953,38.22],[1954,38.8],[1955,39.39],[1956,39.98],[1957,40.59],[1958,41.19],[1959,41.81],[1960,42.44],[1961,43.07],[1962,43.71],[1963,44.35],[1964,45],[1965,45.65],[1966,46.3],[1967,46.94],[1968,47.57],[1969,48.19],[1970,48.82],[1971,49.47],[1972,50.14],[1973,50.83],[1974,51.54],[1975,52.24],[1976,52.92],[1977,53.55],[1978,54.13],[1979,54.65],[1980,55.11],[1981,55.51],[1982,55.88],[1983,56.22],[1984,56.55],[1985,56.86],[1986,57.16],[1987,57.44],[1988,57.7],[1989,57.95],[1990,58.2],[1991,58.45],[1992,58.72],[1993,59],[1994,59.3],[1995,59.62],[1996,59.95],[1997,60.28],[1998,60.61],[1999,60.94],[2000,61.26],[2001,61.56],[2002,61.86],[2003,62.15],[2004,62.45],[2005,62.74],[2006,63.04],[2007,63.35],[2008,63.68],[2009,64.01]]},{"name":"Maldives","region":"South Asia","income":[[1800,472.12],[1820,472.12],[1950,457.04],[1970,699.73],[1971,719.24],[1972,719.32],[1973,713.06],[1974,735.04],[1975,658.84],[1976,645.16],[1977,698.04],[1978,778.18],[1979,836.67],[1980,963.7],[1981,1046.14],[1982,985.5],[1983,1112.25],[1984,1369.88],[1985,1500.14],[1986,1588.81],[1987,1674.2],[1988,1761.8],[1989,1863.84],[1990,2099.77],[1991,2192.57],[1992,2261.8],[1993,2334.22],[1994,2424.26],[1995,2533.7],[1996,2696.2],[1997,2945.77],[1998,3159.42],[1999,3345.16],[2000,3433.5],[2001,3488.21],[2002,3643.83],[2003,3919.91],[2004,4296.72],[2005,4017],[2006,4598.79],[2007,4931.92],[2008,5240.39],[2009,5081.79]],"population":[[1800,42378],[1820,42378],[1911,72000],[1921,70000],[1931,79000],[1946,82000],[1950,79293],[1951,78614],[1952,77940],[1953,77273],[1954,78684],[1955,80121],[1956,81585],[1957,83075],[1958,87582],[1959,89290],[1960,92247],[1961,92793],[1962,92744],[1963,94527],[1964,94244],[1965,97769],[1966,100937],[1967,103810],[1968,107000],[1969,110810],[1970,114572],[1971,118880],[1972,122681],[1973,125665],[1974,128722],[1975,132608],[1976,136604],[1977,140721],[1978,144875],[1979,149280],[1980,153957],[1981,158926],[1982,164210],[1983,169830],[1984,175800],[1985,181749],[1986,188125],[1987,194783],[1988,201721],[1989,208931],[1990,216401],[1991,224107],[1992,232026],[1993,240147],[1994,248459],[1995,256949],[1996,265592],[1997,274366],[1998,283271],[1999,292307],[2000,301475],[2001,310764],[2002,320165],[2003,329684],[2004,339330],[2005,349106],[2006,359008],[2007,369031],[2008,379174]],"lifeExpectancy":[[1950,37.63],[1951,37.94],[1952,38.57],[1953,39.19],[1954,39.82],[1955,40.44],[1956,41.07],[1957,41.7],[1958,42.32],[1959,42.95],[1960,43.58],[1961,44.21],[1962,44.84],[1963,45.47],[1964,46.1],[1965,46.73],[1966,47.36],[1967,47.98],[1968,48.61],[1969,49.24],[1970,49.87],[1971,50.51],[1972,51.15],[1973,51.79],[1974,52.42],[1975,53.06],[1976,53.67],[1977,54.27],[1978,54.84],[1979,55.38],[1980,55.91],[1981,56.43],[1982,56.95],[1983,57.47],[1984,57.99],[1985,58.48],[1986,58.94],[1987,59.33],[1988,59.67],[1989,59.96],[1990,60.23],[1991,60.49],[1992,60.78],[1993,61.13],[1994,61.55],[1995,62.07],[1996,62.71],[1997,63.44],[1998,64.26],[1999,65.13],[2000,66.04],[2001,66.94],[2002,67.81],[2003,68.62],[2004,69.35],[2005,70],[2006,70.56],[2007,71.07],[2008,71.52],[2009,71.94]]},{"name":"Nepal","region":"South Asia","income":[[1800,419.18],[1820,419.18],[1870,419.09],[1913,568.94],[1950,523.98],[1951,533.44],[1952,545.87],[1953,573.1],[1954,579.1],[1955,584.46],[1956,604.31],[1957,597.94],[1958,624.64],[1959,634.84],[1960,640.8],[1961,647.14],[1962,652.4],[1963,657.22],[1964,661.37],[1965,665.64],[1966,699.91],[1967,676.44],[1968,668.49],[1969,685.31],[1970,689.73],[1971,668.18],[1972,674.79],[1973,656.98],[1974,683],[1975,677.24],[1976,690.36],[1977,694.11],[1978,706.97],[1979,705.92],[1980,672.3],[1981,655.45],[1982,718.37],[1983,679.89],[1984,727.02],[1985,752.59],[1986,765.17],[1987,775.63],[1988,815.81],[1989,813.76],[1990,852.69],[1991,884.4],[1992,897.74],[1993,909.05],[1994,959.49],[1995,968.55],[1996,995.5],[1997,1010.89],[1998,1005.27],[1999,1014.02],[2000,1054.79],[2001,1085.11],[2002,1057.21],[2003,1065.44],[2004,1079.3],[2005,1081],[2006,1106.58],[2007,1132.53],[2008,1181.59],[2009,1224.73]],"population":[[1800,3881000],[1820,3881000],[1850,4352000],[1870,4698000],[1890,5192000],[1900,5283000],[1913,5639000],[1950,8989915],[1951,9085715],[1952,9182536],[1953,9280389],[1954,9379284],[1955,9479233],[1956,9580247],[1957,9682338],[1958,9788923],[1959,9906107],[1960,10034723],[1961,10176198],[1962,10332057],[1963,10500330],[1964,10677158],[1965,10862394],[1966,11057476],[1967,11261690],[1968,11473118],[1969,11692022],[1970,11918678],[1971,12154648],[1972,12412593],[1973,12684751],[1974,12972880],[1975,13278095],[1976,13599104],[1977,13933198],[1978,14280079],[1979,14640898],[1980,15016477],[1981,15402612],[1982,15796314],[1983,16199649],[1984,16613359],[1985,17037772],[1986,17472236],[1987,17917180],[1988,18374009],[1989,18843260],[1990,19325207],[1991,19818809],[1992,20326209],[1993,20845700],[1994,21372585],[1995,21907276],[1996,22450069],[1997,23001113],[1998,23560320],[1999,24127391],[2000,24702119],[2001,25284463],[2002,25873917],[2003,26469569],[2004,27070666],[2005,27676547],[2006,28287147],[2007,28901790],[2008,29519114]],"lifeExpectancy":[[1800,32.8],[1945,32.8],[1950,35.6],[1951,35.74],[1952,36.02],[1953,36.31],[1954,36.61],[1955,36.9],[1956,37.21],[1957,37.51],[1958,37.82],[1959,38.14],[1960,38.47],[1961,38.81],[1962,39.16],[1963,39.53],[1964,39.92],[1965,40.32],[1966,40.75],[1967,41.19],[1968,41.66],[1969,42.13],[1970,42.63],[1971,43.14],[1972,43.66],[1973,44.2],[1974,44.74],[1975,45.3],[1976,45.85],[1977,46.41],[1978,46.98],[1979,47.54],[1980,48.11],[1981,48.69],[1982,49.27],[1983,49.85],[1984,50.45],[1985,51.04],[1986,51.63],[1987,52.2],[1988,52.77],[1989,53.34],[1990,53.92],[1991,54.54],[1992,55.2],[1993,55.91],[1994,56.67],[1995,57.47],[1996,58.32],[1997,59.18],[1998,60.03],[1999,60.87],[2000,61.69],[2001,62.47],[2002,63.23],[2003,63.95],[2004,64.63],[2005,65.25],[2006,65.81],[2007,66.31],[2008,66.74],[2009,67.12]]},{"name":"Pakistan","region":"South Asia","income":[[1800,666],[1820,662],[1821,662],[1822,662],[1823,662],[1824,662],[1825,662],[1826,662],[1827,662],[1828,662],[1829,662],[1830,662],[1831,662],[1832,662],[1833,662],[1834,662],[1835,662],[1836,662],[1837,662],[1838,662],[1839,662],[1840,662],[1841,662],[1842,662],[1843,662],[1844,662],[1845,662],[1846,662],[1847,662],[1848,662],[1849,662],[1850,662],[1851,662],[1852,662],[1853,662],[1854,662],[1855,662],[1856,662],[1857,662],[1858,662],[1859,662],[1860,662],[1861,662],[1862,662],[1863,662],[1864,662],[1865,662],[1866,662],[1867,662],[1868,662],[1869,662],[1870,662],[1871,664],[1872,665],[1873,667],[1874,668],[1875,670],[1876,671],[1877,673],[1878,675],[1879,676],[1880,678],[1881,679],[1882,681],[1883,682],[1884,684],[1885,704],[1886,681],[1887,710],[1888,715],[1889,695],[1890,726],[1891,658],[1892,709],[1893,726],[1894,736],[1895,717],[1896,663],[1897,782],[1898,783],[1899,720],[1900,744],[1901,755],[1902,813],[1903,820],[1904,819],[1905,799],[1906,817],[1907,763],[1908,769],[1909,869],[1910,865],[1911,858],[1912,856],[1913,835],[1914,880],[1915,858],[1916,882],[1917,865],[1918,754],[1919,857],[1920,789],[1921,844],[1922,871],[1923,834],[1924,866],[1925,867],[1926,886],[1927,877],[1928,877],[1929,904],[1930,901],[1931,883],[1932,881],[1933,869],[1934,865],[1935,845],[1936,866],[1937,840],[1938,830],[1939,837],[1940,853],[1941,858],[1942,844],[1943,867],[1944,848],[1945,825],[1946,772],[1947,767],[1948,766],[1949,776],[1950,739],[1951,698],[1952,685],[1953,733],[1954,732],[1955,730],[1956,734],[1957,747],[1958,739],[1959,728],[1960,744],[1961,769],[1962,803],[1963,831],[1964,871],[1965,886],[1966,933],[1967,942],[1968,982],[1969,1018],[1970,1094],[1971,1070],[1972,1050],[1973,1096],[1974,1106],[1975,1124],[1976,1156],[1977,1176],[1978,1241],[1979,1250],[1980,1334],[1981,1388],[1982,1443],[1983,1497],[1984,1519],[1985,1609],[1986,1661],[1987,1705],[1988,1761],[1989,1794],[1990,1826],[1991,1875],[1992,1972],[1993,1967],[1994,1991],[1995,2038],[1996,2081],[1997,2049],[1998,2050],[1999,2073],[2000,2086],[2001,2069],[2002,2093],[2003,2153],[2004,2270],[2005,2396],[2006,2497],[2007,2591],[2008,2598],[2009,2603]],"population":[[1820,13651000],[1870,16090000],[1913,20008000],[1929,22812000],[1941,28169000],[1946,32683000],[1950,39448232],[1951,40382206],[1952,41346560],[1953,42342412],[1954,43372063],[1955,44434445],[1956,45535711],[1957,46679944],[1958,47868932],[1959,49104112],[1960,50386898],[1961,51718581],[1962,53100671],[1963,54524471],[1964,55988385],[1965,57494940],[1966,59046203],[1967,60641899],[1968,62282496],[1969,63969987],[1970,65705964],[1971,67491369],[1972,69325921],[1973,71121085],[1974,72911780],[1975,74711541],[1976,76456121],[1977,78152686],[1978,80051300],[1979,82374302],[1980,85219117],[1981,88417079],[1982,91462088],[1983,94147312],[1984,96489872],[1985,99060352],[1986,102046668],[1987,105186881],[1988,108384014],[1989,111502409],[1990,114578478],[1991,117653767],[1992,120065004],[1993,122487513],[1994,125491984],[1995,128690285],[1996,132146638],[1997,135564834],[1998,139007774],[1999,142461389],[2000,146342958],[2001,150334765],[2002,153403524],[2003,156127453],[2004,159196336],[2005,162419946],[2006,165803560],[2007,169270617],[2008,172730891]],"lifeExpectancy":[[1800,25.9],[1916,25.9],[1921,20.13],[1931,26.75],[1941,31.76],[1945,22.8],[1950,45.63],[1951,45.81],[1952,46.18],[1953,46.55],[1954,46.93],[1955,47.31],[1956,47.7],[1957,48.1],[1958,48.51],[1959,48.94],[1960,49.38],[1961,49.85],[1962,50.34],[1963,50.85],[1964,51.38],[1965,51.91],[1966,52.44],[1967,52.94],[1968,53.41],[1969,53.84],[1970,54.24],[1971,54.63],[1972,55],[1973,55.38],[1974,55.76],[1975,56.13],[1976,56.49],[1977,56.83],[1978,57.15],[1979,57.44],[1980,57.71],[1981,57.97],[1982,58.24],[1983,58.51],[1984,58.8],[1985,59.1],[1986,59.4],[1987,59.7],[1988,59.99],[1989,60.28],[1990,60.56],[1991,60.85],[1992,61.14],[1993,61.46],[1994,61.79],[1995,62.13],[1996,62.49],[1997,62.85],[1998,63.21],[1999,63.56],[2000,63.91],[2001,64.25],[2002,64.58],[2003,64.91],[2004,65.23],[2005,65.55],[2006,65.88],[2007,66.2],[2008,66.52],[2009,66.84]]},{"name":"Sri Lanka","region":"South Asia","income":[[1800,453.6],[1820,453.6],[1850,465.1],[1870,702.32],[1871,682.16],[1872,647.27],[1873,650.3],[1874,639.05],[1875,643.92],[1876,650.63],[1877,654.17],[1878,591.99],[1879,634.77],[1880,685.1],[1881,731.41],[1882,771.49],[1883,776.58],[1884,746.19],[1885,694.79],[1886,668.39],[1887,779.57],[1888,759.89],[1889,743.68],[1890,862.16],[1891,855.2],[1892,867.93],[1893,868.21],[1894,860.58],[1895,894.97],[1896,897.5],[1897,928.02],[1898,963.32],[1899,1017.61],[1900,1064.45],[1901,983.09],[1902,969.58],[1903,1010.89],[1904,1002.44],[1905,972.46],[1906,982],[1907,1017.33],[1908,1007.41],[1909,951.02],[1910,996.49],[1911,957.04],[1912,954.05],[1913,1018.14],[1914,997.97],[1915,937.41],[1916,967.28],[1917,1004.45],[1918,913.55],[1919,962.2],[1920,900.8],[1921,873.58],[1922,896.22],[1923,879.03],[1924,930.21],[1925,979.1],[1926,1044.63],[1927,1040.61],[1928,1036.82],[1929,1101.67],[1930,1043.6],[1931,992.24],[1932,941.2],[1933,948.68],[1934,1039.14],[1935,976.68],[1936,968.98],[1937,1028.34],[1938,1010.76],[1939,978.52],[1940,1031.87],[1941,1053.03],[1942,1091.12],[1943,1059.3],[1944,952.32],[1945,920.42],[1946,866.43],[1947,885.51],[1948,956.2],[1949,989.11],[1950,1033.5],[1951,1066.73],[1952,1083.53],[1953,1072.41],[1954,1070.87],[1955,1104.57],[1956,1084.42],[1957,1072.55],[1958,1076.23],[1959,1063.15],[1960,1072.21],[1961,1064.79],[1962,1074.47],[1963,1069.52],[1964,1094.23],[1965,1102.42],[1966,1064.71],[1967,1135.51],[1968,1192.5],[1969,1213.16],[1970,1244.91],[1971,1210.75],[1972,1213.4],[1973,1240.69],[1974,1261.62],[1975,1270.97],[1976,1287.13],[1977,1348.78],[1978,1407.65],[1979,1471.17],[1980,1525.22],[1981,1595.28],[1982,1648.08],[1983,1709.46],[1984,1771.43],[1985,1821.76],[1986,1885.81],[1987,1876.77],[1988,1898.77],[1989,1922.06],[1990,2019.4],[1991,2088.24],[1992,2153.74],[1993,2271.55],[1994,2365.6],[1995,2464.51],[1996,2529.76],[1997,2664.48],[1998,2762.24],[1999,2853.81],[2000,2997.69],[2001,2925.52],[2002,3015.38],[2003,3166.6],[2004,3310.2],[2005,3481],[2006,3718.72],[2007,3940.58],[2008,4142.53],[2009,4254.13]],"population":[[1800,1213000],[1820,1213000],[1850,2217000],[1870,2786000],[1871,2820000],[1872,2842000],[1873,2863000],[1874,2885000],[1875,2908000],[1876,2930000],[1877,2952000],[1878,2975000],[1879,2998000],[1880,3021000],[1881,3044000],[1882,3073000],[1883,3107000],[1884,3144000],[1885,3170000],[1886,3194000],[1887,3221000],[1888,3261000],[1889,3311000],[1890,3343000],[1891,3404000],[1892,3470000],[1893,3524000],[1894,3584000],[1895,3626000],[1896,3693000],[1897,3752000],[1898,3820000],[1899,3874000],[1900,3912000],[1901,4031000],[1902,4071000],[1903,4156000],[1904,4233000],[1905,4383000],[1906,4458000],[1907,4467000],[1908,4520000],[1909,4585000],[1910,4668000],[1911,4757000],[1912,4784000],[1913,4811000],[1914,4838000],[1915,4905000],[1916,4971000],[1917,5040000],[1918,5109000],[1919,5179000],[1920,5250000],[1921,5304000],[1922,5367000],[1923,5426000],[1924,5452000],[1925,5505000],[1926,5545000],[1927,5591000],[1928,5730000],[1929,5669000],[1930,5707000],[1931,5748000],[1932,5788000],[1933,5825000],[1934,5872000],[1935,5897000],[1936,5943000],[1937,5989000],[1938,6045000],[1939,6095000],[1940,6134000],[1941,6169000],[1942,6191000],[1943,6296000],[1944,6442000],[1945,6650000],[1946,6854000],[1947,7037000],[1948,7244000],[1949,7455000],[1950,7533097],[1951,7752374],[1952,7982342],[1953,8221291],[1954,8457223],[1955,8678721],[1956,8898480],[1957,9128546],[1958,9361755],[1959,9609556],[1960,9879178],[1961,10151799],[1962,10421936],[1963,10686957],[1964,10942373],[1965,11202264],[1966,11469679],[1967,11737396],[1968,12010095],[1969,12275330],[1970,12531522],[1971,12776057],[1972,13016733],[1973,13245615],[1974,13449623],[1975,13660275],[1976,13887354],[1977,14116836],[1978,14370898],[1979,14648618],[1980,14900181],[1981,15151762],[1982,15410151],[1983,15618275],[1984,15810021],[1985,16020699],[1986,16256077],[1987,16495304],[1988,16734716],[1989,16970982],[1990,17192896],[1991,17390974],[1992,17587060],[1993,17825536],[1994,18075443],[1995,18304268],[1996,18509760],[1997,18698655],[1998,18884614],[1999,19064642],[2000,19238575],[2001,19408635],[2002,19576783],[2003,19742439],[2004,19905165],[2005,20064776],[2006,20222240],[2007,20378239],[2008,20532150]],"lifeExpectancy":[[1800,32.6],[1901,32.6],[1911,29.9],[1921,32],[1935,46.3],[1940,45.2],[1946,45.8],[1948,54],[1949,55.5],[1950,51.36],[1951,51.86],[1952,52.81],[1953,53.67],[1954,54.45],[1955,55.14],[1956,55.74],[1957,56.27],[1958,56.73],[1959,57.14],[1960,57.51],[1961,57.87],[1962,58.24],[1963,58.64],[1964,59.09],[1965,59.58],[1966,60.14],[1967,60.72],[1968,61.33],[1969,61.95],[1970,62.57],[1971,63.16],[1972,63.73],[1973,64.26],[1974,64.76],[1975,65.25],[1976,65.73],[1977,66.24],[1978,66.76],[1979,67.3],[1980,67.8],[1981,68.23],[1982,68.55],[1983,68.76],[1984,68.85],[1985,68.87],[1986,68.88],[1987,68.92],[1988,69.03],[1989,69.21],[1990,69.42],[1991,69.6],[1992,69.69],[1993,69.67],[1994,69.56],[1995,69.43],[1996,69.38],[1997,69.48],[1998,69.79],[1999,70.29],[2000,70.95],[2001,71.67],[2002,72.35],[2003,72.93],[2004,73.37],[2005,73.66],[2006,73.85],[2007,73.97],[2008,74.1],[2009,74.24]]},{"name":"Algeria","region":"Middle East & North Africa","income":[[1800,766.25],[1820,765.88],[1870,1272.76],[1913,2070.76],[1950,2429.21],[1951,2397.53],[1952,2449.01],[1953,2436.34],[1954,2557.82],[1955,2572.47],[1956,2764.42],[1957,3013.98],[1958,3059.58],[1959,3548.42],[1960,3716.79],[1961,3202.96],[1962,2550.82],[1963,3146.58],[1964,3214.44],[1965,3327.99],[1966,3070.75],[1967,3246.99],[1968,3519.79],[1969,3747.74],[1970,4003.57],[1971,3559.35],[1972,4182.66],[1973,4194.6],[1974,4320.96],[1975,4489.03],[1976,4642.62],[1977,4910.42],[1978,5373.17],[1979,5682.03],[1980,5610.2],[1981,5573.38],[1982,5745.16],[1983,5853.66],[1984,5986.54],[1985,6107.18],[1986,5876.05],[1987,5681.36],[1988,5415.99],[1989,5457.75],[1990,5244.51],[1991,5061.3],[1992,5023.22],[1993,4800.32],[1994,4652.84],[1995,4732.43],[1996,4824.21],[1997,4797.3],[1998,4965.23],[1999,5048.62],[2000,5098.85],[2001,5156.45],[2002,5288.04],[2003,5576.85],[2004,5790.97],[2005,6011],[2006,5969.05],[2007,6040.89],[2008,6175.1],[2009,6207.17]],"population":[[1820,2689000],[1870,3776000],[1913,5497000],[1950,8892718],[1951,9073304],[1952,9279525],[1953,9531710],[1954,9611093],[1955,9841851],[1956,10057133],[1957,10270856],[1958,10484925],[1959,10696396],[1960,10909294],[1961,11121645],[1962,11000948],[1963,11272878],[1964,11612858],[1965,11963091],[1966,12339140],[1967,12760499],[1968,13146267],[1969,13528304],[1970,13931846],[1971,14335388],[1972,14760787],[1973,15197724],[1974,15653200],[1975,16140252],[1976,16634618],[1977,17152804],[1978,17685768],[1979,18229932],[1980,18806061],[1981,19407036],[1982,20033753],[1983,20680982],[1984,21340546],[1985,22008450],[1986,22642538],[1987,23254956],[1988,23883858],[1989,24500650],[1990,25093154],[1991,25689444],[1992,26298373],[1993,26914091],[1994,27517041],[1995,28082573],[1996,28595073],[1997,29072015],[1998,29521270],[1999,29962690],[2000,30409300],[2001,30851518],[2002,31287142],[2003,31713719],[2004,32129324],[2005,32531853],[2006,32930091],[2007,33333216],[2008,33739635]],"lifeExpectancy":[[1800,28.8],[1923,28.82],[1933,31.22],[1941,33.72],[1943,33.72],[1945,33.72],[1950,42.02],[1951,42.29],[1952,42.82],[1953,43.34],[1954,43.87],[1955,44.38],[1956,44.9],[1957,45.41],[1958,45.92],[1959,46.43],[1960,46.96],[1961,47.49],[1962,48.04],[1963,48.62],[1964,49.21],[1965,49.82],[1966,50.44],[1967,51.06],[1968,51.68],[1969,52.31],[1970,52.93],[1971,53.57],[1972,54.21],[1973,54.88],[1974,55.56],[1975,56.24],[1976,56.93],[1977,57.61],[1978,58.28],[1979,58.95],[1980,59.63],[1981,60.35],[1982,61.13],[1983,61.96],[1984,62.82],[1985,63.69],[1986,64.53],[1987,65.3],[1988,65.97],[1989,66.54],[1990,67],[1991,67.36],[1992,67.67],[1993,67.94],[1994,68.2],[1995,68.47],[1996,68.75],[1997,69.06],[1998,69.38],[1999,69.73],[2000,70.08],[2001,70.44],[2002,70.79],[2003,71.12],[2004,71.42],[2005,71.7],[2006,71.96],[2007,72.2],[2008,72.44],[2009,72.67]]},{"name":"Bahrain","region":"Middle East & North Africa","income":[[1800,808.99],[1820,812.82],[1913,1394.65],[1934,1575.47],[1950,9158.27],[1951,9508.37],[1952,9867.08],[1953,10230.37],[1954,10599.69],[1955,10957.17],[1956,11308.31],[1957,11635.8],[1958,11921.78],[1959,12169.79],[1960,12373.91],[1961,12543.97],[1962,12753.28],[1963,13030.13],[1964,13372.47],[1965,13810.42],[1966,14286.48],[1967,14804.67],[1968,15319.7],[1969,15864.95],[1970,16484.34],[1971,17331.76],[1972,18268.66],[1973,19043.08],[1974,19904.55],[1975,17069.07],[1976,18770.21],[1977,19340.1],[1978,19212.87],[1979,18373.37],[1980,19096.98],[1981,18770.08],[1982,19211.15],[1983,19765.09],[1984,19830.06],[1985,19035.18],[1986,18782.87],[1987,18524.02],[1988,18571.21],[1989,18431.74],[1990,17860.39],[1991,18146.86],[1992,19035.58],[1993,20065.77],[1994,19499.26],[1995,19759.06],[1996,20101.55],[1997,20292.02],[1998,20834.14],[1999,21317.72],[2000,22015.32],[2001,22630.44],[2002,23403.56],[2003,24686.46],[2004,25659.68],[2005,27236],[2006,28478.46],[2007,30173.04],[2008,31391.38],[2009,24226.51]],"population":[[1800,64474],[1820,64474],[1870,64474],[1913,81882],[1950,114840],[1951,117580],[1952,120447],[1953,123469],[1954,126708],[1955,130253],[1956,134207],[1957,138655],[1958,143798],[1959,149769],[1960,156648],[1961,164334],[1962,171863],[1963,179108],[1964,185691],[1965,191378],[1966,196706],[1967,202182],[1968,207811],[1969,213596],[1970,219543],[1971,225375],[1972,230800],[1973,238977],[1974,248343],[1975,258789],[1976,273661],[1977,297410],[1978,322535],[1979,336070],[1980,347568],[1981,363427],[1982,377967],[1983,393022],[1984,408282],[1985,423950],[1986,439556],[1987,454612],[1988,469484],[1989,484791],[1990,500476],[1991,515234],[1992,529491],[1993,543998],[1994,558397],[1995,572639],[1996,586047],[1997,598561],[1998,610767],[1999,622634],[2000,634137],[2001,645361],[2002,656397],[2003,667238],[2004,677886],[2005,688345],[2006,698585],[2007,708573],[2008,718306]],"lifeExpectancy":[[1800,30.3],[1935,30.3],[1950,49.84],[1951,50.11],[1952,50.65],[1953,51.2],[1954,51.77],[1955,52.35],[1956,52.93],[1957,53.53],[1958,54.14],[1959,54.75],[1960,55.36],[1961,55.97],[1962,56.58],[1963,57.19],[1964,57.79],[1965,58.4],[1966,59.02],[1967,59.66],[1968,60.32],[1969,60.99],[1970,61.66],[1971,62.3],[1972,62.89],[1973,63.44],[1974,63.95],[1975,64.43],[1976,64.93],[1977,65.47],[1978,66.06],[1979,66.69],[1980,67.35],[1981,68],[1982,68.61],[1983,69.14],[1984,69.6],[1985,70],[1986,70.34],[1987,70.68],[1988,71.02],[1989,71.37],[1990,71.73],[1991,72.1],[1992,72.46],[1993,72.79],[1994,73.09],[1995,73.36],[1996,73.61],[1997,73.82],[1998,74.02],[1999,74.21],[2000,74.38],[2001,74.56],[2002,74.72],[2003,74.89],[2004,75.06],[2005,75.23],[2006,75.4],[2007,75.57],[2008,75.73],[2009,75.88]]},{"name":"Djibouti","region":"Middle East & North Africa","income":[[1800,380.73],[1820,380.73],[1913,588.26],[1950,2576.1],[1951,2655.01],[1952,2669.53],[1953,2705.48],[1954,2786.75],[1955,2803.23],[1956,2836.84],[1957,2864.97],[1958,2859.64],[1959,2939.93],[1960,3043.2],[1961,3063.21],[1962,3020.99],[1963,3047.41],[1964,3019.73],[1965,3013.92],[1966,3025.89],[1967,3020.05],[1968,2999.58],[1969,2992.7],[1970,3554.43],[1971,3679.34],[1972,3694.21],[1973,3753.6],[1974,3573.21],[1975,3548.19],[1976,3700.95],[1977,3081.76],[1978,2961.74],[1979,2898.73],[1980,2853.84],[1981,2875.04],[1982,2879.47],[1983,2821.91],[1984,3094.98],[1985,3020.75],[1986,2949.02],[1987,2880.1],[1988,2742.92],[1989,2580.68],[1990,2487.04],[1991,2438.6],[1992,2377.16],[1993,2231.57],[1994,2159.36],[1995,2052.06],[1996,1927.09],[1997,1895.02],[1998,1875.74],[1999,1901.12],[2000,1894.04],[2001,1899.26],[2002,1908.26],[2003,1931.6],[2004,1942.69],[2005,1964],[2006,2008.4],[2007,2058.87],[2008,2125.61],[2009,2176.79]],"population":[[1800,22848],[1820,22848],[1950,60036],[1951,61572],[1952,63149],[1953,64768],[1954,66431],[1955,68137],[1956,69892],[1957,71851],[1958,73986],[1959,76174],[1960,78417],[1961,83913],[1962,89898],[1963,96376],[1964,103354],[1965,110840],[1966,118886],[1967,127617],[1968,137047],[1969,147181],[1970,158034],[1971,168600],[1972,178848],[1973,188750],[1974,198279],[1975,207959],[1976,217219],[1977,228694],[1978,247883],[1979,263409],[1980,279149],[1981,293659],[1982,305991],[1983,316123],[1984,289431],[1985,296544],[1986,303756],[1987,311025],[1988,326580],[1989,349928],[1990,366088],[1991,375227],[1992,384156],[1993,393258],[1994,402548],[1995,409366],[1996,413627],[1997,417908],[1998,422202],[1999,426507],[2000,430822],[2001,437778],[2002,447416],[2003,457130],[2004,466900],[2005,476703],[2006,486530],[2007,496374],[2008,506221]],"lifeExpectancy":[[1800,29.9],[1945,29.9],[1950,33.76],[1951,34.03],[1952,34.56],[1953,35.08],[1954,35.59],[1955,36.1],[1956,36.59],[1957,37.08],[1958,37.57],[1959,38.05],[1960,38.52],[1961,38.99],[1962,39.47],[1963,39.94],[1964,40.42],[1965,40.89],[1966,41.37],[1967,41.84],[1968,42.31],[1969,42.78],[1970,43.24],[1971,43.69],[1972,44.15],[1973,44.59],[1974,45.03],[1975,45.47],[1976,45.9],[1977,46.33],[1978,46.75],[1979,47.17],[1980,47.58],[1981,47.98],[1982,48.35],[1983,48.7],[1984,49.04],[1985,49.35],[1986,49.65],[1987,49.94],[1988,50.23],[1989,50.52],[1990,50.82],[1991,51.14],[1992,51.47],[1993,51.81],[1994,52.16],[1995,52.5],[1996,52.8],[1997,53.06],[1998,53.27],[1999,53.44],[2000,53.57],[2001,53.7],[2002,53.83],[2003,54],[2004,54.2],[2005,54.46],[2006,54.75],[2007,55.08],[2008,55.42],[2009,55.78]]},{"name":"Iraq","region":"Middle East & North Africa","income":[[1800,700],[1820,700],[1821,706.73],[1822,713.53],[1823,720.39],[1824,727.32],[1825,734.31],[1826,741.37],[1827,748.5],[1828,755.7],[1829,762.97],[1830,770.3],[1831,777.71],[1832,785.19],[1833,792.74],[1834,800.36],[1835,808.06],[1836,815.83],[1837,823.68],[1838,831.6],[1839,839.6],[1840,847.67],[1841,855.82],[1842,864.05],[1843,872.36],[1844,880.75],[1845,889.22],[1846,897.77],[1847,906.4],[1848,915.12],[1849,923.92],[1850,932.8],[1851,941.77],[1852,950.83],[1853,959.98],[1854,969.21],[1855,978.53],[1856,987.94],[1857,997.44],[1858,1007.03],[1859,1016.71],[1860,1026.49],[1861,1036.36],[1862,1046.33],[1863,1056.39],[1864,1066.55],[1865,1076.8],[1866,1087.16],[1867,1097.61],[1868,1108.17],[1869,1118.83],[1870,1129.59],[1871,1144.63],[1872,1159.87],[1873,1175.32],[1874,1190.97],[1875,1206.84],[1876,1222.91],[1877,1239.2],[1878,1255.7],[1879,1272.42],[1880,1289.37],[1881,1306.54],[1882,1323.94],[1883,1341.58],[1884,1359.44],[1885,1377.55],[1886,1395.9],[1887,1414.49],[1888,1433.33],[1889,1452.42],[1890,1471.76],[1891,1491.36],[1892,1511.22],[1893,1531.35],[1894,1551.74],[1895,1572.41],[1896,1593.35],[1897,1614.57],[1898,1636.08],[1899,1657.87],[1900,1679.95],[1901,1702.32],[1902,1724.99],[1903,1747.97],[1904,1771.25],[1905,1794.84],[1906,1818.74],[1907,1842.96],[1908,1867.51],[1909,1892.38],[1910,1917.58],[1911,1943.12],[1912,1969],[1913,1995.22],[1914,2023.23],[1915,2051.63],[1916,2080.43],[1917,2109.64],[1918,2139.25],[1919,2169.28],[1920,2199.73],[1921,2230.61],[1922,2261.93],[1923,2293.68],[1924,2325.88],[1925,2358.52],[1926,2391.63],[1927,2425.21],[1928,2459.25],[1929,2493.77],[1930,2528.78],[1931,2564.28],[1932,2600.27],[1933,2636.77],[1934,2673.79],[1935,2711.32],[1936,2749.38],[1937,2787.98],[1938,2827.11],[1939,2866.8],[1940,2907.04],[1941,2947.85],[1942,2989.23],[1943,3031.19],[1944,3073.74],[1945,3116.89],[1946,3160.64],[1947,3205.01],[1948,3250],[1949,3295.62],[1950,3341.89],[1951,3562.05],[1952,3857.31],[1953,5305.47],[1954,6172.51],[1955,5791.49],[1956,6054.16],[1957,5859.83],[1958,6388.15],[1959,6500.84],[1960,7086.01],[1961,7714.63],[1962,7902.87],[1963,7565.25],[1964,8253.13],[1965,8758.22],[1966,8969.67],[1967,8521.87],[1968,9761.33],[1969,9816.71],[1970,9511.46],[1971,9823.3],[1972,9202.01],[1973,10452.87],[1974,10711.67],[1975,12152.33],[1976,14224.37],[1977,14215.14],[1978,16303],[1979,19452.15],[1980,18465.74],[1981,14677.56],[1982,14150.44],[1983,12567.34],[1984,12243.9],[1985,11706.94],[1986,11252.93],[1987,11429.75],[1988,8801.59],[1989,7824.67],[1990,7525.13],[1991,2913.94],[1992,3703.06],[1993,3613.88],[1994,3350.26],[1995,2973.04],[1996,3264.74],[1997,3062.95],[1998,3438.69],[1999,3643.97],[2000,3951.74],[2001,4209.66],[2002,4402.9],[2003,3366.63],[2004,3293.16],[2005,3200],[2006,3299.56],[2007,3254.5],[2008,3467.12],[2009,3518.18]],"population":[[1820,1093000],[1870,1580000],[1913,2613000],[1950,5163443],[1951,5299983],[1952,5441766],[1953,5589018],[1954,5742552],[1955,5903253],[1956,6073493],[1957,6248643],[1958,6433104],[1959,6624713],[1960,6822030],[1961,7026278],[1962,7240260],[1963,7468223],[1964,7711071],[1965,7970746],[1966,8240451],[1967,8519282],[1968,8807547],[1969,9105567],[1970,9413671],[1971,9732199],[1972,10061506],[1973,10401956],[1974,10753925],[1975,11117804],[1976,11493995],[1977,11882916],[1978,12317137],[1979,12768376],[1980,13232839],[1981,13703103],[1982,14173318],[1983,14652218],[1984,15160546],[1985,15693620],[1986,16247340],[1987,16543189],[1988,17038084],[1989,17568414],[1990,18134702],[1991,17471586],[1992,17861905],[1993,18404698],[1994,18969505],[1995,19557247],[1996,20161940],[1997,20775703],[1998,21397764],[1999,22031349],[2000,22675617],[2001,23331985],[2002,24001816],[2003,24683313],[2004,25374691],[2005,26074906],[2006,26783383],[2007,27499638],[2008,28221181]],"lifeExpectancy":[[1800,31.2],[1940,31.2],[1950,40.04],[1951,40.62],[1952,41.77],[1953,42.89],[1954,44],[1955,45.08],[1956,46.13],[1957,47.17],[1958,48.18],[1959,49.17],[1960,50.13],[1961,51.07],[1962,51.99],[1963,52.87],[1964,53.73],[1965,54.54],[1966,55.32],[1967,56.06],[1968,56.75],[1969,57.39],[1970,57.98],[1971,58.5],[1972,58.95],[1973,59.35],[1974,59.68],[1975,59.97],[1976,60.21],[1977,60.42],[1978,60.61],[1979,60.81],[1980,61],[1981,61.21],[1982,61.42],[1983,61.66],[1984,61.92],[1985,62.21],[1986,62.54],[1987,62.91],[1988,63.33],[1989,63.79],[1990,64.36],[1991,65.06],[1992,65.9],[1993,66.85],[1994,67.88],[1995,68.89],[1996,69.8],[1997,70.54],[1998,71.04],[1999,71.28],[2000,71.24],[2001,70.92],[2002,70.4],[2003,69.77],[2004,69.1],[2005,68.5],[2006,68.06],[2007,67.84],[2008,67.86],[2009,68.1]]},{"name":"Israel","region":"Middle East & North Africa","income":[[1800,882.54],[1820,886.71],[1913,1521.43],[1950,3800.93],[1951,4261.85],[1952,4086.52],[1953,3926.39],[1954,4552.49],[1955,4993.23],[1956,5208.06],[1957,5385.28],[1958,5543.32],[1959,6073.06],[1960,6291.25],[1961,6740.54],[1962,7105.63],[1963,7546.03],[1964,7981.81],[1965,8462.28],[1966,8351.32],[1967,8393.74],[1968,9488.73],[1969,10418.87],[1970,10928.84],[1971,11752.59],[1972,12786.93],[1973,13012.38],[1974,13525.4],[1975,13690.86],[1976,13587.56],[1977,13306.62],[1978,13659.85],[1979,14185.86],[1980,14819.26],[1981,15322.59],[1982,15367.03],[1983,15630.64],[1984,15462.57],[1985,15722.47],[1986,16227.05],[1987,17122.48],[1988,17187.12],[1989,17048.77],[1990,17495.15],[1991,17543.46],[1992,18051.52],[1993,18202.42],[1994,19299.93],[1995,20145.03],[1996,20644.52],[1997,20896.61],[1998,21113.01],[1999,21332.8],[2000,22834.93],[2001,22377.18],[2002,21905.6],[2003,22090.73],[2004,22930.28],[2005,23846],[2006,24667.09],[2007,25392],[2008,25839.31],[2009,25463.69]],"population":[[1800,209954],[1850,209954],[1860,227862],[1877,272230],[1878,275487],[1879,278796],[1880,282159],[1881,285577],[1882,289050],[1883,292581],[1884,296171],[1885,299820],[1886,303529],[1887,307301],[1888,311138],[1889,314897],[1890,318717],[1891,322595],[1892,326535],[1893,330540],[1894,334700],[1895,338923],[1896,343302],[1897,347747],[1898,352496],[1899,357320],[1900,362220],[1901,367198],[1902,372255],[1903,377392],[1904,382612],[1905,387914],[1906,393303],[1907,398779],[1908,404344],[1909,409998],[1910,415745],[1911,427524],[1912,433559],[1913,439694],[1914,445931],[1918,417858],[1922,455836],[1931,588805],[1932,611936],[1933,649925],[1934,689309],[1935,744301],[1936,775728],[1937,797281],[1938,816723],[1939,860556],[1940,889866],[1941,915868],[1942,940120],[1943,971687],[1944,1005926],[1945,1043684],[1946,1084877],[1950,1286131],[1951,1489998],[1952,1620914],[1953,1667098],[1954,1711647],[1955,1772032],[1956,1850059],[1957,1944401],[1958,2024772],[1959,2081592],[1960,2141495],[1961,2217050],[1962,2310904],[1963,2406662],[1964,2498199],[1965,2578184],[1966,2641123],[1967,2693585],[1968,2746986],[1969,2817051],[1970,2903434],[1971,2996919],[1972,3095893],[1973,3197411],[1974,3285761],[1975,3354242],[1976,3423635],[1977,3495918],[1978,3569780],[1979,3653480],[1980,3737473],[1981,3801338],[1982,3858421],[1983,3926893],[1984,4005301],[1985,4074965],[1986,4137141],[1987,4203148],[1988,4271530],[1989,4344042],[1990,4512068],[1991,4756279],[1992,4936550],[1993,5062136],[1994,5184895],[1995,5305120],[1996,5420065],[1997,5531387],[1998,5638981],[1999,5742719],[2000,5842454],[2001,5938093],[2002,6029529],[2003,6116533],[2004,6199008],[2005,6276883],[2006,6352117],[2007,6426679],[2008,6500389]],"lifeExpectancy":[[1950,64.17],[1951,64.5],[1952,65.13],[1953,65.72],[1954,66.26],[1955,66.76],[1956,67.22],[1957,67.64],[1958,68.03],[1959,68.38],[1960,68.7],[1961,69.01],[1962,69.3],[1963,69.58],[1964,69.86],[1965,70.12],[1966,70.37],[1967,70.6],[1968,70.81],[1969,71],[1970,71.19],[1971,71.37],[1972,71.57],[1973,71.79],[1974,72.04],[1975,72.31],[1976,72.6],[1977,72.9],[1978,73.19],[1979,73.49],[1980,73.77],[1981,74.05],[1982,74.31],[1983,74.82],[1984,75.11],[1985,75.44],[1986,75.27],[1987,75.65],[1988,76.01],[1989,76.61],[1990,77.08],[1991,76.93],[1992,76.8],[1993,77.39],[1994,77.64],[1995,77.62],[1996,78.23],[1997,78.12],[1998,78.29],[1999,78.57],[2000,78.75],[2001,79.16],[2002,79.15],[2003,79.5],[2004,79.96],[2005,80.02],[2006,80.37],[2007,80.46],[2008,80.84],[2009,81]]},{"name":"Jordan","region":"Middle East & North Africa","income":[[1800,528.69],[1820,528.69],[1870,643.58],[1913,896.29],[1950,1490.67],[1951,1519.55],[1952,1546.91],[1953,1574.41],[1954,1601.52],[1955,1456.61],[1956,1917.53],[1957,1886.08],[1958,1989.85],[1959,2050.05],[1960,2088.37],[1961,2406.72],[1962,2348.01],[1963,2374.59],[1964,2671.52],[1965,2853.28],[1966,2812.02],[1967,2741.8],[1968,2396.39],[1969,2485.4],[1970,2147.05],[1971,2120.34],[1972,2110.86],[1973,2140.76],[1974,2246.18],[1975,2315.09],[1976,2775.3],[1977,2852.35],[1978,3332.55],[1979,3512.68],[1980,4015.32],[1981,4035.5],[1982,4161.42],[1983,4083.58],[1984,4272.23],[1985,4261.3],[1986,4483.23],[1987,4448.68],[1988,4257.36],[1989,3677.47],[1990,3399.1],[1991,3124.26],[1992,3431.59],[1993,3524.17],[1994,3610.78],[1995,3732.14],[1996,3668.74],[1997,3645.38],[1998,3624.61],[1999,3626.38],[2000,3664.56],[2001,3742.83],[2002,3844.92],[2003,3894.25],[2004,4115.51],[2005,4294],[2006,4531.28],[2007,4829.01],[2008,5086.65],[2009,5109.39]],"population":[[1800,217000],[1820,217000],[1870,266000],[1913,348000],[1950,561254],[1951,584172],[1952,607914],[1953,632897],[1954,659275],[1955,686955],[1956,715991],[1957,746559],[1958,778683],[1959,812544],[1960,848515],[1961,886800],[1962,933559],[1963,974549],[1964,1017180],[1965,1061463],[1966,1107384],[1967,1255058],[1968,1382539],[1969,1453541],[1970,1502959],[1971,1556226],[1972,1613551],[1973,1674258],[1974,1737593],[1975,1802960],[1976,1869657],[1977,1937652],[1978,2006908],[1979,2077386],[1980,2162807],[1981,2253579],[1982,2347031],[1983,2439504],[1984,2532511],[1985,2627750],[1986,2724221],[1987,2820042],[1988,2916505],[1989,3018990],[1990,3262054],[1991,3630633],[1992,3867409],[1993,3984238],[1994,4082087],[1995,4201514],[1996,4363534],[1997,4526235],[1998,4685946],[1999,4842831],[2000,4998564],[2001,5153378],[2002,5307470],[2003,5460265],[2004,5611202],[2005,5759732],[2006,5906760],[2007,6053193],[2008,6198677]],"lifeExpectancy":[[1800,31.7],[1935,31.7],[1950,42.12],[1951,42.38],[1952,42.91],[1953,43.42],[1954,43.93],[1955,44.42],[1956,44.91],[1957,45.39],[1958,45.86],[1959,46.33],[1960,46.82],[1961,47.32],[1962,47.84],[1963,48.41],[1964,49.02],[1965,49.69],[1966,50.43],[1967,51.24],[1968,52.11],[1969,53.03],[1970,54],[1971,55],[1972,56.03],[1973,57.05],[1974,58.05],[1975,59],[1976,59.89],[1977,60.69],[1978,61.42],[1979,62.06],[1980,62.63],[1981,63.13],[1982,63.58],[1983,64.01],[1984,64.43],[1985,64.85],[1986,65.27],[1987,65.69],[1988,66.12],[1989,66.55],[1990,66.97],[1991,67.4],[1992,67.81],[1993,68.2],[1994,68.58],[1995,68.94],[1996,69.29],[1997,69.62],[1998,69.94],[1999,70.25],[2000,70.55],[2001,70.84],[2002,71.12],[2003,71.4],[2004,71.66],[2005,71.92],[2006,72.17],[2007,72.41],[2008,72.65],[2009,72.88]]},{"name":"Kuwait","region":"Middle East & North Africa","income":[[1800,661.9],[1820,665.03],[1913,1141.07],[1938,1319.3],[1950,104248.05],[1951,107493.38],[1952,108382.35],[1953,113211.88],[1954,119849.29],[1955,116444.4],[1956,118681.3],[1957,113523.13],[1958,107961.27],[1959,106738.9],[1960,104014.69],[1961,94263.18],[1962,95458.11],[1963,91444.07],[1964,91341.83],[1965,84952.11],[1966,86817.71],[1967,80894.88],[1968,80502.14],[1969,75675.71],[1970,110805.23],[1971,111654.83],[1972,109347.87],[1973,96344.51],[1974,79178.58],[1975,65562.34],[1976,65578.2],[1977,59265.48],[1978,59706.33],[1979,63804.61],[1980,47907.19],[1981,37146.48],[1982,31354.04],[1983,32366.58],[1984,32575.65],[1985,29473.68],[1986,30593.24],[1987,28118.43],[1988,27895.53],[1989,28764.51],[1990,22095.96],[1991,29268.87],[1992,34932.92],[1993,44804.87],[1994,46467.09],[1995,44959.08],[1996,41620.24],[1997,40300.62],[1998,38056.53],[1999,36011.27],[2000,36397.96],[2001,35249.64],[2002,35110.11],[2003,39560.79],[2004,42275.64],[2005,44947],[2006,44411.38],[2007,43774.85],[2008,44783.08],[2009,42443.53]],"population":[[1800,81280],[1820,81280],[1870,81280],[1913,103226],[1950,144774],[1951,152197],[1952,160000],[1953,168372],[1954,177181],[1955,186639],[1956,196601],[1957,212846],[1958,234855],[1959,262006],[1960,292229],[1961,325342],[1962,358266],[1963,394128],[1964,433233],[1965,476123],[1966,523259],[1967,575003],[1968,631802],[1969,690445],[1970,747502],[1971,793314],[1972,841934],[1973,893534],[1974,948296],[1975,1006892],[1976,1071549],[1977,1140357],[1978,1213584],[1979,1291514],[1980,1369769],[1981,1432188],[1982,1497494],[1983,1565822],[1984,1637314],[1985,1732824],[1986,1811489],[1987,1891487],[1988,1973148],[1989,2056779],[1990,2142011],[1991,954071],[1992,1418095],[1993,1483773],[1994,1551427],[1995,1620808],[1996,1692893],[1997,1765345],[1998,1835863],[1999,1905246],[2000,1973572],[2001,2041961],[2002,2111561],[2003,2183161],[2004,2257549],[2005,2335648],[2006,2418393],[2007,2505559],[2008,2596799]],"lifeExpectancy":[[1800,26],[1908,26],[1939,26],[1950,54.5],[1951,54.78],[1952,55.33],[1953,55.85],[1954,56.35],[1955,56.83],[1956,57.29],[1957,57.74],[1958,58.19],[1959,58.65],[1960,59.14],[1961,59.68],[1962,60.29],[1963,60.97],[1964,61.72],[1965,62.52],[1966,63.35],[1967,64.18],[1968,64.97],[1969,65.71],[1970,66.38],[1971,66.96],[1972,67.46],[1973,67.9],[1974,68.29],[1975,68.63],[1976,68.94],[1977,69.24],[1978,69.55],[1979,69.88],[1980,70.25],[1981,70.68],[1982,71.17],[1983,71.7],[1984,72.26],[1985,72.82],[1986,73.35],[1987,73.83],[1988,74.24],[1989,74.57],[1990,74.82],[1991,75.02],[1992,75.19],[1993,75.35],[1994,75.52],[1995,75.7],[1996,75.88],[1997,76.06],[1998,76.23],[1999,76.4],[2000,76.55],[2001,76.7],[2002,76.84],[2003,76.98],[2004,77.12],[2005,77.26],[2006,77.39],[2007,77.53],[2008,77.66],[2009,77.79]]},{"name":"Lebanon","region":"Middle East & North Africa","income":[[1800,932],[1820,932],[1870,1416.26],[1913,2612.58],[1950,5318.45],[1951,4659.46],[1952,4834.8],[1953,5435.23],[1954,6091.8],[1955,6426.76],[1956,6129.26],[1957,6089.79],[1958,5102.57],[1959,5404.77],[1960,5416.84],[1961,5637.19],[1962,5714.56],[1963,5622.87],[1964,5814.82],[1965,6229.76],[1966,6477.88],[1967,6006.98],[1968,6583.23],[1969,6555.04],[1970,6827.41],[1971,7047.88],[1972,7486.38],[1973,7460.56],[1974,8310.09],[1975,8238.75],[1976,8415.07],[1977,8659.7],[1978,8921.68],[1979,8462.01],[1980,8532.76],[1981,8168.77],[1982,7640.52],[1983,7582.8],[1984,7767.38],[1985,7991.15],[1986,7663.71],[1987,5377.09],[1988,4896.81],[1989,4901.33],[1990,4849.2],[1991,6627.25],[1992,6890.81],[1993,7323.93],[1994,7844.05],[1995,8271.72],[1996,8509.88],[1997,8754.96],[1998,8920.81],[1999,8754.7],[2000,8809.99],[2001,9110.35],[2002,9313.94],[2003,9598.46],[2004,10207.45],[2005,10212],[2006,10256.98],[2007,11026.25],[2008,11864.38],[2009,12766.21]],"population":[[1800,332000],[1820,332000],[1870,476000],[1913,649000],[1950,1364030],[1951,1401246],[1952,1439529],[1953,1478915],[1954,1519439],[1955,1560985],[1956,1603579],[1957,1647412],[1958,1692357],[1959,1738617],[1960,1786235],[1961,1835620],[1962,1886848],[1963,1940191],[1964,1996143],[1965,2057945],[1966,2121579],[1967,2186894],[1968,2253719],[1969,2320495],[1970,2383029],[1971,2529267],[1972,2680018],[1973,2825318],[1974,2987566],[1975,3098159],[1976,3118590],[1977,3115787],[1978,3109385],[1979,3099426],[1980,3085876],[1981,3081499],[1982,3086876],[1983,3089792],[1984,3090257],[1985,3088235],[1986,3086848],[1987,3089353],[1988,3095949],[1989,3106800],[1990,3147267],[1991,3193208],[1992,3219994],[1993,3252469],[1994,3290707],[1995,3334733],[1996,3382135],[1997,3430388],[1998,3479269],[1999,3528559],[2000,3578036],[2001,3627774],[2002,3677780],[2003,3727703],[2004,3777218],[2005,3826018],[2006,3874050],[2007,3921278],[2008,3967467]],"lifeExpectancy":[[1800,29.7],[1940,29.7],[1950,54.28],[1951,54.71],[1952,55.55],[1953,56.36],[1954,57.13],[1955,57.86],[1956,58.55],[1957,59.21],[1958,59.82],[1959,60.4],[1960,60.93],[1961,61.43],[1962,61.89],[1963,62.31],[1964,62.7],[1965,63.07],[1966,63.42],[1967,63.76],[1968,64.1],[1969,64.42],[1970,64.73],[1971,65.02],[1972,65.27],[1973,65.48],[1974,65.66],[1975,65.81],[1976,65.95],[1977,66.08],[1978,66.21],[1979,66.36],[1980,66.52],[1981,66.69],[1982,66.87],[1983,67.05],[1984,67.23],[1985,67.42],[1986,67.62],[1987,67.84],[1988,68.08],[1989,68.34],[1990,68.61],[1991,68.88],[1992,69.14],[1993,69.39],[1994,69.61],[1995,69.82],[1996,70.01],[1997,70.18],[1998,70.34],[1999,70.5],[2000,70.65],[2001,70.8],[2002,70.97],[2003,71.14],[2004,71.31],[2005,71.5],[2006,71.69],[2007,71.88],[2008,72.08],[2009,72.26]]},{"name":"Libya","region":"Middle East & North Africa","income":[[1800,570],[1820,570],[1950,2084.28],[1951,2270.25],[1952,2387.55],[1953,2375.34],[1954,2313.67],[1955,2844.84],[1956,3385.73],[1957,3448.28],[1958,3705.67],[1959,3901.97],[1960,4902.71],[1961,5237.93],[1962,6757.03],[1963,8862.05],[1964,12161.38],[1965,15128.28],[1966,17346.19],[1967,18772.75],[1968,24313.51],[1969,26443.62],[1970,26914.43],[1971,24603.66],[1972,21011.5],[1973,20259.77],[1974,16512.38],[1975,17095.75],[1976,20471.58],[1977,21951.21],[1978,22311.86],[1979,24378.58],[1980,23661.27],[1981,18559.06],[1982,17364.28],[1983,16643.32],[1984,14874.49],[1985,13502.85],[1986,12367.27],[1987,11770.59],[1988,11617.21],[1989,11476.56],[1990,11069.61],[1991,10228.75],[1992,9640.14],[1993,9056.06],[1994,8810.1],[1995,8737.85],[1996,9051.46],[1997,9467.45],[1998,8998.07],[1999,8966.93],[2000,9139.68],[2001,9539.9],[2002,9534.68],[2003,9954.11],[2004,10304.93],[2005,10804],[2006,11305.18],[2007,11916.54],[2008,12079.02],[2009,12051.62]],"population":[[1820,538000],[1950,961305],[1951,989591],[1952,1019729],[1953,1051835],[1954,1086038],[1955,1122475],[1956,1160947],[1957,1201578],[1958,1244627],[1959,1290121],[1960,1337947],[1961,1388517],[1962,1441863],[1963,1498607],[1964,1560361],[1965,1623770],[1966,1693925],[1967,1759224],[1968,1833726],[1969,1922974],[1970,1999162],[1971,2077381],[1972,2183877],[1973,2312369],[1974,2451375],[1975,2569606],[1976,2666160],[1977,2721783],[1978,2796747],[1979,2928575],[1980,3065365],[1981,3204071],[1982,3344074],[1983,3484531],[1984,3624920],[1985,3675422],[1986,3699538],[1987,3799845],[1988,3913314],[1989,4026847],[1990,4139825],[1991,4252354],[1992,4364501],[1993,4475679],[1994,4585017],[1995,4654252],[1996,4686329],[1997,4759670],[1998,4874638],[1999,4993414],[2000,5115450],[2001,5240599],[2002,5368585],[2003,5499074],[2004,5631585],[2005,5765563],[2006,5900754],[2007,6036914],[2008,6173579]],"lifeExpectancy":[[1800,33],[1940,33],[1950,41.69],[1951,41.95],[1952,42.47],[1953,42.98],[1954,43.5],[1955,44.01],[1956,44.53],[1957,45.04],[1958,45.55],[1959,46.06],[1960,46.56],[1961,47.06],[1962,47.55],[1963,48.04],[1964,48.53],[1965,49.01],[1966,49.47],[1967,49.92],[1968,50.37],[1969,50.83],[1970,51.33],[1971,51.89],[1972,52.52],[1973,53.25],[1974,54.06],[1975,54.94],[1976,55.89],[1977,56.88],[1978,57.87],[1979,58.86],[1980,59.83],[1981,60.79],[1982,61.73],[1983,62.67],[1984,63.57],[1985,64.44],[1986,65.25],[1987,65.99],[1988,66.67],[1989,67.27],[1990,67.83],[1991,68.35],[1992,68.86],[1993,69.37],[1994,69.88],[1995,70.38],[1996,70.86],[1997,71.29],[1998,71.67],[1999,71.98],[2000,72.25],[2001,72.49],[2002,72.7],[2003,72.92],[2004,73.14],[2005,73.36],[2006,73.6],[2007,73.83],[2008,74.06],[2009,74.28]]},{"name":"Morocco","region":"Middle East & North Africa","income":[[1800,497.25],[1820,497.17],[1870,651.13],[1913,821.37],[1950,1683.1],[1951,1686.17],[1952,1688.2],[1953,1698.28],[1954,1707.29],[1955,1715.26],[1956,1678.43],[1957,1642],[1958,1606.28],[1959,1570.98],[1960,1536.62],[1961,1551.35],[1962,1566.35],[1963,1581.36],[1964,1596.54],[1965,1612.12],[1966,1660.76],[1967,1711.04],[1968,1762.62],[1969,1815.24],[1970,1869.14],[1971,1924.99],[1972,1930.19],[1973,1959.41],[1974,2024.8],[1975,2117.48],[1976,2304.26],[1977,2370.62],[1978,2392.59],[1979,2453.98],[1980,2627.7],[1981,2508.85],[1982,2702.62],[1983,2616.83],[1984,2655.21],[1985,2748.96],[1986,2889.61],[1987,2755.05],[1988,2963.85],[1989,2960.35],[1990,3002.1],[1991,3138.3],[1992,2948.05],[1993,2857.36],[1994,3090.03],[1995,2828.67],[1996,3112.23],[1997,2982.1],[1998,3156.79],[1999,3097.02],[2000,3073.43],[2001,3211.29],[2002,3258.5],[2003,3400.37],[2004,3519.46],[2005,3547],[2006,3774.77],[2007,3832.92],[2008,3990.75],[2009,4162.93]],"population":[[1820,2689000],[1870,3776000],[1913,5111000],[1950,9343384],[1951,9633621],[1952,9939217],[1953,10205766],[1954,10486500],[1955,10781677],[1956,11088510],[1957,11406350],[1958,11734866],[1959,12074375],[1960,12423434],[1961,12736342],[1962,13056604],[1963,13385360],[1964,13722483],[1965,14066154],[1966,14414636],[1967,14770296],[1968,15137266],[1969,15517155],[1970,15909275],[1971,16313391],[1972,16660670],[1973,16998378],[1974,17335236],[1975,17687376],[1976,18042963],[1977,18396941],[1978,18758283],[1979,19125959],[1980,19487272],[1981,19846221],[1982,20198730],[1983,20740299],[1984,21295943],[1985,21857410],[1986,22421628],[1987,22987397],[1988,23554959],[1989,24122368],[1990,24685960],[1991,25244056],[1992,25798239],[1993,26350819],[1994,26900833],[1995,27446860],[1996,27989535],[1997,28529501],[1998,29065648],[1999,29596788],[2000,30122350],[2001,30645305],[2002,31167783],[2003,31689265],[2004,32209101],[2005,32725847],[2006,33241259],[2007,33757175],[2008,34272968]],"lifeExpectancy":[[1800,33.1],[1940,33.1],[1950,41.85],[1951,42.1],[1952,42.62],[1953,43.13],[1954,43.64],[1955,44.16],[1956,44.67],[1957,45.17],[1958,45.68],[1959,46.18],[1960,46.68],[1961,47.18],[1962,47.67],[1963,48.16],[1964,48.64],[1965,49.13],[1966,49.61],[1967,50.09],[1968,50.57],[1969,51.06],[1970,51.56],[1971,52.06],[1972,52.57],[1973,53.09],[1974,53.63],[1975,54.19],[1976,54.8],[1977,55.46],[1978,56.17],[1979,56.91],[1980,57.68],[1981,58.45],[1982,59.21],[1983,59.93],[1984,60.61],[1985,61.25],[1986,61.86],[1987,62.44],[1988,63],[1989,63.55],[1990,64.1],[1991,64.63],[1992,65.15],[1993,65.64],[1994,66.12],[1995,66.59],[1996,67.04],[1997,67.47],[1998,67.89],[1999,68.3],[2000,68.69],[2001,69.08],[2002,69.44],[2003,69.79],[2004,70.13],[2005,70.44],[2006,70.75],[2007,71.03],[2008,71.31],[2009,71.58]]},{"name":"Oman","region":"Middle East & North Africa","income":[[1800,882.54],[1820,886.71],[1913,1521.43],[1950,1681.63],[1951,1753.06],[1952,1828.23],[1953,1906.94],[1954,1986.07],[1955,2068.1],[1956,2155.84],[1957,2242.75],[1958,2337.97],[1959,2429.59],[1960,2522.63],[1961,2491.42],[1962,2924.64],[1963,2975.73],[1964,2902.51],[1965,2842.57],[1966,2914],[1967,4720.94],[1968,8348.98],[1969,10208.31],[1970,10251.63],[1971,10029.3],[1972,10618.04],[1973,8849.08],[1974,9557.8],[1975,11516.25],[1976,12407.01],[1977,11848.34],[1978,11026.71],[1979,10914.09],[1980,10989.43],[1981,12206.78],[1982,12954.79],[1983,14428.57],[1984,16128.07],[1985,17663.75],[1986,17386.29],[1987,18115.22],[1988,18002.58],[1989,18103.04],[1990,17485.61],[1991,17828.04],[1992,18616.71],[1993,19021.94],[1994,19083.44],[1995,19325.59],[1996,19207.86],[1997,19702.06],[1998,19545.61],[1999,18843.38],[2000,19204.29],[2001,19945.39],[2002,19774.84],[2003,19497.67],[2004,19870.6],[2005,20334],[2006,20984.34],[2007,21239.98],[2008,22789.62],[2009,22804.85]],"population":[[1800,318000],[1820,318000],[1870,367000],[1913,444000],[1950,488588],[1951,498207],[1952,507833],[1953,517464],[1954,528286],[1955,539115],[1956,549950],[1957,561977],[1958,572826],[1959,586055],[1960,599292],[1961,613723],[1962,628164],[1963,644990],[1964,661826],[1965,678672],[1966,696718],[1967,714775],[1968,735222],[1969,755682],[1970,778536],[1971,802594],[1972,829050],[1973,856714],[1974,884395],[1975,913285],[1976,956453],[1977,1004533],[1978,1058744],[1979,1115515],[1980,1174857],[1981,1237945],[1982,1301048],[1983,1363189],[1984,1423521],[1985,1481587],[1986,1537697],[1987,1593882],[1988,1651822],[1989,1711642],[1990,1772974],[1991,1843255],[1992,1915208],[1993,1988746],[1994,2058553],[1995,2130934],[1996,2205958],[1997,2283635],[1998,2364049],[1999,2447279],[2000,2533389],[2001,2622198],[2002,2713462],[2003,2807125],[2004,2903165],[2005,3001583],[2006,3102229],[2007,3204897],[2008,3309440]],"lifeExpectancy":[[1800,32.3],[1945,32.3],[1950,36.72],[1951,36.92],[1952,37.34],[1953,37.78],[1954,38.24],[1955,38.73],[1956,39.24],[1957,39.78],[1958,40.34],[1959,40.91],[1960,41.52],[1961,42.14],[1962,42.79],[1963,43.46],[1964,44.17],[1965,44.92],[1966,45.72],[1967,46.57],[1968,47.48],[1969,48.45],[1970,49.46],[1971,50.5],[1972,51.55],[1973,52.62],[1974,53.68],[1975,54.74],[1976,55.79],[1977,56.85],[1978,57.92],[1979,58.99],[1980,60.07],[1981,61.15],[1982,62.23],[1983,63.31],[1984,64.36],[1985,65.38],[1986,66.37],[1987,67.31],[1988,68.2],[1989,69.02],[1990,69.75],[1991,70.38],[1992,70.91],[1993,71.34],[1994,71.7],[1995,71.99],[1996,72.25],[1997,72.5],[1998,72.76],[1999,73.04],[2000,73.35],[2001,73.68],[2002,74.02],[2003,74.34],[2004,74.66],[2005,74.95],[2006,75.22],[2007,75.48],[2008,75.72],[2009,75.94]]},{"name":"Qatar","region":"Middle East & North Africa","income":[[1800,588.36],[1820,591.14],[1913,1014.29],[1939,1179.54],[1970,80244.5],[1971,80293.69],[1972,81068.9],[1973,82057.81],[1974,80224.5],[1975,79275.52],[1976,81127.92],[1977,71615.83],[1978,74170.51],[1979,73434.87],[1980,67344.1],[1981,65947.52],[1982,57679.64],[1983,52169.59],[1984,49067.69],[1985,44379.47],[1986,42994.48],[1987,40870.69],[1988,40632.35],[1989,40930],[1990,40510.85],[1991,39011.46],[1992,41781.68],[1993,40684.8],[1994,40794.94],[1995,41058.27],[1996,42008.11],[1997,52938.65],[1998,57390.75],[1999,57836.84],[2000,60394.43],[2001,59277.98],[2002,60016],[2003,58706.15],[2004,67458.36],[2005,68696],[2006,75078.13],[2007,76900.53],[2008,75474.32],[2009,74138.28]],"population":[[1800,14092],[1820,14092],[1870,14092],[1913,17897],[1950,25101],[1951,27064],[1952,29057],[1953,31074],[1954,33105],[1955,35142],[1956,36952],[1957,38757],[1958,40550],[1959,42667],[1960,45183],[1961,48712],[1962,52968],[1963,58146],[1964,63897],[1965,70284],[1966,77319],[1967,85168],[1968,93925],[1969,103283],[1970,113262],[1971,122177],[1972,131794],[1973,142167],[1974,153358],[1975,165429],[1976,176798],[1977,188947],[1978,201932],[1979,215809],[1980,230640],[1981,242474],[1982,252300],[1983,283926],[1984,314767],[1985,345079],[1986,375013],[1987,402134],[1988,429731],[1989,456616],[1990,481477],[1991,504531],[1992,529399],[1993,557008],[1994,585368],[1995,613142],[1996,640524],[1997,667336],[1998,693592],[1999,719306],[2000,744483],[2001,769152],[2002,793341],[2003,817052],[2004,840290],[2005,863051],[2006,885359],[2007,907229],[2008,928635]],"lifeExpectancy":[[1800,30.8],[1940,30.8],[1950,47.03],[1951,47.23],[1952,47.67],[1953,48.16],[1954,48.69],[1955,49.27],[1956,49.9],[1957,50.57],[1958,51.28],[1959,52.03],[1960,52.81],[1961,53.61],[1962,54.42],[1963,55.24],[1964,56.04],[1965,56.83],[1966,57.6],[1967,58.35],[1968,59.08],[1969,59.78],[1970,60.47],[1971,61.13],[1972,61.78],[1973,62.41],[1974,63.02],[1975,63.61],[1976,64.17],[1977,64.71],[1978,65.22],[1979,65.69],[1980,66.12],[1981,66.52],[1982,66.87],[1983,67.19],[1984,67.48],[1985,67.75],[1986,68.01],[1987,68.26],[1988,68.53],[1989,68.8],[1990,69.1],[1991,69.42],[1992,69.77],[1993,70.13],[1994,70.52],[1995,70.93],[1996,71.36],[1997,71.81],[1998,72.27],[1999,72.73],[2000,73.18],[2001,73.61],[2002,74.01],[2003,74.38],[2004,74.71],[2005,75],[2006,75.24],[2007,75.46],[2008,75.65],[2009,75.81]]},{"name":"Saudi Arabia","region":"Middle East & North Africa","income":[[1800,441.27],[1820,443.36],[1913,760.72],[1950,5834.36],[1951,6208.71],[1952,6459.55],[1953,6968.42],[1954,7615.79],[1955,7642.33],[1956,8042.36],[1957,8157.59],[1958,8380.7],[1959,9044.26],[1960,9726.96],[1961,10635.36],[1962,11626.42],[1963,12332.87],[1964,13089.1],[1965,14304.44],[1966,15958.99],[1967,16903.05],[1968,17910.56],[1969,18751.91],[1970,19938.92],[1971,22166.86],[1972,24837.43],[1973,28873.35],[1974,32254.54],[1975,30827.93],[1976,31661.42],[1977,34167.76],[1978,33789.05],[1979,33588.81],[1980,34568.06],[1981,35101.25],[1982,33693.18],[1983,28412.06],[1984,26815.59],[1985,23663.08],[1986,21161.24],[1987,21198.26],[1988,20995.14],[1989,20934.15],[1990,23520.95],[1991,25113.59],[1992,24841.62],[1993,23173.54],[1994,22010.66],[1995,21162.71],[1996,20772.36],[1997,20586.69],[1998,20353.7],[1999,19635.3],[2000,20001.87],[2001,19528.5],[2002,19014.54],[2003,19945.47],[2004,20481.98],[2005,21220],[2006,21356.15],[2007,21255.6],[2008,21635.15],[2009,21138.18]],"population":[[1800,2091000],[1820,2091000],[1870,2338000],[1913,2676000],[1950,3859801],[1951,3931753],[1952,4005677],[1953,4081572],[1954,4160424],[1955,4243218],[1956,4328970],[1957,4419650],[1958,4514271],[1959,4613822],[1960,4718301],[1961,4827708],[1962,4943029],[1963,5065249],[1964,5192398],[1965,5327432],[1966,5469365],[1967,5618198],[1968,5774916],[1969,5938534],[1970,6109051],[1971,6287454],[1972,6472756],[1973,6666928],[1974,6868001],[1975,7204820],[1976,7620435],[1977,8128505],[1978,8708801],[1979,9346019],[1980,9999161],[1981,10627409],[1982,11254672],[1983,11912032],[1984,12606940],[1985,13330067],[1986,13998295],[1987,14619745],[1988,15233131],[1989,15829361],[1990,16060761],[1991,16305774],[1992,16945857],[1993,18056656],[1994,19108307],[1995,19966998],[1996,20625641],[1997,21229759],[1998,21842982],[1999,22483640],[2000,23153090],[2001,23832849],[2002,24501530],[2003,25156630],[2004,25795938],[2005,26417599],[2006,27019731],[2007,27601038],[2008,28161417]],"lifeExpectancy":[[1800,32.1],[1945,32.1],[1950,38.66],[1951,38.97],[1952,39.58],[1953,40.18],[1954,40.78],[1955,41.37],[1956,41.96],[1957,42.54],[1958,43.12],[1959,43.71],[1960,44.31],[1961,44.95],[1962,45.61],[1963,46.32],[1964,47.06],[1965,47.83],[1966,48.63],[1967,49.43],[1968,50.23],[1969,51.02],[1970,51.83],[1971,52.65],[1972,53.5],[1973,54.39],[1974,55.31],[1975,56.26],[1976,57.23],[1977,58.2],[1978,59.17],[1979,60.11],[1980,61.02],[1981,61.89],[1982,62.72],[1983,63.5],[1984,64.24],[1985,64.92],[1986,65.57],[1987,66.17],[1988,66.74],[1989,67.29],[1990,67.8],[1991,68.27],[1992,68.71],[1993,69.12],[1994,69.49],[1995,69.83],[1996,70.14],[1997,70.41],[1998,70.66],[1999,70.9],[2000,71.12],[2001,71.33],[2002,71.55],[2003,71.77],[2004,71.99],[2005,72.21],[2006,72.44],[2007,72.66],[2008,72.88],[2009,73.1]]},{"name":"Tunisia","region":"Middle East & North Africa","income":[[1800,518.72],[1820,517.32],[1870,761.63],[1913,1062.88],[1950,1341.82],[1951,1331.69],[1952,1468.48],[1953,1497.12],[1954,1503.54],[1955,1401.36],[1956,1472.77],[1957,1395.23],[1958,1554.59],[1959,1465.08],[1960,1616.32],[1961,1728.37],[1962,1660.3],[1963,1872.91],[1964,1912.76],[1965,1989.82],[1966,1991.34],[1967,1932.36],[1968,2088.68],[1969,2118.73],[1970,2199.31],[1971,2386.27],[1972,2753.29],[1973,2673.63],[1974,2820.76],[1975,2944.73],[1976,3093],[1977,3120.88],[1978,3251.03],[1979,3384.54],[1980,3543.72],[1981,3647.29],[1982,3560.23],[1983,3658.69],[1984,3693.06],[1985,3806.44],[1986,3656.88],[1987,3810.42],[1988,3732.5],[1989,3794.69],[1990,4017.22],[1991,4095.28],[1992,4332.72],[1993,4347.77],[1994,4409.94],[1995,4444.95],[1996,4691.19],[1997,4876.8],[1998,5046.68],[1999,5292.3],[2000,5480.32],[2001,5687.24],[2002,5722.9],[2003,5980.59],[2004,6274.88],[2005,6461],[2006,6740.19],[2007,7099.69],[2008,7356.75],[2009,7499.61]],"population":[[1820,875000],[1870,1176000],[1913,1870000],[1950,3517210],[1951,3582970],[1952,3647735],[1953,3713496],[1954,3779257],[1955,3846014],[1956,3903067],[1957,3950849],[1958,4007300],[1959,4074970],[1960,4149157],[1961,4216031],[1962,4286552],[1963,4374477],[1964,4468393],[1965,4565747],[1966,4676017],[1967,4786986],[1968,4894178],[1969,4996300],[1970,5098627],[1971,5197559],[1972,5303507],[1973,5426213],[1974,5556437],[1975,5703966],[1976,5859294],[1977,6005061],[1978,6136282],[1979,6280477],[1980,6443183],[1981,6605707],[1982,6734098],[1983,6859890],[1984,7184530],[1985,7362332],[1986,7544710],[1987,7724976],[1988,7895088],[1989,8052989],[1990,8207240],[1991,8364780],[1992,8523077],[1993,8680433],[1994,8831747],[1995,8972635],[1996,9105233],[1997,9231669],[1998,9349100],[1999,9458862],[2000,9563816],[2001,9667365],[2002,9770575],[2003,9873149],[2004,9974722],[2005,10074951],[2006,10175014],[2007,10276158],[2008,10378140]],"lifeExpectancy":[[1800,28.8],[1923,28.8],[1933,31.22],[1943,33.72],[1950,43.61],[1951,43.85],[1952,44.35],[1953,44.85],[1954,45.35],[1955,45.85],[1956,46.35],[1957,46.85],[1958,47.35],[1959,47.85],[1960,48.34],[1961,48.82],[1962,49.3],[1963,49.77],[1964,50.24],[1965,50.73],[1966,51.24],[1967,51.79],[1968,52.38],[1969,53.01],[1970,53.69],[1971,54.42],[1972,55.19],[1973,55.99],[1974,56.81],[1975,57.65],[1976,58.51],[1977,59.4],[1978,60.29],[1979,61.18],[1980,62.05],[1981,62.88],[1982,63.65],[1983,64.36],[1984,65.02],[1985,65.63],[1986,66.22],[1987,66.81],[1988,67.4],[1989,68.02],[1990,68.63],[1991,69.23],[1992,69.8],[1993,70.32],[1994,70.79],[1995,71.19],[1996,71.54],[1997,71.84],[1998,72.11],[1999,72.34],[2000,72.56],[2001,72.76],[2002,72.94],[2003,73.12],[2004,73.29],[2005,73.46],[2006,73.63],[2007,73.81],[2008,73.98],[2009,74.15]]},{"name":"United Arab Emirates","region":"Middle East & North Africa","income":[[1800,845.76],[1820,849.76],[1913,1458.04],[1958,5100],[1970,13677.04],[1971,13239.26],[1972,12703.61],[1973,19448.86],[1974,47592.52],[1975,53499.46],[1976,52628.36],[1977,53335.18],[1978,45587.62],[1979,50726.23],[1980,58179.45],[1981,55157.82],[1982,47211.4],[1983,42152.15],[1984,41475.71],[1985,38213.65],[1986,29225.3],[1987,29327.06],[1988,27050.85],[1989,29062.16],[1990,32431.23],[1991,30832.82],[1992,30084.24],[1993,28314.81],[1994,29007.14],[1995,29341.65],[1996,29286.31],[1997,29989.45],[1998,28676.19],[1999,28251.7],[2000,30012.32],[2001,29446.26],[2002,28728.96],[2003,30646.11],[2004,32181.94],[2005,33487],[2006,35347.29],[2007,35324.66],[2008,34981.22],[2009,33734.94]],"population":[[1800,40153],[1820,40153],[1870,40153],[1913,50995],[1950,71520],[1951,73298],[1952,75273],[1953,77480],[1954,79947],[1955,82715],[1956,85831],[1957,89353],[1958,93340],[1959,97870],[1960,103048],[1961,108989],[1962,115827],[1963,123751],[1964,132980],[1965,143798],[1966,156574],[1967,171745],[1968,190974],[1969,217858],[1970,249369],[1971,288136],[1972,336325],[1973,391337],[1974,453222],[1975,522571],[1976,598023],[1977,683672],[1978,778736],[1979,884040],[1980,1000285],[1981,1100356],[1982,1203634],[1983,1315978],[1984,1437950],[1985,1570219],[1986,1713616],[1987,1778365],[1988,1839339],[1989,1896774],[1990,1950792],[1991,2001524],[1992,2048857],[1993,2093393],[1994,2135896],[1995,2176370],[1996,2215556],[1997,2254266],[1998,2292669],[1999,2330923],[2000,2369153],[2001,2407460],[2002,2445989],[2003,2484818],[2004,2523915],[2005,2563212],[2006,2602713],[2007,2642566],[2008,2682747]],"lifeExpectancy":[[1800,30.7],[1945,30.7],[1950,46.99],[1951,47.21],[1952,47.66],[1953,48.17],[1954,48.72],[1955,49.32],[1956,49.97],[1957,50.65],[1958,51.38],[1959,52.14],[1960,52.93],[1961,53.74],[1962,54.56],[1963,55.38],[1964,56.19],[1965,56.98],[1966,57.73],[1967,58.46],[1968,59.16],[1969,59.84],[1970,60.52],[1971,61.22],[1972,61.95],[1973,62.71],[1974,63.5],[1975,64.29],[1976,65.06],[1977,65.78],[1978,66.43],[1979,67.01],[1980,67.53],[1981,68.02],[1982,68.49],[1983,68.97],[1984,69.47],[1985,69.99],[1986,70.53],[1987,71.05],[1988,71.56],[1989,72.06],[1990,72.54],[1991,73.02],[1992,73.49],[1993,73.97],[1994,74.43],[1995,74.88],[1996,75.3],[1997,75.66],[1998,75.97],[1999,76.22],[2000,76.42],[2001,76.57],[2002,76.7],[2003,76.82],[2004,76.94],[2005,77.06],[2006,77.18],[2007,77.31],[2008,77.45],[2009,77.58]]},{"name":"West Bank and Gaza","region":"Middle East & North Africa","income":[[1800,735.45],[1820,738.93],[1913,1267.86],[1950,1405.45],[1951,1461.21],[1952,1515.59],[1953,1570.9],[1954,1633.31],[1955,1694.35],[1956,1757.71],[1957,1827.07],[1958,1895.34],[1959,1965.96],[1960,2039.72],[1961,2118.83],[1962,2198.96],[1963,2282.6],[1964,2368.29],[1965,2457.42],[1966,2552.07],[1967,2649.72],[1968,2750.96],[1969,2840.54],[1970,2931.07],[1971,3029.87],[1972,3133.41],[1973,3233.64],[1974,3340.31],[1975,3448.53],[1976,3565.14],[1977,3682.83],[1978,3806.21],[1979,3931.93],[1980,4062.85],[1981,4199.87],[1982,4336.03],[1983,4482.74],[1984,4631.3],[1985,4784.28],[1986,4945.41],[1987,5107.2],[1988,5276.33],[1989,5452.69],[1990,5635.48],[1991,5821.77],[1992,6017.65],[1993,6218.71],[1994,6431.12],[1995,6647.75],[1996,6875.61],[1997,7110.67],[1998,7477.12],[1999,7864.94],[2000,7586.32],[2001,5852.63],[2002,4515.49],[2003,3793.97],[2004,3664.45],[2005,3542],[2006,3263.47],[2007,3121.4],[2008,3084.56]],"population":[[1800,165944],[1850,165944],[1860,180099],[1877,215167],[1878,217741],[1879,220357],[1880,223014],[1881,225716],[1882,228461],[1883,231252],[1884,234089],[1885,236974],[1886,239905],[1887,242887],[1888,245919],[1889,248890],[1890,251909],[1891,254974],[1892,258089],[1893,261254],[1894,264542],[1895,267880],[1896,271341],[1897,274854],[1898,278608],[1899,282421],[1900,286294],[1901,290228],[1902,294225],[1903,298285],[1904,302411],[1905,306602],[1906,310861],[1907,315189],[1908,319588],[1909,324056],[1910,328599],[1911,337909],[1912,342679],[1913,347528],[1914,352458],[1918,330270],[1922,360287],[1931,465384],[1932,483666],[1933,513691],[1934,544820],[1935,588286],[1936,613124],[1937,630160],[1938,645526],[1939,680171],[1940,703338],[1941,723889],[1942,743058],[1943,768008],[1944,795069],[1945,824913],[1946,857472],[1950,1016540],[1951,1022333],[1952,1030585],[1953,1040483],[1954,1048766],[1955,1053801],[1956,1061298],[1957,1070439],[1958,1077965],[1959,1100998],[1960,1113446],[1961,1109603],[1962,1133134],[1963,1156474],[1964,1182145],[1965,1210960],[1966,1235665],[1967,1142636],[1968,1000482],[1969,1006458],[1970,1032447],[1971,1059861],[1972,1089572],[1973,1124018],[1974,1166576],[1975,1200805],[1976,1228388],[1977,1261091],[1978,1296061],[1979,1329554],[1980,1359954],[1981,1388910],[1982,1425876],[1983,1474659],[1984,1524537],[1985,1576361],[1986,1630382],[1987,1691210],[1988,1757935],[1989,1820817],[1990,1897320],[1991,1997073],[1992,2104779],[1993,2215999],[1994,2345625],[1995,2501920],[1996,2665989],[1997,2826046],[1998,2931882],[1999,3040686],[2000,3152361],[2001,3268832],[2002,3389578],[2003,3512062],[2004,3636195],[2005,3761904],[2006,3889249],[2007,4018332],[2008,4149173]],"lifeExpectancy":[[1950,42.12],[1951,42.38],[1952,42.91],[1953,43.43],[1954,43.93],[1955,44.43],[1956,44.91],[1957,45.39],[1958,45.86],[1959,46.34],[1960,46.82],[1961,47.32],[1962,47.85],[1963,48.41],[1964,49.02],[1965,49.69],[1966,50.44],[1967,51.25],[1968,52.13],[1969,53.06],[1970,54.02],[1971,55.01],[1972,55.98],[1973,56.94],[1974,57.86],[1975,58.74],[1976,59.59],[1977,60.41],[1978,61.2],[1979,61.97],[1980,62.71],[1981,63.41],[1982,64.07],[1983,64.68],[1984,65.26],[1985,65.81],[1986,66.34],[1987,66.88],[1988,67.42],[1989,67.95],[1990,68.48],[1991,68.99],[1992,69.44],[1993,69.85],[1994,70.21],[1995,70.52],[1996,70.79],[1997,71.03],[1998,71.28],[1999,71.52],[2000,71.76],[2001,72.01],[2002,72.25],[2003,72.48],[2004,72.7],[2005,72.92],[2006,73.13],[2007,73.33],[2008,73.54],[2009,73.74]]},{"name":"Yemen, Rep.","region":"Middle East & North Africa","income":[[1800,661.9],[1820,665.03],[1950,771.3],[1951,776.63],[1952,781.72],[1953,787.32],[1954,792.09],[1955,797.17],[1956,800.97],[1957,804.83],[1958,808.4],[1959,811.99],[1960,815.92],[1961,820.54],[1962,825.62],[1963,832.92],[1964,837.04],[1965,843.34],[1966,852.7],[1967,862.44],[1968,870.25],[1969,880.66],[1970,1041.1],[1971,1196.79],[1972,1265.05],[1973,1388.2],[1974,1435.54],[1975,1509.67],[1976,1695.14],[1977,1829.77],[1978,1930.83],[1979,1982.42],[1980,1938.74],[1981,2000.3],[1982,1977.56],[1983,2032.19],[1984,2050.33],[1985,1973.82],[1986,1955.75],[1987,1971.74],[1988,1989.89],[1989,1991.58],[1990,1923.3],[1991,1859.24],[1992,1879.5],[1993,1861.89],[1994,1834.92],[1995,1970.6],[1996,2022.93],[1997,2117.48],[1998,2149.8],[1999,2158.6],[2000,2217.07],[2001,2225.1],[2002,2234.82],[2003,2239.83],[2004,2250.9],[2005,2276],[2006,2277.84],[2007,2283.39],[2008,2295.8],[2009,2313.16]],"population":[[1800,2593000],[1820,2593000],[1870,2840000],[1913,3284000],[1950,4777089],[1951,4869125],[1952,4963829],[1953,5061153],[1954,5162494],[1955,5265327],[1956,5380106],[1957,5498090],[1958,5619377],[1959,5743926],[1960,5871831],[1961,5993828],[1962,6120081],[1963,6248206],[1964,6378206],[1965,6510081],[1966,6624755],[1967,6740785],[1968,6859408],[1969,6978155],[1970,7098239],[1971,7251383],[1972,7407075],[1973,7579501],[1974,7755019],[1975,7934497],[1976,8170521],[1977,8403990],[1978,8641036],[1979,8883381],[1980,9132545],[1981,9390138],[1982,9657618],[1983,9936258],[1984,10229272],[1985,10539928],[1986,10869580],[1987,11219340],[1988,11591069],[1989,11986392],[1990,12416080],[1991,12882420],[1992,13367997],[1993,13885756],[1994,14394750],[1995,14859342],[1996,15327307],[1997,15826497],[1998,16352459],[1999,16904520],[2000,17479206],[2001,18078035],[2002,18701257],[2003,19349881],[2004,20024867],[2005,20727063],[2006,21456188],[2007,22211743],[2008,22993911]],"lifeExpectancy":[[1800,33],[1945,33],[1950,31.91],[1951,32.08],[1952,32.4],[1953,32.71],[1954,33.01],[1955,33.29],[1956,33.56],[1957,33.82],[1958,34.07],[1959,34.31],[1960,34.54],[1961,34.79],[1962,35.04],[1963,35.31],[1964,35.62],[1965,35.95],[1966,36.32],[1967,36.73],[1968,37.18],[1969,37.67],[1970,38.22],[1971,38.83],[1972,39.49],[1973,40.22],[1974,41.01],[1975,41.85],[1976,42.75],[1977,43.7],[1978,44.69],[1979,45.69],[1980,46.68],[1981,47.66],[1982,48.62],[1983,49.53],[1984,50.39],[1985,51.19],[1986,51.93],[1987,52.6],[1988,53.23],[1989,53.82],[1990,54.37],[1991,54.89],[1992,55.4],[1993,55.88],[1994,56.37],[1995,56.84],[1996,57.32],[1997,57.79],[1998,58.25],[1999,58.71],[2000,59.17],[2001,59.63],[2002,60.09],[2003,60.56],[2004,61.03],[2005,61.51],[2006,61.98],[2007,62.46],[2008,62.93],[2009,63.39]]},{"name":"Argentina","region":"America","income":[[1800,871.63],[1820,871.63],[1875,1885.41],[1876,1867.47],[1877,2002.04],[1878,1839.6],[1879,1863.06],[1880,1769.57],[1881,1743.09],[1882,2140.95],[1883,2333.66],[1884,2426.44],[1885,2770.22],[1886,2695.38],[1887,2794.95],[1888,3156.64],[1889,3364.75],[1890,2982.77],[1891,2730.32],[1892,3176.32],[1893,3266.51],[1894,3664.86],[1895,3949.4],[1896,4246.48],[1897,3317.39],[1898,3498.62],[1899,4011.23],[1900,3419.66],[1901,3611.77],[1902,3436.59],[1903,3830.91],[1904,4131.05],[1905,4562.36],[1906,4580.22],[1907,4464.29],[1908,4694.41],[1909,4708.23],[1910,4832.38],[1911,4726.01],[1912,4923.21],[1913,4777.66],[1914,4091.98],[1915,3949.97],[1916,3767.94],[1917,3397.62],[1918,3961.68],[1919,4038.95],[1920,4263.13],[1921,4242.31],[1922,4452.29],[1923,4807.28],[1924,5035.79],[1925,4861.3],[1926,4962.42],[1927,5178.2],[1928,5356.78],[1929,5456.67],[1930,5081.2],[1931,4633.64],[1932,4393.52],[1933,4518.05],[1934,4790.22],[1935,4909.12],[1936,4872.97],[1937,5149.63],[1938,5084.62],[1939,5199.52],[1940,5202.23],[1941,5393.04],[1942,5368.42],[1943,5248.21],[1944,5757.53],[1945,5482.92],[1946,5845.22],[1947,6359.64],[1948,6560.39],[1949,6322.98],[1950,6252.86],[1951,6362.13],[1952,5911.32],[1953,6107.59],[1954,6242.6],[1955,6566.88],[1956,6630.03],[1957,6856.86],[1958,7157.86],[1959,6575.45],[1960,6984.76],[1961,7367.29],[1962,7133.17],[1963,6852.54],[1964,7452.89],[1965,8022.44],[1966,7955.97],[1967,8052.95],[1968,8284.39],[1969,8870.89],[1970,9212.3],[1971,9408.19],[1972,9443.04],[1973,9633.5],[1974,9989.81],[1975,9766.38],[1976,9611.92],[1977,10079.03],[1978,9602.71],[1979,10124.86],[1980,10126.5],[1981,9421.94],[1982,8997.9],[1983,9238.61],[1984,9301.55],[1985,8525.61],[1986,9026.86],[1987,9139.67],[1988,8845.59],[1989,8107.72],[1990,7846.61],[1991,8575.87],[1992,9308.42],[1993,9742.08],[1994,10206.9],[1995,9807.79],[1996,10245.38],[1997,10967.28],[1998,11272.75],[1999,10771.08],[2000,10571.36],[2001,9992.71],[2002,8797.64],[2003,9481.37],[2004,10232.1],[2005,11063],[2006,11883.08],[2007,12784.8],[2008,13515.18],[2009,13498.04]],"population":[[1800,534000],[1820,534000],[1850,1100000],[1870,1796000],[1890,3376000],[1900,4693000],[1901,4873000],[1902,5060000],[1903,5254000],[1904,5455000],[1905,5664000],[1906,5881000],[1907,6107000],[1908,6341000],[1909,6584000],[1910,6836000],[1911,7098000],[1912,7370000],[1913,7653000],[1914,7885000],[1915,8072000],[1916,8226000],[1917,8374000],[1918,8518000],[1919,8672000],[1920,8861000],[1921,9092000],[1922,9368000],[1923,9707000],[1924,10054000],[1925,10358000],[1926,10652000],[1927,10965000],[1928,11282000],[1929,11592000],[1930,11896000],[1931,12167000],[1932,12402000],[1933,12623000],[1934,12834000],[1935,13044000],[1936,13260000],[1937,13490000],[1938,13724000],[1939,13984000],[1940,14169000],[1941,14402000],[1942,14638000],[1943,14877000],[1944,15130000],[1945,15390000],[1946,15654000],[1947,15942000],[1948,16307000],[1949,16737000],[1950,17150336],[1951,17517342],[1952,17876956],[1953,18230816],[1954,18580559],[1955,18927821],[1956,19271511],[1957,19610538],[1958,19946539],[1959,20281150],[1960,20616009],[1961,20950583],[1962,21283783],[1963,21616403],[1964,21949244],[1965,22283100],[1966,22611604],[1967,22934225],[1968,23260514],[1969,23600026],[1970,23962313],[1971,24363816],[1972,24779799],[1973,25209829],[1974,25646371],[1975,26081880],[1976,26531280],[1977,26983828],[1978,27440272],[1979,27901971],[1980,28369799],[1981,28862831],[1982,29341374],[1983,29801763],[1984,30235573],[1985,30675059],[1986,31145966],[1987,31620918],[1988,32090943],[1989,32558573],[1990,33022202],[1991,33491595],[1992,33958947],[1993,34411978],[1994,34864440],[1995,35311049],[1996,35753590],[1997,36203463],[1998,36643768],[1999,37073828],[2000,37497728],[2001,37916560],[2002,38331121],[2003,38740807],[2004,39144753],[2005,39537943],[2006,39921833],[2007,40301927],[2008,40677348]],"lifeExpectancy":[[1800,33.2],[1875,33.2],[1880,33.1],[1885,32.6],[1890,34],[1895,33.3],[1900,36.8],[1905,39.7],[1910,43.5],[1915,46.2],[1920,50.2],[1925,52.6],[1930,54.3],[1935,54.3],[1940,59.1],[1945,62],[1950,61.61],[1951,61.92],[1952,62.51],[1953,63.04],[1954,63.52],[1955,63.94],[1956,64.3],[1957,64.61],[1958,64.86],[1959,65.07],[1960,65.23],[1961,65.35],[1962,65.44],[1963,65.52],[1964,65.6],[1965,65.68],[1966,65.8],[1967,65.95],[1968,66.13],[1969,66.35],[1970,66.61],[1971,66.89],[1972,67.18],[1973,67.48],[1974,67.77],[1975,68.06],[1976,68.35],[1977,68.64],[1978,68.94],[1979,69.24],[1980,69.53],[1981,69.8],[1982,70.05],[1983,70.27],[1984,70.47],[1985,70.65],[1986,70.81],[1987,70.98],[1988,71.16],[1989,71.35],[1990,71.56],[1991,71.78],[1992,72.01],[1993,72.23],[1994,72.46],[1995,72.68],[1996,72.9],[1997,73.12],[1998,73.34],[1999,73.55],[2000,73.77],[2001,73.97],[2002,74.18],[2003,74.38],[2004,74.58],[2005,74.77],[2006,74.96],[2007,75.15],[2008,75.33],[2009,75.52]]},{"name":"Aruba","region":"America","income":[[1800,575.86],[1820,575.86],[1913,1062.48],[1970,4223.84],[1971,4567.57],[1972,4939.76],[1973,5344.09],[1974,5785.94],[1975,6270.23],[1976,6803.64],[1977,7390.36],[1978,8026.34],[1979,8701.79],[1980,9409.56],[1981,10133.58],[1982,10874.91],[1983,11672.8],[1984,12589.72],[1985,13681.02],[1986,15016.43],[1987,17674.34],[1988,21252.41],[1989,23845.24],[1990,24316.97],[1991,25167.86],[1992,25120.55],[1993,25277.57],[1994,25830.48],[1995,25359.88],[1996,24966.43],[1997,26483.67],[1998,27963.77],[1999,27962.89],[2000,28711.44],[2001,27884.99],[2002,26467.87],[2003,25782.77],[2004,26972.7],[2005,26762.65],[2006,26482.97],[2007,26073.67],[2008,25351.09]],"population":[[1800,19286],[1820,19286],[1950,49712],[1951,51335],[1952,51955],[1953,52585],[1954,53220],[1955,53865],[1956,54516],[1957,55176],[1958,55843],[1959,56518],[1960,57203],[1961,57008],[1962,57681],[1963,58541],[1964,59091],[1965,59020],[1966,58632],[1967,58316],[1968,58149],[1969,58424],[1970,59039],[1971,59397],[1972,59461],[1973,59609],[1974,59555],[1975,59390],[1976,59337],[1977,59412],[1978,59481],[1979,59741],[1980,60266],[1981,60717],[1982,61569],[1983,62483],[1984,63337],[1985,64129],[1986,64817],[1987,65415],[1988,65922],[1989,66335],[1990,66653],[1991,66919],[1992,67174],[1993,67414],[1994,67636],[1995,67836],[1996,68057],[1997,68341],[1998,68683],[1999,69083],[2000,69539],[2001,70007],[2002,70441],[2003,70844],[2004,71218],[2005,71566],[2006,71891],[2007,72194],[2008,72480]],"lifeExpectancy":[[1950,58.43],[1951,58.97],[1952,60.01],[1953,60.98],[1954,61.87],[1955,62.68],[1956,63.42],[1957,64.09],[1958,64.68],[1959,65.21],[1960,65.68],[1961,66.09],[1962,66.47],[1963,66.81],[1964,67.14],[1965,67.46],[1966,67.79],[1967,68.12],[1968,68.46],[1969,68.81],[1970,69.16],[1971,69.52],[1972,69.87],[1973,70.21],[1974,70.53],[1975,70.85],[1976,71.15],[1977,71.45],[1978,71.75],[1979,72.03],[1980,72.3],[1981,72.55],[1982,72.76],[1983,72.94],[1984,73.08],[1985,73.18],[1986,73.26],[1987,73.33],[1988,73.38],[1989,73.42],[1990,73.47],[1991,73.5],[1992,73.53],[1993,73.54],[1994,73.55],[1995,73.56],[1996,73.56],[1997,73.57],[1998,73.59],[1999,73.63],[2000,73.68],[2001,73.76],[2002,73.86],[2003,73.98],[2004,74.12],[2005,74.28],[2006,74.44],[2007,74.61],[2008,74.77],[2009,74.92]]},{"name":"Barbados","region":"America","income":[[1800,1017.81],[1820,1017.81],[1913,1877.92],[1950,3245.07],[1960,5319.74],[1961,5711.59],[1962,6204.49],[1963,5863.17],[1964,6130.21],[1965,6806.04],[1966,7057.57],[1967,7788.54],[1968,8306.96],[1969,8904.4],[1970,9712.48],[1971,9814.38],[1972,9853.81],[1973,9990.79],[1974,11268.72],[1975,10983.92],[1976,11414.78],[1977,11817.36],[1978,12375.14],[1979,13301.46],[1980,13858.9],[1981,13504.66],[1982,12736.47],[1983,12679.08],[1984,13003.27],[1985,13020.58],[1986,13560.56],[1987,13783.21],[1988,14140.09],[1989,14528.02],[1990,13954.78],[1991,13293.9],[1992,12263.45],[1993,12299.76],[1994,12736.75],[1995,13009.36],[1996,13356.08],[1997,13901.91],[1998,14702.32],[1999,14710.96],[2000,14982.12],[2001,14533.64],[2002,14544.49],[2003,14779.73],[2004,15268.13],[2005,15837],[2006,16294.8],[2007,16803.95],[2008,16783.85],[2009,15846.77]],"population":[[1800,81729],[1820,81729],[1851,136000],[1861,153000],[1871,162000],[1881,172000],[1891,183000],[1901,196000],[1911,172000],[1921,157000],[1946,194000],[1950,210666],[1951,214729],[1952,217959],[1953,221303],[1954,225244],[1955,227255],[1956,225962],[1957,225569],[1958,227979],[1959,231394],[1960,232339],[1961,229597],[1962,228747],[1963,230738],[1964,233269],[1965,234980],[1966,236227],[1967,238224],[1968,239868],[1969,239321],[1970,238756],[1971,240606],[1972,242445],[1973,244127],[1974,245563],[1975,247147],[1976,248023],[1977,249169],[1978,250145],[1979,251145],[1980,251966],[1981,252376],[1982,253522],[1983,254918],[1984,256227],[1985,257446],[1986,258506],[1987,259428],[1988,260313],[1989,261441],[1990,262624],[1991,263693],[1992,264925],[1993,265977],[1994,266906],[1995,267907],[1996,268944],[1997,270096],[1998,271232],[1999,272364],[2000,273483],[2001,274584],[2002,275673],[2003,276761],[2004,277816],[2005,278870],[2006,279912],[2007,280946],[2008,281968]],"lifeExpectancy":[[1950,54.59],[1951,55.29],[1952,56.65],[1953,57.92],[1954,59.11],[1955,60.22],[1956,61.24],[1957,62.18],[1958,63.04],[1959,63.81],[1960,64.5],[1961,65.11],[1962,65.64],[1963,66.1],[1964,66.5],[1965,66.87],[1966,67.2],[1967,67.53],[1968,67.85],[1969,68.18],[1970,68.52],[1971,68.88],[1972,69.25],[1973,69.62],[1974,69.99],[1975,70.36],[1976,70.73],[1977,71.09],[1978,71.43],[1979,71.77],[1980,72.09],[1981,72.4],[1982,72.7],[1983,73],[1984,73.29],[1985,73.56],[1986,73.83],[1987,74.07],[1988,74.29],[1989,74.49],[1990,74.66],[1991,74.79],[1992,74.88],[1993,74.94],[1994,74.98],[1995,75.01],[1996,75.04],[1997,75.09],[1998,75.16],[1999,75.27],[2000,75.41],[2001,75.59],[2002,75.8],[2003,76.03],[2004,76.28],[2005,76.53],[2006,76.79],[2007,77.04],[2008,77.28],[2009,77.51]]},{"name":"Belize","region":"America","income":[[1800,542.97],[1820,542.97],[1913,1001.8],[1950,1731.13],[1960,1868.46],[1961,1893.4],[1962,1916.32],[1963,1941.29],[1964,1972.05],[1965,2008.96],[1966,2049.49],[1967,2099.16],[1968,2206.04],[1969,2275.3],[1970,2345.4],[1971,2403.23],[1972,2616.7],[1973,2724.54],[1974,3051.15],[1975,3105.45],[1976,3039.69],[1977,3158.69],[1978,3318.66],[1979,3472.14],[1980,3893.63],[1981,3841.46],[1982,3732.09],[1983,3580.48],[1984,3537.98],[1985,3484.98],[1986,3554.57],[1987,3844.93],[1988,4092.66],[1989,4542.52],[1990,4871.11],[1991,5298.35],[1992,5780.69],[1993,5958.65],[1994,5806.45],[1995,5677.1],[1996,5632.53],[1997,5631.5],[1998,5632.34],[1999,5991.97],[2000,6545.45],[2001,6669.07],[2002,6799.54],[2003,7203.58],[2004,7300.54],[2005,7290],[2006,7392.78],[2007,7250.58],[2008,7297.77],[2009,6998.08]],"population":[[1800,25526],[1820,25526],[1861,26000],[1871,25000],[1881,27000],[1891,31000],[1901,37000],[1911,40000],[1921,45000],[1931,51000],[1946,59000],[1950,65797],[1951,66759],[1952,69932],[1953,72143],[1954,74408],[1955,76892],[1956,79651],[1957,82461],[1958,85394],[1959,88641],[1960,91863],[1961,94685],[1962,97594],[1963,100712],[1964,103902],[1965,106965],[1966,110115],[1967,113265],[1968,116293],[1969,119183],[1970,122070],[1971,124890],[1972,127661],[1973,130375],[1974,133027],[1975,135611],[1976,138135],[1977,140578],[1978,142937],[1979,145205],[1980,144416],[1981,149191],[1982,153277],[1983,156825],[1984,160800],[1985,165530],[1986,171219],[1987,176347],[1988,181390],[1989,186418],[1990,190847],[1991,195733],[1992,200798],[1993,206055],[1994,211500],[1995,217120],[1996,222908],[1997,228884],[1998,235030],[1999,241369],[2000,247887],[2001,254497],[2002,261138],[2003,267787],[2004,274435],[2005,281084],[2006,287730],[2007,294385],[2008,301022]],"lifeExpectancy":[[1950,56.67],[1951,56.92],[1952,57.42],[1953,57.93],[1954,58.43],[1955,58.93],[1956,59.43],[1957,59.93],[1958,60.43],[1959,60.93],[1960,61.43],[1961,61.93],[1962,62.43],[1963,62.93],[1964,63.44],[1965,63.94],[1966,64.44],[1967,64.94],[1968,65.44],[1969,65.93],[1970,66.42],[1971,66.9],[1972,67.37],[1973,67.83],[1974,68.29],[1975,68.73],[1976,69.16],[1977,69.57],[1978,69.97],[1979,70.35],[1980,70.69],[1981,71],[1982,71.27],[1983,71.5],[1984,71.69],[1985,71.84],[1986,71.94],[1987,72.02],[1988,72.08],[1989,72.13],[1990,72.19],[1991,72.27],[1992,72.39],[1993,72.54],[1994,72.72],[1995,72.94],[1996,73.18],[1997,73.42],[1998,73.66],[1999,73.89],[2000,74.11],[2001,74.34],[2002,74.59],[2003,74.85],[2004,75.14],[2005,75.44],[2006,75.74],[2007,76.04],[2008,76.33],[2009,76.6]]},{"name":"Bolivia","region":"America","income":[[1800,695.05],[1820,695.05],[1945,2227.96],[1946,2241.79],[1947,2254.85],[1948,2277.13],[1949,2298.47],[1950,2530.6],[1951,2653.57],[1952,2677.33],[1953,2373.25],[1954,2371.67],[1955,2443.66],[1956,2249.19],[1957,2127.69],[1958,2130.5],[1959,2076.82],[1960,2117.78],[1961,2113.49],[1962,2180.97],[1963,2268.27],[1964,2323.02],[1965,2380.76],[1966,2493.24],[1967,2586.89],[1968,2740.72],[1969,2794.62],[1970,2869.46],[1971,2906.44],[1972,2980.33],[1973,3107.44],[1974,3188.22],[1975,3317.13],[1976,3490],[1977,3548.1],[1978,3578.97],[1979,3496.02],[1980,3391.07],[1981,3358.19],[1982,3156.51],[1983,2965.56],[1984,2945.48],[1985,2875.32],[1986,2734.54],[1987,2753.69],[1988,2800.94],[1989,2819.34],[1990,2897.28],[1991,2982.23],[1992,2961.7],[1993,3015.14],[1994,3089.45],[1995,3164.52],[1996,3234.03],[1997,3326.14],[1998,3429.73],[1999,3377.57],[2000,3394.71],[2001,3390.16],[2002,3413.26],[2003,3450.76],[2004,3528.67],[2005,3618],[2006,3712.77],[2007,3803.13],[2008,3956.4],[2009,4007.16]],"population":[[1800,1100000],[1820,1100000],[1850,1374000],[1870,1495000],[1900,1696000],[1901,1710000],[1902,1723000],[1903,1737000],[1904,1751000],[1905,1765000],[1906,1779000],[1907,1793000],[1908,1808000],[1909,1822000],[1910,1837000],[1911,1851000],[1912,1866000],[1913,1881000],[1914,1915000],[1915,1951000],[1916,1986000],[1917,2023000],[1918,2060000],[1919,2098000],[1920,2136000],[1921,2161000],[1922,2186000],[1923,2212000],[1924,2237000],[1925,2263000],[1926,2289000],[1927,2316000],[1928,2343000],[1929,2370000],[1930,2397000],[1931,2425000],[1932,2453000],[1933,2482000],[1934,2511000],[1935,2540000],[1936,2569000],[1937,2599000],[1938,2629000],[1939,2659000],[1940,2690000],[1941,2721000],[1942,2753000],[1943,2785000],[1944,2817000],[1945,2850000],[1946,2883000],[1947,2916000],[1948,2950000],[1949,2984000],[1950,2766028],[1951,2823667],[1952,2883315],[1953,2944968],[1954,3008635],[1955,3074311],[1956,3141998],[1957,3211738],[1958,3283613],[1959,3357701],[1960,3434073],[1961,3512782],[1962,3593918],[1963,3677637],[1964,3764067],[1965,3853315],[1966,3945474],[1967,4040665],[1968,4139069],[1969,4240872],[1970,4346218],[1971,4454684],[1972,4565872],[1973,4679923],[1974,4796240],[1975,4914316],[1976,4955744],[1977,5079716],[1978,5204622],[1979,5326981],[1980,5441298],[1981,5545224],[1982,5642224],[1983,5737434],[1984,5834293],[1985,5934935],[1986,6041350],[1987,6156369],[1988,6283164],[1989,6423135],[1990,6573900],[1991,6731484],[1992,6893451],[1993,7055495],[1994,7216538],[1995,7376582],[1996,7535615],[1997,7693188],[1998,7848703],[1999,8001930],[2000,8152620],[2001,8300463],[2002,8445134],[2003,8586443],[2004,8724156],[2005,8857870],[2006,8989046],[2007,9119152],[2008,9247816]],"lifeExpectancy":[[1800,33],[1925,33],[1940,33],[1950,39.87],[1951,40.01],[1952,40.29],[1953,40.58],[1954,40.87],[1955,41.16],[1956,41.46],[1957,41.76],[1958,42.06],[1959,42.36],[1960,42.67],[1961,42.98],[1962,43.29],[1963,43.61],[1964,43.92],[1965,44.24],[1966,44.55],[1967,44.84],[1968,45.14],[1969,45.44],[1970,45.77],[1971,46.14],[1972,46.56],[1973,47.05],[1974,47.61],[1975,48.23],[1976,48.92],[1977,49.65],[1978,50.41],[1979,51.19],[1980,51.96],[1981,52.74],[1982,53.51],[1983,54.26],[1984,54.99],[1985,55.69],[1986,56.37],[1987,57.01],[1988,57.63],[1989,58.22],[1990,58.78],[1991,59.31],[1992,59.8],[1993,60.25],[1994,60.68],[1995,61.09],[1996,61.48],[1997,61.86],[1998,62.22],[1999,62.59],[2000,62.95],[2001,63.31],[2002,63.67],[2003,64.01],[2004,64.35],[2005,64.69],[2006,65.02],[2007,65.35],[2008,65.68],[2009,66.01]]},{"name":"Brazil","region":"America","income":[[1800,509.2],[1820,539.02],[1850,571.9],[1851,611.36],[1852,594.85],[1853,558.23],[1854,539.18],[1855,544.31],[1856,564.09],[1857,603.65],[1858,642.47],[1859,637.34],[1860,654.19],[1861,648.33],[1862,617.56],[1863,631.48],[1864,640.27],[1865,687.89],[1866,712.8],[1867,772.14],[1868,772.14],[1869,772.14],[1870,715.73],[1871,715.73],[1872,740.64],[1873,718.66],[1874,729.65],[1875,740.64],[1876,712.8],[1877,693.02],[1878,726.72],[1879,732.58],[1880,698.88],[1881,704.74],[1882,721.59],[1883,701.81],[1884,749.43],[1885,695.95],[1886,718.66],[1887,671.04],[1888,645.4],[1889,654.19],[1890,715.73],[1891,760.42],[1892,659.32],[1893,561.16],[1894,561.16],[1895,665.18],[1896,603.65],[1897,594.85],[1898,608.77],[1899,597.78],[1900,575.07],[1901,648.48],[1902,629.74],[1903,630.97],[1904,622.59],[1905,632.64],[1906,696.97],[1907,691.3],[1908,654.7],[1909,705.48],[1910,711.35],[1911,737.66],[1912,770.7],[1913,778.23],[1914,750.11],[1915,738.09],[1916,729.69],[1917,783.66],[1918,749.02],[1919,792.56],[1920,875.52],[1921,874.14],[1922,925.6],[1923,984.14],[1924,980.08],[1925,959.96],[1926,989.1],[1927,1076.22],[1928,1177.58],[1929,1164.62],[1930,1118.34],[1931,1056.7],[1932,1081.05],[1933,1157.13],[1934,1237.46],[1935,1250.24],[1936,1374.69],[1937,1410.23],[1938,1444.01],[1939,1449.77],[1940,1406.39],[1941,1443.76],[1942,1369.92],[1943,1457.02],[1944,1538.99],[1945,1553.89],[1946,1695.26],[1947,1694.1],[1948,1813.51],[1949,1903.64],[1950,1979.81],[1951,2020.23],[1952,2108.94],[1953,2145.84],[1954,2249.2],[1955,2379.48],[1956,2376.5],[1957,2487.37],[1958,2680.43],[1959,2861.75],[1960,3044.13],[1961,3214.19],[1962,3336.59],[1963,3260.25],[1964,3277.01],[1965,3261.05],[1966,3385.4],[1967,3429.86],[1968,3666.98],[1969,3909.48],[1970,4184.07],[1971,4554.85],[1972,4985.71],[1973,5558.5],[1974,5873.83],[1975,6031.57],[1976,6500.65],[1977,6660.12],[1978,6825.89],[1979,7117.96],[1980,7623.18],[1981,7128.81],[1982,7030.84],[1983,6672.28],[1984,6890.25],[1985,7286.96],[1986,7685.06],[1987,7807.1],[1988,7657.32],[1989,7763.04],[1990,7136.93],[1991,7097.83],[1992,6950.28],[1993,7188.19],[1994,7503.67],[1995,7713.35],[1996,7810.2],[1997,7957.98],[1998,7860.55],[1999,7818.96],[2000,8056.06],[2001,8022.52],[2002,8131.21],[2003,8110.41],[2004,8461.5],[2005,8596],[2006,8869.55],[2007,9305.66],[2008,9682],[2009,9569.78]],"population":[[1820,4507000],[1850,7234000],[1870,9797000],[1871,9980000],[1872,10167000],[1873,10358000],[1874,10552000],[1875,10749000],[1876,10951000],[1877,11156000],[1878,11365000],[1879,11578000],[1880,11794000],[1881,12015000],[1882,12240000],[1883,12470000],[1884,12703000],[1885,12941000],[1886,13183000],[1887,13430000],[1888,13682000],[1889,13938000],[1890,14199000],[1891,14539000],[1892,14886000],[1893,15242000],[1894,15607000],[1895,15980000],[1896,16362000],[1897,16753000],[1898,17154000],[1899,17564000],[1900,17984000],[1901,18392000],[1902,18782000],[1903,19180000],[1904,19587000],[1905,20003000],[1906,20427000],[1907,20860000],[1908,21303000],[1909,21754000],[1910,22216000],[1911,22687000],[1912,23168000],[1913,23660000],[1914,24161000],[1915,24674000],[1916,25197000],[1917,25732000],[1918,26277000],[1919,26835000],[1920,27404000],[1921,27969000],[1922,28542000],[1923,29126000],[1924,29723000],[1925,30332000],[1926,30953000],[1927,31587000],[1928,32234000],[1929,32894000],[1930,33568000],[1931,34256000],[1932,34957000],[1933,35673000],[1934,36404000],[1935,37150000],[1936,37911000],[1937,38687000],[1938,39480000],[1939,40289000],[1940,41114000],[1941,42069000],[1942,43069000],[1943,44093000],[1944,45141000],[1945,46215000],[1946,47313000],[1947,48438000],[1948,49590000],[1949,50769000],[1950,53443075],[1951,54995532],[1952,56602560],[1953,58266357],[1954,59989219],[1955,61773546],[1956,63631992],[1957,65551171],[1958,67533213],[1959,69580328],[1960,71694810],[1961,73832902],[1962,76039390],[1963,78316598],[1964,80666939],[1965,83092908],[1966,85557441],[1967,88049823],[1968,90569084],[1969,93114241],[1970,95684297],[1971,98245467],[1972,100840058],[1973,103469438],[1974,106131448],[1975,108823732],[1976,111545124],[1977,114313951],[1978,117146603],[1979,120040282],[1980,122958132],[1981,125929730],[1982,128962939],[1983,131891729],[1984,134626216],[1985,137302933],[1986,140111725],[1987,142938076],[1988,145782100],[1989,148567499],[1990,151083809],[1991,153511587],[1992,155975974],[1993,158471338],[1994,160994257],[1995,163542501],[1996,166073876],[1997,168546719],[1998,170956177],[1999,173293681],[2000,175552771],[2001,177752913],[2002,179914212],[2003,182032604],[2004,184101109],[2005,186112794],[2006,188078227],[2007,190010647],[2008,191908598]],"lifeExpectancy":[[1800,32],[1920,31.98],[1930,32],[1940,36.64],[1945,42.3],[1950,49.97],[1951,50.2],[1952,50.67],[1953,51.14],[1954,51.61],[1955,52.09],[1956,52.58],[1957,53.06],[1958,53.55],[1959,54.03],[1960,54.51],[1961,54.97],[1962,55.43],[1963,55.86],[1964,56.28],[1965,56.69],[1966,57.08],[1967,57.45],[1968,57.83],[1969,58.2],[1970,58.57],[1971,58.94],[1972,59.32],[1973,59.71],[1974,60.1],[1975,60.49],[1976,60.89],[1977,61.29],[1978,61.68],[1979,62.07],[1980,62.46],[1981,62.84],[1982,63.22],[1983,63.6],[1984,63.98],[1985,64.36],[1986,64.74],[1987,65.12],[1988,65.5],[1989,65.88],[1990,66.26],[1991,66.65],[1992,67.06],[1993,67.47],[1994,67.88],[1995,68.3],[1996,68.7],[1997,69.1],[1998,69.48],[1999,69.85],[2000,70.19],[2001,70.51],[2002,70.82],[2003,71.11],[2004,71.4],[2005,71.67],[2006,71.93],[2007,72.19],[2008,72.44],[2009,72.68]]},{"name":"Canada","region":"America","income":[[1800,1159.5],[1820,1312.47],[1830,1451.18],[1840,1686.35],[1850,1929.46],[1860,2105.05],[1870,2459.06],[1871,2546.14],[1872,2474.56],[1873,2672.9],[1874,2690.08],[1875,2588.86],[1876,2381.27],[1877,2506.83],[1878,2375.88],[1879,2561.68],[1880,2635.18],[1881,2959.8],[1882,3060.65],[1883,3033.5],[1884,3237.49],[1885,3008.03],[1886,3011.56],[1887,3076.36],[1888,3263.56],[1889,3249.51],[1890,3451.46],[1891,3495.5],[1892,3440.52],[1893,3386.62],[1894,3512.53],[1895,3440.7],[1896,3321],[1897,3644.66],[1898,3749.07],[1899,4056.95],[1900,4224.78],[1901,4493.99],[1902,4833.78],[1903,4837.7],[1904,4759.25],[1905,5168.85],[1906,5581.55],[1907,5623.11],[1908,5183.71],[1909,5586.47],[1910,5900.16],[1911,6113.16],[1912,6352.01],[1913,6453.07],[1914,5841.42],[1915,6142.69],[1916,6742.36],[1917,6966.52],[1918,6444.11],[1919,5832.8],[1920,5603.71],[1921,4871.63],[1922,5504.55],[1923,5769.84],[1924,5771.38],[1925,6298.53],[1926,6526.05],[1927,7033.87],[1928,7504.92],[1929,7350.88],[1930,6981.06],[1931,5810.09],[1932,5327.95],[1933,4891.07],[1934,5356.36],[1935,5733.08],[1936,5984.97],[1937,6491.73],[1938,6596.94],[1939,6919.43],[1940,7790.3],[1941,8780.77],[1942,10206.71],[1943,10539.59],[1944,10800.51],[1945,10351.21],[1946,10058.5],[1947,10286.28],[1948,10253.07],[1949,10251.27],[1950,10581.27],[1951,10932.47],[1952,11367.16],[1953,11586.61],[1954,11173.26],[1955,11901.51],[1956,12555.55],[1957,12489.95],[1958,12384.41],[1959,12590.8],[1960,12701.48],[1961,12817.92],[1962,13462.49],[1963,13882.56],[1964,14510.9],[1965,15198.11],[1966,15884.84],[1967,16076.59],[1968,16658.21],[1969,17286.99],[1970,17487.46],[1971,18229.64],[1972,18970.57],[1973,20081.31],[1974,20613.59],[1975,20775.51],[1976,21626.09],[1977,22090.88],[1978,22754.83],[1979,23465.83],[1980,23473.9],[1981,23904.53],[1982,22898.79],[1983,23329.8],[1984,24431.85],[1985,25514.79],[1986,25921.17],[1987,26626.52],[1988,27562.41],[1989,27729.9],[1990,27387.27],[1991,26491.6],[1992,26342.88],[1993,26590.4],[1994,27543.91],[1995,27969.67],[1996,28074.84],[1997,28954.93],[1998,29837.46],[1999,31154.86],[2000,32448.61],[2001,32570.57],[2002,33328.97],[2003,33635.25],[2004,34346.97],[2005,35078],[2006,35714.67],[2007,36225.06],[2008,35950.08],[2009,34569.63]],"population":[[1820,816000],[1830,1169000],[1840,1697000],[1850,2485000],[1860,3369000],[1870,3781000],[1871,3801000],[1872,3870000],[1873,3943000],[1874,4012000],[1875,4071000],[1876,4128000],[1877,4184000],[1878,4244000],[1879,4312000],[1880,4384000],[1881,4451000],[1882,4503000],[1883,4560000],[1884,4617000],[1885,4666000],[1886,4711000],[1887,4760000],[1888,4813000],[1889,4865000],[1890,4918000],[1891,4972000],[1892,5022000],[1893,5072000],[1894,5121000],[1895,5169000],[1896,5218000],[1897,5269000],[1898,5325000],[1899,5383000],[1900,5457000],[1901,5536000],[1902,5650000],[1903,5813000],[1904,5994000],[1905,6166000],[1906,6282000],[1907,6596000],[1908,6813000],[1909,6993000],[1910,7188000],[1911,7410000],[1912,7602000],[1913,7852000],[1914,8093000],[1915,8191000],[1916,8214000],[1917,8277000],[1918,8374000],[1919,8548000],[1920,8798000],[1921,9028000],[1922,9159000],[1923,9256000],[1924,9394000],[1925,9549000],[1926,9713000],[1927,9905000],[1928,10107000],[1929,10305000],[1930,10488000],[1931,10657000],[1932,10794000],[1933,10919000],[1934,11030000],[1935,11136000],[1936,11243000],[1937,11341000],[1938,11452000],[1939,11570000],[1940,11688000],[1941,11818000],[1942,11969000],[1943,12115000],[1944,12268000],[1945,12404000],[1946,12634000],[1947,12901000],[1948,13180000],[1949,13469000],[1950,14011422],[1951,14330675],[1952,14785584],[1953,15183375],[1954,15636245],[1955,16050356],[1956,16445087],[1957,17010154],[1958,17462004],[1959,17872034],[1960,18266765],[1961,18634977],[1962,18985849],[1963,19342841],[1964,19711053],[1965,20071104],[1966,20448496],[1967,20819767],[1968,21143100],[1969,21448073],[1970,21749986],[1971,22026400],[1972,22284500],[1973,22559500],[1974,22874700],[1975,23209200],[1976,23517500],[1977,23796400],[1978,24036300],[1979,24276900],[1980,24593300],[1981,24900000],[1982,25201900],[1983,25456300],[1984,25701800],[1985,25941600],[1986,26203800],[1987,26549700],[1988,26894800],[1989,27379300],[1990,27790600],[1991,28117600],[1992,28523502],[1993,28920644],[1994,29262472],[1995,29619002],[1996,29983162],[1997,30305843],[1998,30628924],[1999,30957019],[2000,31278097],[2001,31592805],[2002,31902268],[2003,32207113],[2004,32507874],[2005,32805041],[2006,33098932],[2007,33390141],[2008,33679263]],"lifeExpectancy":[[1800,39],[1831,39.05],[1841,40.32],[1851,41.06],[1861,41.6],[1871,42.56],[1881,44.73],[1891,45.17],[1901,48.63],[1911,52.51],[1921,57.02],[1922,57.02],[1923,57.02],[1924,58.83],[1925,59.31],[1926,57.99],[1927,58.68],[1928,58.57],[1929,57.97],[1930,58.95],[1931,60.36],[1932,61.43],[1933,62.36],[1934,62.77],[1935,62.49],[1936,62.72],[1937,61.35],[1938,63.31],[1939,63.74],[1940,64.01],[1941,63.76],[1942,64.7],[1943,64.61],[1944,65.35],[1945,66.33],[1946,66.53],[1947,66.78],[1948,67.33],[1949,67.65],[1950,68.28],[1951,68.55],[1952,68.75],[1953,69.13],[1954,69.99],[1955,70.05],[1956,70.04],[1957,69.96],[1958,70.62],[1959,70.66],[1960,71.04],[1961,71.27],[1962,71.3],[1963,71.31],[1964,71.69],[1965,71.79],[1966,71.92],[1967,72.13],[1968,72.29],[1969,72.45],[1970,72.65],[1971,72.98],[1972,72.88],[1973,73.11],[1974,73.19],[1975,73.49],[1976,73.92],[1977,74.21],[1978,74.54],[1979,74.9],[1980,75.14],[1981,75.55],[1982,75.76],[1983,76.13],[1984,76.43],[1985,76.41],[1986,76.56],[1987,76.86],[1988,76.93],[1989,77.2],[1990,77.51],[1991,77.69],[1992,77.95],[1993,77.83],[1994,78.01],[1995,78.13],[1996,78.4],[1997,78.61],[1998,78.83],[1999,79.05],[2000,79.41],[2001,79.65],[2002,79.77],[2003,79.95],[2004,80.25],[2005,80.36],[2006,80.78],[2007,80.59],[2008,80.74],[2009,80.89]]},{"name":"Chile","region":"America","income":[[1800,702.1],[1820,702.1],[1821,671.26],[1822,674.88],[1823,672.16],[1824,655.85],[1825,675.33],[1826,680.4],[1827,683.34],[1828,678.3],[1829,682.26],[1830,671.74],[1831,670.8],[1832,679.53],[1833,676.85],[1834,691.32],[1835,706.81],[1836,701.53],[1837,718.11],[1838,721.22],[1839,722.49],[1840,759.86],[1841,761.15],[1842,769.85],[1843,784.83],[1844,787.67],[1845,802.73],[1846,821],[1847,829.82],[1848,854.98],[1849,906.14],[1850,942.87],[1851,959.04],[1852,977.78],[1853,946.81],[1854,964.38],[1855,998.49],[1856,1000.39],[1857,1022.86],[1858,1057.28],[1859,1081.1],[1860,1106.69],[1861,1096.14],[1862,1081.49],[1863,1111.61],[1864,1158.9],[1865,1186.33],[1866,1199.8],[1867,1141.19],[1868,1186.1],[1869,1291.65],[1870,1305.81],[1871,1288.95],[1872,1364.89],[1873,1433.73],[1874,1353.28],[1875,1443.33],[1876,1406.65],[1877,1341.24],[1878,1401.5],[1879,1590.66],[1880,1761.15],[1881,1796.41],[1882,1917.94],[1883,1902.05],[1884,1891.54],[1885,1809.21],[1886,1859.31],[1887,1961.87],[1888,1858.47],[1889,1880.77],[1890,1990.16],[1891,2124.06],[1892,2054.33],[1893,2128.49],[1894,2066.71],[1895,2183.84],[1896,2168.76],[1897,2094.59],[1898,2319.9],[1899,2306.31],[1900,2220.49],[1901,2249.32],[1902,2320.22],[1903,2164.58],[1904,2315.07],[1905,2286.48],[1906,2437.44],[1907,2537.55],[1908,2775.6],[1909,2758.56],[1910,3036.29],[1911,2921.34],[1912,3003.54],[1913,3024.38],[1914,2526.96],[1915,2417.9],[1916,2930.1],[1917,2958.57],[1918,2961.16],[1919,2510.4],[1920,2801.57],[1921,2398.38],[1922,2455.04],[1923,2919.39],[1924,3098.6],[1925,3190.46],[1926,2884.86],[1927,2793.06],[1928,3372.55],[1929,3497.1],[1930,2893.24],[1931,2244.42],[1932,1866.7],[1933,2263.32],[1934,2687.51],[1935,2794.54],[1936,2881.79],[1937,3219.61],[1938,3199.01],[1939,3207.47],[1940,3275.24],[1941,3178.6],[1942,3264.58],[1943,3295.38],[1944,3295.07],[1945,3513.35],[1946,3743.95],[1947,3279.23],[1948,3756.64],[1949,3611.84],[1950,3714],[1951,3775.99],[1952,3939.98],[1953,4161.72],[1954,3954.37],[1955,4023.33],[1956,4004.52],[1957,4315.62],[1958,4444.52],[1959,4090.77],[1960,4321.77],[1961,4418.96],[1962,4519.09],[1963,4695.23],[1964,4694.22],[1965,4632.34],[1966,5044.56],[1967,5106.65],[1968,5189.48],[1969,5283.39],[1970,5294.52],[1971,5664.81],[1972,5494.02],[1973,5094.38],[1974,5052.19],[1975,4324.83],[1976,4399.45],[1977,4756.76],[1978,5071.09],[1979,5409.11],[1980,5748.92],[1981,6003.99],[1982,5095.67],[1983,4868.24],[1984,5071.32],[1985,5090.75],[1986,5290.96],[1987,5547.06],[1988,5850.79],[1989,6359.08],[1990,6478.75],[1991,6877.27],[1992,7596.13],[1993,8000.88],[1994,8501.17],[1995,9082.42],[1996,9620.05],[1997,10118.05],[1998,10310.03],[1999,10105.61],[2000,10435.17],[2001,10665.2],[2002,10778.78],[2003,11082.55],[2004,11649.71],[2005,12262],[2006,12677.5],[2007,13124.6],[2008,13474.41],[2009,13087.38]],"population":[[1800,771447],[1820,771447],[1821,789144],[1822,807304],[1823,825890],[1824,844866],[1825,864198],[1826,883855],[1827,903807],[1828,924027],[1829,944490],[1830,965173],[1831,986056],[1832,1007120],[1833,1028350],[1834,1049733],[1835,1071256],[1836,1092912],[1837,1114694],[1838,1136597],[1839,1158619],[1840,1180761],[1841,1203023],[1842,1225410],[1843,1247926],[1844,1270578],[1845,1293375],[1846,1316325],[1847,1339439],[1848,1362729],[1849,1386207],[1850,1409885],[1851,1433777],[1852,1457897],[1853,1482258],[1854,1506873],[1855,1531758],[1856,1556924],[1857,1582386],[1858,1608154],[1859,1634242],[1860,1660659],[1861,1687416],[1862,1714521],[1863,1741983],[1864,1769808],[1865,1798001],[1866,1826566],[1867,1855505],[1868,1884819],[1869,1914507],[1870,1944569],[1871,1974998],[1872,2005790],[1873,2036939],[1874,2068435],[1875,2100268],[1876,2132427],[1877,2164899],[1878,2197670],[1879,2230723],[1880,2264042],[1881,2297611],[1882,2331409],[1883,2365419],[1884,2399621],[1885,2433995],[1886,2468522],[1887,2503181],[1888,2537954],[1889,2572823],[1890,2607769],[1891,2642778],[1892,2677834],[1893,2712925],[1894,2748040],[1895,2783171],[1896,2818312],[1897,2853462],[1898,2888620],[1899,2923792],[1900,2958986],[1901,2994214],[1902,3029494],[1903,3064845],[1904,3100295],[1905,3135874],[1906,3171619],[1907,3207571],[1908,3243777],[1909,3280289],[1910,3317166],[1911,3354469],[1912,3392269],[1913,3430640],[1914,3469662],[1915,3509420],[1916,3550005],[1917,3591512],[1918,3634043],[1919,3677702],[1920,3722598],[1921,3768846],[1922,3816561],[1923,3865863],[1924,3916875],[1925,3969721],[1926,4024523],[1927,4081406],[1928,4140494],[1929,4201905],[1930,4265756],[1931,4332156],[1932,4401207],[1933,4473001],[1934,4547615],[1935,4625112],[1936,4705534],[1937,4788901],[1938,4875203],[1939,4964398],[1940,5056404],[1941,5151095],[1942,5248293],[1943,5347758],[1944,5449185],[1945,5552190],[1946,5656303],[1947,5760959],[1948,5865486],[1949,5969096],[1950,6090833],[1951,6251933],[1952,6377619],[1953,6492774],[1954,6612138],[1955,6743269],[1956,6888843],[1957,7048426],[1958,7219783],[1959,7399842],[1960,7585349],[1961,7773314],[1962,7961258],[1963,8147349],[1964,8330423],[1965,8509950],[1966,8685954],[1967,8858908],[1968,9029621],[1969,9199122],[1970,9368558],[1971,9540298],[1972,9717524],[1973,9896635],[1974,10076544],[1975,10251542],[1976,10432214],[1977,10599793],[1978,10759823],[1979,10922822],[1980,11093718],[1981,11282304],[1982,11487112],[1983,11686845],[1984,11879139],[1985,12066701],[1986,12259840],[1987,12463354],[1988,12677524],[1989,12901157],[1990,13127760],[1991,13352503],[1992,13572994],[1993,13788271],[1994,14000060],[1995,14205449],[1996,14404243],[1997,14599929],[1998,14790995],[1999,14975383],[2000,15153450],[2001,15327316],[2002,15497046],[2003,15662645],[2004,15823957],[2005,15980912],[2006,16134219],[2007,16284741],[2008,16432536]],"lifeExpectancy":[[1800,32],[1902,32],[1907,30.5],[1912,31.9],[1917,32.2],[1922,31.6],[1927,37],[1932,38.7],[1937,39.1],[1942,44],[1947,47.9],[1950,54.34],[1951,54.45],[1952,54.67],[1953,54.91],[1954,55.16],[1955,55.43],[1956,55.72],[1957,56.02],[1958,56.33],[1959,56.67],[1960,57.03],[1961,57.42],[1962,57.83],[1963,58.28],[1964,58.76],[1965,59.26],[1966,59.78],[1967,60.32],[1968,60.87],[1969,61.44],[1970,62.02],[1971,62.63],[1972,63.27],[1973,63.93],[1974,64.62],[1975,65.34],[1976,66.08],[1977,66.84],[1978,67.6],[1979,68.35],[1980,69.07],[1981,69.74],[1982,70.36],[1983,70.91],[1984,71.4],[1985,71.83],[1986,72.22],[1987,72.57],[1988,72.91],[1989,73.24],[1990,73.56],[1991,73.87],[1992,74.56],[1993,74.64],[1994,75.12],[1995,75.04],[1996,75.36],[1997,75.93],[1998,76.05],[1999,76.25],[2000,77.01],[2001,76.86],[2002,77.42],[2003,77.48],[2004,77.53],[2005,77.93],[2006,78.34],[2007,78.45],[2008,78.56],[2009,78.67]]},{"name":"Colombia","region":"America","income":[[1800,522.98],[1820,522.98],[1905,643.11],[1906,648.17],[1907,677.81],[1908,702],[1909,724.72],[1910,751.11],[1911,772.97],[1912,795.3],[1913,813.77],[1914,823.55],[1915,840.3],[1916,861.89],[1917,874.93],[1918,900.89],[1919,952.4],[1920,992.81],[1921,1024.24],[1922,1067.09],[1923,1107.43],[1924,1141.8],[1925,1173.69],[1926,1255.5],[1927,1336],[1928,1399.43],[1929,1413.64],[1930,1384.68],[1931,1345.95],[1932,1419.21],[1933,1482.01],[1934,1557.56],[1935,1577.06],[1936,1641.72],[1937,1647.76],[1938,1735.24],[1939,1795.23],[1940,1786.07],[1941,1768.32],[1942,1724.65],[1943,1685.56],[1944,1754.34],[1945,1789.64],[1946,1913.78],[1947,1936.98],[1948,1940.11],[1949,2057.58],[1950,2087.95],[1951,2079.14],[1952,2144.12],[1953,2184.17],[1954,2270.06],[1955,2286.56],[1956,2321.02],[1957,2323.81],[1958,2292.18],[1959,2381.6],[1960,2399.03],[1961,2443.57],[1962,2492.35],[1963,2493.77],[1964,2566.86],[1965,2591.01],[1966,2657.98],[1967,2678.73],[1968,2770.65],[1969,2871.63],[1970,2987.81],[1971,3095.9],[1972,3264.66],[1973,3415.45],[1974,3557.45],[1975,3587.95],[1976,3706.3],[1977,3815.81],[1978,4095.24],[1979,4263.25],[1980,4379.58],[1981,4424.36],[1982,4397.58],[1983,4406.32],[1984,4470.55],[1985,4533.92],[1986,4719.37],[1987,4903.22],[1988,5046.81],[1989,5145.39],[1990,5302.34],[1991,5321.6],[1992,5444.65],[1993,5645.09],[1994,5823.7],[1995,6013.41],[1996,6022.65],[1997,6117.36],[1998,6041.41],[1999,5680.88],[2000,5749.55],[2001,5738],[2002,5755.26],[2003,5885.52],[2004,6080.32],[2005,6306],[2006,6663.54],[2007,7081.42],[2008,7168.15],[2009,7090.69]],"population":[[1800,1206000],[1820,1206000],[1850,2065000],[1870,2392000],[1890,3369000],[1900,3998000],[1901,4079000],[1902,4162000],[1903,4247000],[1904,4334000],[1905,4422000],[1906,4512000],[1907,4604000],[1908,4697000],[1909,4793000],[1910,4890000],[1911,4990000],[1912,5091000],[1913,5195000],[1914,5330000],[1915,5468000],[1916,5609000],[1917,5754000],[1918,5903000],[1919,6056000],[1920,6213000],[1921,6374000],[1922,6539000],[1923,6709000],[1924,6882000],[1925,7061000],[1926,7243000],[1927,7431000],[1928,7624000],[1929,7821000],[1930,7914000],[1931,8009000],[1932,8104000],[1933,8201000],[1934,8299000],[1935,8398000],[1936,8498000],[1937,8599000],[1938,8702000],[1939,8935000],[1940,9174000],[1941,9419000],[1942,9671000],[1943,9930000],[1944,10196000],[1945,10469000],[1946,10749000],[1947,11036000],[1948,11332000],[1949,11635000],[1950,11591658],[1951,11965000],[1952,12350771],[1953,12749619],[1954,13162003],[1955,13588405],[1956,14029321],[1957,14485993],[1958,14958277],[1959,15446730],[1960,15952727],[1961,16476124],[1962,17009885],[1963,17546017],[1964,18090000],[1965,18646175],[1966,19201732],[1967,19764027],[1968,20321665],[1969,20869140],[1970,21429658],[1971,21992579],[1972,22542890],[1973,23069231],[1974,23593390],[1975,24114177],[1976,24620486],[1977,25094412],[1978,25542727],[1979,26030848],[1980,26582811],[1981,27159381],[1982,27764644],[1983,28389398],[1984,29027923],[1985,29678395],[1986,30326818],[1987,30964245],[1988,31589376],[1989,32216557],[1990,32858579],[1991,33518610],[1992,34202721],[1993,34896573],[1994,35588746],[1995,36280883],[1996,36971016],[1997,37657830],[1998,38339937],[1999,39016113],[2000,39685655],[2001,40349388],[2002,41008227],[2003,41662073],[2004,42310775],[2005,42954279],[2006,43593035],[2007,44227550],[2008,44858264]],"lifeExpectancy":[[1800,32],[1912,32],[1918,31.99],[1930,32],[1938,36.6],[1944,41.85],[1950,48.37],[1951,48.97],[1952,50.14],[1953,51.22],[1954,52.23],[1955,53.16],[1956,54.02],[1957,54.79],[1958,55.5],[1959,56.14],[1960,56.72],[1961,57.25],[1962,57.74],[1963,58.2],[1964,58.64],[1965,59.06],[1966,59.46],[1967,59.84],[1968,60.2],[1969,60.54],[1970,60.87],[1971,61.21],[1972,61.56],[1973,61.93],[1974,62.32],[1975,62.75],[1976,63.23],[1977,63.76],[1978,64.32],[1979,64.9],[1980,65.48],[1981,66.03],[1982,66.52],[1983,66.95],[1984,67.3],[1985,67.57],[1986,67.78],[1987,67.93],[1988,68.05],[1989,68.17],[1990,68.3],[1991,68.45],[1992,68.64],[1993,68.86],[1994,69.13],[1995,69.43],[1996,69.75],[1997,70.07],[1998,70.39],[1999,70.7],[2000,70.98],[2001,71.25],[2002,71.51],[2003,71.76],[2004,72.01],[2005,72.25],[2006,72.49],[2007,72.72],[2008,72.96],[2009,73.19]]},{"name":"Costa Rica","region":"America","income":[[1800,670.12],[1820,670.12],[1920,2018.1],[1921,1930.71],[1922,2101.23],[1923,1898.13],[1924,2123.84],[1925,2069.57],[1926,2239.72],[1927,2033.47],[1928,2094.67],[1929,1965.69],[1930,2020.83],[1931,1956.83],[1932,1766.24],[1933,2063.55],[1934,1785.98],[1935,1898.13],[1936,1988.51],[1937,2239.22],[1938,2331.87],[1939,2320.61],[1940,2190.97],[1941,2414.62],[1942,2097.5],[1943,2061.95],[1944,1813.06],[1945,2006.27],[1946,2186.31],[1947,2529.91],[1948,2603.3],[1949,2638.98],[1950,2439.82],[1951,2425.02],[1952,2627.01],[1953,2924],[1954,2845.1],[1955,3057.12],[1956,2859.88],[1957,2990.01],[1958,3237.3],[1959,3228.87],[1960,3374.88],[1961,3383.62],[1962,3460.94],[1963,3627.39],[1964,3680.52],[1965,3885.68],[1966,4049.72],[1967,4161.73],[1968,4346.33],[1969,4501.74],[1970,4665.44],[1971,4833.79],[1972,5118.15],[1973,5367.23],[1974,5505.86],[1975,5463.45],[1976,5600.27],[1977,5926.88],[1978,6052.64],[1979,6163.74],[1980,6102.95],[1981,5817.93],[1982,5262.73],[1983,5257.08],[1984,5508.07],[1985,5394.25],[1986,5525.6],[1987,5629.92],[1988,5668.47],[1989,5839.22],[1990,5899.67],[1991,5885.81],[1992,6160.42],[1993,6374.84],[1994,6508.09],[1995,6515.31],[1996,6444.68],[1997,6677.05],[1998,7106.62],[1999,7637.89],[2000,7672.85],[2001,7627.11],[2002,7723.45],[2003,8098.56],[2004,8301.9],[2005,8661],[2006,9231.72],[2007,9765.16],[2008,9840.79],[2009,9551.56]],"population":[[1801,53000],[1820,63000],[1824,65000],[1836,78000],[1844,94000],[1850,101000],[1864,120000],[1870,137000],[1875,153000],[1883,182000],[1892,243000],[1900,297000],[1901,310000],[1902,320000],[1903,320000],[1904,330000],[1905,340000],[1906,340000],[1907,350000],[1908,350000],[1909,360000],[1910,363000],[1911,366000],[1912,369000],[1913,372000],[1914,390000],[1915,390000],[1916,400000],[1917,400000],[1918,410000],[1919,420000],[1920,420000],[1921,430000],[1922,430000],[1923,440000],[1924,450000],[1925,460000],[1926,470000],[1927,470000],[1928,480000],[1929,490000],[1930,500000],[1931,510000],[1932,520000],[1933,530000],[1934,540000],[1935,550000],[1936,560000],[1937,580000],[1938,590000],[1939,610000],[1940,620000],[1941,630000],[1942,650000],[1943,660000],[1944,680000],[1945,700000],[1946,710000],[1947,730000],[1948,750000],[1949,770000],[1950,866982],[1951,895336],[1952,926317],[1953,958893],[1954,993786],[1955,1031782],[1956,1071654],[1957,1112300],[1958,1154408],[1959,1200148],[1960,1248022],[1961,1296587],[1962,1345187],[1963,1393441],[1964,1440184],[1965,1487605],[1966,1538442],[1967,1588717],[1968,1638476],[1969,1687100],[1970,1735523],[1971,1785636],[1972,1834796],[1973,1886035],[1974,1937413],[1975,1991580],[1976,2048557],[1977,2108457],[1978,2192367],[1979,2259714],[1980,2299124],[1981,2357285],[1982,2424367],[1983,2494353],[1984,2567516],[1985,2643808],[1986,2723111],[1987,2799811],[1988,2875267],[1989,2951454],[1990,3027175],[1991,3101029],[1992,3173216],[1993,3244282],[1994,3314588],[1995,3383786],[1996,3451722],[1997,3518107],[1998,3583162],[1999,3647319],[2000,3710558],[2001,3773057],[2002,3834934],[2003,3896092],[2004,3956507],[2005,4016173],[2006,4075261],[2007,4133884],[2008,4191948]],"lifeExpectancy":[[1800,30.21],[1875,30.21],[1889,30.2],[1900,34.7],[1910,35.1],[1920,35.1],[1930,42.2],[1940,46.9],[1950,56.11],[1951,56.39],[1952,56.97],[1953,57.55],[1954,58.13],[1955,58.71],[1956,59.29],[1957,59.87],[1958,60.45],[1959,61.03],[1960,61.61],[1961,62.18],[1962,62.74],[1963,63.29],[1964,63.83],[1965,64.36],[1966,64.87],[1967,65.37],[1968,65.86],[1969,66.35],[1970,66.83],[1971,67.34],[1972,67.86],[1973,68.4],[1974,68.96],[1975,69.54],[1976,70.15],[1977,70.77],[1978,71.39],[1979,72],[1980,72.56],[1981,73.07],[1982,73.5],[1983,73.86],[1984,74.15],[1985,74.39],[1986,74.59],[1987,74.79],[1988,75],[1989,75.24],[1990,75.5],[1991,75.77],[1992,76.05],[1993,76.31],[1994,76.56],[1995,76.79],[1996,77],[1997,77.2],[1998,77.39],[1999,77.57],[2000,77.74],[2001,77.9],[2002,78.06],[2003,78.21],[2004,78.35],[2005,78.48],[2006,78.61],[2007,78.74],[2008,78.86],[2009,78.98]]},{"name":"Cuba","region":"America","income":[[1800,1123.88],[1820,1123.88],[1929,4148.69],[1930,3811.08],[1931,3142.29],[1932,2474.51],[1933,2627.11],[1934,3028.01],[1935,3471.57],[1936,3982.61],[1937,4505],[1938,3437.35],[1939,3572.08],[1940,3058.45],[1941,4047.45],[1942,3344.39],[1943,3649.49],[1944,4128.31],[1945,4496.19],[1946,4793.61],[1947,5368.57],[1948,4664.52],[1949,4957.64],[1950,5180.44],[1951,5507.89],[1952,5586.54],[1953,4811.18],[1954,4953.84],[1955,5076.02],[1956,5429.24],[1957,6092.17],[1958,5982],[1959,5232.62],[1960,5194.75],[1961,5190.1],[1962,5180.76],[1963,5143.38],[1964,5087.17],[1965,5033.96],[1966,5193.19],[1967,5690.27],[1968,5265.77],[1969,5116.29],[1970,4854.33],[1971,5155.9],[1972,5305.45],[1973,5683.94],[1974,5883.88],[1975,6086.94],[1976,6173.86],[1977,6380.49],[1978,6708.18],[1979,6821.94],[1980,6695.01],[1981,7208.8],[1982,7316.92],[1983,7453.54],[1984,7645.61],[1985,7710.16],[1986,7651.77],[1987,7532.92],[1988,7599.98],[1989,7549.09],[1990,7463.69],[1991,6537.35],[1992,5592.84],[1993,4669.61],[1994,4738.16],[1995,4875.77],[1996,5277.62],[1997,5431.99],[1998,5479.51],[1999,5823.76],[2000,6115.59],[2001,6270],[2002,6340.65],[2003,6500.13],[2004,6877.99],[2005,7407.24],[2006,8295.24],[2007,8894.89],[2008,9277.96]],"population":[[1817,572000],[1820,605000],[1827,704000],[1841,1008000],[1850,1186000],[1861,1397000],[1870,1331000],[1877,1522000],[1887,1632000],[1900,1658000],[1901,1716000],[1902,1775000],[1903,1837000],[1904,1879000],[1905,1927000],[1906,1979000],[1907,2034000],[1908,2092000],[1909,2154000],[1910,2219000],[1911,2287000],[1912,2358000],[1913,2431000],[1914,2507000],[1915,2585000],[1916,2664000],[1917,2746000],[1918,2828000],[1919,2912000],[1920,2997000],[1921,3083000],[1922,3170000],[1923,3257000],[1924,3345000],[1925,3432000],[1926,3519000],[1927,3606000],[1928,3693000],[1929,3742000],[1930,3837000],[1931,3910000],[1932,3984000],[1933,4060000],[1934,4137000],[1935,4221000],[1936,4289000],[1937,4357000],[1938,4428000],[1939,4497000],[1940,4566000],[1941,4635000],[1942,4704000],[1943,4779000],[1944,4849000],[1945,4932000],[1946,5039000],[1947,5152000],[1948,5268000],[1949,5386000],[1950,5784797],[1951,5891797],[1952,6007797],[1953,6128797],[1954,6254337],[1955,6381106],[1956,6512938],[1957,6640752],[1958,6763058],[1959,6900886],[1960,7027210],[1961,7134000],[1962,7254373],[1963,7414884],[1964,7612275],[1965,7809916],[1966,7985316],[1967,8139332],[1968,8283933],[1969,8421048],[1970,8542746],[1971,8669625],[1972,8831348],[1973,9001355],[1974,9152866],[1975,9290074],[1976,9420906],[1977,9537988],[1978,9634028],[1979,9710150],[1980,9652975],[1981,9711975],[1982,9789224],[1983,9885596],[1984,9982299],[1985,10078658],[1986,10162192],[1987,10239839],[1988,10334044],[1989,10439251],[1990,10544793],[1991,10642491],[1992,10723260],[1993,10788020],[1994,10844611],[1995,10896802],[1996,10943047],[1997,10983007],[1998,11029133],[1999,11082746],[2000,11134273],[2001,11182298],[2002,11226999],[2003,11268976],[2004,11308764],[2005,11346670],[2006,11382820],[2007,11416987],[2008,11449006]],"lifeExpectancy":[[1800,32.2],[1804,32.7],[1809,33.5],[1814,34.2],[1819,34.7],[1824,36.4],[1829,35.6],[1834,36.3],[1839,36.6],[1844,36],[1849,36.2],[1854,36.5],[1859,36.6],[1864,34.8],[1869,29.6],[1874,29.9],[1879,35.8],[1884,41],[1889,43.7],[1894,22.9],[1899,18.9],[1900,33.11],[1905,34.16],[1910,35.22],[1915,36.29],[1920,37.38],[1925,38.76],[1930,41.5],[1935,44.57],[1940,47.47],[1945,50.93],[1950,58.31],[1951,58.61],[1952,59.19],[1953,59.77],[1954,60.36],[1955,60.94],[1956,61.52],[1957,62.11],[1958,62.7],[1959,63.29],[1960,63.89],[1961,64.51],[1962,65.13],[1963,65.76],[1964,66.4],[1965,67.03],[1966,67.65],[1967,68.25],[1968,68.82],[1969,69.36],[1970,69.88],[1971,70.37],[1972,70.85],[1973,71.31],[1974,71.76],[1975,72.19],[1976,72.59],[1977,72.96],[1978,73.29],[1979,73.58],[1980,73.82],[1981,74.03],[1982,74.19],[1983,74.33],[1984,74.44],[1985,74.52],[1986,74.57],[1987,74.6],[1988,74.61],[1989,74.62],[1990,74.64],[1991,74.69],[1992,74.8],[1993,74.95],[1994,75.16],[1995,75.41],[1996,75.67],[1997,75.94],[1998,76.19],[1999,76.42],[2000,76.64],[2001,76.86],[2002,77.1],[2003,77.36],[2004,77.64],[2005,77.93],[2006,78.21],[2007,78.46],[2008,78.67],[2009,78.84]]},{"name":"Ecuador","region":"America","income":[[1800,1085.13],[1820,1085.13],[1939,2280.28],[1940,2377.52],[1941,2319.07],[1942,2384.45],[1943,2619.62],[1944,2584.66],[1945,2530.62],[1946,2760.5],[1947,2980.45],[1948,3296.76],[1949,3262.54],[1950,3266.23],[1951,3217.46],[1952,3522.11],[1953,3503.58],[1954,3687.72],[1955,3684.14],[1956,3717.83],[1957,3780.55],[1958,3784.77],[1959,3877.18],[1960,4012.4],[1961,3995.41],[1962,4086.11],[1963,4068.08],[1964,4227.1],[1965,4498.49],[1966,4480.75],[1967,4579.07],[1968,4690.4],[1969,4801.95],[1970,4988.61],[1971,5122.72],[1972,5280.99],[1973,5768.63],[1974,5931.37],[1975,6065.29],[1976,6463.83],[1977,6679.62],[1978,6944.34],[1979,7117.72],[1980,7239.77],[1981,7331.12],[1982,7213.79],[1983,6876],[1984,6968.94],[1985,7075.66],[1986,7096.73],[1987,6481.78],[1988,6992.25],[1989,6826.42],[1990,6842.3],[1991,7042.35],[1992,7103.7],[1993,7107.17],[1994,7268.52],[1995,7336.07],[1996,7331.53],[1997,7429.46],[1998,7319.01],[1999,6670.59],[2000,5616.42],[2001,5812.3],[2002,5773.04],[2003,5911],[2004,6311.01],[2005,6533],[2006,6679.1],[2007,6721.26],[2008,7108.36],[2009,7035.45]],"population":[[1800,500000],[1820,500000],[1850,816000],[1870,1013000],[1900,1400000],[1901,1420000],[1902,1441000],[1903,1462000],[1904,1483000],[1905,1505000],[1906,1527000],[1907,1549000],[1908,1571000],[1909,1594000],[1910,1617000],[1911,1641000],[1912,1665000],[1913,1689000],[1914,1703000],[1915,1717000],[1916,1731000],[1917,1746000],[1918,1760000],[1919,1774000],[1920,1790000],[1921,1805000],[1922,1820000],[1923,1835000],[1924,1850000],[1925,1865000],[1926,1881000],[1927,1896000],[1928,1912000],[1929,1928000],[1930,1944000],[1931,1995000],[1932,2050000],[1933,2095000],[1934,2140000],[1935,2196000],[1936,2249000],[1937,2298000],[1938,2355000],[1939,2412000],[1940,2466000],[1941,2541000],[1942,2575000],[1943,2641000],[1944,2712000],[1945,2781000],[1946,2853000],[1947,2936000],[1948,3017000],[1949,3104000],[1950,3369955],[1951,3458093],[1952,3548753],[1953,3642591],[1954,3740256],[1955,3842399],[1956,3948587],[1957,4058385],[1958,4172445],[1959,4291418],[1960,4415956],[1961,4546197],[1962,4681707],[1963,4822279],[1964,4967705],[1965,5117779],[1966,5272639],[1967,5432424],[1968,5596925],[1969,5765935],[1970,5939246],[1971,6116773],[1972,6298651],[1973,6485013],[1974,6675986],[1975,6871698],[1976,7072687],[1977,7278866],[1978,7489432],[1979,7703577],[1980,7920499],[1981,8141078],[1982,8365850],[1983,8593494],[1984,8825829],[1985,9061664],[1986,9301083],[1987,9545158],[1988,9794122],[1989,10048223],[1990,10318036],[1991,10526095],[1992,10748394],[1993,10979476],[1994,11208048],[1995,11438004],[1996,11673950],[1997,11911819],[1998,12139965],[1999,12347543],[2000,12505204],[2001,12701839],[2002,12921234],[2003,13074082],[2004,13212742],[2005,13363593],[2006,13547510],[2007,13755680],[2008,13927650]],"lifeExpectancy":[[1800,32.9],[1939,32.9],[1950,47.27],[1951,47.52],[1952,48.05],[1953,48.61],[1954,49.19],[1955,49.81],[1956,50.44],[1957,51.1],[1958,51.78],[1959,52.46],[1960,53.12],[1961,53.76],[1962,54.35],[1963,54.9],[1964,55.39],[1965,55.83],[1966,56.23],[1967,56.61],[1968,56.99],[1969,57.38],[1970,57.78],[1971,58.2],[1972,58.64],[1973,59.09],[1974,59.57],[1975,60.06],[1976,60.59],[1977,61.14],[1978,61.71],[1979,62.31],[1980,62.92],[1981,63.55],[1982,64.19],[1983,64.82],[1984,65.45],[1985,66.06],[1986,66.66],[1987,67.24],[1988,67.8],[1989,68.33],[1990,68.85],[1991,69.35],[1992,69.84],[1993,70.31],[1994,70.78],[1995,71.24],[1996,71.69],[1997,72.13],[1998,72.56],[1999,72.97],[2000,73.36],[2001,73.7],[2002,74.01],[2003,74.27],[2004,74.49],[2005,74.67],[2006,74.83],[2007,74.98],[2008,75.12],[2009,75.26]]},{"name":"El Salvador","region":"America","income":[[1800,804.31],[1820,804.31],[1920,1834.11],[1921,1808.24],[1922,1868.57],[1923,1916.16],[1924,2000.99],[1925,1820.16],[1926,2102.98],[1927,1821.22],[1928,2074.46],[1929,2047.83],[1930,2055.71],[1931,1817.38],[1932,1619.03],[1933,1813.79],[1934,1848.38],[1935,2008.06],[1936,1937.73],[1937,2094.71],[1938,1922.39],[1939,2036.56],[1940,2185.33],[1941,2112.35],[1942,2253.76],[1943,2428.97],[1944,2264.25],[1945,2145.53],[1946,2154.67],[1947,2679.65],[1948,3357.89],[1949,2999.55],[1950,2928.38],[1951,2911.2],[1952,3048.3],[1953,3178.36],[1954,3126.4],[1955,3195.05],[1956,3346.59],[1957,3421.52],[1958,3392.04],[1959,3437.78],[1960,3468.95],[1961,3478.67],[1962,3776.8],[1963,3817.2],[1964,4047.7],[1965,4132.17],[1966,4271.86],[1967,4358.6],[1968,4345.97],[1969,4339.02],[1970,4301.25],[1971,4370.84],[1972,4520.25],[1973,4607.17],[1974,4791.29],[1975,4924.57],[1976,4980.98],[1977,5138.92],[1978,5339.79],[1979,5124.05],[1980,4629.77],[1981,4299.26],[1982,4098.34],[1983,4083.37],[1984,4113.8],[1985,4140.59],[1986,4109.36],[1987,4140.44],[1988,4142.57],[1989,4114.22],[1990,4167.27],[1991,4213.31],[1992,4444.23],[1993,4645.22],[1994,4836.25],[1995,5042.31],[1996,5037.56],[1997,5154.83],[1998,5248.87],[1999,5325.56],[2000,5341.27],[2001,5332.23],[2002,5351.57],[2003,5350.2],[2004,5349.69],[2005,5403],[2006,5592.24],[2007,5794.23],[2008,5894.67],[2009,5646.85]],"population":[[1800,248000],[1820,248000],[1850,366000],[1870,492000],[1900,766000],[1901,782000],[1902,799000],[1903,816000],[1904,834000],[1905,851000],[1906,869000],[1907,888000],[1908,907000],[1909,926000],[1910,946000],[1911,966000],[1912,987000],[1913,1008000],[1914,1030000],[1915,1052000],[1916,1074000],[1917,1098000],[1918,1121000],[1919,1145000],[1920,1170000],[1921,1190000],[1922,1220000],[1923,1240000],[1924,1270000],[1925,1300000],[1926,1330000],[1927,1350000],[1928,1390000],[1929,1410000],[1930,1440000],[1931,1460000],[1932,1470000],[1933,1490000],[1934,1510000],[1935,1530000],[1936,1550000],[1937,1570000],[1938,1590000],[1939,1610000],[1940,1630000],[1941,1650000],[1942,1680000],[1943,1690000],[1944,1720000],[1945,1740000],[1946,1760000],[1947,1780000],[1948,1810000],[1949,1840000],[1950,1939800],[1951,1989756],[1952,2042865],[1953,2099130],[1954,2158554],[1955,2221139],[1956,2286889],[1957,2355805],[1958,2427891],[1959,2503149],[1960,2581583],[1961,2664838],[1962,2747687],[1963,2836090],[1964,2923870],[1965,3017852],[1966,3128206],[1967,3232927],[1968,3347320],[1969,3469177],[1970,3603907],[1971,3710335],[1972,3790903],[1973,3878197],[1974,3971783],[1975,4071179],[1976,4174737],[1977,4282586],[1978,4396275],[1979,4508055],[1980,4566199],[1981,4515094],[1982,4474873],[1983,4521153],[1984,4587633],[1985,4664361],[1986,4751017],[1987,4842194],[1988,4930397],[1989,5015522],[1990,5099884],[1991,5185604],[1992,5274649],[1993,5369502],[1994,5466906],[1995,5568437],[1996,5674036],[1997,5783439],[1998,5895283],[1999,6008356],[2000,6122515],[2001,6237662],[2002,6353681],[2003,6470379],[2004,6587541],[2005,6704932],[2006,6822378],[2007,6939688],[2008,7057131]],"lifeExpectancy":[[1800,28.7],[1930,28.7],[1950,43.24],[1951,43.7],[1952,44.61],[1953,45.51],[1954,46.39],[1955,47.26],[1956,48.1],[1957,48.94],[1958,49.75],[1959,50.54],[1960,51.3],[1961,52.03],[1962,52.72],[1963,53.37],[1964,53.97],[1965,54.52],[1966,55.02],[1967,55.48],[1968,55.9],[1969,56.27],[1970,56.58],[1971,56.82],[1972,56.98],[1973,57.07],[1974,57.09],[1975,57.05],[1976,56.93],[1977,56.75],[1978,56.55],[1979,56.39],[1980,56.34],[1981,56.5],[1982,56.9],[1983,57.56],[1984,58.48],[1985,59.61],[1986,60.9],[1987,62.26],[1988,63.59],[1989,64.82],[1990,65.91],[1991,66.81],[1992,67.52],[1993,68.08],[1994,68.5],[1995,68.78],[1996,68.97],[1997,69.11],[1998,69.23],[1999,69.36],[2000,69.53],[2001,69.74],[2002,69.97],[2003,70.21],[2004,70.47],[2005,70.74],[2006,71],[2007,71.26],[2008,71.5],[2009,71.74]]},{"name":"French Guiana","region":"America","income":[[1800,819.27],[1820,819.27],[1913,1511.59],[1950,2612.06],[1973,7212.76],[1990,7210.63],[2001,8495.63],[2002,8869.85],[2003,8344.72],[2004,7910.72],[2005,8202.74]],"population":[[1800,9899],[1820,9899],[1950,25516],[1951,26083],[1952,26664],[1953,27257],[1954,27863],[1955,28483],[1956,29145],[1957,29853],[1958,30609],[1959,31400],[1960,32243],[1961,33206],[1962,34424],[1963,35973],[1964,37893],[1965,40035],[1966,42172],[1967,43991],[1968,45383],[1969,46782],[1970,48291],[1971,49934],[1972,51609],[1973,53190],[1974,54687],[1975,56261],[1976,57871],[1977,59707],[1978,62287],[1979,64907],[1980,67762],[1981,70885],[1982,73999],[1983,78844],[1984,83757],[1985,88828],[1986,94003],[1987,99323],[1988,104745],[1989,110251],[1990,115930],[1991,121664],[1992,127452],[1993,133287],[1994,139166],[1995,145082],[1996,150933],[1997,156616],[1998,162127],[1999,167459],[2000,172605],[2001,177562],[2002,182333],[2003,186917],[2004,191309],[2005,195506],[2006,199509],[2007,203321],[2008,206941]],"lifeExpectancy":[[1950,52.21],[1951,52.48],[1952,53.01],[1953,53.55],[1954,54.08],[1955,54.62],[1956,55.16],[1957,55.72],[1958,56.3],[1959,56.91],[1960,57.58],[1961,58.32],[1962,59.14],[1963,60.03],[1964,60.97],[1965,61.92],[1966,62.81],[1967,63.62],[1968,64.29],[1969,64.82],[1970,65.21],[1971,65.46],[1972,65.62],[1973,65.73],[1974,65.83],[1975,65.97],[1976,66.18],[1977,66.47],[1978,66.85],[1979,67.31],[1980,67.84],[1981,68.41],[1982,68.97],[1983,69.49],[1984,69.96],[1985,70.38],[1986,70.74],[1987,71.07],[1988,71.39],[1989,71.7],[1990,72.01],[1991,72.32],[1992,72.63],[1993,72.94],[1994,73.25],[1995,73.55],[1996,73.83],[1997,74.1],[1998,74.34],[1999,74.55],[2000,74.75],[2001,74.92],[2002,75.08],[2003,75.24],[2004,75.39],[2005,75.54],[2006,75.69],[2007,75.85],[2008,76],[2009,76.16]]},{"name":"Grenada","region":"America","income":[[1800,775.67],[1820,775.67],[1950,1320.46],[1970,2079.72],[1971,2231.37],[1972,2404.58],[1973,2622.9],[1974,2805.2],[1975,2911.44],[1976,3209.18],[1977,3439.56],[1978,3766.12],[1979,3877.83],[1980,3865.76],[1981,3862.08],[1982,3872.36],[1983,3816.39],[1984,3917.98],[1985,4099.47],[1986,4491.84],[1987,4947.83],[1988,5135.84],[1989,5504.78],[1990,5839.92],[1991,6057.94],[1992,6098.92],[1993,5978.42],[1994,6130.94],[1995,6279.52],[1996,6430.85],[1997,6690.02],[1998,7565.56],[1999,8137.77],[2000,8655.03],[2001,8320.16],[2002,8365.59],[2003,8862.07],[2004,8276.23],[2005,9128],[2006,8913.55],[2007,9353.93],[2008,9558.52],[2009,8826.9]],"population":[[1800,29409],[1820,29409],[1851,33000],[1861,32000],[1871,38000],[1881,42000],[1891,53000],[1901,63000],[1911,67000],[1921,66000],[1946,72000],[1950,75806],[1951,76969],[1952,78339],[1953,80254],[1954,82525],[1955,84621],[1956,85809],[1957,87086],[1958,88359],[1959,89239],[1960,90148],[1961,90865],[1962,91449],[1963,92076],[1964,92767],[1965,93290],[1966,93579],[1967,93879],[1968,94349],[1969,94867],[1970,95410],[1971,96034],[1972,96618],[1973,96857],[1974,96340],[1975,95819],[1976,95555],[1977,94280],[1978,92535],[1979,91354],[1980,90164],[1981,92354],[1982,92112],[1983,91899],[1984,91905],[1985,92203],[1986,92576],[1987,92719],[1988,92805],[1989,92825],[1990,92360],[1991,91837],[1992,91487],[1993,90904],[1994,90591],[1995,90603],[1996,90371],[1997,90005],[1998,89700],[1999,89470],[2000,89312],[2001,89227],[2002,89211],[2003,89258],[2004,89357],[2005,89502],[2006,89703],[2007,89971],[2008,90303]],"lifeExpectancy":[[1950,62.44],[1951,62.49],[1952,62.58],[1953,62.68],[1954,62.78],[1955,62.87],[1956,62.97],[1957,63.07],[1958,63.16],[1959,63.26],[1960,63.36],[1961,63.46],[1962,63.56],[1963,63.66],[1964,63.75],[1965,63.85],[1966,63.95],[1967,64.04],[1968,64.14],[1969,64.24],[1970,64.34],[1971,64.43],[1972,64.53],[1973,64.62],[1974,64.72],[1975,64.8],[1976,64.88],[1977,64.95],[1978,65.01],[1979,65.07],[1980,65.16],[1981,65.27],[1982,65.42],[1983,65.62],[1984,65.88],[1985,66.22],[1986,66.65],[1987,67.16],[1988,67.75],[1989,68.38],[1990,69.04],[1991,69.7],[1992,70.31],[1993,70.87],[1994,71.37],[1995,71.8],[1996,72.18],[1997,72.53],[1998,72.87],[1999,73.2],[2000,73.53],[2001,73.86],[2002,74.15],[2003,74.43],[2004,74.67],[2005,74.89],[2006,75.09],[2007,75.28],[2008,75.45],[2009,75.62]]},{"name":"Guadeloupe","region":"America","income":[[1800,760.98],[1820,760.98],[1913,1404.04],[1950,2426.2],[1973,3896.92],[1990,3510.82],[2001,6697.88],[2002,6987.87],[2003,6810.68],[2004,7416.83],[2005,7788.25]],"population":[[1800,80726],[1820,80726],[1950,208080],[1951,212927],[1952,218011],[1953,223303],[1954,229120],[1955,235385],[1956,242078],[1957,248602],[1958,255124],[1959,261974],[1960,268888],[1961,275714],[1962,282625],[1963,289527],[1964,295823],[1965,301565],[1966,306983],[1967,311603],[1968,315392],[1969,318493],[1970,320657],[1971,323709],[1972,326841],[1973,329477],[1974,331634],[1975,333418],[1976,334454],[1977,334846],[1978,335118],[1979,335616],[1980,336846],[1981,338693],[1982,340813],[1983,345275],[1984,349721],[1985,354125],[1986,358368],[1987,362691],[1988,367386],[1989,372445],[1990,377678],[1991,382946],[1992,388102],[1993,392897],[1994,397585],[1995,402359],[1996,407191],[1997,412050],[1998,416906],[1999,421729],[2000,426493],[2001,431170],[2002,435739],[2003,440189],[2004,444515],[2005,448713],[2006,452776],[2007,456698],[2008,460486]],"lifeExpectancy":[[1950,54.06],[1951,54.72],[1952,55.99],[1953,57.18],[1954,58.31],[1955,59.36],[1956,60.33],[1957,61.22],[1958,62.03],[1959,62.76],[1960,63.4],[1961,63.94],[1962,64.39],[1963,64.75],[1964,65.05],[1965,65.31],[1966,65.55],[1967,65.8],[1968,66.07],[1969,66.38],[1970,66.72],[1971,67.11],[1972,67.51],[1973,67.92],[1974,68.33],[1975,68.76],[1976,69.21],[1977,69.69],[1978,70.21],[1979,70.74],[1980,71.26],[1981,71.74],[1982,72.17],[1983,72.53],[1984,72.82],[1985,73.08],[1986,73.32],[1987,73.59],[1988,73.91],[1989,74.28],[1990,74.69],[1991,75.12],[1992,75.55],[1993,75.95],[1994,76.31],[1995,76.63],[1996,76.91],[1997,77.17],[1998,77.41],[1999,77.64],[2000,77.87],[2001,78.08],[2002,78.27],[2003,78.44],[2004,78.6],[2005,78.75],[2006,78.88],[2007,79.01],[2008,79.15],[2009,79.28]]},{"name":"Guatemala","region":"America","income":[[1800,682.75],[1820,682.75],[1920,1517.05],[1921,1648.07],[1922,1539.52],[1923,1675.57],[1924,1793.08],[1925,1740.93],[1926,1740.36],[1927,1835.3],[1928,1856.8],[1929,2051.3],[1930,2117.3],[1931,1932.03],[1932,1645.48],[1933,1618.64],[1934,1802.56],[1935,2041.34],[1936,2748.75],[1937,2630.51],[1938,2651.84],[1939,2929.14],[1940,3269.57],[1941,3368.07],[1942,3337.88],[1943,2187.38],[1944,2076.27],[1945,2065],[1946,2387.43],[1947,2354.88],[1948,2370.12],[1949,2516.51],[1950,2485.79],[1951,2448.64],[1952,2428.24],[1953,2445.13],[1954,2419.2],[1955,2407.56],[1956,2550.95],[1957,2617.16],[1958,2660.06],[1959,2710.41],[1960,2696.63],[1961,2733.06],[1962,2750.36],[1963,2928.41],[1964,2978.56],[1965,3055.2],[1966,3169.15],[1967,3242.53],[1968,3466.05],[1969,3565.7],[1970,3700.25],[1971,3831.07],[1972,4031.41],[1973,4218.99],[1974,4397.54],[1975,4392.23],[1976,4621.21],[1977,4879.99],[1978,5018.99],[1979,5150.05],[1980,5236.1],[1981,5147.5],[1982,4820.49],[1983,4587.98],[1984,4488.18],[1985,4337.45],[1986,4220.98],[1987,4246.49],[1988,4284.96],[1989,4324.88],[1990,4328.93],[1991,4358.67],[1992,4439.45],[1993,4483.12],[1994,4531.75],[1995,4622.17],[1996,4627.13],[1997,4684.31],[1998,4790.14],[1999,4840.46],[2000,4884.72],[2001,4872.04],[2002,4858.35],[2003,4840.72],[2004,4858.11],[2005,4897],[2006,5035.14],[2007,5222.58],[2008,5261.46],[2009,5163.22]],"population":[[1820,595000],[1850,850000],[1870,1080000],[1900,1300000],[1901,1313000],[1902,1327000],[1903,1341000],[1904,1355000],[1905,1369000],[1906,1383000],[1907,1397000],[1908,1412000],[1909,1426000],[1910,1441000],[1911,1456000],[1912,1470000],[1913,1486000],[1914,1501000],[1915,1517000],[1916,1533000],[1917,1549000],[1918,1565000],[1919,1581000],[1920,1597000],[1921,1614000],[1922,1631000],[1923,1648000],[1924,1665000],[1925,1682000],[1926,1699000],[1927,1717000],[1928,1735000],[1929,1753000],[1930,1771000],[1931,1810000],[1932,1860000],[1933,1910000],[1934,1940000],[1935,1980000],[1936,2020000],[1937,2070000],[1938,2110000],[1939,2150000],[1940,2200000],[1941,2250000],[1942,2300000],[1943,2340000],[1944,2390000],[1945,2440000],[1946,2500000],[1947,2570000],[1948,2640000],[1949,2720000],[1950,2968976],[1951,3056382],[1952,3146381],[1953,3239239],[1954,3335063],[1955,3433887],[1956,3535792],[1957,3640876],[1958,3749336],[1959,3861360],[1960,3975707],[1961,4091112],[1962,4208858],[1963,4329980],[1964,4454413],[1965,4531949],[1966,4610525],[1967,4690773],[1968,4773538],[1969,4859160],[1970,4950548],[1971,5048218],[1972,5149581],[1973,5254378],[1974,5362594],[1975,5473584],[1976,5586789],[1977,5703430],[1978,5822706],[1979,5942151],[1980,6064228],[1981,6208454],[1982,6395630],[1983,6546945],[1984,6726525],[1985,6917947],[1986,7117868],[1987,7326406],[1988,7543322],[1989,7768407],[1990,8001019],[1991,8240499],[1992,8486949],[1993,8740433],[1994,9001037],[1995,9266312],[1996,9533880],[1997,9803875],[1998,10076122],[1999,10350211],[2000,10625732],[2001,10902031],[2002,11178650],[2003,11456063],[2004,11734580],[2005,12013907],[2006,12293545],[2007,12572928],[2008,12851647]],"lifeExpectancy":[[1800,25.8],[1921,25.82],[1934,25.8],[1940,30.35],[1950,41.36],[1951,41.52],[1952,41.84],[1953,42.19],[1954,42.58],[1955,43],[1956,43.45],[1957,43.93],[1958,44.44],[1959,44.98],[1960,45.53],[1961,46.11],[1962,46.69],[1963,47.28],[1964,47.89],[1965,48.51],[1966,49.16],[1967,49.85],[1968,50.57],[1969,51.31],[1970,52.05],[1971,52.77],[1972,53.45],[1973,54.07],[1974,54.63],[1975,55.13],[1976,55.58],[1977,55.99],[1978,56.39],[1979,56.79],[1980,57.2],[1981,57.64],[1982,58.09],[1983,58.56],[1984,59.06],[1985,59.57],[1986,60.1],[1987,60.64],[1988,61.17],[1989,61.71],[1990,62.24],[1991,62.77],[1992,63.31],[1993,63.86],[1994,64.41],[1995,64.97],[1996,65.53],[1997,66.1],[1998,66.66],[1999,67.22],[2000,67.74],[2001,68.22],[2002,68.66],[2003,69.04],[2004,69.36],[2005,69.64],[2006,69.88],[2007,70.11],[2008,70.33],[2009,70.55]]},{"name":"Guyana","region":"America","income":[[1800,910.69],[1820,910.69],[1913,1680.26],[1950,2903.52],[1960,2197.3],[1961,2236.82],[1962,2202.78],[1963,1884.75],[1964,2049.28],[1965,2213.57],[1966,2277.62],[1967,2325.09],[1968,2302.61],[1969,2421.63],[1970,2489.76],[1971,2540.96],[1972,2439.15],[1973,2456.52],[1974,2632.25],[1975,2838.12],[1976,2859.95],[1977,2760.81],[1978,2688.04],[1979,2620.32],[1980,2653.79],[1981,2688.36],[1982,2334.36],[1983,2180.61],[1984,2078.81],[1985,2139.35],[1986,2133.58],[1987,2169.07],[1988,2104.87],[1989,2013.1],[1990,1959],[1991,2077.16],[1992,2234.65],[1993,2408.93],[1994,2604.9],[1995,2729.15],[1996,2944.07],[1997,3131.96],[1998,3085.38],[1999,3182.97],[2000,3141.35],[2001,3209.76],[2002,3237.95],[2003,3198.6],[2004,3298.36],[2005,3232],[2006,3386.17],[2007,3613.42],[2008,3667.37],[2009,3776.95]],"population":[[1800,166034],[1820,166034],[1950,427971],[1951,439062],[1952,451430],[1953,464323],[1954,477498],[1955,491180],[1956,505229],[1957,520286],[1958,536776],[1959,554471],[1960,571083],[1961,584710],[1962,597896],[1963,612069],[1964,626389],[1965,640316],[1966,656528],[1967,672848],[1968,687477],[1969,701552],[1970,714811],[1971,728990],[1972,742869],[1973,755324],[1974,765282],[1975,767977],[1976,763718],[1977,758334],[1978,755889],[1979,757400],[1980,759352],[1981,761204],[1982,761673],[1983,760529],[1984,759690],[1985,758329],[1986,756887],[1987,755464],[1988,754045],[1989,752537],[1990,750903],[1991,748816],[1992,747460],[1993,747337],[1994,747536],[1995,747929],[1996,747171],[1997,746336],[1998,748211],[1999,752105],[2000,755171],[2001,757092],[2002,759104],[2003,761181],[2004,763251],[2005,765283],[2006,767245],[2007,769095],[2008,770794]],"lifeExpectancy":[[1800,31.12],[1911,31.12],[1921,34.62],[1930,41.42],[1946,50.65],[1950,51.32],[1951,51.57],[1952,52.06],[1953,52.56],[1954,53.06],[1955,53.56],[1956,54.07],[1957,54.59],[1958,55.1],[1959,55.61],[1960,56.12],[1961,56.62],[1962,57.1],[1963,57.56],[1964,57.99],[1965,58.39],[1966,58.73],[1967,59.03],[1968,59.28],[1969,59.49],[1970,59.67],[1971,59.82],[1972,59.95],[1973,60.08],[1974,60.21],[1975,60.34],[1976,60.46],[1977,60.57],[1978,60.66],[1979,60.73],[1980,60.8],[1981,60.88],[1982,60.97],[1983,61.08],[1984,61.21],[1985,61.36],[1986,61.53],[1987,61.7],[1988,61.87],[1989,62.02],[1990,62.15],[1991,62.25],[1992,62.31],[1993,62.34],[1994,62.35],[1995,62.37],[1996,62.41],[1997,62.5],[1998,62.66],[1999,62.88],[2000,63.18],[2001,63.55],[2002,63.99],[2003,64.46],[2004,64.96],[2005,65.47],[2006,65.98],[2007,66.48],[2008,66.97],[2009,67.43]]},{"name":"Haiti","region":"America","income":[[1800,503.81],[1820,503.81],[1945,1764.26],[1946,1759.43],[1947,1769.37],[1948,1766.79],[1949,1765.92],[1950,1774.19],[1951,1771.24],[1952,1840.37],[1953,1751.26],[1954,1861.11],[1955,1754.02],[1956,1871.58],[1957,1726.89],[1958,1827.63],[1959,1707.09],[1960,1780.91],[1961,1673.93],[1962,1796.59],[1963,1644.38],[1964,1572.87],[1965,1556.3],[1966,1514.23],[1967,1452.06],[1968,1477.58],[1969,1493.51],[1970,1530.69],[1971,1613.19],[1972,1654.46],[1973,1712.59],[1974,1804.06],[1975,1747],[1976,1880.97],[1977,1874.3],[1978,1947.74],[1979,2071.78],[1980,2212.9],[1981,2118.88],[1982,2011.16],[1983,1988.46],[1984,1954.71],[1985,1918.55],[1986,1876.28],[1987,1823.02],[1988,1798.56],[1989,1779.9],[1990,1742.99],[1991,1716.39],[1992,1456.31],[1993,1398.46],[1994,1259.94],[1995,1299.75],[1996,1329.43],[1997,1341.73],[1998,1346.85],[1999,1358.24],[2000,1344.49],[2001,1303.77],[2002,1270.36],[2003,1249.95],[2004,1180.25],[2005,1175],[2006,1179.62],[2007,1197],[2008,1185.24],[2009,1198.05]],"population":[[1800,723000],[1820,723000],[1850,938000],[1870,1150000],[1900,1560000],[1901,1583000],[1902,1607000],[1903,1631000],[1904,1655000],[1905,1680000],[1906,1705000],[1907,1730000],[1908,1756000],[1909,1782000],[1910,1809000],[1911,1836000],[1912,1863000],[1913,1891000],[1914,1923000],[1915,1955000],[1916,1988000],[1917,2021000],[1918,2055000],[1919,2089000],[1920,2124000],[1921,2152000],[1922,2181000],[1923,2209000],[1924,2239000],[1925,2268000],[1926,2298000],[1927,2328000],[1928,2359000],[1929,2390000],[1930,2422000],[1931,2453000],[1932,2485000],[1933,2517000],[1934,2549000],[1935,2582000],[1936,2615000],[1937,2648000],[1938,2682000],[1939,2716000],[1940,2751000],[1941,2786000],[1942,2820000],[1943,2856000],[1944,2892000],[1945,2928000],[1946,2961000],[1947,2994000],[1948,3028000],[1949,3062000],[1950,3097220],[1951,3148152],[1952,3201488],[1953,3257356],[1954,3315524],[1955,3376419],[1956,3441339],[1957,3507701],[1958,3576772],[1959,3648298],[1960,3722743],[1961,3800257],[1962,3880130],[1963,3964060],[1964,4049805],[1965,4137405],[1966,4226710],[1967,4318137],[1968,4411541],[1969,4506965],[1970,4604915],[1971,4653084],[1972,4698301],[1973,4742929],[1974,4787018],[1975,4828338],[1976,4867802],[1977,4908554],[1978,4950634],[1979,4994123],[1980,5029725],[1981,5108660],[1982,5198399],[1983,5297652],[1984,5404670],[1985,5517977],[1986,5635089],[1987,5756203],[1988,5880465],[1989,6004762],[1990,6126101],[1991,6226921],[1992,6326682],[1993,6443498],[1994,6558149],[1995,6675578],[1996,6794575],[1997,6913545],[1998,7038935],[1999,7167662],[2000,7306302],[2001,7454154],[2002,7607651],[2003,7771090],[2004,7942419],[2005,8121622],[2006,8308504],[2007,8502814],[2008,8704413]],"lifeExpectancy":[[1950,36.27],[1951,36.6],[1952,37.26],[1953,37.91],[1954,38.55],[1955,39.17],[1956,39.79],[1957,40.4],[1958,41],[1959,41.59],[1960,42.18],[1961,42.76],[1962,43.33],[1963,43.9],[1964,44.46],[1965,45],[1966,45.51],[1967,45.99],[1968,46.43],[1969,46.83],[1970,47.2],[1971,47.56],[1972,47.92],[1973,48.28],[1974,48.65],[1975,49.02],[1976,49.38],[1977,49.72],[1978,50.04],[1979,50.34],[1980,50.63],[1981,50.93],[1982,51.25],[1983,51.61],[1984,52.01],[1985,52.45],[1986,52.93],[1987,53.42],[1988,53.93],[1989,54.44],[1990,54.95],[1991,55.46],[1992,55.98],[1993,56.51],[1994,57.02],[1995,57.5],[1996,57.93],[1997,58.31],[1998,58.63],[1999,58.9],[2000,59.12],[2001,59.34],[2002,59.57],[2003,59.82],[2004,60.11],[2005,60.41],[2006,60.72],[2007,61.01],[2008,61.26],[2009,61.48]]},{"name":"Honduras","region":"America","income":[[1800,583.8],[1820,583.8],[1920,2061.23],[1921,2027.39],[1922,2118.65],[1923,2027.06],[1924,1847.36],[1925,2151.54],[1926,2096.58],[1927,2276.69],[1928,2504.1],[1929,2425.88],[1930,2529.84],[1931,2531.07],[1932,2221.64],[1933,2043.05],[1934,1959.55],[1935,1836.28],[1936,1833.69],[1937,1720.31],[1938,1787.61],[1939,1804.82],[1940,1877.36],[1941,1841.12],[1942,1641.34],[1943,1630.45],[1944,1627.55],[1945,1972.92],[1946,2073.83],[1947,2157.89],[1948,2154.29],[1949,2121.4],[1950,2125.56],[1951,2175.9],[1952,2194.93],[1953,2299.86],[1954,2103.69],[1955,2092.37],[1956,2191.2],[1957,2220.49],[1958,2217.79],[1959,2201.34],[1960,2262.22],[1961,2243.2],[1962,2291.16],[1963,2293.2],[1964,2326.64],[1965,2438.23],[1966,2489.67],[1967,2538.27],[1968,2594.6],[1969,2523.46],[1970,2518.49],[1971,2528.59],[1972,2529.84],[1973,2558.71],[1974,2824.6],[1975,2802.95],[1976,2994.99],[1977,3203.21],[1978,3403.51],[1979,3443.47],[1980,3336.79],[1981,3287.52],[1982,3121.76],[1983,2997.61],[1984,3009.41],[1985,3033.15],[1986,2952.67],[1987,3023.1],[1988,3073.17],[1989,3092.5],[1990,3004.97],[1991,2999.13],[1992,3081.69],[1993,3204.57],[1994,3052.26],[1995,3073.89],[1996,3094.71],[1997,3160.45],[1998,3168.46],[1999,3028.73],[2000,3093.71],[2001,3093.68],[2002,3099.73],[2003,3129.92],[2004,3209.35],[2005,3266],[2006,3412.03],[2007,3549.04],[2008,3615.09],[2009,3473.46]],"population":[[1801,130000],[1820,135000],[1850,350000],[1870,404000],[1900,500000],[1901,511000],[1902,522000],[1903,533000],[1904,545000],[1905,556000],[1906,568000],[1907,581000],[1908,593000],[1909,606000],[1910,619000],[1911,632000],[1912,646000],[1913,660000],[1914,668000],[1915,677000],[1916,685000],[1917,694000],[1918,702000],[1919,711000],[1920,720000],[1921,740000],[1922,770000],[1923,800000],[1924,820000],[1925,850000],[1926,880000],[1927,890000],[1928,910000],[1929,930000],[1930,950000],[1931,970000],[1932,990000],[1933,1010000],[1934,1020000],[1935,1040000],[1936,1060000],[1937,1080000],[1938,1100000],[1939,1120000],[1940,1150000],[1941,1170000],[1942,1200000],[1943,1210000],[1944,1240000],[1945,1260000],[1946,1290000],[1947,1320000],[1948,1350000],[1949,1390000],[1950,1431447],[1951,1474191],[1952,1517453],[1953,1562218],[1954,1610959],[1955,1662219],[1956,1715023],[1957,1770390],[1958,1828733],[1959,1888715],[1960,1951640],[1961,2018693],[1962,2090162],[1963,2165930],[1964,2246099],[1965,2329159],[1966,2413644],[1967,2500689],[1968,2591112],[1969,2685322],[1970,2760666],[1971,2855882],[1972,2965146],[1973,3077805],[1974,2765159],[1975,2857540],[1976,2954226],[1977,3055235],[1978,3167869],[1979,3278690],[1980,3401940],[1981,3542519],[1982,3669448],[1983,3795505],[1984,3932288],[1985,4076514],[1986,4225991],[1987,4372203],[1988,4513723],[1989,4654540],[1990,4792271],[1991,4931117],[1992,5077347],[1993,5229618],[1994,5386133],[1995,5546185],[1996,5707074],[1997,5867957],[1998,6022706],[1999,6180871],[2000,6347658],[2001,6513048],[2002,6677328],[2003,6843018],[2004,7007482],[2005,7167902],[2006,7326496],[2007,7483763],[2008,7639327]],"lifeExpectancy":[[1800,33.9],[1930,33.9],[1950,40.94],[1951,41.15],[1952,41.59],[1953,42.07],[1954,42.58],[1955,43.13],[1956,43.71],[1957,44.33],[1958,44.97],[1959,45.63],[1960,46.3],[1961,46.97],[1962,47.64],[1963,48.29],[1964,48.92],[1965,49.52],[1966,50.11],[1967,50.68],[1968,51.26],[1969,51.84],[1970,52.43],[1971,53.04],[1972,53.67],[1973,54.32],[1974,54.99],[1975,55.69],[1976,56.41],[1977,57.15],[1978,57.9],[1979,58.66],[1980,59.44],[1981,60.22],[1982,61.02],[1983,61.82],[1984,62.62],[1985,63.39],[1986,64.12],[1987,64.78],[1988,65.38],[1989,65.91],[1990,66.38],[1991,66.82],[1992,67.24],[1993,67.67],[1994,68.09],[1995,68.52],[1996,68.94],[1997,69.33],[1998,69.69],[1999,70.01],[2000,70.29],[2001,70.56],[2002,70.8],[2003,71.04],[2004,71.28],[2005,71.52],[2006,71.75],[2007,71.98],[2008,72.2],[2009,72.41]]},{"name":"Jamaica","region":"America","income":[[1800,1350.4],[1820,1350.4],[1850,1048.06],[1870,1031.12],[1913,1171.9],[1938,1874.05],[1942,1870.22],[1943,2215.6],[1946,3178.64],[1947,2914.58],[1950,2556.82],[1951,2721.41],[1952,2898.53],[1953,3258.81],[1954,3580.81],[1955,3893.49],[1956,4220.5],[1957,4756.53],[1958,4737.22],[1959,4897.48],[1960,5113.57],[1961,5207.34],[1962,5246.11],[1963,5312.99],[1964,5596.18],[1965,5915.47],[1966,6029.79],[1967,6124.7],[1968,6328.34],[1969,6706.97],[1970,7416.69],[1971,7329.12],[1972,7433.89],[1973,7959.55],[1974,7531.91],[1975,7409.37],[1976,6867.75],[1977,6650.2],[1978,6628.02],[1979,6428.41],[1980,6015.19],[1981,6094.31],[1982,6068.05],[1983,6186.72],[1984,6116.87],[1985,5820.33],[1986,5905.2],[1987,6351.24],[1988,6524.14],[1989,6948.14],[1990,7296.54],[1991,7285.44],[1992,7404.92],[1993,7447.48],[1994,7497.59],[1995,7524.48],[1996,7316.26],[1997,7121.92],[1998,7012.28],[1999,6928.82],[2000,6934.03],[2001,6987.81],[2002,6994.77],[2003,7092.05],[2004,7093.44],[2005,7132],[2006,7291.22],[2007,7365.48],[2008,7261.39],[2009,7023.74]],"population":[[1800,401000],[1820,401000],[1850,399000],[1870,499000],[1900,720000],[1901,728000],[1902,737000],[1903,745000],[1904,754000],[1905,763000],[1906,772000],[1907,781000],[1908,790000],[1909,799000],[1910,808000],[1911,818000],[1912,827000],[1913,837000],[1914,840000],[1915,842000],[1916,845000],[1917,847000],[1918,850000],[1919,852000],[1920,855000],[1921,860000],[1922,879000],[1923,891000],[1924,900000],[1925,910000],[1926,930000],[1927,946000],[1928,966000],[1929,985000],[1930,1009000],[1931,1039000],[1932,1061000],[1933,1082000],[1934,1098000],[1935,1113000],[1936,1130000],[1937,1142000],[1938,1163000],[1939,1191000],[1940,1212000],[1941,1230000],[1942,1254000],[1943,1249000],[1944,1259000],[1945,1266000],[1946,1298000],[1947,1327000],[1948,1350000],[1949,1374000],[1950,1384550],[1951,1405615],[1952,1426095],[1953,1446425],[1954,1467585],[1955,1488805],[1956,1509975],[1957,1535090],[1958,1565755],[1959,1599115],[1960,1631784],[1961,1647918],[1962,1665128],[1963,1697847],[1964,1738997],[1965,1777397],[1966,1820082],[1967,1861096],[1968,1893477],[1969,1919615],[1970,1943787],[1971,1967012],[1972,1997616],[1973,2036377],[1974,2071146],[1975,2104879],[1976,2133388],[1977,2156814],[1978,2179441],[1979,2207245],[1980,2228803],[1981,2258368],[1982,2298309],[1983,2306556],[1984,2313362],[1985,2318652],[1986,2323182],[1987,2326606],[1988,2330226],[1989,2337517],[1990,2347922],[1991,2358643],[1992,2378618],[1993,2407463],[1994,2436866],[1995,2469389],[1996,2501477],[1997,2531311],[1998,2560447],[1999,2588786],[2000,2615467],[2001,2640289],[2002,2664659],[2003,2688706],[2004,2712355],[2005,2735520],[2006,2758124],[2007,2780132],[2008,2801544]],"lifeExpectancy":[[1800,34.2],[1881,34.2],[1882,40.1],[1883,38.1],[1884,37.2],[1885,37.8],[1886,36.9],[1887,35.5],[1888,38.6],[1889,37.6],[1890,34.3],[1891,37.3],[1892,39.2],[1893,38.6],[1894,39],[1895,37.4],[1896,37.6],[1897,37],[1898,39.1],[1899,37.6],[1900,37.8],[1901,38.1],[1902,40.4],[1903,34.6],[1904,33.6],[1905,37.6],[1906,32.4],[1907,29.5],[1908,36.8],[1909,37.3],[1910,36.7],[1911,37.9],[1912,34.4],[1913,37.5],[1914,38.2],[1915,37],[1916,35.6],[1917,31.7],[1918,26.4],[1919,36.6],[1920,35.4],[1921,30.7],[1922,37],[1923,38],[1924,38.6],[1925,38.9],[1926,40.7],[1927,39.4],[1928,41.6],[1929,43],[1930,45.3],[1931,42.7],[1932,44.2],[1933,41.6],[1934,44.4],[1935,44],[1936,44.4],[1937,47.2],[1938,45.9],[1939,48.5],[1940,47.6],[1941,49.4],[1942,49.8],[1943,50.3],[1944,49.1],[1945,49.1],[1946,51.4],[1947,50.4],[1948,51.7],[1949,53.9],[1950,56.65],[1951,57.14],[1952,58.1],[1953,59.02],[1954,59.9],[1955,60.74],[1956,61.54],[1957,62.29],[1958,63],[1959,63.66],[1960,64.28],[1961,64.85],[1962,65.38],[1963,65.85],[1964,66.28],[1965,66.68],[1966,67.05],[1967,67.39],[1968,67.71],[1969,68.02],[1970,68.32],[1971,68.61],[1972,68.89],[1973,69.16],[1974,69.41],[1975,69.64],[1976,69.84],[1977,70.02],[1978,70.16],[1979,70.28],[1980,70.38],[1981,70.47],[1982,70.54],[1983,70.62],[1984,70.7],[1985,70.78],[1986,70.87],[1987,70.96],[1988,71.04],[1989,71.12],[1990,71.18],[1991,71.24],[1992,71.28],[1993,71.31],[1994,71.32],[1995,71.31],[1996,71.28],[1997,71.23],[1998,71.16],[1999,71.08],[2000,71.02],[2001,70.98],[2002,70.98],[2003,71.03],[2004,71.13],[2005,71.28],[2006,71.46],[2007,71.68],[2008,71.89],[2009,72.11]]},{"name":"Martinique","region":"America","income":[[1800,944.05],[1820,944.05],[1913,1741.82],[1950,3009.89],[1973,10528.11],[1990,11068.35],[2001,13040.82],[2002,13561.81],[2003,13247.9],[2004,13925.33],[2005,14627.13]],"population":[[1800,84039],[1820,84039],[1950,216618],[1951,221631],[1952,226688],[1953,232524],[1954,239131],[1955,245815],[1956,252779],[1957,260147],[1958,267402],[1959,274591],[1960,281802],[1961,288810],[1962,295486],[1963,301371],[1964,306529],[1965,311445],[1966,315759],[1967,319163],[1968,322092],[1969,324121],[1970,325484],[1971,327676],[1972,330290],[1973,332137],[1974,333474],[1975,334654],[1976,335492],[1977,336148],[1978,336888],[1979,337943],[1980,339365],[1981,340940],[1982,342583],[1983,345978],[1984,349558],[1985,353188],[1986,356886],[1987,360841],[1988,365013],[1989,369305],[1990,373565],[1991,377676],[1992,381739],[1993,385826],[1994,389926],[1995,394021],[1996,398129],[1997,402265],[1998,406394],[1999,410487],[2000,414516],[2001,418454],[2002,422277],[2003,425966],[2004,429510],[2005,432900],[2006,436131],[2007,439202],[2008,442119]],"lifeExpectancy":[[1950,54.74],[1951,55.22],[1952,56.15],[1953,57.06],[1954,57.93],[1955,58.79],[1956,59.61],[1957,60.41],[1958,61.18],[1959,61.91],[1960,62.61],[1961,63.27],[1962,63.89],[1963,64.47],[1964,65.01],[1965,65.53],[1966,66.02],[1967,66.5],[1968,66.98],[1969,67.45],[1970,67.93],[1971,68.43],[1972,68.94],[1973,69.45],[1974,69.97],[1975,70.49],[1976,71],[1977,71.49],[1978,71.96],[1979,72.4],[1980,72.81],[1981,73.21],[1982,73.59],[1983,73.96],[1984,74.31],[1985,74.65],[1986,74.96],[1987,75.23],[1988,75.48],[1989,75.69],[1990,75.89],[1991,76.09],[1992,76.29],[1993,76.51],[1994,76.75],[1995,77],[1996,77.27],[1997,77.54],[1998,77.8],[1999,78.05],[2000,78.28],[2001,78.49],[2002,78.69],[2003,78.87],[2004,79.04],[2005,79.2],[2006,79.35],[2007,79.5],[2008,79.63],[2009,79.77]]},{"name":"Mexico","region":"America","income":[[1800,1053.6],[1820,1105.63],[1870,981.78],[1890,1472.82],[1895,1649.1],[1896,1675.45],[1897,1762.72],[1898,1838.1],[1899,1721.61],[1900,1709.31],[1901,1837.59],[1902,1686.64],[1903,1857.23],[1904,1869.64],[1905,2043.53],[1906,1998.24],[1907,2093.88],[1908,2067.87],[1909,2106.18],[1910,2102.03],[1911,2017.76],[1912,2000.96],[1913,1880.29],[1914,1883.54],[1915,1856.03],[1916,1999.11],[1917,2084.7],[1918,2165.95],[1919,2252.31],[1920,2395.46],[1921,2386.88],[1922,2404.07],[1923,2447.87],[1924,2368.93],[1925,2477.54],[1926,2586.29],[1927,2430.9],[1928,2406.84],[1929,2274.99],[1930,2095.67],[1931,2128.79],[1932,1774.36],[1933,1944.06],[1934,2041.55],[1935,2157.92],[1936,2292.82],[1937,2328.97],[1938,2326.41],[1939,2411.19],[1940,2402.91],[1941,2570.67],[1942,2644.12],[1943,2669.16],[1944,2813.56],[1945,2824.38],[1946,2932.21],[1947,2952.46],[1948,2992.76],[1949,3074.34],[1950,3293.78],[1951,3447.11],[1952,3478.13],[1953,3380.66],[1954,3614.58],[1955,3810.53],[1956,3953.72],[1957,4131.55],[1958,4224.17],[1959,4220.45],[1960,4433.09],[1961,4512.03],[1962,4581.61],[1963,4803.87],[1964,5213.6],[1965,5384.97],[1966,5584.87],[1967,5754.73],[1968,6036.64],[1969,6222.44],[1970,6450.93],[1971,6486.92],[1972,6809.41],[1973,7130.34],[1974,7322.16],[1975,7519.08],[1976,7630.74],[1977,7674.93],[1978,8156.87],[1979,8734.87],[1980,9319.56],[1981,9890.22],[1982,9611.15],[1983,9063.14],[1984,9177.23],[1985,9184.99],[1986,8713.36],[1987,8688.16],[1988,8628.26],[1989,8815.27],[1990,9103.39],[1991,9315.66],[1992,9472.38],[1993,9482.49],[1994,9733.59],[1995,8954.52],[1996,9274.7],[1997,9767.3],[1998,10108.77],[1999,10358.8],[2000,10894.51],[2001,10763.08],[2002,10742.44],[2003,10778.21],[2004,11118.69],[2005,11317],[2006,11772.08],[2007,12057.97],[2008,12135.33],[2009,11250.37]],"population":[[1820,6587000],[1850,7662000],[1870,9219000],[1871,9331000],[1872,9444000],[1873,9558000],[1874,9674000],[1875,9791000],[1876,9910000],[1877,10030000],[1878,10151000],[1879,10274000],[1880,10399000],[1881,10524000],[1882,10652000],[1883,10781000],[1884,10912000],[1885,11044000],[1886,11178000],[1887,11313000],[1888,11450000],[1889,11589000],[1890,11729000],[1891,11904000],[1892,12083000],[1893,12263000],[1894,12447000],[1895,12663000],[1896,12822000],[1897,13014000],[1898,13209000],[1899,13406000],[1900,13607000],[1901,13755000],[1902,13904000],[1903,14055000],[1904,14208000],[1905,14363000],[1906,14519000],[1907,14676000],[1908,14836000],[1909,14997000],[1910,15000000],[1911,14990000],[1912,14980000],[1913,14970000],[1914,14960000],[1915,14950000],[1916,14940000],[1917,14930000],[1918,14920000],[1919,14910000],[1920,14900000],[1921,14895000],[1922,15129000],[1923,15367000],[1924,15609000],[1925,15854000],[1926,16103000],[1927,16356000],[1928,16613000],[1929,16875000],[1930,17175000],[1931,17480000],[1932,17790000],[1933,18115000],[1934,18445000],[1935,18781000],[1936,19040000],[1937,19370000],[1938,19705000],[1939,20047000],[1940,20393000],[1941,20955000],[1942,21532000],[1943,22125000],[1944,22734000],[1945,23724000],[1946,24413000],[1947,25122000],[1948,25852000],[1949,26603000],[1950,28485180],[1951,29296235],[1952,30144317],[1953,31031279],[1954,31959113],[1955,32929914],[1956,33945886],[1957,35015548],[1958,36141955],[1959,37328466],[1960,38578505],[1961,39836230],[1962,41121485],[1963,42434264],[1964,43774575],[1965,45142399],[1966,46537832],[1967,47995559],[1968,49518803],[1969,51110928],[1970,52775158],[1971,54406901],[1972,55984294],[1973,57557303],[1974,59122839],[1975,60678045],[1976,62219964],[1977,63759976],[1978,65295990],[1979,66825878],[1980,68347479],[1981,69969263],[1982,71640904],[1983,73362881],[1984,75080138],[1985,76767225],[1986,78442430],[1987,80122492],[1988,81781816],[1989,83366836],[1990,84913652],[1991,86488032],[1992,88111030],[1993,89749141],[1994,91337896],[1995,92880353],[1996,94398579],[1997,95895146],[1998,97325063],[1999,98616905],[2000,99926620],[2001,101246961],[2002,102479927],[2003,103718062],[2004,104959594],[2005,106202903],[2006,107449525],[2007,108700891],[2008,109955400]],"lifeExpectancy":[[1800,26.9],[1890,26.9],[1893,23.29],[1894,26.62],[1895,29.52],[1896,28.8],[1897,26.24],[1898,27.03],[1899,24.98],[1900,27.58],[1901,26.65],[1902,28.37],[1903,28.68],[1904,29.09],[1905,26.8],[1906,27.88],[1907,27.97],[1908,28.72],[1909,29.21],[1910,27.41],[1922,32.6],[1923,33.5],[1924,32.8],[1925,32.1],[1926,34.2],[1927,40.3],[1928,34.5],[1929,35.4],[1930,36.2],[1931,37.7],[1932,38.4],[1933,37.3],[1934,38.2],[1935,40.4],[1936,38.3],[1937,36.8],[1938,39.4],[1939,45.5],[1940,39.2],[1941,42.6],[1942,39.8],[1943,42.8],[1944,43.2],[1945,44.2],[1946,44.8],[1947,46.3],[1948,48.3],[1949,45.8],[1950,48.56],[1951,49.12],[1952,50.21],[1953,51.25],[1954,52.24],[1955,53.18],[1956,54.07],[1957,54.9],[1958,55.69],[1959,56.41],[1960,57.07],[1961,57.66],[1962,58.18],[1963,58.64],[1964,59.06],[1965,59.43],[1966,59.79],[1967,60.15],[1968,60.52],[1969,60.92],[1970,61.35],[1971,61.82],[1972,62.32],[1973,62.84],[1974,63.37],[1975,63.92],[1976,64.47],[1977,65.01],[1978,65.55],[1979,66.06],[1980,66.56],[1981,67.04],[1982,67.5],[1983,67.94],[1984,68.37],[1985,68.79],[1986,69.2],[1987,69.61],[1988,70],[1989,70.4],[1990,70.8],[1991,71.19],[1992,71.59],[1993,71.98],[1994,72.37],[1995,72.74],[1996,73.1],[1997,73.43],[1998,73.73],[1999,74.01],[2000,74.26],[2001,74.51],[2002,74.75],[2003,74.99],[2004,75.24],[2005,75.49],[2006,75.74],[2007,75.99],[2008,76.23],[2009,76.47]]},{"name":"Netherlands Antilles","region":"America","income":[[1800,698.1],[1820,698.1],[1913,1288.03],[1970,10117.71],[1971,10647.82],[1972,11045.68],[1973,11405.41],[1974,11939.92],[1975,12156.49],[1976,12814.81],[1977,17335.5],[1978,18336.29],[1979,19045.02],[1980,20507.69],[1981,20565.55],[1982,20008.69],[1983,19721.51],[1984,19180.39],[1985,18592.1],[1986,17385.59],[1987,17406.53],[1988,17486.37],[1989,18682.47],[1990,18834.43],[1991,19081.35],[1992,19633.02],[1993,20520.88],[1994,21690.98],[1995,22159.94],[1996,22681.57],[1997,23267.56],[1998,22901.65],[1999,22746.86],[2000,22284.26],[2001,22605.42],[2002,22596.6],[2003,22741.81],[2004,22761.26],[2005,22700.41],[2006,22795.7],[2007,23039.61],[2008,23178.37]],"population":[[1800,42536],[1820,42536],[1950,109641],[1951,112935],[1952,115318],[1953,117751],[1954,120236],[1955,122772],[1956,125362],[1957,128007],[1958,130708],[1959,133466],[1960,136282],[1961,136679],[1962,133959],[1963,141865],[1964,144450],[1965,146841],[1966,148637],[1967,150529],[1968,153117],[1969,155768],[1970,158355],[1971,161491],[1972,163778],[1973,165204],[1974,167205],[1975,168549],[1976,169591],[1977,170574],[1978,170743],[1979,171297],[1980,172534],[1981,174179],[1982,176526],[1983,178902],[1984,181168],[1985,182923],[1986,184328],[1987,185666],[1988,186689],[1989,187630],[1990,188788],[1991,190140],[1992,192002],[1993,194496],[1994,196793],[1995,198914],[1996,201239],[1997,203533],[1998,205785],[1999,207987],[2000,210134],[2001,212226],[2002,214258],[2003,216226],[2004,218126],[2005,219958],[2006,221736],[2007,223472],[2008,225168]],"lifeExpectancy":[[1950,58.45],[1951,59],[1952,60.04],[1953,61.01],[1954,61.91],[1955,62.72],[1956,63.46],[1957,64.11],[1958,64.7],[1959,65.22],[1960,65.68],[1961,66.09],[1962,66.46],[1963,66.8],[1964,67.13],[1965,67.46],[1966,67.81],[1967,68.17],[1968,68.55],[1969,68.94],[1970,69.35],[1971,69.76],[1972,70.17],[1973,70.56],[1974,70.94],[1975,71.3],[1976,71.65],[1977,72],[1978,72.34],[1979,72.68],[1980,73.01],[1981,73.33],[1982,73.61],[1983,73.86],[1984,74.08],[1985,74.25],[1986,74.38],[1987,74.46],[1988,74.51],[1989,74.53],[1990,74.53],[1991,74.52],[1992,74.49],[1993,74.47],[1994,74.45],[1995,74.46],[1996,74.5],[1997,74.57],[1998,74.67],[1999,74.79],[2000,74.95],[2001,75.11],[2002,75.29],[2003,75.47],[2004,75.63],[2005,75.79],[2006,75.94],[2007,76.09],[2008,76.23],[2009,76.38]]},{"name":"Nicaragua","region":"America","income":[[1800,726.97],[1820,726.97],[1920,2070.64],[1921,2149.99],[1922,1937.98],[1923,2074.07],[1924,2164.26],[1925,2390.12],[1926,2046.39],[1927,2056.17],[1928,2603.82],[1929,2866.65],[1930,2317.41],[1931,2136.64],[1932,1922.97],[1933,2384.59],[1934,2134.13],[1935,2109.32],[1936,1633.72],[1937,1725.31],[1938,1761.99],[1939,2107.27],[1940,2247.93],[1941,2429.83],[1942,2285.7],[1943,2449.68],[1944,2371.59],[1945,2330.71],[1946,2451.96],[1947,2383.58],[1948,2539.03],[1949,2420.55],[1950,2646.8],[1951,2742.44],[1952,3112.36],[1953,3092.08],[1954,3279.8],[1955,3393.42],[1956,3288.89],[1957,3457.42],[1958,3362.04],[1959,3307.13],[1960,3248.3],[1961,3382.87],[1962,3634.36],[1963,3902.48],[1964,4222.45],[1965,4478.93],[1966,4481.54],[1967,4643.39],[1968,4559.44],[1969,4709.94],[1970,4605.7],[1971,4678.35],[1972,4688.59],[1973,4785.64],[1974,5299.98],[1975,5125.38],[1976,5219.41],[1977,5486.37],[1978,4949.85],[1979,3524.06],[1980,3528.64],[1981,3594.8],[1982,3470.34],[1983,3551.18],[1984,3397.84],[1985,3185.74],[1986,3050.94],[1987,2955.98],[1988,2560.22],[1989,2457.13],[1990,2355.47],[1991,2234.44],[1992,2170.15],[1993,2097.6],[1994,2119.13],[1995,2153.69],[1996,2196.82],[1997,2253.02],[1998,2291.86],[1999,2678.53],[2000,2490.8],[2001,2511.22],[2002,2474.55],[2003,2484.75],[2004,2559.93],[2005,2611],[2006,2657.49],[2007,2675.66],[2008,2688.74],[2009,2591.39]],"population":[[1800,186000],[1820,186000],[1850,300000],[1870,337000],[1900,478000],[1901,485000],[1902,492000],[1903,499000],[1904,507000],[1905,514000],[1906,522000],[1907,529000],[1908,537000],[1909,545000],[1910,553000],[1911,561000],[1912,570000],[1913,578000],[1914,580000],[1915,595000],[1916,604000],[1917,613000],[1918,622000],[1919,631000],[1920,640000],[1921,640000],[1922,650000],[1923,650000],[1924,660000],[1925,660000],[1926,670000],[1927,670000],[1928,670000],[1929,680000],[1930,680000],[1931,690000],[1932,690000],[1933,700000],[1934,710000],[1935,730000],[1936,750000],[1937,770000],[1938,780000],[1939,810000],[1940,830000],[1941,840000],[1942,860000],[1943,880000],[1944,900000],[1945,920000],[1946,950000],[1947,980000],[1948,1000000],[1949,1030000],[1950,1097916],[1951,1131307],[1952,1165790],[1953,1201514],[1954,1238630],[1955,1277288],[1956,1317387],[1957,1358828],[1958,1401760],[1959,1446333],[1960,1492698],[1961,1540819],[1962,1590597],[1963,1642083],[1964,1695330],[1965,1750391],[1966,1807123],[1967,1865490],[1968,1925707],[1969,1987988],[1970,2052544],[1971,2120111],[1972,2182908],[1973,2247491],[1974,2319602],[1975,2394786],[1976,2473102],[1977,2554598],[1978,2609107],[1979,2689042],[1980,2805321],[1981,2901332],[1982,2979423],[1983,3048600],[1984,3121094],[1985,3190053],[1986,3262816],[1987,3344353],[1988,3433924],[1989,3530673],[1990,3683746],[1991,3871551],[1992,4017939],[1993,4140517],[1994,4262327],[1995,4382555],[1996,4498580],[1997,4609572],[1998,4717284],[1999,4824619],[2000,4932420],[2001,5039717],[2002,5146848],[2003,5253603],[2004,5359759],[2005,5465100],[2006,5570129],[2007,5675356],[2008,5780586]],"lifeExpectancy":[[1800,25.4],[1916,25.4],[1921,24.35],[1940,34.47],[1950,41.06],[1951,41.36],[1952,41.97],[1953,42.58],[1954,43.2],[1955,43.82],[1956,44.45],[1957,45.08],[1958,45.72],[1959,46.35],[1960,47],[1961,47.64],[1962,48.29],[1963,48.95],[1964,49.6],[1965,50.27],[1966,50.94],[1967,51.62],[1968,52.3],[1969,52.98],[1970,53.64],[1971,54.29],[1972,54.9],[1973,55.48],[1974,56.02],[1975,56.51],[1976,56.96],[1977,57.37],[1978,57.76],[1979,58.13],[1980,58.5],[1981,58.87],[1982,59.27],[1983,59.69],[1984,60.15],[1985,60.67],[1986,61.26],[1987,61.91],[1988,62.62],[1989,63.37],[1990,64.13],[1991,64.88],[1992,65.59],[1993,66.24],[1994,66.82],[1995,67.34],[1996,67.81],[1997,68.27],[1998,68.72],[1999,69.18],[2000,69.64],[2001,70.12],[2002,70.59],[2003,71.05],[2004,71.49],[2005,71.92],[2006,72.32],[2007,72.71],[2008,73.09],[2009,73.44]]},{"name":"Panama","region":"America","income":[[1800,686.66],[1820,686.66],[1945,2756.5],[1946,2811.71],[1947,2870.98],[1948,2641.44],[1949,2650.17],[1950,2500.03],[1951,2415.69],[1952,2480.38],[1953,2569.85],[1954,2600.24],[1955,2681.59],[1956,2750.55],[1957,2961.8],[1958,2924.12],[1959,3029.42],[1960,3119.95],[1961,3358.29],[1962,3536.54],[1963,3760.37],[1964,3810.21],[1965,4025.8],[1966,4200.79],[1967,4421.01],[1968,4607.85],[1969,4826.57],[1970,4976.35],[1971,5234.49],[1972,5364.25],[1973,5546.03],[1974,5521.94],[1975,5478.34],[1976,5437.09],[1977,5351.91],[1978,5773.1],[1979,5895.08],[1980,6643.42],[1981,6777.81],[1982,7009.6],[1983,6916.65],[1984,6746.94],[1985,6921.11],[1986,7003.71],[1987,7034.78],[1988,5821.91],[1989,5685.88],[1990,5834.2],[1991,6236.41],[1992,6618.74],[1993,6840.32],[1994,6922.27],[1995,6920.48],[1996,6951.6],[1997,7113.69],[1998,7255.6],[1999,7355.14],[2000,7405.97],[2001,7317.09],[2002,7356.03],[2003,7550.69],[2004,7986.1],[2005,8399],[2006,8960.44],[2007,9868.16],[2008,10733.83],[2009,10796.68]],"population":[[1800,78842],[1820,78842],[1850,135000],[1870,176000],[1900,263000],[1901,269000],[1902,275000],[1903,281000],[1904,287000],[1905,293000],[1906,299000],[1907,306000],[1908,312000],[1909,319000],[1910,326000],[1911,333000],[1912,341000],[1913,348000],[1914,365000],[1915,383000],[1916,402000],[1917,422000],[1918,442000],[1919,464000],[1920,487000],[1921,489000],[1922,491000],[1923,493000],[1924,495000],[1925,497000],[1926,499000],[1927,502000],[1928,504000],[1929,506000],[1930,515000],[1931,527000],[1932,543000],[1933,559000],[1934,576000],[1935,592000],[1936,608000],[1937,623000],[1938,640000],[1939,656000],[1940,697000],[1941,720000],[1942,773000],[1943,795000],[1944,784000],[1945,791000],[1946,788000],[1947,804000],[1948,822000],[1949,838000],[1950,892502],[1951,915560],[1952,940080],[1953,962188],[1954,985066],[1955,1010655],[1956,1036550],[1957,1063506],[1958,1085241],[1959,1115146],[1960,1147610],[1961,1181175],[1962,1215725],[1963,1251278],[1964,1287993],[1965,1325975],[1966,1365169],[1967,1405486],[1968,1446758],[1969,1488794],[1970,1531038],[1971,1573444],[1972,1616384],[1973,1659161],[1974,1706336],[1975,1747783],[1976,1789842],[1977,1839782],[1978,1872588],[1979,1914853],[1980,1956454],[1981,1995823],[1982,2036305],[1983,2077631],[1984,2120220],[1985,2164335],[1986,2209048],[1987,2253639],[1988,2298640],[1989,2344226],[1990,2390419],[1991,2437528],[1992,2484997],[1993,2531926],[1994,2579616],[1995,2629303],[1996,2680414],[1997,2734531],[1998,2788234],[1999,2838492],[2000,2889485],[2001,2941167],[2002,2990875],[2003,3039748],[2004,3089531],[2005,3140232],[2006,3191319],[2007,3242173],[2008,3292693]],"lifeExpectancy":[[1800,32.9],[1915,32.9],[1930,35.9],[1940,42.4],[1950,53.26],[1951,53.79],[1952,54.83],[1953,55.79],[1954,56.69],[1955,57.53],[1956,58.3],[1957,59.01],[1958,59.66],[1959,60.26],[1960,60.81],[1961,61.32],[1962,61.8],[1963,62.27],[1964,62.72],[1965,63.17],[1966,63.61],[1967,64.05],[1968,64.48],[1969,64.91],[1970,65.35],[1971,65.8],[1972,66.27],[1973,66.76],[1974,67.26],[1975,67.76],[1976,68.26],[1977,68.74],[1978,69.19],[1979,69.62],[1980,70],[1981,70.35],[1982,70.66],[1983,70.94],[1984,71.2],[1985,71.42],[1986,71.61],[1987,71.78],[1988,71.92],[1989,72.04],[1990,72.16],[1991,72.3],[1992,72.46],[1993,72.65],[1994,72.86],[1995,73.11],[1996,73.36],[1997,73.61],[1998,73.86],[1999,74.09],[2000,74.29],[2001,74.48],[2002,74.66],[2003,74.84],[2004,75.01],[2005,75.17],[2006,75.33],[2007,75.5],[2008,75.65],[2009,75.81]]},{"name":"Paraguay","region":"America","income":[[1800,564.16],[1820,564.16],[1939,2455.59],[1940,2271.97],[1941,2256.51],[1942,2333.36],[1943,2328.36],[1944,2323.8],[1945,2191.57],[1946,2352.9],[1947,1998.8],[1948,1976.22],[1949,2255.95],[1950,2054.03],[1951,2038.81],[1952,1952.31],[1953,1955.91],[1954,1938.39],[1955,1974.52],[1956,2006.18],[1957,2046.15],[1958,2107.31],[1959,2049.46],[1960,2016.41],[1961,2058.78],[1962,2148.03],[1963,2150.97],[1964,2187.33],[1965,2253.94],[1966,2219.58],[1967,2299.38],[1968,2318.87],[1969,2345.99],[1970,2426.65],[1971,2465.48],[1972,2523.34],[1973,2642.34],[1974,2779.72],[1975,2878.12],[1976,3000.98],[1977,3248.37],[1978,3525.63],[1979,3829.88],[1980,4283.09],[1981,4534.67],[1982,4258.5],[1983,4015.03],[1984,4023.96],[1985,4064.65],[1986,3943.64],[1987,3998.88],[1988,4136.87],[1989,4254.41],[1990,4261.11],[1991,4244.88],[1992,4196.41],[1993,4242.62],[1994,4248.93],[1995,4318.04],[1996,4254.72],[1997,4247.4],[1998,4117.41],[1999,4028.5],[2000,3907.3],[2001,3885.14],[2002,3783.67],[2003,3828.38],[2004,3885.94],[2005,3900],[2006,3989.49],[2007,4175.72],[2008,4332.38],[2009,4054.3]],"population":[[1800,143000],[1820,143000],[1850,350000],[1870,384000],[1900,440000],[1901,450000],[1902,461000],[1903,472000],[1904,483000],[1905,494000],[1906,505000],[1907,517000],[1908,529000],[1909,542000],[1910,554000],[1911,567000],[1912,580000],[1913,594000],[1914,608000],[1915,622000],[1916,637000],[1917,652000],[1918,667000],[1919,683000],[1920,699000],[1921,715000],[1922,732000],[1923,749000],[1924,767000],[1925,785000],[1926,803000],[1927,822000],[1928,841000],[1929,860000],[1930,880000],[1931,901000],[1932,922000],[1933,944000],[1934,966000],[1935,988000],[1936,1012000],[1937,1036000],[1938,1061000],[1939,1086000],[1940,1111000],[1941,1137000],[1942,1164000],[1943,1191000],[1944,1219000],[1945,1247000],[1946,1275000],[1947,1305000],[1948,1335000],[1949,1366000],[1950,1475669],[1951,1515299],[1952,1555876],[1953,1597419],[1954,1639946],[1955,1683477],[1956,1726702],[1957,1770902],[1958,1816096],[1959,1862301],[1960,1909538],[1961,1959034],[1962,2009813],[1963,2061907],[1964,2115353],[1965,2170183],[1966,2228306],[1967,2287985],[1968,2349262],[1969,2412181],[1970,2476785],[1971,2544518],[1972,2614104],[1973,2692135],[1974,2772696],[1975,2850419],[1976,2919486],[1977,2984494],[1978,3050953],[1979,3119329],[1980,3193047],[1981,3275777],[1982,3366439],[1983,3462731],[1984,3563622],[1985,3668292],[1986,3775922],[1987,3886512],[1988,4000058],[1989,4116564],[1990,4236056],[1991,4358536],[1992,4483945],[1993,4612341],[1994,4743715],[1995,4877951],[1996,5014837],[1997,5154123],[1998,5295745],[1999,5439657],[2000,5585828],[2001,5734139],[2002,5884491],[2003,6036900],[2004,6191368],[2005,6347884],[2006,6506464],[2007,6667147],[2008,6829969]],"lifeExpectancy":[[1800,35.5],[1932,35.5],[1950,62.58],[1951,62.57],[1952,62.57],[1953,62.61],[1954,62.69],[1955,62.8],[1956,62.95],[1957,63.13],[1958,63.34],[1959,63.56],[1960,63.79],[1961,64.02],[1962,64.22],[1963,64.41],[1964,64.57],[1965,64.71],[1966,64.83],[1967,64.96],[1968,65.11],[1969,65.26],[1970,65.43],[1971,65.6],[1972,65.77],[1973,65.93],[1974,66.07],[1975,66.2],[1976,66.32],[1977,66.44],[1978,66.55],[1979,66.66],[1980,66.77],[1981,66.88],[1982,66.98],[1983,67.08],[1984,67.19],[1985,67.29],[1986,67.41],[1987,67.54],[1988,67.69],[1989,67.84],[1990,68.02],[1991,68.19],[1992,68.37],[1993,68.55],[1994,68.73],[1995,68.92],[1996,69.11],[1997,69.33],[1998,69.56],[1999,69.81],[2000,70.07],[2001,70.34],[2002,70.6],[2003,70.84],[2004,71.07],[2005,71.29],[2006,71.49],[2007,71.68],[2008,71.88],[2009,72.07]]},{"name":"Peru","region":"America","income":[[1800,697.3],[1820,697.3],[1896,842.17],[1897,909.29],[1898,955.97],[1899,996.45],[1900,1036.35],[1901,1098.3],[1902,1143.88],[1903,1206.27],[1904,1231.36],[1905,1304.9],[1906,1391.58],[1907,1460.21],[1908,1469.46],[1909,1475.52],[1910,1482.18],[1911,1495.16],[1912,1528.49],[1913,1559.94],[1914,1530.83],[1915,1642.07],[1916,1789.86],[1917,1832.51],[1918,1820.58],[1919,1857.88],[1920,1852.87],[1921,1899.58],[1922,2031.68],[1923,2138.02],[1924,2302.87],[1925,2327.35],[1926,2523.87],[1927,2529.18],[1928,2650.85],[1929,2882.33],[1930,2512.78],[1931,2272.66],[1932,2150.42],[1933,2354.03],[1934,2629.71],[1935,2830.3],[1936,2918.46],[1937,2910.29],[1938,2908.69],[1939,2877.83],[1940,2887.16],[1941,2841.44],[1942,2729.71],[1943,2726.15],[1944,2910.25],[1945,2967.32],[1946,3029.7],[1947,3062.49],[1948,3110.57],[1949,3288.95],[1950,3486.91],[1951,3665.31],[1952,3758.52],[1953,3896.3],[1954,3902.72],[1955,4084.31],[1956,4157.3],[1957,4245.26],[1958,4144.74],[1959,4053.34],[1960,4486.39],[1961,4747.91],[1962,4957.04],[1963,5038.46],[1964,5235.97],[1965,5430.6],[1966,5724.34],[1967,5788.09],[1968,5568.88],[1969,5555.3],[1970,5823.86],[1971,5916.94],[1972,5937.83],[1973,6078.65],[1974,6224.46],[1975,6536.7],[1976,6453.03],[1977,6281.29],[1978,6118.28],[1979,6317.33],[1980,6441.29],[1981,6561.48],[1982,6434.5],[1983,5452.54],[1984,5578.5],[1985,5563.34],[1986,5987.6],[1987,6360.94],[1988,5714.65],[1989,4911.48],[1990,4564.34],[1991,4581.33],[1992,4446.38],[1993,4603.44],[1994,5123.24],[1995,5453.85],[1996,5474.06],[1997,5838.35],[1998,5745.32],[1999,5704.59],[2000,5791.37],[2001,5714.9],[2002,5909.02],[2003,6054.91],[2004,6161.25],[2005,6466],[2006,6860.37],[2007,7317.57],[2008,7912.56],[2009,7858.97]],"population":[[1820,1317000],[1850,2001000],[1870,2606000],[1890,3346000],[1896,3470000],[1897,3513000],[1898,3558000],[1899,3603000],[1900,3648000],[1901,3694000],[1902,3741000],[1903,3788000],[1904,3836000],[1905,3885000],[1906,3934000],[1907,3984000],[1908,4034000],[1909,4085000],[1910,4137000],[1911,4189000],[1912,4242000],[1913,4295000],[1914,4350000],[1915,4405000],[1916,4460000],[1917,4517000],[1918,4574000],[1919,4631000],[1920,4690000],[1921,4764000],[1922,4838000],[1923,4914000],[1924,4992000],[1925,5070000],[1926,5150000],[1927,5230000],[1928,5312000],[1929,5396000],[1930,5480000],[1931,5569000],[1932,5660000],[1933,5752000],[1934,5846000],[1935,5941000],[1936,6038000],[1937,6137000],[1938,6237000],[1939,6338000],[1940,6440000],[1941,6550000],[1942,6662000],[1943,6776000],[1944,6892000],[1945,7010000],[1946,7130000],[1947,7252000],[1948,7376000],[1949,7502000],[1950,7632500],[1951,7826200],[1952,8025700],[1953,8232100],[1954,8447000],[1955,8671500],[1956,8904900],[1957,9146100],[1958,9396700],[1959,9657800],[1960,9931000],[1961,10217500],[1962,10516500],[1963,10825800],[1964,11143500],[1965,11467300],[1966,11796400],[1967,12132200],[1968,12476000],[1969,12829100],[1970,13192800],[1971,13568300],[1972,13954700],[1973,14350300],[1974,14753100],[1975,15161199],[1976,15573199],[1977,15990099],[1978,16414399],[1979,16848699],[1980,17295298],[1981,17754798],[1982,18125129],[1983,18516941],[1984,18927692],[1985,19348926],[1986,19771935],[1987,20195924],[1988,20625082],[1989,21063800],[1990,21511443],[1991,21967278],[1992,22430449],[1993,22900004],[1994,23374974],[1995,23846388],[1996,24304899],[1997,24748122],[1998,25174087],[1999,25581874],[2000,25979722],[2001,26376033],[2002,26769436],[2003,27158869],[2004,27544305],[2005,27925628],[2006,28302603],[2007,28674757],[2008,29041593]],"lifeExpectancy":[[1800,35.7],[1940,35.7],[1950,43.11],[1951,43.29],[1952,43.67],[1953,44.08],[1954,44.53],[1955,45],[1956,45.51],[1957,46.04],[1958,46.59],[1959,47.14],[1960,47.7],[1961,48.24],[1962,48.76],[1963,49.26],[1964,49.74],[1965,50.23],[1966,50.75],[1967,51.33],[1968,51.98],[1969,52.7],[1970,53.46],[1971,54.25],[1972,55.02],[1973,55.76],[1974,56.45],[1975,57.1],[1976,57.7],[1977,58.29],[1978,58.88],[1979,59.46],[1980,60.06],[1981,60.66],[1982,61.26],[1983,61.86],[1984,62.44],[1985,63.01],[1986,63.56],[1987,64.09],[1988,64.6],[1989,65.1],[1990,65.58],[1991,66.06],[1992,66.53],[1993,67.02],[1994,67.51],[1995,68.01],[1996,68.51],[1997,69.03],[1998,69.53],[1999,70.03],[2000,70.51],[2001,70.96],[2002,71.39],[2003,71.78],[2004,72.14],[2005,72.46],[2006,72.75],[2007,73.01],[2008,73.25],[2009,73.47]]},{"name":"Puerto Rico","region":"America","income":[[1800,775.1],[1820,775.1],[1913,1265.58],[1950,2822.05],[1951,2903.07],[1952,3081.96],[1953,3252.09],[1954,3370.58],[1955,3487.49],[1956,3738.97],[1957,3907.16],[1958,3951.38],[1959,4263.73],[1960,4502.88],[1961,4840.8],[1962,5108.34],[1963,5529.93],[1964,5793.24],[1965,6211.83],[1966,6572.88],[1967,6929.28],[1968,7191.45],[1969,7688.13],[1970,8357.4],[1971,8743.88],[1972,9123.04],[1973,9611.77],[1974,9539.61],[1975,9143.75],[1976,9336.84],[1977,9770.52],[1978,10292.77],[1979,10747.13],[1980,10771.18],[1981,10787.87],[1982,10330.99],[1983,10263.66],[1984,10902.91],[1985,11022.16],[1986,11812.68],[1987,12281.34],[1988,12965.94],[1989,13487.7],[1990,13873.73],[1991,14093.02],[1992,14641.59],[1993,15193.09],[1994,15682.44],[1995,16245.19],[1996,16594.09],[1997,16999.43],[1998,17443.02],[1999,18084.73],[2000,18568.22],[2001,18861.59],[2002,18855.61],[2003,19067.16],[2004,19287.91],[2005,19725.45],[2006,19366.01],[2007,19016.23],[2008,18970.51]],"population":[[1800,155000],[1815,221000],[1820,248000],[1832,330000],[1850,495000],[1860,583000],[1870,645000],[1877,732000],[1887,799000],[1899,953000],[1900,959000],[1901,974000],[1902,990000],[1903,1006000],[1904,1022000],[1905,1039000],[1906,1056000],[1907,1073000],[1908,1090000],[1909,1108000],[1910,1126000],[1911,1144000],[1912,1162000],[1913,1181000],[1914,1199000],[1915,1217000],[1916,1235000],[1917,1254000],[1918,1273000],[1919,1292000],[1920,1312000],[1921,1336000],[1922,1359000],[1923,1383000],[1924,1407000],[1925,1431000],[1926,1455000],[1927,1478000],[1928,1502000],[1929,1526000],[1930,1552000],[1931,1584000],[1932,1615000],[1933,1647000],[1934,1679000],[1935,1710000],[1936,1743000],[1937,1777000],[1938,1810000],[1939,1844000],[1940,1880000],[1941,1935000],[1942,1987000],[1943,2033000],[1944,2062000],[1945,2099000],[1946,2141000],[1947,2162000],[1948,2187000],[1949,2197000],[1950,2218000],[1951,2235000],[1952,2227000],[1953,2204000],[1954,2214000],[1955,2250000],[1956,2249000],[1957,2260000],[1958,2299000],[1959,2322000],[1960,2358000],[1961,2402514],[1962,2448046],[1963,2496601],[1964,2552181],[1965,2596774],[1966,2627368],[1967,2648961],[1968,2673568],[1969,2722232],[1970,2721754],[1971,2766299],[1972,2847132],[1973,2863420],[1974,2886600],[1975,2935124],[1976,3026125],[1977,3080828],[1978,3117884],[1979,3168446],[1980,3209648],[1981,3238968],[1982,3279001],[1983,3316031],[1984,3350037],[1985,3382106],[1986,3413303],[1987,3444468],[1988,3474992],[1989,3505600],[1990,3536910],[1991,3562110],[1992,3585176],[1993,3615497],[1994,3649237],[1995,3683103],[1996,3724655],[1997,3759430],[1998,3781101],[1999,3800081],[2000,3815909],[2001,3839190],[2002,3859606],[2003,3877881],[2004,3894855],[2005,3911299],[2006,3927188],[2007,3942491],[2008,3957169]],"lifeExpectancy":[[1800,30.43],[1894,30.43],[1902,33.3],[1903,30.36],[1910,38.17],[1920,38.46],[1930,40.65],[1940,46.01],[1950,61.71],[1951,62.43],[1952,63.8],[1953,65],[1954,66.05],[1955,66.93],[1956,67.67],[1957,68.25],[1958,68.7],[1959,69.05],[1960,69.3],[1961,69.51],[1962,69.7],[1963,69.89],[1964,70.12],[1965,70.37],[1966,70.65],[1967,70.92],[1968,71.18],[1969,71.42],[1970,71.65],[1971,71.87],[1972,72.11],[1973,72.36],[1974,72.61],[1975,72.86],[1976,73.08],[1977,73.28],[1978,73.43],[1979,73.54],[1980,73.63],[1981,73.71],[1982,73.81],[1983,73.94],[1984,74.09],[1985,74.24],[1986,74.38],[1987,74.47],[1988,74.51],[1989,74.5],[1990,74.45],[1991,74.37],[1992,74.3],[1993,74.25],[1994,74.26],[1995,74.35],[1996,74.55],[1997,74.87],[1998,75.29],[1999,75.78],[2000,76.32],[2001,76.86],[2002,77.37],[2003,77.8],[2004,78.15],[2005,78.4],[2006,78.58],[2007,78.72],[2008,78.84],[2009,78.95]]},{"name":"Suriname","region":"America","income":[[1800,1004.13],[1820,1004.13],[1913,1852.67],[1950,3201.44],[1970,4958.82],[1971,5250.97],[1972,5504.44],[1973,5758.36],[1974,5960.04],[1975,5413.8],[1976,5953.52],[1977,6622.72],[1978,7028.64],[1979,6631.28],[1980,6045.94],[1981,6417.63],[1982,6061.25],[1983,5722.81],[1984,5518.3],[1985,6193.03],[1986,6009.13],[1987,5508.17],[1988,5930.97],[1989,6148.98],[1990,5863.39],[1991,5962.17],[1992,5974.26],[1993,5624.37],[1994,5400.78],[1995,5509.17],[1996,5520.94],[1997,5589.34],[1998,5703.02],[1999,5510.23],[2000,5677.29],[2001,5962.11],[2002,6070.68],[2003,6446.04],[2004,6880.09],[2005,7234],[2006,7425.02],[2007,7722.28],[2008,8091.8],[2009,8199.03]],"population":[[1800,80721],[1820,80721],[1950,208068],[1951,213358],[1952,219442],[1953,226016],[1954,233027],[1955,240491],[1956,248363],[1957,256534],[1958,265294],[1959,274847],[1960,284506],[1961,294466],[1962,305124],[1963,316001],[1964,327023],[1965,336711],[1966,345810],[1967,354353],[1968,361735],[1969,368064],[1970,372898],[1971,377191],[1972,381410],[1973,383662],[1974,380911],[1975,363393],[1976,353047],[1977,360780],[1978,366025],[1979,363631],[1980,354860],[1981,352967],[1982,359611],[1983,365602],[1984,370748],[1985,375592],[1986,379472],[1987,382559],[1988,386349],[1989,390987],[1990,395000],[1991,398992],[1992,402943],[1993,406817],[1994,410577],[1995,414188],[1996,417635],[1997,420899],[1998,423948],[1999,426759],[2000,429323],[2001,431635],[2002,433682],[2003,435449],[2004,436935],[2005,438144],[2006,439117],[2007,439894],[2008,440486]],"lifeExpectancy":[[1800,32.9],[1925,32.9],[1950,54.7],[1951,55.05],[1952,55.73],[1953,56.36],[1954,56.95],[1955,57.5],[1956,58],[1957,58.47],[1958,58.9],[1959,59.3],[1960,59.68],[1961,60.05],[1962,60.41],[1963,60.78],[1964,61.14],[1965,61.52],[1966,61.9],[1967,62.27],[1968,62.63],[1969,62.98],[1970,63.31],[1971,63.61],[1972,63.89],[1973,64.14],[1974,64.37],[1975,64.59],[1976,64.81],[1977,65.05],[1978,65.3],[1979,65.56],[1980,65.83],[1981,66.09],[1982,66.33],[1983,66.53],[1984,66.71],[1985,66.85],[1986,66.96],[1987,67.06],[1988,67.15],[1989,67.24],[1990,67.33],[1991,67.44],[1992,67.55],[1993,67.66],[1994,67.77],[1995,67.88],[1996,67.97],[1997,68.03],[1998,68.08],[1999,68.1],[2000,68.11],[2001,68.12],[2002,68.15],[2003,68.21],[2004,68.3],[2005,68.43],[2006,68.58],[2007,68.76],[2008,68.96],[2009,69.16]]},{"name":"Trinidad and Tobago","region":"America","income":[[1800,774.21],[1820,774.21],[1913,1264.12],[1950,2818.8],[1951,2987.51],[1952,3023.27],[1953,3033.59],[1954,3002.88],[1955,3311.35],[1956,3881.04],[1957,4100.39],[1958,4303.08],[1959,4405.84],[1960,4795.86],[1961,4888.04],[1962,4997.52],[1963,5154.49],[1964,5217.56],[1965,5393.58],[1966,5550.35],[1967,5621.37],[1968,5895.03],[1969,6058.54],[1970,6324.94],[1971,6346.12],[1972,6619.55],[1973,6663.4],[1974,6945.61],[1975,6995.35],[1976,7555.17],[1977,7899.55],[1978,8683.78],[1979,8937.55],[1980,9498.49],[1981,9815.18],[1982,9119.53],[1983,8280.37],[1984,8647.69],[1985,8180.31],[1986,7818.14],[1987,7388.6],[1988,7059.56],[1989,6990.8],[1990,7113.56],[1991,7398.63],[1992,7370.99],[1993,7340.13],[1994,7705.76],[1995,8071.16],[1996,8449.63],[1997,8792.57],[1998,9269.85],[1999,9952.12],[2000,10496.91],[2001,11020.92],[2002,11460.6],[2003,13030.45],[2004,13978.56],[2005,15352],[2006,17384.13],[2007,18141.92],[2008,18511.09],[2009,17826.05]],"population":[[1800,60000],[1820,60000],[1850,80000],[1870,124000],[1900,268000],[1901,274000],[1902,279000],[1903,285000],[1904,291000],[1905,298000],[1906,304000],[1907,310000],[1908,317000],[1909,324000],[1910,331000],[1911,338000],[1912,345000],[1913,352000],[1914,357000],[1915,362000],[1916,367000],[1917,373000],[1918,378000],[1919,383000],[1920,389000],[1921,367000],[1922,371000],[1923,376000],[1924,379000],[1925,382000],[1926,385000],[1927,388000],[1928,392000],[1929,398000],[1930,405000],[1931,412000],[1932,417000],[1933,422000],[1934,428000],[1935,435000],[1936,442000],[1937,450000],[1938,458000],[1939,466000],[1940,476000],[1941,492000],[1942,510000],[1943,525000],[1944,536000],[1945,547000],[1946,561000],[1947,583000],[1948,600000],[1949,616000],[1950,632000],[1951,648700],[1952,662850],[1953,678300],[1954,697500],[1955,720800],[1956,742500],[1957,764900],[1958,788600],[1959,817050],[1960,841150],[1961,861387],[1962,887498],[1963,904380],[1964,923887],[1965,939255],[1966,952535],[1967,960155],[1968,963086],[1969,962927],[1970,955000],[1971,961605],[1972,975199],[1973,984786],[1974,995364],[1975,1006931],[1976,1021480],[1977,1039009],[1978,1055527],[1979,1073027],[1980,1090513],[1981,1101836],[1982,1116479],[1983,1133265],[1984,1150426],[1985,1166353],[1986,1180346],[1987,1191336],[1988,1198392],[1989,1200303],[1990,1198247],[1991,1192417],[1992,1183669],[1993,1174430],[1994,1165700],[1995,1158553],[1996,1148699],[1997,1138101],[1998,1131314],[1999,1125375],[2000,1118204],[2001,1110217],[2002,1101832],[2003,1093146],[2004,1084206],[2005,1075066],[2006,1065842],[2007,1056608],[2008,1047366]],"lifeExpectancy":[[1800,32.9],[1829,32.9],[1835,38.8],[1921,38.8],[1931,45.7],[1946,54.5],[1950,58.22],[1951,58.42],[1952,58.83],[1953,59.3],[1954,59.81],[1955,60.36],[1956,60.96],[1957,61.6],[1958,62.25],[1959,62.9],[1960,63.52],[1961,64.08],[1962,64.55],[1963,64.92],[1964,65.18],[1965,65.35],[1966,65.43],[1967,65.47],[1968,65.5],[1969,65.54],[1970,65.61],[1971,65.72],[1972,65.86],[1973,66.03],[1974,66.22],[1975,66.42],[1976,66.63],[1977,66.84],[1978,67.03],[1979,67.2],[1980,67.36],[1981,67.51],[1982,67.67],[1983,67.83],[1984,67.99],[1985,68.16],[1986,68.34],[1987,68.51],[1988,68.66],[1989,68.8],[1990,68.92],[1991,69],[1992,69.06],[1993,69.08],[1994,69.08],[1995,69.04],[1996,68.96],[1997,68.85],[1998,68.72],[1999,68.59],[2000,68.48],[2001,68.41],[2002,68.39],[2003,68.44],[2004,68.57],[2005,68.75],[2006,68.97],[2007,69.22],[2008,69.46],[2009,69.7]]},{"name":"United States","region":"America","income":[[1800,1912.62],[1801,1948.59],[1802,1981.63],[1803,1946.61],[1804,1944.22],[1805,1987.88],[1806,2024.49],[1807,2045.45],[1808,1896.7],[1809,1993.22],[1810,2050.52],[1811,2093.55],[1812,2056.15],[1813,2079.25],[1814,2119.35],[1815,2111.19],[1816,2023.09],[1817,2021.75],[1818,2027.3],[1819,2023.02],[1820,2011.22],[1821,2043.38],[1822,2101.55],[1823,2077.84],[1824,2134.86],[1825,2184.19],[1826,2200.15],[1827,2210.11],[1828,2209.17],[1829,2133.96],[1830,2293.67],[1831,2438],[1832,2530.55],[1833,2620.99],[1834,2491.55],[1835,2589.99],[1836,2629.47],[1837,2543.05],[1838,2520.65],[1839,2646.12],[1840,2512.15],[1841,2457.92],[1842,2436.73],[1843,2476.52],[1844,2614.36],[1845,2656.44],[1846,2673.07],[1847,2744.83],[1848,2817.92],[1849,2743.7],[1850,2754.9],[1851,2871.34],[1852,3022.03],[1853,3235.59],[1854,3244.9],[1855,3172.17],[1856,3239.39],[1857,3167.39],[1858,3182.83],[1859,3270.94],[1860,3359.31],[1861,3288.25],[1862,3393.61],[1863,3617.64],[1864,3739.47],[1865,3541.92],[1866,3514],[1867,3632],[1868,3681.88],[1869,3781.48],[1870,3970.93],[1871,4044.9],[1872,4106.03],[1873,4198.88],[1874,4055.76],[1875,4170.62],[1876,4131.67],[1877,4181.78],[1878,4275.61],[1879,4718.64],[1880,5178.86],[1881,5239.22],[1882,5428.53],[1883,5402.76],[1884,5362.11],[1885,5277.75],[1886,5332.39],[1887,5472.26],[1888,5330.85],[1889,5549.39],[1890,5524.7],[1891,5584.39],[1892,5717.15],[1893,5579.84],[1894,5297.88],[1895,5828.93],[1896,5603.9],[1897,5962.94],[1898,6008.89],[1899,6609.78],[1900,6624.3],[1901,7305.78],[1902,7282.17],[1903,7356.13],[1904,7494.66],[1905,8031.68],[1906,8205.42],[1907,7928.61],[1908,7339.85],[1909,8048.39],[1910,7913.7],[1911,8010.71],[1912,8317.33],[1913,8448.56],[1914,7615.96],[1915,7758.77],[1916,8875.24],[1917,8714.46],[1918,9254.58],[1919,8908.37],[1920,8568.17],[1921,8068.82],[1922,8504.51],[1923,9512.22],[1924,9544.98],[1925,9581.57],[1926,9990.36],[1927,9869.44],[1928,9892.79],[1929,10387.38],[1930,9346.2],[1931,8640.93],[1932,7433.95],[1933,7267.63],[1934,7977.82],[1935,8601.16],[1936,9629.63],[1937,10028.34],[1938,9569.07],[1939,10225.26],[1940,10948.06],[1941,12667.38],[1942,14819.55],[1943,16980.87],[1944,18085.1],[1945,17614.95],[1946,15431.41],[1947,14931.55],[1948,15266.38],[1949,14866.24],[1950,15855.86],[1951,16750.74],[1952,17039.38],[1953,17471.28],[1954,16979.26],[1955,17822.45],[1956,17783.27],[1957,17749.5],[1958,17217.39],[1959,18084.11],[1960,18175.43],[1961,18226.62],[1962,18978.45],[1963,19461.1],[1964,20243.98],[1965,21209.93],[1966,22263.22],[1967,22495.68],[1968,23268.21],[1969,23669.41],[1970,23345.77],[1971,23744.67],[1972,24654.04],[1973,25742],[1974,25281.7],[1975,24889.6],[1976,25881.72],[1977,26715.14],[1978,27814.18],[1979,28278.91],[1980,27838.11],[1981,28160.14],[1982,27243.47],[1983,28119.69],[1984,29785.25],[1985,30636.21],[1986,31297.31],[1987,31953.81],[1988,32860.52],[1989,33587.09],[1990,33710.39],[1991,33076.87],[1992,33589.59],[1993,33914.89],[1994,34730.56],[1995,35053.29],[1996,35807],[1997,36847.81],[1998,37811.68],[1999,38912.58],[2000,39758.5],[2001,39474.11],[2002,39535.84],[2003,40044.18],[2004,40956.4],[2005,41674],[2006,42385.18],[2007,42866.22],[2008,42656.49],[2009,41256.08]],"population":[[1820,9980510],[1821,10298969],[1822,10625503],[1823,10951077],[1824,11276695],[1825,11602355],[1826,11928057],[1827,12250905],[1828,12580590],[1829,12906416],[1830,13240314],[1831,13658580],[1832,14077890],[1833,14496235],[1834,14914618],[1835,15334042],[1836,15752501],[1837,16170997],[1838,16590533],[1839,17009101],[1840,17443768],[1841,18056100],[1842,18667464],[1843,19278865],[1844,19890301],[1845,20502776],[1846,21114282],[1847,21725822],[1848,22337396],[1849,22950007],[1850,23579718],[1851,24405303],[1852,25230918],[1853,26156953],[1854,26882238],[1855,27707943],[1856,28534680],[1857,29360442],[1858,30186232],[1859,31012051],[1860,31838901],[1861,32677742],[1862,33515609],[1863,34354509],[1864,35192433],[1865,36031388],[1866,36869368],[1867,37708378],[1868,38546412],[1869,39385476],[1870,40240630],[1871,41098000],[1872,42136000],[1873,43174000],[1874,44212000],[1875,45245000],[1876,46287000],[1877,47325000],[1878,48362000],[1879,49400000],[1880,50458000],[1881,51743000],[1882,53027000],[1883,54311000],[1884,55595000],[1885,56879000],[1886,58164000],[1887,59448000],[1888,60732000],[1889,62016000],[1890,63302000],[1891,64612000],[1892,65922000],[1893,67231000],[1894,68541000],[1895,69851000],[1896,71161000],[1897,72471000],[1898,73781000],[1899,75091000],[1900,76391000],[1901,77888000],[1902,79469000],[1903,80946000],[1904,82485000],[1905,84147000],[1906,85770000],[1907,87339000],[1908,89055000],[1909,90845000],[1910,92767000],[1911,94234000],[1912,95703000],[1913,97606000],[1914,99505000],[1915,100941000],[1916,102364000],[1917,103817000],[1918,104958000],[1919,105473000],[1920,106881000],[1921,108964000],[1922,110484000],[1923,112387000],[1924,114558000],[1925,116284000],[1926,117857000],[1927,119502000],[1928,120971000],[1929,122245000],[1930,123668000],[1931,124633000],[1932,125436000],[1933,126180000],[1934,126978000],[1935,127859000],[1936,128681000],[1937,129464000],[1938,130476000],[1939,131539000],[1940,132637000],[1941,133922000],[1942,135386000],[1943,137272000],[1944,138937000],[1945,140474000],[1946,141940000],[1947,144688000],[1948,147203000],[1949,149770000],[1950,152271000],[1951,154878000],[1952,157553000],[1953,160184000],[1954,163026000],[1955,165931000],[1956,168903000],[1957,171984000],[1958,174882000],[1959,177830000],[1960,180671000],[1961,183691000],[1962,186538000],[1963,189242000],[1964,191889000],[1965,194303000],[1966,196560000],[1967,198712000],[1968,200706000],[1969,202677000],[1970,205052000],[1971,207661000],[1972,209896000],[1973,211909000],[1974,213854000],[1975,215973000],[1976,218035000],[1977,220239000],[1978,222585000],[1979,225055000],[1980,227726463],[1981,229966237],[1982,232187835],[1983,234307207],[1984,236348292],[1985,238466283],[1986,240650755],[1987,242803533],[1988,245021414],[1989,247341697],[1990,250131894],[1991,253492503],[1992,256894189],[1993,260255352],[1994,263435673],[1995,266557091],[1996,269667391],[1997,272911760],[1998,276115288],[1999,279294713],[2000,282338631],[2001,285023886],[2002,287675526],[2003,290342554],[2004,293027571],[2005,295734134],[2006,298444215],[2007,301139947],[2008,303824646]],"lifeExpectancy":[[1800,39.41],[1880,39.41],[1890,45.21],[1901,49.3],[1902,50.5],[1903,50.6],[1904,49.6],[1905,50.3],[1906,50.1],[1907,50.2],[1908,51.9],[1909,52.8],[1910,51.8],[1911,53.4],[1912,54.1],[1913,53.5],[1914,54.6],[1915,55.1],[1916,54.2],[1917,54],[1918,47.2],[1919,55.3],[1920,55.4],[1921,58.2],[1922,58.1],[1923,57.5],[1924,58.5],[1925,58.5],[1926,57.9],[1927,59.4],[1928,58.3],[1929,58.5],[1930,59.6],[1931,60.3],[1932,61],[1933,60.95],[1934,60.31],[1935,60.97],[1936,60.42],[1937,61.11],[1938,62.44],[1939,63.12],[1940,63.28],[1941,63.84],[1942,64.63],[1943,64.34],[1944,65.13],[1945,65.63],[1946,66.33],[1947,66.73],[1948,67.3],[1949,67.68],[1950,68.12],[1951,68.22],[1952,68.44],[1953,68.79],[1954,69.58],[1955,69.63],[1956,69.71],[1957,69.49],[1958,69.76],[1959,69.98],[1960,69.91],[1961,70.32],[1962,70.21],[1963,70.04],[1964,70.33],[1965,70.41],[1966,70.43],[1967,70.76],[1968,70.42],[1969,70.66],[1970,70.92],[1971,71.24],[1972,71.34],[1973,71.54],[1974,72.08],[1975,72.68],[1976,72.99],[1977,73.38],[1978,73.58],[1979,74.03],[1980,73.93],[1981,74.36],[1982,74.65],[1983,74.71],[1984,74.82],[1985,74.79],[1986,74.87],[1987,75.01],[1988,75.03],[1989,75.31],[1990,75.6],[1991,75.8],[1992,76.08],[1993,75.83],[1994,76],[1995,76.09],[1996,76.44],[1997,76.8],[1998,76.97],[1999,76.97],[2000,77.13],[2001,77.25],[2002,77.31],[2003,77.49],[2004,77.92],[2005,77.93],[2006,78.21],[2007,79.09],[2008,79.27],[2009,79.43]]},{"name":"Uruguay","region":"America","income":[[1800,784.46],[1820,784.46],[1870,2515.22],[1871,2512],[1872,3035.52],[1873,2999.99],[1874,2670.33],[1875,2240.25],[1876,2427.41],[1877,2448.19],[1878,2591.78],[1879,2247.79],[1880,2401.2],[1881,2227.77],[1882,2398.64],[1883,2764.11],[1884,2680.57],[1885,2963.18],[1886,3008.19],[1887,2614.93],[1888,3134.99],[1889,2785.56],[1890,2476.55],[1891,2641.64],[1892,2646.24],[1893,2810.95],[1894,3064.67],[1895,2962.06],[1896,3049.71],[1897,2875.86],[1898,2595.08],[1899,2607.73],[1900,2558.84],[1901,2575.86],[1902,2967.03],[1903,3016.04],[1904,3044.56],[1905,2692.36],[1906,2921.72],[1907,3180.2],[1908,3429.15],[1909,3410.15],[1910,3616.95],[1911,3410.32],[1912,4045.87],[1913,3817.78],[1914,3061.19],[1915,2849.17],[1916,2892.97],[1917,3134.27],[1918,3261.16],[1919,3615.78],[1920,3084.06],[1921,3173],[1922,3550.25],[1923,3656.14],[1924,3918.22],[1925,3676.65],[1926,3918.96],[1927,4379.65],[1928,4504.87],[1929,4437.56],[1930,4960.9],[1931,4037.12],[1932,3686.22],[1933,3172.25],[1934,3714.87],[1935,3870.21],[1936,3989.47],[1937,3993.26],[1938,4240.05],[1939,4258.09],[1940,4221.98],[1941,4247.21],[1942,3849.73],[1943,3841.54],[1944,4272.8],[1945,4340.79],[1946,4709.27],[1947,4973.97],[1948,5080.7],[1949,5194.38],[1950,5374.01],[1951,5714.81],[1952,5716.77],[1953,5926.63],[1954,6217.57],[1955,6172.35],[1956,6182.26],[1957,6150.77],[1958,6230.9],[1959,5605],[1960,5720.89],[1961,5808.7],[1962,5603.36],[1963,5558.9],[1964,5603.15],[1965,5605.11],[1966,5737.16],[1967,5444.62],[1968,5475.23],[1969,5756.43],[1970,5979.13],[1971,5916.95],[1972,5703.41],[1973,5737.31],[1974,5909.05],[1975,6252.62],[1976,6468.66],[1977,6504.34],[1978,6808.86],[1979,7189.87],[1980,7586.16],[1981,7690.7],[1982,6920.22],[1983,6475.01],[1984,6366.47],[1985,6420.41],[1986,6946.57],[1987,7452.4],[1988,7407.36],[1989,7453.36],[1990,7466.41],[1991,7628.84],[1992,8137],[1993,8331.94],[1994,8728.07],[1995,8495.07],[1996,8856.81],[1997,9230.24],[1998,9590.07],[1999,9266.79],[2000,9092.32],[2001,8732.2],[2002,7727],[2003,7853.82],[2004,8735],[2005,9266],[2006,9641.29],[2007,10331.31],[2008,11178.99],[2009,11461.03]],"population":[[1800,55000],[1820,55000],[1850,132000],[1870,343000],[1871,354000],[1872,364000],[1873,376000],[1874,387000],[1875,399000],[1876,411000],[1877,424000],[1878,437000],[1879,450000],[1880,464000],[1881,482000],[1882,502000],[1883,522000],[1884,543000],[1885,564000],[1886,587000],[1887,610000],[1888,635000],[1889,660000],[1890,686000],[1891,706000],[1892,727000],[1893,748000],[1894,770000],[1895,792000],[1896,815000],[1897,839000],[1898,864000],[1899,889000],[1900,915000],[1901,930000],[1902,945000],[1903,961000],[1904,977000],[1905,993000],[1906,1009000],[1907,1026000],[1908,1043000],[1909,1062000],[1910,1081000],[1911,1112000],[1912,1144000],[1913,1177000],[1914,1223000],[1915,1246000],[1916,1269000],[1917,1292000],[1918,1316000],[1919,1341000],[1920,1371000],[1921,1402000],[1922,1433000],[1923,1465000],[1924,1498000],[1925,1534000],[1926,1571000],[1927,1608000],[1928,1646000],[1929,1685000],[1930,1713000],[1931,1741000],[1932,1770000],[1933,1799000],[1934,1829000],[1935,1859000],[1936,1889000],[1937,1921000],[1938,1952000],[1939,1944000],[1940,1965000],[1941,1987000],[1942,2010000],[1943,2032000],[1944,2055000],[1945,2081000],[1946,2107000],[1947,2134000],[1948,2160000],[1949,2188000],[1950,2194275],[1951,2223060],[1952,2252965],[1953,2283920],[1954,2316543],[1955,2353136],[1956,2389290],[1957,2424959],[1958,2460411],[1959,2495022],[1960,2530969],[1961,2563794],[1962,2598466],[1963,2632111],[1964,2663610],[1965,2693133],[1966,2721207],[1967,2748579],[1968,2776607],[1969,2801859],[1970,2823659],[1971,2826042],[1972,2829526],[1973,2834115],[1974,2838213],[1975,2841818],[1976,2857453],[1977,2873520],[1978,2889495],[1979,2905131],[1980,2919851],[1981,2935649],[1982,2953997],[1983,2972570],[1984,2990097],[1985,3008270],[1986,3026971],[1987,3045153],[1988,3063668],[1989,3084065],[1990,3105708],[1991,3127574],[1992,3149262],[1993,3170958],[1994,3193413],[1995,3215423],[1996,3238280],[1997,3262838],[1998,3284853],[1999,3304234],[2000,3323876],[2001,3343797],[2002,3363085],[2003,3381606],[2004,3399237],[2005,3415920],[2006,3431932],[2007,3447496],[2008,3462531]],"lifeExpectancy":[[1800,32.9],[1925,32.9],[1950,65.98],[1951,66.04],[1952,66.18],[1953,66.33],[1954,66.51],[1955,66.71],[1956,66.93],[1957,67.17],[1958,67.41],[1959,67.66],[1960,67.89],[1961,68.11],[1962,68.29],[1963,68.44],[1964,68.54],[1965,68.6],[1966,68.63],[1967,68.64],[1968,68.65],[1969,68.66],[1970,68.69],[1971,68.73],[1972,68.8],[1973,68.88],[1974,69],[1975,69.14],[1976,69.32],[1977,69.53],[1978,69.76],[1979,70.02],[1980,70.28],[1981,70.56],[1982,70.83],[1983,71.1],[1984,71.35],[1985,71.58],[1986,71.8],[1987,72],[1988,72.19],[1989,72.37],[1990,72.54],[1991,72.72],[1992,72.91],[1993,73.11],[1994,73.32],[1995,73.54],[1996,73.77],[1997,74],[1998,74.23],[1999,74.45],[2000,74.66],[2001,74.88],[2002,75.08],[2003,75.3],[2004,75.51],[2005,75.71],[2006,75.92],[2007,76.12],[2008,76.31],[2009,76.5]]},{"name":"Albania","region":"Europe & Central Asia","income":[[1800,601.22],[1820,613.83],[1870,682.67],[1890,914.81],[1900,1048.26],[1910,1194.13],[1913,1240.6],[1929,1417.53],[1950,1532.35],[1951,1598.49],[1952,1601.06],[1953,1665.79],[1954,1714.69],[1955,1807.13],[1956,1825.3],[1957,1942.28],[1958,2029.79],[1959,2113.35],[1960,2220.34],[1961,2238.79],[1962,2312.89],[1963,2391.78],[1964,2473.7],[1965,2563.95],[1966,2660.07],[1967,2760.2],[1968,2859.81],[1969,2956.94],[1970,3066.02],[1971,3188.58],[1972,3313.42],[1973,3478.46],[1974,3491.43],[1975,3503.59],[1976,3517.62],[1977,3533],[1978,3549.26],[1979,3566.57],[1980,3591.76],[1981,3611.03],[1982,3630.88],[1983,3652.08],[1984,3672.87],[1985,3692.09],[1986,3715.55],[1987,3738.93],[1988,3762.61],[1989,3790.98],[1990,3824.85],[1991,2717.57],[1992,2497.44],[1993,2716.65],[1994,2918.82],[1995,3285.53],[1996,3569.59],[1997,3193.05],[1998,3584.77],[1999,3928.28],[2000,4195.21],[2001,4476.05],[2002,4604.21],[2003,4855.21],[2004,5115.25],[2005,5369],[2006,5635.21],[2007,5967.02],[2008,6399.81],[2009,6546.27]],"population":[[1820,437000],[1850,500000],[1870,603000],[1890,726000],[1900,800000],[1910,874000],[1913,898000],[1920,932000],[1921,937000],[1922,942000],[1923,947000],[1924,952000],[1925,956000],[1926,962000],[1927,967000],[1928,972000],[1929,977000],[1930,982000],[1931,988000],[1932,993000],[1933,998000],[1934,1003000],[1935,1009000],[1936,1014000],[1937,1030000],[1938,1040000],[1939,1070000],[1940,1088000],[1941,1100000],[1942,1117000],[1943,1119000],[1944,1122000],[1945,1138000],[1946,1154000],[1947,1175000],[1948,1192000],[1949,1209000],[1950,1227156],[1951,1254119],[1952,1282697],[1953,1314608],[1954,1352982],[1955,1392164],[1956,1434476],[1957,1476505],[1958,1521417],[1959,1571329],[1960,1623114],[1961,1676635],[1962,1728137],[1963,1779715],[1964,1832284],[1965,1883652],[1966,1932963],[1967,1984060],[1968,2038698],[1969,2100263],[1970,2156612],[1971,2208719],[1972,2263554],[1973,2295691],[1974,2347924],[1975,2401108],[1976,2454824],[1977,2509048],[1978,2563376],[1979,2617679],[1980,2671412],[1981,2724272],[1982,2780097],[1983,2837315],[1984,2895998],[1985,2956697],[1986,3015438],[1987,3075321],[1988,3136843],[1989,3195800],[1990,3250778],[1991,3294227],[1992,3326498],[1993,3351656],[1994,3378424],[1995,3400516],[1996,3414733],[1997,3428038],[1998,3441234],[1999,3457493],[2000,3473835],[2001,3490304],[2002,3508512],[2003,3526642],[2004,3544808],[2005,3563112],[2006,3581655],[2007,3600523],[2008,3619778]],"lifeExpectancy":[[1800,35.4],[1929,35.4],[1950,54.16],[1951,54.37],[1952,54.85],[1953,55.44],[1954,56.15],[1955,56.98],[1956,57.91],[1957,58.94],[1958,60.04],[1959,61.16],[1960,62.25],[1961,63.27],[1962,64.16],[1963,64.89],[1964,65.44],[1965,65.83],[1966,66.1],[1967,66.31],[1968,66.51],[1969,66.73],[1970,66.98],[1971,67.25],[1972,67.53],[1973,67.8],[1974,68.06],[1975,68.31],[1976,68.56],[1977,68.82],[1978,69.08],[1979,69.36],[1980,69.66],[1981,69.98],[1982,70.32],[1983,70.67],[1984,71.02],[1985,71.34],[1986,71.6],[1987,71.78],[1988,71.88],[1989,71.91],[1990,71.9],[1991,71.86],[1992,71.84],[1993,71.87],[1994,71.97],[1995,72.17],[1996,72.47],[1997,72.87],[1998,73.33],[1999,73.84],[2000,74.36],[2001,74.86],[2002,75.31],[2003,75.69],[2004,75.99],[2005,76.21],[2006,76.37],[2007,76.5],[2008,76.62],[2009,76.74]]},{"name":"Armenia","region":"Europe & Central Asia","income":[[1800,502.64],[1820,513.22],[1913,1144.01],[1950,2241.72],[1973,2849.09],[1990,2809.07],[1991,2436.61],[1992,1442.94],[1993,1375.72],[1994,1498.94],[1995,1632.31],[1996,1731.63],[1997,1791.35],[1998,1928.33],[1999,1992.96],[2000,2114.06],[2001,2328.46],[2002,2692.3],[2003,3078.9],[2004,3413.91],[2005,3903],[2006,4413.18],[2007,5011.56],[2008,5338.64],[2009,4523.44]],"population":[[1800,413326],[1820,413326],[1950,1355269],[1951,1379204],[1952,1416722],[1953,1455777],[1954,1505668],[1955,1565329],[1956,1617460],[1957,1672403],[1958,1733125],[1959,1796363],[1960,1868852],[1961,1943799],[1962,2006853],[1963,2065618],[1964,2134940],[1965,2205833],[1966,2273695],[1967,2338063],[1968,2402358],[1969,2463153],[1970,2519745],[1971,2581671],[1972,2647035],[1973,2712997],[1974,2776539],[1975,2834136],[1976,2892704],[1977,2954907],[1978,3014042],[1979,3066726],[1980,3115289],[1981,3166098],[1982,3218691],[1983,3270153],[1984,3322394],[1985,3373532],[1986,3421978],[1987,3468857],[1988,3515614],[1989,3325992],[1990,3376783],[1991,3437479],[1992,3378331],[1993,3231570],[1994,3126094],[1995,3068751],[1996,3063395],[1997,3059000],[1998,3049147],[1999,3047620],[2000,3042556],[2001,3027590],[2002,3013818],[2003,3001712],[2004,2991360],[2005,2982904],[2006,2976372],[2007,2971650],[2008,2968586]],"lifeExpectancy":[[1950,61.94],[1951,62.15],[1952,62.58],[1953,63.01],[1954,63.44],[1955,63.86],[1956,64.28],[1957,64.71],[1958,65.13],[1959,65.56],[1960,65.99],[1961,66.42],[1962,66.86],[1963,67.3],[1964,67.74],[1965,68.18],[1966,68.61],[1967,69.04],[1968,69.45],[1969,69.83],[1970,70.17],[1971,70.44],[1972,70.63],[1973,70.74],[1974,70.79],[1975,70.79],[1976,70.79],[1977,70.8],[1978,70.84],[1979,70.89],[1980,70.93],[1981,70.91],[1982,70.78],[1983,70.52],[1984,70.16],[1985,69.71],[1986,69.22],[1987,68.75],[1988,68.35],[1989,68.06],[1990,67.89],[1991,67.86],[1992,67.96],[1993,68.14],[1994,68.41],[1995,68.76],[1996,69.18],[1997,69.65],[1998,70.16],[1999,70.68],[2000,71.19],[2001,71.66],[2002,72.1],[2003,72.49],[2004,72.83],[2005,73.13],[2006,73.38],[2007,73.61],[2008,73.82],[2009,74.03]]},{"name":"Austria","region":"Europe & Central Asia","income":[[1800,1434.51],[1820,1550.01],[1821,1574.98],[1822,1600.35],[1823,1626.12],[1824,1652.32],[1825,1678.93],[1826,1705.97],[1827,1733.45],[1828,1761.37],[1829,1789.74],[1830,1818.56],[1831,1837.1],[1832,1855.82],[1833,1874.73],[1834,1893.83],[1835,1913.13],[1836,1932.63],[1837,1952.33],[1838,1972.22],[1839,1992.32],[1840,2012.62],[1841,2034.4],[1842,2056.41],[1843,2078.65],[1844,2101.14],[1845,2123.87],[1846,2146.85],[1847,2170.08],[1848,2193.56],[1849,2217.29],[1850,2241.28],[1851,2262.88],[1852,2284.7],[1853,2306.73],[1854,2328.97],[1855,2351.42],[1856,2374.09],[1857,2396.98],[1858,2420.09],[1859,2443.42],[1860,2466.98],[1861,2483.91],[1862,2500.97],[1863,2518.14],[1864,2535.43],[1865,2552.84],[1866,2570.37],[1867,2588.02],[1868,2605.79],[1869,2623.68],[1870,2641.7],[1871,2813.04],[1872,2815.2],[1873,2730.96],[1874,2834.04],[1875,2829.2],[1876,2873.94],[1877,2952.65],[1878,3031.03],[1879,2990.81],[1880,3013.1],[1881,3116],[1882,3115.19],[1883,3222.36],[1884,3287.4],[1885,3245.89],[1886,3329.95],[1887,3538.38],[1888,3508.79],[1889,3454.42],[1890,3619.16],[1891,3720.23],[1892,3771.43],[1893,3764.68],[1894,3951.4],[1895,4024.65],[1896,4053.25],[1897,4105.88],[1898,4303.41],[1899,4359.56],[1900,4362.27],[1901,4344.52],[1902,4477.8],[1903,4480.79],[1904,4513.37],[1905,4728.12],[1906,4870.98],[1907,5130.41],[1908,5113.09],[1909,5056.77],[1910,5090.03],[1911,5205.8],[1912,5422.19],[1913,5360.93],[1914,4448.44],[1915,4104.04],[1916,4064.74],[1917,4000.87],[1918,3952.16],[1919,3494.55],[1920,3731.71],[1921,4099.62],[1922,4451.32],[1923,4396.76],[1924,4892.64],[1925,5208.47],[1926,5279.81],[1927,5422.72],[1928,5657.6],[1929,5721.43],[1930,5546.91],[1931,5085.87],[1932,4547.49],[1933,4382.76],[1934,4411.25],[1935,4496.45],[1936,4632.65],[1937,4881.74],[1938,5506.35],[1939,6336.15],[1940,6124.69],[1941,6524.02],[1942,6161.23],[1943,6287.8],[1944,5888.21],[1945,2667.85],[1946,3026.57],[1947,3351.41],[1948,4276.52],[1949,5094.41],[1950,5733.1],[1951,6124.93],[1952,6137.08],[1953,6399.79],[1954,7045.97],[1955,7817.25],[1956,8348.45],[1957,8842.6],[1958,9137.3],[1959,9360.85],[1960,10083.83],[1961,10560.97],[1962,10750.72],[1963,11116.7],[1964,11705.63],[1965,11964.28],[1966,12549.33],[1967,12834.6],[1968,13335.56],[1969,14125.32],[1970,15078.77],[1971,15779.07],[1972,16661.63],[1973,17379.33],[1974,18033.98],[1975,18016.37],[1976,18874.3],[1977,19749.42],[1978,19693.62],[1979,20803.4],[1980,21284.71],[1981,21220.89],[1982,21597.08],[1983,22266.66],[1984,22336.95],[1985,22821.2],[1986,23329.16],[1987,23687.83],[1988,24371.18],[1989,25307.87],[1990,26135],[1991,26744.4],[1992,27042.02],[1993,26882.04],[1994,27463.48],[1995,27918.82],[1996,28602.35],[1997,29095.92],[1998,30107.98],[1999,31039.62],[2000,32008.5],[2001,32196.42],[2002,32417.61],[2003,32741.19],[2004,33455.69],[2005,34108],[2006,35161.23],[2007,36348.95],[2008,37032.76],[2009,35636.42]],"population":[[1820,3369000],[1821,3386000],[1822,3402000],[1823,3419000],[1824,3436000],[1825,3452000],[1826,3469000],[1827,3486000],[1828,3504000],[1829,3521000],[1830,3538000],[1831,3555000],[1832,3573000],[1833,3590000],[1834,3608000],[1835,3626000],[1836,3614000],[1837,3662000],[1838,3680000],[1839,3698000],[1840,3716000],[1841,3739000],[1842,3762000],[1843,3785000],[1844,3808000],[1845,3831000],[1846,3855000],[1847,3878000],[1848,3902000],[1849,3926000],[1850,3950000],[1851,3978000],[1852,4006000],[1853,4035000],[1854,4063000],[1855,4092000],[1856,4120000],[1857,4150000],[1858,4178000],[1859,4206000],[1860,4235000],[1861,4263000],[1862,4292000],[1863,4321000],[1864,4350000],[1865,4380000],[1866,4409000],[1867,4439000],[1868,4469000],[1869,4499000],[1870,4520000],[1871,4562000],[1872,4604000],[1873,4646000],[1874,4688000],[1875,4730000],[1876,4772000],[1877,4815000],[1878,4857000],[1879,4899000],[1880,4941000],[1881,4985000],[1882,5030000],[1883,5075000],[1884,5121000],[1885,5166000],[1886,5212000],[1887,5257000],[1888,5303000],[1889,5348000],[1890,5394000],[1891,5446000],[1892,5504000],[1893,5563000],[1894,5622000],[1895,5680000],[1896,5739000],[1897,5798000],[1898,5856000],[1899,5915000],[1900,5973000],[1901,6035000],[1902,6099000],[1903,6164000],[1904,6228000],[1905,6292000],[1906,6357000],[1907,6421000],[1908,6485000],[1909,6550000],[1910,6614000],[1911,6669000],[1912,6724000],[1913,6767000],[1914,6806000],[1915,6843000],[1916,6825000],[1917,6785000],[1918,6727000],[1919,6420000],[1920,6455000],[1921,6504000],[1922,6528000],[1923,6543000],[1924,6562000],[1925,6582000],[1926,6603000],[1927,6623000],[1928,6643000],[1929,6664000],[1930,6684000],[1931,6705000],[1932,6725000],[1933,6746000],[1934,6760000],[1935,6761000],[1936,6758000],[1937,6755000],[1938,6753000],[1939,6653000],[1940,6705000],[1941,6745000],[1942,6783000],[1943,6808000],[1944,6834000],[1945,6799000],[1946,7000000],[1947,6971000],[1948,6956000],[1949,6943000],[1950,6935100],[1951,6935451],[1952,6927772],[1953,6932483],[1954,6940209],[1955,6946885],[1956,6952359],[1957,6965860],[1958,6987358],[1959,7014331],[1960,7047437],[1961,7086299],[1962,7129864],[1963,7175811],[1964,7223801],[1965,7270889],[1966,7322066],[1967,7376998],[1968,7415403],[1969,7441055],[1970,7467086],[1971,7500482],[1972,7544201],[1973,7586115],[1974,7599038],[1975,7578903],[1976,7565525],[1977,7568430],[1978,7562305],[1979,7549425],[1980,7549433],[1981,7564629],[1982,7574613],[1983,7552896],[1984,7554132],[1985,7559776],[1986,7568242],[1987,7578903],[1988,7599791],[1989,7627861],[1990,7722953],[1991,7818423],[1992,7914969],[1993,7988599],[1994,8027540],[1995,8047433],[1996,8060852],[1997,8069876],[1998,8078622],[1999,8094156],[2000,8113413],[2001,8131690],[2002,8148312],[2003,8162656],[2004,8174762],[2005,8184691],[2006,8192880],[2007,8199783],[2008,8205533]],"lifeExpectancy":[[1800,34.4],[1870,34.4],[1881,35],[1891,37.3],[1901,42],[1903,40.1],[1911,45.1],[1931,56.45],[1947,61.31],[1948,63.24],[1949,63.43],[1950,64.88],[1951,65.26],[1952,66.8],[1953,67.29],[1954,67.32],[1955,67.6],[1956,67.72],[1957,67.48],[1958,68.49],[1959,68.42],[1960,68.78],[1961,69.75],[1962,69.54],[1963,69.67],[1964,70.16],[1965,69.95],[1966,70.26],[1967,70.14],[1968,70.29],[1969,70.06],[1970,70.11],[1971,70.31],[1972,70.63],[1973,71.21],[1974,71.2],[1975,71.33],[1976,71.82],[1977,72.17],[1978,72.25],[1979,72.56],[1980,72.7],[1981,73.02],[1982,73.18],[1983,73.25],[1984,73.79],[1985,74.01],[1986,74.49],[1987,74.93],[1988,75.41],[1989,75.5],[1990,75.77],[1991,75.83],[1992,76.04],[1993,76.27],[1994,76.59],[1995,76.83],[1996,77.1],[1997,77.5],[1998,77.87],[1999,78.05],[2000,78.33],[2001,78.83],[2002,78.96],[2003,78.96],[2004,79.47],[2005,79.64],[2006,80.1],[2007,80.3],[2008,80.51],[2009,80.23]]},{"name":"Azerbaijan","region":"Europe & Central Asia","income":[[1800,639.95],[1820,653.43],[1913,1456.54],[1950,2854.15],[1973,4425.48],[1990,4629.49],[1991,4528.84],[1992,3455.54],[1993,2627.69],[1994,2088.93],[1995,1828.59],[1996,1843.19],[1997,1943.29],[1998,2132.38],[1999,2285.7],[2000,2533.17],[2001,2775.74],[2002,3059.18],[2003,3387.79],[2004,3760.11],[2005,4648],[2006,6183.5],[2007,7646.12],[2008,8381.63],[2009,9088.42]],"population":[[1800,879960],[1820,879960],[1950,2885332],[1951,2983082],[1952,3090973],[1953,3158974],[1954,3222581],[1955,3313718],[1956,3416717],[1957,3526313],[1958,3630590],[1959,3740596],[1960,3881546],[1961,4033503],[1962,4157301],[1963,4283470],[1964,4430183],[1965,4566962],[1966,4701730],[1967,4827284],[1968,4945231],[1969,5059334],[1970,5168973],[1971,5283659],[1972,5393681],[1973,5497774],[1974,5599407],[1975,5696117],[1976,5789818],[1977,5886578],[1978,5986427],[1979,6082087],[1980,6173361],[1981,6270531],[1982,6369133],[1983,6470276],[1984,6578901],[1985,6681687],[1986,6776473],[1987,6873978],[1988,6975798],[1989,7101735],[1990,7199838],[1991,7308339],[1992,7413618],[1993,7497205],[1994,7572945],[1995,7630291],[1996,7668253],[1997,7695123],[1998,7714005],[1999,7729131],[2000,7748163],[2001,7771092],[2002,7798497],[2003,7830764],[2004,7868385],[2005,7911974],[2006,7961619],[2007,8017309],[2008,8079043]],"lifeExpectancy":[[1950,57.15],[1951,57.35],[1952,57.76],[1953,58.17],[1954,58.57],[1955,58.98],[1956,59.38],[1957,59.79],[1958,60.19],[1959,60.6],[1960,61.01],[1961,61.42],[1962,61.84],[1963,62.25],[1964,62.67],[1965,63.08],[1966,63.5],[1967,63.91],[1968,64.3],[1969,64.67],[1970,65],[1971,65.25],[1972,65.42],[1973,65.5],[1974,65.51],[1975,65.45],[1976,65.34],[1977,65.21],[1978,65.08],[1979,64.97],[1980,64.92],[1981,64.93],[1982,65.02],[1983,65.17],[1984,65.36],[1985,65.55],[1986,65.72],[1987,65.82],[1988,65.84],[1989,65.77],[1990,65.65],[1991,65.49],[1992,65.35],[1993,65.27],[1994,65.26],[1995,65.36],[1996,65.56],[1997,65.86],[1998,66.23],[1999,66.67],[2000,67.14],[2001,67.63],[2002,68.11],[2003,68.58],[2004,69.01],[2005,69.39],[2006,69.73],[2007,70.04],[2008,70.33],[2009,70.6]]},{"name":"Belarus","region":"Europe & Central Asia","income":[[1800,717.05],[1820,732.15],[1913,1632.01],[1950,3197.98],[1973,4958.61],[1990,6807.78],[1991,6693.19],[1992,6014.41],[1993,5528.26],[1994,4868.62],[1995,4355.51],[1996,4475.41],[1997,4987.79],[1998,5411.86],[1999,5602.35],[2000,5936.24],[2001,6225.16],[2002,6545.79],[2003,6999.86],[2004,7806.72],[2005,8541],[2006,9431.37],[2007,10271.59],[2008,11322.27],[2009,11574.43]],"population":[[1800,2355081],[1820,2355081],[1950,7722155],[1951,7742159],[1952,7698249],[1953,7666821],[1954,7698751],[1955,7780565],[1956,7856790],[1957,7912626],[1958,7982625],[1959,8075290],[1960,8167918],[1961,8262998],[1962,8365073],[1963,8438881],[1964,8501607],[1965,8590786],[1966,8694009],[1967,8786887],[1968,8864776],[1969,8946091],[1970,9027198],[1971,9101396],[1972,9169156],[1973,9236465],[1974,9304311],[1975,9360184],[1976,9405544],[1977,9457385],[1978,9520280],[1979,9581518],[1980,9643706],[1981,9712761],[1982,9778781],[1983,9845174],[1984,9914262],[1985,9981744],[1986,10044184],[1987,10097446],[1988,10149612],[1989,10184084],[1990,10215208],[1991,10244639],[1992,10306362],[1993,10360516],[1994,10387841],[1995,10403989],[1996,10408773],[1997,10404210],[1998,10394407],[1999,10382370],[2000,10366719],[2001,10350194],[2002,10335382],[2003,10322151],[2004,10310520],[2005,10300483],[2006,10293011],[2007,10289007],[2008,10287955]],"lifeExpectancy":[[1800,36.2],[1900,36.2],[1950,65.02],[1951,65.25],[1952,65.69],[1953,66.13],[1954,66.55],[1955,66.96],[1956,67.36],[1957,67.74],[1958,68.11],[1959,69.06],[1960,71.85],[1961,72.57],[1962,71.29],[1963,71.95],[1964,73.48],[1965,73.02],[1966,73.38],[1967,73.13],[1968,73.24],[1969,72.84],[1970,72.32],[1971,72.96],[1972,72.67],[1973,72.71],[1974,73.01],[1975,72.08],[1976,71.92],[1977,71.86],[1978,71.72],[1979,71.32],[1980,71.08],[1981,71.36],[1982,71.49],[1983,71.28],[1984,70.65],[1985,70.86],[1986,72.25],[1987,72.15],[1988,71.89],[1989,71.68],[1990,71.14],[1991,70.58],[1992,70.16],[1993,69.05],[1994,68.81],[1995,68.42],[1996,68.56],[1997,68.37],[1998,68.37],[1999,67.97],[2000,68.99],[2001,68.61],[2002,68.17],[2003,68.71],[2004,69.09],[2005,68.84],[2006,69.51],[2007,70.41],[2008,69.19],[2009,69.4]]},{"name":"Belgium","region":"Europe & Central Asia","income":[[1800,1554],[1820,1566.22],[1821,1570.35],[1822,1574.5],[1823,1578.66],[1824,1582.83],[1825,1587.02],[1826,1591.21],[1827,1595.41],[1828,1599.63],[1829,1603.86],[1830,1608.09],[1831,1630.75],[1832,1653.73],[1833,1677.03],[1834,1700.66],[1835,1724.62],[1836,1748.92],[1837,1773.57],[1838,1798.56],[1839,1823.9],[1840,1849.6],[1841,1875.66],[1842,1902.09],[1843,1928.89],[1844,1956.07],[1845,1983.63],[1846,2011.58],[1847,2092.67],[1848,2083.09],[1849,2127.15],[1850,2194.69],[1851,2241.25],[1852,2286.73],[1853,2332.14],[1854,2461.44],[1855,2462.74],[1856,2581.08],[1857,2631],[1858,2631.23],[1859,2614.36],[1860,2728.3],[1861,2749.4],[1862,2801.79],[1863,2861.59],[1864,2936.27],[1865,2914.6],[1866,2980.08],[1867,2973.81],[1868,3059.92],[1869,3171.27],[1870,3206.23],[1871,3195.35],[1872,3364.87],[1873,3360.56],[1874,3444.3],[1875,3409.48],[1876,3426.09],[1877,3437.96],[1878,3507.43],[1879,3510.63],[1880,3654.84],[1881,3660.7],[1882,3740.81],[1883,3751.04],[1884,3740.87],[1885,3742.93],[1886,3761.51],[1887,3877.6],[1888,3874.23],[1889,4032.17],[1890,4091.5],[1891,4052.2],[1892,4108.36],[1893,4124.83],[1894,4140.29],[1895,4192.43],[1896,4240.59],[1897,4282.65],[1898,4316.81],[1899,4366.64],[1900,4456.85],[1901,4442.72],[1902,4466.99],[1903,4506.92],[1904,4565.58],[1905,4639.15],[1906,4682.47],[1907,4700.11],[1908,4700.77],[1909,4746.97],[1910,4858.37],[1911,4959.53],[1912,5029.69],[1913,5045.58],[1914,3696.15],[1915,3027.96],[1916,3388.9],[1917,2821.92],[1918,2636.44],[1919,3249.35],[1920,4906.66],[1921,5166.58],[1922,5513.88],[1923,5864.8],[1924,6123.55],[1925,6131.49],[1926,6209.34],[1927,6183.18],[1928,6598.97],[1929,6763.13],[1930,6865.1],[1931,6615.19],[1932,6291.57],[1933,6216.09],[1934,6063.88],[1935,6335.16],[1936,6529.96],[1937,6834.46],[1938,6697.85],[1939,6423.53],[1940,5272.8],[1941,4501.67],[1942,4617.74],[1943,3740.56],[1944,3794.18],[1945,4048.7],[1946,6372.25],[1947,7175.79],[1948,7533.41],[1949,7749.11],[1950,7990.47],[1951,8393.42],[1952,8343.11],[1953,8645.37],[1954,8950.31],[1955,9244.73],[1956,9529.4],[1957,9714.96],[1958,9477.27],[1959,9675.47],[1960,10076.6],[1961,10512.51],[1962,10991.21],[1963,11396.13],[1964,12089.41],[1965,12406.29],[1966,12720.18],[1967,13149.04],[1968,13647.2],[1969,14520.74],[1970,15379.71],[1971,15899.66],[1972,16672.14],[1973,17639.58],[1974,18325.17],[1975,18032.12],[1976,19019.94],[1977,19117.97],[1978,19645.54],[1979,20090.12],[1980,20969.62],[1981,20696.13],[1982,20979.85],[1983,20979.01],[1984,21498.94],[1985,21708.75],[1986,22024.75],[1987,22525.56],[1988,23555.82],[1989,24269.23],[1990,24925.91],[1991,25293.57],[1992,25575.57],[1993,25229.6],[1994,25947.3],[1995,26480.95],[1996,26725.5],[1997,27561.2],[1998,28030.61],[1999,28937.15],[2000,29940.2],[2001,30092.08],[2002,30485.88],[2003,30736.53],[2004,31600.02],[2005,32077],[2006,32738.41],[2007,33448],[2008,33490.47],[2009,32256.64]],"population":[[1820,3434000],[1821,3464000],[1822,3495000],[1823,3526000],[1824,3557000],[1825,3589000],[1826,3620000],[1827,3652000],[1828,3685000],[1829,3717000],[1830,3750000],[1831,3782000],[1832,3814000],[1833,3846000],[1834,3879000],[1835,3912000],[1836,3945000],[1837,3978000],[1838,4012000],[1839,4046000],[1840,4080000],[1841,4115000],[1842,4151000],[1843,4187000],[1844,4223000],[1845,4259000],[1846,4296000],[1847,4333000],[1848,4371000],[1849,4408000],[1850,4449000],[1851,4477000],[1852,4506000],[1853,4534000],[1854,4563000],[1855,4592000],[1856,4621000],[1857,4651000],[1858,4680000],[1859,4710000],[1860,4740000],[1861,4774000],[1862,4809000],[1863,4844000],[1864,4879000],[1865,4915000],[1866,4950000],[1867,4986000],[1868,5023000],[1869,5029000],[1870,5096000],[1871,5137000],[1872,5178000],[1873,5219000],[1874,5261000],[1875,5303000],[1876,5345000],[1877,5394000],[1878,5442000],[1879,5492000],[1880,5541000],[1881,5606000],[1882,5673000],[1883,5740000],[1884,5807000],[1885,5876000],[1886,5919000],[1887,5962000],[1888,6007000],[1889,6051000],[1890,6096000],[1891,6164000],[1892,6231000],[1893,6300000],[1894,6370000],[1895,6439000],[1896,6494000],[1897,6548000],[1898,6604000],[1899,6662000],[1900,6719000],[1901,6801000],[1902,6903000],[1903,6997000],[1904,7086000],[1905,7175000],[1906,7258000],[1907,7338000],[1908,7411000],[1909,7478000],[1910,7498000],[1911,7517000],[1912,7590000],[1913,7666000],[1914,7723000],[1915,7759000],[1916,7762000],[1917,7729000],[1918,7660000],[1919,7628000],[1920,7552000],[1921,7504000],[1922,7571000],[1923,7635000],[1924,7707000],[1925,7779000],[1926,7844000],[1927,7904000],[1928,7968000],[1929,8032000],[1930,8076000],[1931,8126000],[1932,8186000],[1933,8231000],[1934,8262000],[1935,8288000],[1936,8315000],[1937,8346000],[1938,8374000],[1939,8392000],[1940,8346000],[1941,8276000],[1942,8247000],[1943,8242000],[1944,8291000],[1945,8339000],[1946,8367000],[1947,8450000],[1948,8557000],[1949,8614000],[1950,8639369],[1951,8678386],[1952,8730405],[1953,8777873],[1954,8819380],[1955,8868475],[1956,8923845],[1957,8989111],[1958,9052707],[1959,9103729],[1960,9118700],[1961,9165800],[1962,9218400],[1963,9283100],[1964,9367000],[1965,9448100],[1966,9507800],[1967,9556500],[1968,9589800],[1969,9612700],[1970,9637800],[1971,9672500],[1972,9709100],[1973,9738400],[1974,9767800],[1975,9794800],[1976,9811000],[1977,9821800],[1978,9829700],[1979,9837200],[1980,9846800],[1981,9852400],[1982,9856303],[1983,9855520],[1984,9855300],[1985,9858200],[1986,9861800],[1987,9870200],[1988,9884000],[1989,9937697],[1990,9969310],[1991,10004487],[1992,10045622],[1993,10085426],[1994,10122914],[1995,10155459],[1996,10178934],[1997,10199787],[1998,10217030],[1999,10235655],[2000,10263618],[2001,10291679],[2002,10311970],[2003,10330824],[2004,10348276],[2005,10364388],[2006,10379067],[2007,10392226],[2008,10403951]],"lifeExpectancy":[[1800,40],[1841,40.33],[1842,38.66],[1843,40.36],[1844,41.9],[1845,41.03],[1846,37.83],[1847,35.11],[1848,38.04],[1849,34.5],[1850,42.28],[1851,41.88],[1852,41.77],[1853,41.33],[1854,39.78],[1855,37.49],[1856,40.92],[1857,40.49],[1858,40.18],[1859,38.98],[1860,45.12],[1861,41.27],[1862,43.12],[1863,41.33],[1864,39.81],[1865,37.74],[1866,32.47],[1867,43.08],[1868,42.56],[1869,42.58],[1870,40.92],[1871,34.35],[1872,40.04],[1873,43.48],[1874,44.67],[1875,42.17],[1876,43.68],[1877,44.48],[1878,44.24],[1879,43.84],[1880,42.48],[1881,44.42],[1882,45.54],[1883,44.89],[1884,44.24],[1885,45.48],[1886,43.36],[1887,46.06],[1888,44.92],[1889,45.07],[1890,44.14],[1891,44.06],[1892,43.16],[1893,44.44],[1894,46.65],[1895,45.46],[1896,48.06],[1897,48.82],[1898,48.12],[1899,46.49],[1900,46.59],[1901,49.44],[1902,49.18],[1903,49.26],[1904,49.32],[1905,50.01],[1906,49.74],[1907,51.11],[1908,49.7],[1909,50.7],[1910,51.37],[1911,49.25],[1912,52.26],[1913,52.51],[1919,49.86],[1920,53.66],[1921,54.75],[1922,55.15],[1923,56.77],[1924,57.51],[1925,57.16],[1926,56.97],[1927,57.2],[1928,57.53],[1929,55.07],[1930,57.17],[1931,58.51],[1932,58.59],[1933,58.76],[1934,60.42],[1935,60.01],[1936,60.01],[1937,60],[1938,60.15],[1939,60.01],[1940,55.96],[1941,58.95],[1942,59.2],[1943,60.39],[1944,56.94],[1945,58.39],[1946,61.92],[1947,63.46],[1948,64.98],[1949,65.48],[1950,66.35],[1951,66.8],[1952,68],[1953,68.37],[1954,68.63],[1955,68.58],[1956,68.87],[1957,69.24],[1958,69.93],[1959,70.33],[1960,69.65],[1961,70.52],[1962,70.25],[1963,70.06],[1964,70.73],[1965,70.58],[1966,70.65],[1967,70.94],[1968,70.63],[1969,70.71],[1970,70.97],[1971,71.1],[1972,71.44],[1973,71.65],[1974,72.01],[1975,72],[1976,72.15],[1977,72.8],[1978,72.75],[1979,73.24],[1980,73.29],[1981,73.7],[1982,73.93],[1983,73.93],[1984,74.43],[1985,74.54],[1986,74.74],[1987,75.35],[1988,75.66],[1989,75.73],[1990,76.14],[1991,76.3],[1992,76.46],[1993,76.47],[1994,76.82],[1995,76.97],[1996,77.31],[1997,77.53],[1998,77.62],[1999,77.8],[2000,77.91],[2001,78.22],[2002,78.32],[2003,78.47],[2004,79.12],[2005,79.21],[2006,79.55],[2007,79.49],[2008,79.78],[2009,80.05]]},{"name":"Bosnia and Herzegovina","region":"Europe & Central Asia","income":[[1800,490.82],[1820,501.12],[1870,402.62],[1890,566.65],[1900,606.28],[1910,710.41],[1913,710.43],[1920,693.15],[1921,699.98],[1922,710.29],[1923,736.69],[1924,778.43],[1925,805.15],[1926,849.17],[1927,823.56],[1928,883.37],[1929,916.93],[1930,886.2],[1931,847.43],[1932,758.01],[1933,770.86],[1934,788.59],[1935,766.06],[1936,853.69],[1937,855.96],[1938,911.73],[1939,948.93],[1947,884.19],[1948,1040.8],[1949,1128.12],[1950,1042.5],[1951,1069.5],[1952,973.53],[1953,1104.17],[1954,1150.69],[1955,1208.08],[1956,1170.76],[1957,1353.99],[1958,1398.03],[1959,1555.19],[1960,1638.06],[1961,1694.86],[1962,1709.68],[1963,1869.42],[1964,2029.36],[1965,2063.9],[1966,2154.29],[1967,2172.35],[1968,2199.57],[1969,2426.35],[1970,2523.61],[1971,2790],[1972,2860.17],[1973,2930.94],[1974,3279.66],[1975,3250.83],[1976,3319.88],[1977,3528.48],[1978,3690.94],[1979,3910.97],[1980,4075.45],[1981,4123.1],[1982,4126.61],[1983,4138.77],[1984,4220.39],[1985,4232.24],[1986,4383.55],[1987,4314.11],[1988,4234.67],[1989,4162.74],[1990,3844.61],[1991,3378.38],[1992,2546.78],[1993,1895.66],[1994,2034.37],[1995,2200.62],[1996,3487.83],[1997,4766.36],[1998,5251.02],[1999,5544.95],[2000,5733.15],[2001,5880.63],[2002,6018.98],[2003,6097.74],[2004,6317.27],[2005,6506],[2006,6856.27],[2007,7247.13],[2008,7619.54],[2009,7341.98]],"population":[[1800,851806],[1820,851806],[1950,2662000],[1951,2721000],[1952,2791000],[1953,2863000],[1954,2916000],[1955,2974000],[1956,3025000],[1957,3076000],[1958,3126000],[1959,3185000],[1960,3240000],[1961,3299000],[1962,3349000],[1963,3399000],[1964,3445000],[1965,3493000],[1966,3541000],[1967,3585000],[1968,3627000],[1969,3669000],[1970,3703000],[1971,3761000],[1972,3819000],[1973,3872000],[1974,3925000],[1975,3980000],[1976,4033000],[1977,4086000],[1978,4135000],[1979,4181000],[1980,4092000],[1981,4135743],[1982,4172693],[1983,4207275],[1984,4241401],[1985,4275355],[1986,4307685],[1987,4338977],[1988,4369894],[1989,4398322],[1990,4423646],[1991,4449406],[1992,4256013],[1993,3955016],[1994,3784983],[1995,3708960],[1996,3608495],[1997,3607000],[1998,3817575],[1999,3958653],[2000,4035457],[2001,4111293],[2002,4165416],[2003,4243181],[2004,4345591],[2005,4430494],[2006,4498976],[2007,4552198],[2008,4590310]],"lifeExpectancy":[[1800,35.1],[1920,35.1],[1950,51.68],[1951,52.24],[1952,53.34],[1953,54.38],[1954,55.37],[1955,56.32],[1956,57.21],[1957,58.06],[1958,58.86],[1959,59.62],[1960,60.33],[1961,61.01],[1962,61.65],[1963,62.26],[1964,62.85],[1965,63.43],[1966,63.99],[1967,64.54],[1968,65.09],[1969,65.63],[1970,66.16],[1971,66.7],[1972,67.24],[1973,67.78],[1974,68.3],[1975,68.8],[1976,69.25],[1977,69.64],[1978,69.96],[1979,70.22],[1980,70.45],[1981,70.69],[1982,70.94],[1983,71.21],[1984,71.44],[1985,71.5],[1986,71.22],[1987,70.53],[1988,69.45],[1989,68.1],[1990,66.74],[1991,65.69],[1992,65.22],[1993,65.44],[1994,66.36],[1995,67.85],[1996,69.63],[1997,71.38],[1998,72.83],[1999,73.88],[2000,74.49],[2001,74.72],[2002,74.77],[2003,74.76],[2004,74.77],[2005,74.82],[2006,74.93],[2007,75.06],[2008,75.2],[2009,75.34]]},{"name":"Bulgaria","region":"Europe & Central Asia","income":[[1800,836.31],[1820,853.86],[1870,1084.36],[1890,1460.07],[1900,1578.95],[1910,1879.73],[1913,1980.34],[1924,1173.28],[1925,1190.81],[1926,1509.7],[1927,1619.8],[1928,1573.86],[1929,1523.89],[1930,1658.24],[1931,1876.69],[1932,1864.41],[1933,1871.38],[1934,1689.5],[1935,1595.52],[1936,1927.59],[1937,2022.45],[1938,2059.3],[1939,2068.96],[1940,1998.58],[1941,2022.66],[1942,1910.08],[1943,1953.88],[1944,1790.93],[1945,1384.92],[1950,2131.56],[1951,2567.42],[1952,2444.29],[1953,2691.94],[1954,2613.98],[1955,2772.89],[1956,2747.38],[1957,3008.67],[1958,3238.11],[1959,3464.57],[1960,3759.17],[1961,3966.09],[1962,4254.34],[1963,4412.81],[1964,4721.86],[1965,4970.49],[1966,5325.95],[1967,5577],[1968,5639.35],[1969,5868.78],[1970,6162.47],[1971,6328.5],[1972,6597.49],[1973,6822.39],[1974,6989.57],[1975,7527.86],[1976,7722.87],[1977,7612.24],[1978,7771.12],[1979,8062.6],[1980,7802.85],[1981,7987.02],[1982,8224.19],[1983,8052.37],[1984,8301.98],[1985,8037.95],[1986,8236.46],[1987,8239.85],[1988,8179.01],[1989,8025.27],[1990,7225.88],[1991,6710.7],[1992,6302.62],[1993,6367.39],[1994,6550.71],[1995,6820.31],[1996,6250.97],[1997,5970.39],[1998,6282.64],[1999,6491.1],[2000,6907.01],[2001,7264.61],[2002,7696.78],[2003,8105.39],[2004,8721.23],[2005,9353],[2006,9995.42],[2007,10923.45],[2008,11357.63],[2009,10840.26]],"population":[[1820,2187000],[1850,2500000],[1870,2586000],[1890,3445000],[1900,4000000],[1910,4520000],[1913,4720000],[1920,5072000],[1921,5148000],[1922,5255000],[1923,5365000],[1924,5476000],[1925,5590000],[1926,5705000],[1927,5798000],[1928,5873000],[1929,5950000],[1930,6027000],[1931,6106000],[1932,6186000],[1933,6267000],[1934,6349000],[1935,6415000],[1936,6469000],[1937,6514000],[1938,6564000],[1939,6614000],[1940,6666000],[1941,6715000],[1942,6771000],[1943,6828000],[1944,6885000],[1945,6942000],[1946,7000000],[1947,7064000],[1948,7130000],[1949,7195000],[1950,7250500],[1951,7258200],[1952,7274900],[1953,7346100],[1954,7423300],[1955,7499400],[1956,7575800],[1957,7651254],[1958,7727553],[1959,7797777],[1960,7867374],[1961,7943118],[1962,8012946],[1963,8078145],[1964,8144339],[1965,8201400],[1966,8258057],[1967,8310226],[1968,8369603],[1969,8434172],[1970,8489574],[1971,8536395],[1972,8576200],[1973,8620997],[1974,8678745],[1975,8720742],[1976,8755037],[1977,8797022],[1978,8803281],[1979,8811589],[1980,8843528],[1981,8869441],[1982,8892098],[1983,8910284],[1984,8928271],[1985,8943573],[1986,8958770],[1987,8971958],[1988,8982025],[1989,8990055],[1990,8894028],[1991,8772368],[1992,8658506],[1993,8441872],[1994,8353335],[1995,8255811],[1996,8161026],[1997,8066057],[1998,7971774],[1999,7893227],[2000,7818495],[2001,7738416],[2002,7661799],[2003,7588399],[2004,7517973],[2005,7450349],[2006,7385367],[2007,7322858],[2008,7262675]],"lifeExpectancy":[[1800,35.8],[1900,40.2],[1902,42.5],[1905,43.3],[1923,44.6],[1926,45.3],[1930,48.3],[1937,51.8],[1947,54.08],[1948,55.79],[1949,57.92],[1950,61.39],[1951,60.63],[1952,59.6],[1953,64.14],[1954,64.4],[1955,64.81],[1956,65.21],[1957,66.61],[1958,68.71],[1959,66.57],[1960,69.18],[1961,70.22],[1962,69.51],[1963,70.34],[1964,71.14],[1965,71.3],[1966,71.23],[1967,70.42],[1968,71.25],[1969,70.43],[1970,71.27],[1971,70.87],[1972,70.9],[1973,71.34],[1974,71.2],[1975,71.05],[1976,71.38],[1977,70.81],[1978,71.17],[1979,71.27],[1980,71.1],[1981,71.49],[1982,71.08],[1983,71.25],[1984,71.35],[1985,71.07],[1986,71.55],[1987,71.34],[1988,71.4],[1989,71.46],[1990,71.31],[1991,71.19],[1992,71.19],[1993,71.18],[1994,70.85],[1995,70.95],[1996,70.85],[1997,70.32],[1998,70.91],[1999,71.57],[2000,71.59],[2001,71.9],[2002,72.14],[2003,72.35],[2004,72.54],[2005,72.53],[2006,72.64],[2007,72.95],[2008,73.32],[2009,73.53]]},{"name":"Croatia","region":"Europe & Central Asia","income":[[1800,1227.06],[1820,1252.8],[1870,1290.02],[1890,1815.56],[1900,1942.56],[1910,2276.2],[1913,2276.25],[1920,2220.87],[1921,2242.77],[1922,2275.79],[1923,2360.39],[1924,2494.12],[1925,2579.72],[1926,2720.79],[1927,2638.71],[1928,2830.35],[1929,2937.87],[1930,2839.43],[1931,2715.2],[1932,2428.7],[1933,2469.86],[1934,2526.67],[1935,2454.48],[1936,2735.24],[1937,2742.51],[1938,2921.23],[1939,3040.4],[1947,2832.99],[1948,3334.76],[1949,3614.53],[1950,3340.19],[1951,3426.71],[1952,3119.24],[1953,3537.81],[1954,3686.86],[1955,3870.72],[1956,3751.15],[1957,4338.23],[1958,4479.35],[1959,4982.88],[1960,5248.4],[1961,5430.38],[1962,5477.89],[1963,5989.69],[1964,6502.15],[1965,6612.81],[1966,6902.41],[1967,6960.3],[1968,7047.52],[1969,7774.12],[1970,8085.73],[1971,8939.27],[1972,9164.09],[1973,9390.85],[1974,10508.17],[1975,10415.79],[1976,10637.03],[1977,11305.39],[1978,11825.89],[1979,12530.9],[1980,13057.9],[1981,13210.57],[1982,13221.82],[1983,13260.78],[1984,13522.3],[1985,13560.25],[1986,14045.06],[1987,13822.58],[1988,13568.05],[1989,13337.57],[1990,12318.28],[1991,9653.91],[1992,8447.79],[1993,7699.56],[1994,8100.49],[1995,8636.98],[1996,9176.84],[1997,9875.6],[1998,10225.82],[1999,10229.92],[2000,10582.67],[2001,11070.38],[2002,11628.39],[2003,12080.57],[2004,12490.93],[2005,13232],[2006,13865.36],[2007,14635.87],[2008,14981.18],[2009,14110.46]],"population":[[1800,1227886],[1820,1227886],[1950,3837297],[1951,3859830],[1952,3882229],[1953,3906475],[1954,3929591],[1955,3955526],[1956,3973442],[1957,3991242],[1958,4004029],[1959,4020631],[1960,4036145],[1961,4055443],[1962,4076557],[1963,4098506],[1964,4113553],[1965,4133313],[1966,4155830],[1967,4174366],[1968,4189903],[1969,4200551],[1970,4205389],[1971,4215869],[1972,4225310],[1973,4234664],[1974,4245822],[1975,4255000],[1976,4286311],[1977,4318673],[1978,4349242],[1979,4379909],[1980,4383000],[1981,4390829],[1982,4413368],[1983,4430941],[1984,4441854],[1985,4457874],[1986,4471752],[1987,4484310],[1988,4493676],[1989,4501397],[1990,4508347],[1991,4540641],[1992,4494013],[1993,4486066],[1994,4511187],[1995,4496683],[1996,4464030],[1997,4444595],[1998,4420195],[1999,4408383],[2000,4410830],[2001,4439110],[2002,4481020],[2003,4497779],[2004,4496869],[2005,4495904],[2006,4494749],[2007,4493312],[2008,4491543]],"lifeExpectancy":[[1800,36.1],[1920,36.1],[1950,59.5],[1951,59.95],[1952,60.83],[1953,61.66],[1954,62.44],[1955,63.18],[1956,63.87],[1957,64.5],[1958,65.09],[1959,65.63],[1960,66.12],[1961,66.57],[1962,66.96],[1963,67.31],[1964,67.63],[1965,67.92],[1966,68.18],[1967,68.42],[1968,68.65],[1969,68.87],[1970,69.09],[1971,69.32],[1972,69.55],[1973,69.79],[1974,70.01],[1975,70.22],[1976,70.38],[1977,70.5],[1978,70.55],[1979,70.56],[1980,70.55],[1981,70.54],[1982,70.55],[1983,70.61],[1984,70.73],[1985,70.9],[1986,71.1],[1987,71.31],[1988,71.53],[1989,71.73],[1990,71.95],[1991,72.2],[1992,72.49],[1993,72.83],[1994,73.21],[1995,73.6],[1996,73.96],[1997,74.27],[1998,74.52],[1999,74.69],[2000,74.81],[2001,74.9],[2002,75],[2003,75.14],[2004,75.31],[2005,75.53],[2006,75.78],[2007,76.03],[2008,76.27],[2009,76.49]]},{"name":"Cyprus","region":"Europe & Central Asia","income":[[1800,572.78],[1820,592.1],[1913,1752.95],[1950,2920.87],[1970,6323.94],[1971,7126.25],[1972,7624.59],[1973,7845.87],[1974,7689.08],[1975,6454.1],[1976,7680.86],[1977,8898.47],[1978,9539.09],[1979,10405.7],[1980,10904.71],[1981,11096.52],[1982,11663.94],[1983,12125.95],[1984,13018.71],[1985,13469.91],[1986,13820.98],[1987,14634.95],[1988,15679.76],[1989,16704.33],[1990,17572.31],[1991,17235.54],[1992,18364.5],[1993,18043.12],[1994,18695.08],[1995,20180.14],[1996,20228.69],[1997,20409.23],[1998,21170.8],[1999,21953.68],[2000,22821.38],[2001,23469.74],[2002,23683.6],[2003,23766.98],[2004,24211.44],[2005,24473],[2006,24908.98],[2007,25774.93],[2008,26349.47],[2009,25643.45]],"population":[[1800,184392],[1881,186000],[1891,209000],[1901,237000],[1911,274000],[1921,311000],[1931,348000],[1946,450000],[1950,494000],[1951,502000],[1952,508000],[1953,515000],[1954,523000],[1955,530000],[1956,536000],[1957,546000],[1958,558000],[1959,567000],[1960,573000],[1961,578700],[1962,576000],[1963,582300],[1964,586500],[1965,590800],[1966,595000],[1967,599400],[1968,604300],[1969,609400],[1970,614600],[1971,619800],[1972,626300],[1973,633900],[1974,640700],[1975,610500],[1976,598600],[1977,598400],[1978,601000],[1979,605100],[1980,611000],[1981,617900],[1982,624300],[1983,631800],[1984,639900],[1985,647300],[1986,650000],[1987,659400],[1988,664217],[1989,670912],[1990,681349],[1991,693906],[1992,707285],[1993,718776],[1994,726752],[1995,733188],[1996,738649],[1997,743728],[1998,748822],[1999,753692],[2000,758363],[2001,762887],[2002,767314],[2003,771657],[2004,775927],[2005,780133],[2006,784301],[2007,788457],[2008,792604]],"lifeExpectancy":[[1800,38.5],[1895,38.51],[1905,45],[1915,47.46],[1925,48.46],[1937,48.46],[1943,53.46],[1950,66.55],[1951,66.66],[1952,66.88],[1953,67.1],[1954,67.32],[1955,67.54],[1956,67.76],[1957,67.98],[1958,68.2],[1959,68.42],[1960,68.65],[1961,68.87],[1962,69.09],[1963,69.31],[1964,69.53],[1965,69.75],[1966,69.95],[1967,70.15],[1968,70.35],[1969,70.55],[1970,70.77],[1971,71.03],[1972,71.34],[1973,71.7],[1974,72.11],[1975,72.54],[1976,72.98],[1977,73.41],[1978,73.8],[1979,74.14],[1980,74.44],[1981,74.69],[1982,74.93],[1983,75.16],[1984,75.39],[1985,75.61],[1986,75.82],[1987,76.02],[1988,76.21],[1989,76.38],[1990,76.55],[1991,76.71],[1992,76.87],[1993,77.05],[1994,77.23],[1995,77.42],[1996,77.63],[1997,77.86],[1998,78.08],[1999,78.31],[2000,78.54],[2001,78.75],[2002,78.94],[2003,79.11],[2004,79.27],[2005,79.4],[2006,79.52],[2007,79.63],[2008,79.74],[2009,79.85]]},{"name":"Denmark","region":"Europe & Central Asia","income":[[1800,1342.84],[1820,1389.28],[1821,1442.33],[1822,1450.88],[1823,1432.15],[1824,1456.44],[1825,1451.29],[1826,1456.02],[1827,1485.24],[1828,1495.5],[1829,1461.16],[1830,1470.07],[1831,1459.29],[1832,1500.9],[1833,1483.15],[1834,1552.3],[1835,1531.9],[1836,1523.43],[1837,1552.67],[1838,1553.12],[1839,1560.42],[1840,1599.67],[1841,1585.44],[1842,1580.41],[1843,1659.37],[1844,1719.34],[1845,1748.87],[1846,1770.96],[1847,1749.37],[1848,1825.11],[1849,1917.22],[1850,2005.8],[1851,1888.73],[1852,1937.48],[1853,1928.12],[1854,1918.48],[1855,2105.48],[1856,1963.1],[1857,1972.19],[1858,1936.14],[1859,2042.7],[1860,2002.6],[1861,2012.25],[1862,2051.1],[1863,2158.64],[1864,2119.27],[1865,2170.78],[1866,2155.68],[1867,2136.16],[1868,2154.08],[1869,2258.2],[1870,2334.67],[1871,2325.92],[1872,2438.77],[1873,2406.44],[1874,2456.17],[1875,2477.37],[1876,2502.66],[1877,2406.95],[1878,2476.02],[1879,2534.1],[1880,2576.34],[1881,2581.47],[1882,2652.98],[1883,2726.01],[1884,2713.39],[1885,2703.7],[1886,2780.97],[1887,2854.28],[1888,2851.25],[1889,2867.96],[1890,3019.69],[1891,3061.96],[1892,3117.15],[1893,3158.46],[1894,3197.16],[1895,3337.28],[1896,3420.8],[1897,3458.18],[1898,3470.75],[1899,3575.26],[1900,3658.24],[1901,3769.45],[1902,3819.26],[1903,4006.01],[1904,4054.34],[1905,4084.6],[1906,4158.25],[1907,4267.16],[1908,4353.49],[1909,4470.21],[1910,4553.02],[1911,4745.57],[1912,4697.1],[1913,4826.63],[1914,5077.93],[1915,4673.39],[1916,4819.94],[1917,4485.64],[1918,4295.37],[1919,4799.78],[1920,4970.96],[1921,4770.64],[1922,5201.84],[1923,5699.38],[1924,5668.6],[1925,5488.31],[1926,5770.84],[1927,5854.2],[1928,6022.47],[1929,6395.75],[1930,6739.15],[1931,6771.4],[1932,6540.17],[1933,6702.3],[1934,6852.67],[1935,6960.34],[1936,7090.48],[1937,7219.21],[1938,7348.56],[1939,7652.71],[1940,6541.9],[1941,5855.93],[1942,5933.93],[1943,6521.29],[1944,7125.28],[1945,6520.8],[1946,7445.19],[1947,7788.25],[1948,7925.43],[1949,8403.5],[1950,8996.05],[1951,8999.38],[1952,9035.67],[1953,9485.18],[1954,9601.58],[1955,9645.67],[1956,9715.12],[1957,10416.31],[1958,10600.5],[1959,11325.13],[1960,11569.48],[1961,12242.19],[1962,12831.71],[1963,12828.01],[1964,13937.78],[1965,14476.65],[1966,14769.04],[1967,15155.34],[1968,15706.49],[1969,16649.14],[1970,16877.42],[1971,17230.2],[1972,18059.78],[1973,18627.44],[1974,18392.37],[1975,18242.49],[1976,19400.16],[1977,19679.76],[1978,19934.76],[1979,20617.91],[1980,20529.08],[1981,20379.19],[1982,21037.65],[1983,21610.89],[1984,22601.41],[1985,23592.45],[1986,24451.45],[1987,24524.78],[1988,24831.14],[1989,24914.52],[1990,25208.56],[1991,25503.74],[1992,25956.19],[1993,25882.23],[1994,27258.06],[1995,27985.59],[1996,28655.63],[1997,29490.37],[1998,30058.99],[1999,30767.67],[2000,31805.54],[2001,31964.4],[2002,32039.01],[2003,32089.74],[2004,32694.6],[2005,33626],[2006,34664.67],[2007,35124.41],[2008,34636.39],[2009,32670.06]],"population":[[1820,1155000],[1821,1167000],[1822,1179000],[1823,1196000],[1824,1213000],[1825,1228000],[1826,1243000],[1827,1255000],[1828,1265000],[1829,1270000],[1830,1273000],[1831,1275000],[1832,1276000],[1833,1284000],[1834,1295000],[1835,1306000],[1836,1315000],[1837,1325000],[1838,1335000],[1839,1347000],[1840,1357000],[1841,1371000],[1842,1385000],[1843,1392000],[1844,1414000],[1845,1430000],[1846,1444000],[1847,1456000],[1848,1470000],[1849,1484000],[1850,1499000],[1851,1517000],[1852,1536000],[1853,1552000],[1854,1569000],[1855,1590000],[1856,1612000],[1857,1634000],[1858,1653000],[1859,1674000],[1860,1696000],[1861,1717000],[1862,1739000],[1863,1761000],[1864,1777000],[1865,1799000],[1866,1814000],[1867,1833000],[1868,1852000],[1869,1871000],[1870,1888000],[1871,1903000],[1872,1918000],[1873,1935000],[1874,1954000],[1875,1973000],[1876,1994000],[1877,2019000],[1878,2043000],[1879,2064000],[1880,2081000],[1881,2101000],[1882,2120000],[1883,2137000],[1884,2160000],[1885,2186000],[1886,2213000],[1887,2237000],[1888,2257000],[1889,2276000],[1890,2294000],[1891,2311000],[1892,2327000],[1893,2344000],[1894,2367000],[1895,2397000],[1896,2428000],[1897,2462000],[1898,2497000],[1899,2530000],[1900,2561000],[1901,2594000],[1902,2623000],[1903,2653000],[1904,2681000],[1905,2710000],[1906,2741000],[1907,2775000],[1908,2809000],[1909,2845000],[1910,2882000],[1911,2917000],[1912,2951000],[1913,2983000],[1914,3018000],[1915,3055000],[1916,3092000],[1917,3130000],[1918,3165000],[1919,3202000],[1920,3242000],[1921,3285000],[1922,3322000],[1923,3356000],[1924,3389000],[1925,3425000],[1926,3452000],[1927,3475000],[1928,3497000],[1929,3518000],[1930,3542000],[1931,3569000],[1932,3603000],[1933,3633000],[1934,3666000],[1935,3695000],[1936,3722000],[1937,3749000],[1938,3777000],[1939,3805000],[1940,3832000],[1941,3863000],[1942,3903000],[1943,3949000],[1944,3998000],[1945,4045000],[1946,4101000],[1947,4146000],[1948,4190000],[1949,4230000],[1950,4271000],[1951,4303620],[1952,4334000],[1953,4369280],[1954,4406000],[1955,4439000],[1956,4466471],[1957,4487831],[1958,4515132],[1959,4546636],[1960,4581000],[1961,4609817],[1962,4646899],[1963,4683579],[1964,4720171],[1965,4758100],[1966,4797500],[1967,4838800],[1968,4867300],[1969,4890687],[1970,4928757],[1971,4963126],[1972,4991596],[1973,5021861],[1974,5045297],[1975,5059861],[1976,5072596],[1977,5088419],[1978,5104247],[1979,5116800],[1980,5123027],[1981,5121572],[1982,5117810],[1983,5114297],[1984,5111619],[1985,5113691],[1986,5120534],[1987,5127024],[1988,5129516],[1989,5132593],[1990,5140954],[1991,5154352],[1992,5171393],[1993,5188386],[1994,5205603],[1995,5232612],[1996,5262075],[1997,5283663],[1998,5302767],[1999,5320134],[2000,5337416],[2001,5355826],[2002,5374693],[2003,5394138],[2004,5413392],[2005,5432335],[2006,5450661],[2007,5468120],[2008,5484723]],"lifeExpectancy":[[1800,35],[1835,38.35],[1836,39.92],[1837,41.5],[1838,43.11],[1839,41.86],[1840,41.06],[1841,42.64],[1842,42.49],[1843,43.85],[1844,44],[1845,43.35],[1846,40.43],[1847,40.47],[1848,40.73],[1849,39.5],[1850,43.5],[1851,44.57],[1852,43.08],[1853,38.6],[1854,44.74],[1855,46.18],[1856,46.78],[1857,42.49],[1858,40.04],[1859,44.42],[1860,45.11],[1861,47.65],[1862,47.62],[1863,47.58],[1864,40.2],[1865,39.85],[1866,42.95],[1867,44.97],[1868,45.66],[1869,46.13],[1870,46.06],[1871,46.15],[1872,47.53],[1873,47.58],[1874,46.11],[1875,44.51],[1876,45.88],[1877,47.41],[1878,47.6],[1879,46.29],[1880,44.86],[1881,48.37],[1882,46.77],[1883,48.56],[1884,48.6],[1885,49.69],[1886,49],[1887,48.71],[1888,46.71],[1889,47.83],[1890,47.3],[1891,46.83],[1892,47.49],[1893,47.14],[1894,49.42],[1895,50.93],[1896,52.99],[1897,51.86],[1898,53.15],[1899,50.71],[1900,51.95],[1901,52.66],[1902,54.74],[1903,54.81],[1904,55.81],[1905,54.41],[1906,56.6],[1907,56.13],[1908,54.96],[1909,57.44],[1910,58.09],[1911,57.01],[1912,58.09],[1913,58.93],[1914,58.53],[1915,58.46],[1916,56.97],[1917,57.31],[1918,56.25],[1919,57],[1920,57.55],[1921,61.78],[1922,60.65],[1923,61.22],[1924,61.19],[1925,61.96],[1926,61.71],[1927,61.24],[1928,61.93],[1929,62],[1930,62.31],[1931,61.89],[1932,62.74],[1933,63.66],[1934,64.15],[1935,62.92],[1936,63.5],[1937,63.98],[1938,64.99],[1939,65.83],[1940,66.27],[1941,66.02],[1942,67.16],[1943,67.46],[1944,66.41],[1945,66.09],[1946,67.24],[1947,68.54],[1948,70.12],[1949,70.15],[1950,70.33],[1951,70.93],[1952,70.78],[1953,71.15],[1954,71.35],[1955,71.92],[1956,72.05],[1957,71.81],[1958,72.24],[1959,72.22],[1960,72.21],[1961,72.47],[1962,72.35],[1963,72.44],[1964,72.52],[1965,72.4],[1966,72.48],[1967,72.96],[1968,73.17],[1969,73.26],[1970,73.38],[1971,73.44],[1972,73.47],[1973,73.71],[1974,73.84],[1975,74.11],[1976,73.78],[1977,74.69],[1978,74.45],[1979,74.27],[1980,74.16],[1981,74.29],[1982,74.63],[1983,74.5],[1984,74.65],[1985,74.52],[1986,74.69],[1987,74.8],[1988,74.89],[1989,74.92],[1990,74.92],[1991,75.29],[1992,75.33],[1993,75.25],[1994,75.51],[1995,75.36],[1996,75.74],[1997,76.11],[1998,76.51],[1999,76.66],[2000,76.9],[2001,77.06],[2002,77.18],[2003,77.78],[2004,77.58],[2005,78.32],[2006,78.32],[2007,78.44],[2008,78.41],[2009,78.57]]},{"name":"Estonia","region":"Europe & Central Asia","income":[[1800,906.39],[1820,925.48],[1913,2062.96],[1950,4042.45],[1973,8313.11],[1990,10389.82],[1991,9409.45],[1992,8245.73],[1993,7733.48],[1994,7733.63],[1995,8199.12],[1996,8680.18],[1997,9689.84],[1998,10283.79],[1999,10356.42],[2000,11244.49],[2001,12050.17],[2002,13011.44],[2003,13770.19],[2004,15014.22],[2005,16654],[2006,18350.51],[2007,19705.76],[2008,18993.59],[2009,16349.13]],"population":[[1800,334136],[1820,334136],[1950,1095610],[1951,1111966],[1952,1130445],[1953,1140395],[1954,1148378],[1955,1154371],[1956,1162801],[1957,1174251],[1958,1185336],[1959,1197418],[1960,1210647],[1961,1224467],[1962,1238786],[1963,1254604],[1964,1272439],[1965,1287808],[1966,1300177],[1967,1311560],[1968,1324437],[1969,1342891],[1970,1363183],[1971,1381459],[1972,1397391],[1973,1410836],[1974,1422291],[1975,1432246],[1976,1442204],[1977,1453168],[1978,1463533],[1979,1472244],[1980,1482196],[1981,1493318],[1982,1504043],[1983,1514671],[1984,1526128],[1985,1538224],[1986,1550072],[1987,1562224],[1988,1569187],[1989,1570926],[1990,1569322],[1991,1559547],[1992,1528715],[1993,1491426],[1994,1467535],[1995,1446509],[1996,1427827],[1997,1413351],[1998,1400972],[1999,1389756],[2000,1379835],[2001,1369983],[2002,1360122],[2003,1350722],[2004,1341664],[2005,1332893],[2006,1324333],[2007,1315912],[2008,1307605]],"lifeExpectancy":[[1800,36.5],[1860,36.5],[1897,43],[1900,43.1],[1922,51.7],[1935,56.27],[1950,64.36],[1951,64.6],[1952,65.08],[1953,65.57],[1954,66.06],[1955,66.55],[1956,67.04],[1957,67.53],[1958,68],[1959,68.64],[1960,69.34],[1961,69.66],[1962,69.84],[1963,69.9],[1964,70.64],[1965,70.71],[1966,70.68],[1967,70.97],[1968,70.59],[1969,70.28],[1970,70.39],[1971,70.59],[1972,70.35],[1973,70.7],[1974,70.8],[1975,70.12],[1976,69.74],[1977,69.86],[1978,69.72],[1979,69.5],[1980,69.59],[1981,69.46],[1982,69.86],[1983,69.78],[1984,69.65],[1985,69.79],[1986,70.93],[1987,70.94],[1988,70.98],[1989,70.53],[1990,69.9],[1991,69.8],[1992,69.14],[1993,68.19],[1994,66.67],[1995,67.72],[1996,69.94],[1997,70.13],[1998,69.72],[1999,70.5],[2000,70.8],[2001,70.67],[2002,71.23],[2003,71.82],[2004,72.29],[2005,72.96],[2006,73.13],[2007,73.14],[2008,73.23],[2009,73.5]]},{"name":"Finland","region":"Europe & Central Asia","income":[[1800,1037.69],[1820,1073.4],[1821,1078.92],[1822,1084.47],[1823,1090.05],[1824,1095.65],[1825,1101.29],[1826,1106.95],[1827,1112.64],[1828,1118.37],[1829,1124.12],[1830,1129.9],[1831,1135.71],[1832,1141.55],[1833,1147.42],[1834,1153.32],[1835,1159.25],[1836,1165.21],[1837,1171.21],[1838,1177.23],[1839,1183.28],[1840,1189.37],[1841,1195.48],[1842,1201.63],[1843,1207.81],[1844,1214.02],[1845,1220.27],[1846,1226.54],[1847,1232.85],[1848,1239.19],[1849,1245.56],[1850,1251.97],[1851,1258.44],[1852,1264.95],[1853,1271.49],[1854,1278.06],[1855,1284.67],[1856,1291.32],[1857,1297.99],[1858,1304.71],[1859,1311.45],[1860,1318.23],[1861,1316.39],[1862,1231.83],[1863,1316.16],[1864,1331.17],[1865,1307.65],[1866,1316.86],[1867,1217.5],[1868,1379.02],[1869,1513.88],[1870,1566.35],[1871,1548.7],[1872,1573.71],[1873,1640.18],[1874,1654.92],[1875,1664.63],[1876,1730.68],[1877,1664.65],[1878,1611.83],[1879,1604.46],[1880,1587.17],[1881,1525.64],[1882,1653.22],[1883,1690.22],[1884,1675.84],[1885,1692.17],[1886,1753.02],[1887,1753.07],[1888,1789.84],[1889,1823.23],[1890,1898.07],[1891,1855.95],[1892,1759.05],[1893,1842.91],[1894,1923.34],[1895,2051.12],[1896,2157.69],[1897,2232.26],[1898,2292.74],[1899,2208.61],[1900,2293.12],[1901,2248.73],[1902,2187.05],[1903,2316.91],[1904,2379.03],[1905,2393.93],[1906,2466.09],[1907,2521.28],[1908,2513.65],[1909,2589.75],[1910,2620.18],[1911,2665.1],[1912,2779.55],[1913,2900.86],[1914,2749.61],[1915,2586.14],[1916,2601.75],[1917,2172.74],[1918,1882.63],[1919,2279.04],[1920,2536.46],[1921,2589.95],[1922,2828.49],[1923,3005.49],[1924,3056.68],[1925,3199.82],[1926,3287.25],[1927,3514.45],[1928,3720.77],[1929,3733.94],[1930,3663.59],[1931,3546.72],[1932,3504.34],[1933,3713.08],[1934,4107.16],[1935,4250.49],[1936,4506.28],[1937,4729.48],[1938,4933.25],[1939,4683.47],[1940,4426.07],[1941,4565.98],[1942,4572.8],[1943,5080.7],[1944,5064.01],[1945,4740.94],[1946,5061.83],[1947,5108.35],[1948,5438.68],[1949,5694.41],[1950,5845.63],[1951,6282.55],[1952,6424.52],[1953,6393.12],[1954,6874.03],[1955,7142.39],[1956,7277.78],[1957,7545.42],[1958,7523.81],[1959,7907.52],[1960,8562.87],[1961,9150.5],[1962,9371.84],[1963,9612.4],[1964,10042.22],[1965,10540.94],[1966,10753.82],[1967,10921.64],[1968,11122.84],[1969,12201.15],[1970,13162.25],[1971,13420.39],[1972,14358.88],[1973,15235.13],[1974,15614.72],[1975,15724.68],[1976,15610.75],[1977,15605.42],[1978,15886.31],[1979,16948.22],[1980,17796.77],[1981,18051.17],[1982,18533.16],[1983,18920.9],[1984,19387.97],[1985,19958.81],[1986,20367.55],[1987,21141.01],[1988,22110.88],[1989,23289.8],[1990,23180.78],[1991,21581.75],[1992,20647.16],[1993,20294.81],[1994,21005.54],[1995,21650.15],[1996,22402.5],[1997,23723.95],[1998,25004.32],[1999,25915.26],[2000,27171.97],[2001,27825.53],[2002,28204.59],[2003,28650.03],[2004,29651.4],[2005,30469],[2006,31683.68],[2007,33102.61],[2008,33339.32],[2009,30602.73]],"population":[[1820,1169000],[1821,1186000],[1822,1202000],[1823,1219000],[1824,1235000],[1825,1252000],[1826,1268000],[1827,1310000],[1828,1326000],[1829,1343000],[1830,1364000],[1831,1374000],[1832,1378000],[1833,1383000],[1834,1387000],[1835,1391000],[1836,1399000],[1837,1409000],[1838,1420000],[1839,1430000],[1840,1441000],[1841,1456000],[1842,1476000],[1843,1495000],[1844,1516000],[1845,1536000],[1846,1555000],[1847,1573000],[1848,1591000],[1849,1610000],[1850,1628000],[1851,1642000],[1852,1652000],[1853,1663000],[1854,1673000],[1855,1683000],[1856,1692000],[1857,1703000],[1858,1715000],[1859,1726000],[1860,1738000],[1861,1754000],[1862,1774000],[1863,1794000],[1864,1813000],[1865,1833000],[1866,1840000],[1867,1831000],[1868,1776000],[1869,1734000],[1870,1754000],[1871,1786000],[1872,1819000],[1873,1847000],[1874,1873000],[1875,1899000],[1876,1928000],[1877,1957000],[1878,1983000],[1879,2014000],[1880,2047000],[1881,2072000],[1882,2098000],[1883,2130000],[1884,2164000],[1885,2195000],[1886,2224000],[1887,2259000],[1888,2296000],[1889,2331000],[1890,2364000],[1891,2394000],[1892,2451000],[1893,2430000],[1894,2511000],[1895,2483000],[1896,2515000],[1897,2549000],[1898,2589000],[1899,2624000],[1900,2646000],[1901,2667000],[1902,2686000],[1903,2706000],[1904,2735000],[1905,2762000],[1906,2788000],[1907,2821000],[1908,2861000],[1909,2899000],[1910,2929000],[1911,2962000],[1912,2998000],[1913,3027000],[1914,3053000],[1915,3083000],[1916,3105000],[1917,3124000],[1918,3125000],[1919,3117000],[1920,3133000],[1921,3170000],[1922,3210000],[1923,3243000],[1924,3272000],[1925,3304000],[1926,3339000],[1927,3368000],[1928,3396000],[1929,3424000],[1930,3449000],[1931,3476000],[1932,3503000],[1933,3526000],[1934,3549000],[1935,3576000],[1936,3601000],[1937,3626000],[1938,3656000],[1939,3686000],[1940,3698000],[1941,3702000],[1942,3708000],[1943,3721000],[1944,3735000],[1945,3758000],[1946,3806000],[1947,3859000],[1948,3912000],[1949,3963000],[1950,4008900],[1951,4047300],[1952,4090500],[1953,4139400],[1954,4186900],[1955,4234900],[1956,4281700],[1957,4324000],[1958,4359800],[1959,4394700],[1960,4429600],[1961,4461004],[1962,4491443],[1963,4523309],[1964,4548544],[1965,4563732],[1966,4580869],[1967,4605744],[1968,4626469],[1969,4623785],[1970,4606307],[1971,4612124],[1972,4639657],[1973,4666081],[1974,4690574],[1975,4711439],[1976,4725664],[1977,4738902],[1978,4752528],[1979,4764690],[1980,4779535],[1981,4799964],[1982,4826933],[1983,4855787],[1984,4881788],[1985,4901783],[1986,4917386],[1987,4931729],[1988,4946633],[1989,4962441],[1990,4986431],[1991,5013786],[1992,5041039],[1993,5064846],[1994,5086044],[1995,5104654],[1996,5120310],[1997,5134406],[1998,5146983],[1999,5158097],[2000,5168595],[2001,5180309],[2002,5193039],[2003,5204405],[2004,5214512],[2005,5223442],[2006,5231372],[2007,5238460],[2008,5244749]],"lifeExpectancy":[[1800,31.8],[1805,31.77],[1815,35.77],[1825,38.36],[1835,34.61],[1845,40.4],[1855,35.06],[1865,32.07],[1875,41.57],[1878,39.17],[1879,44.95],[1880,39.67],[1881,37.65],[1882,40.46],[1883,42.79],[1884,42.87],[1885,41.3],[1886,40.92],[1887,45.6],[1888,45.16],[1889,44.93],[1890,44.61],[1891,42.57],[1892,39.73],[1893,43.34],[1894,45.22],[1895,47.64],[1896,46.56],[1897,48.16],[1898,48.07],[1899,44.4],[1900,41.8],[1901,42.87],[1902,46.23],[1903,46.64],[1904,47.21],[1905,46.04],[1906,47.07],[1907,46.98],[1908,46.15],[1909,48.67],[1910,48.53],[1911,48.73],[1912,49.13],[1913,49.05],[1914,49.73],[1915,49.54],[1916,48.03],[1917,46.49],[1918,32.71],[1919,43.07],[1920,47.55],[1921,52.41],[1922,51.92],[1923,52.52],[1924,50.22],[1925,53.42],[1926,53.83],[1927,51.86],[1928,53.71],[1929,51.28],[1930,54.47],[1931,54.88],[1932,55.79],[1933,55.45],[1934,56.04],[1935,57.36],[1936,56.16],[1937,57.1],[1938,57.2],[1939,54.67],[1940,46.65],[1941,46.5],[1942,53.9],[1943,56.27],[1944,48],[1945,57.19],[1946,60.27],[1947,60.53],[1948,61.99],[1949,61.88],[1950,64.24],[1951,65.67],[1952,66.55],[1953,66.61],[1954,67.57],[1955,67.37],[1956,67.99],[1957,67.49],[1958,68.63],[1959,68.81],[1960,69.01],[1961,69.04],[1962,68.75],[1963,69.16],[1964,69.37],[1965,69.13],[1966,69.65],[1967,69.83],[1968,69.79],[1969,69.67],[1970,70.36],[1971,70.18],[1972,70.87],[1973,71.38],[1974,71.3],[1975,71.85],[1976,72],[1977,72.52],[1978,73.08],[1979,73.37],[1980,73.66],[1981,73.98],[1982,74.55],[1983,74.46],[1984,74.77],[1985,74.44],[1986,74.8],[1987,74.83],[1988,74.79],[1989,75.01],[1990,75.04],[1991,75.45],[1992,75.7],[1993,75.94],[1994,76.64],[1995,76.66],[1996,76.94],[1997,77.13],[1998,77.34],[1999,77.53],[2000,77.76],[2001,78.23],[2002,78.37],[2003,78.63],[2004,78.96],[2005,79.09],[2006,79.49],[2007,79.53],[2008,79.7],[2009,79.9]]},{"name":"France","region":"Europe & Central Asia","income":[[1800,1388.32],[1820,1508.17],[1821,1605.15],[1822,1488.9],[1823,1484.46],[1824,1450.73],[1825,1461.26],[1826,1507.24],[1827,1517.77],[1828,1424.55],[1829,1505.31],[1830,1478.21],[1831,1468.18],[1832,1575.78],[1833,1575.21],[1834,1556.85],[1835,1638.99],[1836,1670.87],[1837,1691.88],[1838,1728.95],[1839,1702.64],[1840,1833.29],[1841,1782.25],[1842,1748.42],[1843,1814.96],[1844,1869.79],[1845,1937.81],[1846,2061.01],[1847,2247.78],[1848,1754.96],[1849,1751.73],[1850,1840.71],[1851,1810.27],[1852,2049.4],[1853,2279.88],[1854,2558.73],[1855,2699.62],[1856,2804.19],[1857,2709.43],[1858,2530.47],[1859,2537.44],[1860,2704.03],[1861,2763.29],[1862,2864.8],[1863,2947.49],[1864,3001.41],[1865,2952.32],[1866,3078.84],[1867,3035.75],[1868,3248.75],[1869,3053.02],[1870,2952.12],[1871,3094.7],[1872,3265.24],[1873,3226.92],[1874,3368.09],[1875,3305.81],[1876,3271.13],[1877,3263.78],[1878,3086.79],[1879,3061.22],[1880,3251.85],[1881,3467.16],[1882,3592.01],[1883,3442.58],[1884,3268.75],[1885,3178.76],[1886,3144.18],[1887,3176.37],[1888,3256.96],[1889,3273.56],[1890,3400.86],[1891,3444.97],[1892,3524.93],[1893,3398.78],[1894,3737.15],[1895,3668.19],[1896,3791.6],[1897,3688.84],[1898,3914.43],[1899,4060.44],[1900,4120.2],[1901,3923.77],[1902,3882.54],[1903,4018.39],[1904,4104.52],[1905,4215.5],[1906,4163.4],[1907,4506.35],[1908,4497.65],[1909,4648.43],[1910,4431.67],[1911,4874.61],[1912,5269.95],[1913,5216.06],[1914,4366.68],[1915,3838.35],[1916,4391.91],[1917,4343.65],[1918,3715.96],[1919,4091.01],[1920,4363.66],[1921,4138.93],[1922,4952.53],[1923,5174.88],[1924,5731.07],[1925,5758.31],[1926,5943.23],[1927,5809.19],[1928,6139.65],[1929,6647.68],[1930,6404.85],[1931,6109.1],[1932,5562.21],[1933,5715.58],[1934,5506.14],[1935,5360.76],[1936,5427.12],[1937,5543.16],[1938,5395.35],[1939,5609.14],[1940,4419.43],[1941,4268.29],[1942,4290.23],[1943,4272.41],[1944,3266.23],[1945,4011.65],[1946,5348.07],[1947,5625.06],[1948,6298.46],[1949,6625.98],[1950,7104.01],[1951,7436.28],[1952,7550.91],[1953,7692.44],[1954,8019.09],[1955,8399.74],[1956,8786.31],[1957,9242.42],[1958,9434.98],[1959,9619.51],[1960,10244.42],[1961,10686.66],[1962,11191.29],[1963,11579.29],[1964,12197.97],[1965,12650.59],[1966,13187.05],[1967,13683.81],[1968,14146.15],[1969,15000.57],[1970,15703.71],[1971,16284.72],[1972,16840.55],[1973,17597.08],[1974,18004.5],[1975,17848.25],[1976,18509.58],[1977,18996.91],[1978,19524.41],[1979,20102.02],[1980,20334.47],[1981,20488.68],[1982,20933.53],[1983,21265.16],[1984,21488.65],[1985,21805.96],[1986,22218.56],[1987,22608.9],[1988,23523.51],[1989,24186.1],[1990,24676.73],[1991,24847.93],[1992,25140.92],[1993,24731.22],[1994,25117.85],[1995,25556.85],[1996,25717.2],[1997,26170.75],[1998,26957.92],[1999,27689.46],[2000,28636.15],[2001,28983.72],[2002,29043.35],[2003,29048.88],[2004,29505.88],[2005,29644],[2006,30161.01],[2007,30666.76],[2008,30598.37],[2009,29774.85]],"population":[[1820,31250000],[1821,31460000],[1822,31685000],[1823,31905000],[1824,32127000],[1825,32350000],[1826,32538000],[1827,32727000],[1828,32917000],[1829,33108000],[1830,33300000],[1831,33439000],[1832,33598000],[1833,33718000],[1834,33859000],[1835,34000000],[1836,34178000],[1837,34357000],[1838,34537000],[1839,34718000],[1840,34900000],[1841,35059000],[1842,35218000],[1843,35378000],[1844,35539000],[1845,35700000],[1846,35829000],[1847,35959000],[1848,36089000],[1849,36219000],[1850,36350000],[1851,36479000],[1852,36609000],[1853,36739000],[1854,36869000],[1855,37000000],[1856,37060000],[1857,37120000],[1858,37180000],[1859,37240000],[1860,37300000],[1861,37390000],[1862,37520000],[1863,37710000],[1864,37860000],[1865,38020000],[1866,38080000],[1867,38230000],[1868,38330000],[1869,38890000],[1870,38440000],[1871,37731000],[1872,37679000],[1873,37887000],[1874,38044000],[1875,38221000],[1876,38398000],[1877,38576000],[1878,38763000],[1879,38909000],[1880,39045000],[1881,39191000],[1882,39337000],[1883,39472000],[1884,39629000],[1885,39733000],[1886,39858000],[1887,39889000],[1888,39920000],[1889,40004000],[1890,40014000],[1891,39983000],[1892,39993000],[1893,40014000],[1894,40056000],[1895,40098000],[1896,40192000],[1897,40348000],[1898,40473000],[1899,40546000],[1900,40598000],[1901,40640000],[1902,40713000],[1903,40786000],[1904,40859000],[1905,40890000],[1906,40942000],[1907,40942000],[1908,41046000],[1909,41109000],[1910,41224000],[1911,41307000],[1912,41359000],[1913,41463000],[1914,41476000],[1915,40481000],[1916,39884000],[1917,39288000],[1918,38542000],[1919,38700000],[1920,39000000],[1921,39240000],[1922,39420000],[1923,39880000],[1924,40310000],[1925,40610000],[1926,40870000],[1927,40940000],[1928,41050000],[1929,41230000],[1930,41610000],[1931,41860000],[1932,41860000],[1933,41890000],[1934,41950000],[1935,41940000],[1936,41910000],[1937,41930000],[1938,41960000],[1939,41900000],[1940,41000000],[1941,39600000],[1942,39400000],[1943,39000000],[1944,38900000],[1945,39700000],[1946,40290000],[1947,40680000],[1948,41110000],[1949,41480000],[1950,41828673],[1951,42155534],[1952,42459667],[1953,42751746],[1954,43056505],[1955,43427669],[1956,43843075],[1957,44310863],[1958,44788852],[1959,45239729],[1960,45670000],[1961,46189000],[1962,47124000],[1963,47808000],[1964,48340000],[1965,48763000],[1966,49194000],[1967,49569000],[1968,49934000],[1969,50353000],[1970,50787000],[1971,51285000],[1972,51732000],[1973,52157000],[1974,52503000],[1975,52758427],[1976,52953613],[1977,53165019],[1978,53380649],[1979,53605523],[1980,53869743],[1981,54147284],[1982,54433565],[1983,54649810],[1984,54946500],[1985,55171224],[1986,55387361],[1987,55630100],[1988,55873463],[1989,56416625],[1990,56735161],[1991,57055448],[1992,57374179],[1993,57658289],[1994,57906847],[1995,58149727],[1996,58388408],[1997,58623428],[1998,58866290],[1999,59116128],[2000,59381628],[2001,59658144],[2002,59925035],[2003,60180529],[2004,60424213],[2005,60656178],[2006,60876136],[2007,61083916],[2008,61279972]],"lifeExpectancy":[[1800,32.4],[1806,35],[1807,34.2],[1808,34.5],[1809,35],[1810,37.4],[1811,36.1],[1812,31.7],[1813,31.2],[1814,30.1],[1815,36.5],[1816,40.04],[1817,39.18],[1818,38.53],[1819,37.25],[1820,39.21],[1821,39.83],[1822,38.3],[1823,39.97],[1824,39.14],[1825,38.53],[1826,37.76],[1827,39.35],[1828,37.53],[1829,39.36],[1830,39.56],[1831,39.65],[1832,35.81],[1833,38.83],[1834,35.01],[1835,39.48],[1836,41.95],[1837,39.38],[1838,39.33],[1839,40.91],[1840,40.37],[1841,40.68],[1842,40.01],[1843,40.75],[1844,42.29],[1845,43.58],[1846,40.67],[1847,40.41],[1848,40.29],[1849,35.91],[1850,43.28],[1851,41.77],[1852,41.32],[1853,42.52],[1854,36.13],[1855,37.54],[1856,40.18],[1857,39.59],[1858,39.67],[1859,35.26],[1860,43.33],[1861,40.45],[1862,42.7],[1863,41.73],[1864,42.01],[1865,40.16],[1866,41.83],[1867,42.33],[1868,40.23],[1869,41.14],[1870,36.41],[1871,29.59],[1872,42.64],[1873,41.75],[1874,44.3],[1875,43.17],[1876,43.55],[1877,44.33],[1878,43.36],[1879,43.99],[1880,42.73],[1881,43.55],[1882,43.16],[1883,43.28],[1884,42.52],[1885,43.97],[1886,43.17],[1887,43.75],[1888,44.15],[1889,45.56],[1890,43.36],[1891,44.11],[1892,43.57],[1893,43.6],[1894,45.53],[1895,45.2],[1896,47.56],[1897,47.93],[1898,45.99],[1899,45.23],[1900,45.08],[1901,47.01],[1902,48.01],[1903,48.43],[1904,48.08],[1905,48.36],[1906,47.74],[1907,48.28],[1908,49.3],[1909,50.01],[1910,51.37],[1911,48.17],[1912,51.62],[1913,51.35],[1914,37.85],[1915,35.63],[1916,39.51],[1917,42.6],[1918,34.34],[1919,47.52],[1920,51.6],[1921,52.69],[1922,54.92],[1923,54.65],[1924,55.27],[1925,54.39],[1926,54.03],[1927,55.8],[1928,55.44],[1929,54.27],[1930,56.87],[1931,56.93],[1932,57.26],[1933,57.7],[1934,58.36],[1935,58.32],[1936,58.81],[1937,59.17],[1938,58.97],[1939,59.62],[1940,49.45],[1941,57.67],[1942,57.44],[1943,53.33],[1944,47.19],[1945,54.96],[1946,62.38],[1947,63.98],[1948,65.83],[1949,64.92],[1950,66.39],[1951,66.12],[1952,67.41],[1953,67.34],[1954,68.21],[1955,68.47],[1956,68.5],[1957,68.93],[1958,70.16],[1959,70.19],[1960,70.4],[1961,70.98],[1962,70.51],[1963,70.36],[1964,71.32],[1965,71.15],[1966,71.56],[1967,71.55],[1968,71.54],[1969,71.27],[1970,72.16],[1971,72.13],[1972,72.38],[1973,72.54],[1974,72.89],[1975,72.98],[1976,73.22],[1977,73.83],[1978,73.95],[1979,74.26],[1980,74.35],[1981,74.51],[1982,74.89],[1983,74.87],[1984,75.37],[1985,75.47],[1986,75.75],[1987,76.34],[1988,76.57],[1989,76.69],[1990,76.98],[1991,77.17],[1992,77.46],[1993,77.5],[1994,77.94],[1995,78.06],[1996,78.27],[1997,78.62],[1998,78.79],[1999,78.92],[2000,79.23],[2001,79.41],[2002,79.57],[2003,79.57],[2004,80.5],[2005,80.47],[2006,80.88],[2007,81.14],[2008,81.25],[2009,81.47]]},{"name":"Georgia","region":"Europe & Central Asia","income":[[1800,571.2],[1820,583.23],[1913,1300.06],[1965,2711.39],[1966,2881.8],[1967,3029.8],[1968,3134.36],[1969,3254.08],[1970,3613.63],[1971,3670.07],[1972,3741.23],[1973,3950.02],[1974,4263.52],[1975,4544.1],[1976,4788.27],[1977,5086.05],[1978,5430.06],[1979,5792.37],[1980,6014.45],[1981,6283.62],[1982,6359.83],[1983,6579.72],[1984,6876.8],[1985,7150.61],[1986,6499.97],[1987,6514.54],[1988,6816.1],[1989,6297.59],[1990,5375.31],[1991,4278.33],[1992,2393.03],[1993,1724.67],[1994,1576.71],[1995,1647.82],[1996,1861.57],[1997,2085.64],[1998,2176.23],[1999,2264.09],[2000,2332.22],[2001,2472.71],[2002,2637.56],[2003,2961.18],[2004,3167.15],[2005,3505],[2006,3764.4],[2007,4235.19],[2008,4345.66],[2009,4168.7]],"population":[[1800,1072178],[1820,1072178],[1950,3515602],[1951,3579417],[1952,3628347],[1953,3687436],[1954,3759860],[1955,3827154],[1956,3887496],[1957,3936823],[1958,3994787],[1959,4071078],[1960,4146570],[1961,4211113],[1962,4278649],[1963,4344220],[1964,4406832],[1965,4464959],[1966,4518103],[1967,4564785],[1968,4606979],[1969,4650335],[1970,4694491],[1971,4741628],[1972,4786475],[1973,4825850],[1974,4865233],[1975,4897656],[1976,4930036],[1977,4963464],[1978,4991045],[1979,5018606],[1980,5045697],[1981,5073148],[1982,5101213],[1983,5130925],[1984,5161724],[1985,5192957],[1986,5218973],[1987,5239970],[1988,5320248],[1989,5398106],[1990,5426207],[1991,5420156],[1992,5355289],[1993,5247618],[1994,5120809],[1995,5012952],[1996,4934572],[1997,4883476],[1998,4848495],[1999,4815667],[2000,4777209],[2001,4746164],[2002,4728357],[2003,4710921],[2004,4693892],[2005,4677401],[2006,4661473],[2007,4646003],[2008,4630841]],"lifeExpectancy":[[1950,59.8],[1951,60],[1952,60.4],[1953,60.8],[1954,61.2],[1955,61.6],[1956,62],[1957,62.4],[1958,62.81],[1959,63.21],[1960,63.61],[1961,64.02],[1962,64.44],[1963,64.85],[1964,65.27],[1965,65.67],[1966,66.06],[1967,66.43],[1968,66.79],[1969,67.12],[1970,67.44],[1971,67.75],[1972,68.07],[1973,68.39],[1974,68.71],[1975,69],[1976,69.25],[1977,69.45],[1978,69.58],[1979,69.65],[1980,69.69],[1981,69.71],[1982,69.74],[1983,69.81],[1984,69.91],[1985,70.04],[1986,70.18],[1987,70.31],[1988,70.41],[1989,70.47],[1990,70.51],[1991,70.54],[1992,70.57],[1993,70.61],[1994,70.68],[1995,70.77],[1996,70.88],[1997,71],[1998,71.13],[1999,71.25],[2000,71.36],[2001,71.45],[2002,71.5],[2003,71.53],[2004,71.54],[2005,71.55],[2006,71.57],[2007,71.63],[2008,71.72],[2009,71.86]]},{"name":"Germany","region":"Europe & Central Asia","income":[[1800,1695.68],[1820,1945.75],[1821,1959.18],[1822,1972.7],[1823,1986.32],[1824,2000.03],[1825,2013.83],[1826,2027.73],[1827,2041.73],[1828,2055.82],[1829,2070.01],[1830,2084.3],[1831,2091.83],[1832,2099.4],[1833,2106.99],[1834,2114.61],[1835,2122.26],[1836,2129.93],[1837,2137.64],[1838,2145.37],[1839,2153.13],[1840,2160.91],[1841,2168.73],[1842,2176.57],[1843,2184.44],[1844,2192.34],[1845,2200.27],[1846,2208.23],[1847,2216.21],[1848,2224.23],[1849,2232.27],[1850,2240.35],[1851,2209.1],[1852,2237.39],[1853,2218],[1854,2264.94],[1855,2229.04],[1856,2403.11],[1857,2502.1],[1858,2470.35],[1859,2456.18],[1860,2572.49],[1861,2483.9],[1862,2581.56],[1863,2744.35],[1864,2793.09],[1865,2776.92],[1866,2779.13],[1867,2770.95],[1868,2920.7],[1869,2919.02],[1870,2885.95],[1871,2850.62],[1872,3030.79],[1873,3136.39],[1874,3333],[1875,3314.78],[1876,3249.37],[1877,3189.68],[1878,3300.1],[1879,3183.46],[1880,3124.99],[1881,3178.15],[1882,3208.28],[1883,3363.31],[1884,3418.47],[1885,3477.8],[1886,3470.18],[1887,3570.4],[1888,3673.25],[1889,3733.56],[1890,3809.81],[1891,3760.75],[1892,3874.94],[1893,4025.82],[1894,4076.25],[1895,4215.1],[1896,4299.15],[1897,4354.02],[1898,4468.91],[1899,4558.78],[1900,4683.8],[1901,4505.8],[1902,4540.54],[1903,4720.51],[1904,4838.51],[1905,4870.98],[1906,4946.45],[1907,5091.98],[1908,5106.79],[1909,5138.79],[1910,5253.25],[1911,5348.6],[1912,5529.51],[1913,5724.59],[1914,4800.75],[1915,4549.24],[1916,4604.93],[1917,4632.51],[1918,4681.28],[1919,4058.48],[1920,4386.95],[1921,4829.84],[1922,5227.11],[1923,4314.74],[1924,5019.72],[1925,5542.04],[1926,5656.53],[1927,6184.52],[1928,6418.17],[1929,6357.62],[1930,6235.14],[1931,5730.09],[1932,5275.27],[1933,5579.88],[1934,6054.45],[1935,6464.97],[1936,6984.27],[1937,7351.76],[1938,7836.14],[1939,8483.68],[1940,8477.82],[1941,8962.15],[1942,9007.31],[1943,9242.26],[1944,9546.85],[1945,7083.98],[1946,3478.75],[1947,3822.81],[1948,4446.78],[1949,5150.97],[1950,6090.03],[1951,6599.92],[1952,7144.11],[1953,7697.25],[1954,8233.48],[1955,9096.83],[1956,9692.61],[1957,10187.83],[1958,10571.59],[1959,11261.93],[1960,12091.34],[1961,12478.83],[1962,12902.46],[1963,13158.88],[1964,13844.37],[1965,14414.59],[1966,14731.37],[1967,14745.63],[1968,15479.67],[1969,16383.41],[1970,17009.19],[1971,17382.08],[1972,18016.18],[1973,18778.23],[1974,18929.76],[1975,18894.57],[1976,19903.97],[1977,20512.92],[1978,21114.59],[1979,21958.81],[1980,22148.27],[1981,22202.51],[1982,22031.53],[1983,22485.38],[1984,23198.33],[1985,23757.88],[1986,24274.56],[1987,24639.19],[1988,25359.06],[1989,25983.63],[1990,24996.14],[1991,26127.06],[1992,26505.3],[1993,26119.46],[1994,26720.64],[1995,27145.96],[1996,27336.47],[1997,27788.88],[1998,28291.6],[1999,28842.66],[2000,29726.88],[2001,30061.4],[2002,30035.8],[2003,29952.94],[2004,30260.66],[2005,30496],[2006,31511.65],[2007,32342.82],[2008,32785.53],[2009,31191.15]],"population":[[1820,24905000],[1821,25260000],[1822,25620000],[1823,25969000],[1824,26307000],[1825,26650000],[1826,26964000],[1827,27249000],[1828,27540000],[1829,27807000],[1830,28045000],[1831,28283000],[1832,28535000],[1833,28801000],[1834,29071000],[1835,29390000],[1836,29702000],[1837,30013000],[1838,30365000],[1839,30746000],[1840,31126000],[1841,31475000],[1842,31787000],[1843,32086000],[1844,32394000],[1845,32743000],[1846,33059000],[1847,33231000],[1848,33289000],[1849,33452000],[1850,33746000],[1851,34055000],[1852,34290000],[1853,34422000],[1854,34531000],[1855,34586000],[1856,34715000],[1857,34979000],[1858,35278000],[1859,35633000],[1860,36049000],[1861,36435000],[1862,36788000],[1863,37184000],[1864,37602000],[1865,37955000],[1866,38193000],[1867,38440000],[1868,38637000],[1869,38914000],[1870,39231000],[1871,39456000],[1872,39691000],[1873,40017000],[1874,40450000],[1875,40897000],[1876,41491000],[1877,42034000],[1878,42546000],[1879,43052000],[1880,43500000],[1881,43827000],[1882,44112000],[1883,44404000],[1884,44777000],[1885,45084000],[1886,45505000],[1887,46001000],[1888,46538000],[1889,47083000],[1890,47607000],[1891,48129000],[1892,48633000],[1893,49123000],[1894,49703000],[1895,50363000],[1896,51111000],[1897,51921000],[1898,52753000],[1899,53592000],[1900,54388000],[1901,55214000],[1902,56104000],[1903,56963000],[1904,57806000],[1905,58644000],[1906,59481000],[1907,60341000],[1908,61187000],[1909,62038000],[1910,62884000],[1911,63852000],[1912,64457000],[1913,65058000],[1914,66096000],[1915,66230000],[1916,66076000],[1917,65763000],[1918,65237000],[1919,60547000],[1920,60894000],[1921,61573000],[1922,61900000],[1923,62307000],[1924,62697000],[1925,63166000],[1926,63630000],[1927,64023000],[1928,64393000],[1929,64739000],[1930,65084000],[1931,65423000],[1932,65716000],[1933,66027000],[1934,66409000],[1935,66871000],[1936,67349000],[1937,67831000],[1938,68558000],[1939,69286000],[1940,69835000],[1941,70244000],[1942,70834000],[1943,70411000],[1944,69865000],[1945,67000000],[1946,64678000],[1947,66094000],[1948,67295000],[1949,67991000],[1950,68374572],[1951,68875884],[1952,69145952],[1953,69550236],[1954,69868115],[1955,70195612],[1956,70602518],[1957,71019069],[1958,71488167],[1959,72013853],[1960,72480869],[1961,73123148],[1962,73739117],[1963,74340260],[1964,74954262],[1965,75638851],[1966,76206173],[1967,76368453],[1968,76584401],[1969,77143888],[1970,77783164],[1971,78354709],[1972,78717088],[1973,78950220],[1974,78966137],[1975,78682325],[1976,78298957],[1977,78160773],[1978,78066074],[1979,78081292],[1980,78297904],[1981,78401830],[1982,78335266],[1983,78121655],[1984,77855422],[1985,77684907],[1986,77713485],[1987,77718298],[1988,78030572],[1989,78644914],[1990,79380394],[1991,79984244],[1992,80597764],[1993,81132272],[1994,81414164],[1995,81653702],[1996,81890667],[1997,82011073],[1998,82023672],[1999,82074778],[2000,82187909],[2001,82280551],[2002,82350671],[2003,82398326],[2004,82424609],[2005,82431390],[2006,82422299],[2007,82400996],[2008,82369548]],"lifeExpectancy":[[1800,38.37],[1875,38.37],[1885,39.44],[1895,42.38],[1905,45.45],[1911,49],[1915,40.52],[1925,57.42],[1935,61.5],[1939,62.6],[1940,62.26],[1941,62.19],[1942,59.64],[1943,57.76],[1944,52.66],[1945,46.13],[1946,60.51],[1950,66.78],[1951,66.96],[1952,67.33],[1953,67.69],[1954,68.03],[1955,68.36],[1956,68.68],[1957,68.98],[1958,69.27],[1959,69.54],[1960,69.79],[1961,70.01],[1962,70.21],[1963,70.38],[1964,70.52],[1965,70.62],[1966,70.7],[1967,70.74],[1968,70.77],[1969,70.79],[1970,70.83],[1971,70.9],[1972,71.01],[1973,71.18],[1974,71.4],[1975,71.67],[1976,71.97],[1977,72.29],[1978,72.6],[1979,72.9],[1980,73.18],[1981,73.43],[1982,73.67],[1983,73.9],[1984,74.11],[1985,74.32],[1986,74.54],[1987,74.77],[1988,75],[1989,75.25],[1990,75.39],[1991,75.61],[1992,76.07],[1993,76.15],[1994,76.47],[1995,76.66],[1996,76.9],[1997,77.35],[1998,77.7],[1999,77.94],[2000,78.21],[2001,78.58],[2002,78.67],[2003,78.75],[2004,79.34],[2005,79.48],[2006,79.81],[2007,79.98],[2008,80.06],[2009,80.08]]},{"name":"Greece","region":"Europe & Central Asia","income":[[1800,934.41],[1801,935.9],[1802,937.38],[1803,938.87],[1804,940.36],[1805,941.85],[1806,943.34],[1807,944.84],[1808,946.33],[1809,947.84],[1810,949.34],[1811,950.84],[1812,952.35],[1813,953.86],[1814,955.38],[1815,956.89],[1816,958.41],[1817,959.93],[1818,961.45],[1819,962.98],[1820,964.5],[1821,972.3],[1822,980.15],[1823,988.07],[1824,996.05],[1825,1004.1],[1826,1012.21],[1827,1020.39],[1828,1028.64],[1829,1036.95],[1830,1045.33],[1831,1053.77],[1832,1062.29],[1833,1070.87],[1834,1079.52],[1835,1088.24],[1836,1097.04],[1837,1105.9],[1838,1114.84],[1839,1123.84],[1840,1132.92],[1841,1142.08],[1842,1151.31],[1843,1160.61],[1844,1169.99],[1845,1179.44],[1846,1188.97],[1847,1198.57],[1848,1208.26],[1849,1218.02],[1850,1227.86],[1851,1232.5],[1852,1237.16],[1853,1241.83],[1854,1246.52],[1855,1251.23],[1856,1255.96],[1857,1260.71],[1858,1265.47],[1859,1270.25],[1860,1275.05],[1861,1279.87],[1862,1284.7],[1863,1289.56],[1864,1294.43],[1865,1299.32],[1866,1304.23],[1867,1309.15],[1868,1314.1],[1869,1319.07],[1870,1324.05],[1871,1343.5],[1872,1363.25],[1873,1383.28],[1874,1403.6],[1875,1424.23],[1876,1445.15],[1877,1466.39],[1878,1487.94],[1879,1509.8],[1880,1531.98],[1881,1554.5],[1882,1577.34],[1883,1600.51],[1884,1624.03],[1885,1647.9],[1886,1672.11],[1887,1696.68],[1888,1721.61],[1889,1746.91],[1890,1772.58],[1891,1797.03],[1892,1821.83],[1893,1846.97],[1894,1872.45],[1895,1898.29],[1896,1924.48],[1897,1951.04],[1898,1977.96],[1899,2005.25],[1900,2032.92],[1901,2058.71],[1902,2084.84],[1903,2111.29],[1904,2138.08],[1905,2165.21],[1906,2192.68],[1907,2220.5],[1908,2248.67],[1909,2277.21],[1910,2306.1],[1911,2335.36],[1912,2364.99],[1913,2395],[1914,2455.06],[1915,2516.63],[1916,2579.74],[1917,2644.43],[1918,2710.74],[1919,2778.72],[1920,2848.4],[1921,2919.83],[1922,2993.27],[1923,3034.8],[1924,3144.67],[1925,3276.03],[1926,3342.01],[1927,3409.21],[1928,3435.92],[1929,3606.72],[1930,3482.77],[1931,3296.69],[1932,3539.75],[1933,3709.49],[1934,3751.22],[1935,3852.51],[1936,3819.78],[1937,4313.84],[1938,4176.55],[1939,4121.41],[1940,3478.46],[1941,2936.62],[1942,2477.95],[1943,2085.53],[1944,1756.5],[1945,1477.82],[1946,2188.35],[1947,2786.57],[1948,2847.04],[1949,2962.29],[1950,3040.41],[1951,3278.15],[1952,3269.31],[1953,3682.62],[1954,3766.01],[1955,4019.81],[1956,4333.64],[1957,4585.5],[1958,4759.42],[1959,4890.42],[1960,5067.26],[1961,5473.18],[1962,5653.18],[1963,6213.79],[1964,6709.76],[1965,7316.29],[1966,7717.14],[1967,8056.35],[1968,8581.63],[1969,9410.71],[1970,10150.88],[1971,10842.06],[1972,12129.8],[1973,12566.7],[1974,12082.49],[1975,12712.2],[1976,13362.2],[1977,13630.27],[1978,14376.56],[1979,14743.85],[1980,14877.19],[1981,14774],[1982,14767.21],[1983,14766.5],[1984,15123.24],[1985,15560.95],[1986,15791.5],[1987,15704.89],[1988,16414.35],[1989,16988.41],[1990,16851.57],[1991,17193.36],[1992,17213.67],[1993,16868.79],[1994,17153.8],[1995,17492.91],[1996,17894.05],[1997,18531.3],[1998,19146.38],[1999,19803.27],[2000,20675.21],[2001,21585.57],[2002,22416.45],[2003,23532.36],[2004,24587.16],[2005,25520],[2006,26618.65],[2007,27746.49],[2008,28242.04],[2009,27626.11]],"population":[[1820,2312000],[1821,2333000],[1822,2355000],[1823,2376000],[1824,2398000],[1825,2420000],[1826,2443000],[1827,2465000],[1828,2488000],[1829,2511000],[1830,2534000],[1831,2557000],[1832,2581000],[1833,2605000],[1834,2629000],[1835,2653000],[1836,2677000],[1837,2702000],[1838,2727000],[1839,2752000],[1840,2777000],[1841,2803000],[1842,2829000],[1843,2855000],[1844,2881000],[1845,2908000],[1846,2934000],[1847,2961000],[1848,2989000],[1849,3016000],[1850,3044000],[1851,3072000],[1852,3100000],[1853,3129000],[1854,3158000],[1855,3187000],[1856,3216000],[1857,3246000],[1858,3273000],[1859,3306000],[1860,3336000],[1861,3367000],[1862,3398000],[1863,3430000],[1864,3461000],[1865,3493000],[1866,3525000],[1867,3558000],[1868,3591000],[1869,3621000],[1870,3657000],[1871,3694000],[1872,3732000],[1873,3770000],[1874,3809000],[1875,3848000],[1876,3887000],[1877,3927000],[1878,3967000],[1879,4008000],[1880,4049000],[1881,4090000],[1882,4132000],[1883,4174000],[1884,4217000],[1885,4260000],[1886,4303000],[1887,4347000],[1888,4392000],[1889,4437000],[1890,4482000],[1891,4528000],[1892,4574000],[1893,4621000],[1894,4668000],[1895,4716000],[1896,4764000],[1897,4813000],[1898,4862000],[1899,4912000],[1900,4962000],[1901,4997000],[1902,5032000],[1903,5067000],[1904,5102000],[1905,5138000],[1906,5174000],[1907,5210000],[1908,5246000],[1909,5283000],[1910,5320000],[1911,5355000],[1912,5390000],[1913,5425000],[1914,5463000],[1915,5502000],[1916,5541000],[1917,5580000],[1918,5620000],[1919,5660000],[1920,5700000],[1921,5837000],[1922,5890000],[1923,6010000],[1924,6000000],[1925,5958000],[1926,6042000],[1927,6127000],[1928,6205000],[1929,6275000],[1930,6351000],[1931,6440000],[1932,6516000],[1933,6591000],[1934,6688000],[1935,6793000],[1936,6886000],[1937,6973000],[1938,7061000],[1939,7156000],[1940,7280000],[1941,7362000],[1942,7339000],[1943,7297000],[1944,7284000],[1945,7322000],[1946,7418000],[1947,7529000],[1948,7749000],[1949,7856000],[1950,7566028],[1951,7646402],[1952,7733250],[1953,7817095],[1954,7893412],[1955,7965538],[1956,8031013],[1957,8096218],[1958,8173129],[1959,8258162],[1960,8327405],[1961,8398050],[1962,8448233],[1963,8479625],[1964,8510429],[1965,8550333],[1966,8613651],[1967,8716441],[1968,8740765],[1969,8772764],[1970,8792806],[1971,8831036],[1972,8888628],[1973,8929086],[1974,8962023],[1975,9046542],[1976,9167190],[1977,9308479],[1978,9429959],[1979,9548258],[1980,9642505],[1981,9729350],[1982,9786480],[1983,9840526],[1984,9887169],[1985,9923253],[1986,9951370],[1987,9974490],[1988,9982723],[1989,10030765],[1990,10129603],[1991,10250880],[1992,10325429],[1993,10382995],[1994,10429826],[1995,10457554],[1996,10479420],[1997,10502372],[1998,10520068],[1999,10536749],[2000,10559110],[2001,10581515],[2002,10603863],[2003,10625945],[2004,10647529],[2005,10668354],[2006,10688058],[2007,10706290],[2008,10722816]],"lifeExpectancy":[[1800,36.6],[1877,36.6],[1882,37.1],[1887,37.7],[1892,38.5],[1897,39.4],[1902,40.4],[1907,41.2],[1920,44.65],[1922,45.2],[1927,48.2],[1928,46.17],[1929,49.97],[1932,50.5],[1937,52.8],[1940,54.34],[1950,64.97],[1951,65.2],[1952,65.65],[1953,66.09],[1954,66.51],[1955,66.92],[1956,67.31],[1957,67.68],[1958,68.04],[1959,68.39],[1960,68.73],[1961,69.05],[1962,69.37],[1963,69.68],[1964,69.98],[1965,70.28],[1966,70.57],[1967,70.86],[1968,71.14],[1969,71.41],[1970,71.68],[1971,71.95],[1972,72.21],[1973,72.47],[1974,72.73],[1975,72.99],[1976,73.27],[1977,73.55],[1978,73.84],[1979,74.15],[1980,74.46],[1981,74.77],[1982,75.09],[1983,75.41],[1984,75.72],[1985,76.02],[1986,76.3],[1987,76.56],[1988,76.79],[1989,77],[1990,77.15],[1991,77.26],[1992,77.31],[1993,77.31],[1994,77.28],[1995,77.23],[1996,77.2],[1997,77.2],[1998,77.26],[1999,77.37],[2000,77.53],[2001,77.74],[2002,77.97],[2003,78.21],[2004,78.44],[2005,78.67],[2006,78.88],[2007,79.09],[2008,79.3],[2009,79.5]]},{"name":"Hungary","region":"Europe & Central Asia","income":[[1800,1390.67],[1820,1419.84],[1870,2080.32],[1890,2806.25],[1900,3206.12],[1910,3812.26],[1913,3998.03],[1920,3256.68],[1924,3643.92],[1925,4343.45],[1926,4120.45],[1927,4263.81],[1928,4602.36],[1929,4718.3],[1930,4580.82],[1931,4322.77],[1932,4178.09],[1933,4523.85],[1934,4515.95],[1935,4709.54],[1936,4989.63],[1937,4846.07],[1938,5060.54],[1939,5408.1],[1940,5005.28],[1941,5004.94],[1942,5227.43],[1946,3279.36],[1947,3379.93],[1948,4192.74],[1949,4486.51],[1950,4726.19],[1951,5135.95],[1952,5263.67],[1953,5308.49],[1954,5431.86],[1955,5850.99],[1956,5537.72],[1957,6040.18],[1958,6416.73],[1959,6639.87],[1960,6954.29],[1961,7272.79],[1962,7550.36],[1963,7942.53],[1964,8362.48],[1965,8403.48],[1966,8854.42],[1967,9326.64],[1968,9403.18],[1969,9647.24],[1970,9581.97],[1971,9982.61],[1972,10168.66],[1973,10663.67],[1974,10892.94],[1975,11062.46],[1976,11035.57],[1977,11674.84],[1978,11917.24],[1979,11912.91],[1980,12018.55],[1981,12102.6],[1982,12545.99],[1983,12435.83],[1984,12786.88],[1985,12495.2],[1986,12767.16],[1987,12986.48],[1988,13399.3],[1989,13155.25],[1990,12308.91],[1991,10851.83],[1992,10535.63],[1993,10494.88],[1994,10821.26],[1995,11000.41],[1996,11169.79],[1997,11712.78],[1998,12319.41],[1999,12874.42],[2000,13592.35],[2001,14185.52],[2002,14843.94],[2003,15506.2],[2004,16291.2],[2005,17014],[2006,17725.9],[2007,17916.21],[2008,18068.58],[2009,16982.8]],"population":[[1820,4146000],[1850,5161000],[1870,5917000],[1890,6622000],[1900,7127000],[1910,7644000],[1913,7840000],[1920,7950000],[1921,8029000],[1922,8103000],[1923,8173000],[1924,8232000],[1925,8299000],[1926,8383000],[1927,8454000],[1928,8520000],[1929,8583000],[1930,8649000],[1931,8723000],[1932,8785000],[1933,8848000],[1934,8919000],[1935,8985000],[1936,9046000],[1937,9107000],[1938,9167000],[1939,9227000],[1940,9287000],[1941,9344000],[1942,9396000],[1943,9442000],[1944,9497000],[1945,9024000],[1946,9042000],[1947,9079000],[1948,9158000],[1949,9250000],[1950,9338000],[1951,9423000],[1952,9504000],[1953,9595000],[1954,9706000],[1955,9825000],[1956,9911000],[1957,9839000],[1958,9882000],[1959,9937000],[1960,9983512],[1961,10029000],[1962,10063000],[1963,10091000],[1964,10124000],[1965,10152934],[1966,10184561],[1967,10223422],[1968,10263542],[1969,10302814],[1970,10337004],[1971,10364869],[1972,10394091],[1973,10425984],[1974,10471272],[1975,10531820],[1976,10588729],[1977,10637171],[1978,10673300],[1979,10698234],[1980,10711122],[1981,10711848],[1982,10705535],[1983,10689463],[1984,10668095],[1985,10648713],[1986,10630563],[1987,10612740],[1988,10442500],[1989,10397959],[1990,10371878],[1991,10364737],[1992,10348684],[1993,10329012],[1994,10312714],[1995,10295874],[1996,10273591],[1997,10244684],[1998,10211127],[1999,10172673],[2000,10137449],[2001,10109467],[2002,10083313],[2003,10057745],[2004,10032375],[2005,10006835],[2006,9981334],[2007,9956108],[2008,9930915]],"lifeExpectancy":[[1800,36],[1890,36],[1900,37.34],[1910,39.76],[1920,42.06],[1930,50.21],[1941,56.56],[1949,61.29],[1950,62.07],[1951,62.46],[1952,64.03],[1953,63.87],[1954,65.43],[1955,66.88],[1956,66.04],[1957,66.41],[1958,67.42],[1959,67.32],[1960,68.09],[1961,69.02],[1962,67.96],[1963,68.98],[1964,69.48],[1965,69.17],[1966,69.93],[1967,69.5],[1968,69.33],[1969,69.4],[1970,69.24],[1971,69.13],[1972,69.76],[1973,69.63],[1974,69.35],[1975,69.4],[1976,69.69],[1977,69.95],[1978,69.49],[1979,69.7],[1980,69.11],[1981,69.17],[1982,69.39],[1983,68.95],[1984,68.99],[1985,68.93],[1986,69.14],[1987,69.61],[1988,70],[1989,69.44],[1990,69.41],[1991,69.46],[1992,69.21],[1993,69.25],[1994,69.68],[1995,70.08],[1996,70.67],[1997,71.07],[1998,71],[1999,71.14],[2000,71.86],[2001,72.49],[2002,72.61],[2003,72.63],[2004,73.04],[2005,72.99],[2006,73.45],[2007,73.45],[2008,73.48],[2009,73.67]]},{"name":"Iceland","region":"Europe & Central Asia","income":[[1800,801.9],[1820,828.93],[1870,1416.21],[1871,1441.22],[1872,1436.14],[1873,1501.2],[1874,1546.62],[1875,1539.8],[1876,1514.68],[1877,1546.88],[1878,1604.6],[1879,1698.15],[1880,1799.25],[1881,1802.69],[1882,1609.07],[1883,1547.32],[1884,1565.79],[1885,1599.16],[1886,1604.51],[1887,1577.48],[1888,1632.08],[1889,1701.73],[1890,1773.61],[1891,1816.24],[1892,1932.36],[1893,2057.61],[1894,2080.31],[1895,2035.37],[1896,2075.54],[1897,2062],[1898,2000.08],[1899,1997.73],[1900,2073.92],[1901,2163.93],[1902,2223.26],[1903,2222.88],[1904,2225.98],[1905,2377.91],[1906,2430.86],[1907,2524.6],[1908,2504.78],[1909,2476.25],[1910,2651.74],[1911,2763.78],[1912,2783.22],[1913,2908.62],[1914,2843.71],[1915,2789.84],[1916,2459.7],[1917,2406.44],[1918,2264.74],[1919,2622.11],[1920,2210.37],[1921,2429.41],[1922,2725.28],[1923,2576.98],[1924,2745.48],[1925,2739.43],[1926,2947.87],[1927,3236.57],[1928,3359.91],[1929,3552.27],[1930,3926.26],[1931,3864.34],[1932,3688.39],[1933,4066.56],[1934,4094.87],[1935,3943.75],[1936,3934.71],[1937,4083.18],[1938,4083.27],[1939,4538.18],[1940,4773.73],[1941,5411.37],[1942,6238.02],[1943,6574.81],[1944,7112.1],[1945,7562.67],[1946,7759.22],[1947,8431.86],[1948,8438.73],[1949,8116.16],[1950,7750.29],[1951,7468.81],[1952,7267.69],[1953,8211.29],[1954,8800.72],[1955,9458.67],[1956,9489.02],[1957,9244],[1958,9789.87],[1959,9768.93],[1960,9890.07],[1961,9724.49],[1962,10350.16],[1963,11221.63],[1964,12133.87],[1965,12794.88],[1966,13701.27],[1967,13319.9],[1968,12441.44],[1969,12659.11],[1970,13532.84],[1971,15128.83],[1972,15798.06],[1973,16670.02],[1974,17375.59],[1975,17297.44],[1976,18179.25],[1977,19654.96],[1978,20649.68],[1979,21453.78],[1980,22434.86],[1981,23121.41],[1982,23269.61],[1983,22499.9],[1984,23215.83],[1985,23821.71],[1986,25107.72],[1987,26923.21],[1988,26435.22],[1989,26317.46],[1990,26372.88],[1991,26332.62],[1992,25144.39],[1993,25030.86],[1994,25941.54],[1995,25840.49],[1996,27027.25],[1997,28061.1],[1998,29256.7],[1999,30042.94],[2000,31092.03],[2001,31830.54],[2002,31163.2],[2003,31937.01],[2004,34279.18],[2005,35630],[2006,36326.1],[2007,37787.48],[2008,37782.95],[2009,34989.73]],"population":[[1800,61428],[1820,61428],[1950,142938],[1951,145604],[1952,147962],[1953,151036],[1954,154563],[1955,158044],[1956,161358],[1957,165110],[1958,168771],[1959,172314],[1960,175860],[1961,178905],[1962,182053],[1963,185481],[1964,188847],[1965,192288],[1966,195610],[1967,198676],[1968,201245],[1969,202920],[1970,204104],[1971,206092],[1972,209275],[1973,212364],[1974,215324],[1975,218031],[1976,220133],[1977,221823],[1978,223587],[1979,225749],[1980,228161],[1981,230803],[1982,233997],[1983,237041],[1984,239498],[1985,241403],[1986,242999],[1987,244676],[1988,249885],[1989,252746],[1990,254719],[1991,256831],[1992,259012],[1993,261270],[1994,266075],[1995,267527],[1996,269000],[1997,271192],[1998,274000],[1999,277280],[2000,281043],[2001,284812],[2002,288030],[2003,291064],[2004,293966],[2005,296737],[2006,299388],[2007,301931],[2008,304367]],"lifeExpectancy":[[1800,32.4],[1838,32.4],[1839,27.95],[1840,31.97],[1841,40.22],[1842,40.13],[1843,25.39],[1844,42.9],[1845,41.35],[1846,18.31],[1847,32.94],[1848,41.39],[1849,37.14],[1850,36.61],[1851,30.01],[1852,42.1],[1853,48.6],[1854,43.14],[1855,38.15],[1856,42.34],[1857,39.49],[1858,34.84],[1859,29.67],[1860,19.76],[1861,27.09],[1862,26.96],[1863,35.11],[1864,34.81],[1865,34.21],[1866,27.2],[1867,37.54],[1868,34.64],[1869,28.03],[1870,38.37],[1871,35.02],[1872,25.15],[1873,36.61],[1874,39.62],[1875,36.54],[1876,40.25],[1877,44.64],[1878,41.61],[1879,39.52],[1880,42.32],[1881,35.82],[1882,17.74],[1883,30.27],[1884,42.19],[1885,45.46],[1886,44.97],[1887,40.6],[1888,46.8],[1889,52.47],[1890,36.58],[1891,47.49],[1892,52.73],[1893,52.58],[1894,44.79],[1895,52.52],[1896,53.22],[1897,48.52],[1898,44.2],[1899,49.79],[1900,46.64],[1901,52.98],[1902,50.52],[1903,48.84],[1904,52.66],[1905,49.51],[1906,53.58],[1907,49.74],[1908,45.79],[1909,52.36],[1910,52.67],[1911,55.47],[1912,56],[1913,58.95],[1914,51.92],[1915,53.66],[1916,54.53],[1917,59.02],[1918,51.07],[1919,58.49],[1920,54.58],[1921,54.21],[1922,56.95],[1923,57.67],[1924,54],[1925,58.23],[1926,60.79],[1927,58.12],[1928,61.81],[1929,60.55],[1930,60.23],[1931,60.83],[1932,62.16],[1933,63.02],[1934,63.37],[1935,59.49],[1936,62.75],[1937,63.52],[1938,65.09],[1939,65.99],[1940,65.79],[1941,63.18],[1942,64.12],[1943,65.22],[1944,66.8],[1945,67.53],[1946,68.56],[1947,69.39],[1948,70.17],[1949,71.44],[1950,71.01],[1951,71.05],[1952,72.49],[1953,72.31],[1954,73.36],[1955,73.3],[1956,72.98],[1957,73.47],[1958,73.43],[1959,72.66],[1960,74.09],[1961,73.47],[1962,73.68],[1963,72.98],[1964,73.57],[1965,73.84],[1966,73.23],[1967,73.73],[1968,73.94],[1969,73.71],[1970,73.81],[1971,73.55],[1972,74.46],[1973,74.31],[1974,74.37],[1975,75.35],[1976,76.71],[1977,76.11],[1978,76.42],[1979,76.63],[1980,76.66],[1981,76.35],[1982,76.99],[1983,76.63],[1984,77.43],[1985,77.56],[1986,78.09],[1987,77.23],[1988,77.08],[1989,78.15],[1990,77.98],[1991,77.94],[1992,78.77],[1993,78.98],[1994,79.24],[1995,78.04],[1996,78.84],[1997,78.95],[1998,79.67],[1999,79.46],[2000,79.72],[2001,80.64],[2002,80.5],[2003,81.06],[2004,80.95],[2005,81.43],[2006,81.12],[2007,81.31],[2008,81.85],[2009,81.95]]},{"name":"Ireland","region":"Europe & Central Asia","income":[[1800,1213.16],[1820,1255.19],[1821,1273],[1822,1291.06],[1823,1309.38],[1824,1327.97],[1825,1346.81],[1826,1365.92],[1827,1385.3],[1828,1404.96],[1829,1424.9],[1830,1445.12],[1831,1465.63],[1832,1486.42],[1833,1507.52],[1834,1528.91],[1835,1550.6],[1836,1572.61],[1837,1594.92],[1838,1617.56],[1839,1640.51],[1840,1663.79],[1841,1687.4],[1842,1711.34],[1843,1735.63],[1844,1760.26],[1845,1472.74],[1846,1232.18],[1847,1400],[1848,1232],[1849,1200],[1850,1550],[1851,1800],[1852,1970.3],[1853,1998.25],[1854,2026.61],[1855,2055.37],[1856,2084.54],[1857,2114.12],[1858,2144.12],[1859,2174.54],[1860,2205.4],[1861,2236.69],[1862,2268.43],[1863,2300.62],[1864,2333.27],[1865,2366.38],[1866,2399.96],[1867,2434.01],[1868,2468.55],[1869,2503.58],[1870,2539.11],[1871,2564.79],[1872,2590.73],[1873,2616.93],[1874,2643.4],[1875,2670.13],[1876,2697.13],[1877,2724.41],[1878,2751.97],[1879,2779.8],[1880,2807.91],[1881,2836.31],[1882,2864.99],[1883,2893.97],[1884,2923.24],[1885,2952.8],[1886,2982.66],[1887,3012.83],[1888,3043.3],[1889,3074.08],[1890,3105.17],[1891,3136.57],[1892,3168.29],[1893,3200.34],[1894,3232.7],[1895,3265.4],[1896,3298.42],[1897,3331.78],[1898,3365.48],[1899,3399.51],[1900,3433.9],[1901,3468.62],[1902,3503.7],[1903,3539.14],[1904,3574.93],[1905,3611.09],[1906,3647.61],[1907,3684.5],[1908,3721.76],[1909,3759.4],[1910,3797.42],[1911,3835.83],[1912,3874.62],[1913,3913.81],[1914,3876.19],[1915,3838.93],[1916,3802.03],[1917,3765.48],[1918,3729.28],[1919,3693.44],[1920,3657.94],[1921,3622.77],[1922,3716.68],[1923,3682.89],[1924,3674.88],[1925,3680.34],[1926,3678.42],[1927,3795.01],[1928,3915.26],[1929,4039.53],[1930,4144.23],[1931,4250.85],[1932,4126.9],[1933,4005.44],[1934,4122.34],[1935,4242.7],[1936,4366.06],[1937,4229.22],[1938,4366.34],[1939,4365.92],[1940,4365.8],[1941,4365.89],[1942,4365.68],[1943,4365.62],[1944,4365.67],[1945,4318.47],[1946,4365.83],[1947,4423.12],[1948,4621.03],[1949,4869.55],[1950,4939.18],[1951,5069.59],[1952,5210.28],[1953,5359.59],[1954,5427.05],[1955,5607.71],[1956,5574.54],[1957,5599.08],[1958,5535.12],[1959,5776.53],[1960,6125.35],[1961,6449],[1962,6631.6],[1963,6896.75],[1964,7131.74],[1965,7225.83],[1966,7267.29],[1967,7655.57],[1968,8253.11],[1969,8710.47],[1970,8867.96],[1971,9088.5],[1972,9530.77],[1973,9822.55],[1974,10073.82],[1975,10465.52],[1976,10445.81],[1977,11150.98],[1978,11800.94],[1979,11967.79],[1980,12217.02],[1981,12467.88],[1982,12618.32],[1983,12501.69],[1984,12953.44],[1985,13311.61],[1986,13252.76],[1987,13872.87],[1988,14639.6],[1989,15562.98],[1990,16904.61],[1991,17120.66],[1992,17558.82],[1993,17927.85],[1994,18869.09],[1995,20581.98],[1996,22144.69],[1997,24521.95],[1998,26127.25],[1999,28496.8],[2000,30827.98],[2001,32335.28],[2002,34077.05],[2003,35191.11],[2004,36303.8],[2005,38058],[2006,39093.97],[2007,40501.4],[2008,38533.88],[2009,35692.95]],"population":[[1820,5052603],[1821,5123045],[1822,5170718],[1823,5219102],[1824,5267487],[1825,5316582],[1826,5366390],[1827,5416197],[1828,5466716],[1829,5517947],[1830,5569177],[1831,5621119],[1832,5655984],[1833,5690849],[1834,5725715],[1835,5760580],[1836,5796156],[1837,5831733],[1838,5868021],[1839,5904310],[1840,5940598],[1841,5976886],[1842,5992540],[1843,6006059],[1844,6033097],[1845,6045905],[1846,6040924],[1847,5838137],[1848,5436120],[1849,5162891],[1850,4893931],[1851,4634933],[1852,4508991],[1853,4410800],[1854,4328262],[1855,4279877],[1856,4249993],[1857,4211570],[1858,4191647],[1859,4171013],[1860,4141840],[1861,4118359],[1862,4109821],[1863,4068552],[1864,4013764],[1865,3981033],[1866,3929803],[1867,3904187],[1868,3889245],[1869,3877149],[1870,3855803],[1871,3840861],[1872,3823072],[1873,3791053],[1874,3770419],[1875,3756188],[1876,3755477],[1877,3761169],[1878,3758323],[1879,3746938],[1880,3702112],[1881,3661554],[1882,3629535],[1883,3574747],[1884,3539882],[1885,3514267],[1886,3490786],[1887,3455921],[1888,3416075],[1889,3384767],[1890,3357018],[1891,3329979],[1892,3297249],[1893,3278037],[1894,3265230],[1895,3244595],[1896,3231788],[1897,3223249],[1898,3214711],[1899,3203326],[1900,3179846],[1901,3164192],[1902,3155654],[1903,3143557],[1904,3136442],[1905,3130038],[1906,3129327],[1907,3122211],[1908,3120077],[1909,3121500],[1910,3120077],[1911,3117231],[1912,3107981],[1913,3092327],[1914,3083789],[1915,3043943],[1916,3040385],[1917,3040385],[1918,3045366],[1919,3096596],[1920,3103000],[1921,3096000],[1922,3002000],[1923,3014000],[1924,3005000],[1925,2985000],[1926,2971000],[1927,2957000],[1928,2944000],[1929,2937000],[1930,2927000],[1931,2933000],[1932,2949000],[1933,2962000],[1934,2971000],[1935,2971000],[1936,2967000],[1937,2948000],[1938,2937000],[1939,2934000],[1940,2958000],[1941,2993000],[1942,2963000],[1943,2946000],[1944,2944000],[1945,2952000],[1946,2957000],[1947,2974000],[1948,2985000],[1949,2981000],[1950,2963018],[1951,2959311],[1952,2952156],[1953,2947311],[1954,2936769],[1955,2916133],[1956,2895253],[1957,2878220],[1958,2851522],[1959,2843041],[1960,2832000],[1961,2818300],[1962,2830000],[1963,2850000],[1964,2864000],[1965,2876000],[1966,2884000],[1967,2900100],[1968,2912500],[1969,2925600],[1970,2950100],[1971,2978300],[1972,3024400],[1973,3073200],[1974,3124200],[1975,3177300],[1976,3227800],[1977,3271900],[1978,3314000],[1979,3368200],[1980,3401000],[1981,3443400],[1982,3480000],[1983,3504000],[1984,3529000],[1985,3540000],[1986,3540500],[1987,3539900],[1988,3529600],[1989,3513200],[1990,3508200],[1991,3530771],[1992,3557761],[1993,3578349],[1994,3595542],[1995,3613890],[1996,3636179],[1997,3667233],[1998,3707555],[1999,3750141],[2000,3791690],[2001,3835025],[2002,3879155],[2003,3924023],[2004,3969558],[2005,4015676],[2006,4062235],[2007,4109086],[2008,4156119]],"lifeExpectancy":[[1800,37.7],[1845,37.7],[1846,25],[1847,30],[1848,20.55],[1849,20],[1850,35],[1851,37.7],[1859,37.7],[1901,49.4],[1911,53.8],[1926,57.6],[1936,58.9],[1941,60],[1946,61.4],[1950,65.61],[1951,64.78],[1952,67.2],[1953,67.96],[1954,68.07],[1955,68.06],[1956,69.01],[1957,69.06],[1958,69.36],[1959,69.49],[1960,70.23],[1961,69.69],[1962,69.99],[1963,70.24],[1964,70.49],[1965,70.69],[1966,70.2],[1967,71.24],[1968,70.93],[1969,70.85],[1970,70.89],[1971,71.68],[1972,71.02],[1973,71.24],[1974,71.18],[1975,71.76],[1976,71.86],[1977,72],[1978,71.98],[1979,72.25],[1980,72.6],[1981,72.96],[1982,73.23],[1983,73.26],[1984,73.71],[1985,73.65],[1986,73.72],[1987,74.52],[1988,74.55],[1989,74.58],[1990,74.98],[1991,75.14],[1992,75.54],[1993,75.4],[1994,75.91],[1995,75.58],[1996,75.94],[1997,76.08],[1998,76.3],[1999,76.2],[2000,76.66],[2001,77.24],[2002,77.73],[2003,78.24],[2004,78.64],[2005,79.4],[2006,79.73],[2007,79.66],[2008,79.94],[2009,80.16]]},{"name":"Italy","region":"Europe & Central Asia","income":[[1800,1339.84],[1801,1322.44],[1802,1365.94],[1803,1405.09],[1804,1465.99],[1805,1418.14],[1806,1452.94],[1807,1426.84],[1808,1509.5],[1809,1513.85],[1810,1396.39],[1811,1352.89],[1812,1378.99],[1813,1418.14],[1814,1435.54],[1815,1374.64],[1816,1352.89],[1817,1365.94],[1818,1465.99],[1819,1457.29],[1820,1452.94],[1821,1431.19],[1822,1448.59],[1823,1461.64],[1824,1496.45],[1825,1479.05],[1826,1518.2],[1827,1496.45],[1828,1479.05],[1829,1470.35],[1830,1452.94],[1831,1500.8],[1832,1518.2],[1833,1522.55],[1834,1535.6],[1835,1579.1],[1836,1431.19],[1837,1392.04],[1838,1418.14],[1839,1405.09],[1840,1448.59],[1841,1479.05],[1842,1483.4],[1843,1409.44],[1844,1409.44],[1845,1422.49],[1846,1409.44],[1847,1448.59],[1848,1444.24],[1849,1435.54],[1850,1357.24],[1851,1361.59],[1852,1339.84],[1853,1309.39],[1854,1226.74],[1855,1239.79],[1856,1244.14],[1857,1331.14],[1858,1383.34],[1859,1339.84],[1860,1335.49],[1861,1448.59],[1862,1492.1],[1863,1522.55],[1864,1496.45],[1865,1574.75],[1866,1465.99],[1867,1479.05],[1868,1487.75],[1869,1526.9],[1870,1600.85],[1871,1592.15],[1872,1566.05],[1873,1566.05],[1874,1674.8],[1875,1640],[1876,1579.1],[1877,1600.85],[1878,1683.5],[1879,1679.15],[1880,1722.65],[1881,1770.5],[1882,1809.66],[1883,1831.41],[1884,1774.85],[1885,1827.06],[1886,1914.06],[1887,1940.16],[1888,1918.41],[1889,1848.81],[1890,1896.66],[1891,1944.51],[1892,1931.46],[1893,1979.31],[1894,1988.01],[1895,2009.76],[1896,2031.51],[1897,2044.56],[1898,2053.26],[1899,2079.36],[1900,2127.22],[1901,2166.37],[1902,2214.22],[1903,2270.77],[1904,2340.37],[1905,2414.32],[1906,2479.58],[1907,2557.88],[1908,2592.68],[1909,2636.18],[1910,2640.53],[1911,2670.98],[1912,2762.33],[1913,2871.09],[1914,3133.99],[1915,3155.61],[1916,3517.13],[1917,3756.73],[1918,4142.93],[1919,3599.69],[1920,3229.38],[1921,3268.57],[1922,3419.44],[1923,3438.41],[1924,3409.86],[1925,3564.46],[1926,3560.69],[1927,3578.97],[1928,3782.3],[1929,3881.82],[1930,3664.52],[1931,3696.84],[1932,3832.8],[1933,3798.85],[1934,3826.45],[1935,4125.84],[1936,4218.03],[1937,4388.13],[1938,4396.7],[1939,4653.39],[1940,4495.44],[1941,4384.39],[1942,4377.87],[1943,4124.63],[1944,3499.45],[1945,2730.28],[1946,3417.92],[1947,3892.09],[1948,4108.64],[1949,4219.07],[1950,4461.07],[1951,4719.64],[1952,4931.4],[1953,5222.08],[1954,5436.14],[1955,5733.71],[1956,5958.25],[1957,6248.66],[1958,6518.37],[1959,6885.77],[1960,7314.83],[1961,7820.21],[1962,8243.58],[1963,8636.91],[1964,8821.6],[1965,9011.54],[1966,9503.61],[1967,10022.4],[1968,10694.07],[1969,11274.4],[1970,11788.23],[1971,11939.22],[1972,12269.27],[1973,13133.75],[1974,13614.98],[1975,13160.79],[1976,14021.93],[1977,14255.98],[1978,14831.4],[1979,15712.14],[1980,16201.88],[1981,16362.8],[1982,16537.48],[1983,16717.44],[1984,17530.69],[1985,18078.95],[1986,18479.37],[1987,19207.23],[1988,20293.85],[1989,21166.48],[1990,21561.42],[1991,21755.4],[1992,22013.64],[1993,21826.22],[1994,22471.23],[1995,23680.31],[1996,23897.55],[1997,24675.02],[1998,25409.99],[1999,26128.82],[2000,27160.47],[2001,27779.73],[2002,27968.1],[2003,27839.64],[2004,27887.57],[2005,27750],[2006,28141.34],[2007,28342.66],[2008,27753.8],[2009,26160.59]],"population":[[1820,20176000],[1821,20306000],[1822,20437000],[1823,20568000],[1824,20701000],[1825,20834000],[1826,20968000],[1827,21103000],[1828,21239000],[1829,21376000],[1830,21513000],[1831,21652000],[1832,21791000],[1833,21932000],[1834,22073000],[1835,22215000],[1836,22358000],[1837,22502000],[1838,22647000],[1839,22793000],[1840,22939000],[1841,23087000],[1842,23236000],[1843,23385000],[1844,23536000],[1845,23687000],[1846,23840000],[1847,23993000],[1848,24148000],[1849,24303000],[1850,24460000],[1851,24617000],[1852,24776000],[1853,24935000],[1854,25096000],[1855,25257000],[1856,25420000],[1857,25584000],[1858,25748000],[1859,25914000],[1860,26081000],[1861,26249000],[1862,26418000],[1863,26610000],[1864,26814000],[1865,27023000],[1866,27256000],[1867,27411000],[1868,27501000],[1869,27681000],[1870,27888000],[1871,28063000],[1872,28233000],[1873,28387000],[1874,28505000],[1875,28630000],[1876,28837000],[1877,29067000],[1878,29252000],[1879,29425000],[1880,29534000],[1881,29672000],[1882,29898000],[1883,30113000],[1884,30366000],[1885,30644000],[1886,30857000],[1887,31049000],[1888,31243000],[1889,31468000],[1890,31702000],[1891,31892000],[1892,32091000],[1893,32303000],[1894,32513000],[1895,32689000],[1896,32863000],[1897,33078000],[1898,33285000],[1899,33487000],[1900,33672000],[1901,33877000],[1902,34166000],[1903,34436000],[1904,34715000],[1905,35011000],[1906,35297000],[1907,35594000],[1908,35899000],[1909,36213000],[1910,36572000],[1911,36917000],[1912,37150000],[1913,37248000],[1914,37526000],[1915,37982000],[1916,38142000],[1917,37981000],[1918,37520000],[1919,37250000],[1920,37398000],[1921,37691000],[1922,38086000],[1923,38460000],[1924,38810000],[1925,39165000],[1926,39502000],[1927,39848000],[1928,40186000],[1929,40469000],[1930,40791000],[1931,41132000],[1932,41431000],[1933,41753000],[1934,42093000],[1935,42429000],[1936,42750000],[1937,43068000],[1938,43419000],[1939,43865000],[1940,44341000],[1941,44734000],[1942,45004000],[1943,45177000],[1944,45290000],[1945,45442000],[1946,45725000],[1947,46040000],[1948,46381000],[1949,46733000],[1950,47105000],[1951,47418000],[1952,47666000],[1953,47957000],[1954,48299000],[1955,48633000],[1956,48921000],[1957,49182000],[1958,49476000],[1959,49832000],[1960,50197600],[1961,50523200],[1962,50843200],[1963,51198300],[1964,51600200],[1965,51987100],[1966,52331600],[1967,52667100],[1968,52986600],[1969,53317000],[1970,53661100],[1971,54005500],[1972,54365564],[1973,54796843],[1974,55226259],[1975,55571894],[1976,55838536],[1977,56059245],[1978,56240143],[1979,56367710],[1980,56451247],[1981,56502489],[1982,56535636],[1983,56630129],[1984,56696963],[1985,56731215],[1986,56733833],[1987,56729703],[1988,56734027],[1989,56737529],[1990,56742886],[1991,56747462],[1992,56840847],[1993,57026746],[1994,57179460],[1995,57274531],[1996,57367032],[1997,57479469],[1998,57550318],[1999,57603634],[2000,57719337],[2001,57844924],[2002,57926999],[2003,57998353],[2004,58057477],[2005,58103033],[2006,58133509],[2007,58147733],[2008,58145321]],"lifeExpectancy":[[1800,29.01],[1872,29.69],[1873,31.6],[1874,31.75],[1875,31.31],[1876,33.6],[1877,34.88],[1878,34.32],[1879,33.95],[1880,32.74],[1881,34.2],[1882,34.29],[1883,35.18],[1884,36.6],[1885,36.83],[1886,35.1],[1887,35.97],[1888,36.92],[1889,39.05],[1890,38.5],[1891,38.46],[1892,38.84],[1893,39.79],[1894,39.91],[1895,39.61],[1896,40.7],[1897,43.29],[1898,42.33],[1899,43.67],[1900,41.66],[1901,43.52],[1902,42.99],[1903,43.15],[1904,44.43],[1905,43.94],[1906,45.09],[1907,45.45],[1908,43.19],[1909,44.67],[1910,46.75],[1911,44.77],[1912,48.98],[1913,48.46],[1914,49.89],[1915,42.34],[1916,39.27],[1917,37.69],[1918,25.62],[1919,42.1],[1920,45.51],[1921,49.25],[1922,50.01],[1923,51.45],[1924,51.51],[1925,51.31],[1926,50.96],[1927,52.58],[1928,52.67],[1929,52.29],[1930,55.2],[1931,54.78],[1932,54.77],[1933,56.29],[1934,56.86],[1935,56.22],[1936,56.75],[1937,55.49],[1938,56.13],[1939,57.64],[1940,56.95],[1941,54.62],[1942,52.45],[1943,49.19],[1944,52.34],[1945,54.78],[1946,58.97],[1947,61.18],[1948,63.45],[1949,64.11],[1950,65.77],[1951,65.31],[1952,65.94],[1953,66.58],[1954,67.9],[1955,68.25],[1956,67.64],[1957,67.81],[1958,68.87],[1959,69.32],[1960,69.21],[1961,69.85],[1962,69.24],[1963,69.35],[1964,70.4],[1965,70.27],[1966,71.02],[1967,71.06],[1968,70.88],[1969,70.9],[1970,71.66],[1971,71.91],[1972,72.19],[1973,72.13],[1974,72.85],[1975,72.76],[1976,73.11],[1977,73.48],[1978,73.83],[1979,74.16],[1980,74.12],[1981,74.51],[1982,74.98],[1983,74.8],[1984,75.56],[1985,75.67],[1986,76],[1987,76.42],[1988,76.6],[1989,77],[1990,77.06],[1991,77.07],[1992,77.44],[1993,77.72],[1994,77.93],[1995,78.19],[1996,78.52],[1997,78.82],[1998,78.92],[1999,79.32],[2000,79.73],[2001,80.01],[2002,80.25],[2003,80.33],[2004,81.19],[2005,81.18],[2006,81.59],[2007,81.11],[2008,81.24],[2009,81.34]]},{"name":"Kazakhstan","region":"Europe & Central Asia","income":[[1800,585.03],[1820,597.35],[1913,1331.55],[1950,2609.22],[1973,7244.19],[1990,7085.5],[1991,6265.36],[1992,5919.91],[1993,5404.83],[1994,4802.48],[1995,4492.99],[1996,4567.93],[1997,4709.06],[1998,4691.52],[1999,4870.09],[2000,5366.02],[2001,6082.3],[2002,6667.3],[2003,7272.72],[2004,7930.09],[2005,8699],[2006,9437.71],[2007,10185.05],[2008,10500.47],[2009,10612.29]],"population":[[1800,2041282],[1820,2041282],[1950,6693230],[1951,6936060],[1952,7123394],[1953,7260866],[1954,7516649],[1955,7976879],[1956,8413793],[1957,8709753],[1958,9062534],[1959,9499911],[1960,9982014],[1961,10466809],[1962,10945885],[1963,11311646],[1964,11601936],[1965,11902456],[1966,12179771],[1967,12451717],[1968,12691968],[1969,12900122],[1970,13106377],[1971,13324719],[1972,13541694],[1973,13754298],[1974,13971543],[1975,14157075],[1976,14304436],[1977,14454828],[1978,14623619],[1979,14803694],[1980,14966718],[1981,15136447],[1982,15303467],[1983,15466787],[1984,15630279],[1985,15789549],[1986,15946119],[1987,16109358],[1988,16206749],[1989,16265063],[1990,16398131],[1991,16504750],[1992,16542063],[1993,16451625],[1994,16182154],[1995,15878488],[1996,15696091],[1997,15484518],[1998,15247098],[1999,15084623],[2000,15032140],[2001,15052250],[2002,15077224],[2003,15107581],[2004,15143704],[2005,15185844],[2006,15233244],[2007,15284929],[2008,15340533]],"lifeExpectancy":[[1800,26.2],[1863,26.2],[1868,23.58],[1873,23.8],[1897,28.6],[1900,28.1],[1910,30.6],[1926,36.87],[1939,44.47],[1950,54.16],[1951,54.38],[1952,54.81],[1953,55.25],[1954,55.68],[1955,56.11],[1956,56.54],[1957,56.97],[1958,57.4],[1959,57.84],[1960,58.27],[1961,58.71],[1962,59.15],[1963,59.59],[1964,60.04],[1965,60.47],[1966,60.9],[1967,61.31],[1968,61.69],[1969,62.06],[1970,62.4],[1971,62.7],[1972,62.97],[1973,63.21],[1974,63.44],[1975,63.66],[1976,63.88],[1977,64.12],[1978,64.37],[1979,64.65],[1980,64.96],[1981,65.32],[1982,65.71],[1983,66.12],[1984,66.52],[1985,66.87],[1986,67.12],[1987,67.24],[1988,67.22],[1989,67.05],[1990,66.73],[1991,66.27],[1992,65.71],[1993,65.09],[1994,64.49],[1995,63.95],[1996,63.54],[1997,63.3],[1998,63.24],[1999,63.33],[2000,63.56],[2001,63.87],[2002,64.18],[2003,64.45],[2004,64.64],[2005,64.77],[2006,64.86],[2007,64.93],[2008,65.03],[2009,65.18]]},{"name":"Latvia","region":"Europe & Central Asia","income":[[1800,865.19],[1820,883.41],[1913,1969.19],[1965,4078.83],[1966,4110.99],[1967,4444.34],[1968,4596.58],[1969,4651.53],[1970,5470.69],[1971,5845.61],[1972,6095.31],[1973,6395.1],[1974,6651.16],[1975,7050.03],[1976,7350.82],[1977,7488.92],[1978,7635.77],[1979,8000.76],[1980,8278.29],[1981,8578.01],[1982,8728.46],[1983,9127.3],[1984,9596.89],[1985,9502.49],[1986,9893.28],[1987,10063.53],[1988,10512.99],[1989,11044.48],[1990,10217.78],[1991,8960.02],[1992,6151.51],[1993,5948.96],[1994,6169.9],[1995,6191.8],[1996,6488.44],[1997,7143.44],[1998,7604.97],[1999,8028.97],[2000,8649.22],[2001,9396.42],[2002,10094.47],[2003,10879.77],[2004,11888.05],[2005,13218],[2006,14911.56],[2007,16494.88],[2008,15816.36],[2009,13021.94]],"population":[[1800,590588],[1820,590588],[1950,1936498],[1951,1950888],[1952,1964319],[1953,1976212],[1954,1990651],[1955,2002111],[1956,2026333],[1957,2055709],[1958,2072119],[1959,2088934],[1960,2115183],[1961,2145744],[1962,2172829],[1963,2199396],[1964,2227495],[1965,2253604],[1966,2278721],[1967,2301371],[1968,2322031],[1969,2341871],[1970,2361159],[1971,2381641],[1972,2401244],[1973,2421355],[1974,2442473],[1975,2461606],[1976,2476760],[1977,2491407],[1978,2504508],[1979,2514167],[1980,2524543],[1981,2536976],[1982,2552229],[1983,2569826],[1984,2587996],[1985,2606405],[1986,2626695],[1987,2648965],[1988,2664068],[1989,2667309],[1990,2663590],[1991,2651308],[1992,2615869],[1993,2565708],[1994,2523532],[1995,2488008],[1996,2460277],[1997,2435967],[1998,2413173],[1999,2393657],[2000,2376178],[2001,2358232],[2002,2340205],[2003,2322943],[2004,2306306],[2005,2290237],[2006,2274735],[2007,2259810],[2008,2245423]],"lifeExpectancy":[[1800,33],[1860,33],[1896,44.95],[1924,53.7],[1935,58.08],[1950,64.53],[1951,64.93],[1952,65.7],[1953,66.42],[1954,67.08],[1955,67.69],[1956,68.24],[1957,68.72],[1958,69.16],[1959,69.54],[1960,70.3],[1961,70.54],[1962,69.88],[1963,70.29],[1964,71.52],[1965,71.2],[1966,71.16],[1967,70.82],[1968,70.46],[1969,70.2],[1970,70.22],[1971,70.57],[1972,70.25],[1973,70.2],[1974,70.11],[1975,69.28],[1976,69.41],[1977,69.45],[1978,69.35],[1979,68.87],[1980,69.19],[1981,69.13],[1982,69.71],[1983,69.47],[1984,69.51],[1985,69.63],[1986,71.01],[1987,71.05],[1988,70.99],[1989,70.46],[1990,69.51],[1991,69.24],[1992,68.57],[1993,66.78],[1994,65.53],[1995,66.33],[1996,68.92],[1997,69.55],[1998,69.19],[1999,69.98],[2000,70.57],[2001,70.32],[2002,70.67],[2003,71.17],[2004,71.5],[2005,71.24],[2006,71.14],[2007,71.2],[2008,72.52],[2009,72.77]]},{"name":"Lithuania","region":"Europe & Central Asia","income":[[1800,988.79],[1820,1009.61],[1913,2250.5],[1950,4409.94],[1973,11523.46],[1990,13148.26],[1991,12374.36],[1992,9743.51],[1993,8190.02],[1994,7406.2],[1995,7804.17],[1996,8182.69],[1997,8764.9],[1998,9412.97],[1999,9259.81],[2000,9631.65],[2001,10272.37],[2002,11008.68],[2003,12120.35],[2004,13049.48],[2005,14085],[2006,15280.33],[2007,16875.86],[2008,17432.25],[2009,14928.78]],"population":[[1800,778655],[1820,778655],[1950,2553159],[1951,2561579],[1952,2583984],[1953,2593918],[1954,2597435],[1955,2614336],[1956,2641167],[1957,2651630],[1958,2672229],[1959,2717677],[1960,2764864],[1961,2810271],[1962,2850220],[1963,2886180],[1964,2922673],[1965,2959173],[1966,2996683],[1967,3033728],[1968,3068801],[1969,3101819],[1970,3137562],[1971,3177533],[1972,3213271],[1973,3245551],[1974,3276362],[1975,3305195],[1976,3333542],[1977,3361419],[1978,3386988],[1979,3410869],[1980,3435289],[1981,3462341],[1982,3491974],[1983,3523380],[1984,3555054],[1985,3587032],[1986,3619593],[1987,3653339],[1988,3673950],[1989,3681250],[1990,3694836],[1991,3702136],[1992,3700278],[1993,3689004],[1994,3679636],[1995,3673577],[1996,3668316],[1997,3664372],[1998,3661168],[1999,3658454],[2000,3654387],[2001,3645747],[2002,3633232],[2003,3620094],[2004,3607899],[2005,3596617],[2006,3585906],[2007,3575439],[2008,3565205]],"lifeExpectancy":[[1800,28.9],[1870,28.9],[1900,41.7],[1925,50.5],[1950,63.56],[1951,63.87],[1952,64.49],[1953,65.11],[1954,65.73],[1955,66.34],[1956,66.95],[1957,67.55],[1958,68.14],[1959,67.68],[1960,70.28],[1961,70.47],[1962,69.4],[1963,70.58],[1964,71.94],[1965,71.69],[1966,71.85],[1967,71.92],[1968,71.61],[1969,71.22],[1970,71.08],[1971,72.02],[1972,71.26],[1973,71.61],[1974,71.54],[1975,71.15],[1976,71.29],[1977,71.04],[1978,70.83],[1979,70.7],[1980,70.68],[1981,70.66],[1982,71.06],[1983,70.98],[1984,70.49],[1985,70.66],[1986,72.33],[1987,72.14],[1988,71.98],[1989,71.66],[1990,71.37],[1991,70.55],[1992,70.4],[1993,69.01],[1994,68.58],[1995,69.02],[1996,70.15],[1997,70.99],[1998,71.32],[1999,71.71],[2000,72.18],[2001,71.79],[2002,71.98],[2003,72.24],[2004,72.23],[2005,71.7],[2006,71.47],[2007,71.39],[2008,71.84],[2009,71.93]]},{"name":"Luxembourg","region":"Europe & Central Asia","income":[[1800,1145.57],[1820,1184.19],[1913,3505.89],[1950,14554.96],[1951,13543.17],[1952,14326.14],[1953,14733.28],[1954,14468.25],[1955,15026.48],[1956,15697.47],[1957,16545.86],[1958,16587.41],[1959,16545.58],[1960,17086.72],[1961,17621.05],[1962,17713.7],[1963,17788.6],[1964,19273.35],[1965,19349.16],[1966,19340.04],[1967,19163],[1968,19989.65],[1969,22105.34],[1970,22298.67],[1971,22667.93],[1972,23883.2],[1973,25579.14],[1974,26441.81],[1975,24454.52],[1976,24917.29],[1977,25282.33],[1978,26202.01],[1979,26887.08],[1980,27021.65],[1981,26826.66],[1982,27078.42],[1983,27876.96],[1984,29606.07],[1985,30435.47],[1986,33355.98],[1987,34518.87],[1988,37373.59],[1989,40736.66],[1990,42467.64],[1991,45750.52],[1992,45854.36],[1993,47055.53],[1994,48284.01],[1995,48165.26],[1996,49005.59],[1997,52622.9],[1998,55788.96],[1999,59349.52],[2000,63924.16],[2001,63932.84],[2002,64421.03],[2003,65308.34],[2004,67283.43],[2005,70014],[2006,72742.03],[2007,76273.6],[2008,74985.91],[2009,70857.46]],"population":[[1800,127030],[1820,127030],[1950,295587],[1951,297425],[1952,299263],[1953,301101],[1954,302939],[1955,304777],[1956,306615],[1957,308453],[1958,310291],[1959,312129],[1960,313969],[1961,316845],[1962,320750],[1963,324100],[1964,327750],[1965,331500],[1966,333895],[1967,335012],[1968,335867],[1969,337500],[1970,339174],[1971,342400],[1972,346600],[1973,350450],[1974,355050],[1975,358950],[1976,360750],[1977,361450],[1978,362100],[1979,363000],[1980,364400],[1981,365400],[1982,365718],[1983,365885],[1984,366272],[1985,367169],[1986,369019],[1987,371660],[1988,375624],[1989,377621],[1990,382966],[1991,387152],[1992,392552],[1993,398084],[1994,403756],[1995,409704],[1996,415566],[1997,421014],[1998,426495],[1999,432527],[2000,438777],[2001,444779],[2002,450786],[2003,456764],[2004,462690],[2005,468571],[2006,474413],[2007,480222],[2008,486006]],"lifeExpectancy":[[1800,36.9],[1879,36.9],[1901,47.98],[1902,48.06],[1903,46.91],[1904,44.83],[1905,46.21],[1906,46.59],[1907,49],[1908,46.46],[1909,47.79],[1910,49.66],[1911,46.38],[1912,48.88],[1913,50.24],[1914,50.07],[1915,51.47],[1916,50.12],[1917,48.05],[1918,42.33],[1919,44.68],[1920,54.62],[1921,56.21],[1922,55.27],[1923,54.68],[1924,56.76],[1925,54.79],[1926,53.41],[1927,55.86],[1928,55.35],[1929,52.7],[1930,56.8],[1931,57.59],[1932,56.66],[1933,58.32],[1934,59.9],[1935,59.1],[1936,61.2],[1937,61.06],[1938,59.2],[1939,60.35],[1940,61.95],[1941,59.99],[1942,58.33],[1943,54.32],[1944,47.84],[1945,49.4],[1946,61.61],[1947,63.06],[1948,64.49],[1949,64.84],[1950,65.25],[1951,65.42],[1952,65.76],[1953,66.09],[1954,66.42],[1955,66.73],[1956,67.04],[1957,67.33],[1958,67.62],[1959,67.9],[1960,69.07],[1961,69.57],[1962,68.67],[1963,68.89],[1964,69.07],[1965,69.4],[1966,69.31],[1967,69.69],[1968,70.28],[1969,69.84],[1970,69.58],[1971,69.47],[1972,70.71],[1973,70.47],[1974,70.55],[1975,70.5],[1976,70.45],[1977,71.75],[1978,71.71],[1979,72.4],[1980,72.57],[1981,72.38],[1982,72.47],[1983,73.35],[1984,73.11],[1985,73.68],[1986,74.61],[1987,74.15],[1988,74.75],[1989,74.68],[1990,75.39],[1991,75.47],[1992,75.16],[1993,75.74],[1994,76.36],[1995,76.47],[1996,76.49],[1997,76.81],[1998,77],[1999,77.67],[2000,77.82],[2001,77.95],[2002,78.08],[2003,77.96],[2004,79.26],[2005,79.56],[2006,79.44],[2007,79.36],[2008,79.56],[2009,79.75]]},{"name":"Macedonia, FYR","region":"Europe & Central Asia","income":[[1800,800.76],[1820,817.56],[1870,788.24],[1890,1109.35],[1900,1186.95],[1910,1390.81],[1913,1390.85],[1920,1357.01],[1921,1370.39],[1922,1390.56],[1923,1442.26],[1924,1523.97],[1925,1576.27],[1926,1662.47],[1927,1612.32],[1928,1729.42],[1929,1795.11],[1930,1734.96],[1931,1659.06],[1932,1484],[1933,1509.15],[1934,1543.86],[1935,1499.75],[1936,1671.3],[1937,1675.75],[1938,1784.95],[1939,1857.76],[1947,1731.03],[1948,2037.63],[1949,2208.57],[1950,2040.95],[1951,2093.81],[1952,1905.93],[1953,2161.7],[1954,2252.77],[1955,2365.11],[1956,2292.05],[1957,2650.77],[1958,2737],[1959,3044.67],[1960,3206.91],[1961,3318.1],[1962,3347.13],[1963,3659.85],[1964,3972.98],[1965,4040.6],[1966,4217.55],[1967,4252.92],[1968,4306.22],[1969,4750.19],[1970,4940.59],[1971,5462.13],[1972,5599.5],[1973,5738.05],[1974,6420.76],[1975,6364.32],[1976,6499.5],[1977,6907.88],[1978,7225.93],[1979,7656.7],[1980,7978.72],[1981,8072],[1982,8078.87],[1983,8102.68],[1984,8262.47],[1985,8285.66],[1986,8581.89],[1987,8445.96],[1988,8290.43],[1989,8149.6],[1990,7526.79],[1991,7497.53],[1992,6964.03],[1993,6409.96],[1994,6266.98],[1995,6166.63],[1996,6208.04],[1997,6266.31],[1998,6446.95],[1999,6697.62],[2000,6975.62],[2001,6637.34],[2002,6675.89],[2003,6847.63],[2004,7113.23],[2005,7393],[2006,7658.59],[2007,8086.19],[2008,8449.03],[2009,8364.79]],"population":[[1800,391865],[1820,391865],[1950,1224627],[1951,1255619],[1952,1271611],[1953,1299452],[1954,1325223],[1955,1340031],[1956,1339977],[1957,1344846],[1958,1344772],[1959,1353539],[1960,1366198],[1961,1381753],[1962,1401167],[1963,1422470],[1964,1444676],[1965,1469729],[1966,1489836],[1967,1511816],[1968,1532751],[1969,1553615],[1970,1574407],[1971,1596091],[1972,1617701],[1973,1639236],[1974,1661657],[1975,1684000],[1976,1706445],[1977,1727797],[1978,1747113],[1979,1768203],[1980,1792000],[1981,1808103],[1982,1823791],[1983,1831444],[1984,1837295],[1985,1844740],[1986,1850679],[1987,1856378],[1988,1858920],[1989,1863007],[1990,1861361],[1991,1867710],[1992,1889358],[1993,1917563],[1994,1935034],[1995,1954048],[1996,1971102],[1997,1984860],[1998,1995474],[1999,2004985],[2000,2014512],[2001,2023912],[2002,2030445],[2003,2035145],[2004,2040085],[2005,2045262],[2006,2050554],[2007,2055915],[2008,2061315]],"lifeExpectancy":[[1950,53.09],[1951,53.58],[1952,54.54],[1953,55.45],[1954,56.32],[1955,57.15],[1956,57.94],[1957,58.68],[1958,59.39],[1959,60.07],[1960,60.72],[1961,61.34],[1962,61.95],[1963,62.55],[1964,63.14],[1965,63.72],[1966,64.28],[1967,64.83],[1968,65.35],[1969,65.86],[1970,66.35],[1971,66.83],[1972,67.32],[1973,67.81],[1974,68.28],[1975,68.71],[1976,69.07],[1977,69.34],[1978,69.51],[1979,69.61],[1980,69.64],[1981,69.66],[1982,69.69],[1983,69.78],[1984,69.92],[1985,70.13],[1986,70.37],[1987,70.64],[1988,70.9],[1989,71.14],[1990,71.36],[1991,71.55],[1992,71.73],[1993,71.89],[1994,72.05],[1995,72.2],[1996,72.35],[1997,72.51],[1998,72.67],[1999,72.83],[2000,73.01],[2001,73.18],[2002,73.35],[2003,73.51],[2004,73.67],[2005,73.82],[2006,73.97],[2007,74.11],[2008,74.25],[2009,74.4]]},{"name":"Malta","region":"Europe & Central Asia","income":[[1800,515.5],[1820,532.89],[1950,1525.8],[1960,2300.59],[1961,2326.46],[1962,2250.88],[1963,2255.34],[1964,2301.61],[1965,2452.02],[1966,2704.07],[1967,2878.91],[1968,3158.66],[1969,3350.19],[1970,3765.12],[1971,3885.88],[1972,4129.49],[1973,4531.31],[1974,4952.55],[1975,5853.62],[1976,6726.43],[1977,7348.86],[1978,7939.8],[1979,8586.64],[1980,9104.22],[1981,9401.68],[1982,9683.25],[1983,9751.66],[1984,10018.26],[1985,10476.97],[1986,10774.4],[1987,11105.43],[1988,11937.83],[1989,12805.72],[1990,13494.44],[1991,14216.34],[1992,14745.52],[1993,15256.63],[1994,15975.12],[1995,16779.82],[1996,17357.5],[1997,18048.17],[1998,18581.03],[1999,19172.83],[2000,20276.2],[2001,19797.46],[2002,20162.83],[2003,19966.69],[2004,19874],[2005,20410],[2006,21003.11],[2007,21666.88],[2008,21934.71],[2009,21327.85]],"population":[[1800,134072],[1820,134072],[1950,311973],[1951,312646],[1952,316619],[1953,317248],[1954,319787],[1955,314369],[1956,314066],[1957,318779],[1958,321940],[1959,324842],[1960,328517],[1961,328854],[1962,329011],[1963,328116],[1964,323591],[1965,319164],[1966,317482],[1967,318573],[1968,319254],[1969,322749],[1970,325569],[1971,325468],[1972,319430],[1973,321838],[1974,323524],[1975,327842],[1976,329354],[1977,332066],[1978,339786],[1979,346876],[1980,364001],[1981,363652],[1982,360222],[1983,355773],[1984,351379],[1985,347039],[1986,346625],[1987,349047],[1988,351951],[1989,355323],[1990,359107],[1991,362579],[1992,365897],[1993,370008],[1994,373606],[1995,376893],[1996,379962],[1997,382953],[1998,385608],[1999,387799],[2000,389947],[2001,391873],[2002,393515],[2003,395178],[2004,396851],[2005,398534],[2006,400214],[2007,401880],[2008,403532]],"lifeExpectancy":[[1950,64.7],[1951,65.04],[1952,65.7],[1953,66.29],[1954,66.81],[1955,67.27],[1956,67.66],[1957,67.99],[1958,68.26],[1959,68.48],[1960,68.64],[1961,68.77],[1962,68.88],[1963,68.96],[1964,69.05],[1965,69.15],[1966,69.26],[1967,69.4],[1968,69.57],[1969,69.76],[1970,69.98],[1971,70.23],[1972,70.5],[1973,70.79],[1974,71.09],[1975,71.39],[1976,71.69],[1977,71.99],[1978,72.29],[1979,72.58],[1980,72.86],[1981,73.14],[1982,73.43],[1983,73.72],[1984,74.01],[1985,74.31],[1986,74.6],[1987,74.89],[1988,75.16],[1989,75.43],[1990,75.68],[1991,75.93],[1992,76.16],[1993,76.39],[1994,76.61],[1995,76.83],[1996,77.07],[1997,77.31],[1998,77.55],[1999,77.81],[2000,78.06],[2001,78.32],[2002,78.57],[2003,78.81],[2004,79.04],[2005,79.25],[2006,79.44],[2007,79.61],[2008,79.77],[2009,79.91]]},{"name":"Moldova","region":"Europe & Central Asia","income":[[1800,617.12],[1820,630.11],[1913,1404.57],[1950,2752.3],[1973,4267.57],[1990,4903.83],[1991,4018.45],[1992,2839.94],[1993,2798.54],[1994,1932.28],[1995,1906.77],[1996,1797.92],[1997,1830.29],[1998,1713.62],[1999,1656.77],[2000,1692.09],[2001,1794.94],[2002,1933.65],[2003,2053.17],[2004,2201.64],[2005,2362],[2006,2482.25],[2007,2562.96],[2008,2769.37],[2009,2593.42]],"population":[[1800,712558],[1820,712558],[1950,2336432],[1951,2422094],[1952,2466740],[1953,2505504],[1954,2565909],[1955,2622424],[1956,2682168],[1957,2758940],[1958,2838489],[1959,2919316],[1960,2998981],[1961,3068962],[1962,3136438],[1963,3204914],[1964,3271001],[1965,3333549],[1966,3394160],[1967,3452263],[1968,3505944],[1969,3549420],[1970,3594517],[1971,3648754],[1972,3703001],[1973,3752827],[1974,3800643],[1975,3846519],[1976,3885894],[1977,3920281],[1978,3947422],[1979,3969989],[1980,3996278],[1981,4026204],[1982,4055086],[1983,4082711],[1984,4113243],[1985,4148172],[1986,4183283],[1987,4216682],[1988,4289659],[1989,4359496],[1990,4397798],[1991,4427569],[1992,4448083],[1993,4459725],[1994,4463208],[1995,4459595],[1996,4450539],[1997,4441779],[1998,4435827],[1999,4432040],[2000,4430654],[2001,4431570],[2002,4434547],[2003,4439502],[2004,4446455],[2005,4455421],[2006,4466706],[2007,4480560],[2008,4496774]],"lifeExpectancy":[[1950,57.46],[1951,57.71],[1952,58.18],[1953,58.64],[1954,59.08],[1955,59.51],[1956,59.91],[1957,60.3],[1958,60.68],[1959,61.05],[1960,61.42],[1961,61.79],[1962,62.18],[1963,62.57],[1964,62.96],[1965,63.35],[1966,63.7],[1967,64.02],[1968,64.28],[1969,64.49],[1970,64.65],[1971,64.75],[1972,64.81],[1973,64.84],[1974,64.85],[1975,64.84],[1976,64.81],[1977,64.75],[1978,64.69],[1979,64.63],[1980,64.62],[1981,64.7],[1982,64.89],[1983,65.2],[1984,65.6],[1985,66.05],[1986,66.52],[1987,66.93],[1988,67.26],[1989,67.47],[1990,67.56],[1991,67.51],[1992,67.38],[1993,67.2],[1994,66.99],[1995,66.79],[1996,66.64],[1997,66.55],[1998,66.54],[1999,66.61],[2000,66.76],[2001,66.97],[2002,67.21],[2003,67.45],[2004,67.7],[2005,67.92],[2006,68.13],[2007,68.33],[2008,68.53],[2009,68.72]]},{"name":"Montenegro","region":"Europe & Central Asia","income":[[1800,1112.36],[1820,1135.69],[1870,1094.96],[1890,1541.03],[1900,1648.83],[1910,1932.02],[1913,1932.07],[1920,1885.06],[1921,1903.65],[1922,1931.67],[1923,2003.48],[1924,2116.99],[1925,2189.64],[1926,2309.38],[1927,2239.71],[1928,2402.38],[1929,2493.64],[1930,2410.08],[1931,2304.64],[1932,2061.47],[1933,2096.4],[1934,2144.62],[1935,2083.35],[1936,2321.65],[1937,2327.82],[1938,2479.52],[1939,2580.67],[1947,2404.62],[1948,2830.52],[1949,3067.99],[1950,2835.13],[1951,2908.57],[1952,2647.59],[1953,3002.87],[1954,3129.38],[1955,3285.44],[1956,3183.95],[1957,3682.26],[1958,3802.04],[1959,4229.43],[1960,4454.8],[1961,4609.27],[1962,4649.59],[1963,5084.01],[1964,5518.98],[1965,5612.9],[1966,5858.72],[1967,5907.85],[1968,5981.88],[1969,6598.61],[1970,6863.11],[1971,7587.59],[1972,7778.41],[1973,7970.89],[1974,8919.26],[1975,8840.85],[1976,9028.63],[1977,9595.93],[1978,10037.73],[1979,10636.13],[1980,11083.46],[1981,11213.04],[1982,11222.59],[1983,11255.65],[1984,11477.63],[1985,11509.84],[1986,11921.35],[1987,11732.51],[1988,11516.46],[1989,11320.83],[1990,10455.67],[1991,9245.92],[1992,7003.34],[1993,4393.42],[1994,4398.21],[1995,4947.29],[1996,6193.74],[1997,6465.61],[1998,6637.47],[1999,6013.14],[2000,6185.69],[2001,6311.82],[2002,6557.19],[2003,6892.3],[2004,7374.97],[2005,7833],[2006,10315.88],[2007,11428.36],[2008,12257.79]],"population":[[1800,126582],[1820,126582],[1950,395587],[1951,405216],[1952,413834],[1953,419454],[1954,425065],[1955,431658],[1956,437249],[1957,442829],[1958,448399],[1959,454949],[1960,461487],[1961,468013],[1962,474528],[1963,480046],[1964,486538],[1965,491051],[1966,496539],[1967,501035],[1968,505522],[1969,510001],[1970,514472],[1971,519914],[1972,527678],[1973,534461],[1974,542221],[1975,549000],[1976,554552],[1977,560073],[1978,565561],[1979,571018],[1980,560000],[1981,560090],[1982,562548],[1983,565705],[1984,558389],[1985,560562],[1986,564558],[1987,569473],[1988,574401],[1989,578981],[1990,583202],[1991,590872],[1992,621621],[1993,635875],[1994,653213],[1995,670608],[1996,683946],[1997,692651],[1998,701246],[1999,720412],[2000,732302],[2001,726462],[2002,720230],[2003,713614],[2004,706577],[2005,699259],[2006,691871],[2007,684736],[2008,678177],[2009,672180]],"lifeExpectancy":[[1800,35.4],[1920,35.4],[1950,58.22],[1951,58.47],[1952,58.95],[1953,59.42],[1954,59.88],[1955,60.33],[1956,60.77],[1957,61.2],[1958,61.62],[1959,62.06],[1960,62.51],[1961,63],[1962,63.52],[1963,64.1],[1964,64.72],[1965,65.38],[1966,66.09],[1967,66.82],[1968,67.56],[1969,68.29],[1970,69],[1971,69.69],[1972,70.34],[1973,70.96],[1974,71.54],[1975,72.05],[1976,72.5],[1977,72.89],[1978,73.23],[1979,73.51],[1980,73.74],[1981,73.93],[1982,74.09],[1983,74.23],[1984,74.37],[1985,74.52],[1986,74.69],[1987,74.89],[1988,75.11],[1989,75.34],[1990,75.56],[1991,75.75],[1992,75.9],[1993,75.97],[1994,75.98],[1995,75.91],[1996,75.77],[1997,75.58],[1998,75.36],[1999,75.13],[2000,74.89],[2001,74.66],[2002,74.44],[2003,74.25],[2004,74.09],[2005,74],[2006,73.98],[2007,74.03],[2008,74.15],[2009,74.34]]},{"name":"Netherlands","region":"Europe & Central Asia","income":[[1800,2412.43],[1801,2410.19],[1802,2407.94],[1803,2405.7],[1804,2403.46],[1805,2401.22],[1806,2398.98],[1807,2396.75],[1808,2140.32],[1809,2115.41],[1810,2430.6],[1811,2463.51],[1812,2148.66],[1813,1937.55],[1814,1872.82],[1815,2485.36],[1816,2369.94],[1817,2397.3],[1818,2439.55],[1819,2329.64],[1820,2501.29],[1821,2446.72],[1822,2465.54],[1823,2584.47],[1824,2562.02],[1825,2492.15],[1826,2527.58],[1827,2672.71],[1828,2726.07],[1829,2726.1],[1830,2484.29],[1831,2665.82],[1832,2786.45],[1833,2719.09],[1834,2738.8],[1835,2726.17],[1836,2812.27],[1837,2874.01],[1838,2899.55],[1839,2893.62],[1840,2916.68],[1841,2940.77],[1842,2863.66],[1843,2808.67],[1844,2830.48],[1845,2805.03],[1846,2805.07],[1847,2819.16],[1848,2860.82],[1849,2941.02],[1850,2991.96],[1851,3030.22],[1852,2990.41],[1853,2917.71],[1854,3091.87],[1855,3002.04],[1856,3117.88],[1857,3057.96],[1858,2968.78],[1859,2857.73],[1860,2990.17],[1861,2902.77],[1862,3012.98],[1863,3064.49],[1864,3181.52],[1865,3182.08],[1866,3296.34],[1867,3177.69],[1868,3192],[1869,3290.79],[1870,3390.1],[1871,3358.03],[1872,3384.07],[1873,3442.73],[1874,3302.9],[1875,3481.91],[1876,3479],[1877,3509.16],[1878,3487.48],[1879,3305.83],[1880,3485.25],[1881,3494.5],[1882,3531.33],[1883,3739.93],[1884,3751.79],[1885,3777.75],[1886,3779.03],[1887,3816.41],[1888,3809.49],[1889,3884.11],[1890,3672.78],[1891,3628.37],[1892,3685.88],[1893,3593.38],[1894,3745.99],[1895,3708.29],[1896,3801.33],[1897,3832.52],[1898,3827.14],[1899,3818.28],[1900,3713.31],[1901,3826.9],[1902,3917.61],[1903,3843.64],[1904,3828.61],[1905,3951.5],[1906,3963.17],[1907,3826.46],[1908,3838.51],[1909,3979.81],[1910,4088.22],[1911,4188.72],[1912,4263.1],[1913,4422.05],[1914,4314.78],[1915,4098.55],[1916,4042.31],[1917,3588.65],[1918,3331.55],[1919,3716.74],[1920,4230.58],[1921,4958.89],[1922,5218.13],[1923,5261.95],[1924,5563.92],[1925,5681.74],[1926,6000.34],[1927,6211.6],[1928,6408.23],[1929,6457.97],[1930,6309.26],[1931,6009.03],[1932,5868.27],[1933,5827.76],[1934,5713.9],[1935,5822.82],[1936,6105.71],[1937,6414.44],[1938,6177.32],[1939,6641.98],[1940,5796.49],[1941,5449.65],[1942,4950.39],[1943,4813.35],[1944,3201.78],[1945,3255.32],[1946,5458.49],[1947,6215.75],[1948,6792.51],[1949,7196.12],[1950,7407.85],[1951,7498.82],[1952,7564.17],[1953,8144.21],[1954,8638.54],[1955,9170.54],[1956,9494.99],[1957,9690.89],[1958,9482.82],[1959,9823.19],[1960,10620.98],[1961,10822.2],[1962,11167.47],[1963,11420.64],[1964,12287.88],[1965,12809.27],[1966,13041.3],[1967,13626.76],[1968,14442.49],[1969,15304.9],[1970,16036.47],[1971,16602.54],[1972,16935.57],[1973,17681.37],[1974,18324.6],[1975,18255.08],[1976,18992.14],[1977,19415.07],[1978,19842.47],[1979,20126.43],[1980,20372.21],[1981,20194.33],[1982,19900.97],[1983,20247.92],[1984,20861.01],[1985,21393.33],[1986,22007.79],[1987,22345.03],[1988,23032.6],[1989,23982.73],[1990,24902.12],[1991,25383.24],[1992,25713.88],[1993,25958.69],[1994,26648.08],[1995,27423.96],[1996,28344.59],[1997,29491.94],[1998,30566.5],[1999,31895.29],[2000,33000.17],[2001,33482.67],[2002,33406.92],[2003,33454.56],[2004,34181.87],[2005,34724],[2006,35845.52],[2007,36535.43],[2008,37069.42],[2009,36074.53]],"population":[[1820,2333000],[1821,2365000],[1822,2400000],[1823,2435000],[1824,2474000],[1825,2514000],[1826,2543000],[1827,2561000],[1828,2585000],[1829,2610000],[1830,2633000],[1831,2653000],[1832,2665000],[1833,2683000],[1834,2707000],[1835,2732000],[1836,2762000],[1837,2791000],[1838,2821000],[1839,2853000],[1840,2886000],[1841,2921000],[1842,2952000],[1843,2981000],[1844,3014000],[1845,3047000],[1846,3069000],[1847,3071000],[1848,3069000],[1849,3076000],[1850,3098000],[1851,3133000],[1852,3167000],[1853,3194000],[1854,3218000],[1855,3235000],[1856,3253000],[1857,3277000],[1858,3294000],[1859,3304000],[1860,3318000],[1861,3340000],[1862,3366000],[1863,3397000],[1864,3431000],[1865,3460000],[1866,3484000],[1867,3510000],[1868,3543000],[1869,3575000],[1870,3610000],[1871,3636000],[1872,3662000],[1873,3670000],[1874,3745000],[1875,3788000],[1876,3832000],[1877,3883000],[1878,3834000],[1879,3986000],[1880,4043000],[1881,4079000],[1882,4130000],[1883,4180000],[1884,4226000],[1885,4276000],[1886,4326000],[1887,4378000],[1888,4432000],[1889,4485000],[1890,4535000],[1891,4585000],[1892,4632000],[1893,4684000],[1894,4743000],[1895,4803000],[1896,4866000],[1897,4935000],[1898,5003000],[1899,5070000],[1900,5142000],[1901,5221000],[1902,5305000],[1903,5389000],[1904,5470000],[1905,5551000],[1906,5632000],[1907,5710000],[1908,5786000],[1909,5862000],[1910,5922000],[1911,5984000],[1912,6068000],[1913,6164000],[1914,6277000],[1915,6395000],[1916,6516000],[1917,6654000],[1918,6752000],[1919,6805000],[1920,6848000],[1921,6921000],[1922,7032000],[1923,7150000],[1924,7264000],[1925,7366000],[1926,7471000],[1927,7576000],[1928,7679000],[1929,7782000],[1930,7884000],[1931,7999000],[1932,8123000],[1933,8237000],[1934,8341000],[1935,8434000],[1936,8516000],[1937,8599000],[1938,8685000],[1939,8782000],[1940,8879000],[1941,8966000],[1942,9042000],[1943,9103000],[1944,9175000],[1945,9262000],[1946,9424000],[1947,9630000],[1948,9800000],[1949,9956000],[1950,10113527],[1951,10264311],[1952,10381988],[1953,10493184],[1954,10615380],[1955,10750842],[1956,10889351],[1957,11026383],[1958,11186875],[1959,11347639],[1960,11486000],[1961,11638713],[1962,11805689],[1963,11965966],[1964,12127120],[1965,12292000],[1966,12454800],[1967,12596822],[1968,12724680],[1969,12873000],[1970,13032335],[1971,13193776],[1972,13329874],[1973,13438404],[1974,13540584],[1975,13653438],[1976,13769913],[1977,13852989],[1978,13936754],[1979,14030002],[1980,14143901],[1981,14246049],[1982,14310401],[1983,14362381],[1984,14420022],[1985,14491380],[1986,14571875],[1987,14665278],[1988,14761339],[1989,14848907],[1990,14951510],[1991,15066220],[1992,15174244],[1993,15274942],[1994,15382198],[1995,15459054],[1996,15527809],[1997,15604464],[1998,15699259],[1999,15801947],[2000,15907853],[2001,16017445],[2002,16122830],[2003,16223248],[2004,16318199],[2005,16407491],[2006,16491461],[2007,16570613],[2008,16645313]],"lifeExpectancy":[[1800,39.86],[1850,39.86],[1851,40],[1852,38.66],[1853,38.63],[1854,38.63],[1855,34.53],[1856,38.39],[1857,35.46],[1858,34.66],[1859,30.86],[1860,36.91],[1861,36.44],[1862,38.28],[1863,38.33],[1864,37.56],[1865,36.37],[1866,33.64],[1867,39.31],[1868,37.75],[1869,40.47],[1870,37.34],[1871,32.94],[1872,36.49],[1873,39.2],[1874,41.3],[1875,38.24],[1876,40.35],[1877,42.03],[1878,41.1],[1879,41.96],[1880,40.39],[1881,42.87],[1882,43.79],[1883,42.35],[1884,41.34],[1885,43.3],[1886,41.98],[1887,44.99],[1888,44.22],[1889,44.35],[1890,44.4],[1891,44.25],[1892,43.95],[1893,45.8],[1894,46.93],[1895,46.64],[1896,48.56],[1897,49.36],[1898,49.03],[1899,49.35],[1900,48.4],[1901,48.72],[1902,50.61],[1903,51.51],[1904,50.9],[1905,52.11],[1906,52.78],[1907,53.54],[1908,52.76],[1909,54.96],[1910,55.14],[1911,53.17],[1912,57.21],[1913,57.37],[1914,57.2],[1915,57.22],[1916,56.16],[1917,55.67],[1918,47.61],[1919,54.98],[1920,57.84],[1921,59.77],[1922,59.84],[1923,62.06],[1924,62.97],[1925,63.18],[1926,63.04],[1927,62.65],[1928,63.74],[1929,62.19],[1930,64.73],[1931,64.35],[1932,65.44],[1933,66.08],[1934,66.62],[1935,66.54],[1936,66.76],[1937,66.98],[1938,67.4],[1939,67.73],[1940,65.4],[1941,65.33],[1942,65.84],[1943,64.43],[1944,61.26],[1945,55.45],[1946,67.58],[1947,69.53],[1948,71.05],[1949,70.28],[1950,71.45],[1951,71.51],[1952,72.13],[1953,71.71],[1954,72.4],[1955,72.52],[1956,72.54],[1957,72.99],[1958,73.15],[1959,73.19],[1960,73.37],[1961,73.56],[1962,73.23],[1963,73.35],[1964,73.73],[1965,73.6],[1966,73.55],[1967,73.82],[1968,73.63],[1969,73.54],[1970,73.6],[1971,73.84],[1972,73.75],[1973,74.2],[1974,74.59],[1975,74.52],[1976,74.65],[1977,75.24],[1978,75.15],[1979,75.63],[1980,75.76],[1981,75.97],[1982,76.05],[1983,76.25],[1984,76.32],[1985,76.38],[1986,76.36],[1987,76.83],[1988,77.03],[1989,76.87],[1990,77.05],[1991,77.21],[1992,77.42],[1993,77.11],[1994,77.6],[1995,77.64],[1996,77.65],[1997,78.03],[1998,78.12],[1999,78.07],[2000,78.24],[2001,78.45],[2002,78.53],[2003,78.79],[2004,79.38],[2005,79.65],[2006,80],[2007,79.82],[2008,80.02],[2009,80.19]]},{"name":"Norway","region":"Europe & Central Asia","income":[[1800,950],[1820,978],[1821,984],[1822,990],[1823,996],[1824,1002],[1825,1008],[1826,1014],[1827,1020],[1828,1026],[1829,1032],[1830,1038],[1831,957],[1832,971],[1833,1080],[1834,1130],[1835,1107],[1836,1077],[1837,1080],[1838,1085],[1839,1086],[1840,1185],[1841,1208],[1842,1216],[1843,1190],[1844,1213],[1845,1267],[1846,1291],[1847,1242],[1848,1175],[1849,1206],[1850,1236],[1851,1313],[1852,1301],[1853,1362],[1854,1401],[1855,1472],[1856,1444],[1857,1365],[1858,1416],[1859,1446],[1860,1498],[1861,1457],[1862,1584],[1863,1589],[1864,1649],[1865,1720],[1866,1737],[1867,1774],[1868,1767],[1869,1834],[1870,1826],[1871,1851],[1872,1964],[1873,2001],[1874,2062],[1875,2103],[1876,2136],[1877,2129],[1878,2031],[1879,2026],[1880,2077],[1881,2096],[1882,2099],[1883,2096],[1884,2127],[1885,2134],[1886,2134],[1887,2152],[1888,2249],[1889,2332],[1890,2385],[1891,2393],[1892,2428],[1893,2482],[1894,2479],[1895,2482],[1896,2523],[1897,2624],[1898,2612],[1899,2661],[1900,2668],[1901,2709],[1902,2732],[1903,2705],[1904,2704],[1905,2716],[1906,2822],[1907,2937],[1908,3014],[1909,3058],[1910,3168],[1911,3274],[1912,3410],[1913,3566],[1914,3610],[1915,3737],[1916,3852],[1917,3468],[1918,3300],[1919,3836],[1920,4045],[1921,3615],[1922,3970],[1923,4058],[1924,4041],[1925,4269],[1926,4316],[1927,4469],[1928,4658],[1929,5089],[1930,5460],[1931,5012],[1932,5238],[1933,5350],[1934,5518],[1935,5774],[1936,6144],[1937,6396],[1938,6514],[1939,6800],[1940,6195],[1941,6322],[1942,6049],[1943,5895],[1944,5546],[1945,6164],[1946,6728],[1947,7563],[1948,8013],[1949,8158],[1950,8490],[1951,8884],[1952,9126],[1953,9413],[1954,9809],[1955,9948],[1956,10400],[1957,10636],[1958,10562],[1959,10936],[1960,11481],[1961,12127],[1962,12393],[1963,12794],[1964,13355],[1965,13982],[1966,14421],[1967,15220],[1968,15456],[1969,16050],[1970,16289],[1971,17044],[1972,17810],[1973,18501],[1974,19194],[1975,20125],[1976,21246],[1977,22101],[1978,22828],[1979,23815],[1980,24961],[1981,25164],[1982,25172],[1983,26036],[1984,27549],[1985,28950],[1986,29947],[1987,30478],[1988,30359],[1989,30581],[1990,31162],[1991,32200],[1992,33135],[1993,33900],[1994,35547],[1995,36975],[1996,38795],[1997,40659],[1998,41358],[1999,42008],[2000,43174],[2001,43888],[2002,44429],[2003,44767],[2004,46387],[2005,47551],[2006,48218],[2007,49013],[2008,49221],[2009,47915]],"population":[[1820,970000],[1821,984000],[1822,998000],[1823,1013000],[1824,1028000],[1825,1044000],[1826,1062000],[1827,1079000],[1828,1093000],[1829,1108000],[1830,1124000],[1831,1137000],[1832,1150000],[1833,1163000],[1834,1174000],[1835,1188000],[1836,1202000],[1837,1214000],[1838,1224000],[1839,1233000],[1840,1241000],[1841,1254000],[1842,1271000],[1843,1286000],[1844,1302000],[1845,1319000],[1846,1337000],[1847,1351000],[1848,1363000],[1849,1377000],[1850,1392000],[1851,1409000],[1852,1425000],[1853,1440000],[1854,1457000],[1855,1479000],[1856,1501000],[1857,1521000],[1858,1543000],[1859,1570000],[1860,1596000],[1861,1614000],[1862,1627000],[1863,1646000],[1864,1668000],[1865,1690000],[1866,1707000],[1867,1716000],[1868,1724000],[1869,1729000],[1870,1735000],[1871,1745000],[1872,1755000],[1873,1767000],[1874,1783000],[1875,1803000],[1876,1829000],[1877,1852000],[1878,1877000],[1879,1902000],[1880,1919000],[1881,1923000],[1882,1920000],[1883,1919000],[1884,1929000],[1885,1944000],[1886,1958000],[1887,1970000],[1888,1977000],[1889,1984000],[1890,1997000],[1891,2013000],[1892,2026000],[1893,2038000],[1894,2057000],[1895,2083000],[1896,2112000],[1897,2142000],[1898,2174000],[1899,2204000],[1900,2230000],[1901,2255000],[1902,2275000],[1903,2288000],[1904,2297000],[1905,2309000],[1906,2319000],[1907,2329000],[1908,2346000],[1909,2367000],[1910,2384000],[1911,2401000],[1912,2423000],[1913,2447000],[1914,2472000],[1915,2498000],[1916,2522000],[1917,2551000],[1918,2578000],[1919,2603000],[1920,2635000],[1921,2668000],[1922,2695000],[1923,2713000],[1924,2729000],[1925,2747000],[1926,2763000],[1927,2775000],[1928,2785000],[1929,2795000],[1930,2807000],[1931,2824000],[1932,2842000],[1933,2858000],[1934,2874000],[1935,2889000],[1936,2904000],[1937,2919000],[1938,2936000],[1939,2954000],[1940,2973000],[1941,2990000],[1942,3009000],[1943,3032000],[1944,3060000],[1945,3091000],[1946,3127000],[1947,3165000],[1948,3201000],[1949,3234000],[1950,3265126],[1951,3295871],[1952,3327728],[1953,3360888],[1954,3394246],[1955,3427409],[1956,3459992],[1957,3491938],[1958,3522993],[1959,3552851],[1960,3581239],[1961,3609800],[1962,3638919],[1963,3666540],[1964,3694339],[1965,3723153],[1966,3753628],[1967,3786019],[1968,3818983],[1969,3850977],[1970,3877386],[1971,3903039],[1972,3933004],[1973,3960613],[1974,3985258],[1975,4007313],[1976,4026152],[1977,4043205],[1978,4058671],[1979,4072517],[1980,4085620],[1981,4099702],[1982,4114787],[1983,4128432],[1984,4140095],[1985,4152419],[1986,4166596],[1987,4186147],[1988,4208729],[1989,4226142],[1990,4242006],[1991,4261733],[1992,4286357],[1993,4311964],[1994,4336638],[1995,4359101],[1996,4381277],[1997,4405672],[1998,4432718],[1999,4463377],[2000,4492400],[2001,4515195],[2002,4535591],[2003,4555400],[2004,4574560],[2005,4593041],[2006,4610820],[2007,4627926],[2008,4644457]],"lifeExpectancy":[[1800,38.8],[1815,38.8],[1846,48.05],[1847,44.77],[1848,45.02],[1849,48.05],[1850,49.53],[1851,49.74],[1852,48.46],[1853,47.92],[1854,51.65],[1855,50.44],[1856,50.37],[1857,50.22],[1858,51.59],[1859,49.93],[1860,50],[1861,45.81],[1862,44.7],[1863,46.71],[1864,48.78],[1865,50.42],[1866,49.92],[1867,47.87],[1868,47.16],[1869,49.25],[1870,50.86],[1871,49.69],[1872,50.02],[1873,49.67],[1874,47.77],[1875,47.64],[1876,46.83],[1877,49.77],[1878,51.79],[1879,53.18],[1880,51.91],[1881,50.47],[1882,47.4],[1883,49.64],[1884,50.8],[1885,51.06],[1886,51.72],[1887,51.69],[1888,50.38],[1889,49.06],[1890,48.6],[1891,49.79],[1892,49.68],[1893,51.41],[1894,50.62],[1895,52.8],[1896,53.84],[1897,53.73],[1898,53.96],[1899,51.62],[1900,53.47],[1901,54.59],[1902,56.49],[1903,54.98],[1904,56.09],[1905,55.1],[1906,56.91],[1907,56.49],[1908,56.31],[1909,57.47],[1910,57.99],[1911,58.04],[1912,57.75],[1913,58.32],[1914,57.82],[1915,58.17],[1916,57.25],[1917,57.75],[1918,50.3],[1919,56.82],[1920,58.89],[1921,61.61],[1922,60.79],[1923,61.81],[1924,62.12],[1925,62.52],[1926,63.26],[1927,62.87],[1928,63.4],[1929,62.47],[1930,64.11],[1931,64.14],[1932,64.61],[1933,65.49],[1934,66.22],[1935,65.84],[1936,65.84],[1937,66.04],[1938,67.09],[1939,67.36],[1940,65.89],[1941,65.77],[1942,65.68],[1943,66.12],[1944,65.8],[1945,68.19],[1946,69.51],[1947,70.01],[1948,71.13],[1949,71.53],[1950,71.6],[1951,72.54],[1952,72.67],[1953,73.15],[1954,73.23],[1955,73.44],[1956,73.49],[1957,73.44],[1958,73.43],[1959,73.56],[1960,73.58],[1961,73.59],[1962,73.47],[1963,73.11],[1964,73.61],[1965,73.73],[1966,74.01],[1967,74.08],[1968,73.96],[1969,73.67],[1970,74.08],[1971,74.18],[1972,74.34],[1973,74.43],[1974,74.75],[1975,74.8],[1976,75.03],[1977,75.37],[1978,75.4],[1979,75.39],[1980,75.65],[1981,75.84],[1982,75.97],[1983,76.03],[1984,76.19],[1985,75.9],[1986,76.04],[1987,75.89],[1988,75.99],[1989,76.33],[1990,76.41],[1991,76.93],[1992,77.32],[1993,77.28],[1994,77.86],[1995,77.89],[1996,78.31],[1997,78.32],[1998,78.49],[1999,78.47],[2000,78.76],[2001,78.98],[2002,79.05],[2003,79.61],[2004,80.06],[2005,80.29],[2006,80.55],[2007,80.61],[2008,80.67],[2009,80.85]]},{"name":"Poland","region":"Europe & Central Asia","income":[[1800,1198.39],[1820,1290.47],[1821,1294.57],[1822,1298.67],[1823,1302.79],[1824,1306.92],[1825,1311.07],[1826,1315.22],[1827,1319.4],[1828,1323.58],[1829,1327.78],[1830,1331.99],[1831,1336.21],[1832,1340.45],[1833,1344.7],[1834,1348.97],[1835,1353.24],[1836,1357.54],[1837,1361.84],[1838,1366.16],[1839,1370.49],[1840,1374.84],[1841,1379.2],[1842,1383.57],[1843,1387.96],[1844,1392.36],[1845,1396.78],[1846,1401.21],[1847,1405.65],[1848,1410.11],[1849,1414.58],[1850,1419.07],[1851,1423.57],[1852,1428.09],[1853,1432.61],[1854,1437.16],[1855,1441.72],[1856,1446.29],[1857,1450.88],[1858,1455.48],[1859,1460.09],[1860,1464.72],[1861,1469.37],[1862,1474.03],[1863,1478.7],[1864,1483.39],[1865,1488.1],[1866,1492.82],[1867,1497.55],[1868,1502.3],[1869,1507.07],[1870,1511.84],[1871,1535.12],[1872,1558.75],[1873,1582.74],[1874,1607.11],[1875,1631.85],[1876,1656.97],[1877,1682.47],[1878,1708.37],[1879,1734.67],[1880,1761.37],[1881,1788.49],[1882,1816.02],[1883,1843.97],[1884,1872.36],[1885,1901.18],[1886,1930.45],[1887,1960.16],[1888,1990.34],[1889,2020.98],[1890,2052.09],[1891,2089.19],[1892,2126.96],[1893,2165.42],[1894,2204.57],[1895,2244.43],[1896,2285.01],[1897,2326.32],[1898,2368.38],[1899,2411.2],[1900,2454.79],[1901,2478.36],[1902,2502.15],[1903,2526.17],[1904,2550.42],[1905,2574.9],[1906,2599.62],[1907,2624.58],[1908,2649.77],[1909,2675.21],[1910,2700.89],[1911,2726.76],[1912,2752.88],[1913,2779.24],[1914,2813.64],[1915,2848.47],[1916,2883.73],[1917,2919.43],[1918,2955.56],[1919,2992.15],[1920,3029.19],[1921,3066.68],[1922,3104.64],[1923,3143.07],[1924,3181.98],[1925,3221.37],[1926,3261.24],[1927,3301.61],[1928,3342.48],[1929,3383.85],[1930,3187.21],[1931,2914.14],[1932,2649.16],[1933,2540.64],[1934,2546.64],[1935,2551.83],[1936,2596.46],[1937,3061.3],[1938,3487.75],[1939,3750.1],[1940,3174.55],[1941,2892.29],[1942,2543.47],[1943,2391.53],[1944,1536.58],[1945,1588.31],[1946,2706.91],[1947,3132.14],[1948,3477.09],[1949,3741.25],[1950,3910.56],[1951,4011.8],[1952,4029.33],[1953,4183.46],[1954,4338.68],[1955,4464.95],[1956,4576.69],[1957,4734.25],[1958,4885.49],[1959,4948.3],[1960,5137.59],[1961,5475.68],[1962,5338.75],[1963,5597.46],[1964,5788.41],[1965,6052.03],[1966,6378.94],[1967,6557.15],[1968,6900.04],[1969,6778.28],[1970,7076.39],[1971,7522.54],[1972,8006.51],[1973,8533.52],[1974,8950.74],[1975,9281.98],[1976,9421.88],[1977,9508.14],[1978,9766.19],[1979,9496.48],[1980,9173.32],[1981,8606.55],[1982,8451.53],[1983,8786.11],[1984,9030.45],[1985,9046.3],[1986,9263.85],[1987,9082.35],[1988,9252.06],[1989,9083.71],[1990,8172.11],[1991,7572.21],[1992,7738.88],[1993,8007.93],[1994,8414.16],[1995,8986.89],[1996,9518.9],[1997,10159.58],[1998,10716.13],[1999,11208.8],[2000,11680.79],[2001,11825.87],[2002,12002.24],[2003,12472.53],[2004,13146.01],[2005,13573],[2006,14427.4],[2007,15414.7],[2008,16185.04],[2009,16465.8]],"population":[[1820,10426000],[1850,13000000],[1870,16865000],[1890,22854000],[1900,24750000],[1910,26644000],[1913,26710000],[1920,23968000],[1921,24330000],[1922,24935000],[1923,25569000],[1924,25992000],[1925,26425000],[1926,26815000],[1927,27148000],[1928,27509000],[1929,27856000],[1930,28204000],[1931,28615000],[1932,29022000],[1933,29421000],[1934,29771000],[1935,30129000],[1936,30471000],[1937,30791000],[1938,31062000],[1939,31365000],[1940,30021000],[1946,23959000],[1947,23734000],[1948,23980000],[1949,24410000],[1950,24824000],[1951,25262265],[1952,25730551],[1953,26221264],[1954,26715134],[1955,27220668],[1956,27743876],[1957,28235346],[1958,28692576],[1959,29152334],[1960,29589842],[1961,29978949],[1962,30329617],[1963,30662122],[1964,30975520],[1965,31262358],[1966,31532016],[1967,31785378],[1968,32034813],[1969,32280848],[1970,32526000],[1971,32777810],[1972,33039545],[1973,33331131],[1974,33642890],[1975,33969240],[1976,34299428],[1977,34621254],[1978,34929072],[1979,35256645],[1980,35578016],[1981,35901961],[1982,36227381],[1983,36571418],[1984,36904134],[1985,37225792],[1986,37504275],[1987,37740710],[1988,37866840],[1989,37970155],[1990,38119408],[1991,38253222],[1992,38370697],[1993,38467746],[1994,38548296],[1995,38600642],[1996,38629842],[1997,38654957],[1998,38668756],[1999,38665539],[2000,38654164],[2001,38643641],[2002,38625976],[2003,38602853],[2004,38580445],[2005,38557984],[2006,38536869],[2007,38518241],[2008,38500696]],"lifeExpectancy":[[1800,35.9],[1885,35.9],[1931,49.8],[1950,59.05],[1951,59.65],[1952,60.83],[1953,61.92],[1954,62.93],[1955,63.85],[1956,64.69],[1957,65.45],[1958,65.92],[1959,65.53],[1960,67.86],[1961,67.98],[1962,67.64],[1963,68.57],[1964,68.8],[1965,69.5],[1966,69.91],[1967,69.61],[1968,70.25],[1969,69.74],[1970,69.87],[1971,69.67],[1972,70.85],[1973,70.85],[1974,71.36],[1975,70.77],[1976,70.77],[1977,70.67],[1978,70.6],[1979,70.93],[1980,70.28],[1981,71.26],[1982,71.32],[1983,71.16],[1984,70.9],[1985,70.64],[1986,70.93],[1987,70.98],[1988,71.35],[1989,71.1],[1990,70.75],[1991,70.45],[1992,70.99],[1993,71.51],[1994,71.82],[1995,72.05],[1996,72.39],[1997,72.75],[1998,73.13],[1999,73.18],[2000,73.91],[2001,74.33],[2002,74.67],[2003,74.85],[2004,75.02],[2005,75.15],[2006,75.35],[2007,75.52],[2008,75.68],[2009,75.84]]},{"name":"Portugal","region":"Europe & Central Asia","income":[[1800,1284.41],[1820,1310.25],[1821,1310.27],[1822,1310.3],[1823,1310.32],[1824,1310.35],[1825,1310.37],[1826,1310.39],[1827,1310.42],[1828,1310.44],[1829,1310.47],[1830,1310.49],[1831,1310.52],[1832,1310.54],[1833,1310.57],[1834,1310.59],[1835,1310.62],[1836,1310.64],[1837,1310.67],[1838,1310.69],[1839,1310.71],[1840,1310.74],[1841,1310.76],[1842,1310.79],[1843,1310.81],[1844,1310.84],[1845,1310.86],[1846,1310.89],[1847,1310.91],[1848,1310.94],[1849,1310.96],[1850,1310.99],[1851,1407],[1852,1380.51],[1853,1354.51],[1854,1329],[1855,1303.97],[1856,1295.41],[1857,1286.89],[1858,1278.44],[1859,1270.04],[1860,1261.69],[1861,1253.4],[1862,1256.42],[1863,1259.45],[1864,1262.48],[1865,1265.52],[1866,1305.74],[1867,1335.79],[1868,1341.93],[1869,1368.8],[1870,1384.18],[1871,1324.39],[1872,1354.78],[1873,1402.86],[1874,1371.88],[1875,1361.98],[1876,1322.42],[1877,1375.87],[1878,1368.62],[1879,1361.54],[1880,1344.78],[1881,1377.49],[1882,1408.72],[1883,1431.01],[1884,1467.5],[1885,1493.03],[1886,1561.66],[1887,1581.31],[1888,1586.51],[1889,1544.92],[1890,1601.16],[1891,1560.79],[1892,1543.11],[1893,1562.93],[1894,1531.75],[1895,1586.21],[1896,1596.93],[1897,1677.51],[1898,1723.95],[1899,1772.8],[1900,1848.6],[1901,1801.95],[1902,1796.87],[1903,1807.25],[1904,1815.6],[1905,1750.28],[1906,1746.93],[1907,1773.59],[1908,1730.83],[1909,1715.02],[1910,1743.15],[1911,1762.62],[1912,1783.8],[1913,1774.99],[1914,1785.2],[1915,1742.99],[1916,1751.32],[1917,1721.27],[1918,1632.1],[1919,1665.53],[1920,1745.03],[1921,1831.16],[1922,2029.87],[1923,2091.67],[1924,1989.26],[1925,2052.85],[1926,2014.55],[1927,2338.95],[1928,2087.28],[1929,2285.66],[1930,2229.87],[1931,2315.53],[1932,2331.73],[1933,2458.92],[1934,2532.48],[1935,2368.84],[1936,2161.78],[1937,2494.69],[1938,2480.53],[1939,2482.87],[1940,2292.84],[1941,2479.98],[1942,2425.1],[1943,2564.33],[1944,2686.88],[1945,2560.36],[1946,2736.83],[1947,2939.33],[1948,2904.91],[1949,2919.51],[1950,2961.89],[1951,3077.24],[1952,3068.32],[1953,3262.2],[1954,3397.69],[1955,3513.19],[1956,3639.99],[1957,3774.57],[1958,3793.66],[1959,3966.47],[1960,4196.15],[1961,4428.04],[1962,4727.95],[1963,4974.5],[1964,5278.68],[1965,5667.66],[1966,5911.27],[1967,6361.52],[1968,6918.3],[1969,7079.03],[1970,7769.41],[1971,8334.25],[1972,9022.25],[1973,10026.71],[1974,10005],[1975,9251.92],[1976,9673.53],[1977,10172.49],[1978,10419.96],[1979,10978.31],[1980,11419.72],[1981,11519.39],[1982,11753.84],[1983,11718.43],[1984,11482.99],[1985,11791.3],[1986,12266.89],[1987,13039.31],[1988,14008.38],[1989,14724.11],[1990,15369.31],[1991,16046.61],[1992,16207.27],[1993,15812.16],[1994,15869.43],[1995,16486.84],[1996,17027.45],[1997,17641.03],[1998,18368.52],[1999,18959.84],[2000,19609.73],[2001,19904.87],[2002,19970.91],[2003,19727.84],[2004,19942.44],[2005,20006],[2006,20202.27],[2007,20523.09],[2008,20496.24],[2009,19898.43]],"population":[[1820,3297000],[1821,3316000],[1822,3335000],[1823,3354000],[1824,3373000],[1825,3393000],[1826,3412000],[1827,3432000],[1828,3452000],[1829,3472000],[1830,3491000],[1831,3512000],[1832,3532000],[1833,3552000],[1834,3475000],[1835,3595000],[1836,3617000],[1837,3639000],[1838,3661000],[1839,3683000],[1840,3704000],[1841,3715000],[1842,3726000],[1843,3738000],[1844,3749000],[1845,3760000],[1846,3771000],[1847,3783000],[1848,3794000],[1849,3804000],[1850,3816000],[1851,3827000],[1852,3839000],[1853,3850000],[1854,3858000],[1855,3867000],[1856,3875000],[1857,3889000],[1858,3925000],[1859,3963000],[1860,4000000],[1861,4074000],[1862,4113000],[1863,4131000],[1864,4176000],[1865,4201000],[1866,4226000],[1867,4251000],[1868,4276000],[1869,4302000],[1870,4327000],[1871,4353000],[1872,4379000],[1873,4405000],[1874,4431000],[1875,4458000],[1876,4484000],[1877,4511000],[1878,4538000],[1879,4571000],[1880,4610000],[1881,4651000],[1882,4691000],[1883,4732000],[1884,4773000],[1885,4815000],[1886,4857000],[1887,4899000],[1888,4942000],[1889,4985000],[1890,5028000],[1891,5068000],[1892,5104000],[1893,5141000],[1894,5178000],[1895,5215000],[1896,5252000],[1897,5290000],[1898,5327000],[1899,5366000],[1900,5404000],[1901,5447000],[1902,5494000],[1903,5541000],[1904,5589000],[1905,5637000],[1906,5686000],[1907,5735000],[1908,5784000],[1909,5834000],[1910,5884000],[1911,5935000],[1912,5964000],[1913,5972000],[1914,5980000],[1915,5988000],[1916,5996000],[1917,6005000],[1918,6013000],[1919,6021000],[1920,6029000],[1921,6071000],[1922,6146000],[1923,6223000],[1924,6300000],[1925,6378000],[1926,6457000],[1927,6538000],[1928,6619000],[1929,6701000],[1930,6784000],[1931,6869000],[1932,6954000],[1933,7040000],[1934,7127000],[1935,7216000],[1936,7305000],[1937,7396000],[1938,7488000],[1939,7581000],[1940,7675000],[1941,7757000],[1942,7826000],[1943,7896000],[1944,7967000],[1945,8038000],[1946,8110000],[1947,8183000],[1948,8256000],[1949,8329000],[1950,8442750],[1951,8490250],[1952,8526050],[1953,8578950],[1954,8632100],[1955,8692600],[1956,8756000],[1957,8817650],[1958,8888550],[1959,8961550],[1960,9036700],[1961,9031200],[1962,9019800],[1963,9081600],[1964,9122500],[1965,9128850],[1966,9108800],[1967,9103000],[1968,9115050],[1969,9097200],[1970,9044200],[1971,8990450],[1972,8970450],[1973,8975950],[1974,9098300],[1975,9411090],[1976,9621970],[1977,9662600],[1978,9698780],[1979,9724560],[1980,9777800],[1981,9850079],[1982,9859650],[1983,9872243],[1984,9885387],[1985,9897192],[1986,9907411],[1987,9915289],[1988,9920611],[1989,9923147],[1990,9922689],[1991,9919009],[1992,9927680],[1993,9967832],[1994,10027688],[1995,10065543],[1996,10099918],[1997,10156415],[1998,10224828],[1999,10283381],[2000,10335597],[2001,10386753],[2002,10433867],[2003,10479955],[2004,10524145],[2005,10566212],[2006,10605870],[2007,10642836],[2008,10676910]],"lifeExpectancy":[[1800,35.6],[1925,35.6],[1940,51.43],[1941,47.95],[1942,49.87],[1943,51.05],[1944,52.42],[1945,53.81],[1946,53.69],[1947,56.03],[1948,56.76],[1949,55.38],[1950,58.53],[1951,58.72],[1952,59.82],[1953,61.12],[1954,62.26],[1955,61.43],[1956,61.24],[1957,61.51],[1958,63.81],[1959,62.99],[1960,64.25],[1961,62.87],[1962,64.39],[1963,65.02],[1964,65.24],[1965,66.19],[1966,65.7],[1967,66.6],[1968,66.91],[1969,66.52],[1970,67.17],[1971,66.94],[1972,69.26],[1973,68.66],[1974,69.21],[1975,68.93],[1976,69.16],[1977,70.41],[1978,70.87],[1979,71.68],[1980,71.75],[1981,71.94],[1982,72.77],[1983,72.69],[1984,72.98],[1985,73.26],[1986,73.66],[1987,74.05],[1988,74.07],[1989,74.63],[1990,74.25],[1991,74.19],[1992,74.86],[1993,74.77],[1994,75.76],[1995,75.58],[1996,75.53],[1997,75.97],[1998,76.18],[1999,76.36],[2000,76.84],[2001,77.11],[2002,77.29],[2003,77.49],[2004,78.32],[2005,78.2],[2006,78.94],[2007,79.12],[2008,78.77],[2009,78.94]]},{"name":"Romania","region":"Europe & Central Asia","income":[[1800,1093.92],[1820,1116.86],[1870,2196.25],[1890,2939.27],[1900,3337.87],[1910,3915.9],[1913,4106.97],[1926,2966.42],[1927,2928.18],[1928,2888.6],[1929,2718.46],[1930,2875.09],[1931,2898.76],[1932,2699.76],[1933,2794.09],[1934,2788.24],[1935,2821.77],[1936,2816.99],[1937,2666.64],[1938,2929.59],[1948,1925.76],[1950,2788.13],[1951,2962.12],[1952,3144.61],[1953,3328.7],[1954,3529.11],[1955,3722.17],[1956,3829.44],[1957,3943.37],[1958,4065.81],[1959,4205.87],[1960,4349.19],[1961,4602.36],[1962,4735],[1963,5040.1],[1964,5326.92],[1965,5628.67],[1966,6234.45],[1967,6470.87],[1968,6461.5],[1969,6661.29],[1970,6729.78],[1971,7598.18],[1972,8011.41],[1973,8201.28],[1974,8579.08],[1975,8872.78],[1976,9239.34],[1977,9356.4],[1978,9584.18],[1979,9785.25],[1980,9755.08],[1981,9640.37],[1982,9605.31],[1983,9498.4],[1984,9855.45],[1985,9809.79],[1986,9942.75],[1987,9696.27],[1988,9637.16],[1989,9295.59],[1990,8281.62],[1991,7226.05],[1992,6598.41],[1993,6705.77],[1994,6976.44],[1995,7486.9],[1996,7801.29],[1997,7346.55],[1998,7008.4],[1999,6935.17],[2000,7089.83],[2001,7501.93],[2002,7885.36],[2003,8280.64],[2004,8994.49],[2005,9374],[2006,10151.92],[2007,10826.03],[2008,11662.14],[2009,10868.12]],"population":[[1820,6389000],[1850,8000000],[1870,9179000],[1890,10373000],[1900,11000000],[1910,11866000],[1913,12527000],[1920,12340000],[1921,12479000],[1922,12666000],[1923,12843000],[1924,13020000],[1925,13209000],[1926,13399000],[1927,13574000],[1928,13760000],[1929,13952000],[1930,14141000],[1931,14355000],[1932,14554000],[1933,14730000],[1934,14924000],[1935,15069000],[1936,15256000],[1937,15434000],[1938,15601000],[1939,15751000],[1940,15907000],[1941,15774000],[1942,15839000],[1943,15840000],[1944,15946000],[1945,15929000],[1946,15971000],[1947,15849000],[1948,15893000],[1949,16084000],[1950,16311000],[1951,16464000],[1952,16630000],[1953,16847000],[1954,17040000],[1955,17325000],[1956,17583000],[1957,17829327],[1958,18055948],[1959,18225830],[1960,18403414],[1961,18566932],[1962,18680721],[1963,18813131],[1964,18927081],[1965,19027367],[1966,19140783],[1967,19284814],[1968,19720984],[1969,20010178],[1970,20252541],[1971,20469658],[1972,20662648],[1973,20827525],[1974,21028841],[1975,21245103],[1976,21445698],[1977,21658597],[1978,21831875],[1979,22001388],[1980,22130036],[1981,22256551],[1982,22356726],[1983,22407281],[1984,22453788],[1985,22521195],[1986,22599678],[1987,22686371],[1988,22768897],[1989,22852123],[1990,22865945],[1991,22825559],[1992,22797027],[1993,22768538],[1994,22738680],[1995,22692830],[1996,22627562],[1997,22562458],[1998,22515824],[1999,22480527],[2000,22451921],[2001,22428044],[2002,22404337],[2003,22380273],[2004,22355551],[2005,22329977],[2006,22303552],[2007,22276056],[2008,22246862]],"lifeExpectancy":[[1800,35.7],[1920,35.7],[1932,42.01],[1950,59.86],[1951,60.15],[1952,60.74],[1953,61.34],[1954,61.96],[1955,62.6],[1956,63.25],[1957,63.9],[1958,64.54],[1959,65.14],[1960,65.68],[1961,66.13],[1962,66.46],[1963,66.67],[1964,66.78],[1965,66.83],[1966,66.9],[1967,67.03],[1968,67.26],[1969,67.59],[1970,68],[1971,68.43],[1972,68.83],[1973,69.15],[1974,69.37],[1975,69.5],[1976,69.55],[1977,69.56],[1978,69.57],[1979,69.58],[1980,69.6],[1981,69.62],[1982,69.64],[1983,69.65],[1984,69.64],[1985,69.62],[1986,69.59],[1987,69.54],[1988,69.5],[1989,69.45],[1990,69.4],[1991,69.37],[1992,69.34],[1993,69.33],[1994,69.35],[1995,69.4],[1996,69.51],[1997,69.68],[1998,69.9],[1999,70.17],[2000,70.48],[2001,70.81],[2002,71.14],[2003,71.47],[2004,71.77],[2005,72.04],[2006,72.29],[2007,72.53],[2008,72.76],[2009,72.99]]},{"name":"Serbia","region":"Europe & Central Asia","income":[[1800,1308.87],[1820,1336.32],[1870,1481.18],[1890,2084.6],[1900,2230.41],[1910,2613.49],[1913,2613.56],[1920,2549.97],[1921,2575.11],[1922,2613.02],[1923,2710.16],[1924,2863.71],[1925,2961.99],[1926,3123.97],[1927,3029.72],[1928,3249.77],[1929,3373.22],[1930,3260.19],[1931,3117.55],[1932,2788.6],[1933,2835.85],[1934,2901.09],[1935,2818.2],[1936,3140.56],[1937,3148.91],[1938,3354.11],[1939,3490.94],[1947,3252.79],[1948,3828.92],[1949,4150.15],[1950,3835.16],[1951,3934.49],[1952,3581.46],[1953,4062.06],[1954,4233.2],[1955,4444.31],[1956,4307.01],[1957,4981.09],[1958,5143.12],[1959,5721.27],[1960,6026.13],[1961,6235.08],[1962,6289.63],[1963,6877.27],[1964,7465.67],[1965,7592.72],[1966,7925.24],[1967,7991.71],[1968,8091.85],[1969,8926.12],[1970,9283.91],[1971,10263.93],[1972,10522.07],[1973,10782.43],[1974,12065.32],[1975,11959.25],[1976,12213.27],[1977,12980.67],[1978,13578.31],[1979,14387.78],[1980,14992.89],[1981,15168.18],[1982,15181.09],[1983,15225.82],[1984,15526.1],[1985,15569.67],[1986,16126.32],[1987,15870.88],[1988,15578.62],[1989,15313.99],[1990,14143.66],[1991,12990.68],[1992,9325.07],[1993,6478.91],[1994,6639.38],[1995,7012.19],[1996,7344.15],[1997,7914.32],[1998,8133.2],[1999,6302.01],[2000,6607.33],[2001,6939.82],[2002,7236.08],[2003,7436.24],[2004,8081.66],[2005,8609],[2006,9093.5],[2007,9760.87],[2008,10301.22],[2009,10005.22]],"population":[[1800,2147197],[1820,2147197],[1950,6710261],[1951,6794255],[1952,6860147],[1953,6950699],[1954,7045988],[1955,7145006],[1956,7207162],[1957,7271135],[1958,7331982],[1959,7405493],[1960,7470936],[1961,7542114],[1962,7616060],[1963,7689816],[1964,7756518],[1965,7830883],[1966,7906036],[1967,7971222],[1968,8039165],[1969,8104980],[1970,8166726],[1971,8236091],[1972,8313288],[1973,8383682],[1974,8461865],[1975,8542000],[1976,8614774],[1977,8686367],[1978,8752904],[1979,8817307],[1980,8955000],[1981,8973246],[1982,9032824],[1983,9087632],[1984,9096747],[1985,9150329],[1986,9201321],[1987,9230783],[1988,9270114],[1989,9310769],[1990,9347973],[1991,9617827],[1992,9826397],[1993,9926991],[1994,10031261],[1995,10192265],[1996,10311510],[1997,10336594],[1998,10302093],[1999,10170917],[2000,10117908],[2001,10131896],[2002,10111559],[2003,10109579],[2004,10119145],[2005,10129640],[2006,10140311],[2007,10150265],[2008,10159046],[2009,10166507]],"lifeExpectancy":[[1800,35.5],[1920,35.5],[1950,56.31],[1951,56.75],[1952,57.61],[1953,58.44],[1954,59.23],[1955,59.98],[1956,60.69],[1957,61.37],[1958,62.02],[1959,62.63],[1960,63.21],[1961,63.77],[1962,64.31],[1963,64.83],[1964,65.33],[1965,65.81],[1966,66.27],[1967,66.7],[1968,67.11],[1969,67.5],[1970,67.87],[1971,68.24],[1972,68.61],[1973,68.97],[1974,69.32],[1975,69.65],[1976,69.91],[1977,70.1],[1978,70.22],[1979,70.27],[1980,70.28],[1981,70.27],[1982,70.29],[1983,70.36],[1984,70.47],[1985,70.64],[1986,70.84],[1987,71.05],[1988,71.25],[1989,71.42],[1990,71.56],[1991,71.67],[1992,71.76],[1993,71.83],[1994,71.91],[1995,71.99],[1996,72.09],[1997,72.21],[1998,72.35],[1999,72.51],[2000,72.69],[2001,72.89],[2002,73.09],[2003,73.28],[2004,73.46],[2005,73.63],[2006,73.78],[2007,73.94],[2008,74.08],[2009,74.23]]},{"name":"Slovak Republic","region":"Europe & Central Asia","income":[[1800,1197.6],[1820,1197.6],[1850,1522.03],[1870,1641.83],[1890,2122.91],[1900,2438.9],[1910,2808.4],[1913,2955.87],[1920,2726.87],[1921,2940.51],[1922,2829.41],[1923,3033.56],[1924,3318.73],[1925,3675.88],[1926,3632.7],[1927,3881.4],[1928,4199.46],[1929,4291.43],[1930,4127.01],[1931,3961.86],[1932,3779.92],[1933,3599.45],[1934,3445.75],[1935,3399.29],[1936,3665.52],[1937,4064.56],[1948,4356.41],[1949,4597.55],[1950,4937.84],[1951,4970.41],[1952,5074.66],[1953,4999.31],[1954,5150.73],[1955,5532.03],[1956,5797.5],[1957,6093.26],[1958,6502.62],[1959,6742.24],[1960,7205.56],[1961,7424.43],[1962,7481.11],[1963,7292.14],[1964,7578.14],[1965,7804.18],[1966,8097.45],[1967,8412.9],[1968,8777.18],[1969,8962.51],[1970,9121.12],[1971,9391.97],[1972,9674.17],[1973,9932.09],[1974,10216.42],[1975,10437.16],[1976,10524.37],[1977,10922.66],[1978,10983.19],[1979,11008.51],[1980,11259.07],[1981,11160.97],[1982,11348.55],[1983,11492.08],[1984,11735.04],[1985,11802.32],[1986,11999.9],[1987,12037.27],[1988,12284.16],[1989,12367.44],[1990,12007.55],[1991,10215.84],[1992,9498.47],[1993,9636.52],[1994,10195.81],[1995,10759.84],[1996,11482.63],[1997,12126.23],[1998,12564.34],[1999,12600.77],[2000,12689.76],[2001,13098.91],[2002,13638.78],[2003,14207.56],[2004,14977.87],[2005,15881],[2006,17217.17],[2007,19012.69],[2008,20143.88],[2009,19186.01]],"population":[[1800,2140651],[1820,2140651],[1950,3463446],[1951,3508698],[1952,3558137],[1953,3598761],[1954,3661437],[1955,3726601],[1956,3787111],[1957,3844277],[1958,3899751],[1959,3946039],[1960,3994270],[1961,4191642],[1962,4237384],[1963,4281858],[1964,4326174],[1965,4369939],[1966,4408988],[1967,4442238],[1968,4471590],[1969,4477625],[1970,4523873],[1971,4556627],[1972,4593433],[1973,4637193],[1974,4682100],[1975,4729718],[1976,4778540],[1977,4827803],[1978,4876017],[1979,4922558],[1980,4965958],[1981,5013692],[1982,5048043],[1983,5081376],[1984,5114080],[1985,5144632],[1986,5172084],[1987,5199318],[1988,5223222],[1989,5244662],[1990,5262616],[1991,5281610],[1992,5302888],[1993,5323577],[1994,5345264],[1995,5361594],[1996,5373190],[1997,5383010],[1998,5390236],[1999,5395739],[2000,5400320],[2001,5404681],[2002,5410052],[2003,5416406],[2004,5423567],[2005,5431363],[2006,5439448],[2007,5447502],[2008,5455407]],"lifeExpectancy":[[1800,36.4],[1895,36.4],[1921,44.2],[1930,49.9],[1937,53.2],[1950,60.89],[1951,61.31],[1952,64.36],[1953,65.66],[1954,66.71],[1955,67.84],[1956,68.37],[1957,67.45],[1958,69.35],[1959,69.03],[1960,70.35],[1961,70.79],[1962,70.33],[1963,70.71],[1964,71.09],[1965,70.3],[1966,70.44],[1967,70.98],[1968,70.5],[1969,69.81],[1970,69.74],[1971,69.88],[1972,70.35],[1973,70.05],[1974,70.21],[1975,70.33],[1976,70.5],[1977,70.45],[1978,70.46],[1979,70.79],[1980,70.44],[1981,70.68],[1982,70.8],[1983,70.49],[1984,70.73],[1985,70.74],[1986,70.91],[1987,71.08],[1988,71.16],[1989,70.95],[1990,70.83],[1991,70.9],[1992,71.38],[1993,71.9],[1994,72.36],[1995,72.29],[1996,72.77],[1997,72.71],[1998,72.62],[1999,72.99],[2000,73.19],[2001,73.62],[2002,73.81],[2003,73.85],[2004,74.26],[2005,74.2],[2006,74.46],[2007,74.52],[2008,74.88],[2009,74.94]]},{"name":"Slovenia","region":"Europe & Central Asia","income":[[1800,1357.95],[1820,1386.44],[1870,1743.21],[1890,2453.37],[1900,2624.99],[1910,3075.84],[1913,3075.92],[1920,3001.07],[1921,3030.67],[1922,3075.28],[1923,3189.6],[1924,3370.32],[1925,3485.98],[1926,3676.61],[1927,3565.7],[1928,3824.67],[1929,3969.96],[1930,3836.93],[1931,3669.07],[1932,3281.92],[1933,3337.53],[1934,3414.31],[1935,3316.75],[1936,3696.15],[1937,3705.97],[1938,3947.48],[1939,4108.51],[1947,3828.23],[1948,4506.28],[1949,4884.33],[1950,4513.62],[1951,4630.53],[1952,4215.04],[1953,4780.67],[1954,4982.08],[1955,5230.53],[1956,5068.95],[1957,5862.28],[1958,6052.97],[1959,6733.39],[1960,7092.19],[1961,7338.11],[1962,7402.3],[1963,8093.9],[1964,8786.4],[1965,8935.92],[1966,9327.26],[1967,9405.49],[1968,9523.35],[1969,10505.21],[1970,10926.29],[1971,12079.69],[1972,12383.49],[1973,12689.91],[1974,14199.74],[1975,14074.92],[1976,14373.88],[1977,15277.03],[1978,15980.4],[1979,16933.07],[1980,17645.22],[1981,17851.52],[1982,17866.72],[1983,17919.36],[1984,18272.76],[1985,18324.04],[1986,18979.17],[1987,18678.53],[1988,18334.58],[1989,18023.13],[1990,16645.76],[1991,15100.59],[1992,14214.72],[1993,14560.02],[1994,15279.58],[1995,15857.28],[1996,16392.55],[1997,17161.11],[1998,17747.88],[1999,18663.4],[2000,19399.69],[2001,19966.89],[2002,20660.02],[2003,21203.46],[2004,22113.22],[2005,23004],[2006,24255.45],[2007,25914.73],[2008,26779.28],[2009,24778.21]],"population":[[1800,469664],[1820,469664],[1950,1467759],[1951,1483131],[1952,1489518],[1953,1497875],[1954,1509187],[1955,1517499],[1956,1524799],[1957,1533070],[1958,1540332],[1959,1548561],[1960,1557756],[1961,1571851],[1962,1582962],[1963,1595028],[1964,1606083],[1965,1620052],[1966,1632029],[1967,1646912],[1968,1657849],[1969,1666805],[1970,1675739],[1971,1685624],[1972,1694510],[1973,1703373],[1974,1713184],[1975,1722000],[1976,1734454],[1977,1746919],[1978,1759395],[1979,1772854],[1980,1833000],[1981,1839256],[1982,1861252],[1983,1878555],[1984,1896413],[1985,1914220],[1986,1932129],[1987,1945870],[1988,1961775],[1989,1976217],[1990,1991210],[1991,1999480],[1992,1999210],[1993,1999926],[1994,2001036],[1995,2002827],[1996,2007429],[1997,2011612],[1998,2010807],[1999,2009653],[2000,2010557],[2001,2011179],[2002,2011497],[2003,2011604],[2004,2011473],[2005,2011070],[2006,2010347],[2007,2009245],[2008,2007711]],"lifeExpectancy":[[1800,36.6],[1920,36.6],[1950,64.45],[1951,64.75],[1952,65.32],[1953,65.87],[1954,66.38],[1955,66.86],[1956,67.3],[1957,67.71],[1958,68.08],[1959,68.4],[1960,68.68],[1961,68.89],[1962,69.05],[1963,69.15],[1964,69.2],[1965,69.22],[1966,69.22],[1967,69.23],[1968,69.26],[1969,69.32],[1970,69.42],[1971,69.57],[1972,69.76],[1973,69.97],[1974,70.2],[1975,70.43],[1976,70.63],[1977,70.78],[1978,70.89],[1979,70.97],[1980,71.02],[1981,71.07],[1982,71.16],[1983,70.88],[1984,71.34],[1985,71.77],[1986,72.32],[1987,72.25],[1988,72.9],[1989,73.35],[1990,73.86],[1991,73.5],[1992,73.64],[1993,73.52],[1994,73.96],[1995,74.67],[1996,75.11],[1997,75.13],[1998,75.26],[1999,75.64],[2000,76.11],[2001,76.38],[2002,76.66],[2003,76.55],[2004,77.28],[2005,77.6],[2006,78.24],[2007,78.15],[2008,78.41],[2009,78.63]]},{"name":"Spain","region":"Europe & Central Asia","income":[[1800,1443.02],[1820,1510.35],[1821,1513.78],[1822,1517.21],[1823,1520.65],[1824,1524.09],[1825,1527.55],[1826,1531.01],[1827,1534.48],[1828,1537.96],[1829,1541.44],[1830,1544.93],[1831,1548.44],[1832,1551.94],[1833,1555.46],[1834,1558.99],[1835,1562.52],[1836,1566.06],[1837,1569.61],[1838,1573.17],[1839,1576.73],[1840,1580.31],[1841,1583.89],[1842,1587.48],[1843,1591.07],[1844,1594.68],[1845,1598.29],[1846,1601.92],[1847,1605.55],[1848,1609.18],[1849,1612.83],[1850,1616.49],[1851,1632.37],[1852,1697.44],[1853,1702.12],[1854,1723.99],[1855,1801.43],[1856,1743.21],[1857,1695.79],[1858,1727.9],[1859,1798.2],[1860,1852.46],[1861,1870.46],[1862,1876.68],[1863,1913.85],[1864,1908.72],[1865,1843.65],[1866,1933.43],[1867,1922.37],[1868,1722.31],[1869,1770.45],[1870,1808.9],[1871,1945.24],[1872,2207.57],[1873,2394.12],[1874,2186.23],[1875,2242.35],[1876,2276.7],[1877,2500.26],[1878,2424.55],[1879,2278.23],[1880,2466.65],[1881,2516.2],[1882,2535.07],[1883,2578.06],[1884,2571.04],[1885,2489.16],[1886,2422.5],[1887,2375.82],[1888,2459.86],[1889,2443.33],[1890,2433.81],[1891,2478.14],[1892,2652.1],[1893,2547.88],[1894,2564.95],[1895,2531.14],[1896,2319.09],[1897,2426.09],[1898,2601.44],[1899,2631.41],[1900,2676.85],[1901,2848.79],[1902,2747],[1903,2740.65],[1904,2712.76],[1905,2663.39],[1906,2774.32],[1907,2841.88],[1908,2932.93],[1909,2963.39],[1910,2839.94],[1911,3022.91],[1912,2980.16],[1913,3080.48],[1914,3017.63],[1915,3046.46],[1916,3166.83],[1917,3107.16],[1918,3064.66],[1919,3063.21],[1920,3262.65],[1921,3315.45],[1922,3422.14],[1923,3431.6],[1924,3493.17],[1925,3672.26],[1926,3621.9],[1927,3896.12],[1928,3872.19],[1929,4104.43],[1930,3926.82],[1931,3789.68],[1932,3835.49],[1933,3725.35],[1934,3830.02],[1935,3870.45],[1936,2980.4],[1937,2709.06],[1938,2682.76],[1939,2869.22],[1940,3117.62],[1941,3041.43],[1942,3186.35],[1943,3278.25],[1944,3403.92],[1945,3149.32],[1946,3265.09],[1947,3293.12],[1948,3275.47],[1949,3229.14],[1950,3280.32],[1951,3576.32],[1952,3834.03],[1953,3787.81],[1954,4039.52],[1955,4163.5],[1956,4462.54],[1957,4564.8],[1958,4720.21],[1959,4571.3],[1960,4603.07],[1961,5149.13],[1962,5693.84],[1963,6221.1],[1964,6765.93],[1965,7136.52],[1966,7582.37],[1967,7993.51],[1968,8374.24],[1969,9039.41],[1970,9469.63],[1971,9918.21],[1972,10638.75],[1973,11481.02],[1974,12212.46],[1975,12507.48],[1976,12886.57],[1977,13236.92],[1978,13521.55],[1979,13589.12],[1980,13790.56],[1981,13765.39],[1982,13926.17],[1983,14203.11],[1984,14342.73],[1985,14568.71],[1986,14982.65],[1987,15764.98],[1988,16553.14],[1989,17355.75],[1990,18064.92],[1991,18472.91],[1992,18603.06],[1993,18374.87],[1994,18782.73],[1995,19272.14],[1996,19709.87],[1997,20445.3],[1998,21333.94],[1999,22286.36],[2000,23410.16],[2001,24221.8],[2002,24835.47],[2003,25564.29],[2004,26357.05],[2005,27270],[2006,27898.65],[2007,28427.37],[2008,28159.21],[2009,26811.93]],"population":[[1820,12203000],[1821,12284000],[1822,12366000],[1823,12449000],[1824,12532000],[1825,12615000],[1826,12699000],[1827,12784000],[1828,12869000],[1829,12955000],[1830,13041000],[1831,13128000],[1832,13216000],[1833,13304000],[1834,13392000],[1835,13482000],[1836,13571000],[1837,13662000],[1838,13753000],[1839,13845000],[1840,13937000],[1841,14030000],[1842,14123000],[1843,14217000],[1844,14312000],[1845,14407000],[1846,14503000],[1847,14600000],[1848,14697000],[1849,14795000],[1850,14894000],[1851,14974000],[1852,15055000],[1853,15136000],[1854,15217000],[1855,15299000],[1856,15381000],[1857,15455000],[1858,15526000],[1859,15584000],[1860,15642000],[1861,15699000],[1862,15754000],[1863,15809000],[1864,15864000],[1865,15920000],[1866,15976000],[1867,16032000],[1868,16088000],[1869,16144000],[1870,16201000],[1871,16258000],[1872,16315000],[1873,16372000],[1874,16429000],[1875,16487000],[1876,16545000],[1877,16603000],[1878,16677000],[1879,16768000],[1880,16859000],[1881,16951000],[1882,17043000],[1883,17136000],[1884,17230000],[1885,17323000],[1886,17418000],[1887,17513000],[1888,17600000],[1889,17678000],[1890,17757000],[1891,17836000],[1892,17916000],[1893,17996000],[1894,18076000],[1895,18157000],[1896,18238000],[1897,18320000],[1898,18402000],[1899,18484000],[1900,18566000],[1901,18659000],[1902,18788000],[1903,18919000],[1904,19050000],[1905,19133000],[1906,19316000],[1907,19450000],[1908,19585000],[1909,19721000],[1910,19858000],[1911,19994000],[1912,20128000],[1913,20263000],[1914,20398000],[1915,20535000],[1916,20673000],[1917,20811000],[1918,20950000],[1919,21091000],[1920,21232000],[1921,21411000],[1922,21628000],[1923,21847000],[1924,22069000],[1925,22292000],[1926,22518000],[1927,22747000],[1928,22977000],[1929,23210000],[1930,23445000],[1931,23675000],[1932,23897000],[1933,24122000],[1934,24349000],[1935,24579000],[1936,24810000],[1937,25043000],[1938,25279000],[1939,25517000],[1940,25757000],[1941,25979000],[1942,26182000],[1943,26387000],[1944,26594000],[1945,26802000],[1946,27012000],[1947,27223000],[1948,27437000],[1949,27651000],[1950,28062963],[1951,28298010],[1952,28549870],[1953,28804128],[1954,29060413],[1955,29318745],[1956,29579142],[1957,29841614],[1958,30106188],[1959,30372877],[1960,30641187],[1961,30903894],[1962,31158061],[1963,31429834],[1964,31740862],[1965,32084511],[1966,32451975],[1967,32850275],[1968,33239301],[1969,33566084],[1970,33876479],[1971,34195056],[1972,34513161],[1973,34836716],[1974,35184287],[1975,35563535],[1976,35996780],[1977,36439000],[1978,36861034],[1979,37200014],[1980,37488360],[1981,37750800],[1982,37983310],[1983,38184166],[1984,38362861],[1985,38534853],[1986,38707556],[1987,38880702],[1988,39053881],[1989,39214523],[1990,39350769],[1991,39461418],[1992,39549438],[1993,39627587],[1994,39690971],[1995,39749715],[1996,39803829],[1997,39855442],[1998,39906235],[1999,39953263],[2000,40016081],[2001,40087104],[2002,40152517],[2003,40217413],[2004,40280780],[2005,40341462],[2006,40397842],[2007,40448191],[2008,40491051]],"lifeExpectancy":[[1800,29.5],[1882,29.5],[1892,32.1],[1900,34.8],[1908,41.45],[1909,41.06],[1910,40.92],[1911,39.8],[1912,43.53],[1913,42.56],[1914,42.84],[1915,43.05],[1916,43.98],[1917,42.63],[1918,30.29],[1919,41.12],[1920,39.31],[1921,42.03],[1922,44.21],[1923,44.75],[1924,46.3],[1925,46.95],[1926,47.76],[1927,48.49],[1928,48.67],[1929,49.49],[1930,49.34],[1931,49.25],[1932,51.2],[1933,51.6],[1934,52.24],[1935,52.72],[1936,50.9],[1937,47.22],[1938,47.53],[1939,47.09],[1940,48.39],[1941,47.16],[1942,52.48],[1943,54.85],[1944,56.25],[1945,57.84],[1946,57.57],[1947,59.33],[1948,61.27],[1949,61.02],[1950,61.87],[1951,61.52],[1952,64.94],[1953,65.81],[1954,67.01],[1955,66.78],[1956,66.82],[1957,66.66],[1958,68.85],[1959,68.77],[1960,69.27],[1961,69.66],[1962,69.69],[1963,69.85],[1964,70.58],[1965,70.99],[1966,71.25],[1967,71.44],[1968,71.73],[1969,71.26],[1970,72.24],[1971,71.85],[1972,73.06],[1973,72.84],[1974,73.22],[1975,73.55],[1976,73.87],[1977,74.39],[1978,74.58],[1979,75.12],[1980,75.6],[1981,75.74],[1982,76.3],[1983,76.08],[1984,76.46],[1985,76.42],[1986,76.67],[1987,76.9],[1988,76.91],[1989,76.98],[1990,76.99],[1991,77.12],[1992,77.57],[1993,77.7],[1994,78.05],[1995,78.12],[1996,78.26],[1997,78.77],[1998,78.85],[1999,78.86],[2000,79.34],[2001,79.69],[2002,79.78],[2003,79.72],[2004,80.28],[2005,80.28],[2006,80.94],[2007,80.75],[2008,80.94],[2009,81.11]]},{"name":"Sweden","region":"Europe & Central Asia","income":[[1800,1100],[1801,1105],[1802,1159],[1803,1141],[1804,1081],[1805,1140],[1806,1152],[1807,1117],[1808,1035],[1809,1037],[1810,1131],[1811,1209],[1812,1136],[1813,1168],[1814,1192],[1815,1216],[1816,1217],[1817,1176],[1818,1170],[1819,1157],[1820,1173],[1821,1196],[1822,1209],[1823,1211],[1824,1230],[1825,1253],[1826,1230],[1827,1204],[1828,1221],[1829,1231],[1830,1214],[1831,1246],[1832,1214],[1833,1259],[1834,1273],[1835,1276],[1836,1311],[1837,1293],[1838,1270],[1839,1295],[1840,1306],[1841,1296],[1842,1232],[1843,1271],[1844,1334],[1845,1341],[1846,1306],[1847,1343],[1848,1355],[1849,1388],[1850,1423],[1851,1412],[1852,1393],[1853,1410],[1854,1434],[1855,1537],[1856,1554],[1857,1596],[1858,1576],[1859,1631],[1860,1652],[1861,1597],[1862,1574],[1863,1642],[1864,1636],[1865,1674],[1866,1636],[1867,1672],[1868,1517],[1869,1621],[1870,1866],[1871,1921],[1872,1985],[1873,2043],[1874,2105],[1875,2016],[1876,2160],[1877,2107],[1878,1992],[1879,2084],[1880,2064],[1881,2100],[1882,2015],[1883,2193],[1884,2143],[1885,2167],[1886,2178],[1887,2090],[1888,2160],[1889,2176],[1890,2224],[1891,2346],[1892,2309],[1893,2377],[1894,2386],[1895,2498],[1896,2554],[1897,2675],[1898,2788],[1899,2903],[1900,2897],[1901,2930],[1902,2916],[1903,3097],[1904,3133],[1905,3100],[1906,3330],[1907,3588],[1908,3423],[1909,3474],[1910,3563],[1911,3667],[1912,3838],[1913,3994],[1914,4097],[1915,4185],[1916,4468],[1917,4154],[1918,3988],[1919,4111],[1920,4217],[1921,3854],[1922,4206],[1923,4352],[1924,4628],[1925,4639],[1926,4858],[1927,5046],[1928,5167],[1929,5457],[1930,5517],[1931,5416],[1932,5132],[1933,5329],[1934,5685],[1935,5976],[1936,6207],[1937,6359],[1938,6483],[1939,7001],[1940,6742],[1941,6729],[1942,6648],[1943,6851],[1944,7033],[1945,7196],[1946,7905],[1947,8415],[1948,8496],[1949,8643],[1950,9073],[1951,9255],[1952,9223],[1953,9518],[1954,9947],[1955,10143],[1956,10407],[1957,10640],[1958,10944],[1959,11384],[1960,11952],[1961,12476],[1962,13138],[1963,13733],[1964,14703],[1965,15287],[1966,15782],[1967,16140],[1968,16732],[1969,17523],[1970,18303],[1971,18205],[1972,18723],[1973,19399],[1974,19745],[1975,20049],[1976,20036],[1977,19652],[1978,20000],[1979,20715],[1980,21179],[1981,21266],[1982,21382],[1983,21910],[1984,22839],[1985,23321],[1986,23615],[1987,24223],[1988,24572],[1989,24941],[1990,25295],[1991,25001],[1992,24343],[1993,23670],[1994,24141],[1995,24724],[1996,24959],[1997,25567],[1998,26445],[1999,27572],[2000,28659],[2001,28866],[2002,29472],[2003,29941],[2004,31074],[2005,31995],[2006,33200],[2007,33800],[2008,33634],[2009,32021]],"population":[[1820,2585000],[1821,2611000],[1822,2646000],[1823,2689000],[1824,2727000],[1825,2771000],[1826,2805000],[1827,2828000],[1828,2847000],[1829,2863000],[1830,2888000],[1831,2901000],[1832,2923000],[1833,2959000],[1834,2983000],[1835,3025000],[1836,3059000],[1837,3076000],[1838,3090000],[1839,3106000],[1840,3139000],[1841,3173000],[1842,3207000],[1843,3237000],[1844,3275000],[1845,3317000],[1846,3343000],[1847,3362000],[1848,3397000],[1849,3441000],[1850,3483000],[1851,3517000],[1852,3540000],[1853,3563000],[1854,3608000],[1855,3641000],[1856,3673000],[1857,3688000],[1858,3734000],[1859,3788000],[1860,3860000],[1861,3917000],[1862,3966000],[1863,4023000],[1864,4070000],[1865,4114000],[1866,4161000],[1867,4196000],[1868,4173000],[1869,4159000],[1870,4169000],[1871,4186000],[1872,4227000],[1873,4274000],[1874,4320000],[1875,4362000],[1876,4407000],[1877,4457000],[1878,4508000],[1879,4555000],[1880,4572000],[1881,4569000],[1882,4576000],[1883,4591000],[1884,4624000],[1885,4664000],[1886,4700000],[1887,4726000],[1888,4742000],[1889,4761000],[1890,4780000],[1891,4794000],[1892,4805000],[1893,4816000],[1894,4849000],[1895,4896000],[1896,4941000],[1897,4986000],[1898,5036000],[1899,5080000],[1900,5117000],[1901,5156000],[1902,5187000],[1903,5210000],[1904,5241000],[1905,5278000],[1906,5316000],[1907,5357000],[1908,5404000],[1909,5453000],[1910,5449000],[1911,5542000],[1912,5583000],[1913,5621000],[1914,5659000],[1915,5696000],[1916,5735000],[1917,5779000],[1918,5807000],[1919,5830000],[1920,5876000],[1921,5929000],[1922,5971000],[1923,5997000],[1924,6021000],[1925,6045000],[1926,6064000],[1927,6081000],[1928,6097000],[1929,6113000],[1930,6131000],[1931,6152000],[1932,6176000],[1933,6201000],[1934,6222000],[1935,6242000],[1936,6259000],[1937,6276000],[1938,6298000],[1939,6326000],[1940,6356000],[1941,6389000],[1942,6432000],[1943,6491000],[1944,6560000],[1945,6636000],[1946,6719000],[1947,6803000],[1948,6884000],[1949,6956000],[1950,7014005],[1951,7072830],[1952,7124673],[1953,7171461],[1954,7213490],[1955,7262388],[1956,7314552],[1957,7363802],[1958,7409144],[1959,7446249],[1960,7480395],[1961,7519998],[1962,7561588],[1963,7604328],[1964,7661354],[1965,7733853],[1966,7807797],[1967,7867931],[1968,7912217],[1969,7968018],[1970,8042803],[1971,8098328],[1972,8122293],[1973,8136774],[1974,8160560],[1975,8192566],[1976,8222310],[1977,8251648],[1978,8275778],[1979,8293723],[1980,8310473],[1981,8320485],[1982,8325260],[1983,8329028],[1984,8342621],[1985,8356337],[1986,8384069],[1987,8421403],[1988,8469339],[1989,8526276],[1990,8600815],[1991,8668112],[1992,8718867],[1993,8769284],[1994,8831493],[1995,8877890],[1996,8892234],[1997,8897619],[1998,8902684],[1999,8909790],[2000,8923569],[2001,8939915],[2002,8954175],[2003,8970306],[2004,8986400],[2005,9001774],[2006,9016596],[2007,9031088],[2008,9045389]],"lifeExpectancy":[[1800,32.16],[1801,36.9],[1802,40.2],[1803,40.28],[1804,39.7],[1805,41.05],[1806,36.17],[1807,38.76],[1808,30.15],[1809,26.9],[1810,31.99],[1811,34.58],[1812,35.07],[1813,36.49],[1814,38.57],[1815,40.42],[1816,41.74],[1817,40.29],[1818,40.02],[1819,36.97],[1820,40.23],[1821,38.14],[1822,42.76],[1823,45.19],[1824,44.97],[1825,45.24],[1826,43.08],[1827,42.64],[1828,37.74],[1829,36.18],[1830,40.97],[1831,38.98],[1832,40.84],[1833,42.5],[1834,38.53],[1835,47.14],[1836,45.13],[1837,39.57],[1838,39.98],[1839,39.88],[1840,43.98],[1841,45.17],[1842,42.8],[1843,42.82],[1844,44.03],[1845,45.99],[1846,42.04],[1847,40.12],[1848,45.13],[1849,44.5],[1850,44.69],[1851,43.62],[1852,41.35],[1853,39.99],[1854,44.55],[1855,43.08],[1856,42.14],[1857,34.64],[1858,42],[1859,44.27],[1860,48.47],[1861,47.12],[1862,42.55],[1863,45.38],[1864,44.77],[1865,45.4],[1866,44.73],[1867,46.18],[1868,43.23],[1869,40.96],[1870,45.01],[1871,48.98],[1872,50.08],[1873,48.68],[1874,44.28],[1875,44.61],[1876,44.82],[1877,46.05],[1878,46.73],[1879,48.92],[1880,47.62],[1881,48.5],[1882,48.59],[1883,49.05],[1884,49.17],[1885,48.94],[1886,50.6],[1887,51.46],[1888,52.35],[1889,52.3],[1890,50.48],[1891,51.09],[1892,50.61],[1893,51.36],[1894,52.1],[1895,54.16],[1896,53.49],[1897,54.14],[1898,54.69],[1899,50.95],[1900,52.27],[1901,52.92],[1902,54.76],[1903,55.09],[1904,55.4],[1905,54.55],[1906,56.7],[1907,56.98],[1908,56.42],[1909,58.42],[1910,57.8],[1911,58.03],[1912,57.79],[1913,58.68],[1914,58.26],[1915,57.2],[1916,58.22],[1917,58.9],[1918,49.81],[1919,56.57],[1920,58.81],[1921,61.03],[1922,61.05],[1923,63],[1924,62],[1925,62.56],[1926,62.79],[1927,61.59],[1928,62.27],[1929,62.32],[1930,63.19],[1931,62.69],[1932,63.95],[1933,64.83],[1934,64.98],[1935,64.86],[1936,64.61],[1937,64.63],[1938,65.57],[1939,66.4],[1940,66.74],[1941,67.03],[1942,68.97],[1943,68.72],[1944,67.74],[1945,68.34],[1946,69.51],[1947,69.47],[1948,70.73],[1949,70.8],[1950,71.14],[1951,71.37],[1952,71.86],[1953,71.9],[1954,72.36],[1955,72.6],[1956,72.66],[1957,72.49],[1958,73.14],[1959,73.37],[1960,73.04],[1961,73.5],[1962,73.37],[1963,73.56],[1964,73.73],[1965,73.88],[1966,74.13],[1967,74.16],[1968,74.03],[1969,74.15],[1970,74.7],[1971,74.62],[1972,74.72],[1973,74.88],[1974,74.99],[1975,75],[1976,75.01],[1977,75.44],[1978,75.53],[1979,75.57],[1980,75.8],[1981,76.1],[1982,76.42],[1983,76.66],[1984,76.92],[1985,76.78],[1986,77.04],[1987,77.19],[1988,77.08],[1989,77.74],[1990,77.67],[1991,77.81],[1992,78.16],[1993,78.24],[1994,78.86],[1995,78.94],[1996,79.15],[1997,79.39],[1998,79.53],[1999,79.61],[2000,79.84],[2001,79.93],[2002,80.04],[2003,80.33],[2004,80.67],[2005,80.75],[2006,80.95],[2007,81.08],[2008,80.97],[2009,81.12]]},{"name":"Switzerland","region":"Europe & Central Asia","income":[[1800,1612.48],[1801,1615.2],[1802,1617.94],[1803,1620.67],[1804,1623.42],[1805,1626.16],[1806,1628.91],[1807,1631.67],[1808,1634.43],[1809,1637.19],[1810,1639.96],[1811,1642.74],[1812,1645.52],[1813,1648.3],[1814,1651.09],[1815,1653.88],[1816,1656.68],[1817,1659.48],[1818,1662.29],[1819,1665.1],[1820,1667.92],[1821,1685.32],[1822,1702.91],[1823,1720.68],[1824,1738.64],[1825,1756.78],[1826,1775.11],[1827,1793.63],[1828,1812.35],[1829,1831.26],[1830,1850.37],[1831,1869.68],[1832,1889.19],[1833,1908.9],[1834,1928.82],[1835,1948.95],[1836,1969.29],[1837,1989.84],[1838,2010.6],[1839,2031.58],[1840,2052.78],[1841,2074.21],[1842,2095.85],[1843,2117.72],[1844,2139.82],[1845,2162.15],[1846,2184.71],[1847,2207.51],[1848,2230.54],[1849,2253.82],[1850,2277.34],[1851,2317.03],[1852,2456.55],[1853,2365.44],[1854,2089.19],[1855,2426.6],[1856,2409.29],[1857,2600.59],[1858,3263.3],[1859,3085.16],[1860,2669.3],[1861,2843.62],[1862,3043.76],[1863,3025.86],[1864,2848.95],[1865,3074.86],[1866,3029.94],[1867,2649.21],[1868,3110.78],[1869,3383.55],[1870,3216.2],[1871,3404.86],[1872,3224.55],[1873,3293.34],[1874,3666.89],[1875,4047.59],[1876,3929.51],[1877,3523.54],[1878,3567.13],[1879,3534.6],[1880,3748.24],[1881,3795.81],[1882,3671.4],[1883,3666.4],[1884,4065.55],[1885,4368.15],[1886,4522.68],[1887,4485.18],[1888,4574.38],[1889,4561.95],[1890,4867.95],[1891,4569.92],[1892,4906.55],[1893,5039.99],[1894,4864.53],[1895,5336.39],[1896,5410.17],[1897,5622.86],[1898,5656.7],[1899,5867.33],[1900,5864.6],[1901,5729.43],[1902,5787.75],[1903,5603.22],[1904,5827.02],[1905,5987],[1906,6434.66],[1907,6414.69],[1908,6239.63],[1909,6486.51],[1910,6626.79],[1911,6697.87],[1912,6690.97],[1913,6526.72],[1914,6476.75],[1915,6563.87],[1916,6543.2],[1917,5820.1],[1918,5811.42],[1919,6211.34],[1920,6600.64],[1921,6438.49],[1922,7065.58],[1923,7457.2],[1924,7709.48],[1925,8243.02],[1926,8607.39],[1927,9014.16],[1928,9441.41],[1929,9687.66],[1930,9556.05],[1931,9092.53],[1932,8736.36],[1933,9128.37],[1934,9106.96],[1935,9037.66],[1936,9039.73],[1937,9442.14],[1938,9776.07],[1939,9731.54],[1940,9786.93],[1941,9657.3],[1942,9343.95],[1943,9182.31],[1944,9315.64],[1945,11860.83],[1946,12516.48],[1947,13847.18],[1948,13947.1],[1949,13397.73],[1950,13867.61],[1951,14816.9],[1952,14734.23],[1953,15055.83],[1954,15739.4],[1955,16626.49],[1956,17501.93],[1957,17909.49],[1958,17284.27],[1959,18161.49],[1960,19059.01],[1961,20041.22],[1962,20431.09],[1963,20977.27],[1964,21712.09],[1965,22190.77],[1966,22533.04],[1967,22966.14],[1968,23522.13],[1969,24527.55],[1970,25862.82],[1971,26593.27],[1972,27195.11],[1973,27851.76],[1974,28174.33],[1975,26353.03],[1976,26270.87],[1977,26982.29],[1978,27023.44],[1979,27617.12],[1980,28732.37],[1981,29003.27],[1982,28397.72],[1983,28396.89],[1984,29128.19],[1985,29967.6],[1986,30273.42],[1987,30281.7],[1988,30971.59],[1989,32031.33],[1990,32875.78],[1991,32207.74],[1992,31871.53],[1993,31515.65],[1994,31599.62],[1995,31530.77],[1996,31589.72],[1997,32135.32],[1998,33039.5],[1999,33349.65],[2000,34386.9],[2001,34569.38],[2002,34480.96],[2003,34183.28],[2004,34864.09],[2005,35520],[2006,36745.13],[2007,38007.34],[2008,38623.13],[2009,38003.92]],"population":[[1820,1986000],[1821,1998000],[1822,2008000],[1823,2020000],[1824,2031000],[1825,2042000],[1826,2054000],[1827,2065000],[1828,2077000],[1829,2088000],[1830,2100000],[1831,2112000],[1832,2123000],[1833,2135000],[1834,2147000],[1835,2159000],[1836,2171000],[1837,2183000],[1838,2195000],[1839,2208000],[1840,2220000],[1841,2235000],[1842,2251000],[1843,2266000],[1844,2282000],[1845,2298000],[1846,2314000],[1847,2330000],[1848,2346000],[1849,2363000],[1850,2379000],[1851,2399000],[1852,2406000],[1853,2412000],[1854,2427000],[1855,2442000],[1856,2457000],[1857,2471000],[1858,2484000],[1859,2497000],[1860,2510000],[1861,2524000],[1862,2538000],[1863,2552000],[1864,2566000],[1865,2579000],[1866,2593000],[1867,2607000],[1868,2623000],[1869,2639000],[1870,2655000],[1871,2680000],[1872,2697000],[1873,2715000],[1874,2733000],[1875,2750000],[1876,2768000],[1877,2786000],[1878,2803000],[1879,2821000],[1880,2839000],[1881,2853000],[1882,2863000],[1883,2874000],[1884,2885000],[1885,2896000],[1886,2907000],[1887,2918000],[1888,2929000],[1889,2940000],[1890,2951000],[1891,2965000],[1892,3002000],[1893,3040000],[1894,3077000],[1895,3114000],[1896,3151000],[1897,3188000],[1898,3226000],[1899,3263000],[1900,3300000],[1901,3341000],[1902,3384000],[1903,3428000],[1904,3472000],[1905,3461000],[1906,3560000],[1907,3604000],[1908,3647000],[1909,3691000],[1910,3735000],[1911,3776000],[1912,3819000],[1913,3864000],[1914,3897000],[1915,3883000],[1916,3883000],[1917,3888000],[1918,3880000],[1919,3869000],[1920,3877000],[1921,3876000],[1922,3874000],[1923,3883000],[1924,3896000],[1925,3910000],[1926,3932000],[1927,3956000],[1928,3988000],[1929,4022000],[1930,4051000],[1931,4080000],[1932,4102000],[1933,4122000],[1934,4140000],[1935,4155000],[1936,4168000],[1937,4180000],[1938,4192000],[1939,4206000],[1940,4226000],[1941,4254000],[1942,4286000],[1943,4323000],[1944,4364000],[1945,4412000],[1946,4467000],[1947,4524000],[1948,4582000],[1949,4640000],[1950,4694000],[1951,4749000],[1952,4815000],[1953,4878000],[1954,4929000],[1955,4980000],[1956,5045000],[1957,5126000],[1958,5199000],[1959,5259000],[1960,5362000],[1961,5512000],[1962,5666000],[1963,5789000],[1964,5887000],[1965,5943000],[1966,5996000],[1967,6063000],[1968,6132000],[1969,6212000],[1970,6267000],[1971,6343293],[1972,6401400],[1973,6441100],[1974,6460000],[1975,6403500],[1976,6333313],[1977,6316424],[1978,6332568],[1979,6350840],[1980,6385229],[1981,6425450],[1982,6468126],[1983,6501073],[1984,6529684],[1985,6563770],[1986,6603192],[1987,6649942],[1988,6704112],[1989,6763653],[1990,6836626],[1991,6920562],[1992,6995447],[1993,7058211],[1994,7114530],[1995,7157106],[1996,7181024],[1997,7193761],[1998,7207995],[1999,7232809],[2000,7266920],[2001,7311237],[2002,7361757],[2003,7408319],[2004,7450867],[2005,7489370],[2006,7523934],[2007,7554661],[2008,7581520]],"lifeExpectancy":[[1800,38],[1875,38],[1876,40.1],[1877,40.01],[1878,40.47],[1879,41.81],[1880,42.41],[1881,41.87],[1882,42.98],[1883,44.94],[1884,45],[1885,43.83],[1886,44.68],[1887,45.44],[1888,45.97],[1889,45.14],[1890,44.95],[1891,44.71],[1892,47.23],[1893,46.07],[1894,45.79],[1895,46.84],[1896,48.88],[1897,49.1],[1898,48.2],[1899,49.29],[1900,47.48],[1901,48.94],[1902,50.41],[1903,50.03],[1904,49.16],[1905,49.67],[1906,50.72],[1907,51.19],[1908,52.26],[1909,51.61],[1910,52.91],[1911,51.72],[1912,54.42],[1913,54.21],[1914,55.13],[1915,55.95],[1916,56.59],[1917,55.81],[1918,46.3],[1919,54.97],[1920,54.38],[1921,57.87],[1922,58.5],[1923,60.04],[1924,59.49],[1925,59.95],[1926,60.64],[1927,60.1],[1928,60.47],[1929,60.17],[1930,61.43],[1931,61.24],[1932,61.23],[1933,62.41],[1934,62.89],[1935,62.13],[1936,63.18],[1937,63.51],[1938,63.85],[1939,64.01],[1940,63.58],[1941,64.98],[1942,65.65],[1943,65.84],[1944,64.88],[1945,65.42],[1946,66.07],[1947,66.26],[1948,67.34],[1949,67.97],[1950,68.94],[1951,68.71],[1952,69.62],[1953,69.53],[1954,70],[1955,70.08],[1956,70.21],[1957,70.56],[1958,71.3],[1959,71.46],[1960,71.44],[1961,71.76],[1962,71.32],[1963,71.31],[1964,72.2],[1965,72.33],[1966,72.47],[1967,72.77],[1968,72.72],[1969,72.73],[1970,73.14],[1971,73.26],[1972,73.78],[1973,74.08],[1974,74.43],[1975,74.82],[1976,74.94],[1977,75.39],[1978,75.34],[1979,75.64],[1980,75.64],[1981,75.87],[1982,76.21],[1983,76.22],[1984,76.82],[1985,76.94],[1986,77.11],[1987,77.41],[1988,77.43],[1989,77.62],[1990,77.44],[1991,77.72],[1992,78.02],[1993,78.31],[1994,78.6],[1995,78.68],[1996,79.17],[1997,79.37],[1998,79.62],[1999,79.88],[2000,79.99],[2001,80.41],[2002,80.62],[2003,80.72],[2004,81.28],[2005,81.45],[2006,81.75],[2007,81.94],[2008,81.9],[2009,82.06]]},{"name":"Tajikistan","region":"Europe & Central Asia","income":[[1800,428.48],[1820,437.5],[1913,975.22],[1950,1910.98],[1973,4643.65],[1990,3377.86],[1991,3006.97],[1992,1992.23],[1993,1643.5],[1994,1273.6],[1995,1097.88],[1996,899.28],[1997,898.48],[1998,928.55],[1999,944.1],[2000,1001.5],[2001,1080.51],[2002,1158.35],[2003,1249.69],[2004,1353.05],[2005,1413],[2006,1502.86],[2007,1610.49],[2008,1727.33],[2009,1775.38]],"population":[[1800,466629],[1820,466629],[1950,1530047],[1951,1584833],[1952,1640949],[1953,1684446],[1954,1729862],[1955,1780850],[1956,1836703],[1957,1898639],[1958,1953527],[1959,2009483],[1960,2080556],[1961,2163433],[1962,2253472],[1963,2339558],[1964,2424081],[1965,2510619],[1966,2592754],[1967,2672279],[1968,2759277],[1969,2850066],[1970,2938516],[1971,3039443],[1972,3145141],[1973,3242778],[1974,3344985],[1975,3448869],[1976,3553782],[1977,3659375],[1978,3760973],[1979,3862932],[1980,3969126],[1981,4078516],[1982,4193811],[1983,4315817],[1984,4445727],[1985,4587499],[1986,4738036],[1987,4891199],[1988,5036494],[1989,5183469],[1990,5332472],[1991,5481045],[1992,5600694],[1993,5682454],[1994,5770963],[1995,5864473],[1996,5963936],[1997,6070759],[1998,6185515],[1999,6308673],[2000,6440732],[2001,6578681],[2002,6719567],[2003,6863752],[2004,7011556],[2005,7163506],[2006,7320815],[2007,7484274],[2008,7653394]],"lifeExpectancy":[[1950,52.31],[1951,52.52],[1952,52.94],[1953,53.35],[1954,53.77],[1955,54.18],[1956,54.59],[1957,55],[1958,55.4],[1959,55.81],[1960,56.23],[1961,56.64],[1962,57.06],[1963,57.48],[1964,57.9],[1965,58.31],[1966,58.72],[1967,59.11],[1968,59.48],[1969,59.83],[1970,60.16],[1971,60.46],[1972,60.73],[1973,60.98],[1974,61.21],[1975,61.43],[1976,61.63],[1977,61.82],[1978,62],[1979,62.18],[1980,62.36],[1981,62.56],[1982,62.78],[1983,62.99],[1984,63.2],[1985,63.37],[1986,63.46],[1987,63.45],[1988,63.34],[1989,63.15],[1990,62.9],[1991,62.64],[1992,62.42],[1993,62.28],[1994,62.24],[1995,62.3],[1996,62.46],[1997,62.68],[1998,62.94],[1999,63.22],[2000,63.54],[2001,63.89],[2002,64.28],[2003,64.71],[2004,65.16],[2005,65.61],[2006,66.04],[2007,66.43],[2008,66.78],[2009,67.07]]},{"name":"Turkey","region":"Europe & Central Asia","income":[[1800,869.92],[1820,901.21],[1821,905.71],[1822,910.24],[1823,914.79],[1824,919.36],[1825,923.95],[1826,928.56],[1827,933.2],[1828,937.86],[1829,942.55],[1830,947.26],[1831,951.99],[1832,956.75],[1833,961.52],[1834,966.33],[1835,971.16],[1836,976.01],[1837,980.88],[1838,985.78],[1839,990.71],[1840,995.66],[1841,1000.63],[1842,1005.63],[1843,1010.65],[1844,1015.7],[1845,1020.77],[1846,1025.87],[1847,1031],[1848,1036.15],[1849,1041.32],[1850,1046.53],[1851,1051.75],[1852,1057.01],[1853,1062.29],[1854,1067.59],[1855,1072.93],[1856,1078.29],[1857,1083.67],[1858,1089.09],[1859,1094.53],[1860,1100],[1861,1105.49],[1862,1111.01],[1863,1116.56],[1864,1122.14],[1865,1127.75],[1866,1133.38],[1867,1139.04],[1868,1144.73],[1869,1150.45],[1870,1156.2],[1871,1166.61],[1872,1177.11],[1873,1165.78],[1874,1154.56],[1875,1143.44],[1876,1132.44],[1877,1121.53],[1878,1110.74],[1879,1100.04],[1880,1109.95],[1881,1124.38],[1882,1139],[1883,1153.81],[1884,1168.81],[1885,1184.01],[1886,1199.41],[1887,1215],[1888,1230.8],[1889,1246.8],[1890,1263.01],[1891,1279.44],[1892,1296.07],[1893,1312.92],[1894,1329.99],[1895,1347.29],[1896,1364.81],[1897,1382.55],[1898,1400.53],[1899,1418.74],[1900,1437.19],[1901,1455.87],[1902,1474.8],[1903,1493.98],[1904,1513.4],[1905,1533.08],[1906,1553.01],[1907,1573.21],[1908,1593.66],[1909,1614.38],[1910,1635.38],[1911,1656.64],[1912,1678.18],[1913,1700],[1914,1606.12],[1915,1517.42],[1916,1433.62],[1917,1354.45],[1918,1279.65],[1919,1208.98],[1920,1142.22],[1921,1079.14],[1922,1019.54],[1923,963.24],[1924,1140.49],[1925,1257.11],[1926,1444.64],[1927,1299.53],[1928,1412.59],[1929,1606.65],[1930,1648.38],[1931,1712.44],[1932,1578.24],[1933,1751.5],[1934,1757.67],[1935,1759.11],[1936,2050.89],[1937,2075.18],[1938,2211.33],[1939,2318.35],[1940,2133.46],[1941,1913.46],[1942,1968.48],[1943,1761.75],[1944,1662.85],[1945,1418.05],[1946,1783.28],[1947,1833.7],[1948,2026.87],[1949,1873.5],[1950,1994.79],[1951,2185.5],[1952,2376.31],[1953,2563.65],[1954,2414.81],[1955,2527.02],[1956,2523.46],[1957,2630.53],[1958,2654.56],[1959,2680.81],[1960,2666.17],[1961,2625.62],[1962,2705.56],[1963,2880.23],[1964,2919.57],[1965,2918.4],[1966,3175.94],[1967,3234.14],[1968,3363.34],[1969,3449.46],[1970,3524.41],[1971,3744.17],[1972,3879.15],[1973,3938.36],[1974,4137.58],[1975,4381],[1976,4636.35],[1977,4714.84],[1978,4730.4],[1979,4577.55],[1980,4436.96],[1981,4502.89],[1982,4601.84],[1983,4645.47],[1984,4784.95],[1985,4901.1],[1986,5113.39],[1987,5424.52],[1988,5502.7],[1989,5438.47],[1990,5807.69],[1991,5733.32],[1992,5946.29],[1993,6290.02],[1994,5826.6],[1995,6125],[1996,6432.18],[1997,6791.42],[1998,6877],[1999,6442.52],[2000,6803.29],[2001,6192.75],[2002,6577.7],[2003,6856.14],[2004,7357.12],[2005,7786],[2006,8294.63],[2007,8585.97],[2008,8547.69],[2009,8040.78]],"population":[[1820,10074000],[1870,11793000],[1913,15000000],[1923,13877000],[1924,13968000],[1925,14059000],[1926,14151000],[1927,14250000],[1928,14476000],[1929,14705000],[1930,14928000],[1931,15174000],[1932,15414000],[1933,15658000],[1934,15906000],[1935,16158000],[1936,16434000],[1937,16725000],[1938,17016000],[1939,17517000],[1940,17821000],[1941,18011000],[1942,18203000],[1943,18396000],[1944,18592000],[1945,18790000],[1946,19235000],[1947,19690000],[1948,20156000],[1949,20634000],[1950,21121639],[1951,21669334],[1952,22235677],[1953,22830516],[1954,23463817],[1955,24144571],[1956,24877395],[1957,25670939],[1958,26505694],[1959,27355811],[1960,28217122],[1961,29029976],[1962,29788695],[1963,30509221],[1964,31227361],[1965,31950718],[1966,32677758],[1967,33411317],[1968,34164759],[1969,34952315],[1970,35758382],[1971,36579964],[1972,37492953],[1973,38503442],[1974,39512945],[1975,40529798],[1976,41485146],[1977,42404033],[1978,43316697],[1979,44222576],[1980,45120802],[1981,46222187],[1982,47328791],[1983,48440170],[1984,49554400],[1985,50669003],[1986,51780211],[1987,52881328],[1988,53966237],[1989,55031033],[1990,56084632],[1991,57135435],[1992,58179144],[1993,59212510],[1994,60220670],[1995,61188984],[1996,62127894],[1997,63047647],[1998,63945635],[1999,64819580],[2000,65666677],[2001,66493970],[2002,67308928],[2003,68109469],[2004,68893918],[2005,69660559],[2006,70413958],[2007,71158647],[2008,71892807]],"lifeExpectancy":[[1800,35],[1930,35],[1937,35.43],[1942,31.34],[1947,38.1],[1950,41.73],[1951,42.2],[1952,43.12],[1953,44.05],[1954,44.97],[1955,45.89],[1956,46.81],[1957,47.71],[1958,48.6],[1959,49.45],[1960,50.26],[1961,51.02],[1962,51.7],[1963,52.3],[1964,52.84],[1965,53.32],[1966,53.77],[1967,54.22],[1968,54.67],[1969,55.15],[1970,55.66],[1971,56.2],[1972,56.75],[1973,57.29],[1974,57.83],[1975,58.34],[1976,58.81],[1977,59.24],[1978,59.63],[1979,59.98],[1980,60.3],[1981,60.6],[1982,60.91],[1983,61.23],[1984,61.59],[1985,61.98],[1986,62.43],[1987,62.93],[1988,63.46],[1989,64.03],[1990,64.63],[1991,65.24],[1992,65.85],[1993,66.45],[1994,67.03],[1995,67.59],[1996,68.11],[1997,68.62],[1998,69.1],[1999,69.55],[2000,69.97],[2001,70.34],[2002,70.67],[2003,70.95],[2004,71.19],[2005,71.4],[2006,71.57],[2007,71.74],[2008,71.9],[2009,72.06]]},{"name":"Turkmenistan","region":"Europe & Central Asia","income":[[1800,513.35],[1820,524.16],[1913,1168.39],[1950,2289.5],[1973,6829.32],[1990,5132.08],[1991,4769.85],[1992,3961.89],[1993,3934.1],[1994,3184.62],[1995,2895.41],[1996,3028.61],[1997,2631.32],[1998,2764.27],[1999,3159.59],[2000,3289.74],[2001,3361.4],[2002,3359.35],[2003,3522.74],[2004,3967.58],[2005,4247],[2006,4656.65],[2007,5114.98],[2008,5563.05],[2009,5702.66]],"population":[[1800,367215],[1820,367215],[1950,1204075],[1951,1226498],[1952,1252749],[1953,1282640],[1954,1313402],[1955,1347774],[1956,1381525],[1957,1425659],[1958,1478072],[1959,1530083],[1960,1584820],[1961,1644416],[1962,1704534],[1963,1765175],[1964,1825383],[1965,1882148],[1966,1935923],[1967,1994131],[1968,2054487],[1969,2116408],[1970,2181272],[1971,2246710],[1972,2313102],[1973,2379578],[1974,2450654],[1975,2523906],[1976,2594288],[1977,2663744],[1978,2733933],[1979,2804142],[1980,2875133],[1981,2946676],[1982,3018436],[1983,3091431],[1984,3164611],[1985,3240472],[1986,3323673],[1987,3410704],[1988,3492186],[1989,3573704],[1990,3667588],[1991,3760644],[1992,3848424],[1993,3933744],[1994,4018832],[1995,4101998],[1996,4184336],[1997,4267070],[1998,4350224],[1999,4433925],[2000,4518268],[2001,4603244],[2002,4688963],[2003,4775544],[2004,4863169],[2005,4952081],[2006,5042920],[2007,5136262],[2008,5232077]],"lifeExpectancy":[[1950,50.5],[1951,50.71],[1952,51.13],[1953,51.55],[1954,51.97],[1955,52.39],[1956,52.81],[1957,53.22],[1958,53.63],[1959,54.05],[1960,54.47],[1961,54.89],[1962,55.31],[1963,55.74],[1964,56.16],[1965,56.58],[1966,56.99],[1967,57.38],[1968,57.76],[1969,58.11],[1970,58.43],[1971,58.73],[1972,58.99],[1973,59.23],[1974,59.45],[1975,59.66],[1976,59.89],[1977,60.12],[1978,60.38],[1979,60.66],[1980,60.96],[1981,61.27],[1982,61.57],[1983,61.87],[1984,62.14],[1985,62.37],[1986,62.55],[1987,62.67],[1988,62.73],[1989,62.76],[1990,62.76],[1991,62.75],[1992,62.78],[1993,62.83],[1994,62.94],[1995,63.08],[1996,63.25],[1997,63.44],[1998,63.61],[1999,63.78],[2000,63.92],[2001,64.03],[2002,64.13],[2003,64.21],[2004,64.28],[2005,64.37],[2006,64.49],[2007,64.63],[2008,64.83],[2009,65.06]]},{"name":"Ukraine","region":"Europe & Central Asia","income":[[1800,807.51],[1820,824.52],[1913,1837.91],[1950,3601.45],[1973,6636.82],[1990,8123.2],[1991,7400.99],[1992,6650.45],[1993,5704.11],[1994,4419.12],[1995,3909.54],[1996,3548.69],[1997,3472.48],[1998,3435.91],[1999,3460.32],[2000,3700.35],[2001,4082.19],[2002,4334.82],[2003,4781.15],[2004,5400.28],[2005,5583],[2006,6027.07],[2007,6541.78],[2008,6716.38],[2009,5730.86]],"population":[[1800,11215490],[1820,11215490],[1950,36774854],[1951,37435785],[1952,38006180],[1953,38541349],[1954,38993798],[1955,39368099],[1956,39940180],[1957,40655779],[1958,41359132],[1959,42006030],[1960,42644035],[1961,43195765],[1962,43697245],[1963,44255938],[1964,44785626],[1965,45234869],[1966,45673640],[1967,46111262],[1968,46510301],[1969,46871405],[1970,47235697],[1971,47637239],[1972,48026627],[1973,48367002],[1974,48676939],[1975,48973428],[1976,49233524],[1977,49453675],[1978,49642987],[1979,49835012],[1980,50046649],[1981,50235677],[1982,50397455],[1983,50573066],[1984,50769375],[1985,50944248],[1986,51095072],[1987,51218101],[1988,51422963],[1989,51501478],[1990,51622275],[1991,51730355],[1992,51869109],[1993,51887112],[1994,51637611],[1995,51247259],[1996,50812520],[1997,50369926],[1998,49938798],[1999,49487245],[2000,49007559],[2001,48510505],[2002,48058877],[2003,47668303],[2004,47309706],[2005,46996765],[2006,46710816],[2007,46435909],[2008,46170273]],"lifeExpectancy":[[1800,36.6],[1900,36.6],[1920,36.6],[1926,46.95],[1939,50],[1940,49.8],[1941,24.7],[1942,19.4],[1943,18.2],[1944,28.7],[1945,35.3],[1946,55.2],[1947,45.1],[1948,57.8],[1949,60.6],[1950,64.28],[1951,64.72],[1952,65.58],[1953,66.39],[1954,67.14],[1955,67.83],[1956,68.47],[1957,69.06],[1958,69.58],[1959,69.43],[1960,71.06],[1961,71.34],[1962,70.76],[1963,71.39],[1964,72.19],[1965,71.63],[1966,71.9],[1967,71.5],[1968,71.59],[1969,70.97],[1970,70.87],[1971,71.1],[1972,70.86],[1973,71.05],[1974,70.94],[1975,70.28],[1976,70.34],[1977,70.02],[1978,69.98],[1979,69.72],[1980,69.7],[1981,69.74],[1982,69.9],[1983,69.88],[1984,69.57],[1985,69.88],[1986,71.24],[1987,71.04],[1988,70.93],[1989,70.88],[1990,70.46],[1991,69.64],[1992,69],[1993,68.31],[1994,67.7],[1995,66.79],[1996,67.11],[1997,67.69],[1998,68.57],[1999,68.15],[2000,67.79],[2001,67.93],[2002,67.81],[2003,67.87],[2004,67.73],[2005,67.31],[2006,67.96],[2007,68.17],[2008,68.31],[2009,68.45]]},{"name":"United Kingdom","region":"Europe & Central Asia","income":[[1800,2716.87],[1801,2736.98],[1802,2740.53],[1803,2744.1],[1804,2747.66],[1805,2751.24],[1806,2754.81],[1807,2758.39],[1808,2761.98],[1809,2765.57],[1810,2769.16],[1811,2772.76],[1812,2776.37],[1813,2779.98],[1814,2783.59],[1815,2787.21],[1816,2790.83],[1817,2794.46],[1818,2798.1],[1819,2801.73],[1820,2805.38],[1821,2809.02],[1822,2812.67],[1823,2816.33],[1824,2819.99],[1825,2823.66],[1826,2827.33],[1827,2831],[1828,2834.68],[1829,2838.37],[1830,2842.06],[1831,2931.7],[1832,2862.16],[1833,2851.91],[1834,2926.94],[1835,3041.81],[1836,3111.03],[1837,3028.56],[1838,3150.67],[1839,3255.28],[1840,3119.72],[1841,3013.78],[1842,2908.86],[1843,2924.4],[1844,3060.08],[1845,3181.7],[1846,3351.5],[1847,3382.2],[1848,3460.12],[1849,3541.79],[1850,3523.8],[1851,3692.63],[1852,3723.87],[1853,3822.77],[1854,3879.19],[1855,3818.21],[1856,4039.63],[1857,4065.93],[1858,4029.36],[1859,4084.87],[1860,4128.82],[1861,4192.26],[1862,4171.61],[1863,4157.38],[1864,4221.29],[1865,4300.03],[1866,4316.17],[1867,4222.72],[1868,4304.55],[1869,4280.86],[1870,4490.23],[1871,4689.29],[1872,4671.41],[1873,4735.49],[1874,4766.1],[1875,4832.56],[1876,4827.62],[1877,4820.64],[1878,4788.69],[1879,4718.33],[1880,4893.99],[1881,5022.22],[1882,5127.23],[1883,5127.61],[1884,5097.13],[1885,5029.61],[1886,5066.69],[1887,5225.9],[1888,5417.24],[1889,5663.07],[1890,5641.99],[1891,5594.67],[1892,5413.33],[1893,5363.26],[1894,5670.28],[1895,5795.27],[1896,5979.45],[1897,6000.48],[1898,6231.6],[1899,6427.55],[1900,6321.8],[1901,6263.51],[1902,6368.9],[1903,6248.33],[1904,6231.91],[1905,6362.14],[1906,6517.81],[1907,6584.65],[1908,6261.81],[1909,6348.13],[1910,6489.23],[1911,6627.33],[1912,6701.7],[1913,6925.2],[1914,6933.69],[1915,7442.73],[1916,7578],[1917,7629.56],[1918,7683.46],[1919,6854.63],[1920,6400.75],[1921,6247.68],[1922,6526.04],[1923,6698.84],[1924,6925.75],[1925,7240.38],[1926,6947.11],[1927,7480.27],[1928,7539.42],[1929,7745.39],[1930,7657.49],[1931,7231.83],[1932,7245.67],[1933,7427.52],[1934,7892.03],[1935,8161.54],[1936,8493.92],[1937,8750.7],[1938,8819.43],[1939,8813.73],[1940,9649.17],[1941,10529.74],[1942,10750.98],[1943,10898.52],[1944,10422.38],[1945,9930.83],[1946,9493.42],[1947,9295.07],[1948,9493.84],[1949,9789.47],[1950,9766.5],[1951,10025.45],[1952,9979.51],[1953,10338.51],[1954,10723.3],[1955,11073.65],[1956,11158.95],[1957,11283.18],[1958,11211.11],[1959,11596.73],[1960,12167.33],[1961,12464.91],[1962,12477.18],[1963,12876.6],[1964,13465.99],[1965,13724.35],[1966,13912.63],[1967,14142.85],[1968,14651.01],[1969,14850.49],[1970,15154.18],[1971,15399.08],[1972,15895.12],[1973,16924.43],[1974,16690.27],[1975,16673.64],[1976,17050.63],[1977,17428.75],[1978,18053.95],[1979,18531.69],[1980,18199.83],[1981,17940.78],[1982,18232.42],[1983,18865.5],[1984,19309.67],[1985,19935.24],[1986,20747.69],[1987,21664.79],[1988,22673.28],[1989,23100.74],[1990,23123.53],[1991,22739.73],[1992,22705.09],[1993,23170.28],[1994,24118.67],[1995,24716.01],[1996,25328.77],[1997,26074.53],[1998,26773.33],[1999,27467.51],[2000,28644.71],[2001,28978.41],[2002,29479],[2003,30204.15],[2004,31097.52],[2005,31580],[2006,32293.8],[2007,32909.5],[2008,32875.34],[2009,31042.47]],"population":[[1820,16186397],[1821,16427955],[1822,16661282],[1823,16897898],[1824,17139513],[1825,17381418],[1826,17629610],[1827,17858803],[1828,18093284],[1829,18329053],[1830,18569823],[1831,18811881],[1832,19028016],[1833,19246151],[1834,19468285],[1835,19691420],[1836,19918844],[1837,20136267],[1838,20354979],[1839,20578690],[1840,20804402],[1841,21027114],[1842,21284460],[1843,21504941],[1844,21751903],[1845,21994095],[1846,22231076],[1847,22279863],[1848,22246880],[1849,22266109],[1850,22287069],[1851,22310067],[1852,22567009],[1853,22837200],[1854,23117738],[1855,23417123],[1856,23728007],[1857,23974430],[1858,24230353],[1859,24488987],[1860,24746160],[1861,25009641],[1862,25291179],[1863,25561448],[1864,25828236],[1865,26107967],[1866,26385197],[1867,26667813],[1868,26955755],[1869,27249851],[1870,27544197],[1871,27844139],[1872,28050928],[1873,28385947],[1874,28730581],[1875,29082812],[1876,29444523],[1877,29814831],[1878,30173677],[1879,30557062],[1880,30920888],[1881,31273446],[1882,31576465],[1883,31875253],[1884,32184118],[1885,32500733],[1886,32822214],[1887,33142079],[1888,33464925],[1889,33793233],[1890,34127982],[1891,34472021],[1892,34836751],[1893,35211963],[1894,35593770],[1895,35976405],[1896,36367212],[1897,36763751],[1898,37166289],[1899,37569674],[1900,37975154],[1901,38373808],[1902,38737346],[1903,39102443],[1904,39474558],[1905,39850962],[1906,40231673],[1907,40614789],[1908,41003923],[1909,41398500],[1910,41795923],[1911,42150769],[1912,42318019],[1913,42556673],[1914,42965211],[1915,43296057],[1916,43473615],[1917,43573615],[1918,43529634],[1919,43437404],[1920,43718000],[1921,44072000],[1922,44372000],[1923,44596000],[1924,44915000],[1925,45059000],[1926,45232000],[1927,45389000],[1928,45578000],[1929,45672000],[1930,45866000],[1931,46074000],[1932,46335000],[1933,46520000],[1934,46666000],[1935,46868000],[1936,47081000],[1937,47289000],[1938,47494000],[1939,47991000],[1940,48226000],[1941,48216000],[1942,48400000],[1943,48789000],[1944,49016000],[1945,49182000],[1946,49217000],[1947,49519000],[1948,50014000],[1949,50312000],[1950,50127000],[1951,50290000],[1952,50430000],[1953,50593000],[1954,50765000],[1955,50946000],[1956,51184000],[1957,51430000],[1958,51652000],[1959,51956000],[1960,52372000],[1961,52807000],[1962,53292000],[1963,53625000],[1964,53991000],[1965,54350000],[1966,54643000],[1967,54959000],[1968,55214000],[1969,55461000],[1970,55632000],[1971,55907000],[1972,56079000],[1973,56210000],[1974,56224000],[1975,56215000],[1976,56206000],[1977,56179000],[1978,56167000],[1979,56228000],[1980,56314000],[1981,56382597],[1982,56339704],[1983,56382623],[1984,56462228],[1985,56620240],[1986,56796260],[1987,56981620],[1988,57159603],[1989,57324472],[1990,57493307],[1991,57665646],[1992,57866349],[1993,58026920],[1994,58212518],[1995,58426014],[1996,58618663],[1997,58808266],[1998,59035652],[1999,59293320],[2000,59522468],[2001,59723243],[2002,59912431],[2003,60094648],[2004,60270708],[2005,60441457],[2006,60609153],[2007,60776238],[2008,60943912]],"lifeExpectancy":[[1800,40.02],[1803,40.02],[1808,40.58],[1813,41.25],[1818,40.84],[1823,40.47],[1828,41.43],[1833,40.89],[1838,40.56],[1841,41.7],[1842,41.35],[1843,41.86],[1844,41.55],[1845,42.56],[1846,39.96],[1847,38.33],[1848,39.5],[1849,37.38],[1850,42.8],[1851,41.42],[1852,40.93],[1853,40.56],[1854,39.34],[1855,41.03],[1856,43.25],[1857,41.88],[1858,40.04],[1859,40.84],[1860,43.01],[1861,42.38],[1862,42.52],[1863,40.4],[1864,39.97],[1865,40.65],[1866,40.41],[1867,42.62],[1868,42],[1869,41.67],[1870,40.95],[1871,41.31],[1872,42.9],[1873,43.78],[1874,42.13],[1875,41.85],[1876,43.69],[1877,44.7],[1878,43.01],[1879,44.27],[1880,43.78],[1881,46.11],[1882,44.87],[1883,45.09],[1884,44.79],[1885,45.76],[1886,45.33],[1887,45.65],[1888,46.81],[1889,46.34],[1890,44.75],[1891,44.29],[1892,45.51],[1893,44.87],[1894,48.34],[1895,45.73],[1896,47.41],[1897,47.23],[1898,46.98],[1899,46.13],[1900,46.32],[1901,47.91],[1902,49.08],[1903,50.43],[1904,49.11],[1905,50.86],[1906,50.58],[1907,51.44],[1908,51.84],[1909,52.52],[1910,53.99],[1911,51.54],[1912,54.55],[1913,53.83],[1914,51.99],[1915,48.2],[1916,47.73],[1917,45.57],[1918,40.43],[1919,54.12],[1920,56.6],[1921,58.35],[1922,57.13],[1923,59.4],[1924,58.17],[1925,58.51],[1926,59.66],[1927,59.04],[1928,59.99],[1929,57.71],[1930,60.89],[1931,60.11],[1932,60.63],[1933,60.67],[1934,61.4],[1935,62.05],[1936,61.85],[1937,61.88],[1938,63.3],[1939,63.69],[1940,60.97],[1941,61.37],[1942,63.99],[1943,64.01],[1944,64.85],[1945,65.85],[1946,66.47],[1947,66.44],[1948,68.5],[1949,68.19],[1950,68.7],[1951,68.3],[1952,69.6],[1953,69.87],[1954,70.24],[1955,70.21],[1956,70.48],[1957,70.6],[1958,70.78],[1959,70.88],[1960,71.1],[1961,70.85],[1962,70.92],[1963,70.83],[1964,71.62],[1965,71.61],[1966,71.53],[1967,72.16],[1968,71.79],[1969,71.75],[1970,72],[1971,72.32],[1972,72.1],[1973,72.31],[1974,72.51],[1975,72.78],[1976,72.76],[1977,73.25],[1978,73.18],[1979,73.29],[1980,73.72],[1981,74.06],[1982,74.19],[1983,74.44],[1984,74.83],[1985,74.68],[1986,74.95],[1987,75.3],[1988,75.41],[1989,75.55],[1990,75.89],[1991,76.06],[1992,76.46],[1993,76.32],[1994,76.88],[1995,76.78],[1996,77.05],[1997,77.31],[1998,77.45],[1999,77.56],[2000,78.04],[2001,78.31],[2002,78.43],[2003,78.52],[2004,79.1],[2005,79.3],[2006,79.53],[2007,79.34],[2008,79.5],[2009,79.64]]},{"name":"Uzbekistan","region":"Europe & Central Asia","income":[[1800,346.43],[1820,353.72],[1913,788.48],[1950,1545.05],[1973,2395.67],[1990,1993.43],[1991,1935.31],[1992,1682.5],[1993,1611.38],[1994,1499.51],[1995,1460.98],[1996,1461.98],[1997,1513.43],[1998,1554.93],[1999,1597.63],[2000,1635.22],[2001,1681.66],[2002,1724.3],[2003,1771.19],[2004,1876.6],[2005,1975],[2006,2091.38],[2007,2255.67],[2008,2424.23],[2009,2586.96]],"population":[[1800,1919159],[1820,1919159],[1950,6292797],[1951,6489850],[1952,6681196],[1953,6886387],[1954,7061494],[1955,7232067],[1956,7440744],[1957,7694366],[1958,7951857],[1959,8223106],[1960,8531032],[1961,8867714],[1962,9209650],[1963,9546588],[1964,9877755],[1965,10205805],[1966,10529599],[1967,10864030],[1968,11232040],[1969,11591490],[1970,11940155],[1971,12334057],[1972,12741848],[1973,13147733],[1974,13568700],[1975,13987696],[1976,14404009],[1977,14808950],[1978,15207113],[1979,15605490],[1980,16000074],[1981,16413399],[1982,16849973],[1983,17298283],[1984,17764159],[1985,18258445],[1986,18769226],[1987,19279732],[1988,19694266],[1989,20112207],[1990,20624073],[1991,21137143],[1992,21614451],[1993,22049313],[1994,22462266],[1995,22847085],[1996,23219707],[1997,23596577],[1998,23977448],[1999,24363320],[2000,24755519],[2001,25155064],[2002,25563441],[2003,25981647],[2004,26410416],[2005,26851195],[2006,27307134],[2007,27780059],[2008,28268440]],"lifeExpectancy":[[1950,54.96],[1951,55.17],[1952,55.59],[1953,56.01],[1954,56.43],[1955,56.85],[1956,57.27],[1957,57.68],[1958,58.1],[1959,58.51],[1960,58.93],[1961,59.35],[1962,59.78],[1963,60.21],[1964,60.63],[1965,61.06],[1966,61.47],[1967,61.86],[1968,62.24],[1969,62.6],[1970,62.92],[1971,63.22],[1972,63.48],[1973,63.72],[1974,63.94],[1975,64.16],[1976,64.38],[1977,64.62],[1978,64.87],[1979,65.15],[1980,65.45],[1981,65.77],[1982,66.1],[1983,66.42],[1984,66.72],[1985,66.96],[1986,67.11],[1987,67.17],[1988,67.13],[1989,67],[1990,66.82],[1991,66.63],[1992,66.47],[1993,66.37],[1994,66.35],[1995,66.4],[1996,66.51],[1997,66.64],[1998,66.77],[1999,66.89],[2000,66.99],[2001,67.07],[2002,67.15],[2003,67.22],[2004,67.3],[2005,67.39],[2006,67.5],[2007,67.63],[2008,67.79],[2009,67.97]]},{"name":"Australia","region":"East Asia & Pacific","income":[[1800,671.48],[1820,701.03],[1821,707.39],[1822,728.14],[1823,752.83],[1824,794.94],[1825,833.2],[1826,848.98],[1827,874.78],[1828,896.76],[1829,946.58],[1830,1148.37],[1831,1186.8],[1832,1213.29],[1833,1217.71],[1834,1280.8],[1835,1550.03],[1836,1523.08],[1837,1596.55],[1838,1576.69],[1839,1470.98],[1840,1859.37],[1841,1586.06],[1842,1446.58],[1843,1677.46],[1844,1906.61],[1845,1961.67],[1846,2168.18],[1847,2508.31],[1848,2870.4],[1849,2836.11],[1850,2673.32],[1851,3172.92],[1852,3721.01],[1853,4073.94],[1854,3567.47],[1855,3385.66],[1856,4131.49],[1857,3645.86],[1858,3109.08],[1859,4013.76],[1860,3917.42],[1861,3858.21],[1862,3707.76],[1863,3695.5],[1864,3919.09],[1865,3738.03],[1866,3848.34],[1867,4207.41],[1868,4272.09],[1869,4187.16],[1870,4430.13],[1871,4464.33],[1872,4809.35],[1873,5175.05],[1874,5190.17],[1875,5600.81],[1876,5423.58],[1877,5462.6],[1878,5789.2],[1879,5691.19],[1880,5800.02],[1881,6029.34],[1882,5498.49],[1883,6057.02],[1884,5824.66],[1885,5985.27],[1886,5859.64],[1887,6268.79],[1888,6095.56],[1889,6424.58],[1890,6033.2],[1891,6315.77],[1892,5407.56],[1893,5018.36],[1894,5096.43],[1895,4719.83],[1896,4987.33],[1897,4628.72],[1898,5266.6],[1899,5196.68],[1900,5431.85],[1901,5195.5],[1902,5173.65],[1903,5516.93],[1904,5812.66],[1905,5795.39],[1906,6100.47],[1907,6248.06],[1908,6351.85],[1909,6740.94],[1910,7051.19],[1911,6907.66],[1912,6900.48],[1913,6979.44],[1914,6803.41],[1915,6627.25],[1916,6602.49],[1917,6484.48],[1918,6227.92],[1919,6382.25],[1920,6449.93],[1921,6646.5],[1922,6853.4],[1923,7027.1],[1924,7332.16],[1925,7515.77],[1926,7542.12],[1927,7503.19],[1928,7378.65],[1929,7123.12],[1930,6372.4],[1931,5892.35],[1932,6176.78],[1933,6553.91],[1934,6848.22],[1935,7197.03],[1936,7465.37],[1937,7776.39],[1938,7966.79],[1939,7911.61],[1940,8345.5],[1941,9187.46],[1942,10158.18],[1943,10425.32],[1944,9964.06],[1945,9361.6],[1946,8925.84],[1947,9019.86],[1948,9430.04],[1949,9794.56],[1950,10031.12],[1951,10160.74],[1952,10039.6],[1953,10157.91],[1954,10544.09],[1955,10864.62],[1956,10974.13],[1957,10949.65],[1958,11240.96],[1959,11678.07],[1960,11897.96],[1961,11711.5],[1962,12217.23],[1963,12722.22],[1964,13329.9],[1965,13739.93],[1966,13860.96],[1967,14526.12],[1968,15088.56],[1969,15647.11],[1970,16273.14],[1971,16633.13],[1972,16788.63],[1973,17429.72],[1974,17574.58],[1975,17824.57],[1976,18351.07],[1977,18334.2],[1978,18635.04],[1979,19380.64],[1980,19505.55],[1981,19841.88],[1982,19477.01],[1983,19214.56],[1984,20295.25],[1985,21040.49],[1986,21168.81],[1987,21888.89],[1988,22508.19],[1989,23133.98],[1990,23151.89],[1991,22893.86],[1992,23424.77],[1993,24053.1],[1994,24780.17],[1995,25518.72],[1996,26151.13],[1997,26997.94],[1998,28169.15],[1999,28983.27],[2000,29241.51],[2001,30043.24],[2002,30687.75],[2003,31634.24],[2004,32098.51],[2005,32798],[2006,33119],[2007,34084.07],[2008,34239.63],[2009,34327.26]],"population":[[1820,334000],[1821,331000],[1822,329000],[1823,329000],[1824,332000],[1825,333000],[1826,330000],[1827,328000],[1828,326000],[1829,326000],[1830,330000],[1831,333000],[1832,338000],[1833,349000],[1834,354000],[1835,358000],[1836,367000],[1837,373000],[1838,388000],[1839,403000],[1840,420000],[1841,448000],[1842,465000],[1843,472000],[1844,482000],[1845,494000],[1846,505000],[1847,518000],[1848,538000],[1849,576000],[1850,605000],[1851,636000],[1852,710000],[1853,795000],[1854,887000],[1855,983000],[1856,1065000],[1857,1156000],[1858,1235000],[1859,1279000],[1860,1326000],[1861,1346000],[1862,1382000],[1863,1432000],[1864,1495000],[1865,1558000],[1866,1609000],[1867,1647000],[1868,1700000],[1869,1750000],[1870,1775000],[1871,1675000],[1872,1722000],[1873,1769000],[1874,1822000],[1875,1874000],[1876,1929000],[1877,1995000],[1878,2062000],[1879,2127000],[1880,2197000],[1881,2269000],[1882,2348000],[1883,2447000],[1884,2556000],[1885,2650000],[1886,2741000],[1887,2835000],[1888,2932000],[1889,3022000],[1890,3107000],[1891,3196000],[1892,3274000],[1893,3334000],[1894,3395000],[1895,3460000],[1896,3523000],[1897,3586000],[1898,3642000],[1899,3691000],[1900,3741000],[1901,3795000],[1902,3850000],[1903,3896000],[1904,3946000],[1905,4004000],[1906,4062000],[1907,4127000],[1908,4197000],[1909,4278000],[1910,4375000],[1911,4500000],[1912,4661000],[1913,4821000],[1914,4933000],[1915,4971000],[1916,4955000],[1917,4950000],[1918,5032000],[1919,5193000],[1920,5358000],[1921,5461000],[1922,5574000],[1923,5697000],[1924,5819000],[1925,5943000],[1926,6064000],[1927,6188000],[1928,6304000],[1929,6396000],[1930,6469000],[1931,6527000],[1932,6579000],[1933,6631000],[1934,6682000],[1935,6732000],[1936,6783000],[1937,6841000],[1938,6904000],[1939,6971000],[1940,7042000],[1941,7111000],[1942,7173000],[1943,7236000],[1944,7309000],[1945,7389000],[1946,7474000],[1947,7578000],[1948,7715000],[1949,7919000],[1950,8267337],[1951,8510600],[1952,8691212],[1953,8857924],[1954,9064017],[1955,9277087],[1956,9500606],[1957,9712569],[1958,9915267],[1959,10131729],[1960,10361273],[1961,10598814],[1962,10794968],[1963,11001483],[1964,11218304],[1965,11439384],[1966,11655083],[1967,11872264],[1968,12101660],[1969,12379384],[1970,12660160],[1971,12937200],[1972,13177000],[1973,13380400],[1974,13599100],[1975,13771400],[1976,13915500],[1977,14074100],[1978,14248600],[1979,14421900],[1980,14615900],[1981,14923260],[1982,15184200],[1983,15393500],[1984,15579400],[1985,15788300],[1986,16018350],[1987,16257249],[1988,16520206],[1989,16780235],[1990,17022133],[1991,17257526],[1992,17481977],[1993,17688687],[1994,17892557],[1995,18116171],[1996,18348078],[1997,18565243],[1998,18768789],[1999,18968247],[2000,19164620],[2001,19357594],[2002,19546792],[2003,19731984],[2004,19913144],[2005,20090437],[2006,20264082],[2007,20434176],[2008,20600856]],"lifeExpectancy":[[1800,34.05],[1870,34.05],[1921,61.04],[1922,62.89],[1923,61.73],[1924,62.53],[1925,63.22],[1926,62.94],[1927,62.91],[1928,62.96],[1929,63.15],[1930,64.96],[1931,65.39],[1932,65.69],[1933,65.52],[1934,64.88],[1935,65.15],[1936,65.27],[1937,65.83],[1938,65.87],[1939,65.82],[1940,66.26],[1941,66.14],[1942,65.88],[1943,66.4],[1944,68.03],[1945,68.46],[1946,67.98],[1947,68.59],[1948,68.51],[1949,69.13],[1950,69.02],[1951,68.72],[1952,69.12],[1953,69.7],[1954,69.85],[1955,70.17],[1956,70.05],[1957,70.33],[1958,70.88],[1959,70.45],[1960,70.89],[1961,71.16],[1962,70.93],[1963,70.99],[1964,70.65],[1965,70.98],[1966,70.82],[1967,71.1],[1968,70.73],[1969,71.14],[1970,70.81],[1971,71.41],[1972,71.93],[1973,72.14],[1974,71.89],[1975,72.84],[1976,72.88],[1977,73.49],[1978,73.88],[1979,74.44],[1980,74.6],[1981,74.96],[1982,74.74],[1983,75.55],[1984,76.02],[1985,75.45],[1986,76.13],[1987,76.32],[1988,76.35],[1989,76.45],[1990,77.05],[1991,77.54],[1992,77.54],[1993,78.07],[1994,78.07],[1995,78.45],[1996,78.53],[1997,78.79],[1998,79.28],[1999,79.53],[2000,79.93],[2001,80.27],[2002,80.29],[2003,80.69],[2004,81.04],[2005,81.44],[2006,81.63],[2007,81.67],[2008,81.57],[2009,81.71]]},{"name":"Brunei","region":"East Asia & Pacific","income":[[1800,1011.68],[1820,1011.68],[1913,1367.71],[1929,1440.53],[1950,35554.36],[1970,48558.11],[1971,51244.66],[1972,54117.16],[1973,56943.9],[1974,61078.94],[1975,58861.78],[1976,67973.72],[1977,72555.23],[1978,74695.43],[1979,88381.11],[1980,79534.57],[1981,61817.06],[1982,62407.21],[1983,60976.16],[1984,59654.85],[1985,57144.31],[1986,54048.44],[1987,53585.9],[1988,52649.8],[1989,50628.31],[1990,50563.57],[1991,51141.01],[1992,49174.41],[1993,48067.97],[1994,47618.1],[1995,47786.78],[1996,48234.28],[1997,48967.31],[1998,47521.2],[1999,47811.18],[2000,48020.35],[2001,48192.76],[2002,48906.35],[2003,49184.09],[2004,48333.67],[2005,47465],[2006,48580.7],[2007,47701.82],[2008,45859.75],[2009,44738.99]],"population":[[1800,2128],[1820,2128],[1870,5931],[1911,22000],[1921,26000],[1931,30000],[1947,41000],[1950,44983],[1951,47632],[1952,50634],[1953,53678],[1954,57070],[1955,60983],[1956,65347],[1957,69342],[1958,73521],[1959,78540],[1960,83037],[1961,87067],[1962,90822],[1963,94351],[1964,98171],[1965,102414],[1966,106629],[1967,110971],[1968,115921],[1969,121434],[1970,127554],[1971,136621],[1972,141500],[1973,145170],[1974,151000],[1975,156223],[1976,161626],[1977,167216],[1978,173000],[1979,178899],[1980,185220],[1981,192831],[1982,199468],[1983,206154],[1984,213018],[1985,220215],[1986,227691],[1987,235357],[1988,242997],[1989,250553],[1990,258172],[1991,265877],[1992,273701],[1993,281594],[1994,289516],[1995,297508],[1996,305565],[1997,313563],[1998,321371],[1999,328979],[2000,336376],[2001,343653],[2002,350898],[2003,358098],[2004,365251],[2005,372361],[2006,379444],[2007,386511],[2008,393551]],"lifeExpectancy":[[1800,29.2],[1911,29.2],[1950,60],[1951,60.08],[1952,60.26],[1953,60.44],[1954,60.65],[1955,60.86],[1956,61.1],[1957,61.34],[1958,61.61],[1959,61.88],[1960,62.16],[1961,62.45],[1962,62.76],[1963,63.08],[1964,63.43],[1965,63.81],[1966,64.27],[1967,64.79],[1968,65.38],[1969,66.03],[1970,66.69],[1971,67.32],[1972,67.89],[1973,68.38],[1974,68.78],[1975,69.11],[1976,69.39],[1977,69.66],[1978,69.95],[1979,70.27],[1980,70.63],[1981,71.01],[1982,71.4],[1983,71.77],[1984,72.13],[1985,72.47],[1986,72.78],[1987,73.07],[1988,73.34],[1989,73.6],[1990,73.85],[1991,74.09],[1992,74.33],[1993,74.55],[1994,74.77],[1995,74.99],[1996,75.19],[1997,75.39],[1998,75.58],[1999,75.76],[2000,75.93],[2001,76.09],[2002,76.26],[2003,76.42],[2004,76.58],[2005,76.74],[2006,76.9],[2007,77.05],[2008,77.19],[2009,77.32]]},{"name":"Cambodia","region":"East Asia & Pacific","income":[[1800,809.23],[1820,809.23],[1950,352.03],[1951,355.21],[1952,368.47],[1953,363.27],[1954,395.75],[1955,378.15],[1956,417.47],[1957,434.04],[1958,443.98],[1959,474.59],[1960,489.73],[1961,472.2],[1962,496.91],[1963,519.81],[1964,492.19],[1965,502.02],[1966,511.05],[1967,523.43],[1968,533.17],[1969,527.47],[1970,472.62],[1971,449.47],[1972,421.62],[1973,567.93],[1974,480.68],[1975,423.41],[1976,470.18],[1977,524.97],[1978,593.45],[1979,608.24],[1980,606.6],[1981,597.38],[1982,624.48],[1983,648.64],[1984,677.86],[1985,706.88],[1986,724.21],[1987,683.9],[1988,675.38],[1989,666.82],[1990,642.9],[1991,666.82],[1992,682.3],[1993,677.3],[1994,680.57],[1995,708.19],[1996,730.42],[1997,734.29],[1998,729.51],[1999,793.34],[2000,833.36],[2001,864.97],[2002,896.23],[2003,926.11],[2004,1305.44],[2005,1453],[2006,1571.44],[2007,1830.56],[2008,1914.75],[2009,1830.97]],"population":[[1800,2090000],[1820,2090000],[1870,2340000],[1913,3070000],[1950,4471170],[1951,4581150],[1952,4693836],[1953,4809293],[1954,4927590],[1955,5048797],[1956,5183860],[1957,5322536],[1958,5464922],[1959,5611117],[1960,5761223],[1961,5919487],[1962,6083619],[1963,6253991],[1964,6426908],[1965,6602232],[1966,6779979],[1967,6960067],[1968,7142547],[1969,7327791],[1970,7394644],[1971,7387057],[1972,7450606],[1973,7533628],[1974,7607940],[1975,7489990],[1976,7223359],[1977,6978607],[1978,6749278],[1979,6716111],[1980,6869171],[1981,7059498],[1982,7272485],[1983,7499259],[1984,7656585],[1985,7805090],[1986,8066070],[1987,8371791],[1988,8689250],[1989,9017752],[1990,9355479],[1991,9704523],[1992,10150094],[1993,10643513],[1994,11008712],[1995,11282730],[1996,11542269],[1997,11782962],[1998,12012231],[1999,12239016],[2000,12466262],[2001,12695476],[2002,12926707],[2003,13160169],[2004,13396361],[2005,13636398],[2006,13881427],[2007,14131858],[2008,14387642]],"lifeExpectancy":[[1800,35],[1945,35],[1950,38.59],[1951,38.8],[1952,39.22],[1953,39.63],[1954,40.03],[1955,40.41],[1956,40.79],[1957,41.17],[1958,41.55],[1959,41.96],[1960,42.4],[1961,42.9],[1962,43.43],[1963,43.99],[1964,44.53],[1965,44.98],[1966,45.26],[1967,45.31],[1968,45.08],[1969,44.56],[1970,43.63],[1971,42.17],[1972,40.27],[1973,38.09],[1974,35.84],[1975,33.96],[1976,32.93],[1977,33.02],[1978,34.32],[1979,36.75],[1980,40.02],[1981,43.67],[1982,47.16],[1983,50.08],[1984,52.23],[1985,53.57],[1986,54.2],[1987,54.47],[1988,54.62],[1989,54.77],[1990,54.96],[1991,55.21],[1992,55.45],[1993,55.65],[1994,55.82],[1995,55.99],[1996,56.15],[1997,56.33],[1998,56.54],[1999,56.78],[2000,57.08],[2001,57.44],[2002,57.87],[2003,58.35],[2004,58.88],[2005,59.44],[2006,60.01],[2007,60.58],[2008,61.14],[2009,61.67]]},{"name":"China","region":"East Asia & Pacific","income":[[1800,985.89],[1820,863.05],[1821,859.02],[1822,855.01],[1823,851.02],[1824,847.04],[1825,843.09],[1826,839.15],[1827,835.23],[1828,831.33],[1829,827.45],[1830,823.59],[1831,819.74],[1832,815.92],[1833,812.11],[1834,808.32],[1835,804.54],[1836,800.78],[1837,797.05],[1838,793.32],[1839,789.62],[1840,785.93],[1841,782.26],[1842,778.61],[1843,774.98],[1844,771.36],[1845,767.76],[1846,764.17],[1847,760.6],[1848,757.05],[1849,753.52],[1850,750],[1851,675.4],[1852,608.22],[1853,547.72],[1854,493.24],[1855,444.18],[1856,400],[1857,420.8],[1858,442.67],[1859,465.69],[1860,489.9],[1861,515.37],[1862,542.16],[1863,570.35],[1864,600],[1865,626.77],[1866,654.74],[1867,683.95],[1868,714.47],[1869,746.35],[1870,779.65],[1871,780.42],[1872,781.18],[1873,781.94],[1874,782.71],[1875,783.47],[1876,784.24],[1877,785.01],[1878,785.78],[1879,786.55],[1880,787.32],[1881,788.09],[1882,788.86],[1883,789.63],[1884,790.4],[1885,791.18],[1886,791.95],[1887,792.73],[1888,793.5],[1889,794.28],[1890,795.06],[1891,795.78],[1892,796.5],[1893,797.22],[1894,797.94],[1895,798.66],[1896,799.38],[1897,800.11],[1898,800.83],[1899,801.56],[1900,802.28],[1901,803.06],[1902,803.84],[1903,804.62],[1904,805.4],[1905,806.18],[1906,806.96],[1907,807.74],[1908,808.53],[1909,809.31],[1910,810.09],[1911,810.88],[1912,811.66],[1913,812.45],[1914,823.4],[1915,834.5],[1916,845.75],[1917,857.15],[1918,868.7],[1919,880.41],[1920,892.28],[1921,904.31],[1922,916.5],[1923,928.85],[1924,941.37],[1925,954.06],[1926,966.92],[1927,979.96],[1928,993.16],[1929,1006.55],[1930,1015.72],[1931,1018.48],[1932,1043.08],[1933,1035.38],[1934,940.18],[1935,1010.72],[1936,1068.93],[1937,1037.42],[1938,1006.21],[1939,930.68],[1940,860.82],[1941,796.21],[1942,736.44],[1943,681.16],[1944,630.03],[1945,582.74],[1946,539],[1947,498.54],[1948,461.12],[1949,426.5],[1950,394.49],[1951,432.35],[1952,473.38],[1953,486.2],[1954,490.39],[1955,507.64],[1956,542.5],[1957,560],[1958,607.89],[1959,604.38],[1960,583.02],[1961,486.83],[1962,484.67],[1963,519.76],[1964,567.77],[1965,617.76],[1966,657.14],[1967,622.45],[1968,594.27],[1969,627.78],[1970,685.35],[1971,699.98],[1972,702.94],[1973,738.22],[1974,735.36],[1975,767.09],[1976,750.79],[1977,786.85],[1978,861.1],[1979,915.22],[1980,934.27],[1981,977.54],[1982,1044.34],[1983,1107.46],[1984,1229.08],[1985,1337.64],[1986,1406.19],[1987,1529.5],[1988,1611.38],[1989,1615.03],[1990,1647.38],[1991,1732.13],[1992,1877.41],[1993,2035.59],[1994,2214.2],[1995,2521.34],[1996,2546.44],[1997,2653.3],[1998,2635.55],[1999,2784.39],[2000,3012.12],[2001,3309.8],[2002,3695.65],[2003,4228.98],[2004,4551.13],[2005,4909.2],[2006,5450.12],[2007,6127.78],[2008,6679.2],[2009,7226.07]],"population":[[1820,381000000],[1821,383711494],[1822,386442286],[1823,389192512],[1824,391962310],[1825,394751821],[1826,397561184],[1827,400390540],[1828,403240033],[1829,406109805],[1830,409000000],[1831,409299014],[1832,409598247],[1833,409897699],[1834,410197370],[1835,410497259],[1836,410797368],[1837,411097697],[1838,411398245],[1839,411699012],[1840,412000000],[1841,412000000],[1842,412000000],[1843,412000000],[1844,412000000],[1845,412000000],[1846,412000000],[1847,412000000],[1848,412000000],[1849,412000000],[1850,412000000],[1851,408358528],[1852,404749241],[1853,401171855],[1854,397626087],[1855,394111659],[1856,390628294],[1857,387175716],[1858,383753654],[1859,380361838],[1860,377000000],[1861,375055482],[1862,373120994],[1863,371196483],[1864,369281899],[1865,367377190],[1866,365482306],[1867,363597195],[1868,361721807],[1869,359856092],[1870,358000000],[1871,358988000],[1872,359978000],[1873,360971000],[1874,361967000],[1875,362966000],[1876,363967000],[1877,364971000],[1878,365978000],[1879,366988000],[1880,368000000],[1881,369183000],[1882,370369000],[1883,371560000],[1884,372754000],[1885,373952000],[1886,375154000],[1887,376359000],[1888,377569000],[1889,378783000],[1890,380000000],[1891,381979000],[1892,383969000],[1893,385969000],[1894,387979000],[1895,390000000],[1896,391980000],[1897,393970000],[1898,395970000],[1899,397980000],[1900,400000000],[1901,402243000],[1902,404498000],[1903,406766000],[1904,409047000],[1905,411340000],[1906,413646000],[1907,415965000],[1908,418297000],[1909,420642000],[1910,423000000],[1911,427662000],[1912,432375000],[1913,437140000],[1914,441958000],[1915,446829000],[1916,451753000],[1917,456732000],[1918,461766000],[1919,466855000],[1920,472000000],[1921,473673000],[1922,475352000],[1923,477037000],[1924,478728000],[1925,480425000],[1926,482128000],[1927,483837000],[1928,485552000],[1929,487273000],[1930,489000000],[1931,492640000],[1932,496307000],[1933,500000000],[1934,502639000],[1935,505292000],[1936,507959000],[1937,510640000],[1938,513336000],[1939,516046000],[1940,518770000],[1941,521508000],[1942,524261000],[1943,527028000],[1944,529810000],[1945,532607000],[1946,535418000],[1947,538244000],[1948,541085000],[1949,543941000],[1950,546815000],[1951,557480000],[1952,568910000],[1953,581390000],[1954,595310000],[1955,608655000],[1956,621465000],[1957,637408000],[1958,653235000],[1959,666005000],[1960,667070000],[1961,660330000],[1962,665770000],[1963,682335000],[1964,698355000],[1965,715185000],[1966,735400000],[1967,754550000],[1968,774510000],[1969,796025000],[1970,818315000],[1971,841105000],[1972,862030000],[1973,881940000],[1974,900350000],[1975,916395000],[1976,930685000],[1977,943455000],[1978,956165000],[1979,969005000],[1980,981235000],[1981,993861000],[1982,1000281000],[1983,1023288000],[1984,1036825000],[1985,1051040000],[1986,1066790000],[1987,1084035000],[1988,1101630000],[1989,1118650000],[1990,1135185000],[1991,1150780000],[1992,1164970000],[1993,1178440000],[1994,1191835000],[1995,1204855000],[1996,1217550000],[1997,1230075000],[1998,1241935000],[1999,1252735000],[2000,1262645000],[2001,1271850000],[2002,1280400000],[2003,1288400000],[2004,1295733978],[2005,1303182268],[2006,1310823807],[2007,1318683096],[2008,1326856173]],"lifeExpectancy":[[1800,32],[1850,32],[1856,26],[1864,31],[1871,32],[1924,32],[1930,32],[1934,34],[1936,35],[1942,37],[1949,41],[1950,39.25],[1951,39.64],[1952,40.41],[1953,44.56],[1954,46.47],[1955,48.02],[1956,50.45],[1957,50.55],[1958,50.16],[1959,38.4],[1960,31.63],[1961,34.1],[1962,44.5],[1963,51.9],[1964,53.32],[1965,55.65],[1966,56.8],[1967,58.38],[1968,59.41],[1969,60.97],[1970,62.65],[1971,63.74],[1972,63.12],[1973,62.78],[1974,62.5],[1975,62.7],[1976,62.44],[1977,63.97],[1978,64.24],[1979,65.09],[1980,66.12],[1981,66.45],[1982,66.37],[1983,66.54],[1984,66.71],[1985,66.89],[1986,67.08],[1987,67.29],[1988,67.52],[1989,67.77],[1990,68.04],[1991,68.33],[1992,68.64],[1993,68.95],[1994,69.27],[1995,69.6],[1996,69.94],[1997,70.28],[1998,70.62],[1999,70.96],[2000,71.29],[2001,71.59],[2002,71.87],[2003,72.13],[2004,72.35],[2005,72.56],[2006,72.74],[2007,72.92],[2008,73.1],[2009,73.28]]},{"name":"Fiji","region":"East Asia & Pacific","income":[[1800,472.12],[1820,472.12],[1913,638.26],[1960,2036.45],[1961,2037.5],[1962,2039.39],[1963,2096.9],[1964,2130.13],[1965,2013.01],[1966,1960.75],[1967,2170.07],[1968,2290.59],[1969,2300.62],[1970,2538.96],[1971,2657.58],[1972,2797.76],[1973,3059.32],[1974,3076.71],[1975,3033.46],[1976,3059.19],[1977,3182.57],[1978,3183.86],[1979,3504.12],[1980,3374.56],[1981,3502.68],[1982,3209.26],[1983,3005.77],[1984,3189.48],[1985,2995.25],[1986,3197.96],[1987,2974.85],[1988,3000.08],[1989,3217.64],[1992,3410.29],[1993,3451.92],[1994,3579.65],[1995,3625.41],[1996,3760.19],[1997,3643.63],[1998,3660.5],[1999,3952.06],[2000,3856.32],[2001,3905.93],[2002,4004.48],[2003,4019.14],[2004,4205.96],[2005,4209],[2006,4249.35],[2007,4192.43],[2008,4153.29],[2009,4016.2]],"population":[[1800,130533],[1843,140000],[1850,137000],[1881,127000],[1891,121000],[1900,120000],[1901,120000],[1911,140000],[1921,157000],[1936,198000],[1946,260000],[1950,287348],[1951,295212],[1952,303594],[1953,312528],[1954,322045],[1955,332185],[1956,342987],[1957,354495],[1958,366755],[1959,379819],[1960,393348],[1961,407359],[1962,421869],[1963,436455],[1964,450647],[1965,463444],[1966,474000],[1967,485000],[1968,495000],[1969,506000],[1970,521000],[1971,533000],[1972,544000],[1973,556000],[1974,565000],[1975,576000],[1976,585000],[1977,599339],[1978,610845],[1979,622328],[1980,634506],[1981,646772],[1982,658906],[1983,671914],[1984,685572],[1985,698942],[1986,712989],[1987,719574],[1988,725994],[1989,732181],[1990,738090],[1991,743876],[1992,750242],[1993,757711],[1994,766268],[1995,775901],[1996,786603],[1997,797890],[1998,809292],[1999,820823],[2000,832494],[2001,844330],[2002,856346],[2003,868531],[2004,880874],[2005,893354],[2006,905949],[2007,918675],[2008,931545]],"lifeExpectancy":[[1800,26.1],[1925,26.1],[1950,51.57],[1951,51.8],[1952,52.25],[1953,52.69],[1954,53.12],[1955,53.54],[1956,53.95],[1957,54.35],[1958,54.74],[1959,55.13],[1960,55.52],[1961,55.92],[1962,56.31],[1963,56.72],[1964,57.13],[1965,57.54],[1966,57.97],[1967,58.39],[1968,58.81],[1969,59.22],[1970,59.63],[1971,60.04],[1972,60.44],[1973,60.85],[1974,61.25],[1975,61.66],[1976,62.06],[1977,62.47],[1978,62.87],[1979,63.28],[1980,63.69],[1981,64.11],[1982,64.55],[1983,64.98],[1984,65.41],[1985,65.81],[1986,66.15],[1987,66.42],[1988,66.6],[1989,66.7],[1990,66.73],[1991,66.71],[1992,66.67],[1993,66.63],[1994,66.61],[1995,66.63],[1996,66.7],[1997,66.8],[1998,66.93],[1999,67.1],[2000,67.28],[2001,67.48],[2002,67.69],[2003,67.91],[2004,68.11],[2005,68.31],[2006,68.5],[2007,68.68],[2008,68.87],[2009,69.05]]},{"name":"French Polynesia","region":"East Asia & Pacific","income":[[1800,809.34],[1820,809.34],[1913,1094.17],[1938,3809.11],[1950,6931.99],[1965,14652.18],[1966,15501.46],[1967,14244.02],[1968,15788.21],[1969,14827.48],[1970,14559.83],[1971,15778.51],[1972,14567.16],[1973,15221.11],[1974,17414.38],[1975,16058.06],[1976,16850.77],[1977,16682.11],[1978,17781.65],[1979,17930.54],[1980,17487.1],[1981,18420.35],[1982,19673.49],[1983,20154.29],[1984,20668.02],[1985,21218.42],[1986,22429.06],[1987,23454.41],[1988,23470.77],[1989,23644.36],[1990,23649.59],[1991,24294.36],[1992,24021.2],[1993,23573.74],[1994,23307.75],[1995,22982.73],[1996,22624.68],[1997,22634.06],[1998,23607.7],[1999,24121.45],[2000,24659.01],[2001,24575.06],[2002,25224.33],[2003,25627.58],[2004,25652.81],[2005,26016.11],[2006,26151.76],[2007,26379.1],[2008,26733.88]],"population":[[1800,62530],[1843,66000],[1850,62000],[1900,30000],[1926,36000],[1931,40000],[1936,44000],[1946,55000],[1950,62100],[1951,63000],[1952,64500],[1953,66800],[1954,69200],[1955,71900],[1956,75200],[1957,76600],[1958,78100],[1959,79600],[1960,81100],[1961,82600],[1962,83471],[1963,87046],[1964,90793],[1965,94717],[1966,98562],[1967,102756],[1968,107309],[1969,108700],[1970,114000],[1971,121100],[1972,124000],[1973,127000],[1974,130100],[1975,133100],[1976,136300],[1977,138156],[1978,142083],[1979,146463],[1980,150896],[1981,155686],[1982,160416],[1983,165319],[1984,170279],[1985,175416],[1986,180644],[1987,185839],[1988,191173],[1989,196542],[1990,201826],[1991,207085],[1992,212174],[1993,217191],[1994,222078],[1995,226766],[1996,231305],[1997,235770],[1998,240230],[1999,244679],[2000,249110],[2001,253506],[2002,257847],[2003,262125],[2004,266339],[2005,270485],[2006,274578],[2007,278633],[2008,282645]],"lifeExpectancy":[[1950,45.51],[1951,46.44],[1952,48.21],[1953,49.79],[1954,51.2],[1955,52.42],[1956,53.47],[1957,54.35],[1958,55.08],[1959,55.68],[1960,56.17],[1961,56.59],[1962,56.97],[1963,57.35],[1964,57.73],[1965,58.14],[1966,58.56],[1967,58.98],[1968,59.38],[1969,59.75],[1970,60.11],[1971,60.42],[1972,60.7],[1973,60.97],[1974,61.23],[1975,61.53],[1976,61.9],[1977,62.36],[1978,62.93],[1979,63.58],[1980,64.3],[1981,65.02],[1982,65.72],[1983,66.35],[1984,66.89],[1985,67.36],[1986,67.76],[1987,68.14],[1988,68.51],[1989,68.88],[1990,69.26],[1991,69.63],[1992,69.97],[1993,70.28],[1994,70.56],[1995,70.82],[1996,71.07],[1997,71.33],[1998,71.62],[1999,71.92],[2000,72.24],[2001,72.56],[2002,72.88],[2003,73.18],[2004,73.46],[2005,73.72],[2006,73.96],[2007,74.18],[2008,74.39],[2009,74.59]]},{"name":"Hong Kong, China","region":"East Asia & Pacific","income":[[1800,790.15],[1820,790.15],[1870,877.43],[1913,1643.6],[1950,2849.88],[1951,2949.19],[1952,3054.42],[1953,3160.15],[1954,3271.09],[1955,3386.38],[1956,3506.6],[1957,3629.08],[1958,3756.59],[1959,3888.53],[1960,4026.16],[1961,4167.37],[1962,4692.65],[1963,5246.03],[1964,5559.56],[1965,6199.22],[1966,6250.4],[1967,6197.96],[1968,6269.78],[1969,6867.09],[1970,7317.44],[1971,7668.23],[1972,8315.93],[1973,9128.67],[1974,9110.16],[1975,8981.46],[1976,10157.28],[1977,11186.14],[1978,11919.01],[1979,12585.32],[1980,13494.1],[1981,14392.75],[1982,14560.53],[1983,15156.55],[1984,16504.24],[1985,16398.3],[1986,17935.52],[1987,20038.47],[1988,21476.43],[1989,21897.43],[1990,22536.17],[1991,23541.78],[1992,24757.6],[1993,25864.07],[1994,26685.04],[1995,27018.05],[1996,27448.74],[1997,28377.63],[1998,26767.13],[1999,27452.02],[2000,29972.38],[2001,29866.07],[2002,30209.02],[2003,30961.45],[2004,33401.64],[2005,35680],[2006,37788.38],[2007,39949.68],[2008,40480.28],[2009,39086.39]],"population":[[1800,20000],[1820,20000],[1850,33000],[1870,123000],[1890,214000],[1900,306000],[1913,487000],[1914,507000],[1915,528000],[1916,550000],[1917,573000],[1918,597000],[1919,622000],[1920,648000],[1921,625000],[1922,638000],[1923,668000],[1924,696000],[1925,725000],[1926,710000],[1927,725000],[1928,753000],[1929,785000],[1930,821000],[1931,840000],[1932,901000],[1933,923000],[1934,944000],[1935,966000],[1936,988000],[1937,1282000],[1938,1479000],[1939,1750000],[1940,1786000],[1941,1639000],[1946,1550000],[1947,1750000],[1948,1800000],[1949,1857000],[1950,2237000],[1951,2015300],[1952,2125900],[1953,2242200],[1954,2364900],[1955,2490400],[1956,2614600],[1957,2736300],[1958,2854100],[1959,2967400],[1960,3075300],[1961,3168100],[1962,3305200],[1963,3420900],[1964,3504600],[1965,3597900],[1966,3629900],[1967,3722800],[1968,3802700],[1969,3863900],[1970,3959000],[1971,4045300],[1972,4115700],[1973,4212600],[1974,4319600],[1975,4395800],[1976,4518000],[1977,4583700],[1978,4667500],[1979,4929700],[1980,5063100],[1981,5183400],[1982,5264500],[1983,5345100],[1984,5397900],[1985,5456200],[1986,5524600],[1987,5584510],[1988,5628407],[1989,5660721],[1990,5687959],[1991,5752000],[1992,5829696],[1993,5934511],[1994,6067288],[1995,6225347],[1996,6391564],[1997,6495918],[1998,6544564],[1999,6599307],[2000,6658720],[2001,6713376],[2002,6762476],[2003,6809738],[2004,6855125],[2005,6898686],[2006,6940432],[2007,6980412],[2008,7018636]],"lifeExpectancy":[[1950,59.22],[1951,59.68],[1952,60.56],[1953,61.41],[1954,62.22],[1955,63],[1956,63.73],[1957,64.43],[1958,65.09],[1959,65.72],[1960,66.32],[1961,66.88],[1962,67.42],[1963,67.93],[1964,68.42],[1965,68.9],[1966,69.36],[1967,69.81],[1968,70.24],[1969,70.66],[1970,71.06],[1971,71.44],[1972,71.81],[1973,72.16],[1974,72.49],[1975,72.82],[1976,73.15],[1977,73.5],[1978,73.86],[1979,74.23],[1980,74.59],[1981,74.92],[1982,75.21],[1983,75.45],[1984,75.64],[1985,75.82],[1986,75.99],[1987,76.19],[1988,76.44],[1989,76.74],[1990,77.1],[1991,77.49],[1992,77.9],[1993,78.31],[1994,78.72],[1995,79.11],[1996,79.48],[1997,79.84],[1998,80.19],[1999,80.52],[2000,80.83],[2001,81.11],[2002,81.36],[2003,81.58],[2004,81.77],[2005,81.92],[2006,82.06],[2007,82.18],[2008,82.29],[2009,82.4]]},{"name":"Indonesia","region":"East Asia & Pacific","income":[[1800,514.12],[1820,518.73],[1850,539.86],[1870,554.8],[1871,547.26],[1872,540.26],[1873,545.43],[1874,552.01],[1875,556.52],[1876,567.79],[1877,568.92],[1878,556.43],[1879,562.78],[1880,561.02],[1881,589.05],[1882,567.29],[1883,554.72],[1884,594.98],[1885,594.45],[1886,584.96],[1887,585.6],[1888,580.55],[1889,574.95],[1890,554.2],[1891,563.86],[1892,580.08],[1893,591.63],[1894,593.51],[1895,588.5],[1896,586.03],[1897,586.17],[1898,581.95],[1899,604.2],[1900,615.87],[1901,600.79],[1902,583.07],[1903,608.33],[1904,609.52],[1905,610.21],[1906,619.6],[1907,627.93],[1908,621.19],[1909,643.39],[1910,673.94],[1911,697.39],[1912,700.78],[1913,723.93],[1914,715.9],[1915,717.23],[1916,715.29],[1917,709.19],[1918,722.53],[1919,779.14],[1920,748.45],[1921,741.55],[1922,752.97],[1923,758.93],[1924,788.01],[1925,793.81],[1926,829.87],[1927,870.85],[1928,891.62],[1929,903.85],[1930,904.26],[1931,823.28],[1932,808.18],[1933,801.5],[1934,804.93],[1935,830.79],[1936,881.13],[1937,936.18],[1938,949.68],[1939,949.53],[1940,1017.53],[1941,1013.45],[1942,743.61],[1943,659.2],[1944,525.24],[1945,462.55],[1946,477.15],[1947,526.99],[1948,611.54],[1949,666.09],[1950,704.35],[1951,744.28],[1952,749.68],[1953,770.93],[1954,807.6],[1955,823.68],[1956,804.83],[1957,858.9],[1958,792.47],[1959,816.55],[1960,834.99],[1961,859.77],[1962,849.29],[1963,798.21],[1964,809.58],[1965,802.64],[1966,794.06],[1967,762.43],[1968,827.29],[1969,911.09],[1970,986.73],[1971,1023.36],[1972,1111.11],[1973,1244.57],[1974,1262.42],[1975,1229.41],[1976,1314.63],[1977,1382.7],[1978,1418.14],[1979,1455.9],[1980,1549.1],[1981,1608.11],[1982,1516.87],[1983,1533.45],[1984,1609.27],[1985,1619.87],[1986,1690.43],[1987,1748.36],[1988,1821.98],[1989,1955.78],[1990,2097.7],[1991,2176.65],[1992,2383.14],[1993,2519.34],[1994,2674.28],[1995,2851.72],[1996,3026.82],[1997,3119.34],[1998,2656.41],[1999,2627.02],[2000,2714.94],[2001,2787.53],[2002,2873.91],[2003,2984.31],[2004,3095.79],[2005,3234],[2006,3367.56],[2007,3535.28],[2008,3699.54],[2009,3818.08]],"population":[[1820,17927000],[1821,18075923],[1822,18226083],[1823,18377490],[1824,18530155],[1825,18684088],[1826,18839300],[1827,18995801],[1828,19153603],[1829,19312715],[1830,19473149],[1831,19634916],[1832,19798026],[1833,19962492],[1834,20128324],[1835,20295533],[1836,20464132],[1837,20634131],[1838,20805542],[1839,20978378],[1840,21152649],[1841,21328367],[1842,21505546],[1843,21684196],[1844,21864330],[1845,22045961],[1846,22229101],[1847,22413762],[1848,22599957],[1849,22787699],[1850,22977000],[1851,23242887],[1852,23511851],[1853,23783928],[1854,24059152],[1855,24337562],[1856,24619194],[1857,24904084],[1858,25192271],[1859,25483793],[1860,25778689],[1861,26076997],[1862,26378757],[1863,26684009],[1864,26992793],[1865,27305150],[1866,27621122],[1867,27940751],[1868,28264078],[1869,28591147],[1870,28922000],[1871,29463000],[1872,30060000],[1873,30555000],[1874,30962000],[1875,31197000],[1876,31394000],[1877,31740000],[1878,32035000],[1879,32293000],[1880,32876000],[1881,33213000],[1882,33394000],[1883,33816000],[1884,34162000],[1885,34790000],[1886,35402000],[1887,35898000],[1888,36345000],[1889,36662000],[1890,37579000],[1891,37792000],[1892,38288000],[1893,38263000],[1894,38782000],[1895,39476000],[1896,39936000],[1897,40620000],[1898,41316000],[1899,42025000],[1900,42746000],[1901,43275000],[1902,43810000],[1903,44352000],[1904,44901000],[1905,45457000],[1906,45993000],[1907,46535000],[1908,47085000],[1909,47642000],[1910,48206000],[1911,48778000],[1912,49358000],[1913,49934000],[1914,50517000],[1915,51108000],[1916,51705000],[1917,52083000],[1918,52334000],[1919,53027000],[1920,53723000],[1921,54367000],[1922,55020000],[1923,55683000],[1924,56354000],[1925,57036000],[1926,57727000],[1927,58429000],[1928,59140000],[1929,59863000],[1930,60596000],[1931,61496000],[1932,62400000],[1933,63314000],[1934,64246000],[1935,65192000],[1936,66154000],[1937,67136000],[1938,68131000],[1939,69145000],[1940,70175000],[1941,71316000],[1942,72475000],[1943,73314000],[1944,73565000],[1945,73332000],[1946,74132000],[1947,75146000],[1948,76289000],[1949,77654000],[1950,79043000],[1951,80525000],[1952,82052000],[1953,83611000],[1954,85196000],[1955,86807000],[1956,88456000],[1957,90124000],[1958,91821000],[1959,93565000],[1960,95254000],[1961,97085000],[1962,99028000],[1963,101009000],[1964,103031000],[1965,105093000],[1966,107197000],[1967,109343000],[1968,111532000],[1969,113765000],[1970,116044000],[1971,118368000],[1972,121282000],[1973,124271000],[1974,127201000],[1975,130297000],[1976,133297000],[1977,136725000],[1978,140062000],[1979,143485000],[1980,146995000],[1981,150134000],[1982,153343000],[1983,156623000],[1984,159975000],[1985,163403000],[1986,166312000],[1987,169276000],[1988,172294000],[1989,175369000],[1990,178500000],[1991,181628000],[1992,184816000],[1993,188066000],[1994,191378000],[1995,194755000],[1996,197003000],[1997,199278000],[1998,201580000],[1999,203909000],[2000,206265000],[2001,208648000],[2002,211060000],[2003,214497000],[2004,215967000],[2005,218465000],[2006,220991000],[2007,223547000],[2008,226134000]],"lifeExpectancy":[[1800,30],[1927,30],[1932,32.5],[1937,35],[1942,27.5],[1947,27.5],[1950,36.5],[1951,36.74],[1952,37.23],[1953,37.72],[1954,38.2],[1955,38.68],[1956,39.16],[1957,39.64],[1958,40.13],[1959,40.63],[1960,41.15],[1961,41.69],[1962,42.27],[1963,42.88],[1964,43.53],[1965,44.2],[1966,44.89],[1967,45.58],[1968,46.26],[1969,46.93],[1970,47.59],[1971,48.25],[1972,48.91],[1973,49.58],[1974,50.27],[1975,50.96],[1976,51.65],[1977,52.35],[1978,53.04],[1979,53.73],[1980,54.44],[1981,55.16],[1982,55.92],[1983,56.7],[1984,57.49],[1985,58.29],[1986,59.05],[1987,59.76],[1988,60.42],[1989,61.01],[1990,61.56],[1991,62.09],[1992,62.63],[1993,63.19],[1994,63.79],[1995,64.42],[1996,65.06],[1997,65.69],[1998,66.3],[1999,66.87],[2000,67.41],[2001,67.91],[2002,68.39],[2003,68.84],[2004,69.28],[2005,69.7],[2006,70.1],[2007,70.47],[2008,70.83],[2009,71.17]]},{"name":"Japan","region":"East Asia & Pacific","income":[[1800,1055.06],[1820,1083.6],[1821,1084.14],[1822,1084.69],[1823,1085.23],[1824,1085.77],[1825,1086.32],[1826,1086.86],[1827,1087.4],[1828,1087.95],[1829,1088.49],[1830,1089.04],[1831,1089.58],[1832,1090.13],[1833,1090.68],[1834,1091.22],[1835,1091.77],[1836,1092.32],[1837,1092.86],[1838,1093.41],[1839,1093.96],[1840,1094.51],[1841,1095.05],[1842,1095.6],[1843,1096.15],[1844,1096.7],[1845,1097.25],[1846,1097.8],[1847,1098.35],[1848,1098.9],[1849,1099.45],[1850,1100],[1851,1102.43],[1852,1104.86],[1853,1107.3],[1854,1109.74],[1855,1112.19],[1856,1114.64],[1857,1117.1],[1858,1119.56],[1859,1122.03],[1860,1124.51],[1861,1126.99],[1862,1129.47],[1863,1131.97],[1864,1134.46],[1865,1136.96],[1866,1139.47],[1867,1141.99],[1868,1144.51],[1869,1147.03],[1870,1149.56],[1871,1154.57],[1872,1158.58],[1873,1164.13],[1874,1169.9],[1875,1250.55],[1876,1209.18],[1877,1234.7],[1878,1218.67],[1879,1280.18],[1880,1320.54],[1881,1265.97],[1882,1286.22],[1883,1273.17],[1884,1268.45],[1885,1303.03],[1886,1385.7],[1887,1436],[1888,1355.03],[1889,1402.18],[1890,1518.44],[1891,1432.42],[1892,1513.78],[1893,1504.42],[1894,1666.92],[1895,1669.75],[1896,1559.25],[1897,1572.31],[1898,1845.55],[1899,1686.05],[1900,1736.39],[1901,1772.67],[1902,1655.54],[1903,1745.65],[1904,1735.69],[1905,1686.69],[1906,1887.88],[1907,1924.86],[1908,1911.45],[1909,1881.91],[1910,1882.95],[1911,1954.06],[1912,1991.34],[1913,1991.28],[1914,1901.22],[1915,2045.23],[1916,2326.89],[1917,2372.82],[1918,2373.05],[1919,2593.96],[1920,2402.74],[1921,2629.72],[1922,2584.64],[1923,2549.04],[1924,2582.09],[1925,2645.71],[1926,2621.63],[1927,2614.09],[1928,2780.19],[1929,2821.34],[1930,2572.21],[1931,2549.2],[1932,2716.38],[1933,2933.51],[1934,2894.67],[1935,2919.61],[1936,3090.28],[1937,3187.62],[1938,3372.34],[1939,3877.35],[1940,3957.53],[1941,3955.34],[1942,3880.32],[1943,3885.01],[1944,3661.06],[1945,1853.44],[1946,1988.5],[1947,2121.68],[1948,2375.5],[1949,2478.13],[1950,2644.59],[1951,2926.69],[1952,3216.96],[1953,3406.85],[1954,3554.9],[1955,3814.97],[1956,4058.84],[1957,4317.69],[1958,4528.39],[1959,4893.31],[1960,5488.81],[1961,6094.42],[1962,6576.65],[1963,7061.48],[1964,7803.68],[1965,8170.01],[1966,8957.28],[1967,9847.79],[1968,10992],[1969,12218.48],[1970,13374.86],[1971,13824.24],[1972,14778.79],[1973,15742.88],[1974,15344.57],[1975,15618.93],[1976,16066.67],[1977,16610.38],[1978,17327.76],[1979,18123.89],[1980,18488.26],[1981,18938.11],[1982,19384.11],[1983,19698.72],[1984,20339.95],[1985,21109.16],[1986,21588.49],[1987,22375.94],[1988,23661.04],[1989,24704.53],[1990,25870.14],[1991,26648.77],[1992,26824.9],[1993,26818.24],[1994,27037.83],[1995,27509.08],[1996,28385.16],[1997,28816.58],[1998,27904.68],[1999,27809.6],[2000,28559.6],[2001,28569.05],[2002,28604.59],[2003,29073.61],[2004,29742.05],[2005,30290],[2006,30909.15],[2007,31636.71],[2008,31275.13],[2009,29680.68]],"population":[[1820,31000000],[1821,31032824],[1822,31065683],[1823,31098577],[1824,31131506],[1825,31164470],[1826,31197468],[1827,31230502],[1828,31263570],[1829,31296674],[1830,31329812],[1831,31362986],[1832,31396194],[1833,31429438],[1834,31462717],[1835,31496031],[1836,31529381],[1837,31562766],[1838,31596186],[1839,31629642],[1840,31663133],[1841,31696659],[1842,31730221],[1843,31763819],[1844,31797452],[1845,31831121],[1846,31864825],[1847,31898565],[1848,31932341],[1849,31966153],[1850,32000000],[1851,32117649],[1852,32235730],[1853,32354246],[1854,32473197],[1855,32592585],[1856,32712413],[1857,32832681],[1858,32953391],[1859,33074545],[1860,33196144],[1861,33318191],[1862,33440686],[1863,33563632],[1864,33687029],[1865,33810880],[1866,33935187],[1867,34059950],[1868,34185173],[1869,34310855],[1870,34437000],[1871,34648000],[1872,34859000],[1873,35070000],[1874,35235000],[1875,35436000],[1876,35713000],[1877,36018000],[1878,36315000],[1879,36557000],[1880,36807000],[1881,37112000],[1882,37414000],[1883,37766000],[1884,38138000],[1885,38427000],[1886,38622000],[1887,38866000],[1888,39251000],[1889,39688000],[1890,40077000],[1891,40380000],[1892,40684000],[1893,41001000],[1894,41350000],[1895,41775000],[1896,42196000],[1897,42643000],[1898,43145000],[1899,43626000],[1900,44103000],[1901,44662000],[1902,45255000],[1903,45841000],[1904,46378000],[1905,46829000],[1906,47227000],[1907,47691000],[1908,48260000],[1909,48869000],[1910,49518000],[1911,50215000],[1912,50941000],[1913,51672000],[1914,52396000],[1915,53124000],[1916,53815000],[1917,54437000],[1918,54886000],[1919,55253000],[1920,55818000],[1921,56490000],[1922,57209000],[1923,57937000],[1924,58686000],[1925,59522000],[1926,60490000],[1927,61430000],[1928,62361000],[1929,63244000],[1930,64203000],[1931,65205000],[1932,66189000],[1933,67182000],[1934,68090000],[1935,69238000],[1936,70171000],[1937,71278000],[1938,71879000],[1939,72364000],[1940,72967000],[1941,74005000],[1942,75029000],[1943,76005000],[1944,77178000],[1945,76224000],[1946,77199000],[1947,78119000],[1948,80155000],[1949,81971000],[1950,83805000],[1951,85163848],[1952,86459025],[1953,87655163],[1954,88753892],[1955,89815060],[1956,90766211],[1957,91563009],[1958,92388772],[1959,93296566],[1960,94091638],[1961,94943293],[1962,95831757],[1963,96811940],[1964,97826267],[1965,98882534],[1966,99790308],[1967,100825279],[1968,101960672],[1969,103171831],[1970,104344973],[1971,105696786],[1972,107188273],[1973,108706797],[1974,110162302],[1975,111573116],[1976,112774841],[1977,113872473],[1978,114912911],[1979,115890431],[1980,116807309],[1981,117648092],[1982,118454974],[1983,119269949],[1984,120034697],[1985,120754335],[1986,121491913],[1987,122091325],[1988,122613000],[1989,123107500],[1990,123537399],[1991,123946268],[1992,124329269],[1993,124668019],[1994,125014050],[1995,125341354],[1996,125645311],[1997,125956499],[1998,126246096],[1999,126494403],[2000,126699784],[2001,126891645],[2002,127065841],[2003,127214499],[2004,127333002],[2005,127417244],[2006,127463611],[2007,127467972],[2008,127425722]],"lifeExpectancy":[[1800,36.4],[1865,36.43],[1870,36.59],[1875,36.8],[1880,37.04],[1885,37.33],[1890,37.68],[1895,38.1],[1900,38.6],[1905,39.22],[1910,39.97],[1915,40.9],[1920,42.04],[1922,42.62],[1927,45.66],[1935,48.24],[1937,49],[1940,49],[1942,48.5],[1943,46],[1944,40],[1945,30.54],[1946,46.5],[1947,51.75],[1948,56.89],[1949,57.76],[1950,59.3],[1951,60.99],[1952,63.03],[1953,63.37],[1954,64.61],[1955,65.77],[1956,65.63],[1957,65.5],[1958,67.12],[1959,67.51],[1960,67.8],[1961,68.45],[1962,68.73],[1963,69.81],[1964,70.28],[1965,70.33],[1966,71.14],[1967,71.43],[1968,71.75],[1969,71.98],[1970,72.07],[1971,72.89],[1972,73.42],[1973,73.48],[1974,73.91],[1975,74.41],[1976,74.81],[1977,75.38],[1978,75.7],[1979,76.21],[1980,76.19],[1981,76.6],[1982,77.11],[1983,77.14],[1984,77.54],[1985,77.84],[1986,78.26],[1987,78.67],[1988,78.58],[1989,79.01],[1990,79.04],[1991,79.31],[1992,79.36],[1993,79.5],[1994,79.91],[1995,79.76],[1996,80.46],[1997,80.69],[1998,80.77],[1999,80.75],[2000,81.35],[2001,81.7],[2002,82],[2003,82.07],[2004,82.36],[2005,82.27],[2006,82.68],[2007,82.87],[2008,82.81],[2009,82.98]]},{"name":"Korea, Dem. Rep.","region":"East Asia & Pacific","income":[[1800,698],[1820,698],[1821,698],[1822,698],[1823,698],[1824,699],[1825,699],[1826,699],[1827,699],[1828,699],[1829,699],[1830,699],[1831,699],[1832,699],[1833,699],[1834,699],[1835,700],[1836,700],[1837,700],[1838,700],[1839,700],[1840,700],[1841,700],[1842,700],[1843,700],[1844,700],[1845,701],[1846,701],[1847,701],[1848,701],[1849,701],[1850,701],[1851,701],[1852,701],[1853,701],[1854,701],[1855,701],[1856,702],[1857,702],[1858,702],[1859,702],[1860,702],[1861,702],[1862,702],[1863,702],[1864,702],[1865,702],[1866,702],[1867,703],[1868,703],[1869,703],[1870,703],[1871,706],[1872,708],[1873,711],[1874,714],[1875,716],[1876,719],[1877,722],[1878,725],[1879,727],[1880,730],[1881,733],[1882,736],[1883,739],[1884,741],[1885,744],[1886,747],[1887,750],[1888,753],[1889,756],[1890,758],[1891,761],[1892,764],[1893,767],[1894,770],[1895,773],[1896,776],[1897,779],[1898,782],[1899,785],[1900,788],[1901,791],[1902,794],[1903,797],[1904,800],[1905,803],[1906,806],[1907,809],[1908,812],[1909,815],[1910,819],[1911,822],[1912,847],[1913,870],[1914,900],[1915,1042],[1916,1008],[1917,1104],[1918,1177],[1919,1240],[1920,1067],[1921,1137],[1922,1033],[1923,1093],[1924,1087],[1925,1074],[1926,1102],[1927,1136],[1928,1130],[1929,1058],[1930,990],[1931,983],[1932,973],[1933,1164],[1934,1149],[1935,1239],[1936,1340],[1937,1466],[1938,1529],[1939,1368],[1940,1531],[1941,1539],[1942,1517],[1943,1527],[1944,1448],[1945,674],[1946,682],[1947,719],[1948,773],[1949,830],[1950,870],[1951,727],[1952,777],[1953,1004],[1954,1059],[1955,1109],[1956,1097],[1957,1158],[1958,1193],[1959,1209],[1960,1200],[1961,1229],[1962,1234],[1963,1313],[1964,1396],[1965,1452],[1966,1597],[1967,1684],[1968,1866],[1969,2115],[1970,2262],[1971,2938],[1972,3002],[1973,3332],[1974,3373],[1975,3373],[1976,3373],[1977,3373],[1978,3373],[1979,3373],[1980,3373],[1981,3373],[1982,3373],[1983,3373],[1984,3373],[1985,3373],[1986,3373],[1987,3373],[1988,3373],[1989,3373],[1990,3373],[1991,3373],[1992,3061],[1993,3018],[1994,2300],[1995,2000],[1996,1809],[1997,1691],[1998,1693],[1999,1706],[2000,1690],[2001,1667],[2002,1647],[2003,1628],[2004,1612],[2005,1597],[2006,1572],[2007,1531],[2008,1582],[2009,1635]],"population":[[1800,4345000],[1820,4345000],[1870,4511000],[1913,4897000],[1950,9471140],[1951,9162410],[1952,8865488],[1953,8579873],[1954,8571805],[1955,8839427],[1956,9115740],[1957,9411381],[1958,9727435],[1959,10054154],[1960,10391909],[1961,10651332],[1962,10917494],[1963,11209506],[1964,11527887],[1965,11868751],[1966,12231860],[1967,12617009],[1968,13024159],[1969,13454771],[1970,13911902],[1971,14364579],[1972,14781241],[1973,15160867],[1974,15501464],[1975,15801308],[1976,16069433],[1977,16325320],[1978,16579905],[1979,16840290],[1980,17113626],[1981,17384008],[1982,17647518],[1983,17917990],[1984,18196000],[1985,18481420],[1986,18772457],[1987,19067554],[1988,19371141],[1989,19687910],[1990,20018546],[1991,20361086],[1992,20711375],[1993,21064115],[1994,21339904],[1995,21561856],[1996,21648743],[1997,21585105],[1998,21454900],[1999,21444989],[2000,21647682],[2001,21940326],[2002,22215365],[2003,22466481],[2004,22697553],[2005,22912177],[2006,23113019],[2007,23301725],[2008,23479089]],"lifeExpectancy":[[1800,26],[1903,26],[1908,23.51],[1913,24.98],[1918,26.98],[1923,29.53],[1928,33.61],[1933,37.39],[1938,42.57],[1942,44.89],[1950,48.04],[1951,48.58],[1952,49.63],[1953,50.6],[1954,51.49],[1955,52.31],[1956,53.05],[1957,53.72],[1958,54.34],[1959,54.9],[1960,55.43],[1961,55.94],[1962,56.46],[1963,56.99],[1964,57.57],[1965,58.19],[1966,58.88],[1967,59.61],[1968,60.38],[1969,61.17],[1970,61.98],[1971,62.78],[1972,63.58],[1973,64.34],[1974,65.07],[1975,65.74],[1976,66.35],[1977,66.9],[1978,67.4],[1979,67.85],[1980,68.27],[1981,68.66],[1982,69.04],[1983,69.4],[1984,69.75],[1985,70.07],[1986,70.35],[1987,70.57],[1988,70.71],[1989,70.77],[1990,70.73],[1991,70.56],[1992,70.29],[1993,69.92],[1994,69.49],[1995,69.01],[1996,68.51],[1997,68.03],[1998,67.6],[1999,67.24],[2000,66.96],[2001,66.78],[2002,66.69],[2003,66.67],[2004,66.72],[2005,66.82],[2006,66.97],[2007,67.14],[2008,67.33],[2009,67.53]]},{"name":"Korea, Rep.","region":"East Asia & Pacific","income":[[1800,596],[1820,596],[1821,596],[1822,596],[1823,596],[1824,596],[1825,596],[1826,596],[1827,597],[1828,597],[1829,597],[1830,597],[1831,597],[1832,597],[1833,597],[1834,597],[1835,597],[1836,597],[1837,597],[1838,597],[1839,598],[1840,598],[1841,598],[1842,598],[1843,598],[1844,598],[1845,598],[1846,598],[1847,598],[1848,598],[1849,598],[1850,598],[1851,598],[1852,599],[1853,599],[1854,599],[1855,599],[1856,599],[1857,599],[1858,599],[1859,599],[1860,599],[1861,599],[1862,599],[1863,599],[1864,600],[1865,600],[1866,600],[1867,600],[1868,600],[1869,600],[1870,600],[1871,602],[1872,605],[1873,607],[1874,609],[1875,612],[1876,614],[1877,616],[1878,619],[1879,621],[1880,623],[1881,626],[1882,628],[1883,630],[1884,633],[1885,635],[1886,638],[1887,640],[1888,643],[1889,645],[1890,647],[1891,650],[1892,652],[1893,655],[1894,657],[1895,660],[1896,662],[1897,665],[1898,668],[1899,670],[1900,673],[1901,675],[1902,678],[1903,680],[1904,683],[1905,686],[1906,688],[1907,691],[1908,693],[1909,696],[1910,699],[1911,701],[1912,723],[1913,743],[1914,768],[1915,889],[1916,861],[1917,942],[1918,1005],[1919,1058],[1920,910],[1921,971],[1922,882],[1923,933],[1924,928],[1925,917],[1926,940],[1927,969],[1928,965],[1929,903],[1930,845],[1931,839],[1932,831],[1933,993],[1934,981],[1935,1058],[1936,1144],[1937,1251],[1938,1305],[1939,1168],[1940,1307],[1941,1314],[1942,1295],[1943,1303],[1944,1236],[1945,576],[1946,582],[1947,614],[1948,660],[1949,708],[1950,743],[1951,689],[1952,736],[1953,951],[1954,1003],[1955,1050],[1956,1039],[1957,1097],[1958,1130],[1959,1145],[1960,1137],[1961,1163],[1962,1169],[1963,1243],[1964,1322],[1965,1375],[1966,1512],[1967,1594],[1968,1768],[1969,2003],[1970,2141],[1971,2319],[1972,2458],[1973,2844],[1974,3056],[1975,3225],[1976,3568],[1977,3899],[1978,4224],[1979,4492],[1980,4331],[1981,4558],[1982,4859],[1983,5373],[1984,5804],[1985,6162],[1986,6849],[1987,7612],[1988,8441],[1989,8948],[1990,9764],[1991,10622],[1992,11146],[1993,11701],[1994,12609],[1995,13674],[1996,14574],[1997,15202],[1998,14359],[1999,15692],[2000,16996],[2001,17784],[2002,18871],[2003,19485],[2004,20443],[2005,21342],[2006,22373],[2007,23438],[2008,23903],[2009,23875]],"population":[[1800,9395000],[1820,9395000],[1850,9545000],[1870,9753000],[1890,9848000],[1900,9896000],[1910,10096000],[1911,10258000],[1912,10422000],[1913,10589000],[1914,10764000],[1915,10911000],[1916,11086000],[1917,11263000],[1918,11443000],[1919,11627000],[1920,11804000],[1921,12040000],[1922,12281000],[1923,12526000],[1924,12777000],[1925,13005000],[1926,13179000],[1927,13356000],[1928,13535000],[1929,13716000],[1930,13900000],[1931,14117000],[1932,14338000],[1933,14562000],[1934,14789000],[1935,15020000],[1936,15139000],[1937,15260000],[1938,15381000],[1939,15504000],[1940,15627000],[1941,15859000],[1942,16094000],[1943,16332000],[1944,16574000],[1945,17917000],[1946,19369000],[1947,19886000],[1948,20027000],[1949,20208000],[1950,20845771],[1951,20876189],[1952,20947571],[1953,21060464],[1954,21258836],[1955,21551834],[1956,22031228],[1957,22611552],[1958,23253622],[1959,23981313],[1960,24784140],[1961,25613842],[1962,26420307],[1963,27211316],[1964,27984000],[1965,28705000],[1966,29436000],[1967,30131000],[1968,30838000],[1969,31544000],[1970,32241000],[1971,32883000],[1972,33505000],[1973,34073000],[1974,34692000],[1975,35281000],[1976,35860000],[1977,36436000],[1978,37019000],[1979,37534000],[1980,38124000],[1981,38723000],[1982,39326000],[1983,39910000],[1984,40406000],[1985,40806000],[1986,41214000],[1987,41622000],[1988,42031000],[1989,42449000],[1990,42869000],[1991,43318030],[1992,43805450],[1993,44295873],[1994,44780886],[1995,45264146],[1996,45730245],[1997,46173816],[1998,46589612],[1999,46972817],[2000,47351083],[2001,47697738],[2002,47969150],[2003,48202264],[2004,48426325],[2005,48640671],[2006,48846823],[2007,49044790],[2008,49232844]],"lifeExpectancy":[[1800,25.8],[1903,25.8],[1908,23.51],[1913,24.98],[1918,26.98],[1923,29.53],[1928,33.61],[1933,37.39],[1938,42.57],[1942,44.89],[1950,45.52],[1951,46.17],[1952,47.42],[1953,48.57],[1954,49.62],[1955,50.58],[1956,51.45],[1957,52.22],[1958,52.9],[1959,53.51],[1960,54.05],[1961,54.54],[1962,54.99],[1963,55.42],[1964,55.86],[1965,56.31],[1966,56.8],[1967,57.33],[1968,57.9],[1969,58.51],[1970,59.16],[1971,59.86],[1972,60.6],[1973,61.35],[1974,62.11],[1975,62.85],[1976,63.54],[1977,64.18],[1978,64.75],[1979,65.27],[1980,65.74],[1981,66.19],[1982,66.66],[1983,67.15],[1984,67.68],[1985,68.25],[1986,68.85],[1987,69.48],[1988,70.11],[1989,70.73],[1990,71.32],[1991,71.86],[1992,72.34],[1993,72.77],[1994,73.16],[1995,73.53],[1996,73.91],[1997,74.34],[1998,74.81],[1999,75.35],[2000,75.92],[2001,76.52],[2002,77.11],[2003,77.66],[2004,78.16],[2005,78.58],[2006,78.94],[2007,79.22],[2008,79.46],[2009,79.65]]},{"name":"Macao, China","region":"East Asia & Pacific","income":[[1800,607.01],[1820,607.01],[1913,820.62],[1950,2170.05],[1970,8453.49],[1971,8844.09],[1972,9344.18],[1973,9940.47],[1974,10611.51],[1975,11341.46],[1976,12106.57],[1977,12941.19],[1978,13807.82],[1979,14512.26],[1980,15216.44],[1981,15839.15],[1982,15856.62],[1983,16720.55],[1984,17365.77],[1985,16718.13],[1986,17058.98],[1987,18701.78],[1988,19353.91],[1989,19597.07],[1990,20495.49],[1991,20688.02],[1992,22917.23],[1993,23654.92],[1994,24247.09],[1995,24653.08],[1996,24188.5],[1997,23790.49],[1998,22404.65],[1999,21586.35],[2000,22512.56],[2001,22826.54],[2002,24755.47],[2003,27842.69],[2004,35260.87],[2005,37256],[2006,42523.57],[2007,52028.35],[2008,57436.68]],"population":[[1835,35000],[1839,13000],[1860,85000],[1900,64000],[1910,76000],[1920,84000],[1927,157000],[1937,170000],[1940,375000],[1950,205442],[1951,202367],[1952,199489],[1953,196948],[1954,194893],[1955,192684],[1956,190465],[1957,189390],[1958,188751],[1959,187499],[1960,186053],[1961,189831],[1962,198464],[1963,206989],[1964,215496],[1965,223820],[1966,231905],[1967,239773],[1968,247282],[1969,254436],[1970,261369],[1971,263565],[1972,261202],[1973,258929],[1974,256653],[1975,254331],[1976,251775],[1977,249116],[1978,248564],[1979,251368],[1980,255773],[1981,260929],[1982,270811],[1983,285451],[1984,298982],[1985,305843],[1986,312196],[1987,322983],[1988,332136],[1989,341237],[1990,351756],[1991,363858],[1992,375382],[1993,384495],[1994,393064],[1995,401452],[1996,410597],[1997,417129],[1998,421602],[1999,427618],[2000,431338],[2001,434044],[2002,437794],[2003,441487],[2004,445286],[2005,449198],[2006,453125],[2007,456989],[2008,460823]],"lifeExpectancy":[[1950,52.98],[1951,53.2],[1952,53.66],[1953,54.17],[1954,54.72],[1955,55.32],[1956,55.96],[1957,56.64],[1958,57.37],[1959,58.13],[1960,58.94],[1961,59.79],[1962,60.65],[1963,61.53],[1964,62.4],[1965,63.21],[1966,63.93],[1967,64.54],[1968,65.05],[1969,65.45],[1970,65.78],[1971,66.07],[1972,66.37],[1973,66.73],[1974,67.16],[1975,67.7],[1976,68.36],[1977,69.14],[1978,69.99],[1979,70.89],[1980,71.8],[1981,72.68],[1982,73.49],[1983,74.19],[1984,74.78],[1985,75.26],[1986,75.65],[1987,75.99],[1988,76.3],[1989,76.6],[1990,76.9],[1991,77.2],[1992,77.5],[1993,77.78],[1994,78.04],[1995,78.28],[1996,78.49],[1997,78.66],[1998,78.81],[1999,78.92],[2000,79.04],[2001,79.16],[2002,79.32],[2003,79.51],[2004,79.74],[2005,79.99],[2006,80.26],[2007,80.52],[2008,80.75],[2009,80.95]]},{"name":"Malaysia","region":"East Asia & Pacific","income":[[1800,750.13],[1820,750.13],[1870,824.43],[1911,996.55],[1912,1022.69],[1913,1120.15],[1914,1145.08],[1915,1166.82],[1916,1239.48],[1917,1286.2],[1918,1206.41],[1919,1440.43],[1920,1381.68],[1921,1337.64],[1922,1433.21],[1923,1381.09],[1924,1319.17],[1925,1494.64],[1926,1638.28],[1927,1557.04],[1928,1729.11],[1929,2093.56],[1930,2035.7],[1931,1926.89],[1932,1738.25],[1933,1791.53],[1934,1916.1],[1935,1697.92],[1936,1839.35],[1937,1628.32],[1938,1694.21],[1939,2002.74],[1940,1590.46],[1941,1541.08],[1942,2081.61],[1947,1330.46],[1948,1474.53],[1949,1904.73],[1950,1940.39],[1951,1792.01],[1952,1831.13],[1953,1791.86],[1954,1854.52],[1955,1817.19],[1956,1873.35],[1957,1810.07],[1958,1758.4],[1959,1826.02],[1960,1904.48],[1961,1981.4],[1962,2036.88],[1963,2077.26],[1964,2149.87],[1965,2245.03],[1966,2297.59],[1967,2277.74],[1968,2416.93],[1969,2495.56],[1970,2587.36],[1971,2713.47],[1972,2849.09],[1973,3185.7],[1974,3345.33],[1975,3295.77],[1976,3621.68],[1977,3827.92],[1978,4069.95],[1979,4301.4],[1980,4550.58],[1981,4758.29],[1982,4920.36],[1983,5096.8],[1984,5360.36],[1985,5172.8],[1986,5108.03],[1987,5249.8],[1988,5577.66],[1989,5960.93],[1990,6386.02],[1991,6838.2],[1992,7277.91],[1993,7815.3],[1994,8342.82],[1995,8961.56],[1996,9644.79],[1997,10132.91],[1998,9191.52],[1999,9553.52],[2000,10161.49],[2001,9994.62],[2002,10206.98],[2003,10597.64],[2004,11119.9],[2005,11466],[2006,11933.76],[2007,12459.59],[2008,12818.9],[2009,12387.67]],"population":[[1800,287000],[1820,287000],[1850,530000],[1870,800000],[1890,1585000],[1900,2232000],[1901,2288000],[1902,2345000],[1903,2404000],[1904,2467000],[1905,2532000],[1906,2601000],[1907,2672000],[1908,2745000],[1909,2821000],[1910,2893000],[1911,2967000],[1912,3025000],[1913,3084000],[1914,3144000],[1915,3207000],[1916,3271000],[1917,3337000],[1918,3404000],[1919,3473000],[1920,3545000],[1921,3618000],[1922,3698000],[1923,3779000],[1924,3863000],[1925,3949000],[1926,4038000],[1927,4128000],[1928,4221000],[1929,4316000],[1930,4413000],[1931,4513000],[1932,4604000],[1933,4697000],[1934,4793000],[1935,4890000],[1936,4993000],[1937,5099000],[1938,5207000],[1939,5317000],[1940,5434000],[1941,5554000],[1942,5592000],[1943,5630000],[1944,5668000],[1945,5707000],[1946,5746000],[1947,5786000],[1948,5922000],[1949,6061000],[1950,6433799],[1951,6581839],[1952,6748378],[1953,6928942],[1954,7117564],[1955,7311720],[1956,7519663],[1957,7739235],[1958,7965930],[1959,8195711],[1960,8428493],[1961,8663401],[1962,8906385],[1963,9148451],[1964,9397464],[1965,9647654],[1966,9899803],[1967,10154878],[1968,10409339],[1969,10662303],[1970,10910216],[1971,11171333],[1972,11441462],[1973,11711866],[1974,11986260],[1975,12267303],[1976,12553963],[1977,12845381],[1978,13138530],[1979,13443844],[1980,13764352],[1981,14096663],[1982,14441916],[1983,14793099],[1984,15157328],[1985,15545028],[1986,15941178],[1987,16331785],[1988,16729187],[1989,17117834],[1990,17503607],[1991,17906485],[1992,18319502],[1993,18747901],[1994,19180324],[1995,19611116],[1996,20044560],[1997,20476091],[1998,20911977],[1999,21354459],[2000,21793293],[2001,22229040],[2002,22662365],[2003,23092940],[2004,23522482],[2005,23953136],[2006,24385858],[2007,24821286],[2008,25259428]],"lifeExpectancy":[[1800,30.6],[1930,30.6],[1950,47.01],[1951,47.37],[1952,48.1],[1953,48.83],[1954,49.56],[1955,50.28],[1956,51.01],[1957,51.74],[1958,52.47],[1959,53.19],[1960,53.92],[1961,54.65],[1962,55.37],[1963,56.1],[1964,56.83],[1965,57.56],[1966,58.3],[1967,59.05],[1968,59.81],[1969,60.56],[1970,61.3],[1971,61.99],[1972,62.62],[1973,63.2],[1974,63.72],[1975,64.21],[1976,64.67],[1977,65.15],[1978,65.64],[1979,66.16],[1980,66.69],[1981,67.21],[1982,67.7],[1983,68.14],[1984,68.53],[1985,68.87],[1986,69.16],[1987,69.41],[1988,69.66],[1989,69.89],[1990,70.12],[1991,70.36],[1992,70.6],[1993,70.83],[1994,71.08],[1995,71.32],[1996,71.57],[1997,71.81],[1998,72.04],[1999,72.27],[2000,72.5],[2001,72.72],[2002,72.95],[2003,73.18],[2004,73.42],[2005,73.66],[2006,73.89],[2007,74.12],[2008,74.33],[2009,74.54]]},{"name":"Micronesia, Fed. Sts.","region":"East Asia & Pacific","income":[[1800,553.05],[1820,553.05],[1913,747.68],[1970,3428.19],[1971,3469.53],[1972,3495.18],[1973,4682.78],[1974,5384.38],[1975,5331.31],[1976,5247.19],[1977,5234.55],[1978,5358.55],[1979,5291],[1980,4748.19],[1981,5037.39],[1982,4745.83],[1983,4692.94],[1984,4372.64],[1985,4958.08],[1986,5220.78],[1987,5205.1],[1988,5399.42],[1989,5316.17],[1990,5408.71],[1991,5603.02],[1992,5659.93],[1993,5899.17],[1994,5898.48],[1995,5918.56],[1996,5582.74],[1997,5238.14],[1998,5217.37],[1999,5053.2],[2000,5530.16],[2001,5543.41],[2002,5565.15],[2003,5534.02],[2004,5458.99],[2005,5508],[2006,5399.22],[2007,5189.39],[2008,4994.56]],"population":[[1800,16416],[1820,16416],[1950,30715],[1951,31674],[1952,32664],[1953,33684],[1954,34736],[1955,35821],[1956,36940],[1957,38094],[1958,39284],[1959,40511],[1960,41777],[1961,43081],[1962,44427],[1963,45815],[1964,47246],[1965,48722],[1966,50244],[1967,51813],[1968,53432],[1969,55101],[1970,56822],[1971,58597],[1972,60427],[1973,62731],[1974,64241],[1975,66222],[1976,68263],[1977,70368],[1978,72538],[1979,74774],[1980,77080],[1981,79581],[1982,82188],[1983,84942],[1984,87784],[1985,90631],[1986,94151],[1987,97727],[1988,101343],[1989,104976],[1990,108600],[1991,111689],[1992,114694],[1993,117588],[1994,105444],[1995,105988],[1996,106479],[1997,106911],[1998,107264],[1999,107534],[2000,107754],[2001,107940],[2002,108071],[2003,108143],[2004,108155],[2005,108105],[2006,108004],[2007,107862],[2008,107673]],"lifeExpectancy":[[1950,53.78],[1951,53.98],[1952,54.38],[1953,54.78],[1954,55.18],[1955,55.58],[1956,55.98],[1957,56.38],[1958,56.78],[1959,57.18],[1960,57.58],[1961,57.98],[1962,58.38],[1963,58.78],[1964,59.18],[1965,59.58],[1966,59.98],[1967,60.39],[1968,60.8],[1969,61.21],[1970,61.63],[1971,62.07],[1972,62.52],[1973,62.97],[1974,63.42],[1975,63.84],[1976,64.22],[1977,64.55],[1978,64.82],[1979,65.02],[1980,65.17],[1981,65.28],[1982,65.37],[1983,65.45],[1984,65.54],[1985,65.64],[1986,65.75],[1987,65.87],[1988,65.98],[1989,66.1],[1990,66.21],[1991,66.33],[1992,66.44],[1993,66.55],[1994,66.67],[1995,66.78],[1996,66.88],[1997,66.99],[1998,67.08],[1999,67.18],[2000,67.29],[2001,67.4],[2002,67.53],[2003,67.68],[2004,67.85],[2005,68.03],[2006,68.22],[2007,68.42],[2008,68.61],[2009,68.81]]},{"name":"Mongolia","region":"East Asia & Pacific","income":[[1800,606.93],[1820,606.93],[1950,741.13],[1951,761.58],[1952,786.57],[1953,809.5],[1954,834.53],[1955,859.07],[1956,884.55],[1957,912.66],[1958,939.23],[1959,967.77],[1960,996.67],[1961,1026.27],[1962,1056.35],[1963,1089.39],[1964,1121.78],[1965,1155.34],[1966,1189.06],[1967,1226.04],[1968,1262.52],[1969,1299.6],[1970,1339.74],[1971,1380.61],[1972,1421.74],[1973,1464.19],[1974,1508.42],[1975,1553.03],[1976,1597.77],[1977,1647.51],[1978,1697],[1979,1748.19],[1980,1800],[1981,1897.49],[1982,2000.6],[1983,2059.48],[1984,2122.47],[1985,2182.38],[1986,2322.07],[1987,2338.01],[1988,2391.14],[1989,2389.38],[1990,2268.6],[1991,2011.76],[1992,1785.4],[1993,1705.62],[1994,1723.84],[1995,1814.11],[1996,1841.2],[1997,1902.25],[1998,1958.2],[1999,2009.38],[2000,2017.51],[2001,2061.51],[2002,2140.74],[2003,2269.92],[2004,2487.43],[2005,2643],[2006,2834.89],[2007,3081.2],[2008,3306.55],[2009,3205.17]],"population":[[1800,619000],[1820,619000],[1870,668000],[1913,725000],[1950,778555],[1951,788937],[1952,800663],[1953,813728],[1954,828075],[1955,844046],[1956,862063],[1957,882134],[1958,904296],[1959,928632],[1960,954652],[1961,981849],[1962,1010280],[1963,1031200],[1964,1060600],[1965,1090200],[1966,1119400],[1967,1149500],[1968,1181000],[1969,1214100],[1970,1247600],[1971,1283400],[1972,1320500],[1973,1360100],[1974,1402600],[1975,1445600],[1976,1487150],[1977,1528000],[1978,1571700],[1979,1617200],[1980,1662380],[1981,1708832],[1982,1756032],[1983,1805004],[1984,1855693],[1985,1907701],[1986,1960796],[1987,2015133],[1988,2070723],[1989,2159157],[1990,2216340],[1991,2268325],[1992,2312802],[1993,2349132],[1994,2383109],[1995,2420663],[1996,2458561],[1997,2494803],[1998,2530501],[1999,2565596],[2000,2600835],[2001,2637069],[2002,2674234],[2003,2712315],[2004,2751314],[2005,2791272],[2006,2832224],[2007,2874127],[2008,2916865]],"lifeExpectancy":[[1800,31.8],[1945,31.8],[1950,41.04],[1951,41.34],[1952,41.94],[1953,42.55],[1954,43.15],[1955,43.75],[1956,44.35],[1957,44.95],[1958,45.55],[1959,46.15],[1960,46.75],[1961,47.36],[1962,47.97],[1963,48.58],[1964,49.19],[1965,49.79],[1966,50.39],[1967,50.98],[1968,51.54],[1969,52.09],[1970,52.6],[1971,53.08],[1972,53.52],[1973,53.93],[1974,54.31],[1975,54.66],[1976,55],[1977,55.34],[1978,55.68],[1979,56.04],[1980,56.42],[1981,56.86],[1982,57.34],[1983,57.85],[1984,58.39],[1985,58.93],[1986,59.43],[1987,59.86],[1988,60.23],[1989,60.53],[1990,60.78],[1991,61.03],[1992,61.31],[1993,61.64],[1994,62.03],[1995,62.45],[1996,62.89],[1997,63.29],[1998,63.64],[1999,63.94],[2000,64.19],[2001,64.41],[2002,64.64],[2003,64.89],[2004,65.18],[2005,65.5],[2006,65.85],[2007,66.21],[2008,66.58],[2009,66.93]]},{"name":"Myanmar","region":"East Asia & Pacific","income":[[1800,569.07],[1820,569.07],[1821,569.07],[1822,569.07],[1823,569.07],[1824,569.07],[1825,569.07],[1826,569.07],[1827,569.07],[1828,569.07],[1829,569.07],[1830,569.07],[1831,569.07],[1832,569.07],[1833,569.07],[1834,569.07],[1835,569.07],[1836,569.07],[1837,569.07],[1838,569.07],[1839,569.07],[1840,569.07],[1841,569.07],[1842,569.07],[1843,569.07],[1844,569.07],[1845,569.07],[1846,569.07],[1847,569.07],[1848,569.07],[1849,569.07],[1850,569.07],[1851,569.07],[1852,569.07],[1853,569.07],[1854,569.07],[1855,569.07],[1856,569.07],[1857,569.07],[1858,569.07],[1859,569.07],[1860,569.07],[1861,569.07],[1862,569.07],[1863,569.07],[1864,569.07],[1865,569.07],[1866,569.07],[1867,569.07],[1868,569.07],[1869,569.07],[1870,569.07],[1871,575.11],[1872,581.21],[1873,587.37],[1874,593.6],[1875,599.9],[1876,606.26],[1877,612.69],[1878,619.18],[1879,625.75],[1880,632.39],[1881,639.09],[1882,645.87],[1883,652.72],[1884,659.64],[1885,666.64],[1886,673.71],[1887,680.85],[1888,688.07],[1889,695.37],[1890,702.74],[1891,710.2],[1892,717.73],[1893,725.34],[1894,733.03],[1895,740.8],[1896,748.66],[1897,756.6],[1898,764.62],[1899,772.73],[1900,780.93],[1901,789.21],[1902,756.71],[1903,725.54],[1904,695.66],[1905,667.01],[1906,639.54],[1907,648.35],[1908,657.29],[1909,666.35],[1910,675.53],[1911,684.84],[1912,729.23],[1913,773.61],[1914,822.21],[1915,873.85],[1916,928.74],[1917,902.04],[1918,876.1],[1919,850.9],[1920,826.43],[1921,802.67],[1922,824.63],[1923,847.19],[1924,870.37],[1925,894.19],[1926,918.65],[1927,937.88],[1928,957.51],[1929,977.55],[1930,998],[1931,1018.89],[1932,1003.98],[1933,989.28],[1934,974.8],[1935,960.54],[1936,946.48],[1937,889.09],[1938,835.19],[1939,792.94],[1940,752.82],[1941,714.74],[1942,602.94],[1943,508.63],[1944,429.07],[1945,430.2],[1946,433.47],[1947,436.76],[1948,440.07],[1949,443.42],[1950,446.78],[1951,504.07],[1952,507.32],[1953,512.73],[1954,473.51],[1955,526.86],[1956,552.87],[1957,576.11],[1958,551.27],[1959,626.29],[1960,636.33],[1961,640.73],[1962,684.61],[1963,691.68],[1964,691.54],[1965,696.34],[1966,655.15],[1967,661.14],[1968,691.49],[1969,706.5],[1970,724.44],[1971,733.81],[1972,725.05],[1973,708.8],[1974,732.19],[1975,749.09],[1976,780.88],[1977,813.38],[1978,853.53],[1979,878.84],[1980,935.13],[1981,970.19],[1982,1003.82],[1983,1027.35],[1984,1057.16],[1985,1067.1],[1986,1037.22],[1987,979.04],[1988,854.94],[1989,874.49],[1990,887.18],[1991,870.36],[1992,891.72],[1993,904.21],[1994,919.55],[1995,933.8],[1996,947.26],[1997,959.32],[1998,971.75],[1999,998.69],[2000,1034.45],[2001,1064.53],[2002,1097.67],[2003,1137.58],[2004,1175.12],[2005,1169.24],[2006,1154.04],[2007,1214.05],[2008,1255.33],[2009,1269.14]],"population":[[1800,3506000],[1820,3506000],[1850,3932000],[1870,4245000],[1890,7489000],[1900,10174000],[1901,10490000],[1902,10642000],[1903,10796000],[1904,10953000],[1905,11112000],[1906,11273000],[1907,11437000],[1908,11603000],[1909,11771000],[1910,11942000],[1911,12115000],[1912,12220000],[1913,12326000],[1914,12433000],[1915,12541000],[1916,12650000],[1917,12760000],[1918,12871000],[1919,12893000],[1920,13096000],[1921,13212000],[1922,13351000],[1923,13491000],[1924,13633000],[1925,13776000],[1926,13921000],[1927,14067000],[1928,14215000],[1929,14364000],[1930,14515000],[1931,14667000],[1932,14870000],[1933,15075000],[1934,15283000],[1935,15494000],[1936,15708000],[1937,15925000],[1938,16145000],[1939,16368000],[1940,16594000],[1941,16824000],[1942,16727000],[1943,16908000],[1944,17090000],[1945,17272000],[1946,17454000],[1947,17636000],[1948,17818000],[1949,18000000],[1950,19487657],[1951,19788012],[1952,20092996],[1953,20402681],[1954,20721139],[1955,21048631],[1956,21385445],[1957,21731844],[1958,22088118],[1959,22456123],[1960,22836232],[1961,23228868],[1962,23634436],[1963,24053395],[1964,24485982],[1965,24932663],[1966,25393924],[1967,25870271],[1968,26362230],[1969,26867423],[1970,27386228],[1971,27919082],[1972,28466390],[1973,29226657],[1974,29799458],[1975,30360478],[1976,30936848],[1977,31528087],[1978,32053297],[1979,32664235],[1980,33373316],[1981,34019441],[1982,34680442],[1983,35364794],[1984,36060228],[1985,36740515],[1986,37397074],[1987,38028578],[1988,38603755],[1989,39132189],[1990,39655394],[1991,40155099],[1992,40546538],[1993,40983821],[1994,41577366],[1995,42173781],[1996,42728314],[1997,43247867],[1998,43749992],[1999,44234615],[2000,44702243],[2001,45152531],[2002,45598081],[2003,46030343],[2004,46520134],[2005,46996558],[2006,47382633],[2007,47761980],[2008,48133102]],"lifeExpectancy":[[1800,30.8],[1926,30.8],[1941,30.8],[1942,28],[1943,28.5],[1944,28.1],[1945,28],[1948,30.8],[1950,33.43],[1951,34.23],[1952,35.76],[1953,37.16],[1954,38.43],[1955,39.57],[1956,40.59],[1957,41.49],[1958,42.29],[1959,43.02],[1960,43.69],[1961,44.35],[1962,45.03],[1963,45.74],[1964,46.5],[1965,47.32],[1966,48.17],[1967,49.03],[1968,49.87],[1969,50.69],[1970,51.46],[1971,52.2],[1972,52.91],[1973,53.6],[1974,54.26],[1975,54.88],[1976,55.48],[1977,56.04],[1978,56.57],[1979,57.05],[1980,57.48],[1981,57.84],[1982,58.12],[1983,58.32],[1984,58.46],[1985,58.55],[1986,58.61],[1987,58.65],[1988,58.71],[1989,58.79],[1990,58.88],[1991,58.99],[1992,59.1],[1993,59.19],[1994,59.28],[1995,59.37],[1996,59.46],[1997,59.56],[1998,59.67],[1999,59.8],[2000,59.94],[2001,60.08],[2002,60.2],[2003,60.31],[2004,60.43],[2005,60.59],[2006,60.83],[2007,61.16],[2008,61.6],[2009,62.14]]},{"name":"New Caledonia","region":"East Asia & Pacific","income":[[1800,944.24],[1820,944.24],[1913,1276.53],[1938,4910.2],[1950,9374.16],[1965,21036.53],[1966,19726.05],[1967,20213.73],[1968,22370.06],[1969,24974.42],[1970,31456.12],[1971,32333.81],[1972,32001.31],[1973,27196.04],[1974,29441.36],[1975,30307.07],[1976,30164.32],[1977,30062.78],[1978,32409.54],[1979,27531.77],[1980,26965.06],[1981,24658.06],[1982,24831.15],[1983,23929.05],[1984,23947.91],[1985,24596.34],[1986,23927.7],[1987,24837.87],[1988,32806.33],[1989,35684.01],[1990,36179.11],[1991,37085.95],[1992,36383.17],[1993,35674.86],[1994,35704.58],[1995,36928.13],[1996,36242.51],[1997,36147.49],[1998,34242.72],[1999,33846.34],[2000,33884.5],[2001,33412.18],[2002,32977.87],[2003,32475.12],[2004,32205.65],[2005,31942.83],[2006,31596.57],[2007,31268.19],[2008,30959.74]],"population":[[1800,29432],[1820,29432],[1950,55069],[1951,56780],[1952,58615],[1953,60581],[1954,62689],[1955,64948],[1956,67369],[1957,69963],[1958,72745],[1959,75790],[1960,78804],[1961,81774],[1962,84518],[1963,86978],[1964,88066],[1965,90360],[1966,93462],[1967,96094],[1968,99500],[1969,104000],[1970,112000],[1971,120000],[1972,125500],[1973,128500],[1974,131000],[1975,133000],[1976,134500],[1977,136000],[1978,137500],[1979,138800],[1980,139400],[1981,142500],[1982,145000],[1983,146584],[1984,149659],[1985,152591],[1986,155582],[1987,158737],[1988,161885],[1989,165003],[1990,168361],[1991,171988],[1992,175612],[1993,179152],[1994,182543],[1995,185833],[1996,189104],[1997,192347],[1998,195554],[1999,198714],[2000,201816],[2001,204863],[2002,207858],[2003,210798],[2004,213679],[2005,216494],[2006,219246],[2007,221943],[2008,224585]],"lifeExpectancy":[[1950,51.93],[1951,51.67],[1952,51.27],[1953,51.09],[1954,51.14],[1955,51.41],[1956,51.9],[1957,52.58],[1958,53.43],[1959,54.41],[1960,55.44],[1961,56.48],[1962,57.45],[1963,58.29],[1964,58.98],[1965,59.49],[1966,59.83],[1967,60.04],[1968,60.2],[1969,60.33],[1970,60.51],[1971,60.8],[1972,61.23],[1973,61.81],[1974,62.53],[1975,63.36],[1976,64.25],[1977,65.13],[1978,65.94],[1979,66.66],[1980,67.26],[1981,67.77],[1982,68.19],[1983,68.58],[1984,68.93],[1985,69.26],[1986,69.57],[1987,69.88],[1988,70.17],[1989,70.47],[1990,70.76],[1991,71.04],[1992,71.3],[1993,71.55],[1994,71.79],[1995,72.04],[1996,72.33],[1997,72.66],[1998,73.05],[1999,73.47],[2000,73.92],[2001,74.37],[2002,74.78],[2003,75.14],[2004,75.44],[2005,75.68],[2006,75.87],[2007,76.04],[2008,76.2],[2009,76.36]]},{"name":"New Zealand","region":"East Asia & Pacific","income":[[1800,541.62],[1820,541.62],[1830,541.62],[1840,541.62],[1850,1549.64],[1860,2995.32],[1870,4197.09],[1871,4272.02],[1872,4770.04],[1873,5187.36],[1874,5204.29],[1875,4993.57],[1876,4905.88],[1877,5392.46],[1878,5782.83],[1879,4832.93],[1880,5072.99],[1881,5097.49],[1882,4936.43],[1883,4732.12],[1884,5013.44],[1885,4857.29],[1886,4876.72],[1887,4880.12],[1888,4812.45],[1889,5011.68],[1890,5085.11],[1891,5052.04],[1892,5146.24],[1893,5129.69],[1894,4846.28],[1895,4930.96],[1896,5399.9],[1897,5348.29],[1898,5396.03],[1899,5471.55],[1900,5819.9],[1901,5718.83],[1902,6009.94],[1903,6401.25],[1904,6188.58],[1905,6567.15],[1906,6983.76],[1907,7229.98],[1908,6546.72],[1909,6459.44],[1910,7198.55],[1911,7438.95],[1912,7053.59],[1913,6976.62],[1914,7026.5],[1915,7005.58],[1916,6933.16],[1917,6781.35],[1918,6649.54],[1919,7153.07],[1920,7638.54],[1921,6943.69],[1922,6555.15],[1923,6965.89],[1924,6963.81],[1925,7165.07],[1926,6641.4],[1927,6340.65],[1928,6961.01],[1929,7125.34],[1930,6716.25],[1931,6059.54],[1932,5859.29],[1933,6196.13],[1934,6455.89],[1935,6715.24],[1936,7907.39],[1937,8261.82],[1938,8750.12],[1939,8746.7],[1940,8531.12],[1941,8298.68],[1942,9155.48],[1943,9380.86],[1944,9299.61],[1945,9381.26],[1946,9696.82],[1947,10624.33],[1948,9382.22],[1949,10183.21],[1950,11449.38],[1951,10362.99],[1952,10556.58],[1953,10637.22],[1954,11839],[1955,11814.68],[1956,12186.7],[1957,12247.4],[1958,12437.62],[1959,13039.68],[1960,12816.33],[1961,13195.1],[1962,13175.68],[1963,13719.26],[1964,14107.05],[1965,14730.25],[1966,15384.75],[1967,14463.92],[1968,14279.12],[1969,15586.76],[1970,15150.93],[1971,15674.74],[1972,16046.04],[1973,16823.02],[1974,17439.2],[1975,16910.21],[1976,17126.42],[1977,16233.72],[1978,16294.54],[1979,16633.44],[1980,16718.1],[1981,17445.44],[1982,17632.41],[1983,17919.54],[1984,18612.88],[1985,18647.68],[1986,18979.55],[1987,19007.19],[1988,18874.65],[1989,18983.92],[1990,18833.6],[1991,18380.78],[1992,18363.32],[1993,19337.19],[1994,20116.23],[1995,20661.48],[1996,21064.07],[1997,21050.41],[1998,20876.11],[1999,21689.01],[2000,21895.16],[2001,22426.59],[2002,23189.8],[2003,23728.48],[2004,24339.44],[2005,24554],[2006,24504.21],[2007,24926.5],[2008,24656.53],[2009,24009.46]],"population":[[1820,100000],[1830,100000],[1840,70000],[1850,90000],[1860,132000],[1870,291000],[1871,306000],[1872,320000],[1873,335000],[1874,367000],[1875,406000],[1876,434000],[1877,450000],[1878,467000],[1879,494000],[1880,520000],[1881,539000],[1882,555000],[1883,574000],[1884,598000],[1885,614000],[1886,626000],[1887,640000],[1888,649000],[1889,656000],[1890,665000],[1891,674000],[1892,686000],[1893,705000],[1894,722000],[1895,735000],[1896,748000],[1897,764000],[1898,779000],[1899,794000],[1900,807000],[1901,824000],[1902,844000],[1903,867000],[1904,893000],[1905,919000],[1906,946000],[1907,969000],[1908,996000],[1909,1024000],[1910,1045000],[1911,1067000],[1912,1092000],[1913,1122000],[1914,1143000],[1915,1152000],[1916,1155000],[1917,1152000],[1918,1156000],[1919,1195000],[1920,1241000],[1921,1275000],[1922,1304000],[1923,1326000],[1924,1350000],[1925,1382000],[1926,1412000],[1927,1437000],[1928,1454000],[1929,1471000],[1930,1493000],[1931,1514000],[1932,1527000],[1933,1540000],[1934,1552000],[1935,1562000],[1936,1573000],[1937,1587000],[1938,1604000],[1939,1627000],[1940,1636000],[1941,1629000],[1942,1639000],[1943,1633000],[1944,1654000],[1945,1688000],[1946,1759000],[1947,1797000],[1948,1833000],[1949,1871000],[1950,1908310],[1951,1947389],[1952,1994794],[1953,2047391],[1954,2092779],[1955,2136168],[1956,2178289],[1957,2229407],[1958,2281533],[1959,2331122],[1960,2371746],[1961,2432450],[1962,2488550],[1963,2541350],[1964,2591950],[1965,2640400],[1966,2687550],[1967,2728150],[1968,2759000],[1969,2788500],[1970,2828050],[1971,2875300],[1972,2929100],[1973,2992300],[1974,3058400],[1975,3117800],[1976,3153550],[1977,3164900],[1978,3165800],[1979,3164550],[1980,3170150],[1981,3185450],[1982,3210650],[1983,3245800],[1984,3278900],[1985,3298050],[1986,3308300],[1987,3317166],[1988,3331205],[1989,3341632],[1990,3359604],[1991,3396964],[1992,3437674],[1993,3475061],[1994,3517261],[1995,3565990],[1996,3621200],[1997,3676187],[1998,3726214],[1999,3774096],[2000,3819762],[2001,3864129],[2002,3908037],[2003,3951307],[2004,3993817],[2005,4035461],[2006,4076140],[2007,4115771],[2008,4154311]],"lifeExpectancy":[[1800,34.05],[1870,34.05],[1948,68.86],[1949,68.98],[1950,69.29],[1951,69.16],[1952,69.39],[1953,70.24],[1954,70.35],[1955,70.48],[1956,70.74],[1957,70.26],[1958,70.89],[1959,70.8],[1960,71.26],[1961,70.98],[1962,71.24],[1963,71.31],[1964,71.35],[1965,71.28],[1966,71.14],[1967,71.52],[1968,71.18],[1969,71.55],[1970,71.33],[1971,71.78],[1972,71.89],[1973,71.75],[1974,72],[1975,72.27],[1976,72.47],[1977,72.22],[1978,73.11],[1979,73.15],[1980,72.95],[1981,73.74],[1982,73.84],[1983,73.94],[1984,74.49],[1985,73.99],[1986,74.24],[1987,74.32],[1988,74.6],[1989,75.01],[1990,75.56],[1991,76.2],[1992,76.33],[1993,76.62],[1994,77.07],[1995,76.94],[1996,76.98],[1997,77.55],[1998,78.37],[1999,78.14],[2000,78.9],[2001,78.91],[2002,79.11],[2003,79.41],[2004,79.59],[2005,79.8],[2006,79.98],[2007,80.15],[2008,80.3],[2009,80.45]]},{"name":"Papua New Guinea","region":"East Asia & Pacific","income":[[1800,573.29],[1820,573.29],[1913,775.03],[1950,969.62],[1960,1120.04],[1961,1168.28],[1962,1220],[1963,1245.62],[1964,1325.88],[1965,1432.52],[1966,1484.36],[1967,1511.98],[1968,1543.68],[1969,1634.49],[1970,1771.1],[1971,1839.66],[1972,1898.54],[1973,1975.71],[1974,1981.1],[1975,1919.99],[1976,1814.91],[1977,1791.43],[1978,1903.45],[1979,1895.94],[1980,1809.71],[1981,1761.06],[1982,1722.78],[1983,1732.49],[1984,1681.73],[1985,1704.24],[1986,1739.11],[1987,1742.45],[1988,1748.27],[1989,1680.15],[1990,1588.26],[1991,1695.54],[1992,1880.96],[1993,2166.06],[1994,2235.06],[1995,2104.19],[1996,2206.73],[1997,2064.01],[1998,1933.43],[1999,1917.62],[2000,1821.68],[2001,1773.67],[2002,1727.29],[2003,1722.49],[2004,1728.51],[2005,1747],[2006,1745.9],[2007,1828.01],[2008,1905.5],[2009,1947.16]],"population":[[1800,754894],[1820,754894],[1950,1412466],[1951,1438163],[1952,1465469],[1953,1494506],[1954,1525366],[1955,1557902],[1956,1591955],[1957,1627752],[1958,1665511],[1959,1705225],[1960,1746986],[1961,1791048],[1962,1837378],[1963,1885929],[1964,1936607],[1965,1989516],[1966,2045085],[1967,2102625],[1968,2161618],[1969,2223233],[1970,2288056],[1971,2353081],[1972,2416549],[1973,2476980],[1974,2540118],[1975,2609796],[1976,2680390],[1977,2753462],[1978,2830006],[1979,2908571],[1980,2991217],[1981,3064312],[1982,3139596],[1983,3216925],[1984,3296419],[1985,3378233],[1986,3462394],[1987,3548932],[1988,3638032],[1989,3729905],[1990,3824787],[1991,3922925],[1992,4024135],[1993,4128174],[1994,4235157],[1995,4344820],[1996,4456781],[1997,4571004],[1998,4687521],[1999,4806270],[2000,4926984],[2001,5049055],[2002,5172033],[2003,5295816],[2004,5420280],[2005,5545268],[2006,5670544],[2007,5795887],[2008,5921144]],"lifeExpectancy":[[1800,31.5],[1946,31.5],[1950,33.67],[1951,33.92],[1952,34.42],[1953,34.93],[1954,35.43],[1955,35.93],[1956,36.44],[1957,36.94],[1958,37.44],[1959,37.94],[1960,38.44],[1961,38.94],[1962,39.44],[1963,39.94],[1964,40.44],[1965,40.94],[1966,41.41],[1967,41.87],[1968,42.33],[1969,42.79],[1970,43.29],[1971,43.85],[1972,44.5],[1973,45.23],[1974,46.05],[1975,46.92],[1976,47.84],[1977,48.75],[1978,49.63],[1979,50.43],[1980,51.13],[1981,51.71],[1982,52.18],[1983,52.55],[1984,52.82],[1985,53.05],[1986,53.24],[1987,53.45],[1988,53.69],[1989,53.97],[1990,54.3],[1991,54.64],[1992,54.97],[1993,55.28],[1994,55.57],[1995,55.85],[1996,56.15],[1997,56.48],[1998,56.85],[1999,57.28],[2000,57.74],[2001,58.23],[2002,58.71],[2003,59.16],[2004,59.59],[2005,59.98],[2006,60.33],[2007,60.66],[2008,60.98],[2009,61.29]]},{"name":"Philippines","region":"East Asia & Pacific","income":[[1800,626.97],[1820,626.97],[1870,669.73],[1902,722.13],[1903,862.59],[1904,728.86],[1905,760.94],[1906,775.46],[1907,801.87],[1908,831.78],[1909,831.4],[1910,938.44],[1911,979.62],[1912,978.25],[1913,1060.58],[1914,1021.54],[1915,939.39],[1916,1076.52],[1917,1231.94],[1918,1380.03],[1919,1301.39],[1920,1383.74],[1921,1326.03],[1922,1456.87],[1923,1341.59],[1924,1436.65],[1925,1420.6],[1926,1463.7],[1927,1466.19],[1928,1494],[1929,1516.23],[1930,1483.09],[1931,1460],[1932,1489.42],[1933,1468.54],[1934,1447.15],[1935,1317.45],[1936,1463.72],[1937,1532.46],[1938,1545.88],[1939,1619.02],[1940,1617.56],[1946,693.54],[1947,939.28],[1948,1065.52],[1949,1099.86],[1950,1148.81],[1951,1235.02],[1952,1272.88],[1953,1345.68],[1954,1404.09],[1955,1457.13],[1956,1513.28],[1957,1547.94],[1958,1554.15],[1959,1610.86],[1960,1584.52],[1961,1623.38],[1962,1649.55],[1963,1712.47],[1964,1717.62],[1965,1753.01],[1966,1775.28],[1967,1814.13],[1968,1848.05],[1969,1878.29],[1970,1893.6],[1971,1940.38],[1972,1989.37],[1973,2107.62],[1974,2123.74],[1975,2182.52],[1976,2310.26],[1977,2373.2],[1978,2427.5],[1979,2493.71],[1980,2549.91],[1981,2573.77],[1982,2603.27],[1983,2592.63],[1984,2348.4],[1985,2126.48],[1986,2148.12],[1987,2189.63],[1988,2285.43],[1989,2372],[1990,2386.91],[1991,2319.94],[1992,2279.32],[1993,2279.47],[1994,2328.83],[1995,2383.69],[1996,2464.68],[1997,2536.53],[1998,2469.84],[1999,2502.92],[2000,2598.89],[2001,2591.32],[2002,2650.92],[2003,2727.42],[2004,2847.41],[2005,2932],[2006,3027.82],[2007,3178.78],[2008,3236.92],[2009,3203.97]],"population":[[1800,2176000],[1820,2176000],[1850,3612000],[1870,5063000],[1890,6476000],[1900,7324000],[1901,7465000],[1902,7609000],[1903,7755000],[1904,7904000],[1905,8056000],[1906,8211000],[1907,8369000],[1908,8530000],[1909,8694000],[1910,8861000],[1911,9032000],[1912,9206000],[1913,9384000],[1914,9565000],[1915,9749000],[1916,9937000],[1917,10128000],[1918,10323000],[1919,10522000],[1920,10725000],[1921,10932000],[1922,11143000],[1923,11358000],[1924,11577000],[1925,11800000],[1926,12026000],[1927,12305000],[1928,12543000],[1929,12890000],[1930,13194000],[1931,13507000],[1932,13829000],[1933,14158000],[1934,14497000],[1935,14843000],[1936,15199000],[1937,15563000],[1938,15934000],[1939,16275000],[1940,16585000],[1941,16902000],[1942,17169000],[1943,17552000],[1944,17887000],[1945,18228000],[1946,18775000],[1947,19338000],[1948,19918000],[1949,20516000],[1950,21131264],[1951,21775167],[1952,22438691],[1953,23122432],[1954,23827009],[1955,24553055],[1956,25301226],[1957,26072194],[1958,26866654],[1959,27685324],[1960,28528939],[1961,29410457],[1962,30325264],[1963,31273198],[1964,32254350],[1965,33267569],[1966,34304274],[1967,35356600],[1968,36424438],[1969,37506719],[1970,38603696],[1971,39718094],[1972,40850141],[1973,41998117],[1974,43162098],[1975,44336842],[1976,45574350],[1977,46850962],[1978,48171780],[1979,49537371],[1980,50940182],[1981,52195262],[1982,53456774],[1983,54697515],[1984,55963794],[1985,57288037],[1986,58648857],[1987,60017788],[1988,61384736],[1989,62814469],[1990,64318120],[1991,65788832],[1992,67185766],[1993,68610958],[1994,70111842],[1995,71717437],[1996,73386057],[1997,75012988],[1998,76576177],[1999,78133918],[2000,79739825],[2001,81369751],[2002,82995088],[2003,84619974],[2004,86241697],[2005,87857473],[2006,89468677],[2007,91077287],[2008,92681453]],"lifeExpectancy":[[1800,30.9],[1901,30.9],[1902,12.7],[1903,30.9],[1917,30.9],[1918,25.6],[1919,30.9],[1930,30.9],[1938,40],[1941,42],[1942,41.9],[1943,42],[1944,41.9],[1945,40.5],[1946,41],[1950,46.36],[1951,46.71],[1952,47.41],[1953,48.12],[1954,48.84],[1955,49.58],[1956,50.32],[1957,51.07],[1958,51.81],[1959,52.54],[1960,53.23],[1961,53.87],[1962,54.45],[1963,54.95],[1964,55.38],[1965,55.74],[1966,56.06],[1967,56.35],[1968,56.64],[1969,56.93],[1970,57.24],[1971,57.58],[1972,57.94],[1973,58.31],[1974,58.69],[1975,59.08],[1976,59.49],[1977,59.9],[1978,60.31],[1979,60.72],[1980,61.13],[1981,61.54],[1982,61.95],[1983,62.36],[1984,62.77],[1985,63.19],[1986,63.62],[1987,64.06],[1988,64.51],[1989,64.96],[1990,65.43],[1991,65.88],[1992,66.34],[1993,66.78],[1994,67.2],[1995,67.61],[1996,68],[1997,68.39],[1998,68.77],[1999,69.14],[2000,69.49],[2001,69.84],[2002,70.17],[2003,70.48],[2004,70.78],[2005,71.07],[2006,71.34],[2007,71.6],[2008,71.85],[2009,72.1]]},{"name":"Samoa","region":"East Asia & Pacific","income":[[1800,1308.44],[1820,1308.44],[1913,1768.9],[1973,3667.7],[1974,3247.05],[1975,3098.02],[1976,3360.96],[1977,3311.52],[1978,3496.44],[1979,3938.62],[1980,3684.4],[1981,3343.02],[1982,3301.91],[1983,3310.12],[1984,3345.52],[1985,3466.03],[1986,3642.49],[1987,3642.57],[1988,3569.52],[1989,3678.48],[1990,3491.92],[1991,3387.06],[1992,3354.37],[1993,3463.17],[1994,3344.81],[1995,3529.46],[1996,3746.22],[1997,3734.02],[1998,3780.31],[1999,3854.83],[2000,4090.83],[2001,4386.17],[2002,4435.87],[2003,4545.09],[2004,4667.13],[2005,4872],[2006,4963.4],[2007,5052.76],[2008,5281.41],[2009,5003.61]],"population":[[1800,47300],[1850,46899],[1900,33000],[1906,37000],[1911,38000],[1921,36000],[1926,40000],[1936,56000],[1945,68000],[1950,81858],[1951,84351],[1952,86746],[1953,89031],[1954,91357],[1955,93857],[1956,96619],[1957,99661],[1958,102902],[1959,106412],[1960,110043],[1961,113621],[1962,117081],[1963,120526],[1964,123874],[1965,127151],[1966,130240],[1967,133162],[1968,136151],[1969,139206],[1970,142331],[1971,145356],[1972,148489],[1973,149436],[1974,149966],[1975,150839],[1976,151200],[1977,152748],[1978,153529],[1979,154339],[1980,155177],[1981,156046],[1982,158084],[1983,160155],[1984,162265],[1985,164417],[1986,165746],[1987,166575],[1988,166509],[1989,167389],[1990,170477],[1991,172553],[1992,174011],[1993,177551],[1994,181436],[1995,181623],[1996,180516],[1997,180418],[1998,180177],[1999,179843],[2000,179466],[2001,179058],[2002,178631],[2003,178173],[2004,177714],[2005,177287],[2006,176908],[2007,176615],[2008,176418]],"lifeExpectancy":[[1950,44.9],[1951,45.15],[1952,45.67],[1953,46.18],[1954,46.7],[1955,47.21],[1956,47.73],[1957,48.24],[1958,48.75],[1959,49.27],[1960,49.78],[1961,50.29],[1962,50.8],[1963,51.31],[1964,51.83],[1965,52.34],[1966,52.84],[1967,53.35],[1968,53.86],[1969,54.37],[1970,54.88],[1971,55.38],[1972,55.89],[1973,56.4],[1974,56.9],[1975,57.4],[1976,57.91],[1977,58.41],[1978,58.91],[1979,59.41],[1980,59.92],[1981,60.42],[1982,60.92],[1983,61.42],[1984,61.92],[1985,62.42],[1986,62.92],[1987,63.41],[1988,63.91],[1989,64.4],[1990,64.89],[1991,65.38],[1992,65.86],[1993,66.35],[1994,66.83],[1995,67.3],[1996,67.74],[1997,68.17],[1998,68.56],[1999,68.93],[2000,69.28],[2001,69.6],[2002,69.91],[2003,70.21],[2004,70.51],[2005,70.81],[2006,71.1],[2007,71.38],[2008,71.65],[2009,71.92]]},{"name":"Singapore","region":"East Asia & Pacific","income":[[1800,861.82],[1820,861.82],[1870,955.91],[1900,2181.19],[1901,2402.4],[1902,2270.96],[1903,1953.69],[1904,1888.04],[1905,2090],[1906,2349.06],[1907,2141.77],[1908,2460.38],[1909,2487.7],[1910,2702.41],[1911,2420.61],[1912,2070.75],[1913,1791.8],[1914,2141.85],[1915,2184.41],[1916,1805.95],[1917,2502.44],[1918,1956.12],[1919,2219.48],[1920,1911.46],[1921,2158.63],[1922,2851.87],[1923,2920.33],[1924,2856.89],[1925,3218.95],[1926,2656.8],[1927,1964.79],[1928,2334.94],[1929,3287.13],[1930,3016.41],[1931,2221.66],[1932,1933.51],[1933,2735.08],[1934,3226.93],[1935,3635.38],[1936,3611.6],[1937,3923.18],[1938,3326.45],[1939,3869.21],[1950,3533.04],[1951,3331.42],[1952,2315.14],[1953,2762.9],[1954,3166.36],[1955,2912.65],[1956,3204.49],[1957,2843.1],[1958,2849.15],[1959,3202.78],[1960,3426.03],[1961,3782.96],[1962,3674.74],[1963,3907.52],[1964,3827.09],[1965,4181.25],[1966,4527.16],[1967,4977.42],[1968,5566.63],[1969,6236.47],[1970,6993.76],[1971,7704.6],[1972,8597.76],[1973,9392.46],[1974,9803.18],[1975,9965.82],[1976,10537.03],[1977,11210.09],[1978,12025.08],[1979,13004.71],[1980,14103.68],[1981,14781.26],[1982,15169.16],[1983,16265.91],[1984,17312.22],[1985,17037.04],[1986,17417.21],[1987,18861.53],[1988,20542.93],[1989,21986.22],[1990,23142.8],[1991,23983.76],[1992,24769.89],[1993,27040.11],[1994,29303.24],[1995,30793.47],[1996,31934.8],[1997,33519.48],[1998,31918.24],[1999,33981.15],[2000,36834.85],[2001,34910.71],[2002,36023.11],[2003,37024.32],[2004,39796.67],[2005,41479],[2006,43689.11],[2007,45351.51],[2008,45196.46],[2009,43526.04]],"population":[[1800,30000],[1820,30000],[1850,56000],[1870,84000],[1890,157000],[1900,215000],[1913,323000],[1914,331000],[1915,341000],[1916,351000],[1917,360000],[1918,370000],[1919,380000],[1920,391000],[1921,418000],[1922,436000],[1923,458000],[1924,469000],[1925,492000],[1926,511000],[1927,532000],[1928,553000],[1929,575000],[1930,596000],[1931,563000],[1932,580000],[1933,515000],[1934,525000],[1935,572000],[1936,603000],[1937,651000],[1938,710000],[1939,728000],[1940,751000],[1941,769000],[1947,938000],[1948,961000],[1949,979000],[1950,1022100],[1951,1068100],[1952,1127000],[1953,1191800],[1954,1248200],[1955,1305500],[1956,1371600],[1957,1445929],[1958,1518800],[1959,1587200],[1960,1646400],[1961,1702400],[1962,1750200],[1963,1795000],[1964,1841600],[1965,1886900],[1966,1934400],[1967,1977600],[1968,2012000],[1969,2042500],[1970,2074507],[1971,2112900],[1972,2152400],[1973,2193000],[1974,2229800],[1975,2262600],[1976,2293300],[1977,2325300],[1978,2353600],[1979,2383500],[1980,2413900],[1981,2535368],[1982,2651869],[1983,2689263],[1984,2743297],[1985,2749897],[1986,2750069],[1987,2794552],[1988,2869266],[1989,2957752],[1990,3047100],[1991,3144576],[1992,3235865],[1993,3328154],[1994,3427979],[1995,3542866],[1996,3672284],[1997,3802309],[1998,3904528],[1999,3967753],[2000,4036753],[2001,4120228],[2002,4197776],[2003,4276788],[2004,4353893],[2005,4425720],[2006,4492150],[2007,4553009],[2008,4608167]],"lifeExpectancy":[[1800,29.1],[1819,29.1],[1824,34],[1920,34],[1950,59.25],[1951,59.54],[1952,60.11],[1953,60.69],[1954,61.25],[1955,61.81],[1956,62.37],[1957,62.92],[1958,63.47],[1959,64.01],[1960,64.54],[1961,65.06],[1962,65.56],[1963,66.05],[1964,66.51],[1965,66.95],[1966,67.37],[1967,67.76],[1968,68.13],[1969,68.48],[1970,68.8],[1971,69.11],[1972,69.4],[1973,69.68],[1974,69.95],[1975,70.2],[1976,70.44],[1977,70.66],[1978,70.86],[1979,71.05],[1980,71.24],[1981,71.44],[1982,71.66],[1983,71.92],[1984,72.21],[1985,72.55],[1986,72.94],[1987,73.39],[1988,73.87],[1989,74.37],[1990,74.87],[1991,75.34],[1992,75.77],[1993,76.13],[1994,76.43],[1995,76.69],[1996,76.91],[1997,77.13],[1998,77.37],[1999,77.64],[2000,77.93],[2001,78.26],[2002,78.61],[2003,78.96],[2004,79.3],[2005,79.63],[2006,79.92],[2007,80.18],[2008,80.4],[2009,80.58]]},{"name":"Solomon Islands","region":"East Asia & Pacific","income":[[1800,387.81],[1820,387.81],[1913,530.57],[1967,1304.6],[1968,1324.79],[1969,1245.96],[1970,1266.6],[1971,1251.52],[1972,864.97],[1973,929.95],[1974,1132.36],[1975,962.54],[1976,1057.78],[1977,1169.54],[1978,1231.07],[1979,1485.47],[1980,1348.15],[1981,1477.18],[1982,1467.4],[1983,1613.28],[1984,1579.09],[1985,1542.15],[1986,1792.38],[1987,1783.65],[1988,1797.15],[1989,1889.78],[1990,1870.13],[1991,1926.76],[1992,2109.89],[1993,2131.6],[1994,2261.81],[1995,2379.19],[1996,2350.19],[1997,2252.49],[1998,2230.07],[1999,2159.41],[2000,1802.02],[2001,1597.23],[2002,1530.5],[2003,1587.57],[2004,1671.75],[2005,1712],[2006,1780.28],[2007,1917.09],[2008,2001.01],[2009,1903.69]],"population":[[1800,56998],[1820,56998],[1931,94000],[1950,106647],[1951,107978],[1952,109424],[1953,110989],[1954,112677],[1955,114495],[1956,116446],[1957,118537],[1958,120775],[1959,123166],[1960,126363],[1961,129642],[1962,133007],[1963,136459],[1964,140000],[1965,143000],[1966,147000],[1967,151000],[1968,154000],[1969,158000],[1970,163000],[1971,168500],[1972,174500],[1973,180500],[1974,186500],[1975,193000],[1976,199500],[1977,207339],[1978,215444],[1979,223814],[1980,232452],[1981,241354],[1982,250516],[1983,259953],[1984,269681],[1985,279720],[1986,290061],[1987,300694],[1988,311637],[1989,322908],[1990,334524],[1991,346469],[1992,358713],[1993,371256],[1994,384099],[1995,397238],[1996,410641],[1997,424265],[1998,438082],[1999,452067],[2000,466194],[2001,480442],[2002,494786],[2003,509190],[2004,523617],[2005,538032],[2006,552438],[2007,566842],[2008,581208]],"lifeExpectancy":[[1800,25.7],[1944,25.7],[1950,44.37],[1951,44.62],[1952,45.13],[1953,45.64],[1954,46.15],[1955,46.65],[1956,47.16],[1957,47.66],[1958,48.17],[1959,48.67],[1960,49.17],[1961,49.68],[1962,50.18],[1963,50.68],[1964,51.19],[1965,51.7],[1966,52.2],[1967,52.71],[1968,53.22],[1969,53.73],[1970,54.24],[1971,54.77],[1972,55.31],[1973,55.85],[1974,56.39],[1975,56.91],[1976,57.41],[1977,57.87],[1978,58.27],[1979,58.58],[1980,58.77],[1981,58.77],[1982,58.56],[1983,58.19],[1984,57.69],[1985,57.15],[1986,56.66],[1987,56.33],[1988,56.21],[1989,56.32],[1990,56.66],[1991,57.16],[1992,57.76],[1993,58.38],[1994,58.97],[1995,59.53],[1996,60.06],[1997,60.57],[1998,61.09],[1999,61.62],[2000,62.15],[2001,62.69],[2002,63.23],[2003,63.77],[2004,64.3],[2005,64.81],[2006,65.31],[2007,65.79],[2008,66.24],[2009,66.66]]},{"name":"Taiwan","region":"East Asia & Pacific","income":[[1800,871],[1820,871],[1821,871],[1822,871],[1823,871],[1824,871],[1825,871],[1826,871],[1827,871],[1828,871],[1829,871],[1830,871],[1831,871],[1832,871],[1833,871],[1834,871],[1835,871],[1836,871],[1837,871],[1838,871],[1839,871],[1840,871],[1841,871],[1842,871],[1843,871],[1844,871],[1845,871],[1846,871],[1847,871],[1848,871],[1849,871],[1850,871],[1851,871],[1852,871],[1853,871],[1854,871],[1855,871],[1856,871],[1857,871],[1858,871],[1859,871],[1860,871],[1861,871],[1862,871],[1863,871],[1864,871],[1865,871],[1866,871],[1867,871],[1868,871],[1869,871],[1870,871],[1871,874],[1872,877],[1873,880],[1874,883],[1875,886],[1876,889],[1877,892],[1878,895],[1879,897],[1880,900],[1881,903],[1882,906],[1883,909],[1884,912],[1885,915],[1886,918],[1887,921],[1888,924],[1889,927],[1890,930],[1891,933],[1892,936],[1893,940],[1894,943],[1895,946],[1896,949],[1897,952],[1898,955],[1899,958],[1900,961],[1901,964],[1902,974],[1903,1151],[1904,1099],[1905,905],[1906,938],[1907,1066],[1908,1080],[1909,1218],[1910,1277],[1911,1131],[1912,1144],[1913,1177],[1914,1161],[1915,1176],[1916,1267],[1917,1400],[1918,1364],[1919,1356],[1920,1378],[1921,1442],[1922,1551],[1923,1611],[1924,1689],[1925,1753],[1926,1783],[1927,1732],[1928,1720],[1929,1807],[1930,1827],[1931,1821],[1932,1830],[1933,1783],[1934,1799],[1935,1944],[1936,1982],[1937,1931],[1938,1949],[1939,1849],[1940,1722],[1941,1598],[1942,1624],[1943,1456],[1944,1220],[1945,647],[1946,680],[1947,851],[1948,1052],[1949,1172],[1950,1304],[1951,1359],[1952,1468],[1953,1550],[1954,1638],[1955,1708],[1956,1737],[1957,1801],[1958,1859],[1959,1932],[1960,1984],[1961,2048],[1962,2137],[1963,2265],[1964,2465],[1965,2664],[1966,2821],[1967,3043],[1968,3244],[1969,3453],[1970,3757],[1971,4141],[1972,4590],[1973,5072],[1974,5025],[1975,5160],[1976,5754],[1977,6207],[1978,6909],[1979,7328],[1980,7672],[1981,7980],[1982,8086],[1983,8594],[1984,9353],[1985,9662],[1986,10624],[1987,11815],[1988,12588],[1989,13457],[1990,14123],[1991,14990],[1992,15965],[1993,16852],[1994,17866],[1995,18791],[1996,19754],[1997,20813],[1998,21493],[1999,22478],[2000,23525],[2001,22768],[2002,23495],[2003,24056],[2004,25332],[2005,26069],[2006,27359],[2007,28892],[2008,29004],[2009,28361]],"population":[[1800,2000000],[1820,2000000],[1850,2200000],[1870,2345000],[1890,2500000],[1900,2864000],[1901,2903000],[1902,2942000],[1903,2982000],[1904,3022000],[1905,3085000],[1906,3140000],[1907,3172000],[1908,3200000],[1909,3232000],[1910,3275000],[1911,3334000],[1912,3402000],[1913,3469000],[1914,3528000],[1915,3562000],[1916,3583000],[1917,3621000],[1918,3658000],[1919,3692000],[1920,3736000],[1921,3797000],[1922,3870000],[1923,3940000],[1924,4009000],[1925,4095000],[1926,4195000],[1927,4289000],[1928,4388000],[1929,4493000],[1930,4614000],[1931,4742000],[1932,4867000],[1933,4995000],[1934,5128000],[1935,5255000],[1936,5384000],[1937,5530000],[1938,5678000],[1939,5821000],[1940,5987000],[1941,6163000],[1942,6339000],[1943,6507000],[1944,6520000],[1945,6533000],[1946,6546000],[1947,6346000],[1948,6697000],[1949,7280000],[1950,7981454],[1951,8251326],[1952,8550362],[1953,8849962],[1954,9159966],[1955,9485858],[1956,9825346],[1957,10164215],[1958,10500314],[1959,10852996],[1960,11209160],[1961,11563348],[1962,11918938],[1963,12276610],[1964,12631480],[1965,12977635],[1966,13321002],[1967,13648692],[1968,13962358],[1969,14282297],[1970,14598316],[1971,14918496],[1972,15226039],[1973,15525588],[1974,15824103],[1975,16122188],[1976,16450056],[1977,16785196],[1978,17111535],[1979,17450136],[1980,17848320],[1981,18177430],[1982,18501390],[1983,18803390],[1984,19083348],[1985,19337363],[1986,19555581],[1987,19757799],[1988,19976096],[1989,20207541],[1990,20278957],[1991,20492997],[1992,20686918],[1993,20883467],[1994,21087873],[1995,21282829],[1996,21448723],[1997,21628605],[1998,21823024],[1999,21993460],[2000,22151237],[2001,22303700],[2002,22454239],[2003,22603000],[2004,22749838],[2005,22894384],[2006,23036087],[2007,23174294],[2008,23308370]],"lifeExpectancy":[[1800,28.3],[1906,28.3],[1907,29.5],[1908,30.9],[1909,31.8],[1910,33.9],[1911,33.9],[1912,34],[1913,33.3],[1914,31.9],[1915,28.5],[1916,30],[1917,31.4],[1918,26.1],[1919,31.2],[1920,27.6],[1921,30],[1922,36.6],[1923,35.3],[1924,37.1],[1925,34.2],[1926,37],[1927,39.6],[1928,40.3],[1929,40.9],[1930,41.5],[1931,41.2],[1932,41.3],[1933,42],[1934,42.6],[1935,42.8],[1936,42],[1937,42.5],[1938,43.7],[1939,43.6],[1940,43.8],[1950,54.6],[1951,55.1],[1952,58.5],[1953,60.3],[1954,62],[1955,62.4],[1956,62.5],[1957,62.4],[1958,64.2],[1959,64.2],[1960,64.4],[1961,64.9],[1962,65.2],[1963,66],[1964,66.7],[1965,67.4],[1966,67.4],[1967,67.5],[1968,67.6],[1969,68.6],[1970,68.69],[1971,69.1],[1972,69.39],[1973,69.45],[1974,69.81],[1975,70.07],[1976,70.43],[1977,70.59],[1978,71.16],[1979,71.31],[1980,71.54],[1981,71.65],[1982,72.16],[1983,72.15],[1984,72.81],[1985,72.99],[1986,73.12],[1987,73.39],[1988,73.21],[1989,73.52],[1990,73.8],[1991,74.27],[1992,74.25],[1993,74.53],[1994,74.7],[1995,74.51],[1996,74.69],[1997,75.21],[1998,75.4],[1999,75.51],[2000,76.07],[2001,76.45],[2002,76.93],[2003,77.13],[2004,77.25],[2005,77.25],[2006,77.99],[2007,78.16],[2008,78.36],[2009,78.6]]},{"name":"Thailand","region":"East Asia & Pacific","income":[[1800,496.98],[1820,496.98],[1870,530.09],[1890,683.55],[1913,732.93],[1929,691.86],[1938,720.58],[1950,712.4],[1951,740.14],[1952,757.8],[1953,815.46],[1954,783.36],[1955,823.98],[1956,810.62],[1957,793.58],[1958,796.7],[1959,865.04],[1960,940.12],[1961,958.99],[1962,1002.2],[1963,1050.68],[1964,1088.71],[1965,1140.35],[1966,1231.34],[1967,1295.46],[1968,1361.45],[1969,1426.51],[1970,1477.26],[1971,1503.77],[1972,1524.36],[1973,1633.64],[1974,1665.36],[1975,1707.84],[1976,1823.5],[1977,1961.22],[1978,2111.47],[1979,2176.35],[1980,2227.1],[1981,2313.84],[1982,2393.22],[1983,2482.77],[1984,2581.97],[1985,2659.44],[1986,2764.2],[1987,2982.65],[1988,3330.33],[1989,3684],[1990,4039.67],[1991,4327.9],[1992,4616.9],[1993,4940.01],[1994,5317.17],[1995,5734.62],[1996,6001.24],[1997,5852.63],[1998,5183.91],[1999,5366.1],[2000,5578.4],[2001,5656.2],[2002,5913.19],[2003,6273.01],[2004,6620.03],[2005,6869],[2006,7203.68],[2007,7505.99],[2008,7623.6],[2009,7376.17]],"population":[[1800,4665000],[1820,4665000],[1850,5230000],[1870,5775000],[1890,6670000],[1900,7320000],[1901,7413000],[1902,7507000],[1903,7602000],[1904,7699000],[1905,7797000],[1906,7896000],[1907,7996000],[1908,8098000],[1909,8201000],[1910,8305000],[1911,8431000],[1912,8559000],[1913,8689000],[1914,8822000],[1915,8957000],[1916,9094000],[1917,9232000],[1918,9418000],[1919,9608000],[1920,9802000],[1921,10000000],[1922,10202000],[1923,10435000],[1924,10673000],[1925,10916000],[1926,11165000],[1927,11419000],[1928,11734000],[1929,12058000],[1930,12392000],[1931,12735000],[1932,13087000],[1933,13399000],[1934,13718000],[1935,14045000],[1936,14379000],[1937,14721000],[1938,14980000],[1939,15244000],[1940,15513000],[1941,15787000],[1942,16060000],[1943,16462000],[1944,16868000],[1945,17284000],[1946,17710000],[1947,18148000],[1948,18569000],[1949,19000000],[1950,20041628],[1951,20653334],[1952,21289402],[1953,21964158],[1954,22684974],[1955,23451316],[1956,24244475],[1957,25041917],[1958,25845443],[1959,26667243],[1960,27512750],[1961,28376096],[1962,29263397],[1963,30173764],[1964,31106615],[1965,32061978],[1966,33035794],[1967,34024249],[1968,35028438],[1969,36049959],[1970,37090871],[1971,38201901],[1972,39276153],[1973,40302225],[1974,41305651],[1975,42272000],[1976,43221022],[1977,44148285],[1978,45056957],[1979,46003776],[1980,47025764],[1981,47936504],[1982,48827160],[1983,49694245],[1984,50533778],[1985,51341809],[1986,52129476],[1987,52910342],[1988,53683427],[1989,54445689],[1990,55196722],[1991,55930062],[1992,56667095],[1993,57400686],[1994,58128738],[1995,58855798],[1996,59559308],[1997,60216677],[1998,60846042],[1999,61394684],[2000,61862928],[2001,62334375],[2002,62806748],[2003,63271021],[2004,63731437],[2005,64185502],[2006,64631595],[2007,65068149],[2008,65493298]],"lifeExpectancy":[[1800,30.4],[1930,30.4],[1937,40.3],[1939,40.3],[1941,38.3],[1943,38.3],[1944,38.1],[1947,41.8],[1948,49.9],[1950,51],[1951,51.14],[1952,51.44],[1953,51.75],[1954,52.09],[1955,52.44],[1956,52.81],[1957,53.21],[1958,53.62],[1959,54.04],[1960,54.48],[1961,54.93],[1962,55.39],[1963,55.86],[1964,56.34],[1965,56.82],[1966,57.31],[1967,57.81],[1968,58.33],[1969,58.85],[1970,59.39],[1971,59.93],[1972,60.48],[1973,61.04],[1974,61.6],[1975,62.2],[1976,62.85],[1977,63.56],[1978,64.32],[1979,65.12],[1980,65.93],[1981,66.71],[1982,67.44],[1983,68.07],[1984,68.59],[1985,68.97],[1986,69.22],[1987,69.33],[1988,69.35],[1989,69.28],[1990,69.15],[1991,68.98],[1992,68.79],[1993,68.6],[1994,68.44],[1995,68.3],[1996,68.21],[1997,68.14],[1998,68.1],[1999,68.08],[2000,68.09],[2001,68.12],[2002,68.17],[2003,68.23],[2004,68.32],[2005,68.42],[2006,68.55],[2007,68.7],[2008,68.88],[2009,69.08]]},{"name":"Timor-Leste","region":"East Asia & Pacific","income":[[1800,514.12],[1820,518.73],[1850,539.86],[1870,554.8],[1913,723.93],[1950,704.35],[1973,1244.57],[1990,2257.73],[1991,2419.65],[1992,2577.99],[1993,2746.85],[1994,2945.92],[1995,3188.04],[1996,3547.23],[1997,3756.34],[1998,3749.92],[1999,2442.67],[2000,2743.19],[2001,3082.86],[2002,2726.03],[2003,2400.73],[2004,2268.32],[2005,2203],[2006,2018.5],[2007,2133.7],[2008,2352.74],[2009,2475.68]],"population":[[1800,137262],[1820,137262],[1926,442000],[1935,461000],[1950,435529],[1951,442862],[1952,450195],[1953,457529],[1954,464862],[1955,472195],[1956,479528],[1957,486861],[1958,494194],[1959,501527],[1960,508860],[1961,517732],[1962,526603],[1963,535474],[1964,544346],[1965,553217],[1966,562088],[1967,570960],[1968,579831],[1969,588702],[1970,597574],[1971,613767],[1972,629961],[1973,646155],[1974,661194],[1975,676582],[1976,652698],[1977,628814],[1978,604930],[1979,581046],[1980,557162],[1981,576054],[1982,594947],[1983,613839],[1984,632731],[1985,651624],[1986,670516],[1987,689409],[1988,708301],[1989,727194],[1990,746086],[1991,771238],[1992,796343],[1993,821171],[1994,845714],[1995,870147],[1996,894488],[1997,918738],[1998,942909],[1999,967073],[2000,846599],[2001,899109],[2002,952618],[2003,997853],[2004,1019252],[2005,1040880],[2006,1062777],[2007,1084971],[2008,1107432],[2009,1130120]],"lifeExpectancy":[[1950,28.97],[1951,29.22],[1952,29.73],[1953,30.23],[1954,30.73],[1955,31.24],[1956,31.74],[1957,32.24],[1958,32.74],[1959,33.24],[1960,33.74],[1961,34.24],[1962,34.74],[1963,35.24],[1964,35.74],[1965,36.28],[1966,36.9],[1967,37.6],[1968,38.34],[1969,39.05],[1970,39.53],[1971,39.58],[1972,39.09],[1973,38.09],[1974,36.67],[1975,35.11],[1976,33.77],[1977,32.94],[1978,32.81],[1979,33.41],[1980,34.65],[1981,36.3],[1982,38.02],[1983,39.56],[1984,40.82],[1985,41.79],[1986,42.54],[1987,43.23],[1988,43.98],[1989,44.83],[1990,45.79],[1991,46.86],[1992,47.97],[1993,49.08],[1994,50.19],[1995,51.27],[1996,52.33],[1997,53.36],[1998,54.36],[1999,55.32],[2000,56.23],[2001,57.06],[2002,57.83],[2003,58.51],[2004,59.13],[2005,59.69],[2006,60.2],[2007,60.68],[2008,61.14],[2009,61.6]]},{"name":"Tokelau","region":"East Asia & Pacific","income":[[2005,889.43]],"population":[[1800,1009],[1843,1000],[1850,1000],[1900,350],[1950,1570],[1955,1599],[1960,1862],[1965,1853],[1970,1581],[1975,1569],[1980,1556],[1985,1593],[1990,1602],[1995,1478],[2000,1517],[2005,1401]],"lifeExpectancy":[[2006,69]]},{"name":"Tonga","region":"East Asia & Pacific","income":[[1800,667.71],[1820,667.71],[1913,902.69],[1973,1874.54],[1974,1955.67],[1975,2022.32],[1976,2036.5],[1977,2116.11],[1978,2129.73],[1979,2148.21],[1980,2479.03],[1981,2836.58],[1982,3287.05],[1983,3523.52],[1984,3626.13],[1985,3891.13],[1986,3979.68],[1987,4088.36],[1988,3988.06],[1989,3975.5],[1990,3867.01],[1991,4087.24],[1992,4070.07],[1993,4195.1],[1994,4378.54],[1995,4490.38],[1996,4540.02],[1997,4432.97],[1998,4539.39],[1999,4718.65],[2000,4886.27],[2001,5026],[2002,5084.22],[2003,5228.76],[2004,5270.86],[2005,5135],[2006,5106.83],[2007,5114.47],[2008,5142.53],[2009,5104.06]],"population":[[1800,18658],[1843,18500],[1850,18500],[1900,20000],[1901,21000],[1911,23000],[1921,25000],[1931,29000],[1939,34000],[1950,45744],[1951,47378],[1952,49066],[1953,50808],[1954,52607],[1955,54465],[1956,56428],[1957,58168],[1958,59962],[1959,61811],[1960,63718],[1961,65683],[1962,67709],[1963,69797],[1964,71949],[1965,74168],[1966,76456],[1967,78816],[1968,81249],[1969,81900],[1970,83100],[1971,84300],[1972,85600],[1973,86800],[1974,87700],[1975,89200],[1976,90200],[1977,90593],[1978,90977],[1979,91352],[1980,91361],[1981,91769],[1982,92201],[1983,92628],[1984,92883],[1985,93352],[1986,93744],[1987,93982],[1988,93290],[1989,92744],[1990,92073],[1991,91218],[1992,92094],[1993,93734],[1994,94398],[1995,95158],[1996,96165],[1997,97399],[1998,98835],[1999,100475],[2000,102321],[2001,104227],[2002,106137],[2003,108141],[2004,110237],[2005,112422],[2006,114689],[2007,116921],[2008,118993]],"lifeExpectancy":[[1950,57.91],[1951,58.1],[1952,58.47],[1953,58.84],[1954,59.2],[1955,59.58],[1956,59.95],[1957,60.32],[1958,60.69],[1959,61.06],[1960,61.43],[1961,61.8],[1962,62.16],[1963,62.52],[1964,62.88],[1965,63.23],[1966,63.58],[1967,63.93],[1968,64.27],[1969,64.61],[1970,64.94],[1971,65.26],[1972,65.56],[1973,65.83],[1974,66.09],[1975,66.33],[1976,66.56],[1977,66.79],[1978,67.02],[1979,67.26],[1980,67.5],[1981,67.75],[1982,68],[1983,68.24],[1984,68.48],[1985,68.7],[1986,68.91],[1987,69.1],[1988,69.27],[1989,69.42],[1990,69.55],[1991,69.67],[1992,69.78],[1993,69.89],[1994,70],[1995,70.11],[1996,70.22],[1997,70.35],[1998,70.47],[1999,70.61],[2000,70.75],[2001,70.88],[2002,71.02],[2003,71.16],[2004,71.3],[2005,71.43],[2006,71.56],[2007,71.69],[2008,71.83],[2009,71.96]]},{"name":"Vietnam","region":"East Asia & Pacific","income":[[1800,459.71],[1820,459.71],[1870,440.8],[1913,634.17],[1950,573.94],[1951,589.87],[1952,605.07],[1953,621.19],[1954,638.49],[1955,654.19],[1956,665.99],[1957,676.29],[1958,684.6],[1959,690.41],[1960,696.95],[1961,708.2],[1962,772.05],[1963,769.51],[1964,780.9],[1965,764.66],[1966,749.36],[1967,637.12],[1968,609.88],[1969,644.57],[1970,641.06],[1971,657.68],[1972,699.5],[1973,729.17],[1974,683.26],[1975,619.17],[1976,705.88],[1977,713.54],[1978,702.65],[1979,693.39],[1980,660.36],[1981,668.83],[1982,707.24],[1983,729.51],[1984,777.06],[1985,805.22],[1986,809.93],[1987,820.8],[1988,851.42],[1989,868.8],[1990,893.88],[1991,927.11],[1992,989.02],[1993,1049.36],[1994,1121.67],[1995,1208.14],[1996,1300.38],[1997,1385.9],[1998,1445.95],[1999,1495.63],[2000,1577.53],[2001,1666.51],[2002,1764.46],[2003,1872.13],[2004,1996.87],[2005,2142],[2006,2289.34],[2007,2453.8],[2008,2574.44],[2009,2679.34]],"population":[[1800,6551000],[1820,6551000],[1870,10528000],[1913,19339000],[1950,25348144],[1951,25793577],[1952,26246839],[1953,26724094],[1954,27210027],[1955,27738063],[1956,28327287],[1957,28998543],[1958,29775192],[1959,30682902],[1960,31656282],[1961,32701357],[1962,33796140],[1963,34932464],[1964,36099052],[1965,37258369],[1966,38378468],[1967,39463910],[1968,40511528],[1969,41542068],[1970,42576676],[1971,43614366],[1972,44655014],[1973,45736496],[1974,46902295],[1975,48075207],[1976,49273016],[1977,50533506],[1978,51662728],[1979,52668447],[1980,53715202],[1981,54902677],[1982,56142181],[1983,57436347],[1984,58762040],[1985,60093068],[1986,61439826],[1987,62826491],[1988,64211347],[1989,65868481],[1990,67282704],[1991,68639527],[1992,69940728],[1993,71243961],[1994,72538927],[1995,73772337],[1996,74941175],[1997,76048996],[1998,77092383],[1999,78089676],[2000,79060410],[2001,79999453],[2002,80908147],[2003,81790803],[2004,82662800],[2005,83535576],[2006,84402966],[2007,85262356],[2008,86116559]],"lifeExpectancy":[[1800,32],[1930,32],[1936,33],[1950,39.42],[1951,39.67],[1952,40.17],[1953,40.66],[1954,41.16],[1955,41.65],[1956,42.15],[1957,42.64],[1958,43.13],[1959,43.63],[1960,44.13],[1961,44.62],[1962,45.12],[1963,45.61],[1964,46.11],[1965,46.6],[1966,47.06],[1967,47.49],[1968,47.91],[1969,48.34],[1970,48.82],[1971,49.4],[1972,50.11],[1973,50.95],[1974,51.92],[1975,52.96],[1976,54.01],[1977,55.02],[1978,55.93],[1979,56.74],[1980,57.45],[1981,58.09],[1982,58.71],[1983,59.35],[1984,60.04],[1985,60.8],[1986,61.63],[1987,62.53],[1988,63.47],[1989,64.44],[1990,65.41],[1991,66.35],[1992,67.24],[1993,68.05],[1994,68.79],[1995,69.45],[1996,70.04],[1997,70.59],[1998,71.11],[1999,71.61],[2000,72.08],[2001,72.51],[2002,72.91],[2003,73.26],[2004,73.56],[2005,73.83],[2006,74.07],[2007,74.29],[2008,74.5],[2009,74.7]]},{"name":"Vanuatu","region":"East Asia & Pacific","income":[[1800,829.58],[1820,829.58],[1913,1121.52],[1973,2282.11],[1974,2972.51],[1975,2746.96],[1976,2713.85],[1977,2605.69],[1978,2972.59],[1979,2999.82],[1980,2584.81],[1981,2624.32],[1982,2834.89],[1983,3359.3],[1984,3507.64],[1985,3464.31],[1986,3314.97],[1987,3251.27],[1988,3191.44],[1989,3217.72],[1990,3281.56],[1991,3574.86],[1992,3443.42],[1993,3492.04],[1994,3482.08],[1995,3555.62],[1996,3729.75],[1997,3840.47],[1998,3936.02],[1999,3741.1],[2000,3762.19],[2001,3575.45],[2002,3234.46],[2003,3251.04],[2004,3340.51],[2005,3477],[2006,3632.57],[2007,3779.08],[2008,3916.57],[2009,3943.3]],"population":[[1800,27791],[1820,27791],[1950,52000],[1951,53262],[1952,54554],[1953,55878],[1954,57233],[1955,58622],[1956,60044],[1957,61501],[1958,62993],[1959,64522],[1960,66087],[1961,67691],[1962,69333],[1963,71015],[1964,72577],[1965,74195],[1966,76132],[1967,78219],[1968,80571],[1969,82905],[1970,85400],[1971,88100],[1972,90800],[1973,93700],[1974,96600],[1975,99700],[1976,102800],[1977,106000],[1978,109400],[1979,113399],[1980,116771],[1981,120223],[1982,123745],[1983,127335],[1984,130982],[1985,134677],[1986,138418],[1987,142207],[1988,146040],[1989,149913],[1990,153785],[1991,157616],[1992,161399],[1993,165127],[1994,168793],[1995,172387],[1996,175927],[1997,179428],[1998,182882],[1999,186282],[2000,189618],[2001,192910],[2002,196178],[2003,199414],[2004,202609],[2005,205754],[2006,208869],[2007,211971],[2008,215053]],"lifeExpectancy":[[1950,40.8],[1951,41.1],[1952,41.7],[1953,42.3],[1954,42.9],[1955,43.5],[1956,44.1],[1957,44.7],[1958,45.3],[1959,45.9],[1960,46.5],[1961,47.1],[1962,47.7],[1963,48.3],[1964,48.9],[1965,49.5],[1966,50.1],[1967,50.7],[1968,51.3],[1969,51.9],[1970,52.5],[1971,53.1],[1972,53.7],[1973,54.3],[1974,54.9],[1975,55.5],[1976,56.12],[1977,56.74],[1978,57.36],[1979,57.98],[1980,58.58],[1981,59.14],[1982,59.65],[1983,60.11],[1984,60.52],[1985,60.92],[1986,61.34],[1987,61.8],[1988,62.32],[1989,62.9],[1990,63.51],[1991,64.11],[1992,64.66],[1993,65.14],[1994,65.53],[1995,65.87],[1996,66.15],[1997,66.44],[1998,66.73],[1999,67.06],[2000,67.42],[2001,67.8],[2002,68.18],[2003,68.56],[2004,68.92],[2005,69.26],[2006,69.58],[2007,69.89],[2008,70.2],[2009,70.5]]}] \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/examples/parallelCoordinates.html b/awx/ui/static/lib/novus-nvd3/examples/parallelCoordinates.html deleted file mode 100755 index 8dace04bf8..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/parallelCoordinates.html +++ /dev/null @@ -1,4125 +0,0 @@ - - - - - - - - - -
- -
- - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/pie.html b/awx/ui/static/lib/novus-nvd3/examples/pie.html deleted file mode 100755 index 3ba3f2bbef..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/pie.html +++ /dev/null @@ -1,94 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/pieChart.html b/awx/ui/static/lib/novus-nvd3/examples/pieChart.html deleted file mode 100755 index bdb3de969b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/pieChart.html +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - -

Test1

- - -

Test2

- - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/scatter.html b/awx/ui/static/lib/novus-nvd3/examples/scatter.html deleted file mode 100755 index 2c2776704e..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/scatter.html +++ /dev/null @@ -1,96 +0,0 @@ - - - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/scatterChart.html b/awx/ui/static/lib/novus-nvd3/examples/scatterChart.html deleted file mode 100755 index 57a8b91d52..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/scatterChart.html +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - -
-
- -
-
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/scatterPlusLineChart.html b/awx/ui/static/lib/novus-nvd3/examples/scatterPlusLineChart.html deleted file mode 100755 index d09cc9a38a..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/scatterPlusLineChart.html +++ /dev/null @@ -1,115 +0,0 @@ - - - - - - - - - -
-
- -
-
- - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/sparkline.html b/awx/ui/static/lib/novus-nvd3/examples/sparkline.html deleted file mode 100755 index b7412ec9d9..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/sparkline.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - -

Sparkline:

- - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/sparklinePlus.html b/awx/ui/static/lib/novus-nvd3/examples/sparklinePlus.html deleted file mode 100755 index f04e6e9b8c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/sparklinePlus.html +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - -

SparklinePlus:

-

-
-

APPL:

- -

GOOG:

- - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/stackedArea.html b/awx/ui/static/lib/novus-nvd3/examples/stackedArea.html deleted file mode 100755 index 43a959b0c0..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/stackedArea.html +++ /dev/null @@ -1,156 +0,0 @@ - - - - - - - - -
- -
- - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/stackedAreaChart.html b/awx/ui/static/lib/novus-nvd3/examples/stackedAreaChart.html deleted file mode 100755 index 834b2af5d5..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/stackedAreaChart.html +++ /dev/null @@ -1,269 +0,0 @@ - - - - - - - - -
- -
- -
- -
- - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/examples/stream_layers.js b/awx/ui/static/lib/novus-nvd3/examples/stream_layers.js deleted file mode 100755 index 43d7cfe0ac..0000000000 --- a/awx/ui/static/lib/novus-nvd3/examples/stream_layers.js +++ /dev/null @@ -1,35 +0,0 @@ - -/* Inspired by Lee Byron's test data generator. */ -function stream_layers(n, m, o) { - if (arguments.length < 3) o = 0; - function bump(a) { - var x = 1 / (.1 + Math.random()), - y = 2 * Math.random() - .5, - z = 10 / (.1 + Math.random()); - for (var i = 0; i < m; i++) { - var w = (i / m - y) * z; - a[i] += x * Math.exp(-w * w); - } - } - return d3.range(n).map(function() { - var a = [], i; - for (i = 0; i < m; i++) a[i] = o + o * Math.random(); - for (i = 0; i < 5; i++) bump(a); - return a.map(stream_index); - }); -} - -/* Another layer generator using gamma distributions. */ -function stream_waves(n, m) { - return d3.range(n).map(function(i) { - return d3.range(m).map(function(j) { - var x = 20 * j / m - i / 3; - return 2 * x * Math.exp(-.5 * x); - }).map(stream_index); - }); -} - -function stream_index(d, i) { - return {x: i, y: Math.max(0, d)}; -} - diff --git a/awx/ui/static/lib/novus-nvd3/lib/cie.js b/awx/ui/static/lib/novus-nvd3/lib/cie.js deleted file mode 100755 index 45f0132963..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/cie.js +++ /dev/null @@ -1,155 +0,0 @@ -(function(d3) { - var cie = d3.cie = {}; - - cie.lab = function(l, a, b) { - return arguments.length === 1 - ? (l instanceof Lab ? lab(l.l, l.a, l.b) - : (l instanceof Lch ? lch_lab(l.l, l.c, l.h) - : rgb_lab((l = d3.rgb(l)).r, l.g, l.b))) - : lab(+l, +a, +b); - }; - - cie.lch = function(l, c, h) { - return arguments.length === 1 - ? (l instanceof Lch ? lch(l.l, l.c, l.h) - : (l instanceof Lab ? lab_lch(l.l, l.a, l.b) - : lab_lch((l = rgb_lab((l = d3.rgb(l)).r, l.g, l.b)).l, l.a, l.b))) - : lch(+l, +c, +h); - }; - - cie.interpolateLab = function(a, b) { - a = cie.lab(a); - b = cie.lab(b); - var al = a.l, - aa = a.a, - ab = a.b, - bl = b.l - al, - ba = b.a - aa, - bb = b.b - ab; - return function(t) { - return lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; - }; - }; - - cie.interpolateLch = function(a, b) { - a = cie.lch(a); - b = cie.lch(b); - var al = a.l, - ac = a.c, - ah = a.h, - bl = b.l - al, - bc = b.c - ac, - bh = b.h - ah; - if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; // shortest path - return function(t) { - return lch_lab(al + bl * t, ac + bc * t, ah + bh * t) + ""; - }; - }; - - function lab(l, a, b) { - return new Lab(l, a, b); - } - - function Lab(l, a, b) { - this.l = l; - this.a = a; - this.b = b; - } - - Lab.prototype.brighter = function(k) { - return lab(Math.min(100, this.l + K * (arguments.length ? k : 1)), this.a, this.b); - }; - - Lab.prototype.darker = function(k) { - return lab(Math.max(0, this.l - K * (arguments.length ? k : 1)), this.a, this.b); - }; - - Lab.prototype.rgb = function() { - return lab_rgb(this.l, this.a, this.b); - }; - - Lab.prototype.toString = function() { - return this.rgb() + ""; - }; - - function lch(l, c, h) { - return new Lch(l, c, h); - } - - function Lch(l, c, h) { - this.l = l; - this.c = c; - this.h = h; - } - - Lch.prototype.brighter = function(k) { - return lch(Math.min(100, this.l + K * (arguments.length ? k : 1)), this.c, this.h); - }; - - Lch.prototype.darker = function(k) { - return lch(Math.max(0, this.l - K * (arguments.length ? k : 1)), this.c, this.h); - }; - - Lch.prototype.rgb = function() { - return lch_lab(this.l, this.c, this.h).rgb(); - }; - - Lch.prototype.toString = function() { - return this.rgb() + ""; - }; - - // Corresponds roughly to RGB brighter/darker - var K = 18; - - // D65 standard referent - var X = 0.950470, Y = 1, Z = 1.088830; - - function lab_rgb(l, a, b) { - var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; - x = lab_xyz(x) * X; - y = lab_xyz(y) * Y; - z = lab_xyz(z) * Z; - return d3.rgb( - xyz_rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z), - xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z), - xyz_rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z) - ); - } - - function rgb_lab(r, g, b) { - r = rgb_xyz(r); - g = rgb_xyz(g); - b = rgb_xyz(b); - var x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / X), - y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / Y), - z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / Z); - return lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); - } - - function lab_lch(l, a, b) { - var c = Math.sqrt(a * a + b * b), - h = Math.atan2(b, a) / Math.PI * 180; - return lch(l, c, h); - } - - function lch_lab(l, c, h) { - h = h * Math.PI / 180; - return lab(l, Math.cos(h) * c, Math.sin(h) * c); - } - - function lab_xyz(x) { - return x > 0.206893034 ? x * x * x : (x - 4 / 29) / 7.787037; - } - - function xyz_lab(x) { - return x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; - } - - function xyz_rgb(r) { - return Math.round(255 * (r <= 0.00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - 0.055)); - } - - function rgb_xyz(r) { - return (r /= 255) <= 0.04045 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4); - } -})(d3); diff --git a/awx/ui/static/lib/novus-nvd3/lib/colorbrewer.js b/awx/ui/static/lib/novus-nvd3/lib/colorbrewer.js deleted file mode 100755 index 2295527b9d..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/colorbrewer.js +++ /dev/null @@ -1,302 +0,0 @@ -// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/). -var colorbrewer = {YlGn: { -3: ["#f7fcb9","#addd8e","#31a354"], -4: ["#ffffcc","#c2e699","#78c679","#238443"], -5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"], -6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"], -7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"], -8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"], -9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"] -},YlGnBu: { -3: ["#edf8b1","#7fcdbb","#2c7fb8"], -4: ["#ffffcc","#a1dab4","#41b6c4","#225ea8"], -5: ["#ffffcc","#a1dab4","#41b6c4","#2c7fb8","#253494"], -6: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#2c7fb8","#253494"], -7: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"], -8: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"], -9: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"] -},GnBu: { -3: ["#e0f3db","#a8ddb5","#43a2ca"], -4: ["#f0f9e8","#bae4bc","#7bccc4","#2b8cbe"], -5: ["#f0f9e8","#bae4bc","#7bccc4","#43a2ca","#0868ac"], -6: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#43a2ca","#0868ac"], -7: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"], -8: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"], -9: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"] -},BuGn: { -3: ["#e5f5f9","#99d8c9","#2ca25f"], -4: ["#edf8fb","#b2e2e2","#66c2a4","#238b45"], -5: ["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"], -6: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#2ca25f","#006d2c"], -7: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"], -8: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"], -9: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"] -},PuBuGn: { -3: ["#ece2f0","#a6bddb","#1c9099"], -4: ["#f6eff7","#bdc9e1","#67a9cf","#02818a"], -5: ["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"], -6: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#1c9099","#016c59"], -7: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"], -8: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"], -9: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"] -},PuBu: { -3: ["#ece7f2","#a6bddb","#2b8cbe"], -4: ["#f1eef6","#bdc9e1","#74a9cf","#0570b0"], -5: ["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"], -6: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#2b8cbe","#045a8d"], -7: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"], -8: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"], -9: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"] -},BuPu: { -3: ["#e0ecf4","#9ebcda","#8856a7"], -4: ["#edf8fb","#b3cde3","#8c96c6","#88419d"], -5: ["#edf8fb","#b3cde3","#8c96c6","#8856a7","#810f7c"], -6: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8856a7","#810f7c"], -7: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"], -8: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"], -9: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"] -},RdPu: { -3: ["#fde0dd","#fa9fb5","#c51b8a"], -4: ["#feebe2","#fbb4b9","#f768a1","#ae017e"], -5: ["#feebe2","#fbb4b9","#f768a1","#c51b8a","#7a0177"], -6: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#c51b8a","#7a0177"], -7: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"], -8: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"], -9: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"] -},PuRd: { -3: ["#e7e1ef","#c994c7","#dd1c77"], -4: ["#f1eef6","#d7b5d8","#df65b0","#ce1256"], -5: ["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"], -6: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#dd1c77","#980043"], -7: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"], -8: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"], -9: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"] -},OrRd: { -3: ["#fee8c8","#fdbb84","#e34a33"], -4: ["#fef0d9","#fdcc8a","#fc8d59","#d7301f"], -5: ["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"], -6: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#e34a33","#b30000"], -7: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"], -8: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"], -9: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"] -},YlOrRd: { -3: ["#ffeda0","#feb24c","#f03b20"], -4: ["#ffffb2","#fecc5c","#fd8d3c","#e31a1c"], -5: ["#ffffb2","#fecc5c","#fd8d3c","#f03b20","#bd0026"], -6: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#f03b20","#bd0026"], -7: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"], -8: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"], -9: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"] -},YlOrBr: { -3: ["#fff7bc","#fec44f","#d95f0e"], -4: ["#ffffd4","#fed98e","#fe9929","#cc4c02"], -5: ["#ffffd4","#fed98e","#fe9929","#d95f0e","#993404"], -6: ["#ffffd4","#fee391","#fec44f","#fe9929","#d95f0e","#993404"], -7: ["#ffffd4","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"], -8: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"], -9: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"] -},Purples: { -3: ["#efedf5","#bcbddc","#756bb1"], -4: ["#f2f0f7","#cbc9e2","#9e9ac8","#6a51a3"], -5: ["#f2f0f7","#cbc9e2","#9e9ac8","#756bb1","#54278f"], -6: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#756bb1","#54278f"], -7: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"], -8: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"], -9: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"] -},Blues: { -3: ["#deebf7","#9ecae1","#3182bd"], -4: ["#eff3ff","#bdd7e7","#6baed6","#2171b5"], -5: ["#eff3ff","#bdd7e7","#6baed6","#3182bd","#08519c"], -6: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#3182bd","#08519c"], -7: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"], -8: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"], -9: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"] -},Greens: { -3: ["#e5f5e0","#a1d99b","#31a354"], -4: ["#edf8e9","#bae4b3","#74c476","#238b45"], -5: ["#edf8e9","#bae4b3","#74c476","#31a354","#006d2c"], -6: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#31a354","#006d2c"], -7: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"], -8: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"], -9: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"] -},Oranges: { -3: ["#fee6ce","#fdae6b","#e6550d"], -4: ["#feedde","#fdbe85","#fd8d3c","#d94701"], -5: ["#feedde","#fdbe85","#fd8d3c","#e6550d","#a63603"], -6: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#e6550d","#a63603"], -7: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"], -8: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"], -9: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"] -},Reds: { -3: ["#fee0d2","#fc9272","#de2d26"], -4: ["#fee5d9","#fcae91","#fb6a4a","#cb181d"], -5: ["#fee5d9","#fcae91","#fb6a4a","#de2d26","#a50f15"], -6: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#de2d26","#a50f15"], -7: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"], -8: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"], -9: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"] -},Greys: { -3: ["#f0f0f0","#bdbdbd","#636363"], -4: ["#f7f7f7","#cccccc","#969696","#525252"], -5: ["#f7f7f7","#cccccc","#969696","#636363","#252525"], -6: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#636363","#252525"], -7: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"], -8: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"], -9: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"] -},PuOr: { -3: ["#f1a340","#f7f7f7","#998ec3"], -4: ["#e66101","#fdb863","#b2abd2","#5e3c99"], -5: ["#e66101","#fdb863","#f7f7f7","#b2abd2","#5e3c99"], -6: ["#b35806","#f1a340","#fee0b6","#d8daeb","#998ec3","#542788"], -7: ["#b35806","#f1a340","#fee0b6","#f7f7f7","#d8daeb","#998ec3","#542788"], -8: ["#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788"], -9: ["#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788"], -10: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"], -11: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"] -},BrBG: { -3: ["#d8b365","#f5f5f5","#5ab4ac"], -4: ["#a6611a","#dfc27d","#80cdc1","#018571"], -5: ["#a6611a","#dfc27d","#f5f5f5","#80cdc1","#018571"], -6: ["#8c510a","#d8b365","#f6e8c3","#c7eae5","#5ab4ac","#01665e"], -7: ["#8c510a","#d8b365","#f6e8c3","#f5f5f5","#c7eae5","#5ab4ac","#01665e"], -8: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e"], -9: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e"], -10: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"], -11: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"] -},PRGn: { -3: ["#af8dc3","#f7f7f7","#7fbf7b"], -4: ["#7b3294","#c2a5cf","#a6dba0","#008837"], -5: ["#7b3294","#c2a5cf","#f7f7f7","#a6dba0","#008837"], -6: ["#762a83","#af8dc3","#e7d4e8","#d9f0d3","#7fbf7b","#1b7837"], -7: ["#762a83","#af8dc3","#e7d4e8","#f7f7f7","#d9f0d3","#7fbf7b","#1b7837"], -8: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837"], -9: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837"], -10: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"], -11: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"] -},PiYG: { -3: ["#e9a3c9","#f7f7f7","#a1d76a"], -4: ["#d01c8b","#f1b6da","#b8e186","#4dac26"], -5: ["#d01c8b","#f1b6da","#f7f7f7","#b8e186","#4dac26"], -6: ["#c51b7d","#e9a3c9","#fde0ef","#e6f5d0","#a1d76a","#4d9221"], -7: ["#c51b7d","#e9a3c9","#fde0ef","#f7f7f7","#e6f5d0","#a1d76a","#4d9221"], -8: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221"], -9: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221"], -10: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"], -11: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"] -},RdBu: { -3: ["#ef8a62","#f7f7f7","#67a9cf"], -4: ["#ca0020","#f4a582","#92c5de","#0571b0"], -5: ["#ca0020","#f4a582","#f7f7f7","#92c5de","#0571b0"], -6: ["#b2182b","#ef8a62","#fddbc7","#d1e5f0","#67a9cf","#2166ac"], -7: ["#b2182b","#ef8a62","#fddbc7","#f7f7f7","#d1e5f0","#67a9cf","#2166ac"], -8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac"], -9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac"], -10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"], -11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"] -},RdGy: { -3: ["#ef8a62","#ffffff","#999999"], -4: ["#ca0020","#f4a582","#bababa","#404040"], -5: ["#ca0020","#f4a582","#ffffff","#bababa","#404040"], -6: ["#b2182b","#ef8a62","#fddbc7","#e0e0e0","#999999","#4d4d4d"], -7: ["#b2182b","#ef8a62","#fddbc7","#ffffff","#e0e0e0","#999999","#4d4d4d"], -8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d"], -9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d"], -10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"], -11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"] -},RdYlBu: { -3: ["#fc8d59","#ffffbf","#91bfdb"], -4: ["#d7191c","#fdae61","#abd9e9","#2c7bb6"], -5: ["#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6"], -6: ["#d73027","#fc8d59","#fee090","#e0f3f8","#91bfdb","#4575b4"], -7: ["#d73027","#fc8d59","#fee090","#ffffbf","#e0f3f8","#91bfdb","#4575b4"], -8: ["#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4"], -9: ["#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4"], -10: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"], -11: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"] -},Spectral: { -3: ["#fc8d59","#ffffbf","#99d594"], -4: ["#d7191c","#fdae61","#abdda4","#2b83ba"], -5: ["#d7191c","#fdae61","#ffffbf","#abdda4","#2b83ba"], -6: ["#d53e4f","#fc8d59","#fee08b","#e6f598","#99d594","#3288bd"], -7: ["#d53e4f","#fc8d59","#fee08b","#ffffbf","#e6f598","#99d594","#3288bd"], -8: ["#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd"], -9: ["#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd"], -10: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"], -11: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"] -},RdYlGn: { -3: ["#fc8d59","#ffffbf","#91cf60"], -4: ["#d7191c","#fdae61","#a6d96a","#1a9641"], -5: ["#d7191c","#fdae61","#ffffbf","#a6d96a","#1a9641"], -6: ["#d73027","#fc8d59","#fee08b","#d9ef8b","#91cf60","#1a9850"], -7: ["#d73027","#fc8d59","#fee08b","#ffffbf","#d9ef8b","#91cf60","#1a9850"], -8: ["#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850"], -9: ["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"], -10: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"], -11: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"] -},Accent: { -3: ["#7fc97f","#beaed4","#fdc086"], -4: ["#7fc97f","#beaed4","#fdc086","#ffff99"], -5: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0"], -6: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f"], -7: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17"], -8: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"] -},Dark2: { -3: ["#1b9e77","#d95f02","#7570b3"], -4: ["#1b9e77","#d95f02","#7570b3","#e7298a"], -5: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e"], -6: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02"], -7: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d"], -8: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"] -},Paired: { -3: ["#a6cee3","#1f78b4","#b2df8a"], -4: ["#a6cee3","#1f78b4","#b2df8a","#33a02c"], -5: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99"], -6: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c"], -7: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f"], -8: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00"], -9: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6"], -10: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a"], -11: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99"], -12: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"] -},Pastel1: { -3: ["#fbb4ae","#b3cde3","#ccebc5"], -4: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4"], -5: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6"], -6: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc"], -7: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd"], -8: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec"], -9: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"] -},Pastel2: { -3: ["#b3e2cd","#fdcdac","#cbd5e8"], -4: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4"], -5: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9"], -6: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae"], -7: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc"], -8: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"] -},Set1: { -3: ["#e41a1c","#377eb8","#4daf4a"], -4: ["#e41a1c","#377eb8","#4daf4a","#984ea3"], -5: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00"], -6: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33"], -7: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628"], -8: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf"], -9: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"] -},Set2: { -3: ["#66c2a5","#fc8d62","#8da0cb"], -4: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3"], -5: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854"], -6: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f"], -7: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494"], -8: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"] -},Set3: { -3: ["#8dd3c7","#ffffb3","#bebada"], -4: ["#8dd3c7","#ffffb3","#bebada","#fb8072"], -5: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3"], -6: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462"], -7: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69"], -8: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5"], -9: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9"], -10: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd"], -11: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5"], -12: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"] -}}; diff --git a/awx/ui/static/lib/novus-nvd3/lib/crossfilter.js b/awx/ui/static/lib/novus-nvd3/lib/crossfilter.js deleted file mode 100755 index 1aaabca281..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/crossfilter.js +++ /dev/null @@ -1,1180 +0,0 @@ -(function(exports){ -crossfilter.version = "1.0.3"; -function crossfilter_identity(d) { - return d; -} -crossfilter.permute = permute; - -function permute(array, index) { - for (var i = 0, n = index.length, copy = new Array(n); i < n; ++i) { - copy[i] = array[index[i]]; - } - return copy; -} -var bisect = crossfilter.bisect = bisect_by(crossfilter_identity); - -bisect.by = bisect_by; - -function bisect_by(f) { - - // Locate the insertion point for x in a to maintain sorted order. The - // arguments lo and hi may be used to specify a subset of the array which - // should be considered; by default the entire array is used. If x is already - // present in a, the insertion point will be before (to the left of) any - // existing entries. The return value is suitable for use as the first - // argument to `array.splice` assuming that a is already sorted. - // - // The returned insertion point i partitions the array a into two halves so - // that all v < x for v in a[lo:i] for the left side and all v >= x for v in - // a[i:hi] for the right side. - function bisectLeft(a, x, lo, hi) { - while (lo < hi) { - var mid = lo + hi >> 1; - if (f(a[mid]) < x) lo = mid + 1; - else hi = mid; - } - return lo; - } - - // Similar to bisectLeft, but returns an insertion point which comes after (to - // the right of) any existing entries of x in a. - // - // The returned insertion point i partitions the array into two halves so that - // all v <= x for v in a[lo:i] for the left side and all v > x for v in - // a[i:hi] for the right side. - function bisectRight(a, x, lo, hi) { - while (lo < hi) { - var mid = lo + hi >> 1; - if (x < f(a[mid])) hi = mid; - else lo = mid + 1; - } - return lo; - } - - bisectRight.right = bisectRight; - bisectRight.left = bisectLeft; - return bisectRight; -} -var heap = crossfilter.heap = heap_by(crossfilter_identity); - -heap.by = heap_by; - -function heap_by(f) { - - // Builds a binary heap within the specified array a[lo:hi]. The heap has the - // property such that the parent a[lo+i] is always less than or equal to its - // two children: a[lo+2*i+1] and a[lo+2*i+2]. - function heap(a, lo, hi) { - var n = hi - lo, - i = (n >>> 1) + 1; - while (--i > 0) sift(a, i, n, lo); - return a; - } - - // Sorts the specified array a[lo:hi] in descending order, assuming it is - // already a heap. - function sort(a, lo, hi) { - var n = hi - lo, - t; - while (--n > 0) t = a[lo], a[lo] = a[lo + n], a[lo + n] = t, sift(a, 1, n, lo); - return a; - } - - // Sifts the element a[lo+i-1] down the heap, where the heap is the contiguous - // slice of array a[lo:lo+n]. This method can also be used to update the heap - // incrementally, without incurring the full cost of reconstructing the heap. - function sift(a, i, n, lo) { - var d = a[--lo + i], - x = f(d), - child; - while ((child = i << 1) <= n) { - if (child < n && f(a[lo + child]) > f(a[lo + child + 1])) child++; - if (x <= f(a[lo + child])) break; - a[lo + i] = a[lo + child]; - i = child; - } - a[lo + i] = d; - } - - heap.sort = sort; - return heap; -} -var heapselect = crossfilter.heapselect = heapselect_by(crossfilter_identity); - -heapselect.by = heapselect_by; - -function heapselect_by(f) { - var heap = heap_by(f); - - // Returns a new array containing the top k elements in the array a[lo:hi]. - // The returned array is not sorted, but maintains the heap property. If k is - // greater than hi - lo, then fewer than k elements will be returned. The - // order of elements in a is unchanged by this operation. - function heapselect(a, lo, hi, k) { - var queue = new Array(k = Math.min(hi - lo, k)), - min, - i, - x, - d; - - for (i = 0; i < k; ++i) queue[i] = a[lo++]; - heap(queue, 0, k); - - if (lo < hi) { - min = f(queue[0]); - do { - if (x = f(d = a[lo]) > min) { - queue[0] = d; - min = f(heap(queue, 0, k)[0]); - } - } while (++lo < hi); - } - - return queue; - } - - return heapselect; -} -var insertionsort = crossfilter.insertionsort = insertionsort_by(crossfilter_identity); - -insertionsort.by = insertionsort_by; - -function insertionsort_by(f) { - - function insertionsort(a, lo, hi) { - for (var i = lo + 1; i < hi; ++i) { - for (var j = i, t = a[i], x = f(t); j > lo && f(a[j - 1]) > x; --j) { - a[j] = a[j - 1]; - } - a[j] = t; - } - return a; - } - - return insertionsort; -} -// Algorithm designed by Vladimir Yaroslavskiy. -// Implementation based on the Dart project; see lib/dart/LICENSE for details. - -var quicksort = crossfilter.quicksort = quicksort_by(crossfilter_identity); - -quicksort.by = quicksort_by; - -function quicksort_by(f) { - var insertionsort = insertionsort_by(f); - - function sort(a, lo, hi) { - return (hi - lo < quicksort_sizeThreshold - ? insertionsort - : quicksort)(a, lo, hi); - } - - function quicksort(a, lo, hi) { - - // Compute the two pivots by looking at 5 elements. - var sixth = (hi - lo) / 6 | 0, - i1 = lo + sixth, - i5 = hi - 1 - sixth, - i3 = lo + hi - 1 >> 1, // The midpoint. - i2 = i3 - sixth, - i4 = i3 + sixth; - - var e1 = a[i1], x1 = f(e1), - e2 = a[i2], x2 = f(e2), - e3 = a[i3], x3 = f(e3), - e4 = a[i4], x4 = f(e4), - e5 = a[i5], x5 = f(e5); - - var t; - - // Sort the selected 5 elements using a sorting network. - if (x1 > x2) t = e1, e1 = e2, e2 = t, t = x1, x1 = x2, x2 = t; - if (x4 > x5) t = e4, e4 = e5, e5 = t, t = x4, x4 = x5, x5 = t; - if (x1 > x3) t = e1, e1 = e3, e3 = t, t = x1, x1 = x3, x3 = t; - if (x2 > x3) t = e2, e2 = e3, e3 = t, t = x2, x2 = x3, x3 = t; - if (x1 > x4) t = e1, e1 = e4, e4 = t, t = x1, x1 = x4, x4 = t; - if (x3 > x4) t = e3, e3 = e4, e4 = t, t = x3, x3 = x4, x4 = t; - if (x2 > x5) t = e2, e2 = e5, e5 = t, t = x2, x2 = x5, x5 = t; - if (x2 > x3) t = e2, e2 = e3, e3 = t, t = x2, x2 = x3, x3 = t; - if (x4 > x5) t = e4, e4 = e5, e5 = t, t = x4, x4 = x5, x5 = t; - - var pivot1 = e2, pivotValue1 = x2, - pivot2 = e4, pivotValue2 = x4; - - // e2 and e4 have been saved in the pivot variables. They will be written - // back, once the partitioning is finished. - a[i1] = e1; - a[i2] = a[lo]; - a[i3] = e3; - a[i4] = a[hi - 1]; - a[i5] = e5; - - var less = lo + 1, // First element in the middle partition. - great = hi - 2; // Last element in the middle partition. - - // Note that for value comparison, <, <=, >= and > coerce to a primitive via - // Object.prototype.valueOf; == and === do not, so in order to be consistent - // with natural order (such as for Date objects), we must do two compares. - var pivotsEqual = pivotValue1 <= pivotValue2 && pivotValue1 >= pivotValue2; - if (pivotsEqual) { - - // Degenerated case where the partitioning becomes a dutch national flag - // problem. - // - // [ | < pivot | == pivot | unpartitioned | > pivot | ] - // ^ ^ ^ ^ ^ - // left less k great right - // - // a[left] and a[right] are undefined and are filled after the - // partitioning. - // - // Invariants: - // 1) for x in ]left, less[ : x < pivot. - // 2) for x in [less, k[ : x == pivot. - // 3) for x in ]great, right[ : x > pivot. - for (var k = less; k <= great; ++k) { - var ek = a[k], xk = f(ek); - if (xk < pivotValue1) { - if (k !== less) { - a[k] = a[less]; - a[less] = ek; - } - ++less; - } else if (xk > pivotValue1) { - - // Find the first element <= pivot in the range [k - 1, great] and - // put [:ek:] there. We know that such an element must exist: - // When k == less, then el3 (which is equal to pivot) lies in the - // interval. Otherwise a[k - 1] == pivot and the search stops at k-1. - // Note that in the latter case invariant 2 will be violated for a - // short amount of time. The invariant will be restored when the - // pivots are put into their final positions. - while (true) { - var greatValue = f(a[great]); - if (greatValue > pivotValue1) { - great--; - // This is the only location in the while-loop where a new - // iteration is started. - continue; - } else if (greatValue < pivotValue1) { - // Triple exchange. - a[k] = a[less]; - a[less++] = a[great]; - a[great--] = ek; - break; - } else { - a[k] = a[great]; - a[great--] = ek; - // Note: if great < k then we will exit the outer loop and fix - // invariant 2 (which we just violated). - break; - } - } - } - } - } else { - - // We partition the list into three parts: - // 1. < pivot1 - // 2. >= pivot1 && <= pivot2 - // 3. > pivot2 - // - // During the loop we have: - // [ | < pivot1 | >= pivot1 && <= pivot2 | unpartitioned | > pivot2 | ] - // ^ ^ ^ ^ ^ - // left less k great right - // - // a[left] and a[right] are undefined and are filled after the - // partitioning. - // - // Invariants: - // 1. for x in ]left, less[ : x < pivot1 - // 2. for x in [less, k[ : pivot1 <= x && x <= pivot2 - // 3. for x in ]great, right[ : x > pivot2 - for (var k = less; k <= great; k++) { - var ek = a[k], xk = f(ek); - if (xk < pivotValue1) { - if (k !== less) { - a[k] = a[less]; - a[less] = ek; - } - ++less; - } else { - if (xk > pivotValue2) { - while (true) { - var greatValue = f(a[great]); - if (greatValue > pivotValue2) { - great--; - if (great < k) break; - // This is the only location inside the loop where a new - // iteration is started. - continue; - } else { - // a[great] <= pivot2. - if (greatValue < pivotValue1) { - // Triple exchange. - a[k] = a[less]; - a[less++] = a[great]; - a[great--] = ek; - } else { - // a[great] >= pivot1. - a[k] = a[great]; - a[great--] = ek; - } - break; - } - } - } - } - } - } - - // Move pivots into their final positions. - // We shrunk the list from both sides (a[left] and a[right] have - // meaningless values in them) and now we move elements from the first - // and third partition into these locations so that we can store the - // pivots. - a[lo] = a[less - 1]; - a[less - 1] = pivot1; - a[hi - 1] = a[great + 1]; - a[great + 1] = pivot2; - - // The list is now partitioned into three partitions: - // [ < pivot1 | >= pivot1 && <= pivot2 | > pivot2 ] - // ^ ^ ^ ^ - // left less great right - - // Recursive descent. (Don't include the pivot values.) - sort(a, lo, less - 1); - sort(a, great + 2, hi); - - if (pivotsEqual) { - // All elements in the second partition are equal to the pivot. No - // need to sort them. - return a; - } - - // In theory it should be enough to call _doSort recursively on the second - // partition. - // The Android source however removes the pivot elements from the recursive - // call if the second partition is too large (more than 2/3 of the list). - if (less < i1 && great > i5) { - var lessValue, greatValue; - while ((lessValue = f(a[less])) <= pivotValue1 && lessValue >= pivotValue1) ++less; - while ((greatValue = f(a[great])) <= pivotValue2 && greatValue >= pivotValue2) --great; - - // Copy paste of the previous 3-way partitioning with adaptions. - // - // We partition the list into three parts: - // 1. == pivot1 - // 2. > pivot1 && < pivot2 - // 3. == pivot2 - // - // During the loop we have: - // [ == pivot1 | > pivot1 && < pivot2 | unpartitioned | == pivot2 ] - // ^ ^ ^ - // less k great - // - // Invariants: - // 1. for x in [ *, less[ : x == pivot1 - // 2. for x in [less, k[ : pivot1 < x && x < pivot2 - // 3. for x in ]great, * ] : x == pivot2 - for (var k = less; k <= great; k++) { - var ek = a[k], xk = f(ek); - if (xk <= pivotValue1 && xk >= pivotValue1) { - if (k !== less) { - a[k] = a[less]; - a[less] = ek; - } - less++; - } else { - if (xk <= pivotValue2 && xk >= pivotValue2) { - while (true) { - var greatValue = f(a[great]); - if (greatValue <= pivotValue2 && greatValue >= pivotValue2) { - great--; - if (great < k) break; - // This is the only location inside the loop where a new - // iteration is started. - continue; - } else { - // a[great] < pivot2. - if (greatValue < pivotValue1) { - // Triple exchange. - a[k] = a[less]; - a[less++] = a[great]; - a[great--] = ek; - } else { - // a[great] == pivot1. - a[k] = a[great]; - a[great--] = ek; - } - break; - } - } - } - } - } - } - - // The second partition has now been cleared of pivot elements and looks - // as follows: - // [ * | > pivot1 && < pivot2 | * ] - // ^ ^ - // less great - // Sort the second partition using recursive descent. - - // The second partition looks as follows: - // [ * | >= pivot1 && <= pivot2 | * ] - // ^ ^ - // less great - // Simply sort it by recursive descent. - - return sort(a, less, great + 1); - } - - return sort; -} - -var quicksort_sizeThreshold = 32; -var crossfilter_array8 = crossfilter_arrayUntyped, - crossfilter_array16 = crossfilter_arrayUntyped, - crossfilter_array32 = crossfilter_arrayUntyped, - crossfilter_arrayLengthen = crossfilter_identity, - crossfilter_arrayWiden = crossfilter_identity; - -if (typeof Uint8Array !== "undefined") { - crossfilter_array8 = function(n) { return new Uint8Array(n); }; - crossfilter_array16 = function(n) { return new Uint16Array(n); }; - crossfilter_array32 = function(n) { return new Uint32Array(n); }; - - crossfilter_arrayLengthen = function(array, length) { - var copy = new array.constructor(length); - copy.set(array); - return copy; - }; - - crossfilter_arrayWiden = function(array, width) { - var copy; - switch (width) { - case 16: copy = crossfilter_array16(array.length); break; - case 32: copy = crossfilter_array32(array.length); break; - default: throw new Error("invalid array width!"); - } - copy.set(array); - return copy; - }; -} - -function crossfilter_arrayUntyped(n) { - return new Array(n); -} -function crossfilter_filterExact(bisect, value) { - return function(values) { - var n = values.length; - return [bisect.left(values, value, 0, n), bisect.right(values, value, 0, n)]; - }; -} - -function crossfilter_filterRange(bisect, range) { - var min = range[0], - max = range[1]; - return function(values) { - var n = values.length; - return [bisect.left(values, min, 0, n), bisect.left(values, max, 0, n)]; - }; -} - -function crossfilter_filterAll(values) { - return [0, values.length]; -} -function crossfilter_null() { - return null; -} -function crossfilter_zero() { - return 0; -} -function crossfilter_reduceIncrement(p) { - return p + 1; -} - -function crossfilter_reduceDecrement(p) { - return p - 1; -} - -function crossfilter_reduceAdd(f) { - return function(p, v) { - return p + +f(v); - }; -} - -function crossfilter_reduceSubtract(f) { - return function(p, v) { - return p - f(v); - }; -} -exports.crossfilter = crossfilter; - -function crossfilter() { - var crossfilter = { - add: add, - dimension: dimension, - groupAll: groupAll, - size: size - }; - - var data = [], // the records - n = 0, // the number of records; data.length - m = 0, // number of dimensions in use - M = 8, // number of dimensions that can fit in `filters` - filters = crossfilter_array8(0), // M bits per record; 1 is filtered out - filterListeners = [], // when the filters change - dataListeners = []; // when data is added - - // Adds the specified new records to this crossfilter. - function add(newData) { - var n0 = n, - n1 = newData.length; - - // If there's actually new data to add… - // Merge the new data into the existing data. - // Lengthen the filter bitset to handle the new records. - // Notify listeners (dimensions and groups) that new data is available. - if (n1) { - data = data.concat(newData); - filters = crossfilter_arrayLengthen(filters, n += n1); - dataListeners.forEach(function(l) { l(newData, n0, n1); }); - } - - return crossfilter; - } - - // Adds a new dimension with the specified value accessor function. - function dimension(value) { - var dimension = { - filter: filter, - filterExact: filterExact, - filterRange: filterRange, - filterAll: filterAll, - top: top, - group: group, - groupAll: groupAll - }; - - var one = 1 << m++, // bit mask, e.g., 00001000 - zero = ~one, // inverted one, e.g., 11110111 - values, // sorted, cached array - index, // value rank ↦ object id - newValues, // temporary array storing newly-added values - newIndex, // temporary array storing newly-added index - sort = quicksort_by(function(i) { return newValues[i]; }), - refilter = crossfilter_filterAll, // for recomputing filter - indexListeners = [], // when data is added - lo0 = 0, - hi0 = 0; - - // Updating a dimension is a two-stage process. First, we must update the - // associated filters for the newly-added records. Once all dimensions have - // updated their filters, the groups are notified to update. - dataListeners.unshift(preAdd); - dataListeners.push(postAdd); - - // Incorporate any existing data into this dimension, and make sure that the - // filter bitset is wide enough to handle the new dimension. - if (m > M) filters = crossfilter_arrayWiden(filters, M <<= 1); - preAdd(data, 0, n); - postAdd(data, 0, n); - - // Incorporates the specified new records into this dimension. - // This function is responsible for updating filters, values, and index. - function preAdd(newData, n0, n1) { - - // Permute new values into natural order using a sorted index. - newValues = newData.map(value); - newIndex = sort(crossfilter_range(n1), 0, n1); - newValues = permute(newValues, newIndex); - - // Bisect newValues to determine which new records are selected. - var bounds = refilter(newValues), lo1 = bounds[0], hi1 = bounds[1], i; - for (i = 0; i < lo1; ++i) filters[newIndex[i] + n0] |= one; - for (i = hi1; i < n1; ++i) filters[newIndex[i] + n0] |= one; - - // If this dimension previously had no data, then we don't need to do the - // more expensive merge operation; use the new values and index as-is. - if (!n0) { - values = newValues; - index = newIndex; - lo0 = lo1; - hi0 = hi1; - return; - } - - var oldValues = values, - oldIndex = index, - i0 = 0, - i1 = 0; - - // Otherwise, create new arrays into which to merge new and old. - values = new Array(n); - index = crossfilter_index(n, n); - - // Merge the old and new sorted values, and old and new index. - for (i = 0; i0 < n0 && i1 < n1; ++i) { - if (oldValues[i0] < newValues[i1]) { - values[i] = oldValues[i0]; - index[i] = oldIndex[i0++]; - } else { - values[i] = newValues[i1]; - index[i] = newIndex[i1++] + n0; - } - } - - // Add any remaining old values. - for (; i0 < n0; ++i0, ++i) { - values[i] = oldValues[i0]; - index[i] = oldIndex[i0]; - } - - // Add any remaining new values. - for (; i1 < n1; ++i1, ++i) { - values[i] = newValues[i1]; - index[i] = newIndex[i1] + n0; - } - - // Bisect again to recompute lo0 and hi0. - bounds = refilter(values), lo0 = bounds[0], hi0 = bounds[1]; - } - - // When all filters have updated, notify index listeners of the new values. - function postAdd(newData, n0, n1) { - indexListeners.forEach(function(l) { l(newValues, newIndex, n0, n1); }); - newValues = newIndex = null; - } - - // Updates the selected values based on the specified bounds [lo, hi]. - // This implementation is used by all the public filter methods. - function filterIndex(bounds) { - var i, - j, - k, - lo1 = bounds[0], - hi1 = bounds[1], - added = [], - removed = []; - - // Fast incremental update based on previous lo index. - if (lo1 < lo0) { - for (i = lo1, j = Math.min(lo0, hi1); i < j; ++i) { - filters[k = index[i]] ^= one; - added.push(k); - } - } else if (lo1 > lo0) { - for (i = lo0, j = Math.min(lo1, hi0); i < j; ++i) { - filters[k = index[i]] ^= one; - removed.push(k); - } - } - - // Fast incremental update based on previous hi index. - if (hi1 > hi0) { - for (i = Math.max(lo1, hi0), j = hi1; i < j; ++i) { - filters[k = index[i]] ^= one; - added.push(k); - } - } else if (hi1 < hi0) { - for (i = Math.max(lo0, hi1), j = hi0; i < j; ++i) { - filters[k = index[i]] ^= one; - removed.push(k); - } - } - - lo0 = lo1; - hi0 = hi1; - filterListeners.forEach(function(l) { l(one, added, removed); }); - return dimension; - } - - // Filters this dimension using the specified range, value, or null. - // If the range is null, this is equivalent to filterAll. - // If the range is an array, this is equivalent to filterRange. - // Otherwise, this is equivalent to filterExact. - function filter(range) { - return range == null - ? filterAll() : Array.isArray(range) - ? filterRange(range) - : filterExact(range); - } - - // Filters this dimension to select the exact value. - function filterExact(value) { - return filterIndex((refilter = crossfilter_filterExact(bisect, value))(values)); - } - - // Filters this dimension to select the specified range [lo, hi]. - // The lower bound is inclusive, and the upper bound is exclusive. - function filterRange(range) { - return filterIndex((refilter = crossfilter_filterRange(bisect, range))(values)); - } - - // Clears any filters on this dimension. - function filterAll() { - return filterIndex((refilter = crossfilter_filterAll)(values)); - } - - // Returns the top K selected records, based on this dimension's order. - // Note: observes this dimension's filter, unlike group and groupAll. - function top(k) { - var array = [], - i = hi0, - j; - - while (--i >= lo0 && k > 0) { - if (!filters[j = index[i]]) { - array.push(data[j]); - --k; - } - } - - return array; - } - - // Adds a new group to this dimension, using the specified key function. - function group(key) { - var group = { - top: top, - all: all, - reduce: reduce, - reduceCount: reduceCount, - reduceSum: reduceSum, - order: order, - orderNatural: orderNatural, - size: size - }; - - var groups, // array of {key, value} - groupIndex, // object id ↦ group id - groupWidth = 8, - groupCapacity = crossfilter_capacity(groupWidth), - k = 0, // cardinality - select, - heap, - reduceAdd, - reduceRemove, - reduceInitial, - update = crossfilter_null, - reset = crossfilter_null, - resetNeeded = true; - - if (arguments.length < 1) key = crossfilter_identity; - - // The group listens to the crossfilter for when any dimension changes, so - // that it can update the associated reduce values. It must also listen to - // the parent dimension for when data is added, and compute new keys. - filterListeners.push(update); - indexListeners.push(add); - - // Incorporate any existing data into the grouping. - add(values, index, 0, n); - - // Incorporates the specified new values into this group. - // This function is responsible for updating groups and groupIndex. - function add(newValues, newIndex, n0, n1) { - var oldGroups = groups, - reIndex = crossfilter_index(k, groupCapacity), - add = reduceAdd, - initial = reduceInitial, - k0 = k, // old cardinality - i0 = 0, // index of old group - i1 = 0, // index of new record - j, // object id - g0, // old group - x0, // old key - x1, // new key - g, // group to add - x; // key of group to add - - // If a reset is needed, we don't need to update the reduce values. - if (resetNeeded) add = initial = crossfilter_null; - - // Reset the new groups (k is a lower bound). - // Also, make sure that groupIndex exists and is long enough. - groups = new Array(k), k = 0; - groupIndex = k0 > 1 ? crossfilter_arrayLengthen(groupIndex, n) : crossfilter_index(n, groupCapacity); - - // Get the first old key (x0 of g0), if it exists. - if (k0) x0 = (g0 = oldGroups[0]).key; - - // Find the first new key (x1), skipping NaN keys. - while (i1 < n1 && !((x1 = key(newValues[i1])) >= x1)) ++i1; - - // While new keys remain… - while (i1 < n1) { - - // Determine the lesser of the two current keys; new and old. - // If there are no old keys remaining, then always add the new key. - if (g0 && x0 <= x1) { - g = g0, x = x0; - - // Record the new index of the old group. - reIndex[i0] = k; - - // Retrieve the next old key. - if (g0 = oldGroups[++i0]) x0 = g0.key; - } else { - g = {key: x1, value: initial()}, x = x1; - } - - // Add the lesser group. - groups[k] = g; - - // Add any selected records belonging to the added group, while - // advancing the new key and populating the associated group index. - while (!(x1 > x)) { - groupIndex[j = newIndex[i1] + n0] = k; - if (!(filters[j] & zero)) g.value = add(g.value, data[j]); - if (++i1 >= n1) break; - x1 = key(newValues[i1]); - } - - groupIncrement(); - } - - // Add any remaining old groups that were greater than all new keys. - // No incremental reduce is needed; these groups have no new records. - // Also record the new index of the old group. - while (i0 < k0) { - groups[reIndex[i0] = k] = oldGroups[i0++]; - groupIncrement(); - } - - // If we added any new groups before any old groups, - // update the group index of all the old records. - if (k > i0) for (i0 = 0; i0 < n0; ++i0) { - groupIndex[i0] = reIndex[groupIndex[i0]]; - } - - // Modify the update and reset behavior based on the cardinality. - // If the cardinality is less than or equal to one, then the groupIndex - // is not needed. If the cardinality is zero, then there are no records - // and therefore no groups to update or reset. Note that we also must - // change the registered listener to point to the new method. - j = filterListeners.indexOf(update); - if (k > 1) { - update = updateMany; - reset = resetMany; - } else { - if (k === 1) { - update = updateOne; - reset = resetOne; - } else { - update = crossfilter_null; - reset = crossfilter_null; - } - groupIndex = null; - } - filterListeners[j] = update; - - // Count the number of added groups, - // and widen the group index as needed. - function groupIncrement() { - if (++k === groupCapacity) { - reIndex = crossfilter_arrayWiden(reIndex, groupWidth <<= 1); - groupIndex = crossfilter_arrayWiden(groupIndex, groupWidth); - groupCapacity = crossfilter_capacity(groupWidth); - } - } - } - - // Reduces the specified selected or deselected records. - // This function is only used when the cardinality is greater than 1. - function updateMany(filterOne, added, removed) { - if (filterOne === one || resetNeeded) return; - - var i, - k, - n, - g; - - // Add the added values. - for (i = 0, n = added.length; i < n; ++i) { - if (!(filters[k = added[i]] & zero)) { - g = groups[groupIndex[k]]; - g.value = reduceAdd(g.value, data[k]); - } - } - - // Remove the removed values. - for (i = 0, n = removed.length; i < n; ++i) { - if ((filters[k = removed[i]] & zero) === filterOne) { - g = groups[groupIndex[k]]; - g.value = reduceRemove(g.value, data[k]); - } - } - } - - // Reduces the specified selected or deselected records. - // This function is only used when the cardinality is 1. - function updateOne(filterOne, added, removed) { - if (filterOne === one || resetNeeded) return; - - var i, - k, - n, - g = groups[0]; - - // Add the added values. - for (i = 0, n = added.length; i < n; ++i) { - if (!(filters[k = added[i]] & zero)) { - g.value = reduceAdd(g.value, data[k]); - } - } - - // Remove the removed values. - for (i = 0, n = removed.length; i < n; ++i) { - if ((filters[k = removed[i]] & zero) === filterOne) { - g.value = reduceRemove(g.value, data[k]); - } - } - } - - // Recomputes the group reduce values from scratch. - // This function is only used when the cardinality is greater than 1. - function resetMany() { - var i, - g; - - // Reset all group values. - for (i = 0; i < k; ++i) { - groups[i].value = reduceInitial(); - } - - // Add any selected records. - for (i = 0; i < n; ++i) { - if (!(filters[i] & zero)) { - g = groups[groupIndex[i]]; - g.value = reduceAdd(g.value, data[i]); - } - } - } - - // Recomputes the group reduce values from scratch. - // This function is only used when the cardinality is 1. - function resetOne() { - var i, - g = groups[0]; - - // Reset the singleton group values. - g.value = reduceInitial(); - - // Add any selected records. - for (i = 0; i < n; ++i) { - if (!(filters[i] & zero)) { - g.value = reduceAdd(g.value, data[i]); - } - } - } - - // Returns the array of group values, in the dimension's natural order. - function all() { - if (resetNeeded) reset(), resetNeeded = false; - return groups; - } - - // Returns a new array containing the top K group values, in reduce order. - function top(k) { - var top = select(all(), 0, groups.length, k); - return heap.sort(top, 0, top.length); - } - - // Sets the reduce behavior for this group to use the specified functions. - // This method lazily recomputes the reduce values, waiting until needed. - function reduce(add, remove, initial) { - reduceAdd = add; - reduceRemove = remove; - reduceInitial = initial; - resetNeeded = true; - return group; - } - - // A convenience method for reducing by count. - function reduceCount() { - return reduce(crossfilter_reduceIncrement, crossfilter_reduceDecrement, crossfilter_zero); - } - - // A convenience method for reducing by sum(value). - function reduceSum(value) { - return reduce(crossfilter_reduceAdd(value), crossfilter_reduceSubtract(value), crossfilter_zero); - } - - // Sets the reduce order, using the specified accessor. - function order(value) { - select = heapselect_by(valueOf); - heap = heap_by(valueOf); - function valueOf(d) { return value(d.value); } - return group; - } - - // A convenience method for natural ordering by reduce value. - function orderNatural() { - return order(crossfilter_identity); - } - - // Returns the cardinality of this group, irrespective of any filters. - function size() { - return k; - } - - return reduceCount().orderNatural(); - } - - // A convenience function for generating a singleton group. - function groupAll() { - var g = group(crossfilter_null), all = g.all; - delete g.all; - delete g.top; - delete g.order; - delete g.orderNatural; - delete g.size; - g.value = function() { return all()[0].value; }; - return g; - } - - return dimension; - } - - // A convenience method for groupAll on a dummy dimension. - // This implementation can be optimized since it is always cardinality 1. - function groupAll() { - var group = { - reduce: reduce, - reduceCount: reduceCount, - reduceSum: reduceSum, - value: value - }; - - var reduceValue, - reduceAdd, - reduceRemove, - reduceInitial, - resetNeeded = true; - - // The group listens to the crossfilter for when any dimension changes, so - // that it can update the reduce value. It must also listen to the parent - // dimension for when data is added. - filterListeners.push(update); - dataListeners.push(add); - - // For consistency; actually a no-op since resetNeeded is true. - add(data, 0, n); - - // Incorporates the specified new values into this group. - function add(newData, n0, n1) { - var i; - - if (resetNeeded) return; - - // Add the added values. - for (i = n0; i < n; ++i) { - if (!filters[i]) { - reduceValue = reduceAdd(reduceValue, data[i]); - } - } - } - - // Reduces the specified selected or deselected records. - function update(filterOne, added, removed) { - var i, - k, - n; - - if (resetNeeded) return; - - // Add the added values. - for (i = 0, n = added.length; i < n; ++i) { - if (!filters[k = added[i]]) { - reduceValue = reduceAdd(reduceValue, data[k]); - } - } - - // Remove the removed values. - for (i = 0, n = removed.length; i < n; ++i) { - if (filters[k = removed[i]] === filterOne) { - reduceValue = reduceRemove(reduceValue, data[k]); - } - } - } - - // Recomputes the group reduce value from scratch. - function reset() { - var i; - - reduceValue = reduceInitial(); - - for (i = 0; i < n; ++i) { - if (!filters[i]) { - reduceValue = reduceAdd(reduceValue, data[i]); - } - } - } - - // Sets the reduce behavior for this group to use the specified functions. - // This method lazily recomputes the reduce value, waiting until needed. - function reduce(add, remove, initial) { - reduceAdd = add; - reduceRemove = remove; - reduceInitial = initial; - resetNeeded = true; - return group; - } - - // A convenience method for reducing by count. - function reduceCount() { - return reduce(crossfilter_reduceIncrement, crossfilter_reduceDecrement, crossfilter_zero); - } - - // A convenience method for reducing by sum(value). - function reduceSum(value) { - return reduce(crossfilter_reduceAdd(value), crossfilter_reduceSubtract(value), crossfilter_zero); - } - - // Returns the computed reduce value. - function value() { - if (resetNeeded) reset(), resetNeeded = false; - return reduceValue; - } - - return reduceCount(); - } - - // Returns the number of records in this crossfilter, irrespective of any filters. - function size() { - return n; - } - - return arguments.length - ? add(arguments[0]) - : crossfilter; -} - -// Returns an array of size n, big enough to store ids up to m. -function crossfilter_index(n, m) { - return (m < 0x101 - ? crossfilter_array8 : m < 0x10001 - ? crossfilter_array16 - : crossfilter_array32)(n); -} - -// Constructs a new array of size n, with sequential values from 0 to n - 1. -function crossfilter_range(n) { - var range = crossfilter_index(n, n); - for (var i = -1; ++i < n;) range[i] = i; - return range; -} - -function crossfilter_capacity(w) { - return w === 8 - ? 0x100 : w === 16 - ? 0x10000 - : 0x100000000; -} -})(this); diff --git a/awx/ui/static/lib/novus-nvd3/lib/crossfilter.min.js b/awx/ui/static/lib/novus-nvd3/lib/crossfilter.min.js deleted file mode 100755 index 981f0d64ea..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/crossfilter.min.js +++ /dev/null @@ -1 +0,0 @@ -(function(a){function b(a){return a}function c(a,b){for(var c=0,d=b.length,e=new Array(d);c>1;a(b[f])>1;c>>1)+1;while(--f>0)d(a,f,e,b);return a}function c(a,b,c){var e=c-b,f;while(--e>0)f=a[b],a[b]=a[b+e],a[b+e]=f,d(a,1,e,b);return a}function d(b,c,d,e){var f=b[--e+c],g=a(f),h;while((h=c<<1)<=d){ha(b[e+h+1])&&h++;if(g<=a(b[e+h]))break;b[e+c]=b[e+h],c=h}b[e+c]=f}return b.sort=c,b}function i(a){function c(c,d,e,f){var g=new Array(f=Math.min(e-d,f)),h,i,j,k;for(i=0;ih)g[0]=k,h=a(b(g,0,f)[0]);while(++dc&&a(b[f-1])>h;--f)b[f]=b[f-1];b[f]=g}return b}return b}function m(a){function c(a,c,e){return(e-c>1,j=i-f,k=i+f,l=b[g],m=a(l),n=b[j],o=a(n),p=b[i],q=a(p),r=b[k],s=a(r),t=b[h],u=a(t),v;m>o&&(v=l,l=n,n=v,v=m,m=o,o=v),s>u&&(v=r,r=t,t=v,v=s,s=u,u=v),m>q&&(v=l,l=p,p=v,v=m,m=q,q=v),o>q&&(v=n,n=p,p=v,v=o,o=q,q=v),m>s&&(v=l,l=r,r=v,v=m,m=s,s=v),q>s&&(v=p,p=r,r=v,v=q,q=s,s=v),o>u&&(v=n,n=t,t=v,v=o,o=u,u=v),o>q&&(v=n,n=p,p=v,v=o,o=q,q=v),s>u&&(v=r,r=t,t=v,v=s,s=u,u=v);var w=n,x=o,y=r,z=s;b[g]=l,b[j]=b[d],b[i]=p,b[k]=b[e-1],b[h]=t;var A=d+1,B=e-2,C=x<=z&&x>=z;if(C)for(var D=A;D<=B;++D){var E=b[D],F=a(E);if(Fx)for(;;){var G=a(b[B]);if(G>x){B--;continue}if(Gz)for(;;){var G=a(b[B]);if(G>z){B--;if(Bh){var H,G;while((H=a(b[A]))<=x&&H>=x)++A;while((G=a(b[B]))<=z&&G>=z)--B;for(var D=A;D<=B;D++){var E=b[D],F=a(E);if(F<=x&&F>=x)D!==A&&(b[D]=b[A],b[A]=E),A++;else if(F<=z&&F>=z)for(;;){var G=a(b[B]);if(G<=z&&G>=z){B--;if(BN)for(b=N,c=Math.min(e,O);bO)for(b=Math.max(e,O),c=f;b=N&&a>0)k[d=D[c]]||(b.push(e[d]),--a);return b}function X(a){function K(b,c,g,i){function Q(){++n===m&&(p=s(p,j<<=1),h=s(h,j),m=G(j))}var o=d,p=E(n,m),t=v,u=F,w=n,y=0,z=0,A,B,C,D,K,L;J&&(t=u=x),d=new Array(n),n=0,h=w>1?r(h,f):E(f,m),w&&(C=(B=o[0]).key);while(z=D))++z;while(zL)){h[A=c[z]+g]=n,k[A]&q||(K.value=t(K.value,e[A]));if(++z>=i)break;D=a(b[z])}Q()}while(yy)for(y=0;y1?(H=M,I=O):(n===1?(H=N,I=P):(H=x,I=x),h=null),l[A]=H}function M(a,b,c){if(a===p||J)return;var f,g,i,j;for(f=0,i=b.length;fj&&(k=s(k,j<<=1)),P(e,0,f),Q(e,0,f),o}function t(){function i(a,d,g){var i;if(h)return;for(i=d;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; - } - function d3_formatPrefix(d, i) { - var k = Math.pow(10, Math.abs(8 - i) * 3); - return { - scale: i > 8 ? function(d) { - return d / k; - } : function(d) { - return d * k; - }, - symbol: d - }; - } - 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 = .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; - } - 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; - } - function d3_eventDispatch(target) { - var dispatch = new d3_dispatch, i = 0, n = arguments.length; - while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); - 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; - } - 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; - } - 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; - } - function d3_interpolateByName(name) { - return name == "transform" ? d3.interpolateTransform : d3.interpolate; - } - 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)); - }; - } - 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; - } - function d3_rgb_hex(v) { - return v < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); - } - function d3_rgb_parse(format, rgb, hsl) { - var r = 0, g = 0, b = 0, m1, m2, name; - m1 = /([a-z]+)\((.*)\)/i.exec(format); - if (m1) { - m2 = m1[2].split(","); - switch (m1[1]) { - case "hsl": - { - return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); - } - case "rgb": - { - return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); - } - } - } - if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b); - 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_lab(r, g, b) { - r = d3_rgb_xyz(r); - g = d3_rgb_xyz(g); - b = d3_rgb_xyz(b); - var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); - return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); - } - function d3_rgb_xyz(r) { - return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); - } - function d3_rgb_parseNumber(c) { - var f = parseFloat(c); - return c.charAt(c.length - 1) === "%" ? Math.round(f * 2.55) : f; - } - 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; - } - function d3_hsl_rgb(h, s, l) { - 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); - } - var m1, m2; - h = h % 360; - if (h < 0) h += 360; - s = s < 0 ? 0 : s > 1 ? 1 : s; - l = l < 0 ? 0 : l > 1 ? 1 : l; - m2 = l <= .5 ? l * (1 + s) : l + s - l * s; - m1 = 2 * l - m2; - return d3_rgb(vv(h + 120), vv(h), vv(h - 120)); - } - function d3_hcl(h, c, l) { - return new d3_Hcl(h, c, l); - } - function d3_Hcl(h, c, l) { - this.h = h; - this.c = c; - this.l = l; - } - function d3_hcl_lab(h, c, l) { - return d3_lab(l, Math.cos(h *= Math.PI / 180) * c, Math.sin(h) * c); - } - function d3_lab(l, a, b) { - return new d3_Lab(l, a, b); - } - function d3_Lab(l, a, b) { - this.l = l; - this.a = a; - this.b = b; - } - function d3_lab_rgb(l, a, b) { - var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; - x = d3_lab_xyz(x) * d3_lab_X; - y = d3_lab_xyz(y) * d3_lab_Y; - z = d3_lab_xyz(z) * d3_lab_Z; - return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); - } - function d3_lab_hcl(l, a, b) { - return d3_hcl(Math.atan2(b, a) / Math.PI * 180, Math.sqrt(a * a + b * b), l); - } - function d3_lab_xyz(x) { - return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; - } - function d3_xyz_lab(x) { - return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; - } - function d3_xyz_rgb(r) { - return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); - } - function d3_selection(groups) { - d3_arraySubclass(groups, d3_selectionPrototype); - return groups; - } - function d3_selection_selector(selector) { - return function() { - return d3_select(selector, this); - }; - } - function d3_selection_selectorAll(selector) { - return function() { - return d3_selectAll(selector, this); - }; - } - function d3_selection_attr(name, value) { - 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); - } - name = d3.ns.qualify(name); - return value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; - } - function d3_selection_classedRe(name) { - return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); - } - function d3_selection_classed(name, value) { - function classedConstant() { - var i = -1; - while (++i < n) name[i](this, value); - } - function classedFunction() { - var i = -1, x = value.apply(this, arguments); - while (++i < n) name[i](this, x); - } - name = name.trim().split(/\s+/).map(d3_selection_classedName); - var n = name.length; - return typeof value === "function" ? classedFunction : classedConstant; - } - function d3_selection_classedName(name) { - var re = d3_selection_classedRe(name); - return function(node, value) { - if (c = node.classList) return value ? c.add(name) : c.remove(name); - var c = node.className, cb = c.baseVal != null, cv = cb ? c.baseVal : c; - if (value) { - re.lastIndex = 0; - if (!re.test(cv)) { - cv = d3_collapse(cv + " " + name); - if (cb) c.baseVal = cv; else node.className = cv; - } - } else if (cv) { - cv = d3_collapse(cv.replace(re, " ")); - if (cb) c.baseVal = cv; else node.className = cv; - } - }; - } - function d3_selection_style(name, value, priority) { - 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 value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; - } - function d3_selection_property(name, value) { - 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 value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; - } - function d3_selection_dataNode(data) { - return { - __data__: data - }; - } - function d3_selection_filter(selector) { - return function() { - return d3_selectMatches(this, selector); - }; - } - function d3_selection_sortComparator(comparator) { - if (!arguments.length) comparator = d3.ascending; - return function(a, b) { - return comparator(a && a.__data__, b && b.__data__); - }; - } - function d3_selection_on(type, listener, capture) { - function onRemove() { - var wrapper = this[name]; - if (wrapper) { - this.removeEventListener(type, wrapper, wrapper.$); - delete this[name]; - } - } - function onAdd() { - function wrapper(e) { - var o = d3.event; - d3.event = e; - args[0] = node.__data__; - try { - listener.apply(node, args); - } finally { - d3.event = o; - } - } - var node = this, args = arguments; - onRemove.call(this); - this.addEventListener(type, this[name] = wrapper, wrapper.$ = capture); - wrapper._ = listener; - } - var name = "__on" + type, i = type.indexOf("."); - if (i > 0) type = type.substring(0, i); - return listener ? onAdd : onRemove; - } - function d3_selection_each(groups, callback) { - for (var j = 0, m = groups.length; j < m; j++) { - for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { - if (node = group[i]) callback(node, i, j); - } - } - return groups; - } - function d3_selection_enter(selection) { - d3_arraySubclass(selection, d3_selection_enterPrototype); - return selection; - } - 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) { - return d3_selection_each(groups, function(node, i, j) { - function start(elapsed) { - if (lock.active > id) return stop(); - lock.active = id; - tweens.forEach(function(key, value) { - if (value = value.call(node, d, i)) { - tweened.push(value); - } - }); - 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; - } - var tweened = [], delay = node.delay, duration = node.duration, lock = (node = node.node).__transition__ || (node.__transition__ = { - active: 0, - count: 0 - }), d = node.__data__; - ++lock.count; - delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time); - }); - }, 0, time); - return groups; - } - 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(); - d3_selection_each(this, function(node, i, j) { - d3_transitionDelay = node.delay; - d3_transitionDuration = node.duration; - callback.call(node = node.node, node.__data__, i, j); - }); - d3_transitionId = id; - d3_transitionEase = ease; - d3_transitionDelay = delay; - d3_transitionDuration = duration; - return this; - } - function d3_tweenNull(d, i, a) { - return a != "" && d3_tweenRemove; - } - function d3_tweenByName(b, name) { - return d3.tween(b, d3_interpolateByName(name)); - } - 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); - } - } - 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; - } - 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 ]; - } - function d3_noop() {} - 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 (nice = nice(x1 - x0)) { - domain[i0] = nice.floor(x0); - domain[i1] = nice.ceil(x1); - } - return domain; - } - function d3_scale_niceDefault() { - return Math; - } - function d3_scale_linear(domain, range, interpolate, clamp) { - 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); - } - var output, input; - 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 dx && { - 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; - if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; - extent[0] = Math.ceil(extent[0] / step) * step; - extent[1] = Math.floor(extent[1] / step) * step + step * .5; - 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; - 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)); - }; - } - function d3_scale_log(linear, log) { - function scale(x) { - return linear(log(x)); - } - var pow = log.pow; - 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++) {} - for (j = ticks.length; ticks[j - 1] > v; j--) {} - 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 = Math.max(.1, 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); - } - 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; - } - function d3_scale_pow(linear, exponent) { - function scale(x) { - return linear(powp(x)); - } - var powp = d3_scale_powPow(exponent), powb = d3_scale_powPow(1 / exponent); - 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); - }; - } - function d3_scale_ordinal(domain, ranger) { - 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; - }); - } - var index, range, rangeBand; - 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].apply(scale, ranger.a); - }; - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - rangeBand = 0; - ranger = { - t: "range", - a: arguments - }; - return scale; - }; - scale.rangePoints = function(x, padding) { - if (arguments.length < 2) padding = 0; - var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding); - range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); - rangeBand = 0; - ranger = { - t: "rangePoints", - a: arguments - }; - return scale; - }; - scale.rangeBands = function(x, padding, outerPadding) { - if (arguments.length < 2) padding = 0; - if (arguments.length < 3) outerPadding = padding; - var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); - range = steps(start + step * outerPadding, step); - if (reverse) range.reverse(); - rangeBand = step * (1 - padding); - ranger = { - t: "rangeBands", - a: arguments - }; - return scale; - }; - scale.rangeRoundBands = function(x, padding, outerPadding) { - if (arguments.length < 2) padding = 0; - if (arguments.length < 3) outerPadding = padding; - var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), 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", - a: arguments - }; - return scale; - }; - scale.rangeBand = function() { - return rangeBand; - }; - scale.rangeExtent = function() { - return d3_scaleExtent(ranger.a[0]); - }; - scale.copy = function() { - return d3_scale_ordinal(domain, ranger); - }; - return scale.domain(domain); - } - function d3_scale_quantile(domain, range) { - 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)]; - } - var thresholds; - 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); - }; - return rescale(); - } - function d3_scale_quantize(x0, x1, range) { - 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; - } - var kx, i; - 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); - }; - return rescale(); - } - function d3_scale_threshold(domain, range) { - function scale(x) { - return range[d3.bisect(domain, x)]; - } - scale.domain = function(_) { - if (!arguments.length) return domain; - domain = _; - return scale; - }; - scale.range = function(_) { - if (!arguments.length) return range; - range = _; - return scale; - }; - scale.copy = function() { - return d3_scale_threshold(domain, range); - }; - return scale; - } - 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; - } - 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) { - function line(data) { - function segment() { - segments.push("M", interpolate(projection(points), tension)); - } - var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); - while (++i < n) { - if (defined.call(this, d = data[i], i)) { - points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); - } else if (points.length) { - segment(); - points = []; - } - } - if (points.length) segment(); - return segments.length ? segments.join("") : null; - } - var x = d3_svg_lineX, y = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; - line.x = function(_) { - if (!arguments.length) return x; - x = _; - return line; - }; - line.y = function(_) { - if (!arguments.length) return y; - y = _; - return line; - }; - line.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return line; - }; - line.interpolate = function(_) { - if (!arguments.length) return interpolateKey; - if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; - return line; - }; - line.tension = function(_) { - if (!arguments.length) return tension; - tension = _; - return line; - }; - return line; - } - function d3_svg_lineX(d) { - return d[0]; - } - function d3_svg_lineY(d) { - return d[1]; - } - function d3_svg_lineLinear(points) { - return points.join("L"); - } - function d3_svg_lineLinearClosed(points) { - return d3_svg_lineLinear(points) + "Z"; - } - 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(""); - } - 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(""); - } - 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)); - } - 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)); - } - 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)); - } - 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; - } - 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; - } - 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(""); - } - 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(""); - } - 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; - if (n) { - var 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); - } - function d3_svg_lineDot4(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; - } - 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)); - } - function d3_svg_lineSlope(p0, p1) { - return (p1[1] - p0[1]) / (p1[0] - p0[0]); - } - 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]))) / 2; - } - m[i] = d; - return m; - } - function d3_svg_lineMonotoneTangents(points) { - var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; - while (++i < j) { - d = d3_svg_lineSlope(points[i], points[i + 1]); - if (Math.abs(d) < 1e-6) { - m[i] = m[i + 1] = 0; - } else { - a = m[i] / d; - b = m[i + 1] / d; - s = a * a + b * b; - if (s > 9) { - s = d * 3 / Math.sqrt(s); - m[i] = s * a; - m[i + 1] = s * b; - } - } - } - 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)); - } - 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) { - function area(data) { - function segment() { - segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); - } - var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { - return x; - } : d3_functor(x1), fy1 = y0 === y1 ? function() { - return y; - } : d3_functor(y1), x, y; - while (++i < n) { - if (defined.call(this, d = data[i], i)) { - points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); - points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); - } else if (points0.length) { - segment(); - points0 = []; - points1 = []; - } - } - if (points0.length) segment(); - return segments.length ? segments.join("") : null; - } - var x0 = d3_svg_lineX, x1 = d3_svg_lineX, y0 = 0, y1 = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; - area.x = function(_) { - if (!arguments.length) return x1; - x0 = x1 = _; - return area; - }; - area.x0 = function(_) { - if (!arguments.length) return x0; - x0 = _; - return area; - }; - area.x1 = function(_) { - if (!arguments.length) return x1; - x1 = _; - return area; - }; - area.y = function(_) { - if (!arguments.length) return y1; - y0 = y1 = _; - return area; - }; - area.y0 = function(_) { - if (!arguments.length) return y0; - y0 = _; - return area; - }; - area.y1 = function(_) { - if (!arguments.length) return y1; - y1 = _; - return area; - }; - area.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return area; - }; - area.interpolate = function(_) { - if (!arguments.length) return interpolateKey; - if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; - interpolateReverse = interpolate.reverse || interpolate; - L = interpolate.closed ? "M" : "L"; - return area; - }; - area.tension = function(_) { - if (!arguments.length) return tension; - tension = _; - return area; - }; - return area; - } - 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; - } - function d3_svg_diagonalProjection(d) { - return [ d.x, d.y ]; - } - 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) ]; - }; - } - 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"; - } - 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; - } - function d3_behavior_zoomDelta() { - 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 = 1e3; - d3_behavior_zoomDiv.dispatchEvent(e); - delta = 1e3 - d3_behavior_zoomDiv.scrollTop; - } catch (error) { - delta = e.wheelDelta || -e.detail * 5; - } - return delta; - } - 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; - } - function d3_layout_forceDragstart(d) { - d.fixed |= 2; - } - function d3_layout_forceDragend(d) { - d.fixed &= 1; - } - function d3_layout_forceMouseover(d) { - d.fixed |= 4; - } - function d3_layout_forceMouseout(d) { - d.fixed &= 3; - } - 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) { - 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; - } - 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; - } - 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]; - } - 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) ]; - } - function d3_layout_hierarchyRebind(object, hierarchy) { - d3.rebind(object, hierarchy, "sort", "children", "value"); - object.links = d3_layout_hierarchyLinks; - 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; - } - function d3_layout_hierarchyLinks(nodes) { - return d3.merge(nodes.map(function(parent) { - return (parent.children || []).map(function(child) { - return { - source: parent, - target: child - }; - }); - })); - } - 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; - } - function d3_layout_packSiblings(node) { - 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); - } - if (!(nodes = node.children) || !(n = nodes.length)) return; - var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; - nodes.forEach(d3_layout_packLink); - a = nodes[0]; - a.x = -a.r; - a.y = 0; - bound(a); - if (n > 1) { - b = nodes[1]; - b.x = b.r; - b.y = 0; - bound(b); - 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; - for (i = 3; i < n; i++) { - d3_layout_packPlace(a, b, c = nodes[i]); - 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; - } - } - } - 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); - } - } - } - } - var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; - for (i = 0; i < n; i++) { - c = nodes[i]; - c.x -= cx; - c.y -= cy; - cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); - } - node.r = cr; - nodes.forEach(d3_layout_packUnlink); - } - 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_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 = dx * dx + dy * dy; - da *= da; - db *= db; - var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); - 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; - } - } - 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; - } - function d3_layout_treeSeparation(a, b) { - return a.parent == b.parent ? 1 : 2; - } - 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; - } - 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 - }; - } - function d3_dsv(delimiter, mimeType) { - function dsv(url, callback) { - d3.text(url, mimeType, function(text) { - callback(text && dsv.parse(text)); - }); - } - function formatRow(row) { - return row.map(formatValue).join(delimiter); - } - function formatValue(text) { - return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; - } - var reParse = new RegExp("\r\n|[" + delimiter + "\r\n]", "g"), reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); - dsv.parse = function(text) { - var header; - return dsv.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; - } - }); - }; - dsv.parseRows = function(text, f) { - function token() { - if (reParse.lastIndex >= text.length) return EOF; - if (eol) { - eol = false; - return EOL; - } - var j = reParse.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++; - } - } - reParse.lastIndex = i + 2; - var c = text.charCodeAt(i + 1); - if (c === 13) { - eol = true; - if (text.charCodeAt(i + 2) === 10) reParse.lastIndex++; - } else if (c === 10) { - eol = true; - } - return text.substring(j + 1, i).replace(/""/g, '"'); - } - var m = reParse.exec(text); - if (m) { - eol = m[0].charCodeAt(0) !== delimiterCode; - return text.substring(j, m.index); - } - reParse.lastIndex = text.length; - return text.substring(j); - } - var EOL = {}, EOF = {}, rows = [], n = 0, t, eol; - reParse.lastIndex = 0; - 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; - }; - dsv.format = function(rows) { - return rows.map(formatRow).join("\n"); - }; - return dsv; - } - function d3_geo_type(types, defaultValue) { - return function(object) { - return object && types.hasOwnProperty(object.type) ? types[object.type](object) : defaultValue; - }; - } - 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"; - } - function d3_geo_bounds(o, f) { - if (d3_geo_boundsTypes.hasOwnProperty(o.type)) d3_geo_boundsTypes[o.type](o, f); - } - 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]); - } - } - function d3_geo_greatArcSource(d) { - return d.source; - } - function d3_geo_greatArcTarget(d) { - return d.target; - } - function d3_geo_greatArcInterpolator() { - function interpolate(t) { - var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, 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 ]; - } - var x0, y0, cy0, sy0, kx0, ky0, x1, y1, cy1, sy1, kx1, ky1, d, k; - interpolate.distance = function() { - if (d == null) k = 1 / Math.sin(d = Math.acos(Math.max(-1, Math.min(1, sy0 * sy1 + cy0 * cy1 * Math.cos(x1 - x0))))); - return d; - }; - interpolate.source = function(_) { - var cx0 = Math.cos(x0 = _[0] * d3_geo_radians), sx0 = Math.sin(x0); - cy0 = Math.cos(y0 = _[1] * d3_geo_radians); - sy0 = Math.sin(y0); - kx0 = cy0 * cx0; - ky0 = cy0 * sx0; - d = null; - return interpolate; - }; - interpolate.target = function(_) { - var cx1 = Math.cos(x1 = _[0] * d3_geo_radians), sx1 = Math.sin(x1); - cy1 = Math.cos(y1 = _[1] * d3_geo_radians); - sy1 = Math.sin(y1); - kx1 = cy1 * cx1; - ky1 = cy1 * sx1; - d = null; - return interpolate; - }; - return interpolate; - } - function d3_geo_greatArcInterpolate(a, b) { - var i = d3_geo_greatArcInterpolator().source(a).target(b); - i.distance(); - return i; - } - function d3_geom_contourStart(grid) { - var x = 0, y = 0; - while (true) { - if (grid(x, y)) { - return [ x, y ]; - } - if (x === 0) { - x = y + 1; - y = 0; - } else { - x = x - 1; - y = y + 1; - } - } - } - 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; - } - function d3_geom_polygonInside(p, a, b) { - return (b[0] - a[0]) * (p[1] - a[1]) < (b[1] - a[1]) * (p[0] - a[0]); - } - 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 ]; - } - 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 { - 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)) { - 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()) { - 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; - } - } - for (lbnd = EdgeList.right(EdgeList.leftEnd); lbnd != EdgeList.rightEnd; lbnd = EdgeList.right(lbnd)) { - callback(lbnd.edge); - } - } - 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] - }; - } - function d3_time_utc() { - this._ = new Date(arguments.length > 1 ? Date.UTC.apply(this, arguments) : arguments[0]); - } - function d3_time_formatAbbreviate(name) { - return name.substring(0, 3); - } - 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; - } - function d3_time_formatRe(names) { - return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); - } - function d3_time_formatLookup(names) { - var map = new d3_Map, i = -1, n = names.length; - while (++i < n) map.set(names[i].toLowerCase(), i); - return map; - } - function d3_time_parseWeekdayAbbrev(date, string, i) { - d3_time_dayAbbrevRe.lastIndex = 0; - var n = d3_time_dayAbbrevRe.exec(string.substring(i)); - return n ? i += n[0].length : -1; - } - function d3_time_parseWeekday(date, string, i) { - d3_time_dayRe.lastIndex = 0; - var n = d3_time_dayRe.exec(string.substring(i)); - return n ? i += n[0].length : -1; - } - function d3_time_parseMonthAbbrev(date, string, i) { - d3_time_monthAbbrevRe.lastIndex = 0; - var n = d3_time_monthAbbrevRe.exec(string.substring(i)); - return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; - } - function d3_time_parseMonth(date, string, i) { - d3_time_monthRe.lastIndex = 0; - var n = d3_time_monthRe.exec(string.substring(i)); - return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; - } - 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_expandYear(+n[0]), i += n[0].length) : -1; - } - function d3_time_expandYear(d) { - return d + (d > 68 ? 1900 : 2e3); - } - 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; - } - 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; - } - 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); - } - 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); - } - function d3_time_formatIsoNative(date) { - return date.toISOString(); - } - 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; - } - }; - } - 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) { - return scale.domain(d3_scale_nice(scale.domain(), function() { - return m; - })); - }; - 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); - }; - scale.tickFormat = function() { - return format; - }; - scale.copy = function() { - return d3_time_scale(linear.copy(), methods, format); - }; - return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); - } - 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); - 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); - } - function d3_time_scaleUTCSetYear(y) { - var d = new Date(Date.UTC(y, 0, 1)); - d.setUTCFullYear(y); - 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); - } - 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.10.2" - }; - var d3_array = d3_arraySlice; - try { - d3_array(document.documentElement.childNodes)[0].nodeType; - } catch (e) { - d3_array = d3_arrayCopy; - } - var d3_arraySubclass = [].__proto__ ? function(array, prototype) { - array.__proto__ = prototype; - } : 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; - }; - 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", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); - d3.functor = d3_functor; - 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; - }; - 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(µ, σ) { - var n = arguments.length; - if (n < 2) σ = 1; - if (n < 1) µ = 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 µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); - }; - }, - logNormal: function(µ, σ) { - var n = arguments.length; - if (n < 2) σ = 1; - if (n < 1) µ = 0; - var random = d3.random.normal(); - return function() { - return Math.exp(µ + σ * random()); - }; - }, - irwinHall: function(m) { - return function() { - for (var s = 0, j = 0; j < m; j++) s += Math.random(); - return s / m; - }; - } - }; - 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; - }; - 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; - }; - 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() { - 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, values) { - o[keyValue] = map(values, 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; - } - var nest = {}, keys = [], sortKeys = [], sortValues, rollup; - 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; - }; - nest.sortKeys = function(order) { - sortKeys[keys.length - 1] = order; - return nest; - }; - 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; - }; - 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; - }; - 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) { - var s = req.status; - callback(!s && req.response || s >= 200 && s < 300 || s === 304 ? 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) { - 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; - }; - d3_dispatch.prototype.on = function(type, listener) { - var i = type.indexOf("."), name = ""; - 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); - }; - 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"; - 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 (type == "r" && !precision) type = "g"; - type = d3_format_types.get(type) || d3_format_typeDefault; - return function(value) { - if (integer && value % 1) return ""; - var negative = value < 0 && (value = -value) ? "-" : sign; - if (scale < 0) { - var prefix = d3.formatPrefix(value, precision); - value = prefix.scale(value); - suffix = prefix.symbol; - } else { - value *= scale; - } - value = type(value, precision); - 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; - } 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; - }; - }; - 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))); - } - }); - 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]; - }; - 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)))); - }; - d3.event = null; - d3.transform = function(string) { - var g = document.createElementNS(d3.ns.prefix.svg, "g"); - return (d3.transform = function(string) { - g.setAttribute("transform", string); - var t = g.transform.baseVal.consolidate(); - return new d3_transform(t ? t.matrix : d3_transformIdentity); - })(string); - }; - d3_transform.prototype.toString = function() { - return "translate(" + this.translate + ")rotate(" + this.rotate + ")skewX(" + this.skew + ")scale(" + this.scale + ")"; - }; - var d3_transformDegrees = 180 / Math.PI, d3_transformIdentity = { - a: 1, - b: 0, - c: 0, - d: 1, - e: 0, - f: 0 - }; - 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, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o; - d3_interpolate_number.lastIndex = 0; - 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)); - for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { - o = q[i]; - if (o.x == m[0]) { - if (o.i) { - if (s[o.i + 1] == null) { - s[o.i - 1] += o.x; - s.splice(o.i, 1); - for (j = i + 1; j < n; ++j) q[j].i--; - } else { - 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) { - s[o.i] = o.x; - } else { - 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)); - } - } - while (i < n) { - o = q.pop(); - if (s[o.i + 1] == null) { - s[o.i] = o.x; - } else { - s[o.i] = o.x + s[o.i + 1]; - s.splice(o.i + 1, 1); - } - n--; - } - if (s.length === 1) { - return s[0] == null ? q[0].x : function() { - return b; - }; - } - 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 = [], q = [], 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) { - if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; - 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)); - }; - }; - 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; - if (h1 > 180) h1 -= 360; else if (h1 < -180) h1 += 360; - return function(t) { - return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t) + ""; - }; - }; - d3.interpolateLab = function(a, b) { - a = d3.lab(a); - b = d3.lab(b); - var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; - return function(t) { - return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; - }; - }; - d3.interpolateHcl = function(a, b) { - a = d3.hcl(a); - b = d3.hcl(b); - var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; - if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; - return function(t) { - return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; - }; - }; - 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*|\.?\d+)(?:[eE][-+]?\d+)?/g; - 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); - } ]; - 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); - }; - d3_Rgb.prototype.brighter = function(k) { - k = Math.pow(.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(.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); - }; - 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); - }; - d3_Hsl.prototype.brighter = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - return d3_hsl(this.h, this.s, this.l / k); - }; - d3_Hsl.prototype.darker = function(k) { - k = Math.pow(.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(); - }; - d3.hcl = function(h, c, l) { - return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l); - }; - d3_Hcl.prototype.brighter = function(k) { - return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); - }; - d3_Hcl.prototype.darker = function(k) { - return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); - }; - d3_Hcl.prototype.rgb = function() { - return d3_hcl_lab(this.h, this.c, this.l).rgb(); - }; - d3_Hcl.prototype.toString = function() { - return this.rgb() + ""; - }; - d3.lab = function(l, a, b) { - return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b); - }; - var d3_lab_K = 18; - var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; - d3_Lab.prototype.brighter = function(k) { - return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); - }; - d3_Lab.prototype.darker = function(k) { - return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); - }; - d3_Lab.prototype.rgb = function() { - return d3_lab_rgb(this.l, this.a, this.b); - }; - d3_Lab.prototype.toString = function() { - return this.rgb() + ""; - }; - 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); - }; - if (typeof Sizzle === "function") { - d3_select = function(s, n) { - return Sizzle(s, n)[0] || null; - }; - 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); - }; - 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); - }; - d3_selectionPrototype.attr = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") { - var node = this.node(); - name = d3.ns.qualify(name); - return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); - } - for (value in name) this.each(d3_selection_attr(value, name[value])); - return this; - } - return this.each(d3_selection_attr(name, value)); - }; - d3_selectionPrototype.classed = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") { - var node = this.node(), n = (name = name.trim().split(/^|\s+/g)).length, i = -1; - if (value = node.classList) { - while (++i < n) if (!value.contains(name[i])) return false; - } else { - value = node.className; - if (value.baseVal != null) value = value.baseVal; - while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; - } - return true; - } - for (value in name) this.each(d3_selection_classed(value, name[value])); - return this; - } - return this.each(d3_selection_classed(name, value)); - }; - d3_selectionPrototype.style = function(name, value, priority) { - var n = arguments.length; - if (n < 3) { - if (typeof name !== "string") { - if (n < 2) value = ""; - for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); - return this; - } - if (n < 2) return window.getComputedStyle(this.node(), null).getPropertyValue(name); - priority = ""; - } - return this.each(d3_selection_style(name, value, priority)); - }; - d3_selectionPrototype.property = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") return this.node()[name]; - for (value in name) this.each(d3_selection_property(value, name[value])); - return this; - } - return this.each(d3_selection_property(name, value)); - }; - 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; - }); - }; - d3_selectionPrototype.append = function(name) { - function append() { - return this.appendChild(document.createElementNS(this.namespaceURI, name)); - } - function appendNS() { - return this.appendChild(document.createElementNS(name.space, name.local)); - } - name = d3.ns.qualify(name); - return this.select(name.local ? appendNS : append); - }; - d3_selectionPrototype.insert = function(name, before) { - 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)); - } - name = d3.ns.qualify(name); - return this.select(name.local ? insertNS : insert); - }; - d3_selectionPrototype.remove = function() { - return this.each(function() { - var parent = this.parentNode; - if (parent) parent.removeChild(this); - }); - }; - d3_selectionPrototype.data = function(value, key) { - 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; - } 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 i = -1, n = this.length, group, node; - if (!arguments.length) { - value = new Array(n = (group = this[0]).length); - while (++i < n) { - if (node = group[i]) { - value[i] = node.__data__; - } - } - return value; - } - 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; - }; - 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); - }; - 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(); - }; - d3_selectionPrototype.on = function(type, listener, capture) { - var n = arguments.length; - if (n < 3) { - if (typeof type !== "string") { - if (n < 2) listener = false; - for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); - return this; - } - if (n < 2) return (n = this.node()["__on" + type]) && n._; - capture = false; - } - return this.each(d3_selection_on(type, listener, capture)); - }; - d3_selectionPrototype.each = function(callback) { - return d3_selection_each(this, function(node, i, j) { - callback.call(node, node.__data__, i, j); - }); - }; - 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; - d3.select = function(selector) { - return typeof selector === "string" ? d3_selectionRoot.select(selector) : d3_selection([ [ selector ] ]); - }; - d3.selectAll = function(selector) { - return typeof selector === "string" ? d3_selectionRoot.selectAll(selector) : d3_selection([ d3_array(selector) ]); - }; - 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); - }; - 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.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 = []); - for (var group = this[j], i = 0, n = group.length; i < n; i++) { - if ((node = group[i]) && filter.call(node.node, node.node.__data__, i)) { - subgroup.push(node); - } - } - } - return d3_transition(subgroups, this.id, this.time).ease(this.ease()); - }; - d3_transitionPrototype.attr = function(name, value) { - if (arguments.length < 2) { - for (value in name) this.attrTween(value, d3_tweenByName(name[value], value)); - return this; - } - return this.attrTween(name, d3_tweenByName(value, name)); - }; - d3_transitionPrototype.attrTween = function(nameNS, tween) { - function attrTween(d, i) { - var f = tween.call(this, d, i, this.getAttribute(name)); - return f === d3_tweenRemove ? (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_tweenRemove ? (this.removeAttributeNS(name.space, name.local), null) : f && function(t) { - this.setAttributeNS(name.space, name.local, f(t)); - }; - } - var name = d3.ns.qualify(nameNS); - return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); - }; - d3_transitionPrototype.style = function(name, value, priority) { - var n = arguments.length; - if (n < 3) { - if (typeof name !== "string") { - if (n < 2) value = ""; - for (priority in name) this.styleTween(priority, d3_tweenByName(name[priority], priority), value); - return this; - } - priority = ""; - } - return this.styleTween(name, d3_tweenByName(value, name), 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_tweenRemove ? (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) { - return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node.delay = value.call(node = node.node, node.__data__, i, j) | 0; - } : (value = value | 0, function(node) { - node.delay = value; - })); - }; - d3_transitionPrototype.duration = function(value) { - return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node.duration = Math.max(1, value.call(node = node.node, node.__data__, i, j) | 0); - } : (value = Math.max(1, value | 0), function(node) { - node.duration = value; - })); - }; - d3_transitionPrototype.transition = function() { - return this.select(d3_this); - }; - d3.tween = function(b, interpolate) { - function tweenFunction(d, i, a) { - var v = b.call(this, d, i); - return v == null ? a != "" && d3_tweenRemove : a != v && interpolate(a, v); - } - function tweenString(d, i, a) { - return a != b && interpolate(a, b); - } - return typeof b === "function" ? tweenFunction : b == null ? d3_tweenNull : (b += "", tweenString); - }; - var d3_tweenRemove = {}; - var d3_timer_queue = null, d3_timer_interval, d3_timer_timeout; - 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(); - } - while (t1) { - if (t1.callback === callback) { - t1.then = then; - t1.delay = delay; - found = true; - break; - } - t0 = t1; - t1 = t1.next; - } - if (!found) d3_timer_queue = { - callback: callback, - then: then, - delay: delay, - next: d3_timer_queue - }; - if (!d3_timer_interval) { - d3_timer_timeout = clearTimeout(d3_timer_timeout); - 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(); - }; - var d3_timer_frame = window.requestAnimationFrame || window.webkitRequestAnimationFrame || window.mozRequestAnimationFrame || window.oRequestAnimationFrame || window.msRequestAnimationFrame || function(callback) { - setTimeout(callback, 17); - }; - d3.mouse = function(container) { - return d3_mousePoint(container, d3_eventSource()); - }; - var d3_mouse_bug44083 = /WebKit/.test(navigator.userAgent) ? -1 : 0; - 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; - }) : []; - }; - d3.scale = {}; - d3.scale.linear = function() { - return d3_scale_linear([ 0, 1 ], [ 0, 1 ], d3.interpolate, false); - }; - d3.scale.log = function() { - return d3_scale_log(d3.scale.linear(), d3_scale_logp); - }; - var d3_scale_logFormat = d3.format(".0e"); - 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); - }; - d3.scale.sqrt = function() { - return d3.scale.pow().exponent(.5); - }; - d3.scale.ordinal = function() { - return d3_scale_ordinal([], { - t: "range", - a: [ [] ] - }); - }; - 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([], []); - }; - d3.scale.quantize = function() { - return d3_scale_quantize(0, 1, [ 0, 1 ]); - }; - d3.scale.threshold = function() { - return d3_scale_threshold([ .5 ], [ 0, 1 ]); - }; - d3.scale.identity = function() { - return d3_scale_identity([ 0, 1 ]); - }; - d3.svg = {}; - d3.svg.arc = function() { - 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"; - } - var innerRadius = d3_svg_arcInnerRadius, outerRadius = d3_svg_arcOuterRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; - 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; - d3.svg.line = function() { - return d3_svg_line(d3_identity); - }; - var d3_svg_lineInterpolators = d3.map({ - linear: d3_svg_lineLinear, - "linear-closed": d3_svg_lineLinearClosed, - "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 - }); - d3_svg_lineInterpolators.forEach(function(key, value) { - value.key = key; - value.closed = /-closed$/.test(key); - }); - 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 ]; - 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; - }; - d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; - d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; - d3.svg.area = function() { - return d3_svg_area(d3_identity); - }; - 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() { - 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; - } - var source = d3_svg_chordSource, target = d3_svg_chordTarget, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; - 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; - }; - d3.svg.diagonal = function() { - 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]; - } - var source = d3_svg_chordSource, target = d3_svg_chordTarget, projection = d3_svg_diagonalProjection; - 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; - }; - 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; - }; - d3.svg.mouse = d3.mouse; - d3.svg.touches = d3.touches; - d3.svg.symbol = function() { - function symbol(d, i) { - return (d3_svg_symbols.get(type.call(this, d, i)) || d3_svg_symbolCircle)(size.call(this, d, i)); - } - var type = d3_svg_symbolType, size = d3_svg_symbolSize; - symbol.type = function(x) { - if (!arguments.length) return type; - type = d3_functor(x); - return symbol; - }; - symbol.size = function(x) { - if (!arguments.length) return size; - size = d3_functor(x); - return symbol; - }; - return symbol; - }; - 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() { - function axis(g) { - g.each(function() { - var g = d3.select(this); - 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_; - 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); - 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; - var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathEnter = path.enter().append("path").attr("class", "domain"), pathUpdate = d3.transition(path); - var scale1 = scale.copy(), scale0 = this.__chart__ || scale1; - this.__chart__ = scale1; - tickEnter.append("line").attr("class", "tick"); - tickEnter.append("text"); - var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); - switch (orient) { - case "bottom": - { - tickTransform = d3_svg_axisX; - subtickEnter.attr("y2", tickMinorSize); - subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize); - lineEnter.attr("y2", tickMajorSize); - textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding); - lineUpdate.attr("x2", 0).attr("y2", tickMajorSize); - textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding); - text.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); - lineEnter.attr("y2", -tickMajorSize); - textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); - lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize); - textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); - text.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); - lineEnter.attr("x2", -tickMajorSize); - textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)); - lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0); - textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0); - text.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); - lineEnter.attr("x2", tickMajorSize); - textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding); - lineUpdate.attr("x2", tickMajorSize).attr("y2", 0); - textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0); - text.attr("dy", ".32em").attr("text-anchor", "start"); - pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize); - break; - } - } - 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); - } else { - var dx = scale1.rangeBand() / 2, x = function(d) { - return scale1(d) + dx; - }; - tickEnter.call(tickTransform, x); - tickUpdate.call(tickTransform, x); - } - }); - } - var scale = d3.scale.linear(), orient = "bottom", tickMajorSize = 6, tickMinorSize = 6, tickEndSize = 6, tickPadding = 3, tickArguments_ = [ 10 ], tickValues = null, tickFormat_, tickSubdivide = 0; - 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; - }; - d3.svg.brush = function() { - 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; - g.style("pointer-events", "all").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); - bg.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); - fg.enter().append("rect").attr("class", "extent").style("cursor", "move"); - 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"); - tz.style("display", brush.empty() ? "none" : null); - tz.exit().remove(); - 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() { - 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; - if (offset) { - point[0] += offset[0]; - point[1] += offset[1]; - } - if (!dragging) { - if (d3.event.altKey) { - if (!center) center = [ (extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2 ]; - origin[0] = extent[+(point[0] < center[0])][0]; - origin[1] = extent[+(point[1] < center[1])][1]; - } else center = null; - } - if (resizingX && move1(point, x, 0)) { - redrawX(g); - moved = true; - } - if (resizingY && move1(point, y, 1)) { - redrawY(g); - moved = true; - } - 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; - if (dragging) { - r0 -= position; - r1 -= size + position; - } - min = Math.max(r0, Math.min(r1, point[i])); - if (dragging) { - max = (min += position) + size; - } else { - if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); - if (position < min) { - max = min; - min = position; - } else { - max = position; - } - } - if (extent[0][i] !== min || extent[1][i] !== max) { - extentDomain = null; - extent[0][i] = min; - extent[1][i] = max; - return true; - } - } - function brushend() { - brushmove(); - 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(); - } - 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 (dragging) { - origin[0] = extent[0][0] - origin[0]; - origin[1] = extent[0][1] - origin[1]; - } 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]; - } else if (d3.event.altKey) center = origin.slice(); - g.style("pointer-events", "none").selectAll(".resize").style("display", null); - d3.select("body").style("cursor", eventTarget.style("cursor")); - event_({ - type: "brushstart" - }); - brushmove(); - d3_eventCancel(); - } - var event = d3_eventDispatch(brush, "brushstart", "brush", "brushend"), x = null, y = null, resizes = d3_svg_brushResizes[0], extent = [ [ 0, 0 ], [ 0, 0 ] ], extentDomain; - brush.x = function(z) { - if (!arguments.length) return x; - x = z; - resizes = d3_svg_brushResizes[!x << 1 | !y]; - return brush; - }; - brush.y = function(z) { - if (!arguments.length) return y; - y = z; - resizes = d3_svg_brushResizes[!x << 1 | !y]; - return brush; - }; - brush.extent = function(z) { - var x0, x1, y0, y1, t; - 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 ]; - } - 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 = {}; - d3.behavior.drag = function() { - function drag() { - this.on("mousedown.drag", mousedown).on("touchstart.drag", mousedown); - } - function mousedown() { - function point() { - var p = target.parentNode; - return touchId ? d3.touches(p).filter(function(p) { - return p.identifier === touchId; - })[0] : d3.mouse(p); - } - function dragmove() { - if (!target.parentNode) return dragend(); - 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) { - d3_eventCancel(); - if (d3.event.target === eventTarget) w.on("click.drag", click, true); - } - w.on(touchId ? "touchmove.drag-" + touchId : "mousemove.drag", null).on(touchId ? "touchend.drag-" + touchId : "mouseup.drag", null); - } - function click() { - d3_eventCancel(); - w.on("click.drag", null); - } - var target = this, event_ = event.of(target, arguments), eventTarget = d3.event.target, touchId = d3.event.touches && d3.event.changedTouches[0].identifier, offset, origin_ = point(), moved = 0; - var w = d3.select(window).on(touchId ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true); - if (origin) { - offset = origin.apply(target, arguments); - offset = [ offset.x - origin_[0], offset.y - origin_[1] ]; - } else { - offset = [ 0, 0 ]; - } - if (!touchId) d3_eventCancel(); - event_({ - type: "dragstart" - }); - } - var event = d3_eventDispatch(drag, "drag", "dragstart", "dragend"), origin = null; - drag.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - return drag; - }; - return d3.rebind(drag, event, "on"); - }; - d3.behavior.zoom = function() { - 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); - } - 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() { - 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, true); - } - function click() { - d3_eventCancel(); - w.on("click.zoom", null); - } - 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 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) { - if (now - touchtime < 500) { - 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); - touchtime = null; - dispatch(event.of(this, arguments)); - } - var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime; - 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; - }; - return d3.rebind(zoom, event, "on"); - }; - var d3_behavior_zoomDiv, d3_behavior_zoomInfinity = [ 0, Infinity ]; - d3.layout = {}; - 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; - }; - }; - d3.layout.chord = function() { - function relayout() { - var subgroups = {}, groupSums = [], groupIndex = d3.range(n), subgroupIndex = [], k, x, x0, i, j; - chords = []; - groups = []; - 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; - } - if (sortGroups) { - groupIndex.sort(function(a, b) { - return sortGroups(groupSums[a], groupSums[b]); - }); - } - if (sortSubgroups) { - subgroupIndex.forEach(function(d, i) { - d.sort(function(a, b) { - return sortSubgroups(matrix[i][a], matrix[i][b]); - }); - }); - } - k = (2 * Math.PI - padding * n) / k; - 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[di] = { - index: di, - startAngle: x0, - endAngle: x, - value: (x - x0) / k - }; - x += padding; - } - 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); - }); - } - var chord = {}, chords, groups, matrix, n, padding = 0, sortGroups, sortSubgroups, sortChords; - 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; - }; - d3.layout.force = function() { - 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); - 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; - }; - } - function dragmove(d) { - d.px = d3.event.x; - d.py = d3.event.y; - force.resume(); - } - 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; - force.tick = function() { - if ((alpha *= .99) < .005) { - event.end({ - type: "end", - alpha: alpha = 0 - }); - return true; - } - var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; - 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; - } - } - 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; - } - } - 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)); - } - } - } - 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; - }; - 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 (x > 0) alpha = x; else alpha = 0; - } else if (x > 0) { - event.start({ - type: "start", - alpha: alpha = x - }); - d3.timer(force.tick); - } - return force; - }; - force.start = function() { - 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; - } - 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]; - } - 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; - } - } - return force.resume(); - }; - force.resume = function() { - return force.alpha(.1); - }; - force.stop = function() { - return force.alpha(0); - }; - force.drag = function() { - if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart", d3_layout_forceDragstart).on("drag", dragmove).on("dragend", d3_layout_forceDragend); - this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); - }; - return d3.rebind(force, event, "on"); - }; - d3.layout.partition = function() { - 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; - } - var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; - partition.size = function(x) { - if (!arguments.length) return size; - size = x; - return partition; - }; - return d3_layout_hierarchyRebind(partition, hierarchy); - }; - d3.layout.pie = function() { - function pie(data, i) { - var values = data.map(function(d, i) { - return +value.call(pie, d, i); - }); - var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle); - var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - startAngle) / d3.sum(values); - 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]); - }); - var arcs = []; - index.forEach(function(i) { - var d; - arcs[i] = { - data: data[i], - value: d = values[i], - startAngle: a, - endAngle: a += d * k - }; - }); - return arcs; - } - var value = Number, sort = d3_layout_pieSortByValue, startAngle = 0, endAngle = 2 * Math.PI; - pie.value = function(x) { - if (!arguments.length) return value; - value = x; - return pie; - }; - pie.sort = function(x) { - if (!arguments.length) return sort; - sort = x; - return pie; - }; - pie.startAngle = function(x) { - if (!arguments.length) return startAngle; - startAngle = x; - return pie; - }; - pie.endAngle = function(x) { - if (!arguments.length) return endAngle; - endAngle = x; - return pie; - }; - return pie; - }; - var d3_layout_pieSortByValue = {}; - d3.layout.stack = function() { - function stack(data, index) { - var series = data.map(function(d, i) { - return values.call(stack, d, i); - }); - var points = series.map(function(d, i) { - return d.map(function(v, i) { - return [ x.call(stack, v, i), y.call(stack, v, i) ]; - }); - }); - var orders = order.call(stack, points, index); - series = d3.permute(series, orders); - points = d3.permute(points, orders); - var offsets = offset.call(stack, points, index); - 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; - } - var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; - 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; - }; - 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 - }); - d3.layout.histogram = function() { - 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; - while (++i < m) { - bin = bins[i] = []; - bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); - bin.y = 0; - } - if (m > 0) { - 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; - } - var frequency = true, valuer = Number, ranger = d3_layout_histogramRange, binner = d3_layout_histogramBinSturges; - histogram.value = function(x) { - if (!arguments.length) return valuer; - valuer = x; - return histogram; - }; - histogram.range = function(x) { - if (!arguments.length) return ranger; - ranger = d3_functor(x); - return histogram; - }; - 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; - }; - histogram.frequency = function(x) { - if (!arguments.length) return frequency; - frequency = !!x; - return histogram; - }; - return histogram; - }; - d3.layout.hierarchy = function() { - 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, d; - 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; - } - 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; - } - var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; - 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; - }; - hierarchy.revalue = function(root) { - revalue(root, 0); - return root; - }; - return hierarchy; - }; - var d3_layout_hierarchyInline = false; - d3.layout.pack = function() { - function pack(d, i) { - var nodes = hierarchy.call(this, d, i), root = nodes[0]; - root.x = 0; - root.y = 0; - d3_layout_treeVisitAfter(root, function(d) { - d.r = Math.sqrt(d.value); - }); - d3_layout_treeVisitAfter(root, d3_layout_packSiblings); - var w = size[0], h = size[1], k = Math.max(2 * root.r / w, 2 * root.r / h); - if (padding > 0) { - var dr = padding * k / 2; - d3_layout_treeVisitAfter(root, function(d) { - d.r += dr; - }); - d3_layout_treeVisitAfter(root, d3_layout_packSiblings); - d3_layout_treeVisitAfter(root, function(d) { - d.r -= dr; - }); - k = Math.max(2 * root.r / w, 2 * root.r / h); - } - d3_layout_packTransform(root, w / 2, h / 2, 1 / k); - return nodes; - } - var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ]; - pack.size = function(x) { - if (!arguments.length) return size; - size = x; - return pack; - }; - pack.padding = function(_) { - if (!arguments.length) return padding; - padding = +_; - return pack; - }; - return d3_layout_hierarchyRebind(pack, hierarchy); - }; - d3.layout.cluster = function() { - function cluster(d, i) { - var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0, kx, ky; - 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; - } - }); - 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; - 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; - } - var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ]; - 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); - }; - d3.layout.tree = function() { - function tree(d, i) { - 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; - } - var nodes = hierarchy.call(this, d, i), root = nodes[0]; - 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 - }; - }); - firstWalk(root); - secondWalk(root, -root._tree.prelim); - 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; - 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; - } - var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ]; - 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); - }; - d3.layout.treemap = function() { - 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; - } - } - function squarify(node) { - var children = node.children; - if (children && children.length) { - var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = Math.min(rect.dx, rect.dy), 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) { - remaining.pop(); - best = score; - } else { - 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); - } - } - function stickify(node) { - var children = node.children; - if (children && children.length) { - var rect = pad(node), remaining = children.slice(), 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); - } - } - 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; - } - 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) { - if (flush || v > rect.dy) v = rect.dy; - 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; - rect.y += v; - rect.dy -= v; - } else { - if (flush || v > rect.dx) v = rect.dx; - 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; - 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; - } - var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, ratio = .5 * (1 + Math.sqrt(5)); - treemap.size = function(x) { - if (!arguments.length) return size; - size = x; - return treemap; - }; - treemap.padding = function(x) { - 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); - } - if (!arguments.length) return padding; - 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); - }; - d3.csv = d3_dsv(",", "text/csv"); - d3.tsv = d3_dsv(" ", "text/tab-separated-values"); - d3.geo = {}; - var d3_geo_radians = Math.PI / 180; - d3.geo.azimuthal = function() { - 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] ]; - } - var mode = "orthographic", origin, scale = 200, translate = [ 480, 250 ], x0, y0, cy0, sy0; - 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 ]); - }; - d3.geo.albers = function() { - 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] ]; - } - 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; - } - var origin = [ -98, 38 ], parallels = [ 29.5, 45.5 ], scale = 1e3, translate = [ 480, 250 ], lng0, n, C, p0; - 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 ]; - }; - 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(); - }; - d3.geo.albersUsa = function() { - function albersUsa(coordinates) { - var lon = coordinates[0], lat = coordinates[1]; - return (lat > 50 ? alaska : lon < -140 ? hawaii : lat < 21 ? puertoRico : lower48)(coordinates); - } - 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 ]); - 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() / 1e3, 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() { - 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] ]; - } - var scale = 200, translate = [ 480, 250 ], x0, y0, y1, c1; - 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 ]; - }; - 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() { - function equirectangular(coordinates) { - var x = coordinates[0] / 360, y = -coordinates[1] / 360; - return [ scale * x + translate[0], scale * y + translate[1] ]; - } - var scale = 500, translate = [ 480, 250 ]; - 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() { - 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] ]; - } - var scale = 500, translate = [ 480, 250 ]; - 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; - }; - d3.geo.path = function() { - function path(d, i) { - if (typeof pointRadius === "function") pointCircle = d3_path_circle(pointRadius.apply(this, arguments)); - pathType(d); - var result = buffer.length ? buffer.join("") : null; - buffer = []; - return result; - } - function project(coordinates) { - return projection(coordinates).join(","); - } - function polygonArea(coordinates) { - var sum = area(coordinates[0]), i = 0, n = coordinates.length; - while (++i < n) sum -= area(coordinates[i]); - return sum; - } - function polygonCentroid(coordinates) { - var polygon = d3.geom.polygon(coordinates[0].map(projection)), area = polygon.area(), centroid = polygon.centroid(area < 0 ? (area *= -1, 1) : -1), x = centroid[0], y = centroid[1], z = area, i = 0, n = coordinates.length; - while (++i < n) { - polygon = d3.geom.polygon(coordinates[i].map(projection)); - 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 ]; - } - function area(coordinates) { - return Math.abs(d3.geom.polygon(coordinates.map(projection)).area()); - } - var pointRadius = 4.5, pointCircle = d3_path_circle(pointRadius), projection = d3.geo.albersUsa(), buffer = []; - var pathType = d3_geo_type({ - FeatureCollection: function(o) { - var features = o.features, i = -1, n = features.length; - while (++i < n) buffer.push(pathType(features[i].geometry)); - }, - Feature: function(o) { - pathType(o.geometry); - }, - Point: function(o) { - buffer.push("M", project(o.coordinates), pointCircle); - }, - MultiPoint: function(o) { - var coordinates = o.coordinates, i = -1, n = coordinates.length; - while (++i < n) buffer.push("M", project(coordinates[i]), pointCircle); - }, - LineString: function(o) { - var coordinates = o.coordinates, i = -1, n = coordinates.length; - buffer.push("M"); - while (++i < n) buffer.push(project(coordinates[i]), "L"); - buffer.pop(); - }, - MultiLineString: function(o) { - var coordinates = o.coordinates, i = -1, n = coordinates.length, subcoordinates, j, m; - while (++i < n) { - subcoordinates = coordinates[i]; - j = -1; - m = subcoordinates.length; - buffer.push("M"); - while (++j < m) buffer.push(project(subcoordinates[j]), "L"); - buffer.pop(); - } - }, - Polygon: function(o) { - var coordinates = o.coordinates, i = -1, n = coordinates.length, subcoordinates, j, m; - while (++i < n) { - subcoordinates = coordinates[i]; - j = -1; - if ((m = subcoordinates.length - 1) > 0) { - buffer.push("M"); - while (++j < m) buffer.push(project(subcoordinates[j]), "L"); - buffer[buffer.length - 1] = "Z"; - } - } - }, - MultiPolygon: function(o) { - var coordinates = o.coordinates, i = -1, n = coordinates.length, subcoordinates, j, m, subsubcoordinates, k, p; - 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) { - buffer.push("M"); - while (++k < p) buffer.push(project(subsubcoordinates[k]), "L"); - buffer[buffer.length - 1] = "Z"; - } - } - } - }, - GeometryCollection: function(o) { - var geometries = o.geometries, i = -1, n = geometries.length; - while (++i < n) buffer.push(pathType(geometries[i])); - } - }); - var areaType = path.area = d3_geo_type({ - FeatureCollection: function(o) { - var area = 0, features = o.features, i = -1, 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, n = coordinates.length; - while (++i < n) sum += polygonArea(coordinates[i]); - return sum; - }, - GeometryCollection: function(o) { - var sum = 0, geometries = o.geometries, i = -1, n = geometries.length; - while (++i < n) sum += areaType(geometries[i]); - return sum; - } - }, 0); - var centroidType = path.centroid = d3_geo_type({ - 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, n = coordinates.length; - while (++i < n) { - centroid = polygonCentroid(coordinates[i]); - x += centroid[0]; - y += centroid[1]; - z += centroid[2]; - } - return [ x / z, y / z ]; - } - }); - 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; - }; - 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 ] ]; - }; - 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 - }; - d3.geo.circle = function() { - function circle() {} - function visible(point) { - return arc.distance(point) < radians; - } - 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; - } - p0 = coordinates[0]; - p1 = clipped[0]; - if (p1 && p2[0] === p0[0] && p2[1] === p0[1] && !(p2[0] === p1[0] && p2[1] === p1[1])) { - clipped.push(p1); - } - return resample(clipped); - } - 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; - } - var origin = [ 0, 0 ], degrees = 90 - .01, radians = degrees * d3_geo_radians, arc = d3.geo.greatArc().source(origin).target(d3_identity); - circle.clip = function(d) { - if (typeof origin === "function") arc.source(origin.apply(this, arguments)); - return clipType(d) || null; - }; - var clipType = d3_geo_type({ - FeatureCollection: function(o) { - var features = o.features.map(clipType).filter(d3_identity); - 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(d3_identity); - return geometries.length && (o = Object.create(o), o.geometries = geometries, o); - } - }); - circle.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - if (typeof origin !== "function") arc.source(origin); - return circle; - }; - circle.angle = function(x) { - if (!arguments.length) return degrees; - radians = (degrees = +x) * d3_geo_radians; - return circle; - }; - return d3.rebind(circle, arc, "precision"); - }; - d3.geo.greatArc = function() { - function greatArc() { - var d = greatArc.distance.apply(this, arguments), t = 0, dt = precision / d, coordinates = [ p0 ]; - while ((t += dt) < 1) coordinates.push(interpolate(t)); - coordinates.push(p1); - return { - type: "LineString", - coordinates: coordinates - }; - } - var source = d3_geo_greatArcSource, p0, target = d3_geo_greatArcTarget, p1, precision = 6 * d3_geo_radians, interpolate = d3_geo_greatArcInterpolator(); - greatArc.distance = function() { - if (typeof source === "function") interpolate.source(p0 = source.apply(this, arguments)); - if (typeof target === "function") interpolate.target(p1 = target.apply(this, arguments)); - return interpolate.distance(); - }; - greatArc.source = function(_) { - if (!arguments.length) return source; - source = _; - if (typeof source !== "function") interpolate.source(p0 = source); - return greatArc; - }; - greatArc.target = function(_) { - if (!arguments.length) return target; - target = _; - if (typeof target !== "function") interpolate.target(p1 = target); - return greatArc; - }; - greatArc.precision = function(_) { - if (!arguments.length) return precision / d3_geo_radians; - precision = _ * d3_geo_radians; - return greatArc; - }; - return greatArc; - }; - d3.geo.greatCircle = d3.geo.circle; - d3.geom = {}; - d3.geom.contour = function(grid, start) { - var s = start || d3_geom_contourStart(grid), c = [], x = s[0], y = s[1], dx = 0, dy = 0, pdx = NaN, pdy = NaN, i = 0; - do { - 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; - 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]; - } - 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; - }; - 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 ]; - 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; - 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; - } - } - 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; - }); - 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) { - 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; - } - } - 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; - for (; j < plen; ++j) { - if (points[j].index === -1) continue; - while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) { - --sp; - } - stack[sp++] = points[j].index; - } - var poly = []; - for (i = 0; i < sp; ++i) { - poly.push(vertices[stack[i]]); - } - return poly; - }; - 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 ]; - }; - 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; - }; - 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); - }); - 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" - }; - d3.geom.delaunay = function(vertices) { - var edges = vertices.map(function() { - return []; - }), triangles = []; - d3_voronoi_tessellate(vertices, function(e) { - edges[e.region.l.index].push(vertices[e.region.r.index]); - }); - 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; - }; - d3.geom.quadtree = function(points, x1, y1, x2, y2) { - function insert(n, p, x1, y1, x2, y2) { - if (isNaN(p.x) || isNaN(p.y)) return; - if (n.leaf) { - var v = n.point; - if (v) { - 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); - } - } - function insertChild(n, p, x1, y1, x2, y2) { - var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = p.x >= sx, bottom = p.y >= sy, i = (bottom << 1) + right; - n.leaf = false; - n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); - if (right) x1 = sx; else x2 = sx; - if (bottom) y1 = sy; else y2 = sy; - insert(n, p, x1, y1, x2, y2); - } - var p, i = -1, n = points.length; - if (n && isNaN(points[0].x)) points = points.map(d3_geom_quadtreePoint); - if (arguments.length < 5) { - if (arguments.length === 3) { - y2 = x2 = y1; - y1 = x1; - } else { - x1 = y1 = Infinity; - x2 = y2 = -Infinity; - 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; - } - var dx = x2 - x1, dy = y2 - y1; - if (dx > dy) y2 = y1 + dx; else x2 = x1 + dy; - } - } - 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); - }; - points.forEach(root.add); - return root; - }; - d3.time = {}; - var d3_time = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; - 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; - var d3_time_formatDateTime = "%a %b %e %H:%M:%S %Y", d3_time_formatDate = "%m/%d/%y", d3_time_formatTime = "%H:%M:%S"; - var d3_time_days = d3_time_daySymbols, d3_time_dayAbbreviations = d3_time_days.map(d3_time_formatAbbreviate), d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], d3_time_monthAbbreviations = d3_time_months.map(d3_time_formatAbbreviate); - d3.time.format = function(template) { - 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(""); - } - var n = template.length; - 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; - 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; - }; - 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_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(d3_time_dayAbbreviations), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevRe = d3_time_formatRe(d3_time_monthAbbreviations), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_monthAbbreviations); - var d3_time_formats = { - a: function(d) { - return d3_time_dayAbbreviations[d.getDay()]; - }, - A: function(d) { - return d3_time_days[d.getDay()]; - }, - b: function(d) { - return d3_time_monthAbbreviations[d.getMonth()]; - }, - B: function(d) { - return d3_time_months[d.getMonth()]; - }, - c: d3.time.format(d3_time_formatDateTime), - 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(d3_time_formatDate), - X: d3.time.format(d3_time_formatTime), - y: function(d) { - return d3_time_zfill2(d.getFullYear() % 100); - }, - Y: function(d) { - return d3_time_zfill4(d.getFullYear() % 1e4); - }, - 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, - L: d3_time_parseMilliseconds, - m: d3_time_parseMonthNumber, - M: d3_time_parseMinutes, - p: d3_time_parseAmPm, - S: d3_time_parseSeconds, - x: d3_time_parseLocaleDate, - X: d3_time_parseLocaleTime, - y: d3_time_parseYear, - Y: d3_time_parseFullYear - }; - var d3_time_numberRe = /^\s*\d+/; - var d3_time_amPmLookup = d3.map({ - am: 0, - pm: 1 - }); - d3.time.format.utc = function(template) { - function format(date) { - try { - d3_time = d3_time_utc; - var utc = new d3_time; - utc._ = date; - return local(utc); - } finally { - d3_time = Date; - } - } - var local = d3.time.format(template); - 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; - d3_time_formatIsoNative.parse = function(string) { - var date = new Date(string); - return isNaN(date) ? null : date; - }; - d3_time_formatIsoNative.toString = d3_time_formatIso.toString; - 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); - }, 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); - }, 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); - }, 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) { - var day = new d3_time(1970, 0); - day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); - return day; - }, 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 - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); - }; - d3_time_daySymbols.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) { - date = d3.time.day(date); - date.setDate(1); - return date; - }, 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) { - date = d3.time.day(date); - date.setMonth(0, 1); - return date; - }, 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; - var d3_time_scaleSteps = [ 1e3, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; - 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); - 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); - }; -})(); \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/lib/d3.v2.min.js b/awx/ui/static/lib/novus-nvd3/lib/d3.v2.min.js deleted file mode 100755 index cc47f1ea0c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/d3.v2.min.js +++ /dev/null @@ -1,4 +0,0 @@ -(function(){function e(e,t){try{for(var n in t)Object.defineProperty(e.prototype,n,{value:t[n],enumerable:!1})}catch(r){e.prototype=t}}function t(e){var t=-1,n=e.length,r=[];while(++t=0?e.substring(t):(t=e.length,""),r=[];while(t>0)r.push(e.substring(t-=3,t+3));return r.reverse().join(",")+n}function b(e,t){var n=Math.pow(10,Math.abs(8-t)*3);return{scale:t>8?function(e){return e/n}:function(e){return e*n},symbol:e}}function w(e){return function(t){return t<=0?0:t>=1?1:e(t)}}function E(e){return function(t){return 1-e(1-t)}}function S(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}}function x(e){return e}function T(e){return function(t){return Math.pow(t,e)}}function N(e){return 1-Math.cos(e*Math.PI/2)}function C(e){return Math.pow(2,10*(e-1))}function k(e){return 1-Math.sqrt(1-e*e)}function L(e,t){var n;return arguments.length<2&&(t=.45),arguments.length<1?(e=1,n=t/4):n=t/(2*Math.PI)*Math.asin(1/e),function(r){return 1+e*Math.pow(2,10*-r)*Math.sin((r-n)*2*Math.PI/t)}}function A(e){return e||(e=1.70158),function(t){return t*t*((e+1)*t-e)}}function O(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}function M(){d3.event.stopPropagation(),d3.event.preventDefault()}function _(){var e=d3.event,t;while(t=e.sourceEvent)e=t;return e}function D(e){var t=new d,n=0,r=arguments.length;while(++n360?e-=360:e<0&&(e+=360),e<60?s+(o-s)*e/60:e<180?o:e<240?s+(o-s)*(240-e)/60:s}function i(e){return Math.round(r(e)*255)}var s,o;return e%=360,e<0&&(e+=360),t=t<0?0:t>1?1:t,n=n<0?0:n>1?1:n,o=n<=.5?n*(1+t):n+t-n*t,s=2*n-o,R(i(e+120),i(e),i(e-120))}function Y(e,t,n){return new Z(e,t,n)}function Z(e,t,n){this.h=e,this.c=t,this.l=n}function et(e,t,n){return tt(n,Math.cos(e*=Math.PI/180)*t,Math.sin(e)*t)}function tt(e,t,n){return new nt(e,t,n)}function nt(e,t,n){this.l=e,this.a=t,this.b=n}function rt(e,t,n){var r=(e+16)/116,i=r+t/500,s=r-n/200;return i=st(i)*ds,r=st(r)*vs,s=st(s)*ms,R(ut(3.2404542*i-1.5371385*r-.4985314*s),ut(-0.969266*i+1.8760108*r+.041556*s),ut(.0556434*i-.2040259*r+1.0572252*s))}function it(e,t,n){return Y(Math.atan2(n,t)/Math.PI*180,Math.sqrt(t*t+n*n),e)}function st(e){return e>.206893034?e*e*e:(e-4/29)/7.787037}function ot(e){return e>.008856?Math.pow(e,1/3):7.787037*e+4/29}function ut(e){return Math.round(255*(e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055))}function at(e){return Ki(e,Ss),e}function ft(e){return function(){return gs(e,this)}}function lt(e){return function(){return ys(e,this)}}function ct(e,t){function n(){this.removeAttribute(e)}function r(){this.removeAttributeNS(e.space,e.local)}function i(){this.setAttribute(e,t)}function s(){this.setAttributeNS(e.space,e.local,t)}function o(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}function u(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}return e=d3.ns.qualify(e),t==null?e.local?r:n:typeof t=="function"?e.local?u:o:e.local?s:i}function ht(e){return new RegExp("(?:^|\\s+)"+d3.requote(e)+"(?:\\s+|$)","g")}function pt(e,t){function n(){var n=-1;while(++n0&&(e=e.substring(0,o)),t?i:r}function Et(e,t){for(var n=0,r=e.length;nt?c():(v.active=t,i.forEach(function(t,n){(n=n.call(e,m,u))&&h.push(n)}),s.start.call(e,m,u),l(r)||d3.timer(l,0,n),1)}function l(n){if(v.active!==t)return c();var r=(n-p)/d,i=o(r),a=h.length;while(a>0)h[--a].call(e,i);if(r>=1)return c(),ks=t,s.end.call(e,m,u),ks=0,1}function c(){return--v.count||delete e.__transition__,1}var h=[],p=e.delay,d=e.duration,v=(e=e.node).__transition__||(e.__transition__={active:0,count:0}),m=e.__data__;++v.count,p<=r?f(r):d3.timer(f,p,n)})},0,n),e}function Tt(e){var t=ks,n=Ds,r=Ms,i=_s;return ks=this.id,Ds=this.ease(),Et(this,function(t,n,r){Ms=t.delay,_s=t.duration,e.call(t=t.node,t.__data__,n,r)}),ks=t,Ds=n,Ms=r,_s=i,this}function Nt(e,t,n){return n!=""&&Ps}function Ct(e,t){return d3.tween(e,F(t))}function kt(){var e,t=Date.now(),n=Hs;while(n)e=t-n.then,e>=n.delay&&(n.flush=n.callback(e)),n=n.next;var r=Lt()-t;r>24?(isFinite(r)&&(clearTimeout(js),js=setTimeout(kt,r)),Bs=0):(Bs=1,Fs(kt))}function Lt(){var e=null,t=Hs,n=Infinity;while(t)t.flush?t=e?e.next=t.next:Hs=t.next:(n=Math.min(n,t.then+t.delay),t=(e=t).next);return n}function At(e,t){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();if(Is<0&&(window.scrollX||window.scrollY)){n=d3.select(document.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=n[0][0].getScreenCTM();Is=!i.f&&!i.e,n.remove()}return Is?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}function Ot(){}function Mt(e){var t=e[0],n=e[e.length-1];return t2?Ut:Rt,a=r?q:I;return o=i(e,t,a,n),u=i(t,e,a,d3.interpolate),s}function s(e){return o(e)}var o,u;return s.invert=function(e){return u(e)},s.domain=function(t){return arguments.length?(e=t.map(Number),i()):e},s.range=function(e){return arguments.length?(t=e,i()):t},s.rangeRound=function(e){return s.range(e).interpolate(d3.interpolateRound)},s.clamp=function(e){return arguments.length?(r=e,i()):r},s.interpolate=function(e){return arguments.length?(n=e,i()):n},s.ticks=function(t){return It(e,t)},s.tickFormat=function(t){return qt(e,t)},s.nice=function(){return Dt(e,jt),i()},s.copy=function(){return Ht(e,t,n,r)},i()}function Bt(e,t){return d3.rebind(e,t,"range","rangeRound","interpolate","clamp")}function jt(e){return e=Math.pow(10,Math.round(Math.log(e)/Math.LN10)-1),e&&{floor:function(t){return Math.floor(t/e)*e},ceil:function(t){return Math.ceil(t/e)*e}}}function Ft(e,t){var n=Mt(e),r=n[1]-n[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),s=t/r*i;return s<=.15?i*=10:s<=.35?i*=5:s<=.75&&(i*=2),n[0]=Math.ceil(n[0]/i)*i,n[1]=Math.floor(n[1]/i)*i+i*.5,n[2]=i,n}function It(e,t){return d3.range.apply(d3,Ft(e,t))}function qt(e,t){return d3.format(",."+Math.max(0,-Math.floor(Math.log(Ft(e,t)[2])/Math.LN10+.01))+"f")}function Rt(e,t,n,r){var i=n(e[0],e[1]),s=r(t[0],t[1]);return function(e){return s(i(e))}}function Ut(e,t,n,r){var i=[],s=[],o=0,u=Math.min(e.length,t.length)-1;e[u]0;f--)i.push(r(s)*f)}else{for(;sa;o--);i=i.slice(s,o)}return i},n.tickFormat=function(e,i){arguments.length<2&&(i=qs);if(arguments.length<1)return i;var s=Math.max(.1,e/n.ticks().length),o=t===Xt?(u=-1e-12,Math.floor):(u=1e-12,Math.ceil),u;return function(e){return e/r(o(t(e)+u))<=s?i(e):""}},n.copy=function(){return zt(e.copy(),t)},Bt(n,e)}function Wt(e){return Math.log(e<0?0:e)/Math.LN10}function Xt(e){return-Math.log(e>0?0:-e)/Math.LN10}function Vt(e,t){function n(t){return e(r(t))}var r=$t(t),i=$t(1/t);return n.invert=function(t){return i(e.invert(t))},n.domain=function(t){return arguments.length?(e.domain(t.map(r)),n):e.domain().map(i)},n.ticks=function(e){return It(n.domain(),e)},n.tickFormat=function(e){return qt(n.domain(),e)},n.nice=function(){return n.domain(Dt(n.domain(),jt))},n.exponent=function(e){if(!arguments.length)return t;var s=n.domain();return r=$t(t=e),i=$t(1/t),n.domain(s)},n.copy=function(){return Vt(e.copy(),t)},Bt(n,e)}function $t(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function Jt(e,t){function n(t){return o[((s.get(t)||s.set(t,e.push(t)))-1)%o.length]}function i(t,n){return d3.range(e.length).map(function(e){return t+n*e})}var s,o,u;return n.domain=function(i){if(!arguments.length)return e;e=[],s=new r;var o=-1,u=i.length,a;while(++o1){u=t[1],s=e[a],a++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(s[0]-u[0])+","+(s[1]-u[1])+","+s[0]+","+s[1];for(var f=2;f9&&(s=n*3/Math.sqrt(s),o[u]=s*r,o[u+1]=s*i));u=-1;while(++u<=a)s=(e[Math.min(a,u+1)][0]-e[Math.max(0,u-1)][0])/(6*(1+o[u]*o[u])),t.push([s||0,o[u]*s||0]);return t}function Nn(e){return e.length<3?un(e):e[0]+dn(e,Tn(e))}function Cn(e){var t,n=-1,r=e.length,i,s;while(++n1){var r=Mt(e.domain()),i,s=-1,o=t.length,u=(t[1]-t[0])/++n,a,f;while(++s0;)(f=+t[s]-a*u)>=r[0]&&i.push(f);for(--s,a=0;++ar&&(n=t,r=i);return n}function ir(e){return e.reduce(sr,0)}function sr(e,t){return e+t[1]}function or(e,t){return ur(e,Math.ceil(Math.log(t.length)/Math.LN2+1))}function ur(e,t){var n=-1,r=+e[0],i=(e[1]-r)/t,s=[];while(++n<=t)s[n]=i*n+r;return s}function ar(e){return[d3.min(e),d3.max(e)]}function fr(e,t){return d3.rebind(e,t,"sort","children","value"),e.links=pr,e.nodes=function(t){return uo=!0,(e.nodes=e)(t)},e}function lr(e){return e.children}function cr(e){return e.value}function hr(e,t){return t.value-e.value}function pr(e){return d3.merge(e.map(function(e){return(e.children||[]).map(function(t){return{source:e,target:t}})}))}function dr(e,t){return e.value-t.value}function vr(e,t){var n=e._pack_next;e._pack_next=t,t._pack_prev=e,t._pack_next=n,n._pack_prev=t}function mr(e,t){e._pack_next=t,t._pack_prev=e}function gr(e,t){var n=t.x-e.x,r=t.y-e.y,i=e.r+t.r;return i*i-n*n-r*r>.001}function yr(e){function t(e){r=Math.min(e.x-e.r,r),i=Math.max(e.x+e.r,i),s=Math.min(e.y-e.r,s),o=Math.max(e.y+e.r,o)}if(!(n=e.children)||!(p=n.length))return;var n,r=Infinity,i=-Infinity,s=Infinity,o=-Infinity,u,a,f,l,c,h,p;n.forEach(br),u=n[0],u.x=-u.r,u.y=0,t(u);if(p>1){a=n[1],a.x=a.r,a.y=0,t(a);if(p>2){f=n[2],Sr(u,a,f),t(f),vr(u,f),u._pack_prev=f,vr(f,a),a=u._pack_next;for(l=3;l0&&(e=r)}return e}function Mr(e,t){return e.x-t.x}function _r(e,t){return t.x-e.x}function Dr(e,t){return e.depth-t.depth}function Pr(e,t){function n(e,r){var i=e.children;if(i&&(a=i.length)){var s,o=null,u=-1,a;while(++u=0)s=r[i]._tree,s.prelim+=t,s.mod+=t,t+=s.shift+(n+=s.change)}function Br(e,t,n){e=e._tree,t=t._tree;var r=n/(t.number-e.number);e.change+=r,t.change-=r,t.shift+=n,t.prelim+=n,t.mod+=n}function jr(e,t,n){return e._tree.ancestor.parent==t.parent?e._tree.ancestor:n}function Fr(e){return{x:e.x,y:e.y,dx:e.dx,dy:e.dy}}function Ir(e,t){var n=e.x+t[3],r=e.y+t[0],i=e.dx-t[1]-t[3],s=e.dy-t[0]-t[2];return i<0&&(n+=i/2,i=0),s<0&&(r+=s/2,s=0),{x:n,y:r,dx:i,dy:s}}function qr(e,t){function n(e,r){d3.text(e,t,function(e){r(e&&n.parse(e))})}function r(t){return t.map(i).join(e)}function i(e){return o.test(e)?'"'+e.replace(/\"/g,'""')+'"':e}var s=new RegExp("\r\n|["+e+"\r\n]","g"),o=new RegExp('["'+e+"\n]"),u=e.charCodeAt(0);return n.parse=function(e){var t;return n.parseRows(e,function(e,n){if(n){var r={},i=-1,s=t.length;while(++i=e.length)return i;if(l)return l=!1,r;var t=s.lastIndex;if(e.charCodeAt(t)===34){var n=t;while(n++0}function ii(e,t,n){return(n[0]-t[0])*(e[1]-t[1])<(n[1]-t[1])*(e[0]-t[0])}function si(e,t,n,r){var i=e[0],s=t[0],o=n[0],u=r[0],a=e[1],f=t[1],l=n[1],c=r[1],h=i-o,p=s-i,d=u-o,v=a-l,m=f-a,g=c-l,y=(d*v-g*h)/(g*p-d*m);return[i+y*p,a+y*m]}function oi(e,t){var n={list:e.map(function(e,t){return{index:t,x:e[0],y:e[1]}}).sort(function(e,t){return e.yt.y?1:e.xt.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(e,t){return{edge:e,side:t,vertex:null,l:null,r:null}},insert:function(e,t){t.l=e,t.r=e.r,e.r.l=t,e.r=t},leftBound:function(e){var t=r.leftEnd;do t=t.r;while(t!=r.rightEnd&&i.rightOf(t,e));return t=t.l,t},del:function(e){e.l.r=e.r,e.r.l=e.l,e.edge=null},right:function(e){return e.r},left:function(e){return e.l},leftRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[e.side]},rightRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[ho[e.side]]}},i={bisect:function(e,t){var n={region:{l:e,r:t},ep:{l:null,r:null}},r=t.x-e.x,i=t.y-e.y,s=r>0?r:-r,o=i>0?i:-i;return n.c=e.x*r+e.y*i+(r*r+i*i)*.5,s>o?(n.a=1,n.b=i/r,n.c/=r):(n.b=1,n.a=r/i,n.c/=i),n},intersect:function(e,t){var n=e.edge,r=t.edge;if(!n||!r||n.region.r==r.region.r)return null;var i=n.a*r.b-n.b*r.a;if(Math.abs(i)<1e-10)return null;var s=(n.c*r.b-r.c*n.b)/i,o=(r.c*n.a-n.c*r.a)/i,u=n.region.r,a=r.region.r,f,l;u.y=l.region.r.x;return c&&f.side==="l"||!c&&f.side==="r"?null:{x:s,y:o}},rightOf:function(e,t){var n=e.edge,r=n.region.r,i=t.x>r.x;if(i&&e.side==="l")return 1;if(!i&&e.side==="r")return 0;if(n.a===1){var s=t.y-r.y,o=t.x-r.x,u=0,a=0;!i&&n.b<0||i&&n.b>=0?a=u=s>=n.b*o:(a=t.x+t.y*n.b>n.c,n.b<0&&(a=!a),a||(u=1));if(!u){var f=r.x-n.region.l.x;a=n.b*(o*o-s*s)h*h+p*p}return e.side==="l"?a:!a},endPoint:function(e,n,r){e.ep[n]=r;if(!e.ep[ho[n]])return;t(e)},distance:function(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}},s={list:[],insert:function(e,t,n){e.vertex=t,e.ystar=t.y+n;for(var r=0,i=s.list,o=i.length;ru.ystar||e.ystar==u.ystar&&t.x>u.vertex.x)continue;break}i.splice(r,0,e)},del:function(e){for(var t=0,n=s.list,r=n.length;td.y&&(v=p,p=d,d=v,b="r"),y=i.bisect(p,d),h=r.createHalfEdge(y,b),r.insert(l,h),i.endPoint(y,ho[b],g),m=i.intersect(l,h),m&&(s.del(l),s.insert(l,m,i.distance(m,p))),m=i.intersect(h,c),m&&s.insert(h,m,i.distance(m,p))}}for(a=r.right(r.leftEnd);a!=r.rightEnd;a=r.right(a))t(a.edge)}function ui(){return{leaf:!0,nodes:[],point:null}}function ai(e,t,n,r,i,s){if(!e(t,n,r,i,s)){var o=(n+i)*.5,u=(r+s)*.5,a=t.nodes;a[0]&&ai(e,a[0],n,r,o,u),a[1]&&ai(e,a[1],o,r,i,u),a[2]&&ai(e,a[2],n,u,o,s),a[3]&&ai(e,a[3],o,u,i,s)}}function fi(e){return{x:e[0],y:e[1]}}function li(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function ci(e){return e.substring(0,3)}function hi(e,t,n,r){var i,s,o=0,u=t.length,a=n.length;while(o=a)return-1;i=t.charCodeAt(o++);if(i==37){s=Ho[t.charAt(o++)];if(!s||(r=s(e,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}function pi(e){return new RegExp("^(?:"+e.map(d3.requote).join("|")+")","i")}function di(e){var t=new r,n=-1,i=e.length;while(++n68?1900:2e3)}function Ni(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.m=r[0]-1,n+=r[0].length):-1}function Ci(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.d=+r[0],n+=r[0].length):-1}function ki(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.H=+r[0],n+=r[0].length):-1}function Li(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.M=+r[0],n+=r[0].length):-1}function Ai(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.S=+r[0],n+=r[0].length):-1}function Oi(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+3));return r?(e.L=+r[0],n+=r[0].length):-1}function Mi(e,t,n){var r=jo.get(t.substring(n,n+=2).toLowerCase());return r==null?-1:(e.p=r,n)}function _i(e){var t=e.getTimezoneOffset(),n=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return n+To(r)+To(i)}function Di(e){return e.toISOString()}function Pi(e,t,n){function r(t){var n=e(t),r=s(n,1);return t-n1)while(ot?1:e>=t?0:NaN},d3.descending=function(e,t){return te?1:t>=e?0:NaN},d3.mean=function(e,t){var n=e.length,r,i=0,s=-1,o=0;if(arguments.length===1)while(++s1&&(e=e.map(t)),e=e.filter(f),e.length?d3.quantile(e.sort(d3.ascending),.5):undefined},d3.min=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++ns&&(i=s)}else{while(++ns&&(i=s)}return i},d3.max=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++ni&&(i=s)}else{while(++ni&&(i=s)}return i},d3.extent=function(e,t){var n=-1,r=e.length,i,s,o;if(arguments.length===1){while(++ns&&(i=s),os&&(i=s),o1);return e+t*n*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(e,t){var n=arguments.length;n<2&&(t=1),n<1&&(e=0);var r=d3.random.normal();return function(){return Math.exp(e+t*r())}},irwinHall:function(e){return function(){for(var t=0,n=0;n>>1;e.call(t,t[s],s)>>1;n0&&(i=s);return i},d3.last=function(e,t){var n=0,r=e.length,i=e[0],s;arguments.length===1&&(t=d3.ascending);while(++n=i.length)return u?u.call(n,t):o?t.sort(o):t;var a=-1,f=t.length,l=i[s++],c,h,p=new r,d,v={};while(++a=i.length)return e;var r=[],o=s[n++],u;for(u in e)r.push({key:u,values:t(e[u],n)});return o&&r.sort(function(e,t){return o(e.key,t.key)}),r}var n={},i=[],s=[],o,u;return n.map=function(t){return e(t,0)},n.entries=function(n){return t(e(n,0),0)},n.key=function(e){return i.push(e),n},n.sortKeys=function(e){return s[i.length-1]=e,n},n.sortValues=function(e){return o=e,n},n.rollup=function(e){return u=e,n},n},d3.keys=function(e){var t=[];for(var n in e)t.push(n);return t},d3.values=function(e){var t=[];for(var n in e)t.push(e[n]);return t},d3.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},d3.permute=function(e,t){var n=[],r=-1,i=t.length;while(++rt)r.push(o/i);else while((o=e+n*++s)=200&&e<300||e===304?r:null)}},r.send(null)},d3.text=function(e,t,n){function r(e){n(e&&e.responseText)}arguments.length<3&&(n=t,t=null),d3.xhr(e,t,r)},d3.json=function(e,t){d3.text(e,"application/json",function(e){t(e?JSON.parse(e):null)})},d3.html=function(e,t){d3.text(e,"text/html",function(e){if(e!=null){var n=document.createRange();n.selectNode(document.body),e=n.createContextualFragment(e)}t(e)})},d3.xml=function(e,t,n){function r(e){n(e&&e.responseXML)}arguments.length<3&&(n=t,t=null),d3.xhr(e,t,r)};var es={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:es,qualify:function(e){var t=e.indexOf(":"),n=e;return t>=0&&(n=e.substring(0,t),e=e.substring(t+1)),es.hasOwnProperty(n)?{space:es[n],local:e}:e}},d3.dispatch=function(){var e=new d,t=-1,n=arguments.length;while(++t0&&(r=e.substring(n+1),e=e.substring(0,n)),arguments.length<2?this[e].on(r):this[e].on(r,t)},d3.format=function(e){var t=ts.exec(e),n=t[1]||" ",r=t[3]||"",i=t[5],s=+t[6],o=t[7],u=t[8],a=t[9],f=1,l="",c=!1;u&&(u=+u.substring(1)),i&&(n="0",o&&(s-=Math.floor((s-1)/4)));switch(a){case"n":o=!0,a="g";break;case"%":f=100,l="%",a="f";break;case"p":f=100,l="%",a="r";break;case"d":c=!0,u=0;break;case"s":f=-1,a="r"}return a=="r"&&!u&&(a="g"),a=ns.get(a)||g,function(e){if(c&&e%1)return"";var t=e<0&&(e=-e)?"-":r;if(f<0){var h=d3.formatPrefix(e,u);e=h.scale(e),l=h.symbol}else e*=f;e=a(e,u);if(i){var p=e.length+t.length;p=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,ns=d3.map({g:function(e,t){return e.toPrecision(t)},e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},r:function(e,t){return d3.round(e,t=m(e,t)).toFixed(Math.max(0,Math.min(20,t)))}}),rs=["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(b);d3.formatPrefix=function(e,t){var n=0;return e&&(e<0&&(e*=-1),t&&(e=d3.round(e,m(e,t))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,Math.floor((n<=0?n+1:n-1)/3)*3))),rs[8+n/3]};var is=T(2),ss=T(3),os=function(){return x},us=d3.map({linear:os,poly:T,quad:function(){return is},cubic:function(){return ss},sin:function(){return N},exp:function(){return C},circle:function(){return k},elastic:L,back:A,bounce:function(){return O}}),as=d3.map({"in":x,out:E,"in-out":S,"out-in":function(e){return S(E(e))}});d3.ease=function(e){var t=e.indexOf("-"),n=t>=0?e.substring(0,t):e,r=t>=0?e.substring(t+1):"in";return n=us.get(n)||os,r=as.get(r)||x,w(r(n.apply(null,Array.prototype.slice.call(arguments,1))))},d3.event=null,d3.transform=function(e){var t=document.createElementNS(d3.ns.prefix.svg,"g");return(d3.transform=function(e){t.setAttribute("transform",e);var n=t.transform.baseVal.consolidate();return new P(n?n.matrix:ls)})(e)},P.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var fs=180/Math.PI,ls={a:1,b:0,c:0,d:1,e:0,f:0};d3.interpolate=function(e,t){var n=d3.interpolators.length,r;while(--n>=0&&!(r=d3.interpolators[n](e,t)));return r},d3.interpolateNumber=function(e,t){return t-=e,function(n){return e+t*n}},d3.interpolateRound=function(e,t){return t-=e,function(n){return Math.round(e+t*n)}},d3.interpolateString=function(e,t){var n,r,i,s=0,o=0,u=[],a=[],f,l;cs.lastIndex=0;for(r=0;n=cs.exec(t);++r)n.index&&u.push(t.substring(s,o=n.index)),a.push({i:u.length,x:n[0]}),u.push(null),s=cs.lastIndex;s180?l+=360:l-f>180&&(f+=360),r.push({i:n.push(n.pop()+"rotate(",null,")")-2,x:d3.interpolateNumber(f,l)})):l&&n.push(n.pop()+"rotate("+l+")"),c!=h?r.push({i:n.push(n.pop()+"skewX(",null,")")-2,x:d3.interpolateNumber(c,h)}):h&&n.push(n.pop()+"skewX("+h+")"),p[0]!=d[0]||p[1]!=d[1]?(i=n.push(n.pop()+"scale(",null,",",null,")"),r.push({i:i-4,x:d3.interpolateNumber(p[0],d[0])},{i:i-2,x:d3.interpolateNumber(p[1],d[1])})):(d[0]!=1||d[1]!=1)&&n.push(n.pop()+"scale("+d+")"),i=r.length,function(e){var t=-1,s;while(++t180?s-=360:s<-180&&(s+=360),function(e){return G(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateLab=function(e,t){e=d3.lab(e),t=d3.lab(t);var n=e.l,r=e.a,i=e.b,s=t.l-n,o=t.a-r,u=t.b-i;return function(e){return rt(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateHcl=function(e,t){e=d3.hcl(e),t=d3.hcl(t);var n=e.h,r=e.c,i=e.l,s=t.h-n,o=t.c-r,u=t.l-i;return s>180?s-=360:s<-180&&(s+=360),function(e){return et(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateArray=function(e,t){var n=[],r=[],i=e.length,s=t.length,o=Math.min(e.length,t.length),u;for(u=0;u=0;)if(s=n[r])i&&i!==s.nextSibling&&i.parentNode.insertBefore(s,i),i=s;return this},Ss.sort=function(e){e=bt.apply(this,arguments);for(var t=-1,n=this.length;++t=Vs?e?"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"M0,"+e+"A"+e+","+e+" 0 1,0 0,"+ -e+"A"+e+","+e+" 0 1,0 0,"+e+"Z":"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"Z":e?"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L"+e*h+","+e*p+"A"+e+","+e+" 0 "+f+",0 "+e*l+","+e*c+"Z":"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L0,0"+"Z"}var t=Zt,n=en,r=tn,i=nn;return e.innerRadius=function(n){return arguments.length?(t=u(n),e):t},e.outerRadius=function(t){return arguments.length?(n=u(t),e):n},e.startAngle=function(t){return arguments.length?(r=u(t),e):r},e.endAngle=function(t){return arguments.length?(i=u(t),e):i},e.centroid=function(){var e=(t.apply(this,arguments)+n.apply(this,arguments))/2,s=(r.apply(this,arguments)+i.apply(this,arguments))/2+Xs;return[Math.cos(s)*e,Math.sin(s)*e]},e};var Xs=-Math.PI/2,Vs=2*Math.PI-1e-6;d3.svg.line=function(){return rn(i)};var $s=d3.map({linear:un,"linear-closed":an,"step-before":fn,"step-after":ln,basis:mn,"basis-open":gn,"basis-closed":yn,bundle:bn,cardinal:pn,"cardinal-open":cn,"cardinal-closed":hn,monotone:Nn});$s.forEach(function(e,t){t.key=e,t.closed=/-closed$/.test(e)});var Js=[0,2/3,1/3,0],Ks=[0,1/3,2/3,0],Qs=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var e=rn(Cn);return e.radius=e.x,delete e.x,e.angle=e.y,delete e.y,e},fn.reverse=ln,ln.reverse=fn,d3.svg.area=function(){return kn(i)},d3.svg.area.radial=function(){var e=kn(Cn);return e.radius=e.x,delete e.x,e.innerRadius=e.x0,delete e.x0,e.outerRadius=e.x1,delete e.x1,e.angle=e.y,delete e.y,e.startAngle=e.y0,delete e.y0,e.endAngle=e.y1,delete e.y1,e},d3.svg.chord=function(){function e(e,u){var a=t(this,s,e,u),f=t(this,o,e,u);return"M"+a.p0+r(a.r,a.p1,a.a1-a.a0)+(n(a,f)?i(a.r,a.p1,a.r,a.p0):i(a.r,a.p1,f.r,f.p0)+r(f.r,f.p1,f.a1-f.a0)+i(f.r,f.p1,a.r,a.p0))+"Z"}function t(e,t,n,r){var i=t.call(e,n,r),s=a.call(e,i,r),o=f.call(e,i,r)+Xs,u=l.call(e,i,r)+Xs;return{r:s,a0:o,a1:u,p0:[s*Math.cos(o),s*Math.sin(o)],p1:[s*Math.cos(u),s*Math.sin(u)]}}function n(e,t){return e.a0==t.a0&&e.a1==t.a1}function r(e,t,n){return"A"+e+","+e+" 0 "+ +(n>Math.PI)+",1 "+t}function i(e,t,n,r){return"Q 0,0 "+r}var s=Ln,o=An,a=On,f=tn,l=nn;return e.radius=function(t){return arguments.length?(a=u(t),e):a},e.source=function(t){return arguments.length?(s=u(t),e):s},e.target=function(t){return arguments.length?(o=u(t),e):o},e.startAngle=function(t){return arguments.length?(f=u(t),e):f},e.endAngle=function(t){return arguments.length?(l=u(t),e):l},e},d3.svg.diagonal=function(){function e(e,i){var s=t.call(this,e,i),o=n.call(this,e,i),u=(s.y+o.y)/2,a=[s,{x:s.x,y:u},{x:o.x,y:u},o];return a=a.map(r),"M"+a[0]+"C"+a[1]+" "+a[2]+" "+a[3]}var t=Ln,n=An,r=Dn;return e.source=function(n){return arguments.length?(t=u(n),e):t},e.target=function(t){return arguments.length?(n=u(t),e):n},e.projection=function(t){return arguments.length?(r=t,e):r},e},d3.svg.diagonal.radial=function(){var e=d3.svg.diagonal(),t=Dn,n=e.projection;return e.projection=function(e){return arguments.length?n(Pn(t=e)):t},e},d3.svg.mouse=d3.mouse,d3.svg.touches=d3.touches,d3.svg.symbol=function(){function e(e,r){return(Gs.get(t.call(this,e,r))||jn)(n.call(this,e,r))}var t=Bn,n=Hn;return e.type=function(n){return arguments.length?(t=u(n),e):t},e.size=function(t){return arguments.length?(n=u(t),e):n},e};var Gs=d3.map({circle:jn,cross:function(e){var t=Math.sqrt(e/5)/2;return"M"+ -3*t+","+ -t+"H"+ -t+"V"+ -3*t+"H"+t+"V"+ -t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+ -t+"V"+t+"H"+ -3*t+"Z"},diamond:function(e){var t=Math.sqrt(e/(2*Zs)),n=t*Zs;return"M0,"+ -t+"L"+n+",0"+" 0,"+t+" "+ -n+",0"+"Z"},square:function(e){var t=Math.sqrt(e)/2;return"M"+ -t+","+ -t+"L"+t+","+ -t+" "+t+","+t+" "+ -t+","+t+"Z"},"triangle-down":function(e){var t=Math.sqrt(e/Ys),n=t*Ys/2;return"M0,"+n+"L"+t+","+ -n+" "+ -t+","+ -n+"Z"},"triangle-up":function(e){var t=Math.sqrt(e/Ys),n=t*Ys/2;return"M0,"+ -n+"L"+t+","+n+" "+ -t+","+n+"Z"}});d3.svg.symbolTypes=Gs.keys();var Ys=Math.sqrt(3),Zs=Math.tan(30*Math.PI/180);d3.svg.axis=function(){function e(e){e.each(function(){var e=d3.select(this),c=a==null?t.ticks?t.ticks.apply(t,u):t.domain():a,h=f==null?t.tickFormat?t.tickFormat.apply(t,u):String:f,p=qn(t,c,l),d=e.selectAll(".minor").data(p,String),v=d.enter().insert("line","g").attr("class","tick minor").style("opacity",1e-6),m=d3.transition(d.exit()).style("opacity",1e-6).remove(),g=d3.transition(d).style("opacity",1),y=e.selectAll("g").data(c,String),b=y.enter().insert("g","path").style("opacity",1e-6),w=d3.transition(y.exit()).style("opacity",1e-6).remove(),E=d3.transition(y).style("opacity",1),S,x=_t(t),T=e.selectAll(".domain").data([0]),N=T.enter().append("path").attr("class","domain"),C=d3.transition(T),k=t.copy(),L=this.__chart__||k;this.__chart__=k,b.append("line").attr("class","tick"),b.append("text");var A=b.select("line"),O=E.select("line"),M=y.select("text").text(h),_=b.select("text"),D=E.select("text");switch(n){case"bottom":S=Fn,v.attr("y2",i),g.attr("x2",0).attr("y2",i),A.attr("y2",r),_.attr("y",Math.max(r,0)+o),O.attr("x2",0).attr("y2",r),D.attr("x",0).attr("y",Math.max(r,0)+o),M.attr("dy",".71em").attr("text-anchor","middle"),C.attr("d","M"+x[0]+","+s+"V0H"+x[1]+"V"+s);break;case"top":S=Fn,v.attr("y2",-i),g.attr("x2",0).attr("y2",-i),A.attr("y2",-r),_.attr("y",-(Math.max(r,0)+o)),O.attr("x2",0).attr("y2",-r),D.attr("x",0).attr("y",-(Math.max(r,0)+o)),M.attr("dy","0em").attr("text-anchor","middle"),C.attr("d","M"+x[0]+","+ -s+"V0H"+x[1]+"V"+ -s);break;case"left":S=In,v.attr("x2",-i),g.attr("x2",-i).attr("y2",0),A.attr("x2",-r),_.attr("x",-(Math.max(r,0)+o)),O.attr("x2",-r).attr("y2",0),D.attr("x",-(Math.max(r,0)+o)).attr("y",0),M.attr("dy",".32em").attr("text-anchor","end"),C.attr("d","M"+ -s+","+x[0]+"H0V"+x[1]+"H"+ -s);break;case"right":S=In,v.attr("x2",i),g.attr("x2",i).attr("y2",0),A.attr("x2",r),_.attr("x",Math.max(r,0)+o),O.attr("x2",r).attr("y2",0),D.attr("x",Math.max(r,0)+o).attr("y",0),M.attr("dy",".32em").attr("text-anchor","start"),C.attr("d","M"+s+","+x[0]+"H0V"+x[1]+"H"+s)}if(t.ticks)b.call(S,L),E.call(S,k),w.call(S,k),v.call(S,L),g.call(S,k),m.call(S,k);else{var P=k.rangeBand()/2,H=function(e){return k(e)+P};b.call(S,H),E.call(S,H)}})}var t=d3.scale.linear(),n="bottom",r=6,i=6,s=6,o=3,u=[10],a=null,f,l=0;return e.scale=function(n){return arguments.length?(t=n,e):t},e.orient=function(t){return arguments.length?(n=t,e):n},e.ticks=function(){return arguments.length?(u=arguments,e):u},e.tickValues=function(t){return arguments.length?(a=t,e):a},e.tickFormat=function(t){return arguments.length?(f=t,e):f},e.tickSize=function(t,n,o){if(!arguments.length)return r;var u=arguments.length-1;return r=+t,i=u>1?+n:r,s=u>0?+arguments[u]:r,e},e.tickPadding=function(t){return arguments.length?(o=+t,e):o},e.tickSubdivide=function(t){return arguments.length?(l=+t,e):l},e},d3.svg.brush=function(){function e(s){s.each(function(){var s=d3.select(this),f=s.selectAll(".background").data([0]),l=s.selectAll(".extent").data([0]),c=s.selectAll(".resize").data(a,String),h;s.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),f.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),l.enter().append("rect").attr("class","extent").style("cursor","move"),c.enter().append("g").attr("class",function(e){return"resize "+e}).style("cursor",function(e){return eo[e]}).append("rect").attr("x",function(e){return/[ew]$/.test(e)?-3:null}).attr("y",function(e){return/^[ns]/.test(e)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),c.style("display",e.empty()?"none":null),c.exit().remove(),o&&(h=_t(o),f.attr("x",h[0]).attr("width",h[1]-h[0]),n(s)),u&&(h=_t(u),f.attr("y",h[0]).attr("height",h[1]-h[0]),r(s)),t(s)})}function t(e){e.selectAll(".resize").attr("transform",function(e){return"translate("+f[+/e$/.test(e)][0]+","+f[+/^s/.test(e)][1]+")"})}function n(e){e.select(".extent").attr("x",f[0][0]),e.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1][0]-f[0][0])}function r(e){e.select(".extent").attr("y",f[0][1]),e.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1][1]-f[0][1])}function i(){function i(){var e=d3.event.changedTouches;return e?d3.touches(v,e)[0]:d3.mouse(v)}function a(){d3.event.keyCode==32&&(S||(x=null,T[0]-=f[1][0],T[1]-=f[1][1],S=2),M())}function c(){d3.event.keyCode==32&&S==2&&(T[0]+=f[1][0],T[1]+=f[1][1],S=0,M())}function h(){var e=i(),s=!1;N&&(e[0]+=N[0],e[1]+=N[1]),S||(d3.event.altKey?(x||(x=[(f[0][0]+f[1][0])/2,(f[0][1]+f[1][1])/2]),T[0]=f[+(e[0]0?a=e:a=0:e>0&&(r.start({type:"start",alpha:a=e}),d3.timer(n.tick)),n):a},n.start=function(){function e(e,n){var i=t(r),s=-1,o=i.length,u;while(++si&&(i=u),r.push(u)}for(o=0;o0){s=-1;while(++s=a[0]&&d<=a[1]&&(l=o[d3.bisect(f,d,1,h)-1],l.y+=p,l.push(e[s]))}return o}var t=!0,n=Number,r=ar,i=or;return e.value=function(t){return arguments.length?(n=t,e):n},e.range=function(t){return arguments.length?(r=u(t),e):r},e.bins=function(t){return arguments.length?(i=typeof t=="number"?function(e){return ur(e,t)}:u(t),e):i},e.frequency=function(n){return arguments.length?(t=!!n,e):t},e},d3.layout.hierarchy=function(){function e(t,o,u){var a=i.call(n,t,o),f=uo?t:{data:t};f.depth=o,u.push(f);if(a&&(c=a.length)){var l=-1,c,h=f.children=[],p=0,d=o+1,v;while(++l0){var l=n*f/2;Pr(o,function(e){e.r+=l}),Pr(o,yr),Pr(o,function(e){e.r-=l}),f=Math.max(2*o.r/u,2*o.r/a)}return Er(o,u/2,a/2,1/f),s}var t=d3.layout.hierarchy().sort(dr),n=0,r=[1,1];return e.size=function(t){return arguments.length?(r=t,e):r},e.padding=function(t){return arguments.length?(n=+t,e):n},fr(e,t)},d3.layout.cluster=function(){function e(e,i){var s=t.call(this,e,i),o=s[0],u,a=0,f,l;Pr(o,function(e){var t=e.children;t&&t.length?(e.x=Tr(t),e.y=xr(t)):(e.x=u?a+=n(e,u):0,e.y=0,u=e)});var c=Nr(o),h=Cr(o),p=c.x-n(c,h)/2,d=h.x+n(h,c)/2;return Pr(o,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=(1-(o.y?e.y/o.y:1))*r[1]}),s}var t=d3.layout.hierarchy().sort(null).value(null),n=kr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},fr(e,t)},d3.layout.tree=function(){function e(e,i){function s(e,t){var r=e.children,i=e._tree;if(r&&(o=r.length)){var o,a=r[0],f,l=a,c,h=-1;while(++h0&&(Br(jr(o,e,r),e,h),a+=h,f+=h),l+=o._tree.mod,a+=i._tree.mod,c+=u._tree.mod,f+=s._tree.mod;o&&!Ar(s)&&(s._tree.thread=o,s._tree.mod+=l-f),i&&!Lr(u)&&(u._tree.thread=i,u._tree.mod+=a-c,r=e)}return r}var a=t.call(this,e,i),f=a[0];Pr(f,function(e,t){e._tree={ancestor:e,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),s(f),o(f,-f._tree.prelim);var l=Or(f,_r),c=Or(f,Mr),h=Or(f,Dr),p=l.x-n(l,c)/2,d=c.x+n(c,l)/2,v=h.depth||1;return Pr(f,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=e.depth/v*r[1],delete e._tree}),a}var t=d3.layout.hierarchy().sort(null).value(null),n=kr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},fr(e,t)},d3.layout.treemap=function(){function e(e,t){var n=-1,r=e.length,i,s;while(++n0)u.push(f=a[d-1]),u.area+=f.area,(h=r(u,p))<=c?(a.pop(),c=h):(u.area-=u.pop().area,i(u,p,o,!1),p=Math.min(o.dx,o.dy),u.length=u.area=0,c=Infinity);u.length&&(i(u,p,o,!0),u.length=u.area=0),s.forEach(t)}}function n(t){var r=t.children;if(r&&r.length){var s=l(t),o=r.slice(),u,a=[];e(o,s.dx*s.dy/t.value),a.area=0;while(u=o.pop())a.push(u),a.area+=u.area,u.z!=null&&(i(a,u.z?s.dx:s.dy,s,!o.length),a.length=a.area=0);r.forEach(n)}}function r(e,t){var n=e.area,r,i=0,s=Infinity,o=-1,u=e.length;while(++oi&&(i=r)}return n*=n,t*=t,n?Math.max(t*i*p/n,n/(t*s*p)):Infinity}function i(e,t,n,r){var i=-1,s=e.length,o=n.x,a=n.y,f=t?u(e.area/t):0,l;if(t==n.dx){if(r||f>n.dy)f=n.dy;while(++in.dx)f=n.dx;while(++i50?n:s<-140?r:o<21?i:t)(e)}var t=d3.geo.albers(),n=d3.geo.albers().origin([-160,60]).parallels([55,65]),r=d3.geo.albers().origin([-160,20]).parallels([8,18]),i=d3.geo.albers().origin([-60,10]).parallels([8,18]);return e.scale=function(s){return arguments.length?(t.scale(s),n.scale(s*.6),r.scale(s),i.scale(s*1.5),e.translate(t.translate())):t.scale()},e.translate=function(s){if(!arguments.length)return t.translate();var o=t.scale()/1e3,u=s[0],a=s[1];return t.translate(s),n.translate([u-400*o,a+170*o]),r.translate([u-190*o,a+200*o]),i.translate([u+580*o,a+430*o]),e},e.scale(t.scale())},d3.geo.bonne=function(){function e(e){var u=e[0]*ao-r,a=e[1]*ao-i;if(s){var f=o+s-a,l=u*Math.cos(a)/f;u=f*Math.sin(l),a=f*Math.cos(l)-o}else u*=Math.cos(a),a*=-1;return[t*u+n[0],t*a+n[1]]}var t=200,n=[480,250],r,i,s,o;return e.invert=function(e){var i=(e[0]-n[0])/t,u=(e[1]-n[1])/t;if(s){var a=o+u,f=Math.sqrt(i*i+a*a);u=o+s-f,i=r+f*Math.atan2(i,a)/Math.cos(u)}else u*=-1,i/=Math.cos(u);return[i/ao,u/ao]},e.parallel=function(t){return arguments.length?(o=1/Math.tan -(s=t*ao),e):s/ao},e.origin=function(t){return arguments.length?(r=t[0]*ao,i=t[1]*ao,e):[r/ao,i/ao]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e.origin([0,0]).parallel(45)},d3.geo.equirectangular=function(){function e(e){var r=e[0]/360,i=-e[1]/360;return[t*r+n[0],t*i+n[1]]}var t=500,n=[480,250];return e.invert=function(e){var r=(e[0]-n[0])/t,i=(e[1]-n[1])/t;return[360*r,-360*i]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e},d3.geo.mercator=function(){function e(e){var r=e[0]/360,i=-(Math.log(Math.tan(Math.PI/4+e[1]*ao/2))/ao)/360;return[t*r+n[0],t*Math.max(-0.5,Math.min(.5,i))+n[1]]}var t=500,n=[480,250];return e.invert=function(e){var r=(e[0]-n[0])/t,i=(e[1]-n[1])/t;return[360*r,2*Math.atan(Math.exp(-360*i*ao))/ao-90]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e},d3.geo.path=function(){function e(e,t){typeof s=="function"&&(o=Ur(s.apply(this,arguments))),f(e);var n=a.length?a.join(""):null;return a=[],n}function t(e){return u(e).join(",")}function n(e){var t=i(e[0]),n=0,r=e.length;while(++n0){a.push("M");while(++o0){a.push("M");while(++lr&&(r=e),si&&(i=s)}),[[t,n],[r,i]]};var fo={Feature:Wr,FeatureCollection:Xr,GeometryCollection:Vr,LineString:$r,MultiLineString:Jr,MultiPoint:$r,MultiPolygon:Kr,Point:Qr,Polygon:Gr};d3.geo.circle=function(){function e(){}function t(e){return a.distance(e)=l*l+c*c?r[s].index=-1:(r[h].index=-1,d=r[s].angle,h=s,p=o)):(d=r[s].angle,h=s,p=o);i.push(u);for(s=0,o=0;s<2;++o)r[o].index!==-1&&(i.push(r[o].index),s++);v=i.length;for(;o=0?(n=e.ep.r,r=e.ep.l):(n=e.ep.l,r=e.ep.r),e.a===1?(o=n?n.y:-1e6,i=e.c-e.b*o,u=r?r.y:1e6,s=e.c-e.b*u):(i=n?n.x:-1e6,o=e.c-e.a*i,s=r?r.x:1e6,u=e.c-e.a*s);var a=[i,o],f=[s,u];t[e.region.l.index].push(a,f),t[e.region.r.index].push(a,f)}),t.map(function(t,n){var r=e[n][0],i=e[n][1];return t.forEach(function(e){e.angle=Math.atan2(e[0]-r,e[1]-i)}),t.sort(function(e,t){return e.angle-t.angle}).filter(function(e,n){return!n||e.angle-t[n-1].angle>1e-10})})};var ho={l:"r",r:"l"};d3.geom.delaunay=function(e){var t=e.map(function(){return[]}),n=[];return oi(e,function(n){t[n.region.l.index].push(e[n.region.r.index])}),t.forEach(function(t,r){var i=e[r],s=i[0],o=i[1];t.forEach(function(e){e.angle=Math.atan2(e[0]-s,e[1]-o)}),t.sort(function(e,t){return e.angle-t.angle});for(var u=0,a=t.length-1;u=u,l=t.y>=a,c=(l<<1)+f;e.leaf=!1,e=e.nodes[c]||(e.nodes[c]=ui()),f?n=u:i=u,l?r=a:o=a,s(e,t,n,r,i,o)}var u,a=-1,f=e.length;f&&isNaN(e[0].x)&&(e=e.map(fi));if(arguments.length<5)if(arguments.length===3)i=r=n,n=t;else{t=n=Infinity,r=i=-Infinity;while(++ar&&(r=u.x),u.y>i&&(i=u.y);var l=r-t,c=i-n;l>c?i=n+l:r=t+c}var h=ui();return h.add=function(e){s(h,e,t,n,r,i)},h.visit=function(e){ai(e,h,t,n,r,i)},e.forEach(h.add),h},d3.time={};var po=Date,vo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];li.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(){mo.setUTCDate.apply(this._,arguments)},setDay:function(){mo.setUTCDay.apply(this._,arguments)},setFullYear:function(){mo.setUTCFullYear.apply(this._,arguments)},setHours:function(){mo.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){mo.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){mo.setUTCMinutes.apply(this._,arguments)},setMonth:function(){mo.setUTCMonth.apply(this._,arguments)},setSeconds:function(){mo.setUTCSeconds.apply(this._,arguments)},setTime:function(){mo.setTime.apply(this._,arguments)}};var mo=Date.prototype,go="%a %b %e %H:%M:%S %Y",yo="%m/%d/%y",bo="%H:%M:%S",wo=vo,Eo=wo.map(ci),So=["January","February","March","April","May","June","July","August","September","October","November","December"],xo=So.map(ci);d3.time.format=function(e){function t(t){var r=[],i=-1,s=0,o,u;while(++i=12?"PM":"AM"},S:function(e){return To(e.getSeconds())},U:function(e){return To(d3.time.sundayOfYear(e))},w:function(e){return e.getDay()},W:function(e){return To(d3.time.mondayOfYear(e))},x:d3.time.format(yo),X:d3.time.format(bo),y:function(e){return To(e.getFullYear()%100)},Y:function(e){return Co(e.getFullYear()%1e4)},Z:_i,"%":function(e){return"%"}},Ho={a:vi,A:mi,b:gi,B:yi,c:bi,d:Ci,e:Ci,H:ki,I:ki,L:Oi,m:Ni,M:Li,p:Mi,S:Ai,x:wi,X:Ei,y:xi,Y:Si},Bo=/^\s*\d+/,jo=d3.map({am:0,pm:1});d3.time.format.utc=function(e){function t(e){try{po=li;var t=new po;return t._=e,n(t)}finally{po=Date}}var n=d3.time.format(e);return t.parse=function(e){try{po=li;var t=n.parse(e);return t&&t._}finally{po=Date}},t.toString=n.toString,t};var Fo=d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");d3.time.format.iso=Date.prototype.toISOString?Di:Fo,Di.parse=function(e){var t=new Date(e);return isNaN(t)?null:t},Di.toString=Fo.toString,d3.time.second=Pi(function(e){return new po(Math.floor(e/1e3)*1e3)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*1e3)},function(e){return e.getSeconds()}),d3.time.seconds=d3.time.second.range,d3.time.seconds.utc=d3.time.second.utc.range,d3.time.minute=Pi(function(e){return new po(Math.floor(e/6e4)*6e4)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*6e4)},function(e){return e.getMinutes()}),d3.time.minutes=d3.time.minute.range,d3.time.minutes.utc=d3.time.minute.utc.range,d3.time.hour=Pi(function(e){var t=e.getTimezoneOffset()/60;return new po((Math.floor(e/36e5-t)+t)*36e5)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*36e5)},function(e){return e.getHours()}),d3.time.hours=d3.time.hour.range,d3.time.hours.utc=d3.time.hour.utc.range,d3.time.day=Pi(function(e){var t=new po(1970,0);return t.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t},function(e,t){e.setDate(e.getDate()+t)},function(e){return e.getDate()-1}),d3.time.days=d3.time.day.range,d3.time.days.utc=d3.time.day.utc.range,d3.time.dayOfYear=function(e){var t=d3.time.year(e);return Math.floor((e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5)},vo.forEach(function(e,t){e=e.toLowerCase(),t=7-t;var n=d3.time[e]=Pi(function(e){return(e=d3.time.day(e)).setDate(e.getDate()-(e.getDay()+t)%7),e},function(e,t){e.setDate(e.getDate()+Math.floor(t)*7)},function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%7)/7)-(n!==t)});d3.time[e+"s"]=n.range,d3.time[e+"s"].utc=n.utc.range,d3.time[e+"OfYear"]=function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%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=Pi(function(e){return e=d3.time.day(e),e.setDate(1),e},function(e,t){e.setMonth(e.getMonth()+t)},function(e){return e.getMonth()}),d3.time.months=d3.time.month.range,d3.time.months.utc=d3.time.month.utc.range,d3.time.year=Pi(function(e){return e=d3.time.day(e),e.setMonth(0,1),e},function(e,t){e.setFullYear(e.getFullYear()+t)},function(e){return e.getFullYear()}),d3.time.years=d3.time.year.range,d3.time.years.utc=d3.time.year.utc.range;var Io=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],qo=[[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]],Ro=[[d3.time.format("%Y"),function(e){return!0}],[d3.time.format("%B"),function(e){return e.getMonth()}],[d3.time.format("%b %d"),function(e){return e.getDate()!=1}],[d3.time.format("%a %d"),function(e){return e.getDay()&&e.getDate()!=1}],[d3.time.format("%I %p"),function(e){return e.getHours()}],[d3.time.format("%I:%M"),function(e){return e.getMinutes()}],[d3.time.format(":%S"),function(e){return e.getSeconds()}],[d3.time.format(".%L"),function(e){return e.getMilliseconds()}]],Uo=d3.scale.linear(),zo=Ii(Ro);qo.year=function(e,t){return Uo.domain(e.map(Ri)).ticks(t).map(qi)},d3.time.scale=function(){return Bi(d3.scale.linear(),qo,zo)};var Wo=qo.map(function(e){return[e[0].utc,e[1]]}),Xo=[[d3.time.format.utc("%Y"),function(e){return!0}],[d3.time.format.utc("%B"),function(e){return e.getUTCMonth()}],[d3.time.format.utc("%b %d"),function(e){return e.getUTCDate()!=1}],[d3.time.format.utc("%a %d"),function(e){return e.getUTCDay()&&e.getUTCDate()!=1}],[d3.time.format.utc("%I %p"),function(e){return e.getUTCHours()}],[d3.time.format.utc("%I:%M"),function(e){return e.getUTCMinutes()}],[d3.time.format.utc(":%S"),function(e){return e.getUTCSeconds()}],[d3.time.format.utc(".%L"),function(e){return e.getUTCMilliseconds()}]],Vo=Ii(Xo);Wo.year=function(e,t){return Uo.domain(e.map(zi)).ticks(t).map(Ui)},d3.time.scale.utc=function(){return Bi(d3.scale.linear(),Wo,Vo)}})(); \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/lib/d3.v3.js b/awx/ui/static/lib/novus-nvd3/lib/d3.v3.js deleted file mode 100755 index 8dd7ffe741..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/d3.v3.js +++ /dev/null @@ -1,8436 +0,0 @@ -d3 = function() { - var d3 = { - version: "3.1.5" - }; - if (!Date.now) Date.now = function() { - return +new Date(); - }; - var d3_document = document, d3_window = window; - try { - d3_document.createElement("div").style.setProperty("opacity", 0, ""); - } catch (error) { - var d3_style_prototype = d3_window.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.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.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.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; - }; - function d3_number(x) { - return x != null && !isNaN(x); - } - 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.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.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.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.shuffle = function(array) { - var m = array.length, t, i; - while (m) { - i = Math.random() * m-- | 0; - t = array[m], array[m] = array[i], array[i] = t; - } - return array; - }; - d3.permute = function(array, indexes) { - var permutes = [], i = -1, n = indexes.length; - while (++i < n) permutes[i] = array[indexes[i]]; - return permutes; - }; - 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.transpose = function(matrix) { - return d3.zip.apply(d3, matrix); - }; - 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.merge = function(arrays) { - return Array.prototype.concat.apply([], arrays); - }; - 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; - } - 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; - } - } - 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", d3_map_prefixCode = d3_map_prefix.charCodeAt(0); - d3.nest = function() { - var nest = {}, keys = [], sortKeys = [], sortValues, rollup; - function map(mapType, 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, setter, valuesByKey = new d3_Map(), values; - while (++i < n) { - if (values = valuesByKey.get(keyValue = key(object = array[i]))) { - values.push(object); - } else { - valuesByKey.set(keyValue, [ object ]); - } - } - if (mapType) { - object = mapType(); - setter = function(keyValue, values) { - object.set(keyValue, map(mapType, values, depth)); - }; - } else { - object = {}; - setter = function(keyValue, values) { - object[keyValue] = map(mapType, values, depth); - }; - } - valuesByKey.forEach(setter); - return object; - } - function entries(map, depth) { - if (depth >= keys.length) return map; - var array = [], sortKey = sortKeys[depth++]; - map.forEach(function(key, keyMap) { - array.push({ - key: key, - values: entries(keyMap, depth) - }); - }); - return sortKey ? array.sort(function(a, b) { - return sortKey(a.key, b.key); - }) : array; - } - nest.map = function(array, mapType) { - return map(mapType, array, 0); - }; - nest.entries = function(array) { - return entries(map(d3.map, array, 0), 0); - }; - nest.key = function(d) { - keys.push(d); - return nest; - }; - nest.sortKeys = function(order) { - sortKeys[keys.length - 1] = order; - return nest; - }; - nest.sortValues = function(order) { - sortValues = order; - return nest; - }; - nest.rollup = function(f) { - rollup = f; - return nest; - }; - return nest; - }; - d3.set = function(array) { - var set = new d3_Set(); - if (array) for (var i = 0; i < array.length; i++) set.add(array[i]); - return set; - }; - function d3_Set() {} - d3_class(d3_Set, { - has: function(value) { - return d3_map_prefix + value in this; - }, - add: function(value) { - this[d3_map_prefix + value] = true; - return value; - }, - remove: function(value) { - value = d3_map_prefix + value; - return value in this && delete this[value]; - }, - values: function() { - var values = []; - this.forEach(function(value) { - values.push(value); - }); - return values; - }, - forEach: function(f) { - for (var value in this) { - if (value.charCodeAt(0) === d3_map_prefixCode) { - f.call(this, value.substring(1)); - } - } - } - }); - d3.behavior = {}; - 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; - }; - function d3_rebind(target, source, method) { - return function() { - var value = method.apply(source, arguments); - return value === source ? target : value; - }; - } - 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 = ""; - if (i >= 0) { - name = type.substring(i + 1); - type = type.substring(0, i); - } - if (type) return arguments.length < 2 ? this[type].on(name) : this[type].on(name, listener); - if (arguments.length === 2) { - if (listener == null) for (type in this) { - if (this.hasOwnProperty(type)) this[type].on(name, null); - } - return this; - } - }; - function d3_dispatch_event(dispatch) { - var listeners = [], listenerByName = new d3_Map(); - function event() { - var z = listeners, 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; - if (arguments.length < 2) return l && l.on; - if (l) { - l.on = null; - listeners = listeners.slice(0, i = listeners.indexOf(l)).concat(listeners.slice(i + 1)); - listenerByName.remove(name); - } - if (listener) listeners.push(listenerByName.set(name, { - on: listener - })); - return dispatch; - }; - return event; - } - 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; - } - function d3_eventSuppress(target, type) { - function off() { - target.on(type, null); - } - target.on(type, function() { - d3_eventCancel(); - off(); - }, true); - setTimeout(off, 0); - } - function d3_eventDispatch(target) { - var dispatch = new d3_dispatch(), i = 0, n = arguments.length; - while (++i < n) dispatch[arguments[i]] = d3_dispatch_event(dispatch); - 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.mouse = function(container) { - return d3_mousePoint(container, d3_eventSource()); - }; - var d3_mouse_bug44083 = /WebKit/.test(d3_window.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 && (d3_window.scrollX || d3_window.scrollY)) { - svg = d3.select(d3_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 ]; - } - var d3_array = d3_arraySlice; - 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(d3_document.documentElement.childNodes)[0].nodeType; - } catch (e) { - d3_array = d3_arrayCopy; - } - var d3_arraySubclass = [].__proto__ ? function(array, prototype) { - array.__proto__ = prototype; - } : function(array, prototype) { - for (var property in prototype) array[property] = prototype[property]; - }; - 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; - }) : []; - }; - 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, touchId = d3.event.touches ? d3.event.changedTouches[0].identifier : null, offset, origin_ = point(), moved = 0; - var w = d3.select(d3_window).on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", dragmove).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", dragend, true); - if (origin) { - offset = origin.apply(target, arguments); - offset = [ offset.x - origin_[0], offset.y - origin_[1] ]; - } else { - offset = [ 0, 0 ]; - } - if (touchId == null) d3_eventCancel(); - event_({ - type: "dragstart" - }); - function point() { - var p = target.parentNode; - return touchId != null ? d3.touches(p).filter(function(p) { - return p.identifier === touchId; - })[0] : d3.mouse(p); - } - function dragmove() { - if (!target.parentNode) return dragend(); - 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) { - d3_eventCancel(); - if (d3.event.target === eventTarget) d3_eventSuppress(w, "click"); - } - w.on(touchId != null ? "touchmove.drag-" + touchId : "mousemove.drag", null).on(touchId != null ? "touchend.drag-" + touchId : "mouseup.drag", null); - } - } - drag.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - return drag; - }; - return d3.rebind(drag, event, "on"); - }; - 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 = d3_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); - }; - if (typeof Sizzle === "function") { - d3_select = function(s, n) { - return Sizzle(s, n)[0] || null; - }; - 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); - }; - } - 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_selectionPrototype.attr = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") { - var node = this.node(); - name = d3.ns.qualify(name); - return name.local ? node.getAttributeNS(name.space, name.local) : node.getAttribute(name); - } - for (value in name) this.each(d3_selection_attr(value, name[value])); - return this; - } - return this.each(d3_selection_attr(name, value)); - }; - function d3_selection_attr(name, value) { - name = d3.ns.qualify(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 value == null ? name.local ? attrNullNS : attrNull : typeof value === "function" ? name.local ? attrFunctionNS : attrFunction : name.local ? attrConstantNS : attrConstant; - } - function d3_collapse(s) { - return s.trim().replace(/\s+/g, " "); - } - d3.requote = function(s) { - return s.replace(d3_requote_re, "\\$&"); - }; - var d3_requote_re = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g; - d3_selectionPrototype.classed = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") { - var node = this.node(), n = (name = name.trim().split(/^|\s+/g)).length, i = -1; - if (value = node.classList) { - while (++i < n) if (!value.contains(name[i])) return false; - } else { - value = node.getAttribute("class"); - while (++i < n) if (!d3_selection_classedRe(name[i]).test(value)) return false; - } - return true; - } - for (value in name) this.each(d3_selection_classed(value, name[value])); - return this; - } - return this.each(d3_selection_classed(name, value)); - }; - function d3_selection_classedRe(name) { - return new RegExp("(?:^|\\s+)" + d3.requote(name) + "(?:\\s+|$)", "g"); - } - function d3_selection_classed(name, value) { - name = name.trim().split(/\s+/).map(d3_selection_classedName); - var n = name.length; - function classedConstant() { - var i = -1; - while (++i < n) name[i](this, value); - } - function classedFunction() { - var i = -1, x = value.apply(this, arguments); - while (++i < n) name[i](this, x); - } - return typeof value === "function" ? classedFunction : classedConstant; - } - function d3_selection_classedName(name) { - var re = d3_selection_classedRe(name); - return function(node, value) { - if (c = node.classList) return value ? c.add(name) : c.remove(name); - var c = node.getAttribute("class") || ""; - if (value) { - re.lastIndex = 0; - if (!re.test(c)) node.setAttribute("class", d3_collapse(c + " " + name)); - } else { - node.setAttribute("class", d3_collapse(c.replace(re, " "))); - } - }; - } - d3_selectionPrototype.style = function(name, value, priority) { - var n = arguments.length; - if (n < 3) { - if (typeof name !== "string") { - if (n < 2) value = ""; - for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); - return this; - } - if (n < 2) return d3_window.getComputedStyle(this.node(), null).getPropertyValue(name); - priority = ""; - } - return this.each(d3_selection_style(name, value, priority)); - }; - function d3_selection_style(name, value, priority) { - 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 value == null ? styleNull : typeof value === "function" ? styleFunction : styleConstant; - } - d3_selectionPrototype.property = function(name, value) { - if (arguments.length < 2) { - if (typeof name === "string") return this.node()[name]; - for (value in name) this.each(d3_selection_property(value, name[value])); - return this; - } - return this.each(d3_selection_property(name, value)); - }; - function d3_selection_property(name, value) { - 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 value == null ? propertyNull : typeof value === "function" ? propertyFunction : propertyConstant; - } - d3_selectionPrototype.text = function(value) { - return arguments.length ? 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; - }) : this.node().textContent; - }; - d3_selectionPrototype.html = function(value) { - return arguments.length ? 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; - }) : this.node().innerHTML; - }; - d3_selectionPrototype.append = function(name) { - name = d3.ns.qualify(name); - function append() { - return this.appendChild(d3_document.createElementNS(this.namespaceURI, name)); - } - function appendNS() { - return this.appendChild(d3_document.createElementNS(name.space, name.local)); - } - return this.select(name.local ? appendNS : append); - }; - d3_selectionPrototype.insert = function(name, before) { - name = d3.ns.qualify(name); - if (typeof before !== "function") before = d3_selection_selector(before); - function insert(d, i) { - return this.insertBefore(d3_document.createElementNS(this.namespaceURI, name), before.call(this, d, i)); - } - function insertNS(d, i) { - return this.insertBefore(d3_document.createElementNS(name.space, name.local), before.call(this, d, i)); - } - return this.select(name.local ? insertNS : insert); - }; - 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 (!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), updateNodes = new Array(m), enterNodes = new Array(m), exitNodes = new Array(n), node, nodeData; - if (key) { - var nodeByKeyValue = new d3_Map(), dataByKeyValue = new d3_Map(), keyValues = [], keyValue; - for (i = -1; ++i < n; ) { - keyValue = key.call(node = group[i], node.__data__, i); - if (nodeByKeyValue.has(keyValue)) { - exitNodes[i] = node; - } else { - nodeByKeyValue.set(keyValue, node); - } - keyValues.push(keyValue); - } - for (i = -1; ++i < m; ) { - keyValue = key.call(groupData, nodeData = groupData[i], i); - if (node = nodeByKeyValue.get(keyValue)) { - updateNodes[i] = node; - node.__data__ = nodeData; - } else if (!dataByKeyValue.has(keyValue)) { - enterNodes[i] = d3_selection_dataNode(nodeData); - } - dataByKeyValue.set(keyValue, nodeData); - 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; - } else { - enterNodes[i] = d3_selection_dataNode(nodeData); - } - } - for (;i < m; ++i) { - enterNodes[i] = d3_selection_dataNode(groupData[i]); - } - for (;i < n; ++i) { - exitNodes[i] = group[i]; - } - } - 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 = function(value) { - return arguments.length ? this.property("__data__", value) : this.property("__data__"); - }; - 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 !a - !b || comparator(a.__data__, b.__data__); - }; - } - function d3_noop() {} - d3_selectionPrototype.on = function(type, listener, capture) { - var n = arguments.length; - if (n < 3) { - if (typeof type !== "string") { - if (n < 2) listener = false; - for (capture in type) this.each(d3_selection_on(capture, type[capture], listener)); - return this; - } - if (n < 2) return (n = this.node()["__on" + type]) && n._; - capture = false; - } - return this.each(d3_selection_on(type, listener, capture)); - }; - function d3_selection_on(type, listener, capture) { - var name = "__on" + type, i = type.indexOf("."), wrap = d3_selection_onListener; - if (i > 0) type = type.substring(0, i); - var filter = d3_selection_onFilters.get(type); - if (filter) type = filter, wrap = d3_selection_onFilter; - function onRemove() { - var l = this[name]; - if (l) { - this.removeEventListener(type, l, l.$); - delete this[name]; - } - } - function onAdd() { - var l = wrap(listener, d3_array(arguments)); - onRemove.call(this); - this.addEventListener(type, this[name] = l, l.$ = capture); - l._ = listener; - } - function removeAll() { - var re = new RegExp("^__on([^.]+)" + d3.requote(type) + "$"), match; - for (var name in this) { - if (match = name.match(re)) { - var l = this[name]; - this.removeEventListener(match[1], l, l.$); - delete this[name]; - } - } - } - return i ? listener ? onAdd : onRemove : listener ? d3_noop : removeAll; - } - var d3_selection_onFilters = d3.map({ - mouseenter: "mouseover", - mouseleave: "mouseout" - }); - d3_selection_onFilters.forEach(function(k) { - if ("on" + k in d3_document) d3_selection_onFilters.remove(k); - }); - function d3_selection_onListener(listener, argumentz) { - return function(e) { - var o = d3.event; - d3.event = e; - argumentz[0] = this.__data__; - try { - listener.apply(this, argumentz); - } finally { - d3.event = o; - } - }; - } - function d3_selection_onFilter(listener, argumentz) { - var l = d3_selection_onListener(listener, argumentz); - return function(e) { - var target = this, related = e.relatedTarget; - if (!related || related !== target && !(related.compareDocumentPosition(target) & 8)) { - l.call(target, e); - } - }; - } - d3_selectionPrototype.each = function(callback) { - return d3_selection_each(this, function(node, i, j) { - callback.call(node, node.__data__, i, j); - }); - }; - function d3_selection_each(groups, callback) { - for (var j = 0, m = groups.length; j < m; j++) { - for (var group = groups[j], i = 0, n = group.length, node; i < n; i++) { - if (node = group[i]) callback(node, i, j); - } - } - return groups; - } - d3_selectionPrototype.call = function(callback) { - var args = d3_array(arguments); - callback.apply(args[0] = this, args); - return this; - }; - d3_selectionPrototype.empty = function() { - return !this.node(); - }; - d3_selectionPrototype.node = function() { - 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; - }; - 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); - }; - d3_selectionPrototype.transition = function() { - var id = d3_transitionInheritId || ++d3_transitionId, subgroups = [], subgroup, node, transition = Object.create(d3_transitionInherit); - transition.time = Date.now(); - 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]) d3_transitionNode(node, i, id, transition); - subgroup.push(node); - } - } - return d3_transition(subgroups, id); - }; - var d3_selectionRoot = d3_selection([ [ d3_document ] ]); - d3_selectionRoot[0].parentNode = d3_selectRoot; - d3.select = function(selector) { - return typeof selector === "string" ? d3_selectionRoot.select(selector) : d3_selection([ [ selector ] ]); - }; - d3.selectAll = function(selector) { - return typeof selector === "string" ? d3_selectionRoot.selectAll(selector) : d3_selection([ d3_array(selector) ]); - }; - d3.behavior.zoom = function() { - var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime; - function zoom() { - this.on("mousedown.zoom", mousedown).on("mousemove.zoom", mousemove).on(d3_behavior_zoomWheel + ".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); - rescale(); - return zoom; - }; - zoom.scale = function(x) { - if (!arguments.length) return scale; - scale = +x; - rescale(); - 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(); - translate = [ 0, 0 ]; - scale = 1; - return zoom; - }; - zoom.y = function(z) { - if (!arguments.length) return y1; - y1 = z; - y0 = z.copy(); - translate = [ 0, 0 ]; - scale = 1; - 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 rescale() { - 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)); - } - function dispatch(event) { - rescale(); - 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(d3_window).on("mousemove.zoom", mousemove).on("mouseup.zoom", mouseup), l = location(d3.mouse(target)); - d3_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) d3_eventSuppress(w, "click.zoom"); - } - } - 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), k = Math.log(scale) / Math.LN2; - scaleTo(Math.pow(2, d3.event.shiftKey ? Math.ceil(k) - 1 : Math.floor(k) + 1)); - 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) { - if (now - touchtime < 500) { - 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); - touchtime = null; - dispatch(event.of(this, arguments)); - } - return d3.rebind(zoom, event, "on"); - }; - var d3_behavior_zoomInfinity = [ 0, Infinity ]; - var d3_behavior_zoomDelta, d3_behavior_zoomWheel = "onwheel" in d3_document ? (d3_behavior_zoomDelta = function() { - return -d3.event.deltaY * (d3.event.deltaMode ? 120 : 1); - }, "wheel") : "onmousewheel" in d3_document ? (d3_behavior_zoomDelta = function() { - return d3.event.wheelDelta; - }, "mousewheel") : (d3_behavior_zoomDelta = function() { - return -d3.event.detail; - }, "MozMousePixelScroll"); - function d3_Color() {} - d3_Color.prototype.toString = function() { - return this.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; - } - var d3_hslPrototype = d3_Hsl.prototype = new d3_Color(); - d3_hslPrototype.brighter = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - return d3_hsl(this.h, this.s, this.l / k); - }; - d3_hslPrototype.darker = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - return d3_hsl(this.h, this.s, k * this.l); - }; - d3_hslPrototype.rgb = function() { - return d3_hsl_rgb(this.h, this.s, this.l); - }; - function d3_hsl_rgb(h, s, l) { - var m1, m2; - h = h % 360; - if (h < 0) h += 360; - s = s < 0 ? 0 : s > 1 ? 1 : s; - l = l < 0 ? 0 : l > 1 ? 1 : l; - 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)); - } - var π = Math.PI, ε = 1e-6, d3_radians = π / 180, d3_degrees = 180 / π; - function d3_sgn(x) { - return x > 0 ? 1 : x < 0 ? -1 : 0; - } - function d3_acos(x) { - return Math.acos(Math.max(-1, Math.min(1, x))); - } - function d3_asin(x) { - return x > 1 ? π / 2 : x < -1 ? -π / 2 : Math.asin(x); - } - function d3_sinh(x) { - return (Math.exp(x) - Math.exp(-x)) / 2; - } - function d3_cosh(x) { - return (Math.exp(x) + Math.exp(-x)) / 2; - } - function d3_haversin(x) { - return (x = Math.sin(x / 2)) * x; - } - d3.hcl = function(h, c, l) { - return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l); - }; - function d3_hcl(h, c, l) { - return new d3_Hcl(h, c, l); - } - function d3_Hcl(h, c, l) { - this.h = h; - this.c = c; - this.l = l; - } - var d3_hclPrototype = d3_Hcl.prototype = new d3_Color(); - d3_hclPrototype.brighter = function(k) { - return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1))); - }; - d3_hclPrototype.darker = function(k) { - return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1))); - }; - d3_hclPrototype.rgb = function() { - return d3_hcl_lab(this.h, this.c, this.l).rgb(); - }; - function d3_hcl_lab(h, c, l) { - return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c); - } - d3.lab = function(l, a, b) { - return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b); - }; - function d3_lab(l, a, b) { - return new d3_Lab(l, a, b); - } - function d3_Lab(l, a, b) { - this.l = l; - this.a = a; - this.b = b; - } - var d3_lab_K = 18; - var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883; - var d3_labPrototype = d3_Lab.prototype = new d3_Color(); - d3_labPrototype.brighter = function(k) { - return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); - }; - d3_labPrototype.darker = function(k) { - return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b); - }; - d3_labPrototype.rgb = function() { - return d3_lab_rgb(this.l, this.a, this.b); - }; - function d3_lab_rgb(l, a, b) { - var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200; - x = d3_lab_xyz(x) * d3_lab_X; - y = d3_lab_xyz(y) * d3_lab_Y; - z = d3_lab_xyz(z) * d3_lab_Z; - return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z)); - } - function d3_lab_hcl(l, a, b) { - return d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l); - } - function d3_lab_xyz(x) { - return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037; - } - function d3_xyz_lab(x) { - return x > .008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29; - } - function d3_xyz_rgb(r) { - return Math.round(255 * (r <= .00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - .055)); - } - 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; - } - var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color(); - d3_rgbPrototype.brighter = function(k) { - k = Math.pow(.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_rgbPrototype.darker = function(k) { - k = Math.pow(.7, arguments.length ? k : 1); - return d3_rgb(Math.floor(k * this.r), Math.floor(k * this.g), Math.floor(k * this.b)); - }; - d3_rgbPrototype.hsl = function() { - return d3_rgb_hsl(this.r, this.g, this.b); - }; - d3_rgbPrototype.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 < 16 ? "0" + Math.max(0, v).toString(16) : Math.min(255, v).toString(16); - } - function d3_rgb_parse(format, rgb, hsl) { - var r = 0, g = 0, b = 0, m1, m2, name; - m1 = /([a-z]+)\((.*)\)/i.exec(format); - if (m1) { - m2 = m1[2].split(","); - switch (m1[1]) { - case "hsl": - { - return hsl(parseFloat(m2[0]), parseFloat(m2[1]) / 100, parseFloat(m2[2]) / 100); - } - - case "rgb": - { - return rgb(d3_rgb_parseNumber(m2[0]), d3_rgb_parseNumber(m2[1]), d3_rgb_parseNumber(m2[2])); - } - } - } - if (name = d3_rgb_names.get(format)) return rgb(name.r, name.g, name.b); - 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_lab(r, g, b) { - r = d3_rgb_xyz(r); - g = d3_rgb_xyz(g); - b = d3_rgb_xyz(b); - var x = d3_xyz_lab((.4124564 * r + .3575761 * g + .1804375 * b) / d3_lab_X), y = d3_xyz_lab((.2126729 * r + .7151522 * g + .072175 * b) / d3_lab_Y), z = d3_xyz_lab((.0193339 * r + .119192 * g + .9503041 * b) / d3_lab_Z); - return d3_lab(116 * y - 16, 500 * (x - y), 200 * (y - z)); - } - function d3_rgb_xyz(r) { - return (r /= 255) <= .04045 ? r / 12.92 : Math.pow((r + .055) / 1.055, 2.4); - } - function d3_rgb_parseNumber(c) { - 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)); - }); - function d3_functor(v) { - return typeof v === "function" ? v : function() { - return v; - }; - } - d3.functor = d3_functor; - function d3_identity(d) { - return d; - } - d3.xhr = function(url, mimeType, callback) { - var xhr = {}, dispatch = d3.dispatch("progress", "load", "error"), headers = {}, response = d3_identity, request = new (d3_window.XDomainRequest && /^(http(s)?:)?\/\//.test(url) ? XDomainRequest : XMLHttpRequest)(); - "onload" in request ? request.onload = request.onerror = respond : request.onreadystatechange = function() { - request.readyState > 3 && respond(); - }; - function respond() { - var s = request.status; - !s && request.responseText || s >= 200 && s < 300 || s === 304 ? dispatch.load.call(xhr, response.call(xhr, request)) : dispatch.error.call(xhr, request); - } - request.onprogress = function(event) { - var o = d3.event; - d3.event = event; - try { - dispatch.progress.call(xhr, request); - } finally { - d3.event = o; - } - }; - xhr.header = function(name, value) { - name = (name + "").toLowerCase(); - if (arguments.length < 2) return headers[name]; - if (value == null) delete headers[name]; else headers[name] = value + ""; - return xhr; - }; - xhr.mimeType = function(value) { - if (!arguments.length) return mimeType; - mimeType = value == null ? null : value + ""; - return xhr; - }; - xhr.response = function(value) { - response = value; - return xhr; - }; - [ "get", "post" ].forEach(function(method) { - xhr[method] = function() { - return xhr.send.apply(xhr, [ method ].concat(d3_array(arguments))); - }; - }); - xhr.send = function(method, data, callback) { - if (arguments.length === 2 && typeof data === "function") callback = data, data = null; - request.open(method, url, true); - if (mimeType != null && !("accept" in headers)) headers["accept"] = mimeType + ",*/*"; - if (request.setRequestHeader) for (var name in headers) request.setRequestHeader(name, headers[name]); - if (mimeType != null && request.overrideMimeType) request.overrideMimeType(mimeType); - if (callback != null) xhr.on("error", callback).on("load", function(request) { - callback(null, request); - }); - request.send(data == null ? null : data); - return xhr; - }; - xhr.abort = function() { - request.abort(); - return xhr; - }; - d3.rebind(xhr, dispatch, "on"); - if (arguments.length === 2 && typeof mimeType === "function") callback = mimeType, - mimeType = null; - return callback == null ? xhr : xhr.get(d3_xhr_fixCallback(callback)); - }; - function d3_xhr_fixCallback(callback) { - return callback.length === 1 ? function(error, request) { - callback(error == null ? request : null); - } : callback; - } - function d3_dsv(delimiter, mimeType) { - var reFormat = new RegExp('["' + delimiter + "\n]"), delimiterCode = delimiter.charCodeAt(0); - function dsv(url, row, callback) { - if (arguments.length < 3) callback = row, row = null; - var xhr = d3.xhr(url, mimeType, callback); - xhr.row = function(_) { - return arguments.length ? xhr.response((row = _) == null ? response : typedResponse(_)) : row; - }; - return xhr.row(row); - } - function response(request) { - return dsv.parse(request.responseText); - } - function typedResponse(f) { - return function(request) { - return dsv.parse(request.responseText, f); - }; - } - dsv.parse = function(text, f) { - var o; - return dsv.parseRows(text, function(row, i) { - if (o) return o(row, i - 1); - var a = new Function("d", "return {" + row.map(function(name, i) { - return JSON.stringify(name) + ": d[" + i + "]"; - }).join(",") + "}"); - o = f ? function(row, i) { - return f(a(row), i); - } : a; - }); - }; - dsv.parseRows = function(text, f) { - var EOL = {}, EOF = {}, rows = [], N = text.length, I = 0, n = 0, t, eol; - function token() { - if (I >= N) return EOF; - if (eol) return eol = false, EOL; - var j = I; - if (text.charCodeAt(j) === 34) { - var i = j; - while (i++ < N) { - if (text.charCodeAt(i) === 34) { - if (text.charCodeAt(i + 1) !== 34) break; - ++i; - } - } - I = i + 2; - var c = text.charCodeAt(i + 1); - if (c === 13) { - eol = true; - if (text.charCodeAt(i + 2) === 10) ++I; - } else if (c === 10) { - eol = true; - } - return text.substring(j + 1, i).replace(/""/g, '"'); - } - while (I < N) { - var c = text.charCodeAt(I++), k = 1; - if (c === 10) eol = true; else if (c === 13) { - eol = true; - if (text.charCodeAt(I) === 10) ++I, ++k; - } else if (c !== delimiterCode) continue; - return text.substring(j, I - k); - } - 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; - }; - dsv.format = function(rows) { - if (Array.isArray(rows[0])) return dsv.formatRows(rows); - var fieldSet = new d3_Set(), fields = []; - rows.forEach(function(row) { - for (var field in row) { - if (!fieldSet.has(field)) { - fields.push(fieldSet.add(field)); - } - } - }); - return [ fields.map(formatValue).join(delimiter) ].concat(rows.map(function(row) { - return fields.map(function(field) { - return formatValue(row[field]); - }).join(delimiter); - })).join("\n"); - }; - dsv.formatRows = function(rows) { - return rows.map(formatRow).join("\n"); - }; - function formatRow(row) { - return row.map(formatValue).join(delimiter); - } - function formatValue(text) { - return reFormat.test(text) ? '"' + text.replace(/\"/g, '""') + '"' : text; - } - return dsv; - } - d3.csv = d3_dsv(",", "text/csv"); - d3.tsv = d3_dsv(" ", "text/tab-separated-values"); - var d3_timer_id = 0, d3_timer_byId = {}, d3_timer_queue = null, d3_timer_interval, d3_timer_timeout; - d3.timer = function(callback, delay, then) { - if (arguments.length < 3) { - if (arguments.length < 2) delay = 0; else if (!isFinite(delay)) return; - then = Date.now(); - } - var timer = d3_timer_byId[callback.id]; - if (timer && timer.callback === callback) { - timer.then = then; - timer.delay = delay; - } else d3_timer_byId[callback.id = ++d3_timer_id] = d3_timer_queue = { - callback: callback, - then: then, - delay: delay, - next: d3_timer_queue - }; - 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(); - }; - function d3_timer_flush() { - var t0 = null, t1 = d3_timer_queue, then = Infinity; - while (t1) { - if (t1.flush) { - delete d3_timer_byId[t1.callback.id]; - 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 = d3_window.requestAnimationFrame || d3_window.webkitRequestAnimationFrame || d3_window.mozRequestAnimationFrame || d3_window.oRequestAnimationFrame || d3_window.msRequestAnimationFrame || function(callback) { - setTimeout(callback, 17); - }; - var d3_format_decimalPoint = ".", d3_format_thousandsSeparator = ",", d3_format_grouping = [ 3, 3 ]; - 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) { - var k = Math.pow(10, Math.abs(8 - i) * 3); - return { - scale: i > 8 ? function(d) { - return d / k; - } : function(d) { - return d * k; - }, - symbol: d - }; - } - d3.round = function(x, n) { - return n ? Math.round(x * (n = Math.pow(10, n))) / n : Math.round(x); - }; - d3.format = function(specifier) { - var match = d3_format_re.exec(specifier), fill = match[1] || " ", align = match[2] || ">", sign = match[3] || "", basePrefix = match[4] || "", 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" && align === "=") { - zfill = fill = "0"; - 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 "b": - case "o": - case "x": - case "X": - if (basePrefix) basePrefix = "0" + type.toLowerCase(); - - case "c": - case "d": - integer = true; - precision = 0; - break; - - case "s": - scale = -1; - type = "r"; - break; - } - if (basePrefix === "#") basePrefix = ""; - if (type == "r" && !precision) type = "g"; - if (precision != null) { - if (type == "g") precision = Math.max(1, Math.min(21, precision)); else if (type == "e" || type == "f") precision = Math.max(0, Math.min(20, precision)); - } - type = d3_format_types.get(type) || d3_format_typeDefault; - var zcomma = zfill && comma; - return function(value) { - if (integer && value % 1) return ""; - var negative = value < 0 || value === 0 && 1 / value < 0 ? (value = -value, "-") : sign; - if (scale < 0) { - var prefix = d3.formatPrefix(value, precision); - value = prefix.scale(value); - suffix = prefix.symbol; - } else { - value *= scale; - } - value = type(value, precision); - if (!zfill && comma) value = d3_format_group(value); - var length = basePrefix.length + value.length + (zcomma ? 0 : negative.length), padding = length < width ? new Array(length = width - length + 1).join(fill) : ""; - if (zcomma) value = d3_format_group(padding + value); - if (d3_format_decimalPoint) value.replace(".", d3_format_decimalPoint); - negative += basePrefix; - return (align === "<" ? negative + value + padding : align === ">" ? padding + negative + value : align === "^" ? padding.substring(0, length >>= 1) + negative + value + padding.substring(length) : negative + (zcomma ? value : padding + value)) + suffix; - }; - }; - var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i; - var d3_format_types = d3.map({ - b: function(x) { - return x.toString(2); - }, - c: function(x) { - return String.fromCharCode(x); - }, - o: function(x) { - return x.toString(8); - }, - x: function(x) { - return x.toString(16); - }, - X: function(x) { - return x.toString(16).toUpperCase(); - }, - 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 (x = d3.round(x, d3_format_precision(x, p))).toFixed(Math.max(0, Math.min(20, d3_format_precision(x * (1 + 1e-15), p)))); - } - }); - function d3_format_precision(x, p) { - return p - (x ? Math.ceil(Math.log(x) / Math.LN10) : 1); - } - function d3_format_typeDefault(x) { - return x + ""; - } - var d3_format_group = d3_identity; - if (d3_format_grouping) { - var d3_format_groupingLength = d3_format_grouping.length; - d3_format_group = function(value) { - var i = value.lastIndexOf("."), f = i >= 0 ? "." + value.substring(i + 1) : (i = value.length, - ""), t = [], j = 0, g = d3_format_grouping[0]; - while (i > 0 && g > 0) { - t.push(value.substring(i -= g, i + g)); - g = d3_format_grouping[j = (j + 1) % d3_format_groupingLength]; - } - return t.reverse().join(d3_format_thousandsSeparator || "") + f; - }; - } - d3.geo = {}; - d3.geo.stream = function(object, listener) { - if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { - d3_geo_streamObjectType[object.type](object, listener); - } else { - d3_geo_streamGeometry(object, listener); - } - }; - function d3_geo_streamGeometry(geometry, listener) { - if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { - d3_geo_streamGeometryType[geometry.type](geometry, listener); - } - } - var d3_geo_streamObjectType = { - Feature: function(feature, listener) { - d3_geo_streamGeometry(feature.geometry, listener); - }, - FeatureCollection: function(object, listener) { - var features = object.features, i = -1, n = features.length; - while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); - } - }; - var d3_geo_streamGeometryType = { - Sphere: function(object, listener) { - listener.sphere(); - }, - Point: function(object, listener) { - var coordinate = object.coordinates; - listener.point(coordinate[0], coordinate[1]); - }, - MultiPoint: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length, coordinate; - while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]); - }, - LineString: function(object, listener) { - d3_geo_streamLine(object.coordinates, listener, 0); - }, - MultiLineString: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); - }, - Polygon: function(object, listener) { - d3_geo_streamPolygon(object.coordinates, listener); - }, - MultiPolygon: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); - }, - GeometryCollection: function(object, listener) { - var geometries = object.geometries, i = -1, n = geometries.length; - while (++i < n) d3_geo_streamGeometry(geometries[i], listener); - } - }; - function d3_geo_streamLine(coordinates, listener, closed) { - var i = -1, n = coordinates.length - closed, coordinate; - listener.lineStart(); - while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1]); - listener.lineEnd(); - } - function d3_geo_streamPolygon(coordinates, listener) { - var i = -1, n = coordinates.length; - listener.polygonStart(); - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); - listener.polygonEnd(); - } - d3.geo.area = function(object) { - d3_geo_areaSum = 0; - d3.geo.stream(object, d3_geo_area); - return d3_geo_areaSum; - }; - var d3_geo_areaSum, d3_geo_areaRingU, d3_geo_areaRingV; - var d3_geo_area = { - sphere: function() { - d3_geo_areaSum += 4 * π; - }, - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: function() { - d3_geo_areaRingU = 1, d3_geo_areaRingV = 0; - d3_geo_area.lineStart = d3_geo_areaRingStart; - }, - polygonEnd: function() { - var area = 2 * Math.atan2(d3_geo_areaRingV, d3_geo_areaRingU); - d3_geo_areaSum += area < 0 ? 4 * π + area : area; - d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; - } - }; - function d3_geo_areaRingStart() { - var λ00, φ00, λ0, cosφ0, sinφ0; - d3_geo_area.point = function(λ, φ) { - d3_geo_area.point = nextPoint; - λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), - sinφ0 = Math.sin(φ); - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - φ = φ * d3_radians / 2 + π / 4; - var dλ = λ - λ0, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u0 = d3_geo_areaRingU, v0 = d3_geo_areaRingV, u = cosφ0 * cosφ + k * Math.cos(dλ), v = k * Math.sin(dλ); - d3_geo_areaRingU = u0 * u - v0 * v; - d3_geo_areaRingV = v0 * u + u0 * v; - λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; - } - d3_geo_area.lineEnd = function() { - nextPoint(λ00, φ00); - }; - } - d3.geo.bounds = d3_geo_bounds(d3_identity); - function d3_geo_bounds(projectStream) { - var x0, y0, x1, y1; - var bound = { - point: boundPoint, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: function() { - bound.lineEnd = boundPolygonLineEnd; - }, - polygonEnd: function() { - bound.point = boundPoint; - } - }; - function boundPoint(x, y) { - if (x < x0) x0 = x; - if (x > x1) x1 = x; - if (y < y0) y0 = y; - if (y > y1) y1 = y; - } - function boundPolygonLineEnd() { - bound.point = bound.lineEnd = d3_noop; - } - return function(feature) { - y1 = x1 = -(x0 = y0 = Infinity); - d3.geo.stream(feature, projectStream(bound)); - return [ [ x0, y0 ], [ x1, y1 ] ]; - }; - } - d3.geo.centroid = function(object) { - d3_geo_centroidDimension = d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0; - d3.geo.stream(object, d3_geo_centroid); - var m; - if (d3_geo_centroidW && Math.abs(m = Math.sqrt(d3_geo_centroidX * d3_geo_centroidX + d3_geo_centroidY * d3_geo_centroidY + d3_geo_centroidZ * d3_geo_centroidZ)) > ε) { - return [ Math.atan2(d3_geo_centroidY, d3_geo_centroidX) * d3_degrees, Math.asin(Math.max(-1, Math.min(1, d3_geo_centroidZ / m))) * d3_degrees ]; - } - }; - var d3_geo_centroidDimension, d3_geo_centroidW, d3_geo_centroidX, d3_geo_centroidY, d3_geo_centroidZ; - var d3_geo_centroid = { - sphere: function() { - if (d3_geo_centroidDimension < 2) { - d3_geo_centroidDimension = 2; - d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0; - } - }, - point: d3_geo_centroidPoint, - lineStart: d3_geo_centroidLineStart, - lineEnd: d3_geo_centroidLineEnd, - polygonStart: function() { - if (d3_geo_centroidDimension < 2) { - d3_geo_centroidDimension = 2; - d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0; - } - d3_geo_centroid.lineStart = d3_geo_centroidRingStart; - }, - polygonEnd: function() { - d3_geo_centroid.lineStart = d3_geo_centroidLineStart; - } - }; - function d3_geo_centroidPoint(λ, φ) { - if (d3_geo_centroidDimension) return; - ++d3_geo_centroidW; - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - d3_geo_centroidX += (cosφ * Math.cos(λ) - d3_geo_centroidX) / d3_geo_centroidW; - d3_geo_centroidY += (cosφ * Math.sin(λ) - d3_geo_centroidY) / d3_geo_centroidW; - d3_geo_centroidZ += (Math.sin(φ) - d3_geo_centroidZ) / d3_geo_centroidW; - } - function d3_geo_centroidRingStart() { - var λ00, φ00; - d3_geo_centroidDimension = 1; - d3_geo_centroidLineStart(); - d3_geo_centroidDimension = 2; - var linePoint = d3_geo_centroid.point; - d3_geo_centroid.point = function(λ, φ) { - linePoint(λ00 = λ, φ00 = φ); - }; - d3_geo_centroid.lineEnd = function() { - d3_geo_centroid.point(λ00, φ00); - d3_geo_centroidLineEnd(); - d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; - }; - } - function d3_geo_centroidLineStart() { - var x0, y0, z0; - if (d3_geo_centroidDimension > 1) return; - if (d3_geo_centroidDimension < 1) { - d3_geo_centroidDimension = 1; - d3_geo_centroidW = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0; - } - d3_geo_centroid.point = function(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - x0 = cosφ * Math.cos(λ); - y0 = cosφ * Math.sin(λ); - z0 = Math.sin(φ); - d3_geo_centroid.point = nextPoint; - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z); - d3_geo_centroidW += w; - d3_geo_centroidX += w * (x0 + (x0 = x)); - d3_geo_centroidY += w * (y0 + (y0 = y)); - d3_geo_centroidZ += w * (z0 + (z0 = z)); - } - } - function d3_geo_centroidLineEnd() { - d3_geo_centroid.point = d3_geo_centroidPoint; - } - function d3_geo_cartesian(spherical) { - var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ); - return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ]; - } - function d3_geo_cartesianDot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; - } - function d3_geo_cartesianCross(a, b) { - return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ]; - } - function d3_geo_cartesianAdd(a, b) { - a[0] += b[0]; - a[1] += b[1]; - a[2] += b[2]; - } - function d3_geo_cartesianScale(vector, k) { - return [ vector[0] * k, vector[1] * k, vector[2] * k ]; - } - function d3_geo_cartesianNormalize(d) { - var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); - d[0] /= l; - d[1] /= l; - d[2] /= l; - } - function d3_true() { - return true; - } - function d3_geo_spherical(cartesian) { - return [ Math.atan2(cartesian[1], cartesian[0]), Math.asin(Math.max(-1, Math.min(1, cartesian[2]))) ]; - } - function d3_geo_sphericalEqual(a, b) { - return Math.abs(a[0] - b[0]) < ε && Math.abs(a[1] - b[1]) < ε; - } - function d3_geo_clipPolygon(segments, compare, inside, interpolate, listener) { - var subject = [], clip = []; - segments.forEach(function(segment) { - if ((n = segment.length - 1) <= 0) return; - var n, p0 = segment[0], p1 = segment[n]; - if (d3_geo_sphericalEqual(p0, p1)) { - listener.lineStart(); - for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); - listener.lineEnd(); - return; - } - var a = { - point: p0, - points: segment, - other: null, - visited: false, - entry: true, - subject: true - }, b = { - point: p0, - points: [ p0 ], - other: a, - visited: false, - entry: false, - subject: false - }; - a.other = b; - subject.push(a); - clip.push(b); - a = { - point: p1, - points: [ p1 ], - other: null, - visited: false, - entry: false, - subject: true - }; - b = { - point: p1, - points: [ p1 ], - other: a, - visited: false, - entry: true, - subject: false - }; - a.other = b; - subject.push(a); - clip.push(b); - }); - clip.sort(compare); - d3_geo_clipPolygonLinkCircular(subject); - d3_geo_clipPolygonLinkCircular(clip); - if (!subject.length) return; - if (inside) for (var i = 1, e = !inside(clip[0].point), n = clip.length; i < n; ++i) { - clip[i].entry = e = !e; - } - var start = subject[0], current, points, point; - while (1) { - current = start; - while (current.visited) if ((current = current.next) === start) return; - points = current.points; - listener.lineStart(); - do { - current.visited = current.other.visited = true; - if (current.entry) { - if (current.subject) { - for (var i = 0; i < points.length; i++) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.point, current.next.point, 1, listener); - } - current = current.next; - } else { - if (current.subject) { - points = current.prev.points; - for (var i = points.length; --i >= 0; ) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.point, current.prev.point, -1, listener); - } - current = current.prev; - } - current = current.other; - points = current.points; - } while (!current.visited); - listener.lineEnd(); - } - } - function d3_geo_clipPolygonLinkCircular(array) { - if (!(n = array.length)) return; - var n, i = 0, a = array[0], b; - while (++i < n) { - a.next = b = array[i]; - b.prev = a; - a = b; - } - a.next = b = array[0]; - b.prev = a; - } - function d3_geo_clip(pointVisible, clipLine, interpolate) { - return function(listener) { - var line = clipLine(listener); - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - clip.point = pointRing; - clip.lineStart = ringStart; - clip.lineEnd = ringEnd; - invisible = false; - invisibleArea = visibleArea = 0; - segments = []; - listener.polygonStart(); - }, - polygonEnd: function() { - clip.point = point; - clip.lineStart = lineStart; - clip.lineEnd = lineEnd; - segments = d3.merge(segments); - if (segments.length) { - d3_geo_clipPolygon(segments, d3_geo_clipSort, null, interpolate, listener); - } else if (visibleArea < -ε || invisible && invisibleArea < -ε) { - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - } - listener.polygonEnd(); - segments = null; - }, - sphere: function() { - listener.polygonStart(); - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - listener.polygonEnd(); - } - }; - function point(λ, φ) { - if (pointVisible(λ, φ)) listener.point(λ, φ); - } - function pointLine(λ, φ) { - line.point(λ, φ); - } - function lineStart() { - clip.point = pointLine; - line.lineStart(); - } - function lineEnd() { - clip.point = point; - line.lineEnd(); - } - var segments, visibleArea, invisibleArea, invisible; - var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), ring; - function pointRing(λ, φ) { - ringListener.point(λ, φ); - ring.push([ λ, φ ]); - } - function ringStart() { - ringListener.lineStart(); - ring = []; - } - function ringEnd() { - pointRing(ring[0][0], ring[0][1]); - ringListener.lineEnd(); - var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length; - if (!n) { - invisible = true; - invisibleArea += d3_geo_clipAreaRing(ring, -1); - ring = null; - return; - } - ring = null; - if (clean & 1) { - segment = ringSegments[0]; - visibleArea += d3_geo_clipAreaRing(segment, 1); - var n = segment.length - 1, i = -1, point; - listener.lineStart(); - while (++i < n) listener.point((point = segment[i])[0], point[1]); - listener.lineEnd(); - return; - } - if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); - segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); - } - return clip; - }; - } - function d3_geo_clipSegmentLength1(segment) { - return segment.length > 1; - } - function d3_geo_clipBufferListener() { - var lines = [], line; - return { - lineStart: function() { - lines.push(line = []); - }, - point: function(λ, φ) { - line.push([ λ, φ ]); - }, - lineEnd: d3_noop, - buffer: function() { - var buffer = lines; - lines = []; - line = null; - return buffer; - }, - rejoin: function() { - if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); - } - }; - } - function d3_geo_clipAreaRing(ring, invisible) { - if (!(n = ring.length)) return 0; - var n, i = 0, area = 0, p = ring[0], λ = p[0], φ = p[1], cosφ = Math.cos(φ), x0 = Math.atan2(invisible * Math.sin(λ) * cosφ, Math.sin(φ)), y0 = 1 - invisible * Math.cos(λ) * cosφ, x1 = x0, x, y; - while (++i < n) { - p = ring[i]; - cosφ = Math.cos(φ = p[1]); - x = Math.atan2(invisible * Math.sin(λ = p[0]) * cosφ, Math.sin(φ)); - y = 1 - invisible * Math.cos(λ) * cosφ; - if (Math.abs(y0 - 2) < ε && Math.abs(y - 2) < ε) continue; - if (Math.abs(y) < ε || Math.abs(y0) < ε) {} else if (Math.abs(Math.abs(x - x0) - π) < ε) { - if (y + y0 > 2) area += 4 * (x - x0); - } else if (Math.abs(y0 - 2) < ε) area += 4 * (x - x1); else area += ((3 * π + x - x0) % (2 * π) - π) * (y0 + y); - x1 = x0, x0 = x, y0 = y; - } - return area; - } - function d3_geo_clipSort(a, b) { - return ((a = a.point)[0] < 0 ? a[1] - π / 2 - ε : π / 2 - a[1]) - ((b = b.point)[0] < 0 ? b[1] - π / 2 - ε : π / 2 - b[1]); - } - var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate); - function d3_geo_clipAntimeridianLine(listener) { - var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; - return { - lineStart: function() { - listener.lineStart(); - clean = 1; - }, - point: function(λ1, φ1) { - var sλ1 = λ1 > 0 ? π : -π, dλ = Math.abs(λ1 - λ0); - if (Math.abs(dλ - π) < ε) { - listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? π / 2 : -π / 2); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - listener.point(λ1, φ0); - clean = 0; - } else if (sλ0 !== sλ1 && dλ >= π) { - if (Math.abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; - if (Math.abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; - φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - clean = 0; - } - listener.point(λ0 = λ1, φ0 = φ1); - sλ0 = sλ1; - }, - lineEnd: function() { - listener.lineEnd(); - λ0 = φ0 = NaN; - }, - clean: function() { - return 2 - clean; - } - }; - } - function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) { - var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1); - return Math.abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2; - } - function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { - var φ; - if (from == null) { - φ = direction * π / 2; - listener.point(-π, φ); - listener.point(0, φ); - listener.point(π, φ); - listener.point(π, 0); - listener.point(π, -φ); - listener.point(0, -φ); - listener.point(-π, -φ); - listener.point(-π, 0); - listener.point(-π, φ); - } else if (Math.abs(from[0] - to[0]) > ε) { - var s = (from[0] < to[0] ? 1 : -1) * π; - φ = direction * s / 2; - listener.point(-s, φ); - listener.point(0, φ); - listener.point(s, φ); - } else { - listener.point(to[0], to[1]); - } - } - function d3_geo_clipCircle(radius) { - var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = Math.abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); - return d3_geo_clip(visible, clipLine, interpolate); - function visible(λ, φ) { - return Math.cos(λ) * Math.cos(φ) > cr; - } - function clipLine(listener) { - var point0, c0, v0, v00, clean; - return { - lineStart: function() { - v00 = v0 = false; - clean = 1; - }, - point: function(λ, φ) { - var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; - if (!point0 && (v00 = v0 = v)) listener.lineStart(); - if (v !== v0) { - point2 = intersect(point0, point1); - if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { - point1[0] += ε; - point1[1] += ε; - v = visible(point1[0], point1[1]); - } - } - if (v !== v0) { - clean = 0; - if (v) { - listener.lineStart(); - point2 = intersect(point1, point0); - listener.point(point2[0], point2[1]); - } else { - point2 = intersect(point0, point1); - listener.point(point2[0], point2[1]); - listener.lineEnd(); - } - point0 = point2; - } else if (notHemisphere && point0 && smallRadius ^ v) { - var t; - if (!(c & c0) && (t = intersect(point1, point0, true))) { - clean = 0; - if (smallRadius) { - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - } else { - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - } - } - } - if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { - listener.point(point1[0], point1[1]); - } - point0 = point1, v0 = v, c0 = c; - }, - lineEnd: function() { - if (v0) listener.lineEnd(); - point0 = null; - }, - clean: function() { - return clean | (v00 && v0) << 1; - } - }; - } - function intersect(a, b, two) { - var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b); - var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; - if (!determinant) return !two && a; - var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); - d3_geo_cartesianAdd(A, B); - var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); - if (t2 < 0) return; - var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu); - d3_geo_cartesianAdd(q, A); - q = d3_geo_spherical(q); - if (!two) return q; - var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z; - if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; - var δλ = λ1 - λ0, polar = Math.abs(δλ - π) < ε, meridian = polar || δλ < ε; - if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; - if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (Math.abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { - var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); - d3_geo_cartesianAdd(q1, A); - return [ q, d3_geo_spherical(q1) ]; - } - } - function code(λ, φ) { - var r = smallRadius ? radius : π - radius, code = 0; - if (λ < -r) code |= 1; else if (λ > r) code |= 2; - if (φ < -r) code |= 4; else if (φ > r) code |= 8; - return code; - } - } - var d3_geo_clipViewMAX = 1e9; - function d3_geo_clipView(x0, y0, x1, y1) { - return function(listener) { - var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), segments, polygon, ring; - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - listener = bufferListener; - segments = []; - polygon = []; - }, - polygonEnd: function() { - listener = listener_; - if ((segments = d3.merge(segments)).length) { - listener.polygonStart(); - d3_geo_clipPolygon(segments, compare, inside, interpolate, listener); - listener.polygonEnd(); - } else if (insidePolygon([ x0, y0 ])) { - listener.polygonStart(), listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(), listener.polygonEnd(); - } - segments = polygon = ring = null; - } - }; - function inside(point) { - var a = corner(point, -1), i = insidePolygon([ a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0 ]); - return i; - } - function insidePolygon(p) { - var wn = 0, n = polygon.length, y = p[1]; - for (var i = 0; i < n; ++i) { - for (var j = 1, v = polygon[i], m = v.length, a = v[0]; j < m; ++j) { - b = v[j]; - if (a[1] <= y) { - if (b[1] > y && isLeft(a, b, p) > 0) ++wn; - } else { - if (b[1] <= y && isLeft(a, b, p) < 0) --wn; - } - a = b; - } - } - return wn !== 0; - } - function isLeft(a, b, c) { - return (b[0] - a[0]) * (c[1] - a[1]) - (c[0] - a[0]) * (b[1] - a[1]); - } - function interpolate(from, to, direction, listener) { - var a = 0, a1 = 0; - if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { - do { - listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); - } while ((a = (a + direction + 4) % 4) !== a1); - } else { - listener.point(to[0], to[1]); - } - } - function visible(x, y) { - return x0 <= x && x <= x1 && y0 <= y && y <= y1; - } - function point(x, y) { - if (visible(x, y)) listener.point(x, y); - } - var x__, y__, v__, x_, y_, v_, first; - function lineStart() { - clip.point = linePoint; - if (polygon) polygon.push(ring = []); - first = true; - v_ = false; - x_ = y_ = NaN; - } - function lineEnd() { - if (segments) { - linePoint(x__, y__); - if (v__ && v_) bufferListener.rejoin(); - segments.push(bufferListener.buffer()); - } - clip.point = point; - if (v_) listener.lineEnd(); - } - function linePoint(x, y) { - x = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, x)); - y = Math.max(-d3_geo_clipViewMAX, Math.min(d3_geo_clipViewMAX, y)); - var v = visible(x, y); - if (polygon) ring.push([ x, y ]); - if (first) { - x__ = x, y__ = y, v__ = v; - first = false; - if (v) { - listener.lineStart(); - listener.point(x, y); - } - } else { - if (v && v_) listener.point(x, y); else { - var a = [ x_, y_ ], b = [ x, y ]; - if (clipLine(a, b)) { - if (!v_) { - listener.lineStart(); - listener.point(a[0], a[1]); - } - listener.point(b[0], b[1]); - if (!v) listener.lineEnd(); - } else { - listener.lineStart(); - listener.point(x, y); - } - } - } - x_ = x, y_ = y, v_ = v; - } - return clip; - }; - function corner(p, direction) { - return Math.abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : Math.abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : Math.abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2; - } - function compare(a, b) { - return comparePoints(a.point, b.point); - } - function comparePoints(a, b) { - var ca = corner(a, 1), cb = corner(b, 1); - return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; - } - function clipLine(a, b) { - var dx = b[0] - a[0], dy = b[1] - a[1], t = [ 0, 1 ]; - if (Math.abs(dx) < ε && Math.abs(dy) < ε) return x0 <= a[0] && a[0] <= x1 && y0 <= a[1] && a[1] <= y1; - if (d3_geo_clipViewT(x0 - a[0], dx, t) && d3_geo_clipViewT(a[0] - x1, -dx, t) && d3_geo_clipViewT(y0 - a[1], dy, t) && d3_geo_clipViewT(a[1] - y1, -dy, t)) { - if (t[1] < 1) { - b[0] = a[0] + t[1] * dx; - b[1] = a[1] + t[1] * dy; - } - if (t[0] > 0) { - a[0] += t[0] * dx; - a[1] += t[0] * dy; - } - return true; - } - return false; - } - } - function d3_geo_clipViewT(num, denominator, t) { - if (Math.abs(denominator) < ε) return num <= 0; - var u = num / denominator; - if (denominator > 0) { - if (u > t[1]) return false; - if (u > t[0]) t[0] = u; - } else { - if (u < t[0]) return false; - if (u < t[1]) t[1] = u; - } - return true; - } - function d3_geo_compose(a, b) { - function compose(x, y) { - return x = a(x, y), b(x[0], x[1]); - } - if (a.invert && b.invert) compose.invert = function(x, y) { - return x = b.invert(x, y), x && a.invert(x[0], x[1]); - }; - return compose; - } - function d3_geo_resample(project) { - var δ2 = .5, maxDepth = 16; - function resample(stream) { - var λ0, x0, y0, a0, b0, c0; - var resample = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - stream.polygonStart(); - resample.lineStart = polygonLineStart; - }, - polygonEnd: function() { - stream.polygonEnd(); - resample.lineStart = lineStart; - } - }; - function point(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - } - function lineStart() { - x0 = NaN; - resample.point = linePoint; - stream.lineStart(); - } - function linePoint(λ, φ) { - var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ); - resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); - stream.point(x0, y0); - } - function lineEnd() { - resample.point = point; - stream.lineEnd(); - } - function polygonLineStart() { - var λ00, φ00, x00, y00, a00, b00, c00; - lineStart(); - resample.point = function(λ, φ) { - linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; - resample.point = linePoint; - }; - resample.lineEnd = function() { - resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); - resample.lineEnd = lineEnd; - lineEnd(); - }; - } - return resample; - } - function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { - var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; - if (d2 > 4 * δ2 && depth--) { - var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = Math.abs(Math.abs(c) - 1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2; - if (dz * dz / d2 > δ2 || Math.abs((dx * dx2 + dy * dy2) / d2 - .5) > .3) { - resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream); - stream.point(x2, y2); - resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream); - } - } - } - resample.precision = function(_) { - if (!arguments.length) return Math.sqrt(δ2); - maxDepth = (δ2 = _ * _) > 0 && 16; - return resample; - }; - return resample; - } - d3.geo.projection = d3_geo_projection; - d3.geo.projectionMutator = d3_geo_projectionMutator; - function d3_geo_projection(project) { - return d3_geo_projectionMutator(function() { - return project; - })(); - } - function d3_geo_projectionMutator(projectAt) { - var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) { - x = project(x, y); - return [ x[0] * k + δx, δy - x[1] * k ]; - }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null; - function projection(point) { - point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); - return [ point[0] * k + δx, δy - point[1] * k ]; - } - function invert(point) { - point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); - return point && [ point[0] * d3_degrees, point[1] * d3_degrees ]; - } - projection.stream = function(stream) { - return d3_geo_projectionRadiansRotate(rotate, preclip(projectResample(postclip(stream)))); - }; - projection.clipAngle = function(_) { - if (!arguments.length) return clipAngle; - preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); - return projection; - }; - projection.clipExtent = function(_) { - if (!arguments.length) return clipExtent; - clipExtent = _; - postclip = _ == null ? d3_identity : d3_geo_clipView(_[0][0], _[0][1], _[1][0], _[1][1]); - return projection; - }; - projection.scale = function(_) { - if (!arguments.length) return k; - k = +_; - return reset(); - }; - projection.translate = function(_) { - if (!arguments.length) return [ x, y ]; - x = +_[0]; - y = +_[1]; - return reset(); - }; - projection.center = function(_) { - if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ]; - λ = _[0] % 360 * d3_radians; - φ = _[1] % 360 * d3_radians; - return reset(); - }; - projection.rotate = function(_) { - if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ]; - δλ = _[0] % 360 * d3_radians; - δφ = _[1] % 360 * d3_radians; - δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; - return reset(); - }; - d3.rebind(projection, projectResample, "precision"); - function reset() { - projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project); - var center = project(λ, φ); - δx = x - center[0] * k; - δy = y + center[1] * k; - return projection; - } - return function() { - project = projectAt.apply(this, arguments); - projection.invert = project.invert && invert; - return reset(); - }; - } - function d3_geo_projectionRadiansRotate(rotate, stream) { - return { - point: function(x, y) { - y = rotate(x * d3_radians, y * d3_radians), x = y[0]; - stream.point(x > π ? x - 2 * π : x < -π ? x + 2 * π : x, y[1]); - }, - sphere: function() { - stream.sphere(); - }, - lineStart: function() { - stream.lineStart(); - }, - lineEnd: function() { - stream.lineEnd(); - }, - polygonStart: function() { - stream.polygonStart(); - }, - polygonEnd: function() { - stream.polygonEnd(); - } - }; - } - function d3_geo_equirectangular(λ, φ) { - return [ λ, φ ]; - } - (d3.geo.equirectangular = function() { - return d3_geo_projection(d3_geo_equirectangular); - }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; - d3.geo.rotation = function(rotate) { - rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); - function forward(coordinates) { - coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - } - forward.invert = function(coordinates) { - coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - }; - return forward; - }; - function d3_geo_rotation(δλ, δφ, δγ) { - return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_equirectangular; - } - function d3_geo_forwardRotationλ(δλ) { - return function(λ, φ) { - return λ += δλ, [ λ > π ? λ - 2 * π : λ < -π ? λ + 2 * π : λ, φ ]; - }; - } - function d3_geo_rotationλ(δλ) { - var rotation = d3_geo_forwardRotationλ(δλ); - rotation.invert = d3_geo_forwardRotationλ(-δλ); - return rotation; - } - function d3_geo_rotationφγ(δφ, δγ) { - var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ); - function rotation(λ, φ) { - var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ; - return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), Math.asin(Math.max(-1, Math.min(1, k * cosδγ + y * sinδγ))) ]; - } - rotation.invert = function(λ, φ) { - var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ; - return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), Math.asin(Math.max(-1, Math.min(1, k * cosδφ - x * sinδφ))) ]; - }; - return rotation; - } - d3.geo.circle = function() { - var origin = [ 0, 0 ], angle, precision = 6, interpolate; - function circle() { - var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = []; - interpolate(null, null, 1, { - point: function(x, y) { - ring.push(x = rotate(x, y)); - x[0] *= d3_degrees, x[1] *= d3_degrees; - } - }); - return { - type: "Polygon", - coordinates: [ ring ] - }; - } - circle.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - return circle; - }; - circle.angle = function(x) { - if (!arguments.length) return angle; - interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); - return circle; - }; - circle.precision = function(_) { - if (!arguments.length) return precision; - interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); - return circle; - }; - return circle.angle(90); - }; - function d3_geo_circleInterpolate(radius, precision) { - var cr = Math.cos(radius), sr = Math.sin(radius); - return function(from, to, direction, listener) { - if (from != null) { - from = d3_geo_circleAngle(cr, from); - to = d3_geo_circleAngle(cr, to); - if (direction > 0 ? from < to : from > to) from += direction * 2 * π; - } else { - from = radius + direction * 2 * π; - to = radius; - } - var point; - for (var step = direction * precision, t = from; direction > 0 ? t > to : t < to; t -= step) { - listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]); - } - }; - } - function d3_geo_circleAngle(cr, point) { - var a = d3_geo_cartesian(point); - a[0] -= cr; - d3_geo_cartesianNormalize(a); - var angle = d3_acos(-a[1]); - return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); - } - d3.geo.distance = function(a, b) { - var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t; - return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ); - }; - d3.geo.graticule = function() { - var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5; - function graticule() { - return { - type: "MultiLineString", - coordinates: lines() - }; - } - function lines() { - return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { - return Math.abs(x % DX) > ε; - }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { - return Math.abs(y % DY) > ε; - }).map(y)); - } - graticule.lines = function() { - return lines().map(function(coordinates) { - return { - type: "LineString", - coordinates: coordinates - }; - }); - }; - graticule.outline = function() { - return { - type: "Polygon", - coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ] - }; - }; - graticule.extent = function(_) { - if (!arguments.length) return graticule.minorExtent(); - return graticule.majorExtent(_).minorExtent(_); - }; - graticule.majorExtent = function(_) { - if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ]; - X0 = +_[0][0], X1 = +_[1][0]; - Y0 = +_[0][1], Y1 = +_[1][1]; - if (X0 > X1) _ = X0, X0 = X1, X1 = _; - if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; - return graticule.precision(precision); - }; - graticule.minorExtent = function(_) { - if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; - x0 = +_[0][0], x1 = +_[1][0]; - y0 = +_[0][1], y1 = +_[1][1]; - if (x0 > x1) _ = x0, x0 = x1, x1 = _; - if (y0 > y1) _ = y0, y0 = y1, y1 = _; - return graticule.precision(precision); - }; - graticule.step = function(_) { - if (!arguments.length) return graticule.minorStep(); - return graticule.majorStep(_).minorStep(_); - }; - graticule.majorStep = function(_) { - if (!arguments.length) return [ DX, DY ]; - DX = +_[0], DY = +_[1]; - return graticule; - }; - graticule.minorStep = function(_) { - if (!arguments.length) return [ dx, dy ]; - dx = +_[0], dy = +_[1]; - return graticule; - }; - graticule.precision = function(_) { - if (!arguments.length) return precision; - precision = +_; - x = d3_geo_graticuleX(y0, y1, 90); - y = d3_geo_graticuleY(x0, x1, precision); - X = d3_geo_graticuleX(Y0, Y1, 90); - Y = d3_geo_graticuleY(X0, X1, precision); - return graticule; - }; - return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]); - }; - function d3_geo_graticuleX(y0, y1, dy) { - var y = d3.range(y0, y1 - ε, dy).concat(y1); - return function(x) { - return y.map(function(y) { - return [ x, y ]; - }); - }; - } - function d3_geo_graticuleY(x0, x1, dx) { - var x = d3.range(x0, x1 - ε, dx).concat(x1); - return function(y) { - return x.map(function(x) { - return [ x, y ]; - }); - }; - } - function d3_source(d) { - return d.source; - } - function d3_target(d) { - return d.target; - } - d3.geo.greatArc = function() { - var source = d3_source, source_, target = d3_target, target_; - function greatArc() { - return { - type: "LineString", - coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ] - }; - } - greatArc.distance = function() { - return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments)); - }; - greatArc.source = function(_) { - if (!arguments.length) return source; - source = _, source_ = typeof _ === "function" ? null : _; - return greatArc; - }; - greatArc.target = function(_) { - if (!arguments.length) return target; - target = _, target_ = typeof _ === "function" ? null : _; - return greatArc; - }; - greatArc.precision = function() { - return arguments.length ? greatArc : 0; - }; - return greatArc; - }; - d3.geo.interpolate = function(source, target) { - return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); - }; - function d3_geo_interpolate(x0, y0, x1, y1) { - var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d); - var interpolate = d ? function(t) { - var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; - return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; - } : function() { - return [ x0 * d3_degrees, y0 * d3_degrees ]; - }; - interpolate.distance = d; - return interpolate; - } - d3.geo.length = function(object) { - d3_geo_lengthSum = 0; - d3.geo.stream(object, d3_geo_length); - return d3_geo_lengthSum; - }; - var d3_geo_lengthSum; - var d3_geo_length = { - sphere: d3_noop, - point: d3_noop, - lineStart: d3_geo_lengthLineStart, - lineEnd: d3_noop, - polygonStart: d3_noop, - polygonEnd: d3_noop - }; - function d3_geo_lengthLineStart() { - var λ0, sinφ0, cosφ0; - d3_geo_length.point = function(λ, φ) { - λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ); - d3_geo_length.point = nextPoint; - }; - d3_geo_length.lineEnd = function() { - d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; - }; - function nextPoint(λ, φ) { - var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = Math.abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t); - d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ); - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ; - } - } - function d3_geo_conic(projectAt) { - var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1); - p.parallels = function(_) { - if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ]; - return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180); - }; - return p; - } - function d3_geo_conicEqualArea(φ0, φ1) { - var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n; - function forward(λ, φ) { - var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n; - return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = ρ0 - y; - return [ Math.atan2(x, ρ0_y) / n, Math.asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ]; - }; - return forward; - } - (d3.geo.conicEqualArea = function() { - return d3_geo_conic(d3_geo_conicEqualArea); - }).raw = d3_geo_conicEqualArea; - d3.geo.albersUsa = function() { - var lower48 = d3.geo.conicEqualArea().rotate([ 98, 0 ]).center([ 0, 38 ]).parallels([ 29.5, 45.5 ]); - var alaska = d3.geo.conicEqualArea().rotate([ 160, 0 ]).center([ 0, 60 ]).parallels([ 55, 65 ]); - var hawaii = d3.geo.conicEqualArea().rotate([ 160, 0 ]).center([ 0, 20 ]).parallels([ 8, 18 ]); - var puertoRico = d3.geo.conicEqualArea().rotate([ 60, 0 ]).center([ 0, 10 ]).parallels([ 8, 18 ]); - var alaskaInvert, hawaiiInvert, puertoRicoInvert; - function albersUsa(coordinates) { - return projection(coordinates)(coordinates); - } - function projection(point) { - var lon = point[0], lat = point[1]; - return lat > 50 ? alaska : lon < -140 ? hawaii : lat < 21 ? puertoRico : lower48; - } - albersUsa.invert = function(coordinates) { - return alaskaInvert(coordinates) || hawaiiInvert(coordinates) || puertoRicoInvert(coordinates) || lower48.invert(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(), dx = x[0], dy = x[1]; - lower48.translate(x); - alaska.translate([ dx - .4 * dz, dy + .17 * dz ]); - hawaii.translate([ dx - .19 * dz, dy + .2 * dz ]); - puertoRico.translate([ dx + .58 * dz, dy + .43 * dz ]); - alaskaInvert = d3_geo_albersUsaInvert(alaska, [ [ -180, 50 ], [ -130, 72 ] ]); - hawaiiInvert = d3_geo_albersUsaInvert(hawaii, [ [ -164, 18 ], [ -154, 24 ] ]); - puertoRicoInvert = d3_geo_albersUsaInvert(puertoRico, [ [ -67.5, 17.5 ], [ -65, 19 ] ]); - return albersUsa; - }; - return albersUsa.scale(1e3); - }; - function d3_geo_albersUsaInvert(projection, extent) { - var a = projection(extent[0]), b = projection([ .5 * (extent[0][0] + extent[1][0]), extent[0][1] ]), c = projection([ extent[1][0], extent[0][1] ]), d = projection(extent[1]); - var dya = b[1] - a[1], dxa = b[0] - a[0], dyb = c[1] - b[1], dxb = c[0] - b[0]; - var ma = dya / dxa, mb = dyb / dxb; - var cx = .5 * (ma * mb * (a[1] - c[1]) + mb * (a[0] + b[0]) - ma * (b[0] + c[0])) / (mb - ma), cy = (.5 * (a[0] + b[0]) - cx) / ma + .5 * (a[1] + b[1]); - var dx0 = d[0] - cx, dy0 = d[1] - cy, dx1 = a[0] - cx, dy1 = a[1] - cy, r0 = dx0 * dx0 + dy0 * dy0, r1 = dx1 * dx1 + dy1 * dy1; - var a0 = Math.atan2(dy0, dx0), a1 = Math.atan2(dy1, dx1); - return function(coordinates) { - var dx = coordinates[0] - cx, dy = coordinates[1] - cy, r = dx * dx + dy * dy, a = Math.atan2(dy, dx); - if (r0 < r && r < r1 && a0 < a && a < a1) return projection.invert(coordinates); - }; - } - var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: function() { - d3_geo_pathAreaPolygon = 0; - d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; - }, - polygonEnd: function() { - d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; - d3_geo_pathAreaSum += Math.abs(d3_geo_pathAreaPolygon / 2); - } - }; - function d3_geo_pathAreaRingStart() { - var x00, y00, x0, y0; - d3_geo_pathArea.point = function(x, y) { - d3_geo_pathArea.point = nextPoint; - x00 = x0 = x, y00 = y0 = y; - }; - function nextPoint(x, y) { - d3_geo_pathAreaPolygon += y0 * x - x0 * y; - x0 = x, y0 = y; - } - d3_geo_pathArea.lineEnd = function() { - nextPoint(x00, y00); - }; - } - function d3_geo_pathBuffer() { - var pointCircle = d3_geo_pathCircle(4.5), buffer = []; - var stream = { - point: point, - lineStart: function() { - stream.point = pointLineStart; - }, - lineEnd: lineEnd, - polygonStart: function() { - stream.lineEnd = lineEndPolygon; - }, - polygonEnd: function() { - stream.lineEnd = lineEnd; - stream.point = point; - }, - pointRadius: function(_) { - pointCircle = d3_geo_pathCircle(_); - return stream; - }, - result: function() { - if (buffer.length) { - var result = buffer.join(""); - buffer = []; - return result; - } - } - }; - function point(x, y) { - buffer.push("M", x, ",", y, pointCircle); - } - function pointLineStart(x, y) { - buffer.push("M", x, ",", y); - stream.point = pointLine; - } - function pointLine(x, y) { - buffer.push("L", x, ",", y); - } - function lineEnd() { - stream.point = point; - } - function lineEndPolygon() { - buffer.push("Z"); - } - return stream; - } - var d3_geo_pathCentroid = { - point: d3_geo_pathCentroidPoint, - lineStart: d3_geo_pathCentroidLineStart, - lineEnd: d3_geo_pathCentroidLineEnd, - polygonStart: function() { - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; - }, - polygonEnd: function() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; - d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; - } - }; - function d3_geo_pathCentroidPoint(x, y) { - if (d3_geo_centroidDimension) return; - d3_geo_centroidX += x; - d3_geo_centroidY += y; - ++d3_geo_centroidZ; - } - function d3_geo_pathCentroidLineStart() { - var x0, y0; - if (d3_geo_centroidDimension !== 1) { - if (d3_geo_centroidDimension < 1) { - d3_geo_centroidDimension = 1; - d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0; - } else return; - } - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - x0 = x, y0 = y; - }; - function nextPoint(x, y) { - var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); - d3_geo_centroidX += z * (x0 + x) / 2; - d3_geo_centroidY += z * (y0 + y) / 2; - d3_geo_centroidZ += z; - x0 = x, y0 = y; - } - } - function d3_geo_pathCentroidLineEnd() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; - } - function d3_geo_pathCentroidRingStart() { - var x00, y00, x0, y0; - if (d3_geo_centroidDimension < 2) { - d3_geo_centroidDimension = 2; - d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0; - } - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - x00 = x0 = x, y00 = y0 = y; - }; - function nextPoint(x, y) { - var z = y0 * x - x0 * y; - d3_geo_centroidX += z * (x0 + x); - d3_geo_centroidY += z * (y0 + y); - d3_geo_centroidZ += z * 3; - x0 = x, y0 = y; - } - d3_geo_pathCentroid.lineEnd = function() { - nextPoint(x00, y00); - }; - } - function d3_geo_pathContext(context) { - var pointRadius = 4.5; - var stream = { - point: point, - lineStart: function() { - stream.point = pointLineStart; - }, - lineEnd: lineEnd, - polygonStart: function() { - stream.lineEnd = lineEndPolygon; - }, - polygonEnd: function() { - stream.lineEnd = lineEnd; - stream.point = point; - }, - pointRadius: function(_) { - pointRadius = _; - return stream; - }, - result: d3_noop - }; - function point(x, y) { - context.moveTo(x, y); - context.arc(x, y, pointRadius, 0, 2 * π); - } - function pointLineStart(x, y) { - context.moveTo(x, y); - stream.point = pointLine; - } - function pointLine(x, y) { - context.lineTo(x, y); - } - function lineEnd() { - stream.point = point; - } - function lineEndPolygon() { - context.closePath(); - } - return stream; - } - d3.geo.path = function() { - var pointRadius = 4.5, projection, context, projectStream, contextStream; - function path(object) { - if (object) d3.geo.stream(object, projectStream(contextStream.pointRadius(typeof pointRadius === "function" ? +pointRadius.apply(this, arguments) : pointRadius))); - return contextStream.result(); - } - path.area = function(object) { - d3_geo_pathAreaSum = 0; - d3.geo.stream(object, projectStream(d3_geo_pathArea)); - return d3_geo_pathAreaSum; - }; - path.centroid = function(object) { - d3_geo_centroidDimension = d3_geo_centroidX = d3_geo_centroidY = d3_geo_centroidZ = 0; - d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); - return d3_geo_centroidZ ? [ d3_geo_centroidX / d3_geo_centroidZ, d3_geo_centroidY / d3_geo_centroidZ ] : undefined; - }; - path.bounds = function(object) { - return d3_geo_bounds(projectStream)(object); - }; - path.projection = function(_) { - if (!arguments.length) return projection; - projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; - return path; - }; - path.context = function(_) { - if (!arguments.length) return context; - contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_); - return path; - }; - path.pointRadius = function(_) { - if (!arguments.length) return pointRadius; - pointRadius = typeof _ === "function" ? _ : +_; - return path; - }; - return path.projection(d3.geo.albersUsa()).context(null); - }; - function d3_geo_pathCircle(radius) { - return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + +2 * radius + "z"; - } - function d3_geo_pathProjectStream(project) { - var resample = d3_geo_resample(function(λ, φ) { - return project([ λ * d3_degrees, φ * d3_degrees ]); - }); - return function(stream) { - stream = resample(stream); - return { - point: function(λ, φ) { - stream.point(λ * d3_radians, φ * d3_radians); - }, - sphere: function() { - stream.sphere(); - }, - lineStart: function() { - stream.lineStart(); - }, - lineEnd: function() { - stream.lineEnd(); - }, - polygonStart: function() { - stream.polygonStart(); - }, - polygonEnd: function() { - stream.polygonEnd(); - } - }; - }; - } - d3.geo.albers = function() { - return d3.geo.conicEqualArea().parallels([ 29.5, 45.5 ]).rotate([ 98, 0 ]).center([ 0, 38 ]).scale(1e3); - }; - function d3_geo_azimuthal(scale, angle) { - function azimuthal(λ, φ) { - var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ); - return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ]; - } - azimuthal.invert = function(x, y) { - var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c); - return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ]; - }; - return azimuthal; - } - var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) { - return Math.sqrt(2 / (1 + cosλcosφ)); - }, function(ρ) { - return 2 * Math.asin(ρ / 2); - }); - (d3.geo.azimuthalEqualArea = function() { - return d3_geo_projection(d3_geo_azimuthalEqualArea); - }).raw = d3_geo_azimuthalEqualArea; - var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) { - var c = Math.acos(cosλcosφ); - return c && c / Math.sin(c); - }, d3_identity); - (d3.geo.azimuthalEquidistant = function() { - return d3_geo_projection(d3_geo_azimuthalEquidistant); - }).raw = d3_geo_azimuthalEquidistant; - function d3_geo_conicConformal(φ0, φ1) { - var cosφ0 = Math.cos(φ0), t = function(φ) { - return Math.tan(π / 4 + φ / 2); - }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n; - if (!n) return d3_geo_mercator; - function forward(λ, φ) { - var ρ = Math.abs(Math.abs(φ) - π / 2) < ε ? 0 : F / Math.pow(t(φ), n); - return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y); - return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - π / 2 ]; - }; - return forward; - } - (d3.geo.conicConformal = function() { - return d3_geo_conic(d3_geo_conicConformal); - }).raw = d3_geo_conicConformal; - function d3_geo_conicEquidistant(φ0, φ1) { - var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0; - if (Math.abs(n) < ε) return d3_geo_equirectangular; - function forward(λ, φ) { - var ρ = G - φ; - return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = G - y; - return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ]; - }; - return forward; - } - (d3.geo.conicEquidistant = function() { - return d3_geo_conic(d3_geo_conicEquidistant); - }).raw = d3_geo_conicEquidistant; - var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) { - return 1 / cosλcosφ; - }, Math.atan); - (d3.geo.gnomonic = function() { - return d3_geo_projection(d3_geo_gnomonic); - }).raw = d3_geo_gnomonic; - function d3_geo_mercator(λ, φ) { - return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ]; - } - d3_geo_mercator.invert = function(x, y) { - return [ x, 2 * Math.atan(Math.exp(y)) - π / 2 ]; - }; - function d3_geo_mercatorProjection(project) { - var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto; - m.scale = function() { - var v = scale.apply(m, arguments); - return v === m ? clipAuto ? m.clipExtent(null) : m : v; - }; - m.translate = function() { - var v = translate.apply(m, arguments); - return v === m ? clipAuto ? m.clipExtent(null) : m : v; - }; - m.clipExtent = function(_) { - var v = clipExtent.apply(m, arguments); - if (v === m) { - if (clipAuto = _ == null) { - var k = π * scale(), t = translate(); - clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]); - } - } else if (clipAuto) { - v = null; - } - return v; - }; - return m.clipExtent(null); - } - (d3.geo.mercator = function() { - return d3_geo_mercatorProjection(d3_geo_mercator); - }).raw = d3_geo_mercator; - var d3_geo_orthographic = d3_geo_azimuthal(function() { - return 1; - }, Math.asin); - (d3.geo.orthographic = function() { - return d3_geo_projection(d3_geo_orthographic); - }).raw = d3_geo_orthographic; - var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) { - return 1 / (1 + cosλcosφ); - }, function(ρ) { - return 2 * Math.atan(ρ); - }); - (d3.geo.stereographic = function() { - return d3_geo_projection(d3_geo_stereographic); - }).raw = d3_geo_stereographic; - function d3_geo_transverseMercator(λ, φ) { - var B = Math.cos(φ) * Math.sin(λ); - return [ Math.log((1 + B) / (1 - B)) / 2, Math.atan2(Math.tan(φ), Math.cos(λ)) ]; - } - d3_geo_transverseMercator.invert = function(x, y) { - return [ Math.atan2(d3_sinh(x), Math.cos(y)), d3_asin(Math.sin(y) / d3_cosh(x)) ]; - }; - (d3.geo.transverseMercator = function() { - return d3_geo_mercatorProjection(d3_geo_transverseMercator); - }).raw = d3_geo_transverseMercator; - d3.geom = {}; - d3.svg = {}; - function d3_svg_line(projection) { - var x = d3_svg_lineX, y = d3_svg_lineY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; - function line(data) { - var segments = [], points = [], i = -1, n = data.length, d, fx = d3_functor(x), fy = d3_functor(y); - function segment() { - segments.push("M", interpolate(projection(points), tension)); - } - while (++i < n) { - if (defined.call(this, d = data[i], i)) { - points.push([ +fx.call(this, d, i), +fy.call(this, d, i) ]); - } else if (points.length) { - segment(); - points = []; - } - } - if (points.length) segment(); - return segments.length ? segments.join("") : null; - } - line.x = function(_) { - if (!arguments.length) return x; - x = _; - return line; - }; - line.y = function(_) { - if (!arguments.length) return y; - y = _; - return line; - }; - line.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return line; - }; - line.interpolate = function(_) { - if (!arguments.length) return interpolateKey; - if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; - return line; - }; - line.tension = function(_) { - if (!arguments.length) return tension; - tension = _; - return line; - }; - return line; - } - d3.svg.line = function() { - return d3_svg_line(d3_identity); - }; - function d3_svg_lineX(d) { - return d[0]; - } - function d3_svg_lineY(d) { - return d[1]; - } - var d3_svg_lineInterpolators = d3.map({ - linear: d3_svg_lineLinear, - "linear-closed": d3_svg_lineLinearClosed, - "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 - }); - d3_svg_lineInterpolators.forEach(function(key, value) { - value.key = key; - value.closed = /-closed$/.test(key); - }); - function d3_svg_lineLinear(points) { - return points.join("L"); - } - function d3_svg_lineLinearClosed(points) { - return d3_svg_lineLinear(points) + "Z"; - } - 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(""); - } - 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(""); - } - 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)); - } - 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)); - } - function d3_svg_lineCardinal(points, tension) { - return points.length < 3 ? d3_svg_lineLinear(points) : points[0] + d3_svg_lineHermite(points, d3_svg_lineCardinalTangents(points, tension)); - } - 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; - } - 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; - } - 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(""); - } - 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(""); - } - 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; - if (n) { - var 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); - } - function d3_svg_lineDot4(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2] + a[3] * b[3]; - } - 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 ]; - 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)); - } - function d3_svg_lineSlope(p0, p1) { - return (p1[1] - p0[1]) / (p1[0] - p0[0]); - } - 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]))) / 2; - } - m[i] = d; - return m; - } - function d3_svg_lineMonotoneTangents(points) { - var tangents = [], d, a, b, s, m = d3_svg_lineFiniteDifferences(points), i = -1, j = points.length - 1; - while (++i < j) { - d = d3_svg_lineSlope(points[i], points[i + 1]); - if (Math.abs(d) < 1e-6) { - m[i] = m[i + 1] = 0; - } else { - a = m[i] / d; - b = m[i + 1] / d; - s = a * a + b * b; - if (s > 9) { - s = d * 3 / Math.sqrt(s); - m[i] = s * a; - m[i + 1] = s * b; - } - } - } - 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.geom.hull = function(vertices) { - var x = d3_svg_lineX, y = d3_svg_lineY; - if (arguments.length) return hull(vertices); - function hull(data) { - if (data.length < 3) return []; - var fx = d3_functor(x), fy = d3_functor(y), n = data.length, vertices, plen = n - 1, points = [], stack = [], d, i, j, h = 0, x1, y1, x2, y2, u, v, a, sp; - if (fx === d3_svg_lineX && y === d3_svg_lineY) vertices = data; else for (i = 0, - vertices = []; i < n; ++i) { - vertices.push([ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]); - } - for (i = 1; i < n; ++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; - } - } - for (i = 0; i < n; ++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; - }); - 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) { - 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; - } - } - 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; - for (;j < plen; ++j) { - if (points[j].index === -1) continue; - while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) { - --sp; - } - stack[sp++] = points[j].index; - } - var poly = []; - for (i = 0; i < sp; ++i) { - poly.push(data[stack[i]]); - } - return poly; - } - hull.x = function(_) { - return arguments.length ? (x = _, hull) : x; - }; - hull.y = function(_) { - return arguments.length ? (y = _, hull) : y; - }; - return hull; - }; - 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; - } - d3.geom.polygon = function(coordinates) { - coordinates.area = function() { - var i = 0, n = coordinates.length, area = coordinates[n - 1][1] * coordinates[0][0] - coordinates[n - 1][0] * coordinates[0][1]; - while (++i < n) { - area += coordinates[i - 1][1] * coordinates[i][0] - coordinates[i - 1][0] * coordinates[i][1]; - } - return area * .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 ]; - }; - 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]); - } - function d3_geom_polygonIntersect(c, d, a, b) { - var x1 = c[0], x3 = a[0], x21 = d[0] - x1, x43 = b[0] - x3, y1 = c[1], y3 = a[1], y21 = d[1] - y1, y43 = b[1] - y3, ua = (x43 * (y1 - y3) - y43 * (x1 - x3)) / (y43 * x21 - x43 * y21); - return [ x1 + ua * x21, y1 + ua * y21 ]; - } - d3.geom.delaunay = function(vertices) { - var edges = vertices.map(function() { - return []; - }), triangles = []; - d3_geom_voronoiTessellate(vertices, function(e) { - edges[e.region.l.index].push(vertices[e.region.r.index]); - }); - 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; - }; - d3.geom.voronoi = function(points) { - var size = null, x = d3_svg_lineX, y = d3_svg_lineY, clip; - if (arguments.length) return voronoi(points); - function voronoi(data) { - var points, polygons = data.map(function() { - return []; - }), fx = d3_functor(x), fy = d3_functor(y), d, i, n = data.length, Z = 1e6; - if (fx === d3_svg_lineX && fy === d3_svg_lineY) points = data; else for (points = [], - i = 0; i < n; ++i) { - points.push([ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]); - } - d3_geom_voronoiTessellate(points, 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 : -Z; - x1 = e.c - e.b * y1; - y2 = s2 ? s2.y : Z; - x2 = e.c - e.b * y2; - } else { - x1 = s1 ? s1.x : -Z; - y1 = e.c - e.a * x1; - x2 = s2 ? s2.x : Z; - 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); - }); - polygons = polygons.map(function(polygon, i) { - var cx = points[i][0], cy = points[i][1], angle = polygon.map(function(v) { - return Math.atan2(v[0] - cx, v[1] - cy); - }), order = d3.range(polygon.length).sort(function(a, b) { - return angle[a] - angle[b]; - }); - return order.filter(function(d, i) { - return !i || angle[d] - angle[order[i - 1]] > ε; - }).map(function(d) { - return polygon[d]; - }); - }); - polygons.forEach(function(polygon, i) { - var n = polygon.length; - if (!n) return polygon.push([ -Z, -Z ], [ -Z, Z ], [ Z, Z ], [ Z, -Z ]); - if (n > 2) return; - var p0 = points[i], p1 = polygon[0], p2 = polygon[1], x0 = p0[0], y0 = p0[1], x1 = p1[0], y1 = p1[1], x2 = p2[0], y2 = p2[1], dx = Math.abs(x2 - x1), dy = y2 - y1; - if (Math.abs(dy) < ε) { - var y = y0 < y1 ? -Z : Z; - polygon.push([ -Z, y ], [ Z, y ]); - } else if (dx < ε) { - var x = x0 < x1 ? -Z : Z; - polygon.push([ x, -Z ], [ x, Z ]); - } else { - var y = (x2 - x1) * (y1 - y0) < (x1 - x0) * (y2 - y1) ? Z : -Z, z = Math.abs(dy) - dx; - if (Math.abs(z) < ε) { - polygon.push([ dy < 0 ? y : -y, y ]); - } else { - if (z > 0) y *= -1; - polygon.push([ -Z, y ], [ Z, y ]); - } - } - }); - if (clip) for (i = 0; i < n; ++i) clip(polygons[i]); - for (i = 0; i < n; ++i) polygons[i].point = data[i]; - return polygons; - } - voronoi.x = function(_) { - return arguments.length ? (x = _, voronoi) : x; - }; - voronoi.y = function(_) { - return arguments.length ? (y = _, voronoi) : y; - }; - voronoi.size = function(_) { - if (!arguments.length) return size; - if (_ == null) { - clip = null; - } else { - size = [ +_[0], +_[1] ]; - clip = d3.geom.polygon([ [ 0, 0 ], [ 0, size[1] ], size, [ size[0], 0 ] ]).clip; - } - return voronoi; - }; - voronoi.links = function(data) { - var points, graph = data.map(function() { - return []; - }), links = [], fx = d3_functor(x), fy = d3_functor(y), d, i, n = data.length; - if (fx === d3_svg_lineX && fy === d3_svg_lineY) points = data; else for (i = 0; i < n; ++i) { - points.push([ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]); - } - d3_geom_voronoiTessellate(points, function(e) { - var l = e.region.l.index, r = e.region.r.index; - if (graph[l][r]) return; - graph[l][r] = graph[r][l] = true; - links.push({ - source: data[l], - target: data[r] - }); - }); - return links; - }; - voronoi.triangles = function(data) { - if (x === d3_svg_lineX && y === d3_svg_lineY) return d3.geom.delaunay(data); - var points, point, fx = d3_functor(x), fy = d3_functor(y), d, i, n; - for (i = 0, points = [], n = data.length; i < n; ++i) { - point = [ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]; - point.data = d; - points.push(point); - } - return d3.geom.delaunay(points).map(function(triangle) { - return triangle.map(function(point) { - return point.data; - }); - }); - }; - return voronoi; - }; - var d3_geom_voronoiOpposite = { - l: "r", - r: "l" - }; - function d3_geom_voronoiTessellate(points, callback) { - var Sites = { - list: points.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_geom_voronoiOpposite[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 { - 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_geom_voronoiOpposite[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)) { - 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()) { - 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_geom_voronoiOpposite[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; - } - } - for (lbnd = EdgeList.right(EdgeList.leftEnd); lbnd != EdgeList.rightEnd; lbnd = EdgeList.right(lbnd)) { - callback(lbnd.edge); - } - } - d3.geom.quadtree = function(points, x1, y1, x2, y2) { - var x = d3_svg_lineX, y = d3_svg_lineY, compat; - if (compat = arguments.length) { - x = d3_geom_quadtreeCompatX; - y = d3_geom_quadtreeCompatY; - if (compat === 3) { - y2 = y1; - x2 = x1; - y1 = x1 = 0; - } - return quadtree(points); - } - function quadtree(data) { - var d, fx = d3_functor(x), fy = d3_functor(y), xs, ys, i, n, x1_, y1_, x2_, y2_; - if (x1 != null) { - x1_ = x1, y1_ = y1, x2_ = x2, y2_ = y2; - } else { - x2_ = y2_ = -(x1_ = y1_ = Infinity); - xs = [], ys = []; - n = data.length; - if (compat) for (i = 0; i < n; ++i) { - d = data[i]; - if (d.x < x1_) x1_ = d.x; - if (d.y < y1_) y1_ = d.y; - if (d.x > x2_) x2_ = d.x; - if (d.y > y2_) y2_ = d.y; - xs.push(d.x); - ys.push(d.y); - } else for (i = 0; i < n; ++i) { - var x_ = +fx(d = data[i], i), y_ = +fy(d, i); - if (x_ < x1_) x1_ = x_; - if (y_ < y1_) y1_ = y_; - if (x_ > x2_) x2_ = x_; - if (y_ > y2_) y2_ = y_; - xs.push(x_); - ys.push(y_); - } - } - var dx = x2_ - x1_, dy = y2_ - y1_; - if (dx > dy) y2_ = y1_ + dx; else x2_ = x1_ + dy; - function insert(n, d, x, y, x1, y1, x2, y2) { - if (isNaN(x) || isNaN(y)) return; - if (n.leaf) { - var nx = n.x, ny = n.y; - if (nx != null) { - if (Math.abs(nx - x) + Math.abs(ny - y) < .01) { - insertChild(n, d, x, y, x1, y1, x2, y2); - } else { - var nPoint = n.point; - n.x = n.y = n.point = null; - insertChild(n, nPoint, nx, ny, x1, y1, x2, y2); - insertChild(n, d, x, y, x1, y1, x2, y2); - } - } else { - n.x = x, n.y = y, n.point = d; - } - } else { - insertChild(n, d, x, y, x1, y1, x2, y2); - } - } - function insertChild(n, d, x, y, x1, y1, x2, y2) { - var sx = (x1 + x2) * .5, sy = (y1 + y2) * .5, right = x >= sx, bottom = y >= sy, i = (bottom << 1) + right; - n.leaf = false; - n = n.nodes[i] || (n.nodes[i] = d3_geom_quadtreeNode()); - if (right) x1 = sx; else x2 = sx; - if (bottom) y1 = sy; else y2 = sy; - insert(n, d, x, y, x1, y1, x2, y2); - } - var root = d3_geom_quadtreeNode(); - root.add = function(d) { - insert(root, d, +fx(d, ++i), +fy(d, i), x1_, y1_, x2_, y2_); - }; - root.visit = function(f) { - d3_geom_quadtreeVisit(f, root, x1_, y1_, x2_, y2_); - }; - i = -1; - if (x1 == null) { - while (++i < n) { - insert(root, data[i], xs[i], ys[i], x1_, y1_, x2_, y2_); - } - --i; - } else data.forEach(root.add); - xs = ys = data = d = null; - return root; - } - quadtree.x = function(_) { - return arguments.length ? (x = _, quadtree) : x; - }; - quadtree.y = function(_) { - return arguments.length ? (y = _, quadtree) : y; - }; - quadtree.size = function(_) { - if (!arguments.length) return x1 == null ? null : [ x2, y2 ]; - if (_ == null) { - x1 = y1 = x2 = y2 = null; - } else { - x1 = y1 = 0; - x2 = +_[0], y2 = +_[1]; - } - return quadtree; - }; - return quadtree; - }; - function d3_geom_quadtreeCompatX(d) { - return d.x; - } - function d3_geom_quadtreeCompatY(d) { - return d.y; - } - function d3_geom_quadtreeNode() { - return { - leaf: true, - nodes: [], - point: null, - x: null, - y: 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); - } - } - d3.interpolateRgb = d3_interpolateRgb; - function d3_interpolateRgb(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)); - }; - } - d3.transform = function(string) { - var g = d3_document.createElementNS(d3.ns.prefix.svg, "g"); - return (d3.transform = function(string) { - g.setAttribute("transform", string); - var t = g.transform.baseVal.consolidate(); - return new d3_transform(t ? t.matrix : d3_transformIdentity); - })(string); - }; - 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_degrees; - this.translate = [ m.e, m.f ]; - this.scale = [ kx, ky ]; - this.skew = ky ? Math.atan2(kz, ky) * d3_degrees : 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_transformIdentity = { - a: 1, - b: 0, - c: 0, - d: 1, - e: 0, - f: 0 - }; - d3.interpolateNumber = d3_interpolateNumber; - function d3_interpolateNumber(a, b) { - b -= a = +a; - return function(t) { - return a + b * t; - }; - } - d3.interpolateTransform = d3_interpolateTransform; - function d3_interpolateTransform(a, b) { - var s = [], q = [], 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) { - if (ra - rb > 180) rb += 360; else if (rb - ra > 180) ra += 360; - 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.interpolateObject = d3_interpolateObject; - function d3_interpolateObject(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; - }; - } - d3.interpolateString = d3_interpolateString; - function d3_interpolateString(a, b) { - var m, i, j, s0 = 0, s1 = 0, s = [], q = [], n, o; - a = a + "", b = b + ""; - d3_interpolate_number.lastIndex = 0; - 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)); - for (i = 0, n = q.length; (m = d3_interpolate_number.exec(a)) && i < n; ++i) { - o = q[i]; - if (o.x == m[0]) { - if (o.i) { - if (s[o.i + 1] == null) { - s[o.i - 1] += o.x; - s.splice(o.i, 1); - for (j = i + 1; j < n; ++j) q[j].i--; - } else { - 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) { - s[o.i] = o.x; - } else { - 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)); - } - } - while (i < n) { - o = q.pop(); - if (s[o.i + 1] == null) { - s[o.i] = o.x; - } else { - s[o.i] = o.x + s[o.i + 1]; - s.splice(o.i + 1, 1); - } - n--; - } - if (s.length === 1) { - return s[0] == null ? q[0].x : function() { - return b; - }; - } - return function(t) { - for (i = 0; i < n; ++i) s[(o = q[i]).i] = o.x(t); - return s.join(""); - }; - } - var d3_interpolate_number = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g; - d3.interpolate = d3_interpolate; - function d3_interpolate(a, b) { - var i = d3.interpolators.length, f; - while (--i >= 0 && !(f = d3.interpolators[i](a, b))) ; - return f; - } - function d3_interpolateByName(name) { - return name == "transform" ? d3_interpolateTransform : d3_interpolate; - } - d3.interpolators = [ function(a, b) { - var t = typeof b; - return (t === "string" || t !== typeof a ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) ? d3_interpolateRgb : d3_interpolateString : b instanceof d3_Color ? d3_interpolateRgb : t === "object" ? Array.isArray(b) ? d3_interpolateArray : d3_interpolateObject : d3_interpolateNumber)(a, b); - } ]; - d3.interpolateArray = d3_interpolateArray; - function d3_interpolateArray(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; - }; - } - var d3_ease_default = function() { - return d3_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_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_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_quad(t) { - return t * t; - } - function d3_ease_cubic(t) { - return t * t * t; - } - function d3_ease_cubicInOut(t) { - if (t <= 0) return 0; - if (t >= 1) return 1; - var t2 = t * t, t3 = t2 * t; - return 4 * (t < .5 ? t3 : 3 * (t - t2) + t3 - .75); - } - function d3_ease_poly(e) { - return function(t) { - return Math.pow(t, e); - }; - } - function d3_ease_sin(t) { - return 1 - Math.cos(t * π / 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 = .45; - if (arguments.length) s = p / (2 * π) * Math.asin(1 / a); else a = 1, s = p / 4; - return function(t) { - return 1 + a * Math.pow(2, 10 * -t) * Math.sin((t - s) * 2 * π / 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.interpolateHcl = d3_interpolateHcl; - function d3_interpolateHcl(a, b) { - a = d3.hcl(a); - b = d3.hcl(b); - var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al; - if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; - return function(t) { - return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + ""; - }; - } - d3.interpolateHsl = d3_interpolateHsl; - function d3_interpolateHsl(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; - if (h1 > 180) h1 -= 360; else if (h1 < -180) h1 += 360; - return function(t) { - return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t) + ""; - }; - } - d3.interpolateLab = d3_interpolateLab; - function d3_interpolateLab(a, b) { - a = d3.lab(a); - b = d3.lab(b); - var al = a.l, aa = a.a, ab = a.b, bl = b.l - al, ba = b.a - aa, bb = b.b - ab; - return function(t) { - return d3_lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + ""; - }; - } - d3.interpolateRound = d3_interpolateRound; - function d3_interpolateRound(a, b) { - b -= a; - return function(t) { - return Math.round(a + b * t); - }; - } - 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.layout = {}; - 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 = []; - 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; - } - if (sortGroups) { - groupIndex.sort(function(a, b) { - return sortGroups(groupSums[a], groupSums[b]); - }); - } - if (sortSubgroups) { - subgroupIndex.forEach(function(d, i) { - d.sort(function(a, b) { - return sortSubgroups(matrix[i][a], matrix[i][b]); - }); - }); - } - k = (2 * π - padding * n) / k; - 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[di] = { - index: di, - startAngle: x0, - endAngle: x, - value: (x - x0) / k - }; - x += padding; - } - 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; - }; - 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, nodes = [], links = [], distances, strengths, charges; - function repulse(node) { - return function(quad, x1, _, x2) { - if (quad.point !== node) { - var dx = quad.cx - node.x, dy = quad.cy - node.y, dn = 1 / Math.sqrt(dx * dx + dy * dy); - 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() { - if ((alpha *= .99) < .005) { - event.end({ - type: "end", - alpha: alpha = 0 - }); - return true; - } - var n = nodes.length, m = links.length, q, i, o, s, t, l, k, x, y; - 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; - } - } - 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; - } - } - 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)); - } - } - } - 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 = typeof x === "function" ? x : +x; - return force; - }; - force.distance = force.linkDistance; - force.linkStrength = function(x) { - if (!arguments.length) return linkStrength; - linkStrength = typeof x === "function" ? x : +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; - x = +x; - if (alpha) { - if (x > 0) alpha = x; else alpha = 0; - } else if (x > 0) { - 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; - } - 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]; - ++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; - } - distances = []; - if (typeof linkDistance === "function") for (i = 0; i < m; ++i) distances[i] = +linkDistance.call(this, links[i], i); else for (i = 0; i < m; ++i) distances[i] = linkDistance; - strengths = []; - if (typeof linkStrength === "function") for (i = 0; i < m; ++i) strengths[i] = +linkStrength.call(this, links[i], i); else for (i = 0; i < m; ++i) strengths[i] = linkStrength; - 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; - 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; - } - 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); - }; - force.drag = function() { - if (!drag) drag = d3.behavior.drag().origin(d3_identity).on("dragstart.force", d3_layout_forceDragstart).on("drag.force", dragmove).on("dragend.force", d3_layout_forceDragend); - if (!arguments.length) return drag; - this.on("mouseover.force", d3_layout_forceMouseover).on("mouseout.force", d3_layout_forceMouseout).call(drag); - }; - function dragmove(d) { - d.px = d3.event.x, d.py = d3.event.y; - force.resume(); - } - return d3.rebind(force, event, "on"); - }; - function d3_layout_forceDragstart(d) { - d.fixed |= 2; - } - function d3_layout_forceDragend(d) { - d.fixed &= ~6; - } - function d3_layout_forceMouseover(d) { - d.fixed |= 4; - d.px = d.x, d.py = d.y; - } - function d3_layout_forceMouseout(d) { - d.fixed &= ~4; - } - 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) { - 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; - } - var d3_layout_forceLinkDistance = 20, d3_layout_forceLinkStrength = 1; - d3.layout.hierarchy = function() { - var sort = d3_layout_hierarchySort, children = d3_layout_hierarchyChildren, value = d3_layout_hierarchyValue; - function recurse(node, depth, nodes) { - var childs = children.call(hierarchy, node, depth); - node.depth = depth; - nodes.push(node); - if (childs && (n = childs.length)) { - var i = -1, n, c = node.children = [], v = 0, j = depth + 1, d; - 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, node, depth) || 0; - } - return node; - } - 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, node, 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; - }; - hierarchy.revalue = function(root) { - revalue(root, 0); - return root; - }; - return hierarchy; - }; - function d3_layout_hierarchyRebind(object, hierarchy) { - d3.rebind(object, hierarchy, "sort", "children", "value"); - object.nodes = object; - object.links = d3_layout_hierarchyLinks; - 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; - } - function d3_layout_hierarchyLinks(nodes) { - return d3.merge(nodes.map(function(parent) { - return (parent.children || []).map(function(child) { - return { - source: parent, - target: child - }; - }); - })); - } - d3.layout.partition = function() { - var hierarchy = d3.layout.hierarchy(), size = [ 1, 1 ]; - 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 * π; - function pie(data) { - var values = data.map(function(d, i) { - return +value.call(pie, d, i); - }); - var a = +(typeof startAngle === "function" ? startAngle.apply(this, arguments) : startAngle); - var k = ((typeof endAngle === "function" ? endAngle.apply(this, arguments) : endAngle) - a) / d3.sum(values); - 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]); - }); - var arcs = []; - index.forEach(function(i) { - var d; - arcs[i] = { - data: data[i], - value: d = values[i], - startAngle: a, - endAngle: a += d * k - }; - }); - return arcs; - } - pie.value = function(x) { - if (!arguments.length) return value; - value = x; - return pie; - }; - pie.sort = function(x) { - if (!arguments.length) return sort; - sort = x; - return pie; - }; - pie.startAngle = function(x) { - if (!arguments.length) return startAngle; - startAngle = x; - return pie; - }; - pie.endAngle = function(x) { - if (!arguments.length) return endAngle; - endAngle = x; - return pie; - }; - return pie; - }; - var d3_layout_pieSortByValue = {}; - d3.layout.stack = function() { - var values = d3_identity, order = d3_layout_stackOrderDefault, offset = d3_layout_stackOffsetZero, out = d3_layout_stackOut, x = d3_layout_stackX, y = d3_layout_stackY; - function stack(data, index) { - var series = data.map(function(d, i) { - return values.call(stack, d, i); - }); - var points = series.map(function(d) { - return d.map(function(v, i) { - return [ x.call(stack, v, i), y.call(stack, v, i) ]; - }); - }); - var orders = order.call(stack, points, index); - series = d3.permute(series, orders); - points = d3.permute(points, orders); - var offsets = offset.call(stack, points, index); - 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, 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; - while (++i < m) { - bin = bins[i] = []; - bin.dx = thresholds[i + 1] - (bin.x = thresholds[i]); - bin.y = 0; - } - if (m > 0) { - 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; - } - histogram.value = function(x) { - if (!arguments.length) return valuer; - valuer = x; - return histogram; - }; - histogram.range = function(x) { - if (!arguments.length) return ranger; - ranger = d3_functor(x); - return histogram; - }; - 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; - }; - 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.tree = function() { - var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ]; - 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; - } - 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 - }; - }); - firstWalk(root); - secondWalk(root, -root._tree.prelim); - 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; - 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_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; - } - d3.layout.pack = function() { - var hierarchy = d3.layout.hierarchy().sort(d3_layout_packSort), padding = 0, size = [ 1, 1 ]; - function pack(d, i) { - var nodes = hierarchy.call(this, d, i), root = nodes[0]; - root.x = 0; - root.y = 0; - d3_layout_treeVisitAfter(root, function(d) { - d.r = Math.sqrt(d.value); - }); - d3_layout_treeVisitAfter(root, d3_layout_packSiblings); - var w = size[0], h = size[1], k = Math.max(2 * root.r / w, 2 * root.r / h); - if (padding > 0) { - var dr = padding * k / 2; - d3_layout_treeVisitAfter(root, function(d) { - d.r += dr; - }); - d3_layout_treeVisitAfter(root, d3_layout_packSiblings); - d3_layout_treeVisitAfter(root, function(d) { - d.r -= dr; - }); - k = Math.max(2 * root.r / w, 2 * root.r / h); - } - d3_layout_packTransform(root, w / 2, h / 2, 1 / k); - return nodes; - } - pack.size = function(x) { - if (!arguments.length) return size; - size = x; - return pack; - }; - pack.padding = function(_) { - if (!arguments.length) return padding; - padding = +_; - 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; - } - function d3_layout_packSiblings(node) { - if (!(nodes = node.children) || !(n = nodes.length)) return; - var nodes, xMin = Infinity, xMax = -Infinity, yMin = Infinity, yMax = -Infinity, a, b, c, i, j, k, n; - 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); - } - nodes.forEach(d3_layout_packLink); - a = nodes[0]; - a.x = -a.r; - a.y = 0; - bound(a); - if (n > 1) { - b = nodes[1]; - b.x = b.r; - b.y = 0; - bound(b); - 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; - for (i = 3; i < n; i++) { - d3_layout_packPlace(a, b, c = nodes[i]); - 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; - } - } - } - 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); - } - } - } - } - var cx = (xMin + xMax) / 2, cy = (yMin + yMax) / 2, cr = 0; - for (i = 0; i < n; i++) { - c = nodes[i]; - c.x -= cx; - c.y -= cy; - cr = Math.max(cr, c.r + Math.sqrt(c.x * c.x + c.y * c.y)); - } - node.r = cr; - nodes.forEach(d3_layout_packUnlink); - } - 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_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 = dx * dx + dy * dy; - da *= da; - db *= db; - var x = .5 + (db - da) / (2 * dc), y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); - 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; - } - } - d3.layout.cluster = function() { - var hierarchy = d3.layout.hierarchy().sort(null).value(null), separation = d3_layout_treeSeparation, size = [ 1, 1 ]; - function cluster(d, i) { - var nodes = hierarchy.call(this, d, i), root = nodes[0], previousNode, x = 0; - 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; - } - }); - 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; - 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; - } - d3.layout.treemap = function() { - var hierarchy = d3.layout.hierarchy(), round = Math.round, size = [ 1, 1 ], padding = null, pad = d3_layout_treemapPadNull, sticky = false, stickies, mode = "squarify", ratio = .5 * (1 + Math.sqrt(5)); - 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; - } - } - function squarify(node) { - var children = node.children; - if (children && children.length) { - var rect = pad(node), row = [], remaining = children.slice(), child, best = Infinity, score, u = mode === "slice" ? rect.dx : mode === "dice" ? rect.dy : mode === "slice-dice" ? node.depth & 1 ? rect.dy : rect.dx : Math.min(rect.dx, rect.dy), 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 (mode !== "squarify" || (score = worst(row, u)) <= best) { - remaining.pop(); - best = score; - } else { - 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); - } - } - function stickify(node) { - var children = node.children; - if (children && children.length) { - var rect = pad(node), remaining = children.slice(), 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); - } - } - 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; - } - 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) { - if (flush || v > rect.dy) v = rect.dy; - 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; - rect.y += v; - rect.dy -= v; - } else { - if (flush || v > rect.dx) v = rect.dx; - 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; - 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; - }; - treemap.mode = function(x) { - if (!arguments.length) return mode; - mode = 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.random = { - normal: function(µ, σ) { - var n = arguments.length; - if (n < 2) σ = 1; - if (n < 1) µ = 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 µ + σ * x * Math.sqrt(-2 * Math.log(r) / r); - }; - }, - logNormal: function() { - var random = d3.random.normal.apply(d3, arguments); - return function() { - return Math.exp(random()); - }; - }, - irwinHall: function(m) { - return function() { - for (var s = 0, j = 0; j < m; j++) s += Math.random(); - return s / m; - }; - } - }; - 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_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_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 (nice = nice(x1 - x0)) { - domain[i0] = nice.floor(x0); - domain[i1] = nice.ceil(x1); - } - return domain; - } - function d3_scale_polylinear(domain, range, uninterpolate, interpolate) { - var u = [], i = [], j = 0, k = Math.min(domain.length, range.length) - 1; - 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.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); - } - 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, format) { - return d3_scale_linearTickFormat(domain, m, format); - }; - 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 dx && { - 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; - if (err <= .15) step *= 10; else if (err <= .35) step *= 5; else if (err <= .75) step *= 2; - extent[0] = Math.ceil(extent[0] / step) * step; - extent[1] = Math.floor(extent[1] / step) * step + step * .5; - 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, format) { - var precision = -Math.floor(Math.log(d3_scale_linearTickRange(domain, m)[2]) / Math.LN10 + .01); - return d3.format(format ? format.replace(d3_format_re, function(a, b, c, d, e, f, g, h, i, j) { - return [ b, c, d, e, f, g, h, i || "." + (precision - (j === "%") * 2), j ].join(""); - }) : ",." + precision + "f"); - } - d3.scale.log = function() { - return d3_scale_log(d3.scale.linear().domain([ 0, Math.LN10 ]), 10, d3_scale_logp, d3_scale_powp); - }; - function d3_scale_log(linear, base, 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); - if (x[0] < 0) log = d3_scale_logn, pow = d3_scale_pown; else log = d3_scale_logp, - pow = d3_scale_powp; - linear.domain(x.map(log)); - return scale; - }; - scale.base = function(_) { - if (!arguments.length) return base; - base = +_; - return scale; - }; - scale.nice = function() { - linear.domain(d3_scale_nice(linear.domain(), d3_scale_logNice(base))); - return scale; - }; - scale.ticks = function() { - var extent = d3_scaleExtent(linear.domain()), ticks = []; - if (extent.every(isFinite)) { - var b = Math.log(base), i = Math.floor(extent[0] / b), j = Math.ceil(extent[1] / b), u = pow(extent[0]), v = pow(extent[1]), n = base % 1 ? 2 : base; - if (log === d3_scale_logn) { - ticks.push(-Math.pow(base, -i)); - for (;i++ < j; ) for (var k = n - 1; k > 0; k--) ticks.push(-Math.pow(base, -i) * k); - } else { - for (;i < j; i++) for (var k = 1; k < n; k++) ticks.push(Math.pow(base, i) * k); - ticks.push(Math.pow(base, i)); - } - for (i = 0; ticks[i] < u; i++) {} - for (j = ticks.length; ticks[j - 1] > v; j--) {} - ticks = ticks.slice(i, j); - } - return ticks; - }; - scale.tickFormat = function(n, format) { - if (arguments.length < 2) format = d3_scale_logFormat; - if (!arguments.length) return format; - var b = Math.log(base), k = Math.max(.1, 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(b * f(log(d) / b + e)) <= k ? format(d) : ""; - }; - }; - scale.copy = function() { - return d3_scale_log(linear.copy(), base, log, pow); - }; - 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); - } - function d3_scale_powp(x) { - return Math.exp(x); - } - function d3_scale_logn(x) { - return -Math.log(x > 0 ? 0 : -x); - } - function d3_scale_pown(x) { - return -Math.exp(-x); - } - function d3_scale_logNice(base) { - base = Math.log(base); - var nice = { - floor: function(x) { - return Math.floor(x / base) * base; - }, - ceil: function(x) { - return Math.ceil(x / base) * base; - } - }; - return function() { - return nice; - }; - } - 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, format) { - return d3_scale_linearTickFormat(scale.domain(), m, format); - }; - 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", - a: [ [] ] - }); - }; - 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].apply(scale, ranger.a); - }; - scale.range = function(x) { - if (!arguments.length) return range; - range = x; - rangeBand = 0; - ranger = { - t: "range", - a: arguments - }; - return scale; - }; - scale.rangePoints = function(x, padding) { - if (arguments.length < 2) padding = 0; - var start = x[0], stop = x[1], step = (stop - start) / (Math.max(1, domain.length - 1) + padding); - range = steps(domain.length < 2 ? (start + stop) / 2 : start + step * padding / 2, step); - rangeBand = 0; - ranger = { - t: "rangePoints", - a: arguments - }; - return scale; - }; - scale.rangeBands = function(x, padding, outerPadding) { - if (arguments.length < 2) padding = 0; - if (arguments.length < 3) outerPadding = padding; - var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = (stop - start) / (domain.length - padding + 2 * outerPadding); - range = steps(start + step * outerPadding, step); - if (reverse) range.reverse(); - rangeBand = step * (1 - padding); - ranger = { - t: "rangeBands", - a: arguments - }; - return scale; - }; - scale.rangeRoundBands = function(x, padding, outerPadding) { - if (arguments.length < 2) padding = 0; - if (arguments.length < 3) outerPadding = padding; - var reverse = x[1] < x[0], start = x[reverse - 0], stop = x[1 - reverse], step = Math.floor((stop - start) / (domain.length - padding + 2 * outerPadding)), 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", - a: arguments - }; - return scale; - }; - scale.rangeBand = function() { - return rangeBand; - }; - scale.rangeExtent = function() { - return d3_scaleExtent(ranger.a[0]); - }; - scale.copy = function() { - return d3_scale_ordinal(domain, ranger); - }; - return scale.domain(domain); - } - 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, 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); - }; - 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); - }; - return rescale(); - } - d3.scale.threshold = function() { - return d3_scale_threshold([ .5 ], [ 0, 1 ]); - }; - function d3_scale_threshold(domain, range) { - function scale(x) { - return range[d3.bisect(domain, x)]; - } - scale.domain = function(_) { - if (!arguments.length) return domain; - domain = _; - return scale; - }; - scale.range = function(_) { - if (!arguments.length) return range; - range = _; - return scale; - }; - scale.copy = function() { - return d3_scale_threshold(domain, range); - }; - return scale; - } - 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, format) { - return d3_scale_linearTickFormat(domain, m, format); - }; - identity.copy = function() { - return d3_scale_identity(domain); - }; - return identity; - } - 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 < π ? "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 = -π / 2, d3_svg_arcMax = 2 * π - 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; - } - 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, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, interpolateReverse = interpolate, L = "L", tension = .7; - function area(data) { - var segments = [], points0 = [], points1 = [], i = -1, n = data.length, d, fx0 = d3_functor(x0), fy0 = d3_functor(y0), fx1 = x0 === x1 ? function() { - return x; - } : d3_functor(x1), fy1 = y0 === y1 ? function() { - return y; - } : d3_functor(y1), x, y; - function segment() { - segments.push("M", interpolate(projection(points1), tension), L, interpolateReverse(projection(points0.reverse()), tension), "Z"); - } - while (++i < n) { - if (defined.call(this, d = data[i], i)) { - points0.push([ x = +fx0.call(this, d, i), y = +fy0.call(this, d, i) ]); - points1.push([ +fx1.call(this, d, i), +fy1.call(this, d, i) ]); - } else if (points0.length) { - segment(); - points0 = []; - points1 = []; - } - } - if (points0.length) segment(); - return segments.length ? segments.join("") : null; - } - area.x = function(_) { - if (!arguments.length) return x1; - x0 = x1 = _; - return area; - }; - area.x0 = function(_) { - if (!arguments.length) return x0; - x0 = _; - return area; - }; - area.x1 = function(_) { - if (!arguments.length) return x1; - x1 = _; - return area; - }; - area.y = function(_) { - if (!arguments.length) return y1; - y0 = y1 = _; - return area; - }; - area.y0 = function(_) { - if (!arguments.length) return y0; - y0 = _; - return area; - }; - area.y1 = function(_) { - if (!arguments.length) return y1; - y1 = _; - return area; - }; - area.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return area; - }; - area.interpolate = function(_) { - if (!arguments.length) return interpolateKey; - if (typeof _ === "function") interpolateKey = interpolate = _; else interpolateKey = (interpolate = d3_svg_lineInterpolators.get(_) || d3_svg_lineLinear).key; - interpolateReverse = interpolate.reverse || interpolate; - L = interpolate.closed ? "M" : "L"; - return area; - }; - area.tension = function(_) { - if (!arguments.length) return tension; - tension = _; - return area; - }; - return area; - } - d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter; - d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore; - d3.svg.area = function() { - return d3_svg_area(d3_identity); - }; - 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_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; - 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 > π) + ",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_chordRadius(d) { - return d.radius; - } - d3.svg.diagonal = function() { - var source = d3_source, target = d3_target, 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.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; - }; - 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 / π); - return "M0," + r + "A" + r + "," + r + " 0 1,1 0," + -r + "A" + r + "," + r + " 0 1,1 0," + r + "Z"; - } - 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 * d3_radians); - function d3_transition(groups, id) { - d3_arraySubclass(groups, d3_transitionPrototype); - groups.id = id; - return groups; - } - var d3_transitionPrototype = [], d3_transitionId = 0, d3_transitionInheritId, d3_transitionInherit = { - ease: d3_ease_cubicInOut, - delay: 0, - duration: 250 - }; - d3_transitionPrototype.call = d3_selectionPrototype.call; - d3_transitionPrototype.empty = d3_selectionPrototype.empty; - d3_transitionPrototype.node = d3_selectionPrototype.node; - d3.transition = function(selection) { - return arguments.length ? d3_transitionInheritId ? selection.transition() : selection : d3_selectionRoot.transition(); - }; - d3.transition.prototype = d3_transitionPrototype; - d3_transitionPrototype.select = function(selector) { - var id = this.id, 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.__data__, i))) { - if ("__data__" in node) subnode.__data__ = node.__data__; - d3_transitionNode(subnode, i, id, node.__transition__[id]); - subgroup.push(subnode); - } else { - subgroup.push(null); - } - } - } - return d3_transition(subgroups, id); - }; - d3_transitionPrototype.selectAll = function(selector) { - var id = this.id, subgroups = [], subgroup, subnodes, node, subnode, transition; - 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]) { - transition = node.__transition__[id]; - subnodes = selector.call(node, node.__data__, i); - subgroups.push(subgroup = []); - for (var k = -1, o = subnodes.length; ++k < o; ) { - d3_transitionNode(subnode = subnodes[k], k, id, transition); - subgroup.push(subnode); - } - } - } - } - return d3_transition(subgroups, id); - }; - d3_transitionPrototype.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 = []); - for (var group = this[j], i = 0, n = group.length; i < n; i++) { - if ((node = group[i]) && filter.call(node, node.__data__, i)) { - subgroup.push(node); - } - } - } - return d3_transition(subgroups, this.id, this.time).ease(this.ease()); - }; - d3_transitionPrototype.tween = function(name, tween) { - var id = this.id; - if (arguments.length < 2) return this.node().__transition__[id].tween.get(name); - return d3_selection_each(this, tween == null ? function(node) { - node.__transition__[id].tween.remove(name); - } : function(node) { - node.__transition__[id].tween.set(name, tween); - }); - }; - function d3_transition_tween(groups, name, value, tween) { - var id = groups.id; - return d3_selection_each(groups, typeof value === "function" ? function(node, i, j) { - node.__transition__[id].tween.set(name, tween(value.call(node, node.__data__, i, j))); - } : (value = tween(value), function(node) { - node.__transition__[id].tween.set(name, value); - })); - } - d3_transitionPrototype.attr = function(nameNS, value) { - if (arguments.length < 2) { - for (value in nameNS) this.attr(value, nameNS[value]); - return this; - } - var interpolate = d3_interpolateByName(nameNS), name = d3.ns.qualify(nameNS); - function attrNull() { - this.removeAttribute(name); - } - function attrNullNS() { - this.removeAttributeNS(name.space, name.local); - } - return d3_transition_tween(this, "attr." + nameNS, value, function(b) { - function attrString() { - var a = this.getAttribute(name), i; - return a !== b && (i = interpolate(a, b), function(t) { - this.setAttribute(name, i(t)); - }); - } - function attrStringNS() { - var a = this.getAttributeNS(name.space, name.local), i; - return a !== b && (i = interpolate(a, b), function(t) { - this.setAttributeNS(name.space, name.local, i(t)); - }); - } - return b == null ? name.local ? attrNullNS : attrNull : (b += "", name.local ? attrStringNS : attrString); - }); - }; - 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 && 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 && 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) { - var n = arguments.length; - if (n < 3) { - if (typeof name !== "string") { - if (n < 2) value = ""; - for (priority in name) this.style(priority, name[priority], value); - return this; - } - priority = ""; - } - var interpolate = d3_interpolateByName(name); - function styleNull() { - this.style.removeProperty(name); - } - return d3_transition_tween(this, "style." + name, value, function(b) { - function styleString() { - var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i; - return a !== b && (i = interpolate(a, b), function(t) { - this.style.setProperty(name, i(t), priority); - }); - } - return b == null ? styleNull : (b += "", styleString); - }); - }; - 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, d3_window.getComputedStyle(this, null).getPropertyValue(name)); - return f && function(t) { - this.style.setProperty(name, f(t), priority); - }; - }); - }; - d3_transitionPrototype.text = function(value) { - return d3_transition_tween(this, "text", value, d3_transition_text); - }; - function d3_transition_text(b) { - if (b == null) b = ""; - return function() { - this.textContent = b; - }; - } - d3_transitionPrototype.remove = function() { - return this.each("end.transition", function() { - var p; - if (!this.__transition__ && (p = this.parentNode)) p.removeChild(this); - }); - }; - d3_transitionPrototype.ease = function(value) { - var id = this.id; - if (arguments.length < 1) return this.node().__transition__[id].ease; - if (typeof value !== "function") value = d3.ease.apply(d3, arguments); - return d3_selection_each(this, function(node) { - node.__transition__[id].ease = value; - }); - }; - d3_transitionPrototype.delay = function(value) { - var id = this.id; - return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node.__transition__[id].delay = value.call(node, node.__data__, i, j) | 0; - } : (value |= 0, function(node) { - node.__transition__[id].delay = value; - })); - }; - d3_transitionPrototype.duration = function(value) { - var id = this.id; - return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { - node.__transition__[id].duration = Math.max(1, value.call(node, node.__data__, i, j) | 0); - } : (value = Math.max(1, value | 0), function(node) { - node.__transition__[id].duration = value; - })); - }; - d3_transitionPrototype.each = function(type, listener) { - var id = this.id; - if (arguments.length < 2) { - var inherit = d3_transitionInherit, inheritId = d3_transitionInheritId; - d3_transitionInheritId = id; - d3_selection_each(this, function(node, i, j) { - d3_transitionInherit = node.__transition__[id]; - type.call(node, node.__data__, i, j); - }); - d3_transitionInherit = inherit; - d3_transitionInheritId = inheritId; - } else { - d3_selection_each(this, function(node) { - node.__transition__[id].event.on(type, listener); - }); - } - return this; - }; - d3_transitionPrototype.transition = function() { - var id0 = this.id, id1 = ++d3_transitionId, subgroups = [], subgroup, group, node, transition; - for (var j = 0, m = this.length; j < m; j++) { - subgroups.push(subgroup = []); - for (var group = this[j], i = 0, n = group.length; i < n; i++) { - if (node = group[i]) { - transition = Object.create(node.__transition__[id0]); - transition.delay += transition.duration; - d3_transitionNode(node, i, id1, transition); - } - subgroup.push(node); - } - } - return d3_transition(subgroups, id1); - }; - function d3_transitionNode(node, i, id, inherit) { - var lock = node.__transition__ || (node.__transition__ = { - active: 0, - count: 0 - }), transition = lock[id]; - if (!transition) { - var time = inherit.time; - transition = lock[id] = { - tween: new d3_Map(), - event: d3.dispatch("start", "end"), - time: time, - ease: inherit.ease, - delay: inherit.delay, - duration: inherit.duration - }; - ++lock.count; - d3.timer(function(elapsed) { - var d = node.__data__, ease = transition.ease, event = transition.event, delay = transition.delay, duration = transition.duration, tweened = []; - return delay <= elapsed ? start(elapsed) : d3.timer(start, delay, time), 1; - function start(elapsed) { - if (lock.active > id) return stop(); - lock.active = id; - event.start.call(node, d, i); - transition.tween.forEach(function(key, value) { - if (value = value.call(node, d, i)) { - tweened.push(value); - } - }); - 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(); - event.end.call(node, d, i); - return 1; - } - } - function stop() { - if (--lock.count) delete lock[id]; else delete node.__transition__; - return 1; - } - }, 0, time); - return transition; - } - } - d3.svg.axis = function() { - var scale = d3.scale.linear(), orient = d3_svg_axisDefaultOrient, 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); - 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_; - var subticks = d3_svg_axisSubdivide(scale, ticks, tickSubdivide), subtick = g.selectAll(".tick.minor").data(subticks, String), subtickEnter = subtick.enter().insert("line", ".tick").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); - var tick = g.selectAll(".tick.major").data(ticks, String), tickEnter = tick.enter().insert("g", "path").attr("class", "tick major").style("opacity", 1e-6), tickExit = d3.transition(tick.exit()).style("opacity", 1e-6).remove(), tickUpdate = d3.transition(tick).style("opacity", 1), tickTransform; - var range = d3_scaleRange(scale), path = g.selectAll(".domain").data([ 0 ]), pathUpdate = (path.enter().append("path").attr("class", "domain"), - d3.transition(path)); - var scale1 = scale.copy(), scale0 = this.__chart__ || scale1; - this.__chart__ = scale1; - tickEnter.append("line"); - tickEnter.append("text"); - var lineEnter = tickEnter.select("line"), lineUpdate = tickUpdate.select("line"), text = tick.select("text").text(tickFormat), textEnter = tickEnter.select("text"), textUpdate = tickUpdate.select("text"); - switch (orient) { - case "bottom": - { - tickTransform = d3_svg_axisX; - subtickEnter.attr("y2", tickMinorSize); - subtickUpdate.attr("x2", 0).attr("y2", tickMinorSize); - lineEnter.attr("y2", tickMajorSize); - textEnter.attr("y", Math.max(tickMajorSize, 0) + tickPadding); - lineUpdate.attr("x2", 0).attr("y2", tickMajorSize); - textUpdate.attr("x", 0).attr("y", Math.max(tickMajorSize, 0) + tickPadding); - text.attr("dy", ".71em").style("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); - lineEnter.attr("y2", -tickMajorSize); - textEnter.attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); - lineUpdate.attr("x2", 0).attr("y2", -tickMajorSize); - textUpdate.attr("x", 0).attr("y", -(Math.max(tickMajorSize, 0) + tickPadding)); - text.attr("dy", "0em").style("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); - lineEnter.attr("x2", -tickMajorSize); - textEnter.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)); - lineUpdate.attr("x2", -tickMajorSize).attr("y2", 0); - textUpdate.attr("x", -(Math.max(tickMajorSize, 0) + tickPadding)).attr("y", 0); - text.attr("dy", ".32em").style("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); - lineEnter.attr("x2", tickMajorSize); - textEnter.attr("x", Math.max(tickMajorSize, 0) + tickPadding); - lineUpdate.attr("x2", tickMajorSize).attr("y2", 0); - textUpdate.attr("x", Math.max(tickMajorSize, 0) + tickPadding).attr("y", 0); - text.attr("dy", ".32em").style("text-anchor", "start"); - pathUpdate.attr("d", "M" + tickEndSize + "," + range[0] + "H0V" + range[1] + "H" + tickEndSize); - break; - } - } - 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); - } 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 in d3_svg_axisOrients ? x + "" : d3_svg_axisDefaultOrient; - 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) { - 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; - }; - var d3_svg_axisDefaultOrient = "bottom", d3_svg_axisOrients = { - top: 1, - right: 1, - bottom: 1, - left: 1 - }; - 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, y = null, resizes = d3_svg_brushResizes[0], extent = [ [ 0, 0 ], [ 0, 0 ] ], extentDomain; - 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; - g.style("pointer-events", "all").on("mousedown.brush", brushstart).on("touchstart.brush", brushstart); - bg.enter().append("rect").attr("class", "background").style("visibility", "hidden").style("cursor", "crosshair"); - fg.enter().append("rect").attr("class", "extent").style("cursor", "move"); - 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"); - tz.style("display", brush.empty() ? "none" : null); - tz.exit().remove(); - 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(d3_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 (dragging) { - origin[0] = extent[0][0] - origin[0]; - origin[1] = extent[0][1] - origin[1]; - } 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]; - } else if (d3.event.altKey) center = origin.slice(); - g.style("pointer-events", "none").selectAll(".resize").style("display", null); - d3.select("body").style("cursor", eventTarget.style("cursor")); - 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; - if (offset) { - point[0] += offset[0]; - point[1] += offset[1]; - } - if (!dragging) { - if (d3.event.altKey) { - if (!center) center = [ (extent[0][0] + extent[1][0]) / 2, (extent[0][1] + extent[1][1]) / 2 ]; - origin[0] = extent[+(point[0] < center[0])][0]; - origin[1] = extent[+(point[1] < center[1])][1]; - } else center = null; - } - if (resizingX && move1(point, x, 0)) { - redrawX(g); - moved = true; - } - if (resizingY && move1(point, y, 1)) { - redrawY(g); - moved = true; - } - 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; - if (dragging) { - r0 -= position; - r1 -= size + position; - } - min = Math.max(r0, Math.min(r1, point[i])); - if (dragging) { - max = (min += position) + size; - } else { - if (center) position = Math.max(r0, Math.min(r1, 2 * center[i] - min)); - if (position < min) { - max = min; - min = position; - } else { - max = position; - } - } - if (extent[0][i] !== min || extent[1][i] !== max) { - extentDomain = null; - extent[0][i] = min; - extent[1][i] = max; - return true; - } - } - function brushend() { - brushmove(); - 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]; - return brush; - }; - brush.y = function(z) { - if (!arguments.length) return y; - y = z; - resizes = d3_svg_brushResizes[!x << 1 | !y]; - return brush; - }; - brush.extent = function(z) { - var x0, x1, y0, y1, t; - 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 ]; - } - 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.time = {}; - var d3_time = Date, d3_time_daySymbols = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ]; - 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; - var d3_time_formatDateTime = "%a %b %e %X %Y", d3_time_formatDate = "%m/%d/%Y", d3_time_formatTime = "%H:%M:%S"; - var d3_time_days = [ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ], d3_time_dayAbbreviations = [ "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" ], d3_time_months = [ "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December" ], d3_time_monthAbbreviations = [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ]; - 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.year = d3_time_interval(function(date) { - date = d3.time.day(date); - date.setMonth(0, 1); - return date; - }, 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; - d3.time.day = d3_time_interval(function(date) { - var day = new d3_time(1970, 0); - day.setFullYear(date.getFullYear(), date.getMonth(), date.getDate()); - return day; - }, 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 - (date.getTimezoneOffset() - year.getTimezoneOffset()) * 6e4) / 864e5); - }; - d3_time_daySymbols.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.format = function(template) { - var n = template.length; - function format(date) { - var string = [], i = -1, j = 0, c, p, f; - while (++i < n) { - if (template.charCodeAt(i) === 37) { - string.push(template.substring(j, i)); - if ((p = d3_time_formatPads[c = template.charAt(++i)]) != null) c = template.charAt(++i); - if (f = d3_time_formats[c]) c = f(date, p == null ? c === "e" ? " " : "0" : p); - string.push(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; - 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; - } - function d3_time_formatRe(names) { - return new RegExp("^(?:" + names.map(d3.requote).join("|") + ")", "i"); - } - function d3_time_formatLookup(names) { - var map = new d3_Map(), i = -1, n = names.length; - while (++i < n) map.set(names[i].toLowerCase(), i); - return map; - } - function d3_time_formatPad(value, fill, width) { - value += ""; - var length = value.length; - return length < width ? new Array(width - length + 1).join(fill) + value : value; - } - var d3_time_dayRe = d3_time_formatRe(d3_time_days), d3_time_dayAbbrevRe = d3_time_formatRe(d3_time_dayAbbreviations), d3_time_monthRe = d3_time_formatRe(d3_time_months), d3_time_monthLookup = d3_time_formatLookup(d3_time_months), d3_time_monthAbbrevRe = d3_time_formatRe(d3_time_monthAbbreviations), d3_time_monthAbbrevLookup = d3_time_formatLookup(d3_time_monthAbbreviations); - var d3_time_formatPads = { - "-": "", - _: " ", - "0": "0" - }; - var d3_time_formats = { - a: function(d) { - return d3_time_dayAbbreviations[d.getDay()]; - }, - A: function(d) { - return d3_time_days[d.getDay()]; - }, - b: function(d) { - return d3_time_monthAbbreviations[d.getMonth()]; - }, - B: function(d) { - return d3_time_months[d.getMonth()]; - }, - c: d3.time.format(d3_time_formatDateTime), - d: function(d, p) { - return d3_time_formatPad(d.getDate(), p, 2); - }, - e: function(d, p) { - return d3_time_formatPad(d.getDate(), p, 2); - }, - H: function(d, p) { - return d3_time_formatPad(d.getHours(), p, 2); - }, - I: function(d, p) { - return d3_time_formatPad(d.getHours() % 12 || 12, p, 2); - }, - j: function(d, p) { - return d3_time_formatPad(1 + d3.time.dayOfYear(d), p, 3); - }, - L: function(d, p) { - return d3_time_formatPad(d.getMilliseconds(), p, 3); - }, - m: function(d, p) { - return d3_time_formatPad(d.getMonth() + 1, p, 2); - }, - M: function(d, p) { - return d3_time_formatPad(d.getMinutes(), p, 2); - }, - p: function(d) { - return d.getHours() >= 12 ? "PM" : "AM"; - }, - S: function(d, p) { - return d3_time_formatPad(d.getSeconds(), p, 2); - }, - U: function(d, p) { - return d3_time_formatPad(d3.time.sundayOfYear(d), p, 2); - }, - w: function(d) { - return d.getDay(); - }, - W: function(d, p) { - return d3_time_formatPad(d3.time.mondayOfYear(d), p, 2); - }, - x: d3.time.format(d3_time_formatDate), - X: d3.time.format(d3_time_formatTime), - y: function(d, p) { - return d3_time_formatPad(d.getFullYear() % 100, p, 2); - }, - Y: function(d, p) { - return d3_time_formatPad(d.getFullYear() % 1e4, p, 4); - }, - Z: d3_time_zone, - "%": function() { - 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, - L: d3_time_parseMilliseconds, - m: d3_time_parseMonthNumber, - M: d3_time_parseMinutes, - p: d3_time_parseAmPm, - S: d3_time_parseSeconds, - x: d3_time_parseLocaleDate, - X: d3_time_parseLocaleTime, - y: d3_time_parseYear, - Y: d3_time_parseFullYear - }; - function d3_time_parseWeekdayAbbrev(date, string, i) { - d3_time_dayAbbrevRe.lastIndex = 0; - var n = d3_time_dayAbbrevRe.exec(string.substring(i)); - return n ? i += n[0].length : -1; - } - function d3_time_parseWeekday(date, string, i) { - d3_time_dayRe.lastIndex = 0; - var n = d3_time_dayRe.exec(string.substring(i)); - return n ? i += n[0].length : -1; - } - function d3_time_parseMonthAbbrev(date, string, i) { - d3_time_monthAbbrevRe.lastIndex = 0; - var n = d3_time_monthAbbrevRe.exec(string.substring(i)); - return n ? (date.m = d3_time_monthAbbrevLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; - } - function d3_time_parseMonth(date, string, i) { - d3_time_monthRe.lastIndex = 0; - var n = d3_time_monthRe.exec(string.substring(i)); - return n ? (date.m = d3_time_monthLookup.get(n[0].toLowerCase()), i += n[0].length) : -1; - } - 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_expandYear(+n[0]), i += n[0].length) : -1; - } - function d3_time_expandYear(d) { - return d + (d > 68 ? 1900 : 2e3); - } - 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; - } - 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; - } - 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 - }); - 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_formatPad(zh, "0", 2) + d3_time_formatPad(zm, "0", 2); - } - 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 && +new Date("2000-01-01T00:00:00.000Z") ? d3_time_formatIsoNative : d3_time_formatIso; - function d3_time_formatIsoNative(date) { - return date.toISOString(); - } - d3_time_formatIsoNative.parse = function(string) { - var date = new Date(string); - return isNaN(date) ? null : date; - }; - d3_time_formatIsoNative.toString = d3_time_formatIso.toString; - 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); - }, 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); - }, 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); - }, function(date) { - return date.getHours(); - }); - d3.time.hours = d3.time.hour.range; - d3.time.hours.utc = d3.time.hour.utc.range; - d3.time.month = d3_time_interval(function(date) { - date = d3.time.day(date); - date.setDate(1); - return date; - }, 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; - 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) { - return scale.domain(d3_scale_nice(scale.domain(), function() { - return m; - })); - }; - 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); - }; - scale.tickFormat = function() { - return format; - }; - scale.copy = function() { - return d3_time_scale(linear.copy(), methods, format); - }; - return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp"); - } - 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); - 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, 5e3, 15e3, 3e4, 6e4, 3e5, 9e5, 18e5, 36e5, 108e5, 216e5, 432e5, 864e5, 1728e5, 6048e5, 2592e6, 7776e6, 31536e6 ]; - 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"), d3_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"), d3_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); - 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); - }; - d3.text = function() { - return d3.xhr.apply(d3, arguments).response(d3_text); - }; - function d3_text(request) { - return request.responseText; - } - d3.json = function(url, callback) { - return d3.xhr(url, "application/json", callback).response(d3_json); - }; - function d3_json(request) { - return JSON.parse(request.responseText); - } - d3.html = function(url, callback) { - return d3.xhr(url, "text/html", callback).response(d3_html); - }; - function d3_html(request) { - var range = d3_document.createRange(); - range.selectNode(d3_document.body); - return range.createContextualFragment(request.responseText); - } - d3.xml = function() { - return d3.xhr.apply(d3, arguments).response(d3_xml); - }; - function d3_xml(request) { - return request.responseXML; - } - return d3; -}(); \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/lib/fisheye.js b/awx/ui/static/lib/novus-nvd3/lib/fisheye.js deleted file mode 100755 index e1addd7b8b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/fisheye.js +++ /dev/null @@ -1,86 +0,0 @@ -(function() { - d3.fisheye = { - scale: function(scaleType) { - return d3_fisheye_scale(scaleType(), 3, 0); - }, - circular: function() { - var radius = 200, - distortion = 2, - k0, - k1, - focus = [0, 0]; - - function fisheye(d) { - var dx = d.x - focus[0], - dy = d.y - focus[1], - dd = Math.sqrt(dx * dx + dy * dy); - if (!dd || dd >= radius) return {x: d.x, y: d.y, z: 1}; - var k = k0 * (1 - Math.exp(-dd * k1)) / dd * .75 + .25; - return {x: focus[0] + dx * k, y: focus[1] + dy * k, z: Math.min(k, 10)}; - } - - function rescale() { - k0 = Math.exp(distortion); - k0 = k0 / (k0 - 1) * radius; - k1 = distortion / radius; - return fisheye; - } - - fisheye.radius = function(_) { - if (!arguments.length) return radius; - radius = +_; - return rescale(); - }; - - fisheye.distortion = function(_) { - if (!arguments.length) return distortion; - distortion = +_; - return rescale(); - }; - - fisheye.focus = function(_) { - if (!arguments.length) return focus; - focus = _; - return fisheye; - }; - - return rescale(); - } - }; - - function d3_fisheye_scale(scale, d, a) { - - function fisheye(_) { - var x = scale(_), - left = x < a, - v, - range = d3.extent(scale.range()), - min = range[0], - max = range[1], - m = left ? a - min : max - a; - if (m == 0) m = max - min; - return (left ? -1 : 1) * m * (d + 1) / (d + (m / Math.abs(x - a))) + a; - } - - fisheye.distortion = function(_) { - if (!arguments.length) return d; - d = +_; - return fisheye; - }; - - fisheye.focus = function(_) { - if (!arguments.length) return a; - a = +_; - return fisheye; - }; - - fisheye.copy = function() { - return d3_fisheye_scale(scale.copy(), d, a); - }; - - fisheye.nice = scale.nice; - fisheye.ticks = scale.ticks; - fisheye.tickFormat = scale.tickFormat; - return d3.rebind(fisheye, scale, "domain", "range"); - } -})(); diff --git a/awx/ui/static/lib/novus-nvd3/lib/hive.js b/awx/ui/static/lib/novus-nvd3/lib/hive.js deleted file mode 100755 index 06e53aed47..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/hive.js +++ /dev/null @@ -1,80 +0,0 @@ -d3.hive = {}; - -d3.hive.link = function() { - var source = function(d) { return d.source; }, - target = function(d) { return d.target; }, - angle = function(d) { return d.angle; }, - startRadius = function(d) { return d.radius; }, - endRadius = startRadius, - arcOffset = -Math.PI / 2; - - function link(d, i) { - var s = node(source, this, d, i), - t = node(target, this, d, i), - x; - if (t.a < s.a) x = t, t = s, s = x; - if (t.a - s.a > Math.PI) s.a += 2 * Math.PI; - var a1 = s.a + (t.a - s.a) / 3, - a2 = t.a - (t.a - s.a) / 3; - return s.r0 - s.r1 || t.r0 - t.r1 - ? "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0 - + "L" + Math.cos(s.a) * s.r1 + "," + Math.sin(s.a) * s.r1 - + "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1 - + " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1 - + " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1 - + "L" + Math.cos(t.a) * t.r0 + "," + Math.sin(t.a) * t.r0 - + "C" + Math.cos(a2) * t.r0 + "," + Math.sin(a2) * t.r0 - + " " + Math.cos(a1) * s.r0 + "," + Math.sin(a1) * s.r0 - + " " + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0 - : "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0 - + "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1 - + " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1 - + " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1; - } - - function node(method, thiz, d, i) { - var node = method.call(thiz, d, i), - a = +(typeof angle === "function" ? angle.call(thiz, node, i) : angle) + arcOffset, - r0 = +(typeof startRadius === "function" ? startRadius.call(thiz, node, i) : startRadius), - r1 = (startRadius === endRadius ? r0 : +(typeof endRadius === "function" ? endRadius.call(thiz, node, i) : endRadius)); - return {r0: r0, r1: r1, a: a}; - } - - link.source = function(_) { - if (!arguments.length) return source; - source = _; - return link; - }; - - link.target = function(_) { - if (!arguments.length) return target; - target = _; - return link; - }; - - link.angle = function(_) { - if (!arguments.length) return angle; - angle = _; - return link; - }; - - link.radius = function(_) { - if (!arguments.length) return startRadius; - startRadius = endRadius = _; - return link; - }; - - link.startRadius = function(_) { - if (!arguments.length) return startRadius; - startRadius = _; - return link; - }; - - link.endRadius = function(_) { - if (!arguments.length) return endRadius; - endRadius = _; - return link; - }; - - return link; -}; diff --git a/awx/ui/static/lib/novus-nvd3/lib/horizon.js b/awx/ui/static/lib/novus-nvd3/lib/horizon.js deleted file mode 100755 index d84c65679d..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/horizon.js +++ /dev/null @@ -1,192 +0,0 @@ -(function() { - d3.horizon = function() { - var bands = 1, // between 1 and 5, typically - mode = "offset", // or mirror - interpolate = "linear", // or basis, monotone, step-before, etc. - x = d3_horizonX, - y = d3_horizonY, - w = 960, - h = 40, - duration = 0; - - var color = d3.scale.linear() - .domain([-1, 0, 1]) - .range(["#d62728", "#fff", "#1f77b4"]); - - // For each small multiple… - function horizon(g) { - g.each(function(d, i) { - var g = d3.select(this), - n = 2 * bands + 1, - xMin = Infinity, - xMax = -Infinity, - yMax = -Infinity, - x0, // old x-scale - y0, // old y-scale - id; // unique id for paths - - // Compute x- and y-values along with extents. - var data = d.map(function(d, i) { - var xv = x.call(this, d, i), - yv = y.call(this, d, i); - if (xv < xMin) xMin = xv; - if (xv > xMax) xMax = xv; - if (-yv > yMax) yMax = -yv; - if (yv > yMax) yMax = yv; - return [xv, yv]; - }); - - // Compute the new x- and y-scales, and transform. - var x1 = d3.scale.linear().domain([xMin, xMax]).range([0, w]), - y1 = d3.scale.linear().domain([0, yMax]).range([0, h * bands]), - t1 = d3_horizonTransform(bands, h, mode); - - // Retrieve the old scales, if this is an update. - if (this.__chart__) { - x0 = this.__chart__.x; - y0 = this.__chart__.y; - t0 = this.__chart__.t; - id = this.__chart__.id; - } else { - x0 = x1.copy(); - y0 = y1.copy(); - t0 = t1; - id = ++d3_horizonId; - } - - // We'll use a defs to store the area path and the clip path. - var defs = g.selectAll("defs") - .data([null]); - - // The clip path is a simple rect. - defs.enter().append("defs").append("clipPath") - .attr("id", "d3_horizon_clip" + id) - .append("rect") - .attr("width", w) - .attr("height", h); - - defs.select("rect").transition() - .duration(duration) - .attr("width", w) - .attr("height", h); - - // We'll use a container to clip all horizon layers at once. - g.selectAll("g") - .data([null]) - .enter().append("g") - .attr("clip-path", "url(#d3_horizon_clip" + id + ")"); - - // Instantiate each copy of the path with different transforms. - var path = g.select("g").selectAll("path") - .data(d3.range(-1, -bands - 1, -1).concat(d3.range(1, bands + 1)), Number); - - var d0 = d3_horizonArea - .interpolate(interpolate) - .x(function(d) { return x0(d[0]); }) - .y0(h * bands) - .y1(function(d) { return h * bands - y0(d[1]); }) - (data); - - var d1 = d3_horizonArea - .x(function(d) { return x1(d[0]); }) - .y1(function(d) { return h * bands - y1(d[1]); }) - (data); - - path.enter().append("path") - .style("fill", color) - .attr("transform", t0) - .attr("d", d0); - - path.transition() - .duration(duration) - .style("fill", color) - .attr("transform", t1) - .attr("d", d1); - - path.exit().transition() - .duration(duration) - .attr("transform", t1) - .attr("d", d1) - .remove(); - - // Stash the new scales. - this.__chart__ = {x: x1, y: y1, t: t1, id: id}; - }); - d3.timer.flush(); - } - - horizon.duration = function(x) { - if (!arguments.length) return duration; - duration = +x; - return horizon; - }; - - horizon.bands = function(x) { - if (!arguments.length) return bands; - bands = +x; - color.domain([-bands, 0, bands]); - return horizon; - }; - - horizon.mode = function(x) { - if (!arguments.length) return mode; - mode = x + ""; - return horizon; - }; - - horizon.colors = function(x) { - if (!arguments.length) return color.range(); - color.range(x); - return horizon; - }; - - horizon.interpolate = function(x) { - if (!arguments.length) return interpolate; - interpolate = x + ""; - return horizon; - }; - - horizon.x = function(z) { - if (!arguments.length) return x; - x = z; - return horizon; - }; - - horizon.y = function(z) { - if (!arguments.length) return y; - y = z; - return horizon; - }; - - horizon.width = function(x) { - if (!arguments.length) return w; - w = +x; - return horizon; - }; - - horizon.height = function(x) { - if (!arguments.length) return h; - h = +x; - return horizon; - }; - - return horizon; - }; - - var d3_horizonArea = d3.svg.area(), - d3_horizonId = 0; - - function d3_horizonX(d) { - return d[0]; - } - - function d3_horizonY(d) { - return d[1]; - } - - function d3_horizonTransform(bands, h, mode) { - return mode == "offset" - ? function(d) { return "translate(0," + (d + (d < 0) - bands) * h + ")"; } - : function(d) { return (d < 0 ? "scale(1,-1)" : "") + "translate(0," + (d - bands) * h + ")"; }; - } -})(); diff --git a/awx/ui/static/lib/novus-nvd3/lib/sankey.js b/awx/ui/static/lib/novus-nvd3/lib/sankey.js deleted file mode 100755 index c3bc59fbcc..0000000000 --- a/awx/ui/static/lib/novus-nvd3/lib/sankey.js +++ /dev/null @@ -1,292 +0,0 @@ -d3.sankey = function() { - var sankey = {}, - nodeWidth = 24, - nodePadding = 8, - size = [1, 1], - nodes = [], - links = []; - - sankey.nodeWidth = function(_) { - if (!arguments.length) return nodeWidth; - nodeWidth = +_; - return sankey; - }; - - sankey.nodePadding = function(_) { - if (!arguments.length) return nodePadding; - nodePadding = +_; - return sankey; - }; - - sankey.nodes = function(_) { - if (!arguments.length) return nodes; - nodes = _; - return sankey; - }; - - sankey.links = function(_) { - if (!arguments.length) return links; - links = _; - return sankey; - }; - - sankey.size = function(_) { - if (!arguments.length) return size; - size = _; - return sankey; - }; - - sankey.layout = function(iterations) { - computeNodeLinks(); - computeNodeValues(); - computeNodeBreadths(); - computeNodeDepths(iterations); - computeLinkDepths(); - return sankey; - }; - - sankey.relayout = function() { - computeLinkDepths(); - return sankey; - }; - - sankey.link = function() { - var curvature = .5; - - function link(d) { - var x0 = d.source.x + d.source.dx, - x1 = d.target.x, - xi = d3.interpolateNumber(x0, x1), - x2 = xi(curvature), - x3 = xi(1 - curvature), - y0 = d.source.y + d.sy + d.dy / 2, - y1 = d.target.y + d.ty + d.dy / 2; - return "M" + x0 + "," + y0 - + "C" + x2 + "," + y0 - + " " + x3 + "," + y1 - + " " + x1 + "," + y1; - } - - link.curvature = function(_) { - if (!arguments.length) return curvature; - curvature = +_; - return link; - }; - - return link; - }; - - // Populate the sourceLinks and targetLinks for each node. - // Also, if the source and target are not objects, assume they are indices. - function computeNodeLinks() { - nodes.forEach(function(node) { - node.sourceLinks = []; - node.targetLinks = []; - }); - links.forEach(function(link) { - var source = link.source, - target = link.target; - if (typeof source === "number") source = link.source = nodes[link.source]; - if (typeof target === "number") target = link.target = nodes[link.target]; - source.sourceLinks.push(link); - target.targetLinks.push(link); - }); - } - - // Compute the value (size) of each node by summing the associated links. - function computeNodeValues() { - nodes.forEach(function(node) { - node.value = Math.max( - d3.sum(node.sourceLinks, value), - d3.sum(node.targetLinks, value) - ); - }); - } - - // Iteratively assign the breadth (x-position) for each node. - // Nodes are assigned the maximum breadth of incoming neighbors plus one; - // nodes with no incoming links are assigned breadth zero, while - // nodes with no outgoing links are assigned the maximum breadth. - function computeNodeBreadths() { - var remainingNodes = nodes, - nextNodes, - x = 0; - - while (remainingNodes.length) { - nextNodes = []; - remainingNodes.forEach(function(node) { - node.x = x; - node.dx = nodeWidth; - node.sourceLinks.forEach(function(link) { - nextNodes.push(link.target); - }); - }); - remainingNodes = nextNodes; - ++x; - } - - // - moveSinksRight(x); - scaleNodeBreadths((size[0] - nodeWidth) / (x - 1)); - } - - function moveSourcesRight() { - nodes.forEach(function(node) { - if (!node.targetLinks.length) { - node.x = d3.min(node.sourceLinks, function(d) { return d.target.x; }) - 1; - } - }); - } - - function moveSinksRight(x) { - nodes.forEach(function(node) { - if (!node.sourceLinks.length) { - node.x = x - 1; - } - }); - } - - function scaleNodeBreadths(kx) { - nodes.forEach(function(node) { - node.x *= kx; - }); - } - - function computeNodeDepths(iterations) { - var nodesByBreadth = d3.nest() - .key(function(d) { return d.x; }) - .sortKeys(d3.ascending) - .entries(nodes) - .map(function(d) { return d.values; }); - - // - initializeNodeDepth(); - resolveCollisions(); - for (var alpha = 1; iterations > 0; --iterations) { - relaxRightToLeft(alpha *= .99); - resolveCollisions(); - relaxLeftToRight(alpha); - resolveCollisions(); - } - - function initializeNodeDepth() { - var ky = d3.min(nodesByBreadth, function(nodes) { - return (size[1] - (nodes.length - 1) * nodePadding) / d3.sum(nodes, value); - }); - - nodesByBreadth.forEach(function(nodes) { - nodes.forEach(function(node, i) { - node.y = i; - node.dy = node.value * ky; - }); - }); - - links.forEach(function(link) { - link.dy = link.value * ky; - }); - } - - function relaxLeftToRight(alpha) { - nodesByBreadth.forEach(function(nodes, breadth) { - nodes.forEach(function(node) { - if (node.targetLinks.length) { - var y = d3.sum(node.targetLinks, weightedSource) / d3.sum(node.targetLinks, value); - node.y += (y - center(node)) * alpha; - } - }); - }); - - function weightedSource(link) { - return center(link.source) * link.value; - } - } - - function relaxRightToLeft(alpha) { - nodesByBreadth.slice().reverse().forEach(function(nodes) { - nodes.forEach(function(node) { - if (node.sourceLinks.length) { - var y = d3.sum(node.sourceLinks, weightedTarget) / d3.sum(node.sourceLinks, value); - node.y += (y - center(node)) * alpha; - } - }); - }); - - function weightedTarget(link) { - return center(link.target) * link.value; - } - } - - function resolveCollisions() { - nodesByBreadth.forEach(function(nodes) { - var node, - dy, - y0 = 0, - n = nodes.length, - i; - - // Push any overlapping nodes down. - nodes.sort(ascendingDepth); - for (i = 0; i < n; ++i) { - node = nodes[i]; - dy = y0 - node.y; - if (dy > 0) node.y += dy; - y0 = node.y + node.dy + nodePadding; - } - - // If the bottommost node goes outside the bounds, push it back up. - dy = y0 - nodePadding - size[1]; - if (dy > 0) { - y0 = node.y -= dy; - - // Push any overlapping nodes back up. - for (i = n - 2; i >= 0; --i) { - node = nodes[i]; - dy = node.y + node.dy + nodePadding - y0; - if (dy > 0) node.y -= dy; - y0 = node.y; - } - } - }); - } - - function ascendingDepth(a, b) { - return a.y - b.y; - } - } - - function computeLinkDepths() { - nodes.forEach(function(node) { - node.sourceLinks.sort(ascendingTargetDepth); - node.targetLinks.sort(ascendingSourceDepth); - }); - nodes.forEach(function(node) { - var sy = 0, ty = 0; - node.sourceLinks.forEach(function(link) { - link.sy = sy; - sy += link.dy; - }); - node.targetLinks.forEach(function(link) { - link.ty = ty; - ty += link.dy; - }); - }); - - function ascendingSourceDepth(a, b) { - return a.source.y - b.source.y; - } - - function ascendingTargetDepth(a, b) { - return a.target.y - b.target.y; - } - } - - function center(node) { - return node.y + node.dy / 2; - } - - function value(link) { - return link.value; - } - - return sankey; -}; diff --git a/awx/ui/static/lib/novus-nvd3/nv.d3.js b/awx/ui/static/lib/novus-nvd3/nv.d3.js deleted file mode 100755 index 1aaff86c78..0000000000 --- a/awx/ui/static/lib/novus-nvd3/nv.d3.js +++ /dev/null @@ -1,14368 +0,0 @@ -(function(){ - -var nv = window.nv || {}; - - -nv.version = '1.1.15b'; -nv.dev = true //set false when in production - -window.nv = nv; - -nv.tooltip = nv.tooltip || {}; // For the tooltip system -nv.utils = nv.utils || {}; // Utility subsystem -nv.models = nv.models || {}; //stores all the possible models/components -nv.charts = {}; //stores all the ready to use charts -nv.graphs = []; //stores all the graphs currently on the page -nv.logs = {}; //stores some statistics and potential error messages - -nv.dispatch = d3.dispatch('render_start', 'render_end'); - -// ************************************************************************* -// Development render timers - disabled if dev = false - -if (nv.dev) { - nv.dispatch.on('render_start', function(e) { - nv.logs.startTime = +new Date(); - }); - - nv.dispatch.on('render_end', function(e) { - nv.logs.endTime = +new Date(); - nv.logs.totalTime = nv.logs.endTime - nv.logs.startTime; - nv.log('total', nv.logs.totalTime); // used for development, to keep track of graph generation times - }); -} - -// ******************************************** -// Public Core NV functions - -// Logs all arguments, and returns the last so you can test things in place -// Note: in IE8 console.log is an object not a function, and if modernizr is used -// then calling Function.prototype.bind with with anything other than a function -// causes a TypeError to be thrown. -nv.log = function() { - if (nv.dev && console.log && console.log.apply) - console.log.apply(console, arguments) - else if (nv.dev && typeof console.log == "function" && Function.prototype.bind) { - var log = Function.prototype.bind.call(console.log, console); - log.apply(console, arguments); - } - return arguments[arguments.length - 1]; -}; - - -nv.render = function render(step) { - step = step || 1; // number of graphs to generate in each timeout loop - - nv.render.active = true; - nv.dispatch.render_start(); - - setTimeout(function() { - var chart, graph; - - for (var i = 0; i < step && (graph = nv.render.queue[i]); i++) { - chart = graph.generate(); - if (typeof graph.callback == typeof(Function)) graph.callback(chart); - nv.graphs.push(chart); - } - - nv.render.queue.splice(0, i); - - if (nv.render.queue.length) setTimeout(arguments.callee, 0); - else { - nv.dispatch.render_end(); - nv.render.active = false; - } - }, 0); -}; - -nv.render.active = false; -nv.render.queue = []; - -nv.addGraph = function(obj) { - if (typeof arguments[0] === typeof(Function)) - obj = {generate: arguments[0], callback: arguments[1]}; - - nv.render.queue.push(obj); - - if (!nv.render.active) nv.render(); -}; - -nv.identity = function(d) { return d; }; - -nv.strip = function(s) { return s.replace(/(\s|&)/g,''); }; - -function daysInMonth(month,year) { - return (new Date(year, month+1, 0)).getDate(); -} - -function d3_time_range(floor, step, number) { - return function(t0, t1, dt) { - var time = floor(t0), times = []; - if (time < t0) step(time); - if (dt > 1) { - while (time < t1) { - var date = new Date(+time); - if ((number(date) % dt === 0)) times.push(date); - step(time); - } - } else { - while (time < t1) { times.push(new Date(+time)); step(time); } - } - return times; - }; -} - -d3.time.monthEnd = function(date) { - return new Date(date.getFullYear(), date.getMonth(), 0); -}; - -d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { - date.setUTCDate(date.getUTCDate() + 1); - date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear())); - }, function(date) { - return date.getMonth(); - } -); - -/* Utility class to handle creation of an interactive layer. -This places a rectangle on top of the chart. When you mouse move over it, it sends a dispatch -containing the X-coordinate. It can also render a vertical line where the mouse is located. - -dispatch.elementMousemove is the important event to latch onto. It is fired whenever the mouse moves over -the rectangle. The dispatch is given one object which contains the mouseX/Y location. -It also has 'pointXValue', which is the conversion of mouseX to the x-axis scale. -*/ -nv.interactiveGuideline = function() { - "use strict"; - var tooltip = nv.models.tooltip(); - //Public settings - var width = null - , height = null - //Please pass in the bounding chart's top and left margins - //This is important for calculating the correct mouseX/Y positions. - , margin = {left: 0, top: 0} - , xScale = d3.scale.linear() - , yScale = d3.scale.linear() - , dispatch = d3.dispatch('elementMousemove', 'elementMouseout','elementDblclick') - , showGuideLine = true - , svgContainer = null - //Must pass in the bounding chart's container. - //The mousemove event is attached to this container. - ; - - //Private variables - var isMSIE = navigator.userAgent.indexOf("MSIE") !== -1 //Check user-agent for Microsoft Internet Explorer. - ; - - - function layer(selection) { - selection.each(function(data) { - var container = d3.select(this); - - var availableWidth = (width || 960), availableHeight = (height || 400); - - var wrap = container.selectAll("g.nv-wrap.nv-interactiveLineLayer").data([data]); - var wrapEnter = wrap.enter() - .append("g").attr("class", " nv-wrap nv-interactiveLineLayer"); - - - wrapEnter.append("g").attr("class","nv-interactiveGuideLine"); - - if (!svgContainer) { - return; - } - - function mouseHandler() { - var d3mouse = d3.mouse(this); - var mouseX = d3mouse[0]; - var mouseY = d3mouse[1]; - var subtractMargin = true; - var mouseOutAnyReason = false; - if (isMSIE) { - /* - D3.js (or maybe SVG.getScreenCTM) has a nasty bug in Internet Explorer 10. - d3.mouse() returns incorrect X,Y mouse coordinates when mouse moving - over a rect in IE 10. - However, d3.event.offsetX/Y also returns the mouse coordinates - relative to the triggering . So we use offsetX/Y on IE. - */ - mouseX = d3.event.offsetX; - mouseY = d3.event.offsetY; - - /* - On IE, if you attach a mouse event listener to the container, - it will actually trigger it for all the child elements (like , , etc). - When this happens on IE, the offsetX/Y is set to where ever the child element - is located. - As a result, we do NOT need to subtract margins to figure out the mouse X/Y - position under this scenario. Removing the line below *will* cause - the interactive layer to not work right on IE. - */ - if(d3.event.target.tagName !== "svg") - subtractMargin = false; - - if (d3.event.target.className.baseVal.match("nv-legend")) - mouseOutAnyReason = true; - - } - - if(subtractMargin) { - mouseX -= margin.left; - mouseY -= margin.top; - } - - /* If mouseX/Y is outside of the chart's bounds, - trigger a mouseOut event. - */ - if (mouseX < 0 || mouseY < 0 - || mouseX > availableWidth || mouseY > availableHeight - || (d3.event.relatedTarget && d3.event.relatedTarget.ownerSVGElement === undefined) - || mouseOutAnyReason - ) - { - if (isMSIE) { - if (d3.event.relatedTarget - && d3.event.relatedTarget.ownerSVGElement === undefined - && d3.event.relatedTarget.className.match(tooltip.nvPointerEventsClass)) { - return; - } - } - dispatch.elementMouseout({ - mouseX: mouseX, - mouseY: mouseY - }); - layer.renderGuideLine(null); //hide the guideline - return; - } - - var pointXValue = xScale.invert(mouseX); - dispatch.elementMousemove({ - mouseX: mouseX, - mouseY: mouseY, - pointXValue: pointXValue - }); - - //If user double clicks the layer, fire a elementDblclick dispatch. - if (d3.event.type === "dblclick") { - dispatch.elementDblclick({ - mouseX: mouseX, - mouseY: mouseY, - pointXValue: pointXValue - }); - } - } - - svgContainer - .on("mousemove",mouseHandler, true) - .on("mouseout" ,mouseHandler,true) - .on("dblclick" ,mouseHandler) - ; - - //Draws a vertical guideline at the given X postion. - layer.renderGuideLine = function(x) { - if (!showGuideLine) return; - var line = wrap.select(".nv-interactiveGuideLine") - .selectAll("line") - .data((x != null) ? [nv.utils.NaNtoZero(x)] : [], String); - - line.enter() - .append("line") - .attr("class", "nv-guideline") - .attr("x1", function(d) { return d;}) - .attr("x2", function(d) { return d;}) - .attr("y1", availableHeight) - .attr("y2",0) - ; - line.exit().remove(); - - } - }); - } - - layer.dispatch = dispatch; - layer.tooltip = tooltip; - - layer.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return layer; - }; - - layer.width = function(_) { - if (!arguments.length) return width; - width = _; - return layer; - }; - - layer.height = function(_) { - if (!arguments.length) return height; - height = _; - return layer; - }; - - layer.xScale = function(_) { - if (!arguments.length) return xScale; - xScale = _; - return layer; - }; - - layer.showGuideLine = function(_) { - if (!arguments.length) return showGuideLine; - showGuideLine = _; - return layer; - }; - - layer.svgContainer = function(_) { - if (!arguments.length) return svgContainer; - svgContainer = _; - return layer; - }; - - - return layer; -}; - -/* Utility class that uses d3.bisect to find the index in a given array, where a search value can be inserted. -This is different from normal bisectLeft; this function finds the nearest index to insert the search value. - -For instance, lets say your array is [1,2,3,5,10,30], and you search for 28. -Normal d3.bisectLeft will return 4, because 28 is inserted after the number 10. But interactiveBisect will return 5 -because 28 is closer to 30 than 10. - -Unit tests can be found in: interactiveBisectTest.html - -Has the following known issues: - * Will not work if the data points move backwards (ie, 10,9,8,7, etc) or if the data points are in random order. - * Won't work if there are duplicate x coordinate values. -*/ -nv.interactiveBisect = function (values, searchVal, xAccessor) { - "use strict"; - if (! values instanceof Array) return null; - if (typeof xAccessor !== 'function') xAccessor = function(d,i) { return d.x;} - - var bisect = d3.bisector(xAccessor).left; - var index = d3.max([0, bisect(values,searchVal) - 1]); - var currentValue = xAccessor(values[index], index); - if (typeof currentValue === 'undefined') currentValue = index; - - if (currentValue === searchVal) return index; //found exact match - - var nextIndex = d3.min([index+1, values.length - 1]); - var nextValue = xAccessor(values[nextIndex], nextIndex); - if (typeof nextValue === 'undefined') nextValue = nextIndex; - - if (Math.abs(nextValue - searchVal) >= Math.abs(currentValue - searchVal)) - return index; - else - return nextIndex -}; - -/* -Returns the index in the array "values" that is closest to searchVal. -Only returns an index if searchVal is within some "threshold". -Otherwise, returns null. -*/ -nv.nearestValueIndex = function (values, searchVal, threshold) { - "use strict"; - var yDistMax = Infinity, indexToHighlight = null; - values.forEach(function(d,i) { - var delta = Math.abs(searchVal - d); - if ( delta <= yDistMax && delta < threshold) { - yDistMax = delta; - indexToHighlight = i; - } - }); - return indexToHighlight; -};/* Tooltip rendering model for nvd3 charts. -window.nv.models.tooltip is the updated,new way to render tooltips. - -window.nv.tooltip.show is the old tooltip code. -window.nv.tooltip.* also has various helper methods. -*/ -(function() { - "use strict"; - window.nv.tooltip = {}; - - /* Model which can be instantiated to handle tooltip rendering. - Example usage: - var tip = nv.models.tooltip().gravity('w').distance(23) - .data(myDataObject); - - tip(); //just invoke the returned function to render tooltip. - */ - window.nv.models.tooltip = function() { - var content = null //HTML contents of the tooltip. If null, the content is generated via the data variable. - , data = null /* Tooltip data. If data is given in the proper format, a consistent tooltip is generated. - Format of data: - { - key: "Date", - value: "August 2009", - series: [ - { - key: "Series 1", - value: "Value 1", - color: "#000" - }, - { - key: "Series 2", - value: "Value 2", - color: "#00f" - } - ] - - } - - */ - , gravity = 'w' //Can be 'n','s','e','w'. Determines how tooltip is positioned. - , distance = 50 //Distance to offset tooltip from the mouse location. - , snapDistance = 25 //Tolerance allowed before tooltip is moved from its current position (creates 'snapping' effect) - , fixedTop = null //If not null, this fixes the top position of the tooltip. - , classes = null //Attaches additional CSS classes to the tooltip DIV that is created. - , chartContainer = null //Parent DIV, of the SVG Container that holds the chart. - , tooltipElem = null //actual DOM element representing the tooltip. - , position = {left: null, top: null} //Relative position of the tooltip inside chartContainer. - , enabled = true //True -> tooltips are rendered. False -> don't render tooltips. - //Generates a unique id when you create a new tooltip() object - , id = "nvtooltip-" + Math.floor(Math.random() * 100000) - ; - - //CSS class to specify whether element should not have mouse events. - var nvPointerEventsClass = "nv-pointer-events-none"; - - //Format function for the tooltip values column - var valueFormatter = function(d,i) { - return d; - }; - - //Format function for the tooltip header value. - var headerFormatter = function(d) { - return d; - }; - - //By default, the tooltip model renders a beautiful table inside a DIV. - //You can override this function if a custom tooltip is desired. - var contentGenerator = function(d) { - if (content != null) return content; - - if (d == null) return ''; - - var table = d3.select(document.createElement("table")); - var theadEnter = table.selectAll("thead") - .data([d]) - .enter().append("thead"); - theadEnter.append("tr") - .append("td") - .attr("colspan",3) - .append("strong") - .classed("x-value",true) - .html(headerFormatter(d.value)); - - var tbodyEnter = table.selectAll("tbody") - .data([d]) - .enter().append("tbody"); - var trowEnter = tbodyEnter.selectAll("tr") - .data(function(p) { return p.series}) - .enter() - .append("tr") - .classed("highlight", function(p) { return p.highlight}) - ; - - trowEnter.append("td") - .classed("legend-color-guide",true) - .append("div") - .style("background-color", function(p) { return p.color}); - trowEnter.append("td") - .classed("key",true) - .html(function(p) {return p.key}); - trowEnter.append("td") - .classed("value",true) - .html(function(p,i) { return valueFormatter(p.value,i) }); - - - trowEnter.selectAll("td").each(function(p) { - if (p.highlight) { - var opacityScale = d3.scale.linear().domain([0,1]).range(["#fff",p.color]); - var opacity = 0.6; - d3.select(this) - .style("border-bottom-color", opacityScale(opacity)) - .style("border-top-color", opacityScale(opacity)) - ; - } - }); - - var html = table.node().outerHTML; - if (d.footer !== undefined) - html += ""; - return html; - - }; - - var dataSeriesExists = function(d) { - if (d && d.series && d.series.length > 0) return true; - - return false; - }; - - //In situations where the chart is in a 'viewBox', re-position the tooltip based on how far chart is zoomed. - function convertViewBoxRatio() { - if (chartContainer) { - var svg = d3.select(chartContainer); - if (svg.node().tagName !== "svg") { - svg = svg.select("svg"); - } - var viewBox = (svg.node()) ? svg.attr('viewBox') : null; - if (viewBox) { - viewBox = viewBox.split(' '); - var ratio = parseInt(svg.style('width')) / viewBox[2]; - - position.left = position.left * ratio; - position.top = position.top * ratio; - } - } - } - - //Creates new tooltip container, or uses existing one on DOM. - function getTooltipContainer(newContent) { - var body; - if (chartContainer) - body = d3.select(chartContainer); - else - body = d3.select("body"); - - var container = body.select(".nvtooltip"); - if (container.node() === null) { - //Create new tooltip div if it doesn't exist on DOM. - container = body.append("div") - .attr("class", "nvtooltip " + (classes? classes: "xy-tooltip")) - .attr("id",id) - ; - } - - - container.node().innerHTML = newContent; - container.style("top",0).style("left",0).style("opacity",0); - container.selectAll("div, table, td, tr").classed(nvPointerEventsClass,true) - container.classed(nvPointerEventsClass,true); - return container.node(); - } - - - - //Draw the tooltip onto the DOM. - function nvtooltip() { - if (!enabled) return; - if (!dataSeriesExists(data)) return; - - convertViewBoxRatio(); - - var left = position.left; - var top = (fixedTop != null) ? fixedTop : position.top; - var container = getTooltipContainer(contentGenerator(data)); - tooltipElem = container; - if (chartContainer) { - var svgComp = chartContainer.getElementsByTagName("svg")[0]; - var boundRect = (svgComp) ? svgComp.getBoundingClientRect() : chartContainer.getBoundingClientRect(); - var svgOffset = {left:0,top:0}; - if (svgComp) { - var svgBound = svgComp.getBoundingClientRect(); - var chartBound = chartContainer.getBoundingClientRect(); - var svgBoundTop = svgBound.top; - - //Defensive code. Sometimes, svgBoundTop can be a really negative - // number, like -134254. That's a bug. - // If such a number is found, use zero instead. FireFox bug only - if (svgBoundTop < 0) { - var containerBound = chartContainer.getBoundingClientRect(); - svgBoundTop = (Math.abs(svgBoundTop) > containerBound.height) ? 0 : svgBoundTop; - } - svgOffset.top = Math.abs(svgBoundTop - chartBound.top); - svgOffset.left = Math.abs(svgBound.left - chartBound.left); - } - //If the parent container is an overflow
with scrollbars, subtract the scroll offsets. - //You need to also add any offset between the element and its containing
- //Finally, add any offset of the containing
on the whole page. - left += chartContainer.offsetLeft + svgOffset.left - 2*chartContainer.scrollLeft; - top += chartContainer.offsetTop + svgOffset.top - 2*chartContainer.scrollTop; - } - - if (snapDistance && snapDistance > 0) { - top = Math.floor(top/snapDistance) * snapDistance; - } - - nv.tooltip.calcTooltipPosition([left,top], gravity, distance, container); - return nvtooltip; - }; - - nvtooltip.nvPointerEventsClass = nvPointerEventsClass; - - nvtooltip.content = function(_) { - if (!arguments.length) return content; - content = _; - return nvtooltip; - }; - - //Returns tooltipElem...not able to set it. - nvtooltip.tooltipElem = function() { - return tooltipElem; - }; - - nvtooltip.contentGenerator = function(_) { - if (!arguments.length) return contentGenerator; - if (typeof _ === 'function') { - contentGenerator = _; - } - return nvtooltip; - }; - - nvtooltip.data = function(_) { - if (!arguments.length) return data; - data = _; - return nvtooltip; - }; - - nvtooltip.gravity = function(_) { - if (!arguments.length) return gravity; - gravity = _; - return nvtooltip; - }; - - nvtooltip.distance = function(_) { - if (!arguments.length) return distance; - distance = _; - return nvtooltip; - }; - - nvtooltip.snapDistance = function(_) { - if (!arguments.length) return snapDistance; - snapDistance = _; - return nvtooltip; - }; - - nvtooltip.classes = function(_) { - if (!arguments.length) return classes; - classes = _; - return nvtooltip; - }; - - nvtooltip.chartContainer = function(_) { - if (!arguments.length) return chartContainer; - chartContainer = _; - return nvtooltip; - }; - - nvtooltip.position = function(_) { - if (!arguments.length) return position; - position.left = (typeof _.left !== 'undefined') ? _.left : position.left; - position.top = (typeof _.top !== 'undefined') ? _.top : position.top; - return nvtooltip; - }; - - nvtooltip.fixedTop = function(_) { - if (!arguments.length) return fixedTop; - fixedTop = _; - return nvtooltip; - }; - - nvtooltip.enabled = function(_) { - if (!arguments.length) return enabled; - enabled = _; - return nvtooltip; - }; - - nvtooltip.valueFormatter = function(_) { - if (!arguments.length) return valueFormatter; - if (typeof _ === 'function') { - valueFormatter = _; - } - return nvtooltip; - }; - - nvtooltip.headerFormatter = function(_) { - if (!arguments.length) return headerFormatter; - if (typeof _ === 'function') { - headerFormatter = _; - } - return nvtooltip; - }; - - //id() is a read-only function. You can't use it to set the id. - nvtooltip.id = function() { - return id; - }; - - - return nvtooltip; - }; - - - //Original tooltip.show function. Kept for backward compatibility. - // pos = [left,top] - nv.tooltip.show = function(pos, content, gravity, dist, parentContainer, classes) { - - //Create new tooltip div if it doesn't exist on DOM. - var container = document.createElement('div'); - container.className = 'nvtooltip ' + (classes ? classes : 'xy-tooltip'); - - var body = parentContainer; - if ( !parentContainer || parentContainer.tagName.match(/g|svg/i)) { - //If the parent element is an SVG element, place tooltip in the element. - body = document.getElementsByTagName('body')[0]; - } - - container.style.left = 0; - container.style.top = 0; - container.style.opacity = 0; - container.innerHTML = content; - body.appendChild(container); - - //If the parent container is an overflow
with scrollbars, subtract the scroll offsets. - if (parentContainer) { - pos[0] = pos[0] - parentContainer.scrollLeft; - pos[1] = pos[1] - parentContainer.scrollTop; - } - nv.tooltip.calcTooltipPosition(pos, gravity, dist, container); - }; - - //Looks up the ancestry of a DOM element, and returns the first NON-svg node. - nv.tooltip.findFirstNonSVGParent = function(Elem) { - while(Elem.tagName.match(/^g|svg$/i) !== null) { - Elem = Elem.parentNode; - } - return Elem; - }; - - //Finds the total offsetTop of a given DOM element. - //Looks up the entire ancestry of an element, up to the first relatively positioned element. - nv.tooltip.findTotalOffsetTop = function ( Elem, initialTop ) { - var offsetTop = initialTop; - - do { - if( !isNaN( Elem.offsetTop ) ) { - offsetTop += (Elem.offsetTop); - } - } while( Elem = Elem.offsetParent ); - return offsetTop; - }; - - //Finds the total offsetLeft of a given DOM element. - //Looks up the entire ancestry of an element, up to the first relatively positioned element. - nv.tooltip.findTotalOffsetLeft = function ( Elem, initialLeft) { - var offsetLeft = initialLeft; - - do { - if( !isNaN( Elem.offsetLeft ) ) { - offsetLeft += (Elem.offsetLeft); - } - } while( Elem = Elem.offsetParent ); - return offsetLeft; - }; - - //Global utility function to render a tooltip on the DOM. - //pos = [left,top] coordinates of where to place the tooltip, relative to the SVG chart container. - //gravity = how to orient the tooltip - //dist = how far away from the mouse to place tooltip - //container = tooltip DIV - nv.tooltip.calcTooltipPosition = function(pos, gravity, dist, container) { - - var height = parseInt(container.offsetHeight), - width = parseInt(container.offsetWidth), - windowWidth = nv.utils.windowSize().width, - windowHeight = nv.utils.windowSize().height, - scrollTop = window.pageYOffset, - scrollLeft = window.pageXOffset, - left, top; - - windowHeight = window.innerWidth >= document.body.scrollWidth ? windowHeight : windowHeight - 16; - windowWidth = window.innerHeight >= document.body.scrollHeight ? windowWidth : windowWidth - 16; - - gravity = gravity || 's'; - dist = dist || 20; - - var tooltipTop = function ( Elem ) { - return nv.tooltip.findTotalOffsetTop(Elem, top); - }; - - var tooltipLeft = function ( Elem ) { - return nv.tooltip.findTotalOffsetLeft(Elem,left); - }; - - switch (gravity) { - case 'e': - left = pos[0] - width - dist; - top = pos[1] - (height / 2); - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft < scrollLeft) left = pos[0] + dist > scrollLeft ? pos[0] + dist : scrollLeft - tLeft + left; - if (tTop < scrollTop) top = scrollTop - tTop + top; - if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; - break; - case 'w': - left = pos[0] + dist; - top = pos[1] - (height / 2); - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft + width > windowWidth) left = pos[0] - width - dist; - if (tTop < scrollTop) top = scrollTop + 5; - if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; - break; - case 'n': - left = pos[0] - (width / 2) - 5; - top = pos[1] + dist; - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft < scrollLeft) left = scrollLeft + 5; - if (tLeft + width > windowWidth) left = left - width/2 + 5; - if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; - break; - case 's': - left = pos[0] - (width / 2); - top = pos[1] - height - dist; - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft < scrollLeft) left = scrollLeft + 5; - if (tLeft + width > windowWidth) left = left - width/2 + 5; - if (scrollTop > tTop) top = scrollTop; - break; - case 'none': - left = pos[0]; - top = pos[1] - dist; - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - break; - } - - - container.style.left = left+'px'; - container.style.top = top+'px'; - container.style.opacity = 1; - container.style.position = 'absolute'; - - return container; - }; - - //Global utility function to remove tooltips from the DOM. - nv.tooltip.cleanup = function() { - - // Find the tooltips, mark them for removal by this class (so others cleanups won't find it) - var tooltips = document.getElementsByClassName('nvtooltip'); - var purging = []; - while(tooltips.length) { - purging.push(tooltips[0]); - tooltips[0].style.transitionDelay = '0 !important'; - tooltips[0].style.opacity = 0; - tooltips[0].className = 'nvtooltip-pending-removal'; - } - - setTimeout(function() { - - while (purging.length) { - var removeMe = purging.pop(); - removeMe.parentNode.removeChild(removeMe); - } - }, 500); - }; - -})(); - -nv.utils.windowSize = function() { - // Sane defaults - var size = {width: 640, height: 480}; - - // Earlier IE uses Doc.body - if (document.body && document.body.offsetWidth) { - size.width = document.body.offsetWidth; - size.height = document.body.offsetHeight; - } - - // IE can use depending on mode it is in - if (document.compatMode=='CSS1Compat' && - document.documentElement && - document.documentElement.offsetWidth ) { - size.width = document.documentElement.offsetWidth; - size.height = document.documentElement.offsetHeight; - } - - // Most recent browsers use - if (window.innerWidth && window.innerHeight) { - size.width = window.innerWidth; - size.height = window.innerHeight; - } - return (size); -}; - - - -// Easy way to bind multiple functions to window.onresize -// TODO: give a way to remove a function after its bound, other than removing all of them -nv.utils.windowResize = function(fun){ - if (fun === undefined) return; - var oldresize = window.onresize; - - window.onresize = function(e) { - if (typeof oldresize == 'function') oldresize(e); - fun(e); - } -} - -// Backwards compatible way to implement more d3-like coloring of graphs. -// If passed an array, wrap it in a function which implements the old default -// behavior -nv.utils.getColor = function(color) { - if (!arguments.length) return nv.utils.defaultColor(); //if you pass in nothing, get default colors back - - if( Object.prototype.toString.call( color ) === '[object Array]' ) - return function(d, i) { return d.color || color[i % color.length]; }; - else - return color; - //can't really help it if someone passes rubbish as color -} - -// Default color chooser uses the index of an object as before. -nv.utils.defaultColor = function() { - var colors = d3.scale.category20().range(); - return function(d, i) { return d.color || colors[i % colors.length] }; -} - - -// Returns a color function that takes the result of 'getKey' for each series and -// looks for a corresponding color from the dictionary, -nv.utils.customTheme = function(dictionary, getKey, defaultColors) { - getKey = getKey || function(series) { return series.key }; // use default series.key if getKey is undefined - defaultColors = defaultColors || d3.scale.category20().range(); //default color function - - var defIndex = defaultColors.length; //current default color (going in reverse) - - return function(series, index) { - var key = getKey(series); - - if (!defIndex) defIndex = defaultColors.length; //used all the default colors, start over - - if (typeof dictionary[key] !== "undefined") - return (typeof dictionary[key] === "function") ? dictionary[key]() : dictionary[key]; - else - return defaultColors[--defIndex]; // no match in dictionary, use default color - } -} - - - -// From the PJAX example on d3js.org, while this is not really directly needed -// it's a very cool method for doing pjax, I may expand upon it a little bit, -// open to suggestions on anything that may be useful -nv.utils.pjax = function(links, content) { - d3.selectAll(links).on("click", function() { - history.pushState(this.href, this.textContent, this.href); - load(this.href); - d3.event.preventDefault(); - }); - - function load(href) { - d3.html(href, function(fragment) { - var target = d3.select(content).node(); - target.parentNode.replaceChild(d3.select(fragment).select(content).node(), target); - nv.utils.pjax(links, content); - }); - } - - d3.select(window).on("popstate", function() { - if (d3.event.state) load(d3.event.state); - }); -} - -/* For situations where we want to approximate the width in pixels for an SVG:text element. -Most common instance is when the element is in a display:none; container. -Forumla is : text.length * font-size * constant_factor -*/ -nv.utils.calcApproxTextWidth = function (svgTextElem) { - if (typeof svgTextElem.style === 'function' - && typeof svgTextElem.text === 'function') { - var fontSize = parseInt(svgTextElem.style("font-size").replace("px","")); - var textLength = svgTextElem.text().length; - - return textLength * fontSize * 0.5; - } - return 0; -}; - -/* Numbers that are undefined, null or NaN, convert them to zeros. -*/ -nv.utils.NaNtoZero = function(n) { - if (typeof n !== 'number' - || isNaN(n) - || n === null - || n === Infinity) return 0; - - return n; -}; - -/* -Snippet of code you can insert into each nv.models.* to give you the ability to -do things like: -chart.options({ - showXAxis: true, - tooltips: true -}); - -To enable in the chart: -chart.options = nv.utils.optionsFunc.bind(chart); -*/ -nv.utils.optionsFunc = function(args) { - if (args) { - d3.map(args).forEach((function(key,value) { - if (typeof this[key] === "function") { - this[key](value); - } - }).bind(this)); - } - return this; -};nv.models.axis = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var axis = d3.svg.axis() - ; - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 75 //only used for tickLabel currently - , height = 60 //only used for tickLabel currently - , scale = d3.scale.linear() - , axisLabelText = null - , showMaxMin = true //TODO: showMaxMin should be disabled on all ordinal scaled axes - , highlightZero = true - , rotateLabels = 0 - , rotateYLabel = true - , staggerLabels = false - , isOrdinal = false - , ticks = null - , axisLabelDistance = 12 //The larger this number is, the closer the axis label is to the axis. - ; - - axis - .scale(scale) - .orient('bottom') - .tickFormat(function(d) { return d }) - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var scale0; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-axis').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-axis'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - //------------------------------------------------------------ - - - if (ticks !== null) - axis.ticks(ticks); - else if (axis.orient() == 'top' || axis.orient() == 'bottom') - axis.ticks(Math.abs(scale.range()[1] - scale.range()[0]) / 100); - - - //TODO: consider calculating width/height based on whether or not label is added, for reference in charts using this component - - - g.transition().call(axis); - - scale0 = scale0 || axis.scale(); - - var fmt = axis.tickFormat(); - if (fmt == null) { - fmt = scale0.tickFormat(); - } - - var axisLabel = g.selectAll('text.nv-axislabel') - .data([axisLabelText || null]); - axisLabel.exit().remove(); - switch (axis.orient()) { - case 'top': - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - var w = (scale.range().length==2) ? scale.range()[1] : (scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0])); - axisLabel - .attr('text-anchor', 'middle') - .attr('y', 0) - .attr('x', w/2); - if (showMaxMin) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - .data(scale.domain()); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text'); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(' + scale(d) + ',0)' - }) - .select('text') - .attr('dy', '-0.5em') - .attr('y', -axis.tickPadding()) - .attr('text-anchor', 'middle') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - return 'translate(' + scale.range()[i] + ',0)' - }); - } - break; - case 'bottom': - var xLabelMargin = 36; - var maxTextWidth = 30; - var xTicks = g.selectAll('g').select("text"); - if (rotateLabels%360) { - //Calculate the longest xTick width - xTicks.each(function(d,i){ - var width = this.getBBox().width; - if(width > maxTextWidth) maxTextWidth = width; - }); - //Convert to radians before calculating sin. Add 30 to margin for healthy padding. - var sin = Math.abs(Math.sin(rotateLabels*Math.PI/180)); - var xLabelMargin = (sin ? sin*maxTextWidth : maxTextWidth)+30; - //Rotate all xTicks - xTicks - .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' }) - .style('text-anchor', rotateLabels%360 > 0 ? 'start' : 'end'); - } - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - var w = (scale.range().length==2) ? scale.range()[1] : (scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0])); - axisLabel - .attr('text-anchor', 'middle') - .attr('y', xLabelMargin) - .attr('x', w/2); - if (showMaxMin) { - //if (showMaxMin && !isOrdinal) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - //.data(scale.domain()) - .data([scale.domain()[0], scale.domain()[scale.domain().length - 1]]); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text'); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(' + (scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0)) + ',0)' - }) - .select('text') - .attr('dy', '.71em') - .attr('y', axis.tickPadding()) - .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' }) - .style('text-anchor', rotateLabels ? (rotateLabels%360 > 0 ? 'start' : 'end') : 'middle') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - //return 'translate(' + scale.range()[i] + ',0)' - //return 'translate(' + scale(d) + ',0)' - return 'translate(' + (scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0)) + ',0)' - }); - } - if (staggerLabels) - xTicks - .attr('transform', function(d,i) { return 'translate(0,' + (i % 2 == 0 ? '0' : '12') + ')' }); - - break; - case 'right': - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - axisLabel - .style('text-anchor', rotateYLabel ? 'middle' : 'begin') - .attr('transform', rotateYLabel ? 'rotate(90)' : '') - .attr('y', rotateYLabel ? (-Math.max(margin.right,width) + 12) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart - .attr('x', rotateYLabel ? (scale.range()[0] / 2) : axis.tickPadding()); - if (showMaxMin) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - .data(scale.domain()); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text') - .style('opacity', 0); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(0,' + scale(d) + ')' - }) - .select('text') - .attr('dy', '.32em') - .attr('y', 0) - .attr('x', axis.tickPadding()) - .style('text-anchor', 'start') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - return 'translate(0,' + scale.range()[i] + ')' - }) - .select('text') - .style('opacity', 1); - } - break; - case 'left': - /* - //For dynamically placing the label. Can be used with dynamically-sized chart axis margins - var yTicks = g.selectAll('g').select("text"); - yTicks.each(function(d,i){ - var labelPadding = this.getBBox().width + axis.tickPadding() + 16; - if(labelPadding > width) width = labelPadding; - }); - */ - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - axisLabel - .style('text-anchor', rotateYLabel ? 'middle' : 'end') - .attr('transform', rotateYLabel ? 'rotate(-90)' : '') - .attr('y', rotateYLabel ? (-Math.max(margin.left,width) + axisLabelDistance) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart - .attr('x', rotateYLabel ? (-scale.range()[0] / 2) : -axis.tickPadding()); - if (showMaxMin) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - .data(scale.domain()); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text') - .style('opacity', 0); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(0,' + scale0(d) + ')' - }) - .select('text') - .attr('dy', '.32em') - .attr('y', 0) - .attr('x', -axis.tickPadding()) - .attr('text-anchor', 'end') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - return 'translate(0,' + scale.range()[i] + ')' - }) - .select('text') - .style('opacity', 1); - } - break; - } - axisLabel - .text(function(d) { return d }); - - - if (showMaxMin && (axis.orient() === 'left' || axis.orient() === 'right')) { - //check if max and min overlap other values, if so, hide the values that overlap - g.selectAll('g') // the g's wrapping each tick - .each(function(d,i) { - d3.select(this).select('text').attr('opacity', 1); - if (scale(d) < scale.range()[1] + 10 || scale(d) > scale.range()[0] - 10) { // 10 is assuming text height is 16... if d is 0, leave it! - if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL - d3.select(this).attr('opacity', 0); - - d3.select(this).select('text').attr('opacity', 0); // Don't remove the ZERO line!! - } - }); - - //if Max and Min = 0 only show min, Issue #281 - if (scale.domain()[0] == scale.domain()[1] && scale.domain()[0] == 0) - wrap.selectAll('g.nv-axisMaxMin') - .style('opacity', function(d,i) { return !i ? 1 : 0 }); - - } - - if (showMaxMin && (axis.orient() === 'top' || axis.orient() === 'bottom')) { - var maxMinRange = []; - wrap.selectAll('g.nv-axisMaxMin') - .each(function(d,i) { - try { - if (i) // i== 1, max position - maxMinRange.push(scale(d) - this.getBBox().width - 4) //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case) - else // i==0, min position - maxMinRange.push(scale(d) + this.getBBox().width + 4) - }catch (err) { - if (i) // i== 1, max position - maxMinRange.push(scale(d) - 4) //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case) - else // i==0, min position - maxMinRange.push(scale(d) + 4) - } - }); - g.selectAll('g') // the g's wrapping each tick - .each(function(d,i) { - if (scale(d) < maxMinRange[0] || scale(d) > maxMinRange[1]) { - if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL - d3.select(this).remove(); - else - d3.select(this).select('text').remove(); // Don't remove the ZERO line!! - } - }); - } - - - //highlight zero line ... Maybe should not be an option and should just be in CSS? - if (highlightZero) - g.selectAll('.tick') - .filter(function(d) { return !parseFloat(Math.round(d.__data__*100000)/1000000) && (d.__data__ !== undefined) }) //this is because sometimes the 0 tick is a very small fraction, TODO: think of cleaner technique - .classed('zero', true); - - //store old scales for use in transitions on update - scale0 = scale.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.axis = axis; - - d3.rebind(chart, axis, 'orient', 'tickValues', 'tickSubdivide', 'tickSize', 'tickPadding', 'tickFormat'); - d3.rebind(chart, scale, 'domain', 'range', 'rangeBand', 'rangeBands'); //these are also accessible by chart.scale(), but added common ones directly for ease of use - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if(!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - } - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.ticks = function(_) { - if (!arguments.length) return ticks; - ticks = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.axisLabel = function(_) { - if (!arguments.length) return axisLabelText; - axisLabelText = _; - return chart; - } - - chart.showMaxMin = function(_) { - if (!arguments.length) return showMaxMin; - showMaxMin = _; - return chart; - } - - chart.highlightZero = function(_) { - if (!arguments.length) return highlightZero; - highlightZero = _; - return chart; - } - - chart.scale = function(_) { - if (!arguments.length) return scale; - scale = _; - axis.scale(scale); - isOrdinal = typeof scale.rangeBands === 'function'; - d3.rebind(chart, scale, 'domain', 'range', 'rangeBand', 'rangeBands'); - return chart; - } - - chart.rotateYLabel = function(_) { - if(!arguments.length) return rotateYLabel; - rotateYLabel = _; - return chart; - } - - chart.rotateLabels = function(_) { - if(!arguments.length) return rotateLabels; - rotateLabels = _; - return chart; - } - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - chart.axisLabelDistance = function(_) { - if (!arguments.length) return axisLabelDistance; - axisLabelDistance = _; - return chart; - }; - - //============================================================ - - - return chart; -} -//TODO: consider deprecating and using multibar with single series for this -nv.models.historicalBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.linear() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceX = [] - , forceY = [0] - , padData = false - , clipEdge = true - , color = nv.utils.defaultColor() - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - , interactive = true - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - x .domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )) - - if (padData) - x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); - else - x.range(xRange || [0, availableWidth]); - - y .domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) )) - .range(yRange || [availableHeight, 0]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-bars'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - container - .on('click', function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - defsEnter.append('clipPath') - .attr('id', 'nv-chart-clip-path-' + id) - .append('rect'); - - wrap.select('#nv-chart-clip-path-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); - - - - var bars = wrap.select('.nv-bars').selectAll('.nv-bar') - .data(function(d) { return d }, function(d,i) {return getX(d,i)}); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('rect') - //.attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) - .attr('x', 0 ) - .attr('y', function(d,i) { return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) }) - .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) }) - .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) - .on('mouseover', function(d,i) { - if (!interactive) return; - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - point: d, - series: data[0], - pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - - }) - .on('mouseout', function(d,i) { - if (!interactive) return; - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - point: d, - series: data[0], - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - }) - .on('click', function(d,i) { - if (!interactive) return; - dispatch.elementClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - if (!interactive) return; - dispatch.elementDblClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - bars - .attr('fill', function(d,i) { return color(d, i); }) - .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) - .transition() - .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) - //TODO: better width calculations that don't assume always uniform data spacing;w - .attr('width', (availableWidth / data[0].values.length) * .9 ); - - - bars.transition() - .attr('y', function(d,i) { - var rval = getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : - y(getY(d,i)); - return nv.utils.NaNtoZero(rval); - }) - .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) }); - - }); - - return chart; - } - - //Create methods to allow outside functions to highlight a specific bar. - chart.highlightPoint = function(pointIndex, isHoverOver) { - d3.select(".nv-historicalBar-" + id) - .select(".nv-bars .nv-bar-0-" + pointIndex) - .classed("hover", isHoverOver) - ; - }; - - chart.clearHighlights = function() { - d3.select(".nv-historicalBar-" + id) - .select(".nv-bars .nv-bar.hover") - .classed("hover", false) - ; - }; - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.padData = function(_) { - if (!arguments.length) return padData; - padData = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.interactive = function(_) { - if(!arguments.length) return interactive; - interactive = false; - return chart; - }; - - //============================================================ - - - return chart; -} - -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ - -nv.models.bullet = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , orient = 'left' // TODO top & bottom - , reverse = false - , ranges = function(d) { return d.ranges } - , markers = function(d) { return d.markers } - , measures = function(d) { return d.measures } - , rangeLabels = function(d) { return d.rangeLabels ? d.rangeLabels : [] } - , markerLabels = function(d) { return d.markerLabels ? d.markerLabels : [] } - , measureLabels = function(d) { return d.measureLabels ? d.measureLabels : [] } - , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) - , width = 380 - , height = 30 - , tickFormat = null - , color = nv.utils.getColor(['#1f77b4']) - , dispatch = d3.dispatch('elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(d, i) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending), - rangeLabelz = rangeLabels.call(this, d, i).slice(), - markerLabelz = markerLabels.call(this, d, i).slice(), - measureLabelz = measureLabels.call(this, d, i).slice(); - - - //------------------------------------------------------------ - // Setup Scales - - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain( d3.extent(d3.merge([forceX, rangez])) ) - .range(reverse ? [availableWidth, 0] : [0, availableWidth]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - - var rangeMin = d3.min(rangez), //rangez[2] - rangeMax = d3.max(rangez), //rangez[0] - rangeAvg = rangez[1]; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('rect').attr('class', 'nv-range nv-rangeMax'); - gEnter.append('rect').attr('class', 'nv-range nv-rangeAvg'); - gEnter.append('rect').attr('class', 'nv-range nv-rangeMin'); - gEnter.append('rect').attr('class', 'nv-measure'); - gEnter.append('path').attr('class', 'nv-markerTriangle'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - var xp0 = function(d) { return d < 0 ? x0(d) : x0(0) }, - xp1 = function(d) { return d < 0 ? x1(d) : x1(0) }; - - - g.select('rect.nv-rangeMax') - .attr('height', availableHeight) - .attr('width', w1(rangeMax > 0 ? rangeMax : rangeMin)) - .attr('x', xp1(rangeMax > 0 ? rangeMax : rangeMin)) - .datum(rangeMax > 0 ? rangeMax : rangeMin) - /* - .attr('x', rangeMin < 0 ? - rangeMax > 0 ? - x1(rangeMin) - : x1(rangeMax) - : x1(0)) - */ - - g.select('rect.nv-rangeAvg') - .attr('height', availableHeight) - .attr('width', w1(rangeAvg)) - .attr('x', xp1(rangeAvg)) - .datum(rangeAvg) - /* - .attr('width', rangeMax <= 0 ? - x1(rangeMax) - x1(rangeAvg) - : x1(rangeAvg) - x1(rangeMin)) - .attr('x', rangeMax <= 0 ? - x1(rangeAvg) - : x1(rangeMin)) - */ - - g.select('rect.nv-rangeMin') - .attr('height', availableHeight) - .attr('width', w1(rangeMax)) - .attr('x', xp1(rangeMax)) - .attr('width', w1(rangeMax > 0 ? rangeMin : rangeMax)) - .attr('x', xp1(rangeMax > 0 ? rangeMin : rangeMax)) - .datum(rangeMax > 0 ? rangeMin : rangeMax) - /* - .attr('width', rangeMax <= 0 ? - x1(rangeAvg) - x1(rangeMin) - : x1(rangeMax) - x1(rangeAvg)) - .attr('x', rangeMax <= 0 ? - x1(rangeMin) - : x1(rangeAvg)) - */ - - g.select('rect.nv-measure') - .style('fill', color) - .attr('height', availableHeight / 3) - .attr('y', availableHeight / 3) - .attr('width', measurez < 0 ? - x1(0) - x1(measurez[0]) - : x1(measurez[0]) - x1(0)) - .attr('x', xp1(measurez)) - .on('mouseover', function() { - dispatch.elementMouseover({ - value: measurez[0], - label: measureLabelz[0] || 'Current', - pos: [x1(measurez[0]), availableHeight/2] - }) - }) - .on('mouseout', function() { - dispatch.elementMouseout({ - value: measurez[0], - label: measureLabelz[0] || 'Current' - }) - }) - - var h3 = availableHeight / 6; - if (markerz[0]) { - g.selectAll('path.nv-markerTriangle') - .attr('transform', function(d) { return 'translate(' + x1(markerz[0]) + ',' + (availableHeight / 2) + ')' }) - .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') - .on('mouseover', function() { - dispatch.elementMouseover({ - value: markerz[0], - label: markerLabelz[0] || 'Previous', - pos: [x1(markerz[0]), availableHeight/2] - }) - }) - .on('mouseout', function() { - dispatch.elementMouseout({ - value: markerz[0], - label: markerLabelz[0] || 'Previous' - }) - }); - } else { - g.selectAll('path.nv-markerTriangle').remove(); - } - - - wrap.selectAll('.nv-range') - .on('mouseover', function(d,i) { - var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); - - dispatch.elementMouseover({ - value: d, - label: label, - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d,i) { - var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); - - dispatch.elementMouseout({ - value: d, - label: label - }) - }) - -/* // THIS IS THE PREVIOUS BULLET IMPLEMENTATION, WILL REMOVE SHORTLY - // Update the range rects. - var range = g.selectAll('rect.nv-range') - .data(rangez); - - range.enter().append('rect') - .attr('class', function(d, i) { return 'nv-range nv-s' + i; }) - .attr('width', w0) - .attr('height', availableHeight) - .attr('x', reverse ? x0 : 0) - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: (i <= 0) ? 'Maximum' : (i > 1) ? 'Minimum' : 'Mean', //TODO: make these labels a variable - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: (i <= 0) ? 'Minimum' : (i >=1) ? 'Maximum' : 'Mean' //TODO: make these labels a variable - }) - }) - - d3.transition(range) - .attr('x', reverse ? x1 : 0) - .attr('width', w1) - .attr('height', availableHeight); - - - // Update the measure rects. - var measure = g.selectAll('rect.nv-measure') - .data(measurez); - - measure.enter().append('rect') - .attr('class', function(d, i) { return 'nv-measure nv-s' + i; }) - .style('fill', function(d,i) { return color(d,i ) }) - .attr('width', w0) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x0 : 0) - .attr('y', availableHeight / 3) - .on('mouseover', function(d) { - dispatch.elementMouseover({ - value: d, - label: 'Current', //TODO: make these labels a variable - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d) { - dispatch.elementMouseout({ - value: d, - label: 'Current' //TODO: make these labels a variable - }) - }) - - d3.transition(measure) - .attr('width', w1) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x1 : 0) - .attr('y', availableHeight / 3); - - - - // Update the marker lines. - var marker = g.selectAll('path.nv-markerTriangle') - .data(markerz); - - var h3 = availableHeight / 6; - marker.enter().append('path') - .attr('class', 'nv-markerTriangle') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',' + (availableHeight / 2) + ')' }) - .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: 'Previous', - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: 'Previous' - }) - }); - - d3.transition(marker) - .attr('transform', function(d) { return 'translate(' + (x1(d) - x1(0)) + ',' + (availableHeight / 2) + ')' }); - - marker.exit().remove(); -*/ - - }); - - // d3.timer.flush(); // Not needed? - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - // left, right, top, bottom - chart.orient = function(_) { - if (!arguments.length) return orient; - orient = _; - reverse = orient == 'right' || orient == 'bottom'; - return chart; - }; - - // ranges (bad, satisfactory, good) - chart.ranges = function(_) { - if (!arguments.length) return ranges; - ranges = _; - return chart; - }; - - // markers (previous, goal) - chart.markers = function(_) { - if (!arguments.length) return markers; - markers = _; - return chart; - }; - - // measures (actual, forecast) - chart.measures = function(_) { - if (!arguments.length) return measures; - measures = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.tickFormat = function(_) { - if (!arguments.length) return tickFormat; - tickFormat = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - //============================================================ - - - return chart; -}; - - - -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ -nv.models.bulletChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var bullet = nv.models.bullet() - ; - - var orient = 'left' // TODO top & bottom - , reverse = false - , margin = {top: 5, right: 40, bottom: 20, left: 120} - , ranges = function(d) { return d.ranges } - , markers = function(d) { return d.markers } - , measures = function(d) { return d.measures } - , width = null - , height = 55 - , tickFormat = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' - } - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left, - top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top, - content = tooltip(e.key, e.label, e.value, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(d, i) { - var container = d3.select(this); - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - that = this; - - - chart.update = function() { chart(selection) }; - chart.container = this; - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!d || !ranges.call(this, d, i)) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', 18 + margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-bulletWrap'); - gEnter.append('g').attr('class', 'nv-titles'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) // TODO: need to allow forceX and forceY, and xDomain, yDomain - .range(reverse ? [availableWidth, 0] : [0, availableWidth]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - /* - // Derive width-scales from the x-scales. - var w0 = bulletWidth(x0), - w1 = bulletWidth(x1); - - function bulletWidth(x) { - var x0 = x(0); - return function(d) { - return Math.abs(x(d) - x(0)); - }; - } - - function bulletTranslate(x) { - return function(d) { - return 'translate(' + x(d) + ',0)'; - }; - } - */ - - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - - - var title = gEnter.select('.nv-titles').append('g') - .attr('text-anchor', 'end') - .attr('transform', 'translate(-6,' + (height - margin.top - margin.bottom) / 2 + ')'); - title.append('text') - .attr('class', 'nv-title') - .text(function(d) { return d.title; }); - - title.append('text') - .attr('class', 'nv-subtitle') - .attr('dy', '1em') - .text(function(d) { return d.subtitle; }); - - - - bullet - .width(availableWidth) - .height(availableHeight) - - var bulletWrap = g.select('.nv-bulletWrap'); - - d3.transition(bulletWrap).call(bullet); - - - - // Compute the tick format. - var format = tickFormat || x1.tickFormat( availableWidth / 100 ); - - // Update the tick groups. - var tick = g.selectAll('g.nv-tick') - .data(x1.ticks( availableWidth / 50 ), function(d) { - return this.textContent || format(d); - }); - - // Initialize the ticks with the old scale, x0. - var tickEnter = tick.enter().append('g') - .attr('class', 'nv-tick') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' }) - .style('opacity', 1e-6); - - tickEnter.append('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); - - tickEnter.append('text') - .attr('text-anchor', 'middle') - .attr('dy', '1em') - .attr('y', availableHeight * 7 / 6) - .text(format); - - - // Transition the updating ticks to the new scale, x1. - var tickUpdate = d3.transition(tick) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1); - - tickUpdate.select('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); - - tickUpdate.select('text') - .attr('y', availableHeight * 7 / 6); - - // Transition the exiting ticks to the new scale, x1. - d3.transition(tick.exit()) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1e-6) - .remove(); - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - dispatch.on('tooltipShow', function(e) { - e.key = d.title; - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - }); - - d3.timer.flush(); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - bullet.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow(e); - }); - - bullet.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.bullet = bullet; - - d3.rebind(chart, bullet, 'color'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - // left, right, top, bottom - chart.orient = function(x) { - if (!arguments.length) return orient; - orient = x; - reverse = orient == 'right' || orient == 'bottom'; - return chart; - }; - - // ranges (bad, satisfactory, good) - chart.ranges = function(x) { - if (!arguments.length) return ranges; - ranges = x; - return chart; - }; - - // markers (previous, goal) - chart.markers = function(x) { - if (!arguments.length) return markers; - markers = x; - return chart; - }; - - // measures (actual, forecast) - chart.measures = function(x) { - if (!arguments.length) return measures; - measures = x; - return chart; - }; - - chart.width = function(x) { - if (!arguments.length) return width; - width = x; - return chart; - }; - - chart.height = function(x) { - if (!arguments.length) return height; - height = x; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.tickFormat = function(x) { - if (!arguments.length) return tickFormat; - tickFormat = x; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -}; - - - -nv.models.cumulativeLineChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , interactiveLayer = nv.interactiveGuideline() - ; - - var margin = {top: 30, right: 30, bottom: 50, left: 60} - , color = nv.utils.defaultColor() - , width = null - , height = null - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , tooltips = true - , showControls = true - , useInteractiveGuideline = false - , rescaleY = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , id = lines.id() - , state = { index: 0, rescaleY: rescaleY } - , defaultState = null - , noData = 'No Data Available.' - , average = function(d) { return d.average } - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , transitionDuration = 250 - , noErrorCheck = false //if set to TRUE, will bypass an error check in the indexify function. - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - ; - - //============================================================ - controls.updateState(false); - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var dx = d3.scale.linear() - , index = {i: 0, x: 0} - ; - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this).classed('nv-chart-' + id, true), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - var indexDrag = d3.behavior.drag() - .on('dragstart', dragStart) - .on('drag', dragMove) - .on('dragend', dragEnd); - - - function dragStart(d,i) { - d3.select(chart.container) - .style('cursor', 'ew-resize'); - } - - function dragMove(d,i) { - index.x = d3.event.x; - index.i = Math.round(dx.invert(index.x)); - updateZero(); - } - - function dragEnd(d,i) { - d3.select(chart.container) - .style('cursor', 'auto'); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = lines.xScale(); - y = lines.yScale(); - - - if (!rescaleY) { - var seriesDomains = data - .filter(function(series) { return !series.disabled }) - .map(function(series,i) { - var initialDomain = d3.extent(series.values, lines.y()); - - //account for series being disabled when losing 95% or more - if (initialDomain[0] < -.95) initialDomain[0] = -.95; - - return [ - (initialDomain[0] - initialDomain[1]) / (1 + initialDomain[1]), - (initialDomain[1] - initialDomain[0]) / (1 + initialDomain[0]) - ]; - }); - - var completeDomain = [ - d3.min(seriesDomains, function(d) { return d[0] }), - d3.max(seriesDomains, function(d) { return d[1] }) - ] - - lines.yDomain(completeDomain); - } else { - lines.yDomain(null); - } - - - dx .domain([0, data[0].values.length - 1]) //Assumes all series have same length - .range([0, availableWidth]) - .clamp(true); - - //------------------------------------------------------------ - - - var data = indexify(index.i, data); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - var interactivePointerEvents = (useInteractiveGuideline) ? "none" : "all"; - var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-interactive'); - gEnter.append('g').attr('class', 'nv-x nv-axis').style("pointer-events","none"); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-background'); - gEnter.append('g').attr('class', 'nv-linesWrap').style("pointer-events",interactivePointerEvents); - gEnter.append('g').attr('class', 'nv-avgLinesWrap').style("pointer-events","none"); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { key: 'Re-scale y-axis', disabled: !rescaleY } - ]; - - controls - .width(140) - .color(['#444', '#444', '#444']) - .rightAlign(false) - .margin({top: 5, right: 0, bottom: 5, left: 20}) - ; - - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - // Show error if series goes below 100% - var tempDisabled = data.filter(function(d) { return d.tempDisabled }); - - wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates - if (tempDisabled.length) { - wrap.append('text').attr('class', 'tempDisabled') - .attr('x', availableWidth / 2) - .attr('y', '-.71em') - .style('text-anchor', 'end') - .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.'); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - //------------------------------------------------------------ - //Set up interactive layer - if (useInteractiveGuideline) { - interactiveLayer - .width(availableWidth) - .height(availableHeight) - .margin({left:margin.left,top:margin.top}) - .svgContainer(container) - .xScale(x); - wrap.select(".nv-interactive").call(interactiveLayer); - } - - gEnter.select('.nv-background') - .append('rect'); - - g.select('.nv-background rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - lines - //.x(function(d) { return d.x }) - .y(function(d) { return d.display.y }) - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; })); - - - - var linesWrap = g.select('.nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled && !d.tempDisabled })); - - //d3.transition(linesWrap).call(lines); - linesWrap.call(lines); - - /*Handle average lines [AN-612] ----------------------------*/ - - //Store a series index number in the data array. - data.forEach(function(d,i) { - d.seriesIndex = i; - }); - - var avgLineData = data.filter(function(d) { - return !d.disabled && !!average(d); - }); - - var avgLines = g.select(".nv-avgLinesWrap").selectAll("line") - .data(avgLineData, function(d) { return d.key; }); - - var getAvgLineY = function(d) { - //If average lines go off the svg element, clamp them to the svg bounds. - var yVal = y(average(d)); - if (yVal < 0) return 0; - if (yVal > availableHeight) return availableHeight; - return yVal; - }; - - avgLines.enter() - .append('line') - .style('stroke-width',2) - .style('stroke-dasharray','10,10') - .style('stroke',function (d,i) { - return lines.color()(d,d.seriesIndex); - }) - .attr('x1',0) - .attr('x2',availableWidth) - .attr('y1', getAvgLineY) - .attr('y2', getAvgLineY); - - avgLines - .style('stroke-opacity',function(d){ - //If average lines go offscreen, make them transparent - var yVal = y(average(d)); - if (yVal < 0 || yVal > availableHeight) return 0; - return 1; - }) - .attr('x1',0) - .attr('x2',availableWidth) - .attr('y1', getAvgLineY) - .attr('y2', getAvgLineY); - - avgLines.exit().remove(); - - //Create index line ----------------------------------------- - - var indexLine = linesWrap.selectAll('.nv-indexLine') - .data([index]); - indexLine.enter().append('rect').attr('class', 'nv-indexLine') - .attr('width', 3) - .attr('x', -2) - .attr('fill', 'red') - .attr('fill-opacity', .5) - .style("pointer-events","all") - .call(indexDrag) - - indexLine - .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' }) - .attr('height', availableHeight) - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - //Suggest how many ticks based on the chart width and D3 should listen (70 is the optimal number for MM/DD/YY dates) - .ticks( Math.min(data[0].values.length,availableWidth/70) ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - } - - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-y.nv-axis')) - .call(yAxis); - } - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - - function updateZero() { - indexLine - .data([index]); - - //When dragging the index line, turn off line transitions. - // Then turn them back on when done dragging. - var oldDuration = chart.transitionDuration(); - chart.transitionDuration(0); - chart.update(); - chart.transitionDuration(oldDuration); - } - - g.select('.nv-background rect') - .on('click', function() { - index.x = d3.mouse(this)[0]; - index.i = Math.round(dx.invert(index.x)); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - - updateZero(); - }); - - lines.dispatch.on('elementClick', function(e) { - index.i = e.pointIndex; - index.x = dx(index.i); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - - updateZero(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - rescaleY = !d.disabled; - - state.rescaleY = rescaleY; - dispatch.stateChange(state); - chart.update(); - }); - - - legend.dispatch.on('stateChange', function(newState) { - state.disabled = newState.disabled; - dispatch.stateChange(state); - chart.update(); - }); - - interactiveLayer.dispatch.on('elementMousemove', function(e) { - lines.clearHighlights(); - var singlePoint, pointIndex, pointXLocation, allData = []; - - - data - .filter(function(series, i) { - series.seriesIndex = i; - return !series.disabled; - }) - .forEach(function(series,i) { - pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); - lines.highlightPoint(i, pointIndex, true); - var point = series.values[pointIndex]; - if (typeof point === 'undefined') return; - if (typeof singlePoint === 'undefined') singlePoint = point; - if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); - allData.push({ - key: series.key, - value: chart.y()(point, pointIndex), - color: color(series,series.seriesIndex) - }); - }); - - //Highlight the tooltip entry based on which point the mouse is closest to. - if (allData.length > 2) { - var yValue = chart.yScale().invert(e.mouseY); - var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); - var threshold = 0.03 * domainExtent; - var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); - if (indexToHighlight !== null) - allData[indexToHighlight].highlight = true; - } - - var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex), pointIndex); - interactiveLayer.tooltip - .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) - .chartContainer(that.parentNode) - .enabled(tooltips) - .valueFormatter(function(d,i) { - return yAxis.tickFormat()(d); - }) - .data( - { - value: xValue, - series: allData - } - )(); - - interactiveLayer.renderGuideLine(pointXLocation); - - }); - - interactiveLayer.dispatch.on("elementMouseout",function(e) { - dispatch.tooltipHide(); - lines.clearHighlights(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - - if (typeof e.index !== 'undefined') { - index.i = e.index; - index.x = dx(index.i); - - state.index = e.index; - - indexLine - .data([index]); - } - - - if (typeof e.rescaleY !== 'undefined') { - rescaleY = e.rescaleY; - } - - chart.update(); - }); - - //============================================================ - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.lines = lines; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.interactiveLayer = interactiveLayer; - - d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'xScale','yScale', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi','useVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.rescaleY = function(_) { - if (!arguments.length) return rescaleY; - rescaleY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.useInteractiveGuideline = function(_) { - if(!arguments.length) return useInteractiveGuideline; - useInteractiveGuideline = _; - if (_ === true) { - chart.interactive(false); - chart.useVoronoi(false); - } - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.average = function(_) { - if(!arguments.length) return average; - average = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - chart.noErrorCheck = function(_) { - if (!arguments.length) return noErrorCheck; - noErrorCheck = _; - return chart; - }; - - //============================================================ - - - //============================================================ - // Functions - //------------------------------------------------------------ - - /* Normalize the data according to an index point. */ - function indexify(idx, data) { - return data.map(function(line, i) { - if (!line.values) { - return line; - } - var indexValue = line.values[idx]; - if (indexValue == null) { - return line; - } - var v = lines.y()(indexValue, idx); - - //TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue - if (v < -.95 && !noErrorCheck) { - //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100) - - line.tempDisabled = true; - return line; - } - - line.tempDisabled = false; - - line.values = line.values.map(function(point, pointIndex) { - point.display = {'y': (lines.y()(point, pointIndex) - v) / (1 + v) }; - return point; - }) - - return line; - }) - } - - //============================================================ - - - return chart; -} -//TODO: consider deprecating by adding necessary features to multiBar model -nv.models.discreteBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.ordinal() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove - , color = nv.utils.defaultColor() - , showValues = false - , valueFormat = d3.format(',.2f') - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - , rectClass = 'discreteBar' - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0 } - }) - }); - - x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands(xRange || [0, availableWidth], .1); - - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY))); - - - // If showValues, pad the Y axis range to account for label height - if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]); - else y.range(yRange || [availableHeight, 0]); - - //store old scales if they exist - x0 = x0 || x; - y0 = y0 || y.copy().range([y(0),y(0)]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-groups'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit() - .transition() - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }); - groups - .transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .75); - - - var bars = groups.selectAll('g.nv-bar') - .data(function(d) { return d.values }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('g') - .attr('transform', function(d,i,j) { - return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')' - }) - .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - value: getY(d,i), - point: d, - series: data[d.series], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }); - - barsEnter.append('rect') - .attr('height', 0) - .attr('width', x.rangeBand() * .9 / data.length ) - - if (showValues) { - barsEnter.append('text') - .attr('text-anchor', 'middle') - ; - - bars.select('text') - .text(function(d,i) { return valueFormat(getY(d,i)) }) - .transition() - .attr('x', x.rangeBand() * .9 / 2) - .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 }) - - ; - } else { - bars.selectAll('text').remove(); - } - - bars - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' }) - .style('fill', function(d,i) { return d.color || color(d,i) }) - .style('stroke', function(d,i) { return d.color || color(d,i) }) - .select('rect') - .attr('class', rectClass) - .transition() - .attr('width', x.rangeBand() * .9 / data.length); - bars.transition() - //.delay(function(d,i) { return i * 1200 / data[0].values.length }) - .attr('transform', function(d,i) { - var left = x(getX(d,i)) + x.rangeBand() * .05, - top = getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : //make 1 px positive bars show up above y=0 - y(getY(d,i)); - - return 'translate(' + left + ', ' + top + ')' - }) - .select('rect') - .attr('height', function(d,i) { - return Math.max(Math.abs(y(getY(d,i)) - y((yDomain && yDomain[0]) || 0)) || 1) - }); - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.showValues = function(_) { - if (!arguments.length) return showValues; - showValues = _; - return chart; - }; - - chart.valueFormat= function(_) { - if (!arguments.length) return valueFormat; - valueFormat = _; - return chart; - }; - - chart.rectClass= function(_) { - if (!arguments.length) return rectClass; - rectClass = _; - return chart; - }; - //============================================================ - - - return chart; -} - -nv.models.discreteBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var discretebar = nv.models.discreteBar() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - ; - - var margin = {top: 15, right: 10, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.getColor() - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , staggerLabels = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' - } - , x - , y - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate') - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .highlightZero(false) - .showMaxMin(false) - .tickFormat(function(d) { return d }) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickFormat(d3.format(',.1f')) - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { - dispatch.beforeUpdate(); - container.transition().duration(transitionDuration).call(chart); - }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = discretebar.xScale(); - y = discretebar.yScale().clamp(true); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g'); - var defsEnter = gEnter.append('defs'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis') - .append('g').attr('class', 'nv-zeroLine') - .append('line'); - - gEnter.append('g').attr('class', 'nv-barsWrap'); - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Main Chart Component(s) - - discretebar - .width(availableWidth) - .height(availableHeight); - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(discretebar); - - //------------------------------------------------------------ - - - - defsEnter.append('clipPath') - .attr('id', 'nv-x-label-clip-' + discretebar.id()) - .append('rect'); - - g.select('#nv-x-label-clip-' + discretebar.id() + ' rect') - .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1)) - .attr('height', 16) - .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 )); - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')'); - //d3.transition(g.select('.nv-x.nv-axis')) - g.select('.nv-x.nv-axis').transition() - .call(xAxis); - - - var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); - - if (staggerLabels) { - xTicks - .selectAll('text') - .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' }) - } - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis').transition() - .call(yAxis); - } - - // Zero line - g.select(".nv-zeroLine line") - .attr("x1",0) - .attr("x2",availableWidth) - .attr("y1", y(0)) - .attr("y2", y(0)) - ; - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - - }); - - return chart; - } - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - discretebar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - discretebar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.discretebar = discretebar; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - discretebar.color(color); - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.distribution = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 400 //technically width or height depending on x or y.... - , size = 8 - , axis = 'x' // 'x' or 'y'... horizontal or vertical - , getData = function(d) { return d[axis] } // defaults d.x or d.y - , color = nv.utils.defaultColor() - , scale = d3.scale.linear() - , domain - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var scale0; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom), - naxis = axis == 'x' ? 'y' : 'x', - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - scale0 = scale0 || scale; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-distribution').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') - - //------------------------------------------------------------ - - - var distWrap = g.selectAll('g.nv-dist') - .data(function(d) { return d }, function(d) { return d.key }); - - distWrap.enter().append('g'); - distWrap - .attr('class', function(d,i) { return 'nv-dist nv-series-' + i }) - .style('stroke', function(d,i) { return color(d, i) }); - - var dist = distWrap.selectAll('line.nv-dist' + axis) - .data(function(d) { return d.values }) - dist.enter().append('line') - .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) }) - distWrap.exit().selectAll('line.nv-dist' + axis) - .transition() - .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) - .style('stroke-opacity', 0) - .remove(); - dist - .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i }) - .attr(naxis + '1', 0) - .attr(naxis + '2', size); - dist - .transition() - .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) - - - scale0 = scale.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.axis = function(_) { - if (!arguments.length) return axis; - axis = _; - return chart; - }; - - chart.size = function(_) { - if (!arguments.length) return size; - size = _; - return chart; - }; - - chart.getData = function(_) { - if (!arguments.length) return getData; - getData = d3.functor(_); - return chart; - }; - - chart.scale = function(_) { - if (!arguments.length) return scale; - scale = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - //============================================================ - - - return chart; -} - -nv.models.historicalBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var bars = nv.models.historicalBar() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - ; - - - var margin = {top: 30, right: 90, bottom: 50, left: 90} - , color = nv.utils.defaultColor() - , width = null - , height = null - , showLegend = false - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , x - , y - , state = {} - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient( (rightAlignYAxis) ? 'right' : 'left') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - - // New addition to calculate position if SVG is scaled with viewBox, may move TODO: consider implementing everywhere else - if (offsetElement) { - var svg = d3.select(offsetElement).select('svg'); - var viewBox = (svg.node()) ? svg.attr('viewBox') : null; - if (viewBox) { - viewBox = viewBox.split(' '); - var ratio = parseInt(svg.style('width')) / viewBox[2]; - e.pos[0] = e.pos[0] * ratio; - e.pos[1] = e.pos[1] * ratio; - } - } - - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(bars.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(bars.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = bars.xScale(); - y = bars.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-historicalBarChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBarChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - - //------------------------------------------------------------ - // Main Chart Component(s) - - bars - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(bars); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - g.select('.nv-x.nv-axis') - .transition() - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .transition() - .call(yAxis); - } - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.nv-series').classed('disabled', false); - return d; - }); - } - - state.disabled = data.map(function(d) { return !!d.disabled }); - dispatch.stateChange(state); - - selection.transition().call(chart); - }); - - legend.dispatch.on('legendDblclick', function(d) { - //Double clicking should always enable current series, and disabled all others. - data.forEach(function(d) { - d.disabled = true; - }); - d.disabled = false; - - state.disabled = data.map(function(d) { return !!d.disabled }); - dispatch.stateChange(state); - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.bars = bars; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, bars, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', - 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id', 'interpolate','highlightPoint','clearHighlights', 'interactive'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} -nv.models.indentedTree = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} //TODO: implement, maybe as margin on the containing div - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() - , id = Math.floor(Math.random() * 10000) - , header = true - , filterZero = false - , noData = "No Data Available." - , childIndent = 20 - , columns = [{key:'key', label: 'Name', type:'text'}] //TODO: consider functions like chart.addColumn, chart.removeColumn, instead of a block like this - , tableClass = null - , iconOpen = 'images/grey-plus.png' //TODO: consider removing this and replacing with a '+' or '-' unless user defines images - , iconClose = 'images/grey-minus.png' - , dispatch = d3.dispatch('elementClick', 'elementDblclick', 'elementMouseover', 'elementMouseout') - , getUrl = function(d) { return d.url } - ; - - //============================================================ - - var idx = 0; - - function chart(selection) { - selection.each(function(data) { - var depth = 1, - container = d3.select(this); - - var tree = d3.layout.tree() - .children(function(d) { return d.values }) - .size([height, childIndent]); //Not sure if this is needed now that the result is HTML - - chart.update = function() { container.transition().duration(600).call(chart) }; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - if (!data[0]) data[0] = {key: noData}; - - //------------------------------------------------------------ - - - var nodes = tree.nodes(data[0]); - - // nodes.map(function(d) { - // d.id = i++; - // }) - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('div').data([[nodes]]); - var wrapEnter = wrap.enter().append('div').attr('class', 'nvd3 nv-wrap nv-indentedtree'); - var tableEnter = wrapEnter.append('table'); - var table = wrap.select('table').attr('width', '100%').attr('class', tableClass); - - //------------------------------------------------------------ - - - if (header) { - var thead = tableEnter.append('thead'); - - var theadRow1 = thead.append('tr'); - - columns.forEach(function(column) { - theadRow1 - .append('th') - .attr('width', column.width ? column.width : '10%') - .style('text-align', column.type == 'numeric' ? 'right' : 'left') - .append('span') - .text(column.label); - }); - } - - - var tbody = table.selectAll('tbody') - .data(function(d) { return d }); - tbody.enter().append('tbody'); - - - - //compute max generations - depth = d3.max(nodes, function(node) { return node.depth }); - tree.size([height, depth * childIndent]); //TODO: see if this is necessary at all - - - // Update the nodes… - var node = tbody.selectAll('tr') - // .data(function(d) { return d; }, function(d) { return d.id || (d.id == ++i)}); - .data(function(d) { return d.filter(function(d) { return (filterZero && !d.children) ? filterZero(d) : true; } )}, function(d,i) { return d.id || (d.id || ++idx)}); - //.style('display', 'table-row'); //TODO: see if this does anything - - node.exit().remove(); - - node.select('img.nv-treeicon') - .attr('src', icon) - .classed('folded', folded); - - var nodeEnter = node.enter().append('tr'); - - - columns.forEach(function(column, index) { - - var nodeName = nodeEnter.append('td') - .style('padding-left', function(d) { return (index ? 0 : d.depth * childIndent + 12 + (icon(d) ? 0 : 16)) + 'px' }, 'important') //TODO: check why I did the ternary here - .style('text-align', column.type == 'numeric' ? 'right' : 'left'); - - - if (index == 0) { - nodeName.append('img') - .classed('nv-treeicon', true) - .classed('nv-folded', folded) - .attr('src', icon) - .style('width', '14px') - .style('height', '14px') - .style('padding', '0 1px') - .style('display', function(d) { return icon(d) ? 'inline-block' : 'none'; }) - .on('click', click); - } - - - nodeName.each(function(d) { - if (!index && getUrl(d)) - d3.select(this) - .append('a') - .attr('href',getUrl) - .attr('class', d3.functor(column.classes)) - .append('span') - else - d3.select(this) - .append('span') - - d3.select(this).select('span') - .attr('class', d3.functor(column.classes) ) - .text(function(d) { return column.format ? (d[column.key] ? column.format(d[column.key]) : '-') : (d[column.key] || '-'); }); - }); - - if (column.showCount) { - nodeName.append('span') - .attr('class', 'nv-childrenCount'); - - node.selectAll('span.nv-childrenCount').text(function(d) { - return ((d.values && d.values.length) || (d._values && d._values.length)) ? //If this is a parent - '(' + ((d.values && (d.values.filter(function(d) { return filterZero ? filterZero(d) : true; }).length)) //If children are in values check its children and filter - || (d._values && d._values.filter(function(d) { return filterZero ? filterZero(d) : true; }).length) //Otherwise, do the same, but with the other name, _values... - || 0) + ')' //This is the catch-all in case there are no children after a filter - : '' //If this is not a parent, just give an empty string - }); - } - - // if (column.click) - // nodeName.select('span').on('click', column.click); - - }); - - node - .order() - .on('click', function(d) { - dispatch.elementClick({ - row: this, //TODO: decide whether or not this should be consistent with scatter/line events or should be an html link (a href) - data: d, - pos: [d.x, d.y] - }); - }) - .on('dblclick', function(d) { - dispatch.elementDblclick({ - row: this, - data: d, - pos: [d.x, d.y] - }); - }) - .on('mouseover', function(d) { - dispatch.elementMouseover({ - row: this, - data: d, - pos: [d.x, d.y] - }); - }) - .on('mouseout', function(d) { - dispatch.elementMouseout({ - row: this, - data: d, - pos: [d.x, d.y] - }); - }); - - - - - // Toggle children on click. - function click(d, _, unshift) { - d3.event.stopPropagation(); - - if(d3.event.shiftKey && !unshift) { - //If you shift-click, it'll toggle fold all the children, instead of itself - d3.event.shiftKey = false; - d.values && d.values.forEach(function(node){ - if (node.values || node._values) { - click(node, 0, true); - } - }); - return true; - } - if(!hasChildren(d)) { - //download file - //window.location.href = d.url; - return true; - } - if (d.values) { - d._values = d.values; - d.values = null; - } else { - d.values = d._values; - d._values = null; - } - chart.update(); - } - - - function icon(d) { - return (d._values && d._values.length) ? iconOpen : (d.values && d.values.length) ? iconClose : ''; - } - - function folded(d) { - return (d._values && d._values.length); - } - - function hasChildren(d) { - var values = d.values || d._values; - - return (values && values.length); - } - - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - scatter.color(color); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.header = function(_) { - if (!arguments.length) return header; - header = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.filterZero = function(_) { - if (!arguments.length) return filterZero; - filterZero = _; - return chart; - }; - - chart.columns = function(_) { - if (!arguments.length) return columns; - columns = _; - return chart; - }; - - chart.tableClass = function(_) { - if (!arguments.length) return tableClass; - tableClass = _; - return chart; - }; - - chart.iconOpen = function(_){ - if (!arguments.length) return iconOpen; - iconOpen = _; - return chart; - } - - chart.iconClose = function(_){ - if (!arguments.length) return iconClose; - iconClose = _; - return chart; - } - - chart.getUrl = function(_){ - if (!arguments.length) return getUrl; - getUrl = _; - return chart; - } - - //============================================================ - - - return chart; -};nv.models.legend = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 5, right: 0, bottom: 5, left: 0} - , width = 400 - , height = 20 - , getKey = function(d) { return d.key } - , color = nv.utils.defaultColor() - , align = true - , rightAlign = true - , updateState = true //If true, legend will update data.disabled and trigger a 'stateChange' dispatch. - , radioButtonMode = false //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time) - , dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange') - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-legend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g'); - var g = wrap.select('g'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - var series = g.selectAll('.nv-series') - .data(function(d) { return d }); - var seriesEnter = series.enter().append('g').attr('class', 'nv-series') - .on('mouseover', function(d,i) { - dispatch.legendMouseover(d,i); //TODO: Make consistent with other event objects - }) - .on('mouseout', function(d,i) { - dispatch.legendMouseout(d,i); - }) - .on('click', function(d,i) { - dispatch.legendClick(d,i); - if (updateState) { - if (radioButtonMode) { - //Radio button mode: set every series to disabled, - // and enable the clicked series. - data.forEach(function(series) { series.disabled = true}); - d.disabled = false; - } - else { - d.disabled = !d.disabled; - if (data.every(function(series) { return series.disabled})) { - //the default behavior of NVD3 legends is, if every single series - // is disabled, turn all series' back on. - data.forEach(function(series) { series.disabled = false}); - } - } - dispatch.stateChange({ - disabled: data.map(function(d) { return !!d.disabled }) - }); - } - }) - .on('dblclick', function(d,i) { - dispatch.legendDblclick(d,i); - if (updateState) { - //the default behavior of NVD3 legends, when double clicking one, - // is to set all other series' to false, and make the double clicked series enabled. - data.forEach(function(series) { - series.disabled = true; - }); - d.disabled = false; - dispatch.stateChange({ - disabled: data.map(function(d) { return !!d.disabled }) - }); - } - }); - seriesEnter.append('circle') - .style('stroke-width', 2) - .attr('class','nv-legend-symbol') - .attr('r', 5); - seriesEnter.append('text') - .attr('text-anchor', 'start') - .attr('class','nv-legend-text') - .attr('dy', '.32em') - .attr('dx', '8'); - series.classed('disabled', function(d) { return d.disabled }); - series.exit().remove(); - series.select('circle') - .style('fill', function(d,i) { return d.color || color(d,i)}) - .style('stroke', function(d,i) { return d.color || color(d, i) }); - series.select('text').text(getKey); - - - //TODO: implement fixed-width and max-width options (max-width is especially useful with the align option) - - // NEW ALIGNING CODE, TODO: clean up - if (align) { - - var seriesWidths = []; - series.each(function(d,i) { - var legendText = d3.select(this).select('text'); - var nodeTextLength; - try { - nodeTextLength = legendText.getComputedTextLength(); - // If the legendText is display:none'd (nodeTextLength == 0), simulate an error so we approximate, instead - if(nodeTextLength <= 0) throw Error(); - } - catch(e) { - nodeTextLength = nv.utils.calcApproxTextWidth(legendText); - } - - seriesWidths.push(nodeTextLength + 28); // 28 is ~ the width of the circle plus some padding - }); - - var seriesPerRow = 0; - var legendWidth = 0; - var columnWidths = []; - - while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) { - columnWidths[seriesPerRow] = seriesWidths[seriesPerRow]; - legendWidth += seriesWidths[seriesPerRow++]; - } - if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row - - - while ( legendWidth > availableWidth && seriesPerRow > 1 ) { - columnWidths = []; - seriesPerRow--; - - for (var k = 0; k < seriesWidths.length; k++) { - if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) ) - columnWidths[k % seriesPerRow] = seriesWidths[k]; - } - - legendWidth = columnWidths.reduce(function(prev, cur, index, array) { - return prev + cur; - }); - } - - var xPositions = []; - for (var i = 0, curX = 0; i < seriesPerRow; i++) { - xPositions[i] = curX; - curX += columnWidths[i]; - } - - series - .attr('transform', function(d, i) { - return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * 20) + ')'; - }); - - //position legend as far right as possible within the total width - if (rightAlign) { - g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')'); - } - else { - g.attr('transform', 'translate(0' + ',' + margin.top + ')'); - } - - height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * 20); - - } else { - - var ypos = 5, - newxpos = 5, - maxwidth = 0, - xpos; - series - .attr('transform', function(d, i) { - var length = d3.select(this).select('text').node().getComputedTextLength() + 28; - xpos = newxpos; - - if (width < margin.left + margin.right + xpos + length) { - newxpos = xpos = 5; - ypos += 20; - } - - newxpos += length; - if (newxpos > maxwidth) maxwidth = newxpos; - - return 'translate(' + xpos + ',' + ypos + ')'; - }); - - //position legend as far right as possible within the total width - g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')'); - - height = margin.top + margin.bottom + ypos + 15; - - } - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.key = function(_) { - if (!arguments.length) return getKey; - getKey = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.align = function(_) { - if (!arguments.length) return align; - align = _; - return chart; - }; - - chart.rightAlign = function(_) { - if (!arguments.length) return rightAlign; - rightAlign = _; - return chart; - }; - - chart.updateState = function(_) { - if (!arguments.length) return updateState; - updateState = _; - return chart; - }; - - chart.radioButtonMode = function(_) { - if (!arguments.length) return radioButtonMode; - radioButtonMode = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.line = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var scatter = nv.models.scatter() - ; - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() // a function that returns a color - , getX = function(d) { return d.x } // accessor to get the x value from a data point - , getY = function(d) { return d.y } // accessor to get the y value from a data point - , defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined - , isArea = function(d) { return d.area } // decides if a line is an area or just a line - , clipEdge = false // if true, masks lines within x and y scale - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , interpolate = "linear" // controls the line interpolation - ; - - scatter - .size(16) // default size - .sizeDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0 //used to store previous scales - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - //------------------------------------------------------------ - // Setup Scales - - x = scatter.xScale(); - y = scatter.yScale(); - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-line').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - gEnter.append('g').attr('class', 'nv-groups'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - - scatter - .width(availableWidth) - .height(availableHeight) - - var scatterWrap = wrap.select('.nv-scatterWrap'); - //.datum(data); // Data automatically trickles down from the wrap - - scatterWrap.transition().call(scatter); - - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + scatter.id()) - .append('rect'); - - wrap.select('#nv-edge-clip-' + scatter.id() + ' rect') - .attr('width', availableWidth) - .attr('height', (availableHeight > 0) ? availableHeight : 0); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : ''); - scatterWrap - .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : ''); - - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - - groups.exit().remove(); - - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i)}); - groups - .transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .5); - - - - var areaPaths = groups.selectAll('path.nv-area') - .data(function(d) { return isArea(d) ? [d] : [] }); // this is done differently than lines because I need to check if series is an area - areaPaths.enter().append('path') - .attr('class', 'nv-area') - .attr('d', function(d) { - return d3.svg.area() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) - .y0(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) - .y1(function(d,i) { return y0( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) }) - //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this - .apply(this, [d.values]) - }); - groups.exit().selectAll('path.nv-area') - .remove(); - - areaPaths - .transition() - .attr('d', function(d) { - return d3.svg.area() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .y0(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - .y1(function(d,i) { return y( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) }) - //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this - .apply(this, [d.values]) - }); - - - - var linePaths = groups.selectAll('path.nv-line') - .data(function(d) { return [d.values] }); - linePaths.enter().append('path') - .attr('class', 'nv-line') - .attr('d', - d3.svg.line() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) - .y(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) - ); - - linePaths - .transition() - .attr('d', - d3.svg.line() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .y(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - ); - - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = scatter.dispatch; - chart.scatter = scatter; - - d3.rebind(chart, scatter, 'id', 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', - 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'useVoronoi', 'clipRadius', 'padData','highlightPoint','clearHighlights'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - scatter.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - scatter.y(_); - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - scatter.color(color); - return chart; - }; - - chart.interpolate = function(_) { - if (!arguments.length) return interpolate; - interpolate = _; - return chart; - }; - - chart.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return chart; - }; - - chart.isArea = function(_) { - if (!arguments.length) return isArea; - isArea = d3.functor(_); - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.lineChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , interactiveLayer = nv.interactiveGuideline() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 60} - , color = nv.utils.defaultColor() - , width = null - , height = null - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , useInteractiveGuideline = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , x - , y - , state = {} - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = lines.xScale(); - y = lines.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g'); - var g = wrap.select('g'); - - gEnter.append("rect").style("opacity",0); - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-linesWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-interactive'); - - g.select("rect") - .attr("width",availableWidth) - .attr("height",(availableHeight > 0) ? availableHeight : 0); - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - - //------------------------------------------------------------ - //Set up interactive layer - if (useInteractiveGuideline) { - interactiveLayer - .width(availableWidth) - .height(availableHeight) - .margin({left:margin.left, top:margin.top}) - .svgContainer(container) - .xScale(x); - wrap.select(".nv-interactive").call(interactiveLayer); - } - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - - - var linesWrap = g.select('.nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - linesWrap.transition().call(lines); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - g.select('.nv-x.nv-axis') - .transition() - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .transition() - .call(yAxis); - } - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - interactiveLayer.dispatch.on('elementMousemove', function(e) { - lines.clearHighlights(); - var singlePoint, pointIndex, pointXLocation, allData = []; - data - .filter(function(series, i) { - series.seriesIndex = i; - return !series.disabled; - }) - .forEach(function(series,i) { - pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); - lines.highlightPoint(i, pointIndex, true); - var point = series.values[pointIndex]; - if (typeof point === 'undefined') return; - if (typeof singlePoint === 'undefined') singlePoint = point; - if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); - allData.push({ - key: series.key, - value: chart.y()(point, pointIndex), - color: color(series,series.seriesIndex) - }); - }); - //Highlight the tooltip entry based on which point the mouse is closest to. - if (allData.length > 2) { - var yValue = chart.yScale().invert(e.mouseY); - var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); - var threshold = 0.03 * domainExtent; - var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); - if (indexToHighlight !== null) - allData[indexToHighlight].highlight = true; - } - - var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex)); - interactiveLayer.tooltip - .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) - .chartContainer(that.parentNode) - .enabled(tooltips) - .valueFormatter(function(d,i) { - return yAxis.tickFormat()(d); - }) - .data( - { - value: xValue, - series: allData - } - )(); - - interactiveLayer.renderGuideLine(pointXLocation); - - }); - - interactiveLayer.dispatch.on("elementMouseout",function(e) { - dispatch.tooltipHide(); - lines.clearHighlights(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.lines = lines; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.interactiveLayer = interactiveLayer; - - d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'xRange', 'yRange' - , 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'useVoronoi','id', 'interpolate'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.useInteractiveGuideline = function(_) { - if(!arguments.length) return useInteractiveGuideline; - useInteractiveGuideline = _; - if (_ === true) { - chart.interactive(false); - chart.useVoronoi(false); - } - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.linePlusBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , bars = nv.models.historicalBar() - , xAxis = nv.models.axis() - , y1Axis = nv.models.axis() - , y2Axis = nv.models.axis() - , legend = nv.models.legend() - ; - - var margin = {top: 30, right: 60, bottom: 50, left: 60} - , width = null - , height = null - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , color = nv.utils.defaultColor() - , showLegend = true - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

'; - } - , x - , y1 - , y2 - , state = {} - , defaultState = null - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - ; - - bars - .padData(true) - ; - lines - .clipEdge(false) - .padData(true) - ; - xAxis - .orient('bottom') - .tickPadding(7) - .highlightZero(false) - ; - y1Axis - .orient('left') - ; - y2Axis - .orient('right') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - } - ; - - //------------------------------------------------------------ - - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().call(chart); }; - // chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); - var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240 - - //x = xAxis.scale(); - x = dataLines.filter(function(d) { return !d.disabled; }).length && dataLines.filter(function(d) { return !d.disabled; })[0].values.length ? lines.xScale() : bars.xScale(); - //x = dataLines.filter(function(d) { return !d.disabled; }).length ? lines.xScale() : bars.xScale(); //old code before change above - y1 = bars.yScale(); - y2 = lines.yScale(); - - //------------------------------------------------------------ - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('g.nv-wrap.nv-linePlusBar').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y1 nv-axis'); - gEnter.append('g').attr('class', 'nv-y2 nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-linesWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width( availableWidth / 2 ); - - g.select('.nv-legendWrap') - .datum(data.map(function(series) { - series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; - series.key = series.originalKey + (series.bar ? ' (left axis)' : ' (right axis)'); - return series; - })) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })) - - bars - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })) - - - - var barsWrap = g.select('.nv-barsWrap') - .datum(dataBars.length ? dataBars : [{values:[]}]) - - var linesWrap = g.select('.nv-linesWrap') - .datum(dataLines[0] && !dataLines[0].disabled ? dataLines : [{values:[]}] ); - //.datum(!dataLines[0].disabled ? dataLines : [{values:dataLines[0].values.map(function(d) { return [d[0], null] }) }] ); - - d3.transition(barsWrap).call(bars); - d3.transition(linesWrap).call(lines); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - - - y1Axis - .scale(y1) - .ticks( availableHeight / 36 ) - .tickSize(-availableWidth, 0); - - d3.transition(g.select('.nv-y1.nv-axis')) - .style('opacity', dataBars.length ? 1 : 0) - .call(y1Axis); - - - y2Axis - .scale(y2) - .ticks( availableHeight / 36 ) - .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.nv-y2.nv-axis') - .style('opacity', dataLines.length ? 1 : 0) - .attr('transform', 'translate(' + availableWidth + ',0)'); - //.attr('transform', 'translate(' + x.range()[1] + ',0)'); - - d3.transition(g.select('.nv-y2.nv-axis')) - .call(y2Axis); - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.bars = bars; - chart.xAxis = xAxis; - chart.y1Axis = y1Axis; - chart.y2Axis = y2Axis; - - d3.rebind(chart, lines, 'defined', 'size', 'clipVoronoi', 'interpolate'); - //TODO: consider rebinding x, y and some other stuff, and simply do soemthign lile bars.x(lines.x()), etc. - //d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - bars.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - bars.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -} -nv.models.lineWithFocusChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , lines2 = nv.models.line() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , x2Axis = nv.models.axis() - , y2Axis = nv.models.axis() - , legend = nv.models.legend() - , brush = d3.svg.brush() - ; - - var margin = {top: 30, right: 30, bottom: 30, left: 60} - , margin2 = {top: 0, right: 30, bottom: 20, left: 60} - , color = nv.utils.defaultColor() - , width = null - , height = null - , height2 = 100 - , x - , y - , x2 - , y2 - , showLegend = true - , brushExtent = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush') - , transitionDuration = 250 - ; - - lines - .clipEdge(true) - ; - lines2 - .interactive(false) - ; - xAxis - .orient('bottom') - .tickPadding(5) - ; - yAxis - .orient('left') - ; - x2Axis - .orient('bottom') - .tickPadding(5) - ; - y2Axis - .orient('left') - ; - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2, - availableHeight2 = height2 - margin2.top - margin2.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight1 / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = lines.xScale(); - y = lines.yScale(); - x2 = lines2.xScale(); - y2 = lines2.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-lineWithFocusChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineWithFocusChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-legendWrap'); - - var focusEnter = gEnter.append('g').attr('class', 'nv-focus'); - focusEnter.append('g').attr('class', 'nv-x nv-axis'); - focusEnter.append('g').attr('class', 'nv-y nv-axis'); - focusEnter.append('g').attr('class', 'nv-linesWrap'); - - var contextEnter = gEnter.append('g').attr('class', 'nv-context'); - contextEnter.append('g').attr('class', 'nv-x nv-axis'); - contextEnter.append('g').attr('class', 'nv-y nv-axis'); - contextEnter.append('g').attr('class', 'nv-linesWrap'); - contextEnter.append('g').attr('class', 'nv-brushBackground'); - contextEnter.append('g').attr('class', 'nv-x nv-brush'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - lines - .width(availableWidth) - .height(availableHeight1) - .color( - data - .map(function(d,i) { - return d.color || color(d, i); - }) - .filter(function(d,i) { - return !data[i].disabled; - }) - ); - - lines2 - .defined(lines.defined()) - .width(availableWidth) - .height(availableHeight2) - .color( - data - .map(function(d,i) { - return d.color || color(d, i); - }) - .filter(function(d,i) { - return !data[i].disabled; - }) - ); - - g.select('.nv-context') - .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')') - - var contextLinesWrap = g.select('.nv-context .nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(contextLinesWrap).call(lines2); - - //------------------------------------------------------------ - - - /* - var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(focusLinesWrap).call(lines); - */ - - - //------------------------------------------------------------ - // Setup Main (Focus) Axes - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight1, 0); - - yAxis - .scale(y) - .ticks( availableHeight1 / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-focus .nv-x.nv-axis') - .attr('transform', 'translate(0,' + availableHeight1 + ')'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Brush - - brush - .x(x2) - .on('brush', function() { - //When brushing, turn off transitions because chart needs to change immediately. - var oldTransition = chart.transitionDuration(); - chart.transitionDuration(0); - onBrush(); - chart.transitionDuration(oldTransition); - }); - - if (brushExtent) brush.extent(brushExtent); - - var brushBG = g.select('.nv-brushBackground').selectAll('g') - .data([brushExtent || brush.extent()]) - - var brushBGenter = brushBG.enter() - .append('g'); - - brushBGenter.append('rect') - .attr('class', 'left') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - brushBGenter.append('rect') - .attr('class', 'right') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - var gBrush = g.select('.nv-x.nv-brush') - .call(brush); - gBrush.selectAll('rect') - //.attr('y', -5) - .attr('height', availableHeight2); - gBrush.selectAll('.resize').append('path').attr('d', resizePath); - - onBrush(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Secondary (Context) Axes - - x2Axis - .scale(x2) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight2, 0); - - g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); - d3.transition(g.select('.nv-context .nv-x.nv-axis')) - .call(x2Axis); - - - y2Axis - .scale(y2) - .ticks( availableHeight2 / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-context .nv-y.nv-axis')) - .call(y2Axis); - - g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - - //============================================================ - // Functions - //------------------------------------------------------------ - - // Taken from crossfilter (http://square.github.com/crossfilter/) - function resizePath(d) { - var e = +(d == 'e'), - x = e ? 1 : -1, - y = availableHeight2 / 3; - return 'M' + (.5 * x) + ',' + y - + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6) - + 'V' + (2 * y - 6) - + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y) - + 'Z' - + 'M' + (2.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8) - + 'M' + (4.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8); - } - - - function updateBrushBG() { - if (!brush.empty()) brush.extent(brushExtent); - brushBG - .data([brush.empty() ? x2.domain() : brushExtent]) - .each(function(d,i) { - var leftWidth = x2(d[0]) - x.range()[0], - rightWidth = x.range()[1] - x2(d[1]); - d3.select(this).select('.left') - .attr('width', leftWidth < 0 ? 0 : leftWidth); - - d3.select(this).select('.right') - .attr('x', x2(d[1])) - .attr('width', rightWidth < 0 ? 0 : rightWidth); - }); - } - - - function onBrush() { - brushExtent = brush.empty() ? null : brush.extent(); - var extent = brush.empty() ? x2.domain() : brush.extent(); - - //The brush extent cannot be less than one. If it is, don't update the line chart. - if (Math.abs(extent[0] - extent[1]) <= 1) { - return; - } - - dispatch.brush({extent: extent, brush: brush}); - - - updateBrushBG(); - - // Update Main (Focus) - var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum( - data - .filter(function(d) { return !d.disabled }) - .map(function(d,i) { - return { - key: d.key, - values: d.values.filter(function(d,i) { - return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1]; - }) - } - }) - ); - focusLinesWrap.transition().duration(transitionDuration).call(lines); - - - // Update Main (Focus) Axes - g.select('.nv-focus .nv-x.nv-axis').transition().duration(transitionDuration) - .call(xAxis); - g.select('.nv-focus .nv-y.nv-axis').transition().duration(transitionDuration) - .call(yAxis); - } - - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.lines2 = lines2; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.x2Axis = x2Axis; - chart.y2Axis = y2Axis; - - d3.rebind(chart, lines, 'defined', 'isArea', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return lines.x; - lines.x(_); - lines2.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return lines.y; - lines.y(_); - lines2.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.margin2 = function(_) { - if (!arguments.length) return margin2; - margin2 = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.height2 = function(_) { - if (!arguments.length) return height2; - height2 = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color =nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.interpolate = function(_) { - if (!arguments.length) return lines.interpolate(); - lines.interpolate(_); - lines2.interpolate(_); - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - // Chart has multiple similar Axes, to prevent code duplication, probably need to link all axis functions manually like below - chart.xTickFormat = function(_) { - if (!arguments.length) return xAxis.tickFormat(); - xAxis.tickFormat(_); - x2Axis.tickFormat(_); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return yAxis.tickFormat(); - yAxis.tickFormat(_); - y2Axis.tickFormat(_); - return chart; - }; - - chart.brushExtent = function(_) { - if (!arguments.length) return brushExtent; - brushExtent = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.linePlusBarWithFocusChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , lines2 = nv.models.line() - , bars = nv.models.historicalBar() - , bars2 = nv.models.historicalBar() - , xAxis = nv.models.axis() - , x2Axis = nv.models.axis() - , y1Axis = nv.models.axis() - , y2Axis = nv.models.axis() - , y3Axis = nv.models.axis() - , y4Axis = nv.models.axis() - , legend = nv.models.legend() - , brush = d3.svg.brush() - ; - - var margin = {top: 30, right: 30, bottom: 30, left: 60} - , margin2 = {top: 0, right: 30, bottom: 20, left: 60} - , width = null - , height = null - , height2 = 100 - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , color = nv.utils.defaultColor() - , showLegend = true - , extent - , brushExtent = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

'; - } - , x - , x2 - , y1 - , y2 - , y3 - , y4 - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush') - , transitionDuration = 0 - ; - - lines - .clipEdge(true) - ; - lines2 - .interactive(false) - ; - xAxis - .orient('bottom') - .tickPadding(5) - ; - y1Axis - .orient('left') - ; - y2Axis - .orient('right') - ; - x2Axis - .orient('bottom') - .tickPadding(5) - ; - y3Axis - .orient('left') - ; - y4Axis - .orient('right') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - if (extent) { - e.pointIndex += Math.ceil(extent[0]); - } - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //------------------------------------------------------------ - - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2, - availableHeight2 = height2 - margin2.top - margin2.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight1 / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); - var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240 - - x = bars.xScale(); - x2 = x2Axis.scale(); - y1 = bars.yScale(); - y2 = lines.yScale(); - y3 = bars2.yScale(); - y4 = lines2.yScale(); - - var series1 = data - .filter(function(d) { return !d.disabled && d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - var series2 = data - .filter(function(d) { return !d.disabled && !d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - x .range([0, availableWidth]); - - x2 .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) - .range([0, availableWidth]); - - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-linePlusBar').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-legendWrap'); - - var focusEnter = gEnter.append('g').attr('class', 'nv-focus'); - focusEnter.append('g').attr('class', 'nv-x nv-axis'); - focusEnter.append('g').attr('class', 'nv-y1 nv-axis'); - focusEnter.append('g').attr('class', 'nv-y2 nv-axis'); - focusEnter.append('g').attr('class', 'nv-barsWrap'); - focusEnter.append('g').attr('class', 'nv-linesWrap'); - - var contextEnter = gEnter.append('g').attr('class', 'nv-context'); - contextEnter.append('g').attr('class', 'nv-x nv-axis'); - contextEnter.append('g').attr('class', 'nv-y1 nv-axis'); - contextEnter.append('g').attr('class', 'nv-y2 nv-axis'); - contextEnter.append('g').attr('class', 'nv-barsWrap'); - contextEnter.append('g').attr('class', 'nv-linesWrap'); - contextEnter.append('g').attr('class', 'nv-brushBackground'); - contextEnter.append('g').attr('class', 'nv-x nv-brush'); - - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width( availableWidth / 2 ); - - g.select('.nv-legendWrap') - .datum(data.map(function(series) { - series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; - series.key = series.originalKey + (series.bar ? ' (left axis)' : ' (right axis)'); - return series; - })) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Context Components - - bars2 - .width(availableWidth) - .height(availableHeight2) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); - - lines2 - .width(availableWidth) - .height(availableHeight2) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })); - - var bars2Wrap = g.select('.nv-context .nv-barsWrap') - .datum(dataBars.length ? dataBars : [{values:[]}]); - - var lines2Wrap = g.select('.nv-context .nv-linesWrap') - .datum(!dataLines[0].disabled ? dataLines : [{values:[]}]); - - g.select('.nv-context') - .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')') - - bars2Wrap.transition().call(bars2); - lines2Wrap.transition().call(lines2); - - //------------------------------------------------------------ - - - - //------------------------------------------------------------ - // Setup Brush - - brush - .x(x2) - .on('brush', onBrush); - - if (brushExtent) brush.extent(brushExtent); - - var brushBG = g.select('.nv-brushBackground').selectAll('g') - .data([brushExtent || brush.extent()]) - - var brushBGenter = brushBG.enter() - .append('g'); - - brushBGenter.append('rect') - .attr('class', 'left') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - brushBGenter.append('rect') - .attr('class', 'right') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - var gBrush = g.select('.nv-x.nv-brush') - .call(brush); - gBrush.selectAll('rect') - //.attr('y', -5) - .attr('height', availableHeight2); - gBrush.selectAll('.resize').append('path').attr('d', resizePath); - - //------------------------------------------------------------ - - //------------------------------------------------------------ - // Setup Secondary (Context) Axes - - x2Axis - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight2, 0); - - g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y3.range()[0] + ')'); - g.select('.nv-context .nv-x.nv-axis').transition() - .call(x2Axis); - - - y3Axis - .scale(y3) - .ticks( availableHeight2 / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-context .nv-y1.nv-axis') - .style('opacity', dataBars.length ? 1 : 0) - .attr('transform', 'translate(0,' + x2.range()[0] + ')'); - - g.select('.nv-context .nv-y1.nv-axis').transition() - .call(y3Axis); - - - y4Axis - .scale(y4) - .ticks( availableHeight2 / 36 ) - .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.nv-context .nv-y2.nv-axis') - .style('opacity', dataLines.length ? 1 : 0) - .attr('transform', 'translate(' + x2.range()[1] + ',0)'); - - g.select('.nv-context .nv-y2.nv-axis').transition() - .call(y4Axis); - - //------------------------------------------------------------ - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - - //============================================================ - // Functions - //------------------------------------------------------------ - - // Taken from crossfilter (http://square.github.com/crossfilter/) - function resizePath(d) { - var e = +(d == 'e'), - x = e ? 1 : -1, - y = availableHeight2 / 3; - return 'M' + (.5 * x) + ',' + y - + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6) - + 'V' + (2 * y - 6) - + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y) - + 'Z' - + 'M' + (2.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8) - + 'M' + (4.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8); - } - - - function updateBrushBG() { - if (!brush.empty()) brush.extent(brushExtent); - brushBG - .data([brush.empty() ? x2.domain() : brushExtent]) - .each(function(d,i) { - var leftWidth = x2(d[0]) - x2.range()[0], - rightWidth = x2.range()[1] - x2(d[1]); - d3.select(this).select('.left') - .attr('width', leftWidth < 0 ? 0 : leftWidth); - - d3.select(this).select('.right') - .attr('x', x2(d[1])) - .attr('width', rightWidth < 0 ? 0 : rightWidth); - }); - } - - - function onBrush() { - brushExtent = brush.empty() ? null : brush.extent(); - extent = brush.empty() ? x2.domain() : brush.extent(); - - - dispatch.brush({extent: extent, brush: brush}); - - updateBrushBG(); - - - //------------------------------------------------------------ - // Prepare Main (Focus) Bars and Lines - - bars - .width(availableWidth) - .height(availableHeight1) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); - - - lines - .width(availableWidth) - .height(availableHeight1) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })); - - var focusBarsWrap = g.select('.nv-focus .nv-barsWrap') - .datum(!dataBars.length ? [{values:[]}] : - dataBars - .map(function(d,i) { - return { - key: d.key, - values: d.values.filter(function(d,i) { - return bars.x()(d,i) >= extent[0] && bars.x()(d,i) <= extent[1]; - }) - } - }) - ); - - var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum(dataLines[0].disabled ? [{values:[]}] : - dataLines - .map(function(d,i) { - return { - key: d.key, - values: d.values.filter(function(d,i) { - return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1]; - }) - } - }) - ); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Update Main (Focus) X Axis - - if (dataBars.length) { - x = bars.xScale(); - } else { - x = lines.xScale(); - } - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight1, 0); - - xAxis.domain([Math.ceil(extent[0]), Math.floor(extent[1])]); - - g.select('.nv-x.nv-axis').transition().duration(transitionDuration) - .call(xAxis); - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Update Main (Focus) Bars and Lines - - focusBarsWrap.transition().duration(transitionDuration).call(bars); - focusLinesWrap.transition().duration(transitionDuration).call(lines); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup and Update Main (Focus) Y Axes - - g.select('.nv-focus .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - - - y1Axis - .scale(y1) - .ticks( availableHeight1 / 36 ) - .tickSize(-availableWidth, 0); - - g.select('.nv-focus .nv-y1.nv-axis') - .style('opacity', dataBars.length ? 1 : 0); - - - y2Axis - .scale(y2) - .ticks( availableHeight1 / 36 ) - .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.nv-focus .nv-y2.nv-axis') - .style('opacity', dataLines.length ? 1 : 0) - .attr('transform', 'translate(' + x.range()[1] + ',0)'); - - g.select('.nv-focus .nv-y1.nv-axis').transition().duration(transitionDuration) - .call(y1Axis); - g.select('.nv-focus .nv-y2.nv-axis').transition().duration(transitionDuration) - .call(y2Axis); - } - - //============================================================ - - onBrush(); - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.lines2 = lines2; - chart.bars = bars; - chart.bars2 = bars2; - chart.xAxis = xAxis; - chart.x2Axis = x2Axis; - chart.y1Axis = y1Axis; - chart.y2Axis = y2Axis; - chart.y3Axis = y3Axis; - chart.y4Axis = y4Axis; - - d3.rebind(chart, lines, 'defined', 'size', 'clipVoronoi', 'interpolate'); - //TODO: consider rebinding x, y and some other stuff, and simply do soemthign lile bars.x(lines.x()), etc. - //d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - bars.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - bars.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.brushExtent = function(_) { - if (!arguments.length) return brushExtent; - brushExtent = _; - return chart; - }; - - - //============================================================ - - - return chart; -} - -nv.models.multiBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , x = d3.scale.ordinal() - , y = d3.scale.linear() - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove - , clipEdge = true - , stacked = false - , stackOffset = 'zero' // options include 'silhouette', 'wiggle', 'expand', 'zero', or a custom function - , color = nv.utils.defaultColor() - , hideable = false - , barColor = null // adding the ability to set the color for each rather than the whole group - , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled - , delay = 1200 - , xDomain - , yDomain - , xRange - , yRange - , groupSpacing = 0.1 - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0 //used to store previous scales - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - if(hideable && data.length) hideable = [{ - values: data[0].values.map(function(d) { - return { - x: d.x, - y: 0, - series: d.series, - size: 0.01 - };} - )}]; - - if (stacked) - data = d3.layout.stack() - .offset(stackOffset) - .values(function(d){ return d.values }) - .y(getY) - (!data.length && hideable ? hideable : data); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - - //------------------------------------------------------------ - // HACK for negative value stacking - if (stacked) - data[0].values.map(function(d,i) { - var posBase = 0, negBase = 0; - data.map(function(d) { - var f = d.values[i] - f.size = Math.abs(f.y); - if (f.y<0) { - f.y1 = negBase; - negBase = negBase - f.size; - } else - { - f.y1 = f.size + posBase; - posBase = posBase + f.size; - } - }); - }); - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 } - }) - }); - - x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands(xRange || [0, availableWidth], groupSpacing); - - //y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y + (stacked ? d.y1 : 0) }).concat(forceY))) - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 : d.y1 + d.y ) : d.y }).concat(forceY))) - .range(yRange || [availableHeight, 0]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multibar').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - gEnter.append('g').attr('class', 'nv-groups'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d,i) { return i }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit() - .transition() - .selectAll('rect.nv-bar') - .delay(function(d,i) { - return i * delay/ data[0].values.length; - }) - .attr('y', function(d) { return stacked ? y0(d.y0) : y0(0) }) - .attr('height', 0) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i) }); - groups - .transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .75); - - - var bars = groups.selectAll('rect.nv-bar') - .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('rect') - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) - .attr('x', function(d,i,j) { - return stacked ? 0 : (j * x.rangeBand() / data.length ) - }) - .attr('y', function(d) { return y0(stacked ? d.y0 : 0) }) - .attr('height', 0) - .attr('width', x.rangeBand() / (stacked ? 1 : data.length) ) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) - ; - bars - .style('fill', function(d,i,j){ return color(d, j, i); }) - .style('stroke', function(d,i,j){ return color(d, j, i); }) - .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - value: getY(d,i), - point: d, - series: data[d.series], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }); - bars - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) - .transition() - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) - - if (barColor) { - if (!disabled) disabled = data.map(function() { return true }); - bars - .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }) - .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }); - } - - - if (stacked) - bars.transition() - .delay(function(d,i) { - - return i * delay / data[0].values.length; - }) - .attr('y', function(d,i) { - - return y((stacked ? d.y1 : 0)); - }) - .attr('height', function(d,i) { - return Math.max(Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0))),1); - }) - .attr('x', function(d,i) { - return stacked ? 0 : (d.series * x.rangeBand() / data.length ) - }) - .attr('width', x.rangeBand() / (stacked ? 1 : data.length) ); - else - bars.transition() - .delay(function(d,i) { - return i * delay/ data[0].values.length; - }) - .attr('x', function(d,i) { - return d.series * x.rangeBand() / data.length - }) - .attr('width', x.rangeBand() / data.length) - .attr('y', function(d,i) { - return getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : - y(getY(d,i)) || 0; - }) - .attr('height', function(d,i) { - return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0; - }); - - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.stacked = function(_) { - if (!arguments.length) return stacked; - stacked = _; - return chart; - }; - - chart.stackOffset = function(_) { - if (!arguments.length) return stackOffset; - stackOffset = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.barColor = function(_) { - if (!arguments.length) return barColor; - barColor = nv.utils.getColor(_); - return chart; - }; - - chart.disabled = function(_) { - if (!arguments.length) return disabled; - disabled = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.hideable = function(_) { - if (!arguments.length) return hideable; - hideable = _; - return chart; - }; - - chart.delay = function(_) { - if (!arguments.length) return delay; - delay = _; - return chart; - }; - - chart.groupSpacing = function(_) { - if (!arguments.length) return groupSpacing; - groupSpacing = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.multiBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var multibar = nv.models.multiBar() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.defaultColor() - , showControls = true - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , reduceXTicks = true // if false a tick will show for every data point - , staggerLabels = false - , rotateLabels = 0 - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' on ' + x + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , state = { stacked: false } - , defaultState = null - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , controlWidth = function() { return showControls ? 180 : 0 } - , transitionDuration = 250 - ; - - multibar - .stacked(false) - ; - xAxis - .orient('bottom') - .tickPadding(7) - .highlightZero(true) - .showMaxMin(false) - .tickFormat(function(d) { return d }) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickFormat(d3.format(',.1f')) - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = multibar.xScale(); - y = multibar.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multiBarWithLegend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarWithLegend').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth - controlWidth()); - - if (multibar.barColor()) - data.forEach(function(series,i) { - series.color = d3.rgb('#ccc').darker(i * 1.5).toString(); - }) - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { key: 'Grouped', disabled: multibar.stacked() }, - { key: 'Stacked', disabled: !multibar.stacked() } - ]; - - controls.width(controlWidth()).color(['#444', '#444', '#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - multibar - .disabled(data.map(function(series) { return series.disabled })) - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(multibar); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - g.select('.nv-x.nv-axis').transition() - .call(xAxis); - - var xTicks = g.select('.nv-x.nv-axis > g').selectAll('g'); - - xTicks - .selectAll('line, text') - .style('opacity', 1) - - if (staggerLabels) { - var getTranslate = function(x,y) { - return "translate(" + x + "," + y + ")"; - }; - - var staggerUp = 5, staggerDown = 17; //pixels to stagger by - // Issue #140 - xTicks - .selectAll("text") - .attr('transform', function(d,i,j) { - return getTranslate(0, (j % 2 == 0 ? staggerUp : staggerDown)); - }); - - var totalInBetweenTicks = d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length; - g.selectAll(".nv-x.nv-axis .nv-axisMaxMin text") - .attr("transform", function(d,i) { - return getTranslate(0, (i === 0 || totalInBetweenTicks % 2 !== 0) ? staggerDown : staggerUp); - }); - } - - if (reduceXTicks) - xTicks - .filter(function(d,i) { - return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0; - }) - .selectAll('text, line') - .style('opacity', 0); - - if(rotateLabels) - xTicks - .selectAll('.tick text') - .attr('transform', 'rotate(' + rotateLabels + ' 0,0)') - .style('text-anchor', rotateLabels > 0 ? 'start' : 'end'); - - g.select('.nv-x.nv-axis').selectAll('g.nv-axisMaxMin text') - .style('opacity', 1); - } - - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis').transition() - .call(yAxis); - } - - - //------------------------------------------------------------ - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Grouped': - multibar.stacked(false); - break; - case 'Stacked': - multibar.stacked(true); - break; - } - - state.stacked = multibar.stacked(); - dispatch.stateChange(state); - - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode) - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - if (typeof e.stacked !== 'undefined') { - multibar.stacked(e.stacked); - state.stacked = e.stacked; - } - - chart.update(); - }); - - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - multibar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - multibar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.multibar = multibar; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'clipEdge', - 'id', 'stacked', 'stackOffset', 'delay', 'barColor','groupSpacing'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.reduceXTicks= function(_) { - if (!arguments.length) return reduceXTicks; - reduceXTicks = _; - return chart; - }; - - chart.rotateLabels = function(_) { - if (!arguments.length) return rotateLabels; - rotateLabels = _; - return chart; - } - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.multiBarHorizontal = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.ordinal() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove - , color = nv.utils.defaultColor() - , barColor = null // adding the ability to set the color for each rather than the whole group - , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled - , stacked = false - , showValues = false - , showBarLabels = false - , valuePadding = 60 - , valueFormat = d3.format(',.2f') - , delay = 1200 - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0 //used to store previous scales - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - if (stacked) - data = d3.layout.stack() - .offset('zero') - .values(function(d){ return d.values }) - .y(getY) - (data); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - - - //------------------------------------------------------------ - // HACK for negative value stacking - if (stacked) - data[0].values.map(function(d,i) { - var posBase = 0, negBase = 0; - data.map(function(d) { - var f = d.values[i] - f.size = Math.abs(f.y); - if (f.y<0) { - f.y1 = negBase - f.size; - negBase = negBase - f.size; - } else - { - f.y1 = posBase; - posBase = posBase + f.size; - } - }); - }); - - - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 } - }) - }); - - x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands(xRange || [0, availableHeight], .1); - - //y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y + (stacked ? d.y0 : 0) }).concat(forceY))) - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 + d.y : d.y1 ) : d.y }).concat(forceY))) - - if (showValues && !stacked) - y.range(yRange || [(y.domain()[0] < 0 ? valuePadding : 0), availableWidth - (y.domain()[1] > 0 ? valuePadding : 0) ]); - else - y.range(yRange || [0, availableWidth]); - - x0 = x0 || x; - y0 = y0 || d3.scale.linear().domain(y.domain()).range([y(0),y(0)]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('g.nv-wrap.nv-multibarHorizontal').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibarHorizontal'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-groups'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d,i) { return i }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit().transition() - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i) }); - groups.transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .75); - - - var bars = groups.selectAll('g.nv-bar') - .data(function(d) { return d.values }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('g') - .attr('transform', function(d,i,j) { - return 'translate(' + y0(stacked ? d.y0 : 0) + ',' + (stacked ? 0 : (j * x.rangeBand() / data.length ) + x(getX(d,i))) + ')' - }); - - barsEnter.append('rect') - .attr('width', 0) - .attr('height', x.rangeBand() / (stacked ? 1 : data.length) ) - - bars - .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [ y(getY(d,i) + (stacked ? d.y0 : 0)), x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length) ], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - value: getY(d,i), - point: d, - series: data[d.series], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }); - - - barsEnter.append('text'); - - if (showValues && !stacked) { - bars.select('text') - .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'end' : 'start' }) - .attr('y', x.rangeBand() / (data.length * 2)) - .attr('dy', '.32em') - .text(function(d,i) { return valueFormat(getY(d,i)) }) - bars.transition() - .select('text') - .attr('x', function(d,i) { return getY(d,i) < 0 ? -4 : y(getY(d,i)) - y(0) + 4 }) - } else { - bars.selectAll('text').text(''); - } - - if (showBarLabels && !stacked) { - barsEnter.append('text').classed('nv-bar-label',true); - bars.select('text.nv-bar-label') - .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'start' : 'end' }) - .attr('y', x.rangeBand() / (data.length * 2)) - .attr('dy', '.32em') - .text(function(d,i) { return getX(d,i) }); - bars.transition() - .select('text.nv-bar-label') - .attr('x', function(d,i) { return getY(d,i) < 0 ? y(0) - y(getY(d,i)) + 4 : -4 }); - } - else { - bars.selectAll('text.nv-bar-label').text(''); - } - - bars - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) - - if (barColor) { - if (!disabled) disabled = data.map(function() { return true }); - bars - .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }) - .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }); - } - - if (stacked) - bars.transition() - .attr('transform', function(d,i) { - return 'translate(' + y(d.y1) + ',' + x(getX(d,i)) + ')' - }) - .select('rect') - .attr('width', function(d,i) { - return Math.abs(y(getY(d,i) + d.y0) - y(d.y0)) - }) - .attr('height', x.rangeBand() ); - else - bars.transition() - .attr('transform', function(d,i) { - //TODO: stacked must be all positive or all negative, not both? - return 'translate(' + - (getY(d,i) < 0 ? y(getY(d,i)) : y(0)) - + ',' + - (d.series * x.rangeBand() / data.length - + - x(getX(d,i)) ) - + ')' - }) - .select('rect') - .attr('height', x.rangeBand() / data.length ) - .attr('width', function(d,i) { - return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) - }); - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.stacked = function(_) { - if (!arguments.length) return stacked; - stacked = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.barColor = function(_) { - if (!arguments.length) return barColor; - barColor = nv.utils.getColor(_); - return chart; - }; - - chart.disabled = function(_) { - if (!arguments.length) return disabled; - disabled = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.delay = function(_) { - if (!arguments.length) return delay; - delay = _; - return chart; - }; - - chart.showValues = function(_) { - if (!arguments.length) return showValues; - showValues = _; - return chart; - }; - - chart.showBarLabels = function(_) { - if (!arguments.length) return showBarLabels; - showBarLabels = _; - return chart; - }; - - - chart.valueFormat= function(_) { - if (!arguments.length) return valueFormat; - valueFormat = _; - return chart; - }; - - chart.valuePadding = function(_) { - if (!arguments.length) return valuePadding; - valuePadding = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.multiBarHorizontalChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var multibar = nv.models.multiBarHorizontal() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend().height(30) - , controls = nv.models.legend().height(30) - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.defaultColor() - , showControls = true - , showLegend = true - , showXAxis = true - , showYAxis = true - , stacked = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + ' - ' + x + '

' + - '

' + y + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , state = { stacked: stacked } - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , controlWidth = function() { return showControls ? 180 : 0 } - , transitionDuration = 250 - ; - - multibar - .stacked(stacked) - ; - xAxis - .orient('left') - .tickPadding(5) - .highlightZero(false) - .showMaxMin(false) - .tickFormat(function(d) { return d }) - ; - yAxis - .orient('bottom') - .tickFormat(d3.format(',.1f')) - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = multibar.xScale(); - y = multibar.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multiBarHorizontalChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarHorizontalChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis') - .append('g').attr('class', 'nv-zeroLine') - .append('line'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth - controlWidth()); - - if (multibar.barColor()) - data.forEach(function(series,i) { - series.color = d3.rgb('#ccc').darker(i * 1.5).toString(); - }) - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { key: 'Grouped', disabled: multibar.stacked() }, - { key: 'Stacked', disabled: !multibar.stacked() } - ]; - - controls.width(controlWidth()).color(['#444', '#444', '#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - multibar - .disabled(data.map(function(series) { return series.disabled })) - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(multibar); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableHeight / 24 ) - .tickSize(-availableWidth, 0); - - g.select('.nv-x.nv-axis').transition() - .call(xAxis); - - var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); - - xTicks - .selectAll('line, text'); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight, 0); - - g.select('.nv-y.nv-axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - g.select('.nv-y.nv-axis').transition() - .call(yAxis); - } - - // Zero line - g.select(".nv-zeroLine line") - .attr("x1", y(0)) - .attr("x2", y(0)) - .attr("y1", 0) - .attr("y2", -availableHeight) - ; - - //------------------------------------------------------------ - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Grouped': - multibar.stacked(false); - break; - case 'Stacked': - multibar.stacked(true); - break; - } - - state.stacked = multibar.stacked(); - dispatch.stateChange(state); - - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - if (typeof e.stacked !== 'undefined') { - multibar.stacked(e.stacked); - state.stacked = e.stacked; - } - - chart.update(); - }); - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - multibar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - multibar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.multibar = multibar; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', - 'clipEdge', 'id', 'delay', 'showValues','showBarLabels', 'valueFormat', 'stacked', 'barColor'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - //============================================================ - - - return chart; -} -nv.models.multiChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - color = d3.scale.category20().range(), - width = null, - height = null, - showLegend = true, - tooltips = true, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }, - x, - y, - yDomain1, - yDomain2 - ; //can be accessed via chart.lines.[x/y]Scale() - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x = d3.scale.linear(), - yScale1 = d3.scale.linear(), - yScale2 = d3.scale.linear(), - - lines1 = nv.models.line().yScale(yScale1), - lines2 = nv.models.line().yScale(yScale2), - - bars1 = nv.models.multiBar().stacked(false).yScale(yScale1), - bars2 = nv.models.multiBar().stacked(false).yScale(yScale2), - - stack1 = nv.models.stackedArea().yScale(yScale1), - stack2 = nv.models.stackedArea().yScale(yScale2), - - xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5), - yAxis1 = nv.models.axis().scale(yScale1).orient('left'), - yAxis2 = nv.models.axis().scale(yScale2).orient('right'), - - legend = nv.models.legend().height(30), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines1.x()(e.point, e.pointIndex)), - y = ((e.series.yAxis == 2) ? yAxis2 : yAxis1).tickFormat()(lines1.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, undefined, undefined, offsetElement.offsetParent); - }; - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - chart.update = function() { container.transition().call(chart); }; - chart.container = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - var dataLines1 = data.filter(function(d) {return !d.disabled && d.type == 'line' && d.yAxis == 1}) - var dataLines2 = data.filter(function(d) {return !d.disabled && d.type == 'line' && d.yAxis == 2}) - var dataBars1 = data.filter(function(d) {return !d.disabled && d.type == 'bar' && d.yAxis == 1}) - var dataBars2 = data.filter(function(d) {return !d.disabled && d.type == 'bar' && d.yAxis == 2}) - var dataStack1 = data.filter(function(d) {return !d.disabled && d.type == 'area' && d.yAxis == 1}) - var dataStack2 = data.filter(function(d) {return !d.disabled && d.type == 'area' && d.yAxis == 2}) - - var series1 = data.filter(function(d) {return !d.disabled && d.yAxis == 1}) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: d.x, y: d.y } - }) - }) - - var series2 = data.filter(function(d) {return !d.disabled && d.yAxis == 2}) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: d.x, y: d.y } - }) - }) - - x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) - .range([0, availableWidth]); - - var wrap = container.selectAll('g.wrap.multiChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiChart').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y1 axis'); - gEnter.append('g').attr('class', 'y2 axis'); - gEnter.append('g').attr('class', 'lines1Wrap'); - gEnter.append('g').attr('class', 'lines2Wrap'); - gEnter.append('g').attr('class', 'bars1Wrap'); - gEnter.append('g').attr('class', 'bars2Wrap'); - gEnter.append('g').attr('class', 'stack1Wrap'); - gEnter.append('g').attr('class', 'stack2Wrap'); - gEnter.append('g').attr('class', 'legendWrap'); - - var g = wrap.select('g'); - - if (showLegend) { - legend.width( availableWidth / 2 ); - - g.select('.legendWrap') - .datum(data.map(function(series) { - series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; - series.key = series.originalKey + (series.yAxis == 1 ? '' : ' (right axis)'); - return series; - })) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.legendWrap') - .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); - } - - - lines1 - .width(availableWidth) - .height(availableHeight) - .interpolate("monotone") - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'line'})); - - lines2 - .width(availableWidth) - .height(availableHeight) - .interpolate("monotone") - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'line'})); - - bars1 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'bar'})); - - bars2 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'bar'})); - - stack1 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'area'})); - - stack2 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'area'})); - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var lines1Wrap = g.select('.lines1Wrap') - .datum(dataLines1) - var bars1Wrap = g.select('.bars1Wrap') - .datum(dataBars1) - var stack1Wrap = g.select('.stack1Wrap') - .datum(dataStack1) - - var lines2Wrap = g.select('.lines2Wrap') - .datum(dataLines2) - var bars2Wrap = g.select('.bars2Wrap') - .datum(dataBars2) - var stack2Wrap = g.select('.stack2Wrap') - .datum(dataStack2) - - var extraValue1 = dataStack1.length ? dataStack1.map(function(a){return a.values}).reduce(function(a,b){ - return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}}) - }).concat([{x:0, y:0}]) : [] - var extraValue2 = dataStack2.length ? dataStack2.map(function(a){return a.values}).reduce(function(a,b){ - return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}}) - }).concat([{x:0, y:0}]) : [] - - yScale1 .domain(yDomain1 || d3.extent(d3.merge(series1).concat(extraValue1), function(d) { return d.y } )) - .range([0, availableHeight]) - - yScale2 .domain(yDomain2 || d3.extent(d3.merge(series2).concat(extraValue2), function(d) { return d.y } )) - .range([0, availableHeight]) - - lines1.yDomain(yScale1.domain()) - bars1.yDomain(yScale1.domain()) - stack1.yDomain(yScale1.domain()) - - lines2.yDomain(yScale2.domain()) - bars2.yDomain(yScale2.domain()) - stack2.yDomain(yScale2.domain()) - - if(dataStack1.length){d3.transition(stack1Wrap).call(stack1);} - if(dataStack2.length){d3.transition(stack2Wrap).call(stack2);} - - if(dataBars1.length){d3.transition(bars1Wrap).call(bars1);} - if(dataBars2.length){d3.transition(bars2Wrap).call(bars2);} - - if(dataLines1.length){d3.transition(lines1Wrap).call(lines1);} - if(dataLines2.length){d3.transition(lines2Wrap).call(lines2);} - - - - xAxis - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis1 - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - - d3.transition(g.select('.y1.axis')) - .call(yAxis1); - - yAxis2 - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y2.axis')) - .call(yAxis2); - - g.select('.y2.axis') - .style('opacity', series2.length ? 1 : 0) - .attr('transform', 'translate(' + x.range()[1] + ',0)'); - - legend.dispatch.on('stateChange', function(newState) { - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines1.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines1.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - lines2.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines2.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars1.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars1.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars2.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars2.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - stack1.dispatch.on('tooltipShow', function(e) { - //disable tooltips when value ~= 0 - //// TODO: consider removing points from voronoi that have 0 value instead of this hack - if (!Math.round(stack1.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range - setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); - return false; - } - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - stack1.dispatch.on('tooltipHide', function(e) { - dispatch.tooltipHide(e); - }); - - stack2.dispatch.on('tooltipShow', function(e) { - //disable tooltips when value ~= 0 - //// TODO: consider removing points from voronoi that have 0 value instead of this hack - if (!Math.round(stack2.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range - setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); - return false; - } - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - stack2.dispatch.on('tooltipHide', function(e) { - dispatch.tooltipHide(e); - }); - - lines1.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines1.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - lines2.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines2.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - - - //============================================================ - // Global getters and setters - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.lines1 = lines1; - chart.lines2 = lines2; - chart.bars1 = bars1; - chart.bars2 = bars2; - chart.stack1 = stack1; - chart.stack2 = stack2; - chart.xAxis = xAxis; - chart.yAxis1 = yAxis1; - chart.yAxis2 = yAxis2; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines1.x(_); - bars1.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines1.y(_); - bars1.y(_); - return chart; - }; - - chart.yDomain1 = function(_) { - if (!arguments.length) return yDomain1; - yDomain1 = _; - return chart; - }; - - chart.yDomain2 = function(_) { - if (!arguments.length) return yDomain2; - yDomain2 = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - return chart; -} - - -nv.models.ohlcBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.linear() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , getOpen = function(d) { return d.open } - , getClose = function(d) { return d.close } - , getHigh = function(d) { return d.high } - , getLow = function(d) { return d.low } - , forceX = [] - , forceY = [] - , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart - , clipEdge = true - , color = nv.utils.defaultColor() - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - //TODO: store old scales for transitions - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - x .domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )); - - if (padData) - x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); - else - x.range(xRange || [0, availableWidth]); - - y .domain(yDomain || [ - d3.min(data[0].values.map(getLow).concat(forceY)), - d3.max(data[0].values.map(getHigh).concat(forceY)) - ]) - .range(yRange || [availableHeight, 0]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('g.nv-wrap.nv-ohlcBar').data([data[0].values]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-ohlcBar'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-ticks'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - container - .on('click', function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - defsEnter.append('clipPath') - .attr('id', 'nv-chart-clip-path-' + id) - .append('rect'); - - wrap.select('#nv-chart-clip-path-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); - - - - var ticks = wrap.select('.nv-ticks').selectAll('.nv-tick') - .data(function(d) { return d }); - - ticks.exit().remove(); - - - var ticksEnter = ticks.enter().append('path') - .attr('class', function(d,i,j) { return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i }) - .attr('d', function(d,i) { - var w = (availableWidth / data[0].values.length) * .9; - return 'm0,0l0,' - + (y(getOpen(d,i)) - - y(getHigh(d,i))) - + 'l' - + (-w/2) - + ',0l' - + (w/2) - + ',0l0,' - + (y(getLow(d,i)) - y(getOpen(d,i))) - + 'l0,' - + (y(getClose(d,i)) - - y(getLow(d,i))) - + 'l' - + (w/2) - + ',0l' - + (-w/2) - + ',0z'; - }) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; }) - //.attr('fill', function(d,i) { return color[0]; }) - //.attr('stroke', function(d,i) { return color[0]; }) - //.attr('x', 0 ) - //.attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) }) - //.attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) }) - .on('mouseover', function(d,i) { - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - point: d, - series: data[0], - pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - point: d, - series: data[0], - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - ticks - .attr('class', function(d,i,j) { return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i }) - d3.transition(ticks) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; }) - .attr('d', function(d,i) { - var w = (availableWidth / data[0].values.length) * .9; - return 'm0,0l0,' - + (y(getOpen(d,i)) - - y(getHigh(d,i))) - + 'l' - + (-w/2) - + ',0l' - + (w/2) - + ',0l0,' - + (y(getLow(d,i)) - - y(getOpen(d,i))) - + 'l0,' - + (y(getClose(d,i)) - - y(getLow(d,i))) - + 'l' - + (w/2) - + ',0l' - + (-w/2) - + ',0z'; - }) - //.attr('width', (availableWidth / data[0].values.length) * .9 ) - - - //d3.transition(ticks) - //.attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) }) - //.attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) }); - //.order(); // not sure if this makes any sense for this model - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.open = function(_) { - if (!arguments.length) return getOpen; - getOpen = _; - return chart; - }; - - chart.close = function(_) { - if (!arguments.length) return getClose; - getClose = _; - return chart; - }; - - chart.high = function(_) { - if (!arguments.length) return getHigh; - getHigh = _; - return chart; - }; - - chart.low = function(_) { - if (!arguments.length) return getLow; - getLow = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.padData = function(_) { - if (!arguments.length) return padData; - padData = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - //============================================================ - - - return chart; -} -nv.models.pie = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 500 - , height = 500 - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , getDescription = function(d) { return d.description } - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , color = nv.utils.defaultColor() - , valueFormat = d3.format(',.2f') - , showLabels = true - , pieLabelsOutside = true - , donutLabelsOutside = false - , labelType = "key" - , labelThreshold = .02 //if slice percentage is under this, don't show label - , donut = false - , labelSunbeamLayout = false - , startAngle = false - , endAngle = false - , donutRatio = 0.5 - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - radius = Math.min(availableWidth, availableHeight) / 2, - arcRadius = radius-(radius / 5), - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - //var wrap = container.selectAll('.nv-wrap.nv-pie').data([data]); - var wrap = container.selectAll('.nv-wrap.nv-pie').data(data); - var wrapEnter = wrap.enter().append('g').attr('class','nvd3 nv-wrap nv-pie nv-chart-' + id); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-pie'); - gEnter.append('g').attr('class', 'nv-pieLabels'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - g.select('.nv-pie').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')'); - g.select('.nv-pieLabels').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')'); - - //------------------------------------------------------------ - - - container - .on('click', function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - var arc = d3.svg.arc() - .outerRadius(arcRadius); - - if (startAngle) arc.startAngle(startAngle) - if (endAngle) arc.endAngle(endAngle); - if (donut) arc.innerRadius(radius * donutRatio); - - // Setup the Pie chart and choose the data element - var pie = d3.layout.pie() - .sort(null) - .value(function(d) { return d.disabled ? 0 : getY(d) }); - - var slices = wrap.select('.nv-pie').selectAll('.nv-slice') - .data(pie); - - var pieLabels = wrap.select('.nv-pieLabels').selectAll('.nv-label') - .data(pie); - - slices.exit().remove(); - pieLabels.exit().remove(); - - var ae = slices.enter().append('g') - .attr('class', 'nv-slice') - .on('mouseover', function(d,i){ - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - pointIndex: i, - pos: [d3.event.pageX, d3.event.pageY], - id: id - }); - }) - .on('mouseout', function(d,i){ - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - index: i, - id: id - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - slices - .attr('fill', function(d,i) { return color(d, i); }) - .attr('stroke', function(d,i) { return color(d, i); }); - - var paths = ae.append('path') - .each(function(d) { this._current = d; }); - //.attr('d', arc); - - slices.select('path') - .transition() - .attr('d', arc) - .attrTween('d', arcTween); - - if (showLabels) { - // This does the normal label - var labelsArc = d3.svg.arc().innerRadius(0); - - if (pieLabelsOutside){ labelsArc = arc; } - - if (donutLabelsOutside) { labelsArc = d3.svg.arc().outerRadius(arc.outerRadius()); } - - pieLabels.enter().append("g").classed("nv-label",true) - .each(function(d,i) { - var group = d3.select(this); - - group - .attr('transform', function(d) { - if (labelSunbeamLayout) { - d.outerRadius = arcRadius + 10; // Set Outer Coordinate - d.innerRadius = arcRadius + 15; // Set Inner Coordinate - var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI); - if ((d.startAngle+d.endAngle)/2 < Math.PI) { - rotateAngle -= 90; - } else { - rotateAngle += 90; - } - return 'translate(' + labelsArc.centroid(d) + ') rotate(' + rotateAngle + ')'; - } else { - d.outerRadius = radius + 10; // Set Outer Coordinate - d.innerRadius = radius + 15; // Set Inner Coordinate - return 'translate(' + labelsArc.centroid(d) + ')' - } - }); - - group.append('rect') - .style('stroke', '#fff') - .style('fill', '#fff') - .attr("rx", 3) - .attr("ry", 3); - - group.append('text') - .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned - .style('fill', '#000') - - }); - - var labelLocationHash = {}; - var avgHeight = 14; - var avgWidth = 140; - var createHashKey = function(coordinates) { - - return Math.floor(coordinates[0]/avgWidth) * avgWidth + ',' + Math.floor(coordinates[1]/avgHeight) * avgHeight; - }; - pieLabels.transition() - .attr('transform', function(d) { - if (labelSunbeamLayout) { - d.outerRadius = arcRadius + 10; // Set Outer Coordinate - d.innerRadius = arcRadius + 15; // Set Inner Coordinate - var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI); - if ((d.startAngle+d.endAngle)/2 < Math.PI) { - rotateAngle -= 90; - } else { - rotateAngle += 90; - } - return 'translate(' + labelsArc.centroid(d) + ') rotate(' + rotateAngle + ')'; - } else { - d.outerRadius = radius + 10; // Set Outer Coordinate - d.innerRadius = radius + 15; // Set Inner Coordinate - - /* - Overlapping pie labels are not good. What this attempts to do is, prevent overlapping. - Each label location is hashed, and if a hash collision occurs, we assume an overlap. - Adjust the label's y-position to remove the overlap. - */ - var center = labelsArc.centroid(d); - var hashKey = createHashKey(center); - if (labelLocationHash[hashKey]) { - center[1] -= avgHeight; - } - labelLocationHash[createHashKey(center)] = true; - return 'translate(' + center + ')' - } - }); - pieLabels.select(".nv-label text") - .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned - .text(function(d, i) { - var percent = (d.endAngle - d.startAngle) / (2 * Math.PI); - var labelTypes = { - "key" : getX(d.data), - "value": getY(d.data), - "percent": d3.format('%')(percent) - }; - return (d.value && percent > labelThreshold) ? labelTypes[labelType] : ''; - }); - } - - - // Computes the angle of an arc, converting from radians to degrees. - function angle(d) { - var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90; - return a > 90 ? a - 180 : a; - } - - function arcTween(a) { - a.endAngle = isNaN(a.endAngle) ? 0 : a.endAngle; - a.startAngle = isNaN(a.startAngle) ? 0 : a.startAngle; - if (!donut) a.innerRadius = 0; - var i = d3.interpolate(this._current, a); - this._current = i(0); - return function(t) { - return arc(i(t)); - }; - } - - function tweenPie(b) { - b.innerRadius = 0; - var i = d3.interpolate({startAngle: 0, endAngle: 0}, b); - return function(t) { - return arc(i(t)); - }; - } - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.values = function(_) { - nv.log("pie.values() is no longer supported."); - return chart; - }; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - }; - - chart.description = function(_) { - if (!arguments.length) return getDescription; - getDescription = _; - return chart; - }; - - chart.showLabels = function(_) { - if (!arguments.length) return showLabels; - showLabels = _; - return chart; - }; - - chart.labelSunbeamLayout = function(_) { - if (!arguments.length) return labelSunbeamLayout; - labelSunbeamLayout = _; - return chart; - }; - - chart.donutLabelsOutside = function(_) { - if (!arguments.length) return donutLabelsOutside; - donutLabelsOutside = _; - return chart; - }; - - chart.pieLabelsOutside = function(_) { - if (!arguments.length) return pieLabelsOutside; - pieLabelsOutside = _; - return chart; - }; - - chart.labelType = function(_) { - if (!arguments.length) return labelType; - labelType = _; - labelType = labelType || "key"; - return chart; - }; - - chart.donut = function(_) { - if (!arguments.length) return donut; - donut = _; - return chart; - }; - - chart.donutRatio = function(_) { - if (!arguments.length) return donutRatio; - donutRatio = _; - return chart; - }; - - chart.startAngle = function(_) { - if (!arguments.length) return startAngle; - startAngle = _; - return chart; - }; - - chart.endAngle = function(_) { - if (!arguments.length) return endAngle; - endAngle = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.valueFormat = function(_) { - if (!arguments.length) return valueFormat; - valueFormat = _; - return chart; - }; - - chart.labelThreshold = function(_) { - if (!arguments.length) return labelThreshold; - labelThreshold = _; - return chart; - }; - //============================================================ - - - return chart; -} -nv.models.pieChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var pie = nv.models.pie() - , legend = nv.models.legend() - ; - - var margin = {top: 30, right: 20, bottom: 20, left: 20} - , width = null - , height = null - , showLegend = true - , color = nv.utils.defaultColor() - , tooltips = true - , tooltip = function(key, y, e, graph) { - return '

' + key + '

' + - '

' + y + '

' - } - , state = {} - , defaultState = null - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var tooltipLabel = pie.description()(e.point) || pie.x()(e.point) - var left = e.pos[0] + ( (offsetElement && offsetElement.offsetLeft) || 0 ), - top = e.pos[1] + ( (offsetElement && offsetElement.offsetTop) || 0), - y = pie.valueFormat()(pie.y()(e.point)), - content = tooltip(tooltipLabel, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-pieChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-pieChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-pieWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend - .width( availableWidth ) - .key(pie.x()); - - wrap.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - pie - .width(availableWidth) - .height(availableHeight); - - - var pieWrap = g.select('.nv-pieWrap') - .datum([data]); - - d3.transition(pieWrap).call(pie); - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - pie.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - }); - - return chart; - } - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - pie.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.legend = legend; - chart.dispatch = dispatch; - chart.pie = pie; - - d3.rebind(chart, pie, 'valueFormat', 'values', 'x', 'y', 'description', 'id', 'showLabels', 'donutLabelsOutside', 'pieLabelsOutside', 'labelType', 'donut', 'donutRatio', 'labelThreshold'); - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - pie.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.scatter = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() // chooses color - , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't select one - , x = d3.scale.linear() - , y = d3.scale.linear() - , z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area - , getX = function(d) { return d.x } // accessor to get the x value - , getY = function(d) { return d.y } // accessor to get the y value - , getSize = function(d) { return d.size || 1} // accessor to get the point size - , getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape - , onlyCircles = true // Set to false to use shapes - , forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) - , forceY = [] // List of numbers to Force into the Y scale - , forceSize = [] // List of numbers to Force into the Size scale - , interactive = true // If true, plots a voronoi overlay for advanced point intersection - , pointKey = null - , pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out - , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart - , padDataOuter = .1 //outerPadding to imitate ordinal scale outer padding - , clipEdge = false // if true, masks points within x and y scale - , clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance - , clipRadius = function() { return 25 } // function to get the radius for voronoi point clips - , xDomain = null // Override x domain (skips the calculation from data) - , yDomain = null // Override y domain - , xRange = null // Override x range - , yRange = null // Override y range - , sizeDomain = null // Override point size domain - , sizeRange = null - , singlePoint = false - , dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout') - , useVoronoi = true - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0, z0 // used to store previous scales - , timeoutID - , needsUpdate = false // Flag for when the points are visually updating, but the interactive layer is behind, to disable tooltips - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain && sizeDomain) ? [] : // if we know xDomain and yDomain and sizeDomain, no need to calculate.... if Size is constant remember to set sizeDomain to speed up performance - d3.merge( - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), size: getSize(d,i) } - }) - }) - ); - - x .domain(xDomain || d3.extent(seriesData.map(function(d) { return d.x; }).concat(forceX))) - - if (padData && data[0]) - x.range(xRange || [(availableWidth * padDataOuter + availableWidth) / (2 *data[0].values.length), availableWidth - availableWidth * (1 + padDataOuter) / (2 * data[0].values.length) ]); - //x.range([availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); - else - x.range(xRange || [0, availableWidth]); - - y .domain(yDomain || d3.extent(seriesData.map(function(d) { return d.y }).concat(forceY))) - .range(yRange || [availableHeight, 0]); - - z .domain(sizeDomain || d3.extent(seriesData.map(function(d) { return d.size }).concat(forceSize))) - .range(sizeRange || [16, 256]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - if (x.domain()[0] === x.domain()[1] || y.domain()[0] === y.domain()[1]) singlePoint = true; - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] - y.domain()[0] * 0.01, y.domain()[1] + y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - if ( isNaN(x.domain()[0])) { - x.domain([-1,1]); - } - - if ( isNaN(y.domain()[0])) { - y.domain([-1,1]); - } - - - x0 = x0 || x; - y0 = y0 || y; - z0 = z0 || z; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-scatter').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatter nv-chart-' + id + (singlePoint ? ' nv-single-point' : '')); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-groups'); - gEnter.append('g').attr('class', 'nv-point-paths'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', (availableHeight > 0) ? availableHeight : 0); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - - function updateInteractiveLayer() { - - if (!interactive) return false; - - var eventElements; - - var vertices = d3.merge(data.map(function(group, groupIndex) { - return group.values - .map(function(point, pointIndex) { - // *Adding noise to make duplicates very unlikely - // *Injecting series and point index for reference - /* *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi. - */ - var pX = getX(point,pointIndex); - var pY = getY(point,pointIndex); - - return [x(pX)+ Math.random() * 1e-7, - y(pY)+ Math.random() * 1e-7, - groupIndex, - pointIndex, point]; //temp hack to add noise untill I think of a better way so there are no duplicates - }) - .filter(function(pointArray, pointIndex) { - return pointActive(pointArray[4], pointIndex); // Issue #237.. move filter to after map, so pointIndex is correct! - }) - }) - ); - - - - //inject series and point index for reference into voronoi - if (useVoronoi === true) { - - if (clipVoronoi) { - var pointClipsEnter = wrap.select('defs').selectAll('.nv-point-clips') - .data([id]) - .enter(); - - pointClipsEnter.append('clipPath') - .attr('class', 'nv-point-clips') - .attr('id', 'nv-points-clip-' + id); - - var pointClips = wrap.select('#nv-points-clip-' + id).selectAll('circle') - .data(vertices); - pointClips.enter().append('circle') - .attr('r', clipRadius); - pointClips.exit().remove(); - pointClips - .attr('cx', function(d) { return d[0] }) - .attr('cy', function(d) { return d[1] }); - - wrap.select('.nv-point-paths') - .attr('clip-path', 'url(#nv-points-clip-' + id + ')'); - } - - - if(vertices.length) { - // Issue #283 - Adding 2 dummy points to the voronoi b/c voronoi requires min 3 points to work - vertices.push([x.range()[0] - 20, y.range()[0] - 20, null, null]); - vertices.push([x.range()[1] + 20, y.range()[1] + 20, null, null]); - vertices.push([x.range()[0] - 20, y.range()[0] + 20, null, null]); - vertices.push([x.range()[1] + 20, y.range()[1] - 20, null, null]); - } - - var bounds = d3.geom.polygon([ - [-10,-10], - [-10,height + 10], - [width + 10,height + 10], - [width + 10,-10] - ]); - - var voronoi = d3.geom.voronoi(vertices).map(function(d, i) { - return { - 'data': bounds.clip(d), - 'series': vertices[i][2], - 'point': vertices[i][3] - } - }); - - - var pointPaths = wrap.select('.nv-point-paths').selectAll('path') - .data(voronoi); - pointPaths.enter().append('path') - .attr('class', function(d,i) { return 'nv-path-'+i; }); - pointPaths.exit().remove(); - pointPaths - .attr('d', function(d) { - if (d.data.length === 0) - return 'M 0 0' - else - return 'M' + d.data.join('L') + 'Z'; - }); - - var mouseEventCallback = function(d,mDispatch) { - if (needsUpdate) return 0; - var series = data[d.series]; - if (typeof series === 'undefined') return; - - var point = series.values[d.point]; - - mDispatch({ - point: point, - series: series, - pos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top], - seriesIndex: d.series, - pointIndex: d.point - }); - }; - - pointPaths - .on('click', function(d) { - mouseEventCallback(d, dispatch.elementClick); - }) - .on('mouseover', function(d) { - mouseEventCallback(d, dispatch.elementMouseover); - }) - .on('mouseout', function(d, i) { - mouseEventCallback(d, dispatch.elementMouseout); - }); - - - } else { - /* - // bring data in form needed for click handlers - var dataWithPoints = vertices.map(function(d, i) { - return { - 'data': d, - 'series': vertices[i][2], - 'point': vertices[i][3] - } - }); - */ - - // add event handlers to points instead voronoi paths - wrap.select('.nv-groups').selectAll('.nv-group') - .selectAll('.nv-point') - //.data(dataWithPoints) - //.style('pointer-events', 'auto') // recativate events, disabled by css - .on('click', function(d,i) { - //nv.log('test', d, i); - if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point - var series = data[d.series], - point = series.values[i]; - - dispatch.elementClick({ - point: point, - series: series, - pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], - seriesIndex: d.series, - pointIndex: i - }); - }) - .on('mouseover', function(d,i) { - if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point - var series = data[d.series], - point = series.values[i]; - - dispatch.elementMouseover({ - point: point, - series: series, - pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], - seriesIndex: d.series, - pointIndex: i - }); - }) - .on('mouseout', function(d,i) { - if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point - var series = data[d.series], - point = series.values[i]; - - dispatch.elementMouseout({ - point: point, - series: series, - seriesIndex: d.series, - pointIndex: i - }); - }); - } - - needsUpdate = false; - } - - needsUpdate = true; - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit() - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }); - groups - .transition() - .style('fill', function(d,i) { return color(d, i) }) - .style('stroke', function(d,i) { return color(d, i) }) - .style('stroke-opacity', 1) - .style('fill-opacity', .5); - - - if (onlyCircles) { - - var points = groups.selectAll('circle.nv-point') - .data(function(d) { return d.values }, pointKey); - points.enter().append('circle') - .style('fill', function (d,i) { return d.color }) - .style('stroke', function (d,i) { return d.color }) - .attr('cx', function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) - .attr('cy', function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) - .attr('r', function(d,i) { return Math.sqrt(z(getSize(d,i))/Math.PI) }); - points.exit().remove(); - groups.exit().selectAll('path.nv-point').transition() - .attr('cx', function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .attr('cy', function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - .remove(); - points.each(function(d,i) { - d3.select(this) - .classed('nv-point', true) - .classed('nv-point-' + i, true) - .classed('hover',false) - ; - }); - points.transition() - .attr('cx', function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .attr('cy', function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - .attr('r', function(d,i) { return Math.sqrt(z(getSize(d,i))/Math.PI) }); - - } else { - - var points = groups.selectAll('path.nv-point') - .data(function(d) { return d.values }); - points.enter().append('path') - .style('fill', function (d,i) { return d.color }) - .style('stroke', function (d,i) { return d.color }) - .attr('transform', function(d,i) { - return 'translate(' + x0(getX(d,i)) + ',' + y0(getY(d,i)) + ')' - }) - .attr('d', - d3.svg.symbol() - .type(getShape) - .size(function(d,i) { return z(getSize(d,i)) }) - ); - points.exit().remove(); - groups.exit().selectAll('path.nv-point') - .transition() - .attr('transform', function(d,i) { - return 'translate(' + x(getX(d,i)) + ',' + y(getY(d,i)) + ')' - }) - .remove(); - points.each(function(d,i) { - d3.select(this) - .classed('nv-point', true) - .classed('nv-point-' + i, true) - .classed('hover',false) - ; - }); - points.transition() - .attr('transform', function(d,i) { - //nv.log(d,i,getX(d,i), x(getX(d,i))); - return 'translate(' + x(getX(d,i)) + ',' + y(getY(d,i)) + ')' - }) - .attr('d', - d3.svg.symbol() - .type(getShape) - .size(function(d,i) { return z(getSize(d,i)) }) - ); - } - - - // Delay updating the invisible interactive layer for smoother animation - clearTimeout(timeoutID); // stop repeat calls to updateInteractiveLayer - timeoutID = setTimeout(updateInteractiveLayer, 300); - //updateInteractiveLayer(); - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - z0 = z.copy(); - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - chart.clearHighlights = function() { - //Remove the 'hover' class from all highlighted points. - d3.selectAll(".nv-chart-" + id + " .nv-point.hover").classed("hover",false); - }; - - chart.highlightPoint = function(seriesIndex,pointIndex,isHoverOver) { - d3.select(".nv-chart-" + id + " .nv-series-" + seriesIndex + " .nv-point-" + pointIndex) - .classed("hover",isHoverOver); - }; - - - dispatch.on('elementMouseover.point', function(d) { - if (interactive) chart.highlightPoint(d.seriesIndex,d.pointIndex,true); - }); - - dispatch.on('elementMouseout.point', function(d) { - if (interactive) chart.highlightPoint(d.seriesIndex,d.pointIndex,false); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - }; - - chart.size = function(_) { - if (!arguments.length) return getSize; - getSize = d3.functor(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.zScale = function(_) { - if (!arguments.length) return z; - z = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.sizeDomain = function(_) { - if (!arguments.length) return sizeDomain; - sizeDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.sizeRange = function(_) { - if (!arguments.length) return sizeRange; - sizeRange = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.forceSize = function(_) { - if (!arguments.length) return forceSize; - forceSize = _; - return chart; - }; - - chart.interactive = function(_) { - if (!arguments.length) return interactive; - interactive = _; - return chart; - }; - - chart.pointKey = function(_) { - if (!arguments.length) return pointKey; - pointKey = _; - return chart; - }; - - chart.pointActive = function(_) { - if (!arguments.length) return pointActive; - pointActive = _; - return chart; - }; - - chart.padData = function(_) { - if (!arguments.length) return padData; - padData = _; - return chart; - }; - - chart.padDataOuter = function(_) { - if (!arguments.length) return padDataOuter; - padDataOuter = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.clipVoronoi= function(_) { - if (!arguments.length) return clipVoronoi; - clipVoronoi = _; - return chart; - }; - - chart.useVoronoi= function(_) { - if (!arguments.length) return useVoronoi; - useVoronoi = _; - if (useVoronoi === false) { - clipVoronoi = false; - } - return chart; - }; - - chart.clipRadius = function(_) { - if (!arguments.length) return clipRadius; - clipRadius = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.shape = function(_) { - if (!arguments.length) return getShape; - getShape = _; - return chart; - }; - - chart.onlyCircles = function(_) { - if (!arguments.length) return onlyCircles; - onlyCircles = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.singlePoint = function(_) { - if (!arguments.length) return singlePoint; - singlePoint = _; - return chart; - }; - - //============================================================ - - - return chart; -} -nv.models.scatterChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var scatter = nv.models.scatter() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , distX = nv.models.distribution() - , distY = nv.models.distribution() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 75} - , width = null - , height = null - , color = nv.utils.defaultColor() - , x = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.xScale() - , y = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.yScale() - , xPadding = 0 - , yPadding = 0 - , showDistX = false - , showDistY = false - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , showControls = !!d3.fisheye - , fisheye = 0 - , pauseFisheye = false - , tooltips = true - , tooltipX = function(key, x, y) { return '' + x + '' } - , tooltipY = function(key, x, y) { return '' + y + '' } - , tooltip = null - , state = {} - , defaultState = null - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , noData = "No Data Available." - , transitionDuration = 250 - ; - - scatter - .xScale(x) - .yScale(y) - ; - xAxis - .orient('bottom') - .tickPadding(10) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickPadding(10) - ; - distX - .axis('x') - ; - distY - .axis('y') - ; - - controls.updateState(false); - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0; - - var showTooltip = function(e, offsetElement) { - //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) - - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), - leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), - topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), - yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)); - - if( tooltipX != null ) - nv.tooltip.show([leftX, topX], tooltipX(e.series.key, xVal, yVal, e, chart), 'n', 1, offsetElement, 'x-nvtooltip'); - if( tooltipY != null ) - nv.tooltip.show([leftY, topY], tooltipY(e.series.key, xVal, yVal, e, chart), 'e', 1, offsetElement, 'y-nvtooltip'); - if( tooltip != null ) - nv.tooltip.show([left, top], tooltip(e.series.key, xVal, yVal, e, chart), e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - var controlsData = [ - { key: 'Magnify', disabled: true } - ]; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - // background for pointer events - gEnter.append('rect').attr('class', 'nvd3 nv-background'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - gEnter.append('g').attr('class', 'nv-distWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - var legendWidth = (showControls) ? availableWidth / 2 : availableWidth; - legend.width(legendWidth); - - wrap.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth - legendWidth) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - controls.width(180).color(['#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - scatter - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - - if (xPadding !== 0) - scatter.xDomain(null); - - if (yPadding !== 0) - scatter.yDomain(null); - - wrap.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - - //Adjust for x and y padding - if (xPadding !== 0) { - var xRange = x.domain()[1] - x.domain()[0]; - scatter.xDomain([x.domain()[0] - (xPadding * xRange), x.domain()[1] + (xPadding * xRange)]); - } - - if (yPadding !== 0) { - var yRange = y.domain()[1] - y.domain()[0]; - scatter.yDomain([y.domain()[0] - (yPadding * yRange), y.domain()[1] + (yPadding * yRange)]); - } - - //Only need to update the scatter again if x/yPadding changed the domain. - if (yPadding !== 0 || xPadding !== 0) { - wrap.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - if (showXAxis) { - xAxis - .scale(x) - .ticks( xAxis.ticks() && xAxis.ticks().length ? xAxis.ticks() : availableWidth / 100 ) - .tickSize( -availableHeight , 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .call(xAxis); - - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( yAxis.ticks() && yAxis.ticks().length ? yAxis.ticks() : availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .call(yAxis); - } - - - if (showDistX) { - distX - .getData(scatter.x()) - .scale(x) - .width(availableWidth) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionX'); - g.select('.nv-distributionX') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - } - - if (showDistY) { - distY - .getData(scatter.y()) - .scale(y) - .width(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionY'); - g.select('.nv-distributionY') - .attr('transform', - 'translate(' + (rightAlignYAxis ? availableWidth : -distY.size() ) + ',0)') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - //------------------------------------------------------------ - - - - - if (d3.fisheye) { - g.select('.nv-background') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g.select('.nv-background').on('mousemove', updateFisheye); - g.select('.nv-background').on('click', function() { pauseFisheye = !pauseFisheye;}); - scatter.dispatch.on('elementClick.freezeFisheye', function() { - pauseFisheye = !pauseFisheye; - }); - } - - - function updateFisheye() { - if (pauseFisheye) { - g.select('.nv-point-paths').style('pointer-events', 'all'); - return false; - } - - g.select('.nv-point-paths').style('pointer-events', 'none' ); - - var mouse = d3.mouse(this); - x.distortion(fisheye).focus(mouse[0]); - y.distortion(fisheye).focus(mouse[1]); - - g.select('.nv-scatterWrap') - .call(scatter); - - if (showXAxis) - g.select('.nv-x.nv-axis').call(xAxis); - - if (showYAxis) - g.select('.nv-y.nv-axis').call(yAxis); - - g.select('.nv-distributionX') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - g.select('.nv-distributionY') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - fisheye = d.disabled ? 0 : 2.5; - g.select('.nv-background') .style('pointer-events', d.disabled ? 'none' : 'all'); - g.select('.nv-point-paths').style('pointer-events', d.disabled ? 'all' : 'none' ); - - if (d.disabled) { - x.distortion(fisheye).focus(0); - y.distortion(fisheye).focus(0); - - g.select('.nv-scatterWrap').call(scatter); - g.select('.nv-x.nv-axis').call(xAxis); - g.select('.nv-y.nv-axis').call(yAxis); - } else { - pauseFisheye = false; - } - - chart.update(); - }); - - legend.dispatch.on('stateChange', function(newState) { - state.disabled = newState.disabled; - dispatch.stateChange(state); - chart.update(); - }); - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', function(d,i) { return e.pos[1] - availableHeight;}); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', e.pos[0] + distX.size()); - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', 0); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', distY.size()); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.scatter = scatter; - chart.legend = legend; - chart.controls = controls; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.distX = distX; - chart.distY = distY; - - d3.rebind(chart, scatter, 'id', 'interactive', 'pointActive', 'x', 'y', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'sizeRange', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'useVoronoi'); - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - distX.color(color); - distY.color(color); - return chart; - }; - - chart.showDistX = function(_) { - if (!arguments.length) return showDistX; - showDistX = _; - return chart; - }; - - chart.showDistY = function(_) { - if (!arguments.length) return showDistY; - showDistY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - - chart.fisheye = function(_) { - if (!arguments.length) return fisheye; - fisheye = _; - return chart; - }; - - chart.xPadding = function(_) { - if (!arguments.length) return xPadding; - xPadding = _; - return chart; - }; - - chart.yPadding = function(_) { - if (!arguments.length) return yPadding; - yPadding = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltipXContent = function(_) { - if (!arguments.length) return tooltipX; - tooltipX = _; - return chart; - }; - - chart.tooltipYContent = function(_) { - if (!arguments.length) return tooltipY; - tooltipY = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.scatterPlusLineChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var scatter = nv.models.scatter() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , distX = nv.models.distribution() - , distY = nv.models.distribution() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 75} - , width = null - , height = null - , color = nv.utils.defaultColor() - , x = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.xScale() - , y = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.yScale() - , showDistX = false - , showDistY = false - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , showControls = !!d3.fisheye - , fisheye = 0 - , pauseFisheye = false - , tooltips = true - , tooltipX = function(key, x, y) { return '' + x + '' } - , tooltipY = function(key, x, y) { return '' + y + '' } - , tooltip = function(key, x, y, date) { return '

' + key + '

' - + '

' + date + '

' } - , state = {} - , defaultState = null - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , noData = "No Data Available." - , transitionDuration = 250 - ; - - scatter - .xScale(x) - .yScale(y) - ; - xAxis - .orient('bottom') - .tickPadding(10) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickPadding(10) - ; - distX - .axis('x') - ; - distY - .axis('y') - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0; - - var showTooltip = function(e, offsetElement) { - //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) - - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), - leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), - topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), - yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)); - - if( tooltipX != null ) - nv.tooltip.show([leftX, topX], tooltipX(e.series.key, xVal, yVal, e, chart), 'n', 1, offsetElement, 'x-nvtooltip'); - if( tooltipY != null ) - nv.tooltip.show([leftY, topY], tooltipY(e.series.key, xVal, yVal, e, chart), 'e', 1, offsetElement, 'y-nvtooltip'); - if( tooltip != null ) - nv.tooltip.show([left, top], tooltip(e.series.key, xVal, yVal, e.point.tooltip, e, chart), e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - var controlsData = [ - { key: 'Magnify', disabled: true } - ]; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = scatter.xScale(); - y = scatter.yScale(); - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - // background for pointer events - gEnter.append('rect').attr('class', 'nvd3 nv-background').style("pointer-events","none"); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - gEnter.append('g').attr('class', 'nv-regressionLinesWrap'); - gEnter.append('g').attr('class', 'nv-distWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width( availableWidth / 2 ); - - wrap.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - controls.width(180).color(['#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Main Chart Component(s) - - scatter - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - wrap.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - - wrap.select('.nv-regressionLinesWrap') - .attr('clip-path', 'url(#nv-edge-clip-' + scatter.id() + ')'); - - var regWrap = wrap.select('.nv-regressionLinesWrap').selectAll('.nv-regLines') - .data(function(d) {return d }); - - regWrap.enter().append('g').attr('class', 'nv-regLines'); - - var regLine = regWrap.selectAll('.nv-regLine').data(function(d){return [d]}); - var regLineEnter = regLine.enter() - .append('line').attr('class', 'nv-regLine') - .style('stroke-opacity', 0); - - regLine - .transition() - .attr('x1', x.range()[0]) - .attr('x2', x.range()[1]) - .attr('y1', function(d,i) {return y(x.domain()[0] * d.slope + d.intercept) }) - .attr('y2', function(d,i) { return y(x.domain()[1] * d.slope + d.intercept) }) - .style('stroke', function(d,i,j) { return color(d,j) }) - .style('stroke-opacity', function(d,i) { - return (d.disabled || typeof d.slope === 'undefined' || typeof d.intercept === 'undefined') ? 0 : 1 - }); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( xAxis.ticks() ? xAxis.ticks() : availableWidth / 100 ) - .tickSize( -availableHeight , 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( yAxis.ticks() ? yAxis.ticks() : availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .call(yAxis); - } - - - if (showDistX) { - distX - .getData(scatter.x()) - .scale(x) - .width(availableWidth) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionX'); - g.select('.nv-distributionX') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - } - - if (showDistY) { - distY - .getData(scatter.y()) - .scale(y) - .width(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionY'); - g.select('.nv-distributionY') - .attr('transform', 'translate(' + (rightAlignYAxis ? availableWidth : -distY.size() ) + ',0)') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - //------------------------------------------------------------ - - - - - if (d3.fisheye) { - g.select('.nv-background') - .attr('width', availableWidth) - .attr('height', availableHeight) - ; - - g.select('.nv-background').on('mousemove', updateFisheye); - g.select('.nv-background').on('click', function() { pauseFisheye = !pauseFisheye;}); - scatter.dispatch.on('elementClick.freezeFisheye', function() { - pauseFisheye = !pauseFisheye; - }); - } - - - function updateFisheye() { - if (pauseFisheye) { - g.select('.nv-point-paths').style('pointer-events', 'all'); - return false; - } - - g.select('.nv-point-paths').style('pointer-events', 'none' ); - - var mouse = d3.mouse(this); - x.distortion(fisheye).focus(mouse[0]); - y.distortion(fisheye).focus(mouse[1]); - - g.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - - if (showXAxis) - g.select('.nv-x.nv-axis').call(xAxis); - - if (showYAxis) - g.select('.nv-y.nv-axis').call(yAxis); - - g.select('.nv-distributionX') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - g.select('.nv-distributionY') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - fisheye = d.disabled ? 0 : 2.5; - g.select('.nv-background') .style('pointer-events', d.disabled ? 'none' : 'all'); - g.select('.nv-point-paths').style('pointer-events', d.disabled ? 'all' : 'none' ); - - if (d.disabled) { - x.distortion(fisheye).focus(0); - y.distortion(fisheye).focus(0); - - g.select('.nv-scatterWrap').call(scatter); - g.select('.nv-x.nv-axis').call(xAxis); - g.select('.nv-y.nv-axis').call(yAxis); - } else { - pauseFisheye = false; - } - - chart.update(); - }); - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', e.pos[1] - availableHeight); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', e.pos[0] + distX.size()); - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', 0); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', distY.size()); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.scatter = scatter; - chart.legend = legend; - chart.controls = controls; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.distX = distX; - chart.distY = distY; - - d3.rebind(chart, scatter, 'id', 'interactive', 'pointActive', 'x', 'y', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'sizeRange', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'useVoronoi'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - distX.color(color); - distY.color(color); - return chart; - }; - - chart.showDistX = function(_) { - if (!arguments.length) return showDistX; - showDistX = _; - return chart; - }; - - chart.showDistY = function(_) { - if (!arguments.length) return showDistY; - showDistY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.fisheye = function(_) { - if (!arguments.length) return fisheye; - fisheye = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltipXContent = function(_) { - if (!arguments.length) return tooltipX; - tooltipX = _; - return chart; - }; - - chart.tooltipYContent = function(_) { - if (!arguments.length) return tooltipY; - tooltipY = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.sparkline = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 2, right: 0, bottom: 2, left: 0} - , width = 400 - , height = 32 - , animate = true - , x = d3.scale.linear() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , color = nv.utils.getColor(['#000']) - , xDomain - , yDomain - , xRange - , yRange - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - x .domain(xDomain || d3.extent(data, getX )) - .range(xRange || [0, availableWidth]); - - y .domain(yDomain || d3.extent(data, getY )) - .range(yRange || [availableHeight, 0]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-sparkline').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparkline'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') - - //------------------------------------------------------------ - - - var paths = wrap.selectAll('path') - .data(function(d) { return [d] }); - paths.enter().append('path'); - paths.exit().remove(); - paths - .style('stroke', function(d,i) { return d.color || color(d, i) }) - .attr('d', d3.svg.line() - .x(function(d,i) { return x(getX(d,i)) }) - .y(function(d,i) { return y(getY(d,i)) }) - ); - - - // TODO: Add CURRENT data point (Need Min, Mac, Current / Most recent) - var points = wrap.selectAll('circle.nv-point') - .data(function(data) { - var yValues = data.map(function(d, i) { return getY(d,i); }); - function pointIndex(index) { - if (index != -1) { - var result = data[index]; - result.pointIndex = index; - return result; - } else { - return null; - } - } - var maxPoint = pointIndex(yValues.lastIndexOf(y.domain()[1])), - minPoint = pointIndex(yValues.indexOf(y.domain()[0])), - currentPoint = pointIndex(yValues.length - 1); - return [minPoint, maxPoint, currentPoint].filter(function (d) {return d != null;}); - }); - points.enter().append('circle'); - points.exit().remove(); - points - .attr('cx', function(d,i) { return x(getX(d,d.pointIndex)) }) - .attr('cy', function(d,i) { return y(getY(d,d.pointIndex)) }) - .attr('r', 2) - .attr('class', function(d,i) { - return getX(d, d.pointIndex) == x.domain()[1] ? 'nv-point nv-currentValue' : - getY(d, d.pointIndex) == y.domain()[0] ? 'nv-point nv-minValue' : 'nv-point nv-maxValue' - }); - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.animate = function(_) { - if (!arguments.length) return animate; - animate = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.sparklinePlus = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var sparkline = nv.models.sparkline(); - - var margin = {top: 15, right: 100, bottom: 10, left: 50} - , width = null - , height = null - , x - , y - , index = [] - , paused = false - , xTickFormat = d3.format(',r') - , yTickFormat = d3.format(',.2f') - , showValue = true - , alignValue = true - , rightAlignValue = false - , noData = "No Data Available." - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this); - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - - chart.update = function() { chart(selection) }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - var currentValue = sparkline.y()(data[data.length-1], data.length-1); - - //------------------------------------------------------------ - - - - //------------------------------------------------------------ - // Setup Scales - - x = sparkline.xScale(); - y = sparkline.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-sparklineplus').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparklineplus'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-sparklineWrap'); - gEnter.append('g').attr('class', 'nv-valueWrap'); - gEnter.append('g').attr('class', 'nv-hoverArea'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Main Chart Component(s) - - var sparklineWrap = g.select('.nv-sparklineWrap'); - - sparkline - .width(availableWidth) - .height(availableHeight); - - sparklineWrap - .call(sparkline); - - //------------------------------------------------------------ - - - var valueWrap = g.select('.nv-valueWrap'); - - var value = valueWrap.selectAll('.nv-currentValue') - .data([currentValue]); - - value.enter().append('text').attr('class', 'nv-currentValue') - .attr('dx', rightAlignValue ? -8 : 8) - .attr('dy', '.9em') - .style('text-anchor', rightAlignValue ? 'end' : 'start'); - - value - .attr('x', availableWidth + (rightAlignValue ? margin.right : 0)) - .attr('y', alignValue ? function(d) { return y(d) } : 0) - .style('fill', sparkline.color()(data[data.length-1], data.length-1)) - .text(yTickFormat(currentValue)); - - - - gEnter.select('.nv-hoverArea').append('rect') - .on('mousemove', sparklineHover) - .on('click', function() { paused = !paused }) - .on('mouseout', function() { index = []; updateValueLine(); }); - //.on('mouseout', function() { index = null; updateValueLine(); }); - - g.select('.nv-hoverArea rect') - .attr('transform', function(d) { return 'translate(' + -margin.left + ',' + -margin.top + ')' }) - .attr('width', availableWidth + margin.left + margin.right) - .attr('height', availableHeight + margin.top); - - - - function updateValueLine() { //index is currently global (within the chart), may or may not keep it that way - if (paused) return; - - var hoverValue = g.selectAll('.nv-hoverValue').data(index) - - var hoverEnter = hoverValue.enter() - .append('g').attr('class', 'nv-hoverValue') - .style('stroke-opacity', 0) - .style('fill-opacity', 0); - - hoverValue.exit() - .transition().duration(250) - .style('stroke-opacity', 0) - .style('fill-opacity', 0) - .remove(); - - hoverValue - .attr('transform', function(d) { return 'translate(' + x(sparkline.x()(data[d],d)) + ',0)' }) - .transition().duration(250) - .style('stroke-opacity', 1) - .style('fill-opacity', 1); - - if (!index.length) return; - - hoverEnter.append('line') - .attr('x1', 0) - .attr('y1', -margin.top) - .attr('x2', 0) - .attr('y2', availableHeight); - - - hoverEnter.append('text').attr('class', 'nv-xValue') - .attr('x', -6) - .attr('y', -margin.top) - .attr('text-anchor', 'end') - .attr('dy', '.9em') - - - g.select('.nv-hoverValue .nv-xValue') - .text(xTickFormat(sparkline.x()(data[index[0]], index[0]))); - - hoverEnter.append('text').attr('class', 'nv-yValue') - .attr('x', 6) - .attr('y', -margin.top) - .attr('text-anchor', 'start') - .attr('dy', '.9em') - - g.select('.nv-hoverValue .nv-yValue') - .text(yTickFormat(sparkline.y()(data[index[0]], index[0]))); - - } - - - function sparklineHover() { - if (paused) return; - - var pos = d3.mouse(this)[0] - margin.left; - - function getClosestIndex(data, x) { - var distance = Math.abs(sparkline.x()(data[0], 0) - x); - var closestIndex = 0; - for (var i = 0; i < data.length; i++){ - if (Math.abs(sparkline.x()(data[i], i) - x) < distance) { - distance = Math.abs(sparkline.x()(data[i], i) - x); - closestIndex = i; - } - } - return closestIndex; - } - - index = [getClosestIndex(data, Math.round(x.invert(pos)))]; - - updateValueLine(); - } - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.sparkline = sparkline; - - d3.rebind(chart, sparkline, 'x', 'y', 'xScale', 'yScale', 'color'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xTickFormat = function(_) { - if (!arguments.length) return xTickFormat; - xTickFormat = _; - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return yTickFormat; - yTickFormat = _; - return chart; - }; - - chart.showValue = function(_) { - if (!arguments.length) return showValue; - showValue = _; - return chart; - }; - - chart.alignValue = function(_) { - if (!arguments.length) return alignValue; - alignValue = _; - return chart; - }; - - chart.rightAlignValue = function(_) { - if (!arguments.length) return rightAlignValue; - rightAlignValue = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -} - -nv.models.stackedArea = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() // a function that computes the color - , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one - , getX = function(d) { return d.x } // accessor to get the x value from a data point - , getY = function(d) { return d.y } // accessor to get the y value from a data point - , style = 'stack' - , offset = 'zero' - , order = 'default' - , interpolate = 'linear' // controls the line interpolation - , clipEdge = false // if true, masks lines within x and y scale - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , scatter = nv.models.scatter() - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'areaClick', 'areaMouseover', 'areaMouseout') - ; - - scatter - .size(2.2) // default size - .sizeDomain([2.2,2.2]) // all the same size by default - ; - - /************************************ - * offset: - * 'wiggle' (stream) - * 'zero' (stacked) - * 'expand' (normalize to 100%) - * 'silhouette' (simple centered) - * - * order: - * 'inside-out' (stream) - * 'default' (input order) - ************************************/ - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - //------------------------------------------------------------ - // Setup Scales - - x = scatter.xScale(); - y = scatter.yScale(); - - //------------------------------------------------------------ - - var dataRaw = data; - // Injecting point index into each point because d3.layout.stack().out does not give index - data.forEach(function(aseries, i) { - aseries.seriesIndex = i; - aseries.values = aseries.values.map(function(d, j) { - d.index = j; - d.seriesIndex = i; - return d; - }); - }); - - var dataFiltered = data.filter(function(series) { - return !series.disabled; - }); - - data = d3.layout.stack() - .order(order) - .offset(offset) - .values(function(d) { return d.values }) //TODO: make values customizeable in EVERY model in this fashion - .x(getX) - .y(getY) - .out(function(d, y0, y) { - var yHeight = (getY(d) === 0) ? 0 : y; - d.display = { - y: yHeight, - y0: y0 - }; - }) - (dataFiltered); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-stackedarea').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedarea'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-areaWrap'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - scatter - .width(availableWidth) - .height(availableHeight) - .x(getX) - .y(function(d) { return d.display.y + d.display.y0 }) - .forceY([0]) - .color(data.map(function(d,i) { - return d.color || color(d, d.seriesIndex); - })); - - - var scatterWrap = g.select('.nv-scatterWrap') - .datum(data); - - scatterWrap.call(scatter); - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - var area = d3.svg.area() - .x(function(d,i) { return x(getX(d,i)) }) - .y0(function(d) { - return y(d.display.y0) - }) - .y1(function(d) { - return y(d.display.y + d.display.y0) - }) - .interpolate(interpolate); - - var zeroArea = d3.svg.area() - .x(function(d,i) { return x(getX(d,i)) }) - .y0(function(d) { return y(d.display.y0) }) - .y1(function(d) { return y(d.display.y0) }); - - - var path = g.select('.nv-areaWrap').selectAll('path.nv-area') - .data(function(d) { return d }); - - path.enter().append('path').attr('class', function(d,i) { return 'nv-area nv-area-' + i }) - .attr('d', function(d,i){ - return zeroArea(d.values, d.seriesIndex); - }) - .on('mouseover', function(d,i) { - d3.select(this).classed('hover', true); - dispatch.areaMouseover({ - point: d, - series: d.key, - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: d.seriesIndex - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.areaMouseout({ - point: d, - series: d.key, - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: d.seriesIndex - }); - }) - .on('click', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.areaClick({ - point: d, - series: d.key, - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: d.seriesIndex - }); - }) - - path.exit().remove(); - - path - .style('fill', function(d,i){ - return d.color || color(d, d.seriesIndex) - }) - .style('stroke', function(d,i){ return d.color || color(d, d.seriesIndex) }); - path.transition() - .attr('d', function(d,i) { - return area(d.values,i) - }); - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementMouseover.area', function(e) { - g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', true); - }); - scatter.dispatch.on('elementMouseout.area', function(e) { - g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', false); - }); - - //============================================================ - //Special offset functions - chart.d3_stackedOffset_stackPercent = function(stackData) { - var n = stackData.length, //How many series - m = stackData[0].length, //how many points per series - k = 1 / n, - i, - j, - o, - y0 = []; - - for (j = 0; j < m; ++j) { //Looping through all points - for (i = 0, o = 0; i < dataRaw.length; i++) //looping through series' - o += getY(dataRaw[i].values[j]) //total value of all points at a certian point in time. - - if (o) for (i = 0; i < n; i++) - stackData[i][j][1] /= o; - else - for (i = 0; i < n; i++) - stackData[i][j][1] = k; - } - for (j = 0; j < m; ++j) y0[j] = 0; - return y0; - }; - - }); - - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementClick.area', function(e) { - dispatch.areaClick(e); - }) - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - //============================================================ - - //============================================================ - // Global getters and setters - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.scatter = scatter; - - d3.rebind(chart, scatter, 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', - 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'useVoronoi','clipRadius','highlightPoint','clearHighlights'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - } - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.offset = function(_) { - if (!arguments.length) return offset; - offset = _; - return chart; - }; - - chart.order = function(_) { - if (!arguments.length) return order; - order = _; - return chart; - }; - - //shortcut for offset + order - chart.style = function(_) { - if (!arguments.length) return style; - style = _; - - switch (style) { - case 'stack': - chart.offset('zero'); - chart.order('default'); - break; - case 'stream': - chart.offset('wiggle'); - chart.order('inside-out'); - break; - case 'stream-center': - chart.offset('silhouette'); - chart.order('inside-out'); - break; - case 'expand': - chart.offset('expand'); - chart.order('default'); - break; - case 'stack_percent': - chart.offset(chart.d3_stackedOffset_stackPercent); - chart.order('default'); - break; - } - - return chart; - }; - - chart.interpolate = function(_) { - if (!arguments.length) return interpolate; - interpolate = _; - return chart; - }; - //============================================================ - - - return chart; -} - -nv.models.stackedAreaChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var stacked = nv.models.stackedArea() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , interactiveLayer = nv.interactiveGuideline() - ; - - var margin = {top: 30, right: 25, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.defaultColor() // a function that takes in d, i and returns color - , showControls = true - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , useInteractiveGuideline = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' on ' + x + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , yAxisTickFormat = d3.format(',.2f') - , state = { style: stacked.style() } - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , controlWidth = 250 - , cData = ['Stacked','Stream','Expanded'] - , controlLabels = {} - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(stacked.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(stacked.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = stacked.xScale(); - y = stacked.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-stackedAreaChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedAreaChart').append('g'); - var g = wrap.select('g'); - - gEnter.append("rect").style("opacity",0); - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-stackedWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - gEnter.append('g').attr('class', 'nv-interactive'); - - g.select("rect").attr("width",availableWidth).attr("height",availableHeight); - //------------------------------------------------------------ - // Legend - - if (showLegend) { - var legendWidth = (showControls) ? availableWidth - controlWidth : availableWidth; - legend - .width(legendWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth-legendWidth) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { - key: controlLabels.stacked || 'Stacked', - metaKey: 'Stacked', - disabled: stacked.style() != 'stack', - style: 'stack' - }, - { - key: controlLabels.stream || 'Stream', - metaKey: 'Stream', - disabled: stacked.style() != 'stream', - style: 'stream' - }, - { - key: controlLabels.expanded || 'Expanded', - metaKey: 'Expanded', - disabled: stacked.style() != 'expand', - style: 'expand' - }, - { - key: controlLabels.stack_percent || 'Stack %', - metaKey: 'Stack_Percent', - disabled: stacked.style() != 'stack_percent', - style: 'stack_percent' - } - ]; - - controlWidth = (cData.length/3) * 260; - - controlsData = controlsData.filter(function(d) { - return cData.indexOf(d.metaKey) !== -1; - }) - - controls - .width( controlWidth ) - .color(['#444', '#444', '#444']); - - g.select('.nv-controlsWrap') - .datum(controlsData) - .call(controls); - - - if ( margin.top != Math.max(controls.height(), legend.height()) ) { - margin.top = Math.max(controls.height(), legend.height()); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - - g.select('.nv-controlsWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - //------------------------------------------------------------ - //Set up interactive layer - if (useInteractiveGuideline) { - interactiveLayer - .width(availableWidth) - .height(availableHeight) - .margin({left: margin.left, top: margin.top}) - .svgContainer(container) - .xScale(x); - wrap.select(".nv-interactive").call(interactiveLayer); - } - - stacked - .width(availableWidth) - .height(availableHeight) - - var stackedWrap = g.select('.nv-stackedWrap') - .datum(data); - - stackedWrap.transition().call(stacked); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - - g.select('.nv-x.nv-axis') - .transition().duration(0) - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks(stacked.offset() == 'wiggle' ? 0 : availableHeight / 36) - .tickSize(-availableWidth, 0) - .setTickFormat( (stacked.style() == 'expand' || stacked.style() == 'stack_percent') - ? d3.format('%') : yAxisTickFormat); - - g.select('.nv-y.nv-axis') - .transition().duration(0) - .call(yAxis); - } - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - stacked.dispatch.on('areaClick.toggle', function(e) { - if (data.filter(function(d) { return !d.disabled }).length === 1) - data.forEach(function(d) { - d.disabled = false; - }); - else - data.forEach(function(d,i) { - d.disabled = (i != e.seriesIndex); - }); - - state.disabled = data.map(function(d) { return !!d.disabled }); - dispatch.stateChange(state); - - chart.update(); - }); - - legend.dispatch.on('stateChange', function(newState) { - state.disabled = newState.disabled; - dispatch.stateChange(state); - chart.update(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - stacked.style(d.style); - - - state.style = stacked.style(); - dispatch.stateChange(state); - - chart.update(); - }); - - - interactiveLayer.dispatch.on('elementMousemove', function(e) { - stacked.clearHighlights(); - var singlePoint, pointIndex, pointXLocation, allData = []; - data - .filter(function(series, i) { - series.seriesIndex = i; - return !series.disabled; - }) - .forEach(function(series,i) { - pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); - stacked.highlightPoint(i, pointIndex, true); - var point = series.values[pointIndex]; - if (typeof point === 'undefined') return; - if (typeof singlePoint === 'undefined') singlePoint = point; - if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); - - //If we are in 'expand' mode, use the stacked percent value instead of raw value. - var tooltipValue = (stacked.style() == 'expand') ? point.display.y : chart.y()(point,pointIndex); - allData.push({ - key: series.key, - value: tooltipValue, - color: color(series,series.seriesIndex), - stackedValue: point.display - }); - }); - - allData.reverse(); - - //Highlight the tooltip entry based on which stack the mouse is closest to. - if (allData.length > 2) { - var yValue = chart.yScale().invert(e.mouseY); - var yDistMax = Infinity, indexToHighlight = null; - allData.forEach(function(series,i) { - - //To handle situation where the stacked area chart is negative, we need to use absolute values - //when checking if the mouse Y value is within the stack area. - yValue = Math.abs(yValue); - var stackedY0 = Math.abs(series.stackedValue.y0); - var stackedY = Math.abs(series.stackedValue.y); - if ( yValue >= stackedY0 && yValue <= (stackedY + stackedY0)) - { - indexToHighlight = i; - return; - } - }); - if (indexToHighlight != null) - allData[indexToHighlight].highlight = true; - } - - var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex)); - - //If we are in 'expand' mode, force the format to be a percentage. - var valueFormatter = (stacked.style() == 'expand') ? - function(d,i) {return d3.format(".1%")(d);} : - function(d,i) {return yAxis.tickFormat()(d); }; - interactiveLayer.tooltip - .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) - .chartContainer(that.parentNode) - .enabled(tooltips) - .valueFormatter(valueFormatter) - .data( - { - value: xValue, - series: allData - } - )(); - - interactiveLayer.renderGuideLine(pointXLocation); - - }); - - interactiveLayer.dispatch.on("elementMouseout",function(e) { - dispatch.tooltipHide(); - stacked.clearHighlights(); - }); - - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - if (typeof e.style !== 'undefined') { - stacked.style(e.style); - } - - chart.update(); - }); - - }); - - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - stacked.dispatch.on('tooltipShow', function(e) { - //disable tooltips when value ~= 0 - //// TODO: consider removing points from voronoi that have 0 value instead of this hack - /* - if (!Math.round(stacked.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range - setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); - return false; - } - */ - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - stacked.dispatch.on('tooltipHide', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.stacked = stacked; - chart.legend = legend; - chart.controls = controls; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.interactiveLayer = interactiveLayer; - - d3.rebind(chart, stacked, 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'interactive', 'useVoronoi', 'offset', 'order', 'style', 'clipEdge', 'forceX', 'forceY', 'forceSize', 'interpolate'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - stacked.color(color); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.useInteractiveGuideline = function(_) { - if(!arguments.length) return useInteractiveGuideline; - useInteractiveGuideline = _; - if (_ === true) { - chart.interactive(false); - chart.useVoronoi(false); - } - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - chart.controlsData = function(_) { - if (!arguments.length) return cData; - cData = _; - return chart; - }; - - chart.controlLabels = function(_) { - if (!arguments.length) return controlLabels; - if (typeof _ !== 'object') return controlLabels; - controlLabels = _; - return chart; - }; - - yAxis.setTickFormat = yAxis.tickFormat; - - yAxis.tickFormat = function(_) { - if (!arguments.length) return yAxisTickFormat; - yAxisTickFormat = _; - return yAxis; - }; - - - //============================================================ - - return chart; -} -})(); diff --git a/awx/ui/static/lib/novus-nvd3/nv.d3.min.css b/awx/ui/static/lib/novus-nvd3/nv.d3.min.css deleted file mode 100755 index d46f7ebce2..0000000000 --- a/awx/ui/static/lib/novus-nvd3/nv.d3.min.css +++ /dev/null @@ -1 +0,0 @@ -.chartWrap{margin:0;padding:0;overflow:hidden}.nvtooltip.with-3d-shadow,.with-3d-shadow .nvtooltip{-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-border-radius:6px;-moz-border-radius:6px;border-radius:6px}.nvtooltip{position:absolute;background-color:rgba(255,255,255,1);padding:1px;border:1px solid rgba(0,0,0,.2);z-index:10000;font-family:Arial;font-size:13px;text-align:left;pointer-events:none;white-space:nowrap;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.nvtooltip.with-transitions,.with-transitions .nvtooltip{transition:opacity 250ms linear;-moz-transition:opacity 250ms linear;-webkit-transition:opacity 250ms linear;transition-delay:250ms;-moz-transition-delay:250ms;-webkit-transition-delay:250ms}.nvtooltip.x-nvtooltip,.nvtooltip.y-nvtooltip{padding:8px}.nvtooltip h3{margin:0;padding:4px 14px;line-height:18px;font-weight:400;background-color:rgba(247,247,247,.75);text-align:center;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:5px 5px 0 0}.nvtooltip p{margin:0;padding:5px 14px;text-align:center}.nvtooltip span{display:inline-block;margin:2px 0}.nvtooltip table{margin:6px;border-spacing:0}.nvtooltip table td{padding:2px 9px 2px 0;vertical-align:middle}.nvtooltip table td.key{font-weight:400}.nvtooltip table td.value{text-align:right;font-weight:700}.nvtooltip table tr.highlight td{padding:1px 9px 1px 0;border-bottom-style:solid;border-bottom-width:1px;border-top-style:solid;border-top-width:1px}.nvtooltip table td.legend-color-guide div{width:8px;height:8px;vertical-align:middle}.nvtooltip .footer{padding:3px;text-align:center}.nvtooltip-pending-removal{position:absolute;pointer-events:none}svg{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;display:block;width:100%;height:100%}svg text{font:400 12px Arial}svg .title{font:700 14px Arial}.nvd3 .nv-background{fill:#fff;fill-opacity:0}.nvd3.nv-noData{font-size:18px;font-weight:700}.nv-brush .extent{fill-opacity:.125;shape-rendering:crispEdges}.nvd3 .nv-legend .nv-series{cursor:pointer}.nvd3 .nv-legend .disabled circle{fill-opacity:0}.nvd3 .nv-axis{pointer-events:none}.nvd3 .nv-axis path{fill:none;stroke:#000;stroke-opacity:.75;shape-rendering:crispEdges}.nvd3 .nv-axis path.domain{stroke-opacity:.75}.nvd3 .nv-axis.nv-x path.domain{stroke-opacity:0}.nvd3 .nv-axis line{fill:none;stroke:#e5e5e5;shape-rendering:crispEdges}.nvd3 .nv-axis .zero line,.nvd3 .nv-axis line.zero{stroke-opacity:.75}.nvd3 .nv-axis .nv-axisMaxMin text{font-weight:700}.nvd3 .x .nv-axis .nv-axisMaxMin text,.nvd3 .x2 .nv-axis .nv-axisMaxMin text,.nvd3 .x3 .nv-axis .nv-axisMaxMin text{text-anchor:middle}.nv-brush .resize path{fill:#eee;stroke:#666}.nvd3 .nv-bars .negative rect{zfill:brown}.nvd3 .nv-bars rect{zfill:#4682b4;fill-opacity:.75;transition:fill-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear}.nvd3 .nv-bars rect.hover{fill-opacity:1}.nvd3 .nv-bars .hover rect{fill:#add8e6}.nvd3 .nv-bars text{fill:rgba(0,0,0,0)}.nvd3 .nv-bars .hover text{fill:rgba(0,0,0,1)}.nvd3 .nv-multibar .nv-groups rect,.nvd3 .nv-multibarHorizontal .nv-groups rect,.nvd3 .nv-discretebar .nv-groups rect{stroke-opacity:0;transition:fill-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear}.nvd3 .nv-multibar .nv-groups rect:hover,.nvd3 .nv-multibarHorizontal .nv-groups rect:hover,.nvd3 .nv-discretebar .nv-groups rect:hover{fill-opacity:1}.nvd3 .nv-discretebar .nv-groups text,.nvd3 .nv-multibarHorizontal .nv-groups text{font-weight:700;fill:rgba(0,0,0,1);stroke:rgba(0,0,0,0)}.nvd3.nv-pie path{stroke-opacity:0;transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-pie .nv-slice text{stroke:#000;stroke-width:0}.nvd3.nv-pie path{stroke:#fff;stroke-width:1px;stroke-opacity:1}.nvd3.nv-pie .hover path{fill-opacity:.7}.nvd3.nv-pie .nv-label{pointer-events:none}.nvd3.nv-pie .nv-label rect{fill-opacity:0;stroke-opacity:0}.nvd3 .nv-groups path.nv-line{fill:none;stroke-width:1.5px}.nvd3 .nv-groups path.nv-line.nv-thin-line{stroke-width:1px}.nvd3 .nv-groups path.nv-area{stroke:none}.nvd3 .nv-line.hover path{stroke-width:6px}.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point{fill-opacity:0;stroke-opacity:0}.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point{fill-opacity:.5!important;stroke-opacity:.5!important}.with-transitions .nvd3 .nv-groups .nv-point{transition:stroke-width 250ms linear,stroke-opacity 250ms linear;-moz-transition:stroke-width 250ms linear,stroke-opacity 250ms linear;-webkit-transition:stroke-width 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-scatter .nv-groups .nv-point.hover,.nvd3 .nv-groups .nv-point.hover{stroke-width:7px;fill-opacity:.95!important;stroke-opacity:.95!important}.nvd3 .nv-point-paths path{stroke:#aaa;stroke-opacity:0;fill:#eee;fill-opacity:0}.nvd3 .nv-indexLine{cursor:ew-resize}.nvd3 .nv-distribution{pointer-events:none}.nvd3 .nv-groups .nv-point.hover{stroke-width:20px;stroke-opacity:.5}.nvd3 .nv-scatter .nv-point.hover{fill-opacity:1}.nvd3.nv-stackedarea path.nv-area{fill-opacity:.7;stroke-opacity:0;transition:fill-opacity 250ms linear,stroke-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear,stroke-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-stackedarea path.nv-area.hover{fill-opacity:.9}.nvd3.nv-stackedarea .nv-groups .nv-point{stroke-opacity:0;fill-opacity:0}.nvd3.nv-linePlusBar .nv-bar rect{fill-opacity:.75}.nvd3.nv-linePlusBar .nv-bar rect:hover{fill-opacity:1}.nvd3.nv-bullet{font:10px sans-serif}.nvd3.nv-bullet .nv-measure{fill-opacity:.8}.nvd3.nv-bullet .nv-measure:hover{fill-opacity:1}.nvd3.nv-bullet .nv-marker{stroke:#000;stroke-width:2px}.nvd3.nv-bullet .nv-markerTriangle{stroke:#000;fill:#fff;stroke-width:1.5px}.nvd3.nv-bullet .nv-tick line{stroke:#666;stroke-width:.5px}.nvd3.nv-bullet .nv-range.nv-s0{fill:#eee}.nvd3.nv-bullet .nv-range.nv-s1{fill:#ddd}.nvd3.nv-bullet .nv-range.nv-s2{fill:#ccc}.nvd3.nv-bullet .nv-title{font-size:14px;font-weight:700}.nvd3.nv-bullet .nv-subtitle{fill:#999}.nvd3.nv-bullet .nv-range{fill:#bababa;fill-opacity:.4}.nvd3.nv-bullet .nv-range:hover{fill-opacity:.7}.nvd3.nv-sparkline path{fill:none}.nvd3.nv-sparklineplus g.nv-hoverValue{pointer-events:none}.nvd3.nv-sparklineplus .nv-hoverValue line{stroke:#333;stroke-width:1.5px}.nvd3.nv-sparklineplus,.nvd3.nv-sparklineplus g{pointer-events:all}.nvd3 .nv-hoverArea{fill-opacity:0;stroke-opacity:0}.nvd3.nv-sparklineplus .nv-xValue,.nvd3.nv-sparklineplus .nv-yValue{stroke-width:0;font-size:.9em;font-weight:400}.nvd3.nv-sparklineplus .nv-yValue{stroke:#f66}.nvd3.nv-sparklineplus .nv-maxValue{stroke:#2ca02c;fill:#2ca02c}.nvd3.nv-sparklineplus .nv-minValue{stroke:#d62728;fill:#d62728}.nvd3.nv-sparklineplus .nv-currentValue{font-weight:700;font-size:1.1em}.nvd3.nv-ohlcBar .nv-ticks .nv-tick{stroke-width:2px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover{stroke-width:4px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive{stroke:#2ca02c}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative{stroke:#d62728}.nvd3.nv-historicalStockChart .nv-axis .nv-axislabel{font-weight:700}.nvd3.nv-historicalStockChart .nv-dragTarget{fill-opacity:0;stroke:none;cursor:move}.nvd3 .nv-brush .extent{fill-opacity:0!important}.nvd3 .nv-brushBackground rect{stroke:#000;stroke-width:.4;fill:#fff;fill-opacity:.7}.nvd3.nv-indentedtree .name{margin-left:5px}.nvd3.nv-indentedtree .clickable{color:#08C;cursor:pointer}.nvd3.nv-indentedtree span.clickable:hover{color:#005580;text-decoration:underline}.nvd3.nv-indentedtree .nv-childrenCount{display:inline-block;margin-left:5px}.nvd3.nv-indentedtree .nv-treeicon{cursor:pointer}.nvd3.nv-indentedtree .nv-treeicon.nv-folded{cursor:pointer}.nvd3 .background path{fill:none;stroke:#ccc;stroke-opacity:.4;shape-rendering:crispEdges}.nvd3 .foreground path{fill:none;stroke:#4682b4;stroke-opacity:.7}.nvd3 .brush .extent{fill-opacity:.3;stroke:#fff;shape-rendering:crispEdges}.nvd3 .axis line,.axis path{fill:none;stroke:#000;shape-rendering:crispEdges}.nvd3 .axis text{text-shadow:0 1px 0 #fff}.nvd3 .nv-interactiveGuideLine{pointer-events:none}.nvd3 line.nv-guideline{stroke:#ccc} \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/nv.d3.min.js b/awx/ui/static/lib/novus-nvd3/nv.d3.min.js deleted file mode 100755 index bddd4aef59..0000000000 --- a/awx/ui/static/lib/novus-nvd3/nv.d3.min.js +++ /dev/null @@ -1,6 +0,0 @@ -(function(){function t(e,t){return(new Date(t,e+1,0)).getDate()}function n(e,t,n){return function(r,i,s){var o=e(r),u=[];o1)while(op||r>d||d3.event.relatedTarget&&d3.event.relatedTarget.ownerSVGElement===undefined||a){if(l&&d3.event.relatedTarget&&d3.event.relatedTarget.ownerSVGElement===undefined&&d3.event.relatedTarget.className.match(t.nvPointerEventsClass))return;u.elementMouseout({mouseX:n,mouseY:r}),c.renderGuideLine(null);return}var f=s.invert(n);u.elementMousemove({mouseX:n,mouseY:r,pointXValue:f}),d3.event.type==="dblclick"&&u.elementDblclick({mouseX:n,mouseY:r,pointXValue:f})}var h=d3.select(this),p=n||960,d=r||400,v=h.selectAll("g.nv-wrap.nv-interactiveLineLayer").data([o]),m=v.enter().append("g").attr("class"," nv-wrap nv-interactiveLineLayer");m.append("g").attr("class","nv-interactiveGuideLine");if(!f)return;f.on("mousemove",g,!0).on("mouseout",g,!0).on("dblclick",g),c.renderGuideLine=function(t){if(!a)return;var n=v.select(".nv-interactiveGuideLine").selectAll("line").data(t!=null?[e.utils.NaNtoZero(t)]:[],String);n.enter().append("line").attr("class","nv-guideline").attr("x1",function(e){return e}).attr("x2",function(e){return e}).attr("y1",d).attr("y2",0),n.exit().remove()}})}var t=e.models.tooltip(),n=null,r=null,i={left:0,top:0},s=d3.scale.linear(),o=d3.scale.linear(),u=d3.dispatch("elementMousemove","elementMouseout","elementDblclick"),a=!0,f=null,l=navigator.userAgent.indexOf("MSIE")!==-1;return c.dispatch=u,c.tooltip=t,c.margin=function(e){return arguments.length?(i.top=typeof e.top!="undefined"?e.top:i.top,i.left=typeof e.left!="undefined"?e.left:i.left,c):i},c.width=function(e){return arguments.length?(n=e,c):n},c.height=function(e){return arguments.length?(r=e,c):r},c.xScale=function(e){return arguments.length?(s=e,c):s},c.showGuideLine=function(e){return arguments.length?(a=e,c):a},c.svgContainer=function(e){return arguments.length?(f=e,c):f},c},e.interactiveBisect=function(e,t,n){"use strict";if(!e instanceof Array)return null;typeof n!="function"&&(n=function(e,t){return e.x});var r=d3.bisector(n).left,i=d3.max([0,r(e,t)-1]),s=n(e[i],i);typeof s=="undefined"&&(s=i);if(s===t)return i;var o=d3.min([i+1,e.length-1]),u=n(e[o],o);return typeof u=="undefined"&&(u=o),Math.abs(u-t)>=Math.abs(s-t)?i:o},e.nearestValueIndex=function(e,t,n){"use strict";var r=Infinity,i=null;return e.forEach(function(e,s){var o=Math.abs(t-e);o<=r&&oT.height?0:x}v.top=Math.abs(x-S.top),v.left=Math.abs(E.left-S.left)}t+=a.offsetLeft+v.left-2*a.scrollLeft,u+=a.offsetTop+v.top-2*a.scrollTop}return s&&s>0&&(u=Math.floor(u/s)*s),e.tooltip.calcTooltipPosition([t,u],r,i,h),w}var t=null,n=null,r="w",i=50,s=25,o=null,u=null,a=null,f=null,l={left:null,top:null},c=!0,h="nvtooltip-"+Math.floor(Math.random()*1e5),p="nv-pointer-events-none",d=function(e,t){return e},v=function(e){return e},m=function(e){if(t!=null)return t;if(e==null)return"";var n=d3.select(document.createElement("table")),r=n.selectAll("thead").data([e]).enter().append("thead");r.append("tr").append("td").attr("colspan",3).append("strong").classed("x-value",!0).html(v(e.value));var i=n.selectAll("tbody").data([e]).enter().append("tbody"),s=i.selectAll("tr").data(function(e){return e.series}).enter().append("tr").classed("highlight",function(e){return e.highlight});s.append("td").classed("legend-color-guide",!0).append("div").style("background-color",function(e){return e.color}),s.append("td").classed("key",!0).html(function(e){return e.key}),s.append("td").classed("value",!0).html(function(e,t){return d(e.value,t)}),s.selectAll("td").each(function(e){if(e.highlight){var t=d3.scale.linear().domain([0,1]).range(["#fff",e.color]),n=.6;d3.select(this).style("border-bottom-color",t(n)).style("border-top-color",t(n))}});var o=n.node().outerHTML;return e.footer!==undefined&&(o+=""),o},g=function(e){return e&&e.series&&e.series.length>0?!0:!1};return w.nvPointerEventsClass=p,w.content=function(e){return arguments.length?(t=e,w):t},w.tooltipElem=function(){return f},w.contentGenerator=function(e){return arguments.length?(typeof e=="function"&&(m=e),w):m},w.data=function(e){return arguments.length?(n=e,w):n},w.gravity=function(e){return arguments.length?(r=e,w):r},w.distance=function(e){return arguments.length?(i=e,w):i},w.snapDistance=function(e){return arguments.length?(s=e,w):s},w.classes=function(e){return arguments.length?(u=e,w):u},w.chartContainer=function(e){return arguments.length?(a=e,w):a},w.position=function(e){return arguments.length?(l.left=typeof e.left!="undefined"?e.left:l.left,l.top=typeof e.top!="undefined"?e.top:l.top,w):l},w.fixedTop=function(e){return arguments.length?(o=e,w):o},w.enabled=function(e){return arguments.length?(c=e,w):c},w.valueFormatter=function(e){return arguments.length?(typeof e=="function"&&(d=e),w):d},w.headerFormatter=function(e){return arguments.length?(typeof e=="function"&&(v=e),w):v},w.id=function(){return h},w},e.tooltip.show=function(t,n,r,i,s,o){var u=document.createElement("div");u.className="nvtooltip "+(o?o:"xy-tooltip");var a=s;if(!s||s.tagName.match(/g|svg/i))a=document.getElementsByTagName("body")[0];u.style.left=0,u.style.top=0,u.style.opacity=0,u.innerHTML=n,a.appendChild(u),s&&(t[0]=t[0]-s.scrollLeft,t[1]=t[1]-s.scrollTop),e.tooltip.calcTooltipPosition(t,r,i,u)},e.tooltip.findFirstNonSVGParent=function(e){while(e.tagName.match(/^g|svg$/i)!==null)e=e.parentNode;return e},e.tooltip.findTotalOffsetTop=function(e,t){var n=t;do isNaN(e.offsetTop)||(n+=e.offsetTop);while(e=e.offsetParent);return n},e.tooltip.findTotalOffsetLeft=function(e,t){var n=t;do isNaN(e.offsetLeft)||(n+=e.offsetLeft);while(e=e.offsetParent);return n},e.tooltip.calcTooltipPosition=function(t,n,r,i){var s=parseInt(i.offsetHeight),o=parseInt(i.offsetWidth),u=e.utils.windowSize().width,a=e.utils.windowSize().height,f=window.pageYOffset,l=window.pageXOffset,c,h;a=window.innerWidth>=document.body.scrollWidth?a:a-16,u=window.innerHeight>=document.body.scrollHeight?u:u-16,n=n||"s",r=r||20;var p=function(t){return e.tooltip.findTotalOffsetTop(t,h)},d=function(t){return e.tooltip.findTotalOffsetLeft(t,c)};switch(n){case"e":c=t[0]-o-r,h=t[1]-s/2;var v=d(i),m=p(i);vl?t[0]+r:l-v+c),mf+a&&(h=f+a-m+h-s);break;case"w":c=t[0]+r,h=t[1]-s/2;var v=d(i),m=p(i);v+o>u&&(c=t[0]-o-r),mf+a&&(h=f+a-m+h-s);break;case"n":c=t[0]-o/2-5,h=t[1]+r;var v=d(i),m=p(i);vu&&(c=c-o/2+5),m+s>f+a&&(h=f+a-m+h-s);break;case"s":c=t[0]-o/2,h=t[1]-s-r;var v=d(i),m=p(i);vu&&(c=c-o/2+5),f>m&&(h=f);break;case"none":c=t[0],h=t[1]-r;var v=d(i),m=p(i)}return i.style.left=c+"px",i.style.top=h+"px",i.style.opacity=1,i.style.position="absolute",i},e.tooltip.cleanup=function(){var e=document.getElementsByClassName("nvtooltip"),t=[];while(e.length)t.push(e[0]),e[0].style.transitionDelay="0 !important",e[0].style.opacity=0,e[0].className="nvtooltip-pending-removal";setTimeout(function(){while(t.length){var e=t.pop();e.parentNode.removeChild(e)}},500)}}(),e.utils.windowSize=function(){var e={width:640,height:480};return document.body&&document.body.offsetWidth&&(e.width=document.body.offsetWidth,e.height=document.body.offsetHeight),document.compatMode=="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth&&(e.width=document.documentElement.offsetWidth,e.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(e.width=window.innerWidth,e.height=window.innerHeight),e},e.utils.windowResize=function(e){if(e===undefined)return;var t=window.onresize;window.onresize=function(n){typeof t=="function"&&t(n),e(n)}},e.utils.getColor=function(t){return arguments.length?Object.prototype.toString.call(t)==="[object Array]"?function(e,n){return e.color||t[n%t.length]}:t:e.utils.defaultColor()},e.utils.defaultColor=function(){var e=d3.scale.category20().range();return function(t,n){return t.color||e[n%e.length]}},e.utils.customTheme=function(e,t,n){t=t||function(e){return e.key},n=n||d3.scale.category20().range();var r=n.length;return function(i,s){var o=t(i);return r||(r=n.length),typeof e[o]!="undefined"?typeof e[o]=="function"?e[o]():e[o]:n[--r]}},e.utils.pjax=function(t,n){function r(r){d3.html(r,function(r){var i=d3.select(n).node();i.parentNode.replaceChild(d3.select(r).select(n).node(),i),e.utils.pjax(t,n)})}d3.selectAll(t).on("click",function(){history.pushState(this.href,this.textContent,this.href),r(this.href),d3.event.preventDefault()}),d3.select(window).on("popstate",function(){d3.event.state&&r(d3.event.state)})},e.utils.calcApproxTextWidth=function(e){if(typeof e.style=="function"&&typeof e.text=="function"){var t=parseInt(e.style("font-size").replace("px","")),n=e.text().length;return n*t*.5}return 0},e.utils.NaNtoZero=function(e){return typeof e!="number"||isNaN(e)||e===null||e===Infinity?0:e},e.utils.optionsFunc=function(e){return e&&d3.map(e).forEach(function(e,t){typeof this[e]=="function"&&this[e](t)}.bind(this)),this},e.models.axis=function(){"use strict";function m(e){return e.each(function(e){var i=d3.select(this),m=i.selectAll("g.nv-wrap.nv-axis").data([e]),g=m.enter().append("g").attr("class","nvd3 nv-wrap nv-axis"),y=g.append("g"),b=m.select("g");p!==null?t.ticks(p):(t.orient()=="top"||t.orient()=="bottom")&&t.ticks(Math.abs(s.range()[1]-s.range()[0])/100),b.transition().call(t),v=v||t.scale();var w=t.tickFormat();w==null&&(w=v.tickFormat());var E=b.selectAll("text.nv-axislabel").data([o||null]);E.exit().remove();switch(t.orient()){case"top":E.enter().append("text").attr("class","nv-axislabel");var S=s.range().length==2?s.range()[1]:s.range()[s.range().length-1]+(s.range()[1]-s.range()[0]);E.attr("text-anchor","middle").attr("y",0).attr("x",S/2);if(u){var x=m.selectAll("g.nv-axisMaxMin").data(s.domain());x.enter().append("g").attr("class","nv-axisMaxMin").append("text"),x.exit().remove(),x.attr("transform",function(e,t){return"translate("+s(e)+",0)"}).select("text").attr("dy","-0.5em").attr("y",-t.tickPadding()).attr("text-anchor","middle").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate("+s.range()[t]+",0)"})}break;case"bottom":var T=36,N=30,C=b.selectAll("g").select("text");if(f%360){C.each(function(e,t){var n=this.getBBox().width;n>N&&(N=n)});var k=Math.abs(Math.sin(f*Math.PI/180)),T=(k?k*N:N)+30;C.attr("transform",function(e,t,n){return"rotate("+f+" 0,0)"}).style("text-anchor",f%360>0?"start":"end")}E.enter().append("text").attr("class","nv-axislabel");var S=s.range().length==2?s.range()[1]:s.range()[s.range().length-1]+(s.range()[1]-s.range()[0]);E.attr("text-anchor","middle").attr("y",T).attr("x",S/2);if(u){var x=m.selectAll("g.nv-axisMaxMin").data([s.domain()[0],s.domain()[s.domain().length-1]]);x.enter().append("g").attr("class","nv-axisMaxMin").append("text"),x.exit().remove(),x.attr("transform",function(e,t){return"translate("+(s(e)+(h?s.rangeBand()/2:0))+",0)"}).select("text").attr("dy",".71em").attr("y",t.tickPadding()).attr("transform",function(e,t,n){return"rotate("+f+" 0,0)"}).style("text-anchor",f?f%360>0?"start":"end":"middle").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate("+(s(e)+(h?s.rangeBand()/2:0))+",0)"})}c&&C.attr("transform",function(e,t){return"translate(0,"+(t%2==0?"0":"12")+")"});break;case"right":E.enter().append("text").attr("class","nv-axislabel"),E.style("text-anchor",l?"middle":"begin").attr("transform",l?"rotate(90)":"").attr("y",l?-Math.max(n.right,r)+12:-10).attr("x",l?s.range()[0]/2:t.tickPadding());if(u){var x=m.selectAll("g.nv-axisMaxMin").data(s.domain());x.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),x.exit().remove(),x.attr("transform",function(e,t){return"translate(0,"+s(e)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",t.tickPadding()).style("text-anchor","start").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate(0,"+s.range()[t]+")"}).select("text").style("opacity",1)}break;case"left":E.enter().append("text").attr("class","nv-axislabel"),E.style("text-anchor",l?"middle":"end").attr("transform",l?"rotate(-90)":"").attr("y",l?-Math.max(n.left,r)+d:-10).attr("x",l?-s.range()[0]/2:-t.tickPadding());if(u){var x=m.selectAll("g.nv-axisMaxMin").data(s.domain());x.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),x.exit().remove(),x.attr("transform",function(e,t){return"translate(0,"+v(e)+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",-t.tickPadding()).attr("text-anchor","end").text(function(e,t){var n=w(e);return(""+n).match("NaN")?"":n}),x.transition().attr("transform",function(e,t){return"translate(0,"+s.range()[t]+")"}).select("text").style("opacity",1)}}E.text(function(e){return e}),u&&(t.orient()==="left"||t.orient()==="right")&&(b.selectAll("g").each(function(e,t){d3.select(this).select("text").attr("opacity",1);if(s(e)s.range()[0]-10)(e>1e-10||e<-1e-10)&&d3.select(this).attr("opacity",0),d3.select(this).select("text").attr("opacity",0)}),s.domain()[0]==s.domain()[1]&&s.domain()[0]==0&&m.selectAll("g.nv-axisMaxMin").style("opacity",function(e,t){return t?0:1}));if(u&&(t.orient()==="top"||t.orient()==="bottom")){var L=[];m.selectAll("g.nv-axisMaxMin").each(function(e,t){try{t?L.push(s(e)-this.getBBox().width-4):L.push(s(e)+this.getBBox().width+4)}catch(n){t?L.push(s(e)-4):L.push(s(e)+4)}}),b.selectAll("g").each(function(e,t){if(s(e)L[1])e>1e-10||e<-1e-10?d3.select(this).remove():d3.select(this).select("text").remove()})}a&&b.selectAll(".tick").filter(function(e){return!parseFloat(Math.round(e.__data__*1e5)/1e6)&&e.__data__!==undefined}).classed("zero",!0),v=s.copy()}),m}var t=d3.svg.axis(),n={top:0,right:0,bottom:0,left:0},r=75,i=60,s=d3.scale.linear(),o=null,u=!0,a=!0,f=0,l=!0,c=!1,h=!1,p=null,d=12;t.scale(s).orient("bottom").tickFormat(function(e){return e});var v;return m.axis=t,d3.rebind(m,t,"orient","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"),d3.rebind(m,s,"domain","range","rangeBand","rangeBands"),m.options=e.utils.optionsFunc.bind(m),m.margin=function(e){return arguments.length?(n.top=typeof e.top!="undefined"?e.top:n.top,n.right=typeof e.right!="undefined"?e.right:n.right,n.bottom=typeof e.bottom!="undefined"?e.bottom:n.bottom,n.left=typeof e.left!="undefined"?e.left:n.left,m):n},m.width=function(e){return arguments.length?(r=e,m):r},m.ticks=function(e){return arguments.length?(p=e,m):p},m.height=function(e){return arguments.length?(i=e,m):i},m.axisLabel=function(e){return arguments.length?(o=e,m):o},m.showMaxMin=function(e){return arguments.length?(u=e,m):u},m.highlightZero=function(e){return arguments.length?(a=e,m):a},m.scale=function(e){return arguments.length?(s=e,t.scale(s),h=typeof s.rangeBands=="function",d3.rebind(m,s,"domain","range","rangeBand","rangeBands"),m):s},m.rotateYLabel=function(e){return arguments.length?(l=e,m):l},m.rotateLabels=function(e){return arguments.length?(f=e,m):f},m.staggerLabels=function(e){return arguments.length?(c=e,m):c},m.axisLabelDistance=function(e){return arguments.length?(d=e,m):d},m},e.models.bullet=function(){"use strict";function m(e){return e.each(function(e,n){var p=c-t.left-t.right,m=h-t.top-t.bottom,g=d3.select(this),y=i.call(this,e,n).slice().sort(d3.descending),b=s.call(this,e,n).slice().sort(d3.descending),w=o.call(this,e,n).slice().sort(d3.descending),E=u.call(this,e,n).slice(),S=a.call(this,e,n).slice(),x=f.call(this,e,n).slice(),T=d3.scale.linear().domain(d3.extent(d3.merge([l,y]))).range(r?[p,0]:[0,p]),N=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(T.range());this.__chart__=T;var C=d3.min(y),k=d3.max(y),L=y[1],A=g.selectAll("g.nv-wrap.nv-bullet").data([e]),O=A.enter().append("g").attr("class","nvd3 nv-wrap nv-bullet"),M=O.append("g"),_=A.select("g");M.append("rect").attr("class","nv-range nv-rangeMax"),M.append("rect").attr("class","nv-range nv-rangeAvg"),M.append("rect").attr("class","nv-range nv-rangeMin"),M.append("rect").attr("class","nv-measure"),M.append("path").attr("class","nv-markerTriangle"),A.attr("transform","translate("+t.left+","+t.top+")");var D=function(e){return Math.abs(N(e)-N(0))},P=function(e){return Math.abs(T(e)-T(0))},H=function(e){return e<0?N(e):N(0)},B=function(e){return e<0?T(e):T(0)};_.select("rect.nv-rangeMax").attr("height",m).attr("width",P(k>0?k:C)).attr("x",B(k>0?k:C)).datum(k>0?k:C),_.select("rect.nv-rangeAvg").attr("height",m).attr("width",P(L)).attr("x",B(L)).datum(L),_.select("rect.nv-rangeMin").attr("height",m).attr("width",P(k)).attr("x",B(k)).attr("width",P(k>0?C:k)).attr("x",B(k>0?C:k)).datum(k>0?C:k),_.select("rect.nv-measure").style("fill",d).attr("height",m/3).attr("y",m/3).attr("width",w<0?T(0)-T(w[0]):T(w[0])-T(0)).attr("x",B(w)).on("mouseover",function(){v.elementMouseover({value:w[0],label:x[0]||"Current",pos:[T(w[0]),m/2]})}).on("mouseout",function(){v.elementMouseout({value:w[0],label:x[0]||"Current"})});var j=m/6;b[0]?_.selectAll("path.nv-markerTriangle").attr("transform",function(e){return"translate("+T(b[0])+","+m/2+")"}).attr("d","M0,"+j+"L"+j+","+ -j+" "+ -j+","+ -j+"Z").on("mouseover",function(){v.elementMouseover({value:b[0],label:S[0]||"Previous",pos:[T(b[0]),m/2]})}).on("mouseout",function(){v.elementMouseout({value:b[0],label:S[0]||"Previous"})}):_.selectAll("path.nv-markerTriangle").remove(),A.selectAll(".nv-range").on("mouseover",function(e,t){var n=E[t]||(t?t==1?"Mean":"Minimum":"Maximum");v.elementMouseover({value:e,label:n,pos:[T(e),m/2]})}).on("mouseout",function(e,t){var n=E[t]||(t?t==1?"Mean":"Minimum":"Maximum");v.elementMouseout({value:e,label:n})})}),m}var t={top:0,right:0,bottom:0,left:0},n="left",r=!1,i=function(e){return e.ranges},s=function(e){return e.markers},o=function(e){return e.measures},u=function(e){return e.rangeLabels?e.rangeLabels:[]},a=function(e){return e.markerLabels?e.markerLabels:[]},f=function(e){return e.measureLabels?e.measureLabels:[]},l=[0],c=380,h=30,p=null,d=e.utils.getColor(["#1f77b4"]),v=d3.dispatch("elementMouseover","elementMouseout");return m.dispatch=v,m.options=e.utils.optionsFunc.bind(m),m.orient=function(e){return arguments.length?(n=e,r=n=="right"||n=="bottom",m):n},m.ranges=function(e){return arguments.length?(i=e,m):i},m.markers=function(e){return arguments.length?(s=e,m):s},m.measures=function(e){return arguments.length?(o=e,m):o},m.forceX=function(e){return arguments.length?(l=e,m):l},m.width=function(e){return arguments.length?(c=e,m):c},m.height=function(e){return arguments.length?(h=e,m):h},m.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,m):t},m.tickFormat=function(e){return arguments.length?(p=e,m):p},m.color=function(t){return arguments.length?(d=e.utils.getColor(t),m):d},m},e.models.bulletChart=function(){"use strict";function m(e){return e.each(function(n,h){var g=d3.select(this),y=(a||parseInt(g.style("width"))||960)-i.left-i.right,b=f-i.top-i.bottom,w=this;m.update=function(){m(e)},m.container=this;if(!n||!s.call(this,n,h)){var E=g.selectAll(".nv-noData").data([p]);return E.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),E.attr("x",i.left+y/2).attr("y",18+i.top+b/2).text(function(e){return e}),m}g.selectAll(".nv-noData").remove();var S=s.call(this,n,h).slice().sort(d3.descending),x=o.call(this,n,h).slice().sort(d3.descending),T=u.call(this,n,h).slice().sort(d3.descending),N=g.selectAll("g.nv-wrap.nv-bulletChart").data([n]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-bulletChart"),k=C.append("g"),L=N.select("g");k.append("g").attr("class","nv-bulletWrap"),k.append("g").attr("class","nv-titles"),N.attr("transform","translate("+i.left+","+i.top+")");var A=d3.scale.linear().domain([0,Math.max(S[0],x[0],T[0])]).range(r?[y,0]:[0,y]),O=this.__chart__||d3.scale.linear().domain([0,Infinity]).range(A.range());this.__chart__=A;var M=function(e){return Math.abs(O(e)-O(0))},_=function(e){return Math.abs(A(e)-A(0))},D=k.select(".nv-titles").append("g").attr("text-anchor","end").attr("transform","translate(-6,"+(f-i.top-i.bottom)/2+")");D.append("text").attr("class","nv-title").text(function(e){return e.title}),D.append("text").attr("class","nv-subtitle").attr("dy","1em").text(function(e){return e.subtitle}),t.width(y).height(b);var P=L.select(".nv-bulletWrap");d3.transition(P).call(t);var H=l||A.tickFormat(y/100),B=L.selectAll("g.nv-tick").data(A.ticks(y/50),function(e){return this.textContent||H(e)}),j=B.enter().append("g").attr("class","nv-tick").attr("transform",function(e){return"translate("+O(e)+",0)"}).style("opacity",1e-6);j.append("line").attr("y1",b).attr("y2",b*7/6),j.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",b*7/6).text(H);var F=d3.transition(B).attr("transform",function(e){return"translate("+A(e)+",0)"}).style("opacity",1);F.select("line").attr("y1",b).attr("y2",b*7/6),F.select("text").attr("y",b*7/6),d3.transition(B.exit()).attr("transform",function(e){return"translate("+A(e)+",0)"}).style("opacity",1e-6).remove(),d.on("tooltipShow",function(e){e.key=n.title,c&&v(e,w.parentNode)})}),d3.timer.flush(),m}var t=e.models.bullet(),n="left",r=!1,i={top:5,right:40,bottom:20,left:120},s=function(e){return e.ranges},o=function(e){return e.markers},u=function(e){return e.measures},a=null,f=55,l=null,c=!0,h=function(e,t,n,r,i){return"

"+t+"

"+"

"+n+"

"},p="No Data Available.",d=d3.dispatch("tooltipShow","tooltipHide"),v=function(t,n){var r=t.pos[0]+(n.offsetLeft||0)+i.left,s=t.pos[1]+(n.offsetTop||0)+i.top,o=h(t.key,t.label,t.value,t,m);e.tooltip.show([r,s],o,t.value<0?"e":"w",null,n)};return t.dispatch.on("elementMouseover.tooltip",function(e){d.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){d.tooltipHide(e)}),d.on("tooltipHide",function(){c&&e.tooltip.cleanup()}),m.dispatch=d,m.bullet=t,d3.rebind(m,t,"color"),m.options=e.utils.optionsFunc.bind(m),m.orient=function(e){return arguments.length?(n=e,r=n=="right"||n=="bottom",m):n},m.ranges=function(e){return arguments.length?(s=e,m):s},m.markers=function(e){return arguments.length?(o=e,m):o},m.measures=function(e){return arguments.length?(u=e,m):u},m.width=function(e){return arguments.length?(a=e,m):a},m.height=function(e){return arguments.length?(f=e,m):f},m.margin=function(e){return arguments.length?(i.top=typeof e.top!="undefined"?e.top:i.top,i.right=typeof e.right!="undefined"?e.right:i.right,i.bottom=typeof e.bottom!="undefined"?e.bottom:i.bottom,i.left=typeof e.left!="undefined"?e.left:i.left,m):i},m.tickFormat=function(e){return arguments.length?(l=e,m):l},m.tooltips=function(e){return arguments.length?(c=e,m):c},m.tooltipContent=function(e){return arguments.length?(h=e,m):h},m.noData=function(e){return arguments.length?(p=e,m):p},m},e.models.cumulativeLineChart=function(){"use strict";function D(b){return b.each(function(b){function q(e,t){d3.select(D.container).style("cursor","ew-resize")}function R(e,t){M.x=d3.event.x,M.i=Math.round(O.invert(M.x)),rt()}function U(e,t){d3.select(D.container).style("cursor","auto"),x.index=M.i,k.stateChange(x)}function rt(){nt.data([M]);var e=D.transitionDuration();D.transitionDuration(0),D.update(),D.transitionDuration(e)}var A=d3.select(this).classed("nv-chart-"+S,!0),H=this,B=(f||parseInt(A.style("width"))||960)-u.left-u.right,j=(l||parseInt(A.style("height"))||400)-u.top-u.bottom;D.update=function(){A.transition().duration(L).call(D)},D.container=this,x.disabled=b.map(function(e){return!!e.disabled});if(!T){var F;T={};for(F in x)x[F]instanceof Array?T[F]=x[F].slice(0):T[F]=x[F]}var I=d3.behavior.drag().on("dragstart",q).on("drag",R).on("dragend",U);if(!b||!b.length||!b.filter(function(e){return e.values.length}).length){var z=A.selectAll(".nv-noData").data([N]);return z.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),z.attr("x",u.left+B/2).attr("y",u.top+j/2).text(function(e){return e}),D}A.selectAll(".nv-noData").remove(),w=t.xScale(),E=t.yScale();if(!y){var W=b.filter(function(e){return!e.disabled}).map(function(e,n){var r=d3.extent(e.values,t.y());return r[0]<-0.95&&(r[0]=-0.95),[(r[0]-r[1])/(1+r[1]),(r[1]-r[0])/(1+r[0])]}),X=[d3.min(W,function(e){return e[0]}),d3.max(W,function(e){return e[1]})];t.yDomain(X)}else t.yDomain(null);O.domain([0,b[0].values.length-1]).range([0,B]).clamp(!0);var b=P(M.i,b),V=g?"none":"all",$=A.selectAll("g.nv-wrap.nv-cumulativeLine").data([b]),J=$.enter().append("g").attr("class","nvd3 nv-wrap nv-cumulativeLine").append("g"),K=$.select("g");J.append("g").attr("class","nv-interactive"),J.append("g").attr("class","nv-x nv-axis").style("pointer-events","none"),J.append("g").attr("class","nv-y nv-axis"),J.append("g").attr("class","nv-background"),J.append("g").attr("class","nv-linesWrap").style("pointer-events",V),J.append("g").attr("class","nv-avgLinesWrap").style("pointer-events","none"),J.append("g").attr("class","nv-legendWrap"),J.append("g").attr("class","nv-controlsWrap"),c&&(i.width(B),K.select(".nv-legendWrap").datum(b).call(i),u.top!=i.height()&&(u.top=i.height(),j=(l||parseInt(A.style("height"))||400)-u.top-u.bottom),K.select(".nv-legendWrap").attr("transform","translate(0,"+ -u.top+")"));if(m){var Q=[{key:"Re-scale y-axis",disabled:!y}];s.width(140).color(["#444","#444","#444"]).rightAlign(!1).margin({top:5,right:0,bottom:5,left:20}),K.select(".nv-controlsWrap").datum(Q).attr("transform","translate(0,"+ -u.top+")").call(s)}$.attr("transform","translate("+u.left+","+u.top+")"),d&&K.select(".nv-y.nv-axis").attr("transform","translate("+B+",0)");var G=b.filter(function(e){return e.tempDisabled});$.select(".tempDisabled").remove(),G.length&&$.append("text").attr("class","tempDisabled").attr("x",B/2).attr("y","-.71em").style("text-anchor","end").text(G.map(function(e){return e.key}).join(", ")+" values cannot be calculated for this time period."),g&&(o.width(B).height(j).margin({left:u.left,top:u.top}).svgContainer(A).xScale(w),$.select(".nv-interactive").call(o)),J.select(".nv-background").append("rect"),K.select(".nv-background rect").attr("width",B).attr("height",j),t.y(function(e){return e.display.y}).width(B).height(j).color(b.map(function(e,t){return e.color||a(e,t)}).filter(function(e,t){return!b[t].disabled&&!b[t].tempDisabled}));var Y=K.select(".nv-linesWrap").datum(b.filter(function(e){return!e.disabled&&!e.tempDisabled}));Y.call(t),b.forEach(function(e,t){e.seriesIndex=t});var Z=b.filter(function(e){return!e.disabled&&!!C(e)}),et=K.select(".nv-avgLinesWrap").selectAll("line").data(Z,function(e){return e.key}),tt=function(e){var t=E(C(e));return t<0?0:t>j?j:t};et.enter().append("line").style("stroke-width",2).style("stroke-dasharray","10,10").style("stroke",function(e,n){return t.color()(e,e.seriesIndex)}).attr("x1",0).attr("x2",B).attr("y1",tt).attr("y2",tt),et.style("stroke-opacity",function(e){var t=E(C(e));return t<0||t>j?0:1}).attr("x1",0).attr("x2",B).attr("y1",tt).attr("y2",tt),et.exit().remove();var nt=Y.selectAll(".nv-indexLine").data([M]);nt.enter().append("rect").attr("class","nv-indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).style("pointer-events","all").call(I),nt.attr("transform",function(e){return"translate("+O(e.i)+",0)"}).attr("height",j),h&&(n.scale(w).ticks(Math.min(b[0].values.length,B/70)).tickSize(-j,0),K.select(".nv-x.nv-axis").attr("transform","translate(0,"+E.range()[0]+")"),d3.transition(K.select(".nv-x.nv-axis")).call(n)),p&&(r.scale(E).ticks(j/36).tickSize(-B,0),d3.transition(K.select(".nv-y.nv-axis")).call(r)),K.select(".nv-background rect").on("click",function(){M.x=d3.mouse(this)[0],M.i=Math.round(O.invert(M.x)),x.index=M.i,k.stateChange(x),rt()}),t.dispatch.on("elementClick",function(e){M.i=e.pointIndex,M.x=O(M.i),x.index=M.i,k.stateChange(x),rt()}),s.dispatch.on("legendClick",function(e,t){e.disabled=!e.disabled,y=!e.disabled,x.rescaleY=y,k.stateChange(x),D.update()}),i.dispatch.on("stateChange",function(e){x.disabled=e.disabled,k.stateChange(x),D.update()}),o.dispatch.on("elementMousemove",function(i){t.clearHighlights();var s,f,l,c=[];b.filter(function(e,t){return e.seriesIndex=t,!e.disabled}).forEach(function(n,r){f=e.interactiveBisect(n.values,i.pointXValue,D.x()),t.highlightPoint(r,f,!0);var o=n.values[f];if(typeof o=="undefined")return;typeof s=="undefined"&&(s=o),typeof l=="undefined"&&(l=D.xScale()(D.x()(o,f))),c.push({key:n.key,value:D.y()(o,f),color:a(n,n.seriesIndex)})});if(c.length>2){var h=D.yScale().invert(i.mouseY),p=Math.abs(D.yScale().domain()[0]-D.yScale().domain()[1]),d=.03*p,m=e.nearestValueIndex(c.map(function(e){return e.value}),h,d);m!==null&&(c[m].highlight=!0)}var g=n.tickFormat()(D.x()(s,f),f);o.tooltip.position({left:l+u.left,top:i.mouseY+u.top}).chartContainer(H.parentNode).enabled(v).valueFormatter(function(e,t){return r.tickFormat()(e)}).data({value:g,series:c})(),o.renderGuideLine(l)}),o.dispatch.on("elementMouseout",function(e){k.tooltipHide(),t.clearHighlights()}),k.on("tooltipShow",function(e){v&&_(e,H.parentNode)}),k.on("changeState",function(e){typeof e.disabled!="undefined"&&(b.forEach(function(t,n){t.disabled=e.disabled[n]}),x.disabled=e.disabled),typeof e.index!="undefined"&&(M.i=e.index,M.x=O(M.i),x.index=e.index,nt.data([M])),typeof e.rescaleY!="undefined"&&(y=e.rescaleY),D.update()})}),D}function P(e,n){return n.map(function(n,r){if(!n.values)return n;var i=t.y()(n.values[e],e);return i<-0.95&&!A?(n.tempDisabled=!0,n):(n.tempDisabled=!1,n.values= -n.values.map(function(e,n){return e.display={y:(t.y()(e,n)-i)/(1+i)},e}),n)})}var t=e.models.line(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.interactiveGuideline(),u={top:30,right:30,bottom:50,left:60},a=e.utils.defaultColor(),f=null,l=null,c=!0,h=!0,p=!0,d=!1,v=!0,m=!0,g=!1,y=!0,b=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},w,E,S=t.id(),x={index:0,rescaleY:y},T=null,N="No Data Available.",C=function(e){return e.average},k=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),L=250,A=!1;n.orient("bottom").tickPadding(7),r.orient(d?"right":"left"),s.updateState(!1);var O=d3.scale.linear(),M={i:0,x:0},_=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=b(i.series.key,a,f,i,D);e.tooltip.show([o,u],l,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],k.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){k.tooltipHide(e)}),k.on("tooltipHide",function(){v&&e.tooltip.cleanup()}),D.dispatch=k,D.lines=t,D.legend=i,D.xAxis=n,D.yAxis=r,D.interactiveLayer=o,d3.rebind(D,t,"defined","isArea","x","y","xScale","yScale","size","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","useVoronoi","id"),D.options=e.utils.optionsFunc.bind(D),D.margin=function(e){return arguments.length?(u.top=typeof e.top!="undefined"?e.top:u.top,u.right=typeof e.right!="undefined"?e.right:u.right,u.bottom=typeof e.bottom!="undefined"?e.bottom:u.bottom,u.left=typeof e.left!="undefined"?e.left:u.left,D):u},D.width=function(e){return arguments.length?(f=e,D):f},D.height=function(e){return arguments.length?(l=e,D):l},D.color=function(t){return arguments.length?(a=e.utils.getColor(t),i.color(a),D):a},D.rescaleY=function(e){return arguments.length?(y=e,D):y},D.showControls=function(e){return arguments.length?(m=e,D):m},D.useInteractiveGuideline=function(e){return arguments.length?(g=e,e===!0&&(D.interactive(!1),D.useVoronoi(!1)),D):g},D.showLegend=function(e){return arguments.length?(c=e,D):c},D.showXAxis=function(e){return arguments.length?(h=e,D):h},D.showYAxis=function(e){return arguments.length?(p=e,D):p},D.rightAlignYAxis=function(e){return arguments.length?(d=e,r.orient(e?"right":"left"),D):d},D.tooltips=function(e){return arguments.length?(v=e,D):v},D.tooltipContent=function(e){return arguments.length?(b=e,D):b},D.state=function(e){return arguments.length?(x=e,D):x},D.defaultState=function(e){return arguments.length?(T=e,D):T},D.noData=function(e){return arguments.length?(N=e,D):N},D.average=function(e){return arguments.length?(C=e,D):C},D.transitionDuration=function(e){return arguments.length?(L=e,D):L},D.noErrorCheck=function(e){return arguments.length?(A=e,D):A},D},e.models.discreteBar=function(){"use strict";function E(e){return e.each(function(e){var i=n-t.left-t.right,E=r-t.top-t.bottom,S=d3.select(this);e.forEach(function(e,t){e.values.forEach(function(e){e.series=t})});var T=p&&d?[]:e.map(function(e){return e.values.map(function(e,t){return{x:u(e,t),y:a(e,t),y0:e.y0}})});s.domain(p||d3.merge(T).map(function(e){return e.x})).rangeBands(v||[0,i],.1),o.domain(d||d3.extent(d3.merge(T).map(function(e){return e.y}).concat(f))),c?o.range(m||[E-(o.domain()[0]<0?12:0),o.domain()[1]>0?12:0]):o.range(m||[E,0]),b=b||s,w=w||o.copy().range([o(0),o(0)]);var N=S.selectAll("g.nv-wrap.nv-discretebar").data([e]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-discretebar"),k=C.append("g"),L=N.select("g");k.append("g").attr("class","nv-groups"),N.attr("transform","translate("+t.left+","+t.top+")");var A=N.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});A.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),A.exit().transition().style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),A.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}),A.transition().style("stroke-opacity",1).style("fill-opacity",.75);var O=A.selectAll("g.nv-bar").data(function(e){return e.values});O.exit().remove();var M=O.enter().append("g").attr("transform",function(e,t,n){return"translate("+(s(u(e,t))+s.rangeBand()*.05)+", "+o(0)+")"}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),g.elementMouseover({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(t.series+.5)/e.length,o(a(t,n))],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),g.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){g.elementClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(t.series+.5)/e.length,o(a(t,n))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(t,n){g.elementDblClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(t.series+.5)/e.length,o(a(t,n))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()});M.append("rect").attr("height",0).attr("width",s.rangeBand()*.9/e.length),c?(M.append("text").attr("text-anchor","middle"),O.select("text").text(function(e,t){return h(a(e,t))}).transition().attr("x",s.rangeBand()*.9/2).attr("y",function(e,t){return a(e,t)<0?o(a(e,t))-o(0)+12:-4})):O.selectAll("text").remove(),O.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}).style("fill",function(e,t){return e.color||l(e,t)}).style("stroke",function(e,t){return e.color||l(e,t)}).select("rect").attr("class",y).transition().attr("width",s.rangeBand()*.9/e.length),O.transition().attr("transform",function(e,t){var n=s(u(e,t))+s.rangeBand()*.05,r=a(e,t)<0?o(0):o(0)-o(a(e,t))<1?o(0)-1:o(a(e,t));return"translate("+n+", "+r+")"}).select("rect").attr("height",function(e,t){return Math.max(Math.abs(o(a(e,t))-o(d&&d[0]||0))||1)}),b=s.copy(),w=o.copy()}),E}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.ordinal(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=[0],l=e.utils.defaultColor(),c=!1,h=d3.format(",.2f"),p,d,v,m,g=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),y="discreteBar",b,w;return E.dispatch=g,E.options=e.utils.optionsFunc.bind(E),E.x=function(e){return arguments.length?(u=e,E):u},E.y=function(e){return arguments.length?(a=e,E):a},E.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,E):t},E.width=function(e){return arguments.length?(n=e,E):n},E.height=function(e){return arguments.length?(r=e,E):r},E.xScale=function(e){return arguments.length?(s=e,E):s},E.yScale=function(e){return arguments.length?(o=e,E):o},E.xDomain=function(e){return arguments.length?(p=e,E):p},E.yDomain=function(e){return arguments.length?(d=e,E):d},E.xRange=function(e){return arguments.length?(v=e,E):v},E.yRange=function(e){return arguments.length?(m=e,E):m},E.forceY=function(e){return arguments.length?(f=e,E):f},E.color=function(t){return arguments.length?(l=e.utils.getColor(t),E):l},E.id=function(e){return arguments.length?(i=e,E):i},E.showValues=function(e){return arguments.length?(c=e,E):c},E.valueFormat=function(e){return arguments.length?(h=e,E):h},E.rectClass=function(e){return arguments.length?(y=e,E):y},E},e.models.discreteBarChart=function(){"use strict";function w(e){return e.each(function(e){var u=d3.select(this),p=this,E=(s||parseInt(u.style("width"))||960)-i.left-i.right,S=(o||parseInt(u.style("height"))||400)-i.top-i.bottom;w.update=function(){g.beforeUpdate(),u.transition().duration(y).call(w)},w.container=this;if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var T=u.selectAll(".nv-noData").data([m]);return T.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),T.attr("x",i.left+E/2).attr("y",i.top+S/2).text(function(e){return e}),w}u.selectAll(".nv-noData").remove(),d=t.xScale(),v=t.yScale().clamp(!0);var N=u.selectAll("g.nv-wrap.nv-discreteBarWithAxes").data([e]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-discreteBarWithAxes").append("g"),k=C.append("defs"),L=N.select("g");C.append("g").attr("class","nv-x nv-axis"),C.append("g").attr("class","nv-y nv-axis").append("g").attr("class","nv-zeroLine").append("line"),C.append("g").attr("class","nv-barsWrap"),L.attr("transform","translate("+i.left+","+i.top+")"),l&&L.select(".nv-y.nv-axis").attr("transform","translate("+E+",0)"),t.width(E).height(S);var A=L.select(".nv-barsWrap").datum(e.filter(function(e){return!e.disabled}));A.transition().call(t),k.append("clipPath").attr("id","nv-x-label-clip-"+t.id()).append("rect"),L.select("#nv-x-label-clip-"+t.id()+" rect").attr("width",d.rangeBand()*(c?2:1)).attr("height",16).attr("x",-d.rangeBand()/(c?1:2));if(a){n.scale(d).ticks(E/100).tickSize(-S,0),L.select(".nv-x.nv-axis").attr("transform","translate(0,"+(v.range()[0]+(t.showValues()&&v.domain()[0]<0?16:0))+")"),L.select(".nv-x.nv-axis").transition().call(n);var O=L.select(".nv-x.nv-axis").selectAll("g");c&&O.selectAll("text").attr("transform",function(e,t,n){return"translate(0,"+(n%2==0?"5":"17")+")"})}f&&(r.scale(v).ticks(S/36).tickSize(-E,0),L.select(".nv-y.nv-axis").transition().call(r)),L.select(".nv-zeroLine line").attr("x1",0).attr("x2",E).attr("y1",v(0)).attr("y2",v(0)),g.on("tooltipShow",function(e){h&&b(e,p.parentNode)})}),w}var t=e.models.discreteBar(),n=e.models.axis(),r=e.models.axis(),i={top:15,right:10,bottom:50,left:60},s=null,o=null,u=e.utils.getColor(),a=!0,f=!0,l=!1,c=!1,h=!0,p=function(e,t,n,r,i){return"

"+t+"

"+"

"+n+"

"},d,v,m="No Data Available.",g=d3.dispatch("tooltipShow","tooltipHide","beforeUpdate"),y=250;n.orient("bottom").highlightZero(!1).showMaxMin(!1).tickFormat(function(e){return e}),r.orient(l?"right":"left").tickFormat(d3.format(",.1f"));var b=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=p(i.series.key,a,f,i,w);e.tooltip.show([o,u],l,i.value<0?"n":"s",null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+i.left,e.pos[1]+i.top],g.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){g.tooltipHide(e)}),g.on("tooltipHide",function(){h&&e.tooltip.cleanup()}),w.dispatch=g,w.discretebar=t,w.xAxis=n,w.yAxis=r,d3.rebind(w,t,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","id","showValues","valueFormat"),w.options=e.utils.optionsFunc.bind(w),w.margin=function(e){return arguments.length?(i.top=typeof e.top!="undefined"?e.top:i.top,i.right=typeof e.right!="undefined"?e.right:i.right,i.bottom=typeof e.bottom!="undefined"?e.bottom:i.bottom,i.left=typeof e.left!="undefined"?e.left:i.left,w):i},w.width=function(e){return arguments.length?(s=e,w):s},w.height=function(e){return arguments.length?(o=e,w):o},w.color=function(n){return arguments.length?(u=e.utils.getColor(n),t.color(u),w):u},w.showXAxis=function(e){return arguments.length?(a=e,w):a},w.showYAxis=function(e){return arguments.length?(f=e,w):f},w.rightAlignYAxis=function(e){return arguments.length?(l=e,r.orient(e?"right":"left"),w):l},w.staggerLabels=function(e){return arguments.length?(c=e,w):c},w.tooltips=function(e){return arguments.length?(h=e,w):h},w.tooltipContent=function(e){return arguments.length?(p=e,w):p},w.noData=function(e){return arguments.length?(m=e,w):m},w.transitionDuration=function(e){return arguments.length?(y=e,w):y},w},e.models.distribution=function(){"use strict";function l(e){return e.each(function(e){var a=n-(i==="x"?t.left+t.right:t.top+t.bottom),l=i=="x"?"y":"x",c=d3.select(this);f=f||u;var h=c.selectAll("g.nv-distribution").data([e]),p=h.enter().append("g").attr("class","nvd3 nv-distribution"),d=p.append("g"),v=h.select("g");h.attr("transform","translate("+t.left+","+t.top+")");var m=v.selectAll("g.nv-dist").data(function(e){return e},function(e){return e.key});m.enter().append("g"),m.attr("class",function(e,t){return"nv-dist nv-series-"+t}).style("stroke",function(e,t){return o(e,t)});var g=m.selectAll("line.nv-dist"+i).data(function(e){return e.values});g.enter().append("line").attr(i+"1",function(e,t){return f(s(e,t))}).attr(i+"2",function(e,t){return f(s(e,t))}),m.exit().selectAll("line.nv-dist"+i).transition().attr(i+"1",function(e,t){return u(s(e,t))}).attr(i+"2",function(e,t){return u(s(e,t))}).style("stroke-opacity",0).remove(),g.attr("class",function(e,t){return"nv-dist"+i+" nv-dist"+i+"-"+t}).attr(l+"1",0).attr(l+"2",r),g.transition().attr(i+"1",function(e,t){return u(s(e,t))}).attr(i+"2",function(e,t){return u(s(e,t))}),f=u.copy()}),l}var t={top:0,right:0,bottom:0,left:0},n=400,r=8,i="x",s=function(e){return e[i]},o=e.utils.defaultColor(),u=d3.scale.linear(),a,f;return l.options=e.utils.optionsFunc.bind(l),l.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,l):t},l.width=function(e){return arguments.length?(n=e,l):n},l.axis=function(e){return arguments.length?(i=e,l):i},l.size=function(e){return arguments.length?(r=e,l):r},l.getData=function(e){return arguments.length?(s=d3.functor(e),l):s},l.scale=function(e){return arguments.length?(u=e,l):u},l.color=function(t){return arguments.length?(o=e.utils.getColor(t),l):o},l},e.models.historicalBar=function(){"use strict";function w(E){return E.each(function(w){var E=n-t.left-t.right,S=r-t.top-t.bottom,T=d3.select(this);s.domain(d||d3.extent(w[0].values.map(u).concat(f))),c?s.range(m||[E*.5/w[0].values.length,E*(w[0].values.length-.5)/w[0].values.length]):s.range(m||[0,E]),o.domain(v||d3.extent(w[0].values.map(a).concat(l))).range(g||[S,0]),s.domain()[0]===s.domain()[1]&&(s.domain()[0]?s.domain([s.domain()[0]-s.domain()[0]*.01,s.domain()[1]+s.domain()[1]*.01]):s.domain([-1,1])),o.domain()[0]===o.domain()[1]&&(o.domain()[0]?o.domain([o.domain()[0]+o.domain()[0]*.01,o.domain()[1]-o.domain()[1]*.01]):o.domain([-1,1]));var N=T.selectAll("g.nv-wrap.nv-historicalBar-"+i).data([w[0].values]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBar-"+i),k=C.append("defs"),L=C.append("g"),A=N.select("g");L.append("g").attr("class","nv-bars"),N.attr("transform","translate("+t.left+","+t.top+")"),T.on("click",function(e,t){y.chartClick({data:e,index:t,pos:d3.event,id:i})}),k.append("clipPath").attr("id","nv-chart-clip-path-"+i).append("rect"),N.select("#nv-chart-clip-path-"+i+" rect").attr("width",E).attr("height",S),A.attr("clip-path",h?"url(#nv-chart-clip-path-"+i+")":"");var O=N.select(".nv-bars").selectAll(".nv-bar").data(function(e){return e},function(e,t){return u(e,t)});O.exit().remove();var M=O.enter().append("rect").attr("x",0).attr("y",function(t,n){return e.utils.NaNtoZero(o(Math.max(0,a(t,n))))}).attr("height",function(t,n){return e.utils.NaNtoZero(Math.abs(o(a(t,n))-o(0)))}).attr("transform",function(e,t){return"translate("+(s(u(e,t))-E/w[0].values.length*.45)+",0)"}).on("mouseover",function(e,t){if(!b)return;d3.select(this).classed("hover",!0),y.elementMouseover({point:e,series:w[0],pos:[s(u(e,t)),o(a(e,t))],pointIndex:t,seriesIndex:0,e:d3.event})}).on("mouseout",function(e,t){if(!b)return;d3.select(this).classed("hover",!1),y.elementMouseout({point:e,series:w[0],pointIndex:t,seriesIndex:0,e:d3.event})}).on("click",function(e,t){if(!b)return;y.elementClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()}).on("dblclick",function(e,t){if(!b)return;y.elementDblClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()});O.attr("fill",function(e,t){return p(e,t)}).attr("class",function(e,t,n){return(a(e,t)<0?"nv-bar negative":"nv-bar positive")+" nv-bar-"+n+"-"+t}).transition().attr("transform",function(e,t){return"translate("+(s(u(e,t))-E/w[0].values.length*.45)+",0)"}).attr("width",E/w[0].values.length*.9),O.transition().attr("y",function(t,n){var r=a(t,n)<0?o(0):o(0)-o(a(t,n))<1?o(0)-1:o(a(t,n));return e.utils.NaNtoZero(r)}).attr("height",function(t,n){return e.utils.NaNtoZero(Math.max(Math.abs(o(a(t,n))-o(0)),1))})}),w}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.linear(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=[],l=[0],c=!1,h=!0,p=e.utils.defaultColor(),d,v,m,g,y=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),b=!0;return w.highlightPoint=function(e,t){d3.select(".nv-historicalBar-"+i).select(".nv-bars .nv-bar-0-"+e).classed("hover",t)},w.clearHighlights=function(){d3.select(".nv-historicalBar-"+i).select(".nv-bars .nv-bar.hover").classed("hover",!1)},w.dispatch=y,w.options=e.utils.optionsFunc.bind(w),w.x=function(e){return arguments.length?(u=e,w):u},w.y=function(e){return arguments.length?(a=e,w):a},w.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,w):t},w.width=function(e){return arguments.length?(n=e,w):n},w.height=function(e){return arguments.length?(r=e,w):r},w.xScale=function(e){return arguments.length?(s=e,w):s},w.yScale=function(e){return arguments.length?(o=e,w):o},w.xDomain=function(e){return arguments.length?(d=e,w):d},w.yDomain=function(e){return arguments.length?(v=e,w):v},w.xRange=function(e){return arguments.length?(m=e,w):m},w.yRange=function(e){return arguments.length?(g=e,w):g},w.forceX=function(e){return arguments.length?(f=e,w):f},w.forceY=function(e){return arguments.length?(l=e,w):l},w.padData=function(e){return arguments.length?(c=e,w):c},w.clipEdge=function(e){return arguments.length?(h=e,w):h},w.color=function(t){return arguments.length?(p=e.utils.getColor(t),w):p},w.id=function(e){return arguments.length?(i=e,w):i},w.interactive=function(e){return arguments.length?(b=!1,w):b},w},e.models.historicalBarChart=function(){"use strict";function x(e){return e.each(function(d){var T=d3.select(this),N=this,C=(u||parseInt(T.style("width"))||960)-s.left-s.right,k=(a||parseInt(T.style("height"))||400)-s.top-s.bottom;x.update=function(){T.transition().duration(E).call(x)},x.container=this,g.disabled=d.map(function(e){return!!e.disabled});if(!y){var L;y={};for(L in g)g[L]instanceof Array?y[L]=g[L].slice(0):y[L]=g[L]}if(!d||!d.length||!d.filter(function(e){return e.values.length}).length){var A=T.selectAll(".nv-noData").data([b]);return A.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),A.attr("x",s.left+C/2).attr("y",s.top+k/2).text(function(e){return e}),x}T.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale();var O=T.selectAll("g.nv-wrap.nv-historicalBarChart").data([d]),M=O.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBarChart").append("g"),_=O.select("g");M.append("g").attr("class","nv-x nv-axis"),M.append("g").attr("class","nv-y nv-axis"),M.append("g").attr("class","nv-barsWrap"),M.append("g").attr("class","nv-legendWrap"),f&&(i.width(C),_.select(".nv-legendWrap").datum(d).call(i),s.top!=i.height()&&(s.top=i.height(),k=(a||parseInt(T.style("height"))||400)-s.top-s.bottom),O.select(".nv-legendWrap").attr("transform","translate(0,"+ -s.top+")")),O.attr("transform","translate("+s.left+","+s.top+")"),h&&_.select(".nv-y.nv-axis").attr("transform","translate("+C+",0)"),t.width(C).height(k).color(d.map(function(e,t){return e.color||o(e,t)}).filter(function(e,t){return!d[t].disabled}));var D=_.select(".nv-barsWrap").datum(d.filter(function(e){return!e.disabled}));D.transition().call(t),l&&(n.scale(v).tickSize(-k,0),_.select(".nv-x.nv-axis").attr("transform","translate(0,"+m.range()[0]+")"),_.select(".nv-x.nv-axis").transition().call(n)),c&&(r.scale(m).ticks(k/36).tickSize(-C,0),_.select(".nv-y.nv-axis").transition().call(r)),i.dispatch.on("legendClick",function(t,n){t.disabled=!t.disabled,d.filter(function(e){return!e.disabled}).length||d.map(function(e){return e.disabled=!1,O.selectAll(".nv-series").classed("disabled",!1),e}),g.disabled=d.map(function(e){return!!e.disabled}),w.stateChange(g),e.transition().call(x)}),i.dispatch.on("legendDblclick",function(e){d.forEach(function(e){e.disabled=!0}),e.disabled=!1,g.disabled=d.map(function(e){return!!e.disabled}),w.stateChange(g),x.update()}),w.on("tooltipShow",function(e){p&&S(e,N.parentNode)}),w.on("changeState",function(e){typeof e.disabled!="undefined"&&(d.forEach(function(t,n){t.disabled=e.disabled[n]}),g.disabled=e.disabled),x.update()})}),x}var t=e.models.historicalBar(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s={top:30,right:90,bottom:50,left:90},o=e.utils.defaultColor(),u=null,a=null,f=!1,l=!0,c=!0,h=!1,p=!0,d=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},v,m,g={},y=null,b="No Data Available.",w=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),E=250;n.orient("bottom").tickPadding(7),r.orient(h?"right":"left");var S=function(i,s){if(s){var o=d3.select(s).select("svg"),u=o.node()?o.attr("viewBox"):null;if(u){u=u.split(" ");var a=parseInt(o.style("width"))/u[2];i.pos[0]=i.pos[0]*a,i.pos[1]=i.pos[1]*a}}var f=i.pos[0]+(s.offsetLeft||0),l=i.pos[1]+(s.offsetTop||0),c=n.tickFormat()(t.x()(i.point,i.pointIndex)),h=r.tickFormat()(t.y()(i.point,i.pointIndex)),p=d(i.series.key,c,h,i,x);e.tooltip.show([f,l],p,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+s.left,e.pos[1]+s.top],w.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){w.tooltipHide(e)}),w.on("tooltipHide",function(){p&&e.tooltip.cleanup()}),x.dispatch=w,x.bars=t,x.legend=i,x.xAxis=n,x.yAxis=r,d3.rebind(x,t,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","id","interpolate","highlightPoint","clearHighlights","interactive"),x.options=e.utils.optionsFunc.bind(x),x.margin=function(e){return arguments.length?(s.top=typeof e.top!="undefined"?e.top:s.top,s.right=typeof e.right!="undefined"?e.right:s.right,s.bottom=typeof e.bottom!="undefined"?e.bottom:s.bottom,s.left=typeof e.left!="undefined"?e.left:s.left,x):s},x.width=function(e){return arguments.length?(u=e,x):u},x.height=function(e){return arguments.length?(a=e,x):a},x.color=function(t){return arguments.length?(o=e.utils.getColor(t),i.color(o),x):o},x.showLegend=function(e){return arguments.length?(f=e,x):f},x.showXAxis=function(e){return arguments.length?(l=e,x):l},x.showYAxis=function(e){return arguments.length?(c=e,x):c},x.rightAlignYAxis=function(e){return arguments.length?(h=e,r.orient(e?"right":"left"),x):h},x.tooltips=function(e){return arguments.length?(p=e,x):p},x.tooltipContent=function(e){return arguments.length?(d=e,x):d},x.state=function(e){return arguments.length?(g=e,x):g},x.defaultState=function(e){return arguments.length?(y=e,x):y},x.noData=function(e){return arguments.length?(b=e,x):b},x.transitionDuration=function(e){return arguments.length?(E=e,x):E},x},e.models.indentedTree=function(){"use strict";function g(e){return e.each(function(e){function k(e,t,n){d3.event.stopPropagation();if(d3.event.shiftKey&&!n)return d3.event.shiftKey=!1,e.values&&e.values.forEach(function(e){(e.values||e._values)&&k(e,0,!0)}),!0;if(!O(e))return!0;e.values?(e._values=e.values,e.values=null):(e.values=e._values,e._values=null),g.update()}function L(e){return e._values&&e._values.length?h:e.values&&e.values.length?p:""}function A(e){return e._values&&e._values.length}function O(e){var t=e.values||e._values;return t&&t.length}var t=1,n=d3.select(this),i=d3.layout.tree().children(function(e){return e.values}).size([r,f]);g.update=function(){n.transition().duration(600).call(g)},e[0]||(e[0]={key:a});var s=i.nodes(e[0]),y=d3.select(this).selectAll("div").data([[s]]),b=y.enter().append("div").attr("class","nvd3 nv-wrap nv-indentedtree"),w=b.append("table"),E=y.select("table").attr("width","100%").attr("class",c);if(o){var S=w.append("thead"),x=S.append("tr");l.forEach(function(e){x.append("th").attr("width",e.width?e.width:"10%").style("text-align",e.type=="numeric"?"right":"left").append("span").text(e.label)})}var T=E.selectAll("tbody").data(function(e){return e});T.enter().append("tbody"),t=d3.max(s,function(e){return e.depth}),i.size([r,t*f]);var N=T.selectAll("tr").data(function(e){return e.filter(function(e){return u&&!e.children?u(e):!0})},function(e,t){return e.id||e.id||++m});N.exit().remove(),N.select("img.nv-treeicon").attr("src",L).classed("folded",A);var C=N.enter().append("tr");l.forEach(function(e,t){var n=C.append("td").style("padding-left",function(e){return(t?0:e.depth*f+12+(L(e)?0:16))+"px"},"important").style("text-align",e.type=="numeric"?"right":"left");t==0&&n.append("img").classed("nv-treeicon",!0).classed("nv-folded",A).attr("src",L).style("width","14px").style("height","14px").style("padding","0 1px").style("display",function(e){return L(e)?"inline-block":"none"}).on("click",k),n.each(function(n){!t&&v(n)?d3.select(this).append("a").attr("href",v).attr("class",d3.functor(e.classes)).append("span"):d3.select(this).append("span"),d3.select(this).select("span").attr("class",d3.functor(e.classes)).text(function(t){return e.format?e.format(t):t[e.key]||"-"})}),e.showCount&&(n.append("span").attr("class","nv-childrenCount"),N.selectAll("span.nv-childrenCount").text(function(e){return e.values&&e.values.length||e._values&&e._values.length?"("+(e.values&&e.values.filter(function(e){return u?u(e):!0}).length||e._values&&e._values.filter(function(e){return u?u(e):!0}).length||0)+")":""}))}),N.order().on("click",function(e){d.elementClick({row:this,data:e,pos:[e.x,e.y]})}).on("dblclick",function(e){d.elementDblclick({row:this,data:e,pos:[e.x,e.y]})}).on("mouseover",function(e){d.elementMouseover({row:this,data:e,pos:[e.x,e.y]})}).on("mouseout",function(e){d.elementMouseout({row:this,data:e,pos:[e.x,e.y]})})}),g}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=e.utils.defaultColor(),s=Math.floor(Math.random()*1e4),o=!0,u=!1,a="No Data Available.",f=20,l=[{key:"key",label:"Name",type:"text"}],c=null,h="images/grey-plus.png",p="images/grey-minus.png",d=d3.dispatch("elementClick","elementDblclick","elementMouseover","elementMouseout"),v=function(e){return e.url},m=0;return g.options=e.utils.optionsFunc.bind(g),g.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,g):t},g.width=function(e){return arguments.length?(n=e,g):n},g.height=function(e){return arguments.length?(r=e,g):r},g.color=function(t){return arguments.length?(i=e.utils.getColor(t),scatter.color(i),g):i},g.id=function(e){return arguments.length?(s=e,g):s},g.header=function(e){return arguments.length?(o=e,g):o},g.noData=function(e){return arguments.length?(a=e,g):a},g.filterZero=function(e){return arguments.length?(u=e,g):u},g.columns=function(e){return arguments.length?(l=e,g):l},g.tableClass=function(e){return arguments.length?(c=e,g):c},g.iconOpen=function(e){return arguments.length?(h=e,g):h},g.iconClose=function(e){return arguments.length?(p=e,g):p},g.getUrl=function(e){return arguments.length?(v=e,g):v},g},e.models.legend=function(){"use strict";function c(h){return h.each(function(c){var h=n-t.left-t.right,p=d3.select(this),d=p.selectAll("g.nv-legend").data([c]),v=d.enter().append("g").attr("class","nvd3 nv-legend").append("g"),m=d.select("g");d.attr("transform","translate("+t.left+","+t.top+")");var g=m.selectAll(".nv-series").data(function(e){return e}),y=g.enter().append("g").attr("class","nv-series").on("mouseover",function(e,t){l.legendMouseover(e,t)}).on("mouseout",function(e,t){l.legendMouseout(e,t)}).on("click",function(e,t){l.legendClick(e,t),a&&(f?(c.forEach(function(e){e.disabled=!0}),e.disabled=!1):(e.disabled=!e.disabled,c.every(function(e){return e.disabled})&&c.forEach(function(e){e.disabled=!1})),l.stateChange({disabled:c.map(function(e){return!!e.disabled})}))}).on("dblclick",function(e,t){l.legendDblclick(e,t),a&&(c.forEach(function(e){e.disabled=!0}),e.disabled=!1,l.stateChange({disabled:c.map(function(e){return!!e.disabled})}))});y.append("circle").style("stroke-width",2).attr("class","nv-legend-symbol").attr("r",5),y.append("text").attr("text-anchor","start").attr("class","nv-legend-text").attr("dy",".32em").attr("dx","8"),g.classed("disabled",function(e){return e.disabled}),g.exit().remove(),g.select("circle").style("fill",function(e,t){return e.color||s(e,t)}).style("stroke",function(e,t){return e.color||s(e,t)}),g.select("text").text(i);if(o){var b=[];g.each(function(t,n){var r=d3.select(this).select("text"),i;try{i=r.getComputedTextLength();if(i<=0)throw Error()}catch(s){i=e.utils.calcApproxTextWidth(r)}b.push(i+28)});var w=0,E=0,S=[];while(Eh&&w>1){S=[],w--;for(var x=0;x(S[x%w]||0)&&(S[x%w]=b[x]);E=S.reduce(function(e,t,n,r){return e+t})}var T=[];for(var N=0,C=0;NA&&(A=L),"translate("+O+","+k+")"}),m.attr("transform","translate("+(n-t.right-A)+","+t.top+")"),r=t.top+t.bottom+k+15}}),c}var t={top:5,right:0,bottom:5,left:0},n=400,r=20,i=function(e){return e.key},s=e.utils.defaultColor(),o=!0,u=!0,a=!0,f=!1,l=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout","stateChange");return c.dispatch=l,c.options=e.utils.optionsFunc.bind(c),c.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,c):t},c.width=function(e){return arguments.length?(n=e,c):n},c.height=function(e){return arguments.length?(r=e,c):r},c.key=function(e){return arguments.length?(i=e,c):i},c.color=function(t){return arguments.length?(s=e.utils.getColor(t),c):s},c.align=function(e){return arguments.length?(o=e,c):o},c.rightAlign=function(e){return arguments.length?(u=e,c):u},c.updateState=function(e){return arguments.length?(a=e,c):a},c.radioButtonMode=function(e){return arguments.length?(f=e,c):f},c},e.models.line=function(){"use strict";function m(g){return g.each(function(m){var g=r-n.left-n.right,b=i-n.top-n.bottom,w=d3.select(this);c=t.xScale(),h=t.yScale(),d=d||c,v=v||h;var E=w.selectAll("g.nv-wrap.nv-line").data([m]),S=E.enter().append("g").attr("class","nvd3 nv-wrap nv-line"),T=S.append("defs"),N=S.append("g"),C=E.select("g");N.append("g").attr("class","nv-groups"),N.append("g").attr("class","nv-scatterWrap"),E.attr("transform","translate("+n.left+","+n.top+")"),t.width(g).height(b);var k=E.select(".nv-scatterWrap");k.transition().call(t),T.append("clipPath").attr("id","nv-edge-clip-"+t.id()).append("rect"),E.select("#nv-edge-clip-"+t.id()+" rect").attr("width",g).attr("height",b),C.attr("clip-path",l?"url(#nv-edge-clip-"+t.id()+")":""),k.attr("clip-path",l?"url(#nv-edge-clip-"+t.id()+")":"");var L=E.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});L.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),L.exit().remove(),L.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return s(e,t)}).style("stroke",function(e,t){return s(e,t)}),L.transition().style("stroke-opacity",1).style("fill-opacity",.5);var A=L.selectAll("path.nv-area").data(function(e){return f(e)?[e]:[]});A.enter().append("path").attr("class","nv-area").attr("d",function(t){return d3.svg.area().interpolate(p).defined(a).x(function(t,n){return e. -utils.NaNtoZero(d(o(t,n)))}).y0(function(t,n){return e.utils.NaNtoZero(v(u(t,n)))}).y1(function(e,t){return v(h.domain()[0]<=0?h.domain()[1]>=0?0:h.domain()[1]:h.domain()[0])}).apply(this,[t.values])}),L.exit().selectAll("path.nv-area").remove(),A.transition().attr("d",function(t){return d3.svg.area().interpolate(p).defined(a).x(function(t,n){return e.utils.NaNtoZero(c(o(t,n)))}).y0(function(t,n){return e.utils.NaNtoZero(h(u(t,n)))}).y1(function(e,t){return h(h.domain()[0]<=0?h.domain()[1]>=0?0:h.domain()[1]:h.domain()[0])}).apply(this,[t.values])});var O=L.selectAll("path.nv-line").data(function(e){return[e.values]});O.enter().append("path").attr("class","nv-line").attr("d",d3.svg.line().interpolate(p).defined(a).x(function(t,n){return e.utils.NaNtoZero(d(o(t,n)))}).y(function(t,n){return e.utils.NaNtoZero(v(u(t,n)))})),O.transition().attr("d",d3.svg.line().interpolate(p).defined(a).x(function(t,n){return e.utils.NaNtoZero(c(o(t,n)))}).y(function(t,n){return e.utils.NaNtoZero(h(u(t,n)))})),d=c.copy(),v=h.copy()}),m}var t=e.models.scatter(),n={top:0,right:0,bottom:0,left:0},r=960,i=500,s=e.utils.defaultColor(),o=function(e){return e.x},u=function(e){return e.y},a=function(e,t){return!isNaN(u(e,t))&&u(e,t)!==null},f=function(e){return e.area},l=!1,c,h,p="linear";t.size(16).sizeDomain([16,256]);var d,v;return m.dispatch=t.dispatch,m.scatter=t,d3.rebind(m,t,"id","interactive","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","forceX","forceY","forceSize","clipVoronoi","useVoronoi","clipRadius","padData","highlightPoint","clearHighlights"),m.options=e.utils.optionsFunc.bind(m),m.margin=function(e){return arguments.length?(n.top=typeof e.top!="undefined"?e.top:n.top,n.right=typeof e.right!="undefined"?e.right:n.right,n.bottom=typeof e.bottom!="undefined"?e.bottom:n.bottom,n.left=typeof e.left!="undefined"?e.left:n.left,m):n},m.width=function(e){return arguments.length?(r=e,m):r},m.height=function(e){return arguments.length?(i=e,m):i},m.x=function(e){return arguments.length?(o=e,t.x(e),m):o},m.y=function(e){return arguments.length?(u=e,t.y(e),m):u},m.clipEdge=function(e){return arguments.length?(l=e,m):l},m.color=function(n){return arguments.length?(s=e.utils.getColor(n),t.color(s),m):s},m.interpolate=function(e){return arguments.length?(p=e,m):p},m.defined=function(e){return arguments.length?(a=e,m):a},m.isArea=function(e){return arguments.length?(f=d3.functor(e),m):f},m},e.models.lineChart=function(){"use strict";function N(m){return m.each(function(m){var C=d3.select(this),k=this,L=(a||parseInt(C.style("width"))||960)-o.left-o.right,A=(f||parseInt(C.style("height"))||400)-o.top-o.bottom;N.update=function(){C.transition().duration(x).call(N)},N.container=this,b.disabled=m.map(function(e){return!!e.disabled});if(!w){var O;w={};for(O in b)b[O]instanceof Array?w[O]=b[O].slice(0):w[O]=b[O]}if(!m||!m.length||!m.filter(function(e){return e.values.length}).length){var M=C.selectAll(".nv-noData").data([E]);return M.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),M.attr("x",o.left+L/2).attr("y",o.top+A/2).text(function(e){return e}),N}C.selectAll(".nv-noData").remove(),g=t.xScale(),y=t.yScale();var _=C.selectAll("g.nv-wrap.nv-lineChart").data([m]),D=_.enter().append("g").attr("class","nvd3 nv-wrap nv-lineChart").append("g"),P=_.select("g");D.append("rect").style("opacity",0),D.append("g").attr("class","nv-x nv-axis"),D.append("g").attr("class","nv-y nv-axis"),D.append("g").attr("class","nv-linesWrap"),D.append("g").attr("class","nv-legendWrap"),D.append("g").attr("class","nv-interactive"),P.select("rect").attr("width",L).attr("height",A>0?A:0),l&&(i.width(L),P.select(".nv-legendWrap").datum(m).call(i),o.top!=i.height()&&(o.top=i.height(),A=(f||parseInt(C.style("height"))||400)-o.top-o.bottom),_.select(".nv-legendWrap").attr("transform","translate(0,"+ -o.top+")")),_.attr("transform","translate("+o.left+","+o.top+")"),p&&P.select(".nv-y.nv-axis").attr("transform","translate("+L+",0)"),d&&(s.width(L).height(A).margin({left:o.left,top:o.top}).svgContainer(C).xScale(g),_.select(".nv-interactive").call(s)),t.width(L).height(A).color(m.map(function(e,t){return e.color||u(e,t)}).filter(function(e,t){return!m[t].disabled}));var H=P.select(".nv-linesWrap").datum(m.filter(function(e){return!e.disabled}));H.transition().call(t),c&&(n.scale(g).ticks(L/100).tickSize(-A,0),P.select(".nv-x.nv-axis").attr("transform","translate(0,"+y.range()[0]+")"),P.select(".nv-x.nv-axis").transition().call(n)),h&&(r.scale(y).ticks(A/36).tickSize(-L,0),P.select(".nv-y.nv-axis").transition().call(r)),i.dispatch.on("stateChange",function(e){b=e,S.stateChange(b),N.update()}),s.dispatch.on("elementMousemove",function(i){t.clearHighlights();var a,f,l,c=[];m.filter(function(e,t){return e.seriesIndex=t,!e.disabled}).forEach(function(n,r){f=e.interactiveBisect(n.values,i.pointXValue,N.x()),t.highlightPoint(r,f,!0);var s=n.values[f];if(typeof s=="undefined")return;typeof a=="undefined"&&(a=s),typeof l=="undefined"&&(l=N.xScale()(N.x()(s,f))),c.push({key:n.key,value:N.y()(s,f),color:u(n,n.seriesIndex)})});if(c.length>2){var h=N.yScale().invert(i.mouseY),p=Math.abs(N.yScale().domain()[0]-N.yScale().domain()[1]),d=.03*p,g=e.nearestValueIndex(c.map(function(e){return e.value}),h,d);g!==null&&(c[g].highlight=!0)}var y=n.tickFormat()(N.x()(a,f));s.tooltip.position({left:l+o.left,top:i.mouseY+o.top}).chartContainer(k.parentNode).enabled(v).valueFormatter(function(e,t){return r.tickFormat()(e)}).data({value:y,series:c})(),s.renderGuideLine(l)}),s.dispatch.on("elementMouseout",function(e){S.tooltipHide(),t.clearHighlights()}),S.on("tooltipShow",function(e){v&&T(e,k.parentNode)}),S.on("changeState",function(e){typeof e.disabled!="undefined"&&m.length===e.disabled.length&&(m.forEach(function(t,n){t.disabled=e.disabled[n]}),b.disabled=e.disabled),N.update()})}),N}var t=e.models.line(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.interactiveGuideline(),o={top:30,right:20,bottom:50,left:60},u=e.utils.defaultColor(),a=null,f=null,l=!0,c=!0,h=!0,p=!1,d=!1,v=!0,m=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},g,y,b={},w=null,E="No Data Available.",S=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),x=250;n.orient("bottom").tickPadding(7),r.orient(p?"right":"left");var T=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=m(i.series.key,a,f,i,N);e.tooltip.show([o,u],l,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+o.left,e.pos[1]+o.top],S.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),S.on("tooltipHide",function(){v&&e.tooltip.cleanup()}),N.dispatch=S,N.lines=t,N.legend=i,N.xAxis=n,N.yAxis=r,N.interactiveLayer=s,d3.rebind(N,t,"defined","isArea","x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","useVoronoi","id","interpolate"),N.options=e.utils.optionsFunc.bind(N),N.margin=function(e){return arguments.length?(o.top=typeof e.top!="undefined"?e.top:o.top,o.right=typeof e.right!="undefined"?e.right:o.right,o.bottom=typeof e.bottom!="undefined"?e.bottom:o.bottom,o.left=typeof e.left!="undefined"?e.left:o.left,N):o},N.width=function(e){return arguments.length?(a=e,N):a},N.height=function(e){return arguments.length?(f=e,N):f},N.color=function(t){return arguments.length?(u=e.utils.getColor(t),i.color(u),N):u},N.showLegend=function(e){return arguments.length?(l=e,N):l},N.showXAxis=function(e){return arguments.length?(c=e,N):c},N.showYAxis=function(e){return arguments.length?(h=e,N):h},N.rightAlignYAxis=function(e){return arguments.length?(p=e,r.orient(e?"right":"left"),N):p},N.useInteractiveGuideline=function(e){return arguments.length?(d=e,e===!0&&(N.interactive(!1),N.useVoronoi(!1)),N):d},N.tooltips=function(e){return arguments.length?(v=e,N):v},N.tooltipContent=function(e){return arguments.length?(m=e,N):m},N.state=function(e){return arguments.length?(b=e,N):b},N.defaultState=function(e){return arguments.length?(w=e,N):w},N.noData=function(e){return arguments.length?(E=e,N):E},N.transitionDuration=function(e){return arguments.length?(x=e,N):x},N},e.models.linePlusBarChart=function(){"use strict";function T(e){return e.each(function(e){var l=d3.select(this),c=this,v=(a||parseInt(l.style("width"))||960)-u.left-u.right,N=(f||parseInt(l.style("height"))||400)-u.top-u.bottom;T.update=function(){l.transition().call(T)},b.disabled=e.map(function(e){return!!e.disabled});if(!w){var C;w={};for(C in b)b[C]instanceof Array?w[C]=b[C].slice(0):w[C]=b[C]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var k=l.selectAll(".nv-noData").data([E]);return k.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),k.attr("x",u.left+v/2).attr("y",u.top+N/2).text(function(e){return e}),T}l.selectAll(".nv-noData").remove();var L=e.filter(function(e){return!e.disabled&&e.bar}),A=e.filter(function(e){return!e.bar});m=A.filter(function(e){return!e.disabled}).length&&A.filter(function(e){return!e.disabled})[0].values.length?t.xScale():n.xScale(),g=n.yScale(),y=t.yScale();var O=d3.select(this).selectAll("g.nv-wrap.nv-linePlusBar").data([e]),M=O.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),_=O.select("g");M.append("g").attr("class","nv-x nv-axis"),M.append("g").attr("class","nv-y1 nv-axis"),M.append("g").attr("class","nv-y2 nv-axis"),M.append("g").attr("class","nv-barsWrap"),M.append("g").attr("class","nv-linesWrap"),M.append("g").attr("class","nv-legendWrap"),p&&(o.width(v/2),_.select(".nv-legendWrap").datum(e.map(function(e){return e.originalKey=e.originalKey===undefined?e.key:e.originalKey,e.key=e.originalKey+(e.bar?" (left axis)":" (right axis)"),e})).call(o),u.top!=o.height()&&(u.top=o.height(),N=(f||parseInt(l.style("height"))||400)-u.top-u.bottom),_.select(".nv-legendWrap").attr("transform","translate("+v/2+","+ -u.top+")")),O.attr("transform","translate("+u.left+","+u.top+")"),t.width(v).height(N).color(e.map(function(e,t){return e.color||h(e,t)}).filter(function(t,n){return!e[n].disabled&&!e[n].bar})),n.width(v).height(N).color(e.map(function(e,t){return e.color||h(e,t)}).filter(function(t,n){return!e[n].disabled&&e[n].bar}));var D=_.select(".nv-barsWrap").datum(L.length?L:[{values:[]}]),P=_.select(".nv-linesWrap").datum(A[0]&&!A[0].disabled?A:[{values:[]}]);d3.transition(D).call(n),d3.transition(P).call(t),r.scale(m).ticks(v/100).tickSize(-N,0),_.select(".nv-x.nv-axis").attr("transform","translate(0,"+g.range()[0]+")"),d3.transition(_.select(".nv-x.nv-axis")).call(r),i.scale(g).ticks(N/36).tickSize(-v,0),d3.transition(_.select(".nv-y1.nv-axis")).style("opacity",L.length?1:0).call(i),s.scale(y).ticks(N/36).tickSize(L.length?0:-v,0),_.select(".nv-y2.nv-axis").style("opacity",A.length?1:0).attr("transform","translate("+v+",0)"),d3.transition(_.select(".nv-y2.nv-axis")).call(s),o.dispatch.on("stateChange",function(e){b=e,S.stateChange(b),T.update()}),S.on("tooltipShow",function(e){d&&x(e,c.parentNode)}),S.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),b.disabled=t.disabled),T.update()})}),T}var t=e.models.line(),n=e.models.historicalBar(),r=e.models.axis(),i=e.models.axis(),s=e.models.axis(),o=e.models.legend(),u={top:30,right:60,bottom:50,left:60},a=null,f=null,l=function(e){return e.x},c=function(e){return e.y},h=e.utils.defaultColor(),p=!0,d=!0,v=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},m,g,y,b={},w=null,E="No Data Available.",S=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState");n.padData(!0),t.clipEdge(!1).padData(!0),r.orient("bottom").tickPadding(7).highlightZero(!1),i.orient("left"),s.orient("right");var x=function(n,o){var u=n.pos[0]+(o.offsetLeft||0),a=n.pos[1]+(o.offsetTop||0),f=r.tickFormat()(t.x()(n.point,n.pointIndex)),l=(n.series.bar?i:s).tickFormat()(t.y()(n.point,n.pointIndex)),c=v(n.series.key,f,l,n,T);e.tooltip.show([u,a],c,n.value<0?"n":"s",null,o)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],S.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),n.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],S.tooltipShow(e)}),n.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),S.on("tooltipHide",function(){d&&e.tooltip.cleanup()}),T.dispatch=S,T.legend=o,T.lines=t,T.bars=n,T.xAxis=r,T.y1Axis=i,T.y2Axis=s,d3.rebind(T,t,"defined","size","clipVoronoi","interpolate"),T.options=e.utils.optionsFunc.bind(T),T.x=function(e){return arguments.length?(l=e,t.x(e),n.x(e),T):l},T.y=function(e){return arguments.length?(c=e,t.y(e),n.y(e),T):c},T.margin=function(e){return arguments.length?(u.top=typeof e.top!="undefined"?e.top:u.top,u.right=typeof e.right!="undefined"?e.right:u.right,u.bottom=typeof e.bottom!="undefined"?e.bottom:u.bottom,u.left=typeof e.left!="undefined"?e.left:u.left,T):u},T.width=function(e){return arguments.length?(a=e,T):a},T.height=function(e){return arguments.length?(f=e,T):f},T.color=function(t){return arguments.length?(h=e.utils.getColor(t),o.color(h),T):h},T.showLegend=function(e){return arguments.length?(p=e,T):p},T.tooltips=function(e){return arguments.length?(d=e,T):d},T.tooltipContent=function(e){return arguments.length?(v=e,T):v},T.state=function(e){return arguments.length?(b=e,T):b},T.defaultState=function(e){return arguments.length?(w=e,T):w},T.noData=function(e){return arguments.length?(E=e,T):E},T},e.models.lineWithFocusChart=function(){"use strict";function k(e){return e.each(function(e){function U(e){var t=+(e=="e"),n=t?1:-1,r=M/3;return"M"+.5*n+","+r+"A6,6 0 0 "+t+" "+6.5*n+","+(r+6)+"V"+(2*r-6)+"A6,6 0 0 "+t+" "+.5*n+","+2*r+"Z"+"M"+2.5*n+","+(r+8)+"V"+(2*r-8)+"M"+4.5*n+","+(r+8)+"V"+(2*r-8)}function z(){a.empty()||a.extent(w),I.data([a.empty()?g.domain():w]).each(function(e,t){var n=g(e[0])-v.range()[0],r=v.range()[1]-g(e[1]);d3.select(this).select(".left").attr("width",n<0?0:n),d3.select(this).select(".right").attr("x",g(e[1])).attr("width",r<0?0:r)})}function W(){w=a.empty()?null:a.extent();var n=a.empty()?g.domain():a.extent();if(Math.abs(n[0]-n[1])<=1)return;T.brush({extent:n,brush:a}),z();var s=H.select(".nv-focus .nv-linesWrap").datum(e.filter(function(e){return!e.disabled}).map(function(e,r){return{key:e.key,values:e.values.filter(function(e,r){return t.x()(e,r)>=n[0]&&t.x()(e,r)<=n[1]})}}));s.transition().duration(N).call(t),H.select(".nv-focus .nv-x.nv-axis").transition().duration(N).call(r),H.select(".nv-focus .nv-y.nv-axis").transition().duration(N).call(i)}var S=d3.select(this),L=this,A=(h||parseInt(S.style("width"))||960)-f.left-f.right,O=(p||parseInt(S.style("height"))||400)-f.top-f.bottom-d,M=d-l.top-l.bottom;k.update=function(){S.transition().duration(N).call(k)},k.container=this;if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var _=S.selectAll(".nv-noData").data([x]);return _.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),_.attr("x",f.left+A/2).attr("y",f.top+O/2).text(function(e){return e}),k}S.selectAll(".nv-noData").remove(),v=t.xScale(),m=t.yScale(),g=n.xScale(),y=n.yScale();var D=S.selectAll("g.nv-wrap.nv-lineWithFocusChart").data([e]),P=D.enter().append("g").attr("class","nvd3 nv-wrap nv-lineWithFocusChart").append("g"),H=D.select("g");P.append("g").attr("class","nv-legendWrap");var B=P.append("g").attr("class","nv-focus");B.append("g").attr("class","nv-x nv-axis"),B.append("g").attr("class","nv-y nv-axis"),B.append("g").attr("class","nv-linesWrap");var j=P.append("g").attr("class","nv-context");j.append("g").attr("class","nv-x nv-axis"),j.append("g").attr("class","nv-y nv-axis"),j.append("g").attr("class","nv-linesWrap"),j.append("g").attr("class","nv-brushBackground"),j.append("g").attr("class","nv-x nv-brush"),b&&(u.width(A),H.select(".nv-legendWrap").datum(e).call(u),f.top!=u.height()&&(f.top=u.height(),O=(p||parseInt(S.style("height"))||400)-f.top-f.bottom-d),H.select(".nv-legendWrap").attr("transform","translate(0,"+ -f.top+")")),D.attr("transform","translate("+f.left+","+f.top+")"),t.width(A).height(O).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),n.defined(t.defined()).width(A).height(M).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),H.select(".nv-context").attr("transform","translate(0,"+(O+f.bottom+l.top)+")");var F=H.select(".nv-context .nv-linesWrap").datum(e.filter(function(e){return!e.disabled}));d3.transition(F).call(n),r.scale(v).ticks(A/100).tickSize(-O,0),i.scale(m).ticks(O/36).tickSize(-A,0),H.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+O+")"),a.x(g).on("brush",function(){var e=k.transitionDuration();k.transitionDuration(0),W(),k.transitionDuration(e)}),w&&a.extent(w);var I=H.select(".nv-brushBackground").selectAll("g").data([w||a.extent()]),q=I.enter().append("g");q.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",M),q.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",M);var R=H.select(".nv-x.nv-brush").call(a);R.selectAll("rect").attr("height",M),R.selectAll(".resize").append("path").attr("d",U),W(),s.scale(g).ticks(A/100).tickSize(-M,0),H.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+y.range()[0]+")"),d3.transition(H.select(".nv-context .nv-x.nv-axis")).call(s),o.scale(y).ticks(M/36).tickSize(-A,0),d3.transition(H.select(".nv-context .nv-y.nv-axis")).call(o),H.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+y.range()[0]+")"),u.dispatch.on("stateChange",function(e){k.update()}),T.on("tooltipShow",function(e){E&&C(e,L.parentNode)})}),k}var t=e.models.line(),n=e.models.line(),r=e.models.axis(),i=e.models.axis(),s=e.models.axis(),o=e.models.axis(),u=e.models.legend(),a=d3.svg.brush(),f={top:30,right:30,bottom:30,left:60},l={top:0,right:30,bottom:20,left:60},c=e.utils.defaultColor(),h=null,p=null,d=100,v,m,g,y,b=!0,w=null,E=!0,S=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},x="No Data Available.",T=d3.dispatch("tooltipShow","tooltipHide","brush"),N=250;t.clipEdge(!0),n.interactive(!1),r.orient("bottom").tickPadding(5),i.orient("left"),s.orient("bottom").tickPadding(5),o.orient("left");var C=function(n,s){var o=n.pos[0]+(s.offsetLeft||0),u=n.pos[1]+(s.offsetTop||0),a=r.tickFormat()(t.x()(n.point,n.pointIndex)),f=i.tickFormat()(t.y()(n.point,n.pointIndex)),l=S(n.series.key,a,f,n,k);e.tooltip.show([o,u],l,null,null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+f.left,e.pos[1]+f.top],T.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),T.on("tooltipHide",function(){E&&e.tooltip.cleanup()}),k.dispatch=T,k.legend=u,k.lines=t,k.lines2=n,k.xAxis=r,k.yAxis=i,k.x2Axis=s,k.y2Axis=o,d3.rebind(k,t,"defined","isArea","size","xDomain","yDomain","xRange","yRange","forceX","forceY","interactive","clipEdge","clipVoronoi","id"),k.options=e.utils.optionsFunc.bind(k),k.x=function(e){return arguments.length?(t.x(e),n.x(e),k):t.x},k.y=function(e){return arguments.length?(t.y(e),n.y(e),k):t.y},k.margin=function(e){return arguments.length?(f.top=typeof e.top!="undefined"?e.top:f.top,f.right=typeof e.right!="undefined"?e.right:f.right,f.bottom=typeof e.bottom!="undefined"?e.bottom:f.bottom,f.left=typeof e.left!="undefined"?e.left:f.left,k):f},k.margin2=function(e){return arguments.length?(l=e,k):l},k.width=function(e){return arguments.length?(h=e,k):h},k.height=function(e){return arguments.length?(p=e,k):p},k.height2=function(e){return arguments.length?(d=e,k):d},k.color=function(t){return arguments.length?(c=e.utils.getColor(t),u.color(c),k):c},k.showLegend=function(e){return arguments.length?(b=e,k):b},k.tooltips=function(e){return arguments.length?(E=e,k):E},k.tooltipContent=function(e){return arguments.length?(S=e,k):S},k.interpolate=function(e){return arguments.length?(t.interpolate(e),n.interpolate(e),k):t.interpolate()},k.noData=function(e){return arguments.length?(x=e,k):x},k.xTickFormat=function(e){return arguments.length?(r.tickFormat(e),s.tickFormat(e),k):r.tickFormat()},k.yTickFormat=function(e){return arguments.length?(i.tickFormat(e),o.tickFormat(e),k):i.tickFormat()},k.brushExtent=function(e){return arguments.length?(w=e,k):w},k.transitionDuration=function(e){return arguments.length?(N=e,k):N},k},e.models.linePlusBarWithFocusChart=function(){"use strict";function B(e){return e.each(function(e){function nt(e){var t=+(e=="e"),n=t?1:-1,r=q/3;return"M"+.5*n+","+r+"A6,6 0 0 "+t+" "+6.5*n+","+(r+6)+"V"+(2*r-6)+"A6,6 0 0 "+t+" "+.5*n+","+2*r+"Z"+"M"+2.5*n+","+(r+8)+"V"+(2*r-8)+"M"+4.5*n+","+(r+8)+"V"+(2*r-8)}function rt(){h.empty()||h.extent(x),Z.data([h.empty()?k.domain():x]).each(function(e,t){var n=k(e[0])-k.range()[0],r=k.range()[1]-k(e[1]);d3.select(this).select(".left").attr("width",n<0?0:n),d3.select(this).select(".right").attr("x",k(e[1])).attr("width",r<0?0:r)})}function it(){x=h.empty()?null:h.extent(),S=h.empty()?k.domain():h.extent(),D.brush({extent:S,brush:h}),rt(),r.width(F).height(I).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&e[n].bar})),t.width(F).height(I).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&!e[n].bar}));var n=J.select(".nv-focus .nv-barsWrap").datum(U.length?U.map(function(e,t){return{key:e.key,values:e.values.filter(function(e,t){return r.x()(e,t)>=S[0]&&r.x()(e,t)<=S[1]})}}):[{values:[]}]),i=J.select(".nv-focus .nv-linesWrap").datum(z[0].disabled?[{values:[]}]:z.map(function(e,n){return{key:e.key,values:e.values.filter(function(e,n){return t.x()(e,n)>=S[0]&&t.x()(e,n)<=S[1]})}}));U.length?C=r.xScale():C=t.xScale(),s.scale(C).ticks(F/100).tickSize(-I,0),s.domain([Math.ceil(S[0]),Math.floor(S[1])]),J.select(".nv-x.nv-axis").transition().duration(P).call(s),n.transition().duration(P).call(r),i.transition().duration(P).call(t),J.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+L.range()[0]+")"),u.scale(L).ticks(I/36).tickSize(-F,0),J.select(".nv-focus .nv-y1.nv-axis").style("opacity",U.length?1:0),a.scale(A).ticks(I/36).tickSize(U.length?0:-F,0),J.select(".nv-focus .nv-y2.nv-axis").style("opacity",z.length?1:0).attr("transform","translate("+C.range()[1]+",0)"),J.select(".nv-focus .nv-y1.nv-axis").transition().duration(P).call(u),J.select(".nv-focus .nv-y2.nv-axis").transition().duration(P).call(a)}var N=d3.select(this),j=this,F=(v||parseInt(N.style("width"))||960)-p.left-p.right,I=(m||parseInt(N.style("height"))||400)-p.top-p.bottom-g,q=g-d.top-d.bottom;B.update=function(){N.transition().duration(P).call(B)},B.container=this;if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var R=N.selectAll(".nv-noData").data([_]);return R.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),R.attr("x",p.left+F/2).attr("y",p.top+I/2).text(function(e){return e}),B}N.selectAll(".nv-noData").remove();var U=e.filter(function(e){return!e.disabled&&e.bar}),z=e.filter(function(e){return!e.bar});C=r.xScale(),k=o.scale(),L=r.yScale(),A=t.yScale(),O=i.yScale(),M=n.yScale();var W=e.filter(function(e){return!e.disabled&&e.bar}).map(function(e){return e.values.map(function(e,t){return{x:y(e,t),y:b(e,t)}})}),X=e.filter(function(e){return!e.disabled&&!e.bar}).map(function(e){return e.values.map(function(e,t){return{x:y(e,t),y:b(e,t)}})});C.range([0,F]),k.domain(d3.extent(d3.merge(W.concat(X)),function(e){return e.x})).range([0,F]);var V=N.selectAll("g.nv-wrap.nv-linePlusBar").data([e]),$=V.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),J=V.select("g");$.append("g").attr("class","nv-legendWrap");var K=$.append("g").attr("class","nv-focus");K.append("g").attr("class","nv-x nv-axis"),K.append("g").attr("class","nv-y1 nv-axis"),K.append("g").attr("class","nv-y2 nv-axis"),K.append("g").attr("class","nv-barsWrap"),K.append("g").attr("class","nv-linesWrap");var Q=$.append("g").attr("class","nv-context");Q.append("g").attr("class","nv-x nv-axis"),Q.append("g").attr("class","nv-y1 nv-axis"),Q.append("g").attr("class","nv-y2 nv-axis"),Q.append("g").attr("class","nv-barsWrap"),Q.append("g").attr("class","nv-linesWrap"),Q.append("g").attr("class","nv-brushBackground"),Q.append("g").attr("class","nv-x nv-brush"),E&&(c.width(F/2),J.select(".nv-legendWrap").datum(e.map(function(e){return e.originalKey=e.originalKey===undefined?e.key:e.originalKey,e.key=e.originalKey+(e.bar?" (left axis)":" (right axis)"),e})).call(c),p.top!=c.height()&&(p.top=c.height(),I=(m||parseInt(N.style("height"))||400)-p.top-p.bottom-g),J.select(".nv-legendWrap").attr("transform","translate("+F/2+","+ -p.top+")")),V.attr("transform","translate("+p.left+","+p.top+")"),i.width(F).height(q).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&e[n].bar})),n.width(F).height(q).color(e.map(function(e,t){return e.color||w(e,t)}).filter(function(t,n){return!e[n].disabled&&!e[n].bar}));var G=J.select(".nv-context .nv-barsWrap").datum(U.length?U:[{values:[]}]),Y=J.select(".nv-context .nv-linesWrap").datum(z[0].disabled?[{values:[]}]:z);J.select(".nv-context").attr("transform","translate(0,"+(I+p.bottom+d.top)+")"),G.transition().call(i),Y.transition().call(n),h.x(k).on("brush",it),x&&h.extent(x);var Z=J.select(".nv-brushBackground").selectAll("g").data([x||h.extent()]),et=Z.enter().append("g");et.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",q),et.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",q);var tt=J.select(".nv-x.nv-brush").call(h);tt.selectAll("rect").attr("height",q),tt.selectAll(".resize").append("path").attr("d",nt),o.ticks(F/100).tickSize(-q,0),J.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+O.range()[0]+")"),J.select(".nv-context .nv-x.nv-axis").transition().call(o),f.scale(O).ticks(q/36).tickSize(-F,0),J.select(".nv-context .nv-y1.nv-axis").style("opacity",U.length?1:0).attr("transform","translate(0,"+k.range()[0]+")"),J.select(".nv-context .nv-y1.nv-axis").transition().call(f),l.scale(M).ticks(q/36).tickSize(U.length?0:-F,0),J.select(".nv-context .nv-y2.nv-axis").style("opacity",z.length?1:0).attr("transform","translate("+k.range()[1]+",0)"),J.select(".nv-context .nv-y2.nv-axis").transition().call(l),c.dispatch.on("stateChange",function(e){B.update()}),D.on("tooltipShow",function(e){T&&H(e,j.parentNode)}),it()}),B}var t=e.models.line(),n=e.models.line(),r=e.models.historicalBar(),i=e.models.historicalBar(),s=e.models.axis(),o=e.models.axis(),u=e.models.axis(),a=e.models.axis(),f=e.models.axis(),l=e.models.axis(),c=e.models.legend(),h=d3.svg.brush(),p={top:30,right:30,bottom:30,left:60},d={top:0,right:30,bottom:20,left:60},v=null,m=null,g=100,y=function(e){return e.x},b=function(e){return e.y},w=e.utils.defaultColor(),E=!0,S,x=null,T=!0,N=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},C,k,L,A,O,M,_="No Data Available.",D=d3.dispatch("tooltipShow","tooltipHide","brush"),P=0;t.clipEdge(!0),n.interactive(!1),s.orient("bottom").tickPadding(5),u.orient("left"),a.orient("right"),o.orient("bottom").tickPadding(5),f.orient("left"),l.orient("right");var H=function(n,r){S&&(n.pointIndex+=Math.ceil(S[0]));var i=n.pos[0]+(r.offsetLeft||0),o=n.pos[1]+(r.offsetTop||0),f=s.tickFormat()(t.x()(n.point,n.pointIndex)),l=(n.series.bar?u:a).tickFormat()(t.y()(n.point,n.pointIndex)),c=N(n.series.key,f,l,n,B);e.tooltip.show([i,o],c,n.value<0?"n":"s",null,r)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+p.left,e.pos[1]+p.top],D.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){D.tooltipHide(e)}),r.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+p.left,e.pos[1]+p.top],D.tooltipShow(e)}),r.dispatch.on("elementMouseout.tooltip",function(e){D.tooltipHide(e)}),D.on("tooltipHide",function(){T&&e.tooltip.cleanup()}),B.dispatch=D,B.legend=c,B.lines=t,B.lines2=n,B.bars=r,B.bars2=i,B.xAxis=s,B.x2Axis=o,B.y1Axis=u,B.y2Axis=a,B.y3Axis=f,B.y4Axis=l,d3.rebind(B,t,"defined","size","clipVoronoi","interpolate"),B.options=e.utils.optionsFunc.bind(B),B.x=function(e){return arguments.length?(y=e,t.x(e),r.x(e),B):y},B.y=function(e){return arguments.length?(b=e,t.y(e),r.y(e),B):b},B.margin=function(e){return arguments.length?(p.top=typeof e.top!="undefined"?e.top:p.top,p.right=typeof e.right!="undefined"?e.right:p.right,p.bottom=typeof e.bottom!="undefined"?e.bottom:p.bottom,p.left=typeof e.left!="undefined"?e.left:p.left,B):p},B.width=function(e){return arguments.length?(v=e,B):v},B.height=function(e){return arguments.length?(m=e,B):m},B.color=function(t){return arguments.length?(w=e.utils.getColor(t),c.color(w),B):w},B.showLegend=function(e){return arguments.length?(E=e,B):E},B.tooltips=function(e){return arguments.length?(T=e,B):T},B.tooltipContent=function(e){return arguments.length?(N=e,B):N},B.noData=function(e){return arguments.length?(_=e,B):_},B.brushExtent=function(e){return arguments.length?(x=e,B):x},B},e.models.multiBar=function(){"use strict";function C(e){return e.each(function(e){var C=n-t.left-t.right,k=r-t.top-t.bottom,L=d3.select(this);d&&e.length&&(d=[{values:e[0].values.map(function(e){return{x:e.x,y:0,series:e.series,size:.01}})}]),c&&(e=d3.layout.stack().offset(h).values(function(e){return e.values}).y(a)(!e.length&&d?d:e)),e.forEach(function(e,t){e.values.forEach(function(e){e.series=t})}),c&&e[0].values.map(function(t,n){var r=0,i=0;e.map(function(e){var t=e.values[n];t.size=Math.abs(t.y),t.y<0?(t.y1=i,i-=t.size):(t.y1=t.size+r,r+=t.size)})});var A=y&&b?[]:e.map(function(e){return e.values.map(function(e,t){return{x:u(e,t),y:a(e,t),y0:e.y0,y1:e.y1}})});i.domain(y||d3.merge(A).map(function(e){return e.x})).rangeBands(w||[0,C],S),s.domain(b||d3.extent(d3.merge(A).map(function(e){return c?e.y>0?e.y1:e.y1+e.y:e.y}).concat(f))).range(E||[k,0]),i.domain()[0]===i.domain()[1]&&(i.domain()[0]?i.domain([i.domain()[0]-i.domain()[0]*.01,i.domain()[1]+i.domain()[1]*.01]):i.domain([-1,1])),s.domain()[0]===s.domain()[1]&&(s.domain()[0]?s.domain([s.domain()[0]+s.domain()[0]*.01,s.domain()[1]-s.domain()[1]*.01]):s.domain([-1,1])),T=T||i,N=N||s;var O=L.selectAll("g.nv-wrap.nv-multibar").data([e]),M=O.enter().append("g").attr("class","nvd3 nv-wrap nv-multibar"),_=M.append("defs"),D=M.append("g"),P=O.select("g");D.append("g").attr("class","nv-groups"),O.attr("transform","translate("+t.left+","+t.top+")"),_.append("clipPath").attr("id","nv-edge-clip-"+o).append("rect"),O.select("#nv-edge-clip-"+o+" rect").attr("width",C).attr("height",k),P.attr("clip-path",l?"url(#nv-edge-clip-"+o+")":"");var H=O.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e,t){return t});H.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),H.exit().transition().selectAll("rect.nv-bar").delay(function(t,n){return n*g/e[0].values.length}).attr("y",function(e){return c?N(e.y0):N(0)}).attr("height",0).remove(),H.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return p(e,t)}).style("stroke",function(e,t){return p(e,t)}),H.transition().style("stroke-opacity",1).style("fill-opacity",.75);var B=H.selectAll("rect.nv-bar").data(function(t){return d&&!e.length?d.values:t.values});B.exit().remove();var j=B.enter().append("rect").attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}).attr("x",function(t,n,r){return c?0:r*i.rangeBand()/e.length}).attr("y",function(e){return N(c?e.y0:0)}).attr("height",0).attr("width",i.rangeBand()/(c?1:e.length)).attr("transform",function(e,t){return"translate("+i(u(e,t))+",0)"});B.style("fill",function(e,t,n){return p(e,n,t)}).style("stroke",function(e,t,n){return p(e,n,t)}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),x.elementMouseover({value:a(t,n),point:t,series:e[t.series],pos:[i(u(t,n))+i.rangeBand()*(c?e.length/2:t.series+.5)/e.length,s(a(t,n)+(c?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),x.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){x.elementClick({value:a(t,n),point:t,series:e[t.series],pos:[i(u(t,n))+i.rangeBand()*(c?e.length/2:t.series+.5)/e.length -,s(a(t,n)+(c?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(t,n){x.elementDblClick({value:a(t,n),point:t,series:e[t.series],pos:[i(u(t,n))+i.rangeBand()*(c?e.length/2:t.series+.5)/e.length,s(a(t,n)+(c?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}),B.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}).transition().attr("transform",function(e,t){return"translate("+i(u(e,t))+",0)"}),v&&(m||(m=e.map(function(){return!0})),B.style("fill",function(e,t,n){return d3.rgb(v(e,t)).darker(m.map(function(e,t){return t}).filter(function(e,t){return!m[t]})[n]).toString()}).style("stroke",function(e,t,n){return d3.rgb(v(e,t)).darker(m.map(function(e,t){return t}).filter(function(e,t){return!m[t]})[n]).toString()})),c?B.transition().delay(function(t,n){return n*g/e[0].values.length}).attr("y",function(e,t){return s(c?e.y1:0)}).attr("height",function(e,t){return Math.max(Math.abs(s(e.y+(c?e.y0:0))-s(c?e.y0:0)),1)}).attr("x",function(t,n){return c?0:t.series*i.rangeBand()/e.length}).attr("width",i.rangeBand()/(c?1:e.length)):B.transition().delay(function(t,n){return n*g/e[0].values.length}).attr("x",function(t,n){return t.series*i.rangeBand()/e.length}).attr("width",i.rangeBand()/e.length).attr("y",function(e,t){return a(e,t)<0?s(0):s(0)-s(a(e,t))<1?s(0)-1:s(a(e,t))||0}).attr("height",function(e,t){return Math.max(Math.abs(s(a(e,t))-s(0)),1)||0}),T=i.copy(),N=s.copy()}),C}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=d3.scale.ordinal(),s=d3.scale.linear(),o=Math.floor(Math.random()*1e4),u=function(e){return e.x},a=function(e){return e.y},f=[0],l=!0,c=!1,h="zero",p=e.utils.defaultColor(),d=!1,v=null,m,g=1200,y,b,w,E,S=.1,x=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),T,N;return C.dispatch=x,C.options=e.utils.optionsFunc.bind(C),C.x=function(e){return arguments.length?(u=e,C):u},C.y=function(e){return arguments.length?(a=e,C):a},C.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,C):t},C.width=function(e){return arguments.length?(n=e,C):n},C.height=function(e){return arguments.length?(r=e,C):r},C.xScale=function(e){return arguments.length?(i=e,C):i},C.yScale=function(e){return arguments.length?(s=e,C):s},C.xDomain=function(e){return arguments.length?(y=e,C):y},C.yDomain=function(e){return arguments.length?(b=e,C):b},C.xRange=function(e){return arguments.length?(w=e,C):w},C.yRange=function(e){return arguments.length?(E=e,C):E},C.forceY=function(e){return arguments.length?(f=e,C):f},C.stacked=function(e){return arguments.length?(c=e,C):c},C.stackOffset=function(e){return arguments.length?(h=e,C):h},C.clipEdge=function(e){return arguments.length?(l=e,C):l},C.color=function(t){return arguments.length?(p=e.utils.getColor(t),C):p},C.barColor=function(t){return arguments.length?(v=e.utils.getColor(t),C):v},C.disabled=function(e){return arguments.length?(m=e,C):m},C.id=function(e){return arguments.length?(o=e,C):o},C.hideable=function(e){return arguments.length?(d=e,C):d},C.delay=function(e){return arguments.length?(g=e,C):g},C.groupSpacing=function(e){return arguments.length?(S=e,C):S},C},e.models.multiBarChart=function(){"use strict";function A(e){return e.each(function(e){var b=d3.select(this),O=this,M=(u||parseInt(b.style("width"))||960)-o.left-o.right,_=(a||parseInt(b.style("height"))||400)-o.top-o.bottom;A.update=function(){b.transition().duration(k).call(A)},A.container=this,S.disabled=e.map(function(e){return!!e.disabled});if(!x){var D;x={};for(D in S)S[D]instanceof Array?x[D]=S[D].slice(0):x[D]=S[D]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var P=b.selectAll(".nv-noData").data([T]);return P.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),P.attr("x",o.left+M/2).attr("y",o.top+_/2).text(function(e){return e}),A}b.selectAll(".nv-noData").remove(),w=t.xScale(),E=t.yScale();var H=b.selectAll("g.nv-wrap.nv-multiBarWithLegend").data([e]),B=H.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarWithLegend").append("g"),j=H.select("g");B.append("g").attr("class","nv-x nv-axis"),B.append("g").attr("class","nv-y nv-axis"),B.append("g").attr("class","nv-barsWrap"),B.append("g").attr("class","nv-legendWrap"),B.append("g").attr("class","nv-controlsWrap"),c&&(i.width(M-C()),t.barColor()&&e.forEach(function(e,t){e.color=d3.rgb("#ccc").darker(t*1.5).toString()}),j.select(".nv-legendWrap").datum(e).call(i),o.top!=i.height()&&(o.top=i.height(),_=(a||parseInt(b.style("height"))||400)-o.top-o.bottom),j.select(".nv-legendWrap").attr("transform","translate("+C()+","+ -o.top+")"));if(l){var F=[{key:"Grouped",disabled:t.stacked()},{key:"Stacked",disabled:!t.stacked()}];s.width(C()).color(["#444","#444","#444"]),j.select(".nv-controlsWrap").datum(F).attr("transform","translate(0,"+ -o.top+")").call(s)}H.attr("transform","translate("+o.left+","+o.top+")"),d&&j.select(".nv-y.nv-axis").attr("transform","translate("+M+",0)"),t.disabled(e.map(function(e){return e.disabled})).width(M).height(_).color(e.map(function(e,t){return e.color||f(e,t)}).filter(function(t,n){return!e[n].disabled}));var I=j.select(".nv-barsWrap").datum(e.filter(function(e){return!e.disabled}));I.transition().call(t);if(h){n.scale(w).ticks(M/100).tickSize(-_,0),j.select(".nv-x.nv-axis").attr("transform","translate(0,"+E.range()[0]+")"),j.select(".nv-x.nv-axis").transition().call(n);var q=j.select(".nv-x.nv-axis > g").selectAll("g");q.selectAll("line, text").style("opacity",1);if(m){var R=function(e,t){return"translate("+e+","+t+")"},U=5,z=17;q.selectAll("text").attr("transform",function(e,t,n){return R(0,n%2==0?U:z)});var W=d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length;j.selectAll(".nv-x.nv-axis .nv-axisMaxMin text").attr("transform",function(e,t){return R(0,t===0||W%2!==0?z:U)})}v&&q.filter(function(t,n){return n%Math.ceil(e[0].values.length/(M/100))!==0}).selectAll("text, line").style("opacity",0),g&&q.selectAll(".tick text").attr("transform","rotate("+g+" 0,0)").style("text-anchor",g>0?"start":"end"),j.select(".nv-x.nv-axis").selectAll("g.nv-axisMaxMin text").style("opacity",1)}p&&(r.scale(E).ticks(_/36).tickSize(-M,0),j.select(".nv-y.nv-axis").transition().call(r)),i.dispatch.on("stateChange",function(e){S=e,N.stateChange(S),A.update()}),s.dispatch.on("legendClick",function(e,n){if(!e.disabled)return;F=F.map(function(e){return e.disabled=!0,e}),e.disabled=!1;switch(e.key){case"Grouped":t.stacked(!1);break;case"Stacked":t.stacked(!0)}S.stacked=t.stacked(),N.stateChange(S),A.update()}),N.on("tooltipShow",function(e){y&&L(e,O.parentNode)}),N.on("changeState",function(n){typeof n.disabled!="undefined"&&(e.forEach(function(e,t){e.disabled=n.disabled[t]}),S.disabled=n.disabled),typeof n.stacked!="undefined"&&(t.stacked(n.stacked),S.stacked=n.stacked),A.update()})}),A}var t=e.models.multiBar(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o={top:30,right:20,bottom:50,left:60},u=null,a=null,f=e.utils.defaultColor(),l=!0,c=!0,h=!0,p=!0,d=!1,v=!0,m=!1,g=0,y=!0,b=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" on "+t+"

"},w,E,S={stacked:!1},x=null,T="No Data Available.",N=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),C=function(){return l?180:0},k=250;t.stacked(!1),n.orient("bottom").tickPadding(7).highlightZero(!0).showMaxMin(!1).tickFormat(function(e){return e}),r.orient(d?"right":"left").tickFormat(d3.format(",.1f")),s.updateState(!1);var L=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=b(i.series.key,a,f,i,A);e.tooltip.show([o,u],l,i.value<0?"n":"s",null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+o.left,e.pos[1]+o.top],N.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){N.tooltipHide(e)}),N.on("tooltipHide",function(){y&&e.tooltip.cleanup()}),A.dispatch=N,A.multibar=t,A.legend=i,A.xAxis=n,A.yAxis=r,d3.rebind(A,t,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","clipEdge","id","stacked","stackOffset","delay","barColor","groupSpacing"),A.options=e.utils.optionsFunc.bind(A),A.margin=function(e){return arguments.length?(o.top=typeof e.top!="undefined"?e.top:o.top,o.right=typeof e.right!="undefined"?e.right:o.right,o.bottom=typeof e.bottom!="undefined"?e.bottom:o.bottom,o.left=typeof e.left!="undefined"?e.left:o.left,A):o},A.width=function(e){return arguments.length?(u=e,A):u},A.height=function(e){return arguments.length?(a=e,A):a},A.color=function(t){return arguments.length?(f=e.utils.getColor(t),i.color(f),A):f},A.showControls=function(e){return arguments.length?(l=e,A):l},A.showLegend=function(e){return arguments.length?(c=e,A):c},A.showXAxis=function(e){return arguments.length?(h=e,A):h},A.showYAxis=function(e){return arguments.length?(p=e,A):p},A.rightAlignYAxis=function(e){return arguments.length?(d=e,r.orient(e?"right":"left"),A):d},A.reduceXTicks=function(e){return arguments.length?(v=e,A):v},A.rotateLabels=function(e){return arguments.length?(g=e,A):g},A.staggerLabels=function(e){return arguments.length?(m=e,A):m},A.tooltip=function(e){return arguments.length?(b=e,A):b},A.tooltips=function(e){return arguments.length?(y=e,A):y},A.tooltipContent=function(e){return arguments.length?(b=e,A):b},A.state=function(e){return arguments.length?(S=e,A):S},A.defaultState=function(e){return arguments.length?(x=e,A):x},A.noData=function(e){return arguments.length?(T=e,A):T},A.transitionDuration=function(e){return arguments.length?(k=e,A):k},A},e.models.multiBarHorizontal=function(){"use strict";function C(e){return e.each(function(e){var i=n-t.left-t.right,y=r-t.top-t.bottom,C=d3.select(this);p&&(e=d3.layout.stack().offset("zero").values(function(e){return e.values}).y(a)(e)),e.forEach(function(e,t){e.values.forEach(function(e){e.series=t})}),p&&e[0].values.map(function(t,n){var r=0,i=0;e.map(function(e){var t=e.values[n];t.size=Math.abs(t.y),t.y<0?(t.y1=i-t.size,i-=t.size):(t.y1=r,r+=t.size)})});var k=b&&w?[]:e.map(function(e){return e.values.map(function(e,t){return{x:u(e,t),y:a(e,t),y0:e.y0,y1:e.y1}})});s.domain(b||d3.merge(k).map(function(e){return e.x})).rangeBands(E||[0,y],.1),o.domain(w||d3.extent(d3.merge(k).map(function(e){return p?e.y>0?e.y1+e.y:e.y1:e.y}).concat(f))),d&&!p?o.range(S||[o.domain()[0]<0?m:0,i-(o.domain()[1]>0?m:0)]):o.range(S||[0,i]),T=T||s,N=N||d3.scale.linear().domain(o.domain()).range([o(0),o(0)]);var L=d3.select(this).selectAll("g.nv-wrap.nv-multibarHorizontal").data([e]),A=L.enter().append("g").attr("class","nvd3 nv-wrap nv-multibarHorizontal"),O=A.append("defs"),M=A.append("g"),_=L.select("g");M.append("g").attr("class","nv-groups"),L.attr("transform","translate("+t.left+","+t.top+")");var D=L.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e,t){return t});D.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),D.exit().transition().style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),D.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}).style("fill",function(e,t){return l(e,t)}).style("stroke",function(e,t){return l(e,t)}),D.transition().style("stroke-opacity",1).style("fill-opacity",.75);var P=D.selectAll("g.nv-bar").data(function(e){return e.values});P.exit().remove();var H=P.enter().append("g").attr("transform",function(t,n,r){return"translate("+N(p?t.y0:0)+","+(p?0:r*s.rangeBand()/e.length+s(u(t,n)))+")"});H.append("rect").attr("width",0).attr("height",s.rangeBand()/(p?1:e.length)),P.on("mouseover",function(t,n){d3.select(this).classed("hover",!0),x.elementMouseover({value:a(t,n),point:t,series:e[t.series],pos:[o(a(t,n)+(p?t.y0:0)),s(u(t,n))+s.rangeBand()*(p?e.length/2:t.series+.5)/e.length],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),x.elementMouseout({value:a(t,n),point:t,series:e[t.series],pointIndex:n,seriesIndex:t.series,e:d3.event})}).on("click",function(t,n){x.elementClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(p?e.length/2:t.series+.5)/e.length,o(a(t,n)+(p?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(t,n){x.elementDblClick({value:a(t,n),point:t,series:e[t.series],pos:[s(u(t,n))+s.rangeBand()*(p?e.length/2:t.series+.5)/e.length,o(a(t,n)+(p?t.y0:0))],pointIndex:n,seriesIndex:t.series,e:d3.event}),d3.event.stopPropagation()}),H.append("text"),d&&!p?(P.select("text").attr("text-anchor",function(e,t){return a(e,t)<0?"end":"start"}).attr("y",s.rangeBand()/(e.length*2)).attr("dy",".32em").text(function(e,t){return g(a(e,t))}),P.transition().select("text").attr("x",function(e,t){return a(e,t)<0?-4:o(a(e,t))-o(0)+4})):P.selectAll("text").text(""),v&&!p?(H.append("text").classed("nv-bar-label",!0),P.select("text.nv-bar-label").attr("text-anchor",function(e,t){return a(e,t)<0?"start":"end"}).attr("y",s.rangeBand()/(e.length*2)).attr("dy",".32em").text(function(e,t){return u(e,t)}),P.transition().select("text.nv-bar-label").attr("x",function(e,t){return a(e,t)<0?o(0)-o(a(e,t))+4:-4})):P.selectAll("text.nv-bar-label").text(""),P.attr("class",function(e,t){return a(e,t)<0?"nv-bar negative":"nv-bar positive"}),c&&(h||(h=e.map(function(){return!0})),P.style("fill",function(e,t,n){return d3.rgb(c(e,t)).darker(h.map(function(e,t){return t}).filter(function(e,t){return!h[t]})[n]).toString()}).style("stroke",function(e,t,n){return d3.rgb(c(e,t)).darker(h.map(function(e,t){return t}).filter(function(e,t){return!h[t]})[n]).toString()})),p?P.transition().attr("transform",function(e,t){return"translate("+o(e.y1)+","+s(u(e,t))+")"}).select("rect").attr("width",function(e,t){return Math.abs(o(a(e,t)+e.y0)-o(e.y0))}).attr("height",s.rangeBand()):P.transition().attr("transform",function(t,n){return"translate("+(a(t,n)<0?o(a(t,n)):o(0))+","+(t.series*s.rangeBand()/e.length+s(u(t,n)))+")"}).select("rect").attr("height",s.rangeBand()/e.length).attr("width",function(e,t){return Math.max(Math.abs(o(a(e,t))-o(0)),1)}),T=s.copy(),N=o.copy()}),C}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.ordinal(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=[0],l=e.utils.defaultColor(),c=null,h,p=!1,d=!1,v=!1,m=60,g=d3.format(",.2f"),y=1200,b,w,E,S,x=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout"),T,N;return C.dispatch=x,C.options=e.utils.optionsFunc.bind(C),C.x=function(e){return arguments.length?(u=e,C):u},C.y=function(e){return arguments.length?(a=e,C):a},C.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,C):t},C.width=function(e){return arguments.length?(n=e,C):n},C.height=function(e){return arguments.length?(r=e,C):r},C.xScale=function(e){return arguments.length?(s=e,C):s},C.yScale=function(e){return arguments.length?(o=e,C):o},C.xDomain=function(e){return arguments.length?(b=e,C):b},C.yDomain=function(e){return arguments.length?(w=e,C):w},C.xRange=function(e){return arguments.length?(E=e,C):E},C.yRange=function(e){return arguments.length?(S=e,C):S},C.forceY=function(e){return arguments.length?(f=e,C):f},C.stacked=function(e){return arguments.length?(p=e,C):p},C.color=function(t){return arguments.length?(l=e.utils.getColor(t),C):l},C.barColor=function(t){return arguments.length?(c=e.utils.getColor(t),C):c},C.disabled=function(e){return arguments.length?(h=e,C):h},C.id=function(e){return arguments.length?(i=e,C):i},C.delay=function(e){return arguments.length?(y=e,C):y},C.showValues=function(e){return arguments.length?(d=e,C):d},C.showBarLabels=function(e){return arguments.length?(v=e,C):v},C.valueFormat=function(e){return arguments.length?(g=e,C):g},C.valuePadding=function(e){return arguments.length?(m=e,C):m},C},e.models.multiBarHorizontalChart=function(){"use strict";function C(e){return e.each(function(e){var d=d3.select(this),m=this,k=(u||parseInt(d.style("width"))||960)-o.left-o.right,L=(a||parseInt(d.style("height"))||400)-o.top-o.bottom;C.update=function(){d.transition().duration(T).call(C)},C.container=this,b.disabled=e.map(function(e){return!!e.disabled});if(!w){var A;w={};for(A in b)b[A]instanceof Array?w[A]=b[A].slice(0):w[A]=b[A]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var O=d.selectAll(".nv-noData").data([E]);return O.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),O.attr("x",o.left+k/2).attr("y",o.top+L/2).text(function(e){return e}),C}d.selectAll(".nv-noData").remove(),g=t.xScale(),y=t.yScale();var M=d.selectAll("g.nv-wrap.nv-multiBarHorizontalChart").data([e]),_=M.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarHorizontalChart").append("g"),D=M.select("g");_.append("g").attr("class","nv-x nv-axis"),_.append("g").attr("class","nv-y nv-axis").append("g").attr("class","nv-zeroLine").append("line"),_.append("g").attr("class","nv-barsWrap"),_.append("g").attr("class","nv-legendWrap"),_.append("g").attr("class","nv-controlsWrap"),c&&(i.width(k-x()),t.barColor()&&e.forEach(function(e,t){e.color=d3.rgb("#ccc").darker(t*1.5).toString()}),D.select(".nv-legendWrap").datum(e).call(i),o.top!=i.height()&&(o.top=i.height(),L=(a||parseInt(d.style("height"))||400)-o.top-o.bottom),D.select(".nv-legendWrap").attr("transform","translate("+x()+","+ -o.top+")"));if(l){var P=[{key:"Grouped",disabled:t.stacked()},{key:"Stacked",disabled:!t.stacked()}];s.width(x()).color(["#444","#444","#444"]),D.select(".nv-controlsWrap").datum(P).attr("transform","translate(0,"+ -o.top+")").call(s)}M.attr("transform","translate("+o.left+","+o.top+")"),t.disabled(e.map(function(e){return e.disabled})).width(k).height(L).color(e.map(function(e,t){return e.color||f(e,t)}).filter(function(t,n){return!e[n].disabled}));var H=D.select(".nv-barsWrap").datum(e.filter(function(e){return!e.disabled}));H.transition().call(t);if(h){n.scale(g).ticks(L/24).tickSize(-k,0),D.select(".nv-x.nv-axis").transition().call(n);var B=D.select(".nv-x.nv-axis").selectAll("g");B.selectAll("line, text")}p&&(r.scale(y).ticks(k/100).tickSize(-L,0),D.select(".nv-y.nv-axis").attr("transform","translate(0,"+L+")"),D.select(".nv-y.nv-axis").transition().call(r)),D.select(".nv-zeroLine line").attr("x1",y(0)).attr("x2",y(0)).attr("y1",0).attr("y2",-L),i.dispatch.on("stateChange",function(e){b=e,S.stateChange(b),C.update()}),s.dispatch.on("legendClick",function(e,n){if(!e.disabled)return;P=P.map(function(e){return e.disabled=!0,e}),e.disabled=!1;switch(e.key){case"Grouped":t.stacked(!1);break;case"Stacked":t.stacked(!0)}b.stacked=t.stacked(),S.stateChange(b),C.update()}),S.on("tooltipShow",function(e){v&&N(e,m.parentNode)}),S.on("changeState",function(n){typeof n.disabled!="undefined"&&(e.forEach(function(e,t){e.disabled=n.disabled[t]}),b.disabled=n.disabled),typeof n.stacked!="undefined"&&(t.stacked(n.stacked),b.stacked=n.stacked),C.update()})}),C}var t=e.models.multiBarHorizontal(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend().height(30),s=e.models.legend().height(30),o={top:30,right:20,bottom:50,left:60},u=null,a=null,f=e.utils.defaultColor(),l=!0,c=!0,h=!0,p=!0,d=!1,v=!0,m=function(e,t,n,r,i){return"

"+e+" - "+t+"

"+"

"+n+"

"},g,y,b={stacked:d},w=null,E="No Data Available.",S=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),x=function(){return l?180:0},T=250;t.stacked(d),n.orient("left").tickPadding(5).highlightZero(!1).showMaxMin(!1).tickFormat(function(e){return e}),r.orient("bottom").tickFormat(d3.format(",.1f")),s.updateState(!1);var N=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=m(i.series.key,a,f,i,C);e.tooltip.show([o,u],l,i.value<0?"e":"w",null,s)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+o.left,e.pos[1]+o.top],S.tooltipShow(e)}),t.dispatch.on("elementMouseout.tooltip",function(e){S.tooltipHide(e)}),S.on("tooltipHide",function(){v&&e.tooltip.cleanup()}),C.dispatch=S,C.multibar=t,C.legend=i,C.xAxis=n,C.yAxis=r,d3.rebind(C,t,"x","y","xDomain","yDomain","xRange","yRange","forceX","forceY","clipEdge","id","delay","showValues","showBarLabels","valueFormat","stacked","barColor"),C.options=e.utils.optionsFunc.bind(C),C.margin=function(e){return arguments.length?(o.top=typeof e.top!="undefined"?e.top:o.top,o.right=typeof e.right!="undefined"?e.right:o.right,o.bottom=typeof e.bottom!="undefined"?e.bottom:o.bottom,o.left=typeof e.left!="undefined"?e.left:o.left,C):o},C.width=function(e){return arguments.length?(u=e,C):u},C.height=function(e){return arguments.length?(a=e,C):a},C.color=function(t){return arguments.length?(f=e.utils.getColor(t),i.color(f),C):f},C.showControls=function(e){return arguments.length?(l=e,C):l},C.showLegend=function(e){return arguments.length?(c=e,C):c},C.showXAxis=function(e){return arguments.length?(h=e,C):h},C.showYAxis=function(e){return arguments.length?(p=e,C):p},C.tooltip=function(e){return arguments.length?(m=e,C):m},C.tooltips=function(e){return arguments.length?(v=e,C):v},C.tooltipContent=function(e){return arguments.length?(m=e,C):m},C.state=function(e){return arguments.length?(b=e,C):b},C.defaultState=function(e){return arguments.length?(w=e,C):w},C.noData=function(e){return arguments.length?(E=e,C):E},C.transitionDuration=function(e){return arguments.length?(T=e,C):T},C},e.models.multiChart=function(){"use strict";function C(e){return e.each(function(e){var u=d3.select(this),f=this;C.update=function(){u.transition().call(C)},C.container=this;var k=(r||parseInt(u.style("width"))||960)-t.left-t.right,L=(i||parseInt(u.style("height"))||400)-t.top-t.bottom,A=e.filter(function(e){return!e.disabled&&e.type=="line"&&e.yAxis==1}),O=e.filter(function(e){return!e.disabled&&e.type=="line"&&e.yAxis==2}),M=e.filter(function(e){return!e.disabled&&e.type=="bar"&&e.yAxis==1}),_=e.filter(function(e){return!e.disabled&&e.type=="bar"&&e.yAxis==2}),D=e.filter(function(e){return!e.disabled&&e.type=="area"&&e.yAxis==1}),P=e.filter(function(e){return!e.disabled&&e.type=="area"&&e.yAxis==2}),H=e.filter(function(e){return!e.disabled&&e.yAxis==1}).map(function(e){return e.values.map(function(e,t){return{x:e.x,y:e.y}})}),B=e.filter(function(e){return!e.disabled&&e.yAxis==2}).map(function(e){return e.values.map(function(e,t){return{x:e.x,y:e.y}})});a.domain(d3.extent(d3.merge(H.concat(B)),function(e){return e.x})).range([0,k]);var j=u.selectAll("g.wrap.multiChart").data([e]),F=j.enter().append("g").attr("class","wrap nvd3 multiChart").append("g");F.append("g").attr("class","x axis"),F.append("g").attr("class","y1 axis"),F.append("g").attr("class","y2 axis"),F.append("g").attr("class","lines1Wrap"),F.append("g").attr("class","lines2Wrap"),F.append("g").attr("class","bars1Wrap"),F.append("g").attr("class","bars2Wrap"),F.append("g").attr("class","stack1Wrap"),F.append("g").attr("class","stack2Wrap"),F.append("g").attr("class","legendWrap");var I=j.select("g");s&&(x.width(k/2),I.select(".legendWrap").datum(e.map(function(e){return e.originalKey=e.originalKey===undefined?e.key:e.originalKey,e.key=e.originalKey+(e.yAxis==1?"":" (right axis)"),e})).call(x),t.top!=x.height()&&(t.top=x.height(),L=(i||parseInt(u.style("height"))||400)-t.top-t.bottom),I.select(".legendWrap").attr("transform","translate("+k/2+","+ -t.top+")")),d.width(k).height(L).interpolate("monotone").color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==1&&e[n].type=="line"})),v.width(k).height(L).interpolate("monotone").color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==2&&e[n].type=="line"})),m.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==1&&e[n].type=="bar"})),g.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==2&&e[n].type=="bar"})),y.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==1&&e[n].type=="area"})),b.width(k).height(L).color(e.map(function(e,t){return e.color||n[t%n.length]}).filter(function(t,n){return!e[n].disabled&&e[n].yAxis==2&&e[n].type=="area"})),I.attr("transform","translate("+t.left+","+t.top+")");var q=I.select(".lines1Wrap").datum(A),R=I.select(".bars1Wrap").datum(M),U=I.select(".stack1Wrap").datum(D),z=I.select(".lines2Wrap").datum(O),W=I.select(".bars2Wrap").datum(_),X=I.select(".stack2Wrap").datum(P),V=D.length?D.map(function(e){return e.values}).reduce(function(e,t){return e.map(function(e,n){return{x:e.x,y:e.y+t[n].y}})}).concat([{x:0,y:0}]):[],$=P.length?P.map(function(e){return e.values}).reduce(function(e,t){return e.map(function(e,n){return{x:e.x,y:e.y+t[n].y}})}).concat([{x:0,y:0}]):[];h.domain(l||d3.extent(d3.merge(H).concat(V),function(e){return e.y})).range([0,L]),p.domain(c||d3.extent(d3.merge(B).concat($),function(e){return e.y})).range([0,L]),d.yDomain(h.domain()),m.yDomain(h.domain()),y.yDomain(h.domain()),v.yDomain(p.domain()),g.yDomain(p.domain()),b.yDomain(p.domain()),D.length&&d3.transition(U).call(y),P.length&&d3.transition(X).call(b),M.length&&d3.transition(R).call(m),_.length&&d3.transition(W).call(g),A.length&&d3.transition(q).call(d),O.length&&d3.transition(z).call(v),w.ticks(k/100).tickSize(-L,0),I.select(".x.axis").attr("transform","translate(0,"+L+")"),d3.transition(I.select(".x.axis")).call(w),E.ticks(L/36).tickSize(-k,0),d3.transition(I.select(".y1.axis")).call(E),S.ticks(L/36).tickSize(-k,0),d3.transition(I.select(".y2.axis")).call(S),I.select(".y2.axis").style("opacity",B.length?1:0).attr("transform","translate("+a.range()[1]+",0)"),x.dispatch.on("stateChange",function(e){C.update()}),T.on("tooltipShow",function(e){o&&N(e,f.parentNode)})}),C}var t={top:30,right:20,bottom:50,left:60},n=d3.scale.category20().range(),r=null,i=null,s=!0,o=!0,u=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" at "+t+"

"},a,f,l,c,a=d3.scale.linear(),h=d3.scale.linear(),p=d3.scale.linear(),d=e.models.line().yScale(h),v=e.models.line().yScale(p),m=e.models.multiBar().stacked(!1).yScale(h),g=e.models.multiBar().stacked(!1).yScale(p),y=e.models.stackedArea().yScale(h),b=e.models.stackedArea().yScale(p),w=e.models.axis().scale(a).orient("bottom").tickPadding(5),E=e.models.axis().scale(h).orient("left"),S=e.models.axis().scale(p).orient("right"),x=e.models.legend().height(30),T=d3.dispatch("tooltipShow","tooltipHide"),N=function(t,n){var r=t.pos[0]+(n.offsetLeft||0),i=t.pos[1]+(n.offsetTop||0),s=w.tickFormat()(d.x()(t.point,t.pointIndex)),o=(t.series.yAxis==2?S:E).tickFormat()(d.y()(t.point,t.pointIndex)),a=u(t.series.key,s,o,t,C);e.tooltip.show([r,i],a,undefined,undefined,n.offsetParent)};return d.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),d.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),v.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),v.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),m.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),m.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),g.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),g.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),y.dispatch.on("tooltipShow",function(e){if(!Math.round(y.y()(e.point)*100))return setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1;e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),y.dispatch.on("tooltipHide",function(e){T.tooltipHide(e)}),b.dispatch.on("tooltipShow",function(e){if(!Math.round(b.y()(e.point)*100))return setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1;e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),b.dispatch.on("tooltipHide",function(e){T.tooltipHide(e)}),d.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),d.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),v.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+t.left,e.pos[1]+t.top],T.tooltipShow(e)}),v.dispatch.on("elementMouseout.tooltip",function(e){T.tooltipHide(e)}),T.on("tooltipHide",function(){o&&e.tooltip.cleanup()}),C.dispatch=T,C.lines1=d,C.lines2=v,C.bars1=m,C.bars2=g,C.stack1=y,C.stack2=b,C.xAxis=w,C.yAxis1=E,C.yAxis2=S,C.options=e.utils.optionsFunc.bind(C),C.x=function(e){return arguments.length?(getX=e,d.x(e),m.x(e),C):getX},C.y=function(e){return arguments.length?(getY=e,d.y(e),m.y(e),C):getY},C.yDomain1=function(e){return arguments.length?(l=e,C):l},C.yDomain2=function(e){return arguments.length?(c=e,C):c},C.margin=function(e){return arguments.length?(t=e,C):t},C.width=function(e){return arguments.length?(r=e,C):r},C.height=function(e){return arguments.length?(i=e,C):i},C.color=function(e){return arguments.length?(n=e,x.color(e),C):n},C.showLegend=function(e){return arguments.length?(s=e,C):s},C.tooltips=function(e){return arguments.length?(o=e,C):o},C.tooltipContent=function(e){return arguments.length?(u=e,C):u},C},e.models.ohlcBar=function(){"use strict";function x(e){return e.each(function(e){var g=n-t.left-t.right,x=r-t.top-t.bottom,T=d3.select(this);s.domain(y||d3.extent(e[0].values.map(u).concat(p))),v?s.range(w||[g*.5/e[0].values.length,g*(e[0].values.length-.5)/e[0].values.length]):s.range(w||[0,g]),o.domain(b||[d3.min(e[0].values.map(h).concat(d)),d3.max(e[0].values.map(c).concat(d))]).range(E||[x,0]),s.domain()[0]===s.domain()[1]&&(s.domain()[0]?s.domain([s.domain()[0]-s.domain()[0]*.01,s.domain()[1]+s.domain()[1]*.01]):s.domain([-1,1])),o.domain()[0]===o.domain()[1]&&(o.domain()[0]?o.domain([o.domain()[0]+o.domain()[0]*.01,o.domain()[1]-o.domain()[1]*.01]):o.domain([-1,1]));var N=d3.select(this).selectAll("g.nv-wrap.nv-ohlcBar").data([e[0].values]),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-ohlcBar"),k=C.append("defs"),L=C.append("g"),A=N.select("g");L.append("g").attr("class","nv-ticks"),N.attr("transform","translate("+t.left+","+t.top+")"),T.on("click",function(e,t){S.chartClick({data:e,index:t,pos:d3.event,id:i})}),k.append("clipPath").attr("id","nv-chart-clip-path-"+i).append("rect"),N.select("#nv-chart-clip-path-"+i+" rect").attr("width",g).attr("height",x),A.attr("clip-path",m?"url(#nv-chart-clip-path-"+i+")":"");var O=N.select(".nv-ticks").selectAll(".nv-tick").data(function(e){return e});O.exit().remove();var M=O.enter().append("path").attr("class",function(e,t,n){return(f(e,t)>l(e,t)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+n+"-"+t}).attr("d",function(t,n){var r=g/e[0].values.length*.9;return"m0,0l0,"+(o(f(t,n))-o(c(t,n)))+"l"+ -r/2+",0l"+r/2+",0l0,"+(o(h(t,n))-o(f(t,n)))+"l0,"+(o(l(t,n))-o(h(t,n)))+"l"+r/2+",0l"+ -r/2+",0z"}).attr("transform",function(e,t){return"translate("+s(u(e,t))+","+o(c(e,t))+")"}).on("mouseover",function(t,n){d3.select(this).classed("hover",!0),S.elementMouseover({point:t,series:e[0],pos:[s(u(t,n)),o(a(t,n))],pointIndex:n,seriesIndex:0,e:d3.event})}).on("mouseout",function(t,n){d3.select(this).classed("hover",!1),S.elementMouseout({point:t,series:e[0],pointIndex:n,seriesIndex:0,e:d3.event})}).on("click",function(e,t){S.elementClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()}).on("dblclick",function(e,t){S.elementDblClick({value:a(e,t),data:e,index:t,pos:[s(u(e,t)),o(a(e,t))],e:d3.event,id:i}),d3.event.stopPropagation()});O.attr("class",function(e,t,n){return(f(e,t)>l(e,t)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+n+"-"+t}),d3.transition(O).attr("transform",function(e,t){return"translate("+s(u(e,t))+","+o(c(e,t))+")"}).attr("d",function(t,n){var r=g/e[0].values.length*.9;return"m0,0l0,"+(o(f(t,n))-o(c(t,n)))+"l"+ -r/2+",0l"+r/2+",0l0,"+(o(h(t,n))-o(f(t,n)))+"l0,"+(o(l(t,n))-o(h(t,n)))+"l"+r/2+",0l"+ -r/2+",0z"})}),x}var t={top:0 -,right:0,bottom:0,left:0},n=960,r=500,i=Math.floor(Math.random()*1e4),s=d3.scale.linear(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=function(e){return e.open},l=function(e){return e.close},c=function(e){return e.high},h=function(e){return e.low},p=[],d=[],v=!1,m=!0,g=e.utils.defaultColor(),y,b,w,E,S=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return x.dispatch=S,x.options=e.utils.optionsFunc.bind(x),x.x=function(e){return arguments.length?(u=e,x):u},x.y=function(e){return arguments.length?(a=e,x):a},x.open=function(e){return arguments.length?(f=e,x):f},x.close=function(e){return arguments.length?(l=e,x):l},x.high=function(e){return arguments.length?(c=e,x):c},x.low=function(e){return arguments.length?(h=e,x):h},x.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,x):t},x.width=function(e){return arguments.length?(n=e,x):n},x.height=function(e){return arguments.length?(r=e,x):r},x.xScale=function(e){return arguments.length?(s=e,x):s},x.yScale=function(e){return arguments.length?(o=e,x):o},x.xDomain=function(e){return arguments.length?(y=e,x):y},x.yDomain=function(e){return arguments.length?(b=e,x):b},x.xRange=function(e){return arguments.length?(w=e,x):w},x.yRange=function(e){return arguments.length?(E=e,x):E},x.forceX=function(e){return arguments.length?(p=e,x):p},x.forceY=function(e){return arguments.length?(d=e,x):d},x.padData=function(e){return arguments.length?(v=e,x):v},x.clipEdge=function(e){return arguments.length?(m=e,x):m},x.color=function(t){return arguments.length?(g=e.utils.getColor(t),x):g},x.id=function(e){return arguments.length?(i=e,x):i},x},e.models.pie=function(){"use strict";function S(e){return e.each(function(e){function q(e){var t=(e.startAngle+e.endAngle)*90/Math.PI-90;return t>90?t-180:t}function R(e){e.endAngle=isNaN(e.endAngle)?0:e.endAngle,e.startAngle=isNaN(e.startAngle)?0:e.startAngle,m||(e.innerRadius=0);var t=d3.interpolate(this._current,e);return this._current=t(0),function(e){return A(t(e))}}function U(e){e.innerRadius=0;var t=d3.interpolate({startAngle:0,endAngle:0},e);return function(e){return A(t(e))}}var o=n-t.left-t.right,f=r-t.top-t.bottom,S=Math.min(o,f)/2,x=S-S/5,T=d3.select(this),N=T.selectAll(".nv-wrap.nv-pie").data(e),C=N.enter().append("g").attr("class","nvd3 nv-wrap nv-pie nv-chart-"+u),k=C.append("g"),L=N.select("g");k.append("g").attr("class","nv-pie"),k.append("g").attr("class","nv-pieLabels"),N.attr("transform","translate("+t.left+","+t.top+")"),L.select(".nv-pie").attr("transform","translate("+o/2+","+f/2+")"),L.select(".nv-pieLabels").attr("transform","translate("+o/2+","+f/2+")"),T.on("click",function(e,t){E.chartClick({data:e,index:t,pos:d3.event,id:u})});var A=d3.svg.arc().outerRadius(x);y&&A.startAngle(y),b&&A.endAngle(b),m&&A.innerRadius(S*w);var O=d3.layout.pie().sort(null).value(function(e){return e.disabled?0:s(e)}),M=N.select(".nv-pie").selectAll(".nv-slice").data(O),_=N.select(".nv-pieLabels").selectAll(".nv-label").data(O);M.exit().remove(),_.exit().remove();var D=M.enter().append("g").attr("class","nv-slice").on("mouseover",function(e,t){d3.select(this).classed("hover",!0),E.elementMouseover({label:i(e.data),value:s(e.data),point:e.data,pointIndex:t,pos:[d3.event.pageX,d3.event.pageY],id:u})}).on("mouseout",function(e,t){d3.select(this).classed("hover",!1),E.elementMouseout({label:i(e.data),value:s(e.data),point:e.data,index:t,id:u})}).on("click",function(e,t){E.elementClick({label:i(e.data),value:s(e.data),point:e.data,index:t,pos:d3.event,id:u}),d3.event.stopPropagation()}).on("dblclick",function(e,t){E.elementDblClick({label:i(e.data),value:s(e.data),point:e.data,index:t,pos:d3.event,id:u}),d3.event.stopPropagation()});M.attr("fill",function(e,t){return a(e,t)}).attr("stroke",function(e,t){return a(e,t)});var P=D.append("path").each(function(e){this._current=e});M.select("path").transition().attr("d",A).attrTween("d",R);if(l){var H=d3.svg.arc().innerRadius(0);c&&(H=A),h&&(H=d3.svg.arc().outerRadius(A.outerRadius())),_.enter().append("g").classed("nv-label",!0).each(function(e,t){var n=d3.select(this);n.attr("transform",function(e){if(g){e.outerRadius=x+10,e.innerRadius=x+15;var t=(e.startAngle+e.endAngle)/2*(180/Math.PI);return(e.startAngle+e.endAngle)/2v?r[p]:""})}}),S}var t={top:0,right:0,bottom:0,left:0},n=500,r=500,i=function(e){return e.x},s=function(e){return e.y},o=function(e){return e.description},u=Math.floor(Math.random()*1e4),a=e.utils.defaultColor(),f=d3.format(",.2f"),l=!0,c=!0,h=!1,p="key",v=.02,m=!1,g=!1,y=!1,b=!1,w=.5,E=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return S.dispatch=E,S.options=e.utils.optionsFunc.bind(S),S.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,S):t},S.width=function(e){return arguments.length?(n=e,S):n},S.height=function(e){return arguments.length?(r=e,S):r},S.values=function(t){return e.log("pie.values() is no longer supported."),S},S.x=function(e){return arguments.length?(i=e,S):i},S.y=function(e){return arguments.length?(s=d3.functor(e),S):s},S.description=function(e){return arguments.length?(o=e,S):o},S.showLabels=function(e){return arguments.length?(l=e,S):l},S.labelSunbeamLayout=function(e){return arguments.length?(g=e,S):g},S.donutLabelsOutside=function(e){return arguments.length?(h=e,S):h},S.pieLabelsOutside=function(e){return arguments.length?(c=e,S):c},S.labelType=function(e){return arguments.length?(p=e,p=p||"key",S):p},S.donut=function(e){return arguments.length?(m=e,S):m},S.donutRatio=function(e){return arguments.length?(w=e,S):w},S.startAngle=function(e){return arguments.length?(y=e,S):y},S.endAngle=function(e){return arguments.length?(b=e,S):b},S.id=function(e){return arguments.length?(u=e,S):u},S.color=function(t){return arguments.length?(a=e.utils.getColor(t),S):a},S.valueFormat=function(e){return arguments.length?(f=e,S):f},S.labelThreshold=function(e){return arguments.length?(v=e,S):v},S},e.models.pieChart=function(){"use strict";function v(e){return e.each(function(e){var u=d3.select(this),a=this,f=(i||parseInt(u.style("width"))||960)-r.left-r.right,d=(s||parseInt(u.style("height"))||400)-r.top-r.bottom;v.update=function(){u.transition().call(v)},v.container=this,l.disabled=e.map(function(e){return!!e.disabled});if(!c){var m;c={};for(m in l)l[m]instanceof Array?c[m]=l[m].slice(0):c[m]=l[m]}if(!e||!e.length){var g=u.selectAll(".nv-noData").data([h]);return g.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),g.attr("x",r.left+f/2).attr("y",r.top+d/2).text(function(e){return e}),v}u.selectAll(".nv-noData").remove();var y=u.selectAll("g.nv-wrap.nv-pieChart").data([e]),b=y.enter().append("g").attr("class","nvd3 nv-wrap nv-pieChart").append("g"),w=y.select("g");b.append("g").attr("class","nv-pieWrap"),b.append("g").attr("class","nv-legendWrap"),o&&(n.width(f).key(t.x()),y.select(".nv-legendWrap").datum(e).call(n),r.top!=n.height()&&(r.top=n.height(),d=(s||parseInt(u.style("height"))||400)-r.top-r.bottom),y.select(".nv-legendWrap").attr("transform","translate(0,"+ -r.top+")")),y.attr("transform","translate("+r.left+","+r.top+")"),t.width(f).height(d);var E=w.select(".nv-pieWrap").datum([e]);d3.transition(E).call(t),n.dispatch.on("stateChange",function(e){l=e,p.stateChange(l),v.update()}),t.dispatch.on("elementMouseout.tooltip",function(e){p.tooltipHide(e)}),p.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),l.disabled=t.disabled),v.update()})}),v}var t=e.models.pie(),n=e.models.legend(),r={top:30,right:20,bottom:20,left:20},i=null,s=null,o=!0,u=e.utils.defaultColor(),a=!0,f=function(e,t,n,r){return"

"+e+"

"+"

"+t+"

"},l={},c=null,h="No Data Available.",p=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),d=function(n,r){var i=t.description()(n.point)||t.x()(n.point),s=n.pos[0]+(r&&r.offsetLeft||0),o=n.pos[1]+(r&&r.offsetTop||0),u=t.valueFormat()(t.y()(n.point)),a=f(i,u,n,v);e.tooltip.show([s,o],a,n.value<0?"n":"s",null,r)};return t.dispatch.on("elementMouseover.tooltip",function(e){e.pos=[e.pos[0]+r.left,e.pos[1]+r.top],p.tooltipShow(e)}),p.on("tooltipShow",function(e){a&&d(e)}),p.on("tooltipHide",function(){a&&e.tooltip.cleanup()}),v.legend=n,v.dispatch=p,v.pie=t,d3.rebind(v,t,"valueFormat","values","x","y","description","id","showLabels","donutLabelsOutside","pieLabelsOutside","labelType","donut","donutRatio","labelThreshold"),v.options=e.utils.optionsFunc.bind(v),v.margin=function(e){return arguments.length?(r.top=typeof e.top!="undefined"?e.top:r.top,r.right=typeof e.right!="undefined"?e.right:r.right,r.bottom=typeof e.bottom!="undefined"?e.bottom:r.bottom,r.left=typeof e.left!="undefined"?e.left:r.left,v):r},v.width=function(e){return arguments.length?(i=e,v):i},v.height=function(e){return arguments.length?(s=e,v):s},v.color=function(r){return arguments.length?(u=e.utils.getColor(r),n.color(u),t.color(u),v):u},v.showLegend=function(e){return arguments.length?(o=e,v):o},v.tooltips=function(e){return arguments.length?(a=e,v):a},v.tooltipContent=function(e){return arguments.length?(f=e,v):f},v.state=function(e){return arguments.length?(l=e,v):l},v.defaultState=function(e){return arguments.length?(c=e,v):c},v.noData=function(e){return arguments.length?(h=e,v):h},v},e.models.scatter=function(){"use strict";function I(q){return q.each(function(I){function Q(){if(!g)return!1;var e,i=d3.merge(I.map(function(e,t){return e.values.map(function(e,n){var r=f(e,n),i=l(e,n);return[o(r)+Math.random()*1e-7,u(i)+Math.random()*1e-7,t,n,e]}).filter(function(e,t){return b(e[4],t)})}));if(D===!0){if(x){var a=X.select("defs").selectAll(".nv-point-clips").data([s]).enter();a.append("clipPath").attr("class","nv-point-clips").attr("id","nv-points-clip-"+s);var c=X.select("#nv-points-clip-"+s).selectAll("circle").data(i);c.enter().append("circle").attr("r",T),c.exit().remove(),c.attr("cx",function(e){return e[0]}).attr("cy",function(e){return e[1]}),X.select(".nv-point-paths").attr("clip-path","url(#nv-points-clip-"+s+")")}i.length&&(i.push([o.range()[0]-20,u.range()[0]-20,null,null]),i.push([o.range()[1]+20,u.range()[1]+20,null,null]),i.push([o.range()[0]-20,u.range()[0]+20,null,null]),i.push([o.range()[1]+20,u.range()[1]-20,null,null]));var h=d3.geom.polygon([[-10,-10],[-10,r+10],[n+10,r+10],[n+10,-10]]),p=d3.geom.voronoi(i).map(function(e,t){return{data:h.clip(e),series:i[t][2],point:i[t][3]}}),d=X.select(".nv-point-paths").selectAll("path").data(p);d.enter().append("path").attr("class",function(e,t){return"nv-path-"+t}),d.exit().remove(),d.attr("d",function(e){return e.data.length===0?"M 0 0":"M"+e.data.join("L")+"Z"});var v=function(e,n){if(F)return 0;var r=I[e.series];if(typeof r=="undefined")return;var i=r.values[e.point];n({point:i,series:r,pos:[o(f(i,e.point))+t.left,u(l(i,e.point))+t.top],seriesIndex:e.series,pointIndex:e.point})};d.on("click",function(e){v(e,_.elementClick)}).on("mouseover",function(e){v(e,_.elementMouseover)}).on("mouseout",function(e,t){v(e,_.elementMouseout)})}else X.select(".nv-groups").selectAll(".nv-group").selectAll(".nv-point").on("click",function(e,n){if(F||!I[e.series])return 0;var r=I[e.series],i=r.values[n];_.elementClick({point:i,series:r,pos:[o(f(i,n))+t.left,u(l(i,n))+t.top],seriesIndex:e.series,pointIndex:n})}).on("mouseover",function(e,n){if(F||!I[e.series])return 0;var r=I[e.series],i=r.values[n];_.elementMouseover({point:i,series:r,pos:[o(f(i,n))+t.left,u(l(i,n))+t.top],seriesIndex:e.series,pointIndex:n})}).on("mouseout",function(e,t){if(F||!I[e.series])return 0;var n=I[e.series],r=n.values[t];_.elementMouseout({point:r,series:n,seriesIndex:e.series,pointIndex:t})});F=!1}var q=n-t.left-t.right,R=r-t.top-t.bottom,U=d3.select(this);I.forEach(function(e,t){e.values.forEach(function(e){e.series=t})});var W=N&&C&&A?[]:d3.merge(I.map(function(e){return e.values.map(function(e,t){return{x:f(e,t),y:l(e,t),size:c(e,t)}})}));o.domain(N||d3.extent(W.map(function(e){return e.x}).concat(d))),w&&I[0]?o.range(k||[(q*E+q)/(2*I[0].values.length),q-q*(1+E)/(2*I[0].values.length)]):o.range(k||[0,q]),u.domain(C||d3.extent(W.map(function(e){return e.y}).concat(v))).range(L||[R,0]),a.domain(A||d3.extent(W.map(function(e){return e.size}).concat(m))).range(O||[16,256]);if(o.domain()[0]===o.domain()[1]||u.domain()[0]===u.domain()[1])M=!0;o.domain()[0]===o.domain()[1]&&(o.domain()[0]?o.domain([o.domain()[0]-o.domain()[0]*.01,o.domain()[1]+o.domain()[1]*.01]):o.domain([-1,1])),u.domain()[0]===u.domain()[1]&&(u.domain()[0]?u.domain([u.domain()[0]-u.domain()[0]*.01,u.domain()[1]+u.domain()[1]*.01]):u.domain([-1,1])),isNaN(o.domain()[0])&&o.domain([-1,1]),isNaN(u.domain()[0])&&u.domain([-1,1]),P=P||o,H=H||u,B=B||a;var X=U.selectAll("g.nv-wrap.nv-scatter").data([I]),V=X.enter().append("g").attr("class","nvd3 nv-wrap nv-scatter nv-chart-"+s+(M?" nv-single-point":"")),$=V.append("defs"),J=V.append("g"),K=X.select("g");J.append("g").attr("class","nv-groups"),J.append("g").attr("class","nv-point-paths"),X.attr("transform","translate("+t.left+","+t.top+")"),$.append("clipPath").attr("id","nv-edge-clip-"+s).append("rect"),X.select("#nv-edge-clip-"+s+" rect").attr("width",q).attr("height",R>0?R:0),K.attr("clip-path",S?"url(#nv-edge-clip-"+s+")":""),F=!0;var G=X.select(".nv-groups").selectAll(".nv-group").data(function(e){return e},function(e){return e.key});G.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),G.exit().remove(),G.attr("class",function(e,t){return"nv-group nv-series-"+t}).classed("hover",function(e){return e.hover}),G.transition().style("fill",function(e,t){return i(e,t)}).style("stroke",function(e,t){return i(e,t)}).style("stroke-opacity",1).style("fill-opacity",.5);if(p){var Y=G.selectAll("circle.nv-point").data(function(e){return e.values},y);Y.enter().append("circle").style("fill",function(e,t){return e.color}).style("stroke",function(e,t){return e.color}).attr("cx",function(t,n){return e.utils.NaNtoZero(P(f(t,n)))}).attr("cy",function(t,n){return e.utils.NaNtoZero(H(l(t,n)))}).attr("r",function(e,t){return Math.sqrt(a(c(e,t))/Math.PI)}),Y.exit().remove(),G.exit().selectAll("path.nv-point").transition().attr("cx",function(t,n){return e.utils.NaNtoZero(o(f(t,n)))}).attr("cy",function(t,n){return e.utils.NaNtoZero(u(l(t,n)))}).remove(),Y.each(function(e,t){d3.select(this).classed("nv-point",!0).classed("nv-point-"+t,!0).classed("hover",!1)}),Y.transition().attr("cx",function(t,n){return e.utils.NaNtoZero(o(f(t,n)))}).attr("cy",function(t,n){return e.utils.NaNtoZero(u(l(t,n)))}).attr("r",function(e,t){return Math.sqrt(a(c(e,t))/Math.PI)})}else{var Y=G.selectAll("path.nv-point").data(function(e){return e.values});Y.enter().append("path").style("fill",function(e,t){return e.color}).style("stroke",function(e,t){return e.color}).attr("transform",function(e,t){return"translate("+P(f(e,t))+","+H(l(e,t))+")"}).attr("d",d3.svg.symbol().type(h).size(function(e,t){return a(c(e,t))})),Y.exit().remove(),G.exit().selectAll("path.nv-point").transition().attr("transform",function(e,t){return"translate("+o(f(e,t))+","+u(l(e,t))+")"}).remove(),Y.each(function(e,t){d3.select(this).classed("nv-point",!0).classed("nv-point-"+t,!0).classed("hover",!1)}),Y.transition().attr("transform",function(e,t){return"translate("+o(f(e,t))+","+u(l(e,t))+")"}).attr("d",d3.svg.symbol().type(h).size(function(e,t){return a(c(e,t))}))}clearTimeout(j),j=setTimeout(Q,300),P=o.copy(),H=u.copy(),B=a.copy()}),I}var t={top:0,right:0,bottom:0,left:0},n=960,r=500,i=e.utils.defaultColor(),s=Math.floor(Math.random()*1e5),o=d3.scale.linear(),u=d3.scale.linear(),a=d3.scale.linear(),f=function(e){return e.x},l=function(e){return e.y},c=function(e){return e.size||1},h=function(e){return e.shape||"circle"},p=!0,d=[],v=[],m=[],g=!0,y=null,b=function(e){return!e.notActive},w=!1,E=.1,S=!1,x=!0,T=function(){return 25},N=null,C=null,k=null,L=null,A=null,O=null,M=!1,_=d3.dispatch("elementClick","elementMouseover","elementMouseout"),D=!0,P,H,B,j,F=!1;return I.clearHighlights=function(){d3.selectAll(".nv-chart-"+s+" .nv-point.hover").classed("hover",!1)},I.highlightPoint=function(e,t,n){d3.select(".nv-chart-"+s+" .nv-series-"+e+" .nv-point-"+t).classed("hover",n)},_.on("elementMouseover.point",function(e){g&&I.highlightPoint(e.seriesIndex,e.pointIndex,!0)}),_.on("elementMouseout.point",function(e){g&&I.highlightPoint(e.seriesIndex,e.pointIndex,!1)}),I.dispatch=_,I.options=e.utils.optionsFunc.bind(I),I.x=function(e){return arguments.length?(f=d3.functor(e),I):f},I.y=function(e){return arguments.length?(l=d3.functor(e),I):l},I.size=function(e){return arguments.length?(c=d3.functor(e),I):c},I.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,I):t},I.width=function(e){return arguments.length?(n=e,I):n},I.height=function(e){return arguments.length?(r=e,I):r},I.xScale=function(e){return arguments.length?(o=e,I):o},I.yScale=function(e){return arguments.length?(u=e,I):u},I.zScale=function(e){return arguments.length?(a=e,I):a},I.xDomain=function(e){return arguments.length?(N=e,I):N},I.yDomain=function(e){return arguments.length?(C=e,I):C},I.sizeDomain=function(e){return arguments.length?(A=e,I):A},I.xRange=function(e){return arguments.length?(k=e,I):k},I.yRange=function(e){return arguments.length?(L=e,I):L},I.sizeRange=function(e){return arguments.length?(O=e,I):O},I.forceX=function(e){return arguments.length?(d=e,I):d},I.forceY=function(e){return arguments.length?(v=e,I):v},I.forceSize=function(e){return arguments.length?(m=e,I):m},I.interactive=function(e){return arguments.length?(g=e,I):g},I.pointKey=function(e){return arguments.length?(y=e,I):y},I.pointActive=function(e){return arguments.length?(b=e,I):b},I.padData=function(e){return arguments.length?(w=e,I):w},I.padDataOuter=function(e){return arguments.length?(E=e,I):E},I.clipEdge=function(e){return arguments.length?(S=e,I):S},I.clipVoronoi=function(e){return arguments.length?(x=e,I):x},I.useVoronoi=function(e){return arguments.length?(D=e,D===!1&&(x=!1),I):D},I.clipRadius=function(e){return arguments.length?(T=e,I):T},I.color=function(t){return arguments.length?(i=e.utils.getColor(t),I):i},I.shape=function(e){return arguments.length?(h=e,I):h},I.onlyCircles=function(e){return arguments.length?(p=e,I):p},I.id=function(e){return arguments.length?(s=e,I):s},I.singlePoint=function(e){return arguments.length?(M=e,I):M},I},e.models.scatterChart=function(){"use strict";function F(e){return e.each(function(e){function K(){if(T)return X.select(".nv-point-paths").style("pointer-events","all"),!1;X.select(".nv-point-paths").style("pointer-events","none");var i=d3.mouse(this);h.distortion(x).focus(i[0]),p.distortion(x).focus(i[1]),X.select(".nv-scatterWrap").call(t),b&&X.select(".nv-x.nv-axis").call(n),w&&X.select(".nv-y.nv-axis").call(r),X.select(".nv-distributionX").datum(e.filter(function(e){return!e.disabled})).call(o),X.select(".nv-distributionY").datum(e.filter(function(e){return!e.disabled})).call(u)}var C=d3.select(this),k=this,L=(f||parseInt(C.style("width"))||960)-a.left-a.right,I=(l||parseInt(C.style("height"))||400)-a.top-a.bottom;F.update=function(){C.transition().duration(D).call(F)},F.container=this,A.disabled=e.map(function(e){return!!e.disabled});if(!O){var q;O={};for(q in A)A[q]instanceof Array?O[q]=A[q].slice(0):O[q]=A[q]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var R=C.selectAll(".nv-noData").data([_]);return R.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),R.attr("x",a.left+L/2).attr("y",a.top+I/2).text(function(e){return e}),F}C.selectAll(".nv-noData").remove(),P=P||h,H=H||p;var U=C.selectAll("g.nv-wrap.nv-scatterChart").data([e]),z=U.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+t.id()),W=z.append("g"),X=U.select("g");W.append("rect").attr("class","nvd3 nv-background"),W.append("g").attr("class","nv-x nv-axis"),W.append("g").attr("class","nv-y nv-axis"),W.append("g").attr("class","nv-scatterWrap"),W.append("g").attr("class","nv-distWrap"),W.append("g").attr("class","nv-legendWrap"),W.append("g").attr("class","nv-controlsWrap");if(y){var V=S?L/2:L;i.width(V),U.select(".nv-legendWrap").datum(e).call(i),a.top!=i.height()&&(a.top=i.height(),I=(l||parseInt(C.style("height"))||400)-a.top-a.bottom),U.select(".nv-legendWrap").attr("transform","translate("+(L-V)+","+ -a.top+")")}S&&(s.width(180).color(["#444"]),X.select(".nv-controlsWrap").datum(j).attr("transform","translate(0,"+ -a.top+")").call(s)),U.attr("transform","translate("+a.left+","+a.top+")"),E&&X.select(".nv-y.nv-axis").attr("transform","translate("+L+",0)"),t.width(L).height(I).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),d!==0&&t.xDomain(null),v!==0&&t.yDomain(null),U.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t);if(d!==0){var $=h.domain()[1]-h.domain()[0];t.xDomain([h.domain()[0]-d*$,h.domain()[1]+d*$])}if(v!==0){var J=p.domain()[1]-p.domain()[0];t.yDomain([p.domain()[0]-v*J,p.domain()[1]+v*J])}(v!==0||d!==0)&&U.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t),b&&(n.scale(h).ticks(n.ticks()&&n.ticks().length?n.ticks():L/100).tickSize(-I,0),X.select(".nv-x.nv-axis").attr("transform","translate(0,"+p.range()[0]+")").call(n)),w&&(r.scale(p).ticks(r.ticks()&&r.ticks().length?r.ticks():I/36).tickSize(-L,0),X.select(".nv-y.nv-axis").call(r)),m&&(o.getData(t.x()).scale(h).width(L).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),W.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),X.select(".nv-distributionX").attr("transform","translate(0,"+p.range()[0]+")").datum(e.filter(function(e){return!e.disabled})).call(o)),g&&(u.getData(t.y()).scale(p).width(I).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),W.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),X.select(".nv-distributionY").attr("transform","translate("+(E?L:-u.size())+",0)").datum(e.filter(function(e){return!e.disabled})).call(u)),d3.fisheye&&(X.select(".nv-background").attr("width",L).attr("height",I),X.select(".nv-background").on("mousemove",K),X.select(".nv-background").on("click",function(){T=!T}),t.dispatch.on("elementClick.freezeFisheye",function(){T=!T})),s.dispatch.on("legendClick",function(e,i){e.disabled=!e.disabled,x=e.disabled?0:2.5,X.select(".nv-background").style("pointer-events",e.disabled?"none":"all"),X.select(".nv-point-paths").style("pointer-events",e.disabled?"all":"none"),e.disabled?(h.distortion(x).focus(0),p.distortion(x).focus(0),X.select(".nv-scatterWrap").call(t),X.select(".nv-x.nv-axis").call(n),X.select(".nv-y.nv-axis").call(r)):T=!1,F.update()}),i.dispatch.on("stateChange",function(e){A.disabled=e.disabled,M.stateChange(A),F.update()}),t.dispatch.on("elementMouseover.tooltip",function(e){d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",function(t,n){return e.pos[1]-I}),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",e.pos[0]+o.size()),e.pos=[e.pos[0]+a.left,e.pos[1]+a.top],M.tooltipShow(e)}),M.on("tooltipShow",function(e){N&&B(e,k.parentNode)}),M.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),A.disabled=t.disabled),F.update()}),P=h.copy(),H=p.copy()}),F}var t=e.models.scatter(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.models.distribution(),u=e.models.distribution(),a={top:30,right:20,bottom:50,left:75},f=null,l=null,c=e.utils.defaultColor(),h=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.xScale(),p=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.yScale(),d=0,v=0,m=!1,g=!1,y=!0,b=!0,w=!0,E=!1,S=!!d3.fisheye,x=0,T=!1,N=!0,C=function(e,t,n){return""+t+""},k=function(e,t,n){return""+n+""},L=null,A={},O=null,M=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),_="No Data Available.",D=250;t.xScale(h).yScale(p),n.orient("bottom").tickPadding(10),r.orient(E?"right":"left").tickPadding(10),o.axis("x"),u.axis("y"),s.updateState(!1);var P,H,B=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),f=i.pos[0]+(s.offsetLeft||0),l=p.range()[0]+a.top+(s.offsetTop||0),c=h.range()[0]+a.left+(s.offsetLeft||0),d=i.pos[1]+(s.offsetTop||0),v=n.tickFormat()(t.x()(i.point,i.pointIndex)),m=r.tickFormat()(t.y()(i.point,i.pointIndex));C!=null&&e.tooltip.show([f,l],C(i.series.key,v,m,i,F),"n",1,s,"x-nvtooltip"),k!=null&&e.tooltip.show([c,d],k(i.series.key,v,m,i,F),"e",1,s,"y-nvtooltip"),L!=null&&e.tooltip.show([o,u],L(i.series.key,v,m,i,F),i.value<0?"n":"s",null,s)},j=[{key:"Magnify",disabled:!0}];return t.dispatch.on("elementMouseout.tooltip",function(e){M.tooltipHide(e),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",0),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",u.size())}),M.on("tooltipHide",function(){N&&e.tooltip.cleanup()}),F.dispatch=M,F.scatter=t,F.legend=i,F.controls=s,F.xAxis=n,F.yAxis=r,F.distX=o,F.distY=u,d3.rebind(F,t,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),F.options=e.utils.optionsFunc.bind(F),F.margin=function(e){return arguments.length?(a.top=typeof e.top!="undefined"?e.top:a.top,a.right=typeof e.right!="undefined"?e.right:a.right,a.bottom=typeof e.bottom!="undefined"?e.bottom:a.bottom,a.left=typeof e.left!="undefined"?e.left:a.left,F):a},F.width=function(e){return arguments.length?(f=e,F):f},F.height=function(e){return arguments.length?(l=e,F):l},F.color=function(t){return arguments.length?(c=e.utils.getColor(t),i.color(c),o.color(c),u.color(c),F):c},F.showDistX=function(e){return arguments.length?(m=e,F):m},F.showDistY=function(e){return arguments.length?(g=e,F):g},F.showControls=function(e){return arguments.length?(S=e,F):S},F.showLegend=function(e){return arguments.length?(y=e,F):y},F.showXAxis=function(e){return arguments.length?(b=e,F):b},F.showYAxis=function(e){return arguments.length?(w=e,F):w},F.rightAlignYAxis=function(e){return arguments.length?(E=e,r.orient(e?"right":"left"),F):E},F.fisheye=function(e){return arguments.length?(x=e,F):x},F.xPadding=function(e){return arguments.length?(d=e,F):d},F.yPadding=function(e){return arguments.length?(v=e,F):v},F.tooltips=function(e){return arguments.length?(N=e,F):N},F.tooltipContent=function(e){return arguments.length?(L=e,F):L},F.tooltipXContent=function(e){return arguments.length?(C=e,F):C},F.tooltipYContent=function(e){return arguments.length?(k=e,F):k},F.state=function(e){return arguments.length?(A=e,F):A},F.defaultState=function(e){return arguments.length?(O=e,F):O},F.noData=function(e){return arguments.length?(_=e,F):_},F.transitionDuration=function(e){return arguments.length?(D=e,F):D},F},e.models.scatterPlusLineChart=function(){"use strict";function B(e){return e.each(function(e){function $(){if(S)return z.select(".nv-point-paths").style("pointer-events","all"),!1;z.select(".nv-point-paths").style("pointer-events","none");var i=d3.mouse(this);h.distortion(E).focus(i[0]),p.distortion(E).focus(i[1]),z.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t),g&&z.select(".nv-x.nv-axis").call(n),y&&z.select(".nv-y.nv-axis").call(r),z.select(".nv-distributionX").datum(e.filter(function(e){return!e.disabled})).call(o),z.select(".nv-distributionY").datum(e.filter(function(e){return!e.disabled})).call(u)}var T=d3.select(this),N=this,C=(f||parseInt(T.style("width"))||960)-a.left-a.right,j=(l||parseInt(T.style("height"))||400)-a.top-a.bottom;B.update=function(){T.transition().duration(M).call(B)},B.container=this,k.disabled=e.map(function(e){return!!e.disabled});if(!L){var F;L={};for(F in k)k[F]instanceof Array?L[F]=k[F].slice(0):L[F]=k[F]}if(!e||!e.length||!e.filter(function(e){return e.values.length}).length){var I=T.selectAll(".nv-noData").data([O]);return I.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),I.attr("x",a.left+C/2).attr("y",a.top+j/2).text(function(e){return e}),B}T.selectAll(".nv-noData").remove(),h=t.xScale(),p=t.yScale(),_=_||h,D=D||p;var q=T.selectAll("g.nv-wrap.nv-scatterChart").data([e]),R=q.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+t.id()),U=R.append("g"),z=q.select("g");U.append("rect").attr("class","nvd3 nv-background").style("pointer-events","none"),U.append("g").attr("class","nv-x nv-axis"),U.append("g").attr("class","nv-y nv-axis"),U.append("g").attr("class","nv-scatterWrap"),U.append("g").attr("class","nv-regressionLinesWrap"),U.append("g").attr("class","nv-distWrap"),U.append("g").attr("class","nv-legendWrap"),U.append("g").attr("class","nv-controlsWrap"),q.attr("transform","translate("+a.left+","+a.top+")"),b&&z.select(".nv-y.nv-axis").attr("transform","translate("+C+",0)"),m&&(i.width(C/2),q.select(".nv-legendWrap").datum(e).call(i),a.top!=i.height()&&(a.top=i.height(),j=(l||parseInt(T.style("height"))||400)-a.top-a.bottom),q.select(".nv-legendWrap").attr("transform","translate("+C/2+","+ -a.top+")")),w&&(s.width(180).color(["#444"]),z.select(".nv-controlsWrap").datum(H).attr("transform","translate(0,"+ -a.top+")").call(s)),t.width(C).height(j).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),q.select(".nv-scatterWrap").datum(e.filter(function(e){return!e.disabled})).call(t),q.select(".nv-regressionLinesWrap").attr("clip-path","url(#nv-edge-clip-"+t.id()+")");var W=q.select(".nv-regressionLinesWrap").selectAll(".nv-regLines").data(function(e){return e});W.enter().append("g").attr("class","nv-regLines");var X=W.selectAll(".nv-regLine").data(function(e){return[e]}),V=X.enter().append("line").attr("class","nv-regLine").style("stroke-opacity",0);X.transition().attr("x1",h.range()[0]).attr("x2",h.range()[1]).attr("y1",function(e,t){return p(h.domain()[0]*e.slope+e.intercept)}).attr("y2",function(e,t){return p(h.domain()[1]*e.slope+e.intercept)}).style("stroke",function(e,t,n){return c(e,n)}).style("stroke-opacity",function(e,t){return e.disabled||typeof e.slope=="undefined"||typeof e.intercept=="undefined"?0:1}),g&&(n.scale(h).ticks(n.ticks()?n.ticks():C/100).tickSize(-j,0),z.select(".nv-x.nv-axis").attr("transform","translate(0,"+p.range()[0]+")").call(n)),y&&(r.scale(p).ticks(r.ticks()?r.ticks():j/36).tickSize(-C,0),z.select(".nv-y.nv-axis").call(r)),d&&(o.getData(t.x()).scale(h).width(C).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),U.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),z.select(".nv-distributionX").attr("transform","translate(0,"+p.range()[0]+")").datum(e.filter(function(e){return!e.disabled})).call(o)),v&&(u.getData(t.y()).scale(p).width( -j).color(e.map(function(e,t){return e.color||c(e,t)}).filter(function(t,n){return!e[n].disabled})),U.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),z.select(".nv-distributionY").attr("transform","translate("+(b?C:-u.size())+",0)").datum(e.filter(function(e){return!e.disabled})).call(u)),d3.fisheye&&(z.select(".nv-background").attr("width",C).attr("height",j),z.select(".nv-background").on("mousemove",$),z.select(".nv-background").on("click",function(){S=!S}),t.dispatch.on("elementClick.freezeFisheye",function(){S=!S})),s.dispatch.on("legendClick",function(e,i){e.disabled=!e.disabled,E=e.disabled?0:2.5,z.select(".nv-background").style("pointer-events",e.disabled?"none":"all"),z.select(".nv-point-paths").style("pointer-events",e.disabled?"all":"none"),e.disabled?(h.distortion(E).focus(0),p.distortion(E).focus(0),z.select(".nv-scatterWrap").call(t),z.select(".nv-x.nv-axis").call(n),z.select(".nv-y.nv-axis").call(r)):S=!1,B.update()}),i.dispatch.on("stateChange",function(e){k=e,A.stateChange(k),B.update()}),t.dispatch.on("elementMouseover.tooltip",function(e){d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",e.pos[1]-j),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",e.pos[0]+o.size()),e.pos=[e.pos[0]+a.left,e.pos[1]+a.top],A.tooltipShow(e)}),A.on("tooltipShow",function(e){x&&P(e,N.parentNode)}),A.on("changeState",function(t){typeof t.disabled!="undefined"&&(e.forEach(function(e,n){e.disabled=t.disabled[n]}),k.disabled=t.disabled),B.update()}),_=h.copy(),D=p.copy()}),B}var t=e.models.scatter(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.models.distribution(),u=e.models.distribution(),a={top:30,right:20,bottom:50,left:75},f=null,l=null,c=e.utils.defaultColor(),h=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.xScale(),p=d3.fisheye?d3.fisheye.scale(d3.scale.linear).distortion(0):t.yScale(),d=!1,v=!1,m=!0,g=!0,y=!0,b=!1,w=!!d3.fisheye,E=0,S=!1,x=!0,T=function(e,t,n){return""+t+""},N=function(e,t,n){return""+n+""},C=function(e,t,n,r){return"

"+e+"

"+"

"+r+"

"},k={},L=null,A=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),O="No Data Available.",M=250;t.xScale(h).yScale(p),n.orient("bottom").tickPadding(10),r.orient(b?"right":"left").tickPadding(10),o.axis("x"),u.axis("y"),s.updateState(!1);var _,D,P=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),f=i.pos[0]+(s.offsetLeft||0),l=p.range()[0]+a.top+(s.offsetTop||0),c=h.range()[0]+a.left+(s.offsetLeft||0),d=i.pos[1]+(s.offsetTop||0),v=n.tickFormat()(t.x()(i.point,i.pointIndex)),m=r.tickFormat()(t.y()(i.point,i.pointIndex));T!=null&&e.tooltip.show([f,l],T(i.series.key,v,m,i,B),"n",1,s,"x-nvtooltip"),N!=null&&e.tooltip.show([c,d],N(i.series.key,v,m,i,B),"e",1,s,"y-nvtooltip"),C!=null&&e.tooltip.show([o,u],C(i.series.key,v,m,i.point.tooltip,i,B),i.value<0?"n":"s",null,s)},H=[{key:"Magnify",disabled:!0}];return t.dispatch.on("elementMouseout.tooltip",function(e){A.tooltipHide(e),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-distx-"+e.pointIndex).attr("y1",0),d3.select(".nv-chart-"+t.id()+" .nv-series-"+e.seriesIndex+" .nv-disty-"+e.pointIndex).attr("x2",u.size())}),A.on("tooltipHide",function(){x&&e.tooltip.cleanup()}),B.dispatch=A,B.scatter=t,B.legend=i,B.controls=s,B.xAxis=n,B.yAxis=r,B.distX=o,B.distY=u,d3.rebind(B,t,"id","interactive","pointActive","x","y","shape","size","xScale","yScale","zScale","xDomain","yDomain","xRange","yRange","sizeDomain","sizeRange","forceX","forceY","forceSize","clipVoronoi","clipRadius","useVoronoi"),B.options=e.utils.optionsFunc.bind(B),B.margin=function(e){return arguments.length?(a.top=typeof e.top!="undefined"?e.top:a.top,a.right=typeof e.right!="undefined"?e.right:a.right,a.bottom=typeof e.bottom!="undefined"?e.bottom:a.bottom,a.left=typeof e.left!="undefined"?e.left:a.left,B):a},B.width=function(e){return arguments.length?(f=e,B):f},B.height=function(e){return arguments.length?(l=e,B):l},B.color=function(t){return arguments.length?(c=e.utils.getColor(t),i.color(c),o.color(c),u.color(c),B):c},B.showDistX=function(e){return arguments.length?(d=e,B):d},B.showDistY=function(e){return arguments.length?(v=e,B):v},B.showControls=function(e){return arguments.length?(w=e,B):w},B.showLegend=function(e){return arguments.length?(m=e,B):m},B.showXAxis=function(e){return arguments.length?(g=e,B):g},B.showYAxis=function(e){return arguments.length?(y=e,B):y},B.rightAlignYAxis=function(e){return arguments.length?(b=e,r.orient(e?"right":"left"),B):b},B.fisheye=function(e){return arguments.length?(E=e,B):E},B.tooltips=function(e){return arguments.length?(x=e,B):x},B.tooltipContent=function(e){return arguments.length?(C=e,B):C},B.tooltipXContent=function(e){return arguments.length?(T=e,B):T},B.tooltipYContent=function(e){return arguments.length?(N=e,B):N},B.state=function(e){return arguments.length?(k=e,B):k},B.defaultState=function(e){return arguments.length?(L=e,B):L},B.noData=function(e){return arguments.length?(O=e,B):O},B.transitionDuration=function(e){return arguments.length?(M=e,B):M},B},e.models.sparkline=function(){"use strict";function d(e){return e.each(function(e){var i=n-t.left-t.right,d=r-t.top-t.bottom,v=d3.select(this);s.domain(l||d3.extent(e,u)).range(h||[0,i]),o.domain(c||d3.extent(e,a)).range(p||[d,0]);var m=v.selectAll("g.nv-wrap.nv-sparkline").data([e]),g=m.enter().append("g").attr("class","nvd3 nv-wrap nv-sparkline"),b=g.append("g"),w=m.select("g");m.attr("transform","translate("+t.left+","+t.top+")");var E=m.selectAll("path").data(function(e){return[e]});E.enter().append("path"),E.exit().remove(),E.style("stroke",function(e,t){return e.color||f(e,t)}).attr("d",d3.svg.line().x(function(e,t){return s(u(e,t))}).y(function(e,t){return o(a(e,t))}));var S=m.selectAll("circle.nv-point").data(function(e){function n(t){if(t!=-1){var n=e[t];return n.pointIndex=t,n}return null}var t=e.map(function(e,t){return a(e,t)}),r=n(t.lastIndexOf(o.domain()[1])),i=n(t.indexOf(o.domain()[0])),s=n(t.length-1);return[i,r,s].filter(function(e){return e!=null})});S.enter().append("circle"),S.exit().remove(),S.attr("cx",function(e,t){return s(u(e,e.pointIndex))}).attr("cy",function(e,t){return o(a(e,e.pointIndex))}).attr("r",2).attr("class",function(e,t){return u(e,e.pointIndex)==s.domain()[1]?"nv-point nv-currentValue":a(e,e.pointIndex)==o.domain()[0]?"nv-point nv-minValue":"nv-point nv-maxValue"})}),d}var t={top:2,right:0,bottom:2,left:0},n=400,r=32,i=!0,s=d3.scale.linear(),o=d3.scale.linear(),u=function(e){return e.x},a=function(e){return e.y},f=e.utils.getColor(["#000"]),l,c,h,p;return d.options=e.utils.optionsFunc.bind(d),d.margin=function(e){return arguments.length?(t.top=typeof e.top!="undefined"?e.top:t.top,t.right=typeof e.right!="undefined"?e.right:t.right,t.bottom=typeof e.bottom!="undefined"?e.bottom:t.bottom,t.left=typeof e.left!="undefined"?e.left:t.left,d):t},d.width=function(e){return arguments.length?(n=e,d):n},d.height=function(e){return arguments.length?(r=e,d):r},d.x=function(e){return arguments.length?(u=d3.functor(e),d):u},d.y=function(e){return arguments.length?(a=d3.functor(e),d):a},d.xScale=function(e){return arguments.length?(s=e,d):s},d.yScale=function(e){return arguments.length?(o=e,d):o},d.xDomain=function(e){return arguments.length?(l=e,d):l},d.yDomain=function(e){return arguments.length?(c=e,d):c},d.xRange=function(e){return arguments.length?(h=e,d):h},d.yRange=function(e){return arguments.length?(p=e,d):p},d.animate=function(e){return arguments.length?(i=e,d):i},d.color=function(t){return arguments.length?(f=e.utils.getColor(t),d):f},d},e.models.sparklinePlus=function(){"use strict";function v(e){return e.each(function(c){function O(){if(a)return;var e=C.selectAll(".nv-hoverValue").data(u),r=e.enter().append("g").attr("class","nv-hoverValue").style("stroke-opacity",0).style("fill-opacity",0);e.exit().transition().duration(250).style("stroke-opacity",0).style("fill-opacity",0).remove(),e.attr("transform",function(e){return"translate("+s(t.x()(c[e],e))+",0)"}).transition().duration(250).style("stroke-opacity",1).style("fill-opacity",1);if(!u.length)return;r.append("line").attr("x1",0).attr("y1",-n.top).attr("x2",0).attr("y2",b),r.append("text").attr("class","nv-xValue").attr("x",-6).attr("y",-n.top).attr("text-anchor","end").attr("dy",".9em"),C.select(".nv-hoverValue .nv-xValue").text(f(t.x()(c[u[0]],u[0]))),r.append("text").attr("class","nv-yValue").attr("x",6).attr("y",-n.top).attr("text-anchor","start").attr("dy",".9em"),C.select(".nv-hoverValue .nv-yValue").text(l(t.y()(c[u[0]],u[0])))}function M(){function r(e,n){var r=Math.abs(t.x()(e[0],0)-n),i=0;for(var s=0;s2){var h=M.yScale().invert(i.mouseY),p=Infinity,d=null;c.forEach(function(e,t){h=Math.abs(h);var n=Math.abs(e.stackedValue.y0),r=Math.abs(e.stackedValue.y);if(h>=n&&h<=r+n){d=t;return}}),d!=null&&(c[d].highlight=!0)}var v=n.tickFormat()(M.x()(s,a)),m=t.style()=="expand"?function(e,t){return d3.format(".1%")(e)}:function(e,t){return r.tickFormat()(e)};o.tooltip.position({left:f+u.left,top:i.mouseY+u.top}).chartContainer(D.parentNode).enabled(g).valueFormatter(m).data({value:v,series:c})(),o.renderGuideLine(f)}),o.dispatch.on("elementMouseout",function(e){N.tooltipHide(),t.clearHighlights()}),N.on("tooltipShow",function(e){g&&O(e,D.parentNode)}),N.on("changeState",function(e){typeof e.disabled!="undefined"&&y.length===e.disabled.length&&(y.forEach(function(t,n){t.disabled=e.disabled[n]}),S.disabled=e.disabled),typeof e.style!="undefined"&&t.style(e.style),M.update()})}),M}var t=e.models.stackedArea(),n=e.models.axis(),r=e.models.axis(),i=e.models.legend(),s=e.models.legend(),o=e.interactiveGuideline(),u={top:30,right:25,bottom:50,left:60},a=null,f=null,l=e.utils.defaultColor(),c=!0,h=!0,p=!0,d=!0,v=!1,m=!1,g=!0,y=function(e,t,n,r,i){return"

"+e+"

"+"

"+n+" on "+t+"

"},b,w,E=d3.format(",.2f"),S={style:t.style()},x=null,T="No Data Available.",N=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState"),C=250,k=["Stacked","Stream","Expanded"],L={},A=250;n.orient("bottom").tickPadding(7),r.orient(v?"right":"left"),s.updateState(!1);var O=function(i,s){var o=i.pos[0]+(s.offsetLeft||0),u=i.pos[1]+(s.offsetTop||0),a=n.tickFormat()(t.x()(i.point,i.pointIndex)),f=r.tickFormat()(t.y()(i.point,i.pointIndex)),l=y(i.series.key,a,f,i,M);e.tooltip.show([o,u],l,i.value<0?"n":"s",null,s)};return t.dispatch.on("tooltipShow",function(e){e.pos=[e.pos[0]+u.left,e.pos[1]+u.top],N.tooltipShow(e)}),t.dispatch.on("tooltipHide",function(e){N.tooltipHide(e)}),N.on("tooltipHide",function(){g&&e.tooltip.cleanup()}),M.dispatch=N,M.stacked=t,M.legend=i,M.controls=s,M.xAxis=n,M.yAxis=r,M.interactiveLayer=o,d3.rebind(M,t,"x","y","size","xScale","yScale","xDomain","yDomain","xRange","yRange","sizeDomain","interactive","useVoronoi","offset","order","style","clipEdge","forceX","forceY","forceSize","interpolate"),M.options=e.utils.optionsFunc.bind(M),M.margin=function(e){return arguments.length?(u.top=typeof e.top!="undefined"?e.top:u.top,u.right=typeof e.right!="undefined"?e.right:u.right,u.bottom=typeof e.bottom!="undefined"?e.bottom:u.bottom,u.left=typeof e.left!="undefined"?e.left:u.left,M):u},M.width=function(e){return arguments.length?(a=e,M):a},M.height=function(e){return arguments.length?(f=e,M):f},M.color=function(n){return arguments.length?(l=e.utils.getColor(n),i.color(l),t.color(l),M):l},M.showControls=function(e){return arguments.length?(c=e,M):c},M.showLegend=function(e){return arguments.length?(h=e,M):h},M.showXAxis=function(e){return arguments.length?(p=e,M):p},M.showYAxis=function(e){return arguments.length?(d=e,M):d},M.rightAlignYAxis=function(e){return arguments.length?(v=e,r.orient(e?"right":"left"),M):v},M.useInteractiveGuideline=function(e){return arguments.length?(m=e,e===!0&&(M.interactive(!1),M.useVoronoi(!1)),M):m},M.tooltip=function(e){return arguments.length?(y=e,M):y},M.tooltips=function(e){return arguments.length?(g=e,M):g},M.tooltipContent=function(e){return arguments.length?(y=e,M):y},M.state=function(e){return arguments.length?(S=e,M):S},M.defaultState=function(e){return arguments.length?(x=e,M):x},M.noData=function(e){return arguments.length?(T=e,M):T},M.transitionDuration=function(e){return arguments.length?(A=e,M):A},M.controlsData=function(e){return arguments.length?(k=e,M):k},M.controlLabels=function(e){return arguments.length?typeof e!="object"?L:(L=e,M):L},r.setTickFormat=r.tickFormat,r.tickFormat=function(e){return arguments.length?(E=e,r):E},M}})(); \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/package.json b/awx/ui/static/lib/novus-nvd3/package.json deleted file mode 100755 index 6e328d17a4..0000000000 --- a/awx/ui/static/lib/novus-nvd3/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "nvd3", - "version": "0.0.1", - "devDependencies": { - "grunt": "~0.4.1", - "grunt-contrib-jshint": "~0.3.0", - "grunt-contrib-watch": "~0.3.1", - "grunt-contrib-uglify": "~0.2.0", - "grunt-contrib-concat": "~0.2.0", - "grunt-contrib-copy": "~0.4.1", - "grunt-contrib-cssmin": "~0.6.2" - } -} diff --git a/awx/ui/static/lib/novus-nvd3/src/core.js b/awx/ui/static/lib/novus-nvd3/src/core.js deleted file mode 100755 index b96b071fa2..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/core.js +++ /dev/null @@ -1,125 +0,0 @@ - -var nv = window.nv || {}; - - -nv.version = '1.1.15b'; -nv.dev = true //set false when in production - -window.nv = nv; - -nv.tooltip = nv.tooltip || {}; // For the tooltip system -nv.utils = nv.utils || {}; // Utility subsystem -nv.models = nv.models || {}; //stores all the possible models/components -nv.charts = {}; //stores all the ready to use charts -nv.graphs = []; //stores all the graphs currently on the page -nv.logs = {}; //stores some statistics and potential error messages - -nv.dispatch = d3.dispatch('render_start', 'render_end'); - -// ************************************************************************* -// Development render timers - disabled if dev = false - -if (nv.dev) { - nv.dispatch.on('render_start', function(e) { - nv.logs.startTime = +new Date(); - }); - - nv.dispatch.on('render_end', function(e) { - nv.logs.endTime = +new Date(); - nv.logs.totalTime = nv.logs.endTime - nv.logs.startTime; - nv.log('total', nv.logs.totalTime); // used for development, to keep track of graph generation times - }); -} - -// ******************************************** -// Public Core NV functions - -// Logs all arguments, and returns the last so you can test things in place -// Note: in IE8 console.log is an object not a function, and if modernizr is used -// then calling Function.prototype.bind with with anything other than a function -// causes a TypeError to be thrown. -nv.log = function() { - if (nv.dev && console.log && console.log.apply) - console.log.apply(console, arguments) - else if (nv.dev && typeof console.log == "function" && Function.prototype.bind) { - var log = Function.prototype.bind.call(console.log, console); - log.apply(console, arguments); - } - return arguments[arguments.length - 1]; -}; - - -nv.render = function render(step) { - step = step || 1; // number of graphs to generate in each timeout loop - - nv.render.active = true; - nv.dispatch.render_start(); - - setTimeout(function() { - var chart, graph; - - for (var i = 0; i < step && (graph = nv.render.queue[i]); i++) { - chart = graph.generate(); - if (typeof graph.callback == typeof(Function)) graph.callback(chart); - nv.graphs.push(chart); - } - - nv.render.queue.splice(0, i); - - if (nv.render.queue.length) setTimeout(arguments.callee, 0); - else { - nv.dispatch.render_end(); - nv.render.active = false; - } - }, 0); -}; - -nv.render.active = false; -nv.render.queue = []; - -nv.addGraph = function(obj) { - if (typeof arguments[0] === typeof(Function)) - obj = {generate: arguments[0], callback: arguments[1]}; - - nv.render.queue.push(obj); - - if (!nv.render.active) nv.render(); -}; - -nv.identity = function(d) { return d; }; - -nv.strip = function(s) { return s.replace(/(\s|&)/g,''); }; - -function daysInMonth(month,year) { - return (new Date(year, month+1, 0)).getDate(); -} - -function d3_time_range(floor, step, number) { - return function(t0, t1, dt) { - var time = floor(t0), times = []; - if (time < t0) step(time); - if (dt > 1) { - while (time < t1) { - var date = new Date(+time); - if ((number(date) % dt === 0)) times.push(date); - step(time); - } - } else { - while (time < t1) { times.push(new Date(+time)); step(time); } - } - return times; - }; -} - -d3.time.monthEnd = function(date) { - return new Date(date.getFullYear(), date.getMonth(), 0); -}; - -d3.time.monthEnds = d3_time_range(d3.time.monthEnd, function(date) { - date.setUTCDate(date.getUTCDate() + 1); - date.setDate(daysInMonth(date.getMonth() + 1, date.getFullYear())); - }, function(date) { - return date.getMonth(); - } -); - diff --git a/awx/ui/static/lib/novus-nvd3/src/interactiveLayer.js b/awx/ui/static/lib/novus-nvd3/src/interactiveLayer.js deleted file mode 100755 index 4dfb68dcc7..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/interactiveLayer.js +++ /dev/null @@ -1,251 +0,0 @@ -/* Utility class to handle creation of an interactive layer. -This places a rectangle on top of the chart. When you mouse move over it, it sends a dispatch -containing the X-coordinate. It can also render a vertical line where the mouse is located. - -dispatch.elementMousemove is the important event to latch onto. It is fired whenever the mouse moves over -the rectangle. The dispatch is given one object which contains the mouseX/Y location. -It also has 'pointXValue', which is the conversion of mouseX to the x-axis scale. -*/ -nv.interactiveGuideline = function() { - "use strict"; - var tooltip = nv.models.tooltip(); - //Public settings - var width = null - , height = null - //Please pass in the bounding chart's top and left margins - //This is important for calculating the correct mouseX/Y positions. - , margin = {left: 0, top: 0} - , xScale = d3.scale.linear() - , yScale = d3.scale.linear() - , dispatch = d3.dispatch('elementMousemove', 'elementMouseout','elementDblclick') - , showGuideLine = true - , svgContainer = null - //Must pass in the bounding chart's container. - //The mousemove event is attached to this container. - ; - - //Private variables - var isMSIE = navigator.userAgent.indexOf("MSIE") !== -1 //Check user-agent for Microsoft Internet Explorer. - ; - - - function layer(selection) { - selection.each(function(data) { - var container = d3.select(this); - - var availableWidth = (width || 960), availableHeight = (height || 400); - - var wrap = container.selectAll("g.nv-wrap.nv-interactiveLineLayer").data([data]); - var wrapEnter = wrap.enter() - .append("g").attr("class", " nv-wrap nv-interactiveLineLayer"); - - - wrapEnter.append("g").attr("class","nv-interactiveGuideLine"); - - if (!svgContainer) { - return; - } - - function mouseHandler() { - var d3mouse = d3.mouse(this); - var mouseX = d3mouse[0]; - var mouseY = d3mouse[1]; - var subtractMargin = true; - var mouseOutAnyReason = false; - if (isMSIE) { - /* - D3.js (or maybe SVG.getScreenCTM) has a nasty bug in Internet Explorer 10. - d3.mouse() returns incorrect X,Y mouse coordinates when mouse moving - over a rect in IE 10. - However, d3.event.offsetX/Y also returns the mouse coordinates - relative to the triggering . So we use offsetX/Y on IE. - */ - mouseX = d3.event.offsetX; - mouseY = d3.event.offsetY; - - /* - On IE, if you attach a mouse event listener to the container, - it will actually trigger it for all the child elements (like , , etc). - When this happens on IE, the offsetX/Y is set to where ever the child element - is located. - As a result, we do NOT need to subtract margins to figure out the mouse X/Y - position under this scenario. Removing the line below *will* cause - the interactive layer to not work right on IE. - */ - if(d3.event.target.tagName !== "svg") - subtractMargin = false; - - if (d3.event.target.className.baseVal.match("nv-legend")) - mouseOutAnyReason = true; - - } - - if(subtractMargin) { - mouseX -= margin.left; - mouseY -= margin.top; - } - - /* If mouseX/Y is outside of the chart's bounds, - trigger a mouseOut event. - */ - if (mouseX < 0 || mouseY < 0 - || mouseX > availableWidth || mouseY > availableHeight - || (d3.event.relatedTarget && d3.event.relatedTarget.ownerSVGElement === undefined) - || mouseOutAnyReason - ) - { - if (isMSIE) { - if (d3.event.relatedTarget - && d3.event.relatedTarget.ownerSVGElement === undefined - && d3.event.relatedTarget.className.match(tooltip.nvPointerEventsClass)) { - return; - } - } - dispatch.elementMouseout({ - mouseX: mouseX, - mouseY: mouseY - }); - layer.renderGuideLine(null); //hide the guideline - return; - } - - var pointXValue = xScale.invert(mouseX); - dispatch.elementMousemove({ - mouseX: mouseX, - mouseY: mouseY, - pointXValue: pointXValue - }); - - //If user double clicks the layer, fire a elementDblclick dispatch. - if (d3.event.type === "dblclick") { - dispatch.elementDblclick({ - mouseX: mouseX, - mouseY: mouseY, - pointXValue: pointXValue - }); - } - } - - svgContainer - .on("mousemove",mouseHandler, true) - .on("mouseout" ,mouseHandler,true) - .on("dblclick" ,mouseHandler) - ; - - //Draws a vertical guideline at the given X postion. - layer.renderGuideLine = function(x) { - if (!showGuideLine) return; - var line = wrap.select(".nv-interactiveGuideLine") - .selectAll("line") - .data((x != null) ? [nv.utils.NaNtoZero(x)] : [], String); - - line.enter() - .append("line") - .attr("class", "nv-guideline") - .attr("x1", function(d) { return d;}) - .attr("x2", function(d) { return d;}) - .attr("y1", availableHeight) - .attr("y2",0) - ; - line.exit().remove(); - - } - }); - } - - layer.dispatch = dispatch; - layer.tooltip = tooltip; - - layer.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return layer; - }; - - layer.width = function(_) { - if (!arguments.length) return width; - width = _; - return layer; - }; - - layer.height = function(_) { - if (!arguments.length) return height; - height = _; - return layer; - }; - - layer.xScale = function(_) { - if (!arguments.length) return xScale; - xScale = _; - return layer; - }; - - layer.showGuideLine = function(_) { - if (!arguments.length) return showGuideLine; - showGuideLine = _; - return layer; - }; - - layer.svgContainer = function(_) { - if (!arguments.length) return svgContainer; - svgContainer = _; - return layer; - }; - - - return layer; -}; - -/* Utility class that uses d3.bisect to find the index in a given array, where a search value can be inserted. -This is different from normal bisectLeft; this function finds the nearest index to insert the search value. - -For instance, lets say your array is [1,2,3,5,10,30], and you search for 28. -Normal d3.bisectLeft will return 4, because 28 is inserted after the number 10. But interactiveBisect will return 5 -because 28 is closer to 30 than 10. - -Unit tests can be found in: interactiveBisectTest.html - -Has the following known issues: - * Will not work if the data points move backwards (ie, 10,9,8,7, etc) or if the data points are in random order. - * Won't work if there are duplicate x coordinate values. -*/ -nv.interactiveBisect = function (values, searchVal, xAccessor) { - "use strict"; - if (! values instanceof Array) return null; - if (typeof xAccessor !== 'function') xAccessor = function(d,i) { return d.x;} - - var bisect = d3.bisector(xAccessor).left; - var index = d3.max([0, bisect(values,searchVal) - 1]); - var currentValue = xAccessor(values[index], index); - if (typeof currentValue === 'undefined') currentValue = index; - - if (currentValue === searchVal) return index; //found exact match - - var nextIndex = d3.min([index+1, values.length - 1]); - var nextValue = xAccessor(values[nextIndex], nextIndex); - if (typeof nextValue === 'undefined') nextValue = nextIndex; - - if (Math.abs(nextValue - searchVal) >= Math.abs(currentValue - searchVal)) - return index; - else - return nextIndex -}; - -/* -Returns the index in the array "values" that is closest to searchVal. -Only returns an index if searchVal is within some "threshold". -Otherwise, returns null. -*/ -nv.nearestValueIndex = function (values, searchVal, threshold) { - "use strict"; - var yDistMax = Infinity, indexToHighlight = null; - values.forEach(function(d,i) { - var delta = Math.abs(searchVal - d); - if ( delta <= yDistMax && delta < threshold) { - yDistMax = delta; - indexToHighlight = i; - } - }); - return indexToHighlight; -}; \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/src/intro.js b/awx/ui/static/lib/novus-nvd3/src/intro.js deleted file mode 100755 index af50383ec5..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/intro.js +++ /dev/null @@ -1 +0,0 @@ -(function(){ diff --git a/awx/ui/static/lib/novus-nvd3/src/models/axis.js b/awx/ui/static/lib/novus-nvd3/src/models/axis.js deleted file mode 100755 index 37677640db..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/axis.js +++ /dev/null @@ -1,405 +0,0 @@ -nv.models.axis = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var axis = d3.svg.axis() - ; - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 75 //only used for tickLabel currently - , height = 60 //only used for tickLabel currently - , scale = d3.scale.linear() - , axisLabelText = null - , showMaxMin = true //TODO: showMaxMin should be disabled on all ordinal scaled axes - , highlightZero = true - , rotateLabels = 0 - , rotateYLabel = true - , staggerLabels = false - , isOrdinal = false - , ticks = null - , axisLabelDistance = 12 //The larger this number is, the closer the axis label is to the axis. - ; - - axis - .scale(scale) - .orient('bottom') - .tickFormat(function(d) { return d }) - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var scale0; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-axis').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-axis'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - //------------------------------------------------------------ - - - if (ticks !== null) - axis.ticks(ticks); - else if (axis.orient() == 'top' || axis.orient() == 'bottom') - axis.ticks(Math.abs(scale.range()[1] - scale.range()[0]) / 100); - - - //TODO: consider calculating width/height based on whether or not label is added, for reference in charts using this component - - - g.transition().call(axis); - - scale0 = scale0 || axis.scale(); - - var fmt = axis.tickFormat(); - if (fmt == null) { - fmt = scale0.tickFormat(); - } - - var axisLabel = g.selectAll('text.nv-axislabel') - .data([axisLabelText || null]); - axisLabel.exit().remove(); - switch (axis.orient()) { - case 'top': - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - var w = (scale.range().length==2) ? scale.range()[1] : (scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0])); - axisLabel - .attr('text-anchor', 'middle') - .attr('y', 0) - .attr('x', w/2); - if (showMaxMin) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - .data(scale.domain()); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text'); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(' + scale(d) + ',0)' - }) - .select('text') - .attr('dy', '-0.5em') - .attr('y', -axis.tickPadding()) - .attr('text-anchor', 'middle') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - return 'translate(' + scale.range()[i] + ',0)' - }); - } - break; - case 'bottom': - var xLabelMargin = 36; - var maxTextWidth = 30; - var xTicks = g.selectAll('g').select("text"); - if (rotateLabels%360) { - //Calculate the longest xTick width - xTicks.each(function(d,i){ - var width = this.getBBox().width; - if(width > maxTextWidth) maxTextWidth = width; - }); - //Convert to radians before calculating sin. Add 30 to margin for healthy padding. - var sin = Math.abs(Math.sin(rotateLabels*Math.PI/180)); - var xLabelMargin = (sin ? sin*maxTextWidth : maxTextWidth)+30; - //Rotate all xTicks - xTicks - .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' }) - .style('text-anchor', rotateLabels%360 > 0 ? 'start' : 'end'); - } - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - var w = (scale.range().length==2) ? scale.range()[1] : (scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0])); - axisLabel - .attr('text-anchor', 'middle') - .attr('y', xLabelMargin) - .attr('x', w/2); - if (showMaxMin) { - //if (showMaxMin && !isOrdinal) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - //.data(scale.domain()) - .data([scale.domain()[0], scale.domain()[scale.domain().length - 1]]); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text'); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(' + (scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0)) + ',0)' - }) - .select('text') - .attr('dy', '.71em') - .attr('y', axis.tickPadding()) - .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' }) - .style('text-anchor', rotateLabels ? (rotateLabels%360 > 0 ? 'start' : 'end') : 'middle') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - //return 'translate(' + scale.range()[i] + ',0)' - //return 'translate(' + scale(d) + ',0)' - return 'translate(' + (scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0)) + ',0)' - }); - } - if (staggerLabels) - xTicks - .attr('transform', function(d,i) { return 'translate(0,' + (i % 2 == 0 ? '0' : '12') + ')' }); - - break; - case 'right': - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - axisLabel - .style('text-anchor', rotateYLabel ? 'middle' : 'begin') - .attr('transform', rotateYLabel ? 'rotate(90)' : '') - .attr('y', rotateYLabel ? (-Math.max(margin.right,width) + 12) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart - .attr('x', rotateYLabel ? (scale.range()[0] / 2) : axis.tickPadding()); - if (showMaxMin) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - .data(scale.domain()); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text') - .style('opacity', 0); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(0,' + scale(d) + ')' - }) - .select('text') - .attr('dy', '.32em') - .attr('y', 0) - .attr('x', axis.tickPadding()) - .style('text-anchor', 'start') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - return 'translate(0,' + scale.range()[i] + ')' - }) - .select('text') - .style('opacity', 1); - } - break; - case 'left': - /* - //For dynamically placing the label. Can be used with dynamically-sized chart axis margins - var yTicks = g.selectAll('g').select("text"); - yTicks.each(function(d,i){ - var labelPadding = this.getBBox().width + axis.tickPadding() + 16; - if(labelPadding > width) width = labelPadding; - }); - */ - axisLabel.enter().append('text').attr('class', 'nv-axislabel'); - axisLabel - .style('text-anchor', rotateYLabel ? 'middle' : 'end') - .attr('transform', rotateYLabel ? 'rotate(-90)' : '') - .attr('y', rotateYLabel ? (-Math.max(margin.left,width) + axisLabelDistance) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart - .attr('x', rotateYLabel ? (-scale.range()[0] / 2) : -axis.tickPadding()); - if (showMaxMin) { - var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') - .data(scale.domain()); - axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text') - .style('opacity', 0); - axisMaxMin.exit().remove(); - axisMaxMin - .attr('transform', function(d,i) { - return 'translate(0,' + scale0(d) + ')' - }) - .select('text') - .attr('dy', '.32em') - .attr('y', 0) - .attr('x', -axis.tickPadding()) - .attr('text-anchor', 'end') - .text(function(d,i) { - var v = fmt(d); - return ('' + v).match('NaN') ? '' : v; - }); - axisMaxMin.transition() - .attr('transform', function(d,i) { - return 'translate(0,' + scale.range()[i] + ')' - }) - .select('text') - .style('opacity', 1); - } - break; - } - axisLabel - .text(function(d) { return d }); - - - if (showMaxMin && (axis.orient() === 'left' || axis.orient() === 'right')) { - //check if max and min overlap other values, if so, hide the values that overlap - g.selectAll('g') // the g's wrapping each tick - .each(function(d,i) { - d3.select(this).select('text').attr('opacity', 1); - if (scale(d) < scale.range()[1] + 10 || scale(d) > scale.range()[0] - 10) { // 10 is assuming text height is 16... if d is 0, leave it! - if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL - d3.select(this).attr('opacity', 0); - - d3.select(this).select('text').attr('opacity', 0); // Don't remove the ZERO line!! - } - }); - - //if Max and Min = 0 only show min, Issue #281 - if (scale.domain()[0] == scale.domain()[1] && scale.domain()[0] == 0) - wrap.selectAll('g.nv-axisMaxMin') - .style('opacity', function(d,i) { return !i ? 1 : 0 }); - - } - - if (showMaxMin && (axis.orient() === 'top' || axis.orient() === 'bottom')) { - var maxMinRange = []; - wrap.selectAll('g.nv-axisMaxMin') - .each(function(d,i) { - try { - if (i) // i== 1, max position - maxMinRange.push(scale(d) - this.getBBox().width - 4) //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case) - else // i==0, min position - maxMinRange.push(scale(d) + this.getBBox().width + 4) - }catch (err) { - if (i) // i== 1, max position - maxMinRange.push(scale(d) - 4) //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case) - else // i==0, min position - maxMinRange.push(scale(d) + 4) - } - }); - g.selectAll('g') // the g's wrapping each tick - .each(function(d,i) { - if (scale(d) < maxMinRange[0] || scale(d) > maxMinRange[1]) { - if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL - d3.select(this).remove(); - else - d3.select(this).select('text').remove(); // Don't remove the ZERO line!! - } - }); - } - - - //highlight zero line ... Maybe should not be an option and should just be in CSS? - if (highlightZero) - g.selectAll('.tick') - .filter(function(d) { return !parseFloat(Math.round(d.__data__*100000)/1000000) && (d.__data__ !== undefined) }) //this is because sometimes the 0 tick is a very small fraction, TODO: think of cleaner technique - .classed('zero', true); - - //store old scales for use in transitions on update - scale0 = scale.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.axis = axis; - - d3.rebind(chart, axis, 'orient', 'tickValues', 'tickSubdivide', 'tickSize', 'tickPadding', 'tickFormat'); - d3.rebind(chart, scale, 'domain', 'range', 'rangeBand', 'rangeBands'); //these are also accessible by chart.scale(), but added common ones directly for ease of use - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if(!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - } - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.ticks = function(_) { - if (!arguments.length) return ticks; - ticks = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.axisLabel = function(_) { - if (!arguments.length) return axisLabelText; - axisLabelText = _; - return chart; - } - - chart.showMaxMin = function(_) { - if (!arguments.length) return showMaxMin; - showMaxMin = _; - return chart; - } - - chart.highlightZero = function(_) { - if (!arguments.length) return highlightZero; - highlightZero = _; - return chart; - } - - chart.scale = function(_) { - if (!arguments.length) return scale; - scale = _; - axis.scale(scale); - isOrdinal = typeof scale.rangeBands === 'function'; - d3.rebind(chart, scale, 'domain', 'range', 'rangeBand', 'rangeBands'); - return chart; - } - - chart.rotateYLabel = function(_) { - if(!arguments.length) return rotateYLabel; - rotateYLabel = _; - return chart; - } - - chart.rotateLabels = function(_) { - if(!arguments.length) return rotateLabels; - rotateLabels = _; - return chart; - } - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - chart.axisLabelDistance = function(_) { - if (!arguments.length) return axisLabelDistance; - axisLabelDistance = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/backup/bullet.js b/awx/ui/static/lib/novus-nvd3/src/models/backup/bullet.js deleted file mode 100755 index 86ebeb0f19..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/backup/bullet.js +++ /dev/null @@ -1,250 +0,0 @@ - -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ - -nv.models.bullet = function() { - - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , orient = 'left' // TODO top & bottom - , reverse = false - , ranges = function(d) { return d.ranges } - , markers = function(d) { return d.markers } - , measures = function(d) { return d.measures } - , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) - , width = 380 - , height = 30 - , tickFormat = null - , dispatch = d3.dispatch('elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(d, i) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this), - mainGroup = nv.log(this.parentNode.parentNode).getAttribute('transform'), - heightFromTop = nv.log(parseInt(mainGroup.replace(/.*,(\d+)\)/,"$1"))); //TODO: There should be a smarter way to get this value - - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending); - - - //------------------------------------------------------------ - // Setup Scales - - // Compute the new x-scale. - var MaxX = Math.max(rangez[0] ? rangez[0]:0 , markerz[0] ? markerz[0] : 0 , measurez[0] ? measurez[0] : 0) - var x1 = d3.scale.linear() - .domain([0, MaxX]).nice() // TODO: need to allow forceX and forceY, and xDomain, yDomain - .range(reverse ? [availableWidth, 0] : [0, availableWidth]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - - - // Update the range rects. - var range = g.selectAll('rect.nv-range') - .data(rangez); - - range.enter().append('rect') - .attr('class', function(d, i) { return 'nv-range nv-s' + i; }) - .attr('width', w0) - .attr('height', availableHeight) - .attr('x', reverse ? x0 : 0) - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: (i <= 0) ? 'Maximum' : (i > 1) ? 'Minimum' : 'Mean', //TODO: make these labels a variable - pos: [x1(d), heightFromTop] - }) - }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: (i <= 0) ? 'Minimum' : (i >=1) ? 'Maximum' : 'Mean' //TODO: make these labels a variable - }) - }) - - d3.transition(range) - .attr('x', reverse ? x1 : 0) - .attr('width', w1) - .attr('height', availableHeight); - - - // Update the measure rects. - var measure = g.selectAll('rect.nv-measure') - .data(measurez); - - measure.enter().append('rect') - .attr('class', function(d, i) { return 'nv-measure nv-s' + i; }) - .attr('width', w0) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x0 : 0) - .attr('y', availableHeight / 3) - .on('mouseover', function(d) { - dispatch.elementMouseover({ - value: d, - label: 'Current', //TODO: make these labels a variable - pos: [x1(d), heightFromTop] - }) - }) - .on('mouseout', function(d) { - dispatch.elementMouseout({ - value: d, - label: 'Current' //TODO: make these labels a variable - }) - }) - - d3.transition(measure) - .attr('width', w1) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x1 : 0) - .attr('y', availableHeight / 3); - - - - // Update the marker lines. - var marker = g.selectAll('path.nv-markerTriangle') - .data(markerz); - - var h3 = availableHeight / 6; - marker.enter().append('path') - .attr('class', 'nv-markerTriangle') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',' + (availableHeight / 2) + ')' }) - .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: 'Previous', - pos: [x1(d), heightFromTop] - }) - }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: 'Previous' - }) - }); - - d3.transition(marker) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',' + (availableHeight / 2) + ')' }); - - marker.exit().remove(); - - }); - - d3.timer.flush(); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - // left, right, top, bottom - chart.orient = function(_) { - if (!arguments.length) return orient; - orient = _; - reverse = orient == 'right' || orient == 'bottom'; - return chart; - }; - - // ranges (bad, satisfactory, good) - chart.ranges = function(_) { - if (!arguments.length) return ranges; - ranges = _; - return chart; - }; - - // markers (previous, goal) - chart.markers = function(_) { - if (!arguments.length) return markers; - markers = _; - return chart; - }; - - // measures (actual, forecast) - chart.measures = function(_) { - if (!arguments.length) return measures; - measures = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.tickFormat = function(_) { - if (!arguments.length) return tickFormat; - tickFormat = _; - return chart; - }; - - //============================================================ - - - return chart; -}; - - diff --git a/awx/ui/static/lib/novus-nvd3/src/models/backup/bulletChart.js b/awx/ui/static/lib/novus-nvd3/src/models/backup/bulletChart.js deleted file mode 100755 index a2a0f077cc..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/backup/bulletChart.js +++ /dev/null @@ -1,349 +0,0 @@ - -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ -nv.models.bulletChart = function() { - - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var bullet = nv.models.bullet() - ; - - var orient = 'left' // TODO top & bottom - , reverse = false - , margin = {top: 5, right: 40, bottom: 20, left: 120} - , ranges = function(d) { return d.ranges } - , markers = function(d) { return d.markers } - , measures = function(d) { return d.measures } - , width = null - , height = 55 - , tickFormat = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + e.label + '

' + - '

' + e.value + '

' - } - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, parentElement) { - var offsetElement = parentElement.parentNode.parentNode, - left = e.pos[0] + offsetElement.offsetLeft + margin.left, - top = e.pos[1] + offsetElement.offsetTop + margin.top; - - var content = '

' + e.label + '

' + - '

' + e.value + '

'; - - nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement.parentNode); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(d, i) { - var container = d3.select(this); - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - that = this; - - - chart.update = function() { chart(selection) }; - chart.container = this; - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - /* - // Disabled until I figure out a better way to check for no data with the bullet chart - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - */ - - //------------------------------------------------------------ - - - - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-bulletWrap'); - gEnter.append('g').attr('class', 'nv-titles'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + ( margin.top + i*height )+ ')'); - - //------------------------------------------------------------ - - - // Compute the new x-scale. - var MaxX = Math.max(rangez[0] ? rangez[0]:0 , markerz[0] ? markerz[0] : 0 , measurez[0] ? measurez[0] : 0) - var x1 = d3.scale.linear() - .domain([0, MaxX]).nice() // TODO: need to allow forceX and forceY, and xDomain, yDomain - .range(reverse ? [availableWidth, 0] : [0, availableWidth]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - /* - // Derive width-scales from the x-scales. - var w0 = bulletWidth(x0), - w1 = bulletWidth(x1); - - function bulletWidth(x) { - var x0 = x(0); - return function(d) { - return Math.abs(x(d) - x(0)); - }; - } - - function bulletTranslate(x) { - return function(d) { - return 'translate(' + x(d) + ',0)'; - }; - } - */ - - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - - - var title = gEnter.select('.nv-titles').append("g") - .attr("text-anchor", "end") - .attr("transform", "translate(-6," + (height - margin.top - margin.bottom) / 2 + ")"); - title.append("text") - .attr("class", "nv-title") - .text(function(d) { return d.title; }); - - title.append("text") - .attr("class", "nv-subtitle") - .attr("dy", "1em") - .text(function(d) { return d.subtitle; }); - - - - bullet - .width(availableWidth) - .height(availableHeight) - - var bulletWrap = g.select('.nv-bulletWrap'); - - d3.transition(bulletWrap).call(bullet); - - - - // Compute the tick format. - var format = tickFormat || x1.tickFormat(8); - - // Update the tick groups. - var tick = g.selectAll('g.nv-tick') - .data(x1.ticks(8), function(d) { - return this.textContent || format(d); - }); - - // Initialize the ticks with the old scale, x0. - var tickEnter = tick.enter().append('g') - .attr('class', 'nv-tick') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' }) - .style('opacity', 1e-6); - - tickEnter.append('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); - - tickEnter.append('text') - .attr('text-anchor', 'middle') - .attr('dy', '1em') - .attr('y', availableHeight * 7 / 6) - .text(format); - - // Transition the entering ticks to the new scale, x1. - d3.transition(tickEnter) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1); - - // Transition the updating ticks to the new scale, x1. - var tickUpdate = d3.transition(tick) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1); - - tickUpdate.select('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); - - tickUpdate.select('text') - .attr('y', availableHeight * 7 / 6); - - // Transition the exiting ticks to the new scale, x1. - d3.transition(tick.exit()) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1e-6) - .remove(); - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - }); - - d3.timer.flush(); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - bullet.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow(e); - }); - - bullet.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.bullet = bullet; - - // left, right, top, bottom - chart.orient = function(x) { - if (!arguments.length) return orient; - orient = x; - reverse = orient == 'right' || orient == 'bottom'; - return chart; - }; - - // ranges (bad, satisfactory, good) - chart.ranges = function(x) { - if (!arguments.length) return ranges; - ranges = x; - return chart; - }; - - // markers (previous, goal) - chart.markers = function(x) { - if (!arguments.length) return markers; - markers = x; - return chart; - }; - - // measures (actual, forecast) - chart.measures = function(x) { - if (!arguments.length) return measures; - measures = x; - return chart; - }; - - chart.width = function(x) { - if (!arguments.length) return width; - width = x; - return chart; - }; - - chart.height = function(x) { - if (!arguments.length) return height; - height = x; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.tickFormat = function(x) { - if (!arguments.length) return tickFormat; - tickFormat = x; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -}; - - diff --git a/awx/ui/static/lib/novus-nvd3/src/models/boilerplate.js b/awx/ui/static/lib/novus-nvd3/src/models/boilerplate.js deleted file mode 100755 index 3d2360a6c2..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/boilerplate.js +++ /dev/null @@ -1,104 +0,0 @@ - -nv.models.chartName = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - - var margin = {top: 30, right: 10, bottom: 10, left: 10} - , width = 960 - , height = 500 - , color = nv.utils.getColor(d3.scale.category20c().range()) - , dispatch = d3.dispatch('stateChange', 'changeState') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-chartName').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-chartName'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - gEnter.append('g').attr('class', 'nv-mainWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_) - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/bullet.js b/awx/ui/static/lib/novus-nvd3/src/models/bullet.js deleted file mode 100755 index 9b9bf4d19c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/bullet.js +++ /dev/null @@ -1,385 +0,0 @@ - -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ - -nv.models.bullet = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , orient = 'left' // TODO top & bottom - , reverse = false - , ranges = function(d) { return d.ranges } - , markers = function(d) { return d.markers } - , measures = function(d) { return d.measures } - , rangeLabels = function(d) { return d.rangeLabels ? d.rangeLabels : [] } - , markerLabels = function(d) { return d.markerLabels ? d.markerLabels : [] } - , measureLabels = function(d) { return d.measureLabels ? d.measureLabels : [] } - , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) - , width = 380 - , height = 30 - , tickFormat = null - , color = nv.utils.getColor(['#1f77b4']) - , dispatch = d3.dispatch('elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(d, i) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending), - rangeLabelz = rangeLabels.call(this, d, i).slice(), - markerLabelz = markerLabels.call(this, d, i).slice(), - measureLabelz = measureLabels.call(this, d, i).slice(); - - - //------------------------------------------------------------ - // Setup Scales - - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain( d3.extent(d3.merge([forceX, rangez])) ) - .range(reverse ? [availableWidth, 0] : [0, availableWidth]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - - var rangeMin = d3.min(rangez), //rangez[2] - rangeMax = d3.max(rangez), //rangez[0] - rangeAvg = rangez[1]; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('rect').attr('class', 'nv-range nv-rangeMax'); - gEnter.append('rect').attr('class', 'nv-range nv-rangeAvg'); - gEnter.append('rect').attr('class', 'nv-range nv-rangeMin'); - gEnter.append('rect').attr('class', 'nv-measure'); - gEnter.append('path').attr('class', 'nv-markerTriangle'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - var xp0 = function(d) { return d < 0 ? x0(d) : x0(0) }, - xp1 = function(d) { return d < 0 ? x1(d) : x1(0) }; - - - g.select('rect.nv-rangeMax') - .attr('height', availableHeight) - .attr('width', w1(rangeMax > 0 ? rangeMax : rangeMin)) - .attr('x', xp1(rangeMax > 0 ? rangeMax : rangeMin)) - .datum(rangeMax > 0 ? rangeMax : rangeMin) - /* - .attr('x', rangeMin < 0 ? - rangeMax > 0 ? - x1(rangeMin) - : x1(rangeMax) - : x1(0)) - */ - - g.select('rect.nv-rangeAvg') - .attr('height', availableHeight) - .attr('width', w1(rangeAvg)) - .attr('x', xp1(rangeAvg)) - .datum(rangeAvg) - /* - .attr('width', rangeMax <= 0 ? - x1(rangeMax) - x1(rangeAvg) - : x1(rangeAvg) - x1(rangeMin)) - .attr('x', rangeMax <= 0 ? - x1(rangeAvg) - : x1(rangeMin)) - */ - - g.select('rect.nv-rangeMin') - .attr('height', availableHeight) - .attr('width', w1(rangeMax)) - .attr('x', xp1(rangeMax)) - .attr('width', w1(rangeMax > 0 ? rangeMin : rangeMax)) - .attr('x', xp1(rangeMax > 0 ? rangeMin : rangeMax)) - .datum(rangeMax > 0 ? rangeMin : rangeMax) - /* - .attr('width', rangeMax <= 0 ? - x1(rangeAvg) - x1(rangeMin) - : x1(rangeMax) - x1(rangeAvg)) - .attr('x', rangeMax <= 0 ? - x1(rangeMin) - : x1(rangeAvg)) - */ - - g.select('rect.nv-measure') - .style('fill', color) - .attr('height', availableHeight / 3) - .attr('y', availableHeight / 3) - .attr('width', measurez < 0 ? - x1(0) - x1(measurez[0]) - : x1(measurez[0]) - x1(0)) - .attr('x', xp1(measurez)) - .on('mouseover', function() { - dispatch.elementMouseover({ - value: measurez[0], - label: measureLabelz[0] || 'Current', - pos: [x1(measurez[0]), availableHeight/2] - }) - }) - .on('mouseout', function() { - dispatch.elementMouseout({ - value: measurez[0], - label: measureLabelz[0] || 'Current' - }) - }) - - var h3 = availableHeight / 6; - if (markerz[0]) { - g.selectAll('path.nv-markerTriangle') - .attr('transform', function(d) { return 'translate(' + x1(markerz[0]) + ',' + (availableHeight / 2) + ')' }) - .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') - .on('mouseover', function() { - dispatch.elementMouseover({ - value: markerz[0], - label: markerLabelz[0] || 'Previous', - pos: [x1(markerz[0]), availableHeight/2] - }) - }) - .on('mouseout', function() { - dispatch.elementMouseout({ - value: markerz[0], - label: markerLabelz[0] || 'Previous' - }) - }); - } else { - g.selectAll('path.nv-markerTriangle').remove(); - } - - - wrap.selectAll('.nv-range') - .on('mouseover', function(d,i) { - var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); - - dispatch.elementMouseover({ - value: d, - label: label, - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d,i) { - var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); - - dispatch.elementMouseout({ - value: d, - label: label - }) - }) - -/* // THIS IS THE PREVIOUS BULLET IMPLEMENTATION, WILL REMOVE SHORTLY - // Update the range rects. - var range = g.selectAll('rect.nv-range') - .data(rangez); - - range.enter().append('rect') - .attr('class', function(d, i) { return 'nv-range nv-s' + i; }) - .attr('width', w0) - .attr('height', availableHeight) - .attr('x', reverse ? x0 : 0) - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: (i <= 0) ? 'Maximum' : (i > 1) ? 'Minimum' : 'Mean', //TODO: make these labels a variable - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: (i <= 0) ? 'Minimum' : (i >=1) ? 'Maximum' : 'Mean' //TODO: make these labels a variable - }) - }) - - d3.transition(range) - .attr('x', reverse ? x1 : 0) - .attr('width', w1) - .attr('height', availableHeight); - - - // Update the measure rects. - var measure = g.selectAll('rect.nv-measure') - .data(measurez); - - measure.enter().append('rect') - .attr('class', function(d, i) { return 'nv-measure nv-s' + i; }) - .style('fill', function(d,i) { return color(d,i ) }) - .attr('width', w0) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x0 : 0) - .attr('y', availableHeight / 3) - .on('mouseover', function(d) { - dispatch.elementMouseover({ - value: d, - label: 'Current', //TODO: make these labels a variable - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d) { - dispatch.elementMouseout({ - value: d, - label: 'Current' //TODO: make these labels a variable - }) - }) - - d3.transition(measure) - .attr('width', w1) - .attr('height', availableHeight / 3) - .attr('x', reverse ? x1 : 0) - .attr('y', availableHeight / 3); - - - - // Update the marker lines. - var marker = g.selectAll('path.nv-markerTriangle') - .data(markerz); - - var h3 = availableHeight / 6; - marker.enter().append('path') - .attr('class', 'nv-markerTriangle') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',' + (availableHeight / 2) + ')' }) - .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') - .on('mouseover', function(d,i) { - dispatch.elementMouseover({ - value: d, - label: 'Previous', - pos: [x1(d), availableHeight/2] - }) - }) - .on('mouseout', function(d,i) { - dispatch.elementMouseout({ - value: d, - label: 'Previous' - }) - }); - - d3.transition(marker) - .attr('transform', function(d) { return 'translate(' + (x1(d) - x1(0)) + ',' + (availableHeight / 2) + ')' }); - - marker.exit().remove(); -*/ - - }); - - // d3.timer.flush(); // Not needed? - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - // left, right, top, bottom - chart.orient = function(_) { - if (!arguments.length) return orient; - orient = _; - reverse = orient == 'right' || orient == 'bottom'; - return chart; - }; - - // ranges (bad, satisfactory, good) - chart.ranges = function(_) { - if (!arguments.length) return ranges; - ranges = _; - return chart; - }; - - // markers (previous, goal) - chart.markers = function(_) { - if (!arguments.length) return markers; - markers = _; - return chart; - }; - - // measures (actual, forecast) - chart.measures = function(_) { - if (!arguments.length) return measures; - measures = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.tickFormat = function(_) { - if (!arguments.length) return tickFormat; - tickFormat = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - //============================================================ - - - return chart; -}; - - diff --git a/awx/ui/static/lib/novus-nvd3/src/models/bulletChart.js b/awx/ui/static/lib/novus-nvd3/src/models/bulletChart.js deleted file mode 100755 index fa5bd5967d..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/bulletChart.js +++ /dev/null @@ -1,343 +0,0 @@ - -// Chart design based on the recommendations of Stephen Few. Implementation -// based on the work of Clint Ivy, Jamie Love, and Jason Davies. -// http://projects.instantcognition.com/protovis/bulletchart/ -nv.models.bulletChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var bullet = nv.models.bullet() - ; - - var orient = 'left' // TODO top & bottom - , reverse = false - , margin = {top: 5, right: 40, bottom: 20, left: 120} - , ranges = function(d) { return d.ranges } - , markers = function(d) { return d.markers } - , measures = function(d) { return d.measures } - , width = null - , height = 55 - , tickFormat = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' - } - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left, - top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top, - content = tooltip(e.key, e.label, e.value, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(d, i) { - var container = d3.select(this); - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - that = this; - - - chart.update = function() { chart(selection) }; - chart.container = this; - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!d || !ranges.call(this, d, i)) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', 18 + margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - - var rangez = ranges.call(this, d, i).slice().sort(d3.descending), - markerz = markers.call(this, d, i).slice().sort(d3.descending), - measurez = measures.call(this, d, i).slice().sort(d3.descending); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-bulletWrap'); - gEnter.append('g').attr('class', 'nv-titles'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - // Compute the new x-scale. - var x1 = d3.scale.linear() - .domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) // TODO: need to allow forceX and forceY, and xDomain, yDomain - .range(reverse ? [availableWidth, 0] : [0, availableWidth]); - - // Retrieve the old x-scale, if this is an update. - var x0 = this.__chart__ || d3.scale.linear() - .domain([0, Infinity]) - .range(x1.range()); - - // Stash the new scale. - this.__chart__ = x1; - - /* - // Derive width-scales from the x-scales. - var w0 = bulletWidth(x0), - w1 = bulletWidth(x1); - - function bulletWidth(x) { - var x0 = x(0); - return function(d) { - return Math.abs(x(d) - x(0)); - }; - } - - function bulletTranslate(x) { - return function(d) { - return 'translate(' + x(d) + ',0)'; - }; - } - */ - - var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) - w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; - - - var title = gEnter.select('.nv-titles').append('g') - .attr('text-anchor', 'end') - .attr('transform', 'translate(-6,' + (height - margin.top - margin.bottom) / 2 + ')'); - title.append('text') - .attr('class', 'nv-title') - .text(function(d) { return d.title; }); - - title.append('text') - .attr('class', 'nv-subtitle') - .attr('dy', '1em') - .text(function(d) { return d.subtitle; }); - - - - bullet - .width(availableWidth) - .height(availableHeight) - - var bulletWrap = g.select('.nv-bulletWrap'); - - d3.transition(bulletWrap).call(bullet); - - - - // Compute the tick format. - var format = tickFormat || x1.tickFormat( availableWidth / 100 ); - - // Update the tick groups. - var tick = g.selectAll('g.nv-tick') - .data(x1.ticks( availableWidth / 50 ), function(d) { - return this.textContent || format(d); - }); - - // Initialize the ticks with the old scale, x0. - var tickEnter = tick.enter().append('g') - .attr('class', 'nv-tick') - .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' }) - .style('opacity', 1e-6); - - tickEnter.append('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); - - tickEnter.append('text') - .attr('text-anchor', 'middle') - .attr('dy', '1em') - .attr('y', availableHeight * 7 / 6) - .text(format); - - - // Transition the updating ticks to the new scale, x1. - var tickUpdate = d3.transition(tick) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1); - - tickUpdate.select('line') - .attr('y1', availableHeight) - .attr('y2', availableHeight * 7 / 6); - - tickUpdate.select('text') - .attr('y', availableHeight * 7 / 6); - - // Transition the exiting ticks to the new scale, x1. - d3.transition(tick.exit()) - .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) - .style('opacity', 1e-6) - .remove(); - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - dispatch.on('tooltipShow', function(e) { - e.key = d.title; - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - }); - - d3.timer.flush(); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - bullet.dispatch.on('elementMouseover.tooltip', function(e) { - dispatch.tooltipShow(e); - }); - - bullet.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.bullet = bullet; - - d3.rebind(chart, bullet, 'color'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - // left, right, top, bottom - chart.orient = function(x) { - if (!arguments.length) return orient; - orient = x; - reverse = orient == 'right' || orient == 'bottom'; - return chart; - }; - - // ranges (bad, satisfactory, good) - chart.ranges = function(x) { - if (!arguments.length) return ranges; - ranges = x; - return chart; - }; - - // markers (previous, goal) - chart.markers = function(x) { - if (!arguments.length) return markers; - markers = x; - return chart; - }; - - // measures (actual, forecast) - chart.measures = function(x) { - if (!arguments.length) return measures; - measures = x; - return chart; - }; - - chart.width = function(x) { - if (!arguments.length) return width; - width = x; - return chart; - }; - - chart.height = function(x) { - if (!arguments.length) return height; - height = x; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.tickFormat = function(x) { - if (!arguments.length) return tickFormat; - tickFormat = x; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -}; - - diff --git a/awx/ui/static/lib/novus-nvd3/src/models/cumulativeLineChart.js b/awx/ui/static/lib/novus-nvd3/src/models/cumulativeLineChart.js deleted file mode 100755 index d2de8bbfb8..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/cumulativeLineChart.js +++ /dev/null @@ -1,772 +0,0 @@ - -nv.models.cumulativeLineChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , interactiveLayer = nv.interactiveGuideline() - ; - - var margin = {top: 30, right: 30, bottom: 50, left: 60} - , color = nv.utils.defaultColor() - , width = null - , height = null - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , tooltips = true - , showControls = true - , useInteractiveGuideline = false - , rescaleY = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , id = lines.id() - , state = { index: 0, rescaleY: rescaleY } - , defaultState = null - , noData = 'No Data Available.' - , average = function(d) { return d.average } - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , transitionDuration = 250 - , noErrorCheck = false //if set to TRUE, will bypass an error check in the indexify function. - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - ; - - //============================================================ - controls.updateState(false); - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var dx = d3.scale.linear() - , index = {i: 0, x: 0} - ; - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this).classed('nv-chart-' + id, true), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - var indexDrag = d3.behavior.drag() - .on('dragstart', dragStart) - .on('drag', dragMove) - .on('dragend', dragEnd); - - - function dragStart(d,i) { - d3.select(chart.container) - .style('cursor', 'ew-resize'); - } - - function dragMove(d,i) { - index.x = d3.event.x; - index.i = Math.round(dx.invert(index.x)); - updateZero(); - } - - function dragEnd(d,i) { - d3.select(chart.container) - .style('cursor', 'auto'); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = lines.xScale(); - y = lines.yScale(); - - - if (!rescaleY) { - var seriesDomains = data - .filter(function(series) { return !series.disabled }) - .map(function(series,i) { - var initialDomain = d3.extent(series.values, lines.y()); - - //account for series being disabled when losing 95% or more - if (initialDomain[0] < -.95) initialDomain[0] = -.95; - - return [ - (initialDomain[0] - initialDomain[1]) / (1 + initialDomain[1]), - (initialDomain[1] - initialDomain[0]) / (1 + initialDomain[0]) - ]; - }); - - var completeDomain = [ - d3.min(seriesDomains, function(d) { return d[0] }), - d3.max(seriesDomains, function(d) { return d[1] }) - ] - - lines.yDomain(completeDomain); - } else { - lines.yDomain(null); - } - - - dx .domain([0, data[0].values.length - 1]) //Assumes all series have same length - .range([0, availableWidth]) - .clamp(true); - - //------------------------------------------------------------ - - - var data = indexify(index.i, data); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - var interactivePointerEvents = (useInteractiveGuideline) ? "none" : "all"; - var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-interactive'); - gEnter.append('g').attr('class', 'nv-x nv-axis').style("pointer-events","none"); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-background'); - gEnter.append('g').attr('class', 'nv-linesWrap').style("pointer-events",interactivePointerEvents); - gEnter.append('g').attr('class', 'nv-avgLinesWrap').style("pointer-events","none"); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { key: 'Re-scale y-axis', disabled: !rescaleY } - ]; - - controls - .width(140) - .color(['#444', '#444', '#444']) - .rightAlign(false) - .margin({top: 5, right: 0, bottom: 5, left: 20}) - ; - - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - // Show error if series goes below 100% - var tempDisabled = data.filter(function(d) { return d.tempDisabled }); - - wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates - if (tempDisabled.length) { - wrap.append('text').attr('class', 'tempDisabled') - .attr('x', availableWidth / 2) - .attr('y', '-.71em') - .style('text-anchor', 'end') - .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.'); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - //------------------------------------------------------------ - //Set up interactive layer - if (useInteractiveGuideline) { - interactiveLayer - .width(availableWidth) - .height(availableHeight) - .margin({left:margin.left,top:margin.top}) - .svgContainer(container) - .xScale(x); - wrap.select(".nv-interactive").call(interactiveLayer); - } - - gEnter.select('.nv-background') - .append('rect'); - - g.select('.nv-background rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - lines - //.x(function(d) { return d.x }) - .y(function(d) { return d.display.y }) - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; })); - - - - var linesWrap = g.select('.nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled && !d.tempDisabled })); - - //d3.transition(linesWrap).call(lines); - linesWrap.call(lines); - - /*Handle average lines [AN-612] ----------------------------*/ - - //Store a series index number in the data array. - data.forEach(function(d,i) { - d.seriesIndex = i; - }); - - var avgLineData = data.filter(function(d) { - return !d.disabled && !!average(d); - }); - - var avgLines = g.select(".nv-avgLinesWrap").selectAll("line") - .data(avgLineData, function(d) { return d.key; }); - - var getAvgLineY = function(d) { - //If average lines go off the svg element, clamp them to the svg bounds. - var yVal = y(average(d)); - if (yVal < 0) return 0; - if (yVal > availableHeight) return availableHeight; - return yVal; - }; - - avgLines.enter() - .append('line') - .style('stroke-width',2) - .style('stroke-dasharray','10,10') - .style('stroke',function (d,i) { - return lines.color()(d,d.seriesIndex); - }) - .attr('x1',0) - .attr('x2',availableWidth) - .attr('y1', getAvgLineY) - .attr('y2', getAvgLineY); - - avgLines - .style('stroke-opacity',function(d){ - //If average lines go offscreen, make them transparent - var yVal = y(average(d)); - if (yVal < 0 || yVal > availableHeight) return 0; - return 1; - }) - .attr('x1',0) - .attr('x2',availableWidth) - .attr('y1', getAvgLineY) - .attr('y2', getAvgLineY); - - avgLines.exit().remove(); - - //Create index line ----------------------------------------- - - var indexLine = linesWrap.selectAll('.nv-indexLine') - .data([index]); - indexLine.enter().append('rect').attr('class', 'nv-indexLine') - .attr('width', 3) - .attr('x', -2) - .attr('fill', 'red') - .attr('fill-opacity', .5) - .style("pointer-events","all") - .call(indexDrag) - - indexLine - .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' }) - .attr('height', availableHeight) - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - //Suggest how many ticks based on the chart width and D3 should listen (70 is the optimal number for MM/DD/YY dates) - .ticks( Math.min(data[0].values.length,availableWidth/70) ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - } - - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-y.nv-axis')) - .call(yAxis); - } - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - - function updateZero() { - indexLine - .data([index]); - - //When dragging the index line, turn off line transitions. - // Then turn them back on when done dragging. - var oldDuration = chart.transitionDuration(); - chart.transitionDuration(0); - chart.update(); - chart.transitionDuration(oldDuration); - } - - g.select('.nv-background rect') - .on('click', function() { - index.x = d3.mouse(this)[0]; - index.i = Math.round(dx.invert(index.x)); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - - updateZero(); - }); - - lines.dispatch.on('elementClick', function(e) { - index.i = e.pointIndex; - index.x = dx(index.i); - - // update state and send stateChange with new index - state.index = index.i; - dispatch.stateChange(state); - - updateZero(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - rescaleY = !d.disabled; - - state.rescaleY = rescaleY; - dispatch.stateChange(state); - chart.update(); - }); - - - legend.dispatch.on('stateChange', function(newState) { - state.disabled = newState.disabled; - dispatch.stateChange(state); - chart.update(); - }); - - interactiveLayer.dispatch.on('elementMousemove', function(e) { - lines.clearHighlights(); - var singlePoint, pointIndex, pointXLocation, allData = []; - - - data - .filter(function(series, i) { - series.seriesIndex = i; - return !series.disabled; - }) - .forEach(function(series,i) { - pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); - lines.highlightPoint(i, pointIndex, true); - var point = series.values[pointIndex]; - if (typeof point === 'undefined') return; - if (typeof singlePoint === 'undefined') singlePoint = point; - if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); - allData.push({ - key: series.key, - value: chart.y()(point, pointIndex), - color: color(series,series.seriesIndex) - }); - }); - - //Highlight the tooltip entry based on which point the mouse is closest to. - if (allData.length > 2) { - var yValue = chart.yScale().invert(e.mouseY); - var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); - var threshold = 0.03 * domainExtent; - var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); - if (indexToHighlight !== null) - allData[indexToHighlight].highlight = true; - } - - var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex), pointIndex); - interactiveLayer.tooltip - .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) - .chartContainer(that.parentNode) - .enabled(tooltips) - .valueFormatter(function(d,i) { - return yAxis.tickFormat()(d); - }) - .data( - { - value: xValue, - series: allData - } - )(); - - interactiveLayer.renderGuideLine(pointXLocation); - - }); - - interactiveLayer.dispatch.on("elementMouseout",function(e) { - dispatch.tooltipHide(); - lines.clearHighlights(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - - if (typeof e.index !== 'undefined') { - index.i = e.index; - index.x = dx(index.i); - - state.index = e.index; - - indexLine - .data([index]); - } - - - if (typeof e.rescaleY !== 'undefined') { - rescaleY = e.rescaleY; - } - - chart.update(); - }); - - //============================================================ - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.lines = lines; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.interactiveLayer = interactiveLayer; - - d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'xScale','yScale', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi','useVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.rescaleY = function(_) { - if (!arguments.length) return rescaleY; - rescaleY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.useInteractiveGuideline = function(_) { - if(!arguments.length) return useInteractiveGuideline; - useInteractiveGuideline = _; - if (_ === true) { - chart.interactive(false); - chart.useVoronoi(false); - } - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.average = function(_) { - if(!arguments.length) return average; - average = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - chart.noErrorCheck = function(_) { - if (!arguments.length) return noErrorCheck; - noErrorCheck = _; - return chart; - }; - - //============================================================ - - - //============================================================ - // Functions - //------------------------------------------------------------ - - /* Normalize the data according to an index point. */ - function indexify(idx, data) { - return data.map(function(line, i) { - if (!line.values) { - return line; - } - var indexValue = line.values[idx]; - if (indexValue == null) { - return line; - } - var v = lines.y()(indexValue, idx); - - //TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue - if (v < -.95 && !noErrorCheck) { - //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100) - - line.tempDisabled = true; - return line; - } - - line.tempDisabled = false; - - line.values = line.values.map(function(point, pointIndex) { - point.display = {'y': (lines.y()(point, pointIndex) - v) / (1 + v) }; - return point; - }) - - return line; - }) - } - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/discreteBar.js b/awx/ui/static/lib/novus-nvd3/src/models/discreteBar.js deleted file mode 100755 index a20f58296f..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/discreteBar.js +++ /dev/null @@ -1,349 +0,0 @@ -//TODO: consider deprecating by adding necessary features to multiBar model -nv.models.discreteBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.ordinal() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove - , color = nv.utils.defaultColor() - , showValues = false - , valueFormat = d3.format(',.2f') - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - , rectClass = 'discreteBar' - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0 } - }) - }); - - x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands(xRange || [0, availableWidth], .1); - - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY))); - - - // If showValues, pad the Y axis range to account for label height - if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]); - else y.range(yRange || [availableHeight, 0]); - - //store old scales if they exist - x0 = x0 || x; - y0 = y0 || y.copy().range([y(0),y(0)]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-groups'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit() - .transition() - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }); - groups - .transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .75); - - - var bars = groups.selectAll('g.nv-bar') - .data(function(d) { return d.values }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('g') - .attr('transform', function(d,i,j) { - return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')' - }) - .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - value: getY(d,i), - point: d, - series: data[d.series], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }); - - barsEnter.append('rect') - .attr('height', 0) - .attr('width', x.rangeBand() * .9 / data.length ) - - if (showValues) { - barsEnter.append('text') - .attr('text-anchor', 'middle') - ; - - bars.select('text') - .text(function(d,i) { return valueFormat(getY(d,i)) }) - .transition() - .attr('x', x.rangeBand() * .9 / 2) - .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 }) - - ; - } else { - bars.selectAll('text').remove(); - } - - bars - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' }) - .style('fill', function(d,i) { return d.color || color(d,i) }) - .style('stroke', function(d,i) { return d.color || color(d,i) }) - .select('rect') - .attr('class', rectClass) - .transition() - .attr('width', x.rangeBand() * .9 / data.length); - bars.transition() - //.delay(function(d,i) { return i * 1200 / data[0].values.length }) - .attr('transform', function(d,i) { - var left = x(getX(d,i)) + x.rangeBand() * .05, - top = getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : //make 1 px positive bars show up above y=0 - y(getY(d,i)); - - return 'translate(' + left + ', ' + top + ')' - }) - .select('rect') - .attr('height', function(d,i) { - return Math.max(Math.abs(y(getY(d,i)) - y((yDomain && yDomain[0]) || 0)) || 1) - }); - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.showValues = function(_) { - if (!arguments.length) return showValues; - showValues = _; - return chart; - }; - - chart.valueFormat= function(_) { - if (!arguments.length) return valueFormat; - valueFormat = _; - return chart; - }; - - chart.rectClass= function(_) { - if (!arguments.length) return rectClass; - rectClass = _; - return chart; - }; - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/discreteBarChart.js b/awx/ui/static/lib/novus-nvd3/src/models/discreteBarChart.js deleted file mode 100755 index d695576eb6..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/discreteBarChart.js +++ /dev/null @@ -1,344 +0,0 @@ - -nv.models.discreteBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var discretebar = nv.models.discreteBar() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - ; - - var margin = {top: 15, right: 10, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.getColor() - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , staggerLabels = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + x + '

' + - '

' + y + '

' - } - , x - , y - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate') - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .highlightZero(false) - .showMaxMin(false) - .tickFormat(function(d) { return d }) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickFormat(d3.format(',.1f')) - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { - dispatch.beforeUpdate(); - container.transition().duration(transitionDuration).call(chart); - }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = discretebar.xScale(); - y = discretebar.yScale().clamp(true); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g'); - var defsEnter = gEnter.append('defs'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis') - .append('g').attr('class', 'nv-zeroLine') - .append('line'); - - gEnter.append('g').attr('class', 'nv-barsWrap'); - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Main Chart Component(s) - - discretebar - .width(availableWidth) - .height(availableHeight); - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(discretebar); - - //------------------------------------------------------------ - - - - defsEnter.append('clipPath') - .attr('id', 'nv-x-label-clip-' + discretebar.id()) - .append('rect'); - - g.select('#nv-x-label-clip-' + discretebar.id() + ' rect') - .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1)) - .attr('height', 16) - .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 )); - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')'); - //d3.transition(g.select('.nv-x.nv-axis')) - g.select('.nv-x.nv-axis').transition() - .call(xAxis); - - - var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); - - if (staggerLabels) { - xTicks - .selectAll('text') - .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' }) - } - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis').transition() - .call(yAxis); - } - - // Zero line - g.select(".nv-zeroLine line") - .attr("x1",0) - .attr("x2",availableWidth) - .attr("y1", y(0)) - .attr("y2", y(0)) - ; - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - - }); - - return chart; - } - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - discretebar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - discretebar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.discretebar = discretebar; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, discretebar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'id', 'showValues', 'valueFormat'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - discretebar.color(color); - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/distribution.js b/awx/ui/static/lib/novus-nvd3/src/models/distribution.js deleted file mode 100755 index 62a7465552..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/distribution.js +++ /dev/null @@ -1,148 +0,0 @@ - -nv.models.distribution = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 400 //technically width or height depending on x or y.... - , size = 8 - , axis = 'x' // 'x' or 'y'... horizontal or vertical - , getData = function(d) { return d[axis] } // defaults d.x or d.y - , color = nv.utils.defaultColor() - , scale = d3.scale.linear() - , domain - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var scale0; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom), - naxis = axis == 'x' ? 'y' : 'x', - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - scale0 = scale0 || scale; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-distribution').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') - - //------------------------------------------------------------ - - - var distWrap = g.selectAll('g.nv-dist') - .data(function(d) { return d }, function(d) { return d.key }); - - distWrap.enter().append('g'); - distWrap - .attr('class', function(d,i) { return 'nv-dist nv-series-' + i }) - .style('stroke', function(d,i) { return color(d, i) }); - - var dist = distWrap.selectAll('line.nv-dist' + axis) - .data(function(d) { return d.values }) - dist.enter().append('line') - .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) }) - distWrap.exit().selectAll('line.nv-dist' + axis) - .transition() - .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) - .style('stroke-opacity', 0) - .remove(); - dist - .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i }) - .attr(naxis + '1', 0) - .attr(naxis + '2', size); - dist - .transition() - .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) - .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) - - - scale0 = scale.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.axis = function(_) { - if (!arguments.length) return axis; - axis = _; - return chart; - }; - - chart.size = function(_) { - if (!arguments.length) return size; - size = _; - return chart; - }; - - chart.getData = function(_) { - if (!arguments.length) return getData; - getData = d3.functor(_); - return chart; - }; - - chart.scale = function(_) { - if (!arguments.length) return scale; - scale = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/historicalBar.js b/awx/ui/static/lib/novus-nvd3/src/models/historicalBar.js deleted file mode 100755 index 2a6c644d1f..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/historicalBar.js +++ /dev/null @@ -1,331 +0,0 @@ -//TODO: consider deprecating and using multibar with single series for this -nv.models.historicalBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.linear() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceX = [] - , forceY = [0] - , padData = false - , clipEdge = true - , color = nv.utils.defaultColor() - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - , interactive = true - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - x .domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )) - - if (padData) - x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); - else - x.range(xRange || [0, availableWidth]); - - y .domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) )) - .range(yRange || [availableHeight, 0]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-bars'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - container - .on('click', function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - defsEnter.append('clipPath') - .attr('id', 'nv-chart-clip-path-' + id) - .append('rect'); - - wrap.select('#nv-chart-clip-path-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); - - - - var bars = wrap.select('.nv-bars').selectAll('.nv-bar') - .data(function(d) { return d }, function(d,i) {return getX(d,i)}); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('rect') - //.attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) - .attr('x', 0 ) - .attr('y', function(d,i) { return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) }) - .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) }) - .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) - .on('mouseover', function(d,i) { - if (!interactive) return; - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - point: d, - series: data[0], - pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - - }) - .on('mouseout', function(d,i) { - if (!interactive) return; - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - point: d, - series: data[0], - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - }) - .on('click', function(d,i) { - if (!interactive) return; - dispatch.elementClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - if (!interactive) return; - dispatch.elementDblClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - bars - .attr('fill', function(d,i) { return color(d, i); }) - .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) - .transition() - .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) - //TODO: better width calculations that don't assume always uniform data spacing;w - .attr('width', (availableWidth / data[0].values.length) * .9 ); - - - bars.transition() - .attr('y', function(d,i) { - var rval = getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : - y(getY(d,i)); - return nv.utils.NaNtoZero(rval); - }) - .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) }); - - }); - - return chart; - } - - //Create methods to allow outside functions to highlight a specific bar. - chart.highlightPoint = function(pointIndex, isHoverOver) { - d3.select(".nv-historicalBar-" + id) - .select(".nv-bars .nv-bar-0-" + pointIndex) - .classed("hover", isHoverOver) - ; - }; - - chart.clearHighlights = function() { - d3.select(".nv-historicalBar-" + id) - .select(".nv-bars .nv-bar.hover") - .classed("hover", false) - ; - }; - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.padData = function(_) { - if (!arguments.length) return padData; - padData = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.interactive = function(_) { - if(!arguments.length) return interactive; - interactive = false; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/historicalBarChart.js b/awx/ui/static/lib/novus-nvd3/src/models/historicalBarChart.js deleted file mode 100755 index 07aab36f58..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/historicalBarChart.js +++ /dev/null @@ -1,419 +0,0 @@ - -nv.models.historicalBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var bars = nv.models.historicalBar() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - ; - - - var margin = {top: 30, right: 90, bottom: 50, left: 90} - , color = nv.utils.defaultColor() - , width = null - , height = null - , showLegend = false - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , x - , y - , state = {} - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient( (rightAlignYAxis) ? 'right' : 'left') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - - // New addition to calculate position if SVG is scaled with viewBox, may move TODO: consider implementing everywhere else - if (offsetElement) { - var svg = d3.select(offsetElement).select('svg'); - var viewBox = (svg.node()) ? svg.attr('viewBox') : null; - if (viewBox) { - viewBox = viewBox.split(' '); - var ratio = parseInt(svg.style('width')) / viewBox[2]; - e.pos[0] = e.pos[0] * ratio; - e.pos[1] = e.pos[1] * ratio; - } - } - - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(bars.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(bars.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = bars.xScale(); - y = bars.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-historicalBarChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBarChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - - //------------------------------------------------------------ - // Main Chart Component(s) - - bars - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(bars); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - g.select('.nv-x.nv-axis') - .transition() - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .transition() - .call(yAxis); - } - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.nv-series').classed('disabled', false); - return d; - }); - } - - state.disabled = data.map(function(d) { return !!d.disabled }); - dispatch.stateChange(state); - - selection.transition().call(chart); - }); - - legend.dispatch.on('legendDblclick', function(d) { - //Double clicking should always enable current series, and disabled all others. - data.forEach(function(d) { - d.disabled = true; - }); - d.disabled = false; - - state.disabled = data.map(function(d) { return !!d.disabled }); - dispatch.stateChange(state); - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.bars = bars; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, bars, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', - 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id', 'interpolate','highlightPoint','clearHighlights', 'interactive'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/indentedTree.js b/awx/ui/static/lib/novus-nvd3/src/models/indentedTree.js deleted file mode 100755 index 18c2700f31..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/indentedTree.js +++ /dev/null @@ -1,337 +0,0 @@ -nv.models.indentedTree = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} //TODO: implement, maybe as margin on the containing div - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() - , id = Math.floor(Math.random() * 10000) - , header = true - , filterZero = false - , noData = "No Data Available." - , childIndent = 20 - , columns = [{key:'key', label: 'Name', type:'text'}] //TODO: consider functions like chart.addColumn, chart.removeColumn, instead of a block like this - , tableClass = null - , iconOpen = 'images/grey-plus.png' //TODO: consider removing this and replacing with a '+' or '-' unless user defines images - , iconClose = 'images/grey-minus.png' - , dispatch = d3.dispatch('elementClick', 'elementDblclick', 'elementMouseover', 'elementMouseout') - , getUrl = function(d) { return d.url } - ; - - //============================================================ - - var idx = 0; - - function chart(selection) { - selection.each(function(data) { - var depth = 1, - container = d3.select(this); - - var tree = d3.layout.tree() - .children(function(d) { return d.values }) - .size([height, childIndent]); //Not sure if this is needed now that the result is HTML - - chart.update = function() { container.transition().duration(600).call(chart) }; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - if (!data[0]) data[0] = {key: noData}; - - //------------------------------------------------------------ - - - var nodes = tree.nodes(data[0]); - - // nodes.map(function(d) { - // d.id = i++; - // }) - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('div').data([[nodes]]); - var wrapEnter = wrap.enter().append('div').attr('class', 'nvd3 nv-wrap nv-indentedtree'); - var tableEnter = wrapEnter.append('table'); - var table = wrap.select('table').attr('width', '100%').attr('class', tableClass); - - //------------------------------------------------------------ - - - if (header) { - var thead = tableEnter.append('thead'); - - var theadRow1 = thead.append('tr'); - - columns.forEach(function(column) { - theadRow1 - .append('th') - .attr('width', column.width ? column.width : '10%') - .style('text-align', column.type == 'numeric' ? 'right' : 'left') - .append('span') - .text(column.label); - }); - } - - - var tbody = table.selectAll('tbody') - .data(function(d) { return d }); - tbody.enter().append('tbody'); - - - - //compute max generations - depth = d3.max(nodes, function(node) { return node.depth }); - tree.size([height, depth * childIndent]); //TODO: see if this is necessary at all - - - // Update the nodes… - var node = tbody.selectAll('tr') - // .data(function(d) { return d; }, function(d) { return d.id || (d.id == ++i)}); - .data(function(d) { return d.filter(function(d) { return (filterZero && !d.children) ? filterZero(d) : true; } )}, function(d,i) { return d.id || (d.id || ++idx)}); - //.style('display', 'table-row'); //TODO: see if this does anything - - node.exit().remove(); - - node.select('img.nv-treeicon') - .attr('src', icon) - .classed('folded', folded); - - var nodeEnter = node.enter().append('tr'); - - - columns.forEach(function(column, index) { - - var nodeName = nodeEnter.append('td') - .style('padding-left', function(d) { return (index ? 0 : d.depth * childIndent + 12 + (icon(d) ? 0 : 16)) + 'px' }, 'important') //TODO: check why I did the ternary here - .style('text-align', column.type == 'numeric' ? 'right' : 'left'); - - - if (index == 0) { - nodeName.append('img') - .classed('nv-treeicon', true) - .classed('nv-folded', folded) - .attr('src', icon) - .style('width', '14px') - .style('height', '14px') - .style('padding', '0 1px') - .style('display', function(d) { return icon(d) ? 'inline-block' : 'none'; }) - .on('click', click); - } - - - nodeName.each(function(d) { - if (!index && getUrl(d)) - d3.select(this) - .append('a') - .attr('href',getUrl) - .attr('class', d3.functor(column.classes)) - .append('span') - else - d3.select(this) - .append('span') - - d3.select(this).select('span') - .attr('class', d3.functor(column.classes) ) - .text(function(d) { return column.format ? column.format(d) : - (d[column.key] || '-') }); - }); - - if (column.showCount) { - nodeName.append('span') - .attr('class', 'nv-childrenCount'); - - node.selectAll('span.nv-childrenCount').text(function(d) { - return ((d.values && d.values.length) || (d._values && d._values.length)) ? //If this is a parent - '(' + ((d.values && (d.values.filter(function(d) { return filterZero ? filterZero(d) : true; }).length)) //If children are in values check its children and filter - || (d._values && d._values.filter(function(d) { return filterZero ? filterZero(d) : true; }).length) //Otherwise, do the same, but with the other name, _values... - || 0) + ')' //This is the catch-all in case there are no children after a filter - : '' //If this is not a parent, just give an empty string - }); - } - - // if (column.click) - // nodeName.select('span').on('click', column.click); - - }); - - node - .order() - .on('click', function(d) { - dispatch.elementClick({ - row: this, //TODO: decide whether or not this should be consistent with scatter/line events or should be an html link (a href) - data: d, - pos: [d.x, d.y] - }); - }) - .on('dblclick', function(d) { - dispatch.elementDblclick({ - row: this, - data: d, - pos: [d.x, d.y] - }); - }) - .on('mouseover', function(d) { - dispatch.elementMouseover({ - row: this, - data: d, - pos: [d.x, d.y] - }); - }) - .on('mouseout', function(d) { - dispatch.elementMouseout({ - row: this, - data: d, - pos: [d.x, d.y] - }); - }); - - - - - // Toggle children on click. - function click(d, _, unshift) { - d3.event.stopPropagation(); - - if(d3.event.shiftKey && !unshift) { - //If you shift-click, it'll toggle fold all the children, instead of itself - d3.event.shiftKey = false; - d.values && d.values.forEach(function(node){ - if (node.values || node._values) { - click(node, 0, true); - } - }); - return true; - } - if(!hasChildren(d)) { - //download file - //window.location.href = d.url; - return true; - } - if (d.values) { - d._values = d.values; - d.values = null; - } else { - d.values = d._values; - d._values = null; - } - chart.update(); - } - - - function icon(d) { - return (d._values && d._values.length) ? iconOpen : (d.values && d.values.length) ? iconClose : ''; - } - - function folded(d) { - return (d._values && d._values.length); - } - - function hasChildren(d) { - var values = d.values || d._values; - - return (values && values.length); - } - - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - scatter.color(color); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.header = function(_) { - if (!arguments.length) return header; - header = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.filterZero = function(_) { - if (!arguments.length) return filterZero; - filterZero = _; - return chart; - }; - - chart.columns = function(_) { - if (!arguments.length) return columns; - columns = _; - return chart; - }; - - chart.tableClass = function(_) { - if (!arguments.length) return tableClass; - tableClass = _; - return chart; - }; - - chart.iconOpen = function(_){ - if (!arguments.length) return iconOpen; - iconOpen = _; - return chart; - } - - chart.iconClose = function(_){ - if (!arguments.length) return iconClose; - iconClose = _; - return chart; - } - - chart.getUrl = function(_){ - if (!arguments.length) return getUrl; - getUrl = _; - return chart; - } - - //============================================================ - - - return chart; -}; \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/src/models/legend.js b/awx/ui/static/lib/novus-nvd3/src/models/legend.js deleted file mode 100755 index 26940e8fa7..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/legend.js +++ /dev/null @@ -1,272 +0,0 @@ -nv.models.legend = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 5, right: 0, bottom: 5, left: 0} - , width = 400 - , height = 20 - , getKey = function(d) { return d.key } - , color = nv.utils.defaultColor() - , align = true - , rightAlign = true - , updateState = true //If true, legend will update data.disabled and trigger a 'stateChange' dispatch. - , radioButtonMode = false //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time) - , dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange') - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-legend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g'); - var g = wrap.select('g'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - var series = g.selectAll('.nv-series') - .data(function(d) { return d }); - var seriesEnter = series.enter().append('g').attr('class', 'nv-series') - .on('mouseover', function(d,i) { - dispatch.legendMouseover(d,i); //TODO: Make consistent with other event objects - }) - .on('mouseout', function(d,i) { - dispatch.legendMouseout(d,i); - }) - .on('click', function(d,i) { - dispatch.legendClick(d,i); - if (updateState) { - if (radioButtonMode) { - //Radio button mode: set every series to disabled, - // and enable the clicked series. - data.forEach(function(series) { series.disabled = true}); - d.disabled = false; - } - else { - d.disabled = !d.disabled; - if (data.every(function(series) { return series.disabled})) { - //the default behavior of NVD3 legends is, if every single series - // is disabled, turn all series' back on. - data.forEach(function(series) { series.disabled = false}); - } - } - dispatch.stateChange({ - disabled: data.map(function(d) { return !!d.disabled }) - }); - } - }) - .on('dblclick', function(d,i) { - dispatch.legendDblclick(d,i); - if (updateState) { - //the default behavior of NVD3 legends, when double clicking one, - // is to set all other series' to false, and make the double clicked series enabled. - data.forEach(function(series) { - series.disabled = true; - }); - d.disabled = false; - dispatch.stateChange({ - disabled: data.map(function(d) { return !!d.disabled }) - }); - } - }); - seriesEnter.append('circle') - .style('stroke-width', 2) - .attr('class','nv-legend-symbol') - .attr('r', 5); - seriesEnter.append('text') - .attr('text-anchor', 'start') - .attr('class','nv-legend-text') - .attr('dy', '.32em') - .attr('dx', '8'); - series.classed('disabled', function(d) { return d.disabled }); - series.exit().remove(); - series.select('circle') - .style('fill', function(d,i) { return d.color || color(d,i)}) - .style('stroke', function(d,i) { return d.color || color(d, i) }); - series.select('text').text(getKey); - - - //TODO: implement fixed-width and max-width options (max-width is especially useful with the align option) - - // NEW ALIGNING CODE, TODO: clean up - if (align) { - - var seriesWidths = []; - series.each(function(d,i) { - var legendText = d3.select(this).select('text'); - var nodeTextLength; - try { - nodeTextLength = legendText.node().getComputedTextLength(); - // If the legendText is display:none'd (nodeTextLength == 0), simulate an error so we approximate, instead - if(nodeTextLength <= 0) throw Error(); - } - catch(e) { - nodeTextLength = nv.utils.calcApproxTextWidth(legendText); - } - - seriesWidths.push(nodeTextLength + 28); // 28 is ~ the width of the circle plus some padding - }); - - var seriesPerRow = 0; - var legendWidth = 0; - var columnWidths = []; - - while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) { - columnWidths[seriesPerRow] = seriesWidths[seriesPerRow]; - legendWidth += seriesWidths[seriesPerRow++]; - } - if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row - - - while ( legendWidth > availableWidth && seriesPerRow > 1 ) { - columnWidths = []; - seriesPerRow--; - - for (var k = 0; k < seriesWidths.length; k++) { - if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) ) - columnWidths[k % seriesPerRow] = seriesWidths[k]; - } - - legendWidth = columnWidths.reduce(function(prev, cur, index, array) { - return prev + cur; - }); - } - - var xPositions = []; - for (var i = 0, curX = 0; i < seriesPerRow; i++) { - xPositions[i] = curX; - curX += columnWidths[i]; - } - - series - .attr('transform', function(d, i) { - return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * 20) + ')'; - }); - - //position legend as far right as possible within the total width - if (rightAlign) { - g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')'); - } - else { - g.attr('transform', 'translate(0' + ',' + margin.top + ')'); - } - - height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * 20); - - } else { - - var ypos = 5, - newxpos = 5, - maxwidth = 0, - xpos; - series - .attr('transform', function(d, i) { - var length = d3.select(this).select('text').node().getComputedTextLength() + 28; - xpos = newxpos; - - if (width < margin.left + margin.right + xpos + length) { - newxpos = xpos = 5; - ypos += 20; - } - - newxpos += length; - if (newxpos > maxwidth) maxwidth = newxpos; - - return 'translate(' + xpos + ',' + ypos + ')'; - }); - - //position legend as far right as possible within the total width - g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')'); - - height = margin.top + margin.bottom + ypos + 15; - - } - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.key = function(_) { - if (!arguments.length) return getKey; - getKey = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.align = function(_) { - if (!arguments.length) return align; - align = _; - return chart; - }; - - chart.rightAlign = function(_) { - if (!arguments.length) return rightAlign; - rightAlign = _; - return chart; - }; - - chart.updateState = function(_) { - if (!arguments.length) return updateState; - updateState = _; - return chart; - }; - - chart.radioButtonMode = function(_) { - if (!arguments.length) return radioButtonMode; - radioButtonMode = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/line.js b/awx/ui/static/lib/novus-nvd3/src/models/line.js deleted file mode 100755 index 403f453682..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/line.js +++ /dev/null @@ -1,274 +0,0 @@ - -nv.models.line = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var scatter = nv.models.scatter() - ; - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() // a function that returns a color - , getX = function(d) { return d.x } // accessor to get the x value from a data point - , getY = function(d) { return d.y } // accessor to get the y value from a data point - , defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined - , isArea = function(d) { return d.area } // decides if a line is an area or just a line - , clipEdge = false // if true, masks lines within x and y scale - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , interpolate = "linear" // controls the line interpolation - ; - - scatter - .size(16) // default size - .sizeDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0 //used to store previous scales - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - //------------------------------------------------------------ - // Setup Scales - - x = scatter.xScale(); - y = scatter.yScale(); - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-line').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - gEnter.append('g').attr('class', 'nv-groups'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - - scatter - .width(availableWidth) - .height(availableHeight) - - var scatterWrap = wrap.select('.nv-scatterWrap'); - //.datum(data); // Data automatically trickles down from the wrap - - scatterWrap.transition().call(scatter); - - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + scatter.id()) - .append('rect'); - - wrap.select('#nv-edge-clip-' + scatter.id() + ' rect') - .attr('width', availableWidth) - .attr('height', (availableHeight > 0) ? availableHeight : 0); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : ''); - scatterWrap - .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : ''); - - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - - groups.exit().remove(); - - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i)}); - groups - .transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .5); - - - - var areaPaths = groups.selectAll('path.nv-area') - .data(function(d) { return isArea(d) ? [d] : [] }); // this is done differently than lines because I need to check if series is an area - areaPaths.enter().append('path') - .attr('class', 'nv-area') - .attr('d', function(d) { - return d3.svg.area() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) - .y0(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) - .y1(function(d,i) { return y0( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) }) - //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this - .apply(this, [d.values]) - }); - groups.exit().selectAll('path.nv-area') - .remove(); - - areaPaths - .transition() - .attr('d', function(d) { - return d3.svg.area() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .y0(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - .y1(function(d,i) { return y( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) }) - //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this - .apply(this, [d.values]) - }); - - - - var linePaths = groups.selectAll('path.nv-line') - .data(function(d) { return [d.values] }); - linePaths.enter().append('path') - .attr('class', 'nv-line') - .attr('d', - d3.svg.line() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) - .y(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) - ); - - linePaths - .transition() - .attr('d', - d3.svg.line() - .interpolate(interpolate) - .defined(defined) - .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .y(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - ); - - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = scatter.dispatch; - chart.scatter = scatter; - - d3.rebind(chart, scatter, 'id', 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', - 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'useVoronoi', 'clipRadius', 'padData','highlightPoint','clearHighlights'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - scatter.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - scatter.y(_); - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - scatter.color(color); - return chart; - }; - - chart.interpolate = function(_) { - if (!arguments.length) return interpolate; - interpolate = _; - return chart; - }; - - chart.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return chart; - }; - - chart.isArea = function(_) { - if (!arguments.length) return isArea; - isArea = d3.functor(_); - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/lineChart.js b/awx/ui/static/lib/novus-nvd3/src/models/lineChart.js deleted file mode 100755 index 4d5ef48f1b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/lineChart.js +++ /dev/null @@ -1,467 +0,0 @@ - -nv.models.lineChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , interactiveLayer = nv.interactiveGuideline() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 60} - , color = nv.utils.defaultColor() - , width = null - , height = null - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , useInteractiveGuideline = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , x - , y - , state = {} - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = lines.xScale(); - y = lines.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g'); - var g = wrap.select('g'); - - gEnter.append("rect").style("opacity",0); - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-linesWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-interactive'); - - g.select("rect") - .attr("width",availableWidth) - .attr("height",(availableHeight > 0) ? availableHeight : 0); - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - - //------------------------------------------------------------ - //Set up interactive layer - if (useInteractiveGuideline) { - interactiveLayer - .width(availableWidth) - .height(availableHeight) - .margin({left:margin.left, top:margin.top}) - .svgContainer(container) - .xScale(x); - wrap.select(".nv-interactive").call(interactiveLayer); - } - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - - - var linesWrap = g.select('.nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - linesWrap.transition().call(lines); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - g.select('.nv-x.nv-axis') - .transition() - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .transition() - .call(yAxis); - } - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - interactiveLayer.dispatch.on('elementMousemove', function(e) { - lines.clearHighlights(); - var singlePoint, pointIndex, pointXLocation, allData = []; - data - .filter(function(series, i) { - series.seriesIndex = i; - return !series.disabled; - }) - .forEach(function(series,i) { - pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); - lines.highlightPoint(i, pointIndex, true); - var point = series.values[pointIndex]; - if (typeof point === 'undefined') return; - if (typeof singlePoint === 'undefined') singlePoint = point; - if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); - allData.push({ - key: series.key, - value: chart.y()(point, pointIndex), - color: color(series,series.seriesIndex) - }); - }); - //Highlight the tooltip entry based on which point the mouse is closest to. - if (allData.length > 2) { - var yValue = chart.yScale().invert(e.mouseY); - var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); - var threshold = 0.03 * domainExtent; - var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); - if (indexToHighlight !== null) - allData[indexToHighlight].highlight = true; - } - - var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex)); - interactiveLayer.tooltip - .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) - .chartContainer(that.parentNode) - .enabled(tooltips) - .valueFormatter(function(d,i) { - return yAxis.tickFormat()(d); - }) - .data( - { - value: xValue, - series: allData - } - )(); - - interactiveLayer.renderGuideLine(pointXLocation); - - }); - - interactiveLayer.dispatch.on("elementMouseout",function(e) { - dispatch.tooltipHide(); - lines.clearHighlights(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.lines = lines; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.interactiveLayer = interactiveLayer; - - d3.rebind(chart, lines, 'defined', 'isArea', 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'xRange', 'yRange' - , 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'useVoronoi','id', 'interpolate'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.useInteractiveGuideline = function(_) { - if(!arguments.length) return useInteractiveGuideline; - useInteractiveGuideline = _; - if (_ === true) { - chart.interactive(false); - chart.useVoronoi(false); - } - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/linePlusBarChart.js b/awx/ui/static/lib/novus-nvd3/src/models/linePlusBarChart.js deleted file mode 100755 index 77fcbab781..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/linePlusBarChart.js +++ /dev/null @@ -1,433 +0,0 @@ - -nv.models.linePlusBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , bars = nv.models.historicalBar() - , xAxis = nv.models.axis() - , y1Axis = nv.models.axis() - , y2Axis = nv.models.axis() - , legend = nv.models.legend() - ; - - var margin = {top: 30, right: 60, bottom: 50, left: 60} - , width = null - , height = null - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , color = nv.utils.defaultColor() - , showLegend = true - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

'; - } - , x - , y1 - , y2 - , state = {} - , defaultState = null - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - ; - - bars - .padData(true) - ; - lines - .clipEdge(false) - .padData(true) - ; - xAxis - .orient('bottom') - .tickPadding(7) - .highlightZero(false) - ; - y1Axis - .orient('left') - ; - y2Axis - .orient('right') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - } - ; - - //------------------------------------------------------------ - - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().call(chart); }; - // chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); - var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240 - - //x = xAxis.scale(); - x = dataLines.filter(function(d) { return !d.disabled; }).length && dataLines.filter(function(d) { return !d.disabled; })[0].values.length ? lines.xScale() : bars.xScale(); - //x = dataLines.filter(function(d) { return !d.disabled; }).length ? lines.xScale() : bars.xScale(); //old code before change above - y1 = bars.yScale(); - y2 = lines.yScale(); - - //------------------------------------------------------------ - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('g.nv-wrap.nv-linePlusBar').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y1 nv-axis'); - gEnter.append('g').attr('class', 'nv-y2 nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-linesWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width( availableWidth / 2 ); - - g.select('.nv-legendWrap') - .datum(data.map(function(series) { - series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; - series.key = series.originalKey + (series.bar ? ' (left axis)' : ' (right axis)'); - return series; - })) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })) - - bars - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })) - - - - var barsWrap = g.select('.nv-barsWrap') - .datum(dataBars.length ? dataBars : [{values:[]}]) - - var linesWrap = g.select('.nv-linesWrap') - .datum(dataLines[0] && !dataLines[0].disabled ? dataLines : [{values:[]}] ); - //.datum(!dataLines[0].disabled ? dataLines : [{values:dataLines[0].values.map(function(d) { return [d[0], null] }) }] ); - - d3.transition(barsWrap).call(bars); - d3.transition(linesWrap).call(lines); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - - - y1Axis - .scale(y1) - .ticks( availableHeight / 36 ) - .tickSize(-availableWidth, 0); - - d3.transition(g.select('.nv-y1.nv-axis')) - .style('opacity', dataBars.length ? 1 : 0) - .call(y1Axis); - - - y2Axis - .scale(y2) - .ticks( availableHeight / 36 ) - .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.nv-y2.nv-axis') - .style('opacity', dataLines.length ? 1 : 0) - .attr('transform', 'translate(' + availableWidth + ',0)'); - //.attr('transform', 'translate(' + x.range()[1] + ',0)'); - - d3.transition(g.select('.nv-y2.nv-axis')) - .call(y2Axis); - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.bars = bars; - chart.xAxis = xAxis; - chart.y1Axis = y1Axis; - chart.y2Axis = y2Axis; - - d3.rebind(chart, lines, 'defined', 'size', 'clipVoronoi', 'interpolate'); - //TODO: consider rebinding x, y and some other stuff, and simply do soemthign lile bars.x(lines.x()), etc. - //d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - bars.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - bars.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/linePlusBarWithFocusChart.js b/awx/ui/static/lib/novus-nvd3/src/models/linePlusBarWithFocusChart.js deleted file mode 100755 index 2ef31137a9..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/linePlusBarWithFocusChart.js +++ /dev/null @@ -1,658 +0,0 @@ - -nv.models.linePlusBarWithFocusChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , lines2 = nv.models.line() - , bars = nv.models.historicalBar() - , bars2 = nv.models.historicalBar() - , xAxis = nv.models.axis() - , x2Axis = nv.models.axis() - , y1Axis = nv.models.axis() - , y2Axis = nv.models.axis() - , y3Axis = nv.models.axis() - , y4Axis = nv.models.axis() - , legend = nv.models.legend() - , brush = d3.svg.brush() - ; - - var margin = {top: 30, right: 30, bottom: 30, left: 60} - , margin2 = {top: 0, right: 30, bottom: 20, left: 60} - , width = null - , height = null - , height2 = 100 - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , color = nv.utils.defaultColor() - , showLegend = true - , extent - , brushExtent = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

'; - } - , x - , x2 - , y1 - , y2 - , y3 - , y4 - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush') - , transitionDuration = 0 - ; - - lines - .clipEdge(true) - ; - lines2 - .interactive(false) - ; - xAxis - .orient('bottom') - .tickPadding(5) - ; - y1Axis - .orient('left') - ; - y2Axis - .orient('right') - ; - x2Axis - .orient('bottom') - .tickPadding(5) - ; - y3Axis - .orient('left') - ; - y4Axis - .orient('right') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - if (extent) { - e.pointIndex += Math.ceil(extent[0]); - } - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //------------------------------------------------------------ - - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2, - availableHeight2 = height2 - margin2.top - margin2.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight1 / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); - var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240 - - x = bars.xScale(); - x2 = x2Axis.scale(); - y1 = bars.yScale(); - y2 = lines.yScale(); - y3 = bars2.yScale(); - y4 = lines2.yScale(); - - var series1 = data - .filter(function(d) { return !d.disabled && d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - var series2 = data - .filter(function(d) { return !d.disabled && !d.bar }) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i) } - }) - }); - - x .range([0, availableWidth]); - - x2 .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) - .range([0, availableWidth]); - - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-linePlusBar').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-legendWrap'); - - var focusEnter = gEnter.append('g').attr('class', 'nv-focus'); - focusEnter.append('g').attr('class', 'nv-x nv-axis'); - focusEnter.append('g').attr('class', 'nv-y1 nv-axis'); - focusEnter.append('g').attr('class', 'nv-y2 nv-axis'); - focusEnter.append('g').attr('class', 'nv-barsWrap'); - focusEnter.append('g').attr('class', 'nv-linesWrap'); - - var contextEnter = gEnter.append('g').attr('class', 'nv-context'); - contextEnter.append('g').attr('class', 'nv-x nv-axis'); - contextEnter.append('g').attr('class', 'nv-y1 nv-axis'); - contextEnter.append('g').attr('class', 'nv-y2 nv-axis'); - contextEnter.append('g').attr('class', 'nv-barsWrap'); - contextEnter.append('g').attr('class', 'nv-linesWrap'); - contextEnter.append('g').attr('class', 'nv-brushBackground'); - contextEnter.append('g').attr('class', 'nv-x nv-brush'); - - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width( availableWidth / 2 ); - - g.select('.nv-legendWrap') - .datum(data.map(function(series) { - series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; - series.key = series.originalKey + (series.bar ? ' (left axis)' : ' (right axis)'); - return series; - })) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Context Components - - bars2 - .width(availableWidth) - .height(availableHeight2) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); - - lines2 - .width(availableWidth) - .height(availableHeight2) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })); - - var bars2Wrap = g.select('.nv-context .nv-barsWrap') - .datum(dataBars.length ? dataBars : [{values:[]}]); - - var lines2Wrap = g.select('.nv-context .nv-linesWrap') - .datum(!dataLines[0].disabled ? dataLines : [{values:[]}]); - - g.select('.nv-context') - .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')') - - bars2Wrap.transition().call(bars2); - lines2Wrap.transition().call(lines2); - - //------------------------------------------------------------ - - - - //------------------------------------------------------------ - // Setup Brush - - brush - .x(x2) - .on('brush', onBrush); - - if (brushExtent) brush.extent(brushExtent); - - var brushBG = g.select('.nv-brushBackground').selectAll('g') - .data([brushExtent || brush.extent()]) - - var brushBGenter = brushBG.enter() - .append('g'); - - brushBGenter.append('rect') - .attr('class', 'left') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - brushBGenter.append('rect') - .attr('class', 'right') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - var gBrush = g.select('.nv-x.nv-brush') - .call(brush); - gBrush.selectAll('rect') - //.attr('y', -5) - .attr('height', availableHeight2); - gBrush.selectAll('.resize').append('path').attr('d', resizePath); - - //------------------------------------------------------------ - - //------------------------------------------------------------ - // Setup Secondary (Context) Axes - - x2Axis - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight2, 0); - - g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y3.range()[0] + ')'); - g.select('.nv-context .nv-x.nv-axis').transition() - .call(x2Axis); - - - y3Axis - .scale(y3) - .ticks( availableHeight2 / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-context .nv-y1.nv-axis') - .style('opacity', dataBars.length ? 1 : 0) - .attr('transform', 'translate(0,' + x2.range()[0] + ')'); - - g.select('.nv-context .nv-y1.nv-axis').transition() - .call(y3Axis); - - - y4Axis - .scale(y4) - .ticks( availableHeight2 / 36 ) - .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.nv-context .nv-y2.nv-axis') - .style('opacity', dataLines.length ? 1 : 0) - .attr('transform', 'translate(' + x2.range()[1] + ',0)'); - - g.select('.nv-context .nv-y2.nv-axis').transition() - .call(y4Axis); - - //------------------------------------------------------------ - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - - //============================================================ - // Functions - //------------------------------------------------------------ - - // Taken from crossfilter (http://square.github.com/crossfilter/) - function resizePath(d) { - var e = +(d == 'e'), - x = e ? 1 : -1, - y = availableHeight2 / 3; - return 'M' + (.5 * x) + ',' + y - + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6) - + 'V' + (2 * y - 6) - + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y) - + 'Z' - + 'M' + (2.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8) - + 'M' + (4.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8); - } - - - function updateBrushBG() { - if (!brush.empty()) brush.extent(brushExtent); - brushBG - .data([brush.empty() ? x2.domain() : brushExtent]) - .each(function(d,i) { - var leftWidth = x2(d[0]) - x2.range()[0], - rightWidth = x2.range()[1] - x2(d[1]); - d3.select(this).select('.left') - .attr('width', leftWidth < 0 ? 0 : leftWidth); - - d3.select(this).select('.right') - .attr('x', x2(d[1])) - .attr('width', rightWidth < 0 ? 0 : rightWidth); - }); - } - - - function onBrush() { - brushExtent = brush.empty() ? null : brush.extent(); - extent = brush.empty() ? x2.domain() : brush.extent(); - - - dispatch.brush({extent: extent, brush: brush}); - - updateBrushBG(); - - - //------------------------------------------------------------ - // Prepare Main (Focus) Bars and Lines - - bars - .width(availableWidth) - .height(availableHeight1) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); - - - lines - .width(availableWidth) - .height(availableHeight1) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })); - - var focusBarsWrap = g.select('.nv-focus .nv-barsWrap') - .datum(!dataBars.length ? [{values:[]}] : - dataBars - .map(function(d,i) { - return { - key: d.key, - values: d.values.filter(function(d,i) { - return bars.x()(d,i) >= extent[0] && bars.x()(d,i) <= extent[1]; - }) - } - }) - ); - - var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum(dataLines[0].disabled ? [{values:[]}] : - dataLines - .map(function(d,i) { - return { - key: d.key, - values: d.values.filter(function(d,i) { - return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1]; - }) - } - }) - ); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Update Main (Focus) X Axis - - if (dataBars.length) { - x = bars.xScale(); - } else { - x = lines.xScale(); - } - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight1, 0); - - xAxis.domain([Math.ceil(extent[0]), Math.floor(extent[1])]); - - g.select('.nv-x.nv-axis').transition().duration(transitionDuration) - .call(xAxis); - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Update Main (Focus) Bars and Lines - - focusBarsWrap.transition().duration(transitionDuration).call(bars); - focusLinesWrap.transition().duration(transitionDuration).call(lines); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup and Update Main (Focus) Y Axes - - g.select('.nv-focus .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y1.range()[0] + ')'); - - - y1Axis - .scale(y1) - .ticks( availableHeight1 / 36 ) - .tickSize(-availableWidth, 0); - - g.select('.nv-focus .nv-y1.nv-axis') - .style('opacity', dataBars.length ? 1 : 0); - - - y2Axis - .scale(y2) - .ticks( availableHeight1 / 36 ) - .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none - - g.select('.nv-focus .nv-y2.nv-axis') - .style('opacity', dataLines.length ? 1 : 0) - .attr('transform', 'translate(' + x.range()[1] + ',0)'); - - g.select('.nv-focus .nv-y1.nv-axis').transition().duration(transitionDuration) - .call(y1Axis); - g.select('.nv-focus .nv-y2.nv-axis').transition().duration(transitionDuration) - .call(y2Axis); - } - - //============================================================ - - onBrush(); - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.lines2 = lines2; - chart.bars = bars; - chart.bars2 = bars2; - chart.xAxis = xAxis; - chart.x2Axis = x2Axis; - chart.y1Axis = y1Axis; - chart.y2Axis = y2Axis; - chart.y3Axis = y3Axis; - chart.y4Axis = y4Axis; - - d3.rebind(chart, lines, 'defined', 'size', 'clipVoronoi', 'interpolate'); - //TODO: consider rebinding x, y and some other stuff, and simply do soemthign lile bars.x(lines.x()), etc. - //d3.rebind(chart, lines, 'x', 'y', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines.x(_); - bars.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines.y(_); - bars.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.brushExtent = function(_) { - if (!arguments.length) return brushExtent; - brushExtent = _; - return chart; - }; - - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/lineWithFisheye.js b/awx/ui/static/lib/novus-nvd3/src/models/lineWithFisheye.js deleted file mode 100755 index 2b4116720c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/lineWithFisheye.js +++ /dev/null @@ -1,200 +0,0 @@ - -nv.models.line = function() { - "use strict"; - //Default Settings - var margin = {top: 0, right: 0, bottom: 0, left: 0}, - width = 960, - height = 500, - color = nv.utils.defaultColor(), // function that returns colors - id = Math.floor(Math.random() * 10000), //Create semi-unique ID incase user doesn't select one - getX = function(d) { return d.x }, // accessor to get the x value from a data point - getY = function(d) { return d.y }, // accessor to get the y value from a data point - clipEdge = false, // if true, masks lines within x and y scale - interpolate = "linear"; // controls the line interpolation - - - var scatter = nv.models.scatter() - .id(id) - .size(16) // default size - .sizeDomain([16,256]), //set to speed up calculation, needs to be unset if there is a custom size accessor - //x = scatter.xScale(), - //y = scatter.yScale(), - x, y, - x0, y0, timeoutID; - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom; - - //get the scales inscase scatter scale was set manually - x = x || scatter.xScale(); - y = y || scatter.yScale(); - - //store old scales if they exist - x0 = x0 || x; - y0 = y0 || y; - - - var wrap = d3.select(this).selectAll('g.nv-wrap.nv-line').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - wrapEnter.append('g').attr('class', 'nv-scatterWrap'); - var scatterWrap = wrap.select('.nv-scatterWrap').datum(data); - - gEnter.append('g').attr('class', 'nv-groups'); - - - scatter - .width(availableWidth) - .height(availableHeight) - - d3.transition(scatterWrap).call(scatter); - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - scatterWrap - .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - d3.transition(groups.exit()) - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i) }) - d3.transition(groups) - .style('stroke-opacity', 1) - .style('fill-opacity', .5) - - - var paths = groups.selectAll('path') - .data(function(d, i) { return [d.values] }); - paths.enter().append('path') - .attr('class', 'nv-line') - .attr('d', d3.svg.line() - .interpolate(interpolate) - .x(function(d,i) { return x0(getX(d,i)) }) - .y(function(d,i) { return y0(getY(d,i)) }) - ); - d3.transition(groups.exit().selectAll('path')) - .attr('d', d3.svg.line() - .interpolate(interpolate) - .x(function(d,i) { return x(getX(d,i)) }) - .y(function(d,i) { return y(getY(d,i)) }) - ) - .remove(); // redundant? line is already being removed - d3.transition(paths) - .attr('d', d3.svg.line() - .interpolate(interpolate) - .x(function(d,i) { return x(getX(d,i)) }) - .y(function(d,i) { return y(getY(d,i)) }) - ); - - - //store old scales for use in transitions on update, to animate from old to new positions - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - chart.dispatch = scatter.dispatch; - - d3.rebind(chart, scatter, 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - scatter.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - scatter.y(_); - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - scatter.color(color); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.interpolate = function(_) { - if (!arguments.length) return interpolate; - interpolate = _; - return chart; - }; - - chart.defined = function(_) { - if (!arguments.length) return defined; - defined = _; - return chart; - }; - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/lineWithFisheyeChart.js b/awx/ui/static/lib/novus-nvd3/src/models/lineWithFisheyeChart.js deleted file mode 100755 index ad89419048..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/lineWithFisheyeChart.js +++ /dev/null @@ -1,297 +0,0 @@ - -nv.models.lineChart = function() { - "use strict"; - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - color = nv.utils.defaultColor(), - width = null, - height = null, - showLegend = true, - showControls = true, - fisheye = 0, - pauseFisheye = false, - tooltips = true, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }, - noData = "No Data Available." - ; - - - var x = d3.fisheye.scale(d3.scale.linear).distortion(0); - - var lines = nv.models.line().xScale(x), - //x = lines.xScale(), - y = lines.yScale(), - xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5), - yAxis = nv.models.axis().scale(y).orient('left'), - legend = nv.models.legend().height(30), - controls = nv.models.legend().height(30).updateState(false), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - - var controlsData = [ - { key: 'Magnify', disabled: true } - ]; - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().call(chart) }; - chart.container = this; // I need a reference to the container in order to have outside code check if the chart is visible or not - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - container.append('text') - .attr('class', 'nvd3 nv-noData') - .attr('x', availableWidth / 2) - .attr('y', availableHeight / 2) - .attr('dy', '-.7em') - .style('text-anchor', 'middle') - .text(noData); - return chart; - } else { - container.select('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - - var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g'); - - - gEnter.append('rect') - .attr('class', 'nvd3 nv-background') - .attr('width', availableWidth) - .attr('height', availableHeight); - - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-linesWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - - var g = wrap.select('g'); - - - - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - if (showControls) { - controls.width(180).color(['#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - - - lines - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - - - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var linesWrap = g.select('.nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(linesWrap).call(lines); - - - - xAxis - //.scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - - - yAxis - //.scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-y.nv-axis')) - .call(yAxis); - - - - g.select('.nv-background').on('mousemove', updateFisheye); - g.select('.nv-background').on('click', function() { pauseFisheye = !pauseFisheye; }); - //g.select('.point-paths').on('mousemove', updateFisheye); - - - function updateFisheye() { - if (pauseFisheye) { - //g.select('.background') .style('pointer-events', 'none'); - g.select('.nv-point-paths').style('pointer-events', 'all'); - return false; - } - - g.select('.nv-background') .style('pointer-events', 'all'); - g.select('.nv-point-paths').style('pointer-events', 'none' ); - - var mouse = d3.mouse(this); - linesWrap.call(lines); - g.select('.nv-x.nv-axis').call(xAxis); - x.distortion(fisheye).focus(mouse[0]); - } - - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - fisheye = d.disabled ? 0 : 5; - g.select('.nv-background') .style('pointer-events', d.disabled ? 'none' : 'all'); - g.select('.nv-point-paths').style('pointer-events', d.disabled ? 'all' : 'none' ); - - //scatter.interactive(d.disabled); - //tooltips = d.disabled; - - if (d.disabled) { - x.distortion(fisheye).focus(0); - - linesWrap.call(lines); - g.select('.nv-x.nv-axis').call(xAxis); - } else { - pauseFisheye = false; - } - - chart.update(); - }); - - - legend.dispatch.on('stateChange', function(newState) { - chart.update(); - }); - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - if (tooltips) dispatch.on('tooltipShow', function(e) { showTooltip(e, that.parentNode) } ); // TODO: maybe merge with above? - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - if (tooltips) dispatch.on('tooltipHide', nv.tooltip.cleanup); - - }); - - return chart; - } - - - chart.dispatch = dispatch; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, lines, 'defined', 'x', 'y', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id', 'interpolate'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/lineWithFocusChart.js b/awx/ui/static/lib/novus-nvd3/src/models/lineWithFocusChart.js deleted file mode 100755 index 8e056706b6..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/lineWithFocusChart.js +++ /dev/null @@ -1,575 +0,0 @@ -nv.models.lineWithFocusChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var lines = nv.models.line() - , lines2 = nv.models.line() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , x2Axis = nv.models.axis() - , y2Axis = nv.models.axis() - , legend = nv.models.legend() - , brush = d3.svg.brush() - ; - - var margin = {top: 30, right: 30, bottom: 30, left: 60} - , margin2 = {top: 0, right: 30, bottom: 20, left: 60} - , color = nv.utils.defaultColor() - , width = null - , height = null - , height2 = 100 - , x - , y - , x2 - , y2 - , showLegend = true - , brushExtent = null - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - } - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush') - , transitionDuration = 250 - ; - - lines - .clipEdge(true) - ; - lines2 - .interactive(false) - ; - xAxis - .orient('bottom') - .tickPadding(5) - ; - yAxis - .orient('left') - ; - x2Axis - .orient('bottom') - .tickPadding(5) - ; - y2Axis - .orient('left') - ; - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, null, null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2, - availableHeight2 = height2 - margin2.top - margin2.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight1 / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = lines.xScale(); - y = lines.yScale(); - x2 = lines2.xScale(); - y2 = lines2.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-lineWithFocusChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineWithFocusChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-legendWrap'); - - var focusEnter = gEnter.append('g').attr('class', 'nv-focus'); - focusEnter.append('g').attr('class', 'nv-x nv-axis'); - focusEnter.append('g').attr('class', 'nv-y nv-axis'); - focusEnter.append('g').attr('class', 'nv-linesWrap'); - - var contextEnter = gEnter.append('g').attr('class', 'nv-context'); - contextEnter.append('g').attr('class', 'nv-x nv-axis'); - contextEnter.append('g').attr('class', 'nv-y nv-axis'); - contextEnter.append('g').attr('class', 'nv-linesWrap'); - contextEnter.append('g').attr('class', 'nv-brushBackground'); - contextEnter.append('g').attr('class', 'nv-x nv-brush'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight1 = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom - height2; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')') - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - lines - .width(availableWidth) - .height(availableHeight1) - .color( - data - .map(function(d,i) { - return d.color || color(d, i); - }) - .filter(function(d,i) { - return !data[i].disabled; - }) - ); - - lines2 - .defined(lines.defined()) - .width(availableWidth) - .height(availableHeight2) - .color( - data - .map(function(d,i) { - return d.color || color(d, i); - }) - .filter(function(d,i) { - return !data[i].disabled; - }) - ); - - g.select('.nv-context') - .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')') - - var contextLinesWrap = g.select('.nv-context .nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(contextLinesWrap).call(lines2); - - //------------------------------------------------------------ - - - /* - var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(focusLinesWrap).call(lines); - */ - - - //------------------------------------------------------------ - // Setup Main (Focus) Axes - - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight1, 0); - - yAxis - .scale(y) - .ticks( availableHeight1 / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-focus .nv-x.nv-axis') - .attr('transform', 'translate(0,' + availableHeight1 + ')'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Brush - - brush - .x(x2) - .on('brush', function() { - //When brushing, turn off transitions because chart needs to change immediately. - var oldTransition = chart.transitionDuration(); - chart.transitionDuration(0); - onBrush(); - chart.transitionDuration(oldTransition); - }); - - if (brushExtent) brush.extent(brushExtent); - - var brushBG = g.select('.nv-brushBackground').selectAll('g') - .data([brushExtent || brush.extent()]) - - var brushBGenter = brushBG.enter() - .append('g'); - - brushBGenter.append('rect') - .attr('class', 'left') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - brushBGenter.append('rect') - .attr('class', 'right') - .attr('x', 0) - .attr('y', 0) - .attr('height', availableHeight2); - - var gBrush = g.select('.nv-x.nv-brush') - .call(brush); - gBrush.selectAll('rect') - //.attr('y', -5) - .attr('height', availableHeight2); - gBrush.selectAll('.resize').append('path').attr('d', resizePath); - - onBrush(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Secondary (Context) Axes - - x2Axis - .scale(x2) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight2, 0); - - g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); - d3.transition(g.select('.nv-context .nv-x.nv-axis')) - .call(x2Axis); - - - y2Axis - .scale(y2) - .ticks( availableHeight2 / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-context .nv-y.nv-axis')) - .call(y2Axis); - - g.select('.nv-context .nv-x.nv-axis') - .attr('transform', 'translate(0,' + y2.range()[0] + ')'); - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - //============================================================ - - - //============================================================ - // Functions - //------------------------------------------------------------ - - // Taken from crossfilter (http://square.github.com/crossfilter/) - function resizePath(d) { - var e = +(d == 'e'), - x = e ? 1 : -1, - y = availableHeight2 / 3; - return 'M' + (.5 * x) + ',' + y - + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6) - + 'V' + (2 * y - 6) - + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y) - + 'Z' - + 'M' + (2.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8) - + 'M' + (4.5 * x) + ',' + (y + 8) - + 'V' + (2 * y - 8); - } - - - function updateBrushBG() { - if (!brush.empty()) brush.extent(brushExtent); - brushBG - .data([brush.empty() ? x2.domain() : brushExtent]) - .each(function(d,i) { - var leftWidth = x2(d[0]) - x.range()[0], - rightWidth = x.range()[1] - x2(d[1]); - d3.select(this).select('.left') - .attr('width', leftWidth < 0 ? 0 : leftWidth); - - d3.select(this).select('.right') - .attr('x', x2(d[1])) - .attr('width', rightWidth < 0 ? 0 : rightWidth); - }); - } - - - function onBrush() { - brushExtent = brush.empty() ? null : brush.extent(); - var extent = brush.empty() ? x2.domain() : brush.extent(); - - //The brush extent cannot be less than one. If it is, don't update the line chart. - if (Math.abs(extent[0] - extent[1]) <= 1) { - return; - } - - dispatch.brush({extent: extent, brush: brush}); - - - updateBrushBG(); - - // Update Main (Focus) - var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') - .datum( - data - .filter(function(d) { return !d.disabled }) - .map(function(d,i) { - return { - key: d.key, - area: d.area, - values: d.values.filter(function(d,i) { - return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1]; - }) - } - }) - ); - focusLinesWrap.transition().duration(transitionDuration).call(lines); - - - // Update Main (Focus) Axes - g.select('.nv-focus .nv-x.nv-axis').transition().duration(transitionDuration) - .call(xAxis); - g.select('.nv-focus .nv-y.nv-axis').transition().duration(transitionDuration) - .call(yAxis); - } - - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.legend = legend; - chart.lines = lines; - chart.lines2 = lines2; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.x2Axis = x2Axis; - chart.y2Axis = y2Axis; - - d3.rebind(chart, lines, 'defined', 'isArea', 'size', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'interactive', 'clipEdge', 'clipVoronoi', 'id'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return lines.x; - lines.x(_); - lines2.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return lines.y; - lines.y(_); - lines2.y(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.margin2 = function(_) { - if (!arguments.length) return margin2; - margin2 = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.height2 = function(_) { - if (!arguments.length) return height2; - height2 = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color =nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.interpolate = function(_) { - if (!arguments.length) return lines.interpolate(); - lines.interpolate(_); - lines2.interpolate(_); - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - // Chart has multiple similar Axes, to prevent code duplication, probably need to link all axis functions manually like below - chart.xTickFormat = function(_) { - if (!arguments.length) return xAxis.tickFormat(); - xAxis.tickFormat(_); - x2Axis.tickFormat(_); - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return yAxis.tickFormat(); - yAxis.tickFormat(_); - y2Axis.tickFormat(_); - return chart; - }; - - chart.brushExtent = function(_) { - if (!arguments.length) return brushExtent; - brushExtent = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/multiBar.js b/awx/ui/static/lib/novus-nvd3/src/models/multiBar.js deleted file mode 100755 index 1085919b02..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/multiBar.js +++ /dev/null @@ -1,461 +0,0 @@ - -nv.models.multiBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , x = d3.scale.ordinal() - , y = d3.scale.linear() - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove - , clipEdge = true - , stacked = false - , stackOffset = 'zero' // options include 'silhouette', 'wiggle', 'expand', 'zero', or a custom function - , color = nv.utils.defaultColor() - , hideable = false - , barColor = null // adding the ability to set the color for each rather than the whole group - , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled - , delay = 1200 - , xDomain - , yDomain - , xRange - , yRange - , groupSpacing = 0.1 - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0 //used to store previous scales - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - if(hideable && data.length) hideable = [{ - values: data[0].values.map(function(d) { - return { - x: d.x, - y: 0, - series: d.series, - size: 0.01 - };} - )}]; - - if (stacked) - data = d3.layout.stack() - .offset(stackOffset) - .values(function(d){ return d.values }) - .y(getY) - (!data.length && hideable ? hideable : data); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - - //------------------------------------------------------------ - // HACK for negative value stacking - if (stacked) - data[0].values.map(function(d,i) { - var posBase = 0, negBase = 0; - data.map(function(d) { - var f = d.values[i] - f.size = Math.abs(f.y); - if (f.y<0) { - f.y1 = negBase; - negBase = negBase - f.size; - } else - { - f.y1 = f.size + posBase; - posBase = posBase + f.size; - } - }); - }); - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 } - }) - }); - - x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands(xRange || [0, availableWidth], groupSpacing); - - //y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y + (stacked ? d.y1 : 0) }).concat(forceY))) - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 : d.y1 + d.y ) : d.y }).concat(forceY))) - .range(yRange || [availableHeight, 0]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multibar').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - gEnter.append('g').attr('class', 'nv-groups'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d,i) { return i }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit() - .transition() - .selectAll('rect.nv-bar') - .delay(function(d,i) { - return i * delay/ data[0].values.length; - }) - .attr('y', function(d) { return stacked ? y0(d.y0) : y0(0) }) - .attr('height', 0) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i) }); - groups - .transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .75); - - - var bars = groups.selectAll('rect.nv-bar') - .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('rect') - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) - .attr('x', function(d,i,j) { - return stacked ? 0 : (j * x.rangeBand() / data.length ) - }) - .attr('y', function(d) { return y0(stacked ? d.y0 : 0) }) - .attr('height', 0) - .attr('width', x.rangeBand() / (stacked ? 1 : data.length) ) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) - ; - bars - .style('fill', function(d,i,j){ return color(d, j, i); }) - .style('stroke', function(d,i,j){ return color(d, j, i); }) - .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - value: getY(d,i), - point: d, - series: data[d.series], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }); - bars - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) - .transition() - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) - - if (barColor) { - if (!disabled) disabled = data.map(function() { return true }); - bars - .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }) - .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }); - } - - - if (stacked) - bars.transition() - .delay(function(d,i) { - - return i * delay / data[0].values.length; - }) - .attr('y', function(d,i) { - - return y((stacked ? d.y1 : 0)); - }) - .attr('height', function(d,i) { - return Math.max(Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0))),1); - }) - .attr('x', function(d,i) { - return stacked ? 0 : (d.series * x.rangeBand() / data.length ) - }) - .attr('width', x.rangeBand() / (stacked ? 1 : data.length) ); - else - bars.transition() - .delay(function(d,i) { - return i * delay/ data[0].values.length; - }) - .attr('x', function(d,i) { - return d.series * x.rangeBand() / data.length - }) - .attr('width', x.rangeBand() / data.length) - .attr('y', function(d,i) { - return getY(d,i) < 0 ? - y(0) : - y(0) - y(getY(d,i)) < 1 ? - y(0) - 1 : - y(getY(d,i)) || 0; - }) - .attr('height', function(d,i) { - return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0; - }); - - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.stacked = function(_) { - if (!arguments.length) return stacked; - stacked = _; - return chart; - }; - - chart.stackOffset = function(_) { - if (!arguments.length) return stackOffset; - stackOffset = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.barColor = function(_) { - if (!arguments.length) return barColor; - barColor = nv.utils.getColor(_); - return chart; - }; - - chart.disabled = function(_) { - if (!arguments.length) return disabled; - disabled = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.hideable = function(_) { - if (!arguments.length) return hideable; - hideable = _; - return chart; - }; - - chart.delay = function(_) { - if (!arguments.length) return delay; - delay = _; - return chart; - }; - - chart.groupSpacing = function(_) { - if (!arguments.length) return groupSpacing; - groupSpacing = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/multiBarChart.js b/awx/ui/static/lib/novus-nvd3/src/models/multiBarChart.js deleted file mode 100755 index 0323063f40..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/multiBarChart.js +++ /dev/null @@ -1,524 +0,0 @@ - -nv.models.multiBarChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var multibar = nv.models.multiBar() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.defaultColor() - , showControls = true - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , reduceXTicks = true // if false a tick will show for every data point - , staggerLabels = false - , rotateLabels = 0 - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' on ' + x + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , state = { stacked: false } - , defaultState = null - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , controlWidth = function() { return showControls ? 180 : 0 } - , transitionDuration = 250 - ; - - multibar - .stacked(false) - ; - xAxis - .orient('bottom') - .tickPadding(7) - .highlightZero(true) - .showMaxMin(false) - .tickFormat(function(d) { return d }) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickFormat(d3.format(',.1f')) - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = multibar.xScale(); - y = multibar.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multiBarWithLegend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarWithLegend').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth - controlWidth()); - - if (multibar.barColor()) - data.forEach(function(series,i) { - series.color = d3.rgb('#ccc').darker(i * 1.5).toString(); - }) - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { key: 'Grouped', disabled: multibar.stacked() }, - { key: 'Stacked', disabled: !multibar.stacked() } - ]; - - controls.width(controlWidth()).color(['#444', '#444', '#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - multibar - .disabled(data.map(function(series) { return series.disabled })) - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(multibar); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - g.select('.nv-x.nv-axis').transition() - .call(xAxis); - - var xTicks = g.select('.nv-x.nv-axis > g').selectAll('g'); - - xTicks - .selectAll('line, text') - .style('opacity', 1) - - if (staggerLabels) { - var getTranslate = function(x,y) { - return "translate(" + x + "," + y + ")"; - }; - - var staggerUp = 5, staggerDown = 17; //pixels to stagger by - // Issue #140 - xTicks - .selectAll("text") - .attr('transform', function(d,i,j) { - return getTranslate(0, (j % 2 == 0 ? staggerUp : staggerDown)); - }); - - var totalInBetweenTicks = d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length; - g.selectAll(".nv-x.nv-axis .nv-axisMaxMin text") - .attr("transform", function(d,i) { - return getTranslate(0, (i === 0 || totalInBetweenTicks % 2 !== 0) ? staggerDown : staggerUp); - }); - } - - if (reduceXTicks) - xTicks - .filter(function(d,i) { - return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0; - }) - .selectAll('text, line') - .style('opacity', 0); - - if(rotateLabels) - xTicks - .selectAll('.tick text') - .attr('transform', 'rotate(' + rotateLabels + ' 0,0)') - .style('text-anchor', rotateLabels > 0 ? 'start' : 'end'); - - g.select('.nv-x.nv-axis').selectAll('g.nv-axisMaxMin text') - .style('opacity', 1); - } - - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis').transition() - .call(yAxis); - } - - - //------------------------------------------------------------ - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Grouped': - multibar.stacked(false); - break; - case 'Stacked': - multibar.stacked(true); - break; - } - - state.stacked = multibar.stacked(); - dispatch.stateChange(state); - - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode) - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - if (typeof e.stacked !== 'undefined') { - multibar.stacked(e.stacked); - state.stacked = e.stacked; - } - - chart.update(); - }); - - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - multibar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - multibar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.multibar = multibar; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'clipEdge', - 'id', 'stacked', 'stackOffset', 'delay', 'barColor','groupSpacing'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.reduceXTicks= function(_) { - if (!arguments.length) return reduceXTicks; - reduceXTicks = _; - return chart; - }; - - chart.rotateLabels = function(_) { - if (!arguments.length) return rotateLabels; - rotateLabels = _; - return chart; - } - - chart.staggerLabels = function(_) { - if (!arguments.length) return staggerLabels; - staggerLabels = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/multiBarHorizontal.js b/awx/ui/static/lib/novus-nvd3/src/models/multiBarHorizontal.js deleted file mode 100755 index d617ae1d64..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/multiBarHorizontal.js +++ /dev/null @@ -1,447 +0,0 @@ - -nv.models.multiBarHorizontal = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.ordinal() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove - , color = nv.utils.defaultColor() - , barColor = null // adding the ability to set the color for each rather than the whole group - , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled - , stacked = false - , showValues = false - , showBarLabels = false - , valuePadding = 60 - , valueFormat = d3.format(',.2f') - , delay = 1200 - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0 //used to store previous scales - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - if (stacked) - data = d3.layout.stack() - .offset('zero') - .values(function(d){ return d.values }) - .y(getY) - (data); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - - - //------------------------------------------------------------ - // HACK for negative value stacking - if (stacked) - data[0].values.map(function(d,i) { - var posBase = 0, negBase = 0; - data.map(function(d) { - var f = d.values[i] - f.size = Math.abs(f.y); - if (f.y<0) { - f.y1 = negBase - f.size; - negBase = negBase - f.size; - } else - { - f.y1 = posBase; - posBase = posBase + f.size; - } - }); - }); - - - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 } - }) - }); - - x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) - .rangeBands(xRange || [0, availableHeight], .1); - - //y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y + (stacked ? d.y0 : 0) }).concat(forceY))) - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 + d.y : d.y1 ) : d.y }).concat(forceY))) - - if (showValues && !stacked) - y.range(yRange || [(y.domain()[0] < 0 ? valuePadding : 0), availableWidth - (y.domain()[1] > 0 ? valuePadding : 0) ]); - else - y.range(yRange || [0, availableWidth]); - - x0 = x0 || x; - y0 = y0 || d3.scale.linear().domain(y.domain()).range([y(0),y(0)]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('g.nv-wrap.nv-multibarHorizontal').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibarHorizontal'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-groups'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d,i) { return i }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit().transition() - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i) }); - groups.transition() - .style('stroke-opacity', 1) - .style('fill-opacity', .75); - - - var bars = groups.selectAll('g.nv-bar') - .data(function(d) { return d.values }); - - bars.exit().remove(); - - - var barsEnter = bars.enter().append('g') - .attr('transform', function(d,i,j) { - return 'translate(' + y0(stacked ? d.y0 : 0) + ',' + (stacked ? 0 : (j * x.rangeBand() / data.length ) + x(getX(d,i))) + ')' - }); - - barsEnter.append('rect') - .attr('width', 0) - .attr('height', x.rangeBand() / (stacked ? 1 : data.length) ) - - bars - .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [ y(getY(d,i) + (stacked ? d.y0 : 0)), x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length) ], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - value: getY(d,i), - point: d, - series: data[d.series], - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - value: getY(d,i), - point: d, - series: data[d.series], - pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: d.series, - e: d3.event - }); - d3.event.stopPropagation(); - }); - - - barsEnter.append('text'); - - if (showValues && !stacked) { - bars.select('text') - .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'end' : 'start' }) - .attr('y', x.rangeBand() / (data.length * 2)) - .attr('dy', '.32em') - .text(function(d,i) { return valueFormat(getY(d,i)) }) - bars.transition() - .select('text') - .attr('x', function(d,i) { return getY(d,i) < 0 ? -4 : y(getY(d,i)) - y(0) + 4 }) - } else { - bars.selectAll('text').text(''); - } - - if (showBarLabels && !stacked) { - barsEnter.append('text').classed('nv-bar-label',true); - bars.select('text.nv-bar-label') - .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'start' : 'end' }) - .attr('y', x.rangeBand() / (data.length * 2)) - .attr('dy', '.32em') - .text(function(d,i) { return getX(d,i) }); - bars.transition() - .select('text.nv-bar-label') - .attr('x', function(d,i) { return getY(d,i) < 0 ? y(0) - y(getY(d,i)) + 4 : -4 }); - } - else { - bars.selectAll('text.nv-bar-label').text(''); - } - - bars - .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) - - if (barColor) { - if (!disabled) disabled = data.map(function() { return true }); - bars - .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }) - .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }); - } - - if (stacked) - bars.transition() - .attr('transform', function(d,i) { - return 'translate(' + y(d.y1) + ',' + x(getX(d,i)) + ')' - }) - .select('rect') - .attr('width', function(d,i) { - return Math.abs(y(getY(d,i) + d.y0) - y(d.y0)) - }) - .attr('height', x.rangeBand() ); - else - bars.transition() - .attr('transform', function(d,i) { - //TODO: stacked must be all positive or all negative, not both? - return 'translate(' + - (getY(d,i) < 0 ? y(getY(d,i)) : y(0)) - + ',' + - (d.series * x.rangeBand() / data.length - + - x(getX(d,i)) ) - + ')' - }) - .select('rect') - .attr('height', x.rangeBand() / data.length ) - .attr('width', function(d,i) { - return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) - }); - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.stacked = function(_) { - if (!arguments.length) return stacked; - stacked = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.barColor = function(_) { - if (!arguments.length) return barColor; - barColor = nv.utils.getColor(_); - return chart; - }; - - chart.disabled = function(_) { - if (!arguments.length) return disabled; - disabled = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.delay = function(_) { - if (!arguments.length) return delay; - delay = _; - return chart; - }; - - chart.showValues = function(_) { - if (!arguments.length) return showValues; - showValues = _; - return chart; - }; - - chart.showBarLabels = function(_) { - if (!arguments.length) return showBarLabels; - showBarLabels = _; - return chart; - }; - - - chart.valueFormat= function(_) { - if (!arguments.length) return valueFormat; - valueFormat = _; - return chart; - }; - - chart.valuePadding = function(_) { - if (!arguments.length) return valuePadding; - valuePadding = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/multiBarHorizontalChart.js b/awx/ui/static/lib/novus-nvd3/src/models/multiBarHorizontalChart.js deleted file mode 100755 index 4b54559663..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/multiBarHorizontalChart.js +++ /dev/null @@ -1,461 +0,0 @@ - -nv.models.multiBarHorizontalChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var multibar = nv.models.multiBarHorizontal() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend().height(30) - , controls = nv.models.legend().height(30) - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.defaultColor() - , showControls = true - , showLegend = true - , showXAxis = true - , showYAxis = true - , stacked = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + ' - ' + x + '

' + - '

' + y + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , state = { stacked: stacked } - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , controlWidth = function() { return showControls ? 180 : 0 } - , transitionDuration = 250 - ; - - multibar - .stacked(stacked) - ; - xAxis - .orient('left') - .tickPadding(5) - .highlightZero(false) - .showMaxMin(false) - .tickFormat(function(d) { return d }) - ; - yAxis - .orient('bottom') - .tickFormat(d3.format(',.1f')) - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = multibar.xScale(); - y = multibar.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multiBarHorizontalChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarHorizontalChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis') - .append('g').attr('class', 'nv-zeroLine') - .append('line'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth - controlWidth()); - - if (multibar.barColor()) - data.forEach(function(series,i) { - series.color = d3.rgb('#ccc').darker(i * 1.5).toString(); - }) - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { key: 'Grouped', disabled: multibar.stacked() }, - { key: 'Stacked', disabled: !multibar.stacked() } - ]; - - controls.width(controlWidth()).color(['#444', '#444', '#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - multibar - .disabled(data.map(function(series) { return series.disabled })) - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - barsWrap.transition().call(multibar); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableHeight / 24 ) - .tickSize(-availableWidth, 0); - - g.select('.nv-x.nv-axis').transition() - .call(xAxis); - - var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); - - xTicks - .selectAll('line, text'); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight, 0); - - g.select('.nv-y.nv-axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - g.select('.nv-y.nv-axis').transition() - .call(yAxis); - } - - // Zero line - g.select(".nv-zeroLine line") - .attr("x1", y(0)) - .attr("x2", y(0)) - .attr("y1", 0) - .attr("y2", -availableHeight) - ; - - //------------------------------------------------------------ - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Grouped': - multibar.stacked(false); - break; - case 'Stacked': - multibar.stacked(true); - break; - } - - state.stacked = multibar.stacked(); - dispatch.stateChange(state); - - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - if (typeof e.stacked !== 'undefined') { - multibar.stacked(e.stacked); - state.stacked = e.stacked; - } - - chart.update(); - }); - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - multibar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - multibar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.multibar = multibar; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', - 'clipEdge', 'id', 'delay', 'showValues','showBarLabels', 'valueFormat', 'stacked', 'barColor'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/multiBarTimeSeries.js b/awx/ui/static/lib/novus-nvd3/src/models/multiBarTimeSeries.js deleted file mode 100755 index abc062c387..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/multiBarTimeSeries.js +++ /dev/null @@ -1,384 +0,0 @@ -nv.models.multiBarTimeSeries = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , x = d3.time.scale() - , y = d3.scale.linear() - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove - , clipEdge = true - , stacked = false - , color = nv.utils.defaultColor() - , delay = 1200 - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0 //used to store previous scales - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - if (stacked) - data = d3.layout.stack() - .offset('zero') - .values(function(d){ return d.values }) - .y(getY) - (data); - - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), y0: d.y0 } - }) - }); - - x .domain(xDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.x }))) - .range(xRange || [0, availableWidth]); - - y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y + (stacked ? d.y0 : 0) }).concat(forceY))) - .range(yRange || [availableHeight, 0]); - - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multibar').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - gEnter.append('g').attr('class', 'nv-groups'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - d3.transition(groups.exit()) - //.style('stroke-opacity', 1e-6) - //.style('fill-opacity', 1e-6) - .selectAll('rect.nv-bar') - .delay(function(d,i) { return i * delay/ data[0].values.length }) - .attr('y', function(d) { return stacked ? y0(d.y0) : y0(0) }) - .attr('height', 0) - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }) - .style('fill', function(d,i){ return color(d, i) }) - .style('stroke', function(d,i){ return color(d, i) }); - d3.transition(groups) - .style('stroke-opacity', 1) - .style('fill-opacity', .75); - - - var bars = groups.selectAll('rect.nv-bar') - .data(function(d) { return d.values }); - - bars.exit().remove(); - - var maxElements = 0; - for(var ei=0; ei' + key + '' + - '

' + y + ' on ' + x + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') - ; - - multibar - .stacked(false) - ; - xAxis - .orient('bottom') - .tickPadding(7) - .highlightZero(false) - .showMaxMin(false) - ; - yAxis - .orient('left') - .tickFormat(d3.format(',.1f')) - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { selection.transition().call(chart) }; - chart.container = this; - - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = multibar.xScale(); - y = multibar.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-multiBarWithLegend').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarWithLegend').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-barsWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width(availableWidth / 2); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { key: 'Grouped', disabled: multibar.stacked() }, - { key: 'Stacked', disabled: !multibar.stacked() } - ]; - - controls.width(180).color(['#444', '#444', '#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - multibar - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - - var barsWrap = g.select('.nv-barsWrap') - .datum(data.filter(function(d) { return !d.disabled })) - - d3.transition(barsWrap).call(multibar); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - xAxis - .scale(x) - .ticks(availableWidth / 100) - .tickSize(-availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')'); - d3.transition(g.select('.nv-x.nv-axis')) - .call(xAxis); - - var xTicks = g.select('.nv-x.nv-axis > g').selectAll('g'); - - xTicks - .selectAll('line, text') - .style('opacity', 1) - - if (reduceXTicks) - xTicks - .filter(function(d,i) { - return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0; - }) - .selectAll('text, line') - .style('opacity', 0); - - if(rotateLabels) - xTicks - .selectAll('text') - .attr('transform', function(d,i,j) { return 'rotate('+rotateLabels+' 0,0)' }) - .attr('text-transform', rotateLabels > 0 ? 'start' : 'end'); - - yAxis - .scale(y) - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.nv-y.nv-axis')) - .call(yAxis); - - //------------------------------------------------------------ - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - if (!data.filter(function(d) { return !d.disabled }).length) { - data.map(function(d) { - d.disabled = false; - wrap.selectAll('.nv-series').classed('disabled', false); - return d; - }); - } - - selection.transition().call(chart); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - switch (d.key) { - case 'Grouped': - multibar.stacked(false); - break; - case 'Stacked': - multibar.stacked(true); - break; - } - - selection.transition().call(chart); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode) - }); - - //============================================================ - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - multibar.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - multibar.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.multibar = multibar; - chart.legend = legend; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - - d3.rebind(chart, multibar, 'x', 'y', 'xDomain', 'yDomain', 'xRange', 'yRange', 'forceX', 'forceY', 'clipEdge', 'id', 'stacked', 'delay'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.reduceXTicks= function(_) { - if (!arguments.length) return reduceXTicks; - reduceXTicks = _; - return chart; - }; - - chart.rotateLabels = function(_) { - if (!arguments.length) return rotateLabels; - rotateLabels = _; - return chart; - } - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -} - diff --git a/awx/ui/static/lib/novus-nvd3/src/models/multiChart.js b/awx/ui/static/lib/novus-nvd3/src/models/multiChart.js deleted file mode 100755 index e3e2c5e86e..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/multiChart.js +++ /dev/null @@ -1,452 +0,0 @@ -nv.models.multiChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 30, right: 20, bottom: 50, left: 60}, - color = d3.scale.category20().range(), - width = null, - height = null, - showLegend = true, - tooltips = true, - tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' at ' + x + '

' - }, - x, - y, - yDomain1, - yDomain2 - ; //can be accessed via chart.lines.[x/y]Scale() - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x = d3.scale.linear(), - yScale1 = d3.scale.linear(), - yScale2 = d3.scale.linear(), - - lines1 = nv.models.line().yScale(yScale1), - lines2 = nv.models.line().yScale(yScale2), - - bars1 = nv.models.multiBar().stacked(false).yScale(yScale1), - bars2 = nv.models.multiBar().stacked(false).yScale(yScale2), - - stack1 = nv.models.stackedArea().yScale(yScale1), - stack2 = nv.models.stackedArea().yScale(yScale2), - - xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5), - yAxis1 = nv.models.axis().scale(yScale1).orient('left'), - yAxis2 = nv.models.axis().scale(yScale2).orient('right'), - - legend = nv.models.legend().height(30), - dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(lines1.x()(e.point, e.pointIndex)), - y = ((e.series.yAxis == 2) ? yAxis2 : yAxis1).tickFormat()(lines1.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, undefined, undefined, offsetElement.offsetParent); - }; - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - chart.update = function() { container.transition().call(chart); }; - chart.container = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - var dataLines1 = data.filter(function(d) {return !d.disabled && d.type == 'line' && d.yAxis == 1}) - var dataLines2 = data.filter(function(d) {return !d.disabled && d.type == 'line' && d.yAxis == 2}) - var dataBars1 = data.filter(function(d) {return !d.disabled && d.type == 'bar' && d.yAxis == 1}) - var dataBars2 = data.filter(function(d) {return !d.disabled && d.type == 'bar' && d.yAxis == 2}) - var dataStack1 = data.filter(function(d) {return !d.disabled && d.type == 'area' && d.yAxis == 1}) - var dataStack2 = data.filter(function(d) {return !d.disabled && d.type == 'area' && d.yAxis == 2}) - - var series1 = data.filter(function(d) {return !d.disabled && d.yAxis == 1}) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: d.x, y: d.y } - }) - }) - - var series2 = data.filter(function(d) {return !d.disabled && d.yAxis == 2}) - .map(function(d) { - return d.values.map(function(d,i) { - return { x: d.x, y: d.y } - }) - }) - - x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) - .range([0, availableWidth]); - - var wrap = container.selectAll('g.wrap.multiChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiChart').append('g'); - - gEnter.append('g').attr('class', 'x axis'); - gEnter.append('g').attr('class', 'y1 axis'); - gEnter.append('g').attr('class', 'y2 axis'); - gEnter.append('g').attr('class', 'lines1Wrap'); - gEnter.append('g').attr('class', 'lines2Wrap'); - gEnter.append('g').attr('class', 'bars1Wrap'); - gEnter.append('g').attr('class', 'bars2Wrap'); - gEnter.append('g').attr('class', 'stack1Wrap'); - gEnter.append('g').attr('class', 'stack2Wrap'); - gEnter.append('g').attr('class', 'legendWrap'); - - var g = wrap.select('g'); - - if (showLegend) { - legend.width( availableWidth / 2 ); - - g.select('.legendWrap') - .datum(data.map(function(series) { - series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; - series.key = series.originalKey + (series.yAxis == 1 ? '' : ' (right axis)'); - return series; - })) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.legendWrap') - .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); - } - - - lines1 - .width(availableWidth) - .height(availableHeight) - .interpolate("monotone") - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'line'})); - - lines2 - .width(availableWidth) - .height(availableHeight) - .interpolate("monotone") - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'line'})); - - bars1 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'bar'})); - - bars2 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'bar'})); - - stack1 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'area'})); - - stack2 - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color[i % color.length]; - }).filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'area'})); - - g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - var lines1Wrap = g.select('.lines1Wrap') - .datum(dataLines1) - var bars1Wrap = g.select('.bars1Wrap') - .datum(dataBars1) - var stack1Wrap = g.select('.stack1Wrap') - .datum(dataStack1) - - var lines2Wrap = g.select('.lines2Wrap') - .datum(dataLines2) - var bars2Wrap = g.select('.bars2Wrap') - .datum(dataBars2) - var stack2Wrap = g.select('.stack2Wrap') - .datum(dataStack2) - - var extraValue1 = dataStack1.length ? dataStack1.map(function(a){return a.values}).reduce(function(a,b){ - return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}}) - }).concat([{x:0, y:0}]) : [] - var extraValue2 = dataStack2.length ? dataStack2.map(function(a){return a.values}).reduce(function(a,b){ - return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}}) - }).concat([{x:0, y:0}]) : [] - - yScale1 .domain(yDomain1 || d3.extent(d3.merge(series1).concat(extraValue1), function(d) { return d.y } )) - .range([0, availableHeight]) - - yScale2 .domain(yDomain2 || d3.extent(d3.merge(series2).concat(extraValue2), function(d) { return d.y } )) - .range([0, availableHeight]) - - lines1.yDomain(yScale1.domain()) - bars1.yDomain(yScale1.domain()) - stack1.yDomain(yScale1.domain()) - - lines2.yDomain(yScale2.domain()) - bars2.yDomain(yScale2.domain()) - stack2.yDomain(yScale2.domain()) - - if(dataStack1.length){d3.transition(stack1Wrap).call(stack1);} - if(dataStack2.length){d3.transition(stack2Wrap).call(stack2);} - - if(dataBars1.length){d3.transition(bars1Wrap).call(bars1);} - if(dataBars2.length){d3.transition(bars2Wrap).call(bars2);} - - if(dataLines1.length){d3.transition(lines1Wrap).call(lines1);} - if(dataLines2.length){d3.transition(lines2Wrap).call(lines2);} - - - - xAxis - .ticks( availableWidth / 100 ) - .tickSize(-availableHeight, 0); - - g.select('.x.axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - d3.transition(g.select('.x.axis')) - .call(xAxis); - - yAxis1 - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - - d3.transition(g.select('.y1.axis')) - .call(yAxis1); - - yAxis2 - .ticks( availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - d3.transition(g.select('.y2.axis')) - .call(yAxis2); - - g.select('.y2.axis') - .style('opacity', series2.length ? 1 : 0) - .attr('transform', 'translate(' + x.range()[1] + ',0)'); - - legend.dispatch.on('stateChange', function(newState) { - chart.update(); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - lines1.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines1.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - lines2.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines2.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars1.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars1.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - bars2.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - bars2.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - stack1.dispatch.on('tooltipShow', function(e) { - //disable tooltips when value ~= 0 - //// TODO: consider removing points from voronoi that have 0 value instead of this hack - if (!Math.round(stack1.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range - setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); - return false; - } - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - stack1.dispatch.on('tooltipHide', function(e) { - dispatch.tooltipHide(e); - }); - - stack2.dispatch.on('tooltipShow', function(e) { - //disable tooltips when value ~= 0 - //// TODO: consider removing points from voronoi that have 0 value instead of this hack - if (!Math.round(stack2.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range - setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); - return false; - } - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - stack2.dispatch.on('tooltipHide', function(e) { - dispatch.tooltipHide(e); - }); - - lines1.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines1.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - lines2.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - lines2.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - - - //============================================================ - // Global getters and setters - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.lines1 = lines1; - chart.lines2 = lines2; - chart.bars1 = bars1; - chart.bars2 = bars2; - chart.stack1 = stack1; - chart.stack2 = stack2; - chart.xAxis = xAxis; - chart.yAxis1 = yAxis1; - chart.yAxis2 = yAxis2; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - lines1.x(_); - bars1.x(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - lines1.y(_); - bars1.y(_); - return chart; - }; - - chart.yDomain1 = function(_) { - if (!arguments.length) return yDomain1; - yDomain1 = _; - return chart; - }; - - chart.yDomain2 = function(_) { - if (!arguments.length) return yDomain2; - yDomain2 = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin = _; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = _; - legend.color(_); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - return chart; -} - diff --git a/awx/ui/static/lib/novus-nvd3/src/models/ohlcBar.js b/awx/ui/static/lib/novus-nvd3/src/models/ohlcBar.js deleted file mode 100755 index 46f2b60c2c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/ohlcBar.js +++ /dev/null @@ -1,380 +0,0 @@ - -nv.models.ohlcBar = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , x = d3.scale.linear() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , getOpen = function(d) { return d.open } - , getClose = function(d) { return d.close } - , getHigh = function(d) { return d.high } - , getLow = function(d) { return d.low } - , forceX = [] - , forceY = [] - , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart - , clipEdge = true - , color = nv.utils.defaultColor() - , xDomain - , yDomain - , xRange - , yRange - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - //TODO: store old scales for transitions - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - x .domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )); - - if (padData) - x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); - else - x.range(xRange || [0, availableWidth]); - - y .domain(yDomain || [ - d3.min(data[0].values.map(getLow).concat(forceY)), - d3.max(data[0].values.map(getHigh).concat(forceY)) - ]) - .range(yRange || [availableHeight, 0]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = d3.select(this).selectAll('g.nv-wrap.nv-ohlcBar').data([data[0].values]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-ohlcBar'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-ticks'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - container - .on('click', function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - defsEnter.append('clipPath') - .attr('id', 'nv-chart-clip-path-' + id) - .append('rect'); - - wrap.select('#nv-chart-clip-path-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); - - - - var ticks = wrap.select('.nv-ticks').selectAll('.nv-tick') - .data(function(d) { return d }); - - ticks.exit().remove(); - - - var ticksEnter = ticks.enter().append('path') - .attr('class', function(d,i,j) { return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i }) - .attr('d', function(d,i) { - var w = (availableWidth / data[0].values.length) * .9; - return 'm0,0l0,' - + (y(getOpen(d,i)) - - y(getHigh(d,i))) - + 'l' - + (-w/2) - + ',0l' - + (w/2) - + ',0l0,' - + (y(getLow(d,i)) - y(getOpen(d,i))) - + 'l0,' - + (y(getClose(d,i)) - - y(getLow(d,i))) - + 'l' - + (w/2) - + ',0l' - + (-w/2) - + ',0z'; - }) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; }) - //.attr('fill', function(d,i) { return color[0]; }) - //.attr('stroke', function(d,i) { return color[0]; }) - //.attr('x', 0 ) - //.attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) }) - //.attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) }) - .on('mouseover', function(d,i) { - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - point: d, - series: data[0], - pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - point: d, - series: data[0], - pointIndex: i, - seriesIndex: 0, - e: d3.event - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - //label: d[label], - value: getY(d,i), - data: d, - index: i, - pos: [x(getX(d,i)), y(getY(d,i))], - e: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - ticks - .attr('class', function(d,i,j) { return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i }) - d3.transition(ticks) - .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; }) - .attr('d', function(d,i) { - var w = (availableWidth / data[0].values.length) * .9; - return 'm0,0l0,' - + (y(getOpen(d,i)) - - y(getHigh(d,i))) - + 'l' - + (-w/2) - + ',0l' - + (w/2) - + ',0l0,' - + (y(getLow(d,i)) - - y(getOpen(d,i))) - + 'l0,' - + (y(getClose(d,i)) - - y(getLow(d,i))) - + 'l' - + (w/2) - + ',0l' - + (-w/2) - + ',0z'; - }) - //.attr('width', (availableWidth / data[0].values.length) * .9 ) - - - //d3.transition(ticks) - //.attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) }) - //.attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) }); - //.order(); // not sure if this makes any sense for this model - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = _; - return chart; - }; - - chart.open = function(_) { - if (!arguments.length) return getOpen; - getOpen = _; - return chart; - }; - - chart.close = function(_) { - if (!arguments.length) return getClose; - getClose = _; - return chart; - }; - - chart.high = function(_) { - if (!arguments.length) return getHigh; - getHigh = _; - return chart; - }; - - chart.low = function(_) { - if (!arguments.length) return getLow; - getLow = _; - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.padData = function(_) { - if (!arguments.length) return padData; - padData = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/parallelCoordinates.js b/awx/ui/static/lib/novus-nvd3/src/models/parallelCoordinates.js deleted file mode 100755 index 107154f72b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/parallelCoordinates.js +++ /dev/null @@ -1,239 +0,0 @@ - -//Code adapted from Jason Davies' "Parallel Coordinates" -// http://bl.ocks.org/jasondavies/1341281 - -nv.models.parallelCoordinates = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - - var margin = {top: 30, right: 10, bottom: 10, left: 10} - , width = 960 - , height = 500 - , x = d3.scale.ordinal() - , y = {} - , dimensions = [] - , color = nv.utils.getColor(d3.scale.category20c().range()) - , axisLabel = function(d) { return d; } - , filters = [] - , active = [] - , dispatch = d3.dispatch('brush') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - active = data; //set all active before first brush call - - chart.update = function() { }; //This is a placeholder until this chart is made resizeable - - //------------------------------------------------------------ - // Setup Scales - - x - .rangePoints([0, availableWidth], 1) - .domain(dimensions); - - // Extract the list of dimensions and create a scale for each. - dimensions.forEach(function(d) { - y[d] = d3.scale.linear() - .domain(d3.extent(data, function(p) { return +p[d]; })) - .range([availableHeight, 0]); - - y[d].brush = d3.svg.brush().y(y[d]).on('brush', brush); - - return d != 'name'; - }) - - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-parallelCoordinates').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-parallelCoordinates'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - gEnter.append('g').attr('class', 'nv-parallelCoordinatesWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - var line = d3.svg.line(), - axis = d3.svg.axis().orient('left'), - background, - foreground; - - - // Add grey background lines for context. - background = gEnter.append('g') - .attr('class', 'background') - .selectAll('path') - .data(data) - .enter().append('path') - .attr('d', path) - ; - - // Add blue foreground lines for focus. - foreground = gEnter.append('g') - .attr('class', 'foreground') - .selectAll('path') - .data(data) - .enter().append('path') - .attr('d', path) - ; - - // Add a group element for each dimension. - var dimension = g.selectAll('.dimension') - .data(dimensions) - .enter().append('g') - .attr('class', 'dimension') - .attr('transform', function(d) { return 'translate(' + x(d) + ',0)'; }); - - // Add an axis and title. - dimension.append('g') - .attr('class', 'axis') - .each(function(d) { d3.select(this).call(axis.scale(y[d])); }) - .append('text') - .attr('text-anchor', 'middle') - .attr('y', -9) - .text(String); - - // Add and store a brush for each axis. - dimension.append('g') - .attr('class', 'brush') - .each(function(d) { d3.select(this).call(y[d].brush); }) - .selectAll('rect') - .attr('x', -8) - .attr('width', 16); - - - // Returns the path for a given data point. - function path(d) { - return line(dimensions.map(function(p) { return [x(p), y[p](d[p])]; })); - } - - // Handles a brush event, toggling the display of foreground lines. - function brush() { - var actives = dimensions.filter(function(p) { return !y[p].brush.empty(); }), - extents = actives.map(function(p) { return y[p].brush.extent(); }); - - filters = []; //erase current filters - actives.forEach(function(d,i) { - filters[i] = { - dimension: d, - extent: extents[i] - } - }); - - active = []; //erase current active list - foreground.style('display', function(d) { - var isActive = actives.every(function(p, i) { - return extents[i][0] <= d[p] && d[p] <= extents[i][1]; - }); - if (isActive) active.push(d); - return isActive ? null : 'none'; - }); - - dispatch.brush({ - filters: filters, - active: active - }); - - } - - - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - - chart.dispatch = dispatch; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_) - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.dimensions = function(_) { - if (!arguments.length) return dimensions; - dimensions = _; - return chart; - }; - - chart.filters = function() { - return filters; - }; - - chart.active = function() { - return active; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/pie.js b/awx/ui/static/lib/novus-nvd3/src/models/pie.js deleted file mode 100755 index 3dca974670..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/pie.js +++ /dev/null @@ -1,418 +0,0 @@ -nv.models.pie = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 500 - , height = 500 - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , getDescription = function(d) { return d.description } - , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one - , color = nv.utils.defaultColor() - , valueFormat = d3.format(',.2f') - , labelFormat = d3.format('%') - , showLabels = true - , pieLabelsOutside = true - , donutLabelsOutside = false - , labelType = "key" - , labelThreshold = .02 //if slice percentage is under this, don't show label - , donut = false - , labelSunbeamLayout = false - , startAngle = false - , endAngle = false - , donutRatio = 0.5 - , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - radius = Math.min(availableWidth, availableHeight) / 2, - arcRadius = radius-(radius / 5), - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - //var wrap = container.selectAll('.nv-wrap.nv-pie').data([data]); - var wrap = container.selectAll('.nv-wrap.nv-pie').data(data); - var wrapEnter = wrap.enter().append('g').attr('class','nvd3 nv-wrap nv-pie nv-chart-' + id); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-pie'); - gEnter.append('g').attr('class', 'nv-pieLabels'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - g.select('.nv-pie').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')'); - g.select('.nv-pieLabels').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')'); - - //------------------------------------------------------------ - - - container - .on('click', function(d,i) { - dispatch.chartClick({ - data: d, - index: i, - pos: d3.event, - id: id - }); - }); - - - var arc = d3.svg.arc() - .outerRadius(arcRadius); - - if (startAngle) arc.startAngle(startAngle) - if (endAngle) arc.endAngle(endAngle); - if (donut) arc.innerRadius(radius * donutRatio); - - // Setup the Pie chart and choose the data element - var pie = d3.layout.pie() - .sort(null) - .value(function(d) { return d.disabled ? 0 : getY(d) }); - - var slices = wrap.select('.nv-pie').selectAll('.nv-slice') - .data(pie); - - var pieLabels = wrap.select('.nv-pieLabels').selectAll('.nv-label') - .data(pie); - - slices.exit().remove(); - pieLabels.exit().remove(); - - var ae = slices.enter().append('g') - .attr('class', 'nv-slice') - .on('mouseover', function(d,i){ - d3.select(this).classed('hover', true); - dispatch.elementMouseover({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - pointIndex: i, - pos: [d3.event.pageX, d3.event.pageY], - id: id - }); - }) - .on('mouseout', function(d,i){ - d3.select(this).classed('hover', false); - dispatch.elementMouseout({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - index: i, - id: id - }); - }) - .on('click', function(d,i) { - dispatch.elementClick({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }) - .on('dblclick', function(d,i) { - dispatch.elementDblClick({ - label: getX(d.data), - value: getY(d.data), - point: d.data, - index: i, - pos: d3.event, - id: id - }); - d3.event.stopPropagation(); - }); - - slices - .attr('fill', function(d,i) { return color(d, i); }) - .attr('stroke', function(d,i) { return color(d, i); }); - - var paths = ae.append('path') - .each(function(d) { this._current = d; }); - //.attr('d', arc); - - slices.select('path') - .transition() - .attr('d', arc) - .attrTween('d', arcTween); - - if (showLabels) { - // This does the normal label - var labelsArc = d3.svg.arc().innerRadius(0); - - if (pieLabelsOutside){ labelsArc = arc; } - - if (donutLabelsOutside) { labelsArc = d3.svg.arc().outerRadius(arc.outerRadius()); } - - pieLabels.enter().append("g").classed("nv-label",true) - .each(function(d,i) { - var group = d3.select(this); - - group - .attr('transform', function(d) { - if (labelSunbeamLayout) { - d.outerRadius = arcRadius + 10; // Set Outer Coordinate - d.innerRadius = arcRadius + 15; // Set Inner Coordinate - var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI); - if ((d.startAngle+d.endAngle)/2 < Math.PI) { - rotateAngle -= 90; - } else { - rotateAngle += 90; - } - return 'translate(' + labelsArc.centroid(d) + ') rotate(' + rotateAngle + ')'; - } else { - d.outerRadius = radius + 10; // Set Outer Coordinate - d.innerRadius = radius + 15; // Set Inner Coordinate - return 'translate(' + labelsArc.centroid(d) + ')' - } - }); - - group.append('rect') - .style('stroke', '#fff') - .style('fill', '#fff') - .attr("rx", 3) - .attr("ry", 3); - - group.append('text') - .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned - .style('fill', '#000') - - }); - - var labelLocationHash = {}; - var avgHeight = 14; - var avgWidth = 140; - var createHashKey = function(coordinates) { - - return Math.floor(coordinates[0]/avgWidth) * avgWidth + ',' + Math.floor(coordinates[1]/avgHeight) * avgHeight; - }; - pieLabels.transition() - .attr('transform', function(d) { - if (labelSunbeamLayout) { - d.outerRadius = arcRadius + 10; // Set Outer Coordinate - d.innerRadius = arcRadius + 15; // Set Inner Coordinate - var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI); - if ((d.startAngle+d.endAngle)/2 < Math.PI) { - rotateAngle -= 90; - } else { - rotateAngle += 90; - } - return 'translate(' + labelsArc.centroid(d) + ') rotate(' + rotateAngle + ')'; - } else { - d.outerRadius = radius + 10; // Set Outer Coordinate - d.innerRadius = radius + 15; // Set Inner Coordinate - - /* - Overlapping pie labels are not good. What this attempts to do is, prevent overlapping. - Each label location is hashed, and if a hash collision occurs, we assume an overlap. - Adjust the label's y-position to remove the overlap. - */ - var center = labelsArc.centroid(d); - if(d.value){ - var hashKey = createHashKey(center); - if (labelLocationHash[hashKey]) { - center[1] -= avgHeight; - } - labelLocationHash[createHashKey(center)] = true; - } - return 'translate(' + center + ')' - } - }); - pieLabels.select(".nv-label text") - .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned - .text(function(d, i) { - var percent = (d.endAngle - d.startAngle) / (2 * Math.PI); - var labelTypes = { - "key" : getX(d.data), - "value": getY(d.data), - "percent": labelFormat(percent) - }; - return (d.value && percent > labelThreshold) ? labelTypes[labelType] : ''; - }); - } - - - // Computes the angle of an arc, converting from radians to degrees. - function angle(d) { - var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90; - return a > 90 ? a - 180 : a; - } - - function arcTween(a) { - a.endAngle = isNaN(a.endAngle) ? 0 : a.endAngle; - a.startAngle = isNaN(a.startAngle) ? 0 : a.startAngle; - if (!donut) a.innerRadius = 0; - var i = d3.interpolate(this._current, a); - this._current = i(0); - return function(t) { - return arc(i(t)); - }; - } - - function tweenPie(b) { - b.innerRadius = 0; - var i = d3.interpolate({startAngle: 0, endAngle: 0}, b); - return function(t) { - return arc(i(t)); - }; - } - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.values = function(_) { - nv.log("pie.values() is no longer supported."); - return chart; - }; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = _; - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - }; - - chart.description = function(_) { - if (!arguments.length) return getDescription; - getDescription = _; - return chart; - }; - - chart.showLabels = function(_) { - if (!arguments.length) return showLabels; - showLabels = _; - return chart; - }; - - chart.labelSunbeamLayout = function(_) { - if (!arguments.length) return labelSunbeamLayout; - labelSunbeamLayout = _; - return chart; - }; - - chart.donutLabelsOutside = function(_) { - if (!arguments.length) return donutLabelsOutside; - donutLabelsOutside = _; - return chart; - }; - - chart.pieLabelsOutside = function(_) { - if (!arguments.length) return pieLabelsOutside; - pieLabelsOutside = _; - return chart; - }; - - chart.labelType = function(_) { - if (!arguments.length) return labelType; - labelType = _; - labelType = labelType || "key"; - return chart; - }; - - chart.donut = function(_) { - if (!arguments.length) return donut; - donut = _; - return chart; - }; - - chart.donutRatio = function(_) { - if (!arguments.length) return donutRatio; - donutRatio = _; - return chart; - }; - - chart.startAngle = function(_) { - if (!arguments.length) return startAngle; - startAngle = _; - return chart; - }; - - chart.endAngle = function(_) { - if (!arguments.length) return endAngle; - endAngle = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.valueFormat = function(_) { - if (!arguments.length) return valueFormat; - valueFormat = _; - return chart; - }; - - chart.labelFormat = function(_) { - if (!arguments.length) return labelFormat; - labelFormat = _; - return chart; - }; - - chart.labelThreshold = function(_) { - if (!arguments.length) return labelThreshold; - labelThreshold = _; - return chart; - }; - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/pieChart.js b/awx/ui/static/lib/novus-nvd3/src/models/pieChart.js deleted file mode 100755 index b583d6078d..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/pieChart.js +++ /dev/null @@ -1,292 +0,0 @@ -nv.models.pieChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var pie = nv.models.pie() - , legend = nv.models.legend() - ; - - var margin = {top: 30, right: 20, bottom: 20, left: 20} - , width = null - , height = null - , showLegend = true - , color = nv.utils.defaultColor() - , tooltips = true - , tooltip = function(key, y, e, graph) { - return '

' + key + '

' + - '

' + y + '

' - } - , state = {} - , defaultState = null - , noData = "No Data Available." - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var tooltipLabel = pie.description()(e.point) || pie.x()(e.point) - var left = e.pos[0] + ( (offsetElement && offsetElement.offsetLeft) || 0 ), - top = e.pos[1] + ( (offsetElement && offsetElement.offsetTop) || 0), - y = pie.valueFormat()(pie.y()(e.point)), - content = tooltip(tooltipLabel, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-pieChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-pieChart').append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-pieWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend - .width( availableWidth ) - .key(pie.x()); - - wrap.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - - //------------------------------------------------------------ - // Main Chart Component(s) - - pie - .width(availableWidth) - .height(availableHeight); - - - var pieWrap = g.select('.nv-pieWrap') - .datum([data]); - - d3.transition(pieWrap).call(pie); - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - pie.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - }); - - return chart; - } - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - pie.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.legend = legend; - chart.dispatch = dispatch; - chart.pie = pie; - - d3.rebind(chart, pie, 'valueFormat', 'labelFormat', 'values', 'x', 'y', 'description', 'id', 'showLabels', 'donutLabelsOutside', 'pieLabelsOutside', 'labelType', 'donut', 'donutRatio', 'labelThreshold'); - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - pie.color(color); - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/scatter.js b/awx/ui/static/lib/novus-nvd3/src/models/scatter.js deleted file mode 100755 index 0a745587d2..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/scatter.js +++ /dev/null @@ -1,674 +0,0 @@ - -nv.models.scatter = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() // chooses color - , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't select one - , x = d3.scale.linear() - , y = d3.scale.linear() - , z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area - , getX = function(d) { return d.x } // accessor to get the x value - , getY = function(d) { return d.y } // accessor to get the y value - , getSize = function(d) { return d.size || 1} // accessor to get the point size - , getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape - , onlyCircles = true // Set to false to use shapes - , forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) - , forceY = [] // List of numbers to Force into the Y scale - , forceSize = [] // List of numbers to Force into the Size scale - , interactive = true // If true, plots a voronoi overlay for advanced point intersection - , pointKey = null - , pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out - , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart - , padDataOuter = .1 //outerPadding to imitate ordinal scale outer padding - , clipEdge = false // if true, masks points within x and y scale - , clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance - , clipRadius = function() { return 25 } // function to get the radius for voronoi point clips - , xDomain = null // Override x domain (skips the calculation from data) - , yDomain = null // Override y domain - , xRange = null // Override x range - , yRange = null // Override y range - , sizeDomain = null // Override point size domain - , sizeRange = null - , singlePoint = false - , dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout') - , useVoronoi = true - ; - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0, z0 // used to store previous scales - , timeoutID - , needsUpdate = false // Flag for when the points are visually updating, but the interactive layer is behind, to disable tooltips - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - //add series index to each data point for reference - data.forEach(function(series, i) { - series.values.forEach(function(point) { - point.series = i; - }); - }); - - //------------------------------------------------------------ - // Setup Scales - - // remap and flatten the data for use in calculating the scales' domains - var seriesData = (xDomain && yDomain && sizeDomain) ? [] : // if we know xDomain and yDomain and sizeDomain, no need to calculate.... if Size is constant remember to set sizeDomain to speed up performance - d3.merge( - data.map(function(d) { - return d.values.map(function(d,i) { - return { x: getX(d,i), y: getY(d,i), size: getSize(d,i) } - }) - }) - ); - - x .domain(xDomain || d3.extent(seriesData.map(function(d) { return d.x; }).concat(forceX))) - - if (padData && data[0]) - x.range(xRange || [(availableWidth * padDataOuter + availableWidth) / (2 *data[0].values.length), availableWidth - availableWidth * (1 + padDataOuter) / (2 * data[0].values.length) ]); - //x.range([availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); - else - x.range(xRange || [0, availableWidth]); - - y .domain(yDomain || d3.extent(seriesData.map(function(d) { return d.y }).concat(forceY))) - .range(yRange || [availableHeight, 0]); - - z .domain(sizeDomain || d3.extent(seriesData.map(function(d) { return d.size }).concat(forceSize))) - .range(sizeRange || [16, 256]); - - // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point - if (x.domain()[0] === x.domain()[1] || y.domain()[0] === y.domain()[1]) singlePoint = true; - if (x.domain()[0] === x.domain()[1]) - x.domain()[0] ? - x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) - : x.domain([-1,1]); - - if (y.domain()[0] === y.domain()[1]) - y.domain()[0] ? - y.domain([y.domain()[0] - y.domain()[0] * 0.01, y.domain()[1] + y.domain()[1] * 0.01]) - : y.domain([-1,1]); - - if ( isNaN(x.domain()[0])) { - x.domain([-1,1]); - } - - if ( isNaN(y.domain()[0])) { - y.domain([-1,1]); - } - - - x0 = x0 || x; - y0 = y0 || y; - z0 = z0 || z; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-scatter').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatter nv-chart-' + id + (singlePoint ? ' nv-single-point' : '')); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-groups'); - gEnter.append('g').attr('class', 'nv-point-paths'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', (availableHeight > 0) ? availableHeight : 0); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - - function updateInteractiveLayer() { - - if (!interactive) return false; - - var eventElements; - - var vertices = d3.merge(data.map(function(group, groupIndex) { - return group.values - .map(function(point, pointIndex) { - // *Adding noise to make duplicates very unlikely - // *Injecting series and point index for reference - /* *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi. - */ - var pX = getX(point,pointIndex); - var pY = getY(point,pointIndex); - - return [x(pX)+ Math.random() * 1e-7, - y(pY)+ Math.random() * 1e-7, - groupIndex, - pointIndex, point]; //temp hack to add noise untill I think of a better way so there are no duplicates - }) - .filter(function(pointArray, pointIndex) { - return pointActive(pointArray[4], pointIndex); // Issue #237.. move filter to after map, so pointIndex is correct! - }) - }) - ); - - - - //inject series and point index for reference into voronoi - if (useVoronoi === true) { - - if (clipVoronoi) { - var pointClipsEnter = wrap.select('defs').selectAll('.nv-point-clips') - .data([id]) - .enter(); - - pointClipsEnter.append('clipPath') - .attr('class', 'nv-point-clips') - .attr('id', 'nv-points-clip-' + id); - - var pointClips = wrap.select('#nv-points-clip-' + id).selectAll('circle') - .data(vertices); - pointClips.enter().append('circle') - .attr('r', clipRadius); - pointClips.exit().remove(); - pointClips - .attr('cx', function(d) { return d[0] }) - .attr('cy', function(d) { return d[1] }); - - wrap.select('.nv-point-paths') - .attr('clip-path', 'url(#nv-points-clip-' + id + ')'); - } - - - if(vertices.length) { - // Issue #283 - Adding 2 dummy points to the voronoi b/c voronoi requires min 3 points to work - vertices.push([x.range()[0] - 20, y.range()[0] - 20, null, null]); - vertices.push([x.range()[1] + 20, y.range()[1] + 20, null, null]); - vertices.push([x.range()[0] - 20, y.range()[0] + 20, null, null]); - vertices.push([x.range()[1] + 20, y.range()[1] - 20, null, null]); - } - - var bounds = d3.geom.polygon([ - [-10,-10], - [-10,height + 10], - [width + 10,height + 10], - [width + 10,-10] - ]); - - var voronoi = d3.geom.voronoi(vertices).map(function(d, i) { - return { - 'data': bounds.clip(d), - 'series': vertices[i][2], - 'point': vertices[i][3] - } - }); - - - var pointPaths = wrap.select('.nv-point-paths').selectAll('path') - .data(voronoi); - pointPaths.enter().append('path') - .attr('class', function(d,i) { return 'nv-path-'+i; }); - pointPaths.exit().remove(); - pointPaths - .attr('d', function(d) { - if (d.data.length === 0) - return 'M 0 0' - else - return 'M' + d.data.join('L') + 'Z'; - }); - - var mouseEventCallback = function(d,mDispatch) { - if (needsUpdate) return 0; - var series = data[d.series]; - if (typeof series === 'undefined') return; - - var point = series.values[d.point]; - - mDispatch({ - point: point, - series: series, - pos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top], - seriesIndex: d.series, - pointIndex: d.point - }); - }; - - pointPaths - .on('click', function(d) { - mouseEventCallback(d, dispatch.elementClick); - }) - .on('mouseover', function(d) { - mouseEventCallback(d, dispatch.elementMouseover); - }) - .on('mouseout', function(d, i) { - mouseEventCallback(d, dispatch.elementMouseout); - }); - - - } else { - /* - // bring data in form needed for click handlers - var dataWithPoints = vertices.map(function(d, i) { - return { - 'data': d, - 'series': vertices[i][2], - 'point': vertices[i][3] - } - }); - */ - - // add event handlers to points instead voronoi paths - wrap.select('.nv-groups').selectAll('.nv-group') - .selectAll('.nv-point') - //.data(dataWithPoints) - //.style('pointer-events', 'auto') // recativate events, disabled by css - .on('click', function(d,i) { - //nv.log('test', d, i); - if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point - var series = data[d.series], - point = series.values[i]; - - dispatch.elementClick({ - point: point, - series: series, - pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], - seriesIndex: d.series, - pointIndex: i - }); - }) - .on('mouseover', function(d,i) { - if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point - var series = data[d.series], - point = series.values[i]; - - dispatch.elementMouseover({ - point: point, - series: series, - pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], - seriesIndex: d.series, - pointIndex: i - }); - }) - .on('mouseout', function(d,i) { - if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point - var series = data[d.series], - point = series.values[i]; - - dispatch.elementMouseout({ - point: point, - series: series, - seriesIndex: d.series, - pointIndex: i - }); - }); - } - - needsUpdate = false; - } - - needsUpdate = true; - - var groups = wrap.select('.nv-groups').selectAll('.nv-group') - .data(function(d) { return d }, function(d) { return d.key }); - groups.enter().append('g') - .style('stroke-opacity', 1e-6) - .style('fill-opacity', 1e-6); - groups.exit() - .remove(); - groups - .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) - .classed('hover', function(d) { return d.hover }); - groups - .transition() - .style('fill', function(d,i) { return color(d, i) }) - .style('stroke', function(d,i) { return color(d, i) }) - .style('stroke-opacity', 1) - .style('fill-opacity', .5); - - - if (onlyCircles) { - - var points = groups.selectAll('circle.nv-point') - .data(function(d) { return d.values }, pointKey); - points.enter().append('circle') - .style('fill', function (d,i) { return d.color }) - .style('stroke', function (d,i) { return d.color }) - .attr('cx', function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) - .attr('cy', function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) - .attr('r', function(d,i) { return Math.sqrt(z(getSize(d,i))/Math.PI) }); - points.exit().remove(); - groups.exit().selectAll('path.nv-point').transition() - .attr('cx', function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .attr('cy', function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - .remove(); - points.each(function(d,i) { - d3.select(this) - .classed('nv-point', true) - .classed('nv-point-' + i, true) - .classed('hover',false) - ; - }); - points.transition() - .attr('cx', function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) - .attr('cy', function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) - .attr('r', function(d,i) { return Math.sqrt(z(getSize(d,i))/Math.PI) }); - - } else { - - var points = groups.selectAll('path.nv-point') - .data(function(d) { return d.values }); - points.enter().append('path') - .style('fill', function (d,i) { return d.color }) - .style('stroke', function (d,i) { return d.color }) - .attr('transform', function(d,i) { - return 'translate(' + x0(getX(d,i)) + ',' + y0(getY(d,i)) + ')' - }) - .attr('d', - d3.svg.symbol() - .type(getShape) - .size(function(d,i) { return z(getSize(d,i)) }) - ); - points.exit().remove(); - groups.exit().selectAll('path.nv-point') - .transition() - .attr('transform', function(d,i) { - return 'translate(' + x(getX(d,i)) + ',' + y(getY(d,i)) + ')' - }) - .remove(); - points.each(function(d,i) { - d3.select(this) - .classed('nv-point', true) - .classed('nv-point-' + i, true) - .classed('hover',false) - ; - }); - points.transition() - .attr('transform', function(d,i) { - //nv.log(d,i,getX(d,i), x(getX(d,i))); - return 'translate(' + x(getX(d,i)) + ',' + y(getY(d,i)) + ')' - }) - .attr('d', - d3.svg.symbol() - .type(getShape) - .size(function(d,i) { return z(getSize(d,i)) }) - ); - } - - - // Delay updating the invisible interactive layer for smoother animation - clearTimeout(timeoutID); // stop repeat calls to updateInteractiveLayer - timeoutID = setTimeout(updateInteractiveLayer, 300); - //updateInteractiveLayer(); - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - z0 = z.copy(); - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - chart.clearHighlights = function() { - //Remove the 'hover' class from all highlighted points. - d3.selectAll(".nv-chart-" + id + " .nv-point.hover").classed("hover",false); - }; - - chart.highlightPoint = function(seriesIndex,pointIndex,isHoverOver) { - d3.select(".nv-chart-" + id + " .nv-series-" + seriesIndex + " .nv-point-" + pointIndex) - .classed("hover",isHoverOver); - }; - - - dispatch.on('elementMouseover.point', function(d) { - if (interactive) chart.highlightPoint(d.seriesIndex,d.pointIndex,true); - }); - - dispatch.on('elementMouseout.point', function(d) { - if (interactive) chart.highlightPoint(d.seriesIndex,d.pointIndex,false); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - }; - - chart.size = function(_) { - if (!arguments.length) return getSize; - getSize = d3.functor(_); - return chart; - }; - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.zScale = function(_) { - if (!arguments.length) return z; - z = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.sizeDomain = function(_) { - if (!arguments.length) return sizeDomain; - sizeDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.sizeRange = function(_) { - if (!arguments.length) return sizeRange; - sizeRange = _; - return chart; - }; - - chart.forceX = function(_) { - if (!arguments.length) return forceX; - forceX = _; - return chart; - }; - - chart.forceY = function(_) { - if (!arguments.length) return forceY; - forceY = _; - return chart; - }; - - chart.forceSize = function(_) { - if (!arguments.length) return forceSize; - forceSize = _; - return chart; - }; - - chart.interactive = function(_) { - if (!arguments.length) return interactive; - interactive = _; - return chart; - }; - - chart.pointKey = function(_) { - if (!arguments.length) return pointKey; - pointKey = _; - return chart; - }; - - chart.pointActive = function(_) { - if (!arguments.length) return pointActive; - pointActive = _; - return chart; - }; - - chart.padData = function(_) { - if (!arguments.length) return padData; - padData = _; - return chart; - }; - - chart.padDataOuter = function(_) { - if (!arguments.length) return padDataOuter; - padDataOuter = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.clipVoronoi= function(_) { - if (!arguments.length) return clipVoronoi; - clipVoronoi = _; - return chart; - }; - - chart.useVoronoi= function(_) { - if (!arguments.length) return useVoronoi; - useVoronoi = _; - if (useVoronoi === false) { - clipVoronoi = false; - } - return chart; - }; - - chart.clipRadius = function(_) { - if (!arguments.length) return clipRadius; - clipRadius = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.shape = function(_) { - if (!arguments.length) return getShape; - getShape = _; - return chart; - }; - - chart.onlyCircles = function(_) { - if (!arguments.length) return onlyCircles; - onlyCircles = _; - return chart; - }; - - chart.id = function(_) { - if (!arguments.length) return id; - id = _; - return chart; - }; - - chart.singlePoint = function(_) { - if (!arguments.length) return singlePoint; - singlePoint = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/scatterChart.js b/awx/ui/static/lib/novus-nvd3/src/models/scatterChart.js deleted file mode 100755 index 65b6e387b1..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/scatterChart.js +++ /dev/null @@ -1,628 +0,0 @@ -nv.models.scatterChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var scatter = nv.models.scatter() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , distX = nv.models.distribution() - , distY = nv.models.distribution() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 75} - , width = null - , height = null - , color = nv.utils.defaultColor() - , x = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.xScale() - , y = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.yScale() - , xPadding = 0 - , yPadding = 0 - , showDistX = false - , showDistY = false - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , showControls = !!d3.fisheye - , fisheye = 0 - , pauseFisheye = false - , tooltips = true - , tooltipX = function(key, x, y) { return '' + x + '' } - , tooltipY = function(key, x, y) { return '' + y + '' } - , tooltip = null - , state = {} - , defaultState = null - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , noData = "No Data Available." - , transitionDuration = 250 - ; - - scatter - .xScale(x) - .yScale(y) - ; - xAxis - .orient('bottom') - .tickPadding(10) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickPadding(10) - ; - distX - .axis('x') - ; - distY - .axis('y') - ; - - controls.updateState(false); - - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0; - - var showTooltip = function(e, offsetElement) { - //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) - - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), - leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), - topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), - yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)); - - if( tooltipX != null ) - nv.tooltip.show([leftX, topX], tooltipX(e.series.key, xVal, yVal, e, chart), 'n', 1, offsetElement, 'x-nvtooltip'); - if( tooltipY != null ) - nv.tooltip.show([leftY, topY], tooltipY(e.series.key, xVal, yVal, e, chart), 'e', 1, offsetElement, 'y-nvtooltip'); - if( tooltip != null ) - nv.tooltip.show([left, top], tooltip(e.series.key, xVal, yVal, e, chart), e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - var controlsData = [ - { key: 'Magnify', disabled: true } - ]; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - // background for pointer events - gEnter.append('rect').attr('class', 'nvd3 nv-background'); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - gEnter.append('g').attr('class', 'nv-distWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - var legendWidth = (showControls) ? availableWidth / 2 : availableWidth; - legend.width(legendWidth); - - wrap.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth - legendWidth) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - controls.width(180).color(['#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - scatter - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - - if (xPadding !== 0) - scatter.xDomain(null); - - if (yPadding !== 0) - scatter.yDomain(null); - - wrap.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - - //Adjust for x and y padding - if (xPadding !== 0) { - var xRange = x.domain()[1] - x.domain()[0]; - scatter.xDomain([x.domain()[0] - (xPadding * xRange), x.domain()[1] + (xPadding * xRange)]); - } - - if (yPadding !== 0) { - var yRange = y.domain()[1] - y.domain()[0]; - scatter.yDomain([y.domain()[0] - (yPadding * yRange), y.domain()[1] + (yPadding * yRange)]); - } - - //Only need to update the scatter again if x/yPadding changed the domain. - if (yPadding !== 0 || xPadding !== 0) { - wrap.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - if (showXAxis) { - xAxis - .scale(x) - .ticks( xAxis.ticks() && xAxis.ticks().length ? xAxis.ticks() : availableWidth / 100 ) - .tickSize( -availableHeight , 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .call(xAxis); - - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( yAxis.ticks() && yAxis.ticks().length ? yAxis.ticks() : availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .call(yAxis); - } - - - if (showDistX) { - distX - .getData(scatter.x()) - .scale(x) - .width(availableWidth) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionX'); - g.select('.nv-distributionX') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - } - - if (showDistY) { - distY - .getData(scatter.y()) - .scale(y) - .width(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionY'); - g.select('.nv-distributionY') - .attr('transform', - 'translate(' + (rightAlignYAxis ? availableWidth : -distY.size() ) + ',0)') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - //------------------------------------------------------------ - - - - - if (d3.fisheye) { - g.select('.nv-background') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g.select('.nv-background').on('mousemove', updateFisheye); - g.select('.nv-background').on('click', function() { pauseFisheye = !pauseFisheye;}); - scatter.dispatch.on('elementClick.freezeFisheye', function() { - pauseFisheye = !pauseFisheye; - }); - } - - - function updateFisheye() { - if (pauseFisheye) { - g.select('.nv-point-paths').style('pointer-events', 'all'); - return false; - } - - g.select('.nv-point-paths').style('pointer-events', 'none' ); - - var mouse = d3.mouse(this); - x.distortion(fisheye).focus(mouse[0]); - y.distortion(fisheye).focus(mouse[1]); - - g.select('.nv-scatterWrap') - .call(scatter); - - if (showXAxis) - g.select('.nv-x.nv-axis').call(xAxis); - - if (showYAxis) - g.select('.nv-y.nv-axis').call(yAxis); - - g.select('.nv-distributionX') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - g.select('.nv-distributionY') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - fisheye = d.disabled ? 0 : 2.5; - g.select('.nv-background') .style('pointer-events', d.disabled ? 'none' : 'all'); - g.select('.nv-point-paths').style('pointer-events', d.disabled ? 'all' : 'none' ); - - if (d.disabled) { - x.distortion(fisheye).focus(0); - y.distortion(fisheye).focus(0); - - g.select('.nv-scatterWrap').call(scatter); - g.select('.nv-x.nv-axis').call(xAxis); - g.select('.nv-y.nv-axis').call(yAxis); - } else { - pauseFisheye = false; - } - - chart.update(); - }); - - legend.dispatch.on('stateChange', function(newState) { - state.disabled = newState.disabled; - dispatch.stateChange(state); - chart.update(); - }); - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', function(d,i) { return e.pos[1] - availableHeight;}); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', e.pos[0] + distX.size()); - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', 0); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', distY.size()); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.scatter = scatter; - chart.legend = legend; - chart.controls = controls; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.distX = distX; - chart.distY = distY; - - d3.rebind(chart, scatter, 'id', 'interactive', 'pointActive', 'x', 'y', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'sizeRange', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'useVoronoi'); - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - distX.color(color); - distY.color(color); - return chart; - }; - - chart.showDistX = function(_) { - if (!arguments.length) return showDistX; - showDistX = _; - return chart; - }; - - chart.showDistY = function(_) { - if (!arguments.length) return showDistY; - showDistY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - - chart.fisheye = function(_) { - if (!arguments.length) return fisheye; - fisheye = _; - return chart; - }; - - chart.xPadding = function(_) { - if (!arguments.length) return xPadding; - xPadding = _; - return chart; - }; - - chart.yPadding = function(_) { - if (!arguments.length) return yPadding; - yPadding = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltipXContent = function(_) { - if (!arguments.length) return tooltipX; - tooltipX = _; - return chart; - }; - - chart.tooltipYContent = function(_) { - if (!arguments.length) return tooltipY; - tooltipY = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/scatterPlusLineChart.js b/awx/ui/static/lib/novus-nvd3/src/models/scatterPlusLineChart.js deleted file mode 100755 index 23c8785385..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/scatterPlusLineChart.js +++ /dev/null @@ -1,620 +0,0 @@ - -nv.models.scatterPlusLineChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var scatter = nv.models.scatter() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , distX = nv.models.distribution() - , distY = nv.models.distribution() - ; - - var margin = {top: 30, right: 20, bottom: 50, left: 75} - , width = null - , height = null - , color = nv.utils.defaultColor() - , x = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.xScale() - , y = d3.fisheye ? d3.fisheye.scale(d3.scale.linear).distortion(0) : scatter.yScale() - , showDistX = false - , showDistY = false - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , showControls = !!d3.fisheye - , fisheye = 0 - , pauseFisheye = false - , tooltips = true - , tooltipX = function(key, x, y) { return '' + x + '' } - , tooltipY = function(key, x, y) { return '' + y + '' } - , tooltip = function(key, x, y, date) { return '

' + key + '

' - + '

' + date + '

' } - , state = {} - , defaultState = null - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , noData = "No Data Available." - , transitionDuration = 250 - ; - - scatter - .xScale(x) - .yScale(y) - ; - xAxis - .orient('bottom') - .tickPadding(10) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - .tickPadding(10) - ; - distX - .axis('x') - ; - distY - .axis('y') - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var x0, y0; - - var showTooltip = function(e, offsetElement) { - //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes?) - - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), - leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), - topY = e.pos[1] + ( offsetElement.offsetTop || 0), - xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), - yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)); - - if( tooltipX != null ) - nv.tooltip.show([leftX, topX], tooltipX(e.series.key, xVal, yVal, e, chart), 'n', 1, offsetElement, 'x-nvtooltip'); - if( tooltipY != null ) - nv.tooltip.show([leftY, topY], tooltipY(e.series.key, xVal, yVal, e, chart), 'e', 1, offsetElement, 'y-nvtooltip'); - if( tooltip != null ) - nv.tooltip.show([left, top], tooltip(e.series.key, xVal, yVal, e.point.tooltip, e, chart), e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - var controlsData = [ - { key: 'Magnify', disabled: true } - ]; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display noData message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = scatter.xScale(); - y = scatter.yScale(); - - x0 = x0 || x; - y0 = y0 || y; - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g') - - // background for pointer events - gEnter.append('rect').attr('class', 'nvd3 nv-background').style("pointer-events","none"); - - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - gEnter.append('g').attr('class', 'nv-regressionLinesWrap'); - gEnter.append('g').attr('class', 'nv-distWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Legend - - if (showLegend) { - legend.width( availableWidth / 2 ); - - wrap.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - wrap.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - controls.width(180).color(['#444']); - g.select('.nv-controlsWrap') - .datum(controlsData) - .attr('transform', 'translate(0,' + (-margin.top) +')') - .call(controls); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Main Chart Component(s) - - scatter - .width(availableWidth) - .height(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })) - - wrap.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - - wrap.select('.nv-regressionLinesWrap') - .attr('clip-path', 'url(#nv-edge-clip-' + scatter.id() + ')'); - - var regWrap = wrap.select('.nv-regressionLinesWrap').selectAll('.nv-regLines') - .data(function(d) {return d }); - - regWrap.enter().append('g').attr('class', 'nv-regLines'); - - var regLine = regWrap.selectAll('.nv-regLine').data(function(d){return [d]}); - var regLineEnter = regLine.enter() - .append('line').attr('class', 'nv-regLine') - .style('stroke-opacity', 0); - - regLine - .transition() - .attr('x1', x.range()[0]) - .attr('x2', x.range()[1]) - .attr('y1', function(d,i) {return y(x.domain()[0] * d.slope + d.intercept) }) - .attr('y2', function(d,i) { return y(x.domain()[1] * d.slope + d.intercept) }) - .style('stroke', function(d,i,j) { return color(d,j) }) - .style('stroke-opacity', function(d,i) { - return (d.disabled || typeof d.slope === 'undefined' || typeof d.intercept === 'undefined') ? 0 : 1 - }); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( xAxis.ticks() ? xAxis.ticks() : availableWidth / 100 ) - .tickSize( -availableHeight , 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks( yAxis.ticks() ? yAxis.ticks() : availableHeight / 36 ) - .tickSize( -availableWidth, 0); - - g.select('.nv-y.nv-axis') - .call(yAxis); - } - - - if (showDistX) { - distX - .getData(scatter.x()) - .scale(x) - .width(availableWidth) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionX'); - g.select('.nv-distributionX') - .attr('transform', 'translate(0,' + y.range()[0] + ')') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - } - - if (showDistY) { - distY - .getData(scatter.y()) - .scale(y) - .width(availableHeight) - .color(data.map(function(d,i) { - return d.color || color(d, i); - }).filter(function(d,i) { return !data[i].disabled })); - gEnter.select('.nv-distWrap').append('g') - .attr('class', 'nv-distributionY'); - g.select('.nv-distributionY') - .attr('transform', 'translate(' + (rightAlignYAxis ? availableWidth : -distY.size() ) + ',0)') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - //------------------------------------------------------------ - - - - - if (d3.fisheye) { - g.select('.nv-background') - .attr('width', availableWidth) - .attr('height', availableHeight) - ; - - g.select('.nv-background').on('mousemove', updateFisheye); - g.select('.nv-background').on('click', function() { pauseFisheye = !pauseFisheye;}); - scatter.dispatch.on('elementClick.freezeFisheye', function() { - pauseFisheye = !pauseFisheye; - }); - } - - - function updateFisheye() { - if (pauseFisheye) { - g.select('.nv-point-paths').style('pointer-events', 'all'); - return false; - } - - g.select('.nv-point-paths').style('pointer-events', 'none' ); - - var mouse = d3.mouse(this); - x.distortion(fisheye).focus(mouse[0]); - y.distortion(fisheye).focus(mouse[1]); - - g.select('.nv-scatterWrap') - .datum(data.filter(function(d) { return !d.disabled })) - .call(scatter); - - if (showXAxis) - g.select('.nv-x.nv-axis').call(xAxis); - - if (showYAxis) - g.select('.nv-y.nv-axis').call(yAxis); - - g.select('.nv-distributionX') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distX); - g.select('.nv-distributionY') - .datum(data.filter(function(d) { return !d.disabled })) - .call(distY); - } - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - controls.dispatch.on('legendClick', function(d,i) { - d.disabled = !d.disabled; - - fisheye = d.disabled ? 0 : 2.5; - g.select('.nv-background') .style('pointer-events', d.disabled ? 'none' : 'all'); - g.select('.nv-point-paths').style('pointer-events', d.disabled ? 'all' : 'none' ); - - if (d.disabled) { - x.distortion(fisheye).focus(0); - y.distortion(fisheye).focus(0); - - g.select('.nv-scatterWrap').call(scatter); - g.select('.nv-x.nv-axis').call(xAxis); - g.select('.nv-y.nv-axis').call(yAxis); - } else { - pauseFisheye = false; - } - - chart.update(); - }); - - legend.dispatch.on('stateChange', function(newState) { - state = newState; - dispatch.stateChange(state); - chart.update(); - }); - - - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', e.pos[1] - availableHeight); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', e.pos[0] + distX.size()); - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; - dispatch.tooltipShow(e); - }); - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined') { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - chart.update(); - }); - - //============================================================ - - - //store old scales for use in transitions on update - x0 = x.copy(); - y0 = y.copy(); - - - }); - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) - .attr('y1', 0); - d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) - .attr('x2', distY.size()); - }); - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.scatter = scatter; - chart.legend = legend; - chart.controls = controls; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.distX = distX; - chart.distY = distY; - - d3.rebind(chart, scatter, 'id', 'interactive', 'pointActive', 'x', 'y', 'shape', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'sizeRange', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'clipRadius', 'useVoronoi'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - distX.color(color); - distY.color(color); - return chart; - }; - - chart.showDistX = function(_) { - if (!arguments.length) return showDistX; - showDistX = _; - return chart; - }; - - chart.showDistY = function(_) { - if (!arguments.length) return showDistY; - showDistY = _; - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.fisheye = function(_) { - if (!arguments.length) return fisheye; - fisheye = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltipXContent = function(_) { - if (!arguments.length) return tooltipX; - tooltipX = _; - return chart; - }; - - chart.tooltipYContent = function(_) { - if (!arguments.length) return tooltipY; - tooltipY = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/sparkline.js b/awx/ui/static/lib/novus-nvd3/src/models/sparkline.js deleted file mode 100755 index e4c2e87b47..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/sparkline.js +++ /dev/null @@ -1,194 +0,0 @@ - -nv.models.sparkline = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 2, right: 0, bottom: 2, left: 0} - , width = 400 - , height = 32 - , animate = true - , x = d3.scale.linear() - , y = d3.scale.linear() - , getX = function(d) { return d.x } - , getY = function(d) { return d.y } - , color = nv.utils.getColor(['#000']) - , xDomain - , yDomain - , xRange - , yRange - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - - //------------------------------------------------------------ - // Setup Scales - - x .domain(xDomain || d3.extent(data, getX )) - .range(xRange || [0, availableWidth]); - - y .domain(yDomain || d3.extent(data, getY )) - .range(yRange || [availableHeight, 0]); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-sparkline').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparkline'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') - - //------------------------------------------------------------ - - - var paths = wrap.selectAll('path') - .data(function(d) { return [d] }); - paths.enter().append('path'); - paths.exit().remove(); - paths - .style('stroke', function(d,i) { return d.color || color(d, i) }) - .attr('d', d3.svg.line() - .x(function(d,i) { return x(getX(d,i)) }) - .y(function(d,i) { return y(getY(d,i)) }) - ); - - - // TODO: Add CURRENT data point (Need Min, Mac, Current / Most recent) - var points = wrap.selectAll('circle.nv-point') - .data(function(data) { - var yValues = data.map(function(d, i) { return getY(d,i); }); - function pointIndex(index) { - if (index != -1) { - var result = data[index]; - result.pointIndex = index; - return result; - } else { - return null; - } - } - var maxPoint = pointIndex(yValues.lastIndexOf(y.domain()[1])), - minPoint = pointIndex(yValues.indexOf(y.domain()[0])), - currentPoint = pointIndex(yValues.length - 1); - return [minPoint, maxPoint, currentPoint].filter(function (d) {return d != null;}); - }); - points.enter().append('circle'); - points.exit().remove(); - points - .attr('cx', function(d,i) { return x(getX(d,d.pointIndex)) }) - .attr('cy', function(d,i) { return y(getY(d,d.pointIndex)) }) - .attr('r', 2) - .attr('class', function(d,i) { - return getX(d, d.pointIndex) == x.domain()[1] ? 'nv-point nv-currentValue' : - getY(d, d.pointIndex) == y.domain()[0] ? 'nv-point nv-minValue' : 'nv-point nv-maxValue' - }); - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - }; - - chart.xScale = function(_) { - if (!arguments.length) return x; - x = _; - return chart; - }; - - chart.yScale = function(_) { - if (!arguments.length) return y; - y = _; - return chart; - }; - - chart.xDomain = function(_) { - if (!arguments.length) return xDomain; - xDomain = _; - return chart; - }; - - chart.yDomain = function(_) { - if (!arguments.length) return yDomain; - yDomain = _; - return chart; - }; - - chart.xRange = function(_) { - if (!arguments.length) return xRange; - xRange = _; - return chart; - }; - - chart.yRange = function(_) { - if (!arguments.length) return yRange; - yRange = _; - return chart; - }; - - chart.animate = function(_) { - if (!arguments.length) return animate; - animate = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/sparklinePlus.js b/awx/ui/static/lib/novus-nvd3/src/models/sparklinePlus.js deleted file mode 100755 index 1535f8afc7..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/sparklinePlus.js +++ /dev/null @@ -1,295 +0,0 @@ - -nv.models.sparklinePlus = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var sparkline = nv.models.sparkline(); - - var margin = {top: 15, right: 100, bottom: 10, left: 50} - , width = null - , height = null - , x - , y - , index = [] - , paused = false - , xTickFormat = d3.format(',r') - , yTickFormat = d3.format(',.2f') - , showValue = true - , alignValue = true - , rightAlignValue = false - , noData = "No Data Available." - ; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this); - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - - - chart.update = function() { chart(selection) }; - chart.container = this; - - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - var currentValue = sparkline.y()(data[data.length-1], data.length-1); - - //------------------------------------------------------------ - - - - //------------------------------------------------------------ - // Setup Scales - - x = sparkline.xScale(); - y = sparkline.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-sparklineplus').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparklineplus'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-sparklineWrap'); - gEnter.append('g').attr('class', 'nv-valueWrap'); - gEnter.append('g').attr('class', 'nv-hoverArea'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Main Chart Component(s) - - var sparklineWrap = g.select('.nv-sparklineWrap'); - - sparkline - .width(availableWidth) - .height(availableHeight); - - sparklineWrap - .call(sparkline); - - //------------------------------------------------------------ - - - var valueWrap = g.select('.nv-valueWrap'); - - var value = valueWrap.selectAll('.nv-currentValue') - .data([currentValue]); - - value.enter().append('text').attr('class', 'nv-currentValue') - .attr('dx', rightAlignValue ? -8 : 8) - .attr('dy', '.9em') - .style('text-anchor', rightAlignValue ? 'end' : 'start'); - - value - .attr('x', availableWidth + (rightAlignValue ? margin.right : 0)) - .attr('y', alignValue ? function(d) { return y(d) } : 0) - .style('fill', sparkline.color()(data[data.length-1], data.length-1)) - .text(yTickFormat(currentValue)); - - - - gEnter.select('.nv-hoverArea').append('rect') - .on('mousemove', sparklineHover) - .on('click', function() { paused = !paused }) - .on('mouseout', function() { index = []; updateValueLine(); }); - //.on('mouseout', function() { index = null; updateValueLine(); }); - - g.select('.nv-hoverArea rect') - .attr('transform', function(d) { return 'translate(' + -margin.left + ',' + -margin.top + ')' }) - .attr('width', availableWidth + margin.left + margin.right) - .attr('height', availableHeight + margin.top); - - - - function updateValueLine() { //index is currently global (within the chart), may or may not keep it that way - if (paused) return; - - var hoverValue = g.selectAll('.nv-hoverValue').data(index) - - var hoverEnter = hoverValue.enter() - .append('g').attr('class', 'nv-hoverValue') - .style('stroke-opacity', 0) - .style('fill-opacity', 0); - - hoverValue.exit() - .transition().duration(250) - .style('stroke-opacity', 0) - .style('fill-opacity', 0) - .remove(); - - hoverValue - .attr('transform', function(d) { return 'translate(' + x(sparkline.x()(data[d],d)) + ',0)' }) - .transition().duration(250) - .style('stroke-opacity', 1) - .style('fill-opacity', 1); - - if (!index.length) return; - - hoverEnter.append('line') - .attr('x1', 0) - .attr('y1', -margin.top) - .attr('x2', 0) - .attr('y2', availableHeight); - - - hoverEnter.append('text').attr('class', 'nv-xValue') - .attr('x', -6) - .attr('y', -margin.top) - .attr('text-anchor', 'end') - .attr('dy', '.9em') - - - g.select('.nv-hoverValue .nv-xValue') - .text(xTickFormat(sparkline.x()(data[index[0]], index[0]))); - - hoverEnter.append('text').attr('class', 'nv-yValue') - .attr('x', 6) - .attr('y', -margin.top) - .attr('text-anchor', 'start') - .attr('dy', '.9em') - - g.select('.nv-hoverValue .nv-yValue') - .text(yTickFormat(sparkline.y()(data[index[0]], index[0]))); - - } - - - function sparklineHover() { - if (paused) return; - - var pos = d3.mouse(this)[0] - margin.left; - - function getClosestIndex(data, x) { - var distance = Math.abs(sparkline.x()(data[0], 0) - x); - var closestIndex = 0; - for (var i = 0; i < data.length; i++){ - if (Math.abs(sparkline.x()(data[i], i) - x) < distance) { - distance = Math.abs(sparkline.x()(data[i], i) - x); - closestIndex = i; - } - } - return closestIndex; - } - - index = [getClosestIndex(data, Math.round(x.invert(pos)))]; - - updateValueLine(); - } - - }); - - return chart; - } - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.sparkline = sparkline; - - d3.rebind(chart, sparkline, 'x', 'y', 'xScale', 'yScale', 'color'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.xTickFormat = function(_) { - if (!arguments.length) return xTickFormat; - xTickFormat = _; - return chart; - }; - - chart.yTickFormat = function(_) { - if (!arguments.length) return yTickFormat; - yTickFormat = _; - return chart; - }; - - chart.showValue = function(_) { - if (!arguments.length) return showValue; - showValue = _; - return chart; - }; - - chart.alignValue = function(_) { - if (!arguments.length) return alignValue; - alignValue = _; - return chart; - }; - - chart.rightAlignValue = function(_) { - if (!arguments.length) return rightAlignValue; - rightAlignValue = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/stackedArea.js b/awx/ui/static/lib/novus-nvd3/src/models/stackedArea.js deleted file mode 100755 index 5c35999215..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/stackedArea.js +++ /dev/null @@ -1,368 +0,0 @@ - -nv.models.stackedArea = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var margin = {top: 0, right: 0, bottom: 0, left: 0} - , width = 960 - , height = 500 - , color = nv.utils.defaultColor() // a function that computes the color - , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one - , getX = function(d) { return d.x } // accessor to get the x value from a data point - , getY = function(d) { return d.y } // accessor to get the y value from a data point - , style = 'stack' - , offset = 'zero' - , order = 'default' - , interpolate = 'linear' // controls the line interpolation - , clipEdge = false // if true, masks lines within x and y scale - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , scatter = nv.models.scatter() - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'areaClick', 'areaMouseover', 'areaMouseout') - ; - - scatter - .size(2.2) // default size - .sizeDomain([2.2,2.2]) // all the same size by default - ; - - /************************************ - * offset: - * 'wiggle' (stream) - * 'zero' (stacked) - * 'expand' (normalize to 100%) - * 'silhouette' (simple centered) - * - * order: - * 'inside-out' (stream) - * 'default' (input order) - ************************************/ - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var availableWidth = width - margin.left - margin.right, - availableHeight = height - margin.top - margin.bottom, - container = d3.select(this); - - //------------------------------------------------------------ - // Setup Scales - - x = scatter.xScale(); - y = scatter.yScale(); - - //------------------------------------------------------------ - - var dataRaw = data; - // Injecting point index into each point because d3.layout.stack().out does not give index - data.forEach(function(aseries, i) { - aseries.seriesIndex = i; - aseries.values = aseries.values.map(function(d, j) { - d.index = j; - d.seriesIndex = i; - return d; - }); - }); - - var dataFiltered = data.filter(function(series) { - return !series.disabled; - }); - - data = d3.layout.stack() - .order(order) - .offset(offset) - .values(function(d) { return d.values }) //TODO: make values customizeable in EVERY model in this fashion - .x(getX) - .y(getY) - .out(function(d, y0, y) { - var yHeight = (getY(d) === 0) ? 0 : y; - d.display = { - y: yHeight, - y0: y0 - }; - }) - (dataFiltered); - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-stackedarea').data([data]); - var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedarea'); - var defsEnter = wrapEnter.append('defs'); - var gEnter = wrapEnter.append('g'); - var g = wrap.select('g'); - - gEnter.append('g').attr('class', 'nv-areaWrap'); - gEnter.append('g').attr('class', 'nv-scatterWrap'); - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - //------------------------------------------------------------ - - - scatter - .width(availableWidth) - .height(availableHeight) - .x(getX) - .y(function(d) { return d.display.y + d.display.y0 }) - .forceY([0]) - .color(data.map(function(d,i) { - return d.color || color(d, d.seriesIndex); - })); - - - var scatterWrap = g.select('.nv-scatterWrap') - .datum(data); - - scatterWrap.call(scatter); - - defsEnter.append('clipPath') - .attr('id', 'nv-edge-clip-' + id) - .append('rect'); - - wrap.select('#nv-edge-clip-' + id + ' rect') - .attr('width', availableWidth) - .attr('height', availableHeight); - - g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); - - var area = d3.svg.area() - .x(function(d,i) { return x(getX(d,i)) }) - .y0(function(d) { - return y(d.display.y0) - }) - .y1(function(d) { - return y(d.display.y + d.display.y0) - }) - .interpolate(interpolate); - - var zeroArea = d3.svg.area() - .x(function(d,i) { return x(getX(d,i)) }) - .y0(function(d) { return y(d.display.y0) }) - .y1(function(d) { return y(d.display.y0) }); - - - var path = g.select('.nv-areaWrap').selectAll('path.nv-area') - .data(function(d) { return d }); - - path.enter().append('path').attr('class', function(d,i) { return 'nv-area nv-area-' + i }) - .attr('d', function(d,i){ - return zeroArea(d.values, d.seriesIndex); - }) - .on('mouseover', function(d,i) { - d3.select(this).classed('hover', true); - dispatch.areaMouseover({ - point: d, - series: d.key, - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: d.seriesIndex - }); - }) - .on('mouseout', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.areaMouseout({ - point: d, - series: d.key, - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: d.seriesIndex - }); - }) - .on('click', function(d,i) { - d3.select(this).classed('hover', false); - dispatch.areaClick({ - point: d, - series: d.key, - pos: [d3.event.pageX, d3.event.pageY], - seriesIndex: d.seriesIndex - }); - }) - - path.exit().remove(); - - path - .style('fill', function(d,i){ - return d.color || color(d, d.seriesIndex) - }) - .style('stroke', function(d,i){ return d.color || color(d, d.seriesIndex) }); - path.transition() - .attr('d', function(d,i) { - return area(d.values,i) - }); - - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementMouseover.area', function(e) { - g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', true); - }); - scatter.dispatch.on('elementMouseout.area', function(e) { - g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', false); - }); - - //============================================================ - //Special offset functions - chart.d3_stackedOffset_stackPercent = function(stackData) { - var n = stackData.length, //How many series - m = stackData[0].length, //how many points per series - k = 1 / n, - i, - j, - o, - y0 = []; - - for (j = 0; j < m; ++j) { //Looping through all points - for (i = 0, o = 0; i < dataRaw.length; i++) //looping through series' - o += getY(dataRaw[i].values[j]) //total value of all points at a certian point in time. - - if (o) for (i = 0; i < n; i++) - stackData[i][j][1] /= o; - else - for (i = 0; i < n; i++) - stackData[i][j][1] = k; - } - for (j = 0; j < m; ++j) y0[j] = 0; - return y0; - }; - - }); - - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - scatter.dispatch.on('elementClick.area', function(e) { - dispatch.areaClick(e); - }) - scatter.dispatch.on('elementMouseover.tooltip', function(e) { - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - scatter.dispatch.on('elementMouseout.tooltip', function(e) { - dispatch.tooltipHide(e); - }); - - //============================================================ - - //============================================================ - // Global getters and setters - //------------------------------------------------------------ - - chart.dispatch = dispatch; - chart.scatter = scatter; - - d3.rebind(chart, scatter, 'interactive', 'size', 'xScale', 'yScale', 'zScale', 'xDomain', 'yDomain', 'xRange', 'yRange', - 'sizeDomain', 'forceX', 'forceY', 'forceSize', 'clipVoronoi', 'useVoronoi','clipRadius','highlightPoint','clearHighlights'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.x = function(_) { - if (!arguments.length) return getX; - getX = d3.functor(_); - return chart; - }; - - chart.y = function(_) { - if (!arguments.length) return getY; - getY = d3.functor(_); - return chart; - } - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.clipEdge = function(_) { - if (!arguments.length) return clipEdge; - clipEdge = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - return chart; - }; - - chart.offset = function(_) { - if (!arguments.length) return offset; - offset = _; - return chart; - }; - - chart.order = function(_) { - if (!arguments.length) return order; - order = _; - return chart; - }; - - //shortcut for offset + order - chart.style = function(_) { - if (!arguments.length) return style; - style = _; - - switch (style) { - case 'stack': - chart.offset('zero'); - chart.order('default'); - break; - case 'stream': - chart.offset('wiggle'); - chart.order('inside-out'); - break; - case 'stream-center': - chart.offset('silhouette'); - chart.order('inside-out'); - break; - case 'expand': - chart.offset('expand'); - chart.order('default'); - break; - case 'stack_percent': - chart.offset(chart.d3_stackedOffset_stackPercent); - chart.order('default'); - break; - } - - return chart; - }; - - chart.interpolate = function(_) { - if (!arguments.length) return interpolate; - interpolate = _; - return chart; - }; - //============================================================ - - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/models/stackedAreaChart.js b/awx/ui/static/lib/novus-nvd3/src/models/stackedAreaChart.js deleted file mode 100755 index 4b4c967591..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/models/stackedAreaChart.js +++ /dev/null @@ -1,635 +0,0 @@ - -nv.models.stackedAreaChart = function() { - "use strict"; - //============================================================ - // Public Variables with Default Settings - //------------------------------------------------------------ - - var stacked = nv.models.stackedArea() - , xAxis = nv.models.axis() - , yAxis = nv.models.axis() - , legend = nv.models.legend() - , controls = nv.models.legend() - , interactiveLayer = nv.interactiveGuideline() - ; - - var margin = {top: 30, right: 25, bottom: 50, left: 60} - , width = null - , height = null - , color = nv.utils.defaultColor() // a function that takes in d, i and returns color - , showControls = true - , showLegend = true - , showXAxis = true - , showYAxis = true - , rightAlignYAxis = false - , useInteractiveGuideline = false - , tooltips = true - , tooltip = function(key, x, y, e, graph) { - return '

' + key + '

' + - '

' + y + ' on ' + x + '

' - } - , x //can be accessed via chart.xScale() - , y //can be accessed via chart.yScale() - , yAxisTickFormat = d3.format(',.2f') - , state = { style: stacked.style() } - , defaultState = null - , noData = 'No Data Available.' - , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState') - , controlWidth = 250 - , cData = ['Stacked','Stream','Expanded'] - , controlLabels = {} - , transitionDuration = 250 - ; - - xAxis - .orient('bottom') - .tickPadding(7) - ; - yAxis - .orient((rightAlignYAxis) ? 'right' : 'left') - ; - - controls.updateState(false); - //============================================================ - - - //============================================================ - // Private Variables - //------------------------------------------------------------ - - var showTooltip = function(e, offsetElement) { - var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), - top = e.pos[1] + ( offsetElement.offsetTop || 0), - x = xAxis.tickFormat()(stacked.x()(e.point, e.pointIndex)), - y = yAxis.tickFormat()(stacked.y()(e.point, e.pointIndex)), - content = tooltip(e.series.key, x, y, e, chart); - - nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); - }; - - //============================================================ - - - function chart(selection) { - selection.each(function(data) { - var container = d3.select(this), - that = this; - - var availableWidth = (width || parseInt(container.style('width')) || 960) - - margin.left - margin.right, - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - - chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; - chart.container = this; - - //set state.disabled - state.disabled = data.map(function(d) { return !!d.disabled }); - - if (!defaultState) { - var key; - defaultState = {}; - for (key in state) { - if (state[key] instanceof Array) - defaultState[key] = state[key].slice(0); - else - defaultState[key] = state[key]; - } - } - - //------------------------------------------------------------ - // Display No Data message if there's nothing to show. - - if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { - var noDataText = container.selectAll('.nv-noData').data([noData]); - - noDataText.enter().append('text') - .attr('class', 'nvd3 nv-noData') - .attr('dy', '-.7em') - .style('text-anchor', 'middle'); - - noDataText - .attr('x', margin.left + availableWidth / 2) - .attr('y', margin.top + availableHeight / 2) - .text(function(d) { return d }); - - return chart; - } else { - container.selectAll('.nv-noData').remove(); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Scales - - x = stacked.xScale(); - y = stacked.yScale(); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup containers and skeleton of chart - - var wrap = container.selectAll('g.nv-wrap.nv-stackedAreaChart').data([data]); - var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedAreaChart').append('g'); - var g = wrap.select('g'); - - gEnter.append("rect").style("opacity",0); - gEnter.append('g').attr('class', 'nv-x nv-axis'); - gEnter.append('g').attr('class', 'nv-y nv-axis'); - gEnter.append('g').attr('class', 'nv-stackedWrap'); - gEnter.append('g').attr('class', 'nv-legendWrap'); - gEnter.append('g').attr('class', 'nv-controlsWrap'); - gEnter.append('g').attr('class', 'nv-interactive'); - - g.select("rect").attr("width",availableWidth).attr("height",availableHeight); - //------------------------------------------------------------ - // Legend - - if (showLegend) { - var legendWidth = (showControls) ? availableWidth - controlWidth : availableWidth; - legend - .width(legendWidth); - - g.select('.nv-legendWrap') - .datum(data) - .call(legend); - - if ( margin.top != legend.height()) { - margin.top = legend.height(); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - g.select('.nv-legendWrap') - .attr('transform', 'translate(' + (availableWidth-legendWidth) + ',' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Controls - - if (showControls) { - var controlsData = [ - { - key: controlLabels.stacked || 'Stacked', - metaKey: 'Stacked', - disabled: stacked.style() != 'stack', - style: 'stack' - }, - { - key: controlLabels.stream || 'Stream', - metaKey: 'Stream', - disabled: stacked.style() != 'stream', - style: 'stream' - }, - { - key: controlLabels.expanded || 'Expanded', - metaKey: 'Expanded', - disabled: stacked.style() != 'expand', - style: 'expand' - }, - { - key: controlLabels.stack_percent || 'Stack %', - metaKey: 'Stack_Percent', - disabled: stacked.style() != 'stack_percent', - style: 'stack_percent' - } - ]; - - controlWidth = (cData.length/3) * 260; - - controlsData = controlsData.filter(function(d) { - return cData.indexOf(d.metaKey) !== -1; - }) - - controls - .width( controlWidth ) - .color(['#444', '#444', '#444']); - - g.select('.nv-controlsWrap') - .datum(controlsData) - .call(controls); - - - if ( margin.top != Math.max(controls.height(), legend.height()) ) { - margin.top = Math.max(controls.height(), legend.height()); - availableHeight = (height || parseInt(container.style('height')) || 400) - - margin.top - margin.bottom; - } - - - g.select('.nv-controlsWrap') - .attr('transform', 'translate(0,' + (-margin.top) +')'); - } - - //------------------------------------------------------------ - - - wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); - - if (rightAlignYAxis) { - g.select(".nv-y.nv-axis") - .attr("transform", "translate(" + availableWidth + ",0)"); - } - - //------------------------------------------------------------ - // Main Chart Component(s) - - //------------------------------------------------------------ - //Set up interactive layer - if (useInteractiveGuideline) { - interactiveLayer - .width(availableWidth) - .height(availableHeight) - .margin({left: margin.left, top: margin.top}) - .svgContainer(container) - .xScale(x); - wrap.select(".nv-interactive").call(interactiveLayer); - } - - stacked - .width(availableWidth) - .height(availableHeight) - - var stackedWrap = g.select('.nv-stackedWrap') - .datum(data); - - stackedWrap.transition().call(stacked); - - //------------------------------------------------------------ - - - //------------------------------------------------------------ - // Setup Axes - - if (showXAxis) { - xAxis - .scale(x) - .ticks( availableWidth / 100 ) - .tickSize( -availableHeight, 0); - - g.select('.nv-x.nv-axis') - .attr('transform', 'translate(0,' + availableHeight + ')'); - - g.select('.nv-x.nv-axis') - .transition().duration(0) - .call(xAxis); - } - - if (showYAxis) { - yAxis - .scale(y) - .ticks(stacked.offset() == 'wiggle' ? 0 : availableHeight / 36) - .tickSize(-availableWidth, 0) - .setTickFormat( (stacked.style() == 'expand' || stacked.style() == 'stack_percent') - ? d3.format('%') : yAxisTickFormat); - - g.select('.nv-y.nv-axis') - .transition().duration(0) - .call(yAxis); - } - - //------------------------------------------------------------ - - - //============================================================ - // Event Handling/Dispatching (in chart's scope) - //------------------------------------------------------------ - - stacked.dispatch.on('areaClick.toggle', function(e) { - if (data.filter(function(d) { return !d.disabled }).length === 1) - data.forEach(function(d) { - d.disabled = false; - }); - else - data.forEach(function(d,i) { - d.disabled = (i != e.seriesIndex); - }); - - state.disabled = data.map(function(d) { return !!d.disabled }); - dispatch.stateChange(state); - - chart.update(); - }); - - legend.dispatch.on('stateChange', function(newState) { - state.disabled = newState.disabled; - dispatch.stateChange(state); - chart.update(); - }); - - controls.dispatch.on('legendClick', function(d,i) { - if (!d.disabled) return; - - controlsData = controlsData.map(function(s) { - s.disabled = true; - return s; - }); - d.disabled = false; - - stacked.style(d.style); - - - state.style = stacked.style(); - dispatch.stateChange(state); - - chart.update(); - }); - - - interactiveLayer.dispatch.on('elementMousemove', function(e) { - stacked.clearHighlights(); - var singlePoint, pointIndex, pointXLocation, allData = []; - data - .filter(function(series, i) { - series.seriesIndex = i; - return !series.disabled; - }) - .forEach(function(series,i) { - pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); - stacked.highlightPoint(i, pointIndex, true); - var point = series.values[pointIndex]; - if (typeof point === 'undefined') return; - if (typeof singlePoint === 'undefined') singlePoint = point; - if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); - - //If we are in 'expand' mode, use the stacked percent value instead of raw value. - var tooltipValue = (stacked.style() == 'expand') ? point.display.y : chart.y()(point,pointIndex); - allData.push({ - key: series.key, - value: tooltipValue, - color: color(series,series.seriesIndex), - stackedValue: point.display - }); - }); - - allData.reverse(); - - //Highlight the tooltip entry based on which stack the mouse is closest to. - if (allData.length > 2) { - var yValue = chart.yScale().invert(e.mouseY); - var yDistMax = Infinity, indexToHighlight = null; - allData.forEach(function(series,i) { - - //To handle situation where the stacked area chart is negative, we need to use absolute values - //when checking if the mouse Y value is within the stack area. - yValue = Math.abs(yValue); - var stackedY0 = Math.abs(series.stackedValue.y0); - var stackedY = Math.abs(series.stackedValue.y); - if ( yValue >= stackedY0 && yValue <= (stackedY + stackedY0)) - { - indexToHighlight = i; - return; - } - }); - if (indexToHighlight != null) - allData[indexToHighlight].highlight = true; - } - - var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex)); - - //If we are in 'expand' mode, force the format to be a percentage. - var valueFormatter = (stacked.style() == 'expand') ? - function(d,i) {return d3.format(".1%")(d);} : - function(d,i) {return yAxis.tickFormat()(d); }; - interactiveLayer.tooltip - .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) - .chartContainer(that.parentNode) - .enabled(tooltips) - .valueFormatter(valueFormatter) - .data( - { - value: xValue, - series: allData - } - )(); - - interactiveLayer.renderGuideLine(pointXLocation); - - }); - - interactiveLayer.dispatch.on("elementMouseout",function(e) { - dispatch.tooltipHide(); - stacked.clearHighlights(); - }); - - - dispatch.on('tooltipShow', function(e) { - if (tooltips) showTooltip(e, that.parentNode); - }); - - // Update chart from a state object passed to event handler - dispatch.on('changeState', function(e) { - - if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) { - data.forEach(function(series,i) { - series.disabled = e.disabled[i]; - }); - - state.disabled = e.disabled; - } - - if (typeof e.style !== 'undefined') { - stacked.style(e.style); - } - - chart.update(); - }); - - }); - - - return chart; - } - - - //============================================================ - // Event Handling/Dispatching (out of chart's scope) - //------------------------------------------------------------ - - stacked.dispatch.on('tooltipShow', function(e) { - //disable tooltips when value ~= 0 - //// TODO: consider removing points from voronoi that have 0 value instead of this hack - /* - if (!Math.round(stacked.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range - setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); - return false; - } - */ - - e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], - dispatch.tooltipShow(e); - }); - - stacked.dispatch.on('tooltipHide', function(e) { - dispatch.tooltipHide(e); - }); - - dispatch.on('tooltipHide', function() { - if (tooltips) nv.tooltip.cleanup(); - }); - - //============================================================ - - - //============================================================ - // Expose Public Variables - //------------------------------------------------------------ - - // expose chart's sub-components - chart.dispatch = dispatch; - chart.stacked = stacked; - chart.legend = legend; - chart.controls = controls; - chart.xAxis = xAxis; - chart.yAxis = yAxis; - chart.interactiveLayer = interactiveLayer; - - d3.rebind(chart, stacked, 'x', 'y', 'size', 'xScale', 'yScale', 'xDomain', 'yDomain', 'xRange', 'yRange', 'sizeDomain', 'interactive', 'useVoronoi', 'offset', 'order', 'style', 'clipEdge', 'forceX', 'forceY', 'forceSize', 'interpolate'); - - chart.options = nv.utils.optionsFunc.bind(chart); - - chart.margin = function(_) { - if (!arguments.length) return margin; - margin.top = typeof _.top != 'undefined' ? _.top : margin.top; - margin.right = typeof _.right != 'undefined' ? _.right : margin.right; - margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; - margin.left = typeof _.left != 'undefined' ? _.left : margin.left; - return chart; - }; - - chart.width = function(_) { - if (!arguments.length) return width; - width = _; - return chart; - }; - - chart.height = function(_) { - if (!arguments.length) return height; - height = _; - return chart; - }; - - chart.color = function(_) { - if (!arguments.length) return color; - color = nv.utils.getColor(_); - legend.color(color); - stacked.color(color); - return chart; - }; - - chart.showControls = function(_) { - if (!arguments.length) return showControls; - showControls = _; - return chart; - }; - - chart.showLegend = function(_) { - if (!arguments.length) return showLegend; - showLegend = _; - return chart; - }; - - chart.showXAxis = function(_) { - if (!arguments.length) return showXAxis; - showXAxis = _; - return chart; - }; - - chart.showYAxis = function(_) { - if (!arguments.length) return showYAxis; - showYAxis = _; - return chart; - }; - - chart.rightAlignYAxis = function(_) { - if(!arguments.length) return rightAlignYAxis; - rightAlignYAxis = _; - yAxis.orient( (_) ? 'right' : 'left'); - return chart; - }; - - chart.useInteractiveGuideline = function(_) { - if(!arguments.length) return useInteractiveGuideline; - useInteractiveGuideline = _; - if (_ === true) { - chart.interactive(false); - chart.useVoronoi(false); - } - return chart; - }; - - chart.tooltip = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.tooltips = function(_) { - if (!arguments.length) return tooltips; - tooltips = _; - return chart; - }; - - chart.tooltipContent = function(_) { - if (!arguments.length) return tooltip; - tooltip = _; - return chart; - }; - - chart.state = function(_) { - if (!arguments.length) return state; - state = _; - return chart; - }; - - chart.defaultState = function(_) { - if (!arguments.length) return defaultState; - defaultState = _; - return chart; - }; - - chart.noData = function(_) { - if (!arguments.length) return noData; - noData = _; - return chart; - }; - - chart.transitionDuration = function(_) { - if (!arguments.length) return transitionDuration; - transitionDuration = _; - return chart; - }; - - chart.controlsData = function(_) { - if (!arguments.length) return cData; - cData = _; - return chart; - }; - - chart.controlLabels = function(_) { - if (!arguments.length) return controlLabels; - if (typeof _ !== 'object') return controlLabels; - controlLabels = _; - return chart; - }; - - yAxis.setTickFormat = yAxis.tickFormat; - - yAxis.tickFormat = function(_) { - if (!arguments.length) return yAxisTickFormat; - yAxisTickFormat = _; - return yAxis; - }; - - - //============================================================ - - return chart; -} diff --git a/awx/ui/static/lib/novus-nvd3/src/nv.d3.css b/awx/ui/static/lib/novus-nvd3/src/nv.d3.css deleted file mode 100755 index cae834827c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/nv.d3.css +++ /dev/null @@ -1,769 +0,0 @@ - -/******************** - * HTML CSS - */ - - -.chartWrap { - margin: 0; - padding: 0; - overflow: hidden; -} - -/******************** - Box shadow and border radius styling -*/ -.nvtooltip.with-3d-shadow, .with-3d-shadow .nvtooltip { - -moz-box-shadow: 0 5px 10px rgba(0,0,0,.2); - -webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2); - box-shadow: 0 5px 10px rgba(0,0,0,.2); - - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; -} - -/******************** - * TOOLTIP CSS - */ - -.nvtooltip { - position: absolute; - background-color: rgba(255,255,255,1.0); - padding: 1px; - border: 1px solid rgba(0,0,0,.2); - z-index: 10000; - - font-family: Arial; - font-size: 13px; - text-align: left; - pointer-events: none; - - white-space: nowrap; - - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; -} - -/*Give tooltips that old fade in transition by - putting a "with-transitions" class on the container div. -*/ -.nvtooltip.with-transitions, .with-transitions .nvtooltip { - transition: opacity 250ms linear; - -moz-transition: opacity 250ms linear; - -webkit-transition: opacity 250ms linear; - - transition-delay: 250ms; - -moz-transition-delay: 250ms; - -webkit-transition-delay: 250ms; -} - -.nvtooltip.x-nvtooltip, -.nvtooltip.y-nvtooltip { - padding: 8px; -} - -.nvtooltip h3 { - margin: 0; - padding: 4px 14px; - line-height: 18px; - font-weight: normal; - background-color: rgba(247,247,247,0.75); - text-align: center; - - border-bottom: 1px solid #ebebeb; - - -webkit-border-radius: 5px 5px 0 0; - -moz-border-radius: 5px 5px 0 0; - border-radius: 5px 5px 0 0; -} - -.nvtooltip p { - margin: 0; - padding: 5px 14px; - text-align: center; -} - -.nvtooltip span { - display: inline-block; - margin: 2px 0; -} - -.nvtooltip table { - margin: 6px; - border-spacing:0; -} - - -.nvtooltip table td { - padding: 2px 9px 2px 0; - vertical-align: middle; -} - -.nvtooltip table td.key { - font-weight:normal; -} -.nvtooltip table td.value { - text-align: right; - font-weight: bold; -} - -.nvtooltip table tr.highlight td { - padding: 1px 9px 1px 0; - border-bottom-style: solid; - border-bottom-width: 1px; - border-top-style: solid; - border-top-width: 1px; -} - -.nvtooltip table td.legend-color-guide div { - width: 8px; - height: 8px; - vertical-align: middle; -} - -.nvtooltip .footer { - padding: 3px; - text-align: center; -} - - -.nvtooltip-pending-removal { - position: absolute; - pointer-events: none; -} - - -/******************** - * SVG CSS - */ - - -svg { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - /* Trying to get SVG to act like a greedy block in all browsers */ - display: block; - width:100%; - height:100%; -} - - -svg text { - font: normal 12px Arial; -} - -svg .title { - font: bold 14px Arial; -} - -.nvd3 .nv-background { - fill: white; - fill-opacity: 0; - /* - pointer-events: none; - */ -} - -.nvd3.nv-noData { - font-size: 18px; - font-weight: bold; -} - - -/********** -* Brush -*/ - -.nv-brush .extent { - fill-opacity: .125; - shape-rendering: crispEdges; -} - - - -/********** -* Legend -*/ - -.nvd3 .nv-legend .nv-series { - cursor: pointer; -} - -.nvd3 .nv-legend .disabled circle { - fill-opacity: 0; -} - - - -/********** -* Axes -*/ -.nvd3 .nv-axis { - pointer-events:none; -} - -.nvd3 .nv-axis path { - fill: none; - stroke: #000; - stroke-opacity: .75; - shape-rendering: crispEdges; -} - -.nvd3 .nv-axis path.domain { - stroke-opacity: .75; -} - -.nvd3 .nv-axis.nv-x path.domain { - stroke-opacity: 0; -} - -.nvd3 .nv-axis line { - fill: none; - stroke: #e5e5e5; - shape-rendering: crispEdges; -} - -.nvd3 .nv-axis .zero line, -/*this selector may not be necessary*/ .nvd3 .nv-axis line.zero { - stroke-opacity: .75; -} - -.nvd3 .nv-axis .nv-axisMaxMin text { - font-weight: bold; -} - -.nvd3 .x .nv-axis .nv-axisMaxMin text, -.nvd3 .x2 .nv-axis .nv-axisMaxMin text, -.nvd3 .x3 .nv-axis .nv-axisMaxMin text { - text-anchor: middle -} - - - -/********** -* Brush -*/ - -.nv-brush .resize path { - fill: #eee; - stroke: #666; -} - - - -/********** -* Bars -*/ - -.nvd3 .nv-bars .negative rect { - zfill: brown; -} - -.nvd3 .nv-bars rect { - zfill: steelblue; - fill-opacity: .75; - - transition: fill-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear; -} - -.nvd3 .nv-bars rect.hover { - fill-opacity: 1; -} - -.nvd3 .nv-bars .hover rect { - fill: lightblue; -} - -.nvd3 .nv-bars text { - fill: rgba(0,0,0,0); -} - -.nvd3 .nv-bars .hover text { - fill: rgba(0,0,0,1); -} - - -/********** -* Bars -*/ - -.nvd3 .nv-multibar .nv-groups rect, -.nvd3 .nv-multibarHorizontal .nv-groups rect, -.nvd3 .nv-discretebar .nv-groups rect { - stroke-opacity: 0; - - transition: fill-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear; -} - -.nvd3 .nv-multibar .nv-groups rect:hover, -.nvd3 .nv-multibarHorizontal .nv-groups rect:hover, -.nvd3 .nv-discretebar .nv-groups rect:hover { - fill-opacity: 1; -} - -.nvd3 .nv-discretebar .nv-groups text, -.nvd3 .nv-multibarHorizontal .nv-groups text { - font-weight: bold; - fill: rgba(0,0,0,1); - stroke: rgba(0,0,0,0); -} - -/*********** -* Pie Chart -*/ - -.nvd3.nv-pie path { - stroke-opacity: 0; - transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear, stroke-width 250ms linear, stroke-opacity 250ms linear; - -} - -.nvd3.nv-pie .nv-slice text { - stroke: #000; - stroke-width: 0; -} - -.nvd3.nv-pie path { - stroke: #fff; - stroke-width: 1px; - stroke-opacity: 1; -} - -.nvd3.nv-pie .hover path { - fill-opacity: .7; -} -.nvd3.nv-pie .nv-label { - pointer-events: none; -} -.nvd3.nv-pie .nv-label rect { - fill-opacity: 0; - stroke-opacity: 0; -} - -/********** -* Lines -*/ - -.nvd3 .nv-groups path.nv-line { - fill: none; - stroke-width: 1.5px; - /* - stroke-linecap: round; - shape-rendering: geometricPrecision; - - transition: stroke-width 250ms linear; - -moz-transition: stroke-width 250ms linear; - -webkit-transition: stroke-width 250ms linear; - - transition-delay: 250ms - -moz-transition-delay: 250ms; - -webkit-transition-delay: 250ms; - */ -} - -.nvd3 .nv-groups path.nv-line.nv-thin-line { - stroke-width: 1px; -} - - -.nvd3 .nv-groups path.nv-area { - stroke: none; - /* - stroke-linecap: round; - shape-rendering: geometricPrecision; - - stroke-width: 2.5px; - transition: stroke-width 250ms linear; - -moz-transition: stroke-width 250ms linear; - -webkit-transition: stroke-width 250ms linear; - - transition-delay: 250ms - -moz-transition-delay: 250ms; - -webkit-transition-delay: 250ms; - */ -} - -.nvd3 .nv-line.hover path { - stroke-width: 6px; -} - -/* -.nvd3.scatter .groups .point { - fill-opacity: 0.1; - stroke-opacity: 0.1; -} - */ - -.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point { - fill-opacity: 0; - stroke-opacity: 0; -} - -.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point { - fill-opacity: .5 !important; - stroke-opacity: .5 !important; -} - - -.with-transitions .nvd3 .nv-groups .nv-point { - transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -moz-transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -webkit-transition: stroke-width 250ms linear, stroke-opacity 250ms linear; - -} - -.nvd3.nv-scatter .nv-groups .nv-point.hover, -.nvd3 .nv-groups .nv-point.hover { - stroke-width: 7px; - fill-opacity: .95 !important; - stroke-opacity: .95 !important; -} - - -.nvd3 .nv-point-paths path { - stroke: #aaa; - stroke-opacity: 0; - fill: #eee; - fill-opacity: 0; -} - - - -.nvd3 .nv-indexLine { - cursor: ew-resize; -} - - -/********** -* Distribution -*/ - -.nvd3 .nv-distribution { - pointer-events: none; -} - - - -/********** -* Scatter -*/ - -/* **Attempting to remove this for useVoronoi(false), need to see if it's required anywhere -.nvd3 .nv-groups .nv-point { - pointer-events: none; -} -*/ - -.nvd3 .nv-groups .nv-point.hover { - stroke-width: 20px; - stroke-opacity: .5; -} - -.nvd3 .nv-scatter .nv-point.hover { - fill-opacity: 1; -} - -/* -.nv-group.hover .nv-point { - fill-opacity: 1; -} -*/ - - -/********** -* Stacked Area -*/ - -.nvd3.nv-stackedarea path.nv-area { - fill-opacity: .7; - /* - stroke-opacity: .65; - fill-opacity: 1; - */ - stroke-opacity: 0; - - transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; - -moz-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; - -webkit-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; - - /* - transition-delay: 500ms; - -moz-transition-delay: 500ms; - -webkit-transition-delay: 500ms; - */ - -} - -.nvd3.nv-stackedarea path.nv-area.hover { - fill-opacity: .9; - /* - stroke-opacity: .85; - */ -} -/* -.d3stackedarea .groups path { - stroke-opacity: 0; -} - */ - - - -.nvd3.nv-stackedarea .nv-groups .nv-point { - stroke-opacity: 0; - fill-opacity: 0; -} - -/* -.nvd3.nv-stackedarea .nv-groups .nv-point.hover { - stroke-width: 20px; - stroke-opacity: .75; - fill-opacity: 1; -}*/ - - - -/********** -* Line Plus Bar -*/ - -.nvd3.nv-linePlusBar .nv-bar rect { - fill-opacity: .75; -} - -.nvd3.nv-linePlusBar .nv-bar rect:hover { - fill-opacity: 1; -} - - -/********** -* Bullet -*/ - -.nvd3.nv-bullet { font: 10px sans-serif; } -.nvd3.nv-bullet .nv-measure { fill-opacity: .8; } -.nvd3.nv-bullet .nv-measure:hover { fill-opacity: 1; } -.nvd3.nv-bullet .nv-marker { stroke: #000; stroke-width: 2px; } -.nvd3.nv-bullet .nv-markerTriangle { stroke: #000; fill: #fff; stroke-width: 1.5px; } -.nvd3.nv-bullet .nv-tick line { stroke: #666; stroke-width: .5px; } -.nvd3.nv-bullet .nv-range.nv-s0 { fill: #eee; } -.nvd3.nv-bullet .nv-range.nv-s1 { fill: #ddd; } -.nvd3.nv-bullet .nv-range.nv-s2 { fill: #ccc; } -.nvd3.nv-bullet .nv-title { font-size: 14px; font-weight: bold; } -.nvd3.nv-bullet .nv-subtitle { fill: #999; } - - -.nvd3.nv-bullet .nv-range { - fill: #bababa; - fill-opacity: .4; -} -.nvd3.nv-bullet .nv-range:hover { - fill-opacity: .7; -} - - - -/********** -* Sparkline -*/ - -.nvd3.nv-sparkline path { - fill: none; -} - -.nvd3.nv-sparklineplus g.nv-hoverValue { - pointer-events: none; -} - -.nvd3.nv-sparklineplus .nv-hoverValue line { - stroke: #333; - stroke-width: 1.5px; - } - -.nvd3.nv-sparklineplus, -.nvd3.nv-sparklineplus g { - pointer-events: all; -} - -.nvd3 .nv-hoverArea { - fill-opacity: 0; - stroke-opacity: 0; -} - -.nvd3.nv-sparklineplus .nv-xValue, -.nvd3.nv-sparklineplus .nv-yValue { - /* - stroke: #666; - */ - stroke-width: 0; - font-size: .9em; - font-weight: normal; -} - -.nvd3.nv-sparklineplus .nv-yValue { - stroke: #f66; -} - -.nvd3.nv-sparklineplus .nv-maxValue { - stroke: #2ca02c; - fill: #2ca02c; -} - -.nvd3.nv-sparklineplus .nv-minValue { - stroke: #d62728; - fill: #d62728; -} - -.nvd3.nv-sparklineplus .nv-currentValue { - /* - stroke: #444; - fill: #000; - */ - font-weight: bold; - font-size: 1.1em; -} - -/********** -* historical stock -*/ - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick { - stroke-width: 2px; -} - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover { - stroke-width: 4px; -} - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive { - stroke: #2ca02c; -} - -.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative { - stroke: #d62728; -} - -.nvd3.nv-historicalStockChart .nv-axis .nv-axislabel { - font-weight: bold; -} - -.nvd3.nv-historicalStockChart .nv-dragTarget { - fill-opacity: 0; - stroke: none; - cursor: move; -} - -.nvd3 .nv-brush .extent { - /* - cursor: ew-resize !important; - */ - fill-opacity: 0 !important; -} - -.nvd3 .nv-brushBackground rect { - stroke: #000; - stroke-width: .4; - fill: #fff; - fill-opacity: .7; -} - - - -/********** -* Indented Tree -*/ - - -/** - * TODO: the following 3 selectors are based on classes used in the example. I should either make them standard and leave them here, or move to a CSS file not included in the library - */ -.nvd3.nv-indentedtree .name { - margin-left: 5px; -} - -.nvd3.nv-indentedtree .clickable { - color: #08C; - cursor: pointer; -} - -.nvd3.nv-indentedtree span.clickable:hover { - color: #005580; - text-decoration: underline; -} - - -.nvd3.nv-indentedtree .nv-childrenCount { - display: inline-block; - margin-left: 5px; -} - -.nvd3.nv-indentedtree .nv-treeicon { - cursor: pointer; - /* - cursor: n-resize; - */ -} - -.nvd3.nv-indentedtree .nv-treeicon.nv-folded { - cursor: pointer; - /* - cursor: s-resize; - */ -} - -/********** -* Parallel Coordinates -*/ - -.nvd3 .background path { - fill: none; - stroke: #ccc; - stroke-opacity: .4; - shape-rendering: crispEdges; -} - -.nvd3 .foreground path { - fill: none; - stroke: steelblue; - stroke-opacity: .7; -} - -.nvd3 .brush .extent { - fill-opacity: .3; - stroke: #fff; - shape-rendering: crispEdges; -} - -.nvd3 .axis line, .axis path { - fill: none; - stroke: #000; - shape-rendering: crispEdges; -} - -.nvd3 .axis text { - text-shadow: 0 1px 0 #fff; -} - -/**** -Interactive Layer -*/ -.nvd3 .nv-interactiveGuideLine { - pointer-events:none; -} -.nvd3 line.nv-guideline { - stroke: #ccc; -} \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/src/outro.js b/awx/ui/static/lib/novus-nvd3/src/outro.js deleted file mode 100755 index 158693a025..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/outro.js +++ /dev/null @@ -1 +0,0 @@ -})(); \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/src/tooltip.js b/awx/ui/static/lib/novus-nvd3/src/tooltip.js deleted file mode 100755 index 46e5a8161c..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/tooltip.js +++ /dev/null @@ -1,490 +0,0 @@ -/* Tooltip rendering model for nvd3 charts. -window.nv.models.tooltip is the updated,new way to render tooltips. - -window.nv.tooltip.show is the old tooltip code. -window.nv.tooltip.* also has various helper methods. -*/ -(function() { - "use strict"; - window.nv.tooltip = {}; - - /* Model which can be instantiated to handle tooltip rendering. - Example usage: - var tip = nv.models.tooltip().gravity('w').distance(23) - .data(myDataObject); - - tip(); //just invoke the returned function to render tooltip. - */ - window.nv.models.tooltip = function() { - var content = null //HTML contents of the tooltip. If null, the content is generated via the data variable. - , data = null /* Tooltip data. If data is given in the proper format, a consistent tooltip is generated. - Format of data: - { - key: "Date", - value: "August 2009", - series: [ - { - key: "Series 1", - value: "Value 1", - color: "#000" - }, - { - key: "Series 2", - value: "Value 2", - color: "#00f" - } - ] - - } - - */ - , gravity = 'w' //Can be 'n','s','e','w'. Determines how tooltip is positioned. - , distance = 50 //Distance to offset tooltip from the mouse location. - , snapDistance = 25 //Tolerance allowed before tooltip is moved from its current position (creates 'snapping' effect) - , fixedTop = null //If not null, this fixes the top position of the tooltip. - , classes = null //Attaches additional CSS classes to the tooltip DIV that is created. - , chartContainer = null //Parent DIV, of the SVG Container that holds the chart. - , tooltipElem = null //actual DOM element representing the tooltip. - , position = {left: null, top: null} //Relative position of the tooltip inside chartContainer. - , enabled = true //True -> tooltips are rendered. False -> don't render tooltips. - //Generates a unique id when you create a new tooltip() object - , id = "nvtooltip-" + Math.floor(Math.random() * 100000) - ; - - //CSS class to specify whether element should not have mouse events. - var nvPointerEventsClass = "nv-pointer-events-none"; - - //Format function for the tooltip values column - var valueFormatter = function(d,i) { - return d; - }; - - //Format function for the tooltip header value. - var headerFormatter = function(d) { - return d; - }; - - //By default, the tooltip model renders a beautiful table inside a DIV. - //You can override this function if a custom tooltip is desired. - var contentGenerator = function(d) { - if (content != null) return content; - - if (d == null) return ''; - - var table = d3.select(document.createElement("table")); - var theadEnter = table.selectAll("thead") - .data([d]) - .enter().append("thead"); - theadEnter.append("tr") - .append("td") - .attr("colspan",3) - .append("strong") - .classed("x-value",true) - .html(headerFormatter(d.value)); - - var tbodyEnter = table.selectAll("tbody") - .data([d]) - .enter().append("tbody"); - var trowEnter = tbodyEnter.selectAll("tr") - .data(function(p) { return p.series}) - .enter() - .append("tr") - .classed("highlight", function(p) { return p.highlight}) - ; - - trowEnter.append("td") - .classed("legend-color-guide",true) - .append("div") - .style("background-color", function(p) { return p.color}); - trowEnter.append("td") - .classed("key",true) - .html(function(p) {return p.key}); - trowEnter.append("td") - .classed("value",true) - .html(function(p,i) { return valueFormatter(p.value,i) }); - - - trowEnter.selectAll("td").each(function(p) { - if (p.highlight) { - var opacityScale = d3.scale.linear().domain([0,1]).range(["#fff",p.color]); - var opacity = 0.6; - d3.select(this) - .style("border-bottom-color", opacityScale(opacity)) - .style("border-top-color", opacityScale(opacity)) - ; - } - }); - - var html = table.node().outerHTML; - if (d.footer !== undefined) - html += ""; - return html; - - }; - - var dataSeriesExists = function(d) { - if (d && d.series && d.series.length > 0) return true; - - return false; - }; - - //In situations where the chart is in a 'viewBox', re-position the tooltip based on how far chart is zoomed. - function convertViewBoxRatio() { - if (chartContainer) { - var svg = d3.select(chartContainer); - if (svg.node().tagName !== "svg") { - svg = svg.select("svg"); - } - var viewBox = (svg.node()) ? svg.attr('viewBox') : null; - if (viewBox) { - viewBox = viewBox.split(' '); - var ratio = parseInt(svg.style('width')) / viewBox[2]; - - position.left = position.left * ratio; - position.top = position.top * ratio; - } - } - } - - //Creates new tooltip container, or uses existing one on DOM. - function getTooltipContainer(newContent) { - var body; - if (chartContainer) - body = d3.select(chartContainer); - else - body = d3.select("body"); - - var container = body.select(".nvtooltip"); - if (container.node() === null) { - //Create new tooltip div if it doesn't exist on DOM. - container = body.append("div") - .attr("class", "nvtooltip " + (classes? classes: "xy-tooltip")) - .attr("id",id) - ; - } - - - container.node().innerHTML = newContent; - container.style("top",0).style("left",0).style("opacity",0); - container.selectAll("div, table, td, tr").classed(nvPointerEventsClass,true) - container.classed(nvPointerEventsClass,true); - return container.node(); - } - - - - //Draw the tooltip onto the DOM. - function nvtooltip() { - if (!enabled) return; - if (!dataSeriesExists(data)) return; - - convertViewBoxRatio(); - - var left = position.left; - var top = (fixedTop != null) ? fixedTop : position.top; - var container = getTooltipContainer(contentGenerator(data)); - tooltipElem = container; - if (chartContainer) { - var svgComp = chartContainer.getElementsByTagName("svg")[0]; - var boundRect = (svgComp) ? svgComp.getBoundingClientRect() : chartContainer.getBoundingClientRect(); - var svgOffset = {left:0,top:0}; - if (svgComp) { - var svgBound = svgComp.getBoundingClientRect(); - var chartBound = chartContainer.getBoundingClientRect(); - var svgBoundTop = svgBound.top; - - //Defensive code. Sometimes, svgBoundTop can be a really negative - // number, like -134254. That's a bug. - // If such a number is found, use zero instead. FireFox bug only - if (svgBoundTop < 0) { - var containerBound = chartContainer.getBoundingClientRect(); - svgBoundTop = (Math.abs(svgBoundTop) > containerBound.height) ? 0 : svgBoundTop; - } - svgOffset.top = Math.abs(svgBoundTop - chartBound.top); - svgOffset.left = Math.abs(svgBound.left - chartBound.left); - } - //If the parent container is an overflow
with scrollbars, subtract the scroll offsets. - //You need to also add any offset between the element and its containing
- //Finally, add any offset of the containing
on the whole page. - left += chartContainer.offsetLeft + svgOffset.left - 2*chartContainer.scrollLeft; - top += chartContainer.offsetTop + svgOffset.top - 2*chartContainer.scrollTop; - } - - if (snapDistance && snapDistance > 0) { - top = Math.floor(top/snapDistance) * snapDistance; - } - - nv.tooltip.calcTooltipPosition([left,top], gravity, distance, container); - return nvtooltip; - }; - - nvtooltip.nvPointerEventsClass = nvPointerEventsClass; - - nvtooltip.content = function(_) { - if (!arguments.length) return content; - content = _; - return nvtooltip; - }; - - //Returns tooltipElem...not able to set it. - nvtooltip.tooltipElem = function() { - return tooltipElem; - }; - - nvtooltip.contentGenerator = function(_) { - if (!arguments.length) return contentGenerator; - if (typeof _ === 'function') { - contentGenerator = _; - } - return nvtooltip; - }; - - nvtooltip.data = function(_) { - if (!arguments.length) return data; - data = _; - return nvtooltip; - }; - - nvtooltip.gravity = function(_) { - if (!arguments.length) return gravity; - gravity = _; - return nvtooltip; - }; - - nvtooltip.distance = function(_) { - if (!arguments.length) return distance; - distance = _; - return nvtooltip; - }; - - nvtooltip.snapDistance = function(_) { - if (!arguments.length) return snapDistance; - snapDistance = _; - return nvtooltip; - }; - - nvtooltip.classes = function(_) { - if (!arguments.length) return classes; - classes = _; - return nvtooltip; - }; - - nvtooltip.chartContainer = function(_) { - if (!arguments.length) return chartContainer; - chartContainer = _; - return nvtooltip; - }; - - nvtooltip.position = function(_) { - if (!arguments.length) return position; - position.left = (typeof _.left !== 'undefined') ? _.left : position.left; - position.top = (typeof _.top !== 'undefined') ? _.top : position.top; - return nvtooltip; - }; - - nvtooltip.fixedTop = function(_) { - if (!arguments.length) return fixedTop; - fixedTop = _; - return nvtooltip; - }; - - nvtooltip.enabled = function(_) { - if (!arguments.length) return enabled; - enabled = _; - return nvtooltip; - }; - - nvtooltip.valueFormatter = function(_) { - if (!arguments.length) return valueFormatter; - if (typeof _ === 'function') { - valueFormatter = _; - } - return nvtooltip; - }; - - nvtooltip.headerFormatter = function(_) { - if (!arguments.length) return headerFormatter; - if (typeof _ === 'function') { - headerFormatter = _; - } - return nvtooltip; - }; - - //id() is a read-only function. You can't use it to set the id. - nvtooltip.id = function() { - return id; - }; - - - return nvtooltip; - }; - - - //Original tooltip.show function. Kept for backward compatibility. - // pos = [left,top] - nv.tooltip.show = function(pos, content, gravity, dist, parentContainer, classes) { - - //Create new tooltip div if it doesn't exist on DOM. - var container = document.createElement('div'); - container.className = 'nvtooltip ' + (classes ? classes : 'xy-tooltip'); - - var body = parentContainer; - if ( !parentContainer || parentContainer.tagName.match(/g|svg/i)) { - //If the parent element is an SVG element, place tooltip in the element. - body = document.getElementsByTagName('body')[0]; - } - - container.style.left = 0; - container.style.top = 0; - container.style.opacity = 0; - container.innerHTML = content; - body.appendChild(container); - - //If the parent container is an overflow
with scrollbars, subtract the scroll offsets. - if (parentContainer) { - pos[0] = pos[0] - parentContainer.scrollLeft; - pos[1] = pos[1] - parentContainer.scrollTop; - } - nv.tooltip.calcTooltipPosition(pos, gravity, dist, container); - }; - - //Looks up the ancestry of a DOM element, and returns the first NON-svg node. - nv.tooltip.findFirstNonSVGParent = function(Elem) { - while(Elem.tagName.match(/^g|svg$/i) !== null) { - Elem = Elem.parentNode; - } - return Elem; - }; - - //Finds the total offsetTop of a given DOM element. - //Looks up the entire ancestry of an element, up to the first relatively positioned element. - nv.tooltip.findTotalOffsetTop = function ( Elem, initialTop ) { - var offsetTop = initialTop; - - do { - if( !isNaN( Elem.offsetTop ) ) { - offsetTop += (Elem.offsetTop); - } - } while( Elem = Elem.offsetParent ); - return offsetTop; - }; - - //Finds the total offsetLeft of a given DOM element. - //Looks up the entire ancestry of an element, up to the first relatively positioned element. - nv.tooltip.findTotalOffsetLeft = function ( Elem, initialLeft) { - var offsetLeft = initialLeft; - - do { - if( !isNaN( Elem.offsetLeft ) ) { - offsetLeft += (Elem.offsetLeft); - } - } while( Elem = Elem.offsetParent ); - return offsetLeft; - }; - - //Global utility function to render a tooltip on the DOM. - //pos = [left,top] coordinates of where to place the tooltip, relative to the SVG chart container. - //gravity = how to orient the tooltip - //dist = how far away from the mouse to place tooltip - //container = tooltip DIV - nv.tooltip.calcTooltipPosition = function(pos, gravity, dist, container) { - - var height = parseInt(container.offsetHeight), - width = parseInt(container.offsetWidth), - windowWidth = nv.utils.windowSize().width, - windowHeight = nv.utils.windowSize().height, - scrollTop = window.pageYOffset, - scrollLeft = window.pageXOffset, - left, top; - - windowHeight = window.innerWidth >= document.body.scrollWidth ? windowHeight : windowHeight - 16; - windowWidth = window.innerHeight >= document.body.scrollHeight ? windowWidth : windowWidth - 16; - - gravity = gravity || 's'; - dist = dist || 20; - - var tooltipTop = function ( Elem ) { - return nv.tooltip.findTotalOffsetTop(Elem, top); - }; - - var tooltipLeft = function ( Elem ) { - return nv.tooltip.findTotalOffsetLeft(Elem,left); - }; - - switch (gravity) { - case 'e': - left = pos[0] - width - dist; - top = pos[1] - (height / 2); - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft < scrollLeft) left = pos[0] + dist > scrollLeft ? pos[0] + dist : scrollLeft - tLeft + left; - if (tTop < scrollTop) top = scrollTop - tTop + top; - if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; - break; - case 'w': - left = pos[0] + dist; - top = pos[1] - (height / 2); - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft + width > windowWidth) left = pos[0] - width - dist; - if (tTop < scrollTop) top = scrollTop + 5; - if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; - break; - case 'n': - left = pos[0] - (width / 2) - 5; - top = pos[1] + dist; - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft < scrollLeft) left = scrollLeft + 5; - if (tLeft + width > windowWidth) left = left - width/2 + 5; - if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; - break; - case 's': - left = pos[0] - (width / 2); - top = pos[1] - height - dist; - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - if (tLeft < scrollLeft) left = scrollLeft + 5; - if (tLeft + width > windowWidth) left = left - width/2 + 5; - if (scrollTop > tTop) top = scrollTop; - break; - case 'none': - left = pos[0]; - top = pos[1] - dist; - var tLeft = tooltipLeft(container); - var tTop = tooltipTop(container); - break; - } - - - container.style.left = left+'px'; - container.style.top = top+'px'; - container.style.opacity = 1; - container.style.position = 'absolute'; - - return container; - }; - - //Global utility function to remove tooltips from the DOM. - nv.tooltip.cleanup = function() { - - // Find the tooltips, mark them for removal by this class (so others cleanups won't find it) - var tooltips = document.getElementsByClassName('nvtooltip'); - var purging = []; - while(tooltips.length) { - purging.push(tooltips[0]); - tooltips[0].style.transitionDelay = '0 !important'; - tooltips[0].style.opacity = 0; - tooltips[0].className = 'nvtooltip-pending-removal'; - } - - setTimeout(function() { - - while (purging.length) { - var removeMe = purging.pop(); - removeMe.parentNode.removeChild(removeMe); - } - }, 500); - }; - -})(); diff --git a/awx/ui/static/lib/novus-nvd3/src/utils.js b/awx/ui/static/lib/novus-nvd3/src/utils.js deleted file mode 100755 index 13e848f567..0000000000 --- a/awx/ui/static/lib/novus-nvd3/src/utils.js +++ /dev/null @@ -1,153 +0,0 @@ - -nv.utils.windowSize = function() { - // Sane defaults - var size = {width: 640, height: 480}; - - // Earlier IE uses Doc.body - if (document.body && document.body.offsetWidth) { - size.width = document.body.offsetWidth; - size.height = document.body.offsetHeight; - } - - // IE can use depending on mode it is in - if (document.compatMode=='CSS1Compat' && - document.documentElement && - document.documentElement.offsetWidth ) { - size.width = document.documentElement.offsetWidth; - size.height = document.documentElement.offsetHeight; - } - - // Most recent browsers use - if (window.innerWidth && window.innerHeight) { - size.width = window.innerWidth; - size.height = window.innerHeight; - } - return (size); -}; - - - -// Easy way to bind multiple functions to window.onresize -// TODO: give a way to remove a function after its bound, other than removing all of them -nv.utils.windowResize = function(fun){ - if (fun === undefined) return; - var oldresize = window.onresize; - - window.onresize = function(e) { - if (typeof oldresize == 'function') oldresize(e); - fun(e); - } -} - -// Backwards compatible way to implement more d3-like coloring of graphs. -// If passed an array, wrap it in a function which implements the old default -// behavior -nv.utils.getColor = function(color) { - if (!arguments.length) return nv.utils.defaultColor(); //if you pass in nothing, get default colors back - - if( Object.prototype.toString.call( color ) === '[object Array]' ) - return function(d, i) { return d.color || color[i % color.length]; }; - else - return color; - //can't really help it if someone passes rubbish as color -} - -// Default color chooser uses the index of an object as before. -nv.utils.defaultColor = function() { - var colors = d3.scale.category20().range(); - return function(d, i) { return d.color || colors[i % colors.length] }; -} - - -// Returns a color function that takes the result of 'getKey' for each series and -// looks for a corresponding color from the dictionary, -nv.utils.customTheme = function(dictionary, getKey, defaultColors) { - getKey = getKey || function(series) { return series.key }; // use default series.key if getKey is undefined - defaultColors = defaultColors || d3.scale.category20().range(); //default color function - - var defIndex = defaultColors.length; //current default color (going in reverse) - - return function(series, index) { - var key = getKey(series); - - if (!defIndex) defIndex = defaultColors.length; //used all the default colors, start over - - if (typeof dictionary[key] !== "undefined") - return (typeof dictionary[key] === "function") ? dictionary[key]() : dictionary[key]; - else - return defaultColors[--defIndex]; // no match in dictionary, use default color - } -} - - - -// From the PJAX example on d3js.org, while this is not really directly needed -// it's a very cool method for doing pjax, I may expand upon it a little bit, -// open to suggestions on anything that may be useful -nv.utils.pjax = function(links, content) { - d3.selectAll(links).on("click", function() { - history.pushState(this.href, this.textContent, this.href); - load(this.href); - d3.event.preventDefault(); - }); - - function load(href) { - d3.html(href, function(fragment) { - var target = d3.select(content).node(); - target.parentNode.replaceChild(d3.select(fragment).select(content).node(), target); - nv.utils.pjax(links, content); - }); - } - - d3.select(window).on("popstate", function() { - if (d3.event.state) load(d3.event.state); - }); -} - -/* For situations where we want to approximate the width in pixels for an SVG:text element. -Most common instance is when the element is in a display:none; container. -Forumla is : text.length * font-size * constant_factor -*/ -nv.utils.calcApproxTextWidth = function (svgTextElem) { - if (typeof svgTextElem.style === 'function' - && typeof svgTextElem.text === 'function') { - var fontSize = parseInt(svgTextElem.style("font-size").replace("px","")); - var textLength = svgTextElem.text().length; - - return textLength * fontSize * 0.5; - } - return 0; -}; - -/* Numbers that are undefined, null or NaN, convert them to zeros. -*/ -nv.utils.NaNtoZero = function(n) { - if (typeof n !== 'number' - || isNaN(n) - || n === null - || n === Infinity) return 0; - - return n; -}; - -/* -Snippet of code you can insert into each nv.models.* to give you the ability to -do things like: -chart.options({ - showXAxis: true, - tooltips: true -}); - -To enable in the chart: -chart.options = nv.utils.optionsFunc.bind(chart); -*/ -nv.utils.optionsFunc = function(args) { - if (args) { - d3.map(args).forEach((function(key,value) { - if (typeof this[key] === "function") { - this[key](value); - } - }).bind(this)); - } - return this; -}; \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/test/ScatterChartTest.html b/awx/ui/static/lib/novus-nvd3/test/ScatterChartTest.html deleted file mode 100755 index 464453d334..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/ScatterChartTest.html +++ /dev/null @@ -1,256 +0,0 @@ - - - - - - - -
-

Scatter chart tests

- -
- Normal - four series', all random (40 points) - - -
-
- Normal - one series', all random (5 points), zero left margin - - -
-
- Zero right margin, 200 points - - -
-
- Bigger margins - - -
-
- Zero data points - - -
-
- One point. - - -
-
- Two points - - -
-
- Three series', one point each - - -
-
- Three series', first one has zero points - - -
-
- Lots of series - - -
-
- Scatter plus line: y=2x + 0 - - -
-
- Scatter plus line: y=2x + 10; - - -
-
- Scatter plus line: y=-0.5x + 1.0; - - -
-
- Scatter chart: duplicate y values - - -
-
- Scatter chart: duplicate x values - - -
-
- Scatter chart: extremely small data points (1e-10) - - -
- - -
- - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/test/interactiveBisectTest.html b/awx/ui/static/lib/novus-nvd3/test/interactiveBisectTest.html deleted file mode 100755 index 9cbf5aa9f1..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/interactiveBisectTest.html +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - -

Unit tests for nv.interactiveBisect - this function is important for rendering tooltips and the guideline on charts.

- - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/test/lineChartTest.html b/awx/ui/static/lib/novus-nvd3/test/lineChartTest.html deleted file mode 100755 index 88de3764d8..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/lineChartTest.html +++ /dev/null @@ -1,475 +0,0 @@ - - - - - - - -

Line chart test cases - feel free to add more tests

-
- -
- Example of chart with many series', and new interactive guideline plus tooltip. A chunk of data was purposely removed - to show how the chart handles it. - - -
-
- Chart with old tooltip style (with-transitions). - - -
-
- Chart with three data points. - - -
-
- Chart where two series have different number of points. - - -
-
- Chart with one point. - - -
-
- Chart with 1000 points. - - -
- -
- Chart with no data. - - -
-
- All points random. No order. - - -
-
- Points do not increase linearly. - - -
- -
- Chart with 15 series' - - -
-
- Data points go backwards - - -
-
- Duplicate X coordinate points. - - -
- -
- Duplicate Y coordinate points. - - -
- -
- Chart in a overflow div with scrolls (new tooltips) - - -
- -
- Chart in a overflow div with scrolls (old tooltips) - - -
- -
-
- What if there are null, Infinity and NaN values in points? - - -
-
- Chart with very small, 1e-10, points (old tooltips) - - -
-
- - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/test/multiBarChartTest.html b/awx/ui/static/lib/novus-nvd3/test/multiBarChartTest.html deleted file mode 100755 index 6242ff8496..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/multiBarChartTest.html +++ /dev/null @@ -1,148 +0,0 @@ - - - - - - -

Multibar chart test cases - feel free to add more tests

- -
- Normal chart, with transition delay, and bar color set. - -
-
- Normal chart, no transitionDuration or delay, no bar color set. - -
-
- Chart with single series, no group spacing. - -
-
- Chart with 18 series, 7 data points per series. - -
-
- Chart with 1 data point - -
-
- Chart with 2 data points - -
-
- Chart with 0 data points - -
- - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/test/pieChartTest.html b/awx/ui/static/lib/novus-nvd3/test/pieChartTest.html deleted file mode 100755 index 8fef1af71a..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/pieChartTest.html +++ /dev/null @@ -1,177 +0,0 @@ - - - - - - - -
-

Standard Pie Chart

- -
- -
-

Donut pie chart

- -
- -
-

Pie chart with 30 series'

- -
- -
-

Pie chart with percent label type

- -
- -
-

Empty array passed in

- -
- -
-

Series' have only zero values

- -
- -
-

NaN, null, undefined values passed in

- -
- - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/test/polylinearTest.html b/awx/ui/static/lib/novus-nvd3/test/polylinearTest.html deleted file mode 100755 index eef88b3481..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/polylinearTest.html +++ /dev/null @@ -1,192 +0,0 @@ - - - - - - - -

Test cases for Domain and Range overrides - Example of a polylinear scale

-
- -
- Line chart: yDomain = [0,2,200], yRange = [500,50,0] - -
-
- Historical bar chart: yDomain = [0,2,130], yRange = [500,50,0] - -
- -
- Notes: - The chart.yRange() and chart.xRange() properties are an advanced feature. They are useful - in situations where your data has wild extremes: ie, you have lots of smaller numbers, and lots of really big numbers.

- - Without a polylinear scale, those really big data points will overwhelm the small points.

- - Please look at the examples to understand how polylinear scales work. Comment/uncomment the lines that alter yDomain and yRange - to see the effect it has on the charts. -
-
- - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/test/realTimeChartTest.html b/awx/ui/static/lib/novus-nvd3/test/realTimeChartTest.html deleted file mode 100755 index d8a8029dd6..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/realTimeChartTest.html +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - -

Example showing real time chart updating

- The chart below is a historical bar chart, which is ideal for visualizing time series data.
- First, you need to update the data model for the chart. In the example, we append a random number - every half a second. Then, you call chart.update(). - -
- - -
- - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/test/stackedAreaChartTest.html b/awx/ui/static/lib/novus-nvd3/test/stackedAreaChartTest.html deleted file mode 100755 index 1bb0a9a3ce..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/stackedAreaChartTest.html +++ /dev/null @@ -1,322 +0,0 @@ - - - - - - -

Stacked area chart test cases - feel free to add more tests

- -
Full chart example with new tooltip and guideline
-
Chart with old tooltips (with-transitions)
-
Chart with single point
-
Chart with two points
-
Chart with 'holes'
-
Total random points
-
Less than four points, old tooltips
-
No data
-
Data is all negative
- - - - - - - - - - - - - - diff --git a/awx/ui/static/lib/novus-nvd3/test/testScript.js b/awx/ui/static/lib/novus-nvd3/test/testScript.js deleted file mode 100755 index 2e7dc16e4b..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/testScript.js +++ /dev/null @@ -1,20 +0,0 @@ -//A little snippet of D3 code that creates a button that lets you toggle whether a chart is the only one visible on a page or not. -d3.selectAll(".chart button").on("click",function() { - var thisId = this.parentElement.id; - - var chartContainer = d3.select("#" + thisId); - if (chartContainer.attr("class").match("selected")) - chartContainer.classed("selected",false); - else - chartContainer.classed("selected",true); - - d3.selectAll(".chart").style("display",function() { - if (thisId === this.id) return "block"; - - if (d3.select(this).style("display") === "none") - return "block"; - else - return "none"; - }); - window.onresize(); -}); \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/test/teststyle.css b/awx/ui/static/lib/novus-nvd3/test/teststyle.css deleted file mode 100755 index db5bdd0965..0000000000 --- a/awx/ui/static/lib/novus-nvd3/test/teststyle.css +++ /dev/null @@ -1,39 +0,0 @@ -body { - overflow-y:scroll; - font-family: arial; -} - -text { - font: 12px sans-serif; -} - -.chart { - float:left; - height: 500px; - text-align: center; - font-weight: bold; - margin-bottom: 2em; -} -.chart.full { - width: 100%; -} - -.chart.half { - width: 50%; -} - -.chart.third { - width: 33%; -} - -.chart.selected { - width: 100% !important; -} - -.navigation a{ - margin-right: 1em; -} - -.navigation { - margin-bottom: 1em; -} diff --git a/awx/ui/static/lib/nvd3/.bower.json b/awx/ui/static/lib/nvd3/.bower.json new file mode 100644 index 0000000000..d1497d7a89 --- /dev/null +++ b/awx/ui/static/lib/nvd3/.bower.json @@ -0,0 +1,57 @@ +{ + "name": "nvd3", + "version": "1.7.1", + "homepage": "http://www.nvd3.org", + "authors": [ + "Bob Monteverde", + "Tyler Wolf", + "Robin Hu", + "Frank Shao", + "liquidpele" + ], + "description": "Re-usable charts and chart components for d3.", + "main": [ + "build/nv.d3.js", + "build/nv.d3.css" + ], + "keywords": [ + "d3", + "visualization", + "svg", + "charts" + ], + "license": "Apache License, v2.0", + "dependencies": { + "d3": "~3.3.13" + }, + "ignore": [ + "**/.*", + "node_modules", + "bower_components", + "test", + "src", + "examples", + "GruntFile.js", + "*.html", + "*.log", + "*.xml", + "*.json", + "*.md" + ], + "resolutions": { + "d3": "~3.3.13" + }, + "devDependencies": { + "d3": "~3.3.13" + }, + "_release": "1.7.1", + "_resolution": { + "type": "version", + "tag": "v1.7.1", + "commit": "679fe2ff96c194e442970cb9959ebccd79f6bd43" + }, + "_source": "git://github.com/novus/nvd3.git", + "_target": "~1.7.1", + "_originalSource": "nvd3", + "_direct": true +} \ No newline at end of file diff --git a/awx/ui/static/lib/novus-nvd3/bower.json b/awx/ui/static/lib/nvd3/bower.json old mode 100755 new mode 100644 similarity index 57% rename from awx/ui/static/lib/novus-nvd3/bower.json rename to awx/ui/static/lib/nvd3/bower.json index acfa8cfc4a..577ea78d56 --- a/awx/ui/static/lib/novus-nvd3/bower.json +++ b/awx/ui/static/lib/nvd3/bower.json @@ -1,15 +1,19 @@ { "name": "nvd3", - "version": "1.1.15-beta", + "version": "1.7.1", "homepage": "http://www.nvd3.org", "authors": [ "Bob Monteverde", "Tyler Wolf", "Robin Hu", - "Frank Shao" + "Frank Shao", + "liquidpele" ], "description": "Re-usable charts and chart components for d3.", - "main": ["nv.d3.js", "nv.d3.css"], + "main": [ + "build/nv.d3.js", + "build/nv.d3.css" + ], "keywords": [ "d3", "visualization", @@ -20,16 +24,24 @@ "dependencies": { "d3": "~3.3.13" }, - "ignore" : [ + "ignore": [ "**/.*", "node_modules", "bower_components", "test", - "tests", - "src/models/*", - "src/*.js", - "lib", + "src", "examples", - "deprecated" - ] + "GruntFile.js", + "*.html", + "*.log", + "*.xml", + "*.json", + "*.md" + ], + "resolutions": { + "d3": "~3.3.13" + }, + "devDependencies": { + "d3": "~3.3.13" + } } diff --git a/awx/ui/static/lib/novus-nvd3/nv.d3.css b/awx/ui/static/lib/nvd3/build/nv.d3.css old mode 100755 new mode 100644 similarity index 78% rename from awx/ui/static/lib/novus-nvd3/nv.d3.css rename to awx/ui/static/lib/nvd3/build/nv.d3.css index cae834827c..26453e88f4 --- a/awx/ui/static/lib/novus-nvd3/nv.d3.css +++ b/awx/ui/static/lib/nvd3/build/nv.d3.css @@ -1,13 +1,32 @@ - /******************** - * HTML CSS + * SVG CSS */ -.chartWrap { - margin: 0; - padding: 0; - overflow: hidden; +svg { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + /* Trying to get SVG to act like a greedy block in all browsers */ + display: block; + width:100%; + height:100%; +} + +/******************** + Default CSS for an svg element nvd3 used +*/ +svg.nvd3-svg { + -webkit-touch-callout: none; + -webkit-user-select: none; + -khtml-user-select: none; + -ms-user-select: none; + -moz-user-select: none; + user-select: none; + display: block; } /******************** @@ -18,9 +37,9 @@ -webkit-box-shadow: 0 5px 10px rgba(0,0,0,.2); box-shadow: 0 5px 10px rgba(0,0,0,.2); - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; } /******************** @@ -53,13 +72,13 @@ putting a "with-transitions" class on the container div. */ .nvtooltip.with-transitions, .with-transitions .nvtooltip { - transition: opacity 250ms linear; - -moz-transition: opacity 250ms linear; - -webkit-transition: opacity 250ms linear; + transition: opacity 50ms linear; + -moz-transition: opacity 50ms linear; + -webkit-transition: opacity 50ms linear; - transition-delay: 250ms; - -moz-transition-delay: 250ms; - -webkit-transition-delay: 250ms; + transition-delay: 200ms; + -moz-transition-delay: 200ms; + -webkit-transition-delay: 200ms; } .nvtooltip.x-nvtooltip, @@ -79,7 +98,7 @@ -webkit-border-radius: 5px 5px 0 0; -moz-border-radius: 5px 5px 0 0; - border-radius: 5px 5px 0 0; + border-radius: 1px 5px 0 0; } .nvtooltip p { @@ -131,46 +150,22 @@ text-align: center; } - .nvtooltip-pending-removal { position: absolute; pointer-events: none; } - -/******************** - * SVG CSS - */ - - -svg { - -webkit-touch-callout: none; - -webkit-user-select: none; - -khtml-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; - /* Trying to get SVG to act like a greedy block in all browsers */ - display: block; - width:100%; - height:100%; -} - - -svg text { +.nvd3 text { font: normal 12px Arial; } -svg .title { +.nvd3 .title { font: bold 14px Arial; } .nvd3 .nv-background { fill: white; fill-opacity: 0; - /* - pointer-events: none; - */ } .nvd3.nv-noData { @@ -189,7 +184,6 @@ svg .title { } - /********** * Legend */ @@ -198,15 +192,23 @@ svg .title { cursor: pointer; } -.nvd3 .nv-legend .disabled circle { +.nvd3 .nv-legend .nv-disabled circle { fill-opacity: 0; } - /********** * Axes */ + +.axis { + opacity: 1; +} + +.axis.nv-disabled { + opacity: 0; +} + .nvd3 .nv-axis { pointer-events:none; } @@ -248,7 +250,6 @@ svg .title { } - /********** * Brush */ @@ -259,7 +260,6 @@ svg .title { } - /********** * Bars */ @@ -333,6 +333,11 @@ svg .title { } +.nvd3.nv-pie .nv-pie-title { + font-size: 24px; + fill: rgba(19, 196, 249, 0.59); +} + .nvd3.nv-pie .nv-slice text { stroke: #000; stroke-width: 0; @@ -362,18 +367,6 @@ svg .title { .nvd3 .nv-groups path.nv-line { fill: none; stroke-width: 1.5px; - /* - stroke-linecap: round; - shape-rendering: geometricPrecision; - - transition: stroke-width 250ms linear; - -moz-transition: stroke-width 250ms linear; - -webkit-transition: stroke-width 250ms linear; - - transition-delay: 250ms - -moz-transition-delay: 250ms; - -webkit-transition-delay: 250ms; - */ } .nvd3 .nv-groups path.nv-line.nv-thin-line { @@ -383,32 +376,12 @@ svg .title { .nvd3 .nv-groups path.nv-area { stroke: none; - /* - stroke-linecap: round; - shape-rendering: geometricPrecision; - - stroke-width: 2.5px; - transition: stroke-width 250ms linear; - -moz-transition: stroke-width 250ms linear; - -webkit-transition: stroke-width 250ms linear; - - transition-delay: 250ms - -moz-transition-delay: 250ms; - -webkit-transition-delay: 250ms; - */ } .nvd3 .nv-line.hover path { stroke-width: 6px; } -/* -.nvd3.scatter .groups .point { - fill-opacity: 0.1; - stroke-opacity: 0.1; -} - */ - .nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point { fill-opacity: 0; stroke-opacity: 0; @@ -458,17 +431,10 @@ svg .title { } - /********** * Scatter */ -/* **Attempting to remove this for useVoronoi(false), need to see if it's required anywhere -.nvd3 .nv-groups .nv-point { - pointer-events: none; -} -*/ - .nvd3 .nv-groups .nv-point.hover { stroke-width: 20px; stroke-opacity: .5; @@ -478,12 +444,6 @@ svg .title { fill-opacity: 1; } -/* -.nv-group.hover .nv-point { - fill-opacity: 1; -} -*/ - /********** * Stacked Area @@ -491,36 +451,15 @@ svg .title { .nvd3.nv-stackedarea path.nv-area { fill-opacity: .7; - /* - stroke-opacity: .65; - fill-opacity: 1; - */ stroke-opacity: 0; - transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; -moz-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; -webkit-transition: fill-opacity 250ms linear, stroke-opacity 250ms linear; - - /* - transition-delay: 500ms; - -moz-transition-delay: 500ms; - -webkit-transition-delay: 500ms; - */ - } .nvd3.nv-stackedarea path.nv-area.hover { fill-opacity: .9; - /* - stroke-opacity: .85; - */ } -/* -.d3stackedarea .groups path { - stroke-opacity: 0; -} - */ - .nvd3.nv-stackedarea .nv-groups .nv-point { @@ -528,14 +467,6 @@ svg .title { fill-opacity: 0; } -/* -.nvd3.nv-stackedarea .nv-groups .nv-point.hover { - stroke-width: 20px; - stroke-opacity: .75; - fill-opacity: 1; -}*/ - - /********** * Line Plus Bar @@ -576,7 +507,6 @@ svg .title { } - /********** * Sparkline */ @@ -606,9 +536,6 @@ svg .title { .nvd3.nv-sparklineplus .nv-xValue, .nvd3.nv-sparklineplus .nv-yValue { - /* - stroke: #666; - */ stroke-width: 0; font-size: .9em; font-weight: normal; @@ -629,10 +556,6 @@ svg .title { } .nvd3.nv-sparklineplus .nv-currentValue { - /* - stroke: #444; - fill: #000; - */ font-weight: bold; font-size: 1.1em; } @@ -642,19 +565,19 @@ svg .title { */ .nvd3.nv-ohlcBar .nv-ticks .nv-tick { - stroke-width: 2px; + stroke-width: 1px; } .nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover { - stroke-width: 4px; + stroke-width: 2px; } .nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive { - stroke: #2ca02c; + stroke: #2ca02c; } .nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative { - stroke: #d62728; + stroke: #d62728; } .nvd3.nv-historicalStockChart .nv-axis .nv-axislabel { @@ -668,9 +591,6 @@ svg .title { } .nvd3 .nv-brush .extent { - /* - cursor: ew-resize !important; - */ fill-opacity: 0 !important; } @@ -682,63 +602,19 @@ svg .title { } - -/********** -* Indented Tree -*/ - - -/** - * TODO: the following 3 selectors are based on classes used in the example. I should either make them standard and leave them here, or move to a CSS file not included in the library - */ -.nvd3.nv-indentedtree .name { - margin-left: 5px; -} - -.nvd3.nv-indentedtree .clickable { - color: #08C; - cursor: pointer; -} - -.nvd3.nv-indentedtree span.clickable:hover { - color: #005580; - text-decoration: underline; -} - - -.nvd3.nv-indentedtree .nv-childrenCount { - display: inline-block; - margin-left: 5px; -} - -.nvd3.nv-indentedtree .nv-treeicon { - cursor: pointer; - /* - cursor: n-resize; - */ -} - -.nvd3.nv-indentedtree .nv-treeicon.nv-folded { - cursor: pointer; - /* - cursor: s-resize; - */ -} - /********** * Parallel Coordinates */ .nvd3 .background path { fill: none; - stroke: #ccc; + stroke: #EEE; stroke-opacity: .4; shape-rendering: crispEdges; } .nvd3 .foreground path { fill: none; - stroke: steelblue; stroke-opacity: .7; } diff --git a/awx/ui/static/lib/nvd3/build/nv.d3.js b/awx/ui/static/lib/nvd3/build/nv.d3.js new file mode 100644 index 0000000000..f02b6d6aa6 --- /dev/null +++ b/awx/ui/static/lib/nvd3/build/nv.d3.js @@ -0,0 +1,11357 @@ +/* nvd3 version 1.7.1(https://github.com/novus/nvd3) 2015-02-05 */ +(function(){ + +// set up main nv object on window +var nv = window.nv || {}; +window.nv = nv; + +// the major global objects under the nv namespace +nv.dev = false; //set false when in production +nv.tooltip = nv.tooltip || {}; // For the tooltip system +nv.utils = nv.utils || {}; // Utility subsystem +nv.models = nv.models || {}; //stores all the possible models/components +nv.charts = {}; //stores all the ready to use charts +nv.graphs = []; //stores all the graphs currently on the page +nv.logs = {}; //stores some statistics and potential error messages + +nv.dispatch = d3.dispatch('render_start', 'render_end'); + +// Function bind polyfill +// Needed ONLY for phantomJS as it's missing until version 2.0 which is unreleased as of this comment +// https://github.com/ariya/phantomjs/issues/10522 +// http://kangax.github.io/compat-table/es5/#Function.prototype.bind +// phantomJS is used for running the test suite +if (!Function.prototype.bind) { + Function.prototype.bind = function (oThis) { + if (typeof this !== "function") { + // closest thing possible to the ECMAScript 5 internal IsCallable function + throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); + } + + var aArgs = Array.prototype.slice.call(arguments, 1), + fToBind = this, + fNOP = function () {}, + fBound = function () { + return fToBind.apply(this instanceof fNOP && oThis + ? this + : oThis, + aArgs.concat(Array.prototype.slice.call(arguments))); + }; + + fNOP.prototype = this.prototype; + fBound.prototype = new fNOP(); + return fBound; + }; +} + +// Development render timers - disabled if dev = false +if (nv.dev) { + nv.dispatch.on('render_start', function(e) { + nv.logs.startTime = +new Date(); + }); + + nv.dispatch.on('render_end', function(e) { + nv.logs.endTime = +new Date(); + nv.logs.totalTime = nv.logs.endTime - nv.logs.startTime; + nv.log('total', nv.logs.totalTime); // used for development, to keep track of graph generation times + }); +} + +// Logs all arguments, and returns the last so you can test things in place +// Note: in IE8 console.log is an object not a function, and if modernizr is used +// then calling Function.prototype.bind with with anything other than a function +// causes a TypeError to be thrown. +nv.log = function() { + if (nv.dev && window.console && console.log && console.log.apply) + console.log.apply(console, arguments); + else if (nv.dev && window.console && typeof console.log == "function" && Function.prototype.bind) { + var log = Function.prototype.bind.call(console.log, console); + log.apply(console, arguments); + } + return arguments[arguments.length - 1]; +}; + +// print console warning, should be used by deprecated functions +nv.deprecated = function(name) { + if (nv.dev && console && console.warn) { + console.warn('`' + name + '` has been deprecated.'); + } +}; + +// render function is used to queue up chart rendering +// in non-blocking timeout functions +nv.render = function render(step) { + // number of graphs to generate in each timeout loop + step = step || 1; + + nv.render.active = true; + nv.dispatch.render_start(); + + setTimeout(function() { + var chart, graph; + + for (var i = 0; i < step && (graph = nv.render.queue[i]); i++) { + chart = graph.generate(); + if (typeof graph.callback == typeof(Function)) graph.callback(chart); + nv.graphs.push(chart); + } + + nv.render.queue.splice(0, i); + + if (nv.render.queue.length) setTimeout(arguments.callee, 0); + else { + nv.dispatch.render_end(); + nv.render.active = false; + } + }, 0); +}; + +nv.render.active = false; +nv.render.queue = []; + +// main function to use when adding a new graph, see examples +nv.addGraph = function(obj) { + if (typeof arguments[0] === typeof(Function)) { + obj = {generate: arguments[0], callback: arguments[1]}; + } + + nv.render.queue.push(obj); + + if (!nv.render.active) { + nv.render(); + } +};/* Utility class to handle creation of an interactive layer. + This places a rectangle on top of the chart. When you mouse move over it, it sends a dispatch + containing the X-coordinate. It can also render a vertical line where the mouse is located. + + dispatch.elementMousemove is the important event to latch onto. It is fired whenever the mouse moves over + the rectangle. The dispatch is given one object which contains the mouseX/Y location. + It also has 'pointXValue', which is the conversion of mouseX to the x-axis scale. + */ +nv.interactiveGuideline = function() { + "use strict"; + + var tooltip = nv.models.tooltip(); + + //Public settings + var width = null; + var height = null; + + //Please pass in the bounding chart's top and left margins + //This is important for calculating the correct mouseX/Y positions. + var margin = {left: 0, top: 0} + , xScale = d3.scale.linear() + , yScale = d3.scale.linear() + , dispatch = d3.dispatch('elementMousemove', 'elementMouseout', 'elementClick', 'elementDblclick') + , showGuideLine = true; + //Must pass in the bounding chart's container. + //The mousemove event is attached to this container. + var svgContainer = null; + + // check if IE by looking for activeX + var isMSIE = "ActiveXObject" in window; + + + function layer(selection) { + selection.each(function(data) { + var container = d3.select(this); + var availableWidth = (width || 960), availableHeight = (height || 400); + var wrap = container.selectAll("g.nv-wrap.nv-interactiveLineLayer") + .data([data]); + var wrapEnter = wrap.enter() + .append("g").attr("class", " nv-wrap nv-interactiveLineLayer"); + wrapEnter.append("g").attr("class","nv-interactiveGuideLine"); + + if (!svgContainer) { + return; + } + + function mouseHandler() { + var d3mouse = d3.mouse(this); + var mouseX = d3mouse[0]; + var mouseY = d3mouse[1]; + var subtractMargin = true; + var mouseOutAnyReason = false; + if (isMSIE) { + /* + D3.js (or maybe SVG.getScreenCTM) has a nasty bug in Internet Explorer 10. + d3.mouse() returns incorrect X,Y mouse coordinates when mouse moving + over a rect in IE 10. + However, d3.event.offsetX/Y also returns the mouse coordinates + relative to the triggering . So we use offsetX/Y on IE. + */ + mouseX = d3.event.offsetX; + mouseY = d3.event.offsetY; + + /* + On IE, if you attach a mouse event listener to the container, + it will actually trigger it for all the child elements (like , , etc). + When this happens on IE, the offsetX/Y is set to where ever the child element + is located. + As a result, we do NOT need to subtract margins to figure out the mouse X/Y + position under this scenario. Removing the line below *will* cause + the interactive layer to not work right on IE. + */ + if(d3.event.target.tagName !== "svg") { + subtractMargin = false; + } + + if (d3.event.target.className.baseVal.match("nv-legend")) { + mouseOutAnyReason = true; + } + + } + + if(subtractMargin) { + mouseX -= margin.left; + mouseY -= margin.top; + } + + /* If mouseX/Y is outside of the chart's bounds, + trigger a mouseOut event. + */ + if (mouseX < 0 || mouseY < 0 + || mouseX > availableWidth || mouseY > availableHeight + || (d3.event.relatedTarget && d3.event.relatedTarget.ownerSVGElement === undefined) + || mouseOutAnyReason + ) { + + if (isMSIE) { + if (d3.event.relatedTarget + && d3.event.relatedTarget.ownerSVGElement === undefined + && d3.event.relatedTarget.className.match(tooltip.nvPointerEventsClass)) { + + return; + } + } + dispatch.elementMouseout({ + mouseX: mouseX, + mouseY: mouseY + }); + layer.renderGuideLine(null); //hide the guideline + return; + } + + var pointXValue = xScale.invert(mouseX); + dispatch.elementMousemove({ + mouseX: mouseX, + mouseY: mouseY, + pointXValue: pointXValue + }); + + //If user double clicks the layer, fire a elementDblclick + if (d3.event.type === "dblclick") { + dispatch.elementDblclick({ + mouseX: mouseX, + mouseY: mouseY, + pointXValue: pointXValue + }); + } + + // if user single clicks the layer, fire elementClick + if (d3.event.type === 'click') { + dispatch.elementClick({ + mouseX: mouseX, + mouseY: mouseY, + pointXValue: pointXValue + }); + } + } + + svgContainer + .on("mousemove",mouseHandler, true) + .on("mouseout" ,mouseHandler,true) + .on("dblclick" ,mouseHandler) + .on("click", mouseHandler) + ; + + //Draws a vertical guideline at the given X postion. + layer.renderGuideLine = function(x) { + if (!showGuideLine) return; + var line = wrap.select(".nv-interactiveGuideLine") + .selectAll("line") + .data((x != null) ? [nv.utils.NaNtoZero(x)] : [], String); + + line.enter() + .append("line") + .attr("class", "nv-guideline") + .attr("x1", function(d) { return d;}) + .attr("x2", function(d) { return d;}) + .attr("y1", availableHeight) + .attr("y2",0) + ; + line.exit().remove(); + + } + }); + } + + layer.dispatch = dispatch; + layer.tooltip = tooltip; + + layer.margin = function(_) { + if (!arguments.length) return margin; + margin.top = typeof _.top != 'undefined' ? _.top : margin.top; + margin.left = typeof _.left != 'undefined' ? _.left : margin.left; + return layer; + }; + + layer.width = function(_) { + if (!arguments.length) return width; + width = _; + return layer; + }; + + layer.height = function(_) { + if (!arguments.length) return height; + height = _; + return layer; + }; + + layer.xScale = function(_) { + if (!arguments.length) return xScale; + xScale = _; + return layer; + }; + + layer.showGuideLine = function(_) { + if (!arguments.length) return showGuideLine; + showGuideLine = _; + return layer; + }; + + layer.svgContainer = function(_) { + if (!arguments.length) return svgContainer; + svgContainer = _; + return layer; + }; + + return layer; +}; + +/* Utility class that uses d3.bisect to find the index in a given array, where a search value can be inserted. + This is different from normal bisectLeft; this function finds the nearest index to insert the search value. + + For instance, lets say your array is [1,2,3,5,10,30], and you search for 28. + Normal d3.bisectLeft will return 4, because 28 is inserted after the number 10. But interactiveBisect will return 5 + because 28 is closer to 30 than 10. + + Unit tests can be found in: interactiveBisectTest.html + + Has the following known issues: + * Will not work if the data points move backwards (ie, 10,9,8,7, etc) or if the data points are in random order. + * Won't work if there are duplicate x coordinate values. + */ +nv.interactiveBisect = function (values, searchVal, xAccessor) { + "use strict"; + if (! (values instanceof Array)) { + return null; + } + if (typeof xAccessor !== 'function') { + xAccessor = function(d,i) { + return d.x; + } + } + + var bisect = d3.bisector(xAccessor).left; + var index = d3.max([0, bisect(values,searchVal) - 1]); + var currentValue = xAccessor(values[index], index); + + if (typeof currentValue === 'undefined') { + currentValue = index; + } + + if (currentValue === searchVal) { + return index; //found exact match + } + + var nextIndex = d3.min([index+1, values.length - 1]); + var nextValue = xAccessor(values[nextIndex], nextIndex); + + if (typeof nextValue === 'undefined') { + nextValue = nextIndex; + } + + if (Math.abs(nextValue - searchVal) >= Math.abs(currentValue - searchVal)) { + return index; + } else { + return nextIndex + } +}; + +/* + Returns the index in the array "values" that is closest to searchVal. + Only returns an index if searchVal is within some "threshold". + Otherwise, returns null. + */ +nv.nearestValueIndex = function (values, searchVal, threshold) { + "use strict"; + var yDistMax = Infinity, indexToHighlight = null; + values.forEach(function(d,i) { + var delta = Math.abs(searchVal - d); + if ( delta <= yDistMax && delta < threshold) { + yDistMax = delta; + indexToHighlight = i; + } + }); + return indexToHighlight; +}; +/* Tooltip rendering model for nvd3 charts. + window.nv.models.tooltip is the updated,new way to render tooltips. + + window.nv.tooltip.show is the old tooltip code. + window.nv.tooltip.* also has various helper methods. + */ +(function() { + "use strict"; + window.nv.tooltip = {}; + + /* Model which can be instantiated to handle tooltip rendering. + Example usage: + var tip = nv.models.tooltip().gravity('w').distance(23) + .data(myDataObject); + + tip(); //just invoke the returned function to render tooltip. + */ + window.nv.models.tooltip = function() { + //HTML contents of the tooltip. If null, the content is generated via the data variable. + var content = null; + + /* + Tooltip data. If data is given in the proper format, a consistent tooltip is generated. + Example Format of data: + { + key: "Date", + value: "August 2009", + series: [ + {key: "Series 1", value: "Value 1", color: "#000"}, + {key: "Series 2", value: "Value 2", color: "#00f"} + ] + } + */ + var data = null; + + var gravity = 'w' //Can be 'n','s','e','w'. Determines how tooltip is positioned. + ,distance = 50 //Distance to offset tooltip from the mouse location. + ,snapDistance = 25 //Tolerance allowed before tooltip is moved from its current position (creates 'snapping' effect) + , fixedTop = null //If not null, this fixes the top position of the tooltip. + , classes = null //Attaches additional CSS classes to the tooltip DIV that is created. + , chartContainer = null //Parent DIV, of the SVG Container that holds the chart. + , tooltipElem = null //actual DOM element representing the tooltip. + , position = {left: null, top: null} //Relative position of the tooltip inside chartContainer. + , enabled = true; //True -> tooltips are rendered. False -> don't render tooltips. + + //Generates a unique id when you create a new tooltip() object + var id = "nvtooltip-" + Math.floor(Math.random() * 100000); + + //CSS class to specify whether element should not have mouse events. + var nvPointerEventsClass = "nv-pointer-events-none"; + + //Format function for the tooltip values column + var valueFormatter = function(d,i) { + return d; + }; + + //Format function for the tooltip header value. + var headerFormatter = function(d) { + return d; + }; + + //By default, the tooltip model renders a beautiful table inside a DIV. + //You can override this function if a custom tooltip is desired. + var contentGenerator = function(d) { + if (content != null) { + return content; + } + + if (d == null) { + return ''; + } + + var table = d3.select(document.createElement("table")); + var theadEnter = table.selectAll("thead") + .data([d]) + .enter().append("thead"); + + theadEnter.append("tr") + .append("td") + .attr("colspan",3) + .append("strong") + .classed("x-value",true) + .html(headerFormatter(d.value)); + + var tbodyEnter = table.selectAll("tbody") + .data([d]) + .enter().append("tbody"); + + var trowEnter = tbodyEnter.selectAll("tr") + .data(function(p) { return p.series}) + .enter() + .append("tr") + .classed("highlight", function(p) { return p.highlight}); + + trowEnter.append("td") + .classed("legend-color-guide",true) + .append("div") + .style("background-color", function(p) { return p.color}); + + trowEnter.append("td") + .classed("key",true) + .html(function(p) {return p.key}); + + trowEnter.append("td") + .classed("value",true) + .html(function(p,i) { return valueFormatter(p.value,i) }); + + + trowEnter.selectAll("td").each(function(p) { + if (p.highlight) { + var opacityScale = d3.scale.linear().domain([0,1]).range(["#fff",p.color]); + var opacity = 0.6; + d3.select(this) + .style("border-bottom-color", opacityScale(opacity)) + .style("border-top-color", opacityScale(opacity)) + ; + } + }); + + var html = table.node().outerHTML; + if (d.footer !== undefined) + html += ""; + return html; + + }; + + var dataSeriesExists = function(d) { + if (d && d.series && d.series.length > 0) { + return true; + } + return false; + }; + + //In situations where the chart is in a 'viewBox', re-position the tooltip based on how far chart is zoomed. + function convertViewBoxRatio() { + if (chartContainer) { + var svg = d3.select(chartContainer); + if (svg.node().tagName !== "svg") { + svg = svg.select("svg"); + } + var viewBox = (svg.node()) ? svg.attr('viewBox') : null; + if (viewBox) { + viewBox = viewBox.split(' '); + var ratio = parseInt(svg.style('width')) / viewBox[2]; + + position.left = position.left * ratio; + position.top = position.top * ratio; + } + } + } + + //Creates new tooltip container, or uses existing one on DOM. + function getTooltipContainer(newContent) { + var body; + if (chartContainer) { + body = d3.select(chartContainer); + } else { + body = d3.select("body"); + } + + var container = body.select(".nvtooltip"); + if (container.node() === null) { + //Create new tooltip div if it doesn't exist on DOM. + container = body.append("div") + .attr("class", "nvtooltip " + (classes? classes: "xy-tooltip")) + .attr("id",id) + ; + } + + container.node().innerHTML = newContent; + container.style("top",0).style("left",0).style("opacity",0); + container.selectAll("div, table, td, tr").classed(nvPointerEventsClass,true) + container.classed(nvPointerEventsClass,true); + return container.node(); + } + + //Draw the tooltip onto the DOM. + function nvtooltip() { + if (!enabled) return; + if (!dataSeriesExists(data)) return; + + convertViewBoxRatio(); + + var left = position.left; + var top = (fixedTop != null) ? fixedTop : position.top; + var container = getTooltipContainer(contentGenerator(data)); + tooltipElem = container; + if (chartContainer) { + var svgComp = chartContainer.getElementsByTagName("svg")[0]; + var boundRect = (svgComp) ? svgComp.getBoundingClientRect() : chartContainer.getBoundingClientRect(); + var svgOffset = {left:0,top:0}; + if (svgComp) { + var svgBound = svgComp.getBoundingClientRect(); + var chartBound = chartContainer.getBoundingClientRect(); + var svgBoundTop = svgBound.top; + + //Defensive code. Sometimes, svgBoundTop can be a really negative + // number, like -134254. That's a bug. + // If such a number is found, use zero instead. FireFox bug only + if (svgBoundTop < 0) { + var containerBound = chartContainer.getBoundingClientRect(); + svgBoundTop = (Math.abs(svgBoundTop) > containerBound.height) ? 0 : svgBoundTop; + } + svgOffset.top = Math.abs(svgBoundTop - chartBound.top); + svgOffset.left = Math.abs(svgBound.left - chartBound.left); + } + //If the parent container is an overflow
with scrollbars, subtract the scroll offsets. + //You need to also add any offset between the element and its containing
+ //Finally, add any offset of the containing
on the whole page. + left += chartContainer.offsetLeft + svgOffset.left - 2*chartContainer.scrollLeft; + top += chartContainer.offsetTop + svgOffset.top - 2*chartContainer.scrollTop; + } + + if (snapDistance && snapDistance > 0) { + top = Math.floor(top/snapDistance) * snapDistance; + } + + nv.tooltip.calcTooltipPosition([left,top], gravity, distance, container); + return nvtooltip; + } + + nvtooltip.nvPointerEventsClass = nvPointerEventsClass; + + nvtooltip.content = function(_) { + if (!arguments.length) return content; + content = _; + return nvtooltip; + }; + + //Returns tooltipElem...not able to set it. + nvtooltip.tooltipElem = function() { + return tooltipElem; + }; + + nvtooltip.contentGenerator = function(_) { + if (!arguments.length) return contentGenerator; + if (typeof _ === 'function') { + contentGenerator = _; + } + return nvtooltip; + }; + + nvtooltip.data = function(_) { + if (!arguments.length) return data; + data = _; + return nvtooltip; + }; + + nvtooltip.gravity = function(_) { + if (!arguments.length) return gravity; + gravity = _; + return nvtooltip; + }; + + nvtooltip.distance = function(_) { + if (!arguments.length) return distance; + distance = _; + return nvtooltip; + }; + + nvtooltip.snapDistance = function(_) { + if (!arguments.length) return snapDistance; + snapDistance = _; + return nvtooltip; + }; + + nvtooltip.classes = function(_) { + if (!arguments.length) return classes; + classes = _; + return nvtooltip; + }; + + nvtooltip.chartContainer = function(_) { + if (!arguments.length) return chartContainer; + chartContainer = _; + return nvtooltip; + }; + + nvtooltip.position = function(_) { + if (!arguments.length) return position; + position.left = (typeof _.left !== 'undefined') ? _.left : position.left; + position.top = (typeof _.top !== 'undefined') ? _.top : position.top; + return nvtooltip; + }; + + nvtooltip.fixedTop = function(_) { + if (!arguments.length) return fixedTop; + fixedTop = _; + return nvtooltip; + }; + + nvtooltip.enabled = function(_) { + if (!arguments.length) return enabled; + enabled = _; + return nvtooltip; + }; + + nvtooltip.valueFormatter = function(_) { + if (!arguments.length) return valueFormatter; + if (typeof _ === 'function') { + valueFormatter = _; + } + return nvtooltip; + }; + + nvtooltip.headerFormatter = function(_) { + if (!arguments.length) return headerFormatter; + if (typeof _ === 'function') { + headerFormatter = _; + } + return nvtooltip; + }; + + //id() is a read-only function. You can't use it to set the id. + nvtooltip.id = function() { + return id; + }; + + return nvtooltip; + }; + + //Original tooltip.show function. Kept for backward compatibility. + // pos = [left,top] + nv.tooltip.show = function(pos, content, gravity, dist, parentContainer, classes) { + + //Create new tooltip div if it doesn't exist on DOM. + var container = document.createElement('div'); + container.className = 'nvtooltip ' + (classes ? classes : 'xy-tooltip'); + + var body = parentContainer; + if ( !parentContainer || parentContainer.tagName.match(/g|svg/i)) { + //If the parent element is an SVG element, place tooltip in the element. + body = document.getElementsByTagName('body')[0]; + } + + container.style.left = 0; + container.style.top = 0; + container.style.opacity = 0; + // Content can also be dom element + if (typeof content !== 'string') + container.appendChild(content); + else + container.innerHTML = content; + body.appendChild(container); + + //If the parent container is an overflow
with scrollbars, subtract the scroll offsets. + if (parentContainer) { + pos[0] = pos[0] - parentContainer.scrollLeft; + pos[1] = pos[1] - parentContainer.scrollTop; + } + nv.tooltip.calcTooltipPosition(pos, gravity, dist, container); + }; + + //Looks up the ancestry of a DOM element, and returns the first NON-svg node. + nv.tooltip.findFirstNonSVGParent = function(Elem) { + while(Elem.tagName.match(/^g|svg$/i) !== null) { + Elem = Elem.parentNode; + } + return Elem; + }; + + //Finds the total offsetTop of a given DOM element. + //Looks up the entire ancestry of an element, up to the first relatively positioned element. + nv.tooltip.findTotalOffsetTop = function ( Elem, initialTop ) { + var offsetTop = initialTop; + + do { + if( !isNaN( Elem.offsetTop ) ) { + offsetTop += (Elem.offsetTop); + } + } while( Elem = Elem.offsetParent ); + return offsetTop; + }; + + //Finds the total offsetLeft of a given DOM element. + //Looks up the entire ancestry of an element, up to the first relatively positioned element. + nv.tooltip.findTotalOffsetLeft = function ( Elem, initialLeft) { + var offsetLeft = initialLeft; + + do { + if( !isNaN( Elem.offsetLeft ) ) { + offsetLeft += (Elem.offsetLeft); + } + } while( Elem = Elem.offsetParent ); + return offsetLeft; + }; + + //Global utility function to render a tooltip on the DOM. + //pos = [left,top] coordinates of where to place the tooltip, relative to the SVG chart container. + //gravity = how to orient the tooltip + //dist = how far away from the mouse to place tooltip + //container = tooltip DIV + nv.tooltip.calcTooltipPosition = function(pos, gravity, dist, container) { + + var height = parseInt(container.offsetHeight), + width = parseInt(container.offsetWidth), + windowWidth = nv.utils.windowSize().width, + windowHeight = nv.utils.windowSize().height, + scrollTop = window.pageYOffset, + scrollLeft = window.pageXOffset, + left, top; + + windowHeight = window.innerWidth >= document.body.scrollWidth ? windowHeight : windowHeight - 16; + windowWidth = window.innerHeight >= document.body.scrollHeight ? windowWidth : windowWidth - 16; + + gravity = gravity || 's'; + dist = dist || 20; + + var tooltipTop = function ( Elem ) { + return nv.tooltip.findTotalOffsetTop(Elem, top); + }; + + var tooltipLeft = function ( Elem ) { + return nv.tooltip.findTotalOffsetLeft(Elem,left); + }; + + switch (gravity) { + case 'e': + left = pos[0] - width - dist; + top = pos[1] - (height / 2); + var tLeft = tooltipLeft(container); + var tTop = tooltipTop(container); + if (tLeft < scrollLeft) left = pos[0] + dist > scrollLeft ? pos[0] + dist : scrollLeft - tLeft + left; + if (tTop < scrollTop) top = scrollTop - tTop + top; + if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; + break; + case 'w': + left = pos[0] + dist; + top = pos[1] - (height / 2); + var tLeft = tooltipLeft(container); + var tTop = tooltipTop(container); + if (tLeft + width > windowWidth) left = pos[0] - width - dist; + if (tTop < scrollTop) top = scrollTop + 5; + if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; + break; + case 'n': + left = pos[0] - (width / 2) - 5; + top = pos[1] + dist; + var tLeft = tooltipLeft(container); + var tTop = tooltipTop(container); + if (tLeft < scrollLeft) left = scrollLeft + 5; + if (tLeft + width > windowWidth) left = left - width/2 + 5; + if (tTop + height > scrollTop + windowHeight) top = scrollTop + windowHeight - tTop + top - height; + break; + case 's': + left = pos[0] - (width / 2); + top = pos[1] - height - dist; + var tLeft = tooltipLeft(container); + var tTop = tooltipTop(container); + if (tLeft < scrollLeft) left = scrollLeft + 5; + if (tLeft + width > windowWidth) left = left - width/2 + 5; + if (scrollTop > tTop) top = scrollTop; + break; + case 'none': + left = pos[0]; + top = pos[1] - dist; + var tLeft = tooltipLeft(container); + var tTop = tooltipTop(container); + break; + } + + container.style.left = left+'px'; + container.style.top = top+'px'; + container.style.opacity = 1; + container.style.position = 'absolute'; + + return container; + }; + + //Global utility function to remove tooltips from the DOM. + nv.tooltip.cleanup = function() { + + // Find the tooltips, mark them for removal by this class (so others cleanups won't find it) + var tooltips = document.getElementsByClassName('nvtooltip'); + var purging = []; + while(tooltips.length) { + purging.push(tooltips[0]); + tooltips[0].style.transitionDelay = '0 !important'; + tooltips[0].style.opacity = 0; + tooltips[0].className = 'nvtooltip-pending-removal'; + } + + setTimeout(function() { + + while (purging.length) { + var removeMe = purging.pop(); + removeMe.parentNode.removeChild(removeMe); + } + }, 500); + }; + +})(); + + +/* +Gets the browser window size + +Returns object with height and width properties + */ +nv.utils.windowSize = function() { + // Sane defaults + var size = {width: 640, height: 480}; + + // Earlier IE uses Doc.body + if (document.body && document.body.offsetWidth) { + size.width = document.body.offsetWidth; + size.height = document.body.offsetHeight; + } + + // IE can use depending on mode it is in + if (document.compatMode=='CSS1Compat' && + document.documentElement && + document.documentElement.offsetWidth ) { + + size.width = document.documentElement.offsetWidth; + size.height = document.documentElement.offsetHeight; + } + + // Most recent browsers use + if (window.innerWidth && window.innerHeight) { + size.width = window.innerWidth; + size.height = window.innerHeight; + } + return (size); +}; + + +/* +Binds callback function to run when window is resized + */ +nv.utils.windowResize = function(handler) { + if (window.addEventListener) { + window.addEventListener('resize', handler); + } else { + nv.log("ERROR: Failed to bind to window.resize with: ", handler); + } + // return object with clear function to remove the single added callback. + return { + callback: handler, + clear: function() { + window.removeEventListener('resize', handler); + } + } +}; + + +/* +Backwards compatible way to implement more d3-like coloring of graphs. +If passed an array, wrap it in a function which implements the old behavior +Else return what was passed in +*/ +nv.utils.getColor = function(color) { + //if you pass in nothing, get default colors back + if (!arguments.length) { + return nv.utils.defaultColor(); + + //if passed an array, wrap it in a function + } else if(color instanceof Array) { + return function(d, i) { return d.color || color[i % color.length]; }; + + //if passed a function, return the function, or whatever it may be + //external libs, such as angularjs-nvd3-directives use this + } else { + //can't really help it if someone passes rubbish as color + return color; + } +}; + + +/* +Default color chooser uses the index of an object as before. + */ +nv.utils.defaultColor = function() { + var colors = d3.scale.category20().range(); + return function(d, i) { + return d.color || colors[i % colors.length] + }; +}; + + +/* +Returns a color function that takes the result of 'getKey' for each series and +looks for a corresponding color from the dictionary +*/ +nv.utils.customTheme = function(dictionary, getKey, defaultColors) { + // use default series.key if getKey is undefined + getKey = getKey || function(series) { return series.key }; + defaultColors = defaultColors || d3.scale.category20().range(); + + // start at end of default color list and walk back to index 0 + var defIndex = defaultColors.length; + + return function(series, index) { + var key = getKey(series); + if (typeof dictionary[key] === 'function') { + return dictionary[key](); + } else if (dictionary[key] !== undefined) { + return dictionary[key]; + } else { + // no match in dictionary, use a default color + if (!defIndex) { + // used all the default colors, start over + defIndex = defaultColors.length; + } + defIndex = defIndex - 1; + return defaultColors[defIndex]; + } + }; +}; + + +/* +From the PJAX example on d3js.org, while this is not really directly needed +it's a very cool method for doing pjax, I may expand upon it a little bit, +open to suggestions on anything that may be useful +*/ +nv.utils.pjax = function(links, content) { + + var load = function(href) { + d3.html(href, function(fragment) { + var target = d3.select(content).node(); + target.parentNode.replaceChild( + d3.select(fragment).select(content).node(), + target); + nv.utils.pjax(links, content); + }); + }; + + d3.selectAll(links).on("click", function() { + history.pushState(this.href, this.textContent, this.href); + load(this.href); + d3.event.preventDefault(); + }); + + d3.select(window).on("popstate", function() { + if (d3.event.state) { + load(d3.event.state); + } + }); +}; + + +/* +For when we want to approximate the width in pixels for an SVG:text element. +Most common instance is when the element is in a display:none; container. +Forumla is : text.length * font-size * constant_factor +*/ +nv.utils.calcApproxTextWidth = function (svgTextElem) { + if (typeof svgTextElem.style === 'function' + && typeof svgTextElem.text === 'function') { + + var fontSize = parseInt(svgTextElem.style("font-size").replace("px","")); + var textLength = svgTextElem.text().length; + return textLength * fontSize * 0.5; + } + return 0; +}; + + +/* +Numbers that are undefined, null or NaN, convert them to zeros. +*/ +nv.utils.NaNtoZero = function(n) { + if (typeof n !== 'number' + || isNaN(n) + || n === null + || n === Infinity + || n === -Infinity) { + + return 0; + } + return n; +}; + +/* +Add a way to watch for d3 transition ends to d3 +*/ +d3.selection.prototype.watchTransition = function(renderWatch){ + var args = [this].concat([].slice.call(arguments, 1)); + return renderWatch.transition.apply(renderWatch, args); +}; + + +/* +Helper object to watch when d3 has rendered something +*/ +nv.utils.renderWatch = function(dispatch, duration) { + if (!(this instanceof nv.utils.renderWatch)) { + return new nv.utils.renderWatch(dispatch, duration); + } + + var _duration = duration !== undefined ? duration : 250; + var renderStack = []; + var self = this; + + this.models = function(models) { + models = [].slice.call(arguments, 0); + models.forEach(function(model){ + model.__rendered = false; + (function(m){ + m.dispatch.on('renderEnd', function(arg){ + m.__rendered = true; + self.renderEnd('model'); + }); + })(model); + + if (renderStack.indexOf(model) < 0) { + renderStack.push(model); + } + }); + return this; + }; + + this.reset = function(duration) { + if (duration !== undefined) { + _duration = duration; + } + renderStack = []; + }; + + this.transition = function(selection, args, duration) { + args = arguments.length > 1 ? [].slice.call(arguments, 1) : []; + + if (args.length > 1) { + duration = args.pop(); + } else { + duration = _duration !== undefined ? _duration : 250; + } + selection.__rendered = false; + + if (renderStack.indexOf(selection) < 0) { + renderStack.push(selection); + } + + if (duration === 0) { + selection.__rendered = true; + selection.delay = function() { return this; }; + selection.duration = function() { return this; }; + return selection; + } else { + if (selection.length === 0) { + selection.__rendered = true; + } else if (selection.every( function(d){ return !d.length; } )) { + selection.__rendered = true; + } else { + selection.__rendered = false; + } + + var n = 0; + return selection + .transition() + .duration(duration) + .each(function(){ ++n; }) + .each('end', function(d, i) { + if (--n === 0) { + selection.__rendered = true; + self.renderEnd.apply(this, args); + } + }); + } + }; + + this.renderEnd = function() { + if (renderStack.every( function(d){ return d.__rendered; } )) { + renderStack.forEach( function(d){ d.__rendered = false; }); + dispatch.renderEnd.apply(this, arguments); + } + } + +}; + + +/* +Takes multiple objects and combines them into the first one (dst) +example: nv.utils.deepExtend({a: 1}, {a: 2, b: 3}, {c: 4}); +gives: {a: 2, b: 3, c: 4} +*/ +nv.utils.deepExtend = function(dst){ + var sources = arguments.length > 1 ? [].slice.call(arguments, 1) : []; + sources.forEach(function(source) { + for (key in source) { + var isArray = dst[key] instanceof Array; + var isObject = typeof dst[key] === 'object'; + var srcObj = typeof source[key] === 'object'; + + if (isObject && !isArray && srcObj) { + nv.utils.deepExtend(dst[key], source[key]); + } else { + dst[key] = source[key]; + } + } + }); +}; + + +/* +state utility object, used to track d3 states in the models +*/ +nv.utils.state = function(){ + if (!(this instanceof nv.utils.state)) { + return new nv.utils.state(); + } + var state = {}; + var _self = this; + var _setState = function(){}; + var _getState = function(){ return {}; }; + var init = null; + var changed = null; + + this.dispatch = d3.dispatch('change', 'set'); + + this.dispatch.on('set', function(state){ + _setState(state, true); + }); + + this.getter = function(fn){ + _getState = fn; + return this; + }; + + this.setter = function(fn, callback) { + if (!callback) { + callback = function(){}; + } + _setState = function(state, update){ + fn(state); + if (update) { + callback(); + } + }; + return this; + }; + + this.init = function(state){ + init = init || {}; + nv.utils.deepExtend(init, state); + }; + + var _set = function(){ + var settings = _getState(); + + if (JSON.stringify(settings) === JSON.stringify(state)) { + return false; + } + + for (var key in settings) { + if (state[key] === undefined) { + state[key] = {}; + } + state[key] = settings[key]; + changed = true; + } + return true; + }; + + this.update = function(){ + if (init) { + _setState(init, false); + init = null; + } + if (_set.call(this)) { + this.dispatch.change(state); + } + }; + +}; + + +/* +Snippet of code you can insert into each nv.models.* to give you the ability to +do things like: +chart.options({ + showXAxis: true, + tooltips: true +}); + +To enable in the chart: +chart.options = nv.utils.optionsFunc.bind(chart); +*/ +nv.utils.optionsFunc = function(args) { + nv.deprecated('nv.utils.optionsFunc'); + if (args) { + d3.map(args).forEach((function(key,value) { + if (typeof this[key] === "function") { + this[key](value); + } + }).bind(this)); + } + return this; +}; + + +/* +numTicks: requested number of ticks +data: the chart data + +returns the number of ticks to actually use on X axis, based on chart data +to avoid duplicate ticks with the same value +*/ +nv.utils.calcTicksX = function(numTicks, data) { + // find max number of values from all data streams + var numValues = 1; + var i = 0; + for (i; i < data.length; i += 1) { + var stream_len = data[i] && data[i].values ? data[i].values.length : 0; + numValues = stream_len > numValues ? stream_len : numValues; + } + nv.log("Requested number of ticks: ", numTicks); + nv.log("Calculated max values to be: ", numValues); + // make sure we don't have more ticks than values to avoid duplicates + numTicks = numTicks > numValues ? numTicks = numValues - 1 : numTicks; + // make sure we have at least one tick + numTicks = numTicks < 1 ? 1 : numTicks; + // make sure it's an integer + numTicks = Math.floor(numTicks); + nv.log("Calculating tick count as: ", numTicks); + return numTicks; +}; + + +/* +returns number of ticks to actually use on Y axis, based on chart data +*/ +nv.utils.calcTicksY = function(numTicks, data) { + // currently uses the same logic but we can adjust here if needed later + return nv.utils.calcTicksX(numTicks, data); +}; + + +/* +Add a particular option from an options object onto chart +Options exposed on a chart are a getter/setter function that returns chart +on set to mimic typical d3 option chaining, e.g. svg.option1('a').option2('b'); + +option objects should be generated via Object.create() to provide +the option of manipulating data via get/set functions. +*/ +nv.utils.initOption = function(chart, name) { + // if it's a call option, just call it directly, otherwise do get/set + if (chart._calls && chart._calls[name]) { + chart[name] = chart._calls[name]; + } else { + chart[name] = function (_) { + if (!arguments.length) return chart._options[name]; + chart._options[name] = _; + return chart; + }; + } +}; + + +/* +Add all options in an options object to the chart +*/ +nv.utils.initOptions = function(chart) { + var ops = Object.getOwnPropertyNames(chart._options || {}); + var calls = Object.getOwnPropertyNames(chart._calls || {}); + ops = ops.concat(calls); + for (var i in ops) { + nv.utils.initOption(chart, ops[i]); + } +}; + + +/* +Inherit options from a D3 object +d3.rebind makes calling the function on target actually call it on source +Also use _d3options so we can track what we inherit for documentation and chained inheritance +*/ +nv.utils.inheritOptionsD3 = function(target, d3_source, oplist) { + target._d3options = oplist.concat(target._d3options || []); + oplist.unshift(d3_source); + oplist.unshift(target); + d3.rebind.apply(this, oplist); +}; + + +/* +Remove duplicates from an array +*/ +nv.utils.arrayUnique = function(a) { + return a.sort().filter(function(item, pos) { + return !pos || item != a[pos - 1]; + }); +}; + + +/* +Keeps a list of custom symbols to draw from in addition to d3.svg.symbol +Necessary since d3 doesn't let you extend its list -_- +Add new symbols by doing nv.utils.symbols.set('name', function(size){...}); +*/ +nv.utils.symbolMap = d3.map(); + + +/* +Replaces d3.svg.symbol so that we can look both there and our own map + */ +nv.utils.symbol = function() { + var type, + size = 64; + function symbol(d,i) { + var t = type.call(this,d,i); + var s = size.call(this,d,i); + if (d3.svg.symbolTypes.indexOf(t) !== -1) { + return d3.svg.symbol().type(t).size(s)(); + } else { + return nv.utils.symbolMap.get(t)(s); + } + } + symbol.type = function(_) { + if (!arguments.length) return type; + type = d3.functor(_); + return symbol; + }; + symbol.size = function(_) { + if (!arguments.length) return size; + size = d3.functor(_); + return symbol; + }; + return symbol; +}; + + +/* +Inherit option getter/setter functions from source to target +d3.rebind makes calling the function on target actually call it on source +Also track via _inherited and _d3options so we can track what we inherit +for documentation generation purposes and chained inheritance +*/ +nv.utils.inheritOptions = function(target, source) { + // inherit all the things + var ops = Object.getOwnPropertyNames(source._options || {}); + var calls = Object.getOwnPropertyNames(source._calls || {}); + var inherited = source._inherited || []; + var d3ops = source._d3options || []; + var args = ops.concat(calls).concat(inherited).concat(d3ops); + args.unshift(source); + args.unshift(target); + d3.rebind.apply(this, args); + // pass along the lists to keep track of them, don't allow duplicates + target._inherited = nv.utils.arrayUnique(ops.concat(calls).concat(inherited).concat(ops).concat(target._inherited || [])); + target._d3options = nv.utils.arrayUnique(d3ops.concat(target._d3options || [])); +}; + + +/* +Runs common initialize code on the svg before the chart builds +*/ +nv.utils.initSVG = function(svg) { + svg.classed({'nvd3-svg':true}); +};nv.models.axis = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var axis = d3.svg.axis(); + var scale = d3.scale.linear(); + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 75 //only used for tickLabel currently + , height = 60 //only used for tickLabel currently + , axisLabelText = null + , showMaxMin = true //TODO: showMaxMin should be disabled on all ordinal scaled axes + , highlightZero = true + , rotateLabels = 0 + , rotateYLabel = true + , staggerLabels = false + , isOrdinal = false + , ticks = null + , axisLabelDistance = 0 + , duration = 250 + , dispatch = d3.dispatch('renderEnd') + , axisRendered = false + , maxMinRendered = false + ; + axis + .scale(scale) + .orient('bottom') + .tickFormat(function(d) { return d }) + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var scale0; + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + function chart(selection) { + renderWatch.reset(); + selection.each(function(data) { + var container = d3.select(this); + nv.utils.initSVG(container); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-axis').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-axis'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g') + + if (ticks !== null) + axis.ticks(ticks); + else if (axis.orient() == 'top' || axis.orient() == 'bottom') + axis.ticks(Math.abs(scale.range()[1] - scale.range()[0]) / 100); + + //TODO: consider calculating width/height based on whether or not label is added, for reference in charts using this component + g.watchTransition(renderWatch, 'axis').call(axis); + + scale0 = scale0 || axis.scale(); + + var fmt = axis.tickFormat(); + if (fmt == null) { + fmt = scale0.tickFormat(); + } + + var axisLabel = g.selectAll('text.nv-axislabel') + .data([axisLabelText || null]); + axisLabel.exit().remove(); + + switch (axis.orient()) { + case 'top': + axisLabel.enter().append('text').attr('class', 'nv-axislabel'); + var w; + if (scale.range().length < 2) { + w = 0; + } else if (scale.range().length === 2) { + w = scale.range()[1]; + } else { + w = scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]); + } + axisLabel + .attr('text-anchor', 'middle') + .attr('y', 0) + .attr('x', w/2); + if (showMaxMin) { + var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') + .data(scale.domain()); + axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text'); + axisMaxMin.exit().remove(); + axisMaxMin + .attr('transform', function(d,i) { + return 'translate(' + nv.utils.NaNtoZero(scale(d)) + ',0)' + }) + .select('text') + .attr('dy', '-0.5em') + .attr('y', -axis.tickPadding()) + .attr('text-anchor', 'middle') + .text(function(d,i) { + var v = fmt(d); + return ('' + v).match('NaN') ? '' : v; + }); + axisMaxMin.watchTransition(renderWatch, 'min-max top') + .attr('transform', function(d,i) { + return 'translate(' + nv.utils.NaNtoZero(scale.range()[i]) + ',0)' + }); + } + break; + case 'bottom': + var xLabelMargin = axisLabelDistance + 36; + var maxTextWidth = 30; + var xTicks = g.selectAll('g').select("text"); + if (rotateLabels%360) { + //Calculate the longest xTick width + xTicks.each(function(d,i){ + var width = this.getBoundingClientRect().width; + if(width > maxTextWidth) maxTextWidth = width; + }); + //Convert to radians before calculating sin. Add 30 to margin for healthy padding. + var sin = Math.abs(Math.sin(rotateLabels*Math.PI/180)); + var xLabelMargin = (sin ? sin*maxTextWidth : maxTextWidth)+30; + //Rotate all xTicks + xTicks + .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' }) + .style('text-anchor', rotateLabels%360 > 0 ? 'start' : 'end'); + } + axisLabel.enter().append('text').attr('class', 'nv-axislabel'); + var w; + if (scale.range().length < 2) { + w = 0; + } else if (scale.range().length === 2) { + w = scale.range()[1]; + } else { + w = scale.range()[scale.range().length-1]+(scale.range()[1]-scale.range()[0]); + } + axisLabel + .attr('text-anchor', 'middle') + .attr('y', xLabelMargin) + .attr('x', w/2); + if (showMaxMin) { + //if (showMaxMin && !isOrdinal) { + var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') + //.data(scale.domain()) + .data([scale.domain()[0], scale.domain()[scale.domain().length - 1]]); + axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text'); + axisMaxMin.exit().remove(); + axisMaxMin + .attr('transform', function(d,i) { + return 'translate(' + nv.utils.NaNtoZero((scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0))) + ',0)' + }) + .select('text') + .attr('dy', '.71em') + .attr('y', axis.tickPadding()) + .attr('transform', function(d,i,j) { return 'rotate(' + rotateLabels + ' 0,0)' }) + .style('text-anchor', rotateLabels ? (rotateLabels%360 > 0 ? 'start' : 'end') : 'middle') + .text(function(d,i) { + var v = fmt(d); + return ('' + v).match('NaN') ? '' : v; + }); + axisMaxMin.watchTransition(renderWatch, 'min-max bottom') + .attr('transform', function(d,i) { + return 'translate(' + nv.utils.NaNtoZero((scale(d) + (isOrdinal ? scale.rangeBand() / 2 : 0))) + ',0)' + }); + } + if (staggerLabels) + xTicks + .attr('transform', function(d,i) { + return 'translate(0,' + (i % 2 == 0 ? '0' : '12') + ')' + }); + + break; + case 'right': + axisLabel.enter().append('text').attr('class', 'nv-axislabel'); + axisLabel + .style('text-anchor', rotateYLabel ? 'middle' : 'begin') + .attr('transform', rotateYLabel ? 'rotate(90)' : '') + .attr('y', rotateYLabel ? (-Math.max(margin.right,width) + 12) : -10) //TODO: consider calculating this based on largest tick width... OR at least expose this on chart + .attr('x', rotateYLabel ? (scale.range()[0] / 2) : axis.tickPadding()); + if (showMaxMin) { + var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') + .data(scale.domain()); + axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text') + .style('opacity', 0); + axisMaxMin.exit().remove(); + axisMaxMin + .attr('transform', function(d,i) { + return 'translate(0,' + nv.utils.NaNtoZero(scale(d)) + ')' + }) + .select('text') + .attr('dy', '.32em') + .attr('y', 0) + .attr('x', axis.tickPadding()) + .style('text-anchor', 'start') + .text(function(d,i) { + var v = fmt(d); + return ('' + v).match('NaN') ? '' : v; + }); + axisMaxMin.watchTransition(renderWatch, 'min-max right') + .attr('transform', function(d,i) { + return 'translate(0,' + nv.utils.NaNtoZero(scale.range()[i]) + ')' + }) + .select('text') + .style('opacity', 1); + } + break; + case 'left': + /* + //For dynamically placing the label. Can be used with dynamically-sized chart axis margins + var yTicks = g.selectAll('g').select("text"); + yTicks.each(function(d,i){ + var labelPadding = this.getBoundingClientRect().width + axis.tickPadding() + 16; + if(labelPadding > width) width = labelPadding; + }); + */ + axisLabel.enter().append('text').attr('class', 'nv-axislabel'); + axisLabel + .style('text-anchor', rotateYLabel ? 'middle' : 'end') + .attr('transform', rotateYLabel ? 'rotate(-90)' : '') + .attr('y', rotateYLabel ? (-Math.max(margin.left,width) + 25 - (axisLabelDistance || 0)) : -10) + .attr('x', rotateYLabel ? (-scale.range()[0] / 2) : -axis.tickPadding()); + if (showMaxMin) { + var axisMaxMin = wrap.selectAll('g.nv-axisMaxMin') + .data(scale.domain()); + axisMaxMin.enter().append('g').attr('class', 'nv-axisMaxMin').append('text') + .style('opacity', 0); + axisMaxMin.exit().remove(); + axisMaxMin + .attr('transform', function(d,i) { + return 'translate(0,' + nv.utils.NaNtoZero(scale0(d)) + ')' + }) + .select('text') + .attr('dy', '.32em') + .attr('y', 0) + .attr('x', -axis.tickPadding()) + .attr('text-anchor', 'end') + .text(function(d,i) { + var v = fmt(d); + return ('' + v).match('NaN') ? '' : v; + }); + axisMaxMin.watchTransition(renderWatch, 'min-max right') + .attr('transform', function(d,i) { + return 'translate(0,' + nv.utils.NaNtoZero(scale.range()[i]) + ')' + }) + .select('text') + .style('opacity', 1); + } + break; + } + axisLabel.text(function(d) { return d }); + + if (showMaxMin && (axis.orient() === 'left' || axis.orient() === 'right')) { + //check if max and min overlap other values, if so, hide the values that overlap + g.selectAll('g') // the g's wrapping each tick + .each(function(d,i) { + d3.select(this).select('text').attr('opacity', 1); + if (scale(d) < scale.range()[1] + 10 || scale(d) > scale.range()[0] - 10) { // 10 is assuming text height is 16... if d is 0, leave it! + if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL + d3.select(this).attr('opacity', 0); + + d3.select(this).select('text').attr('opacity', 0); // Don't remove the ZERO line!! + } + }); + + //if Max and Min = 0 only show min, Issue #281 + if (scale.domain()[0] == scale.domain()[1] && scale.domain()[0] == 0) { + wrap.selectAll('g.nv-axisMaxMin').style('opacity', function (d, i) { + return !i ? 1 : 0 + }); + } + } + + if (showMaxMin && (axis.orient() === 'top' || axis.orient() === 'bottom')) { + var maxMinRange = []; + wrap.selectAll('g.nv-axisMaxMin') + .each(function(d,i) { + try { + if (i) // i== 1, max position + maxMinRange.push(scale(d) - this.getBoundingClientRect().width - 4) //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case) + else // i==0, min position + maxMinRange.push(scale(d) + this.getBoundingClientRect().width + 4) + }catch (err) { + if (i) // i== 1, max position + maxMinRange.push(scale(d) - 4); //assuming the max and min labels are as wide as the next tick (with an extra 4 pixels just in case) + else // i==0, min position + maxMinRange.push(scale(d) + 4); + } + }); + // the g's wrapping each tick + g.selectAll('g').each(function(d,i) { + if (scale(d) < maxMinRange[0] || scale(d) > maxMinRange[1]) { + if (d > 1e-10 || d < -1e-10) // accounts for minor floating point errors... though could be problematic if the scale is EXTREMELY SMALL + d3.select(this).remove(); + else + d3.select(this).select('text').remove(); // Don't remove the ZERO line!! + } + }); + } + + //highlight zero line ... Maybe should not be an option and should just be in CSS? + if (highlightZero) { + g.selectAll('.tick') + .filter(function (d) { + return !parseFloat(Math.round(this.__data__ * 100000) / 1000000) && (this.__data__ !== undefined) + }) //this is because sometimes the 0 tick is a very small fraction, TODO: think of cleaner technique + .classed('zero', true); + } + //store old scales for use in transitions on update + scale0 = scale.copy(); + + }); + + renderWatch.renderEnd('axis immediate'); + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.axis = axis; + chart.dispatch = dispatch; + + chart.options = nv.utils.optionsFunc.bind(chart); + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + axisLabelDistance: {get: function(){return axisLabelDistance;}, set: function(_){axisLabelDistance=_;}}, + staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}}, + rotateLabels: {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}}, + rotateYLabel: {get: function(){return rotateYLabel;}, set: function(_){rotateYLabel=_;}}, + highlightZero: {get: function(){return highlightZero;}, set: function(_){highlightZero=_;}}, + showMaxMin: {get: function(){return showMaxMin;}, set: function(_){showMaxMin=_;}}, + axisLabel: {get: function(){return axisLabelText;}, set: function(_){axisLabelText=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + ticks: {get: function(){return ticks;}, set: function(_){ticks=_;}}, + width: {get: function(){return width;}, set: function(_){width=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration=_; + renderWatch.reset(duration); + }}, + scale: {get: function(){return scale;}, set: function(_){ + scale = _; + axis.scale(scale); + isOrdinal = typeof scale.rangeBands === 'function'; + nv.utils.inheritOptionsD3(chart, scale, ['domain', 'range', 'rangeBand', 'rangeBands']); + }} + }); + + nv.utils.initOptions(chart); + nv.utils.inheritOptionsD3(chart, axis, ['orient', 'tickValues', 'tickSubdivide', 'tickSize', 'tickPadding', 'tickFormat']); + nv.utils.inheritOptionsD3(chart, scale, ['domain', 'range', 'rangeBand', 'rangeBands']); + + return chart; +}; + +// Chart design based on the recommendations of Stephen Few. Implementation +// based on the work of Clint Ivy, Jamie Love, and Jason Davies. +// http://projects.instantcognition.com/protovis/bulletchart/ + +nv.models.bullet = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , orient = 'left' // TODO top & bottom + , reverse = false + , ranges = function(d) { return d.ranges } + , markers = function(d) { return d.markers ? d.markers : [0] } + , measures = function(d) { return d.measures } + , rangeLabels = function(d) { return d.rangeLabels ? d.rangeLabels : [] } + , markerLabels = function(d) { return d.markerLabels ? d.markerLabels : [] } + , measureLabels = function(d) { return d.measureLabels ? d.measureLabels : [] } + , forceX = [0] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) + , width = 380 + , height = 30 + , tickFormat = null + , color = nv.utils.getColor(['#1f77b4']) + , dispatch = d3.dispatch('elementMouseover', 'elementMouseout') + ; + + function chart(selection) { + selection.each(function(d, i) { + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + container = d3.select(this); + nv.utils.initSVG(container); + + var rangez = ranges.call(this, d, i).slice().sort(d3.descending), + markerz = markers.call(this, d, i).slice().sort(d3.descending), + measurez = measures.call(this, d, i).slice().sort(d3.descending), + rangeLabelz = rangeLabels.call(this, d, i).slice(), + markerLabelz = markerLabels.call(this, d, i).slice(), + measureLabelz = measureLabels.call(this, d, i).slice(); + + // Setup Scales + // Compute the new x-scale. + var x1 = d3.scale.linear() + .domain( d3.extent(d3.merge([forceX, rangez])) ) + .range(reverse ? [availableWidth, 0] : [0, availableWidth]); + + // Retrieve the old x-scale, if this is an update. + var x0 = this.__chart__ || d3.scale.linear() + .domain([0, Infinity]) + .range(x1.range()); + + // Stash the new scale. + this.__chart__ = x1; + + var rangeMin = d3.min(rangez), //rangez[2] + rangeMax = d3.max(rangez), //rangez[0] + rangeAvg = rangez[1]; + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-bullet').data([d]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bullet'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('rect').attr('class', 'nv-range nv-rangeMax'); + gEnter.append('rect').attr('class', 'nv-range nv-rangeAvg'); + gEnter.append('rect').attr('class', 'nv-range nv-rangeMin'); + gEnter.append('rect').attr('class', 'nv-measure'); + gEnter.append('path').attr('class', 'nv-markerTriangle'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) + w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; + var xp0 = function(d) { return d < 0 ? x0(d) : x0(0) }, + xp1 = function(d) { return d < 0 ? x1(d) : x1(0) }; + + g.select('rect.nv-rangeMax') + .attr('height', availableHeight) + .attr('width', w1(rangeMax > 0 ? rangeMax : rangeMin)) + .attr('x', xp1(rangeMax > 0 ? rangeMax : rangeMin)) + .datum(rangeMax > 0 ? rangeMax : rangeMin) + + g.select('rect.nv-rangeAvg') + .attr('height', availableHeight) + .attr('width', w1(rangeAvg)) + .attr('x', xp1(rangeAvg)) + .datum(rangeAvg) + + g.select('rect.nv-rangeMin') + .attr('height', availableHeight) + .attr('width', w1(rangeMax)) + .attr('x', xp1(rangeMax)) + .attr('width', w1(rangeMax > 0 ? rangeMin : rangeMax)) + .attr('x', xp1(rangeMax > 0 ? rangeMin : rangeMax)) + .datum(rangeMax > 0 ? rangeMin : rangeMax) + + g.select('rect.nv-measure') + .style('fill', color) + .attr('height', availableHeight / 3) + .attr('y', availableHeight / 3) + .attr('width', measurez < 0 ? + x1(0) - x1(measurez[0]) + : x1(measurez[0]) - x1(0)) + .attr('x', xp1(measurez)) + .on('mouseover', function() { + dispatch.elementMouseover({ + value: measurez[0], + label: measureLabelz[0] || 'Current', + pos: [x1(measurez[0]), availableHeight/2] + }) + }) + .on('mouseout', function() { + dispatch.elementMouseout({ + value: measurez[0], + label: measureLabelz[0] || 'Current' + }) + }); + + var h3 = availableHeight / 6; + if (markerz[0]) { + g.selectAll('path.nv-markerTriangle') + .attr('transform', function(d) { return 'translate(' + x1(markerz[0]) + ',' + (availableHeight / 2) + ')' }) + .attr('d', 'M0,' + h3 + 'L' + h3 + ',' + (-h3) + ' ' + (-h3) + ',' + (-h3) + 'Z') + .on('mouseover', function() { + dispatch.elementMouseover({ + value: markerz[0], + label: markerLabelz[0] || 'Previous', + pos: [x1(markerz[0]), availableHeight/2] + }) + }) + .on('mouseout', function() { + dispatch.elementMouseout({ + value: markerz[0], + label: markerLabelz[0] || 'Previous' + }) + }); + } else { + g.selectAll('path.nv-markerTriangle').remove(); + } + + wrap.selectAll('.nv-range') + .on('mouseover', function(d,i) { + var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); + + dispatch.elementMouseover({ + value: d, + label: label, + pos: [x1(d), availableHeight/2] + }) + }) + .on('mouseout', function(d,i) { + var label = rangeLabelz[i] || (!i ? "Maximum" : i == 1 ? "Mean" : "Minimum"); + + dispatch.elementMouseout({ + value: d, + label: label + }) + }); + }); + + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + ranges: {get: function(){return ranges;}, set: function(_){ranges=_;}}, // ranges (bad, satisfactory, good) + markers: {get: function(){return markers;}, set: function(_){markers=_;}}, // markers (previous, goal) + measures: {get: function(){return measures;}, set: function(_){measures=_;}}, // measures (actual, forecast) + forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}}, + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + tickFormat: {get: function(){return tickFormat;}, set: function(_){tickFormat=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + orient: {get: function(){return orient;}, set: function(_){ // left, right, top, bottom + orient = _; + reverse = orient == 'right' || orient == 'bottom'; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + return chart; +}; + + + +// Chart design based on the recommendations of Stephen Few. Implementation +// based on the work of Clint Ivy, Jamie Love, and Jason Davies. +// http://projects.instantcognition.com/protovis/bulletchart/ +nv.models.bulletChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var bullet = nv.models.bullet() + ; + + var orient = 'left' // TODO top & bottom + , reverse = false + , margin = {top: 5, right: 40, bottom: 20, left: 120} + , ranges = function(d) { return d.ranges } + , markers = function(d) { return d.markers ? d.markers : [0] } + , measures = function(d) { return d.measures } + , width = null + , height = 55 + , tickFormat = null + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + x + '

' + + '

' + y + '

' + } + , noData = 'No Data Available.' + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ) + margin.left, + top = e.pos[1] + ( offsetElement.offsetTop || 0) + margin.top, + content = tooltip(e.key, e.label, e.value, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); + }; + + function chart(selection) { + selection.each(function(d, i) { + var container = d3.select(this); + nv.utils.initSVG(container); + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + that = this; + + chart.update = function() { chart(selection) }; + chart.container = this; + + // Display No Data message if there's nothing to show. + if (!d || !ranges.call(this, d, i)) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', 18 + margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + var rangez = ranges.call(this, d, i).slice().sort(d3.descending), + markerz = markers.call(this, d, i).slice().sort(d3.descending), + measurez = measures.call(this, d, i).slice().sort(d3.descending); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-bulletChart').data([d]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-bulletChart'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-bulletWrap'); + gEnter.append('g').attr('class', 'nv-titles'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + // Compute the new x-scale. + var x1 = d3.scale.linear() + .domain([0, Math.max(rangez[0], markerz[0], measurez[0])]) // TODO: need to allow forceX and forceY, and xDomain, yDomain + .range(reverse ? [availableWidth, 0] : [0, availableWidth]); + + // Retrieve the old x-scale, if this is an update. + var x0 = this.__chart__ || d3.scale.linear() + .domain([0, Infinity]) + .range(x1.range()); + + // Stash the new scale. + this.__chart__ = x1; + + var w0 = function(d) { return Math.abs(x0(d) - x0(0)) }, // TODO: could optimize by precalculating x0(0) and x1(0) + w1 = function(d) { return Math.abs(x1(d) - x1(0)) }; + + var title = gEnter.select('.nv-titles').append('g') + .attr('text-anchor', 'end') + .attr('transform', 'translate(-6,' + (height - margin.top - margin.bottom) / 2 + ')'); + title.append('text') + .attr('class', 'nv-title') + .text(function(d) { return d.title; }); + + title.append('text') + .attr('class', 'nv-subtitle') + .attr('dy', '1em') + .text(function(d) { return d.subtitle; }); + + bullet + .width(availableWidth) + .height(availableHeight) + + var bulletWrap = g.select('.nv-bulletWrap'); + d3.transition(bulletWrap).call(bullet); + + // Compute the tick format. + var format = tickFormat || x1.tickFormat( availableWidth / 100 ); + + // Update the tick groups. + var tick = g.selectAll('g.nv-tick') + .data(x1.ticks( availableWidth / 50 ), function(d) { + return this.textContent || format(d); + }); + + // Initialize the ticks with the old scale, x0. + var tickEnter = tick.enter().append('g') + .attr('class', 'nv-tick') + .attr('transform', function(d) { return 'translate(' + x0(d) + ',0)' }) + .style('opacity', 1e-6); + + tickEnter.append('line') + .attr('y1', availableHeight) + .attr('y2', availableHeight * 7 / 6); + + tickEnter.append('text') + .attr('text-anchor', 'middle') + .attr('dy', '1em') + .attr('y', availableHeight * 7 / 6) + .text(format); + + // Transition the updating ticks to the new scale, x1. + var tickUpdate = d3.transition(tick) + .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) + .style('opacity', 1); + + tickUpdate.select('line') + .attr('y1', availableHeight) + .attr('y2', availableHeight * 7 / 6); + + tickUpdate.select('text') + .attr('y', availableHeight * 7 / 6); + + // Transition the exiting ticks to the new scale, x1. + d3.transition(tick.exit()) + .attr('transform', function(d) { return 'translate(' + x1(d) + ',0)' }) + .style('opacity', 1e-6) + .remove(); + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + dispatch.on('tooltipShow', function(e) { + e.key = d.title; + if (tooltips) showTooltip(e, that.parentNode); + }); + + }); + + d3.timer.flush(); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + bullet.dispatch.on('elementMouseover.tooltip', function(e) { + dispatch.tooltipShow(e); + }); + + bullet.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.bullet = bullet; + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + ranges: {get: function(){return ranges;}, set: function(_){ranges=_;}}, // ranges (bad, satisfactory, good) + markers: {get: function(){return markers;}, set: function(_){markers=_;}}, // markers (previous, goal) + measures: {get: function(){return measures;}, set: function(_){measures=_;}}, // measures (actual, forecast) + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + tickFormat: {get: function(){return tickFormat;}, set: function(_){tickFormat=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + orient: {get: function(){return orient;}, set: function(_){ // left, right, top, bottom + orient = _; + reverse = orient == 'right' || orient == 'bottom'; + }} + }); + + nv.utils.inheritOptions(chart, bullet); + nv.utils.initOptions(chart); + + return chart; +}; + + + +nv.models.cumulativeLineChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var lines = nv.models.line() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend() + , controls = nv.models.legend() + , interactiveLayer = nv.interactiveGuideline() + ; + + var margin = {top: 30, right: 30, bottom: 50, left: 60} + , color = nv.utils.defaultColor() + , width = null + , height = null + , showLegend = true + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , tooltips = true + , showControls = true + , useInteractiveGuideline = false + , rescaleY = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

' + } + , x //can be accessed via chart.xScale() + , y //can be accessed via chart.yScale() + , id = lines.id() + , state = nv.utils.state() + , defaultState = null + , noData = 'No Data Available.' + , average = function(d) { return d.average } + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState', 'renderEnd') + , transitionDuration = 250 + , duration = 250 + , noErrorCheck = false //if set to TRUE, will bypass an error check in the indexify function. + ; + + state.index = 0; + state.rescaleY = rescaleY; + + xAxis + .orient('bottom') + .tickPadding(7) + ; + yAxis + .orient((rightAlignYAxis) ? 'right' : 'left') + ; + + controls.updateState(false); + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var dx = d3.scale.linear() + , index = {i: 0, x: 0} + , renderWatch = nv.utils.renderWatch(dispatch, duration) + ; + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, null, null, offsetElement); + }; + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }), + index: index.i, + rescaleY: rescaleY + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.index !== undefined) + index.i = state.index; + if (state.rescaleY !== undefined) + rescaleY = state.rescaleY; + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(lines); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + selection.each(function(data) { + var container = d3.select(this); + nv.utils.initSVG(container); + container.classed('nv-chart-' + id, true); + var that = this; + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + chart.update = function() { + if (duration === 0) + container.call(chart); + else + container.transition().duration(duration).call(chart) + }; + chart.container = this; + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disableddisabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + var indexDrag = d3.behavior.drag() + .on('dragstart', dragStart) + .on('drag', dragMove) + .on('dragend', dragEnd); + + + function dragStart(d,i) { + d3.select(chart.container) + .style('cursor', 'ew-resize'); + } + + function dragMove(d,i) { + index.x = d3.event.x; + index.i = Math.round(dx.invert(index.x)); + updateZero(); + } + + function dragEnd(d,i) { + d3.select(chart.container) + .style('cursor', 'auto'); + + // update state and send stateChange with new index + state.index = index.i; + dispatch.stateChange(state); + } + + // Display No Data message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = lines.xScale(); + y = lines.yScale(); + + if (!rescaleY) { + var seriesDomains = data + .filter(function(series) { return !series.disabled }) + .map(function(series,i) { + var initialDomain = d3.extent(series.values, lines.y()); + + //account for series being disabled when losing 95% or more + if (initialDomain[0] < -.95) initialDomain[0] = -.95; + + return [ + (initialDomain[0] - initialDomain[1]) / (1 + initialDomain[1]), + (initialDomain[1] - initialDomain[0]) / (1 + initialDomain[0]) + ]; + }); + + var completeDomain = [ + d3.min(seriesDomains, function(d) { return d[0] }), + d3.max(seriesDomains, function(d) { return d[1] }) + ]; + + lines.yDomain(completeDomain); + } else { + lines.yDomain(null); + } + + dx.domain([0, data[0].values.length - 1]) //Assumes all series have same length + .range([0, availableWidth]) + .clamp(true); + + var data = indexify(index.i, data); + + // Setup containers and skeleton of chart + var interactivePointerEvents = (useInteractiveGuideline) ? "none" : "all"; + var wrap = container.selectAll('g.nv-wrap.nv-cumulativeLine').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-cumulativeLine').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-interactive'); + gEnter.append('g').attr('class', 'nv-x nv-axis').style("pointer-events","none"); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-background'); + gEnter.append('g').attr('class', 'nv-linesWrap').style("pointer-events",interactivePointerEvents); + gEnter.append('g').attr('class', 'nv-avgLinesWrap').style("pointer-events","none"); + gEnter.append('g').attr('class', 'nv-legendWrap'); + gEnter.append('g').attr('class', 'nv-controlsWrap'); + + // Legend + if (showLegend) { + legend.width(availableWidth); + + g.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + g.select('.nv-legendWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')') + } + + // Controls + if (showControls) { + var controlsData = [ + { key: 'Re-scale y-axis', disabled: !rescaleY } + ]; + + controls + .width(140) + .color(['#444', '#444', '#444']) + .rightAlign(false) + .margin({top: 5, right: 0, bottom: 5, left: 20}) + ; + + g.select('.nv-controlsWrap') + .datum(controlsData) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(controls); + } + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } + + // Show error if series goes below 100% + var tempDisabled = data.filter(function(d) { return d.tempDisabled }); + + wrap.select('.tempDisabled').remove(); //clean-up and prevent duplicates + if (tempDisabled.length) { + wrap.append('text').attr('class', 'tempDisabled') + .attr('x', availableWidth / 2) + .attr('y', '-.71em') + .style('text-anchor', 'end') + .text(tempDisabled.map(function(d) { return d.key }).join(', ') + ' values cannot be calculated for this time period.'); + } + + //Set up interactive layer + if (useInteractiveGuideline) { + interactiveLayer + .width(availableWidth) + .height(availableHeight) + .margin({left:margin.left,top:margin.top}) + .svgContainer(container) + .xScale(x); + wrap.select(".nv-interactive").call(interactiveLayer); + } + + gEnter.select('.nv-background') + .append('rect'); + + g.select('.nv-background rect') + .attr('width', availableWidth) + .attr('height', availableHeight); + + lines + //.x(function(d) { return d.x }) + .y(function(d) { return d.display.y }) + .width(availableWidth) + .height(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && !data[i].tempDisabled; })); + + var linesWrap = g.select('.nv-linesWrap') + .datum(data.filter(function(d) { return !d.disabled && !d.tempDisabled })); + + linesWrap.call(lines); + + //Store a series index number in the data array. + data.forEach(function(d,i) { + d.seriesIndex = i; + }); + + var avgLineData = data.filter(function(d) { + return !d.disabled && !!average(d); + }); + + var avgLines = g.select(".nv-avgLinesWrap").selectAll("line") + .data(avgLineData, function(d) { return d.key; }); + + var getAvgLineY = function(d) { + //If average lines go off the svg element, clamp them to the svg bounds. + var yVal = y(average(d)); + if (yVal < 0) return 0; + if (yVal > availableHeight) return availableHeight; + return yVal; + }; + + avgLines.enter() + .append('line') + .style('stroke-width',2) + .style('stroke-dasharray','10,10') + .style('stroke',function (d,i) { + return lines.color()(d,d.seriesIndex); + }) + .attr('x1',0) + .attr('x2',availableWidth) + .attr('y1', getAvgLineY) + .attr('y2', getAvgLineY); + + avgLines + .style('stroke-opacity',function(d){ + //If average lines go offscreen, make them transparent + var yVal = y(average(d)); + if (yVal < 0 || yVal > availableHeight) return 0; + return 1; + }) + .attr('x1',0) + .attr('x2',availableWidth) + .attr('y1', getAvgLineY) + .attr('y2', getAvgLineY); + + avgLines.exit().remove(); + + //Create index line + var indexLine = linesWrap.selectAll('.nv-indexLine') + .data([index]); + indexLine.enter().append('rect').attr('class', 'nv-indexLine') + .attr('width', 3) + .attr('x', -2) + .attr('fill', 'red') + .attr('fill-opacity', .5) + .style("pointer-events","all") + .call(indexDrag); + + indexLine + .attr('transform', function(d) { return 'translate(' + dx(d.i) + ',0)' }) + .attr('height', availableHeight); + + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .ticks( nv.utils.calcTicksX(availableWidth/70, data) ) + .tickSize(-availableHeight, 0); + + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + y.range()[0] + ')'); + g.select('.nv-x.nv-axis') + .call(xAxis); + } + + if (showYAxis) { + yAxis + .scale(y) + .ticks( nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + g.select('.nv-y.nv-axis') + .call(yAxis); + } + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + function updateZero() { + indexLine + .data([index]); + + //When dragging the index line, turn off line transitions. + // Then turn them back on when done dragging. + var oldDuration = chart.duration(); + chart.duration(0); + chart.update(); + chart.duration(oldDuration); + } + + g.select('.nv-background rect') + .on('click', function() { + index.x = d3.mouse(this)[0]; + index.i = Math.round(dx.invert(index.x)); + + // update state and send stateChange with new index + state.index = index.i; + dispatch.stateChange(state); + + updateZero(); + }); + + lines.dispatch.on('elementClick', function(e) { + index.i = e.pointIndex; + index.x = dx(index.i); + + // update state and send stateChange with new index + state.index = index.i; + dispatch.stateChange(state); + + updateZero(); + }); + + controls.dispatch.on('legendClick', function(d,i) { + d.disabled = !d.disabled; + rescaleY = !d.disabled; + + state.rescaleY = rescaleY; + dispatch.stateChange(state); + chart.update(); + }); + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + interactiveLayer.dispatch.on('elementMousemove', function(e) { + lines.clearHighlights(); + var singlePoint, pointIndex, pointXLocation, allData = []; + + data + .filter(function(series, i) { + series.seriesIndex = i; + return !series.disabled; + }) + .forEach(function(series,i) { + pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); + lines.highlightPoint(i, pointIndex, true); + var point = series.values[pointIndex]; + if (typeof point === 'undefined') return; + if (typeof singlePoint === 'undefined') singlePoint = point; + if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); + allData.push({ + key: series.key, + value: chart.y()(point, pointIndex), + color: color(series,series.seriesIndex) + }); + }); + + //Highlight the tooltip entry based on which point the mouse is closest to. + if (allData.length > 2) { + var yValue = chart.yScale().invert(e.mouseY); + var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); + var threshold = 0.03 * domainExtent; + var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); + if (indexToHighlight !== null) + allData[indexToHighlight].highlight = true; + } + + var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex), pointIndex); + interactiveLayer.tooltip + .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) + .chartContainer(that.parentNode) + .enabled(tooltips) + .valueFormatter(function(d,i) { + return yAxis.tickFormat()(d); + }) + .data( + { + value: xValue, + series: allData + } + )(); + + interactiveLayer.renderGuideLine(pointXLocation); + }); + + interactiveLayer.dispatch.on("elementMouseout",function(e) { + dispatch.tooltipHide(); + lines.clearHighlights(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + + state.disabled = e.disabled; + } + + if (typeof e.index !== 'undefined') { + index.i = e.index; + index.x = dx(index.i); + + state.index = e.index; + + indexLine + .data([index]); + } + + if (typeof e.rescaleY !== 'undefined') { + rescaleY = e.rescaleY; + } + + chart.update(); + }); + + }); + + renderWatch.renderEnd('cumulativeLineChart immediate'); + + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + lines.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Functions + //------------------------------------------------------------ + + var indexifyYGetter = null; + /* Normalize the data according to an index point. */ + function indexify(idx, data) { + if (!indexifyYGetter) indexifyYGetter = lines.y(); + return data.map(function(line, i) { + if (!line.values) { + return line; + } + var indexValue = line.values[idx]; + if (indexValue == null) { + return line; + } + var v = indexifyYGetter(indexValue, idx); + + //TODO: implement check below, and disable series if series loses 100% or more cause divide by 0 issue + if (v < -.95 && !noErrorCheck) { + //if a series loses more than 100%, calculations fail.. anything close can cause major distortion (but is mathematically correct till it hits 100) + + line.tempDisabled = true; + return line; + } + + line.tempDisabled = false; + + line.values = line.values.map(function(point, pointIndex) { + point.display = {'y': (indexifyYGetter(point, pointIndex) - v) / (1 + v) }; + return point; + }); + + return line; + }) + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.lines = lines; + chart.legend = legend; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.interactiveLayer = interactiveLayer; + chart.state = state; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + rescaleY: {get: function(){return rescaleY;}, set: function(_){rescaleY=_;}}, + showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + average: {get: function(){return average;}, set: function(_){average=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + noErrorCheck: {get: function(){return noErrorCheck;}, set: function(_){noErrorCheck=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + }}, + useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){ + useInteractiveGuideline = _; + if (_ === true) { + chart.interactive(false); + chart.useVoronoi(false); + } + }}, + rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){ + rightAlignYAxis = _; + yAxis.orient( (_) ? 'right' : 'left'); + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + lines.duration(duration); + xAxis.duration(duration); + yAxis.duration(duration); + renderWatch.reset(duration); + }} + }); + + nv.utils.inheritOptions(chart, lines); + nv.utils.initOptions(chart); + + return chart; +};//TODO: consider deprecating by adding necessary features to multiBar model +nv.models.discreteBar = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 960 + , height = 500 + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , x = d3.scale.ordinal() + , y = d3.scale.linear() + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove + , color = nv.utils.defaultColor() + , showValues = false + , valueFormat = d3.format(',.2f') + , xDomain + , yDomain + , xRange + , yRange + , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout','renderEnd') + , rectClass = 'discreteBar' + , duration = 250 + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var x0, y0; + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + function chart(selection) { + renderWatch.reset(); + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + container = d3.select(this); + nv.utils.initSVG(container); + + //add series index to each data point for reference + data.forEach(function(series, i) { + series.values.forEach(function(point) { + point.series = i; + }); + }); + + // Setup Scales + // remap and flatten the data for use in calculating the scales' domains + var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate + data.map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i), y0: d.y0 } + }) + }); + + x .domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) + .rangeBands(xRange || [0, availableWidth], .1); + y .domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return d.y }).concat(forceY))); + + // If showValues, pad the Y axis range to account for label height + if (showValues) y.range(yRange || [availableHeight - (y.domain()[0] < 0 ? 12 : 0), y.domain()[1] > 0 ? 12 : 0]); + else y.range(yRange || [availableHeight, 0]); + + //store old scales if they exist + x0 = x0 || x; + y0 = y0 || y.copy().range([y(0),y(0)]); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-discretebar').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discretebar'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-groups'); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + //TODO: by definition, the discrete bar should not have multiple groups, will modify/remove later + var groups = wrap.select('.nv-groups').selectAll('.nv-group') + .data(function(d) { return d }, function(d) { return d.key }); + groups.enter().append('g') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6); + groups.exit() + .watchTransition(renderWatch, 'discreteBar: exit groups') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6) + .remove(); + groups + .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) + .classed('hover', function(d) { return d.hover }); + groups + .watchTransition(renderWatch, 'discreteBar: groups') + .style('stroke-opacity', 1) + .style('fill-opacity', .75); + + var bars = groups.selectAll('g.nv-bar') + .data(function(d) { return d.values }); + bars.exit().remove(); + + var barsEnter = bars.enter().append('g') + .attr('transform', function(d,i,j) { + return 'translate(' + (x(getX(d,i)) + x.rangeBand() * .05 ) + ', ' + y(0) + ')' + }) + .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here + d3.select(this).classed('hover', true); + dispatch.elementMouseover({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('mouseout', function(d,i) { + d3.select(this).classed('hover', false); + dispatch.elementMouseout({ + value: getY(d,i), + point: d, + series: data[d.series], + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('click', function(d,i) { + dispatch.elementClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }) + .on('dblclick', function(d,i) { + dispatch.elementDblClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (d.series + .5) / data.length), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }); + + barsEnter.append('rect') + .attr('height', 0) + .attr('width', x.rangeBand() * .9 / data.length ) + + if (showValues) { + barsEnter.append('text') + .attr('text-anchor', 'middle') + ; + + bars.select('text') + .text(function(d,i) { return valueFormat(getY(d,i)) }) + .watchTransition(renderWatch, 'discreteBar: bars text') + .attr('x', x.rangeBand() * .9 / 2) + .attr('y', function(d,i) { return getY(d,i) < 0 ? y(getY(d,i)) - y(0) + 12 : -4 }) + + ; + } else { + bars.selectAll('text').remove(); + } + + bars + .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive' }) + .style('fill', function(d,i) { return d.color || color(d,i) }) + .style('stroke', function(d,i) { return d.color || color(d,i) }) + .select('rect') + .attr('class', rectClass) + .watchTransition(renderWatch, 'discreteBar: bars rect') + .attr('width', x.rangeBand() * .9 / data.length); + bars.watchTransition(renderWatch, 'discreteBar: bars') + //.delay(function(d,i) { return i * 1200 / data[0].values.length }) + .attr('transform', function(d,i) { + var left = x(getX(d,i)) + x.rangeBand() * .05, + top = getY(d,i) < 0 ? + y(0) : + y(0) - y(getY(d,i)) < 1 ? + y(0) - 1 : //make 1 px positive bars show up above y=0 + y(getY(d,i)); + + return 'translate(' + left + ', ' + top + ')' + }) + .select('rect') + .attr('height', function(d,i) { + return Math.max(Math.abs(y(getY(d,i)) - y((yDomain && yDomain[0]) || 0)) || 1) + }); + + + //store old scales for use in transitions on update + x0 = x.copy(); + y0 = y.copy(); + + }); + + renderWatch.renderEnd('discreteBar immediate'); + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}}, + showValues: {get: function(){return showValues;}, set: function(_){showValues=_;}}, + x: {get: function(){return getX;}, set: function(_){getX=_;}}, + y: {get: function(){return getY;}, set: function(_){getY=_;}}, + xScale: {get: function(){return x;}, set: function(_){x=_;}}, + yScale: {get: function(){return y;}, set: function(_){y=_;}}, + xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}}, + yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}}, + xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}}, + yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}}, + valueFormat: {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}}, + id: {get: function(){return id;}, set: function(_){id=_;}}, + rectClass: {get: function(){return rectClass;}, set: function(_){rectClass=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + }} + }); + + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.discreteBarChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var discretebar = nv.models.discreteBar() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + ; + + var margin = {top: 15, right: 10, bottom: 50, left: 60} + , width = null + , height = null + , color = nv.utils.getColor() + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , staggerLabels = false + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + x + '

' + + '

' + y + '

' + } + , x + , y + , noData = "No Data Available." + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'beforeUpdate','renderEnd') + , duration = 250 + ; + + xAxis + .orient('bottom') + .highlightZero(false) + .showMaxMin(false) + .tickFormat(function(d) { return d }) + ; + yAxis + .orient((rightAlignYAxis) ? 'right' : 'left') + .tickFormat(d3.format(',.1f')) + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(discretebar.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(discretebar.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(discretebar); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + chart.update = function() { + dispatch.beforeUpdate(); + container.transition().duration(duration).call(chart); + }; + chart.container = this; + + // Display No Data message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = discretebar.xScale(); + y = discretebar.yScale().clamp(true); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-discreteBarWithAxes').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-discreteBarWithAxes').append('g'); + var defsEnter = gEnter.append('defs'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis') + .append('g').attr('class', 'nv-zeroLine') + .append('line'); + + gEnter.append('g').attr('class', 'nv-barsWrap'); + + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } + + // Main Chart Component(s) + discretebar + .width(availableWidth) + .height(availableHeight); + + var barsWrap = g.select('.nv-barsWrap') + .datum(data.filter(function(d) { return !d.disabled })) + + barsWrap.transition().call(discretebar); + + + defsEnter.append('clipPath') + .attr('id', 'nv-x-label-clip-' + discretebar.id()) + .append('rect'); + + g.select('#nv-x-label-clip-' + discretebar.id() + ' rect') + .attr('width', x.rangeBand() * (staggerLabels ? 2 : 1)) + .attr('height', 16) + .attr('x', -x.rangeBand() / (staggerLabels ? 1 : 2 )); + + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize(-availableHeight, 0); + + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + (y.range()[0] + ((discretebar.showValues() && y.domain()[0] < 0) ? 16 : 0)) + ')'); + g.select('.nv-x.nv-axis').call(xAxis); + + var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); + if (staggerLabels) { + xTicks + .selectAll('text') + .attr('transform', function(d,i,j) { return 'translate(0,' + (j % 2 == 0 ? '5' : '17') + ')' }) + } + } + + if (showYAxis) { + yAxis + .scale(y) + .ticks( nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + g.select('.nv-y.nv-axis').call(yAxis); + } + + // Zero line + g.select(".nv-zeroLine line") + .attr("x1",0) + .attr("x2",availableWidth) + .attr("y1", y(0)) + .attr("y2", y(0)) + ; + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + }); + + renderWatch.renderEnd('discreteBar chart immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + discretebar.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + discretebar.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.discretebar = discretebar; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + discretebar.duration(duration); + xAxis.duration(duration); + yAxis.duration(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + discretebar.color(color); + }}, + rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){ + rightAlignYAxis = _; + yAxis.orient( (_) ? 'right' : 'left'); + }} + }); + + nv.utils.inheritOptions(chart, discretebar); + nv.utils.initOptions(chart); + + return chart; +} + +nv.models.distribution = function() { + "use strict"; + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 400 //technically width or height depending on x or y.... + , size = 8 + , axis = 'x' // 'x' or 'y'... horizontal or vertical + , getData = function(d) { return d[axis] } // defaults d.x or d.y + , color = nv.utils.defaultColor() + , scale = d3.scale.linear() + , domain + , duration = 250 + , dispatch = d3.dispatch('renderEnd') + ; + + //============================================================ + + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var scale0; + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + //============================================================ + + + function chart(selection) { + renderWatch.reset(); + selection.each(function(data) { + var availableLength = width - (axis === 'x' ? margin.left + margin.right : margin.top + margin.bottom), + naxis = axis == 'x' ? 'y' : 'x', + container = d3.select(this); + nv.utils.initSVG(container); + + //------------------------------------------------------------ + // Setup Scales + + scale0 = scale0 || scale; + + //------------------------------------------------------------ + + + //------------------------------------------------------------ + // Setup containers and skeleton of chart + + var wrap = container.selectAll('g.nv-distribution').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-distribution'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') + + //------------------------------------------------------------ + + + var distWrap = g.selectAll('g.nv-dist') + .data(function(d) { return d }, function(d) { return d.key }); + + distWrap.enter().append('g'); + distWrap + .attr('class', function(d,i) { return 'nv-dist nv-series-' + i }) + .style('stroke', function(d,i) { return color(d, i) }); + + var dist = distWrap.selectAll('line.nv-dist' + axis) + .data(function(d) { return d.values }) + dist.enter().append('line') + .attr(axis + '1', function(d,i) { return scale0(getData(d,i)) }) + .attr(axis + '2', function(d,i) { return scale0(getData(d,i)) }) + renderWatch.transition(distWrap.exit().selectAll('line.nv-dist' + axis), 'dist exit') + // .transition() + .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) + .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) + .style('stroke-opacity', 0) + .remove(); + dist + .attr('class', function(d,i) { return 'nv-dist' + axis + ' nv-dist' + axis + '-' + i }) + .attr(naxis + '1', 0) + .attr(naxis + '2', size); + renderWatch.transition(dist, 'dist') + // .transition() + .attr(axis + '1', function(d,i) { return scale(getData(d,i)) }) + .attr(axis + '2', function(d,i) { return scale(getData(d,i)) }) + + + scale0 = scale.copy(); + + }); + renderWatch.renderEnd('distribution immediate'); + return chart; + } + + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + chart.options = nv.utils.optionsFunc.bind(chart); + chart.dispatch = dispatch; + + chart.margin = function(_) { + if (!arguments.length) return margin; + margin.top = typeof _.top != 'undefined' ? _.top : margin.top; + margin.right = typeof _.right != 'undefined' ? _.right : margin.right; + margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; + margin.left = typeof _.left != 'undefined' ? _.left : margin.left; + return chart; + }; + + chart.width = function(_) { + if (!arguments.length) return width; + width = _; + return chart; + }; + + chart.axis = function(_) { + if (!arguments.length) return axis; + axis = _; + return chart; + }; + + chart.size = function(_) { + if (!arguments.length) return size; + size = _; + return chart; + }; + + chart.getData = function(_) { + if (!arguments.length) return getData; + getData = d3.functor(_); + return chart; + }; + + chart.scale = function(_) { + if (!arguments.length) return scale; + scale = _; + return chart; + }; + + chart.color = function(_) { + if (!arguments.length) return color; + color = nv.utils.getColor(_); + return chart; + }; + + chart.duration = function(_) { + if (!arguments.length) return duration; + duration = _; + renderWatch.reset(duration); + return chart; + }; + //============================================================ + + + return chart; +} +//TODO: consider deprecating and using multibar with single series for this +nv.models.historicalBar = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = null + , height = null + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , x = d3.scale.linear() + , y = d3.scale.linear() + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , forceX = [] + , forceY = [0] + , padData = false + , clipEdge = true + , color = nv.utils.defaultColor() + , xDomain + , yDomain + , xRange + , yRange + , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'renderEnd') + , interactive = true + ; + + var renderWatch = nv.utils.renderWatch(dispatch, 0); + + function chart(selection) { + selection.each(function(data) { + renderWatch.reset(); + + var container = d3.select(this); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right; + var availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + nv.utils.initSVG(container); + + // Setup Scales + x.domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )); + + if (padData) + x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); + else + x.range(xRange || [0, availableWidth]); + + y.domain(yDomain || d3.extent(data[0].values.map(getY).concat(forceY) )) + .range(yRange || [availableHeight, 0]); + + // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point + if (x.domain()[0] === x.domain()[1]) + x.domain()[0] ? + x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) + : x.domain([-1,1]); + + if (y.domain()[0] === y.domain()[1]) + y.domain()[0] ? + y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) + : y.domain([-1,1]); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-historicalBar-' + id).data([data[0].values]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBar-' + id); + var defsEnter = wrapEnter.append('defs'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-bars'); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + container + .on('click', function(d,i) { + dispatch.chartClick({ + data: d, + index: i, + pos: d3.event, + id: id + }); + }); + + defsEnter.append('clipPath') + .attr('id', 'nv-chart-clip-path-' + id) + .append('rect'); + + wrap.select('#nv-chart-clip-path-' + id + ' rect') + .attr('width', availableWidth) + .attr('height', availableHeight); + + g.attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); + + var bars = wrap.select('.nv-bars').selectAll('.nv-bar') + .data(function(d) { return d }, function(d,i) {return getX(d,i)}); + bars.exit().remove(); + + var barsEnter = bars.enter().append('rect') + .attr('x', 0 ) + .attr('y', function(d,i) { return nv.utils.NaNtoZero(y(Math.max(0, getY(d,i)))) }) + .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.abs(y(getY(d,i)) - y(0))) }) + .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) + .on('mouseover', function(d,i) { + if (!interactive) return; + d3.select(this).classed('hover', true); + dispatch.elementMouseover({ + point: d, + series: data[0], + pos: [x(getX(d,i)), y(getY(d,i))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: 0, + e: d3.event + }); + + }) + .on('mouseout', function(d,i) { + if (!interactive) return; + d3.select(this).classed('hover', false); + dispatch.elementMouseout({ + point: d, + series: data[0], + pointIndex: i, + seriesIndex: 0, + e: d3.event + }); + }) + .on('click', function(d,i) { + if (!interactive) return; + dispatch.elementClick({ + //label: d[label], + value: getY(d,i), + data: d, + index: i, + pos: [x(getX(d,i)), y(getY(d,i))], + e: d3.event, + id: id + }); + d3.event.stopPropagation(); + }) + .on('dblclick', function(d,i) { + if (!interactive) return; + dispatch.elementDblClick({ + //label: d[label], + value: getY(d,i), + data: d, + index: i, + pos: [x(getX(d,i)), y(getY(d,i))], + e: d3.event, + id: id + }); + d3.event.stopPropagation(); + }); + + bars + .attr('fill', function(d,i) { return color(d, i); }) + .attr('class', function(d,i,j) { return (getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive') + ' nv-bar-' + j + '-' + i }) + .watchTransition(renderWatch, 'bars') + .attr('transform', function(d,i) { return 'translate(' + (x(getX(d,i)) - availableWidth / data[0].values.length * .45) + ',0)'; }) + //TODO: better width calculations that don't assume always uniform data spacing;w + .attr('width', (availableWidth / data[0].values.length) * .9 ); + + bars.watchTransition(renderWatch, 'bars') + .attr('y', function(d,i) { + var rval = getY(d,i) < 0 ? + y(0) : + y(0) - y(getY(d,i)) < 1 ? + y(0) - 1 : + y(getY(d,i)); + return nv.utils.NaNtoZero(rval); + }) + .attr('height', function(d,i) { return nv.utils.NaNtoZero(Math.max(Math.abs(y(getY(d,i)) - y(0)),1)) }); + + }); + + renderWatch.renderEnd('historicalBar immediate'); + return chart; + } + + //Create methods to allow outside functions to highlight a specific bar. + chart.highlightPoint = function(pointIndex, isHoverOver) { + d3.select(".nv-historicalBar-" + id) + .select(".nv-bars .nv-bar-0-" + pointIndex) + .classed("hover", isHoverOver) + ; + }; + + chart.clearHighlights = function() { + d3.select(".nv-historicalBar-" + id) + .select(".nv-bars .nv-bar.hover") + .classed("hover", false) + ; + }; + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}}, + forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}}, + padData: {get: function(){return padData;}, set: function(_){padData=_;}}, + x: {get: function(){return getX;}, set: function(_){getX=_;}}, + y: {get: function(){return getY;}, set: function(_){getY=_;}}, + xScale: {get: function(){return x;}, set: function(_){x=_;}}, + yScale: {get: function(){return y;}, set: function(_){y=_;}}, + xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}}, + yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}}, + xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}}, + yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}}, + clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}}, + id: {get: function(){return id;}, set: function(_){id=_;}}, + interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.historicalBarChart = function(bar_model) { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var bars = bar_model || nv.models.historicalBar() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend() + , interactiveLayer = nv.interactiveGuideline() + ; + + + var margin = {top: 30, right: 90, bottom: 50, left: 90} + , color = nv.utils.defaultColor() + , width = null + , height = null + , showLegend = false + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , useInteractiveGuideline = false + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

' + } + , x + , y + , state = {} + , defaultState = null + , noData = 'No Data Available.' + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState', 'renderEnd') + , transitionDuration = 250 + ; + + xAxis + .orient('bottom') + .tickPadding(7) + ; + yAxis + .orient( (rightAlignYAxis) ? 'right' : 'left') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + + // New addition to calculate position if SVG is scaled with viewBox, may move TODO: consider implementing everywhere else + if (offsetElement) { + var svg = d3.select(offsetElement).select('svg'); + var viewBox = (svg.node()) ? svg.attr('viewBox') : null; + if (viewBox) { + viewBox = viewBox.split(' '); + var ratio = parseInt(svg.style('width')) / viewBox[2]; + e.pos[0] = e.pos[0] * ratio; + e.pos[1] = e.pos[1] * ratio; + } + } + + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(bars.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(bars.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, null, null, offsetElement); + }; + var renderWatch = nv.utils.renderWatch(dispatch, 0); + + function chart(selection) { + selection.each(function(data) { + renderWatch.reset(); + renderWatch.models(bars); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + + chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; + chart.container = this; + + //set state.disabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display noData message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = bars.xScale(); + y = bars.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-historicalBarChart').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-historicalBarChart').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-barsWrap'); + gEnter.append('g').attr('class', 'nv-legendWrap'); + gEnter.append('g').attr('class', 'nv-interactive'); + + // Legend + if (showLegend) { + legend.width(availableWidth); + + g.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + wrap.select('.nv-legendWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')') + } + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } + + //Set up interactive layer + if (useInteractiveGuideline) { + interactiveLayer + .width(availableWidth) + .height(availableHeight) + .margin({left:margin.left, top:margin.top}) + .svgContainer(container) + .xScale(x); + wrap.select(".nv-interactive").call(interactiveLayer); + } + bars + .width(availableWidth) + .height(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled })); + + var barsWrap = g.select('.nv-barsWrap') + .datum(data.filter(function(d) { return !d.disabled })); + barsWrap.transition().call(bars); + + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .tickSize(-availableHeight, 0); + + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + y.range()[0] + ')'); + g.select('.nv-x.nv-axis') + .transition() + .call(xAxis); + } + + if (showYAxis) { + yAxis + .scale(y) + .ticks( nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + g.select('.nv-y.nv-axis') + .transition() + .call(yAxis); + } + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + interactiveLayer.dispatch.on('elementMousemove', function(e) { + bars.clearHighlights(); + + var singlePoint, pointIndex, pointXLocation, allData = []; + data + .filter(function(series, i) { + series.seriesIndex = i; + return !series.disabled; + }) + .forEach(function(series,i) { + pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); + bars.highlightPoint(pointIndex,true); + var point = series.values[pointIndex]; + if (typeof point === 'undefined') return; + if (typeof singlePoint === 'undefined') singlePoint = point; + if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); + allData.push({ + key: series.key, + value: chart.y()(point, pointIndex), + color: color(series,series.seriesIndex), + data: series.values[pointIndex] + }); + }); + + var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex)); + interactiveLayer.tooltip + .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) + .chartContainer(that.parentNode) + .enabled(tooltips) + .valueFormatter(function(d,i) { + return yAxis.tickFormat()(d); + }) + .data( + { + value: xValue, + series: allData + } + )(); + + interactiveLayer.renderGuideLine(pointXLocation); + + }); + + interactiveLayer.dispatch.on("elementMouseout",function(e) { + dispatch.tooltipHide(); + bars.clearHighlights(); + }); + + legend.dispatch.on('legendClick', function(d,i) { + d.disabled = !d.disabled; + + if (!data.filter(function(d) { return !d.disabled }).length) { + data.map(function(d) { + d.disabled = false; + wrap.selectAll('.nv-series').classed('disabled', false); + return d; + }); + } + + state.disabled = data.map(function(d) { return !!d.disabled }); + dispatch.stateChange(state); + + selection.transition().call(chart); + }); + + legend.dispatch.on('legendDblclick', function(d) { + //Double clicking should always enable current series, and disabled all others. + data.forEach(function(d) { + d.disabled = true; + }); + d.disabled = false; + + state.disabled = data.map(function(d) { return !!d.disabled }); + dispatch.stateChange(state); + chart.update(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + dispatch.on('changeState', function(e) { + + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + + state.disabled = e.disabled; + } + + chart.update(); + }); + }); + + renderWatch.renderEnd('historicalBarChart immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + bars.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + bars.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.bars = bars; + chart.legend = legend; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.interactiveLayer = interactiveLayer; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + bars.color(color); + }}, + duration: {get: function(){return transitionDuration;}, set: function(_){ + transitionDuration=_; + renderWatch.reset(transitionDuration); + yAxis.duration(transitionDuration); + xAxis.duration(transitionDuration); + }}, + rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){ + rightAlignYAxis = _; + yAxis.orient( (_) ? 'right' : 'left'); + }}, + useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){ + useInteractiveGuideline = _; + if (_ === true) { + chart.interactive(false); + } + }} + }); + + nv.utils.inheritOptions(chart, bars); + nv.utils.initOptions(chart); + + return chart; +}; + + +// ohlcChart is just a historical chart with oclc bars and some tweaks +nv.models.ohlcBarChart = function() { + var chart = nv.models.historicalBarChart(nv.models.ohlcBar()); + + // special default tooltip since we show multiple values per x + chart.useInteractiveGuideline(true); + chart.interactiveLayer.tooltip.contentGenerator(function(data) { + // we assume only one series exists for this chart + var d = data.series[0].data; + // match line colors as defined in nv.d3.css + var color = d.open < d.close ? "2ca02c" : "d62728"; + return '' + + '

' + data.value + '

' + + '' + + '' + + '' + + '' + + '' + + '
open:' + chart.yAxis.tickFormat()(d.open) + '
close:' + chart.yAxis.tickFormat()(d.close) + '
high' + chart.yAxis.tickFormat()(d.high) + '
low:' + chart.yAxis.tickFormat()(d.low) + '
'; + }); + return chart; +};nv.models.legend = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 5, right: 0, bottom: 5, left: 0} + , width = 400 + , height = 20 + , getKey = function(d) { return d.key } + , color = nv.utils.defaultColor() + , align = true + , rightAlign = true + , updateState = true //If true, legend will update data.disabled and trigger a 'stateChange' dispatch. + , radioButtonMode = false //If true, clicking legend items will cause it to behave like a radio button. (only one can be selected at a time) + , dispatch = d3.dispatch('legendClick', 'legendDblclick', 'legendMouseover', 'legendMouseout', 'stateChange') + ; + + function chart(selection) { + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right, + container = d3.select(this); + nv.utils.initSVG(container); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-legend').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-legend').append('g'); + var g = wrap.select('g'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var series = g.selectAll('.nv-series') + .data(function(d) { return d }); + var seriesEnter = series.enter().append('g').attr('class', 'nv-series') + .on('mouseover', function(d,i) { + dispatch.legendMouseover(d,i); //TODO: Make consistent with other event objects + }) + .on('mouseout', function(d,i) { + dispatch.legendMouseout(d,i); + }) + .on('click', function(d,i) { + dispatch.legendClick(d,i); + if (updateState) { + if (radioButtonMode) { + //Radio button mode: set every series to disabled, + // and enable the clicked series. + data.forEach(function(series) { series.disabled = true}); + d.disabled = false; + } + else { + d.disabled = !d.disabled; + if (data.every(function(series) { return series.disabled})) { + //the default behavior of NVD3 legends is, if every single series + // is disabled, turn all series' back on. + data.forEach(function(series) { series.disabled = false}); + } + } + dispatch.stateChange({ + disabled: data.map(function(d) { return !!d.disabled }) + }); + } + }) + .on('dblclick', function(d,i) { + dispatch.legendDblclick(d,i); + if (updateState) { + //the default behavior of NVD3 legends, when double clicking one, + // is to set all other series' to false, and make the double clicked series enabled. + data.forEach(function(series) { + series.disabled = true; + }); + d.disabled = false; + dispatch.stateChange({ + disabled: data.map(function(d) { return !!d.disabled }) + }); + } + }); + seriesEnter.append('circle') + .style('stroke-width', 2) + .attr('class','nv-legend-symbol') + .attr('r', 5); + seriesEnter.append('text') + .attr('text-anchor', 'start') + .attr('class','nv-legend-text') + .attr('dy', '.32em') + .attr('dx', '8'); + series.classed('nv-disabled', function(d) { return d.disabled }); + series.exit().remove(); + series.select('circle') + .style('fill', function(d,i) { return d.color || color(d,i)}) + .style('stroke', function(d,i) { return d.color || color(d, i) }); + series.select('text').text(getKey); + + //TODO: implement fixed-width and max-width options (max-width is especially useful with the align option) + // NEW ALIGNING CODE, TODO: clean up + if (align) { + + var seriesWidths = []; + series.each(function(d,i) { + var legendText = d3.select(this).select('text'); + var nodeTextLength; + try { + nodeTextLength = legendText.node().getComputedTextLength(); + // If the legendText is display:none'd (nodeTextLength == 0), simulate an error so we approximate, instead + if(nodeTextLength <= 0) throw Error(); + } + catch(e) { + nodeTextLength = nv.utils.calcApproxTextWidth(legendText); + } + + seriesWidths.push(nodeTextLength + 28); // 28 is ~ the width of the circle plus some padding + }); + + var seriesPerRow = 0; + var legendWidth = 0; + var columnWidths = []; + + while ( legendWidth < availableWidth && seriesPerRow < seriesWidths.length) { + columnWidths[seriesPerRow] = seriesWidths[seriesPerRow]; + legendWidth += seriesWidths[seriesPerRow++]; + } + if (seriesPerRow === 0) seriesPerRow = 1; //minimum of one series per row + + while ( legendWidth > availableWidth && seriesPerRow > 1 ) { + columnWidths = []; + seriesPerRow--; + + for (var k = 0; k < seriesWidths.length; k++) { + if (seriesWidths[k] > (columnWidths[k % seriesPerRow] || 0) ) + columnWidths[k % seriesPerRow] = seriesWidths[k]; + } + + legendWidth = columnWidths.reduce(function(prev, cur, index, array) { + return prev + cur; + }); + } + + var xPositions = []; + for (var i = 0, curX = 0; i < seriesPerRow; i++) { + xPositions[i] = curX; + curX += columnWidths[i]; + } + + series + .attr('transform', function(d, i) { + return 'translate(' + xPositions[i % seriesPerRow] + ',' + (5 + Math.floor(i / seriesPerRow) * 20) + ')'; + }); + + //position legend as far right as possible within the total width + if (rightAlign) { + g.attr('transform', 'translate(' + (width - margin.right - legendWidth) + ',' + margin.top + ')'); + } + else { + g.attr('transform', 'translate(0' + ',' + margin.top + ')'); + } + + height = margin.top + margin.bottom + (Math.ceil(seriesWidths.length / seriesPerRow) * 20); + + } else { + + var ypos = 5, + newxpos = 5, + maxwidth = 0, + xpos; + series + .attr('transform', function(d, i) { + var length = d3.select(this).select('text').node().getComputedTextLength() + 28; + xpos = newxpos; + + if (width < margin.left + margin.right + xpos + length) { + newxpos = xpos = 5; + ypos += 20; + } + + newxpos += length; + if (newxpos > maxwidth) maxwidth = newxpos; + + return 'translate(' + xpos + ',' + ypos + ')'; + }); + + //position legend as far right as possible within the total width + g.attr('transform', 'translate(' + (width - margin.right - maxwidth) + ',' + margin.top + ')'); + + height = margin.top + margin.bottom + ypos + 15; + } + }); + + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + key: {get: function(){return getKey;}, set: function(_){getKey=_;}}, + align: {get: function(){return align;}, set: function(_){align=_;}}, + rightAlign: {get: function(){return rightAlign;}, set: function(_){rightAlign=_;}}, + updateState: {get: function(){return updateState;}, set: function(_){updateState=_;}}, + radioButtonMode: {get: function(){return radioButtonMode;}, set: function(_){radioButtonMode=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.line = function() { + "use strict"; + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var scatter = nv.models.scatter() + ; + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 960 + , height = 500 + , color = nv.utils.defaultColor() // a function that returns a color + , getX = function(d) { return d.x } // accessor to get the x value from a data point + , getY = function(d) { return d.y } // accessor to get the y value from a data point + , defined = function(d,i) { return !isNaN(getY(d,i)) && getY(d,i) !== null } // allows a line to be not continuous when it is not defined + , isArea = function(d) { return d.area } // decides if a line is an area or just a line + , clipEdge = false // if true, masks lines within x and y scale + , x //can be accessed via chart.xScale() + , y //can be accessed via chart.yScale() + , interpolate = "linear" // controls the line interpolation + , duration = 250 + , dispatch = d3.dispatch('elementClick', 'elementMouseover', 'elementMouseout', 'renderEnd') + ; + + scatter + .pointSize(16) // default size + .pointDomain([16,256]) //set to speed up calculation, needs to be unset if there is a custom size accessor + ; + + //============================================================ + + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var x0, y0 //used to store previous scales + , renderWatch = nv.utils.renderWatch(dispatch, duration) + ; + + //============================================================ + + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(scatter); + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + container = d3.select(this); + nv.utils.initSVG(container); + + // Setup Scales + x = scatter.xScale(); + y = scatter.yScale(); + + x0 = x0 || x; + y0 = y0 || y; + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-line').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-line'); + var defsEnter = wrapEnter.append('defs'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-groups'); + gEnter.append('g').attr('class', 'nv-scatterWrap'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + scatter + .width(availableWidth) + .height(availableHeight); + + var scatterWrap = wrap.select('.nv-scatterWrap'); + scatterWrap.call(scatter); + + defsEnter.append('clipPath') + .attr('id', 'nv-edge-clip-' + scatter.id()) + .append('rect'); + + wrap.select('#nv-edge-clip-' + scatter.id() + ' rect') + .attr('width', availableWidth) + .attr('height', (availableHeight > 0) ? availableHeight : 0); + + g .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : ''); + scatterWrap + .attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + scatter.id() + ')' : ''); + + var groups = wrap.select('.nv-groups').selectAll('.nv-group') + .data(function(d) { return d }, function(d) { return d.key }); + groups.enter().append('g') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6); + + groups.exit().remove(); + + groups + .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) + .classed('hover', function(d) { return d.hover }) + .style('fill', function(d,i){ return color(d, i) }) + .style('stroke', function(d,i){ return color(d, i)}); + groups.watchTransition(renderWatch, 'line: groups') + .style('stroke-opacity', 1) + .style('fill-opacity', .5); + + var areaPaths = groups.selectAll('path.nv-area') + .data(function(d) { return isArea(d) ? [d] : [] }); // this is done differently than lines because I need to check if series is an area + areaPaths.enter().append('path') + .attr('class', 'nv-area') + .attr('d', function(d) { + return d3.svg.area() + .interpolate(interpolate) + .defined(defined) + .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) + .y0(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) + .y1(function(d,i) { return y0( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) }) + //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this + .apply(this, [d.values]) + }); + groups.exit().selectAll('path.nv-area') + .remove(); + + areaPaths.watchTransition(renderWatch, 'line: areaPaths') + .attr('d', function(d) { + return d3.svg.area() + .interpolate(interpolate) + .defined(defined) + .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) + .y0(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) + .y1(function(d,i) { return y( y.domain()[0] <= 0 ? y.domain()[1] >= 0 ? 0 : y.domain()[1] : y.domain()[0] ) }) + //.y1(function(d,i) { return y0(0) }) //assuming 0 is within y domain.. may need to tweak this + .apply(this, [d.values]) + }); + + var linePaths = groups.selectAll('path.nv-line') + .data(function(d) { return [d.values] }); + linePaths.enter().append('path') + .attr('class', 'nv-line') + .attr('d', + d3.svg.line() + .interpolate(interpolate) + .defined(defined) + .x(function(d,i) { return nv.utils.NaNtoZero(x0(getX(d,i))) }) + .y(function(d,i) { return nv.utils.NaNtoZero(y0(getY(d,i))) }) + ); + + linePaths.watchTransition(renderWatch, 'line: linePaths') + .attr('d', + d3.svg.line() + .interpolate(interpolate) + .defined(defined) + .x(function(d,i) { return nv.utils.NaNtoZero(x(getX(d,i))) }) + .y(function(d,i) { return nv.utils.NaNtoZero(y(getY(d,i))) }) + ); + + //store old scales for use in transitions on update + x0 = x.copy(); + y0 = y.copy(); + }); + renderWatch.renderEnd('line immediate'); + return chart; + } + + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.scatter = scatter; + // Pass through events + scatter.dispatch.on('elementClick', function(){ dispatch.elementClick.apply(this, arguments); }) + scatter.dispatch.on('elementMouseover', function(){ dispatch.elementMouseover.apply(this, arguments); }) + scatter.dispatch.on('elementMouseout', function(){ dispatch.elementMouseout.apply(this, arguments); }) + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + defined: {get: function(){return defined;}, set: function(_){defined=_;}}, + interpolate: {get: function(){return interpolate;}, set: function(_){interpolate=_;}}, + clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + scatter.duration(duration); + }}, + isArea: {get: function(){return isArea;}, set: function(_){ + isArea = d3.functor(_); + }}, + x: {get: function(){return getX;}, set: function(_){ + getX = _; + scatter.x(_); + }}, + y: {get: function(){return getY;}, set: function(_){ + getY = _; + scatter.y(_); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + scatter.color(color); + }} + }); + + nv.utils.inheritOptions(chart, scatter); + nv.utils.initOptions(chart); + + return chart; +}; +nv.models.lineChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var lines = nv.models.line() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend() + , interactiveLayer = nv.interactiveGuideline() + ; + + var margin = {top: 30, right: 20, bottom: 50, left: 60} + , color = nv.utils.defaultColor() + , width = null + , height = null + , showLegend = true + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , useInteractiveGuideline = false + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

' + } + , x + , y + , state = nv.utils.state() + , defaultState = null + , noData = 'No Data Available.' + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState', 'renderEnd') + , duration = 250 + ; + + xAxis + .orient('bottom') + .tickPadding(7) + ; + yAxis + .orient((rightAlignYAxis) ? 'right' : 'left') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, null, null, offsetElement); + }; + + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }) + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(lines); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + + chart.update = function() { + if (duration === 0) + container.call(chart); + else + container.transition().duration(duration).call(chart) + }; + chart.container = this; + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disableddisabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display noData message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + + // Setup Scales + x = lines.xScale(); + y = lines.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-lineChart').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineChart').append('g'); + var g = wrap.select('g'); + + gEnter.append("rect").style("opacity",0); + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-linesWrap'); + gEnter.append('g').attr('class', 'nv-legendWrap'); + gEnter.append('g').attr('class', 'nv-interactive'); + + g.select("rect") + .attr("width",availableWidth) + .attr("height",(availableHeight > 0) ? availableHeight : 0); + + // Legend + if (showLegend) { + legend.width(availableWidth); + + g.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + wrap.select('.nv-legendWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')') + } + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } + + //Set up interactive layer + if (useInteractiveGuideline) { + interactiveLayer + .width(availableWidth) + .height(availableHeight) + .margin({left:margin.left, top:margin.top}) + .svgContainer(container) + .xScale(x); + wrap.select(".nv-interactive").call(interactiveLayer); + } + + lines + .width(availableWidth) + .height(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled })); + + + var linesWrap = g.select('.nv-linesWrap') + .datum(data.filter(function(d) { return !d.disabled })); + + linesWrap.call(lines); + + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize(-availableHeight, 0); + + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + y.range()[0] + ')'); + g.select('.nv-x.nv-axis') + .call(xAxis); + } + + if (showYAxis) { + yAxis + .scale(y) + .ticks( nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + g.select('.nv-y.nv-axis') + .call(yAxis); + } + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + interactiveLayer.dispatch.on('elementMousemove', function(e) { + lines.clearHighlights(); + var singlePoint, pointIndex, pointXLocation, allData = []; + data + .filter(function(series, i) { + series.seriesIndex = i; + return !series.disabled; + }) + .forEach(function(series,i) { + pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); + lines.highlightPoint(i, pointIndex, true); + var point = series.values[pointIndex]; + if (typeof point === 'undefined') return; + if (typeof singlePoint === 'undefined') singlePoint = point; + if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); + allData.push({ + key: series.key, + value: chart.y()(point, pointIndex), + color: color(series,series.seriesIndex) + }); + }); + //Highlight the tooltip entry based on which point the mouse is closest to. + if (allData.length > 2) { + var yValue = chart.yScale().invert(e.mouseY); + var domainExtent = Math.abs(chart.yScale().domain()[0] - chart.yScale().domain()[1]); + var threshold = 0.03 * domainExtent; + var indexToHighlight = nv.nearestValueIndex(allData.map(function(d){return d.value}),yValue,threshold); + if (indexToHighlight !== null) + allData[indexToHighlight].highlight = true; + } + + var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex)); + interactiveLayer.tooltip + .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) + .chartContainer(that.parentNode) + .enabled(tooltips) + .valueFormatter(function(d,i) { + return yAxis.tickFormat()(d); + }) + .data( + { + value: xValue, + series: allData + } + )(); + + interactiveLayer.renderGuideLine(pointXLocation); + + }); + + interactiveLayer.dispatch.on('elementClick', function(e) { + var pointXLocation, allData = []; + + data.filter(function(series, i) { + series.seriesIndex = i; + return !series.disabled; + }).forEach(function(series) { + var pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); + var point = series.values[pointIndex]; + if (typeof point === 'undefined') return; + if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); + var yPos = chart.yScale()(chart.y()(point,pointIndex)); + allData.push({ + point: point, + pointIndex: pointIndex, + pos: [pointXLocation, yPos], + seriesIndex: series.seriesIndex, + series: series + }); + }); + + lines.dispatch.elementClick(allData); + }); + + interactiveLayer.dispatch.on("elementMouseout",function(e) { + dispatch.tooltipHide(); + lines.clearHighlights(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + dispatch.on('changeState', function(e) { + + if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + + state.disabled = e.disabled; + } + + chart.update(); + }); + + }); + + renderWatch.renderEnd('lineChart immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + lines.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.lines = lines; + chart.legend = legend; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.interactiveLayer = interactiveLayer; + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + lines.duration(duration); + xAxis.duration(duration); + yAxis.duration(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + lines.color(color); + }}, + rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){ + rightAlignYAxis = _; + yAxis.orient( rightAlignYAxis ? 'right' : 'left'); + }}, + useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){ + useInteractiveGuideline = _; + if (useInteractiveGuideline) { + lines.interactive(false); + lines.useVoronoi(false); + } + }} + }); + + nv.utils.inheritOptions(chart, lines); + nv.utils.initOptions(chart); + + return chart; +}; +nv.models.linePlusBarChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var lines = nv.models.line() + , lines2 = nv.models.line() + , bars = nv.models.historicalBar() + , bars2 = nv.models.historicalBar() + , xAxis = nv.models.axis() + , x2Axis = nv.models.axis() + , y1Axis = nv.models.axis() + , y2Axis = nv.models.axis() + , y3Axis = nv.models.axis() + , y4Axis = nv.models.axis() + , legend = nv.models.legend() + , brush = d3.svg.brush() + ; + + var margin = {top: 30, right: 30, bottom: 30, left: 60} + , margin2 = {top: 0, right: 30, bottom: 20, left: 60} + , width = null + , height = null + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , color = nv.utils.defaultColor() + , showLegend = true + , focusEnable = true + , focusShowAxisY = false + , focusShowAxisX = true + , focusHeight = 50 + , extent + , brushExtent = null + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

'; + } + , x + , x2 + , y1 + , y2 + , y3 + , y4 + , noData = "No Data Available." + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush', 'stateChange', 'changeState') + , transitionDuration = 0 + , state = nv.utils.state() + , defaultState = null + , legendLeftAxisHint = ' (left axis)' + , legendRightAxisHint = ' (right axis)' + ; + + lines + .clipEdge(true) + ; + lines2 + .interactive(false) + ; + xAxis + .orient('bottom') + .tickPadding(5) + ; + y1Axis + .orient('left') + ; + y2Axis + .orient('right') + ; + x2Axis + .orient('bottom') + .tickPadding(5) + ; + y3Axis + .orient('left') + ; + y4Axis + .orient('right') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + if (extent) { + e.pointIndex += Math.ceil(extent[0]); + } + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = (e.series.bar ? y1Axis : y2Axis).tickFormat()(lines.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }) + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight1 = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom - (focusEnable ? focusHeight : 0) , + availableHeight2 = focusHeight - margin2.top - margin2.bottom; + + chart.update = function() { container.transition().duration(transitionDuration).call(chart); }; + chart.container = this; + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disableddisabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display No Data message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight1 / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + var dataBars = data.filter(function(d) { return !d.disabled && d.bar }); + var dataLines = data.filter(function(d) { return !d.bar }); // removed the !d.disabled clause here to fix Issue #240 + + x = bars.xScale(); + x2 = x2Axis.scale(); + y1 = bars.yScale(); + y2 = lines.yScale(); + y3 = bars2.yScale(); + y4 = lines2.yScale(); + + var series1 = data + .filter(function(d) { return !d.disabled && d.bar }) + .map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i) } + }) + }); + + var series2 = data + .filter(function(d) { return !d.disabled && !d.bar }) + .map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i) } + }) + }); + + x.range([0, availableWidth]); + + x2 .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) + .range([0, availableWidth]); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-linePlusBar').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-linePlusBar').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-legendWrap'); + + // this is the main chart + var focusEnter = gEnter.append('g').attr('class', 'nv-focus'); + focusEnter.append('g').attr('class', 'nv-x nv-axis'); + focusEnter.append('g').attr('class', 'nv-y1 nv-axis'); + focusEnter.append('g').attr('class', 'nv-y2 nv-axis'); + focusEnter.append('g').attr('class', 'nv-barsWrap'); + focusEnter.append('g').attr('class', 'nv-linesWrap'); + + // context chart is where you can focus in + var contextEnter = gEnter.append('g').attr('class', 'nv-context'); + contextEnter.append('g').attr('class', 'nv-x nv-axis'); + contextEnter.append('g').attr('class', 'nv-y1 nv-axis'); + contextEnter.append('g').attr('class', 'nv-y2 nv-axis'); + contextEnter.append('g').attr('class', 'nv-barsWrap'); + contextEnter.append('g').attr('class', 'nv-linesWrap'); + contextEnter.append('g').attr('class', 'nv-brushBackground'); + contextEnter.append('g').attr('class', 'nv-x nv-brush'); + + //============================================================ + // Legend + //------------------------------------------------------------ + + if (showLegend) { + legend.width( availableWidth / 2 ); + + g.select('.nv-legendWrap') + .datum(data.map(function(series) { + series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; + series.key = series.originalKey + (series.bar ? legendLeftAxisHint : legendRightAxisHint); + return series; + })) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight1 = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom - focusHeight; + } + + g.select('.nv-legendWrap') + .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); + } + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + //============================================================ + // Context chart (focus chart) components + //------------------------------------------------------------ + + // hide or show the focus context chart + g.select('.nv-context').style('display', focusEnable ? 'initial' : 'none'); + + bars2 + .width(availableWidth) + .height(availableHeight2) + .color(data.map(function (d, i) { + return d.color || color(d, i); + }).filter(function (d, i) { + return !data[i].disabled && data[i].bar + })); + lines2 + .width(availableWidth) + .height(availableHeight2) + .color(data.map(function (d, i) { + return d.color || color(d, i); + }).filter(function (d, i) { + return !data[i].disabled && !data[i].bar + })); + + var bars2Wrap = g.select('.nv-context .nv-barsWrap') + .datum(dataBars.length ? dataBars : [ + {values: []} + ]); + var lines2Wrap = g.select('.nv-context .nv-linesWrap') + .datum(!dataLines[0].disabled ? dataLines : [ + {values: []} + ]); + + g.select('.nv-context') + .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')'); + + bars2Wrap.transition().call(bars2); + lines2Wrap.transition().call(lines2); + + // context (focus chart) axis controls + if (focusShowAxisX) { + x2Axis + .ticks(nv.utils.calcTicksX(availableWidth / 100, data)) + .tickSize(-availableHeight2, 0); + g.select('.nv-context .nv-x.nv-axis') + .attr('transform', 'translate(0,' + y3.range()[0] + ')'); + g.select('.nv-context .nv-x.nv-axis').transition() + .call(x2Axis); + } + + if (focusShowAxisY) { + y3Axis + .scale(y3) + .ticks( availableHeight2 / 36 ) + .tickSize( -availableWidth, 0); + y4Axis + .scale(y4) + .ticks( availableHeight2 / 36 ) + .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none + + g.select('.nv-context .nv-y3.nv-axis') + .style('opacity', dataBars.length ? 1 : 0) + .attr('transform', 'translate(0,' + x2.range()[0] + ')'); + g.select('.nv-context .nv-y2.nv-axis') + .style('opacity', dataLines.length ? 1 : 0) + .attr('transform', 'translate(' + x2.range()[1] + ',0)'); + + g.select('.nv-context .nv-y1.nv-axis').transition() + .call(y3Axis); + g.select('.nv-context .nv-y2.nv-axis').transition() + .call(y4Axis); + } + + // Setup Brush + brush.x(x2).on('brush', onBrush); + + if (brushExtent) brush.extent(brushExtent); + + var brushBG = g.select('.nv-brushBackground').selectAll('g') + .data([brushExtent || brush.extent()]); + + var brushBGenter = brushBG.enter() + .append('g'); + + brushBGenter.append('rect') + .attr('class', 'left') + .attr('x', 0) + .attr('y', 0) + .attr('height', availableHeight2); + + brushBGenter.append('rect') + .attr('class', 'right') + .attr('x', 0) + .attr('y', 0) + .attr('height', availableHeight2); + + var gBrush = g.select('.nv-x.nv-brush') + .call(brush); + gBrush.selectAll('rect') + //.attr('y', -5) + .attr('height', availableHeight2); + gBrush.selectAll('.resize').append('path').attr('d', resizePath); + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + state.disabled = e.disabled; + } + chart.update(); + }); + + //============================================================ + // Functions + //------------------------------------------------------------ + + // Taken from crossfilter (http://square.github.com/crossfilter/) + function resizePath(d) { + var e = +(d == 'e'), + x = e ? 1 : -1, + y = availableHeight2 / 3; + return 'M' + (.5 * x) + ',' + y + + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6) + + 'V' + (2 * y - 6) + + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y) + + 'Z' + + 'M' + (2.5 * x) + ',' + (y + 8) + + 'V' + (2 * y - 8) + + 'M' + (4.5 * x) + ',' + (y + 8) + + 'V' + (2 * y - 8); + } + + + function updateBrushBG() { + if (!brush.empty()) brush.extent(brushExtent); + brushBG + .data([brush.empty() ? x2.domain() : brushExtent]) + .each(function(d,i) { + var leftWidth = x2(d[0]) - x2.range()[0], + rightWidth = x2.range()[1] - x2(d[1]); + d3.select(this).select('.left') + .attr('width', leftWidth < 0 ? 0 : leftWidth); + + d3.select(this).select('.right') + .attr('x', x2(d[1])) + .attr('width', rightWidth < 0 ? 0 : rightWidth); + }); + } + + function onBrush() { + brushExtent = brush.empty() ? null : brush.extent(); + extent = brush.empty() ? x2.domain() : brush.extent(); + dispatch.brush({extent: extent, brush: brush}); + updateBrushBG(); + + // Prepare Main (Focus) Bars and Lines + bars + .width(availableWidth) + .height(availableHeight1) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && data[i].bar })); + + lines + .width(availableWidth) + .height(availableHeight1) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled && !data[i].bar })); + + var focusBarsWrap = g.select('.nv-focus .nv-barsWrap') + .datum(!dataBars.length ? [{values:[]}] : + dataBars + .map(function(d,i) { + return { + key: d.key, + values: d.values.filter(function(d,i) { + return bars.x()(d,i) >= extent[0] && bars.x()(d,i) <= extent[1]; + }) + } + }) + ); + + var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') + .datum(dataLines[0].disabled ? [{values:[]}] : + dataLines + .map(function(d,i) { + return { + key: d.key, + values: d.values.filter(function(d,i) { + return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1]; + }) + } + }) + ); + + // Update Main (Focus) X Axis + if (dataBars.length) { + x = bars.xScale(); + } else { + x = lines.xScale(); + } + + xAxis + .scale(x) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize(-availableHeight1, 0); + + xAxis.domain([Math.ceil(extent[0]), Math.floor(extent[1])]); + + g.select('.nv-x.nv-axis').transition().duration(transitionDuration) + .call(xAxis); + + // Update Main (Focus) Bars and Lines + focusBarsWrap.transition().duration(transitionDuration).call(bars); + focusLinesWrap.transition().duration(transitionDuration).call(lines); + + // Setup and Update Main (Focus) Y Axes + g.select('.nv-focus .nv-x.nv-axis') + .attr('transform', 'translate(0,' + y1.range()[0] + ')'); + + y1Axis + .scale(y1) + .ticks( nv.utils.calcTicksY(availableHeight1/36, data) ) + .tickSize(-availableWidth, 0); + y2Axis + .scale(y2) + .ticks( nv.utils.calcTicksY(availableHeight1/36, data) ) + .tickSize(dataBars.length ? 0 : -availableWidth, 0); // Show the y2 rules only if y1 has none + + g.select('.nv-focus .nv-y1.nv-axis') + .style('opacity', dataBars.length ? 1 : 0); + g.select('.nv-focus .nv-y2.nv-axis') + .style('opacity', dataLines.length && !dataLines[0].disabled ? 1 : 0) + .attr('transform', 'translate(' + x.range()[1] + ',0)'); + + g.select('.nv-focus .nv-y1.nv-axis').transition().duration(transitionDuration) + .call(y1Axis); + g.select('.nv-focus .nv-y2.nv-axis').transition().duration(transitionDuration) + .call(y2Axis); + } + + onBrush(); + + }); + + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + lines.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + bars.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + bars.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.legend = legend; + chart.lines = lines; + chart.lines2 = lines2; + chart.bars = bars; + chart.bars2 = bars2; + chart.xAxis = xAxis; + chart.x2Axis = x2Axis; + chart.y1Axis = y1Axis; + chart.y2Axis = y2Axis; + chart.y3Axis = y3Axis; + chart.y4Axis = y4Axis; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + brushExtent: {get: function(){return brushExtent;}, set: function(_){brushExtent=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + focusEnable: {get: function(){return focusEnable;}, set: function(_){focusEnable=_;}}, + focusHeight: {get: function(){return focusHeight;}, set: function(_){focusHeight=_;}}, + focusShowAxisX: {get: function(){return focusShowAxisX;}, set: function(_){focusShowAxisX=_;}}, + focusShowAxisY: {get: function(){return focusShowAxisY;}, set: function(_){focusShowAxisY=_;}}, + legendLeftAxisHint: {get: function(){return legendLeftAxisHint;}, set: function(_){legendLeftAxisHint=_;}}, + legendRightAxisHint: {get: function(){return legendRightAxisHint;}, set: function(_){legendRightAxisHint=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return transitionDuration;}, set: function(_){ + transitionDuration = _; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + }}, + x: {get: function(){return getX;}, set: function(_){ + getX = _; + lines.x(_); + lines2.x(_); + bars.x(_); + bars2.x(_); + }}, + y: {get: function(){return getY;}, set: function(_){ + getY = _; + lines.y(_); + lines2.y(_); + bars.y(_); + bars2.y(_); + }} + }); + + nv.utils.inheritOptions(chart, lines); + nv.utils.initOptions(chart); + + return chart; +}; +nv.models.lineWithFocusChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var lines = nv.models.line() + , lines2 = nv.models.line() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , x2Axis = nv.models.axis() + , y2Axis = nv.models.axis() + , legend = nv.models.legend() + , brush = d3.svg.brush() + ; + + var margin = {top: 30, right: 30, bottom: 30, left: 60} + , margin2 = {top: 0, right: 30, bottom: 20, left: 60} + , color = nv.utils.defaultColor() + , width = null + , height = null + , height2 = 100 + , x + , y + , x2 + , y2 + , showLegend = true + , brushExtent = null + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

' + } + , noData = "No Data Available." + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'brush', 'stateChange', 'changeState') + , transitionDuration = 250 + , state = nv.utils.state() + , defaultState = null + ; + + lines + .clipEdge(true) + ; + lines2 + .interactive(false) + ; + xAxis + .orient('bottom') + .tickPadding(5) + ; + yAxis + .orient('left') + ; + x2Axis + .orient('bottom') + .tickPadding(5) + ; + y2Axis + .orient('left') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(lines.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(lines.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, null, null, offsetElement); + }; + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }) + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight1 = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom - height2, + availableHeight2 = height2 - margin2.top - margin2.bottom; + + chart.update = function() { container.transition().duration(transitionDuration).call(chart) }; + chart.container = this; + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disableddisabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display No Data message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight1 / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = lines.xScale(); + y = lines.yScale(); + x2 = lines2.xScale(); + y2 = lines2.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-lineWithFocusChart').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-lineWithFocusChart').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-legendWrap'); + + var focusEnter = gEnter.append('g').attr('class', 'nv-focus'); + focusEnter.append('g').attr('class', 'nv-x nv-axis'); + focusEnter.append('g').attr('class', 'nv-y nv-axis'); + focusEnter.append('g').attr('class', 'nv-linesWrap'); + + var contextEnter = gEnter.append('g').attr('class', 'nv-context'); + contextEnter.append('g').attr('class', 'nv-x nv-axis'); + contextEnter.append('g').attr('class', 'nv-y nv-axis'); + contextEnter.append('g').attr('class', 'nv-linesWrap'); + contextEnter.append('g').attr('class', 'nv-brushBackground'); + contextEnter.append('g').attr('class', 'nv-x nv-brush'); + + // Legend + if (showLegend) { + legend.width(availableWidth); + + g.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight1 = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom - height2; + } + + g.select('.nv-legendWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')') + } + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + // Main Chart Component(s) + lines + .width(availableWidth) + .height(availableHeight1) + .color( + data + .map(function(d,i) { + return d.color || color(d, i); + }) + .filter(function(d,i) { + return !data[i].disabled; + }) + ); + + lines2 + .defined(lines.defined()) + .width(availableWidth) + .height(availableHeight2) + .color( + data + .map(function(d,i) { + return d.color || color(d, i); + }) + .filter(function(d,i) { + return !data[i].disabled; + }) + ); + + g.select('.nv-context') + .attr('transform', 'translate(0,' + ( availableHeight1 + margin.bottom + margin2.top) + ')') + + var contextLinesWrap = g.select('.nv-context .nv-linesWrap') + .datum(data.filter(function(d) { return !d.disabled })) + + d3.transition(contextLinesWrap).call(lines2); + + // Setup Main (Focus) Axes + xAxis + .scale(x) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize(-availableHeight1, 0); + + yAxis + .scale(y) + .ticks( nv.utils.calcTicksY(availableHeight1/36, data) ) + .tickSize( -availableWidth, 0); + + g.select('.nv-focus .nv-x.nv-axis') + .attr('transform', 'translate(0,' + availableHeight1 + ')'); + + // Setup Brush + brush + .x(x2) + .on('brush', function() { + //When brushing, turn off transitions because chart needs to change immediately. + var oldTransition = chart.duration(); + chart.duration(0); + onBrush(); + chart.duration(oldTransition); + }); + + if (brushExtent) brush.extent(brushExtent); + + var brushBG = g.select('.nv-brushBackground').selectAll('g') + .data([brushExtent || brush.extent()]) + + var brushBGenter = brushBG.enter() + .append('g'); + + brushBGenter.append('rect') + .attr('class', 'left') + .attr('x', 0) + .attr('y', 0) + .attr('height', availableHeight2); + + brushBGenter.append('rect') + .attr('class', 'right') + .attr('x', 0) + .attr('y', 0) + .attr('height', availableHeight2); + + var gBrush = g.select('.nv-x.nv-brush') + .call(brush); + gBrush.selectAll('rect') + //.attr('y', -5) + .attr('height', availableHeight2); + gBrush.selectAll('.resize').append('path').attr('d', resizePath); + + onBrush(); + + // Setup Secondary (Context) Axes + x2Axis + .scale(x2) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize(-availableHeight2, 0); + + g.select('.nv-context .nv-x.nv-axis') + .attr('transform', 'translate(0,' + y2.range()[0] + ')'); + d3.transition(g.select('.nv-context .nv-x.nv-axis')) + .call(x2Axis); + + y2Axis + .scale(y2) + .ticks( nv.utils.calcTicksY(availableHeight2/36, data) ) + .tickSize( -availableWidth, 0); + + d3.transition(g.select('.nv-context .nv-y.nv-axis')) + .call(y2Axis); + + g.select('.nv-context .nv-x.nv-axis') + .attr('transform', 'translate(0,' + y2.range()[0] + ')'); + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + dispatch.on('changeState', function(e) { + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + } + chart.update(); + }); + + //============================================================ + // Functions + //------------------------------------------------------------ + + // Taken from crossfilter (http://square.github.com/crossfilter/) + function resizePath(d) { + var e = +(d == 'e'), + x = e ? 1 : -1, + y = availableHeight2 / 3; + return 'M' + (.5 * x) + ',' + y + + 'A6,6 0 0 ' + e + ' ' + (6.5 * x) + ',' + (y + 6) + + 'V' + (2 * y - 6) + + 'A6,6 0 0 ' + e + ' ' + (.5 * x) + ',' + (2 * y) + + 'Z' + + 'M' + (2.5 * x) + ',' + (y + 8) + + 'V' + (2 * y - 8) + + 'M' + (4.5 * x) + ',' + (y + 8) + + 'V' + (2 * y - 8); + } + + + function updateBrushBG() { + if (!brush.empty()) brush.extent(brushExtent); + brushBG + .data([brush.empty() ? x2.domain() : brushExtent]) + .each(function(d,i) { + var leftWidth = x2(d[0]) - x.range()[0], + rightWidth = x.range()[1] - x2(d[1]); + d3.select(this).select('.left') + .attr('width', leftWidth < 0 ? 0 : leftWidth); + + d3.select(this).select('.right') + .attr('x', x2(d[1])) + .attr('width', rightWidth < 0 ? 0 : rightWidth); + }); + } + + + function onBrush() { + brushExtent = brush.empty() ? null : brush.extent(); + var extent = brush.empty() ? x2.domain() : brush.extent(); + + //The brush extent cannot be less than one. If it is, don't update the line chart. + if (Math.abs(extent[0] - extent[1]) <= 1) { + return; + } + + dispatch.brush({extent: extent, brush: brush}); + + + updateBrushBG(); + + // Update Main (Focus) + var focusLinesWrap = g.select('.nv-focus .nv-linesWrap') + .datum( + data + .filter(function(d) { return !d.disabled }) + .map(function(d,i) { + return { + key: d.key, + area: d.area, + values: d.values.filter(function(d,i) { + return lines.x()(d,i) >= extent[0] && lines.x()(d,i) <= extent[1]; + }) + } + }) + ); + focusLinesWrap.transition().duration(transitionDuration).call(lines); + + + // Update Main (Focus) Axes + g.select('.nv-focus .nv-x.nv-axis').transition().duration(transitionDuration) + .call(xAxis); + g.select('.nv-focus .nv-y.nv-axis').transition().duration(transitionDuration) + .call(yAxis); + } + }); + + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + lines.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.legend = legend; + chart.lines = lines; + chart.lines2 = lines2; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.x2Axis = x2Axis; + chart.y2Axis = y2Axis; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + focusHeight: {get: function(){return height2;}, set: function(_){height2=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + brushExtent: {get: function(){return brushExtent;}, set: function(_){brushExtent=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + // line color is handled above? + }}, + interpolate: {get: function(){return lines.interpolate();}, set: function(_){ + lines.interpolate(_); + lines2.interpolate(_); + }}, + xTickFormat: {get: function(){return xAxis.xTickFormat();}, set: function(_){ + xAxis.xTickFormat(_); + x2Axis.xTickFormat(_); + }}, + yTickFormat: {get: function(){return yAxis.yTickFormat();}, set: function(_){ + yAxis.yTickFormat(_); + y2Axis.yTickFormat(_); + }}, + duration: {get: function(){return transitionDuration;}, set: function(_){ + transitionDuration=_; + yAxis.duration(transitionDuration); + xAxis.duration(transitionDuration); + }}, + x: {get: function(){return lines.x();}, set: function(_){ + lines.x(_); + lines2.x(_); + }}, + y: {get: function(){return lines.y();}, set: function(_){ + lines.y(_); + lines2.y(_); + }} + }); + + nv.utils.inheritOptions(chart, lines); + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.multiBar = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 960 + , height = 500 + , x = d3.scale.ordinal() + , y = d3.scale.linear() + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove + , clipEdge = true + , stacked = false + , stackOffset = 'zero' // options include 'silhouette', 'wiggle', 'expand', 'zero', or a custom function + , color = nv.utils.defaultColor() + , hideable = false + , barColor = null // adding the ability to set the color for each rather than the whole group + , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled + , duration = 500 + , xDomain + , yDomain + , xRange + , yRange + , groupSpacing = 0.1 + , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'renderEnd') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var x0, y0 //used to store previous scales + , renderWatch = nv.utils.renderWatch(dispatch, duration) + ; + + var last_datalength = 0; + + function chart(selection) { + renderWatch.reset(); + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + container = d3.select(this); + nv.utils.initSVG(container); + + // This function defines the requirements for render complete + var endFn = function(d, i) { + if (d.series === data.length - 1 && i === data[0].values.length - 1) + return true; + return false; + }; + + if(hideable && data.length) hideable = [{ + values: data[0].values.map(function(d) { + return { + x: d.x, + y: 0, + series: d.series, + size: 0.01 + };} + )}]; + + if (stacked) + data = d3.layout.stack() + .offset(stackOffset) + .values(function(d){ return d.values }) + .y(getY) + (!data.length && hideable ? hideable : data); + + + //add series index to each data point for reference + data.forEach(function(series, i) { + series.values.forEach(function(point) { + point.series = i; + }); + }); + + // HACK for negative value stacking + if (stacked) + data[0].values.map(function(d,i) { + var posBase = 0, negBase = 0; + data.map(function(d) { + var f = d.values[i] + f.size = Math.abs(f.y); + if (f.y<0) { + f.y1 = negBase; + negBase = negBase - f.size; + } else + { + f.y1 = f.size + posBase; + posBase = posBase + f.size; + } + }); + }); + + // Setup Scales + // remap and flatten the data for use in calculating the scales' domains + var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate + data.map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 } + }) + }); + + x.domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) + .rangeBands(xRange || [0, availableWidth], groupSpacing); + + y.domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 : d.y1 + d.y ) : d.y }).concat(forceY))) + .range(yRange || [availableHeight, 0]); + + // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point + if (x.domain()[0] === x.domain()[1]) + x.domain()[0] ? + x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) + : x.domain([-1,1]); + + if (y.domain()[0] === y.domain()[1]) + y.domain()[0] ? + y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) + : y.domain([-1,1]); + + x0 = x0 || x; + y0 = y0 || y; + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-multibar').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibar'); + var defsEnter = wrapEnter.append('defs'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g') + + gEnter.append('g').attr('class', 'nv-groups'); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + defsEnter.append('clipPath') + .attr('id', 'nv-edge-clip-' + id) + .append('rect'); + wrap.select('#nv-edge-clip-' + id + ' rect') + .attr('width', availableWidth) + .attr('height', availableHeight); + + g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); + + var groups = wrap.select('.nv-groups').selectAll('.nv-group') + .data(function(d) { return d }, function(d,i) { return i }); + groups.enter().append('g') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6); + + var exitTransition = renderWatch + .transition(groups.exit().selectAll('rect.nv-bar'), 'multibarExit', Math.min(100, duration)) + .attr('y', function(d) { return (stacked ? y0(d.y0) : y0(0)) || 0 }) + .attr('height', 0) + .remove(); + if (exitTransition.delay) + exitTransition.delay(function(d,i) { + var delay = i * (duration / (last_datalength + 1)) - i; + return delay; + }); + groups + .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) + .classed('hover', function(d) { return d.hover }) + .style('fill', function(d,i){ return color(d, i) }) + .style('stroke', function(d,i){ return color(d, i) }); + groups + .style('stroke-opacity', 1) + .style('fill-opacity', 0.75); + + var bars = groups.selectAll('rect.nv-bar') + .data(function(d) { return (hideable && !data.length) ? hideable.values : d.values }); + bars.exit().remove(); + + var barsEnter = bars.enter().append('rect') + .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) + .attr('x', function(d,i,j) { + return stacked ? 0 : (j * x.rangeBand() / data.length ) + }) + .attr('y', function(d) { return y0(stacked ? d.y0 : 0) || 0 }) + .attr('height', 0) + .attr('width', x.rangeBand() / (stacked ? 1 : data.length) ) + .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) + ; + bars + .style('fill', function(d,i,j){ return color(d, j, i); }) + .style('stroke', function(d,i,j){ return color(d, j, i); }) + .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here + d3.select(this).classed('hover', true); + dispatch.elementMouseover({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('mouseout', function(d,i) { + d3.select(this).classed('hover', false); + dispatch.elementMouseout({ + value: getY(d,i), + point: d, + series: data[d.series], + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('click', function(d,i) { + dispatch.elementClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }) + .on('dblclick', function(d,i) { + dispatch.elementDblClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }); + bars + .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) + .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',0)'; }) + + if (barColor) { + if (!disabled) disabled = data.map(function() { return true }); + bars + .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }) + .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }); + } + + var barSelection = + bars.watchTransition(renderWatch, 'multibar', Math.min(250, duration)) + .delay(function(d,i) { + return i * duration / data[0].values.length; + }); + if (stacked) + barSelection + .attr('y', function(d,i) { + return y((stacked ? d.y1 : 0)); + }) + .attr('height', function(d,i) { + return Math.max(Math.abs(y(d.y + (stacked ? d.y0 : 0)) - y((stacked ? d.y0 : 0))),1); + }) + .attr('x', function(d,i) { + return stacked ? 0 : (d.series * x.rangeBand() / data.length ) + }) + .attr('width', x.rangeBand() / (stacked ? 1 : data.length) ); + else + barSelection + .attr('x', function(d,i) { + return d.series * x.rangeBand() / data.length + }) + .attr('width', x.rangeBand() / data.length) + .attr('y', function(d,i) { + return getY(d,i) < 0 ? + y(0) : + y(0) - y(getY(d,i)) < 1 ? + y(0) - 1 : + y(getY(d,i)) || 0; + }) + .attr('height', function(d,i) { + return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) || 0; + }); + + //store old scales for use in transitions on update + x0 = x.copy(); + y0 = y.copy(); + + // keep track of the last data value length for transition calculations + if (data[0] && data[0].values) { + last_datalength = data[0].values.length; + } + + }); + + renderWatch.renderEnd('multibar immediate'); + + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + x: {get: function(){return getX;}, set: function(_){getX=_;}}, + y: {get: function(){return getY;}, set: function(_){getY=_;}}, + xScale: {get: function(){return x;}, set: function(_){x=_;}}, + yScale: {get: function(){return y;}, set: function(_){y=_;}}, + xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}}, + yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}}, + xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}}, + yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}}, + forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}}, + stacked: {get: function(){return stacked;}, set: function(_){stacked=_;}}, + stackOffset: {get: function(){return stackOffset;}, set: function(_){stackOffset=_;}}, + clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}}, + disabled: {get: function(){return disabled;}, set: function(_){disabled=_;}}, + id: {get: function(){return id;}, set: function(_){id=_;}}, + hideable: {get: function(){return hideable;}, set: function(_){hideable=_;}}, + groupSpacing:{get: function(){return groupSpacing;}, set: function(_){groupSpacing=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }}, + barColor: {get: function(){return barColor;}, set: function(_){ + barColor = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.multiBarChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var multibar = nv.models.multiBar() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend() + , controls = nv.models.legend() + ; + + var margin = {top: 30, right: 20, bottom: 50, left: 60} + , width = null + , height = null + , color = nv.utils.defaultColor() + , showControls = true + , controlLabels = {} + , showLegend = true + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , reduceXTicks = true // if false a tick will show for every data point + , staggerLabels = false + , rotateLabels = 0 + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' on ' + x + '

' + } + , x //can be accessed via chart.xScale() + , y //can be accessed via chart.yScale() + , state = nv.utils.state() + , defaultState = null + , noData = "No Data Available." + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState', 'renderEnd') + , controlWidth = function() { return showControls ? 180 : 0 } + , duration = 250 + ; + + state.stacked = false // DEPRECATED Maintained for backward compatibility + + multibar + .stacked(false) + ; + xAxis + .orient('bottom') + .tickPadding(7) + .highlightZero(true) + .showMaxMin(false) + .tickFormat(function(d) { return d }) + ; + yAxis + .orient((rightAlignYAxis) ? 'right' : 'left') + .tickFormat(d3.format(',.1f')) + ; + + controls.updateState(false); + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var renderWatch = nv.utils.renderWatch(dispatch); + var stacked = false; + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }), + stacked: stacked + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.stacked !== undefined) + stacked = state.stacked; + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(multibar); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + chart.update = function() { + if (duration === 0) + container.call(chart); + else + container.transition() + .duration(duration) + .call(chart); + }; + chart.container = this; + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disableddisabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display noData message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = multibar.xScale(); + y = multibar.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-multiBarWithLegend').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarWithLegend').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-barsWrap'); + gEnter.append('g').attr('class', 'nv-legendWrap'); + gEnter.append('g').attr('class', 'nv-controlsWrap'); + + // Legend + if (showLegend) { + legend.width(availableWidth - controlWidth()); + + if (multibar.barColor()) + data.forEach(function(series,i) { + series.color = d3.rgb('#ccc').darker(i * 1.5).toString(); + }); + + g.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + g.select('.nv-legendWrap') + .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')'); + } + + // Controls + if (showControls) { + var controlsData = [ + { key: controlLabels.grouped || 'Grouped', disabled: multibar.stacked() }, + { key: controlLabels.stacked || 'Stacked', disabled: !multibar.stacked() } + ]; + + controls.width(controlWidth()).color(['#444', '#444', '#444']); + g.select('.nv-controlsWrap') + .datum(controlsData) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(controls); + } + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } + + // Main Chart Component(s) + multibar + .disabled(data.map(function(series) { return series.disabled })) + .width(availableWidth) + .height(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled })); + + + var barsWrap = g.select('.nv-barsWrap') + .datum(data.filter(function(d) { return !d.disabled })); + + barsWrap.call(multibar); + + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize(-availableHeight, 0); + + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + y.range()[0] + ')'); + g.select('.nv-x.nv-axis') + .call(xAxis); + + var xTicks = g.select('.nv-x.nv-axis > g').selectAll('g'); + + xTicks + .selectAll('line, text') + .style('opacity', 1) + + if (staggerLabels) { + var getTranslate = function(x,y) { + return "translate(" + x + "," + y + ")"; + }; + + var staggerUp = 5, staggerDown = 17; //pixels to stagger by + // Issue #140 + xTicks + .selectAll("text") + .attr('transform', function(d,i,j) { + return getTranslate(0, (j % 2 == 0 ? staggerUp : staggerDown)); + }); + + var totalInBetweenTicks = d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length; + g.selectAll(".nv-x.nv-axis .nv-axisMaxMin text") + .attr("transform", function(d,i) { + return getTranslate(0, (i === 0 || totalInBetweenTicks % 2 !== 0) ? staggerDown : staggerUp); + }); + } + + if (reduceXTicks) + xTicks + .filter(function(d,i) { + return i % Math.ceil(data[0].values.length / (availableWidth / 100)) !== 0; + }) + .selectAll('text, line') + .style('opacity', 0); + + if(rotateLabels) + xTicks + .selectAll('.tick text') + .attr('transform', 'rotate(' + rotateLabels + ' 0,0)') + .style('text-anchor', rotateLabels > 0 ? 'start' : 'end'); + + g.select('.nv-x.nv-axis').selectAll('g.nv-axisMaxMin text') + .style('opacity', 1); + } + + if (showYAxis) { + yAxis + .scale(y) + .ticks( nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + g.select('.nv-y.nv-axis') + .call(yAxis); + } + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + controls.dispatch.on('legendClick', function(d,i) { + if (!d.disabled) return; + controlsData = controlsData.map(function(s) { + s.disabled = true; + return s; + }); + d.disabled = false; + + switch (d.key) { + case 'Grouped': + multibar.stacked(false); + break; + case 'Stacked': + multibar.stacked(true); + break; + } + + state.stacked = multibar.stacked(); + dispatch.stateChange(state); + + chart.update(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode) + }); + + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + + state.disabled = e.disabled; + } + + if (typeof e.stacked !== 'undefined') { + multibar.stacked(e.stacked); + state.stacked = e.stacked; + stacked = e.stacked; + } + + chart.update(); + }); + }); + + renderWatch.renderEnd('multibarchart immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + multibar.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + multibar.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.multibar = multibar; + chart.legend = legend; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.state = state; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}}, + controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + reduceXTicks: {get: function(){return reduceXTicks;}, set: function(_){reduceXTicks=_;}}, + rotateLabels: {get: function(){return rotateLabels;}, set: function(_){rotateLabels=_;}}, + staggerLabels: {get: function(){return staggerLabels;}, set: function(_){staggerLabels=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + multibar.duration(duration); + xAxis.duration(duration); + yAxis.duration(duration); + renderWatch.reset(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + }}, + rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){ + rightAlignYAxis = _; + yAxis.orient( rightAlignYAxis ? 'right' : 'left'); + }} + }); + + nv.utils.inheritOptions(chart, multibar); + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.multiBarHorizontal = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 960 + , height = 500 + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , x = d3.scale.ordinal() + , y = d3.scale.linear() + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , getYerr = function(d) { return d.yErr } + , forceY = [0] // 0 is forced by default.. this makes sense for the majority of bar graphs... user can always do chart.forceY([]) to remove + , color = nv.utils.defaultColor() + , barColor = null // adding the ability to set the color for each rather than the whole group + , disabled // used in conjunction with barColor to communicate from multiBarHorizontalChart what series are disabled + , stacked = false + , showValues = false + , showBarLabels = false + , valuePadding = 60 + , valueFormat = d3.format(',.2f') + , delay = 1200 + , xDomain + , yDomain + , xRange + , yRange + , duration = 250 + , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout','renderEnd') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var x0, y0; //used to store previous scales + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + function chart(selection) { + renderWatch.reset(); + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + container = d3.select(this); + nv.utils.initSVG(container); + + if (stacked) + data = d3.layout.stack() + .offset('zero') + .values(function(d){ return d.values }) + .y(getY) + (data); + + //add series index to each data point for reference + data.forEach(function(series, i) { + series.values.forEach(function(point) { + point.series = i; + }); + }); + + // HACK for negative value stacking + if (stacked) + data[0].values.map(function(d,i) { + var posBase = 0, negBase = 0; + data.map(function(d) { + var f = d.values[i] + f.size = Math.abs(f.y); + if (f.y<0) { + f.y1 = negBase - f.size; + negBase = negBase - f.size; + } else + { + f.y1 = posBase; + posBase = posBase + f.size; + } + }); + }); + + // Setup Scales + // remap and flatten the data for use in calculating the scales' domains + var seriesData = (xDomain && yDomain) ? [] : // if we know xDomain and yDomain, no need to calculate + data.map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i), y0: d.y0, y1: d.y1 } + }) + }); + + x.domain(xDomain || d3.merge(seriesData).map(function(d) { return d.x })) + .rangeBands(xRange || [0, availableHeight], .1); + + y.domain(yDomain || d3.extent(d3.merge(seriesData).map(function(d) { return stacked ? (d.y > 0 ? d.y1 + d.y : d.y1 ) : d.y }).concat(forceY))) + + if (showValues && !stacked) + y.range(yRange || [(y.domain()[0] < 0 ? valuePadding : 0), availableWidth - (y.domain()[1] > 0 ? valuePadding : 0) ]); + else + y.range(yRange || [0, availableWidth]); + + x0 = x0 || x; + y0 = y0 || d3.scale.linear().domain(y.domain()).range([y(0),y(0)]); + + // Setup containers and skeleton of chart + var wrap = d3.select(this).selectAll('g.nv-wrap.nv-multibarHorizontal').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multibarHorizontal'); + var defsEnter = wrapEnter.append('defs'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-groups'); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var groups = wrap.select('.nv-groups').selectAll('.nv-group') + .data(function(d) { return d }, function(d,i) { return i }); + groups.enter().append('g') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6); + groups.exit().watchTransition(renderWatch, 'multibarhorizontal: exit groups') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6) + .remove(); + groups + .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) + .classed('hover', function(d) { return d.hover }) + .style('fill', function(d,i){ return color(d, i) }) + .style('stroke', function(d,i){ return color(d, i) }); + groups.watchTransition(renderWatch, 'multibarhorizontal: groups') + .style('stroke-opacity', 1) + .style('fill-opacity', .75); + + var bars = groups.selectAll('g.nv-bar') + .data(function(d) { return d.values }); + bars.exit().remove(); + + var barsEnter = bars.enter().append('g') + .attr('transform', function(d,i,j) { + return 'translate(' + y0(stacked ? d.y0 : 0) + ',' + (stacked ? 0 : (j * x.rangeBand() / data.length ) + x(getX(d,i))) + ')' + }); + + barsEnter.append('rect') + .attr('width', 0) + .attr('height', x.rangeBand() / (stacked ? 1 : data.length) ) + + bars + .on('mouseover', function(d,i) { //TODO: figure out why j works above, but not here + d3.select(this).classed('hover', true); + dispatch.elementMouseover({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [ y(getY(d,i) + (stacked ? d.y0 : 0)), x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length) ], + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('mouseout', function(d,i) { + d3.select(this).classed('hover', false); + dispatch.elementMouseout({ + value: getY(d,i), + point: d, + series: data[d.series], + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + }) + .on('click', function(d,i) { + dispatch.elementClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }) + .on('dblclick', function(d,i) { + dispatch.elementDblClick({ + value: getY(d,i), + point: d, + series: data[d.series], + pos: [x(getX(d,i)) + (x.rangeBand() * (stacked ? data.length / 2 : d.series + .5) / data.length), y(getY(d,i) + (stacked ? d.y0 : 0))], // TODO: Figure out why the value appears to be shifted + pointIndex: i, + seriesIndex: d.series, + e: d3.event + }); + d3.event.stopPropagation(); + }); + + if (getYerr(data[0],0)) { + barsEnter.append('polyline'); + + bars.select('polyline') + .attr('fill', 'none') + .attr('points', function(d,i) { + var xerr = getYerr(d,i) + , mid = 0.8 * x.rangeBand() / ((stacked ? 1 : data.length) * 2); + xerr = xerr.length ? xerr : [-Math.abs(xerr), Math.abs(xerr)]; + xerr = xerr.map(function(e) { return y(e) - y(0); }); + var a = [[xerr[0],-mid], [xerr[0],mid], [xerr[0],0], [xerr[1],0], [xerr[1],-mid], [xerr[1],mid]]; + return a.map(function (path) { return path.join(',') }).join(' '); + }) + .attr('transform', function(d,i) { + var mid = x.rangeBand() / ((stacked ? 1 : data.length) * 2); + return 'translate(' + (getY(d,i) < 0 ? 0 : y(getY(d,i)) - y(0)) + ', ' + mid + ')' + }); + } + + barsEnter.append('text'); + + if (showValues && !stacked) { + bars.select('text') + .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'end' : 'start' }) + .attr('y', x.rangeBand() / (data.length * 2)) + .attr('dy', '.32em') + .html(function(d,i) { + var t = valueFormat(getY(d,i)) + , yerr = getYerr(d,i); + if (yerr === undefined) + return t; + if (!yerr.length) + return t + '±' + valueFormat(Math.abs(yerr)); + return t + '+' + valueFormat(Math.abs(yerr[1])) + '-' + valueFormat(Math.abs(yerr[0])); + }); + bars.watchTransition(renderWatch, 'multibarhorizontal: bars') + .select('text') + .attr('x', function(d,i) { return getY(d,i) < 0 ? -4 : y(getY(d,i)) - y(0) + 4 }) + } else { + bars.selectAll('text').text(''); + } + + if (showBarLabels && !stacked) { + barsEnter.append('text').classed('nv-bar-label',true); + bars.select('text.nv-bar-label') + .attr('text-anchor', function(d,i) { return getY(d,i) < 0 ? 'start' : 'end' }) + .attr('y', x.rangeBand() / (data.length * 2)) + .attr('dy', '.32em') + .text(function(d,i) { return getX(d,i) }); + bars.watchTransition(renderWatch, 'multibarhorizontal: bars') + .select('text.nv-bar-label') + .attr('x', function(d,i) { return getY(d,i) < 0 ? y(0) - y(getY(d,i)) + 4 : -4 }); + } + else { + bars.selectAll('text.nv-bar-label').text(''); + } + + bars + .attr('class', function(d,i) { return getY(d,i) < 0 ? 'nv-bar negative' : 'nv-bar positive'}) + + if (barColor) { + if (!disabled) disabled = data.map(function() { return true }); + bars + .style('fill', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }) + .style('stroke', function(d,i,j) { return d3.rgb(barColor(d,i)).darker( disabled.map(function(d,i) { return i }).filter(function(d,i){ return !disabled[i] })[j] ).toString(); }); + } + + if (stacked) + bars.watchTransition(renderWatch, 'multibarhorizontal: bars') + .attr('transform', function(d,i) { + return 'translate(' + y(d.y1) + ',' + x(getX(d,i)) + ')' + }) + .select('rect') + .attr('width', function(d,i) { + return Math.abs(y(getY(d,i) + d.y0) - y(d.y0)) + }) + .attr('height', x.rangeBand() ); + else + bars.watchTransition(renderWatch, 'multibarhorizontal: bars') + .attr('transform', function(d,i) { + //TODO: stacked must be all positive or all negative, not both? + return 'translate(' + + (getY(d,i) < 0 ? y(getY(d,i)) : y(0)) + + ',' + + (d.series * x.rangeBand() / data.length + + + x(getX(d,i)) ) + + ')' + }) + .select('rect') + .attr('height', x.rangeBand() / data.length ) + .attr('width', function(d,i) { + return Math.max(Math.abs(y(getY(d,i)) - y(0)),1) + }); + + //store old scales for use in transitions on update + x0 = x.copy(); + y0 = y.copy(); + + }); + + renderWatch.renderEnd('multibarHorizontal immediate'); + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + x: {get: function(){return getX;}, set: function(_){getX=_;}}, + y: {get: function(){return getY;}, set: function(_){getY=_;}}, + yErr: {get: function(){return getYerr;}, set: function(_){getYerr=_;}}, + xScale: {get: function(){return x;}, set: function(_){x=_;}}, + yScale: {get: function(){return y;}, set: function(_){y=_;}}, + xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}}, + yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}}, + xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}}, + yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}}, + forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}}, + stacked: {get: function(){return stacked;}, set: function(_){stacked=_;}}, + showValues: {get: function(){return showValues;}, set: function(_){showValues=_;}}, + // this shows the group name, seems pointless? + //showBarLabels: {get: function(){return showBarLabels;}, set: function(_){showBarLabels=_;}}, + disabled: {get: function(){return disabled;}, set: function(_){disabled=_;}}, + id: {get: function(){return id;}, set: function(_){id=_;}}, + valueFormat: {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}}, + valuePadding: {get: function(){return valuePadding;}, set: function(_){valuePadding=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }}, + barColor: {get: function(){return color;}, set: function(_){ + barColor = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + + return chart; +}; +nv.models.multiBarHorizontalChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var multibar = nv.models.multiBarHorizontal() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend().height(30) + , controls = nv.models.legend().height(30) + ; + + var margin = {top: 30, right: 20, bottom: 50, left: 60} + , width = null + , height = null + , color = nv.utils.defaultColor() + , showControls = true + , controlLabels = {} + , showLegend = true + , showXAxis = true + , showYAxis = true + , stacked = false + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + ' - ' + x + '

' + + '

' + y + '

' + } + , x //can be accessed via chart.xScale() + , y //can be accessed via chart.yScale() + , state = nv.utils.state() + , defaultState = null + , noData = 'No Data Available.' + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState','renderEnd') + , controlWidth = function() { return showControls ? 180 : 0 } + , duration = 250 + ; + + state.stacked = false; // DEPRECATED Maintained for backward compatibility + + multibar + .stacked(stacked) + ; + xAxis + .orient('left') + .tickPadding(5) + .highlightZero(false) + .showMaxMin(false) + .tickFormat(function(d) { return d }) + ; + yAxis + .orient('bottom') + .tickFormat(d3.format(',.1f')) + ; + + controls.updateState(false); + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(multibar.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(multibar.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'e' : 'w', null, offsetElement); + }; + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }), + stacked: stacked + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.stacked !== undefined) + stacked = state.stacked; + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(multibar); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + chart.update = function() { container.transition().duration(duration).call(chart) }; + chart.container = this; + + stacked = multibar.stacked(); + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disableddisabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display No Data message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = multibar.xScale(); + y = multibar.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-multiBarHorizontalChart').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-multiBarHorizontalChart').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis') + .append('g').attr('class', 'nv-zeroLine') + .append('line'); + gEnter.append('g').attr('class', 'nv-barsWrap'); + gEnter.append('g').attr('class', 'nv-legendWrap'); + gEnter.append('g').attr('class', 'nv-controlsWrap'); + + // Legend + if (showLegend) { + legend.width(availableWidth - controlWidth()); + + if (multibar.barColor()) + data.forEach(function(series,i) { + series.color = d3.rgb('#ccc').darker(i * 1.5).toString(); + }); + + g.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + g.select('.nv-legendWrap') + .attr('transform', 'translate(' + controlWidth() + ',' + (-margin.top) +')'); + } + + // Controls + if (showControls) { + var controlsData = [ + { key: controlLabels.grouped || 'Grouped', disabled: multibar.stacked() }, + { key: controlLabels.stacked || 'Stacked', disabled: !multibar.stacked() } + ]; + + controls.width(controlWidth()).color(['#444', '#444', '#444']); + g.select('.nv-controlsWrap') + .datum(controlsData) + .attr('transform', 'translate(0,' + (-margin.top) +')') + .call(controls); + } + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + // Main Chart Component(s) + multibar + .disabled(data.map(function(series) { return series.disabled })) + .width(availableWidth) + .height(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled })); + + var barsWrap = g.select('.nv-barsWrap') + .datum(data.filter(function(d) { return !d.disabled })); + + barsWrap.transition().call(multibar); + + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .ticks( nv.utils.calcTicksY(availableHeight/24, data) ) + .tickSize(-availableWidth, 0); + + g.select('.nv-x.nv-axis').call(xAxis); + + var xTicks = g.select('.nv-x.nv-axis').selectAll('g'); + + xTicks + .selectAll('line, text'); + } + + if (showYAxis) { + yAxis + .scale(y) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize( -availableHeight, 0); + + g.select('.nv-y.nv-axis') + .attr('transform', 'translate(0,' + availableHeight + ')'); + g.select('.nv-y.nv-axis').call(yAxis); + } + + // Zero line + g.select(".nv-zeroLine line") + .attr("x1", y(0)) + .attr("x2", y(0)) + .attr("y1", 0) + .attr("y2", -availableHeight) + ; + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + controls.dispatch.on('legendClick', function(d,i) { + if (!d.disabled) return; + controlsData = controlsData.map(function(s) { + s.disabled = true; + return s; + }); + d.disabled = false; + + switch (d.key) { + case 'Grouped': + multibar.stacked(false); + break; + case 'Stacked': + multibar.stacked(true); + break; + } + + state.stacked = multibar.stacked(); + dispatch.stateChange(state); + stacked = multibar.stacked(); + + chart.update(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + + state.disabled = e.disabled; + } + + if (typeof e.stacked !== 'undefined') { + multibar.stacked(e.stacked); + state.stacked = e.stacked; + stacked = e.stacked; + } + + chart.update(); + }); + }); + renderWatch.renderEnd('multibar horizontal chart immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + multibar.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + multibar.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.multibar = multibar; + chart.legend = legend; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.state = state; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}}, + controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + multibar.duration(duration); + xAxis.duration(duration); + yAxis.duration(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + }} + }); + + nv.utils.inheritOptions(chart, multibar); + nv.utils.initOptions(chart); + + return chart; +}; +nv.models.multiChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 30, right: 20, bottom: 50, left: 60}, + color = nv.utils.defaultColor(), + width = null, + height = null, + showLegend = true, + tooltips = true, + tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' at ' + x + '

' + }, + x, + y, + noData = 'No Data Available.', + yDomain1, + yDomain2, + getX = function(d) { return d.x }, + getY = function(d) { return d.y}, + interpolate = 'monotone' + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var x = d3.scale.linear(), + yScale1 = d3.scale.linear(), + yScale2 = d3.scale.linear(), + + lines1 = nv.models.line().yScale(yScale1), + lines2 = nv.models.line().yScale(yScale2), + + bars1 = nv.models.multiBar().stacked(false).yScale(yScale1), + bars2 = nv.models.multiBar().stacked(false).yScale(yScale2), + + stack1 = nv.models.stackedArea().yScale(yScale1), + stack2 = nv.models.stackedArea().yScale(yScale2), + + xAxis = nv.models.axis().scale(x).orient('bottom').tickPadding(5), + yAxis1 = nv.models.axis().scale(yScale1).orient('left'), + yAxis2 = nv.models.axis().scale(yScale2).orient('right'), + + legend = nv.models.legend().height(30), + dispatch = d3.dispatch('tooltipShow', 'tooltipHide'); + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(lines1.x()(e.point, e.pointIndex)), + y = ((e.series.yAxis == 2) ? yAxis2 : yAxis1).tickFormat()(lines1.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, undefined, undefined, offsetElement.offsetParent); + }; + + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + + chart.update = function() { container.transition().call(chart); }; + chart.container = this; + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + var dataLines1 = data.filter(function(d) {return d.type == 'line' && d.yAxis == 1}); + var dataLines2 = data.filter(function(d) {return d.type == 'line' && d.yAxis == 2}); + var dataBars1 = data.filter(function(d) {return d.type == 'bar' && d.yAxis == 1}); + var dataBars2 = data.filter(function(d) {return d.type == 'bar' && d.yAxis == 2}); + var dataStack1 = data.filter(function(d) {return d.type == 'area' && d.yAxis == 1}); + var dataStack2 = data.filter(function(d) {return d.type == 'area' && d.yAxis == 2}); + + // Display noData message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + var series1 = data.filter(function(d) {return !d.disabled && d.yAxis == 1}) + .map(function(d) { + return d.values.map(function(d,i) { + return { x: d.x, y: d.y } + }) + }); + + var series2 = data.filter(function(d) {return !d.disabled && d.yAxis == 2}) + .map(function(d) { + return d.values.map(function(d,i) { + return { x: d.x, y: d.y } + }) + }); + + x .domain(d3.extent(d3.merge(series1.concat(series2)), function(d) { return d.x } )) + .range([0, availableWidth]); + + var wrap = container.selectAll('g.wrap.multiChart').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'wrap nvd3 multiChart').append('g'); + + gEnter.append('g').attr('class', 'x axis'); + gEnter.append('g').attr('class', 'y1 axis'); + gEnter.append('g').attr('class', 'y2 axis'); + gEnter.append('g').attr('class', 'lines1Wrap'); + gEnter.append('g').attr('class', 'lines2Wrap'); + gEnter.append('g').attr('class', 'bars1Wrap'); + gEnter.append('g').attr('class', 'bars2Wrap'); + gEnter.append('g').attr('class', 'stack1Wrap'); + gEnter.append('g').attr('class', 'stack2Wrap'); + gEnter.append('g').attr('class', 'legendWrap'); + + var g = wrap.select('g'); + + var color_array = data.map(function(d,i) { + return data[i].color || color(d, i); + }); + + if (showLegend) { + legend.color(color_array); + legend.width( availableWidth / 2 ); + + g.select('.legendWrap') + .datum(data.map(function(series) { + series.originalKey = series.originalKey === undefined ? series.key : series.originalKey; + series.key = series.originalKey + (series.yAxis == 1 ? '' : ' (right axis)'); + return series; + })) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + g.select('.legendWrap') + .attr('transform', 'translate(' + ( availableWidth / 2 ) + ',' + (-margin.top) +')'); + } + + lines1 + .width(availableWidth) + .height(availableHeight) + .interpolate(interpolate) + .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'line'})); + lines2 + .width(availableWidth) + .height(availableHeight) + .interpolate(interpolate) + .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'line'})); + bars1 + .width(availableWidth) + .height(availableHeight) + .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'bar'})); + bars2 + .width(availableWidth) + .height(availableHeight) + .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'bar'})); + stack1 + .width(availableWidth) + .height(availableHeight) + .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 1 && data[i].type == 'area'})); + stack2 + .width(availableWidth) + .height(availableHeight) + .color(color_array.filter(function(d,i) { return !data[i].disabled && data[i].yAxis == 2 && data[i].type == 'area'})); + + g.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var lines1Wrap = g.select('.lines1Wrap') + .datum( + dataLines1.filter(function(d){return !d.disabled}) + ); + var bars1Wrap = g.select('.bars1Wrap') + .datum( + dataBars1.filter(function(d){return !d.disabled}) + ); + var stack1Wrap = g.select('.stack1Wrap') + .datum( + dataStack1.filter(function(d){return !d.disabled}) + ); + + var lines2Wrap = g.select('.lines2Wrap') + .datum( + dataLines2.filter(function(d){return !d.disabled}) + ); + var bars2Wrap = g.select('.bars2Wrap') + .datum( + dataBars2.filter(function(d){return !d.disabled}) + ); + var stack2Wrap = g.select('.stack2Wrap') + .datum( + dataStack2.filter(function(d){return !d.disabled}) + ); + + var extraValue1 = dataStack1.length ? dataStack1.map(function(a){return a.values}).reduce(function(a,b){ + return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}}) + }).concat([{x:0, y:0}]) : [] + var extraValue2 = dataStack2.length ? dataStack2.map(function(a){return a.values}).reduce(function(a,b){ + return a.map(function(aVal,i){return {x: aVal.x, y: aVal.y + b[i].y}}) + }).concat([{x:0, y:0}]) : [] + + yScale1 .domain(yDomain1 || d3.extent(d3.merge(series1).concat(extraValue1), function(d) { return d.y } )) + .range([0, availableHeight]) + + yScale2 .domain(yDomain2 || d3.extent(d3.merge(series2).concat(extraValue2), function(d) { return d.y } )) + .range([0, availableHeight]) + + lines1.yDomain(yScale1.domain()) + bars1.yDomain(yScale1.domain()) + stack1.yDomain(yScale1.domain()) + + lines2.yDomain(yScale2.domain()) + bars2.yDomain(yScale2.domain()) + stack2.yDomain(yScale2.domain()) + + if(dataStack1.length){d3.transition(stack1Wrap).call(stack1);} + if(dataStack2.length){d3.transition(stack2Wrap).call(stack2);} + + if(dataBars1.length){d3.transition(bars1Wrap).call(bars1);} + if(dataBars2.length){d3.transition(bars2Wrap).call(bars2);} + + if(dataLines1.length){d3.transition(lines1Wrap).call(lines1);} + if(dataLines2.length){d3.transition(lines2Wrap).call(lines2);} + + xAxis + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize(-availableHeight, 0); + + g.select('.x.axis') + .attr('transform', 'translate(0,' + availableHeight + ')'); + d3.transition(g.select('.x.axis')) + .call(xAxis); + + yAxis1 + .ticks( nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + + d3.transition(g.select('.y1.axis')) + .call(yAxis1); + + yAxis2 + .ticks( nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + d3.transition(g.select('.y2.axis')) + .call(yAxis2); + + g.select('.y1.axis') + .classed('nv-disabled', series1.length ? false : true) + .attr('transform', 'translate(' + x.range()[0] + ',0)'); + + g.select('.y2.axis') + .classed('nv-disabled', series2.length ? false : true) + .attr('transform', 'translate(' + x.range()[1] + ',0)'); + + legend.dispatch.on('stateChange', function(newState) { + chart.update(); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + }); + + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + lines1.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines1.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + lines2.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines2.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + bars1.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + bars1.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + bars2.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + bars2.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + stack1.dispatch.on('tooltipShow', function(e) { + //disable tooltips when value ~= 0 + //// TODO: consider removing points from voronoi that have 0 value instead of this hack + if (!Math.round(stack1.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range + setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); + return false; + } + + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], + dispatch.tooltipShow(e); + }); + + stack1.dispatch.on('tooltipHide', function(e) { + dispatch.tooltipHide(e); + }); + + stack2.dispatch.on('tooltipShow', function(e) { + //disable tooltips when value ~= 0 + //// TODO: consider removing points from voronoi that have 0 value instead of this hack + if (!Math.round(stack2.y()(e.point) * 100)) { // 100 will not be good for very small numbers... will have to think about making this valu dynamic, based on data range + setTimeout(function() { d3.selectAll('.point.hover').classed('hover', false) }, 0); + return false; + } + + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], + dispatch.tooltipShow(e); + }); + + stack2.dispatch.on('tooltipHide', function(e) { + dispatch.tooltipHide(e); + }); + + lines1.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines1.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + lines2.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + lines2.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Global getters and setters + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.lines1 = lines1; + chart.lines2 = lines2; + chart.bars1 = bars1; + chart.bars2 = bars2; + chart.stack1 = stack1; + chart.stack2 = stack2; + chart.xAxis = xAxis; + chart.yAxis1 = yAxis1; + chart.yAxis2 = yAxis2; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + yDomain1: {get: function(){return yDomain1;}, set: function(_){yDomain1=_;}}, + yDomain2: {get: function(){return yDomain2;}, set: function(_){yDomain2=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + interpolate: {get: function(){return interpolate;}, set: function(_){interpolate=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }}, + x: {get: function(){return getX;}, set: function(_){ + getX = _; + lines1.x(_); + bars1.x(_); + }}, + y: {get: function(){return getY;}, set: function(_){ + getY = _; + lines1.y(_); + bars1.y(_); + }} + }); + + nv.utils.initOptions(chart); + + return chart; +}; + + +nv.models.ohlcBar = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = null + , height = null + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , x = d3.scale.linear() + , y = d3.scale.linear() + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , getOpen = function(d) { return d.open } + , getClose = function(d) { return d.close } + , getHigh = function(d) { return d.high } + , getLow = function(d) { return d.low } + , forceX = [] + , forceY = [] + , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart + , clipEdge = true + , color = nv.utils.defaultColor() + , interactive = false + , xDomain + , yDomain + , xRange + , yRange + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState', 'renderEnd', 'chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right; + var availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + nv.utils.initSVG(container); + + // Setup Scales + x.domain(xDomain || d3.extent(data[0].values.map(getX).concat(forceX) )); + + if (padData) + x.range(xRange || [availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); + else + x.range(xRange || [0, availableWidth]); + + y.domain(yDomain || [ + d3.min(data[0].values.map(getLow).concat(forceY)), + d3.max(data[0].values.map(getHigh).concat(forceY)) + ] + ).range(yRange || [availableHeight, 0]); + + // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point + if (x.domain()[0] === x.domain()[1]) + x.domain()[0] ? + x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) + : x.domain([-1,1]); + + if (y.domain()[0] === y.domain()[1]) + y.domain()[0] ? + y.domain([y.domain()[0] + y.domain()[0] * 0.01, y.domain()[1] - y.domain()[1] * 0.01]) + : y.domain([-1,1]); + + // Setup containers and skeleton of chart + var wrap = d3.select(this).selectAll('g.nv-wrap.nv-ohlcBar').data([data[0].values]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-ohlcBar'); + var defsEnter = wrapEnter.append('defs'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-ticks'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + container + .on('click', function(d,i) { + dispatch.chartClick({ + data: d, + index: i, + pos: d3.event, + id: id + }); + }); + + defsEnter.append('clipPath') + .attr('id', 'nv-chart-clip-path-' + id) + .append('rect'); + + wrap.select('#nv-chart-clip-path-' + id + ' rect') + .attr('width', availableWidth) + .attr('height', availableHeight); + + g .attr('clip-path', clipEdge ? 'url(#nv-chart-clip-path-' + id + ')' : ''); + + var ticks = wrap.select('.nv-ticks').selectAll('.nv-tick') + .data(function(d) { return d }); + ticks.exit().remove(); + + var ticksEnter = ticks.enter().append('path') + .attr('class', function(d,i,j) { return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i }) + .attr('d', function(d,i) { + var w = (availableWidth / data[0].values.length) * .9; + return 'm0,0l0,' + + (y(getOpen(d,i)) + - y(getHigh(d,i))) + + 'l' + + (-w/2) + + ',0l' + + (w/2) + + ',0l0,' + + (y(getLow(d,i)) - y(getOpen(d,i))) + + 'l0,' + + (y(getClose(d,i)) + - y(getLow(d,i))) + + 'l' + + (w/2) + + ',0l' + + (-w/2) + + ',0z'; + }) + .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; }) + .attr('fill', function(d,i) { return color[0]; }) + .attr('stroke', function(d,i) { return color[0]; }) + .attr('x', 0 ) + .attr('y', function(d,i) { return y(Math.max(0, getY(d,i))) }) + .attr('height', function(d,i) { return Math.abs(y(getY(d,i)) - y(0)) }); + + // the bar colors are controlled by CSS currently + ticks.attr('class', function(d,i,j) { + return (getOpen(d,i) > getClose(d,i) ? 'nv-tick negative' : 'nv-tick positive') + ' nv-tick-' + j + '-' + i; + }); + + d3.transition(ticks) + .attr('transform', function(d,i) { return 'translate(' + x(getX(d,i)) + ',' + y(getHigh(d,i)) + ')'; }) + .attr('d', function(d,i) { + var w = (availableWidth / data[0].values.length) * .9; + return 'm0,0l0,' + + (y(getOpen(d,i)) + - y(getHigh(d,i))) + + 'l' + + (-w/2) + + ',0l' + + (w/2) + + ',0l0,' + + (y(getLow(d,i)) + - y(getOpen(d,i))) + + 'l0,' + + (y(getClose(d,i)) + - y(getLow(d,i))) + + 'l' + + (w/2) + + ',0l' + + (-w/2) + + ',0z'; + }); + }); + + return chart; + } + + + //Create methods to allow outside functions to highlight a specific bar. + chart.highlightPoint = function(pointIndex, isHoverOver) { + chart.clearHighlights(); + d3.select(".nv-ohlcBar .nv-tick-0-" + pointIndex) + .classed("hover", isHoverOver) + ; + }; + + chart.clearHighlights = function() { + d3.select(".nv-ohlcBar .nv-tick.hover") + .classed("hover", false) + ; + }; + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + xScale: {get: function(){return x;}, set: function(_){x=_;}}, + yScale: {get: function(){return y;}, set: function(_){y=_;}}, + xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}}, + yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}}, + xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}}, + yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}}, + forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}}, + forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}}, + padData: {get: function(){return padData;}, set: function(_){padData=_;}}, + clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}}, + id: {get: function(){return id;}, set: function(_){id=_;}}, + interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}}, + + x: {get: function(){return getX;}, set: function(_){getX=_;}}, + y: {get: function(){return getY;}, set: function(_){getY=_;}}, + open: {get: function(){return getOpen();}, set: function(_){getOpen=_;}}, + close: {get: function(){return getClose();}, set: function(_){getClose=_;}}, + high: {get: function(){return getHigh;}, set: function(_){getHigh=_;}}, + low: {get: function(){return getLow;}, set: function(_){getLow=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top != undefined ? _.top : margin.top; + margin.right = _.right != undefined ? _.right : margin.right; + margin.bottom = _.bottom != undefined ? _.bottom : margin.bottom; + margin.left = _.left != undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + return chart; +}; + +// Code adapted from Jason Davies' "Parallel Coordinates" +// http://bl.ocks.org/jasondavies/1341281 + +nv.models.parallelCoordinates = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 30, right: 10, bottom: 10, left: 10} + , width = null + , height = null + , x = d3.scale.ordinal() + , y = {} + , dimensions = [] + , color = nv.utils.defaultColor() + , filters = [] + , active = [] + , dispatch = d3.dispatch('brush') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right; + var availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + nv.utils.initSVG(container); + + active = data; //set all active before first brush call + + //This is a placeholder until this chart is made resizeable + chart.update = function() { }; + + // Setup Scales + x.rangePoints([0, availableWidth], 1).domain(dimensions); + + // Extract the list of dimensions and create a scale for each. + dimensions.forEach(function(d) { + y[d] = d3.scale.linear() + .domain(d3.extent(data, function(p) { return +p[d]; })) + .range([availableHeight, 0]); + + y[d].brush = d3.svg.brush().y(y[d]).on('brush', brush); + + return d != 'name'; + }); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-parallelCoordinates').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-parallelCoordinates'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-parallelCoordinatesWrap'); + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + var line = d3.svg.line(), + axis = d3.svg.axis().orient('left'), + background, + foreground; + + // Add grey background lines for context. + background = gEnter.append('g') + .attr('class', 'background') + .selectAll('path') + .data(data) + .enter().append('path') + .attr('d', path) + ; + + // Add blue foreground lines for focus. + foreground = gEnter.append('g') + .attr('class', 'foreground') + .selectAll('path') + .data(data) + .enter().append('path') + .attr('d', path) + .attr('stroke', color) + ; + + // Add a group element for each dimension. + var dimension = g.selectAll('.dimension') + .data(dimensions) + .enter().append('g') + .attr('class', 'dimension') + .attr('transform', function(d) { return 'translate(' + x(d) + ',0)'; }); + + // Add an axis and title. + dimension.append('g') + .attr('class', 'axis') + .each(function(d) { d3.select(this).call(axis.scale(y[d])); }) + .append('text') + .attr('text-anchor', 'middle') + .attr('y', -9) + .text(String); + + // Add and store a brush for each axis. + dimension.append('g') + .attr('class', 'brush') + .each(function(d) { d3.select(this).call(y[d].brush); }) + .selectAll('rect') + .attr('x', -8) + .attr('width', 16); + + // Returns the path for a given data point. + function path(d) { + return line(dimensions.map(function(p) { return [x(p), y[p](d[p])]; })); + } + + // Handles a brush event, toggling the display of foreground lines. + function brush() { + var actives = dimensions.filter(function(p) { return !y[p].brush.empty(); }), + extents = actives.map(function(p) { return y[p].brush.extent(); }); + + filters = []; //erase current filters + actives.forEach(function(d,i) { + filters[i] = { + dimension: d, + extent: extents[i] + } + }); + + active = []; //erase current active list + foreground.style('display', function(d) { + var isActive = actives.every(function(p, i) { + return extents[i][0] <= d[p] && d[p] <= extents[i][1]; + }); + if (isActive) active.push(d); + return isActive ? null : 'none'; + }); + + dispatch.brush({ + filters: filters, + active: active + }); + } + }); + + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + dimensions: {get: function(){return dimensions;}, set: function(_){dimensions=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = typeof _.top != 'undefined' ? _.top : margin.top; + margin.right = typeof _.right != 'undefined' ? _.right : margin.right; + margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; + margin.left = typeof _.left != 'undefined' ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + return chart; +}; +nv.models.pie = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 500 + , height = 500 + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , id = Math.floor(Math.random() * 10000) //Create semi-unique ID in case user doesn't select one + , color = nv.utils.defaultColor() + , valueFormat = d3.format(',.2f') + , labelFormat = d3.format('%') + , showLabels = true + , pieLabelsOutside = true + , donutLabelsOutside = false + , labelType = "key" + , labelThreshold = .02 //if slice percentage is under this, don't show label + , donut = false + , title = false + , growOnHover = true + , titleOffset = 0 + , labelSunbeamLayout = false + , startAngle = false + , padAngle = false + , endAngle = false + , cornerRadius = 0 + , donutRatio = 0.5 + , duration = 250 + , dispatch = d3.dispatch('chartClick', 'elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'renderEnd') + ; + + + //============================================================ + // chart function + //------------------------------------------------------------ + + var renderWatch = nv.utils.renderWatch(dispatch); + + function chart(selection) { + renderWatch.reset(); + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right + ,availableHeight = height - margin.top - margin.bottom + ,radius = Math.min(availableWidth, availableHeight) / 2 + ,arcRadius = radius-(radius / 5) + ,container = d3.select(this) + ; + nv.utils.initSVG(container); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('.nv-wrap.nv-pie').data(data); + var wrapEnter = wrap.enter().append('g').attr('class','nvd3 nv-wrap nv-pie nv-chart-' + id); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + var g_pie = gEnter.append('g').attr('class', 'nv-pie'); + gEnter.append('g').attr('class', 'nv-pieLabels'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + g.select('.nv-pie').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')'); + g.select('.nv-pieLabels').attr('transform', 'translate(' + availableWidth / 2 + ',' + availableHeight / 2 + ')'); + + // + container.on('click', function(d,i) { + dispatch.chartClick({ + data: d, + index: i, + pos: d3.event, + id: id + }); + }); + + + var arc = d3.svg.arc().outerRadius(arcRadius); + var arcOver = d3.svg.arc().outerRadius(arcRadius + 5); + + if (startAngle) { + arc.startAngle(startAngle); + arcOver.startAngle(startAngle); + } + if (endAngle) { + arc.endAngle(endAngle); + arcOver.endAngle(endAngle); + } + if (donut) { + arc.innerRadius(radius * donutRatio); + arcOver.innerRadius(radius * donutRatio); + } + + // Setup the Pie chart and choose the data element + var pie = d3.layout.pie() + .sort(null) + .value(function(d) { return d.disabled ? 0 : getY(d) }); + + // padAngle added in d3 3.5 + if (pie.padAngle && padAngle) { + pie.padAngle(padAngle); + } + + if (arc.cornerRadius && cornerRadius) { + arc.cornerRadius(cornerRadius); + arcOver.cornerRadius(cornerRadius); + } + + // if title is specified and donut, put it in the middle + if (donut && title) { + var title_g = g_pie.append('g').attr('class', 'nv-pie'); + + title_g.append("text") + .style("text-anchor", "middle") + .attr('class', 'nv-pie-title') + .text(function (d) { + return title; + }) + .attr("dy", "0.35em") // trick to vertically center text + .attr('transform', function(d, i) { + return 'translate(0, '+ titleOffset + ')'; + }); + } + + var slices = wrap.select('.nv-pie').selectAll('.nv-slice').data(pie); + var pieLabels = wrap.select('.nv-pieLabels').selectAll('.nv-label').data(pie); + + slices.exit().remove(); + pieLabels.exit().remove(); + + var ae = slices.enter().append('g') + ae.attr('class', 'nv-slice') + ae.on('mouseover', function(d,i){ + d3.select(this).classed('hover', true); + if (growOnHover) { + d3.select(this).select("path").transition() + .duration(70) + .attr("d", arcOver); + } + dispatch.elementMouseover({ + label: getX(d.data), + value: getY(d.data), + point: d.data, + pointIndex: i, + pos: [d3.event.pageX, d3.event.pageY], + id: id, + color: d3.select(this).style("fill") + }); + }); + ae.on('mouseout', function(d,i){ + d3.select(this).classed('hover', false); + if (growOnHover) { + d3.select(this).select("path").transition() + .duration(50) + .attr("d", arc); + } + dispatch.elementMouseout({ + label: getX(d.data), + value: getY(d.data), + point: d.data, + index: i, + id: id + }); + }); + + slices.attr('fill', function(d,i) { return color(d, i); }) + slices.attr('stroke', function(d,i) { return color(d, i); }); + + var paths = ae.append('path').each(function(d) { + this._current = d; + }); + + paths.on('click', function(d,i) { + dispatch.elementClick({ + label: getX(d.data), + value: getY(d.data), + point: d.data, + index: i, + pos: d3.event, + id: id + }); + d3.event.stopPropagation(); + }); + paths.on('dblclick', function(d,i) { + dispatch.elementDblClick({ + label: getX(d.data), + value: getY(d.data), + point: d.data, + index: i, + pos: d3.event, + id: id + }); + d3.event.stopPropagation(); + }); + slices.select('path') + .transition() + .attr('d', arc) + .attrTween('d', arcTween); + + if (showLabels) { + // This does the normal label + var labelsArc = d3.svg.arc().innerRadius(0); + + if (pieLabelsOutside){ + var labelsArc = arc; + } + + if (donutLabelsOutside) { + labelsArc = d3.svg.arc().outerRadius(arc.outerRadius()); + } + + pieLabels.enter().append("g").classed("nv-label",true).each(function(d,i) { + var group = d3.select(this); + + group.attr('transform', function(d) { + if (labelSunbeamLayout) { + d.outerRadius = arcRadius + 10; // Set Outer Coordinate + d.innerRadius = arcRadius + 15; // Set Inner Coordinate + var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI); + if ((d.startAngle+d.endAngle)/2 < Math.PI) { + rotateAngle -= 90; + } else { + rotateAngle += 90; + } + return 'translate(' + labelsArc.centroid(d) + ') rotate(' + rotateAngle + ')'; + } else { + d.outerRadius = radius + 10; // Set Outer Coordinate + d.innerRadius = radius + 15; // Set Inner Coordinate + return 'translate(' + labelsArc.centroid(d) + ')' + } + }); + + group.append('rect') + .style('stroke', '#fff') + .style('fill', '#fff') + .attr("rx", 3) + .attr("ry", 3); + + group.append('text') + .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned + .style('fill', '#000') + + }); + + var labelLocationHash = {}; + var avgHeight = 14; + var avgWidth = 140; + var createHashKey = function(coordinates) { + return Math.floor(coordinates[0]/avgWidth) * avgWidth + ',' + Math.floor(coordinates[1]/avgHeight) * avgHeight; + }; + + pieLabels.watchTransition(renderWatch,'pie labels').attr('transform', function(d) { + if (labelSunbeamLayout) { + d.outerRadius = arcRadius + 10; // Set Outer Coordinate + d.innerRadius = arcRadius + 15; // Set Inner Coordinate + var rotateAngle = (d.startAngle + d.endAngle) / 2 * (180 / Math.PI); + if ((d.startAngle+d.endAngle)/2 < Math.PI) { + rotateAngle -= 90; + } else { + rotateAngle += 90; + } + return 'translate(' + labelsArc.centroid(d) + ') rotate(' + rotateAngle + ')'; + } else { + d.outerRadius = radius + 10; // Set Outer Coordinate + d.innerRadius = radius + 15; // Set Inner Coordinate + + /* + Overlapping pie labels are not good. What this attempts to do is, prevent overlapping. + Each label location is hashed, and if a hash collision occurs, we assume an overlap. + Adjust the label's y-position to remove the overlap. + */ + var center = labelsArc.centroid(d); + if(d.value){ + var hashKey = createHashKey(center); + if (labelLocationHash[hashKey]) { + center[1] -= avgHeight; + } + labelLocationHash[createHashKey(center)] = true; + } + return 'translate(' + center + ')' + } + }); + + pieLabels.select(".nv-label text") + .style('text-anchor', labelSunbeamLayout ? ((d.startAngle + d.endAngle) / 2 < Math.PI ? 'start' : 'end') : 'middle') //center the text on it's origin or begin/end if orthogonal aligned + .text(function(d, i) { + var percent = (d.endAngle - d.startAngle) / (2 * Math.PI); + var labelTypes = { + "key" : getX(d.data), + "value": getY(d.data), + "percent": labelFormat(percent) + }; + return (d.value && percent > labelThreshold) ? labelTypes[labelType] : ''; + }) + ; + } + + + // Computes the angle of an arc, converting from radians to degrees. + function angle(d) { + var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90; + return a > 90 ? a - 180 : a; + } + + function arcTween(a) { + a.endAngle = isNaN(a.endAngle) ? 0 : a.endAngle; + a.startAngle = isNaN(a.startAngle) ? 0 : a.startAngle; + if (!donut) a.innerRadius = 0; + var i = d3.interpolate(this._current, a); + this._current = i(0); + return function(t) { + return arc(i(t)); + }; + } + }); + + renderWatch.renderEnd('pie immediate'); + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLabels: {get: function(){return showLabels;}, set: function(_){showLabels=_;}}, + title: {get: function(){return title;}, set: function(_){title=_;}}, + titleOffset: {get: function(){return titleOffset;}, set: function(_){titleOffset=_;}}, + labelThreshold: {get: function(){return labelThreshold;}, set: function(_){labelThreshold=_;}}, + labelFormat: {get: function(){return labelFormat;}, set: function(_){labelFormat=_;}}, + valueFormat: {get: function(){return valueFormat;}, set: function(_){valueFormat=_;}}, + x: {get: function(){return getX;}, set: function(_){getX=_;}}, + id: {get: function(){return id;}, set: function(_){id=_;}}, + endAngle: {get: function(){return endAngle;}, set: function(_){endAngle=_;}}, + startAngle: {get: function(){return startAngle;}, set: function(_){startAngle=_;}}, + padAngle: {get: function(){return padAngle;}, set: function(_){padAngle=_;}}, + cornerRadius: {get: function(){return cornerRadius;}, set: function(_){cornerRadius=_;}}, + donutRatio: {get: function(){return donutRatio;}, set: function(_){donutRatio=_;}}, + pieLabelsOutside: {get: function(){return pieLabelsOutside;}, set: function(_){pieLabelsOutside=_;}}, + donutLabelsOutside: {get: function(){return donutLabelsOutside;}, set: function(_){donutLabelsOutside=_;}}, + labelSunbeamLayout: {get: function(){return labelSunbeamLayout;}, set: function(_){labelSunbeamLayout=_;}}, + donut: {get: function(){return donut;}, set: function(_){donut=_;}}, + growOnHover: {get: function(){return growOnHover;}, set: function(_){growOnHover=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = typeof _.top != 'undefined' ? _.top : margin.top; + margin.right = typeof _.right != 'undefined' ? _.right : margin.right; + margin.bottom = typeof _.bottom != 'undefined' ? _.bottom : margin.bottom; + margin.left = typeof _.left != 'undefined' ? _.left : margin.left; + }}, + y: {get: function(){return getY;}, set: function(_){ + getY=d3.functor(_); + }}, + color: {get: function(){return color;}, set: function(_){ + color=nv.utils.getColor(_); + }}, + labelType: {get: function(){return labelType;}, set: function(_){ + labelType= _ || 'key'; + }} + }); + + nv.utils.initOptions(chart); + return chart; +}; +nv.models.pieChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var pie = nv.models.pie(); + var legend = nv.models.legend(); + + var margin = {top: 30, right: 20, bottom: 20, left: 20} + , width = null + , height = null + , showLegend = true + , color = nv.utils.defaultColor() + , tooltips = true + , tooltip = function(key, y, e, graph) { + return '

' + key + '

' + + '

' + y + '

'; + } + , state = nv.utils.state() + , defaultState = null + , noData = "No Data Available." + , duration = 250 + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState','renderEnd') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var showTooltip = function(e, offsetElement) { + var tooltipLabel = pie.x()(e.point); + var left = e.pos[0] + ( (offsetElement && offsetElement.offsetLeft) || 0 ), + top = e.pos[1] + ( (offsetElement && offsetElement.offsetTop) || 0), + y = pie.valueFormat()(pie.y()(e.point)), + content = tooltip(tooltipLabel, y, e, chart) + ; + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + var renderWatch = nv.utils.renderWatch(dispatch); + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }) + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.active !== undefined) { + data.forEach(function (series, i) { + series.disabled = !state.active[i]; + }); + } + } + }; + + //============================================================ + // Chart function + //------------------------------------------------------------ + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(pie); + + selection.each(function(data) { + var container = d3.select(this); + nv.utils.initSVG(container); + + var that = this; + var availableWidth = (width || parseInt(container.style('width'), 10) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height'), 10) || 400) + - margin.top - margin.bottom + ; + + chart.update = function() { container.transition().call(chart); }; + chart.container = this; + + state.setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + //set state.disabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display No Data message if there's nothing to show. + if (!data || !data.length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-pieChart').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-pieChart').append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-pieWrap'); + gEnter.append('g').attr('class', 'nv-legendWrap'); + + // Legend + if (showLegend) { + legend.width( availableWidth ).key(pie.x()); + + wrap.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + wrap.select('.nv-legendWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')'); + } + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + // Main Chart Component(s) + pie.width(availableWidth).height(availableHeight); + var pieWrap = g.select('.nv-pieWrap').datum([data]); + d3.transition(pieWrap).call(pie); + + // Event Handling/Dispatching (in chart's scope) + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) { + state[key] = newState[key]; + } + dispatch.stateChange(state); + chart.update(); + }); + + pie.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + state.disabled = e.disabled; + } + chart.update(); + }); + + }); + + renderWatch.renderEnd('pieChart immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + pie.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.legend = legend; + chart.dispatch = dispatch; + chart.pie = pie; + chart.options = nv.utils.optionsFunc.bind(chart); + + // use Object get/set functionality to map between vars and chart functions + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + // options that require extra logic in the setter + color: {get: function(){return color;}, set: function(_){ + color = _; + legend.color(color); + pie.color(color); + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + }} + }); + nv.utils.inheritOptions(chart, pie); + nv.utils.initOptions(chart); + return chart; +}; + +nv.models.scatter = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = null + , height = null + , color = nv.utils.defaultColor() // chooses color + , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't select one + , x = d3.scale.linear() + , y = d3.scale.linear() + , z = d3.scale.linear() //linear because d3.svg.shape.size is treated as area + , getX = function(d) { return d.x } // accessor to get the x value + , getY = function(d) { return d.y } // accessor to get the y value + , getSize = function(d) { return d.size || 1} // accessor to get the point size + , getShape = function(d) { return d.shape || 'circle' } // accessor to get point shape + , forceX = [] // List of numbers to Force into the X scale (ie. 0, or a max / min, etc.) + , forceY = [] // List of numbers to Force into the Y scale + , forceSize = [] // List of numbers to Force into the Size scale + , interactive = true // If true, plots a voronoi overlay for advanced point intersection + , pointActive = function(d) { return !d.notActive } // any points that return false will be filtered out + , padData = false // If true, adds half a data points width to front and back, for lining up a line chart with a bar chart + , padDataOuter = .1 //outerPadding to imitate ordinal scale outer padding + , clipEdge = false // if true, masks points within x and y scale + , clipVoronoi = true // if true, masks each point with a circle... can turn off to slightly increase performance + , clipRadius = function() { return 25 } // function to get the radius for voronoi point clips + , xDomain = null // Override x domain (skips the calculation from data) + , yDomain = null // Override y domain + , xRange = null // Override x range + , yRange = null // Override y range + , sizeDomain = null // Override point size domain + , sizeRange = null + , singlePoint = false + , dispatch = d3.dispatch('elementClick', 'elementDblClick', 'elementMouseover', 'elementMouseout', 'renderEnd') + , useVoronoi = true + , duration = 250 + ; + + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var x0, y0, z0 // used to store previous scales + , timeoutID + , needsUpdate = false // Flag for when the points are visually updating, but the interactive layer is behind, to disable tooltips + , renderWatch = nv.utils.renderWatch(dispatch, duration) + ; + + function chart(selection) { + renderWatch.reset(); + selection.each(function(data) { + var container = d3.select(this); + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right; + var availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + nv.utils.initSVG(container); + + //add series index to each data point for reference + data.forEach(function(series, i) { + series.values.forEach(function(point) { + point.series = i; + }); + }); + + // Setup Scales + // remap and flatten the data for use in calculating the scales' domains + var seriesData = (xDomain && yDomain && sizeDomain) ? [] : // if we know xDomain and yDomain and sizeDomain, no need to calculate.... if Size is constant remember to set sizeDomain to speed up performance + d3.merge( + data.map(function(d) { + return d.values.map(function(d,i) { + return { x: getX(d,i), y: getY(d,i), size: getSize(d,i) } + }) + }) + ); + + x .domain(xDomain || d3.extent(seriesData.map(function(d) { return d.x; }).concat(forceX))) + + if (padData && data[0]) + x.range(xRange || [(availableWidth * padDataOuter + availableWidth) / (2 *data[0].values.length), availableWidth - availableWidth * (1 + padDataOuter) / (2 * data[0].values.length) ]); + //x.range([availableWidth * .5 / data[0].values.length, availableWidth * (data[0].values.length - .5) / data[0].values.length ]); + else + x.range(xRange || [0, availableWidth]); + + y .domain(yDomain || d3.extent(seriesData.map(function(d) { return d.y }).concat(forceY))) + .range(yRange || [availableHeight, 0]); + + z .domain(sizeDomain || d3.extent(seriesData.map(function(d) { return d.size }).concat(forceSize))) + .range(sizeRange || [16, 256]); + + // If scale's domain don't have a range, slightly adjust to make one... so a chart can show a single data point + if (x.domain()[0] === x.domain()[1] || y.domain()[0] === y.domain()[1]) singlePoint = true; + if (x.domain()[0] === x.domain()[1]) + x.domain()[0] ? + x.domain([x.domain()[0] - x.domain()[0] * 0.01, x.domain()[1] + x.domain()[1] * 0.01]) + : x.domain([-1,1]); + + if (y.domain()[0] === y.domain()[1]) + y.domain()[0] ? + y.domain([y.domain()[0] - y.domain()[0] * 0.01, y.domain()[1] + y.domain()[1] * 0.01]) + : y.domain([-1,1]); + + if ( isNaN(x.domain()[0])) { + x.domain([-1,1]); + } + + if ( isNaN(y.domain()[0])) { + y.domain([-1,1]); + } + + x0 = x0 || x; + y0 = y0 || y; + z0 = z0 || z; + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-scatter').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatter nv-chart-' + id + (singlePoint ? ' nv-single-point' : '')); + var defsEnter = wrapEnter.append('defs'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-groups'); + gEnter.append('g').attr('class', 'nv-point-paths'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + defsEnter.append('clipPath') + .attr('id', 'nv-edge-clip-' + id) + .append('rect'); + + wrap.select('#nv-edge-clip-' + id + ' rect') + .attr('width', availableWidth) + .attr('height', (availableHeight > 0) ? availableHeight : 0); + + g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); + + function updateInteractiveLayer() { + + if (!interactive) return false; + + var eventElements; + + var vertices = d3.merge(data.map(function(group, groupIndex) { + return group.values + .map(function(point, pointIndex) { + // *Adding noise to make duplicates very unlikely + // *Injecting series and point index for reference + /* *Adding a 'jitter' to the points, because there's an issue in d3.geom.voronoi. + */ + var pX = getX(point,pointIndex); + var pY = getY(point,pointIndex); + + return [x(pX)+ Math.random() * 1e-7, + y(pY)+ Math.random() * 1e-7, + groupIndex, + pointIndex, point]; //temp hack to add noise untill I think of a better way so there are no duplicates + }) + .filter(function(pointArray, pointIndex) { + return pointActive(pointArray[4], pointIndex); // Issue #237.. move filter to after map, so pointIndex is correct! + }) + }) + ); + + //inject series and point index for reference into voronoi + if (useVoronoi === true) { + + if(vertices.length < 3) { + // Issue #283 - Adding 2 dummy points to the voronoi b/c voronoi requires min 3 points to work + vertices.push([x.range()[0] - 20, y.range()[0] - 20, null, null]); + vertices.push([x.range()[1] + 20, y.range()[1] + 20, null, null]); + vertices.push([x.range()[0] - 20, y.range()[0] + 20, null, null]); + vertices.push([x.range()[1] + 20, y.range()[1] - 20, null, null]); + } + + // keep voronoi sections from going more than 10 outside of graph + // to avoid overlap with other things like legend etc + var bounds = d3.geom.polygon([ + [-10,-10], + [-10,height + 10], + [width + 10,height + 10], + [width + 10,-10] + ]); + + var voronoi = d3.geom.voronoi(vertices).map(function(d, i) { + return { + 'data': bounds.clip(d), + 'series': vertices[i][2], + 'point': vertices[i][3] + } + }); + + // nuke all voronoi paths on reload and recreate them + wrap.select('.nv-point-paths').selectAll('path').remove(); + var pointPaths = wrap.select('.nv-point-paths').selectAll('path').data(voronoi); + pointPaths + .enter().append("svg:path") + .attr("d", function(d) { + if (!d || !d.data || d.data.length === 0) + return 'M 0 0'; + else + return "M" + d.data.join(",") + "Z"; + }) + .attr("id", function(d,i) { + return "nv-path-"+i; }) + .attr("clip-path", function(d,i) { return "url(#nv-clip-"+i+")"; }) + ; + // chain these to above to see the voronoi elements (good for debugging) + //.style("fill", d3.rgb(230, 230, 230)) + //.style('fill-opacity', 0.4) + //.style('stroke-opacity', 1) + //.style("stroke", d3.rgb(200,200,200)); + + if (clipVoronoi) { + // voronoi sections are already set to clip, + // just create the circles with the IDs they expect + var clips = wrap.append("svg:g").attr("id", "nv-point-clips"); + clips.selectAll("clipPath") + .data(vertices) + .enter().append("svg:clipPath") + .attr("id", function(d, i) { return "nv-clip-"+i;}) + .append("svg:circle") + .attr('cx', function(d) { return d[0]; }) + .attr('cy', function(d) { return d[1]; }) + .attr('r', clipRadius); + } + + var mouseEventCallback = function(d,mDispatch) { + if (needsUpdate) return 0; + var series = data[d.series]; + if (typeof series === 'undefined') return; + var point = series.values[d.point]; + + mDispatch({ + point: point, + series: series, + pos: [x(getX(point, d.point)) + margin.left, y(getY(point, d.point)) + margin.top], + seriesIndex: d.series, + pointIndex: d.point + }); + }; + + pointPaths + .on('click', function(d) { + mouseEventCallback(d, dispatch.elementClick); + }) + .on('dblclick', function(d) { + mouseEventCallback(d, dispatch.elementDblClick); + }) + .on('mouseover', function(d) { + mouseEventCallback(d, dispatch.elementMouseover); + }) + .on('mouseout', function(d, i) { + mouseEventCallback(d, dispatch.elementMouseout); + }); + + } else { + /* + // bring data in form needed for click handlers + var dataWithPoints = vertices.map(function(d, i) { + return { + 'data': d, + 'series': vertices[i][2], + 'point': vertices[i][3] + } + }); + */ + + // add event handlers to points instead voronoi paths + wrap.select('.nv-groups').selectAll('.nv-group') + .selectAll('.nv-point') + //.data(dataWithPoints) + //.style('pointer-events', 'auto') // recativate events, disabled by css + .on('click', function(d,i) { + //nv.log('test', d, i); + if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point + var series = data[d.series], + point = series.values[i]; + + dispatch.elementClick({ + point: point, + series: series, + pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], + seriesIndex: d.series, + pointIndex: i + }); + }) + .on('mouseover', function(d,i) { + if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point + var series = data[d.series], + point = series.values[i]; + + dispatch.elementMouseover({ + point: point, + series: series, + pos: [x(getX(point, i)) + margin.left, y(getY(point, i)) + margin.top], + seriesIndex: d.series, + pointIndex: i + }); + }) + .on('mouseout', function(d,i) { + if (needsUpdate || !data[d.series]) return 0; //check if this is a dummy point + var series = data[d.series], + point = series.values[i]; + + dispatch.elementMouseout({ + point: point, + series: series, + seriesIndex: d.series, + pointIndex: i + }); + }); + } + + needsUpdate = false; + } + + needsUpdate = true; + var groups = wrap.select('.nv-groups').selectAll('.nv-group') + .data(function(d) { return d }, function(d) { return d.key }); + groups.enter().append('g') + .style('stroke-opacity', 1e-6) + .style('fill-opacity', 1e-6); + groups.exit() + .remove(); + groups + .attr('class', function(d,i) { return 'nv-group nv-series-' + i }) + .classed('hover', function(d) { return d.hover }); + groups.watchTransition(renderWatch, 'scatter: groups') + .style('fill', function(d,i) { return color(d, i) }) + .style('stroke', function(d,i) { return color(d, i) }) + .style('stroke-opacity', 1) + .style('fill-opacity', .5); + + // create the points + var points = groups.selectAll('path.nv-point') + .data(function(d) { return d.values }); + points.enter().append('path') + .style('fill', function (d,i) { return d.color }) + .style('stroke', function (d,i) { return d.color }) + .attr('transform', function(d,i) { + return 'translate(' + x0(getX(d,i)) + ',' + y0(getY(d,i)) + ')' + }) + .attr('d', + nv.utils.symbol() + .type(getShape) + .size(function(d,i) { return z(getSize(d,i)) }) + ); + points.exit().remove(); + groups.exit().selectAll('path.nv-point') + .watchTransition(renderWatch, 'scatter exit') + .attr('transform', function(d,i) { + return 'translate(' + x(getX(d,i)) + ',' + y(getY(d,i)) + ')' + }) + .remove(); + points.each(function(d,i) { + d3.select(this) + .classed('nv-point', true) + .classed('nv-point-' + i, true) + .classed('hover',false) + ; + }); + points + .watchTransition(renderWatch, 'scatter points') + .attr('transform', function(d,i) { + //nv.log(d,i,getX(d,i), x(getX(d,i))); + return 'translate(' + x(getX(d,i)) + ',' + y(getY(d,i)) + ')' + }) + .attr('d', + nv.utils.symbol() + .type(getShape) + .size(function(d,i) { return z(getSize(d,i)) }) + ); + + // Delay updating the invisible interactive layer for smoother animation + clearTimeout(timeoutID); // stop repeat calls to updateInteractiveLayer + timeoutID = setTimeout(updateInteractiveLayer, 300); + //updateInteractiveLayer(); + + //store old scales for use in transitions on update + x0 = x.copy(); + y0 = y.copy(); + z0 = z.copy(); + + }); + renderWatch.renderEnd('scatter immediate'); + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + // utility function calls provided by this chart + chart._calls = new function() { + this.clearHighlights = function () { + d3.selectAll(".nv-chart-" + id + " .nv-point.hover").classed("hover", false); + return null; + }; + this.highlightPoint = function (seriesIndex, pointIndex, isHoverOver) { + d3.select(".nv-chart-" + id + " .nv-series-" + seriesIndex + " .nv-point-" + pointIndex) + .classed("hover", isHoverOver); + }; + }; + + // trigger calls from events too + dispatch.on('elementMouseover.point', function(d) { + if (interactive) chart._calls.highlightPoint(d.seriesIndex,d.pointIndex,true); + }); + + dispatch.on('elementMouseout.point', function(d) { + if (interactive) chart._calls.highlightPoint(d.seriesIndex,d.pointIndex,false); + }); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + xScale: {get: function(){return x;}, set: function(_){x=_;}}, + yScale: {get: function(){return y;}, set: function(_){y=_;}}, + pointScale: {get: function(){return z;}, set: function(_){z=_;}}, + xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}}, + yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}}, + pointDomain: {get: function(){return sizeDomain;}, set: function(_){sizeDomain=_;}}, + xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}}, + yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}}, + pointRange: {get: function(){return sizeRange;}, set: function(_){sizeRange=_;}}, + forceX: {get: function(){return forceX;}, set: function(_){forceX=_;}}, + forceY: {get: function(){return forceY;}, set: function(_){forceY=_;}}, + forcePoint: {get: function(){return forceSize;}, set: function(_){forceSize=_;}}, + interactive: {get: function(){return interactive;}, set: function(_){interactive=_;}}, + pointActive: {get: function(){return pointActive;}, set: function(_){pointActive=_;}}, + padDataOuter: {get: function(){return padDataOuter;}, set: function(_){padDataOuter=_;}}, + padData: {get: function(){return padData;}, set: function(_){padData=_;}}, + clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}}, + clipVoronoi: {get: function(){return clipVoronoi;}, set: function(_){clipVoronoi=_;}}, + clipRadius: {get: function(){return clipRadius;}, set: function(_){clipRadius=_;}}, + id: {get: function(){return id;}, set: function(_){id=_;}}, + + + // simple functor options + x: {get: function(){return getX;}, set: function(_){getX = d3.functor(_);}}, + y: {get: function(){return getY;}, set: function(_){getY = d3.functor(_);}}, + pointSize: {get: function(){return getSize;}, set: function(_){getSize = d3.functor(_);}}, + pointShape: {get: function(){return getShape;}, set: function(_){getShape = d3.functor(_);}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }}, + useVoronoi: {get: function(){return useVoronoi;}, set: function(_){ + useVoronoi = _; + if (useVoronoi === false) { + clipVoronoi = false; + } + }} + }); + + nv.utils.initOptions(chart); + return chart; +}; + +nv.models.scatterChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var scatter = nv.models.scatter() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend() + , distX = nv.models.distribution() + , distY = nv.models.distribution() + ; + + var margin = {top: 30, right: 20, bottom: 50, left: 75} + , width = null + , height = null + , color = nv.utils.defaultColor() + , x = scatter.xScale() + , y = scatter.yScale() + , showDistX = false + , showDistY = false + , showLegend = true + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , tooltips = true + , tooltipX = function(key, x, y) { return '' + x + '' } + , tooltipY = function(key, x, y) { return '' + y + '' } + , tooltip = function(key, x, y, date) { return '

' + key + '

' + + '

' + date + '

' } + , state = nv.utils.state() + , defaultState = null + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState', 'renderEnd') + , noData = "No Data Available." + , duration = 250 + ; + + scatter + .xScale(x) + .yScale(y) + ; + xAxis + .orient('bottom') + .tickPadding(10) + ; + yAxis + .orient((rightAlignYAxis) ? 'right' : 'left') + .tickPadding(10) + ; + distX + .axis('x') + ; + distY + .axis('y') + ; + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var x0, y0 + , renderWatch = nv.utils.renderWatch(dispatch, duration); + + var showTooltip = function(e, offsetElement) { + //TODO: make tooltip style an option between single or dual on axes (maybe on all charts with axes? + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + leftX = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + topX = y.range()[0] + margin.top + ( offsetElement.offsetTop || 0), + leftY = x.range()[0] + margin.left + ( offsetElement.offsetLeft || 0 ), + topY = e.pos[1] + ( offsetElement.offsetTop || 0), + xVal = xAxis.tickFormat()(scatter.x()(e.point, e.pointIndex)), + yVal = yAxis.tickFormat()(scatter.y()(e.point, e.pointIndex)); + + if( tooltipX != null ) + nv.tooltip.show([leftX, topX], tooltipX(e.series.key, xVal, yVal, e, chart), 'n', 1, offsetElement, 'x-nvtooltip'); + if( tooltipY != null ) + nv.tooltip.show([leftY, topY], tooltipY(e.series.key, xVal, yVal, e, chart), 'e', 1, offsetElement, 'y-nvtooltip'); + if( tooltip != null ) + nv.tooltip.show([left, top], tooltip(e.series.key, xVal, yVal, e.point.tooltip, e, chart), e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }) + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(scatter); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + if (showDistX) renderWatch.models(distX); + if (showDistY) renderWatch.models(distY); + + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + chart.update = function() { + if (duration === 0) + container.call(chart); + else + container.transition().duration(duration).call(chart); + }; + chart.container = this; + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disableddisabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display noData message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + renderWatch.renderEnd('scatter immediate'); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = scatter.xScale(); + y = scatter.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-scatterChart').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-scatterChart nv-chart-' + scatter.id()); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + // background for pointer events + gEnter.append('rect').attr('class', 'nvd3 nv-background').style("pointer-events","none"); + + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-scatterWrap'); + gEnter.append('g').attr('class', 'nv-regressionLinesWrap'); + gEnter.append('g').attr('class', 'nv-distWrap'); + gEnter.append('g').attr('class', 'nv-legendWrap'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } + + // Legend + if (showLegend) { + legend.width( availableWidth / 2 ); + + wrap.select('.nv-legendWrap') + .datum(data) + .call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + wrap.select('.nv-legendWrap') + .attr('transform', 'translate(' + (availableWidth / 2) + ',' + (-margin.top) +')'); + } + + // Main Chart Component(s) + scatter + .width(availableWidth) + .height(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled })); + + wrap.select('.nv-scatterWrap') + .datum(data.filter(function(d) { return !d.disabled })) + .call(scatter); + + + wrap.select('.nv-regressionLinesWrap') + .attr('clip-path', 'url(#nv-edge-clip-' + scatter.id() + ')'); + + var regWrap = wrap.select('.nv-regressionLinesWrap').selectAll('.nv-regLines') + .data(function (d) { + return d; + }); + + regWrap.enter().append('g').attr('class', 'nv-regLines'); + + var regLine = regWrap.selectAll('.nv-regLine') + .data(function (d) { + return [d] + }); + + regLine.enter() + .append('line').attr('class', 'nv-regLine') + .style('stroke-opacity', 0); + + // don't add lines unless we have slope and intercept to use + regLine.filter(function(d) { + return d.intercept && d.slope; + }) + .watchTransition(renderWatch, 'scatterPlusLineChart: regline') + .attr('x1', x.range()[0]) + .attr('x2', x.range()[1]) + .attr('y1', function (d, i) { + return y(x.domain()[0] * d.slope + d.intercept) + }) + .attr('y2', function (d, i) { + return y(x.domain()[1] * d.slope + d.intercept) + }) + .style('stroke', function (d, i, j) { + return color(d, j) + }) + .style('stroke-opacity', function (d, i) { + return (d.disabled || typeof d.slope === 'undefined' || typeof d.intercept === 'undefined') ? 0 : 1 + }); + + // Setup Axes + if (showXAxis) { + xAxis + .scale(x) + .ticks( xAxis.ticks() ? xAxis.ticks() : nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize( -availableHeight , 0); + + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + y.range()[0] + ')') + .call(xAxis); + } + + if (showYAxis) { + yAxis + .scale(y) + .ticks( yAxis.ticks() ? yAxis.ticks() : nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize( -availableWidth, 0); + + g.select('.nv-y.nv-axis') + .call(yAxis); + } + + + if (showDistX) { + distX + .getData(scatter.x()) + .scale(x) + .width(availableWidth) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled })); + gEnter.select('.nv-distWrap').append('g') + .attr('class', 'nv-distributionX'); + g.select('.nv-distributionX') + .attr('transform', 'translate(0,' + y.range()[0] + ')') + .datum(data.filter(function(d) { return !d.disabled })) + .call(distX); + } + + if (showDistY) { + distY + .getData(scatter.y()) + .scale(y) + .width(availableHeight) + .color(data.map(function(d,i) { + return d.color || color(d, i); + }).filter(function(d,i) { return !data[i].disabled })); + gEnter.select('.nv-distWrap').append('g') + .attr('class', 'nv-distributionY'); + g.select('.nv-distributionY') + .attr('transform', 'translate(' + (rightAlignYAxis ? availableWidth : -distY.size() ) + ',0)') + .datum(data.filter(function(d) { return !d.disabled })) + .call(distY); + } + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + + scatter.dispatch.on('elementMouseover.tooltip', function(e) { + d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) + .attr('y1', e.pos[1] - availableHeight); + d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) + .attr('x2', e.pos[0] + distX.size()); + + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + + if (typeof e.disabled !== 'undefined') { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + + state.disabled = e.disabled; + } + + chart.update(); + }); + + //store old scales for use in transitions on update + x0 = x.copy(); + y0 = y.copy(); + + }); + + renderWatch.renderEnd('scatter with line immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + scatter.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + + d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-distx-' + e.pointIndex) + .attr('y1', 0); + d3.select('.nv-chart-' + scatter.id() + ' .nv-series-' + e.seriesIndex + ' .nv-disty-' + e.pointIndex) + .attr('x2', distY.size()); + }); + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.scatter = scatter; + chart.legend = legend; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.distX = distX; + chart.distY = distY; + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showDistX: {get: function(){return showDistX;}, set: function(_){showDistX=_;}}, + showDistY: {get: function(){return showDistY;}, set: function(_){showDistY=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + tooltipXContent: {get: function(){return tooltipX;}, set: function(_){tooltipX=_;}}, + tooltipYContent: {get: function(){return tooltipY;}, set: function(_){tooltipY=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + duration: {get: function(){return duration;}, set: function(_){duration=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){ + rightAlignYAxis = _; + yAxis.orient( (_) ? 'right' : 'left'); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + distX.color(color); + distY.color(color); + }} + }); + + nv.utils.inheritOptions(chart, scatter); + nv.utils.initOptions(chart); + return chart; +}; + +nv.models.sparkline = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 2, right: 0, bottom: 2, left: 0} + , width = 400 + , height = 32 + , animate = true + , x = d3.scale.linear() + , y = d3.scale.linear() + , getX = function(d) { return d.x } + , getY = function(d) { return d.y } + , color = nv.utils.getColor(['#000']) + , xDomain + , yDomain + , xRange + , yRange + ; + + function chart(selection) { + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + container = d3.select(this); + nv.utils.initSVG(container); + + // Setup Scales + x .domain(xDomain || d3.extent(data, getX )) + .range(xRange || [0, availableWidth]); + + y .domain(yDomain || d3.extent(data, getY )) + .range(yRange || [availableHeight, 0]); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-sparkline').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparkline'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')') + + var paths = wrap.selectAll('path') + .data(function(d) { return [d] }); + paths.enter().append('path'); + paths.exit().remove(); + paths + .style('stroke', function(d,i) { return d.color || color(d, i) }) + .attr('d', d3.svg.line() + .x(function(d,i) { return x(getX(d,i)) }) + .y(function(d,i) { return y(getY(d,i)) }) + ); + + // TODO: Add CURRENT data point (Need Min, Mac, Current / Most recent) + var points = wrap.selectAll('circle.nv-point') + .data(function(data) { + var yValues = data.map(function(d, i) { return getY(d,i); }); + function pointIndex(index) { + if (index != -1) { + var result = data[index]; + result.pointIndex = index; + return result; + } else { + return null; + } + } + var maxPoint = pointIndex(yValues.lastIndexOf(y.domain()[1])), + minPoint = pointIndex(yValues.indexOf(y.domain()[0])), + currentPoint = pointIndex(yValues.length - 1); + return [minPoint, maxPoint, currentPoint].filter(function (d) {return d != null;}); + }); + points.enter().append('circle'); + points.exit().remove(); + points + .attr('cx', function(d,i) { return x(getX(d,d.pointIndex)) }) + .attr('cy', function(d,i) { return y(getY(d,d.pointIndex)) }) + .attr('r', 2) + .attr('class', function(d,i) { + return getX(d, d.pointIndex) == x.domain()[1] ? 'nv-point nv-currentValue' : + getY(d, d.pointIndex) == y.domain()[0] ? 'nv-point nv-minValue' : 'nv-point nv-maxValue' + }); + }); + + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + xDomain: {get: function(){return xDomain;}, set: function(_){xDomain=_;}}, + yDomain: {get: function(){return yDomain;}, set: function(_){yDomain=_;}}, + xRange: {get: function(){return xRange;}, set: function(_){xRange=_;}}, + yRange: {get: function(){return yRange;}, set: function(_){yRange=_;}}, + xScale: {get: function(){return x;}, set: function(_){x=_;}}, + yScale: {get: function(){return y;}, set: function(_){y=_;}}, + animate: {get: function(){return animate;}, set: function(_){animate=_;}}, + + //functor options + x: {get: function(){return getX;}, set: function(_){getX=d3.functor(_);}}, + y: {get: function(){return getY;}, set: function(_){getY=d3.functor(_);}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }} + }); + + nv.utils.initOptions(chart); + return chart; +}; + +nv.models.sparklinePlus = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var sparkline = nv.models.sparkline(); + + var margin = {top: 15, right: 100, bottom: 10, left: 50} + , width = null + , height = null + , x + , y + , index = [] + , paused = false + , xTickFormat = d3.format(',r') + , yTickFormat = d3.format(',.2f') + , showValue = true + , alignValue = true + , rightAlignValue = false + , noData = "No Data Available." + ; + + function chart(selection) { + selection.each(function(data) { + var container = d3.select(this); + nv.utils.initSVG(container); + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + chart.update = function() { chart(selection) }; + chart.container = this; + + // Display No Data message if there's nothing to show. + if (!data || !data.length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + var currentValue = sparkline.y()(data[data.length-1], data.length-1); + + // Setup Scales + x = sparkline.xScale(); + y = sparkline.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-sparklineplus').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-sparklineplus'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-sparklineWrap'); + gEnter.append('g').attr('class', 'nv-valueWrap'); + gEnter.append('g').attr('class', 'nv-hoverArea'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + // Main Chart Component(s) + var sparklineWrap = g.select('.nv-sparklineWrap'); + + sparkline.width(availableWidth).height(availableHeight); + sparklineWrap.call(sparkline); + + var valueWrap = g.select('.nv-valueWrap'); + var value = valueWrap.selectAll('.nv-currentValue') + .data([currentValue]); + + value.enter().append('text').attr('class', 'nv-currentValue') + .attr('dx', rightAlignValue ? -8 : 8) + .attr('dy', '.9em') + .style('text-anchor', rightAlignValue ? 'end' : 'start'); + + value + .attr('x', availableWidth + (rightAlignValue ? margin.right : 0)) + .attr('y', alignValue ? function(d) { return y(d) } : 0) + .style('fill', sparkline.color()(data[data.length-1], data.length-1)) + .text(yTickFormat(currentValue)); + + gEnter.select('.nv-hoverArea').append('rect') + .on('mousemove', sparklineHover) + .on('click', function() { paused = !paused }) + .on('mouseout', function() { index = []; updateValueLine(); }); + + g.select('.nv-hoverArea rect') + .attr('transform', function(d) { return 'translate(' + -margin.left + ',' + -margin.top + ')' }) + .attr('width', availableWidth + margin.left + margin.right) + .attr('height', availableHeight + margin.top); + + //index is currently global (within the chart), may or may not keep it that way + function updateValueLine() { + if (paused) return; + + var hoverValue = g.selectAll('.nv-hoverValue').data(index) + + var hoverEnter = hoverValue.enter() + .append('g').attr('class', 'nv-hoverValue') + .style('stroke-opacity', 0) + .style('fill-opacity', 0); + + hoverValue.exit() + .transition().duration(250) + .style('stroke-opacity', 0) + .style('fill-opacity', 0) + .remove(); + + hoverValue + .attr('transform', function(d) { return 'translate(' + x(sparkline.x()(data[d],d)) + ',0)' }) + .transition().duration(250) + .style('stroke-opacity', 1) + .style('fill-opacity', 1); + + if (!index.length) return; + + hoverEnter.append('line') + .attr('x1', 0) + .attr('y1', -margin.top) + .attr('x2', 0) + .attr('y2', availableHeight); + + hoverEnter.append('text').attr('class', 'nv-xValue') + .attr('x', -6) + .attr('y', -margin.top) + .attr('text-anchor', 'end') + .attr('dy', '.9em') + + g.select('.nv-hoverValue .nv-xValue') + .text(xTickFormat(sparkline.x()(data[index[0]], index[0]))); + + hoverEnter.append('text').attr('class', 'nv-yValue') + .attr('x', 6) + .attr('y', -margin.top) + .attr('text-anchor', 'start') + .attr('dy', '.9em') + + g.select('.nv-hoverValue .nv-yValue') + .text(yTickFormat(sparkline.y()(data[index[0]], index[0]))); + } + + function sparklineHover() { + if (paused) return; + + var pos = d3.mouse(this)[0] - margin.left; + + function getClosestIndex(data, x) { + var distance = Math.abs(sparkline.x()(data[0], 0) - x); + var closestIndex = 0; + for (var i = 0; i < data.length; i++){ + if (Math.abs(sparkline.x()(data[i], i) - x) < distance) { + distance = Math.abs(sparkline.x()(data[i], i) - x); + closestIndex = i; + } + } + return closestIndex; + } + + index = [getClosestIndex(data, Math.round(x.invert(pos)))]; + updateValueLine(); + } + + }); + + return chart; + } + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.sparkline = sparkline; + + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + xTickFormat: {get: function(){return xTickFormat;}, set: function(_){xTickFormat=_;}}, + yTickFormat: {get: function(){return yTickFormat;}, set: function(_){yTickFormat=_;}}, + showValue: {get: function(){return showValue;}, set: function(_){showValue=_;}}, + alignValue: {get: function(){return alignValue;}, set: function(_){alignValue=_;}}, + rightAlignValue: {get: function(){return rightAlignValue;}, set: function(_){rightAlignValue=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }} + }); + + nv.utils.inheritOptions(chart, sparkline); + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.stackedArea = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var margin = {top: 0, right: 0, bottom: 0, left: 0} + , width = 960 + , height = 500 + , color = nv.utils.defaultColor() // a function that computes the color + , id = Math.floor(Math.random() * 100000) //Create semi-unique ID incase user doesn't selet one + , getX = function(d) { return d.x } // accessor to get the x value from a data point + , getY = function(d) { return d.y } // accessor to get the y value from a data point + , style = 'stack' + , offset = 'zero' + , order = 'default' + , interpolate = 'linear' // controls the line interpolation + , clipEdge = false // if true, masks lines within x and y scale + , x //can be accessed via chart.xScale() + , y //can be accessed via chart.yScale() + , scatter = nv.models.scatter() + , duration = 250 + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'areaClick', 'areaMouseover', 'areaMouseout','renderEnd') + ; + + // scatter is interactive by default, but this chart isn't so must disable + scatter.interactive(false); + + scatter + .pointSize(2.2) // default size + .pointDomain([2.2, 2.2]) // all the same size by default + ; + + /************************************ + * offset: + * 'wiggle' (stream) + * 'zero' (stacked) + * 'expand' (normalize to 100%) + * 'silhouette' (simple centered) + * + * order: + * 'inside-out' (stream) + * 'default' (input order) + ************************************/ + + var renderWatch = nv.utils.renderWatch(dispatch, duration); + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(scatter); + selection.each(function(data) { + var availableWidth = width - margin.left - margin.right, + availableHeight = height - margin.top - margin.bottom, + container = d3.select(this); + nv.utils.initSVG(container); + + // Setup Scales + x = scatter.xScale(); + y = scatter.yScale(); + + var dataRaw = data; + // Injecting point index into each point because d3.layout.stack().out does not give index + data.forEach(function(aseries, i) { + aseries.seriesIndex = i; + aseries.values = aseries.values.map(function(d, j) { + d.index = j; + d.seriesIndex = i; + return d; + }); + }); + + var dataFiltered = data.filter(function(series) { + return !series.disabled; + }); + + data = d3.layout.stack() + .order(order) + .offset(offset) + .values(function(d) { return d.values }) //TODO: make values customizeable in EVERY model in this fashion + .x(getX) + .y(getY) + .out(function(d, y0, y) { + var yHeight = (getY(d) === 0) ? 0 : y; + d.display = { + y: yHeight, + y0: y0 + }; + }) + (dataFiltered); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-stackedarea').data([data]); + var wrapEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedarea'); + var defsEnter = wrapEnter.append('defs'); + var gEnter = wrapEnter.append('g'); + var g = wrap.select('g'); + + gEnter.append('g').attr('class', 'nv-areaWrap'); + gEnter.append('g').attr('class', 'nv-scatterWrap'); + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + scatter + .width(availableWidth) + .height(availableHeight) + .x(getX) + .y(function(d) { return d.display.y + d.display.y0 }) + .forceY([0]) + .color(data.map(function(d,i) { + return d.color || color(d, d.seriesIndex); + })); + + var scatterWrap = g.select('.nv-scatterWrap') + .datum(data); + + scatterWrap.call(scatter); + + defsEnter.append('clipPath') + .attr('id', 'nv-edge-clip-' + id) + .append('rect'); + + wrap.select('#nv-edge-clip-' + id + ' rect') + .attr('width', availableWidth) + .attr('height', availableHeight); + + g.attr('clip-path', clipEdge ? 'url(#nv-edge-clip-' + id + ')' : ''); + + var area = d3.svg.area() + .x(function(d,i) { return x(getX(d,i)) }) + .y0(function(d) { + return y(d.display.y0) + }) + .y1(function(d) { + return y(d.display.y + d.display.y0) + }) + .interpolate(interpolate); + + var zeroArea = d3.svg.area() + .x(function(d,i) { return x(getX(d,i)) }) + .y0(function(d) { return y(d.display.y0) }) + .y1(function(d) { return y(d.display.y0) }); + + var path = g.select('.nv-areaWrap').selectAll('path.nv-area') + .data(function(d) { return d }); + + path.enter().append('path').attr('class', function(d,i) { return 'nv-area nv-area-' + i }) + .attr('d', function(d,i){ + return zeroArea(d.values, d.seriesIndex); + }) + .on('mouseover', function(d,i) { + d3.select(this).classed('hover', true); + dispatch.areaMouseover({ + point: d, + series: d.key, + pos: [d3.event.pageX, d3.event.pageY], + seriesIndex: d.seriesIndex + }); + }) + .on('mouseout', function(d,i) { + d3.select(this).classed('hover', false); + dispatch.areaMouseout({ + point: d, + series: d.key, + pos: [d3.event.pageX, d3.event.pageY], + seriesIndex: d.seriesIndex + }); + }) + .on('click', function(d,i) { + d3.select(this).classed('hover', false); + dispatch.areaClick({ + point: d, + series: d.key, + pos: [d3.event.pageX, d3.event.pageY], + seriesIndex: d.seriesIndex + }); + }); + + path.exit().remove(); + path.style('fill', function(d,i){ + return d.color || color(d, d.seriesIndex) + }) + .style('stroke', function(d,i){ return d.color || color(d, d.seriesIndex) }); + path.watchTransition(renderWatch,'stackedArea path') + .attr('d', function(d,i) { + return area(d.values,i) + }); + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + scatter.dispatch.on('elementMouseover.area', function(e) { + g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', true); + }); + scatter.dispatch.on('elementMouseout.area', function(e) { + g.select('.nv-chart-' + id + ' .nv-area-' + e.seriesIndex).classed('hover', false); + }); + + //Special offset functions + chart.d3_stackedOffset_stackPercent = function(stackData) { + var n = stackData.length, //How many series + m = stackData[0].length, //how many points per series + k = 1 / n, + i, + j, + o, + y0 = []; + + for (j = 0; j < m; ++j) { //Looping through all points + for (i = 0, o = 0; i < dataRaw.length; i++) { //looping through series' + o += getY(dataRaw[i].values[j]); //total value of all points at a certian point in time. + } + + if (o) for (i = 0; i < n; i++) { + stackData[i][j][1] /= o; + } else { + for (i = 0; i < n; i++) { + stackData[i][j][1] = k; + } + } + } + for (j = 0; j < m; ++j) y0[j] = 0; + return y0; + }; + + }); + + renderWatch.renderEnd('stackedArea immediate'); + return chart; + } + + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + scatter.dispatch.on('elementClick.area', function(e) { + dispatch.areaClick(e); + }); + scatter.dispatch.on('elementMouseover.tooltip', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top], + dispatch.tooltipShow(e); + }); + scatter.dispatch.on('elementMouseout.tooltip', function(e) { + dispatch.tooltipHide(e); + }); + + //============================================================ + // Global getters and setters + //------------------------------------------------------------ + + chart.dispatch = dispatch; + chart.scatter = scatter; + + chart.interpolate = function(_) { + if (!arguments.length) return interpolate; + interpolate = _; + return chart; + }; + + chart.duration = function(_) { + if (!arguments.length) return duration; + duration = _; + renderWatch.reset(duration); + scatter.duration(duration); + return chart; + }; + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + clipEdge: {get: function(){return clipEdge;}, set: function(_){clipEdge=_;}}, + offset: {get: function(){return offset;}, set: function(_){offset=_;}}, + order: {get: function(){return order;}, set: function(_){order=_;}}, + interpolate: {get: function(){return interpolate;}, set: function(_){interpolate=_;}}, + + // simple functor options + x: {get: function(){return getX;}, set: function(_){getX = d3.functor(_);}}, + y: {get: function(){return getY;}, set: function(_){getY = d3.functor(_);}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + }}, + style: {get: function(){return style;}, set: function(_){ + style = _; + switch (style) { + case 'stack': + chart.offset('zero'); + chart.order('default'); + break; + case 'stream': + chart.offset('wiggle'); + chart.order('inside-out'); + break; + case 'stream-center': + chart.offset('silhouette'); + chart.order('inside-out'); + break; + case 'expand': + chart.offset('expand'); + chart.order('default'); + break; + case 'stack_percent': + chart.offset(chart.d3_stackedOffset_stackPercent); + chart.order('default'); + break; + } + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + scatter.duration(duration); + }} + }); + + nv.utils.inheritOptions(chart, scatter); + nv.utils.initOptions(chart); + + return chart; +}; + +nv.models.stackedAreaChart = function() { + "use strict"; + + //============================================================ + // Public Variables with Default Settings + //------------------------------------------------------------ + + var stacked = nv.models.stackedArea() + , xAxis = nv.models.axis() + , yAxis = nv.models.axis() + , legend = nv.models.legend() + , controls = nv.models.legend() + , interactiveLayer = nv.interactiveGuideline() + ; + + var margin = {top: 30, right: 25, bottom: 50, left: 60} + , width = null + , height = null + , color = nv.utils.defaultColor() + , showControls = true + , showLegend = true + , showXAxis = true + , showYAxis = true + , rightAlignYAxis = false + , useInteractiveGuideline = false + , tooltips = true + , tooltip = function(key, x, y, e, graph) { + return '

' + key + '

' + + '

' + y + ' on ' + x + '

' + } + , x //can be accessed via chart.xScale() + , y //can be accessed via chart.yScale() + , yAxisTickFormat = d3.format(',.2f') + , state = nv.utils.state() + , defaultState = null + , noData = 'No Data Available.' + , dispatch = d3.dispatch('tooltipShow', 'tooltipHide', 'stateChange', 'changeState','renderEnd') + , controlWidth = 250 + , cData = ['Stacked','Stream','Expanded'] + , controlLabels = {} + , duration = 250 + ; + + state.style = stacked.style(); + xAxis.orient('bottom').tickPadding(7); + yAxis.orient((rightAlignYAxis) ? 'right' : 'left'); + + controls.updateState(false); + + //============================================================ + // Private Variables + //------------------------------------------------------------ + + var renderWatch = nv.utils.renderWatch(dispatch); + var style = stacked.style(); + + var showTooltip = function(e, offsetElement) { + var left = e.pos[0] + ( offsetElement.offsetLeft || 0 ), + top = e.pos[1] + ( offsetElement.offsetTop || 0), + x = xAxis.tickFormat()(stacked.x()(e.point, e.pointIndex)), + y = yAxis.tickFormat()(stacked.y()(e.point, e.pointIndex)), + content = tooltip(e.series.key, x, y, e, chart); + + nv.tooltip.show([left, top], content, e.value < 0 ? 'n' : 's', null, offsetElement); + }; + + var stateGetter = function(data) { + return function(){ + return { + active: data.map(function(d) { return !d.disabled }), + style: stacked.style() + }; + } + }; + + var stateSetter = function(data) { + return function(state) { + if (state.style !== undefined) + style = state.style; + if (state.active !== undefined) + data.forEach(function(series,i) { + series.disabled = !state.active[i]; + }); + } + }; + + function chart(selection) { + renderWatch.reset(); + renderWatch.models(stacked); + if (showXAxis) renderWatch.models(xAxis); + if (showYAxis) renderWatch.models(yAxis); + + selection.each(function(data) { + var container = d3.select(this), + that = this; + nv.utils.initSVG(container); + + var availableWidth = (width || parseInt(container.style('width')) || 960) + - margin.left - margin.right, + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + + chart.update = function() { container.transition().duration(duration).call(chart); }; + chart.container = this; + + state + .setter(stateSetter(data), chart.update) + .getter(stateGetter(data)) + .update(); + + // DEPRECATED set state.disabled + state.disabled = data.map(function(d) { return !!d.disabled }); + + if (!defaultState) { + var key; + defaultState = {}; + for (key in state) { + if (state[key] instanceof Array) + defaultState[key] = state[key].slice(0); + else + defaultState[key] = state[key]; + } + } + + // Display No Data message if there's nothing to show. + if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) { + var noDataText = container.selectAll('.nv-noData').data([noData]); + + noDataText.enter().append('text') + .attr('class', 'nvd3 nv-noData') + .attr('dy', '-.7em') + .style('text-anchor', 'middle'); + + noDataText + .attr('x', margin.left + availableWidth / 2) + .attr('y', margin.top + availableHeight / 2) + .text(function(d) { return d }); + + return chart; + } else { + container.selectAll('.nv-noData').remove(); + } + + // Setup Scales + x = stacked.xScale(); + y = stacked.yScale(); + + // Setup containers and skeleton of chart + var wrap = container.selectAll('g.nv-wrap.nv-stackedAreaChart').data([data]); + var gEnter = wrap.enter().append('g').attr('class', 'nvd3 nv-wrap nv-stackedAreaChart').append('g'); + var g = wrap.select('g'); + + gEnter.append("rect").style("opacity",0); + gEnter.append('g').attr('class', 'nv-x nv-axis'); + gEnter.append('g').attr('class', 'nv-y nv-axis'); + gEnter.append('g').attr('class', 'nv-stackedWrap'); + gEnter.append('g').attr('class', 'nv-legendWrap'); + gEnter.append('g').attr('class', 'nv-controlsWrap'); + gEnter.append('g').attr('class', 'nv-interactive'); + + g.select("rect").attr("width",availableWidth).attr("height",availableHeight); + + // Legend + if (showLegend) { + var legendWidth = (showControls) ? availableWidth - controlWidth : availableWidth; + + legend.width(legendWidth); + g.select('.nv-legendWrap').datum(data).call(legend); + + if ( margin.top != legend.height()) { + margin.top = legend.height(); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + g.select('.nv-legendWrap') + .attr('transform', 'translate(' + (availableWidth-legendWidth) + ',' + (-margin.top) +')'); + } + + // Controls + if (showControls) { + var controlsData = [ + { + key: controlLabels.stacked || 'Stacked', + metaKey: 'Stacked', + disabled: stacked.style() != 'stack', + style: 'stack' + }, + { + key: controlLabels.stream || 'Stream', + metaKey: 'Stream', + disabled: stacked.style() != 'stream', + style: 'stream' + }, + { + key: controlLabels.expanded || 'Expanded', + metaKey: 'Expanded', + disabled: stacked.style() != 'expand', + style: 'expand' + }, + { + key: controlLabels.stack_percent || 'Stack %', + metaKey: 'Stack_Percent', + disabled: stacked.style() != 'stack_percent', + style: 'stack_percent' + } + ]; + + controlWidth = (cData.length/3) * 260; + controlsData = controlsData.filter(function(d) { + return cData.indexOf(d.metaKey) !== -1; + }); + + controls + .width( controlWidth ) + .color(['#444', '#444', '#444']); + + g.select('.nv-controlsWrap') + .datum(controlsData) + .call(controls); + + if ( margin.top != Math.max(controls.height(), legend.height()) ) { + margin.top = Math.max(controls.height(), legend.height()); + availableHeight = (height || parseInt(container.style('height')) || 400) + - margin.top - margin.bottom; + } + + g.select('.nv-controlsWrap') + .attr('transform', 'translate(0,' + (-margin.top) +')'); + } + + wrap.attr('transform', 'translate(' + margin.left + ',' + margin.top + ')'); + + if (rightAlignYAxis) { + g.select(".nv-y.nv-axis") + .attr("transform", "translate(" + availableWidth + ",0)"); + } + + //Set up interactive layer + if (useInteractiveGuideline) { + interactiveLayer + .width(availableWidth) + .height(availableHeight) + .margin({left: margin.left, top: margin.top}) + .svgContainer(container) + .xScale(x); + wrap.select(".nv-interactive").call(interactiveLayer); + } + + stacked + .width(availableWidth) + .height(availableHeight); + + var stackedWrap = g.select('.nv-stackedWrap') + .datum(data); + + stackedWrap.transition().call(stacked); + + // Setup Axes + if (showXAxis) { + xAxis.scale(x) + .ticks( nv.utils.calcTicksX(availableWidth/100, data) ) + .tickSize( -availableHeight, 0); + + g.select('.nv-x.nv-axis') + .attr('transform', 'translate(0,' + availableHeight + ')'); + + g.select('.nv-x.nv-axis') + .transition().duration(0) + .call(xAxis); + } + + if (showYAxis) { + yAxis.scale(y) + .ticks(stacked.offset() == 'wiggle' ? 0 : nv.utils.calcTicksY(availableHeight/36, data) ) + .tickSize(-availableWidth, 0) + .setTickFormat( (stacked.style() == 'expand' || stacked.style() == 'stack_percent') + ? d3.format('%') : yAxisTickFormat); + + g.select('.nv-y.nv-axis') + .transition().duration(0) + .call(yAxis); + } + + //============================================================ + // Event Handling/Dispatching (in chart's scope) + //------------------------------------------------------------ + + stacked.dispatch.on('areaClick.toggle', function(e) { + if (data.filter(function(d) { return !d.disabled }).length === 1) + data.forEach(function(d) { + d.disabled = false; + }); + else + data.forEach(function(d,i) { + d.disabled = (i != e.seriesIndex); + }); + + state.disabled = data.map(function(d) { return !!d.disabled }); + dispatch.stateChange(state); + + chart.update(); + }); + + legend.dispatch.on('stateChange', function(newState) { + for (var key in newState) + state[key] = newState[key]; + dispatch.stateChange(state); + chart.update(); + }); + + controls.dispatch.on('legendClick', function(d,i) { + if (!d.disabled) return; + + controlsData = controlsData.map(function(s) { + s.disabled = true; + return s; + }); + d.disabled = false; + + stacked.style(d.style); + + + state.style = stacked.style(); + dispatch.stateChange(state); + + chart.update(); + }); + + interactiveLayer.dispatch.on('elementMousemove', function(e) { + stacked.clearHighlights(); + var singlePoint, pointIndex, pointXLocation, allData = []; + data + .filter(function(series, i) { + series.seriesIndex = i; + return !series.disabled; + }) + .forEach(function(series,i) { + pointIndex = nv.interactiveBisect(series.values, e.pointXValue, chart.x()); + stacked.highlightPoint(i, pointIndex, true); + var point = series.values[pointIndex]; + if (typeof point === 'undefined') return; + if (typeof singlePoint === 'undefined') singlePoint = point; + if (typeof pointXLocation === 'undefined') pointXLocation = chart.xScale()(chart.x()(point,pointIndex)); + + //If we are in 'expand' mode, use the stacked percent value instead of raw value. + var tooltipValue = (stacked.style() == 'expand') ? point.display.y : chart.y()(point,pointIndex); + allData.push({ + key: series.key, + value: tooltipValue, + color: color(series,series.seriesIndex), + stackedValue: point.display + }); + }); + + allData.reverse(); + + //Highlight the tooltip entry based on which stack the mouse is closest to. + if (allData.length > 2) { + var yValue = chart.yScale().invert(e.mouseY); + var yDistMax = Infinity, indexToHighlight = null; + allData.forEach(function(series,i) { + + //To handle situation where the stacked area chart is negative, we need to use absolute values + //when checking if the mouse Y value is within the stack area. + yValue = Math.abs(yValue); + var stackedY0 = Math.abs(series.stackedValue.y0); + var stackedY = Math.abs(series.stackedValue.y); + if ( yValue >= stackedY0 && yValue <= (stackedY + stackedY0)) + { + indexToHighlight = i; + return; + } + }); + if (indexToHighlight != null) + allData[indexToHighlight].highlight = true; + } + + var xValue = xAxis.tickFormat()(chart.x()(singlePoint,pointIndex)); + + //If we are in 'expand' mode, force the format to be a percentage. + var valueFormatter = (stacked.style() == 'expand') ? + function(d,i) {return d3.format(".1%")(d);} : + function(d,i) {return yAxis.tickFormat()(d); }; + interactiveLayer.tooltip + .position({left: pointXLocation + margin.left, top: e.mouseY + margin.top}) + .chartContainer(that.parentNode) + .enabled(tooltips) + .valueFormatter(valueFormatter) + .data( + { + value: xValue, + series: allData + } + )(); + + interactiveLayer.renderGuideLine(pointXLocation); + + }); + + interactiveLayer.dispatch.on("elementMouseout",function(e) { + dispatch.tooltipHide(); + stacked.clearHighlights(); + }); + + + dispatch.on('tooltipShow', function(e) { + if (tooltips) showTooltip(e, that.parentNode); + }); + + // Update chart from a state object passed to event handler + dispatch.on('changeState', function(e) { + + if (typeof e.disabled !== 'undefined' && data.length === e.disabled.length) { + data.forEach(function(series,i) { + series.disabled = e.disabled[i]; + }); + + state.disabled = e.disabled; + } + + if (typeof e.style !== 'undefined') { + stacked.style(e.style); + style = e.style; + } + + chart.update(); + }); + + }); + + renderWatch.renderEnd('stacked Area chart immediate'); + return chart; + } + + //============================================================ + // Event Handling/Dispatching (out of chart's scope) + //------------------------------------------------------------ + + stacked.dispatch.on('tooltipShow', function(e) { + e.pos = [e.pos[0] + margin.left, e.pos[1] + margin.top]; + dispatch.tooltipShow(e); + }); + + stacked.dispatch.on('tooltipHide', function(e) { + dispatch.tooltipHide(e); + }); + + dispatch.on('tooltipHide', function() { + if (tooltips) nv.tooltip.cleanup(); + }); + + //============================================================ + // Expose Public Variables + //------------------------------------------------------------ + + // expose chart's sub-components + chart.dispatch = dispatch; + chart.stacked = stacked; + chart.legend = legend; + chart.controls = controls; + chart.xAxis = xAxis; + chart.yAxis = yAxis; + chart.interactiveLayer = interactiveLayer; + + yAxis.setTickFormat = yAxis.tickFormat; + + chart.dispatch = dispatch; + chart.options = nv.utils.optionsFunc.bind(chart); + + chart._options = Object.create({}, { + // simple options, just get/set the necessary values + width: {get: function(){return width;}, set: function(_){width=_;}}, + height: {get: function(){return height;}, set: function(_){height=_;}}, + showLegend: {get: function(){return showLegend;}, set: function(_){showLegend=_;}}, + showXAxis: {get: function(){return showXAxis;}, set: function(_){showXAxis=_;}}, + showYAxis: {get: function(){return showYAxis;}, set: function(_){showYAxis=_;}}, + tooltips: {get: function(){return tooltips;}, set: function(_){tooltips=_;}}, + tooltipContent: {get: function(){return tooltip;}, set: function(_){tooltip=_;}}, + defaultState: {get: function(){return defaultState;}, set: function(_){defaultState=_;}}, + noData: {get: function(){return noData;}, set: function(_){noData=_;}}, + showControls: {get: function(){return showControls;}, set: function(_){showControls=_;}}, + controlLabels: {get: function(){return controlLabels;}, set: function(_){controlLabels=_;}}, + yAxisTickFormat: {get: function(){return yAxisTickFormat;}, set: function(_){yAxisTickFormat=_;}}, + + // options that require extra logic in the setter + margin: {get: function(){return margin;}, set: function(_){ + margin.top = _.top !== undefined ? _.top : margin.top; + margin.right = _.right !== undefined ? _.right : margin.right; + margin.bottom = _.bottom !== undefined ? _.bottom : margin.bottom; + margin.left = _.left !== undefined ? _.left : margin.left; + }}, + duration: {get: function(){return duration;}, set: function(_){ + duration = _; + renderWatch.reset(duration); + stacked.duration(duration); + xAxis.duration(duration); + yAxis.duration(duration); + }}, + color: {get: function(){return color;}, set: function(_){ + color = nv.utils.getColor(_); + legend.color(color); + stacked.color(color); + }}, + rightAlignYAxis: {get: function(){return rightAlignYAxis;}, set: function(_){ + rightAlignYAxis = _; + yAxis.orient( rightAlignYAxis ? 'right' : 'left'); + }}, + useInteractiveGuideline: {get: function(){return useInteractiveGuideline;}, set: function(_){ + useInteractiveGuideline = !!_; + if (_) { + chart.interactive(false); + chart.useVoronoi(false); + } + }} + }); + + nv.utils.inheritOptions(chart, stacked); + nv.utils.initOptions(chart); + + return chart; +}; + +nv.version = "1.7.1"; +})(); \ No newline at end of file diff --git a/awx/ui/static/lib/nvd3/build/nv.d3.min.css b/awx/ui/static/lib/nvd3/build/nv.d3.min.css new file mode 100644 index 0000000000..63e8eb54b4 --- /dev/null +++ b/awx/ui/static/lib/nvd3/build/nv.d3.min.css @@ -0,0 +1 @@ +svg.nvd3-svg{-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-ms-user-select:none;-moz-user-select:none;user-select:none;display:block}.nvtooltip.with-3d-shadow,.with-3d-shadow .nvtooltip{-moz-box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-box-shadow:0 5px 10px rgba(0,0,0,.2);box-shadow:0 5px 10px rgba(0,0,0,.2);-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}.nvtooltip{position:absolute;background-color:rgba(255,255,255,1);padding:1px;border:1px solid rgba(0,0,0,.2);z-index:10000;font-family:Arial;font-size:13px;text-align:left;pointer-events:none;white-space:nowrap;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.nvtooltip.with-transitions,.with-transitions .nvtooltip{transition:opacity 50ms linear;-moz-transition:opacity 50ms linear;-webkit-transition:opacity 50ms linear;transition-delay:200ms;-moz-transition-delay:200ms;-webkit-transition-delay:200ms}.nvtooltip.x-nvtooltip,.nvtooltip.y-nvtooltip{padding:8px}.nvtooltip h3{margin:0;padding:4px 14px;line-height:18px;font-weight:400;background-color:rgba(247,247,247,.75);text-align:center;border-bottom:1px solid #ebebeb;-webkit-border-radius:5px 5px 0 0;-moz-border-radius:5px 5px 0 0;border-radius:1px 5px 0 0}.nvtooltip p{margin:0;padding:5px 14px;text-align:center}.nvtooltip span{display:inline-block;margin:2px 0}.nvtooltip table{margin:6px;border-spacing:0}.nvtooltip table td{padding:2px 9px 2px 0;vertical-align:middle}.nvtooltip table td.key{font-weight:400}.nvtooltip table td.value{text-align:right;font-weight:700}.nvtooltip table tr.highlight td{padding:1px 9px 1px 0;border-bottom-style:solid;border-bottom-width:1px;border-top-style:solid;border-top-width:1px}.nvtooltip table td.legend-color-guide div{width:8px;height:8px;vertical-align:middle}.nvtooltip .footer{padding:3px;text-align:center}.nvtooltip-pending-removal{position:absolute;pointer-events:none}.nvd3 text{font:400 12px Arial}.nvd3 .nv-background{fill:#fff;fill-opacity:0}.nvd3.nv-noData{font-size:18px;font-weight:700}.nv-brush .extent{fill-opacity:.125;shape-rendering:crispEdges}.nvd3 .nv-legend .nv-series{cursor:pointer}.nvd3 .nv-legend .nv-disabled circle{fill-opacity:0}.axis{opacity:1}.axis.nv-disabled{opacity:0}.nvd3 .nv-axis{pointer-events:none}.nvd3 .nv-axis path{fill:none;stroke:#000;stroke-opacity:.75;shape-rendering:crispEdges}.nvd3 .nv-axis path.domain{stroke-opacity:.75}.nvd3 .nv-axis.nv-x path.domain{stroke-opacity:0}.nvd3 .nv-axis line{fill:none;stroke:#e5e5e5;shape-rendering:crispEdges}.nvd3 .nv-axis .zero line,.nvd3 .nv-axis line.zero{stroke-opacity:.75}.nvd3 .nv-axis .nv-axisMaxMin text{font-weight:700}.nvd3 .x .nv-axis .nv-axisMaxMin text,.nvd3 .x2 .nv-axis .nv-axisMaxMin text,.nvd3 .x3 .nv-axis .nv-axisMaxMin text{text-anchor:middle}.nv-brush .resize path{fill:#eee;stroke:#666}.nvd3 .nv-bars .negative rect{zfill:brown}.nvd3 .nv-bars rect{zfill:#4682b4;fill-opacity:.75;transition:fill-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear}.nvd3 .nv-bars rect.hover{fill-opacity:1}.nvd3 .nv-bars .hover rect{fill:#add8e6}.nvd3 .nv-bars text{fill:rgba(0,0,0,0)}.nvd3 .nv-bars .hover text{fill:rgba(0,0,0,1)}.nvd3 .nv-multibar .nv-groups rect,.nvd3 .nv-multibarHorizontal .nv-groups rect,.nvd3 .nv-discretebar .nv-groups rect{stroke-opacity:0;transition:fill-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear}.nvd3 .nv-multibar .nv-groups rect:hover,.nvd3 .nv-multibarHorizontal .nv-groups rect:hover,.nvd3 .nv-discretebar .nv-groups rect:hover{fill-opacity:1}.nvd3 .nv-discretebar .nv-groups text,.nvd3 .nv-multibarHorizontal .nv-groups text{font-weight:700;fill:rgba(0,0,0,1);stroke:rgba(0,0,0,0)}.nvd3.nv-pie path{stroke-opacity:0;transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear,stroke-width 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-pie .nv-pie-title{font-size:24px;fill:rgba(19,196,249,.59)}.nvd3.nv-pie .nv-slice text{stroke:#000;stroke-width:0}.nvd3.nv-pie path{stroke:#fff;stroke-width:1px;stroke-opacity:1}.nvd3.nv-pie .hover path{fill-opacity:.7}.nvd3.nv-pie .nv-label{pointer-events:none}.nvd3.nv-pie .nv-label rect{fill-opacity:0;stroke-opacity:0}.nvd3 .nv-groups path.nv-line{fill:none;stroke-width:1.5px}.nvd3 .nv-groups path.nv-line.nv-thin-line{stroke-width:1px}.nvd3 .nv-groups path.nv-area{stroke:none}.nvd3 .nv-line.hover path{stroke-width:6px}.nvd3.nv-line .nvd3.nv-scatter .nv-groups .nv-point{fill-opacity:0;stroke-opacity:0}.nvd3.nv-scatter.nv-single-point .nv-groups .nv-point{fill-opacity:.5!important;stroke-opacity:.5!important}.with-transitions .nvd3 .nv-groups .nv-point{transition:stroke-width 250ms linear,stroke-opacity 250ms linear;-moz-transition:stroke-width 250ms linear,stroke-opacity 250ms linear;-webkit-transition:stroke-width 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-scatter .nv-groups .nv-point.hover,.nvd3 .nv-groups .nv-point.hover{stroke-width:7px;fill-opacity:.95!important;stroke-opacity:.95!important}.nvd3 .nv-point-paths path{stroke:#aaa;stroke-opacity:0;fill:#eee;fill-opacity:0}.nvd3 .nv-indexLine{cursor:ew-resize}.nvd3 .nv-distribution{pointer-events:none}.nvd3 .nv-groups .nv-point.hover{stroke-width:20px;stroke-opacity:.5}.nvd3 .nv-scatter .nv-point.hover{fill-opacity:1}.nvd3.nv-stackedarea path.nv-area{fill-opacity:.7;stroke-opacity:0;transition:fill-opacity 250ms linear,stroke-opacity 250ms linear;-moz-transition:fill-opacity 250ms linear,stroke-opacity 250ms linear;-webkit-transition:fill-opacity 250ms linear,stroke-opacity 250ms linear}.nvd3.nv-stackedarea path.nv-area.hover{fill-opacity:.9}.nvd3.nv-stackedarea .nv-groups .nv-point{stroke-opacity:0;fill-opacity:0}.nvd3.nv-linePlusBar .nv-bar rect{fill-opacity:.75}.nvd3.nv-linePlusBar .nv-bar rect:hover{fill-opacity:1}.nvd3.nv-bullet{font:10px sans-serif}.nvd3.nv-bullet .nv-measure{fill-opacity:.8}.nvd3.nv-bullet .nv-measure:hover{fill-opacity:1}.nvd3.nv-bullet .nv-marker{stroke:#000;stroke-width:2px}.nvd3.nv-bullet .nv-markerTriangle{stroke:#000;fill:#fff;stroke-width:1.5px}.nvd3.nv-bullet .nv-tick line{stroke:#666;stroke-width:.5px}.nvd3.nv-bullet .nv-range.nv-s0{fill:#eee}.nvd3.nv-bullet .nv-range.nv-s1{fill:#ddd}.nvd3.nv-bullet .nv-range.nv-s2{fill:#ccc}.nvd3.nv-bullet .nv-title{font-size:14px;font-weight:700}.nvd3.nv-bullet .nv-subtitle{fill:#999}.nvd3.nv-bullet .nv-range{fill:#bababa;fill-opacity:.4}.nvd3.nv-bullet .nv-range:hover{fill-opacity:.7}.nvd3.nv-sparkline path{fill:none}.nvd3.nv-sparklineplus g.nv-hoverValue{pointer-events:none}.nvd3.nv-sparklineplus .nv-hoverValue line{stroke:#333;stroke-width:1.5px}.nvd3.nv-sparklineplus,.nvd3.nv-sparklineplus g{pointer-events:all}.nvd3 .nv-hoverArea{fill-opacity:0;stroke-opacity:0}.nvd3.nv-sparklineplus .nv-xValue,.nvd3.nv-sparklineplus .nv-yValue{stroke-width:0;font-size:.9em;font-weight:400}.nvd3.nv-sparklineplus .nv-yValue{stroke:#f66}.nvd3.nv-sparklineplus .nv-maxValue{stroke:#2ca02c;fill:#2ca02c}.nvd3.nv-sparklineplus .nv-minValue{stroke:#d62728;fill:#d62728}.nvd3.nv-sparklineplus .nv-currentValue{font-weight:700;font-size:1.1em}.nvd3.nv-ohlcBar .nv-ticks .nv-tick{stroke-width:1px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.hover{stroke-width:2px}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.positive{stroke:#2ca02c}.nvd3.nv-ohlcBar .nv-ticks .nv-tick.negative{stroke:#d62728}.nvd3.nv-historicalStockChart .nv-axis .nv-axislabel{font-weight:700}.nvd3.nv-historicalStockChart .nv-dragTarget{fill-opacity:0;stroke:none;cursor:move}.nvd3 .nv-brush .extent{fill-opacity:0!important}.nvd3 .nv-brushBackground rect{stroke:#000;stroke-width:.4;fill:#fff;fill-opacity:.7}.nvd3 .background path{fill:none;stroke:#EEE;stroke-opacity:.4;shape-rendering:crispEdges}.nvd3 .foreground path{fill:none;stroke-opacity:.7}.nvd3 .brush .extent{fill-opacity:.3;stroke:#fff;shape-rendering:crispEdges}.nvd3 .axis line,.axis path{fill:none;stroke:#000;shape-rendering:crispEdges}.nvd3 .axis text{text-shadow:0 1px 0 #fff}.nvd3 .nv-interactiveGuideLine{pointer-events:none}.nvd3 line.nv-guideline{stroke:#ccc} \ No newline at end of file diff --git a/awx/ui/static/lib/nvd3/build/nv.d3.min.js b/awx/ui/static/lib/nvd3/build/nv.d3.min.js new file mode 100644 index 0000000000..b622baac69 --- /dev/null +++ b/awx/ui/static/lib/nvd3/build/nv.d3.min.js @@ -0,0 +1,7 @@ +/* nvd3 version 1.7.0 (https://github.com/liquidpele/nvd3) 2014-12-18 */ +!function(){var a=window.nv||{};window.nv=a,a.dev=!1,a.tooltip=a.tooltip||{},a.utils=a.utils||{},a.models=a.models||{},a.charts={},a.graphs=[],a.logs={},a.dispatch=d3.dispatch("render_start","render_end"),Function.prototype.bind||(Function.prototype.bind=function(a){if("function"!=typeof this)throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable");var b=Array.prototype.slice.call(arguments,1),c=this,d=function(){},e=function(){return c.apply(this instanceof d&&a?this:a,b.concat(Array.prototype.slice.call(arguments)))};return d.prototype=this.prototype,e.prototype=new d,e}),a.dev&&(a.dispatch.on("render_start",function(){a.logs.startTime=+new Date}),a.dispatch.on("render_end",function(){a.logs.endTime=+new Date,a.logs.totalTime=a.logs.endTime-a.logs.startTime,a.log("total",a.logs.totalTime)})),a.log=function(){if(a.dev&&window.console&&console.log&&console.log.apply)console.log.apply(console,arguments);else if(a.dev&&window.console&&"function"==typeof console.log&&Function.prototype.bind){var b=Function.prototype.bind.call(console.log,console);b.apply(console,arguments)}return arguments[arguments.length-1]},a.deprecated=function(b){a.dev&&console&&console.warn&&console.warn("`"+b+"` has been deprecated.")},a.render=function(b){b=b||1,a.render.active=!0,a.dispatch.render_start(),setTimeout(function(){for(var c,d,e=0;b>e&&(d=a.render.queue[e]);e++)c=d.generate(),typeof d.callback==typeof Function&&d.callback(c),a.graphs.push(c);a.render.queue.splice(0,e),a.render.queue.length?setTimeout(arguments.callee,0):(a.dispatch.render_end(),a.render.active=!1)},0)},a.render.active=!1,a.render.queue=[],a.addGraph=function(b){typeof arguments[0]==typeof Function&&(b={generate:arguments[0],callback:arguments[1]}),a.render.queue.push(b),a.render.active||a.render()},a.interactiveGuideline=function(){"use strict";function b(l){l.each(function(l){function m(){var a=d3.mouse(this),d=a[0],e=a[1],i=!0,j=!1;if(k&&(d=d3.event.offsetX,e=d3.event.offsetY,"svg"!==d3.event.target.tagName&&(i=!1),d3.event.target.className.baseVal.match("nv-legend")&&(j=!0)),i&&(d-=f.left,e-=f.top),0>d||0>e||d>o||e>p||d3.event.relatedTarget&&void 0===d3.event.relatedTarget.ownerSVGElement||j){if(k&&d3.event.relatedTarget&&void 0===d3.event.relatedTarget.ownerSVGElement&&d3.event.relatedTarget.className.match(c.nvPointerEventsClass))return;return h.elementMouseout({mouseX:d,mouseY:e}),void b.renderGuideLine(null)}var l=g.invert(d);h.elementMousemove({mouseX:d,mouseY:e,pointXValue:l}),"dblclick"===d3.event.type&&h.elementDblclick({mouseX:d,mouseY:e,pointXValue:l}),"click"===d3.event.type&&h.elementClick({mouseX:d,mouseY:e,pointXValue:l})}var n=d3.select(this),o=d||960,p=e||400,q=n.selectAll("g.nv-wrap.nv-interactiveLineLayer").data([l]),r=q.enter().append("g").attr("class"," nv-wrap nv-interactiveLineLayer");r.append("g").attr("class","nv-interactiveGuideLine"),j&&(j.on("mousemove",m,!0).on("mouseout",m,!0).on("dblclick",m).on("click",m),b.renderGuideLine=function(b){if(i){var c=q.select(".nv-interactiveGuideLine").selectAll("line").data(null!=b?[a.utils.NaNtoZero(b)]:[],String);c.enter().append("line").attr("class","nv-guideline").attr("x1",function(a){return a}).attr("x2",function(a){return a}).attr("y1",p).attr("y2",0),c.exit().remove()}})})}var c=a.models.tooltip(),d=null,e=null,f={left:0,top:0},g=d3.scale.linear(),h=(d3.scale.linear(),d3.dispatch("elementMousemove","elementMouseout","elementClick","elementDblclick")),i=!0,j=null,k="ActiveXObject"in window;return b.dispatch=h,b.tooltip=c,b.margin=function(a){return arguments.length?(f.top="undefined"!=typeof a.top?a.top:f.top,f.left="undefined"!=typeof a.left?a.left:f.left,b):f},b.width=function(a){return arguments.length?(d=a,b):d},b.height=function(a){return arguments.length?(e=a,b):e},b.xScale=function(a){return arguments.length?(g=a,b):g},b.showGuideLine=function(a){return arguments.length?(i=a,b):i},b.svgContainer=function(a){return arguments.length?(j=a,b):j},b},a.interactiveBisect=function(a,b,c){"use strict";if(!(a instanceof Array))return null;"function"!=typeof c&&(c=function(a){return a.x});var d=d3.bisector(c).left,e=d3.max([0,d(a,b)-1]),f=c(a[e],e);if("undefined"==typeof f&&(f=e),f===b)return e;var g=d3.min([e+1,a.length-1]),h=c(a[g],g);return"undefined"==typeof h&&(h=g),Math.abs(h-b)>=Math.abs(f-b)?e:g},a.nearestValueIndex=function(a,b,c){"use strict";var d=1/0,e=null;return a.forEach(function(a,f){var g=Math.abs(b-a);d>=g&&c>g&&(d=g,e=f)}),e},function(){"use strict";window.nv.tooltip={},window.nv.models.tooltip=function(){function b(){if(l){var a=d3.select(l);"svg"!==a.node().tagName&&(a=a.select("svg"));var b=a.node()?a.attr("viewBox"):null;if(b){b=b.split(" ");var c=parseInt(a.style("width"))/b[2];n.left=n.left*c,n.top=n.top*c}}}function c(a){var b;b=d3.select(l?l:"body");var c=b.select(".nvtooltip");return null===c.node()&&(c=b.append("div").attr("class","nvtooltip "+(k?k:"xy-tooltip")).attr("id",p)),c.node().innerHTML=a,c.style("top",0).style("left",0).style("opacity",0),c.selectAll("div, table, td, tr").classed(q,!0),c.classed(q,!0),c.node()}function d(){if(o&&u(f)){b();var e=n.left,k=null!=j?j:n.top,p=c(t(f));if(m=p,l){var q=l.getElementsByTagName("svg")[0],r=(q?q.getBoundingClientRect():l.getBoundingClientRect(),{left:0,top:0});if(q){var s=q.getBoundingClientRect(),v=l.getBoundingClientRect(),w=s.top;if(0>w){var x=l.getBoundingClientRect();w=Math.abs(w)>x.height?0:w}r.top=Math.abs(w-v.top),r.left=Math.abs(s.left-v.left)}e+=l.offsetLeft+r.left-2*l.scrollLeft,k+=l.offsetTop+r.top-2*l.scrollTop}return i&&i>0&&(k=Math.floor(k/i)*i),a.tooltip.calcTooltipPosition([e,k],g,h,p),d}}var e=null,f=null,g="w",h=50,i=25,j=null,k=null,l=null,m=null,n={left:null,top:null},o=!0,p="nvtooltip-"+Math.floor(1e5*Math.random()),q="nv-pointer-events-none",r=function(a){return a},s=function(a){return a},t=function(a){if(null!=e)return e;if(null==a)return"";var b=d3.select(document.createElement("table")),c=b.selectAll("thead").data([a]).enter().append("thead");c.append("tr").append("td").attr("colspan",3).append("strong").classed("x-value",!0).html(s(a.value));var d=b.selectAll("tbody").data([a]).enter().append("tbody"),f=d.selectAll("tr").data(function(a){return a.series}).enter().append("tr").classed("highlight",function(a){return a.highlight});f.append("td").classed("legend-color-guide",!0).append("div").style("background-color",function(a){return a.color}),f.append("td").classed("key",!0).html(function(a){return a.key}),f.append("td").classed("value",!0).html(function(a,b){return r(a.value,b)}),f.selectAll("td").each(function(a){if(a.highlight){var b=d3.scale.linear().domain([0,1]).range(["#fff",a.color]),c=.6;d3.select(this).style("border-bottom-color",b(c)).style("border-top-color",b(c))}});var g=b.node().outerHTML;return void 0!==a.footer&&(g+=""),g},u=function(a){return a&&a.series&&a.series.length>0?!0:!1};return d.nvPointerEventsClass=q,d.content=function(a){return arguments.length?(e=a,d):e},d.tooltipElem=function(){return m},d.contentGenerator=function(a){return arguments.length?("function"==typeof a&&(t=a),d):t},d.data=function(a){return arguments.length?(f=a,d):f},d.gravity=function(a){return arguments.length?(g=a,d):g},d.distance=function(a){return arguments.length?(h=a,d):h},d.snapDistance=function(a){return arguments.length?(i=a,d):i},d.classes=function(a){return arguments.length?(k=a,d):k},d.chartContainer=function(a){return arguments.length?(l=a,d):l},d.position=function(a){return arguments.length?(n.left="undefined"!=typeof a.left?a.left:n.left,n.top="undefined"!=typeof a.top?a.top:n.top,d):n},d.fixedTop=function(a){return arguments.length?(j=a,d):j},d.enabled=function(a){return arguments.length?(o=a,d):o},d.valueFormatter=function(a){return arguments.length?("function"==typeof a&&(r=a),d):r},d.headerFormatter=function(a){return arguments.length?("function"==typeof a&&(s=a),d):s},d.id=function(){return p},d},a.tooltip.show=function(b,c,d,e,f,g){var h=document.createElement("div");h.className="nvtooltip "+(g?g:"xy-tooltip");var i=f;(!f||f.tagName.match(/g|svg/i))&&(i=document.getElementsByTagName("body")[0]),h.style.left=0,h.style.top=0,h.style.opacity=0,"string"!=typeof c?h.appendChild(c):h.innerHTML=c,i.appendChild(h),f&&(b[0]=b[0]-f.scrollLeft,b[1]=b[1]-f.scrollTop),a.tooltip.calcTooltipPosition(b,d,e,h)},a.tooltip.findFirstNonSVGParent=function(a){for(;null!==a.tagName.match(/^g|svg$/i);)a=a.parentNode;return a},a.tooltip.findTotalOffsetTop=function(a,b){var c=b;do isNaN(a.offsetTop)||(c+=a.offsetTop);while(a=a.offsetParent);return c},a.tooltip.findTotalOffsetLeft=function(a,b){var c=b;do isNaN(a.offsetLeft)||(c+=a.offsetLeft);while(a=a.offsetParent);return c},a.tooltip.calcTooltipPosition=function(b,c,d,e){var f,g,h=parseInt(e.offsetHeight),i=parseInt(e.offsetWidth),j=a.utils.windowSize().width,k=a.utils.windowSize().height,l=window.pageYOffset,m=window.pageXOffset;k=window.innerWidth>=document.body.scrollWidth?k:k-16,j=window.innerHeight>=document.body.scrollHeight?j:j-16,c=c||"s",d=d||20;var n=function(b){return a.tooltip.findTotalOffsetTop(b,g)},o=function(b){return a.tooltip.findTotalOffsetLeft(b,f)};switch(c){case"e":f=b[0]-i-d,g=b[1]-h/2;var p=o(e),q=n(e);m>p&&(f=b[0]+d>m?b[0]+d:m-p+f),l>q&&(g=l-q+g),q+h>l+k&&(g=l+k-q+g-h);break;case"w":f=b[0]+d,g=b[1]-h/2;var p=o(e),q=n(e);p+i>j&&(f=b[0]-i-d),l>q&&(g=l+5),q+h>l+k&&(g=l+k-q+g-h);break;case"n":f=b[0]-i/2-5,g=b[1]+d;var p=o(e),q=n(e);m>p&&(f=m+5),p+i>j&&(f=f-i/2+5),q+h>l+k&&(g=l+k-q+g-h);break;case"s":f=b[0]-i/2,g=b[1]-h-d;var p=o(e),q=n(e);m>p&&(f=m+5),p+i>j&&(f=f-i/2+5),l>q&&(g=l);break;case"none":f=b[0],g=b[1]-d;var p=o(e),q=n(e)}return e.style.left=f+"px",e.style.top=g+"px",e.style.opacity=1,e.style.position="absolute",e},a.tooltip.cleanup=function(){for(var a=document.getElementsByClassName("nvtooltip"),b=[];a.length;)b.push(a[0]),a[0].style.transitionDelay="0 !important",a[0].style.opacity=0,a[0].className="nvtooltip-pending-removal";setTimeout(function(){for(;b.length;){var a=b.pop();a.parentNode.removeChild(a)}},500)}}(),a.utils.windowSize=function(){var a={width:640,height:480};return document.body&&document.body.offsetWidth&&(a.width=document.body.offsetWidth,a.height=document.body.offsetHeight),"CSS1Compat"==document.compatMode&&document.documentElement&&document.documentElement.offsetWidth&&(a.width=document.documentElement.offsetWidth,a.height=document.documentElement.offsetHeight),window.innerWidth&&window.innerHeight&&(a.width=window.innerWidth,a.height=window.innerHeight),a},a.utils.windowResize=function(b){return window.addEventListener?window.addEventListener("resize",b):a.log("ERROR: Failed to bind to window.resize with: ",b),{callback:b,clear:function(){window.removeEventListener("resize",b)}}},a.utils.getColor=function(b){return arguments.length?b instanceof Array?function(a,c){return a.color||b[c%b.length]}:b:a.utils.defaultColor()},a.utils.defaultColor=function(){var a=d3.scale.category20().range();return function(b,c){return b.color||a[c%a.length]}},a.utils.customTheme=function(a,b,c){b=b||function(a){return a.key},c=c||d3.scale.category20().range();var d=c.length;return function(e){var f=b(e);return"function"==typeof a[f]?a[f]():void 0!==a[f]?a[f]:(d||(d=c.length),d-=1,c[d])}},a.utils.pjax=function(b,c){var d=function(d){d3.html(d,function(d){var e=d3.select(c).node();e.parentNode.replaceChild(d3.select(d).select(c).node(),e),a.utils.pjax(b,c)})};d3.selectAll(b).on("click",function(){history.pushState(this.href,this.textContent,this.href),d(this.href),d3.event.preventDefault()}),d3.select(window).on("popstate",function(){d3.event.state&&d(d3.event.state)})},a.utils.calcApproxTextWidth=function(a){if("function"==typeof a.style&&"function"==typeof a.text){var b=parseInt(a.style("font-size").replace("px","")),c=a.text().length;return c*b*.5}return 0},a.utils.NaNtoZero=function(a){return"number"!=typeof a||isNaN(a)||null===a||1/0===a||a===-1/0?0:a},d3.selection.prototype.watchTransition=function(a){var b=[this].concat([].slice.call(arguments,1));return a.transition.apply(a,b)},a.utils.renderWatch=function(b,c){if(!(this instanceof a.utils.renderWatch))return new a.utils.renderWatch(b,c);var d=void 0!==c?c:250,e=[],f=this;this.models=function(a){return a=[].slice.call(arguments,0),a.forEach(function(a){a.__rendered=!1,function(a){a.dispatch.on("renderEnd",function(){a.__rendered=!0,f.renderEnd("model")})}(a),e.indexOf(a)<0&&e.push(a)}),this},this.reset=function(a){void 0!==a&&(d=a),e=[]},this.transition=function(a,b,c){if(b=arguments.length>1?[].slice.call(arguments,1):[],c=b.length>1?b.pop():void 0!==d?d:250,a.__rendered=!1,e.indexOf(a)<0&&e.push(a),0===c)return a.__rendered=!0,a.delay=function(){return this},a.duration=function(){return this},a;a.__rendered=0===a.length?!0:a.every(function(a){return!a.length})?!0:!1;var g=0;return a.transition().duration(c).each(function(){++g}).each("end",function(){0===--g&&(a.__rendered=!0,f.renderEnd.apply(this,b))})},this.renderEnd=function(){e.every(function(a){return a.__rendered})&&(e.forEach(function(a){a.__rendered=!1}),b.renderEnd.apply(this,arguments))}},a.utils.deepExtend=function(b){var c=arguments.length>1?[].slice.call(arguments,1):[];c.forEach(function(c){for(key in c){var d=b[key]instanceof Array,e="object"==typeof b[key],f="object"==typeof c[key];e&&!d&&f?a.utils.deepExtend(b[key],c[key]):b[key]=c[key]}})},a.utils.state=function(){if(!(this instanceof a.utils.state))return new a.utils.state;var b={},c=function(){},d=function(){return{}},e=null,f=null;this.dispatch=d3.dispatch("change","set"),this.dispatch.on("set",function(a){c(a,!0)}),this.getter=function(a){return d=a,this},this.setter=function(a,b){return b||(b=function(){}),c=function(c,d){a(c),d&&b()},this},this.init=function(b){e=e||{},a.utils.deepExtend(e,b)};var g=function(){var a=d();if(JSON.stringify(a)===JSON.stringify(b))return!1;for(var c in a)void 0===b[c]&&(b[c]={}),b[c]=a[c],f=!0;return!0};this.update=function(){e&&(c(e,!1),e=null),g.call(this)&&this.dispatch.change(b)}},a.utils.optionsFunc=function(b){return a.deprecated("nv.utils.optionsFunc"),b&&d3.map(b).forEach(function(a,b){"function"==typeof this[a]&&this[a](b)}.bind(this)),this},a.utils.calcTicksX=function(b,c){var d=1,e=0;for(e;ed?f:d}return a.log("Requested number of ticks: ",b),a.log("Calculated max values to be: ",d),b=b>d?b=d-1:b,b=1>b?1:b,b=Math.floor(b),a.log("Calculating tick count as: ",b),b},a.utils.calcTicksY=function(b,c){return a.utils.calcTicksX(b,c)},a.utils.initOption=function(a,b){a[b]=a._calls&&a._calls[b]?a._calls[b]:function(c){return arguments.length?(a._options[b]=c,a):a._options[b]}},a.utils.initOptions=function(b){var c=Object.getOwnPropertyNames(b._options||{}),d=Object.getOwnPropertyNames(b._calls||{});c=c.concat(d);for(var e in c)a.utils.initOption(b,c[e])},a.utils.inheritOptionsD3=function(a,b,c){a._d3options=c.concat(a._d3options||[]),c.unshift(b),c.unshift(a),d3.rebind.apply(this,c)},a.utils.arrayUnique=function(a){return a.sort().filter(function(b,c){return!c||b!=a[c-1]})},a.utils.symbolMap=d3.map(),a.utils.symbol=function(){function b(b,e){var f=c.call(this,b,e),g=d.call(this,b,e);return-1!==d3.svg.symbolTypes.indexOf(f)?d3.svg.symbol().type(f).size(g)():a.utils.symbolMap.get(f)(g)}var c,d=64;return b.type=function(a){return arguments.length?(c=d3.functor(a),b):c},b.size=function(a){return arguments.length?(d=d3.functor(a),b):d},b},a.utils.inheritOptions=function(b,c){var d=Object.getOwnPropertyNames(c._options||{}),e=Object.getOwnPropertyNames(c._calls||{}),f=c._inherited||[],g=c._d3options||[],h=d.concat(e).concat(f).concat(g);h.unshift(c),h.unshift(b),d3.rebind.apply(this,h),b._inherited=a.utils.arrayUnique(d.concat(e).concat(f).concat(d).concat(b._inherited||[])),b._d3options=a.utils.arrayUnique(g.concat(b._d3options||[]))},a.utils.initSVG=function(a){a.classed({"nvd3-svg":!0})},a.models.axis=function(){"use strict";function b(g){return t.reset(),g.each(function(b){var g=d3.select(this);a.utils.initSVG(g);var q=g.selectAll("g.nv-wrap.nv-axis").data([b]),r=q.enter().append("g").attr("class","nvd3 nv-wrap nv-axis"),u=(r.append("g"),q.select("g"));null!==o?c.ticks(o):("top"==c.orient()||"bottom"==c.orient())&&c.ticks(Math.abs(d.range()[1]-d.range()[0])/100),u.watchTransition(t,"axis").call(c),s=s||c.scale();var v=c.tickFormat();null==v&&(v=s.tickFormat());var w=u.selectAll("text.nv-axislabel").data([h||null]);switch(w.exit().remove(),c.orient()){case"top":w.enter().append("text").attr("class","nv-axislabel");var x;if(x=d.range().length<2?0:2===d.range().length?d.range()[1]:d.range()[d.range().length-1]+(d.range()[1]-d.range()[0]),w.attr("text-anchor","middle").attr("y",0).attr("x",x/2),i){var y=q.selectAll("g.nv-axisMaxMin").data(d.domain());y.enter().append("g").attr("class","nv-axisMaxMin").append("text"),y.exit().remove(),y.attr("transform",function(b){return"translate("+a.utils.NaNtoZero(d(b))+",0)"}).select("text").attr("dy","-0.5em").attr("y",-c.tickPadding()).attr("text-anchor","middle").text(function(a){var b=v(a);return(""+b).match("NaN")?"":b}),y.watchTransition(t,"min-max top").attr("transform",function(b,c){return"translate("+a.utils.NaNtoZero(d.range()[c])+",0)"})}break;case"bottom":var z=p+36,A=30,B=u.selectAll("g").select("text");if(k%360){B.each(function(){var a=this.getBoundingClientRect().width;a>A&&(A=a)});var C=Math.abs(Math.sin(k*Math.PI/180)),z=(C?C*A:A)+30;B.attr("transform",function(){return"rotate("+k+" 0,0)"}).style("text-anchor",k%360>0?"start":"end")}w.enter().append("text").attr("class","nv-axislabel");var x;if(x=d.range().length<2?0:2===d.range().length?d.range()[1]:d.range()[d.range().length-1]+(d.range()[1]-d.range()[0]),w.attr("text-anchor","middle").attr("y",z).attr("x",x/2),i){var y=q.selectAll("g.nv-axisMaxMin").data([d.domain()[0],d.domain()[d.domain().length-1]]);y.enter().append("g").attr("class","nv-axisMaxMin").append("text"),y.exit().remove(),y.attr("transform",function(b){return"translate("+a.utils.NaNtoZero(d(b)+(n?d.rangeBand()/2:0))+",0)"}).select("text").attr("dy",".71em").attr("y",c.tickPadding()).attr("transform",function(){return"rotate("+k+" 0,0)"}).style("text-anchor",k?k%360>0?"start":"end":"middle").text(function(a){var b=v(a);return(""+b).match("NaN")?"":b}),y.watchTransition(t,"min-max bottom").attr("transform",function(b){return"translate("+a.utils.NaNtoZero(d(b)+(n?d.rangeBand()/2:0))+",0)"})}m&&B.attr("transform",function(b,c){return"translate(0,"+a.utils.NaNtoZero(c%2==0?"0":"12")+")"});break;case"right":if(w.enter().append("text").attr("class","nv-axislabel"),w.style("text-anchor",l?"middle":"begin").attr("transform",l?"rotate(90)":"").attr("y",l?-Math.max(e.right,f)+12:-10).attr("x",l?d.range()[0]/2:c.tickPadding()),i){var y=q.selectAll("g.nv-axisMaxMin").data(d.domain());y.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),y.exit().remove(),y.attr("transform",function(b){return"translate(0,"+a.utils.NaNtoZero(d(b))+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",c.tickPadding()).style("text-anchor","start").text(function(a){var b=v(a);return(""+b).match("NaN")?"":b}),y.watchTransition(t,"min-max right").attr("transform",function(b,c){return"translate(0,"+a.utils.NaNtoZero(d.range()[c])+")"}).select("text").style("opacity",1)}break;case"left":if(w.enter().append("text").attr("class","nv-axislabel"),w.style("text-anchor",l?"middle":"end").attr("transform",l?"rotate(-90)":"").attr("y",l?-Math.max(e.left,f)+25-(p||0):-10).attr("x",l?-d.range()[0]/2:-c.tickPadding()),i){var y=q.selectAll("g.nv-axisMaxMin").data(d.domain());y.enter().append("g").attr("class","nv-axisMaxMin").append("text").style("opacity",0),y.exit().remove(),y.attr("transform",function(b){return"translate(0,"+a.utils.NaNtoZero(s(b))+")"}).select("text").attr("dy",".32em").attr("y",0).attr("x",-c.tickPadding()).attr("text-anchor","end").text(function(a){var b=v(a);return(""+b).match("NaN")?"":b}),y.watchTransition(t,"min-max right").attr("transform",function(b,c){return"translate(0,"+a.utils.NaNtoZero(d.range()[c])+")"}).select("text").style("opacity",1)}}if(w.text(function(a){return a}),!i||"left"!==c.orient()&&"right"!==c.orient()||(u.selectAll("g").each(function(a){d3.select(this).select("text").attr("opacity",1),(d(a)d.range()[0]-10)&&((a>1e-10||-1e-10>a)&&d3.select(this).attr("opacity",0),d3.select(this).select("text").attr("opacity",0))}),d.domain()[0]==d.domain()[1]&&0==d.domain()[0]&&q.selectAll("g.nv-axisMaxMin").style("opacity",function(a,b){return b?0:1})),i&&("top"===c.orient()||"bottom"===c.orient())){var D=[];q.selectAll("g.nv-axisMaxMin").each(function(a,b){try{D.push(b?d(a)-this.getBoundingClientRect().width-4:d(a)+this.getBoundingClientRect().width+4)}catch(c){D.push(b?d(a)-4:d(a)+4)}}),u.selectAll("g").each(function(a){(d(a)D[1])&&(a>1e-10||-1e-10>a?d3.select(this).remove():d3.select(this).select("text").remove())})}j&&u.selectAll(".tick").filter(function(){return!parseFloat(Math.round(1e5*this.__data__)/1e6)&&void 0!==this.__data__}).classed("zero",!0),s=d.copy()}),t.renderEnd("axis immediate"),b}var c=d3.svg.axis(),d=d3.scale.linear(),e={top:0,right:0,bottom:0,left:0},f=75,g=60,h=null,i=!0,j=!0,k=0,l=!0,m=!1,n=!1,o=null,p=0,q=250,r=d3.dispatch("renderEnd");c.scale(d).orient("bottom").tickFormat(function(a){return a});var s,t=a.utils.renderWatch(r,q);return b.axis=c,b.dispatch=r,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{axisLabelDistance:{get:function(){return p},set:function(a){p=a}},staggerLabels:{get:function(){return m},set:function(a){m=a}},rotateLabels:{get:function(){return k},set:function(a){k=a}},rotateYLabel:{get:function(){return l},set:function(a){l=a}},highlightZero:{get:function(){return j},set:function(a){j=a}},showMaxMin:{get:function(){return i},set:function(a){i=a}},axisLabel:{get:function(){return h},set:function(a){h=a}},height:{get:function(){return g},set:function(a){g=a}},ticks:{get:function(){return o},set:function(a){o=a}},width:{get:function(){return f},set:function(a){f=a}},margin:{get:function(){return e},set:function(a){e.top=void 0!==a.top?a.top:e.top,e.right=void 0!==a.right?a.right:e.right,e.bottom=void 0!==a.bottom?a.bottom:e.bottom,e.left=void 0!==a.left?a.left:e.left}},duration:{get:function(){return q},set:function(a){q=a,t.reset(q)}},scale:{get:function(){return d},set:function(e){d=e,c.scale(d),n="function"==typeof d.rangeBands,a.utils.inheritOptionsD3(b,d,["domain","range","rangeBand","rangeBands"])}}}),a.utils.initOptions(b),a.utils.inheritOptionsD3(b,c,["orient","tickValues","tickSubdivide","tickSize","tickPadding","tickFormat"]),a.utils.inheritOptionsD3(b,d,["domain","range","rangeBand","rangeBands"]),b},a.models.bullet=function(){"use strict";function b(d){return d.each(function(b,d){var o=m-c.left-c.right,r=n-c.top-c.bottom,s=d3.select(this);a.utils.initSVG(s);{var t=f.call(this,b,d).slice().sort(d3.descending),u=g.call(this,b,d).slice().sort(d3.descending),v=h.call(this,b,d).slice().sort(d3.descending),w=i.call(this,b,d).slice(),x=j.call(this,b,d).slice(),y=k.call(this,b,d).slice(),z=d3.scale.linear().domain(d3.extent(d3.merge([l,t]))).range(e?[o,0]:[0,o]);this.__chart__||d3.scale.linear().domain([0,1/0]).range(z.range())}this.__chart__=z;var A=d3.min(t),B=d3.max(t),C=t[1],D=s.selectAll("g.nv-wrap.nv-bullet").data([b]),E=D.enter().append("g").attr("class","nvd3 nv-wrap nv-bullet"),F=E.append("g"),G=D.select("g");F.append("rect").attr("class","nv-range nv-rangeMax"),F.append("rect").attr("class","nv-range nv-rangeAvg"),F.append("rect").attr("class","nv-range nv-rangeMin"),F.append("rect").attr("class","nv-measure"),F.append("path").attr("class","nv-markerTriangle"),D.attr("transform","translate("+c.left+","+c.top+")");var H=function(a){return Math.abs(z(a)-z(0))},I=function(a){return z(0>a?a:0)};G.select("rect.nv-rangeMax").attr("height",r).attr("width",H(B>0?B:A)).attr("x",I(B>0?B:A)).datum(B>0?B:A),G.select("rect.nv-rangeAvg").attr("height",r).attr("width",H(C)).attr("x",I(C)).datum(C),G.select("rect.nv-rangeMin").attr("height",r).attr("width",H(B)).attr("x",I(B)).attr("width",H(B>0?A:B)).attr("x",I(B>0?A:B)).datum(B>0?A:B),G.select("rect.nv-measure").style("fill",p).attr("height",r/3).attr("y",r/3).attr("width",0>v?z(0)-z(v[0]):z(v[0])-z(0)).attr("x",I(v)).on("mouseover",function(){q.elementMouseover({value:v[0],label:y[0]||"Current",pos:[z(v[0]),r/2]})}).on("mouseout",function(){q.elementMouseout({value:v[0],label:y[0]||"Current"})});var J=r/6;u[0]?G.selectAll("path.nv-markerTriangle").attr("transform",function(){return"translate("+z(u[0])+","+r/2+")"}).attr("d","M0,"+J+"L"+J+","+-J+" "+-J+","+-J+"Z").on("mouseover",function(){q.elementMouseover({value:u[0],label:x[0]||"Previous",pos:[z(u[0]),r/2]})}).on("mouseout",function(){q.elementMouseout({value:u[0],label:x[0]||"Previous"})}):G.selectAll("path.nv-markerTriangle").remove(),D.selectAll(".nv-range").on("mouseover",function(a,b){var c=w[b]||(b?1==b?"Mean":"Minimum":"Maximum");q.elementMouseover({value:a,label:c,pos:[z(a),r/2]})}).on("mouseout",function(a,b){var c=w[b]||(b?1==b?"Mean":"Minimum":"Maximum");q.elementMouseout({value:a,label:c})})}),b}var c={top:0,right:0,bottom:0,left:0},d="left",e=!1,f=function(a){return a.ranges},g=function(a){return a.markers?a.markers:[0]},h=function(a){return a.measures},i=function(a){return a.rangeLabels?a.rangeLabels:[]},j=function(a){return a.markerLabels?a.markerLabels:[]},k=function(a){return a.measureLabels?a.measureLabels:[]},l=[0],m=380,n=30,o=null,p=a.utils.getColor(["#1f77b4"]),q=d3.dispatch("elementMouseover","elementMouseout");return b.dispatch=q,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{ranges:{get:function(){return f},set:function(a){f=a}},markers:{get:function(){return g},set:function(a){g=a}},measures:{get:function(){return h},set:function(a){h=a}},forceX:{get:function(){return l},set:function(a){l=a}},width:{get:function(){return m},set:function(a){m=a}},height:{get:function(){return n},set:function(a){n=a}},tickFormat:{get:function(){return o},set:function(a){o=a}},margin:{get:function(){return c},set:function(a){c.top=void 0!==a.top?a.top:c.top,c.right=void 0!==a.right?a.right:c.right,c.bottom=void 0!==a.bottom?a.bottom:c.bottom,c.left=void 0!==a.left?a.left:c.left}},orient:{get:function(){return d},set:function(a){d=a,e="right"==d||"bottom"==d}},color:{get:function(){return p},set:function(b){p=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.bulletChart=function(){"use strict";function b(d){return d.each(function(n,r){var s=d3.select(this);a.utils.initSVG(s);var t=(j||parseInt(s.style("width"))||960)-f.left-f.right,u=k-f.top-f.bottom,v=this;if(b.update=function(){b(d)},b.container=this,!n||!g.call(this,n,r)){var w=s.selectAll(".nv-noData").data([o]);return w.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),w.attr("x",f.left+t/2).attr("y",18+f.top+u/2).text(function(a){return a}),b}s.selectAll(".nv-noData").remove();var x=g.call(this,n,r).slice().sort(d3.descending),y=h.call(this,n,r).slice().sort(d3.descending),z=i.call(this,n,r).slice().sort(d3.descending),A=s.selectAll("g.nv-wrap.nv-bulletChart").data([n]),B=A.enter().append("g").attr("class","nvd3 nv-wrap nv-bulletChart"),C=B.append("g"),D=A.select("g");C.append("g").attr("class","nv-bulletWrap"),C.append("g").attr("class","nv-titles"),A.attr("transform","translate("+f.left+","+f.top+")");var E=d3.scale.linear().domain([0,Math.max(x[0],y[0],z[0])]).range(e?[t,0]:[0,t]),F=this.__chart__||d3.scale.linear().domain([0,1/0]).range(E.range());this.__chart__=E;var G=C.select(".nv-titles").append("g").attr("text-anchor","end").attr("transform","translate(-6,"+(k-f.top-f.bottom)/2+")");G.append("text").attr("class","nv-title").text(function(a){return a.title}),G.append("text").attr("class","nv-subtitle").attr("dy","1em").text(function(a){return a.subtitle}),c.width(t).height(u);var H=D.select(".nv-bulletWrap");d3.transition(H).call(c);var I=l||E.tickFormat(t/100),J=D.selectAll("g.nv-tick").data(E.ticks(t/50),function(a){return this.textContent||I(a)}),K=J.enter().append("g").attr("class","nv-tick").attr("transform",function(a){return"translate("+F(a)+",0)"}).style("opacity",1e-6);K.append("line").attr("y1",u).attr("y2",7*u/6),K.append("text").attr("text-anchor","middle").attr("dy","1em").attr("y",7*u/6).text(I);var L=d3.transition(J).attr("transform",function(a){return"translate("+E(a)+",0)"}).style("opacity",1);L.select("line").attr("y1",u).attr("y2",7*u/6),L.select("text").attr("y",7*u/6),d3.transition(J.exit()).attr("transform",function(a){return"translate("+E(a)+",0)"}).style("opacity",1e-6).remove(),p.on("tooltipShow",function(a){a.key=n.title,m&&q(a,v.parentNode)})}),d3.timer.flush(),b}var c=a.models.bullet(),d="left",e=!1,f={top:5,right:40,bottom:20,left:120},g=function(a){return a.ranges},h=function(a){return a.markers?a.markers:[0]},i=function(a){return a.measures},j=null,k=55,l=null,m=!0,n=function(a,b,c){return"

"+b+"

"+c+"

"},o="No Data Available.",p=d3.dispatch("tooltipShow","tooltipHide"),q=function(c,d){var e=c.pos[0]+(d.offsetLeft||0)+f.left,g=c.pos[1]+(d.offsetTop||0)+f.top,h=n(c.key,c.label,c.value,c,b);a.tooltip.show([e,g],h,c.value<0?"e":"w",null,d)};return c.dispatch.on("elementMouseover.tooltip",function(a){p.tooltipShow(a)}),c.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)}),p.on("tooltipHide",function(){m&&a.tooltip.cleanup()}),b.bullet=c,b.dispatch=p,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{ranges:{get:function(){return g},set:function(a){g=a}},markers:{get:function(){return h},set:function(a){h=a}},measures:{get:function(){return i},set:function(a){i=a}},width:{get:function(){return j},set:function(a){j=a}},height:{get:function(){return k},set:function(a){k=a}},tickFormat:{get:function(){return l},set:function(a){l=a}},tooltips:{get:function(){return m},set:function(a){m=a}},tooltipContent:{get:function(){return n},set:function(a){n=a}},noData:{get:function(){return o},set:function(a){o=a}},margin:{get:function(){return f},set:function(a){f.top=void 0!==a.top?a.top:f.top,f.right=void 0!==a.right?a.right:f.right,f.bottom=void 0!==a.bottom?a.bottom:f.bottom,f.left=void 0!==a.left?a.left:f.left}},orient:{get:function(){return d},set:function(a){d=a,e="right"==d||"bottom"==d}}}),a.utils.inheritOptions(b,c),a.utils.initOptions(b),b},a.models.cumulativeLineChart=function(){"use strict";function b(x){return I.reset(),I.models(f),q&&I.models(g),r&&I.models(h),x.each(function(x){function F(){d3.select(b.container).style("cursor","ew-resize")}function I(){H.x=d3.event.x,H.i=Math.round(G.invert(H.x)),N()}function M(){d3.select(b.container).style("cursor","auto"),z.index=H.i,D.stateChange(z)}function N(){fb.data([H]);var a=b.duration();b.duration(0),b.update(),b.duration(a)}var O=d3.select(this);a.utils.initSVG(O),O.classed("nv-chart-"+y,!0);var P=this,Q=(n||parseInt(O.style("width"))||960)-l.left-l.right,R=(o||parseInt(O.style("height"))||400)-l.top-l.bottom;if(b.update=function(){0===E?O.call(b):O.transition().duration(E).call(b)},b.container=this,z.setter(L(x),b.update).getter(K(x)).update(),z.disabled=x.map(function(a){return!!a.disabled}),!A){var S;A={};for(S in z)A[S]=z[S]instanceof Array?z[S].slice(0):z[S]}var T=d3.behavior.drag().on("dragstart",F).on("drag",I).on("dragend",M);if(!(x&&x.length&&x.filter(function(a){return a.values.length}).length)){var U=O.selectAll(".nv-noData").data([B]);return U.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),U.attr("x",l.left+Q/2).attr("y",l.top+R/2).text(function(a){return a}),b}if(O.selectAll(".nv-noData").remove(),d=f.xScale(),e=f.yScale(),w)f.yDomain(null);else{var V=x.filter(function(a){return!a.disabled}).map(function(a){var b=d3.extent(a.values,f.y());return b[0]<-.95&&(b[0]=-.95),[(b[0]-b[1])/(1+b[1]),(b[1]-b[0])/(1+b[0])]}),W=[d3.min(V,function(a){return a[0] +}),d3.max(V,function(a){return a[1]})];f.yDomain(W)}G.domain([0,x[0].values.length-1]).range([0,Q]).clamp(!0);var x=c(H.i,x),X=v?"none":"all",Y=O.selectAll("g.nv-wrap.nv-cumulativeLine").data([x]),Z=Y.enter().append("g").attr("class","nvd3 nv-wrap nv-cumulativeLine").append("g"),$=Y.select("g");if(Z.append("g").attr("class","nv-interactive"),Z.append("g").attr("class","nv-x nv-axis").style("pointer-events","none"),Z.append("g").attr("class","nv-y nv-axis"),Z.append("g").attr("class","nv-background"),Z.append("g").attr("class","nv-linesWrap").style("pointer-events",X),Z.append("g").attr("class","nv-avgLinesWrap").style("pointer-events","none"),Z.append("g").attr("class","nv-legendWrap"),Z.append("g").attr("class","nv-controlsWrap"),p&&(i.width(Q),$.select(".nv-legendWrap").datum(x).call(i),l.top!=i.height()&&(l.top=i.height(),R=(o||parseInt(O.style("height"))||400)-l.top-l.bottom),$.select(".nv-legendWrap").attr("transform","translate(0,"+-l.top+")")),u){var _=[{key:"Re-scale y-axis",disabled:!w}];j.width(140).color(["#444","#444","#444"]).rightAlign(!1).margin({top:5,right:0,bottom:5,left:20}),$.select(".nv-controlsWrap").datum(_).attr("transform","translate(0,"+-l.top+")").call(j)}Y.attr("transform","translate("+l.left+","+l.top+")"),s&&$.select(".nv-y.nv-axis").attr("transform","translate("+Q+",0)");var ab=x.filter(function(a){return a.tempDisabled});Y.select(".tempDisabled").remove(),ab.length&&Y.append("text").attr("class","tempDisabled").attr("x",Q/2).attr("y","-.71em").style("text-anchor","end").text(ab.map(function(a){return a.key}).join(", ")+" values cannot be calculated for this time period."),v&&(k.width(Q).height(R).margin({left:l.left,top:l.top}).svgContainer(O).xScale(d),Y.select(".nv-interactive").call(k)),Z.select(".nv-background").append("rect"),$.select(".nv-background rect").attr("width",Q).attr("height",R),f.y(function(a){return a.display.y}).width(Q).height(R).color(x.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!x[b].disabled&&!x[b].tempDisabled}));var bb=$.select(".nv-linesWrap").datum(x.filter(function(a){return!a.disabled&&!a.tempDisabled}));bb.call(f),x.forEach(function(a,b){a.seriesIndex=b});var cb=x.filter(function(a){return!a.disabled&&!!C(a)}),db=$.select(".nv-avgLinesWrap").selectAll("line").data(cb,function(a){return a.key}),eb=function(a){var b=e(C(a));return 0>b?0:b>R?R:b};db.enter().append("line").style("stroke-width",2).style("stroke-dasharray","10,10").style("stroke",function(a){return f.color()(a,a.seriesIndex)}).attr("x1",0).attr("x2",Q).attr("y1",eb).attr("y2",eb),db.style("stroke-opacity",function(a){var b=e(C(a));return 0>b||b>R?0:1}).attr("x1",0).attr("x2",Q).attr("y1",eb).attr("y2",eb),db.exit().remove();var fb=bb.selectAll(".nv-indexLine").data([H]);fb.enter().append("rect").attr("class","nv-indexLine").attr("width",3).attr("x",-2).attr("fill","red").attr("fill-opacity",.5).style("pointer-events","all").call(T),fb.attr("transform",function(a){return"translate("+G(a.i)+",0)"}).attr("height",R),q&&(g.scale(d).ticks(a.utils.calcTicksX(Q/70,x)).tickSize(-R,0),$.select(".nv-x.nv-axis").attr("transform","translate(0,"+e.range()[0]+")"),$.select(".nv-x.nv-axis").call(g)),r&&(h.scale(e).ticks(a.utils.calcTicksY(R/36,x)).tickSize(-Q,0),$.select(".nv-y.nv-axis").call(h)),$.select(".nv-background rect").on("click",function(){H.x=d3.mouse(this)[0],H.i=Math.round(G.invert(H.x)),z.index=H.i,D.stateChange(z),N()}),f.dispatch.on("elementClick",function(a){H.i=a.pointIndex,H.x=G(H.i),z.index=H.i,D.stateChange(z),N()}),j.dispatch.on("legendClick",function(a){a.disabled=!a.disabled,w=!a.disabled,z.rescaleY=w,D.stateChange(z),b.update()}),i.dispatch.on("stateChange",function(a){for(var c in a)z[c]=a[c];D.stateChange(z),b.update()}),k.dispatch.on("elementMousemove",function(c){f.clearHighlights();var d,e,i,j=[];if(x.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(g,h){e=a.interactiveBisect(g.values,c.pointXValue,b.x()),f.highlightPoint(h,e,!0);var k=g.values[e];"undefined"!=typeof k&&("undefined"==typeof d&&(d=k),"undefined"==typeof i&&(i=b.xScale()(b.x()(k,e))),j.push({key:g.key,value:b.y()(k,e),color:m(g,g.seriesIndex)}))}),j.length>2){var n=b.yScale().invert(c.mouseY),o=Math.abs(b.yScale().domain()[0]-b.yScale().domain()[1]),p=.03*o,q=a.nearestValueIndex(j.map(function(a){return a.value}),n,p);null!==q&&(j[q].highlight=!0)}var r=g.tickFormat()(b.x()(d,e),e);k.tooltip.position({left:i+l.left,top:c.mouseY+l.top}).chartContainer(P.parentNode).enabled(t).valueFormatter(function(a){return h.tickFormat()(a)}).data({value:r,series:j})(),k.renderGuideLine(i)}),k.dispatch.on("elementMouseout",function(){D.tooltipHide(),f.clearHighlights()}),D.on("tooltipShow",function(a){t&&J(a,P.parentNode)}),D.on("changeState",function(a){"undefined"!=typeof a.disabled&&(x.forEach(function(b,c){b.disabled=a.disabled[c]}),z.disabled=a.disabled),"undefined"!=typeof a.index&&(H.i=a.index,H.x=G(H.i),z.index=a.index,fb.data([H])),"undefined"!=typeof a.rescaleY&&(w=a.rescaleY),b.update()})}),I.renderEnd("cumulativeLineChart immediate"),b}function c(a,b){return M||(M=f.y()),b.map(function(b){if(!b.values)return b;var c=b.values[a];if(null==c)return b;var d=M(c,a);return-.95>d&&!F?(b.tempDisabled=!0,b):(b.tempDisabled=!1,b.values=b.values.map(function(a,b){return a.display={y:(M(a,b)-d)/(1+d)},a}),b)})}var d,e,f=a.models.line(),g=a.models.axis(),h=a.models.axis(),i=a.models.legend(),j=a.models.legend(),k=a.interactiveGuideline(),l={top:30,right:30,bottom:50,left:60},m=a.utils.defaultColor(),n=null,o=null,p=!0,q=!0,r=!0,s=!1,t=!0,u=!0,v=!1,w=!0,x=function(a,b,c){return"

"+a+"

"+c+" at "+b+"

"},y=f.id(),z=a.utils.state(),A=null,B="No Data Available.",C=function(a){return a.average},D=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),E=250,F=!1;z.index=0,z.rescaleY=w,g.orient("bottom").tickPadding(7),h.orient(s?"right":"left"),j.updateState(!1);var G=d3.scale.linear(),H={i:0,x:0},I=a.utils.renderWatch(D,E),J=function(c,d){var e=c.pos[0]+(d.offsetLeft||0),i=c.pos[1]+(d.offsetTop||0),j=g.tickFormat()(f.x()(c.point,c.pointIndex)),k=h.tickFormat()(f.y()(c.point,c.pointIndex)),l=x(c.series.key,j,k,c,b);a.tooltip.show([e,i],l,null,null,d)},K=function(a){return function(){return{active:a.map(function(a){return!a.disabled}),index:H.i,rescaleY:w}}},L=function(a){return function(b){void 0!==b.index&&(H.i=b.index),void 0!==b.rescaleY&&(w=b.rescaleY),void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};f.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+l.left,a.pos[1]+l.top],D.tooltipShow(a)}),f.dispatch.on("elementMouseout.tooltip",function(a){D.tooltipHide(a)}),D.on("tooltipHide",function(){t&&a.tooltip.cleanup()});var M=null;return b.dispatch=D,b.lines=f,b.legend=i,b.xAxis=g,b.yAxis=h,b.interactiveLayer=k,b.state=z,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return n},set:function(a){n=a}},height:{get:function(){return o},set:function(a){o=a}},rescaleY:{get:function(){return w},set:function(a){w=a}},showControls:{get:function(){return u},set:function(a){u=a}},showLegend:{get:function(){return p},set:function(a){p=a}},average:{get:function(){return C},set:function(a){C=a}},tooltips:{get:function(){return t},set:function(a){t=a}},tooltipContent:{get:function(){return x},set:function(a){x=a}},defaultState:{get:function(){return A},set:function(a){A=a}},noData:{get:function(){return B},set:function(a){B=a}},showXAxis:{get:function(){return q},set:function(a){q=a}},showYAxis:{get:function(){return r},set:function(a){r=a}},noErrorCheck:{get:function(){return F},set:function(a){F=a}},margin:{get:function(){return l},set:function(a){l.top=void 0!==a.top?a.top:l.top,l.right=void 0!==a.right?a.right:l.right,l.bottom=void 0!==a.bottom?a.bottom:l.bottom,l.left=void 0!==a.left?a.left:l.left}},color:{get:function(){return m},set:function(b){m=a.utils.getColor(b),i.color(m)}},useInteractiveGuideline:{get:function(){return v},set:function(a){v=a,a===!0&&(b.interactive(!1),b.useVoronoi(!1))}},rightAlignYAxis:{get:function(){return s},set:function(a){s=a,h.orient(a?"right":"left")}},duration:{get:function(){return E},set:function(a){E=a,f.duration(E),g.duration(E),h.duration(E),I.reset(E)}}}),a.utils.inheritOptions(b,f),a.utils.initOptions(b),b},a.models.discreteBar=function(){"use strict";function b(l){return x.reset(),l.each(function(b){var l=j-i.left-i.right,w=k-i.top-i.bottom,y=d3.select(this);a.utils.initSVG(y),b.forEach(function(a,b){a.values.forEach(function(a){a.series=b})});var z=c&&d?[]:b.map(function(a){return a.values.map(function(a,b){return{x:o(a,b),y:p(a,b),y0:a.y0}})});m.domain(c||d3.merge(z).map(function(a){return a.x})).rangeBands(e||[0,l],.1),n.domain(d||d3.extent(d3.merge(z).map(function(a){return a.y}).concat(q))),n.range(s?f||[w-(n.domain()[0]<0?12:0),n.domain()[1]>0?12:0]:f||[w,0]),g=g||m,h=h||n.copy().range([n(0),n(0)]);{var A=y.selectAll("g.nv-wrap.nv-discretebar").data([b]),B=A.enter().append("g").attr("class","nvd3 nv-wrap nv-discretebar"),C=B.append("g");A.select("g")}C.append("g").attr("class","nv-groups"),A.attr("transform","translate("+i.left+","+i.top+")");var D=A.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a){return a.key});D.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),D.exit().watchTransition(x,"discreteBar: exit groups").style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),D.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}),D.watchTransition(x,"discreteBar: groups").style("stroke-opacity",1).style("fill-opacity",.75);var E=D.selectAll("g.nv-bar").data(function(a){return a.values});E.exit().remove();var F=E.enter().append("g").attr("transform",function(a,b){return"translate("+(m(o(a,b))+.05*m.rangeBand())+", "+n(0)+")"}).on("mouseover",function(a,c){d3.select(this).classed("hover",!0),u.elementMouseover({value:p(a,c),point:a,series:b[a.series],pos:[m(o(a,c))+m.rangeBand()*(a.series+.5)/b.length,n(p(a,c))],pointIndex:c,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,c){d3.select(this).classed("hover",!1),u.elementMouseout({value:p(a,c),point:a,series:b[a.series],pointIndex:c,seriesIndex:a.series,e:d3.event})}).on("click",function(a,c){u.elementClick({value:p(a,c),point:a,series:b[a.series],pos:[m(o(a,c))+m.rangeBand()*(a.series+.5)/b.length,n(p(a,c))],pointIndex:c,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,c){u.elementDblClick({value:p(a,c),point:a,series:b[a.series],pos:[m(o(a,c))+m.rangeBand()*(a.series+.5)/b.length,n(p(a,c))],pointIndex:c,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()});F.append("rect").attr("height",0).attr("width",.9*m.rangeBand()/b.length),s?(F.append("text").attr("text-anchor","middle"),E.select("text").text(function(a,b){return t(p(a,b))}).watchTransition(x,"discreteBar: bars text").attr("x",.9*m.rangeBand()/2).attr("y",function(a,b){return p(a,b)<0?n(p(a,b))-n(0)+12:-4})):E.selectAll("text").remove(),E.attr("class",function(a,b){return p(a,b)<0?"nv-bar negative":"nv-bar positive"}).style("fill",function(a,b){return a.color||r(a,b)}).style("stroke",function(a,b){return a.color||r(a,b)}).select("rect").attr("class",v).watchTransition(x,"discreteBar: bars rect").attr("width",.9*m.rangeBand()/b.length),E.watchTransition(x,"discreteBar: bars").attr("transform",function(a,b){var c=m(o(a,b))+.05*m.rangeBand(),d=p(a,b)<0?n(0):n(0)-n(p(a,b))<1?n(0)-1:n(p(a,b));return"translate("+c+", "+d+")"}).select("rect").attr("height",function(a,b){return Math.max(Math.abs(n(p(a,b))-n(d&&d[0]||0))||1)}),g=m.copy(),h=n.copy()}),x.renderEnd("discreteBar immediate"),b}var c,d,e,f,g,h,i={top:0,right:0,bottom:0,left:0},j=960,k=500,l=Math.floor(1e4*Math.random()),m=d3.scale.ordinal(),n=d3.scale.linear(),o=function(a){return a.x},p=function(a){return a.y},q=[0],r=a.utils.defaultColor(),s=!1,t=d3.format(",.2f"),u=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout","renderEnd"),v="discreteBar",w=250,x=a.utils.renderWatch(u,w);return b.dispatch=u,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return j},set:function(a){j=a}},height:{get:function(){return k},set:function(a){k=a}},forceY:{get:function(){return q},set:function(a){q=a}},showValues:{get:function(){return s},set:function(a){s=a}},x:{get:function(){return o},set:function(a){o=a}},y:{get:function(){return p},set:function(a){p=a}},xScale:{get:function(){return m},set:function(a){m=a}},yScale:{get:function(){return n},set:function(a){n=a}},xDomain:{get:function(){return c},set:function(a){c=a}},yDomain:{get:function(){return d},set:function(a){d=a}},xRange:{get:function(){return e},set:function(a){e=a}},yRange:{get:function(){return f},set:function(a){f=a}},valueFormat:{get:function(){return t},set:function(a){t=a}},id:{get:function(){return l},set:function(a){l=a}},rectClass:{get:function(){return v},set:function(a){v=a}},margin:{get:function(){return i},set:function(a){i.top=void 0!==a.top?a.top:i.top,i.right=void 0!==a.right?a.right:i.right,i.bottom=void 0!==a.bottom?a.bottom:i.bottom,i.left=void 0!==a.left?a.left:i.left}},color:{get:function(){return r},set:function(b){r=a.utils.getColor(b)}},duration:{get:function(){return w},set:function(a){w=a,x.reset(w)}}}),a.utils.initOptions(b),b},a.models.discreteBarChart=function(){"use strict";function b(k){return v.reset(),v.models(e),l&&v.models(f),m&&v.models(g),k.each(function(k){var q=d3.select(this),v=this;a.utils.initSVG(q);var w=(i||parseInt(q.style("width"))||960)-h.left-h.right,x=(j||parseInt(q.style("height"))||400)-h.top-h.bottom;if(b.update=function(){s.beforeUpdate(),q.transition().duration(t).call(b)},b.container=this,!(k&&k.length&&k.filter(function(a){return a.values.length}).length)){var y=q.selectAll(".nv-noData").data([r]);return y.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),y.attr("x",h.left+w/2).attr("y",h.top+x/2).text(function(a){return a}),b}q.selectAll(".nv-noData").remove(),c=e.xScale(),d=e.yScale().clamp(!0);var z=q.selectAll("g.nv-wrap.nv-discreteBarWithAxes").data([k]),A=z.enter().append("g").attr("class","nvd3 nv-wrap nv-discreteBarWithAxes").append("g"),B=A.append("defs"),C=z.select("g");A.append("g").attr("class","nv-x nv-axis"),A.append("g").attr("class","nv-y nv-axis").append("g").attr("class","nv-zeroLine").append("line"),A.append("g").attr("class","nv-barsWrap"),C.attr("transform","translate("+h.left+","+h.top+")"),n&&C.select(".nv-y.nv-axis").attr("transform","translate("+w+",0)"),e.width(w).height(x);var D=C.select(".nv-barsWrap").datum(k.filter(function(a){return!a.disabled}));if(D.transition().call(e),B.append("clipPath").attr("id","nv-x-label-clip-"+e.id()).append("rect"),C.select("#nv-x-label-clip-"+e.id()+" rect").attr("width",c.rangeBand()*(o?2:1)).attr("height",16).attr("x",-c.rangeBand()/(o?1:2)),l){f.scale(c).ticks(a.utils.calcTicksX(w/100,k)).tickSize(-x,0),C.select(".nv-x.nv-axis").attr("transform","translate(0,"+(d.range()[0]+(e.showValues()&&d.domain()[0]<0?16:0))+")"),C.select(".nv-x.nv-axis").call(f);var E=C.select(".nv-x.nv-axis").selectAll("g");o&&E.selectAll("text").attr("transform",function(a,b,c){return"translate(0,"+(c%2==0?"5":"17")+")"})}m&&(g.scale(d).ticks(a.utils.calcTicksY(x/36,k)).tickSize(-w,0),C.select(".nv-y.nv-axis").call(g)),C.select(".nv-zeroLine line").attr("x1",0).attr("x2",w).attr("y1",d(0)).attr("y2",d(0)),s.on("tooltipShow",function(a){p&&u(a,v.parentNode)})}),v.renderEnd("discreteBar chart immediate"),b}var c,d,e=a.models.discreteBar(),f=a.models.axis(),g=a.models.axis(),h={top:15,right:10,bottom:50,left:60},i=null,j=null,k=a.utils.getColor(),l=!0,m=!0,n=!1,o=!1,p=!0,q=function(a,b,c){return"

"+b+"

"+c+"

"},r="No Data Available.",s=d3.dispatch("tooltipShow","tooltipHide","beforeUpdate","renderEnd"),t=250;f.orient("bottom").highlightZero(!1).showMaxMin(!1).tickFormat(function(a){return a}),g.orient(n?"right":"left").tickFormat(d3.format(",.1f"));var u=function(c,d){var h=c.pos[0]+(d.offsetLeft||0),i=c.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(c.point,c.pointIndex)),k=g.tickFormat()(e.y()(c.point,c.pointIndex)),l=q(c.series.key,j,k,c,b);a.tooltip.show([h,i],l,c.value<0?"n":"s",null,d)},v=a.utils.renderWatch(s,t);return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+h.left,a.pos[1]+h.top],s.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){s.tooltipHide(a)}),s.on("tooltipHide",function(){p&&a.tooltip.cleanup()}),b.dispatch=s,b.discretebar=e,b.xAxis=f,b.yAxis=g,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return i},set:function(a){i=a}},height:{get:function(){return j},set:function(a){j=a}},staggerLabels:{get:function(){return o},set:function(a){o=a}},showXAxis:{get:function(){return l},set:function(a){l=a}},showYAxis:{get:function(){return m},set:function(a){m=a}},tooltips:{get:function(){return p},set:function(a){p=a}},tooltipContent:{get:function(){return q},set:function(a){q=a}},noData:{get:function(){return r},set:function(a){r=a}},margin:{get:function(){return h},set:function(a){h.top=void 0!==a.top?a.top:h.top,h.right=void 0!==a.right?a.right:h.right,h.bottom=void 0!==a.bottom?a.bottom:h.bottom,h.left=void 0!==a.left?a.left:h.left}},duration:{get:function(){return t},set:function(a){t=a,v.reset(t),e.duration(t),f.duration(t),g.duration(t)}},color:{get:function(){return k},set:function(b){k=a.utils.getColor(b),e.color(k)}},rightAlignYAxis:{get:function(){return n},set:function(a){n=a,g.orient(a?"right":"left")}}}),a.utils.inheritOptions(b,e),a.utils.initOptions(b),b},a.models.distribution=function(){"use strict";function b(k){return m.reset(),k.each(function(b){var k=(e-("x"===g?d.left+d.right:d.top+d.bottom),"x"==g?"y":"x"),l=d3.select(this);a.utils.initSVG(l),c=c||j;var n=l.selectAll("g.nv-distribution").data([b]),o=n.enter().append("g").attr("class","nvd3 nv-distribution"),p=(o.append("g"),n.select("g"));n.attr("transform","translate("+d.left+","+d.top+")");var q=p.selectAll("g.nv-dist").data(function(a){return a},function(a){return a.key});q.enter().append("g"),q.attr("class",function(a,b){return"nv-dist nv-series-"+b}).style("stroke",function(a,b){return i(a,b)});var r=q.selectAll("line.nv-dist"+g).data(function(a){return a.values});r.enter().append("line").attr(g+"1",function(a,b){return c(h(a,b))}).attr(g+"2",function(a,b){return c(h(a,b))}),m.transition(q.exit().selectAll("line.nv-dist"+g),"dist exit").attr(g+"1",function(a,b){return j(h(a,b))}).attr(g+"2",function(a,b){return j(h(a,b))}).style("stroke-opacity",0).remove(),r.attr("class",function(a,b){return"nv-dist"+g+" nv-dist"+g+"-"+b}).attr(k+"1",0).attr(k+"2",f),m.transition(r,"dist").attr(g+"1",function(a,b){return j(h(a,b))}).attr(g+"2",function(a,b){return j(h(a,b))}),c=j.copy()}),m.renderEnd("distribution immediate"),b}var c,d={top:0,right:0,bottom:0,left:0},e=400,f=8,g="x",h=function(a){return a[g]},i=a.utils.defaultColor(),j=d3.scale.linear(),k=250,l=d3.dispatch("renderEnd"),m=a.utils.renderWatch(l,k);return b.options=a.utils.optionsFunc.bind(b),b.dispatch=l,b.margin=function(a){return arguments.length?(d.top="undefined"!=typeof a.top?a.top:d.top,d.right="undefined"!=typeof a.right?a.right:d.right,d.bottom="undefined"!=typeof a.bottom?a.bottom:d.bottom,d.left="undefined"!=typeof a.left?a.left:d.left,b):d},b.width=function(a){return arguments.length?(e=a,b):e},b.axis=function(a){return arguments.length?(g=a,b):g},b.size=function(a){return arguments.length?(f=a,b):f},b.getData=function(a){return arguments.length?(h=d3.functor(a),b):h},b.scale=function(a){return arguments.length?(j=a,b):j},b.color=function(c){return arguments.length?(i=a.utils.getColor(c),b):i},b.duration=function(a){return arguments.length?(k=a,m.reset(k),b):k},b},a.models.historicalBar=function(){"use strict";function b(w){return w.each(function(b){v.reset();var w=d3.select(this),x=(h||parseInt(w.style("width"))||960)-g.left-g.right,y=(i||parseInt(w.style("height"))||400)-g.top-g.bottom;a.utils.initSVG(w),k.domain(c||d3.extent(b[0].values.map(m).concat(o))),k.range(q?e||[.5*x/b[0].values.length,x*(b[0].values.length-.5)/b[0].values.length]:e||[0,x]),l.domain(d||d3.extent(b[0].values.map(n).concat(p))).range(f||[y,0]),k.domain()[0]===k.domain()[1]&&k.domain(k.domain()[0]?[k.domain()[0]-.01*k.domain()[0],k.domain()[1]+.01*k.domain()[1]]:[-1,1]),l.domain()[0]===l.domain()[1]&&l.domain(l.domain()[0]?[l.domain()[0]+.01*l.domain()[0],l.domain()[1]-.01*l.domain()[1]]:[-1,1]);var z=w.selectAll("g.nv-wrap.nv-historicalBar-"+j).data([b[0].values]),A=z.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBar-"+j),B=A.append("defs"),C=A.append("g"),D=z.select("g");C.append("g").attr("class","nv-bars"),z.attr("transform","translate("+g.left+","+g.top+")"),w.on("click",function(a,b){t.chartClick({data:a,index:b,pos:d3.event,id:j})}),B.append("clipPath").attr("id","nv-chart-clip-path-"+j).append("rect"),z.select("#nv-chart-clip-path-"+j+" rect").attr("width",x).attr("height",y),D.attr("clip-path",r?"url(#nv-chart-clip-path-"+j+")":"");var E=z.select(".nv-bars").selectAll(".nv-bar").data(function(a){return a},function(a,b){return m(a,b)});E.exit().remove();E.enter().append("rect").attr("x",0).attr("y",function(b,c){return a.utils.NaNtoZero(l(Math.max(0,n(b,c))))}).attr("height",function(b,c){return a.utils.NaNtoZero(Math.abs(l(n(b,c))-l(0)))}).attr("transform",function(a,c){return"translate("+(k(m(a,c))-x/b[0].values.length*.45)+",0)"}).on("mouseover",function(a,c){u&&(d3.select(this).classed("hover",!0),t.elementMouseover({point:a,series:b[0],pos:[k(m(a,c)),l(n(a,c))],pointIndex:c,seriesIndex:0,e:d3.event}))}).on("mouseout",function(a,c){u&&(d3.select(this).classed("hover",!1),t.elementMouseout({point:a,series:b[0],pointIndex:c,seriesIndex:0,e:d3.event}))}).on("click",function(a,b){u&&(t.elementClick({value:n(a,b),data:a,index:b,pos:[k(m(a,b)),l(n(a,b))],e:d3.event,id:j}),d3.event.stopPropagation())}).on("dblclick",function(a,b){u&&(t.elementDblClick({value:n(a,b),data:a,index:b,pos:[k(m(a,b)),l(n(a,b))],e:d3.event,id:j}),d3.event.stopPropagation())});E.attr("fill",function(a,b){return s(a,b)}).attr("class",function(a,b,c){return(n(a,b)<0?"nv-bar negative":"nv-bar positive")+" nv-bar-"+c+"-"+b}).watchTransition(v,"bars").attr("transform",function(a,c){return"translate("+(k(m(a,c))-x/b[0].values.length*.45)+",0)"}).attr("width",x/b[0].values.length*.9),E.watchTransition(v,"bars").attr("y",function(b,c){var d=n(b,c)<0?l(0):l(0)-l(n(b,c))<1?l(0)-1:l(n(b,c));return a.utils.NaNtoZero(d)}).attr("height",function(b,c){return a.utils.NaNtoZero(Math.max(Math.abs(l(n(b,c))-l(0)),1))})}),v.renderEnd("historicalBar immediate"),b}var c,d,e,f,g={top:0,right:0,bottom:0,left:0},h=null,i=null,j=Math.floor(1e4*Math.random()),k=d3.scale.linear(),l=d3.scale.linear(),m=function(a){return a.x},n=function(a){return a.y},o=[],p=[0],q=!1,r=!0,s=a.utils.defaultColor(),t=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout","renderEnd"),u=!0,v=a.utils.renderWatch(t,0);return b.highlightPoint=function(a,b){d3.select(".nv-historicalBar-"+j).select(".nv-bars .nv-bar-0-"+a).classed("hover",b)},b.clearHighlights=function(){d3.select(".nv-historicalBar-"+j).select(".nv-bars .nv-bar.hover").classed("hover",!1)},b.dispatch=t,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return h},set:function(a){h=a}},height:{get:function(){return i},set:function(a){i=a}},forceX:{get:function(){return o},set:function(a){o=a}},forceY:{get:function(){return p},set:function(a){p=a}},padData:{get:function(){return q},set:function(a){q=a}},x:{get:function(){return m},set:function(a){m=a}},y:{get:function(){return n},set:function(a){n=a}},xScale:{get:function(){return k},set:function(a){k=a}},yScale:{get:function(){return l},set:function(a){l=a}},xDomain:{get:function(){return c},set:function(a){c=a}},yDomain:{get:function(){return d},set:function(a){d=a}},xRange:{get:function(){return e},set:function(a){e=a}},yRange:{get:function(){return f},set:function(a){f=a}},clipEdge:{get:function(){return r},set:function(a){r=a}},id:{get:function(){return j},set:function(a){j=a}},interactive:{get:function(){return u},set:function(a){u=a}},margin:{get:function(){return g},set:function(a){g.top=void 0!==a.top?a.top:g.top,g.right=void 0!==a.right?a.right:g.right,g.bottom=void 0!==a.bottom?a.bottom:g.bottom,g.left=void 0!==a.left?a.left:g.left}},color:{get:function(){return s},set:function(b){s=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.historicalBarChart=function(b){"use strict";function c(b){return b.each(function(u){B.reset(),B.models(f),p&&B.models(g),q&&B.models(h);var C=d3.select(this),D=this;a.utils.initSVG(C);var E=(m||parseInt(C.style("width"))||960)-k.left-k.right,F=(n||parseInt(C.style("height"))||400)-k.top-k.bottom;if(c.update=function(){C.transition().duration(z).call(c)},c.container=this,v.disabled=u.map(function(a){return!!a.disabled}),!w){var G;w={};for(G in v)w[G]=v[G]instanceof Array?v[G].slice(0):v[G]}if(!(u&&u.length&&u.filter(function(a){return a.values.length}).length)){var H=C.selectAll(".nv-noData").data([x]);return H.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),H.attr("x",k.left+E/2).attr("y",k.top+F/2).text(function(a){return a}),c}C.selectAll(".nv-noData").remove(),d=f.xScale(),e=f.yScale();var I=C.selectAll("g.nv-wrap.nv-historicalBarChart").data([u]),J=I.enter().append("g").attr("class","nvd3 nv-wrap nv-historicalBarChart").append("g"),K=I.select("g");J.append("g").attr("class","nv-x nv-axis"),J.append("g").attr("class","nv-y nv-axis"),J.append("g").attr("class","nv-barsWrap"),J.append("g").attr("class","nv-legendWrap"),J.append("g").attr("class","nv-interactive"),o&&(i.width(E),K.select(".nv-legendWrap").datum(u).call(i),k.top!=i.height()&&(k.top=i.height(),F=(n||parseInt(C.style("height"))||400)-k.top-k.bottom),I.select(".nv-legendWrap").attr("transform","translate(0,"+-k.top+")")),I.attr("transform","translate("+k.left+","+k.top+")"),r&&K.select(".nv-y.nv-axis").attr("transform","translate("+E+",0)"),s&&(j.width(E).height(F).margin({left:k.left,top:k.top}).svgContainer(C).xScale(d),I.select(".nv-interactive").call(j)),f.width(E).height(F).color(u.map(function(a,b){return a.color||l(a,b)}).filter(function(a,b){return!u[b].disabled}));var L=K.select(".nv-barsWrap").datum(u.filter(function(a){return!a.disabled}));L.transition().call(f),p&&(g.scale(d).tickSize(-F,0),K.select(".nv-x.nv-axis").attr("transform","translate(0,"+e.range()[0]+")"),K.select(".nv-x.nv-axis").transition().call(g)),q&&(h.scale(e).ticks(a.utils.calcTicksY(F/36,u)).tickSize(-E,0),K.select(".nv-y.nv-axis").transition().call(h)),j.dispatch.on("elementMousemove",function(b){f.clearHighlights();var d,e,i,m=[];u.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(g){e=a.interactiveBisect(g.values,b.pointXValue,c.x()),f.highlightPoint(e,!0);var h=g.values[e];"undefined"!=typeof h&&("undefined"==typeof d&&(d=h),"undefined"==typeof i&&(i=c.xScale()(c.x()(h,e))),m.push({key:g.key,value:c.y()(h,e),color:l(g,g.seriesIndex),data:g.values[e]}))});var n=g.tickFormat()(c.x()(d,e));j.tooltip.position({left:i+k.left,top:b.mouseY+k.top}).chartContainer(D.parentNode).enabled(t).valueFormatter(function(a){return h.tickFormat()(a)}).data({value:n,series:m})(),j.renderGuideLine(i)}),j.dispatch.on("elementMouseout",function(){y.tooltipHide(),f.clearHighlights()}),i.dispatch.on("legendClick",function(a){a.disabled=!a.disabled,u.filter(function(a){return!a.disabled}).length||u.map(function(a){return a.disabled=!1,I.selectAll(".nv-series").classed("disabled",!1),a}),v.disabled=u.map(function(a){return!!a.disabled}),y.stateChange(v),b.transition().call(c)}),i.dispatch.on("legendDblclick",function(a){u.forEach(function(a){a.disabled=!0}),a.disabled=!1,v.disabled=u.map(function(a){return!!a.disabled}),y.stateChange(v),c.update()}),y.on("tooltipShow",function(a){t&&A(a,D.parentNode)}),y.on("changeState",function(a){"undefined"!=typeof a.disabled&&(u.forEach(function(b,c){b.disabled=a.disabled[c]}),v.disabled=a.disabled),c.update()})}),B.renderEnd("historicalBarChart immediate"),c}var d,e,f=b||a.models.historicalBar(),g=a.models.axis(),h=a.models.axis(),i=a.models.legend(),j=a.interactiveGuideline(),k={top:30,right:90,bottom:50,left:90},l=a.utils.defaultColor(),m=null,n=null,o=!1,p=!0,q=!0,r=!1,s=!1,t=!0,u=function(a,b,c){return"

"+a+"

"+c+" at "+b+"

"},v={},w=null,x="No Data Available.",y=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),z=250;g.orient("bottom").tickPadding(7),h.orient(r?"right":"left");var A=function(b,d){if(d){var e=d3.select(d).select("svg"),i=e.node()?e.attr("viewBox"):null;if(i){i=i.split(" ");var j=parseInt(e.style("width"))/i[2];b.pos[0]=b.pos[0]*j,b.pos[1]=b.pos[1]*j}}var k=b.pos[0]+(d.offsetLeft||0),l=b.pos[1]+(d.offsetTop||0),m=g.tickFormat()(f.x()(b.point,b.pointIndex)),n=h.tickFormat()(f.y()(b.point,b.pointIndex)),o=u(b.series.key,m,n,b,c);a.tooltip.show([k,l],o,null,null,d)},B=a.utils.renderWatch(y,0);return f.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+k.left,a.pos[1]+k.top],y.tooltipShow(a)}),f.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),y.on("tooltipHide",function(){t&&a.tooltip.cleanup()}),c.dispatch=y,c.bars=f,c.legend=i,c.xAxis=g,c.yAxis=h,c.interactiveLayer=j,c.options=a.utils.optionsFunc.bind(c),c._options=Object.create({},{width:{get:function(){return m},set:function(a){m=a}},height:{get:function(){return n},set:function(a){n=a}},showLegend:{get:function(){return o},set:function(a){o=a}},showXAxis:{get:function(){return p},set:function(a){p=a}},showYAxis:{get:function(){return q},set:function(a){q=a}},tooltips:{get:function(){return t},set:function(a){t=a}},tooltipContent:{get:function(){return u},set:function(a){u=a}},defaultState:{get:function(){return w},set:function(a){w=a}},noData:{get:function(){return x},set:function(a){x=a}},margin:{get:function(){return k},set:function(a){k.top=void 0!==a.top?a.top:k.top,k.right=void 0!==a.right?a.right:k.right,k.bottom=void 0!==a.bottom?a.bottom:k.bottom,k.left=void 0!==a.left?a.left:k.left}},color:{get:function(){return l},set:function(b){l=a.utils.getColor(b),i.color(l),f.color(l)}},duration:{get:function(){return z},set:function(a){z=a,B.reset(z),h.duration(z),g.duration(z)}},rightAlignYAxis:{get:function(){return r},set:function(a){r=a,h.orient(a?"right":"left")}},useInteractiveGuideline:{get:function(){return s},set:function(a){s=a,a===!0&&c.interactive(!1)}}}),a.utils.inheritOptions(c,f),a.utils.initOptions(c),c},a.models.ohlcBarChart=function(){var b=a.models.historicalBarChart(a.models.ohlcBar());return b.useInteractiveGuideline(!0),b.interactiveLayer.tooltip.contentGenerator(function(a){var c=a.series[0].data,d=c.open'+a.value+"
open:"+b.yAxis.tickFormat()(c.open)+"
close:"+b.yAxis.tickFormat()(c.close)+"
high"+b.yAxis.tickFormat()(c.high)+"
low:"+b.yAxis.tickFormat()(c.low)+"
"}),b},a.models.legend=function(){"use strict";function b(m){return m.each(function(b){var m=d-c.left-c.right,n=d3.select(this);a.utils.initSVG(n);var o=n.selectAll("g.nv-legend").data([b]),p=(o.enter().append("g").attr("class","nvd3 nv-legend").append("g"),o.select("g"));o.attr("transform","translate("+c.left+","+c.top+")");var q=p.selectAll(".nv-series").data(function(a){return a}),r=q.enter().append("g").attr("class","nv-series").on("mouseover",function(a,b){l.legendMouseover(a,b)}).on("mouseout",function(a,b){l.legendMouseout(a,b)}).on("click",function(a,c){l.legendClick(a,c),j&&(k?(b.forEach(function(a){a.disabled=!0 +}),a.disabled=!1):(a.disabled=!a.disabled,b.every(function(a){return a.disabled})&&b.forEach(function(a){a.disabled=!1})),l.stateChange({disabled:b.map(function(a){return!!a.disabled})}))}).on("dblclick",function(a,c){l.legendDblclick(a,c),j&&(b.forEach(function(a){a.disabled=!0}),a.disabled=!1,l.stateChange({disabled:b.map(function(a){return!!a.disabled})}))});if(r.append("circle").style("stroke-width",2).attr("class","nv-legend-symbol").attr("r",5),r.append("text").attr("text-anchor","start").attr("class","nv-legend-text").attr("dy",".32em").attr("dx","8"),q.classed("nv-disabled",function(a){return a.disabled}),q.exit().remove(),q.select("circle").style("fill",function(a,b){return a.color||g(a,b)}).style("stroke",function(a,b){return a.color||g(a,b)}),q.select("text").text(f),h){var s=[];q.each(function(){var b,c=d3.select(this).select("text");try{if(b=c.node().getComputedTextLength(),0>=b)throw Error()}catch(d){b=a.utils.calcApproxTextWidth(c)}s.push(b+28)});for(var t=0,u=0,v=[];m>u&&tm&&t>1;){v=[],t--;for(var w=0;w(v[w%t]||0)&&(v[w%t]=s[w]);u=v.reduce(function(a,b){return a+b})}for(var x=[],y=0,z=0;t>y;y++)x[y]=z,z+=v[y];q.attr("transform",function(a,b){return"translate("+x[b%t]+","+(5+20*Math.floor(b/t))+")"}),i?p.attr("transform","translate("+(d-c.right-u)+","+c.top+")"):p.attr("transform","translate(0,"+c.top+")"),e=c.top+c.bottom+20*Math.ceil(s.length/t)}else{var A,B=5,C=5,D=0;q.attr("transform",function(){var a=d3.select(this).select("text").node().getComputedTextLength()+28;return A=C,dD&&(D=C),"translate("+A+","+B+")"}),p.attr("transform","translate("+(d-c.right-D)+","+c.top+")"),e=c.top+c.bottom+B+15}}),b}var c={top:5,right:0,bottom:5,left:0},d=400,e=20,f=function(a){return a.key},g=a.utils.defaultColor(),h=!0,i=!0,j=!0,k=!1,l=d3.dispatch("legendClick","legendDblclick","legendMouseover","legendMouseout","stateChange");return b.dispatch=l,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return d},set:function(a){d=a}},height:{get:function(){return e},set:function(a){e=a}},key:{get:function(){return f},set:function(a){f=a}},align:{get:function(){return h},set:function(a){h=a}},rightAlign:{get:function(){return i},set:function(a){i=a}},updateState:{get:function(){return j},set:function(a){j=a}},radioButtonMode:{get:function(){return k},set:function(a){k=a}},margin:{get:function(){return c},set:function(a){c.top=void 0!==a.top?a.top:c.top,c.right=void 0!==a.right?a.right:c.right,c.bottom=void 0!==a.bottom?a.bottom:c.bottom,c.left=void 0!==a.left?a.left:c.left}},color:{get:function(){return g},set:function(b){g=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.line=function(){"use strict";function b(p){return t.reset(),t.models(e),p.each(function(b){var p=g-f.left-f.right,q=h-f.top-f.bottom,u=d3.select(this);a.utils.initSVG(u),c=e.xScale(),d=e.yScale(),r=r||c,s=s||d;var v=u.selectAll("g.nv-wrap.nv-line").data([b]),w=v.enter().append("g").attr("class","nvd3 nv-wrap nv-line"),x=w.append("defs"),y=w.append("g"),z=v.select("g");y.append("g").attr("class","nv-groups"),y.append("g").attr("class","nv-scatterWrap"),v.attr("transform","translate("+f.left+","+f.top+")"),e.width(p).height(q);var A=v.select(".nv-scatterWrap");A.call(e),x.append("clipPath").attr("id","nv-edge-clip-"+e.id()).append("rect"),v.select("#nv-edge-clip-"+e.id()+" rect").attr("width",p).attr("height",q>0?q:0),z.attr("clip-path",n?"url(#nv-edge-clip-"+e.id()+")":""),A.attr("clip-path",n?"url(#nv-edge-clip-"+e.id()+")":"");var B=v.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a){return a.key});B.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),B.exit().remove(),B.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return i(a,b)}).style("stroke",function(a,b){return i(a,b)}),B.watchTransition(t,"line: groups").style("stroke-opacity",1).style("fill-opacity",.5);var C=B.selectAll("path.nv-area").data(function(a){return m(a)?[a]:[]});C.enter().append("path").attr("class","nv-area").attr("d",function(b){return d3.svg.area().interpolate(o).defined(l).x(function(b,c){return a.utils.NaNtoZero(r(j(b,c)))}).y0(function(b,c){return a.utils.NaNtoZero(s(k(b,c)))}).y1(function(){return s(d.domain()[0]<=0?d.domain()[1]>=0?0:d.domain()[1]:d.domain()[0])}).apply(this,[b.values])}),B.exit().selectAll("path.nv-area").remove(),C.watchTransition(t,"line: areaPaths").attr("d",function(b){return d3.svg.area().interpolate(o).defined(l).x(function(b,d){return a.utils.NaNtoZero(c(j(b,d)))}).y0(function(b,c){return a.utils.NaNtoZero(d(k(b,c)))}).y1(function(){return d(d.domain()[0]<=0?d.domain()[1]>=0?0:d.domain()[1]:d.domain()[0])}).apply(this,[b.values])});var D=B.selectAll("path.nv-line").data(function(a){return[a.values]});D.enter().append("path").attr("class","nv-line").attr("d",d3.svg.line().interpolate(o).defined(l).x(function(b,c){return a.utils.NaNtoZero(r(j(b,c)))}).y(function(b,c){return a.utils.NaNtoZero(s(k(b,c)))})),D.watchTransition(t,"line: linePaths").attr("d",d3.svg.line().interpolate(o).defined(l).x(function(b,d){return a.utils.NaNtoZero(c(j(b,d)))}).y(function(b,c){return a.utils.NaNtoZero(d(k(b,c)))})),r=c.copy(),s=d.copy()}),t.renderEnd("line immediate"),b}var c,d,e=a.models.scatter(),f={top:0,right:0,bottom:0,left:0},g=960,h=500,i=a.utils.defaultColor(),j=function(a){return a.x},k=function(a){return a.y},l=function(a,b){return!isNaN(k(a,b))&&null!==k(a,b)},m=function(a){return a.area},n=!1,o="linear",p=250,q=d3.dispatch("elementClick","elementMouseover","elementMouseout","renderEnd");e.pointSize(16).pointDomain([16,256]);var r,s,t=a.utils.renderWatch(q,p);return b.dispatch=q,b.scatter=e,e.dispatch.on("elementClick",function(){q.elementClick.apply(this,arguments)}),e.dispatch.on("elementMouseover",function(){q.elementMouseover.apply(this,arguments)}),e.dispatch.on("elementMouseout",function(){q.elementMouseout.apply(this,arguments)}),b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return g},set:function(a){g=a}},height:{get:function(){return h},set:function(a){h=a}},defined:{get:function(){return l},set:function(a){l=a}},interpolate:{get:function(){return o},set:function(a){o=a}},clipEdge:{get:function(){return n},set:function(a){n=a}},margin:{get:function(){return f},set:function(a){f.top=void 0!==a.top?a.top:f.top,f.right=void 0!==a.right?a.right:f.right,f.bottom=void 0!==a.bottom?a.bottom:f.bottom,f.left=void 0!==a.left?a.left:f.left}},duration:{get:function(){return p},set:function(a){p=a,t.reset(p),e.duration(p)}},isArea:{get:function(){return m},set:function(a){m=d3.functor(a)}},x:{get:function(){return j},set:function(a){j=a,e.x(a)}},y:{get:function(){return k},set:function(a){k=a,e.y(a)}},color:{get:function(){return i},set:function(b){i=a.utils.getColor(b),e.color(i)}}}),a.utils.inheritOptions(b,e),a.utils.initOptions(b),b},a.models.lineChart=function(){"use strict";function b(t){return A.reset(),A.models(e),o&&A.models(f),p&&A.models(g),t.each(function(t){var A=d3.select(this),D=this;a.utils.initSVG(A);var E=(l||parseInt(A.style("width"))||960)-j.left-j.right,F=(m||parseInt(A.style("height"))||400)-j.top-j.bottom;if(b.update=function(){0===y?A.call(b):A.transition().duration(y).call(b)},b.container=this,u.setter(C(t),b.update).getter(B(t)).update(),u.disabled=t.map(function(a){return!!a.disabled}),!v){var G;v={};for(G in u)v[G]=u[G]instanceof Array?u[G].slice(0):u[G]}if(!(t&&t.length&&t.filter(function(a){return a.values.length}).length)){var H=A.selectAll(".nv-noData").data([w]);return H.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),H.attr("x",j.left+E/2).attr("y",j.top+F/2).text(function(a){return a}),b}A.selectAll(".nv-noData").remove(),c=e.xScale(),d=e.yScale();var I=A.selectAll("g.nv-wrap.nv-lineChart").data([t]),J=I.enter().append("g").attr("class","nvd3 nv-wrap nv-lineChart").append("g"),K=I.select("g");J.append("rect").style("opacity",0),J.append("g").attr("class","nv-x nv-axis"),J.append("g").attr("class","nv-y nv-axis"),J.append("g").attr("class","nv-linesWrap"),J.append("g").attr("class","nv-legendWrap"),J.append("g").attr("class","nv-interactive"),K.select("rect").attr("width",E).attr("height",F>0?F:0),n&&(h.width(E),K.select(".nv-legendWrap").datum(t).call(h),j.top!=h.height()&&(j.top=h.height(),F=(m||parseInt(A.style("height"))||400)-j.top-j.bottom),I.select(".nv-legendWrap").attr("transform","translate(0,"+-j.top+")")),I.attr("transform","translate("+j.left+","+j.top+")"),q&&K.select(".nv-y.nv-axis").attr("transform","translate("+E+",0)"),r&&(i.width(E).height(F).margin({left:j.left,top:j.top}).svgContainer(A).xScale(c),I.select(".nv-interactive").call(i)),e.width(E).height(F).color(t.map(function(a,b){return a.color||k(a,b)}).filter(function(a,b){return!t[b].disabled}));var L=K.select(".nv-linesWrap").datum(t.filter(function(a){return!a.disabled}));L.call(e),o&&(f.scale(c).ticks(a.utils.calcTicksX(E/100,t)).tickSize(-F,0),K.select(".nv-x.nv-axis").attr("transform","translate(0,"+d.range()[0]+")"),K.select(".nv-x.nv-axis").call(f)),p&&(g.scale(d).ticks(a.utils.calcTicksY(F/36,t)).tickSize(-E,0),K.select(".nv-y.nv-axis").call(g)),h.dispatch.on("stateChange",function(a){for(var c in a)u[c]=a[c];x.stateChange(u),b.update()}),i.dispatch.on("elementMousemove",function(c){e.clearHighlights();var d,h,l,m=[];if(t.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(f,g){h=a.interactiveBisect(f.values,c.pointXValue,b.x()),e.highlightPoint(g,h,!0);var i=f.values[h];"undefined"!=typeof i&&("undefined"==typeof d&&(d=i),"undefined"==typeof l&&(l=b.xScale()(b.x()(i,h))),m.push({key:f.key,value:b.y()(i,h),color:k(f,f.seriesIndex)}))}),m.length>2){var n=b.yScale().invert(c.mouseY),o=Math.abs(b.yScale().domain()[0]-b.yScale().domain()[1]),p=.03*o,q=a.nearestValueIndex(m.map(function(a){return a.value}),n,p);null!==q&&(m[q].highlight=!0)}var r=f.tickFormat()(b.x()(d,h));i.tooltip.position({left:l+j.left,top:c.mouseY+j.top}).chartContainer(D.parentNode).enabled(s).valueFormatter(function(a){return g.tickFormat()(a)}).data({value:r,series:m})(),i.renderGuideLine(l)}),i.dispatch.on("elementClick",function(c){var d,f=[];t.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(e){var g=a.interactiveBisect(e.values,c.pointXValue,b.x()),h=e.values[g];if("undefined"!=typeof h){"undefined"==typeof d&&(d=b.xScale()(b.x()(h,g)));var i=b.yScale()(b.y()(h,g));f.push({point:h,pointIndex:g,pos:[d,i],seriesIndex:e.seriesIndex,series:e})}}),e.dispatch.elementClick(f)}),i.dispatch.on("elementMouseout",function(){x.tooltipHide(),e.clearHighlights()}),x.on("tooltipShow",function(a){s&&z(a,D.parentNode)}),x.on("changeState",function(a){"undefined"!=typeof a.disabled&&t.length===a.disabled.length&&(t.forEach(function(b,c){b.disabled=a.disabled[c]}),u.disabled=a.disabled),b.update()})}),A.renderEnd("lineChart immediate"),b}var c,d,e=a.models.line(),f=a.models.axis(),g=a.models.axis(),h=a.models.legend(),i=a.interactiveGuideline(),j={top:30,right:20,bottom:50,left:60},k=a.utils.defaultColor(),l=null,m=null,n=!0,o=!0,p=!0,q=!1,r=!1,s=!0,t=function(a,b,c){return"

"+a+"

"+c+" at "+b+"

"},u=a.utils.state(),v=null,w="No Data Available.",x=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),y=250;f.orient("bottom").tickPadding(7),g.orient(q?"right":"left");var z=function(c,d){var h=c.pos[0]+(d.offsetLeft||0),i=c.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(c.point,c.pointIndex)),k=g.tickFormat()(e.y()(c.point,c.pointIndex)),l=t(c.series.key,j,k,c,b);a.tooltip.show([h,i],l,null,null,d)},A=a.utils.renderWatch(x,y),B=function(a){return function(){return{active:a.map(function(a){return!a.disabled})}}},C=function(a){return function(b){void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],x.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){x.tooltipHide(a)}),x.on("tooltipHide",function(){s&&a.tooltip.cleanup()}),b.dispatch=x,b.lines=e,b.legend=h,b.xAxis=f,b.yAxis=g,b.interactiveLayer=i,b.dispatch=x,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return l},set:function(a){l=a}},height:{get:function(){return m},set:function(a){m=a}},showLegend:{get:function(){return n},set:function(a){n=a}},showXAxis:{get:function(){return o},set:function(a){o=a}},showYAxis:{get:function(){return p},set:function(a){p=a}},tooltips:{get:function(){return s},set:function(a){s=a}},tooltipContent:{get:function(){return t},set:function(a){t=a}},defaultState:{get:function(){return v},set:function(a){v=a}},noData:{get:function(){return w},set:function(a){w=a}},margin:{get:function(){return j},set:function(a){j.top=void 0!==a.top?a.top:j.top,j.right=void 0!==a.right?a.right:j.right,j.bottom=void 0!==a.bottom?a.bottom:j.bottom,j.left=void 0!==a.left?a.left:j.left}},duration:{get:function(){return y},set:function(a){y=a,A.reset(y),e.duration(y),f.duration(y),g.duration(y)}},color:{get:function(){return k},set:function(b){k=a.utils.getColor(b),h.color(k),e.color(k)}},rightAlignYAxis:{get:function(){return q},set:function(a){q=a,g.orient(q?"right":"left")}},useInteractiveGuideline:{get:function(){return r},set:function(a){r=a,r&&(e.interactive(!1),e.useVoronoi(!1))}}}),a.utils.inheritOptions(b,e),a.utils.initOptions(b),b},a.models.linePlusBarChart=function(){"use strict";function b(J){return J.each(function(J){function U(a){var b=+("e"==a),c=b?1:-1,d=_/3;return"M"+.5*c+","+d+"A6,6 0 0 "+b+" "+6.5*c+","+(d+6)+"V"+(2*d-6)+"A6,6 0 0 "+b+" "+.5*c+","+2*d+"ZM"+2.5*c+","+(d+8)+"V"+(2*d-8)+"M"+4.5*c+","+(d+8)+"V"+(2*d-8)}function V(){u.empty()||u.extent(H),nb.data([u.empty()?e.domain():H]).each(function(a){var b=e(a[0])-e.range()[0],c=e.range()[1]-e(a[1]);d3.select(this).select(".left").attr("width",0>b?0:b),d3.select(this).select(".right").attr("x",e(a[1])).attr("width",0>c?0:c)})}function W(){H=u.empty()?null:u.extent(),c=u.empty()?e.domain():u.extent(),L.brush({extent:c,brush:u}),V(),l.width(Z).height($).color(J.map(function(a,b){return a.color||B(a,b)}).filter(function(a,b){return!J[b].disabled&&J[b].bar})),j.width(Z).height($).color(J.map(function(a,b){return a.color||B(a,b)}).filter(function(a,b){return!J[b].disabled&&!J[b].bar}));var b=ib.select(".nv-focus .nv-barsWrap").datum(cb.length?cb.map(function(a){return{key:a.key,values:a.values.filter(function(a,b){return l.x()(a,b)>=c[0]&&l.x()(a,b)<=c[1]})}}):[{values:[]}]),h=ib.select(".nv-focus .nv-linesWrap").datum(db[0].disabled?[{values:[]}]:db.map(function(a){return{key:a.key,values:a.values.filter(function(a,b){return j.x()(a,b)>=c[0]&&j.x()(a,b)<=c[1]})}}));d=cb.length?l.xScale():j.xScale(),n.scale(d).ticks(a.utils.calcTicksX(Z/100,J)).tickSize(-$,0),n.domain([Math.ceil(c[0]),Math.floor(c[1])]),ib.select(".nv-x.nv-axis").transition().duration(M).call(n),b.transition().duration(M).call(l),h.transition().duration(M).call(j),ib.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+f.range()[0]+")"),p.scale(f).ticks(a.utils.calcTicksY($/36,J)).tickSize(-Z,0),q.scale(g).ticks(a.utils.calcTicksY($/36,J)).tickSize(cb.length?0:-Z,0),ib.select(".nv-focus .nv-y1.nv-axis").style("opacity",cb.length?1:0),ib.select(".nv-focus .nv-y2.nv-axis").style("opacity",db.length&&!db[0].disabled?1:0).attr("transform","translate("+d.range()[1]+",0)"),ib.select(".nv-focus .nv-y1.nv-axis").transition().duration(M).call(p),ib.select(".nv-focus .nv-y2.nv-axis").transition().duration(M).call(q)}var X=d3.select(this),Y=this;a.utils.initSVG(X);var Z=(x||parseInt(X.style("width"))||960)-v.left-v.right,$=(y||parseInt(X.style("height"))||400)-v.top-v.bottom-(D?G:0),_=G-w.top-w.bottom;if(b.update=function(){X.transition().duration(M).call(b)},b.container=this,N.setter(T(J),b.update).getter(S(J)).update(),N.disabled=J.map(function(a){return!!a.disabled}),!O){var ab;O={};for(ab in N)O[ab]=N[ab]instanceof Array?N[ab].slice(0):N[ab]}if(!(J&&J.length&&J.filter(function(a){return a.values.length}).length)){var bb=X.selectAll(".nv-noData").data([K]);return bb.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),bb.attr("x",v.left+Z/2).attr("y",v.top+$/2).text(function(a){return a}),b}X.selectAll(".nv-noData").remove();var cb=J.filter(function(a){return!a.disabled&&a.bar}),db=J.filter(function(a){return!a.bar});d=l.xScale(),e=o.scale(),f=l.yScale(),g=j.yScale(),h=m.yScale(),i=k.yScale();var eb=J.filter(function(a){return!a.disabled&&a.bar}).map(function(a){return a.values.map(function(a,b){return{x:z(a,b),y:A(a,b)}})}),fb=J.filter(function(a){return!a.disabled&&!a.bar}).map(function(a){return a.values.map(function(a,b){return{x:z(a,b),y:A(a,b)}})});d.range([0,Z]),e.domain(d3.extent(d3.merge(eb.concat(fb)),function(a){return a.x})).range([0,Z]);var gb=X.selectAll("g.nv-wrap.nv-linePlusBar").data([J]),hb=gb.enter().append("g").attr("class","nvd3 nv-wrap nv-linePlusBar").append("g"),ib=gb.select("g");hb.append("g").attr("class","nv-legendWrap");var jb=hb.append("g").attr("class","nv-focus");jb.append("g").attr("class","nv-x nv-axis"),jb.append("g").attr("class","nv-y1 nv-axis"),jb.append("g").attr("class","nv-y2 nv-axis"),jb.append("g").attr("class","nv-barsWrap"),jb.append("g").attr("class","nv-linesWrap");var kb=hb.append("g").attr("class","nv-context");kb.append("g").attr("class","nv-x nv-axis"),kb.append("g").attr("class","nv-y1 nv-axis"),kb.append("g").attr("class","nv-y2 nv-axis"),kb.append("g").attr("class","nv-barsWrap"),kb.append("g").attr("class","nv-linesWrap"),kb.append("g").attr("class","nv-brushBackground"),kb.append("g").attr("class","nv-x nv-brush"),C&&(t.width(Z/2),ib.select(".nv-legendWrap").datum(J.map(function(a){return a.originalKey=void 0===a.originalKey?a.key:a.originalKey,a.key=a.originalKey+(a.bar?P:Q),a})).call(t),v.top!=t.height()&&(v.top=t.height(),$=(y||parseInt(X.style("height"))||400)-v.top-v.bottom-G),ib.select(".nv-legendWrap").attr("transform","translate("+Z/2+","+-v.top+")")),gb.attr("transform","translate("+v.left+","+v.top+")"),ib.select(".nv-context").style("display",D?"initial":"none"),m.width(Z).height(_).color(J.map(function(a,b){return a.color||B(a,b)}).filter(function(a,b){return!J[b].disabled&&J[b].bar})),k.width(Z).height(_).color(J.map(function(a,b){return a.color||B(a,b)}).filter(function(a,b){return!J[b].disabled&&!J[b].bar}));var lb=ib.select(".nv-context .nv-barsWrap").datum(cb.length?cb:[{values:[]}]),mb=ib.select(".nv-context .nv-linesWrap").datum(db[0].disabled?[{values:[]}]:db);ib.select(".nv-context").attr("transform","translate(0,"+($+v.bottom+w.top)+")"),lb.transition().call(m),mb.transition().call(k),F&&(o.ticks(a.utils.calcTicksX(Z/100,J)).tickSize(-_,0),ib.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+h.range()[0]+")"),ib.select(".nv-context .nv-x.nv-axis").transition().call(o)),E&&(r.scale(h).ticks(_/36).tickSize(-Z,0),s.scale(i).ticks(_/36).tickSize(cb.length?0:-Z,0),ib.select(".nv-context .nv-y3.nv-axis").style("opacity",cb.length?1:0).attr("transform","translate(0,"+e.range()[0]+")"),ib.select(".nv-context .nv-y2.nv-axis").style("opacity",db.length?1:0).attr("transform","translate("+e.range()[1]+",0)"),ib.select(".nv-context .nv-y1.nv-axis").transition().call(r),ib.select(".nv-context .nv-y2.nv-axis").transition().call(s)),u.x(e).on("brush",W),H&&u.extent(H);var nb=ib.select(".nv-brushBackground").selectAll("g").data([H||u.extent()]),ob=nb.enter().append("g");ob.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",_),ob.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",_);var pb=ib.select(".nv-x.nv-brush").call(u);pb.selectAll("rect").attr("height",_),pb.selectAll(".resize").append("path").attr("d",U),t.dispatch.on("stateChange",function(a){for(var c in a)N[c]=a[c];L.stateChange(N),b.update()}),L.on("tooltipShow",function(a){I&&R(a,Y.parentNode)}),L.on("changeState",function(a){"undefined"!=typeof a.disabled&&(J.forEach(function(b,c){b.disabled=a.disabled[c]}),N.disabled=a.disabled),b.update()}),W()}),b}var c,d,e,f,g,h,i,j=a.models.line(),k=a.models.line(),l=a.models.historicalBar(),m=a.models.historicalBar(),n=a.models.axis(),o=a.models.axis(),p=a.models.axis(),q=a.models.axis(),r=a.models.axis(),s=a.models.axis(),t=a.models.legend(),u=d3.svg.brush(),v={top:30,right:30,bottom:30,left:60},w={top:0,right:30,bottom:20,left:60},x=null,y=null,z=function(a){return a.x},A=function(a){return a.y},B=a.utils.defaultColor(),C=!0,D=!0,E=!1,F=!0,G=50,H=null,I=!0,J=function(a,b,c){return"

"+a+"

"+c+" at "+b+"

"},K="No Data Available.",L=d3.dispatch("tooltipShow","tooltipHide","brush","stateChange","changeState"),M=0,N=a.utils.state(),O=null,P=" (left axis)",Q=" (right axis)";j.clipEdge(!0),k.interactive(!1),n.orient("bottom").tickPadding(5),p.orient("left"),q.orient("right"),o.orient("bottom").tickPadding(5),r.orient("left"),s.orient("right");var R=function(d,e){c&&(d.pointIndex+=Math.ceil(c[0]));var f=d.pos[0]+(e.offsetLeft||0),g=d.pos[1]+(e.offsetTop||0),h=n.tickFormat()(j.x()(d.point,d.pointIndex)),i=(d.series.bar?p:q).tickFormat()(j.y()(d.point,d.pointIndex)),k=J(d.series.key,h,i,d,b);a.tooltip.show([f,g],k,d.value<0?"n":"s",null,e)},S=function(a){return function(){return{active:a.map(function(a){return!a.disabled})}}},T=function(a){return function(b){void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return j.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+v.left,a.pos[1]+v.top],L.tooltipShow(a)}),j.dispatch.on("elementMouseout.tooltip",function(a){L.tooltipHide(a)}),l.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+v.left,a.pos[1]+v.top],L.tooltipShow(a)}),l.dispatch.on("elementMouseout.tooltip",function(a){L.tooltipHide(a)}),L.on("tooltipHide",function(){I&&a.tooltip.cleanup()}),b.dispatch=L,b.legend=t,b.lines=j,b.lines2=k,b.bars=l,b.bars2=m,b.xAxis=n,b.x2Axis=o,b.y1Axis=p,b.y2Axis=q,b.y3Axis=r,b.y4Axis=s,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return x},set:function(a){x=a}},height:{get:function(){return y},set:function(a){y=a}},showLegend:{get:function(){return C},set:function(a){C=a}},tooltips:{get:function(){return I},set:function(a){I=a}},tooltipContent:{get:function(){return J},set:function(a){J=a}},brushExtent:{get:function(){return H},set:function(a){H=a}},noData:{get:function(){return K},set:function(a){K=a}},focusEnable:{get:function(){return D},set:function(a){D=a}},focusHeight:{get:function(){return G},set:function(a){G=a}},focusShowAxisX:{get:function(){return F},set:function(a){F=a}},focusShowAxisY:{get:function(){return E},set:function(a){E=a}},legendLeftAxisHint:{get:function(){return P},set:function(a){P=a}},legendRightAxisHint:{get:function(){return Q},set:function(a){Q=a}},margin:{get:function(){return v},set:function(a){v.top=void 0!==a.top?a.top:v.top,v.right=void 0!==a.right?a.right:v.right,v.bottom=void 0!==a.bottom?a.bottom:v.bottom,v.left=void 0!==a.left?a.left:v.left}},duration:{get:function(){return M},set:function(a){M=a}},color:{get:function(){return B},set:function(b){B=a.utils.getColor(b),t.color(B)}},x:{get:function(){return z},set:function(a){z=a,j.x(a),k.x(a),l.x(a),m.x(a)}},y:{get:function(){return A},set:function(a){A=a,j.y(a),k.y(a),l.y(a),m.y(a)}}}),a.utils.inheritOptions(b,j),a.utils.initOptions(b),b},a.models.lineWithFocusChart=function(){"use strict";function b(x){return x.each(function(x){function G(a){var b=+("e"==a),c=b?1:-1,d=N/3;return"M"+.5*c+","+d+"A6,6 0 0 "+b+" "+6.5*c+","+(d+6)+"V"+(2*d-6)+"A6,6 0 0 "+b+" "+.5*c+","+2*d+"ZM"+2.5*c+","+(d+8)+"V"+(2*d-8)+"M"+4.5*c+","+(d+8)+"V"+(2*d-8)}function H(){n.empty()||n.extent(v),W.data([n.empty()?e.domain():v]).each(function(a){var b=e(a[0])-c.range()[0],d=c.range()[1]-e(a[1]);d3.select(this).select(".left").attr("width",0>b?0:b),d3.select(this).select(".right").attr("x",e(a[1])).attr("width",0>d?0:d)})}function I(){v=n.empty()?null:n.extent();var a=n.empty()?e.domain():n.extent();if(!(Math.abs(a[0]-a[1])<=1)){z.brush({extent:a,brush:n}),H();var b=S.select(".nv-focus .nv-linesWrap").datum(x.filter(function(a){return!a.disabled}).map(function(b){return{key:b.key,area:b.area,values:b.values.filter(function(b,c){return g.x()(b,c)>=a[0]&&g.x()(b,c)<=a[1]})}}));b.transition().duration(A).call(g),S.select(".nv-focus .nv-x.nv-axis").transition().duration(A).call(i),S.select(".nv-focus .nv-y.nv-axis").transition().duration(A).call(j)}}var J=d3.select(this),K=this;a.utils.initSVG(J);var L=(r||parseInt(J.style("width"))||960)-o.left-o.right,M=(s||parseInt(J.style("height"))||400)-o.top-o.bottom-t,N=t-p.top-p.bottom;if(b.update=function(){J.transition().duration(A).call(b)},b.container=this,B.setter(F(x),b.update).getter(E(x)).update(),B.disabled=x.map(function(a){return!!a.disabled}),!C){var O;C={};for(O in B)C[O]=B[O]instanceof Array?B[O].slice(0):B[O]}if(!(x&&x.length&&x.filter(function(a){return a.values.length}).length)){var P=J.selectAll(".nv-noData").data([y]);return P.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),P.attr("x",o.left+L/2).attr("y",o.top+M/2).text(function(a){return a}),b}J.selectAll(".nv-noData").remove(),c=g.xScale(),d=g.yScale(),e=h.xScale(),f=h.yScale();var Q=J.selectAll("g.nv-wrap.nv-lineWithFocusChart").data([x]),R=Q.enter().append("g").attr("class","nvd3 nv-wrap nv-lineWithFocusChart").append("g"),S=Q.select("g");R.append("g").attr("class","nv-legendWrap");var T=R.append("g").attr("class","nv-focus");T.append("g").attr("class","nv-x nv-axis"),T.append("g").attr("class","nv-y nv-axis"),T.append("g").attr("class","nv-linesWrap");var U=R.append("g").attr("class","nv-context");U.append("g").attr("class","nv-x nv-axis"),U.append("g").attr("class","nv-y nv-axis"),U.append("g").attr("class","nv-linesWrap"),U.append("g").attr("class","nv-brushBackground"),U.append("g").attr("class","nv-x nv-brush"),u&&(m.width(L),S.select(".nv-legendWrap").datum(x).call(m),o.top!=m.height()&&(o.top=m.height(),M=(s||parseInt(J.style("height"))||400)-o.top-o.bottom-t),S.select(".nv-legendWrap").attr("transform","translate(0,"+-o.top+")")),Q.attr("transform","translate("+o.left+","+o.top+")"),g.width(L).height(M).color(x.map(function(a,b){return a.color||q(a,b)}).filter(function(a,b){return!x[b].disabled})),h.defined(g.defined()).width(L).height(N).color(x.map(function(a,b){return a.color||q(a,b)}).filter(function(a,b){return!x[b].disabled})),S.select(".nv-context").attr("transform","translate(0,"+(M+o.bottom+p.top)+")");var V=S.select(".nv-context .nv-linesWrap").datum(x.filter(function(a){return!a.disabled}));d3.transition(V).call(h),i.scale(c).ticks(a.utils.calcTicksX(L/100,x)).tickSize(-M,0),j.scale(d).ticks(a.utils.calcTicksY(M/36,x)).tickSize(-L,0),S.select(".nv-focus .nv-x.nv-axis").attr("transform","translate(0,"+M+")"),n.x(e).on("brush",function(){var a=b.duration();b.duration(0),I(),b.duration(a)}),v&&n.extent(v);var W=S.select(".nv-brushBackground").selectAll("g").data([v||n.extent()]),X=W.enter().append("g");X.append("rect").attr("class","left").attr("x",0).attr("y",0).attr("height",N),X.append("rect").attr("class","right").attr("x",0).attr("y",0).attr("height",N);var Y=S.select(".nv-x.nv-brush").call(n);Y.selectAll("rect").attr("height",N),Y.selectAll(".resize").append("path").attr("d",G),I(),k.scale(e).ticks(a.utils.calcTicksX(L/100,x)).tickSize(-N,0),S.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+f.range()[0]+")"),d3.transition(S.select(".nv-context .nv-x.nv-axis")).call(k),l.scale(f).ticks(a.utils.calcTicksY(N/36,x)).tickSize(-L,0),d3.transition(S.select(".nv-context .nv-y.nv-axis")).call(l),S.select(".nv-context .nv-x.nv-axis").attr("transform","translate(0,"+f.range()[0]+")"),m.dispatch.on("stateChange",function(a){for(var c in a)B[c]=a[c];z.stateChange(B),b.update()}),z.on("tooltipShow",function(a){w&&D(a,K.parentNode)}),z.on("changeState",function(a){"undefined"!=typeof a.disabled&&x.forEach(function(b,c){b.disabled=a.disabled[c]}),b.update()})}),b}var c,d,e,f,g=a.models.line(),h=a.models.line(),i=a.models.axis(),j=a.models.axis(),k=a.models.axis(),l=a.models.axis(),m=a.models.legend(),n=d3.svg.brush(),o={top:30,right:30,bottom:30,left:60},p={top:0,right:30,bottom:20,left:60},q=a.utils.defaultColor(),r=null,s=null,t=100,u=!0,v=null,w=!0,x=function(a,b,c){return"

"+a+"

"+c+" at "+b+"

"},y="No Data Available.",z=d3.dispatch("tooltipShow","tooltipHide","brush","stateChange","changeState"),A=250,B=a.utils.state(),C=null;g.clipEdge(!0),h.interactive(!1),i.orient("bottom").tickPadding(5),j.orient("left"),k.orient("bottom").tickPadding(5),l.orient("left");var D=function(c,d){var e=c.pos[0]+(d.offsetLeft||0),f=c.pos[1]+(d.offsetTop||0),h=i.tickFormat()(g.x()(c.point,c.pointIndex)),k=j.tickFormat()(g.y()(c.point,c.pointIndex)),l=x(c.series.key,h,k,c,b);a.tooltip.show([e,f],l,null,null,d)},E=function(a){return function(){return{active:a.map(function(a){return!a.disabled})}}},F=function(a){return function(b){void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return g.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+o.left,a.pos[1]+o.top],z.tooltipShow(a)}),g.dispatch.on("elementMouseout.tooltip",function(a){z.tooltipHide(a)}),z.on("tooltipHide",function(){w&&a.tooltip.cleanup()}),b.dispatch=z,b.legend=m,b.lines=g,b.lines2=h,b.xAxis=i,b.yAxis=j,b.x2Axis=k,b.y2Axis=l,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return r},set:function(a){r=a}},height:{get:function(){return s},set:function(a){s=a}},focusHeight:{get:function(){return t},set:function(a){t=a}},showLegend:{get:function(){return u},set:function(a){u=a}},brushExtent:{get:function(){return v},set:function(a){v=a}},tooltips:{get:function(){return w},set:function(a){w=a}},tooltipContent:{get:function(){return x},set:function(a){x=a}},defaultState:{get:function(){return C},set:function(a){C=a}},noData:{get:function(){return y},set:function(a){y=a}},margin:{get:function(){return o},set:function(a){o.top=void 0!==a.top?a.top:o.top,o.right=void 0!==a.right?a.right:o.right,o.bottom=void 0!==a.bottom?a.bottom:o.bottom,o.left=void 0!==a.left?a.left:o.left}},color:{get:function(){return q},set:function(b){q=a.utils.getColor(b),m.color(q)}},interpolate:{get:function(){return g.interpolate()},set:function(a){g.interpolate(a),h.interpolate(a)}},xTickFormat:{get:function(){return i.xTickFormat()},set:function(a){i.xTickFormat(a),k.xTickFormat(a)}},yTickFormat:{get:function(){return j.yTickFormat()},set:function(a){j.yTickFormat(a),l.yTickFormat(a)}},duration:{get:function(){return A},set:function(a){A=a,j.duration(A),i.duration(A)}},x:{get:function(){return g.x()},set:function(a){g.x(a),h.x(a)}},y:{get:function(){return g.y()},set:function(a){g.y(a),h.y(a)}}}),a.utils.inheritOptions(b,g),a.utils.initOptions(b),b},a.models.multiBar=function(){"use strict";function b(D){return B.reset(),D.each(function(b){var D=k-j.left-j.right,E=l-j.top-j.bottom,F=d3.select(this);a.utils.initSVG(F);w&&b.length&&(w=[{values:b[0].values.map(function(a){return{x:a.x,y:0,series:a.series,size:.01}})}]),t&&(b=d3.layout.stack().offset(u).values(function(a){return a.values}).y(q)(!b.length&&w?w:b)),b.forEach(function(a,b){a.values.forEach(function(a){a.series=b})}),t&&b[0].values.map(function(a,c){var d=0,e=0;b.map(function(a){var b=a.values[c];b.size=Math.abs(b.y),b.y<0?(b.y1=e,e-=b.size):(b.y1=b.size+d,d+=b.size)})});var G=d&&e?[]:b.map(function(a){return a.values.map(function(a,b){return{x:p(a,b),y:q(a,b),y0:a.y0,y1:a.y1}})});m.domain(d||d3.merge(G).map(function(a){return a.x})).rangeBands(f||[0,D],z),n.domain(e||d3.extent(d3.merge(G).map(function(a){return t?a.y>0?a.y1:a.y1+a.y:a.y +}).concat(r))).range(g||[E,0]),m.domain()[0]===m.domain()[1]&&m.domain(m.domain()[0]?[m.domain()[0]-.01*m.domain()[0],m.domain()[1]+.01*m.domain()[1]]:[-1,1]),n.domain()[0]===n.domain()[1]&&n.domain(n.domain()[0]?[n.domain()[0]+.01*n.domain()[0],n.domain()[1]-.01*n.domain()[1]]:[-1,1]),h=h||m,i=i||n;var H=F.selectAll("g.nv-wrap.nv-multibar").data([b]),I=H.enter().append("g").attr("class","nvd3 nv-wrap nv-multibar"),J=I.append("defs"),K=I.append("g"),L=H.select("g");K.append("g").attr("class","nv-groups"),H.attr("transform","translate("+j.left+","+j.top+")"),J.append("clipPath").attr("id","nv-edge-clip-"+o).append("rect"),H.select("#nv-edge-clip-"+o+" rect").attr("width",D).attr("height",E),L.attr("clip-path",s?"url(#nv-edge-clip-"+o+")":"");var M=H.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a,b){return b});M.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6);var N=B.transition(M.exit().selectAll("rect.nv-bar"),"multibarExit",Math.min(100,y)).attr("y",function(a){return i(t?a.y0:0)||0}).attr("height",0).remove();N.delay&&N.delay(function(a,b){var c=b*(y/(C+1))-b;return c}),M.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return v(a,b)}).style("stroke",function(a,b){return v(a,b)}),M.style("stroke-opacity",1).style("fill-opacity",.75);var O=M.selectAll("rect.nv-bar").data(function(a){return w&&!b.length?w.values:a.values});O.exit().remove();O.enter().append("rect").attr("class",function(a,b){return q(a,b)<0?"nv-bar negative":"nv-bar positive"}).attr("x",function(a,c,d){return t?0:d*m.rangeBand()/b.length}).attr("y",function(a){return i(t?a.y0:0)||0}).attr("height",0).attr("width",m.rangeBand()/(t?1:b.length)).attr("transform",function(a,b){return"translate("+m(p(a,b))+",0)"});O.style("fill",function(a,b,c){return v(a,c,b)}).style("stroke",function(a,b,c){return v(a,c,b)}).on("mouseover",function(a,c){d3.select(this).classed("hover",!0),A.elementMouseover({value:q(a,c),point:a,series:b[a.series],pos:[m(p(a,c))+m.rangeBand()*(t?b.length/2:a.series+.5)/b.length,n(q(a,c)+(t?a.y0:0))],pointIndex:c,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,c){d3.select(this).classed("hover",!1),A.elementMouseout({value:q(a,c),point:a,series:b[a.series],pointIndex:c,seriesIndex:a.series,e:d3.event})}).on("click",function(a,c){A.elementClick({value:q(a,c),point:a,series:b[a.series],pos:[m(p(a,c))+m.rangeBand()*(t?b.length/2:a.series+.5)/b.length,n(q(a,c)+(t?a.y0:0))],pointIndex:c,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,c){A.elementDblClick({value:q(a,c),point:a,series:b[a.series],pos:[m(p(a,c))+m.rangeBand()*(t?b.length/2:a.series+.5)/b.length,n(q(a,c)+(t?a.y0:0))],pointIndex:c,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}),O.attr("class",function(a,b){return q(a,b)<0?"nv-bar negative":"nv-bar positive"}).attr("transform",function(a,b){return"translate("+m(p(a,b))+",0)"}),x&&(c||(c=b.map(function(){return!0})),O.style("fill",function(a,b,d){return d3.rgb(x(a,b)).darker(c.map(function(a,b){return b}).filter(function(a,b){return!c[b]})[d]).toString()}).style("stroke",function(a,b,d){return d3.rgb(x(a,b)).darker(c.map(function(a,b){return b}).filter(function(a,b){return!c[b]})[d]).toString()}));var P=O.watchTransition(B,"multibar",Math.min(250,y)).delay(function(a,c){return c*y/b[0].values.length});t?P.attr("y",function(a){return n(t?a.y1:0)}).attr("height",function(a){return Math.max(Math.abs(n(a.y+(t?a.y0:0))-n(t?a.y0:0)),1)}).attr("x",function(a){return t?0:a.series*m.rangeBand()/b.length}).attr("width",m.rangeBand()/(t?1:b.length)):P.attr("x",function(a){return a.series*m.rangeBand()/b.length}).attr("width",m.rangeBand()/b.length).attr("y",function(a,b){return q(a,b)<0?n(0):n(0)-n(q(a,b))<1?n(0)-1:n(q(a,b))||0}).attr("height",function(a,b){return Math.max(Math.abs(n(q(a,b))-n(0)),1)||0}),h=m.copy(),i=n.copy(),b[0]&&b[0].values&&(C=b[0].values.length)}),B.renderEnd("multibar immediate"),b}var c,d,e,f,g,h,i,j={top:0,right:0,bottom:0,left:0},k=960,l=500,m=d3.scale.ordinal(),n=d3.scale.linear(),o=Math.floor(1e4*Math.random()),p=function(a){return a.x},q=function(a){return a.y},r=[0],s=!0,t=!1,u="zero",v=a.utils.defaultColor(),w=!1,x=null,y=500,z=.1,A=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout","renderEnd"),B=a.utils.renderWatch(A,y),C=0;return b.dispatch=A,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return k},set:function(a){k=a}},height:{get:function(){return l},set:function(a){l=a}},x:{get:function(){return p},set:function(a){p=a}},y:{get:function(){return q},set:function(a){q=a}},xScale:{get:function(){return m},set:function(a){m=a}},yScale:{get:function(){return n},set:function(a){n=a}},xDomain:{get:function(){return d},set:function(a){d=a}},yDomain:{get:function(){return e},set:function(a){e=a}},xRange:{get:function(){return f},set:function(a){f=a}},yRange:{get:function(){return g},set:function(a){g=a}},forceY:{get:function(){return r},set:function(a){r=a}},stacked:{get:function(){return t},set:function(a){t=a}},stackOffset:{get:function(){return u},set:function(a){u=a}},clipEdge:{get:function(){return s},set:function(a){s=a}},disabled:{get:function(){return c},set:function(a){c=a}},id:{get:function(){return o},set:function(a){o=a}},hideable:{get:function(){return w},set:function(a){w=a}},groupSpacing:{get:function(){return z},set:function(a){z=a}},margin:{get:function(){return j},set:function(a){j.top=void 0!==a.top?a.top:j.top,j.right=void 0!==a.right?a.right:j.right,j.bottom=void 0!==a.bottom?a.bottom:j.bottom,j.left=void 0!==a.left?a.left:j.left}},duration:{get:function(){return y},set:function(a){y=a,B.reset(y)}},color:{get:function(){return v},set:function(b){v=a.utils.getColor(b)}},barColor:{get:function(){return x},set:function(b){x=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.multiBarChart=function(){"use strict";function b(x){return E.reset(),E.models(e),q&&E.models(f),r&&E.models(g),x.each(function(x){var E=d3.select(this),J=this;a.utils.initSVG(E);var K=(k||parseInt(E.style("width"))||960)-j.left-j.right,L=(l||parseInt(E.style("height"))||400)-j.top-j.bottom;if(b.update=function(){0===D?E.call(b):E.transition().duration(D).call(b)},b.container=this,y.setter(I(x),b.update).getter(H(x)).update(),y.disabled=x.map(function(a){return!!a.disabled}),!z){var M;z={};for(M in y)z[M]=y[M]instanceof Array?y[M].slice(0):y[M]}if(!(x&&x.length&&x.filter(function(a){return a.values.length}).length)){var N=E.selectAll(".nv-noData").data([A]);return N.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),N.attr("x",j.left+K/2).attr("y",j.top+L/2).text(function(a){return a}),b}E.selectAll(".nv-noData").remove(),c=e.xScale(),d=e.yScale();var O=E.selectAll("g.nv-wrap.nv-multiBarWithLegend").data([x]),P=O.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarWithLegend").append("g"),Q=O.select("g");if(P.append("g").attr("class","nv-x nv-axis"),P.append("g").attr("class","nv-y nv-axis"),P.append("g").attr("class","nv-barsWrap"),P.append("g").attr("class","nv-legendWrap"),P.append("g").attr("class","nv-controlsWrap"),p&&(h.width(K-C()),e.barColor()&&x.forEach(function(a,b){a.color=d3.rgb("#ccc").darker(1.5*b).toString()}),Q.select(".nv-legendWrap").datum(x).call(h),j.top!=h.height()&&(j.top=h.height(),L=(l||parseInt(E.style("height"))||400)-j.top-j.bottom),Q.select(".nv-legendWrap").attr("transform","translate("+C()+","+-j.top+")")),n){var R=[{key:o.grouped||"Grouped",disabled:e.stacked()},{key:o.stacked||"Stacked",disabled:!e.stacked()}];i.width(C()).color(["#444","#444","#444"]),Q.select(".nv-controlsWrap").datum(R).attr("transform","translate(0,"+-j.top+")").call(i)}O.attr("transform","translate("+j.left+","+j.top+")"),s&&Q.select(".nv-y.nv-axis").attr("transform","translate("+K+",0)"),e.disabled(x.map(function(a){return a.disabled})).width(K).height(L).color(x.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!x[b].disabled}));var S=Q.select(".nv-barsWrap").datum(x.filter(function(a){return!a.disabled}));if(S.call(e),q){f.scale(c).ticks(a.utils.calcTicksX(K/100,x)).tickSize(-L,0),Q.select(".nv-x.nv-axis").attr("transform","translate(0,"+d.range()[0]+")"),Q.select(".nv-x.nv-axis").call(f);var T=Q.select(".nv-x.nv-axis > g").selectAll("g");if(T.selectAll("line, text").style("opacity",1),u){var U=function(a,b){return"translate("+a+","+b+")"},V=5,W=17;T.selectAll("text").attr("transform",function(a,b,c){return U(0,c%2==0?V:W)});var X=d3.selectAll(".nv-x.nv-axis .nv-wrap g g text")[0].length;Q.selectAll(".nv-x.nv-axis .nv-axisMaxMin text").attr("transform",function(a,b){return U(0,0===b||X%2!==0?W:V)})}t&&T.filter(function(a,b){return b%Math.ceil(x[0].values.length/(K/100))!==0}).selectAll("text, line").style("opacity",0),v&&T.selectAll(".tick text").attr("transform","rotate("+v+" 0,0)").style("text-anchor",v>0?"start":"end"),Q.select(".nv-x.nv-axis").selectAll("g.nv-axisMaxMin text").style("opacity",1)}r&&(g.scale(d).ticks(a.utils.calcTicksY(L/36,x)).tickSize(-K,0),Q.select(".nv-y.nv-axis").call(g)),h.dispatch.on("stateChange",function(a){for(var c in a)y[c]=a[c];B.stateChange(y),b.update()}),i.dispatch.on("legendClick",function(a){if(a.disabled){switch(R=R.map(function(a){return a.disabled=!0,a}),a.disabled=!1,a.key){case"Grouped":e.stacked(!1);break;case"Stacked":e.stacked(!0)}y.stacked=e.stacked(),B.stateChange(y),b.update()}}),B.on("tooltipShow",function(a){w&&G(a,J.parentNode)}),B.on("changeState",function(a){"undefined"!=typeof a.disabled&&(x.forEach(function(b,c){b.disabled=a.disabled[c]}),y.disabled=a.disabled),"undefined"!=typeof a.stacked&&(e.stacked(a.stacked),y.stacked=a.stacked,F=a.stacked),b.update()})}),E.renderEnd("multibarchart immediate"),b}var c,d,e=a.models.multiBar(),f=a.models.axis(),g=a.models.axis(),h=a.models.legend(),i=a.models.legend(),j={top:30,right:20,bottom:50,left:60},k=null,l=null,m=a.utils.defaultColor(),n=!0,o={},p=!0,q=!0,r=!0,s=!1,t=!0,u=!1,v=0,w=!0,x=function(a,b,c){return"

"+a+"

"+c+" on "+b+"

"},y=a.utils.state(),z=null,A="No Data Available.",B=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),C=function(){return n?180:0},D=250;y.stacked=!1,e.stacked(!1),f.orient("bottom").tickPadding(7).highlightZero(!0).showMaxMin(!1).tickFormat(function(a){return a}),g.orient(s?"right":"left").tickFormat(d3.format(",.1f")),i.updateState(!1);var E=a.utils.renderWatch(B),F=!1,G=function(c,d){var h=c.pos[0]+(d.offsetLeft||0),i=c.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(c.point,c.pointIndex)),k=g.tickFormat()(e.y()(c.point,c.pointIndex)),l=x(c.series.key,j,k,c,b);a.tooltip.show([h,i],l,c.value<0?"n":"s",null,d)},H=function(a){return function(){return{active:a.map(function(a){return!a.disabled}),stacked:F}}},I=function(a){return function(b){void 0!==b.stacked&&(F=b.stacked),void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],B.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){B.tooltipHide(a)}),B.on("tooltipHide",function(){w&&a.tooltip.cleanup()}),b.dispatch=B,b.multibar=e,b.legend=h,b.xAxis=f,b.yAxis=g,b.state=y,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return k},set:function(a){k=a}},height:{get:function(){return l},set:function(a){l=a}},showLegend:{get:function(){return p},set:function(a){p=a}},showControls:{get:function(){return n},set:function(a){n=a}},controlLabels:{get:function(){return o},set:function(a){o=a}},showXAxis:{get:function(){return q},set:function(a){q=a}},showYAxis:{get:function(){return r},set:function(a){r=a}},tooltips:{get:function(){return w},set:function(a){w=a}},tooltipContent:{get:function(){return x},set:function(a){x=a}},defaultState:{get:function(){return z},set:function(a){z=a}},noData:{get:function(){return A},set:function(a){A=a}},reduceXTicks:{get:function(){return t},set:function(a){t=a}},rotateLabels:{get:function(){return v},set:function(a){v=a}},staggerLabels:{get:function(){return u},set:function(a){u=a}},margin:{get:function(){return j},set:function(a){j.top=void 0!==a.top?a.top:j.top,j.right=void 0!==a.right?a.right:j.right,j.bottom=void 0!==a.bottom?a.bottom:j.bottom,j.left=void 0!==a.left?a.left:j.left}},duration:{get:function(){return D},set:function(a){D=a,e.duration(D),f.duration(D),g.duration(D),E.reset(D)}},color:{get:function(){return m},set:function(b){m=a.utils.getColor(b),h.color(m)}},rightAlignYAxis:{get:function(){return s},set:function(a){s=a,g.orient(s?"right":"left")}}}),a.utils.inheritOptions(b,e),a.utils.initOptions(b),b},a.models.multiBarHorizontal=function(){"use strict";function b(m){return C.reset(),m.each(function(b){var m=k-j.left-j.right,A=l-j.top-j.bottom,D=d3.select(this);a.utils.initSVG(D),v&&(b=d3.layout.stack().offset("zero").values(function(a){return a.values}).y(q)(b)),b.forEach(function(a,b){a.values.forEach(function(a){a.series=b})}),v&&b[0].values.map(function(a,c){var d=0,e=0;b.map(function(a){var b=a.values[c];b.size=Math.abs(b.y),b.y<0?(b.y1=e-b.size,e-=b.size):(b.y1=d,d+=b.size)})});var E=d&&e?[]:b.map(function(a){return a.values.map(function(a,b){return{x:p(a,b),y:q(a,b),y0:a.y0,y1:a.y1}})});n.domain(d||d3.merge(E).map(function(a){return a.x})).rangeBands(f||[0,A],.1),o.domain(e||d3.extent(d3.merge(E).map(function(a){return v?a.y>0?a.y1+a.y:a.y1:a.y}).concat(s))),o.range(w&&!v?g||[o.domain()[0]<0?y:0,m-(o.domain()[1]>0?y:0)]:g||[0,m]),h=h||n,i=i||d3.scale.linear().domain(o.domain()).range([o(0),o(0)]);{var F=d3.select(this).selectAll("g.nv-wrap.nv-multibarHorizontal").data([b]),G=F.enter().append("g").attr("class","nvd3 nv-wrap nv-multibarHorizontal"),H=(G.append("defs"),G.append("g"));F.select("g")}H.append("g").attr("class","nv-groups"),F.attr("transform","translate("+j.left+","+j.top+")");var I=F.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a,b){return b});I.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),I.exit().watchTransition(C,"multibarhorizontal: exit groups").style("stroke-opacity",1e-6).style("fill-opacity",1e-6).remove(),I.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}).style("fill",function(a,b){return t(a,b)}).style("stroke",function(a,b){return t(a,b)}),I.watchTransition(C,"multibarhorizontal: groups").style("stroke-opacity",1).style("fill-opacity",.75);var J=I.selectAll("g.nv-bar").data(function(a){return a.values});J.exit().remove();var K=J.enter().append("g").attr("transform",function(a,c,d){return"translate("+i(v?a.y0:0)+","+(v?0:d*n.rangeBand()/b.length+n(p(a,c)))+")"});K.append("rect").attr("width",0).attr("height",n.rangeBand()/(v?1:b.length)),J.on("mouseover",function(a,c){d3.select(this).classed("hover",!0),B.elementMouseover({value:q(a,c),point:a,series:b[a.series],pos:[o(q(a,c)+(v?a.y0:0)),n(p(a,c))+n.rangeBand()*(v?b.length/2:a.series+.5)/b.length],pointIndex:c,seriesIndex:a.series,e:d3.event})}).on("mouseout",function(a,c){d3.select(this).classed("hover",!1),B.elementMouseout({value:q(a,c),point:a,series:b[a.series],pointIndex:c,seriesIndex:a.series,e:d3.event})}).on("click",function(a,c){B.elementClick({value:q(a,c),point:a,series:b[a.series],pos:[n(p(a,c))+n.rangeBand()*(v?b.length/2:a.series+.5)/b.length,o(q(a,c)+(v?a.y0:0))],pointIndex:c,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}).on("dblclick",function(a,c){B.elementDblClick({value:q(a,c),point:a,series:b[a.series],pos:[n(p(a,c))+n.rangeBand()*(v?b.length/2:a.series+.5)/b.length,o(q(a,c)+(v?a.y0:0))],pointIndex:c,seriesIndex:a.series,e:d3.event}),d3.event.stopPropagation()}),r(b[0],0)&&(K.append("polyline"),J.select("polyline").attr("fill","none").attr("points",function(a,c){var d=r(a,c),e=.8*n.rangeBand()/(2*(v?1:b.length));d=d.length?d:[-Math.abs(d),Math.abs(d)],d=d.map(function(a){return o(a)-o(0)});var f=[[d[0],-e],[d[0],e],[d[0],0],[d[1],0],[d[1],-e],[d[1],e]];return f.map(function(a){return a.join(",")}).join(" ")}).attr("transform",function(a,c){var d=n.rangeBand()/(2*(v?1:b.length));return"translate("+(q(a,c)<0?0:o(q(a,c))-o(0))+", "+d+")"})),K.append("text"),w&&!v?(J.select("text").attr("text-anchor",function(a,b){return q(a,b)<0?"end":"start"}).attr("y",n.rangeBand()/(2*b.length)).attr("dy",".32em").html(function(a,b){var c=z(q(a,b)),d=r(a,b);return void 0===d?c:d.length?c+"+"+z(Math.abs(d[1]))+"-"+z(Math.abs(d[0])):c+"±"+z(Math.abs(d))}),J.watchTransition(C,"multibarhorizontal: bars").select("text").attr("x",function(a,b){return q(a,b)<0?-4:o(q(a,b))-o(0)+4})):J.selectAll("text").text(""),x&&!v?(K.append("text").classed("nv-bar-label",!0),J.select("text.nv-bar-label").attr("text-anchor",function(a,b){return q(a,b)<0?"start":"end"}).attr("y",n.rangeBand()/(2*b.length)).attr("dy",".32em").text(function(a,b){return p(a,b)}),J.watchTransition(C,"multibarhorizontal: bars").select("text.nv-bar-label").attr("x",function(a,b){return q(a,b)<0?o(0)-o(q(a,b))+4:-4})):J.selectAll("text.nv-bar-label").text(""),J.attr("class",function(a,b){return q(a,b)<0?"nv-bar negative":"nv-bar positive"}),u&&(c||(c=b.map(function(){return!0})),J.style("fill",function(a,b,d){return d3.rgb(u(a,b)).darker(c.map(function(a,b){return b}).filter(function(a,b){return!c[b]})[d]).toString()}).style("stroke",function(a,b,d){return d3.rgb(u(a,b)).darker(c.map(function(a,b){return b}).filter(function(a,b){return!c[b]})[d]).toString()})),v?J.watchTransition(C,"multibarhorizontal: bars").attr("transform",function(a,b){return"translate("+o(a.y1)+","+n(p(a,b))+")"}).select("rect").attr("width",function(a,b){return Math.abs(o(q(a,b)+a.y0)-o(a.y0))}).attr("height",n.rangeBand()):J.watchTransition(C,"multibarhorizontal: bars").attr("transform",function(a,c){return"translate("+o(q(a,c)<0?q(a,c):0)+","+(a.series*n.rangeBand()/b.length+n(p(a,c)))+")"}).select("rect").attr("height",n.rangeBand()/b.length).attr("width",function(a,b){return Math.max(Math.abs(o(q(a,b))-o(0)),1)}),h=n.copy(),i=o.copy()}),C.renderEnd("multibarHorizontal immediate"),b}var c,d,e,f,g,h,i,j={top:0,right:0,bottom:0,left:0},k=960,l=500,m=Math.floor(1e4*Math.random()),n=d3.scale.ordinal(),o=d3.scale.linear(),p=function(a){return a.x},q=function(a){return a.y},r=function(a){return a.yErr},s=[0],t=a.utils.defaultColor(),u=null,v=!1,w=!1,x=!1,y=60,z=d3.format(",.2f"),A=250,B=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout","renderEnd"),C=a.utils.renderWatch(B,A);return b.dispatch=B,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return k},set:function(a){k=a}},height:{get:function(){return l},set:function(a){l=a}},x:{get:function(){return p},set:function(a){p=a}},y:{get:function(){return q},set:function(a){q=a}},yErr:{get:function(){return r},set:function(a){r=a}},xScale:{get:function(){return n},set:function(a){n=a}},yScale:{get:function(){return o},set:function(a){o=a}},xDomain:{get:function(){return d},set:function(a){d=a}},yDomain:{get:function(){return e},set:function(a){e=a}},xRange:{get:function(){return f},set:function(a){f=a}},yRange:{get:function(){return g},set:function(a){g=a}},forceY:{get:function(){return s},set:function(a){s=a}},stacked:{get:function(){return v},set:function(a){v=a}},showValues:{get:function(){return w},set:function(a){w=a}},disabled:{get:function(){return c},set:function(a){c=a}},id:{get:function(){return m},set:function(a){m=a}},valueFormat:{get:function(){return z},set:function(a){z=a}},valuePadding:{get:function(){return y},set:function(a){y=a}},margin:{get:function(){return j},set:function(a){j.top=void 0!==a.top?a.top:j.top,j.right=void 0!==a.right?a.right:j.right,j.bottom=void 0!==a.bottom?a.bottom:j.bottom,j.left=void 0!==a.left?a.left:j.left}},duration:{get:function(){return A},set:function(a){A=a,C.reset(A)}},color:{get:function(){return t},set:function(b){t=a.utils.getColor(b)}},barColor:{get:function(){return t},set:function(b){u=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.multiBarHorizontalChart=function(){"use strict";function b(u){return E.reset(),E.models(e),q&&E.models(f),r&&E.models(g),u.each(function(u){var E=d3.select(this),F=this;a.utils.initSVG(E);var G=(k||parseInt(E.style("width"))||960)-j.left-j.right,H=(l||parseInt(E.style("height"))||400)-j.top-j.bottom;if(b.update=function(){E.transition().duration(A).call(b)},b.container=this,s=e.stacked(),v.setter(D(u),b.update).getter(C(u)).update(),v.disabled=u.map(function(a){return!!a.disabled}),!w){var I;w={};for(I in v)w[I]=v[I]instanceof Array?v[I].slice(0):v[I]}if(!(u&&u.length&&u.filter(function(a){return a.values.length}).length)){var J=E.selectAll(".nv-noData").data([x]);return J.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),J.attr("x",j.left+G/2).attr("y",j.top+H/2).text(function(a){return a}),b}E.selectAll(".nv-noData").remove(),c=e.xScale(),d=e.yScale();var K=E.selectAll("g.nv-wrap.nv-multiBarHorizontalChart").data([u]),L=K.enter().append("g").attr("class","nvd3 nv-wrap nv-multiBarHorizontalChart").append("g"),M=K.select("g");if(L.append("g").attr("class","nv-x nv-axis"),L.append("g").attr("class","nv-y nv-axis").append("g").attr("class","nv-zeroLine").append("line"),L.append("g").attr("class","nv-barsWrap"),L.append("g").attr("class","nv-legendWrap"),L.append("g").attr("class","nv-controlsWrap"),p&&(h.width(G-z()),e.barColor()&&u.forEach(function(a,b){a.color=d3.rgb("#ccc").darker(1.5*b).toString()}),M.select(".nv-legendWrap").datum(u).call(h),j.top!=h.height()&&(j.top=h.height(),H=(l||parseInt(E.style("height"))||400)-j.top-j.bottom),M.select(".nv-legendWrap").attr("transform","translate("+z()+","+-j.top+")")),n){var N=[{key:o.grouped||"Grouped",disabled:e.stacked()},{key:o.stacked||"Stacked",disabled:!e.stacked()}];i.width(z()).color(["#444","#444","#444"]),M.select(".nv-controlsWrap").datum(N).attr("transform","translate(0,"+-j.top+")").call(i)}K.attr("transform","translate("+j.left+","+j.top+")"),e.disabled(u.map(function(a){return a.disabled})).width(G).height(H).color(u.map(function(a,b){return a.color||m(a,b)}).filter(function(a,b){return!u[b].disabled}));var O=M.select(".nv-barsWrap").datum(u.filter(function(a){return!a.disabled}));if(O.transition().call(e),q){f.scale(c).ticks(a.utils.calcTicksY(H/24,u)).tickSize(-G,0),M.select(".nv-x.nv-axis").call(f);var P=M.select(".nv-x.nv-axis").selectAll("g");P.selectAll("line, text")}r&&(g.scale(d).ticks(a.utils.calcTicksX(G/100,u)).tickSize(-H,0),M.select(".nv-y.nv-axis").attr("transform","translate(0,"+H+")"),M.select(".nv-y.nv-axis").call(g)),M.select(".nv-zeroLine line").attr("x1",d(0)).attr("x2",d(0)).attr("y1",0).attr("y2",-H),h.dispatch.on("stateChange",function(a){for(var c in a)v[c]=a[c];y.stateChange(v),b.update()}),i.dispatch.on("legendClick",function(a){if(a.disabled){switch(N=N.map(function(a){return a.disabled=!0,a}),a.disabled=!1,a.key){case"Grouped":e.stacked(!1);break;case"Stacked":e.stacked(!0)}v.stacked=e.stacked(),y.stateChange(v),s=e.stacked(),b.update()}}),y.on("tooltipShow",function(a){t&&B(a,F.parentNode)}),y.on("changeState",function(a){"undefined"!=typeof a.disabled&&(u.forEach(function(b,c){b.disabled=a.disabled[c]}),v.disabled=a.disabled),"undefined"!=typeof a.stacked&&(e.stacked(a.stacked),v.stacked=a.stacked,s=a.stacked),b.update()})}),E.renderEnd("multibar horizontal chart immediate"),b}var c,d,e=a.models.multiBarHorizontal(),f=a.models.axis(),g=a.models.axis(),h=a.models.legend().height(30),i=a.models.legend().height(30),j={top:30,right:20,bottom:50,left:60},k=null,l=null,m=a.utils.defaultColor(),n=!0,o={},p=!0,q=!0,r=!0,s=!1,t=!0,u=function(a,b,c){return"

"+a+" - "+b+"

"+c+"

"},v=a.utils.state(),w=null,x="No Data Available.",y=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),z=function(){return n?180:0},A=250;v.stacked=!1,e.stacked(s),f.orient("left").tickPadding(5).highlightZero(!1).showMaxMin(!1).tickFormat(function(a){return a}),g.orient("bottom").tickFormat(d3.format(",.1f")),i.updateState(!1);var B=function(c,d){var h=c.pos[0]+(d.offsetLeft||0),i=c.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(c.point,c.pointIndex)),k=g.tickFormat()(e.y()(c.point,c.pointIndex)),l=u(c.series.key,j,k,c,b);a.tooltip.show([h,i],l,c.value<0?"e":"w",null,d)},C=function(a){return function(){return{active:a.map(function(a){return!a.disabled}),stacked:s}}},D=function(a){return function(b){void 0!==b.stacked&&(s=b.stacked),void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}},E=a.utils.renderWatch(y,A);return e.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+j.left,a.pos[1]+j.top],y.tooltipShow(a)}),e.dispatch.on("elementMouseout.tooltip",function(a){y.tooltipHide(a)}),y.on("tooltipHide",function(){t&&a.tooltip.cleanup()}),b.dispatch=y,b.multibar=e,b.legend=h,b.xAxis=f,b.yAxis=g,b.state=v,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return k},set:function(a){k=a}},height:{get:function(){return l},set:function(a){l=a}},showLegend:{get:function(){return p},set:function(a){p=a}},showControls:{get:function(){return n},set:function(a){n=a}},controlLabels:{get:function(){return o},set:function(a){o=a}},showXAxis:{get:function(){return q},set:function(a){q=a}},showYAxis:{get:function(){return r},set:function(a){r=a}},tooltips:{get:function(){return t},set:function(a){t=a}},tooltipContent:{get:function(){return u},set:function(a){u=a}},defaultState:{get:function(){return w},set:function(a){w=a}},noData:{get:function(){return x},set:function(a){x=a}},margin:{get:function(){return j},set:function(a){j.top=void 0!==a.top?a.top:j.top,j.right=void 0!==a.right?a.right:j.right,j.bottom=void 0!==a.bottom?a.bottom:j.bottom,j.left=void 0!==a.left?a.left:j.left}},duration:{get:function(){return A},set:function(a){A=a,E.reset(A),e.duration(A),f.duration(A),g.duration(A)}},color:{get:function(){return m},set:function(b){m=a.utils.getColor(b),h.color(m)}}}),a.utils.inheritOptions(b,e),a.utils.initOptions(b),b},a.models.multiChart=function(){"use strict";function b(l){return l.each(function(l){var n=d3.select(this),o=this;a.utils.initSVG(n),b.update=function(){n.transition().call(b)},b.container=this;var E=(h||parseInt(n.style("width"))||960)-f.left-f.right,F=(i||parseInt(n.style("height"))||400)-f.top-f.bottom,G=l.filter(function(a){return"line"==a.type&&1==a.yAxis}),H=l.filter(function(a){return"line"==a.type&&2==a.yAxis}),I=l.filter(function(a){return"bar"==a.type&&1==a.yAxis}),J=l.filter(function(a){return"bar"==a.type&&2==a.yAxis}),K=l.filter(function(a){return"area"==a.type&&1==a.yAxis}),L=l.filter(function(a){return"area"==a.type&&2==a.yAxis});if(!(l&&l.length&&l.filter(function(a){return a.values.length}).length)){var M=n.selectAll(".nv-noData").data([m]);return M.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),M.attr("x",f.left+E/2).attr("y",f.top+F/2).text(function(a){return a}),b}n.selectAll(".nv-noData").remove();var N=l.filter(function(a){return!a.disabled&&1==a.yAxis}).map(function(a){return a.values.map(function(a){return{x:a.x,y:a.y}})}),O=l.filter(function(a){return!a.disabled&&2==a.yAxis}).map(function(a){return a.values.map(function(a){return{x:a.x,y:a.y}})});c.domain(d3.extent(d3.merge(N.concat(O)),function(a){return a.x})).range([0,E]);var P=n.selectAll("g.wrap.multiChart").data([l]),Q=P.enter().append("g").attr("class","wrap nvd3 multiChart").append("g");Q.append("g").attr("class","x axis"),Q.append("g").attr("class","y1 axis"),Q.append("g").attr("class","y2 axis"),Q.append("g").attr("class","lines1Wrap"),Q.append("g").attr("class","lines2Wrap"),Q.append("g").attr("class","bars1Wrap"),Q.append("g").attr("class","bars2Wrap"),Q.append("g").attr("class","stack1Wrap"),Q.append("g").attr("class","stack2Wrap"),Q.append("g").attr("class","legendWrap");var R=P.select("g"),S=l.map(function(a,b){return l[b].color||g(a,b)});j&&(B.color(S),B.width(E/2),R.select(".legendWrap").datum(l.map(function(a){return a.originalKey=void 0===a.originalKey?a.key:a.originalKey,a.key=a.originalKey+(1==a.yAxis?"":" (right axis)"),a})).call(B),f.top!=B.height()&&(f.top=B.height(),F=(i||parseInt(n.style("height"))||400)-f.top-f.bottom),R.select(".legendWrap").attr("transform","translate("+E/2+","+-f.top+")")),s.width(E).height(F).interpolate(p).color(S.filter(function(a,b){return!l[b].disabled&&1==l[b].yAxis&&"line"==l[b].type})),t.width(E).height(F).interpolate(p).color(S.filter(function(a,b){return!l[b].disabled&&2==l[b].yAxis&&"line"==l[b].type})),u.width(E).height(F).color(S.filter(function(a,b){return!l[b].disabled&&1==l[b].yAxis&&"bar"==l[b].type})),v.width(E).height(F).color(S.filter(function(a,b){return!l[b].disabled&&2==l[b].yAxis&&"bar"==l[b].type})),w.width(E).height(F).color(S.filter(function(a,b){return!l[b].disabled&&1==l[b].yAxis&&"area"==l[b].type})),x.width(E).height(F).color(S.filter(function(a,b){return!l[b].disabled&&2==l[b].yAxis&&"area"==l[b].type})),R.attr("transform","translate("+f.left+","+f.top+")");var T=R.select(".lines1Wrap").datum(G.filter(function(a){return!a.disabled})),U=R.select(".bars1Wrap").datum(I.filter(function(a){return!a.disabled})),V=R.select(".stack1Wrap").datum(K.filter(function(a){return!a.disabled})),W=R.select(".lines2Wrap").datum(H.filter(function(a){return!a.disabled})),X=R.select(".bars2Wrap").datum(J.filter(function(a){return!a.disabled})),Y=R.select(".stack2Wrap").datum(L.filter(function(a){return!a.disabled})),Z=K.length?K.map(function(a){return a.values}).reduce(function(a,b){return a.map(function(a,c){return{x:a.x,y:a.y+b[c].y}})}).concat([{x:0,y:0}]):[],$=L.length?L.map(function(a){return a.values}).reduce(function(a,b){return a.map(function(a,c){return{x:a.x,y:a.y+b[c].y}})}).concat([{x:0,y:0}]):[];q.domain(d||d3.extent(d3.merge(N).concat(Z),function(a){return a.y})).range([0,F]),r.domain(e||d3.extent(d3.merge(O).concat($),function(a){return a.y})).range([0,F]),s.yDomain(q.domain()),u.yDomain(q.domain()),w.yDomain(q.domain()),t.yDomain(r.domain()),v.yDomain(r.domain()),x.yDomain(r.domain()),K.length&&d3.transition(V).call(w),L.length&&d3.transition(Y).call(x),I.length&&d3.transition(U).call(u),J.length&&d3.transition(X).call(v),G.length&&d3.transition(T).call(s),H.length&&d3.transition(W).call(t),y.ticks(a.utils.calcTicksX(E/100,l)).tickSize(-F,0),R.select(".x.axis").attr("transform","translate(0,"+F+")"),d3.transition(R.select(".x.axis")).call(y),z.ticks(a.utils.calcTicksY(F/36,l)).tickSize(-E,0),d3.transition(R.select(".y1.axis")).call(z),A.ticks(a.utils.calcTicksY(F/36,l)).tickSize(-E,0),d3.transition(R.select(".y2.axis")).call(A),R.select(".y1.axis").classed("nv-disabled",N.length?!1:!0).attr("transform","translate("+c.range()[0]+",0)"),R.select(".y2.axis").classed("nv-disabled",O.length?!1:!0).attr("transform","translate("+c.range()[1]+",0)"),B.dispatch.on("stateChange",function(){b.update()}),C.on("tooltipShow",function(a){k&&D(a,o.parentNode)})}),b}var c,d,e,f={top:30,right:20,bottom:50,left:60},g=a.utils.defaultColor(),h=null,i=null,j=!0,k=!0,l=function(a,b,c){return"

"+a+"

"+c+" at "+b+"

"},m="No Data Available.",n=function(a){return a.x},o=function(a){return a.y},p="monotone",c=d3.scale.linear(),q=d3.scale.linear(),r=d3.scale.linear(),s=a.models.line().yScale(q),t=a.models.line().yScale(r),u=a.models.multiBar().stacked(!1).yScale(q),v=a.models.multiBar().stacked(!1).yScale(r),w=a.models.stackedArea().yScale(q),x=a.models.stackedArea().yScale(r),y=a.models.axis().scale(c).orient("bottom").tickPadding(5),z=a.models.axis().scale(q).orient("left"),A=a.models.axis().scale(r).orient("right"),B=a.models.legend().height(30),C=d3.dispatch("tooltipShow","tooltipHide"),D=function(c,d){var e=c.pos[0]+(d.offsetLeft||0),f=c.pos[1]+(d.offsetTop||0),g=y.tickFormat()(s.x()(c.point,c.pointIndex)),h=(2==c.series.yAxis?A:z).tickFormat()(s.y()(c.point,c.pointIndex)),i=l(c.series.key,g,h,c,b); +a.tooltip.show([e,f],i,void 0,void 0,d.offsetParent)};return s.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],C.tooltipShow(a)}),s.dispatch.on("elementMouseout.tooltip",function(a){C.tooltipHide(a)}),t.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],C.tooltipShow(a)}),t.dispatch.on("elementMouseout.tooltip",function(a){C.tooltipHide(a)}),u.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],C.tooltipShow(a)}),u.dispatch.on("elementMouseout.tooltip",function(a){C.tooltipHide(a)}),v.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],C.tooltipShow(a)}),v.dispatch.on("elementMouseout.tooltip",function(a){C.tooltipHide(a)}),w.dispatch.on("tooltipShow",function(a){return Math.round(100*w.y()(a.point))?(a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],void C.tooltipShow(a)):(setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1)}),w.dispatch.on("tooltipHide",function(a){C.tooltipHide(a)}),x.dispatch.on("tooltipShow",function(a){return Math.round(100*x.y()(a.point))?(a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],void C.tooltipShow(a)):(setTimeout(function(){d3.selectAll(".point.hover").classed("hover",!1)},0),!1)}),x.dispatch.on("tooltipHide",function(a){C.tooltipHide(a)}),s.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],C.tooltipShow(a)}),s.dispatch.on("elementMouseout.tooltip",function(a){C.tooltipHide(a)}),t.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+f.left,a.pos[1]+f.top],C.tooltipShow(a)}),t.dispatch.on("elementMouseout.tooltip",function(a){C.tooltipHide(a)}),C.on("tooltipHide",function(){k&&a.tooltip.cleanup()}),b.dispatch=C,b.lines1=s,b.lines2=t,b.bars1=u,b.bars2=v,b.stack1=w,b.stack2=x,b.xAxis=y,b.yAxis1=z,b.yAxis2=A,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return h},set:function(a){h=a}},height:{get:function(){return i},set:function(a){i=a}},showLegend:{get:function(){return j},set:function(a){j=a}},yDomain1:{get:function(){return d},set:function(a){d=a}},yDomain2:{get:function(){return e},set:function(a){e=a}},tooltips:{get:function(){return k},set:function(a){k=a}},tooltipContent:{get:function(){return l},set:function(a){l=a}},noData:{get:function(){return m},set:function(a){m=a}},interpolate:{get:function(){return p},set:function(a){p=a}},margin:{get:function(){return f},set:function(a){f.top=void 0!==a.top?a.top:f.top,f.right=void 0!==a.right?a.right:f.right,f.bottom=void 0!==a.bottom?a.bottom:f.bottom,f.left=void 0!==a.left?a.left:f.left}},color:{get:function(){return g},set:function(b){g=a.utils.getColor(b)}},x:{get:function(){return n},set:function(a){n=a,s.x(a),u.x(a)}},y:{get:function(){return o},set:function(a){o=a,s.y(a),u.y(a)}}}),a.utils.initOptions(b),b},a.models.ohlcBar=function(){"use strict";function b(x){return x.each(function(b){var x=d3.select(this),z=(h||parseInt(x.style("width"))||960)-g.left-g.right,A=(i||parseInt(x.style("height"))||400)-g.top-g.bottom;a.utils.initSVG(x),k.domain(c||d3.extent(b[0].values.map(m).concat(s))),k.range(u?e||[.5*z/b[0].values.length,z*(b[0].values.length-.5)/b[0].values.length]:e||[0,z]),l.domain(d||[d3.min(b[0].values.map(r).concat(t)),d3.max(b[0].values.map(q).concat(t))]).range(f||[A,0]),k.domain()[0]===k.domain()[1]&&k.domain(k.domain()[0]?[k.domain()[0]-.01*k.domain()[0],k.domain()[1]+.01*k.domain()[1]]:[-1,1]),l.domain()[0]===l.domain()[1]&&l.domain(l.domain()[0]?[l.domain()[0]+.01*l.domain()[0],l.domain()[1]-.01*l.domain()[1]]:[-1,1]);var B=d3.select(this).selectAll("g.nv-wrap.nv-ohlcBar").data([b[0].values]),C=B.enter().append("g").attr("class","nvd3 nv-wrap nv-ohlcBar"),D=C.append("defs"),E=C.append("g"),F=B.select("g");E.append("g").attr("class","nv-ticks"),B.attr("transform","translate("+g.left+","+g.top+")"),x.on("click",function(a,b){y.chartClick({data:a,index:b,pos:d3.event,id:j})}),D.append("clipPath").attr("id","nv-chart-clip-path-"+j).append("rect"),B.select("#nv-chart-clip-path-"+j+" rect").attr("width",z).attr("height",A),F.attr("clip-path",v?"url(#nv-chart-clip-path-"+j+")":"");var G=B.select(".nv-ticks").selectAll(".nv-tick").data(function(a){return a});G.exit().remove();G.enter().append("path").attr("class",function(a,b,c){return(o(a,b)>p(a,b)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+c+"-"+b}).attr("d",function(a,c){var d=z/b[0].values.length*.9;return"m0,0l0,"+(l(o(a,c))-l(q(a,c)))+"l"+-d/2+",0l"+d/2+",0l0,"+(l(r(a,c))-l(o(a,c)))+"l0,"+(l(p(a,c))-l(r(a,c)))+"l"+d/2+",0l"+-d/2+",0z"}).attr("transform",function(a,b){return"translate("+k(m(a,b))+","+l(q(a,b))+")"}).attr("fill",function(){return w[0]}).attr("stroke",function(){return w[0]}).attr("x",0).attr("y",function(a,b){return l(Math.max(0,n(a,b)))}).attr("height",function(a,b){return Math.abs(l(n(a,b))-l(0))});G.attr("class",function(a,b,c){return(o(a,b)>p(a,b)?"nv-tick negative":"nv-tick positive")+" nv-tick-"+c+"-"+b}),d3.transition(G).attr("transform",function(a,b){return"translate("+k(m(a,b))+","+l(q(a,b))+")"}).attr("d",function(a,c){var d=z/b[0].values.length*.9;return"m0,0l0,"+(l(o(a,c))-l(q(a,c)))+"l"+-d/2+",0l"+d/2+",0l0,"+(l(r(a,c))-l(o(a,c)))+"l0,"+(l(p(a,c))-l(r(a,c)))+"l"+d/2+",0l"+-d/2+",0z"})}),b}var c,d,e,f,g={top:0,right:0,bottom:0,left:0},h=null,i=null,j=Math.floor(1e4*Math.random()),k=d3.scale.linear(),l=d3.scale.linear(),m=function(a){return a.x},n=function(a){return a.y},o=function(a){return a.open},p=function(a){return a.close},q=function(a){return a.high},r=function(a){return a.low},s=[],t=[],u=!1,v=!0,w=a.utils.defaultColor(),x=!1,y=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd","chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout");return b.highlightPoint=function(a,c){b.clearHighlights(),d3.select(".nv-ohlcBar .nv-tick-0-"+a).classed("hover",c)},b.clearHighlights=function(){d3.select(".nv-ohlcBar .nv-tick.hover").classed("hover",!1)},b.dispatch=y,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return h},set:function(a){h=a}},height:{get:function(){return i},set:function(a){i=a}},xScale:{get:function(){return k},set:function(a){k=a}},yScale:{get:function(){return l},set:function(a){l=a}},xDomain:{get:function(){return c},set:function(a){c=a}},yDomain:{get:function(){return d},set:function(a){d=a}},xRange:{get:function(){return e},set:function(a){e=a}},yRange:{get:function(){return f},set:function(a){f=a}},forceX:{get:function(){return s},set:function(a){s=a}},forceY:{get:function(){return t},set:function(a){t=a}},padData:{get:function(){return u},set:function(a){u=a}},clipEdge:{get:function(){return v},set:function(a){v=a}},id:{get:function(){return j},set:function(a){j=a}},interactive:{get:function(){return x},set:function(a){x=a}},x:{get:function(){return m},set:function(a){m=a}},y:{get:function(){return n},set:function(a){n=a}},open:{get:function(){return o()},set:function(a){o=a}},close:{get:function(){return p()},set:function(a){p=a}},high:{get:function(){return q},set:function(a){q=a}},low:{get:function(){return r},set:function(a){r=a}},margin:{get:function(){return g},set:function(a){g.top=void 0!=a.top?a.top:g.top,g.right=void 0!=a.right?a.right:g.right,g.bottom=void 0!=a.bottom?a.bottom:g.bottom,g.left=void 0!=a.left?a.left:g.left}},color:{get:function(){return w},set:function(b){w=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.parallelCoordinates=function(){"use strict";function b(m){return m.each(function(m){function n(a){return y(h.map(function(b){return[f(b),g[b](a[b])]}))}function o(){var a=h.filter(function(a){return!g[a].brush.empty()}),b=a.map(function(a){return g[a].brush.extent()});j=[],a.forEach(function(a,c){j[c]={dimension:a,extent:b[c]}}),k=[],x.style("display",function(c){var d=a.every(function(a,d){return b[d][0]<=c[a]&&c[a]<=b[d][1]});return d&&k.push(c),d?null:"none"}),l.brush({filters:j,active:k})}var p=d3.select(this),q=(d||parseInt(p.style("width"))||960)-c.left-c.right,r=(e||parseInt(p.style("height"))||400)-c.top-c.bottom;a.utils.initSVG(p),k=m,b.update=function(){},f.rangePoints([0,q],1).domain(h),h.forEach(function(a){return g[a]=d3.scale.linear().domain(d3.extent(m,function(b){return+b[a]})).range([r,0]),g[a].brush=d3.svg.brush().y(g[a]).on("brush",o),"name"!=a});var s=p.selectAll("g.nv-wrap.nv-parallelCoordinates").data([m]),t=s.enter().append("g").attr("class","nvd3 nv-wrap nv-parallelCoordinates"),u=t.append("g"),v=s.select("g");u.append("g").attr("class","nv-parallelCoordinatesWrap"),s.attr("transform","translate("+c.left+","+c.top+")");var w,x,y=d3.svg.line(),z=d3.svg.axis().orient("left");w=u.append("g").attr("class","background").selectAll("path").data(m).enter().append("path").attr("d",n),x=u.append("g").attr("class","foreground").selectAll("path").data(m).enter().append("path").attr("d",n).attr("stroke",i);var A=v.selectAll(".dimension").data(h).enter().append("g").attr("class","dimension").attr("transform",function(a){return"translate("+f(a)+",0)"});A.append("g").attr("class","axis").each(function(a){d3.select(this).call(z.scale(g[a]))}).append("text").attr("text-anchor","middle").attr("y",-9).text(String),A.append("g").attr("class","brush").each(function(a){d3.select(this).call(g[a].brush)}).selectAll("rect").attr("x",-8).attr("width",16)}),b}var c={top:30,right:10,bottom:10,left:10},d=null,e=null,f=d3.scale.ordinal(),g={},h=[],i=a.utils.defaultColor(),j=[],k=[],l=d3.dispatch("brush");return b.dispatch=l,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return d},set:function(a){d=a}},height:{get:function(){return e},set:function(a){e=a}},dimensions:{get:function(){return h},set:function(a){h=a}},margin:{get:function(){return c},set:function(a){c.top="undefined"!=typeof a.top?a.top:c.top,c.right="undefined"!=typeof a.right?a.right:c.right,c.bottom="undefined"!=typeof a.bottom?a.bottom:c.bottom,c.left="undefined"!=typeof a.left?a.left:c.left}},color:{get:function(){return i},set:function(b){i=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.pie=function(){"use strict";function b(k){return C.reset(),k.each(function(b){function k(a){a.endAngle=isNaN(a.endAngle)?0:a.endAngle,a.startAngle=isNaN(a.startAngle)?0:a.startAngle,r||(a.innerRadius=0);var b=d3.interpolate(this._current,a);return this._current=b(0),function(a){return N(b(a))}}var D=e-c.left-c.right,E=f-c.top-c.bottom,F=Math.min(D,E)/2,G=F-F/5,H=d3.select(this);a.utils.initSVG(H);var I=H.selectAll(".nv-wrap.nv-pie").data(b),J=I.enter().append("g").attr("class","nvd3 nv-wrap nv-pie nv-chart-"+i),K=J.append("g"),L=I.select("g"),M=K.append("g").attr("class","nv-pie");K.append("g").attr("class","nv-pieLabels"),I.attr("transform","translate("+c.left+","+c.top+")"),L.select(".nv-pie").attr("transform","translate("+D/2+","+E/2+")"),L.select(".nv-pieLabels").attr("transform","translate("+D/2+","+E/2+")"),H.on("click",function(a,b){B.chartClick({data:a,index:b,pos:d3.event,id:i})});var N=d3.svg.arc().outerRadius(G),O=d3.svg.arc().outerRadius(G+5);w&&(N.startAngle(w),O.startAngle(w)),y&&(N.endAngle(y),O.endAngle(y)),r&&(N.innerRadius(F*A),O.innerRadius(F*A));var P=d3.layout.pie().sort(null).value(function(a){return a.disabled?0:h(a)});if(P.padAngle&&x&&P.padAngle(x),N.cornerRadius&&z&&(N.cornerRadius(z),O.cornerRadius(z)),r&&s){var Q=M.append("g").attr("class","nv-pie");Q.append("text").style("text-anchor","middle").attr("class","nv-pie-title").text(function(){return s}).attr("dy","0.35em").attr("transform",function(){return"translate(0, "+u+")"})}var R=I.select(".nv-pie").selectAll(".nv-slice").data(P),S=I.select(".nv-pieLabels").selectAll(".nv-label").data(P);R.exit().remove(),S.exit().remove();var T=R.enter().append("g");T.attr("class","nv-slice"),T.on("mouseover",function(a,b){d3.select(this).classed("hover",!0),t&&d3.select(this).select("path").transition().duration(70).attr("d",O),B.elementMouseover({label:g(a.data),value:h(a.data),point:a.data,pointIndex:b,pos:[d3.event.pageX,d3.event.pageY],id:i,color:d3.select(this).style("fill")})}),T.on("mouseout",function(a,b){d3.select(this).classed("hover",!1),t&&d3.select(this).select("path").transition().duration(50).attr("d",N),B.elementMouseout({label:g(a.data),value:h(a.data),point:a.data,index:b,id:i})}),T.on("click",function(a,b){B.elementClick({label:g(a.data),value:h(a.data),point:a.data,index:b,pos:d3.event,id:i}),d3.event.stopPropagation()}),T.on("dblclick",function(a,b){B.elementDblClick({label:g(a.data),value:h(a.data),point:a.data,index:b,pos:d3.event,id:i}),d3.event.stopPropagation()}),R.attr("fill",function(a,b){return j(a,b)}),R.attr("stroke",function(a,b){return j(a,b)});T.append("path").each(function(a){this._current=a});if(R.select("path").transition().attr("d",N).attrTween("d",k),m){var U=d3.svg.arc().innerRadius(0);if(n)var U=N;o&&(U=d3.svg.arc().outerRadius(N.outerRadius())),S.enter().append("g").classed("nv-label",!0).each(function(a){var b=d3.select(this);b.attr("transform",function(a){if(v){a.outerRadius=G+10,a.innerRadius=G+15;var b=(a.startAngle+a.endAngle)/2*(180/Math.PI);return(a.startAngle+a.endAngle)/2q?c[p]:""})}}),C.renderEnd("pie immediate"),b}var c={top:0,right:0,bottom:0,left:0},e=500,f=500,g=function(a){return a.x},h=function(a){return a.y},i=Math.floor(1e4*Math.random()),j=a.utils.defaultColor(),k=d3.format(",.2f"),l=d3.format("%"),m=!0,n=!0,o=!1,p="key",q=.02,r=!1,s=!1,t=!0,u=0,v=!1,w=!1,x=!1,y=!1,z=0,A=.5,B=d3.dispatch("chartClick","elementClick","elementDblClick","elementMouseover","elementMouseout","renderEnd"),C=a.utils.renderWatch(B);return b.dispatch=B,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return e},set:function(a){e=a}},height:{get:function(){return f},set:function(a){f=a}},showLabels:{get:function(){return m},set:function(a){m=a}},title:{get:function(){return s},set:function(a){s=a}},titleOffset:{get:function(){return u},set:function(a){u=a}},labelThreshold:{get:function(){return q},set:function(a){q=a}},labelFormat:{get:function(){return l},set:function(a){l=a}},valueFormat:{get:function(){return k},set:function(a){k=a}},x:{get:function(){return g},set:function(a){g=a}},id:{get:function(){return i},set:function(a){i=a}},endAngle:{get:function(){return y},set:function(a){y=a}},startAngle:{get:function(){return w},set:function(a){w=a}},padAngle:{get:function(){return x},set:function(a){x=a}},cornerRadius:{get:function(){return z},set:function(a){z=a}},donutRatio:{get:function(){return A},set:function(a){A=a}},pieLabelsOutside:{get:function(){return n},set:function(a){n=a}},donutLabelsOutside:{get:function(){return o},set:function(a){o=a}},labelSunbeamLayout:{get:function(){return v},set:function(a){v=a}},donut:{get:function(){return r},set:function(a){r=a}},growOnHover:{get:function(){return t},set:function(a){t=a}},margin:{get:function(){return c},set:function(a){c.top="undefined"!=typeof a.top?a.top:c.top,c.right="undefined"!=typeof a.right?a.right:c.right,c.bottom="undefined"!=typeof a.bottom?a.bottom:c.bottom,c.left="undefined"!=typeof a.left?a.left:c.left}},y:{get:function(){return h},set:function(a){h=d3.functor(a)}},color:{get:function(){return j},set:function(b){j=a.utils.getColor(b)}},labelType:{get:function(){return p},set:function(a){p=a||"key"}}}),a.utils.initOptions(b),b},a.models.pieChart=function(){"use strict";function b(i){return r.reset(),r.models(c),i.each(function(i){var j=d3.select(this);a.utils.initSVG(j);var k=(f||parseInt(j.style("width"),10)||960)-e.left-e.right,o=(g||parseInt(j.style("height"),10)||400)-e.top-e.bottom;if(b.update=function(){j.transition().call(b)},b.container=this,l.setter(t(i),b.update).getter(s(i)).update(),l.disabled=i.map(function(a){return!!a.disabled}),!m){var q;m={};for(q in l)m[q]=l[q]instanceof Array?l[q].slice(0):l[q]}if(!i||!i.length){var r=j.selectAll(".nv-noData").data([n]);return r.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),r.attr("x",e.left+k/2).attr("y",e.top+o/2).text(function(a){return a}),b}j.selectAll(".nv-noData").remove();var u=j.selectAll("g.nv-wrap.nv-pieChart").data([i]),v=u.enter().append("g").attr("class","nvd3 nv-wrap nv-pieChart").append("g"),w=u.select("g");v.append("g").attr("class","nv-pieWrap"),v.append("g").attr("class","nv-legendWrap"),h&&(d.width(k).key(c.x()),u.select(".nv-legendWrap").datum(i).call(d),e.top!=d.height()&&(e.top=d.height(),o=(g||parseInt(j.style("height"))||400)-e.top-e.bottom),u.select(".nv-legendWrap").attr("transform","translate(0,"+-e.top+")")),u.attr("transform","translate("+e.left+","+e.top+")"),c.width(k).height(o);var x=w.select(".nv-pieWrap").datum([i]);d3.transition(x).call(c),d.dispatch.on("stateChange",function(a){for(var c in a)l[c]=a[c];p.stateChange(l),b.update()}),c.dispatch.on("elementMouseout.tooltip",function(a){p.tooltipHide(a)}),p.on("changeState",function(a){"undefined"!=typeof a.disabled&&(i.forEach(function(b,c){b.disabled=a.disabled[c]}),l.disabled=a.disabled),b.update()})}),r.renderEnd("pieChart immediate"),b}var c=a.models.pie(),d=a.models.legend(),e={top:30,right:20,bottom:20,left:20},f=null,g=null,h=!0,i=a.utils.defaultColor(),j=!0,k=function(a,b,c){return'

'+a+"

"+b+"

"},l=a.utils.state(),m=null,n="No Data Available.",o=250,p=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),q=function(d,e){var f=c.x()(d.point),g=d.pos[0]+(e&&e.offsetLeft||0),h=d.pos[1]+(e&&e.offsetTop||0),i=c.valueFormat()(c.y()(d.point)),j=k(f,i,d,b);a.tooltip.show([g,h],j,d.value<0?"n":"s",null,e)},r=a.utils.renderWatch(p),s=function(a){return function(){return{active:a.map(function(a){return!a.disabled})}}},t=function(a){return function(b){void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return c.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+e.left,a.pos[1]+e.top],p.tooltipShow(a)}),p.on("tooltipShow",function(a){j&&q(a)}),p.on("tooltipHide",function(){j&&a.tooltip.cleanup()}),b.legend=d,b.dispatch=p,b.pie=c,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{noData:{get:function(){return n},set:function(a){n=a}},tooltipContent:{get:function(){return k},set:function(a){k=a}},tooltips:{get:function(){return j},set:function(a){j=a}},showLegend:{get:function(){return h},set:function(a){h=a}},defaultState:{get:function(){return m},set:function(a){m=a}},color:{get:function(){return i},set:function(a){i=a,d.color(i),c.color(i)}},duration:{get:function(){return o},set:function(a){o=a,r.reset(o)}}}),a.utils.inheritOptions(b,c),a.utils.initOptions(b),b},a.models.scatter=function(){"use strict";function b(L){return N.reset(),L.each(function(b){function L(){if(!v)return!1;var a=d3.merge(b.map(function(a,b){return a.values.map(function(a,c){var d=o(a,c),e=p(a,c);return[l(d)+1e-7*Math.random(),m(e)+1e-7*Math.random(),b,c,a]}).filter(function(a,b){return w(a[4],b)})}));if(K===!0){a.length<3&&(a.push([l.range()[0]-20,m.range()[0]-20,null,null]),a.push([l.range()[1]+20,m.range()[1]+20,null,null]),a.push([l.range()[0]-20,m.range()[0]+20,null,null]),a.push([l.range()[1]+20,m.range()[1]-20,null,null]));var c=d3.geom.polygon([[-10,-10],[-10,i+10],[h+10,i+10],[h+10,-10]]),d=d3.geom.voronoi(a).map(function(b,d){return{data:c.clip(b),series:a[d][2],point:a[d][3]}});S.select(".nv-point-paths").selectAll("path").remove();var e=S.select(".nv-point-paths").selectAll("path").data(d);if(e.enter().append("svg:path").attr("d",function(a){return a&&a.data&&0!==a.data.length?"M"+a.data.join(",")+"Z":"M 0 0"}).attr("id",function(a,b){return"nv-path-"+b}).attr("clip-path",function(a,b){return"url(#nv-clip-"+b+")"}),A){var f=S.append("svg:g").attr("id","nv-point-clips");f.selectAll("clipPath").data(a).enter().append("svg:clipPath").attr("id",function(a,b){return"nv-clip-"+b}).append("svg:circle").attr("cx",function(a){return a[0]}).attr("cy",function(a){return a[1]}).attr("r",B)}var j=function(a,c){if(M)return 0;var d=b[a.series];if("undefined"!=typeof d){var e=d.values[a.point];c({point:e,series:d,pos:[l(o(e,a.point))+g.left,m(p(e,a.point))+g.top],seriesIndex:a.series,pointIndex:a.point})}};e.on("click",function(a){j(a,J.elementClick)}).on("dblclick",function(a){j(a,J.elementDblClick)}).on("mouseover",function(a){j(a,J.elementMouseover)}).on("mouseout",function(a){j(a,J.elementMouseout)})}else S.select(".nv-groups").selectAll(".nv-group").selectAll(".nv-point").on("click",function(a,c){if(M||!b[a.series])return 0;var d=b[a.series],e=d.values[c];J.elementClick({point:e,series:d,pos:[l(o(e,c))+g.left,m(p(e,c))+g.top],seriesIndex:a.series,pointIndex:c})}).on("mouseover",function(a,c){if(M||!b[a.series])return 0;var d=b[a.series],e=d.values[c];J.elementMouseover({point:e,series:d,pos:[l(o(e,c))+g.left,m(p(e,c))+g.top],seriesIndex:a.series,pointIndex:c})}).on("mouseout",function(a,c){if(M||!b[a.series])return 0;var d=b[a.series],e=d.values[c];J.elementMouseout({point:e,series:d,seriesIndex:a.series,pointIndex:c})});M=!1}var O=d3.select(this),P=(h||parseInt(O.style("width"))||960)-g.left-g.right,Q=(i||parseInt(O.style("height"))||400)-g.top-g.bottom;a.utils.initSVG(O),b.forEach(function(a,b){a.values.forEach(function(a){a.series=b})});var R=C&&D&&G?[]:d3.merge(b.map(function(a){return a.values.map(function(a,b){return{x:o(a,b),y:p(a,b),size:q(a,b)}})}));l.domain(C||d3.extent(R.map(function(a){return a.x}).concat(s))),l.range(x&&b[0]?E||[(P*y+P)/(2*b[0].values.length),P-P*(1+y)/(2*b[0].values.length)]:E||[0,P]),m.domain(D||d3.extent(R.map(function(a){return a.y}).concat(t))).range(F||[Q,0]),n.domain(G||d3.extent(R.map(function(a){return a.size}).concat(u))).range(H||[16,256]),(l.domain()[0]===l.domain()[1]||m.domain()[0]===m.domain()[1])&&(I=!0),l.domain()[0]===l.domain()[1]&&l.domain(l.domain()[0]?[l.domain()[0]-.01*l.domain()[0],l.domain()[1]+.01*l.domain()[1]]:[-1,1]),m.domain()[0]===m.domain()[1]&&m.domain(m.domain()[0]?[m.domain()[0]-.01*m.domain()[0],m.domain()[1]+.01*m.domain()[1]]:[-1,1]),isNaN(l.domain()[0])&&l.domain([-1,1]),isNaN(m.domain()[0])&&m.domain([-1,1]),c=c||l,d=d||m,e=e||n;var S=O.selectAll("g.nv-wrap.nv-scatter").data([b]),T=S.enter().append("g").attr("class","nvd3 nv-wrap nv-scatter nv-chart-"+k+(I?" nv-single-point":"")),U=T.append("defs"),V=T.append("g"),W=S.select("g");V.append("g").attr("class","nv-groups"),V.append("g").attr("class","nv-point-paths"),S.attr("transform","translate("+g.left+","+g.top+")"),U.append("clipPath").attr("id","nv-edge-clip-"+k).append("rect"),S.select("#nv-edge-clip-"+k+" rect").attr("width",P).attr("height",Q>0?Q:0),W.attr("clip-path",z?"url(#nv-edge-clip-"+k+")":""),M=!0;var X=S.select(".nv-groups").selectAll(".nv-group").data(function(a){return a},function(a){return a.key});X.enter().append("g").style("stroke-opacity",1e-6).style("fill-opacity",1e-6),X.exit().remove(),X.attr("class",function(a,b){return"nv-group nv-series-"+b}).classed("hover",function(a){return a.hover}),X.watchTransition(N,"scatter: groups").style("fill",function(a,b){return j(a,b)}).style("stroke",function(a,b){return j(a,b)}).style("stroke-opacity",1).style("fill-opacity",.5);var Y=X.selectAll("path.nv-point").data(function(a){return a.values});Y.enter().append("path").style("fill",function(a){return a.color}).style("stroke",function(a){return a.color}).attr("transform",function(a,b){return"translate("+c(o(a,b))+","+d(p(a,b))+")"}).attr("d",a.utils.symbol().type(r).size(function(a,b){return n(q(a,b))})),Y.exit().remove(),X.exit().selectAll("path.nv-point").watchTransition(N,"scatter exit").attr("transform",function(a,b){return"translate("+l(o(a,b))+","+m(p(a,b))+")"}).remove(),Y.each(function(a,b){d3.select(this).classed("nv-point",!0).classed("nv-point-"+b,!0).classed("hover",!1)}),Y.watchTransition(N,"scatter points").attr("transform",function(a,b){return"translate("+l(o(a,b))+","+m(p(a,b))+")"}).attr("d",a.utils.symbol().type(r).size(function(a,b){return n(q(a,b))})),clearTimeout(f),f=setTimeout(L,300),c=l.copy(),d=m.copy(),e=n.copy()}),N.renderEnd("scatter immediate"),b}var c,d,e,f,g={top:0,right:0,bottom:0,left:0},h=null,i=null,j=a.utils.defaultColor(),k=Math.floor(1e5*Math.random()),l=d3.scale.linear(),m=d3.scale.linear(),n=d3.scale.linear(),o=function(a){return a.x},p=function(a){return a.y},q=function(a){return a.size||1},r=function(a){return a.shape||"circle"},s=[],t=[],u=[],v=!0,w=function(a){return!a.notActive},x=!1,y=.1,z=!1,A=!0,B=function(){return 25},C=null,D=null,E=null,F=null,G=null,H=null,I=!1,J=d3.dispatch("elementClick","elementDblClick","elementMouseover","elementMouseout","renderEnd"),K=!0,L=250,M=!1,N=a.utils.renderWatch(J,L);return b.dispatch=J,b.options=a.utils.optionsFunc.bind(b),b._calls=new function(){this.clearHighlights=function(){return d3.selectAll(".nv-chart-"+k+" .nv-point.hover").classed("hover",!1),null},this.highlightPoint=function(a,b,c){d3.select(".nv-chart-"+k+" .nv-series-"+a+" .nv-point-"+b).classed("hover",c)}},J.on("elementMouseover.point",function(a){v&&b._calls.highlightPoint(a.seriesIndex,a.pointIndex,!0)}),J.on("elementMouseout.point",function(a){v&&b._calls.highlightPoint(a.seriesIndex,a.pointIndex,!1)}),b._options=Object.create({},{width:{get:function(){return h},set:function(a){h=a}},height:{get:function(){return i},set:function(a){i=a}},xScale:{get:function(){return l},set:function(a){l=a}},yScale:{get:function(){return m},set:function(a){m=a}},pointScale:{get:function(){return n},set:function(a){n=a}},xDomain:{get:function(){return C},set:function(a){C=a}},yDomain:{get:function(){return D},set:function(a){D=a}},pointDomain:{get:function(){return G},set:function(a){G=a}},xRange:{get:function(){return E},set:function(a){E=a}},yRange:{get:function(){return F},set:function(a){F=a}},pointRange:{get:function(){return H},set:function(a){H=a}},forceX:{get:function(){return s},set:function(a){s=a}},forceY:{get:function(){return t},set:function(a){t=a}},forcePoint:{get:function(){return u},set:function(a){u=a}},interactive:{get:function(){return v},set:function(a){v=a}},pointActive:{get:function(){return w},set:function(a){w=a}},padDataOuter:{get:function(){return y},set:function(a){y=a}},padData:{get:function(){return x},set:function(a){x=a}},clipEdge:{get:function(){return z},set:function(a){z=a}},clipVoronoi:{get:function(){return A},set:function(a){A=a}},clipRadius:{get:function(){return B},set:function(a){B=a}},id:{get:function(){return k},set:function(a){k=a}},x:{get:function(){return o},set:function(a){o=d3.functor(a)}},y:{get:function(){return p},set:function(a){p=d3.functor(a)}},pointSize:{get:function(){return q},set:function(a){q=d3.functor(a)}},pointShape:{get:function(){return r},set:function(a){r=d3.functor(a)}},margin:{get:function(){return g},set:function(a){g.top=void 0!==a.top?a.top:g.top,g.right=void 0!==a.right?a.right:g.right,g.bottom=void 0!==a.bottom?a.bottom:g.bottom,g.left=void 0!==a.left?a.left:g.left}},duration:{get:function(){return L},set:function(a){L=a,N.reset(L)}},color:{get:function(){return j},set:function(b){j=a.utils.getColor(b)}},useVoronoi:{get:function(){return K},set:function(a){K=a,K===!1&&(A=!1)}}}),a.utils.initOptions(b),b},a.models.scatterChart=function(){"use strict";function b(v){return F.reset(),F.models(c),r&&F.models(d),s&&F.models(e),o&&F.models(g),p&&F.models(h),v.each(function(v){var w=d3.select(this),x=this;a.utils.initSVG(w);var J=(j||parseInt(w.style("width"))||960)-i.left-i.right,K=(k||parseInt(w.style("height"))||400)-i.top-i.bottom;if(b.update=function(){0===C?w.call(b):w.transition().duration(C).call(b)},b.container=this,y.setter(I(v),b.update).getter(H(v)).update(),y.disabled=v.map(function(a){return!!a.disabled}),!z){var L;z={};for(L in y)z[L]=y[L]instanceof Array?y[L].slice(0):y[L]}if(!(v&&v.length&&v.filter(function(a){return a.values.length}).length)){var M=w.selectAll(".nv-noData").data([B]);return M.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),M.attr("x",i.left+J/2).attr("y",i.top+K/2).text(function(a){return a}),F.renderEnd("scatter immediate"),b}w.selectAll(".nv-noData").remove(),m=c.xScale(),n=c.yScale();var N=w.selectAll("g.nv-wrap.nv-scatterChart").data([v]),O=N.enter().append("g").attr("class","nvd3 nv-wrap nv-scatterChart nv-chart-"+c.id()),P=O.append("g"),Q=N.select("g");P.append("rect").attr("class","nvd3 nv-background").style("pointer-events","none"),P.append("g").attr("class","nv-x nv-axis"),P.append("g").attr("class","nv-y nv-axis"),P.append("g").attr("class","nv-scatterWrap"),P.append("g").attr("class","nv-regressionLinesWrap"),P.append("g").attr("class","nv-distWrap"),P.append("g").attr("class","nv-legendWrap"),N.attr("transform","translate("+i.left+","+i.top+")"),t&&Q.select(".nv-y.nv-axis").attr("transform","translate("+J+",0)"),q&&(f.width(J/2),N.select(".nv-legendWrap").datum(v).call(f),i.top!=f.height()&&(i.top=f.height(),K=(k||parseInt(w.style("height"))||400)-i.top-i.bottom),N.select(".nv-legendWrap").attr("transform","translate("+J/2+","+-i.top+")")),c.width(J).height(K).color(v.map(function(a,b){return a.color||l(a,b)}).filter(function(a,b){return!v[b].disabled})),N.select(".nv-scatterWrap").datum(v.filter(function(a){return!a.disabled})).call(c),N.select(".nv-regressionLinesWrap").attr("clip-path","url(#nv-edge-clip-"+c.id()+")");var R=N.select(".nv-regressionLinesWrap").selectAll(".nv-regLines").data(function(a){return a});R.enter().append("g").attr("class","nv-regLines");var S=R.selectAll(".nv-regLine").data(function(a){return[a]});S.enter().append("line").attr("class","nv-regLine").style("stroke-opacity",0),S.filter(function(a){return a.intercept&&a.slope}).watchTransition(F,"scatterPlusLineChart: regline").attr("x1",m.range()[0]).attr("x2",m.range()[1]).attr("y1",function(a){return n(m.domain()[0]*a.slope+a.intercept)}).attr("y2",function(a){return n(m.domain()[1]*a.slope+a.intercept)}).style("stroke",function(a,b,c){return l(a,c)}).style("stroke-opacity",function(a){return a.disabled||"undefined"==typeof a.slope||"undefined"==typeof a.intercept?0:1}),r&&(d.scale(m).ticks(d.ticks()?d.ticks():a.utils.calcTicksX(J/100,v)).tickSize(-K,0),Q.select(".nv-x.nv-axis").attr("transform","translate(0,"+n.range()[0]+")").call(d)),s&&(e.scale(n).ticks(e.ticks()?e.ticks():a.utils.calcTicksY(K/36,v)).tickSize(-J,0),Q.select(".nv-y.nv-axis").call(e)),o&&(g.getData(c.x()).scale(m).width(J).color(v.map(function(a,b){return a.color||l(a,b)}).filter(function(a,b){return!v[b].disabled})),P.select(".nv-distWrap").append("g").attr("class","nv-distributionX"),Q.select(".nv-distributionX").attr("transform","translate(0,"+n.range()[0]+")").datum(v.filter(function(a){return!a.disabled})).call(g)),p&&(h.getData(c.y()).scale(n).width(K).color(v.map(function(a,b){return a.color||l(a,b)}).filter(function(a,b){return!v[b].disabled})),P.select(".nv-distWrap").append("g").attr("class","nv-distributionY"),Q.select(".nv-distributionY").attr("transform","translate("+(t?J:-h.size())+",0)").datum(v.filter(function(a){return!a.disabled +})).call(h)),f.dispatch.on("stateChange",function(a){for(var c in a)y[c]=a[c];A.stateChange(y),b.update()}),c.dispatch.on("elementMouseover.tooltip",function(a){d3.select(".nv-chart-"+c.id()+" .nv-series-"+a.seriesIndex+" .nv-distx-"+a.pointIndex).attr("y1",a.pos[1]-K),d3.select(".nv-chart-"+c.id()+" .nv-series-"+a.seriesIndex+" .nv-disty-"+a.pointIndex).attr("x2",a.pos[0]+g.size()),a.pos=[a.pos[0]+i.left,a.pos[1]+i.top],A.tooltipShow(a)}),A.on("tooltipShow",function(a){u&&G(a,x.parentNode)}),A.on("changeState",function(a){"undefined"!=typeof a.disabled&&(v.forEach(function(b,c){b.disabled=a.disabled[c]}),y.disabled=a.disabled),b.update()}),D=m.copy(),E=n.copy()}),F.renderEnd("scatter with line immediate"),b}var c=a.models.scatter(),d=a.models.axis(),e=a.models.axis(),f=a.models.legend(),g=a.models.distribution(),h=a.models.distribution(),i={top:30,right:20,bottom:50,left:75},j=null,k=null,l=a.utils.defaultColor(),m=c.xScale(),n=c.yScale(),o=!1,p=!1,q=!0,r=!0,s=!0,t=!1,u=!0,v=function(a,b){return""+b+""},w=function(a,b,c){return""+c+""},x=function(a,b,c,d){return"

"+a+"

"+d+"

"},y=a.utils.state(),z=null,A=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),B="No Data Available.",C=250;c.xScale(m).yScale(n),d.orient("bottom").tickPadding(10),e.orient(t?"right":"left").tickPadding(10),g.axis("x"),h.axis("y");var D,E,F=a.utils.renderWatch(A,C),G=function(f,g){var h=f.pos[0]+(g.offsetLeft||0),j=f.pos[1]+(g.offsetTop||0),k=f.pos[0]+(g.offsetLeft||0),l=n.range()[0]+i.top+(g.offsetTop||0),o=m.range()[0]+i.left+(g.offsetLeft||0),p=f.pos[1]+(g.offsetTop||0),q=d.tickFormat()(c.x()(f.point,f.pointIndex)),r=e.tickFormat()(c.y()(f.point,f.pointIndex));null!=v&&a.tooltip.show([k,l],v(f.series.key,q,r,f,b),"n",1,g,"x-nvtooltip"),null!=w&&a.tooltip.show([o,p],w(f.series.key,q,r,f,b),"e",1,g,"y-nvtooltip"),null!=x&&a.tooltip.show([h,j],x(f.series.key,q,r,f.point.tooltip,f,b),f.value<0?"n":"s",null,g)},H=function(a){return function(){return{active:a.map(function(a){return!a.disabled})}}},I=function(a){return function(b){void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return c.dispatch.on("elementMouseout.tooltip",function(a){A.tooltipHide(a),d3.select(".nv-chart-"+c.id()+" .nv-series-"+a.seriesIndex+" .nv-distx-"+a.pointIndex).attr("y1",0),d3.select(".nv-chart-"+c.id()+" .nv-series-"+a.seriesIndex+" .nv-disty-"+a.pointIndex).attr("x2",h.size())}),A.on("tooltipHide",function(){u&&a.tooltip.cleanup()}),b.dispatch=A,b.scatter=c,b.legend=f,b.xAxis=d,b.yAxis=e,b.distX=g,b.distY=h,b._options=Object.create({},{width:{get:function(){return j},set:function(a){j=a}},height:{get:function(){return k},set:function(a){k=a}},showDistX:{get:function(){return o},set:function(a){o=a}},showDistY:{get:function(){return p},set:function(a){p=a}},showLegend:{get:function(){return q},set:function(a){q=a}},showXAxis:{get:function(){return r},set:function(a){r=a}},showYAxis:{get:function(){return s},set:function(a){s=a}},tooltips:{get:function(){return u},set:function(a){u=a}},tooltipContent:{get:function(){return x},set:function(a){x=a}},tooltipXContent:{get:function(){return v},set:function(a){v=a}},tooltipYContent:{get:function(){return w},set:function(a){w=a}},defaultState:{get:function(){return z},set:function(a){z=a}},noData:{get:function(){return B},set:function(a){B=a}},duration:{get:function(){return C},set:function(a){C=a}},margin:{get:function(){return i},set:function(a){i.top=void 0!==a.top?a.top:i.top,i.right=void 0!==a.right?a.right:i.right,i.bottom=void 0!==a.bottom?a.bottom:i.bottom,i.left=void 0!==a.left?a.left:i.left}},rightAlignYAxis:{get:function(){return t},set:function(a){t=a,e.orient(a?"right":"left")}},color:{get:function(){return l},set:function(b){l=a.utils.getColor(b),f.color(l),g.color(l),h.color(l)}}}),a.utils.inheritOptions(b,c),a.utils.initOptions(b),b},a.models.sparkline=function(){"use strict";function b(j){return j.each(function(b){var j=h-g.left-g.right,p=i-g.top-g.bottom,q=d3.select(this);a.utils.initSVG(q),k.domain(c||d3.extent(b,m)).range(e||[0,j]),l.domain(d||d3.extent(b,n)).range(f||[p,0]);{var r=q.selectAll("g.nv-wrap.nv-sparkline").data([b]),s=r.enter().append("g").attr("class","nvd3 nv-wrap nv-sparkline");s.append("g"),r.select("g")}r.attr("transform","translate("+g.left+","+g.top+")");var t=r.selectAll("path").data(function(a){return[a]});t.enter().append("path"),t.exit().remove(),t.style("stroke",function(a,b){return a.color||o(a,b)}).attr("d",d3.svg.line().x(function(a,b){return k(m(a,b))}).y(function(a,b){return l(n(a,b))}));var u=r.selectAll("circle.nv-point").data(function(a){function b(b){if(-1!=b){var c=a[b];return c.pointIndex=b,c}return null}var c=a.map(function(a,b){return n(a,b)}),d=b(c.lastIndexOf(l.domain()[1])),e=b(c.indexOf(l.domain()[0])),f=b(c.length-1);return[e,d,f].filter(function(a){return null!=a})});u.enter().append("circle"),u.exit().remove(),u.attr("cx",function(a){return k(m(a,a.pointIndex))}).attr("cy",function(a){return l(n(a,a.pointIndex))}).attr("r",2).attr("class",function(a){return m(a,a.pointIndex)==k.domain()[1]?"nv-point nv-currentValue":n(a,a.pointIndex)==l.domain()[0]?"nv-point nv-minValue":"nv-point nv-maxValue"})}),b}var c,d,e,f,g={top:2,right:0,bottom:2,left:0},h=400,i=32,j=!0,k=d3.scale.linear(),l=d3.scale.linear(),m=function(a){return a.x},n=function(a){return a.y},o=a.utils.getColor(["#000"]);return b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return h},set:function(a){h=a}},height:{get:function(){return i},set:function(a){i=a}},xDomain:{get:function(){return c},set:function(a){c=a}},yDomain:{get:function(){return d},set:function(a){d=a}},xRange:{get:function(){return e},set:function(a){e=a}},yRange:{get:function(){return f},set:function(a){f=a}},xScale:{get:function(){return k},set:function(a){k=a}},yScale:{get:function(){return l},set:function(a){l=a}},animate:{get:function(){return j},set:function(a){j=a}},x:{get:function(){return m},set:function(a){m=d3.functor(a)}},y:{get:function(){return n},set:function(a){n=d3.functor(a)}},margin:{get:function(){return g},set:function(a){g.top=void 0!==a.top?a.top:g.top,g.right=void 0!==a.right?a.right:g.right,g.bottom=void 0!==a.bottom?a.bottom:g.bottom,g.left=void 0!==a.left?a.left:g.left}},color:{get:function(){return o},set:function(b){o=a.utils.getColor(b)}}}),a.utils.initOptions(b),b},a.models.sparklinePlus=function(){"use strict";function b(m){return m.each(function(q){function r(){if(!j){var a=B.selectAll(".nv-hoverValue").data(i),b=a.enter().append("g").attr("class","nv-hoverValue").style("stroke-opacity",0).style("fill-opacity",0);a.exit().transition().duration(250).style("stroke-opacity",0).style("fill-opacity",0).remove(),a.attr("transform",function(a){return"translate("+c(e.x()(q[a],a))+",0)"}).transition().duration(250).style("stroke-opacity",1).style("fill-opacity",1),i.length&&(b.append("line").attr("x1",0).attr("y1",-f.top).attr("x2",0).attr("y2",v),b.append("text").attr("class","nv-xValue").attr("x",-6).attr("y",-f.top).attr("text-anchor","end").attr("dy",".9em"),B.select(".nv-hoverValue .nv-xValue").text(k(e.x()(q[i[0]],i[0]))),b.append("text").attr("class","nv-yValue").attr("x",6).attr("y",-f.top).attr("text-anchor","start").attr("dy",".9em"),B.select(".nv-hoverValue .nv-yValue").text(l(e.y()(q[i[0]],i[0]))))}}function s(){function a(a,b){for(var c=Math.abs(e.x()(a[0],0)-b),d=0,f=0;fc;++c){for(b=0,d=0;bb;b++)a[b][c][1]/=d;else for(b=0;e>b;b++)a[b][c][1]=g}for(c=0;f>c;++c)h[c]=0;return h}}),t.renderEnd("stackedArea immediate"),b}var c,d,e={top:0,right:0,bottom:0,left:0},f=960,g=500,h=a.utils.defaultColor(),i=Math.floor(1e5*Math.random()),j=function(a){return a.x},k=function(a){return a.y},l="stack",m="zero",n="default",o="linear",p=!1,q=a.models.scatter(),r=250,s=d3.dispatch("tooltipShow","tooltipHide","areaClick","areaMouseover","areaMouseout","renderEnd");q.interactive(!1),q.pointSize(2.2).pointDomain([2.2,2.2]);var t=a.utils.renderWatch(s,r);return q.dispatch.on("elementClick.area",function(a){s.areaClick(a)}),q.dispatch.on("elementMouseover.tooltip",function(a){a.pos=[a.pos[0]+e.left,a.pos[1]+e.top],s.tooltipShow(a)}),q.dispatch.on("elementMouseout.tooltip",function(a){s.tooltipHide(a)}),b.dispatch=s,b.scatter=q,b.interpolate=function(a){return arguments.length?(o=a,b):o},b.duration=function(a){return arguments.length?(r=a,t.reset(r),q.duration(r),b):r},b.dispatch=s,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return f},set:function(a){f=a}},height:{get:function(){return g},set:function(a){g=a}},clipEdge:{get:function(){return p},set:function(a){p=a}},offset:{get:function(){return m},set:function(a){m=a}},order:{get:function(){return n},set:function(a){n=a}},interpolate:{get:function(){return o},set:function(a){o=a}},x:{get:function(){return j},set:function(a){j=d3.functor(a)}},y:{get:function(){return k},set:function(a){k=d3.functor(a)}},margin:{get:function(){return e},set:function(a){e.top=void 0!==a.top?a.top:e.top,e.right=void 0!==a.right?a.right:e.right,e.bottom=void 0!==a.bottom?a.bottom:e.bottom,e.left=void 0!==a.left?a.left:e.left}},color:{get:function(){return h},set:function(b){h=a.utils.getColor(b)}},style:{get:function(){return l},set:function(a){switch(l=a){case"stack":b.offset("zero"),b.order("default");break;case"stream":b.offset("wiggle"),b.order("inside-out");break;case"stream-center":b.offset("silhouette"),b.order("inside-out");break;case"expand":b.offset("expand"),b.order("default");break;case"stack_percent":b.offset(b.d3_stackedOffset_stackPercent),b.order("default")}}},duration:{get:function(){return r},set:function(a){r=a,t.reset(r),q.duration(r)}}}),a.utils.inheritOptions(b,q),a.utils.initOptions(b),b},a.models.stackedAreaChart=function(){"use strict";function b(v){return F.reset(),F.models(e),q&&F.models(f),r&&F.models(g),v.each(function(v){var F=d3.select(this),K=this;a.utils.initSVG(F);var L=(l||parseInt(F.style("width"))||960)-k.left-k.right,M=(m||parseInt(F.style("height"))||400)-k.top-k.bottom;if(b.update=function(){F.transition().duration(E).call(b)},b.container=this,x.setter(J(v),b.update).getter(I(v)).update(),x.disabled=v.map(function(a){return!!a.disabled}),!y){var N;y={};for(N in x)y[N]=x[N]instanceof Array?x[N].slice(0):x[N]}if(!(v&&v.length&&v.filter(function(a){return a.values.length}).length)){var O=F.selectAll(".nv-noData").data([z]);return O.enter().append("text").attr("class","nvd3 nv-noData").attr("dy","-.7em").style("text-anchor","middle"),O.attr("x",k.left+L/2).attr("y",k.top+M/2).text(function(a){return a}),b}F.selectAll(".nv-noData").remove(),c=e.xScale(),d=e.yScale();var P=F.selectAll("g.nv-wrap.nv-stackedAreaChart").data([v]),Q=P.enter().append("g").attr("class","nvd3 nv-wrap nv-stackedAreaChart").append("g"),R=P.select("g");if(Q.append("rect").style("opacity",0),Q.append("g").attr("class","nv-x nv-axis"),Q.append("g").attr("class","nv-y nv-axis"),Q.append("g").attr("class","nv-stackedWrap"),Q.append("g").attr("class","nv-legendWrap"),Q.append("g").attr("class","nv-controlsWrap"),Q.append("g").attr("class","nv-interactive"),R.select("rect").attr("width",L).attr("height",M),p){var S=o?L-B:L;h.width(S),R.select(".nv-legendWrap").datum(v).call(h),k.top!=h.height()&&(k.top=h.height(),M=(m||parseInt(F.style("height"))||400)-k.top-k.bottom),R.select(".nv-legendWrap").attr("transform","translate("+(L-S)+","+-k.top+")")}if(o){var T=[{key:D.stacked||"Stacked",metaKey:"Stacked",disabled:"stack"!=e.style(),style:"stack"},{key:D.stream||"Stream",metaKey:"Stream",disabled:"stream"!=e.style(),style:"stream"},{key:D.expanded||"Expanded",metaKey:"Expanded",disabled:"expand"!=e.style(),style:"expand"},{key:D.stack_percent||"Stack %",metaKey:"Stack_Percent",disabled:"stack_percent"!=e.style(),style:"stack_percent"}];B=C.length/3*260,T=T.filter(function(a){return-1!==C.indexOf(a.metaKey)}),i.width(B).color(["#444","#444","#444"]),R.select(".nv-controlsWrap").datum(T).call(i),k.top!=Math.max(i.height(),h.height())&&(k.top=Math.max(i.height(),h.height()),M=(m||parseInt(F.style("height"))||400)-k.top-k.bottom),R.select(".nv-controlsWrap").attr("transform","translate(0,"+-k.top+")")}P.attr("transform","translate("+k.left+","+k.top+")"),s&&R.select(".nv-y.nv-axis").attr("transform","translate("+L+",0)"),t&&(j.width(L).height(M).margin({left:k.left,top:k.top}).svgContainer(F).xScale(c),P.select(".nv-interactive").call(j)),e.width(L).height(M);var U=R.select(".nv-stackedWrap").datum(v);U.transition().call(e),q&&(f.scale(c).ticks(a.utils.calcTicksX(L/100,v)).tickSize(-M,0),R.select(".nv-x.nv-axis").attr("transform","translate(0,"+M+")"),R.select(".nv-x.nv-axis").transition().duration(0).call(f)),r&&(g.scale(d).ticks("wiggle"==e.offset()?0:a.utils.calcTicksY(M/36,v)).tickSize(-L,0).setTickFormat("expand"==e.style()||"stack_percent"==e.style()?d3.format("%"):w),R.select(".nv-y.nv-axis").transition().duration(0).call(g)),e.dispatch.on("areaClick.toggle",function(a){v.forEach(1===v.filter(function(a){return!a.disabled}).length?function(a){a.disabled=!1}:function(b,c){b.disabled=c!=a.seriesIndex}),x.disabled=v.map(function(a){return!!a.disabled}),A.stateChange(x),b.update()}),h.dispatch.on("stateChange",function(a){for(var c in a)x[c]=a[c];A.stateChange(x),b.update()}),i.dispatch.on("legendClick",function(a){a.disabled&&(T=T.map(function(a){return a.disabled=!0,a}),a.disabled=!1,e.style(a.style),x.style=e.style(),A.stateChange(x),b.update())}),j.dispatch.on("elementMousemove",function(c){e.clearHighlights();var d,h,i,l=[];if(v.filter(function(a,b){return a.seriesIndex=b,!a.disabled}).forEach(function(f,g){h=a.interactiveBisect(f.values,c.pointXValue,b.x()),e.highlightPoint(g,h,!0);var j=f.values[h];if("undefined"!=typeof j){"undefined"==typeof d&&(d=j),"undefined"==typeof i&&(i=b.xScale()(b.x()(j,h)));var k="expand"==e.style()?j.display.y:b.y()(j,h);l.push({key:f.key,value:k,color:n(f,f.seriesIndex),stackedValue:j.display})}}),l.reverse(),l.length>2){var m=b.yScale().invert(c.mouseY),o=null;l.forEach(function(a,b){m=Math.abs(m);var c=Math.abs(a.stackedValue.y0),d=Math.abs(a.stackedValue.y);return m>=c&&d+c>=m?void(o=b):void 0}),null!=o&&(l[o].highlight=!0)}var p=f.tickFormat()(b.x()(d,h)),q="expand"==e.style()?function(a){return d3.format(".1%")(a)}:function(a){return g.tickFormat()(a)};j.tooltip.position({left:i+k.left,top:c.mouseY+k.top}).chartContainer(K.parentNode).enabled(u).valueFormatter(q).data({value:p,series:l})(),j.renderGuideLine(i)}),j.dispatch.on("elementMouseout",function(){A.tooltipHide(),e.clearHighlights()}),A.on("tooltipShow",function(a){u&&H(a,K.parentNode)}),A.on("changeState",function(a){"undefined"!=typeof a.disabled&&v.length===a.disabled.length&&(v.forEach(function(b,c){b.disabled=a.disabled[c]}),x.disabled=a.disabled),"undefined"!=typeof a.style&&(e.style(a.style),G=a.style),b.update()})}),F.renderEnd("stacked Area chart immediate"),b}var c,d,e=a.models.stackedArea(),f=a.models.axis(),g=a.models.axis(),h=a.models.legend(),i=a.models.legend(),j=a.interactiveGuideline(),k={top:30,right:25,bottom:50,left:60},l=null,m=null,n=a.utils.defaultColor(),o=!0,p=!0,q=!0,r=!0,s=!1,t=!1,u=!0,v=function(a,b,c){return"

"+a+"

"+c+" on "+b+"

"},w=d3.format(",.2f"),x=a.utils.state(),y=null,z="No Data Available.",A=d3.dispatch("tooltipShow","tooltipHide","stateChange","changeState","renderEnd"),B=250,C=["Stacked","Stream","Expanded"],D={},E=250;x.style=e.style(),f.orient("bottom").tickPadding(7),g.orient(s?"right":"left"),i.updateState(!1);var F=a.utils.renderWatch(A),G=e.style(),H=function(c,d){var h=c.pos[0]+(d.offsetLeft||0),i=c.pos[1]+(d.offsetTop||0),j=f.tickFormat()(e.x()(c.point,c.pointIndex)),k=g.tickFormat()(e.y()(c.point,c.pointIndex)),l=v(c.series.key,j,k,c,b);a.tooltip.show([h,i],l,c.value<0?"n":"s",null,d)},I=function(a){return function(){return{active:a.map(function(a){return!a.disabled}),style:e.style()}}},J=function(a){return function(b){void 0!==b.style&&(G=b.style),void 0!==b.active&&a.forEach(function(a,c){a.disabled=!b.active[c]})}};return e.dispatch.on("tooltipShow",function(a){a.pos=[a.pos[0]+k.left,a.pos[1]+k.top],A.tooltipShow(a)}),e.dispatch.on("tooltipHide",function(a){A.tooltipHide(a)}),A.on("tooltipHide",function(){u&&a.tooltip.cleanup()}),b.dispatch=A,b.stacked=e,b.legend=h,b.controls=i,b.xAxis=f,b.yAxis=g,b.interactiveLayer=j,g.setTickFormat=g.tickFormat,b.dispatch=A,b.options=a.utils.optionsFunc.bind(b),b._options=Object.create({},{width:{get:function(){return l},set:function(a){l=a}},height:{get:function(){return m},set:function(a){m=a}},showLegend:{get:function(){return p},set:function(a){p=a}},showXAxis:{get:function(){return q},set:function(a){q=a}},showYAxis:{get:function(){return r},set:function(a){r=a}},tooltips:{get:function(){return u},set:function(a){u=a}},tooltipContent:{get:function(){return v},set:function(a){v=a}},defaultState:{get:function(){return y},set:function(a){y=a}},noData:{get:function(){return z},set:function(a){z=a}},showControls:{get:function(){return o},set:function(a){o=a}},controlLabels:{get:function(){return D},set:function(a){D=a}},yAxisTickFormat:{get:function(){return w},set:function(a){w=a}},margin:{get:function(){return k},set:function(a){k.top=void 0!==a.top?a.top:k.top,k.right=void 0!==a.right?a.right:k.right,k.bottom=void 0!==a.bottom?a.bottom:k.bottom,k.left=void 0!==a.left?a.left:k.left}},duration:{get:function(){return E},set:function(a){E=a,F.reset(E),e.duration(E),f.duration(E),g.duration(E)}},color:{get:function(){return n},set:function(b){n=a.utils.getColor(b),h.color(n),e.color(n)}},rightAlignYAxis:{get:function(){return s},set:function(a){s=a,g.orient(s?"right":"left")}},useInteractiveGuideline:{get:function(){return t},set:function(a){t=!!a,a&&(b.interactive(!1),b.useVoronoi(!1))}}}),a.utils.inheritOptions(b,e),a.utils.initOptions(b),b},a.version="1.7.0"}(); \ No newline at end of file diff --git a/awx/ui/templates/ui/index.html b/awx/ui/templates/ui/index.html index fe6f9de38f..41a84ca269 100644 --- a/awx/ui/templates/ui/index.html +++ b/awx/ui/templates/ui/index.html @@ -14,7 +14,7 @@ - +