From 82725e1c5aa71dd3787eab8ddd8b2cbbd1b177a8 Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Tue, 25 Apr 2017 12:10:44 +0100 Subject: [PATCH] Fixes --- ...ort-4.json => companion-api-import-4.json} | 0 __tests__/test-import.js | 8 +- __tests__/test-persist.js | 2 +- d3.js | 5877 ++++------------- d3.min.js | 7 +- package.json | 34 +- 6 files changed, 1207 insertions(+), 4721 deletions(-) rename __tests__/fixtures/{companion_api_import-4.json => companion-api-import-4.json} (100%) diff --git a/__tests__/fixtures/companion_api_import-4.json b/__tests__/fixtures/companion-api-import-4.json similarity index 100% rename from __tests__/fixtures/companion_api_import-4.json rename to __tests__/fixtures/companion-api-import-4.json diff --git a/__tests__/test-import.js b/__tests__/test-import.js index 4711d0d5..60e48797 100644 --- a/__tests__/test-import.js +++ b/__tests__/test-import.js @@ -1,8 +1,10 @@ -jest.dontMock('../src/app/stores/Persist'); -jest.dontMock('../src/app/components/TranslatedComponent'); -jest.dontMock('../src/app/components/ModalImport'); +jest.unmock('../src/app/stores/Persist'); +jest.unmock('../src/app/components/TranslatedComponent'); +jest.unmock('../src/app/components/ModalImport'); +jest.unmock('prop-types'); import React from 'react'; +import PropTypes from 'prop-types'; import ReactDOM from 'react-dom'; import TU from 'react-testutils-additions'; import Utils from './testUtils'; diff --git a/__tests__/test-persist.js b/__tests__/test-persist.js index 5c5aeb4e..4f54ab56 100644 --- a/__tests__/test-persist.js +++ b/__tests__/test-persist.js @@ -1,4 +1,4 @@ -jest.dontMock('../src/app/stores/Persist'); +jest.unmock('../src/app/stores/Persist'); import React from 'react'; import ReactDOM from 'react-dom'; diff --git a/d3.js b/d3.js index 8aa43ce5..59b68609 100644 --- a/d3.js +++ b/d3.js @@ -1,7 +1,7 @@ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.d3 = global.d3 || {}))); + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.d3 = global.d3 || {}))); }(this, (function (exports) { 'use strict'; var ascending = function(a, b) { @@ -43,45 +43,50 @@ function ascendingComparator(f) { var ascendingBisect = bisector(ascending); var bisectRight = ascendingBisect.right; +function pair(a, b) { + return [a, b]; +} + var number = function(x) { return x === null ? NaN : +x; }; -var extent = function(array, f) { - var i = -1, - n = array.length, - a, - b, - c; +var extent = function(values, valueof) { + var n = values.length, + i = -1, + value, + min, + max; - if (f == null) { - while (++i < n) if ((b = array[i]) != null && b >= b) { a = c = b; break; } - while (++i < n) if ((b = array[i]) != null) { - if (a > b) a = b; - if (c < b) c = b; + if (valueof == null) { + while (++i < n) { // Find the first comparable value. + if ((value = values[i]) != null && value >= value) { + min = max = value; + while (++i < n) { // Compare the remaining values. + if ((value = values[i]) != null) { + if (min > value) min = value; + if (max < value) max = value; + } + } + } } } else { - while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = c = b; break; } - while (++i < n) if ((b = f(array[i], i, array)) != null) { - if (a > b) a = b; - if (c < b) c = b; + while (++i < n) { // Find the first comparable value. + if ((value = valueof(values[i], i, values)) != null && value >= value) { + min = max = value; + while (++i < n) { // Compare the remaining values. + if ((value = valueof(values[i], i, values)) != null) { + if (min > value) min = value; + if (max < value) max = value; + } + } + } } } - return [a, c]; -}; - -var array = Array.prototype; - -var slice = array.slice; -var map = array.map; - -var constant$1 = function(x) { - return function() { - return x; - }; + return [min, max]; }; var identity = function(x) { @@ -107,14 +112,42 @@ var e5 = Math.sqrt(10); var e2 = Math.sqrt(2); var ticks = function(start, stop, count) { - var step = tickStep(start, stop, count); - return sequence( - Math.ceil(start / step) * step, - Math.floor(stop / step) * step + step / 2, // inclusive - step - ); + var reverse = stop < start, + i = -1, + n, + ticks, + step; + + if (reverse) n = start, start = stop, stop = n; + + if ((step = tickIncrement(start, stop, count)) === 0 || !isFinite(step)) return []; + + if (step > 0) { + start = Math.ceil(start / step); + stop = Math.floor(stop / step); + ticks = new Array(n = Math.ceil(stop - start + 1)); + while (++i < n) ticks[i] = (start + i) * step; + } else { + start = Math.floor(start * step); + stop = Math.ceil(stop * step); + ticks = new Array(n = Math.ceil(start - stop + 1)); + while (++i < n) ticks[i] = (start - i) / step; + } + + if (reverse) ticks.reverse(); + + return ticks; }; +function tickIncrement(start, stop, count) { + var step = (stop - start) / Math.max(0, count), + power = Math.floor(Math.log(step) / Math.LN10), + error = step / Math.pow(10, power); + return power >= 0 + ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) + : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1); +} + function tickStep(start, stop, count) { var step0 = Math.abs(stop - start) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), @@ -129,17 +162,17 @@ var sturges = function(values) { return Math.ceil(Math.log(values.length) / Math.LN2) + 1; }; -var threshold = function(array, p, f) { - if (f == null) f = number; - if (!(n = array.length)) return; - if ((p = +p) <= 0 || n < 2) return +f(array[0], 0, array); - if (p >= 1) return +f(array[n - 1], n - 1, array); +var threshold = function(values, p, valueof) { + if (valueof == null) valueof = number; + if (!(n = values.length)) return; + if ((p = +p) <= 0 || n < 2) return +valueof(values[0], 0, values); + if (p >= 1) return +valueof(values[n - 1], n - 1, values); var n, - h = (n - 1) * p, - i = Math.floor(h), - a = +f(array[i], i, array), - b = +f(array[i + 1], i + 1, array); - return a + (b - a) * (h - i); + i = (n - 1) * p, + i0 = Math.floor(i), + value0 = +valueof(values[i0], i0, values), + value1 = +valueof(values[i0 + 1], i0 + 1, values); + return value0 + (value1 - value0) * (i - i0); }; var merge = function(arrays) { @@ -164,23 +197,39 @@ var merge = function(arrays) { return merged; }; -var min = function(array, f) { - var i = -1, - n = array.length, - a, - b; +var min = function(values, valueof) { + var n = values.length, + i = -1, + value, + min; - if (f == null) { - while (++i < n) if ((b = array[i]) != null && b >= b) { a = b; break; } - while (++i < n) if ((b = array[i]) != null && a > b) a = b; + if (valueof == null) { + while (++i < n) { // Find the first comparable value. + if ((value = values[i]) != null && value >= value) { + min = value; + while (++i < n) { // Compare the remaining values. + if ((value = values[i]) != null && min > value) { + min = value; + } + } + } + } } else { - while (++i < n) if ((b = f(array[i], i, array)) != null && b >= b) { a = b; break; } - while (++i < n) if ((b = f(array[i], i, array)) != null && a > b) a = b; + while (++i < n) { // Find the first comparable value. + if ((value = valueof(values[i], i, values)) != null && value >= value) { + min = value; + while (++i < n) { // Compare the remaining values. + if ((value = valueof(values[i], i, values)) != null && min > value) { + min = value; + } + } + } + } } - return a; + return min; }; function length(d) { @@ -199,14 +248,12 @@ var bottom = 3; var left = 4; var epsilon = 1e-6; -function translateX(scale0, scale1, d) { - var x = scale0(d); - return "translate(" + (isFinite(x) ? x : scale1(d)) + ",0)"; +function translateX(x) { + return "translate(" + x + ",0)"; } -function translateY(scale0, scale1, d) { - var y = scale0(d); - return "translate(0," + (isFinite(y) ? y : scale1(d)) + ")"; +function translateY(y) { + return "translate(0," + y + ")"; } function center(scale) { @@ -227,13 +274,15 @@ function axis(orient, scale) { tickFormat = null, tickSizeInner = 6, tickSizeOuter = 6, - tickPadding = 3; + tickPadding = 3, + k = orient === top || orient === left ? -1 : 1, + x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x"), + transform = orient === top || orient === bottom ? translateX : translateY; function axis(context) { var values = tickValues == null ? (scale.ticks ? scale.ticks.apply(scale, tickArguments) : scale.domain()) : tickValues, format = tickFormat == null ? (scale.tickFormat ? scale.tickFormat.apply(scale, tickArguments) : identity$1) : tickFormat, spacing = Math.max(tickSizeInner, 0) + tickPadding, - transform = orient === top || orient === bottom ? translateX : translateY, range = scale.range(), range0 = range[0] + 0.5, range1 = range[range.length - 1] + 0.5, @@ -244,9 +293,7 @@ function axis(orient, scale) { tickExit = tick.exit(), tickEnter = tick.enter().append("g").attr("class", "tick"), line = tick.select("line"), - text = tick.select("text"), - k = orient === top || orient === left ? -1 : 1, - x, y = orient === left || orient === right ? (x = "x", "y") : (x = "y", "x"); + text = tick.select("text"); path = path.merge(path.enter().insert("path", ".tick") .attr("class", "domain") @@ -274,11 +321,11 @@ function axis(orient, scale) { tickExit = tickExit.transition(context) .attr("opacity", epsilon) - .attr("transform", function(d) { return transform(position, this.parentNode.__axis || position, d); }); + .attr("transform", function(d) { return isFinite(d = position(d)) ? transform(d) : this.getAttribute("transform"); }); tickEnter .attr("opacity", epsilon) - .attr("transform", function(d) { return transform(this.parentNode.__axis || position, position, d); }); + .attr("transform", function(d) { var p = this.parentNode.__axis; return transform(p && isFinite(p = p(d)) ? p : position(d)); }); } tickExit.remove(); @@ -290,7 +337,7 @@ function axis(orient, scale) { tick .attr("opacity", 1) - .attr("transform", function(d) { return transform(position, position, d); }); + .attr("transform", function(d) { return transform(position(d)); }); line .attr(x + "2", k * tickSizeInner); @@ -484,8 +531,6 @@ var creator = function(name) { : creatorInherit)(fullname); }; -var nextId = 0; - var matcher = function(selector) { return function() { return this.matches(selector); @@ -606,43 +651,6 @@ var selection_on = function(typename, value, capture) { return this; }; -function customEvent(event1, listener, that, args) { - var event0 = event; - event1.sourceEvent = event; - event = event1; - try { - return listener.apply(that, args); - } finally { - event = event0; - } -} - -var sourceEvent = function() { - var current = event, source; - while (source = current.sourceEvent) current = source; - return current; -}; - -var point = function(node, event) { - var svg = node.ownerSVGElement || node; - - if (svg.createSVGPoint) { - var point = svg.createSVGPoint(); - point.x = event.clientX, point.y = event.clientY; - point = point.matrixTransform(node.getScreenCTM().inverse()); - return [point.x, point.y]; - } - - var rect = node.getBoundingClientRect(); - return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop]; -}; - -var mouse = function(node) { - var event = sourceEvent(); - if (event.changedTouches) event = event.changedTouches[0]; - return point(node, event); -}; - function none() {} var selector = function(selector) { @@ -729,7 +737,7 @@ EnterNode.prototype = { querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } }; -var constant$2 = function(x) { +var constant$1 = function(x) { return function() { return x; }; @@ -818,7 +826,7 @@ var selection_data = function(value, key) { parents = this._parents, groups = this._groups; - if (typeof value !== "function") value = constant$2(value); + if (typeof value !== "function") value = constant$1(value); for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { var parent = parents[j], @@ -1332,96 +1340,6 @@ Selection.prototype = selection.prototype = { dispatch: selection_dispatch }; -var select = function(selector) { - return typeof selector === "string" - ? new Selection([[document.querySelector(selector)]], [document.documentElement]) - : new Selection([[selector]], root); -}; - -var touch = function(node, touches, identifier) { - if (arguments.length < 3) identifier = touches, touches = sourceEvent().changedTouches; - - for (var i = 0, n = touches ? touches.length : 0, touch; i < n; ++i) { - if ((touch = touches[i]).identifier === identifier) { - return point(node, touch); - } - } - - return null; -}; - -function nopropagation() { - event.stopImmediatePropagation(); -} - -var noevent = function() { - event.preventDefault(); - event.stopImmediatePropagation(); -}; - -var dragDisable = function(view) { - var root = view.document.documentElement, - selection$$1 = select(view).on("dragstart.drag", noevent, true); - if ("onselectstart" in root) { - selection$$1.on("selectstart.drag", noevent, true); - } else { - root.__noselect = root.style.MozUserSelect; - root.style.MozUserSelect = "none"; - } -}; - -function yesdrag(view, noclick) { - var root = view.document.documentElement, - selection$$1 = select(view).on("dragstart.drag", null); - if (noclick) { - selection$$1.on("click.drag", noevent, true); - setTimeout(function() { selection$$1.on("click.drag", null); }, 0); - } - if ("onselectstart" in root) { - selection$$1.on("selectstart.drag", null); - } else { - root.style.MozUserSelect = root.__noselect; - delete root.__noselect; - } -} - -var constant$3 = function(x) { - return function() { - return x; - }; -}; - -function DragEvent(target, type, subject, id, active, x, y, dx, dy, dispatch) { - this.target = target; - this.type = type; - this.subject = subject; - this.identifier = id; - this.active = active; - this.x = x; - this.y = y; - this.dx = dx; - this.dy = dy; - this._ = dispatch; -} - -DragEvent.prototype.on = function() { - var value = this._.on.apply(this._, arguments); - return value === this._ ? this : value; -}; - -// Ignore right-click, since that should open the context menu. -function defaultFilter$1() { - return !event.button; -} - -function defaultContainer() { - return this.parentNode; -} - -function defaultSubject(d) { - return d == null ? {x: event.x, y: event.y} : d; -} - var define = function(constructor, factory, prototype) { constructor.prototype = factory.prototype = prototype; prototype.constructor = constructor; @@ -1936,7 +1854,7 @@ function basis(t1, v0, v1, v2, v3) { + t3 * v3) / 6; } -var constant$4 = function(x) { +var constant$3 = function(x) { return function() { return x; }; @@ -1956,21 +1874,21 @@ function exponential(a, b, y) { function hue(a, b) { var d = b - a; - return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$4(isNaN(a) ? b : a); + return d ? linear(a, d > 180 || d < -180 ? d - 360 * Math.round(d / 360) : d) : constant$3(isNaN(a) ? b : a); } function gamma(y) { return (y = +y) === 1 ? nogamma : function(a, b) { - return b - a ? exponential(a, b, y) : constant$4(isNaN(a) ? b : a); + return b - a ? exponential(a, b, y) : constant$3(isNaN(a) ? b : a); }; } function nogamma(a, b) { var d = b - a; - return d ? linear(a, d) : constant$4(isNaN(a) ? b : a); + return d ? linear(a, d) : constant$3(isNaN(a) ? b : a); } -var interpolateRgb = (function rgbGamma(y) { +var interpolateRgb = ((function rgbGamma(y) { var color$$1 = gamma(y); function rgb$$1(start, end) { @@ -1990,7 +1908,7 @@ var interpolateRgb = (function rgbGamma(y) { rgb$$1.gamma = rgbGamma; return rgb$$1; -})(1); +}))(1); var array$1 = function(a, b) { var nb = b ? b.length : 0, @@ -2108,7 +2026,7 @@ var interpolateString = function(a, b) { var interpolateValue = function(a, b) { var t = typeof b, c; - return b == null || t === "boolean" ? constant$4(b) + return b == null || t === "boolean" ? constant$3(b) : (t === "number" ? reinterpolate : t === "string" ? ((c = color(b)) ? (b = c, interpolateRgb) : interpolateString) : b instanceof color ? interpolateRgb @@ -2236,70 +2154,8 @@ function interpolateTransform(parse, pxComma, pxParen, degParen) { var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)"); var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")"); -var rho = Math.SQRT2; -var rho2 = 2; -var rho4 = 4; -var epsilon2 = 1e-12; - -function cosh(x) { - return ((x = Math.exp(x)) + 1 / x) / 2; -} - -function sinh(x) { - return ((x = Math.exp(x)) - 1 / x) / 2; -} - -function tanh(x) { - return ((x = Math.exp(2 * x)) - 1) / (x + 1); -} - // p0 = [ux0, uy0, w0] // p1 = [ux1, uy1, w1] -var interpolateZoom = function(p0, p1) { - var ux0 = p0[0], uy0 = p0[1], w0 = p0[2], - ux1 = p1[0], uy1 = p1[1], w1 = p1[2], - dx = ux1 - ux0, - dy = uy1 - uy0, - d2 = dx * dx + dy * dy, - i, - S; - - // Special case for u0 ≅ u1. - if (d2 < epsilon2) { - S = Math.log(w1 / w0) / rho; - i = function(t) { - return [ - ux0 + t * dx, - uy0 + t * dy, - w0 * Math.exp(rho * t * S) - ]; - }; - } - - // General case. - else { - var d1 = Math.sqrt(d2), - b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), - b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), - r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), - r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1); - S = (r1 - r0) / rho; - i = function(t) { - var s = t * S, - coshr0 = cosh(r0), - u = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s + r0) - sinh(r0)); - return [ - ux0 + u * dx, - uy0 + u * dy, - w0 * coshr0 / cosh(rho * s + r0) - ]; - }; - } - - i.duration = S * 1000; - - return i; -}; function cubehelix$1(hue$$1) { return (function cubehelixGamma(y) { @@ -2786,7 +2642,7 @@ var transition_attr = function(name, value) { return this.attrTween(name, typeof value === "function" ? (fullname.local ? attrFunctionNS$1 : attrFunction$1)(fullname, i, tweenValue(this, "attr." + name, value)) : value == null ? (fullname.local ? attrRemoveNS$1 : attrRemove$1)(fullname) - : (fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, i, value)); + : (fullname.local ? attrConstantNS$1 : attrConstant$1)(fullname, i, value + "")); }; function attrTweenNS(fullname, value) { @@ -3055,7 +2911,7 @@ var transition_style = function(name, value, priority) { .on("end.style." + name, styleRemoveEnd(name)) : this.styleTween(name, typeof value === "function" ? styleFunction$1(name, i, tweenValue(this, "style." + name, value)) - : styleConstant$1(name, i, value), priority); + : styleConstant$1(name, i, value + ""), priority); }; function styleTween(name, value, priority) { @@ -3206,23 +3062,6 @@ var polyInOut = (function custom(e) { return polyInOut; })(exponent); -var b1 = 4 / 11; -var b2 = 6 / 11; -var b3 = 8 / 11; -var b4 = 3 / 4; -var b5 = 9 / 11; -var b6 = 10 / 11; -var b7 = 15 / 16; -var b8 = 21 / 22; -var b9 = 63 / 64; -var b0 = 1 / b1 / b1; - - - -function bounceOut(t) { - return (t = +t) < b1 ? b0 * t * t : t < b3 ? b0 * (t -= b2) * t + b4 : t < b6 ? b0 * (t -= b5) * t + b7 : b0 * (t -= b8) * t + b9; -} - var overshoot = 1.70158; var backIn = (function custom(s) { @@ -3347,34 +3186,6 @@ var selection_transition = function(name) { selection.prototype.interrupt = selection_interrupt; selection.prototype.transition = selection_transition; -var root$1 = [null]; - -var constant$5 = function(x) { - return function() { - return x; - }; -}; - -var BrushEvent = function(target, type, selection) { - this.target = target; - this.type = type; - this.selection = selection; -}; - -function nopropagation$1() { - event.stopImmediatePropagation(); -} - -var noevent$1 = function() { - event.preventDefault(); - event.stopImmediatePropagation(); -}; - -var MODE_DRAG = {name: "drag"}; -var MODE_SPACE = {name: "space"}; -var MODE_HANDLE = {name: "handle"}; -var MODE_CENTER = {name: "center"}; - var X = { name: "x", handles: ["e", "w"].map(type), @@ -3396,112 +3207,15 @@ var XY = { output: function(xy) { return xy; } }; -var cursors = { - overlay: "crosshair", - selection: "move", - 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 flipX = { - e: "w", - w: "e", - nw: "ne", - ne: "nw", - se: "sw", - sw: "se" -}; - -var flipY = { - n: "s", - s: "n", - nw: "sw", - ne: "se", - se: "ne", - sw: "nw" -}; - -var signsX = { - overlay: +1, - selection: +1, - n: null, - e: +1, - s: null, - w: -1, - nw: -1, - ne: +1, - se: +1, - sw: -1 -}; - -var signsY = { - overlay: +1, - selection: +1, - n: -1, - e: null, - s: +1, - w: null, - nw: -1, - ne: -1, - se: +1, - sw: +1 -}; - function type(t) { return {type: t}; } -// Ignore right-click, since that should open the context menu. -function defaultFilter() { - return !event.button; -} - -function defaultExtent() { - var svg = this.ownerSVGElement || this; - return [[0, 0], [svg.width.baseVal.value, svg.height.baseVal.value]]; -} - -// Like d3.local, but with the name “__brush” rather than auto-generated. -function local$$1(node) { - while (!node.__brush) if (!(node = node.parentNode)) return; - return node.__brush; -} - -function empty(extent) { - return extent[0][0] === extent[1][0] - || extent[0][1] === extent[1][1]; -} - -var cos = Math.cos; -var sin = Math.sin; var pi$1 = Math.PI; -var halfPi$1 = pi$1 / 2; + var tau$1 = pi$1 * 2; var max$1 = Math.max; -function compareValue(compare) { - return function(a, b) { - return compare( - a.source.value + a.target.value, - b.source.value + b.target.value - ); - }; -} - -var slice$2 = Array.prototype.slice; - -var constant$6 = function(x) { - return function() { - return x; - }; -}; - var pi$2 = Math.PI; var tau$2 = 2 * pi$2; var epsilon$1 = 1e-6; @@ -3610,14 +3324,16 @@ Path.prototype = path.prototype = { // Is this arc empty? We’re done. if (!r) return; + // Does the angle go the wrong way? Flip the direction. + if (da < 0) da = da % tau$2 + tau$2; + // Is this a complete circle? Draw two arcs to complete the circle. if (da > tauEpsilon) { this._ += "A" + r + "," + r + ",0,1," + cw + "," + (x - dx) + "," + (y - dy) + "A" + r + "," + r + ",0,1," + cw + "," + (this._x1 = x0) + "," + (this._y1 = y0); } - // Otherwise, draw an arc! - else { - if (da < 0) da = da % tau$2 + tau$2; + // Is this arc non-empty? Draw an arc! + else if (da > epsilon$1) { this._ += "A" + r + "," + r + ",0," + (+(da >= pi$2)) + "," + cw + "," + (this._x1 = x + r * Math.cos(a1)) + "," + (this._y1 = y + r * Math.sin(a1)); } }, @@ -3629,26 +3345,6 @@ Path.prototype = path.prototype = { } }; -function defaultSource(d) { - return d.source; -} - -function defaultTarget(d) { - return d.target; -} - -function defaultRadius(d) { - return d.radius; -} - -function defaultStartAngle(d) { - return d.startAngle; -} - -function defaultEndAngle(d) { - return d.endAngle; -} - var prefix = "$"; function Map() {} @@ -3723,22 +3419,6 @@ function map$1(object, f) { return map; } -function createObject() { - return {}; -} - -function setObject(object, key, value) { - object[key] = value; -} - -function createMap() { - return map$1(); -} - -function setMap(map, key, value) { - map.set(key, value); -} - function Set() {} var proto = map$1.prototype; @@ -3805,7 +3485,7 @@ function inferColumns(rows) { } var dsv = function(delimiter) { - var reFormat = new RegExp("[\"" + delimiter + "\n]"), + var reFormat = new RegExp("[\"" + delimiter + "\n\r]"), delimiterCode = delimiter.charCodeAt(0); function parse(text, f) { @@ -3918,16 +3598,6 @@ var tsv = dsv("\t"); var tsvParse = tsv.parse; -var constant$7 = function(x) { - return function() { - return x; - }; -}; - -var jiggle = function() { - return (Math.random() - 0.5) * 1e-6; -}; - var tree_add = function(d) { var x = +this._x.call(null, d), y = +this._y.call(null, d); @@ -4351,35 +4021,6 @@ treeProto.visitAfter = tree_visitAfter; treeProto.x = tree_x; treeProto.y = tree_y; -function x(d) { - return d.x + d.vx; -} - -function y(d) { - return d.y + d.vy; -} - -function index(d) { - return d.index; -} - -function find(nodeById, nodeId) { - var node = nodeById.get(nodeId); - if (!node) throw new Error("missing: " + nodeId); - return node; -} - -function x$1(d) { - return d.x; -} - -function y$1(d) { - return d.y; -} - -var initialRadius = 10; -var initialAngle = Math.PI * (3 - Math.sqrt(5)); - // Computes the decimal coefficient and exponent of the specified number x with // significant digits p, where x is positive and p is in [1, 21] or undefined. // For example, formatDecimal(1.23) returns ["123", 0]. @@ -4418,6 +4059,14 @@ var formatGroup = function(grouping, thousands) { }; }; +var formatNumerals = function(numerals) { + return function(value) { + return value.replace(/[0-9]/g, function(i) { + return numerals[+i]; + }); + }; +}; + var formatDefault = function(x, p) { x = x.toPrecision(p); @@ -4478,9 +4127,11 @@ var formatTypes = { // [[fill]align][sign][symbol][0][width][,][.precision][type] var re = /^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i; -var formatSpecifier = function(specifier) { +function formatSpecifier(specifier) { return new FormatSpecifier(specifier); -}; +} + +formatSpecifier.prototype = FormatSpecifier.prototype; // instanceof function FormatSpecifier(specifier) { if (!(match = re.exec(specifier))) throw new Error("invalid format: " + specifier); @@ -4528,16 +4179,18 @@ FormatSpecifier.prototype.toString = function() { + this.type; }; -var prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"]; - -function identity$3(x) { +var identity$3 = function(x) { return x; -} +}; + +var prefixes = ["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"]; var formatLocale = function(locale) { var group = locale.grouping && locale.thousands ? formatGroup(locale.grouping, locale.thousands) : identity$3, currency = locale.currency, - decimal = locale.decimal; + decimal = locale.decimal, + numerals = locale.numerals ? formatNumerals(locale.numerals) : identity$3, + percent = locale.percent || "%"; function newFormat(specifier) { specifier = formatSpecifier(specifier); @@ -4555,7 +4208,7 @@ var formatLocale = function(locale) { // Compute the prefix and suffix. // For SI-prefix, the suffix is lazily computed. var prefix = symbol === "$" ? currency[0] : symbol === "#" && /[boxX]/.test(type) ? "0" + type.toLowerCase() : "", - suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? "%" : ""; + suffix = symbol === "$" ? currency[1] : /[%p]/.test(type) ? percent : ""; // What format function should we use? // Is this an integer type? @@ -4582,27 +4235,12 @@ var formatLocale = function(locale) { } else { value = +value; - // Convert negative to positive, and compute the prefix. - // Note that -0 is not less than 0, but 1 / -0 is! - var valueNegative = (value < 0 || 1 / value < 0) && (value *= -1, true); - // Perform the initial formatting. - value = formatType(value, precision); + var valueNegative = value < 0; + value = formatType(Math.abs(value), precision); - // If the original value was negative, it may be rounded to zero during - // formatting; treat this as (positive) zero. - if (valueNegative) { - i = -1, n = value.length; - valueNegative = false; - while (++i < n) { - if (c = value.charCodeAt(i), (48 < c && c < 58) - || (type === "x" && 96 < c && c < 103) - || (type === "X" && 64 < c && c < 71)) { - valueNegative = true; - break; - } - } - } + // If a negative value rounds to zero during formatting, treat as positive. + if (valueNegative && +value === 0) valueNegative = false; // Compute the prefix and suffix. valuePrefix = (valueNegative ? (sign === "(" ? sign : "-") : sign === "-" || sign === "(" ? "" : sign) + valuePrefix; @@ -4634,11 +4272,13 @@ var formatLocale = function(locale) { // Reconstruct the final output based on the desired alignment. switch (align) { - case "<": return valuePrefix + value + valueSuffix + padding; - case "=": return valuePrefix + padding + value + valueSuffix; - case "^": return padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); + case "<": value = valuePrefix + value + valueSuffix + padding; break; + case "=": value = valuePrefix + padding + value + valueSuffix; break; + case "^": value = padding.slice(0, length = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length); break; + default: value = padding + valuePrefix + value + valueSuffix; break; } - return padding + valuePrefix + value + valueSuffix; + + return numerals(value); } format.toString = function() { @@ -4737,28 +4377,28 @@ function add$1(adder, a, b) { } var epsilon$2 = 1e-6; -var epsilon2$1 = 1e-12; + var pi$3 = Math.PI; var halfPi$2 = pi$3 / 2; var quarterPi = pi$3 / 4; var tau$3 = pi$3 * 2; -var degrees$1 = 180 / pi$3; + var radians = pi$3 / 180; var abs = Math.abs; var atan = Math.atan; var atan2 = Math.atan2; var cos$1 = Math.cos; -var ceil = Math.ceil; -var exp = Math.exp; -var log = Math.log; -var pow = Math.pow; + + + + var sin$1 = Math.sin; -var sign = Math.sign || function(x) { return x > 0 ? 1 : x < 0 ? -1 : 0; }; + var sqrt = Math.sqrt; -var tan = Math.tan; + function acos(x) { return x > 1 ? 0 : x < -1 ? pi$3 : Math.acos(x); @@ -4768,10 +4408,6 @@ function asin(x) { return x > 1 ? halfPi$2 : x < -1 ? -halfPi$2 : Math.asin(x); } -function haversin(x) { - return (x = sin$1(x / 2)) * x; -} - function noop$1() {} function streamGeometry(geometry, stream) { @@ -4781,8 +4417,8 @@ function streamGeometry(geometry, stream) { } var streamObjectType = { - Feature: function(feature, stream) { - streamGeometry(feature.geometry, stream); + Feature: function(object, stream) { + streamGeometry(object.geometry, stream); }, FeatureCollection: function(object, stream) { var features = object.features, i = -1, n = features.length; @@ -4853,86 +4489,21 @@ var lambda0; var cosPhi0; var sinPhi0; -var areaStream = { - point: noop$1, - lineStart: noop$1, - lineEnd: noop$1, - polygonStart: function() { - areaRingSum.reset(); - areaStream.lineStart = areaRingStart; - areaStream.lineEnd = areaRingEnd; - }, - polygonEnd: function() { - var areaRing = +areaRingSum; - areaSum.add(areaRing < 0 ? tau$3 + areaRing : areaRing); - this.lineStart = this.lineEnd = this.point = noop$1; - }, - sphere: function() { - areaSum.add(tau$3); - } -}; - -function areaRingStart() { - areaStream.point = areaPointFirst; -} - -function areaRingEnd() { - areaPoint(lambda00, phi00); -} - -function areaPointFirst(lambda, phi) { - areaStream.point = areaPoint; - lambda00 = lambda, phi00 = phi; - lambda *= radians, phi *= radians; - lambda0 = lambda, cosPhi0 = cos$1(phi = phi / 2 + quarterPi), sinPhi0 = sin$1(phi); -} - -function areaPoint(lambda, phi) { - lambda *= radians, phi *= radians; - phi = phi / 2 + quarterPi; // half the angular distance from south pole - - // Spherical excess E for a spherical triangle with vertices: south pole, - // previous point, current point. Uses a formula derived from Cagnoli’s - // theorem. See Todhunter, Spherical Trig. (1871), Sec. 103, Eq. (2). - var dLambda = lambda - lambda0, - sdLambda = dLambda >= 0 ? 1 : -1, - adLambda = sdLambda * dLambda, - cosPhi = cos$1(phi), - sinPhi = sin$1(phi), - k = sinPhi0 * sinPhi, - u = cosPhi0 * cosPhi + k * cos$1(adLambda), - v = k * sdLambda * sin$1(adLambda); - areaRingSum.add(atan2(v, u)); - - // Advance the previous points. - lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi; -} - -function spherical(cartesian) { - return [atan2(cartesian[1], cartesian[0]), asin(cartesian[2])]; -} - function cartesian(spherical) { var lambda = spherical[0], phi = spherical[1], cosPhi = cos$1(phi); return [cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi)]; } -function cartesianDot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; -} + function 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]]; } // TODO return a -function cartesianAddInPlace(a, b) { - a[0] += b[0], a[1] += b[1], a[2] += b[2]; -} -function cartesianScale(vector, k) { - return [vector[0] * k, vector[1] * k, vector[2] * k]; -} + + // TODO return d function cartesianNormalizeInPlace(d) { @@ -4952,359 +4523,12 @@ var deltaSum = adder(); var ranges; var range; -var boundsStream = { - point: boundsPoint, - lineStart: boundsLineStart, - lineEnd: boundsLineEnd, - polygonStart: function() { - boundsStream.point = boundsRingPoint; - boundsStream.lineStart = boundsRingStart; - boundsStream.lineEnd = boundsRingEnd; - deltaSum.reset(); - areaStream.polygonStart(); - }, - polygonEnd: function() { - areaStream.polygonEnd(); - boundsStream.point = boundsPoint; - boundsStream.lineStart = boundsLineStart; - boundsStream.lineEnd = boundsLineEnd; - if (areaRingSum < 0) lambda0$1 = -(lambda1 = 180), phi0 = -(phi1 = 90); - else if (deltaSum > epsilon$2) phi1 = 90; - else if (deltaSum < -epsilon$2) phi0 = -90; - range[0] = lambda0$1, range[1] = lambda1; - } -}; - -function boundsPoint(lambda, phi) { - ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]); - if (phi < phi0) phi0 = phi; - if (phi > phi1) phi1 = phi; -} - -function linePoint(lambda, phi) { - var p = cartesian([lambda * radians, phi * radians]); - if (p0) { - var normal = cartesianCross(p0, p), - equatorial = [normal[1], -normal[0], 0], - inflection = cartesianCross(equatorial, normal); - cartesianNormalizeInPlace(inflection); - inflection = spherical(inflection); - var delta = lambda - lambda2, - sign$$1 = delta > 0 ? 1 : -1, - lambdai = inflection[0] * degrees$1 * sign$$1, - phii, - antimeridian = abs(delta) > 180; - if (antimeridian ^ (sign$$1 * lambda2 < lambdai && lambdai < sign$$1 * lambda)) { - phii = inflection[1] * degrees$1; - if (phii > phi1) phi1 = phii; - } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign$$1 * lambda2 < lambdai && lambdai < sign$$1 * lambda)) { - phii = -inflection[1] * degrees$1; - if (phii < phi0) phi0 = phii; - } else { - if (phi < phi0) phi0 = phi; - if (phi > phi1) phi1 = phi; - } - if (antimeridian) { - if (lambda < lambda2) { - if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda; - } else { - if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda; - } - } else { - if (lambda1 >= lambda0$1) { - if (lambda < lambda0$1) lambda0$1 = lambda; - if (lambda > lambda1) lambda1 = lambda; - } else { - if (lambda > lambda2) { - if (angle(lambda0$1, lambda) > angle(lambda0$1, lambda1)) lambda1 = lambda; - } else { - if (angle(lambda, lambda1) > angle(lambda0$1, lambda1)) lambda0$1 = lambda; - } - } - } - } else { - ranges.push(range = [lambda0$1 = lambda, lambda1 = lambda]); - } - if (phi < phi0) phi0 = phi; - if (phi > phi1) phi1 = phi; - p0 = p, lambda2 = lambda; -} - -function boundsLineStart() { - boundsStream.point = linePoint; -} - -function boundsLineEnd() { - range[0] = lambda0$1, range[1] = lambda1; - boundsStream.point = boundsPoint; - p0 = null; -} - -function boundsRingPoint(lambda, phi) { - if (p0) { - var delta = lambda - lambda2; - deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta); - } else { - lambda00$1 = lambda, phi00$1 = phi; - } - areaStream.point(lambda, phi); - linePoint(lambda, phi); -} - -function boundsRingStart() { - areaStream.lineStart(); -} - -function boundsRingEnd() { - boundsRingPoint(lambda00$1, phi00$1); - areaStream.lineEnd(); - if (abs(deltaSum) > epsilon$2) lambda0$1 = -(lambda1 = 180); - range[0] = lambda0$1, range[1] = lambda1; - p0 = null; -} - -// Finds the left-right distance between two longitudes. -// This is almost the same as (lambda1 - lambda0 + 360°) % 360°, except that we want -// the distance between ±180° to be 360°. -function angle(lambda0, lambda1) { - return (lambda1 -= lambda0) < 0 ? lambda1 + 360 : lambda1; -} - -function rangeCompare(a, b) { - return a[0] - b[0]; -} - -function rangeContains(range, x) { - return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; -} - var W0; -var W1; var X0; var Y0; -var Z0; -var X1; -var Y1; -var Z1; -var X2; -var Y2; -var Z2; -var lambda00$2; -var phi00$2; -var x0; -var y0; -var z0; // previous point - -var centroidStream = { - sphere: noop$1, - point: centroidPoint, - lineStart: centroidLineStart, - lineEnd: centroidLineEnd, - polygonStart: function() { - centroidStream.lineStart = centroidRingStart; - centroidStream.lineEnd = centroidRingEnd; - }, - polygonEnd: function() { - centroidStream.lineStart = centroidLineStart; - centroidStream.lineEnd = centroidLineEnd; - } -}; - -// Arithmetic mean of Cartesian vectors. -function centroidPoint(lambda, phi) { - lambda *= radians, phi *= radians; - var cosPhi = cos$1(phi); - centroidPointCartesian(cosPhi * cos$1(lambda), cosPhi * sin$1(lambda), sin$1(phi)); -} - -function centroidPointCartesian(x, y, z) { - ++W0; - X0 += (x - X0) / W0; - Y0 += (y - Y0) / W0; - Z0 += (z - Z0) / W0; -} - -function centroidLineStart() { - centroidStream.point = centroidLinePointFirst; -} - -function centroidLinePointFirst(lambda, phi) { - lambda *= radians, phi *= radians; - var cosPhi = cos$1(phi); - x0 = cosPhi * cos$1(lambda); - y0 = cosPhi * sin$1(lambda); - z0 = sin$1(phi); - centroidStream.point = centroidLinePoint; - centroidPointCartesian(x0, y0, z0); -} - -function centroidLinePoint(lambda, phi) { - lambda *= radians, phi *= radians; - var cosPhi = cos$1(phi), - x = cosPhi * cos$1(lambda), - y = cosPhi * sin$1(lambda), - z = sin$1(phi), - w = atan2(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); - W1 += w; - X1 += w * (x0 + (x0 = x)); - Y1 += w * (y0 + (y0 = y)); - Z1 += w * (z0 + (z0 = z)); - centroidPointCartesian(x0, y0, z0); -} - -function centroidLineEnd() { - centroidStream.point = centroidPoint; -} - -// See J. E. Brock, The Inertia Tensor for a Spherical Triangle, -// J. Applied Mechanics 42, 239 (1975). -function centroidRingStart() { - centroidStream.point = centroidRingPointFirst; -} - -function centroidRingEnd() { - centroidRingPoint(lambda00$2, phi00$2); - centroidStream.point = centroidPoint; -} - -function centroidRingPointFirst(lambda, phi) { - lambda00$2 = lambda, phi00$2 = phi; - lambda *= radians, phi *= radians; - centroidStream.point = centroidRingPoint; - var cosPhi = cos$1(phi); - x0 = cosPhi * cos$1(lambda); - y0 = cosPhi * sin$1(lambda); - z0 = sin$1(phi); - centroidPointCartesian(x0, y0, z0); -} - -function centroidRingPoint(lambda, phi) { - lambda *= radians, phi *= radians; - var cosPhi = cos$1(phi), - x = cosPhi * cos$1(lambda), - y = cosPhi * sin$1(lambda), - z = sin$1(phi), - cx = y0 * z - z0 * y, - cy = z0 * x - x0 * z, - cz = x0 * y - y0 * x, - m = sqrt(cx * cx + cy * cy + cz * cz), - u = x0 * x + y0 * y + z0 * z, - v = m && -asin(m) / m, // area weight - w = atan2(m, u); // line weight - X2 += v * cx; - Y2 += v * cy; - Z2 += v * cz; - W1 += w; - X1 += w * (x0 + (x0 = x)); - Y1 += w * (y0 + (y0 = y)); - Z1 += w * (z0 + (z0 = z)); - centroidPointCartesian(x0, y0, z0); -} - -var constant$8 = function(x) { - return function() { - return x; - }; -}; - -var compose = function(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 rotationIdentity(lambda, phi) { - return [lambda > pi$3 ? lambda - tau$3 : lambda < -pi$3 ? lambda + tau$3 : lambda, phi]; -} - -rotationIdentity.invert = rotationIdentity; - -function rotateRadians(deltaLambda, deltaPhi, deltaGamma) { - return (deltaLambda %= tau$3) ? (deltaPhi || deltaGamma ? compose(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) - : rotationLambda(deltaLambda)) - : (deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) - : rotationIdentity); -} - -function forwardRotationLambda(deltaLambda) { - return function(lambda, phi) { - return lambda += deltaLambda, [lambda > pi$3 ? lambda - tau$3 : lambda < -pi$3 ? lambda + tau$3 : lambda, phi]; - }; -} - -function rotationLambda(deltaLambda) { - var rotation = forwardRotationLambda(deltaLambda); - rotation.invert = forwardRotationLambda(-deltaLambda); - return rotation; -} - -function rotationPhiGamma(deltaPhi, deltaGamma) { - var cosDeltaPhi = cos$1(deltaPhi), - sinDeltaPhi = sin$1(deltaPhi), - cosDeltaGamma = cos$1(deltaGamma), - sinDeltaGamma = sin$1(deltaGamma); - - function rotation(lambda, phi) { - var cosPhi = cos$1(phi), - x = cos$1(lambda) * cosPhi, - y = sin$1(lambda) * cosPhi, - z = sin$1(phi), - k = z * cosDeltaPhi + x * sinDeltaPhi; - return [ - atan2(y * cosDeltaGamma - k * sinDeltaGamma, x * cosDeltaPhi - z * sinDeltaPhi), - asin(k * cosDeltaGamma + y * sinDeltaGamma) - ]; - } - - rotation.invert = function(lambda, phi) { - var cosPhi = cos$1(phi), - x = cos$1(lambda) * cosPhi, - y = sin$1(lambda) * cosPhi, - z = sin$1(phi), - k = z * cosDeltaGamma - y * sinDeltaGamma; - return [ - atan2(y * cosDeltaGamma + z * sinDeltaGamma, x * cosDeltaPhi + k * sinDeltaPhi), - asin(k * cosDeltaPhi - x * sinDeltaPhi) - ]; - }; - - return rotation; -} +var Z0; // previous point // Generates a circle centered at [0°, 0°], with a given radius and precision. -function circleStream(stream, radius, delta, direction, t0, t1) { - if (!delta) return; - var cosRadius = cos$1(radius), - sinRadius = sin$1(radius), - step = direction * delta; - if (t0 == null) { - t0 = radius + direction * tau$3; - t1 = radius - step / 2; - } else { - t0 = circleRadius(cosRadius, t0); - t1 = circleRadius(cosRadius, t1); - if (direction > 0 ? t0 < t1 : t0 > t1) t0 += direction * tau$3; - } - for (var point, t = t0; direction > 0 ? t > t1 : t < t1; t -= step) { - point = spherical([cosRadius, -sinRadius * cos$1(t), -sinRadius * sin$1(t)]); - stream.point(point[0], point[1]); - } -} - -// Returns the signed angle of a cartesian point relative to [cosRadius, 0, 0]. -function circleRadius(cosRadius, point) { - point = cartesian(point), point[0] -= cosRadius; - cartesianNormalizeInPlace(point); - var radius = acos(-point[1]); - return ((-point[2] < 0 ? -radius : radius) + tau$3 - epsilon$2) % tau$3; -} var clipBuffer = function() { var lines = [], @@ -5329,66 +4553,6 @@ var clipBuffer = function() { }; }; -var clipLine = function(a, b, x0, y0, x1, y1) { - var ax = a[0], - ay = a[1], - bx = b[0], - by = b[1], - t0 = 0, - t1 = 1, - dx = bx - ax, - dy = by - ay, - r; - - r = x0 - ax; - if (!dx && r > 0) return; - r /= dx; - if (dx < 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } else if (dx > 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } - - r = x1 - ax; - if (!dx && r < 0) return; - r /= dx; - if (dx < 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } else if (dx > 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } - - r = y0 - ay; - if (!dy && r > 0) return; - r /= dy; - if (dy < 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } else if (dy > 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } - - r = y1 - ay; - if (!dy && r < 0) return; - r /= dy; - if (dy < 0) { - if (r > t1) return; - if (r > t0) t0 = r; - } else if (dy > 0) { - if (r < t0) return; - if (r < t1) t1 = r; - } - - if (t0 > 0) a[0] = ax + t0 * dx, a[1] = ay + t0 * dy; - if (t1 < 1) b[0] = ax + t1 * dx, b[1] = ay + t1 * dy; - return true; -}; - var pointEqual = function(a, b) { return abs(a[0] - b[0]) < epsilon$2 && abs(a[1] - b[1]) < epsilon$2; }; @@ -5493,532 +4657,9 @@ function link$1(array) { b.p = a; } -var clipMax = 1e9; -var clipMin = -clipMax; - // TODO Use d3-polygon’s polygonContains here for the ring check? // TODO Eliminate duplicate buffering in clipBuffer and polygon.push? -function clipExtent(x0, y0, x1, y1) { - - function visible(x, y) { - return x0 <= x && x <= x1 && y0 <= y && y <= y1; - } - - function interpolate(from, to, direction, stream) { - var a = 0, a1 = 0; - if (from == null - || (a = corner(from, direction)) !== (a1 = corner(to, direction)) - || comparePoint(from, to) < 0 ^ direction > 0) { - do stream.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); - while ((a = (a + direction + 4) % 4) !== a1); - } else { - stream.point(to[0], to[1]); - } - } - - function corner(p, direction) { - return abs(p[0] - x0) < epsilon$2 ? direction > 0 ? 0 : 3 - : abs(p[0] - x1) < epsilon$2 ? direction > 0 ? 2 : 1 - : abs(p[1] - y0) < epsilon$2 ? direction > 0 ? 1 : 0 - : direction > 0 ? 3 : 2; // abs(p[1] - y1) < epsilon - } - - function compareIntersection(a, b) { - return comparePoint(a.x, b.x); - } - - function comparePoint(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]; - } - - return function(stream) { - var activeStream = stream, - bufferStream = clipBuffer(), - segments, - polygon, - ring, - x__, y__, v__, // first point - x_, y_, v_, // previous point - first, - clean; - - var clipStream = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: polygonStart, - polygonEnd: polygonEnd - }; - - function point(x, y) { - if (visible(x, y)) activeStream.point(x, y); - } - - function polygonInside() { - var winding = 0; - - for (var i = 0, n = polygon.length; i < n; ++i) { - for (var ring = polygon[i], j = 1, m = ring.length, point = ring[0], a0, a1, b0 = point[0], b1 = point[1]; j < m; ++j) { - a0 = b0, a1 = b1, point = ring[j], b0 = point[0], b1 = point[1]; - if (a1 <= y1) { if (b1 > y1 && (b0 - a0) * (y1 - a1) > (b1 - a1) * (x0 - a0)) ++winding; } - else { if (b1 <= y1 && (b0 - a0) * (y1 - a1) < (b1 - a1) * (x0 - a0)) --winding; } - } - } - - return winding; - } - - // Buffer geometry within a polygon and then clip it en masse. - function polygonStart() { - activeStream = bufferStream, segments = [], polygon = [], clean = true; - } - - function polygonEnd() { - var startInside = polygonInside(), - cleanInside = clean && startInside, - visible = (segments = merge(segments)).length; - if (cleanInside || visible) { - stream.polygonStart(); - if (cleanInside) { - stream.lineStart(); - interpolate(null, null, 1, stream); - stream.lineEnd(); - } - if (visible) { - clipPolygon(segments, compareIntersection, startInside, interpolate, stream); - } - stream.polygonEnd(); - } - activeStream = stream, segments = polygon = ring = null; - } - - function lineStart() { - clipStream.point = linePoint; - if (polygon) polygon.push(ring = []); - first = true; - v_ = false; - x_ = y_ = NaN; - } - - // TODO rather than special-case polygons, simply handle them separately. - // Ideally, coincident intersection points should be jittered to avoid - // clipping issues. - function lineEnd() { - if (segments) { - linePoint(x__, y__); - if (v__ && v_) bufferStream.rejoin(); - segments.push(bufferStream.result()); - } - clipStream.point = point; - if (v_) activeStream.lineEnd(); - } - - function linePoint(x, y) { - var v = visible(x, y); - if (polygon) ring.push([x, y]); - if (first) { - x__ = x, y__ = y, v__ = v; - first = false; - if (v) { - activeStream.lineStart(); - activeStream.point(x, y); - } - } else { - if (v && v_) activeStream.point(x, y); - else { - var a = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], - b = [x = Math.max(clipMin, Math.min(clipMax, x)), y = Math.max(clipMin, Math.min(clipMax, y))]; - if (clipLine(a, b, x0, y0, x1, y1)) { - if (!v_) { - activeStream.lineStart(); - activeStream.point(a[0], a[1]); - } - activeStream.point(b[0], b[1]); - if (!v) activeStream.lineEnd(); - clean = false; - } else if (v) { - activeStream.lineStart(); - activeStream.point(x, y); - clean = false; - } - } - } - x_ = x, y_ = y, v_ = v; - } - - return clipStream; - }; -} - -var lengthSum = adder(); -var lambda0$2; -var sinPhi0$1; -var cosPhi0$1; - -var lengthStream = { - sphere: noop$1, - point: noop$1, - lineStart: lengthLineStart, - lineEnd: noop$1, - polygonStart: noop$1, - polygonEnd: noop$1 -}; - -function lengthLineStart() { - lengthStream.point = lengthPointFirst; - lengthStream.lineEnd = lengthLineEnd; -} - -function lengthLineEnd() { - lengthStream.point = lengthStream.lineEnd = noop$1; -} - -function lengthPointFirst(lambda, phi) { - lambda *= radians, phi *= radians; - lambda0$2 = lambda, sinPhi0$1 = sin$1(phi), cosPhi0$1 = cos$1(phi); - lengthStream.point = lengthPoint; -} - -function lengthPoint(lambda, phi) { - lambda *= radians, phi *= radians; - var sinPhi = sin$1(phi), - cosPhi = cos$1(phi), - delta = abs(lambda - lambda0$2), - cosDelta = cos$1(delta), - sinDelta = sin$1(delta), - x = cosPhi * sinDelta, - y = cosPhi0$1 * sinPhi - sinPhi0$1 * cosPhi * cosDelta, - z = sinPhi0$1 * sinPhi + cosPhi0$1 * cosPhi * cosDelta; - lengthSum.add(atan2(sqrt(x * x + y * y), z)); - lambda0$2 = lambda, sinPhi0$1 = sinPhi, cosPhi0$1 = cosPhi; -} - -function graticuleX(y0, y1, dy) { - var y = sequence(y0, y1 - epsilon$2, dy).concat(y1); - return function(x) { return y.map(function(y) { return [x, y]; }); }; -} - -function graticuleY(x0, x1, dx) { - var x = sequence(x0, x1 - epsilon$2, dx).concat(x1); - return function(y) { return x.map(function(x) { return [x, y]; }); }; -} - -var identity$4 = function(x) { - return x; -}; - -var areaSum$1 = adder(); -var areaRingSum$1 = adder(); -var x00; -var y00; -var x0$1; -var y0$1; - -var areaStream$1 = { - point: noop$1, - lineStart: noop$1, - lineEnd: noop$1, - polygonStart: function() { - areaStream$1.lineStart = areaRingStart$1; - areaStream$1.lineEnd = areaRingEnd$1; - }, - polygonEnd: function() { - areaStream$1.lineStart = areaStream$1.lineEnd = areaStream$1.point = noop$1; - areaSum$1.add(abs(areaRingSum$1)); - areaRingSum$1.reset(); - }, - result: function() { - var area = areaSum$1 / 2; - areaSum$1.reset(); - return area; - } -}; - -function areaRingStart$1() { - areaStream$1.point = areaPointFirst$1; -} - -function areaPointFirst$1(x, y) { - areaStream$1.point = areaPoint$1; - x00 = x0$1 = x, y00 = y0$1 = y; -} - -function areaPoint$1(x, y) { - areaRingSum$1.add(y0$1 * x - x0$1 * y); - x0$1 = x, y0$1 = y; -} - -function areaRingEnd$1() { - areaPoint$1(x00, y00); -} - -var x0$2 = Infinity; -var y0$2 = x0$2; -var x1 = -x0$2; -var y1 = x1; - -var boundsStream$1 = { - point: boundsPoint$1, - lineStart: noop$1, - lineEnd: noop$1, - polygonStart: noop$1, - polygonEnd: noop$1, - result: function() { - var bounds = [[x0$2, y0$2], [x1, y1]]; - x1 = y1 = -(y0$2 = x0$2 = Infinity); - return bounds; - } -}; - -function boundsPoint$1(x, y) { - if (x < x0$2) x0$2 = x; - if (x > x1) x1 = x; - if (y < y0$2) y0$2 = y; - if (y > y1) y1 = y; -} - -// TODO Enforce positive area for exterior, negative area for interior? - -var X0$1 = 0; -var Y0$1 = 0; -var Z0$1 = 0; -var X1$1 = 0; -var Y1$1 = 0; -var Z1$1 = 0; -var X2$1 = 0; -var Y2$1 = 0; -var Z2$1 = 0; -var x00$1; -var y00$1; -var x0$3; -var y0$3; - -var centroidStream$1 = { - point: centroidPoint$1, - lineStart: centroidLineStart$1, - lineEnd: centroidLineEnd$1, - polygonStart: function() { - centroidStream$1.lineStart = centroidRingStart$1; - centroidStream$1.lineEnd = centroidRingEnd$1; - }, - polygonEnd: function() { - centroidStream$1.point = centroidPoint$1; - centroidStream$1.lineStart = centroidLineStart$1; - centroidStream$1.lineEnd = centroidLineEnd$1; - }, - result: function() { - var centroid = Z2$1 ? [X2$1 / Z2$1, Y2$1 / Z2$1] - : Z1$1 ? [X1$1 / Z1$1, Y1$1 / Z1$1] - : Z0$1 ? [X0$1 / Z0$1, Y0$1 / Z0$1] - : [NaN, NaN]; - X0$1 = Y0$1 = Z0$1 = - X1$1 = Y1$1 = Z1$1 = - X2$1 = Y2$1 = Z2$1 = 0; - return centroid; - } -}; - -function centroidPoint$1(x, y) { - X0$1 += x; - Y0$1 += y; - ++Z0$1; -} - -function centroidLineStart$1() { - centroidStream$1.point = centroidPointFirstLine; -} - -function centroidPointFirstLine(x, y) { - centroidStream$1.point = centroidPointLine; - centroidPoint$1(x0$3 = x, y0$3 = y); -} - -function centroidPointLine(x, y) { - var dx = x - x0$3, dy = y - y0$3, z = sqrt(dx * dx + dy * dy); - X1$1 += z * (x0$3 + x) / 2; - Y1$1 += z * (y0$3 + y) / 2; - Z1$1 += z; - centroidPoint$1(x0$3 = x, y0$3 = y); -} - -function centroidLineEnd$1() { - centroidStream$1.point = centroidPoint$1; -} - -function centroidRingStart$1() { - centroidStream$1.point = centroidPointFirstRing; -} - -function centroidRingEnd$1() { - centroidPointRing(x00$1, y00$1); -} - -function centroidPointFirstRing(x, y) { - centroidStream$1.point = centroidPointRing; - centroidPoint$1(x00$1 = x0$3 = x, y00$1 = y0$3 = y); -} - -function centroidPointRing(x, y) { - var dx = x - x0$3, - dy = y - y0$3, - z = sqrt(dx * dx + dy * dy); - - X1$1 += z * (x0$3 + x) / 2; - Y1$1 += z * (y0$3 + y) / 2; - Z1$1 += z; - - z = y0$3 * x - x0$3 * y; - X2$1 += z * (x0$3 + x); - Y2$1 += z * (y0$3 + y); - Z2$1 += z * 3; - centroidPoint$1(x0$3 = x, y0$3 = y); -} - -function PathContext(context) { - this._context = context; -} - -PathContext.prototype = { - _radius: 4.5, - pointRadius: function(_) { - return this._radius = _, this; - }, - polygonStart: function() { - this._line = 0; - }, - polygonEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._point = 0; - }, - lineEnd: function() { - if (this._line === 0) this._context.closePath(); - this._point = NaN; - }, - point: function(x, y) { - switch (this._point) { - case 0: { - this._context.moveTo(x, y); - this._point = 1; - break; - } - case 1: { - this._context.lineTo(x, y); - break; - } - default: { - this._context.moveTo(x + this._radius, y); - this._context.arc(x, y, this._radius, 0, tau$3); - break; - } - } - }, - result: noop$1 -}; - -var lengthSum$1 = adder(); -var lengthRing; -var x00$2; -var y00$2; -var x0$4; -var y0$4; - -var lengthStream$1 = { - point: noop$1, - lineStart: function() { - lengthStream$1.point = lengthPointFirst$1; - }, - lineEnd: function() { - if (lengthRing) lengthPoint$1(x00$2, y00$2); - lengthStream$1.point = noop$1; - }, - polygonStart: function() { - lengthRing = true; - }, - polygonEnd: function() { - lengthRing = null; - }, - result: function() { - var length = +lengthSum$1; - lengthSum$1.reset(); - return length; - } -}; - -function lengthPointFirst$1(x, y) { - lengthStream$1.point = lengthPoint$1; - x00$2 = x0$4 = x, y00$2 = y0$4 = y; -} - -function lengthPoint$1(x, y) { - x0$4 -= x, y0$4 -= y; - lengthSum$1.add(sqrt(x0$4 * x0$4 + y0$4 * y0$4)); - x0$4 = x, y0$4 = y; -} - -function PathString() { - this._string = []; -} - -PathString.prototype = { - _circle: circle$1(4.5), - pointRadius: function(_) { - return this._circle = circle$1(_), this; - }, - polygonStart: function() { - this._line = 0; - }, - polygonEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._point = 0; - }, - lineEnd: function() { - if (this._line === 0) this._string.push("Z"); - this._point = NaN; - }, - point: function(x, y) { - switch (this._point) { - case 0: { - this._string.push("M", x, ",", y); - this._point = 1; - break; - } - case 1: { - this._string.push("L", x, ",", y); - break; - } - default: { - this._string.push("M", x, ",", y, this._circle); - break; - } - } - }, - result: function() { - if (this._string.length) { - var result = this._string.join(""); - this._string = []; - return result; - } - } -}; - -function circle$1(radius) { - return "m0," + radius - + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius - + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius - + "z"; -} - var sum$1 = adder(); var polygonContains = function(polygon, point) { @@ -6084,6 +4725,148 @@ var polygonContains = function(polygon, point) { return (angle < -epsilon$2 || angle < epsilon$2 && sum$1 < -epsilon$2) ^ (winding & 1); }; +var lengthSum = adder(); +var lambda0$2; +var sinPhi0$1; +var cosPhi0$1; + +var lengthStream = { + sphere: noop$1, + point: noop$1, + lineStart: lengthLineStart, + lineEnd: noop$1, + polygonStart: noop$1, + polygonEnd: noop$1 +}; + +function lengthLineStart() { + lengthStream.point = lengthPointFirst; + lengthStream.lineEnd = lengthLineEnd; +} + +function lengthLineEnd() { + lengthStream.point = lengthStream.lineEnd = noop$1; +} + +function lengthPointFirst(lambda, phi) { + lambda *= radians, phi *= radians; + lambda0$2 = lambda, sinPhi0$1 = sin$1(phi), cosPhi0$1 = cos$1(phi); + lengthStream.point = lengthPoint; +} + +function lengthPoint(lambda, phi) { + lambda *= radians, phi *= radians; + var sinPhi = sin$1(phi), + cosPhi = cos$1(phi), + delta = abs(lambda - lambda0$2), + cosDelta = cos$1(delta), + sinDelta = sin$1(delta), + x = cosPhi * sinDelta, + y = cosPhi0$1 * sinPhi - sinPhi0$1 * cosPhi * cosDelta, + z = sinPhi0$1 * sinPhi + cosPhi0$1 * cosPhi * cosDelta; + lengthSum.add(atan2(sqrt(x * x + y * y), z)); + lambda0$2 = lambda, sinPhi0$1 = sinPhi, cosPhi0$1 = cosPhi; +} + +var length$1 = function(object) { + lengthSum.reset(); + geoStream(object, lengthStream); + return +lengthSum; +}; + +var coordinates = [null, null]; +var object$1 = {type: "LineString", coordinates: coordinates}; + +var distance = function(a, b) { + coordinates[0] = a; + coordinates[1] = b; + return length$1(object$1); +}; + +var containsGeometryType = { + Sphere: function() { + return true; + }, + Point: function(object, point) { + return containsPoint(object.coordinates, point); + }, + MultiPoint: function(object, point) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) if (containsPoint(coordinates[i], point)) return true; + return false; + }, + LineString: function(object, point) { + return containsLine(object.coordinates, point); + }, + MultiLineString: function(object, point) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) if (containsLine(coordinates[i], point)) return true; + return false; + }, + Polygon: function(object, point) { + return containsPolygon(object.coordinates, point); + }, + MultiPolygon: function(object, point) { + var coordinates = object.coordinates, i = -1, n = coordinates.length; + while (++i < n) if (containsPolygon(coordinates[i], point)) return true; + return false; + }, + GeometryCollection: function(object, point) { + var geometries = object.geometries, i = -1, n = geometries.length; + while (++i < n) if (containsGeometry(geometries[i], point)) return true; + return false; + } +}; + +function containsGeometry(geometry, point) { + return geometry && containsGeometryType.hasOwnProperty(geometry.type) + ? containsGeometryType[geometry.type](geometry, point) + : false; +} + +function containsPoint(coordinates, point) { + return distance(coordinates, point) === 0; +} + +function containsLine(coordinates, point) { + var ab = distance(coordinates[0], coordinates[1]), + ao = distance(coordinates[0], point), + ob = distance(point, coordinates[1]); + return ao + ob <= ab + epsilon$2; +} + +function containsPolygon(coordinates, point) { + return !!polygonContains(coordinates.map(ringRadians), pointRadians(point)); +} + +function ringRadians(ring) { + return ring = ring.map(pointRadians), ring.pop(), ring; +} + +function pointRadians(point) { + return [point[0] * radians, point[1] * radians]; +} + +var areaSum$1 = adder(); +var areaRingSum$1 = adder(); +var x00; +var y00; +var x0$1; +var y0$1; + +// TODO Enforce positive area for exterior, negative area for interior? + +var X0$1 = 0; +var Y0$1 = 0; +var Z0$1 = 0; + +var lengthSum$1 = adder(); +var lengthRing; +var x00$2; +var y00$2; +var x0$4; +var y0$4; + var clip = function(pointVisible, clipLine, interpolate, start) { return function(rotate, sink) { var line = clipLine(sink), @@ -6214,7 +4997,7 @@ function compareIntersection(a, b) { - ((b = b.x)[0] < 0 ? b[1] - halfPi$2 - epsilon$2 : halfPi$2 - b[1]); } -var clipAntimeridian = clip( +clip( function() { return true; }, clipAntimeridianLine, clipAntimeridianInterpolate, @@ -6304,504 +5087,8 @@ function clipAntimeridianInterpolate(from, to, direction, stream) { } } -var clipCircle = function(radius, delta) { - var cr = cos$1(radius), - smallRadius = cr > 0, - notHemisphere = abs(cr) > epsilon$2; // TODO optimise for this common case - - function interpolate(from, to, direction, stream) { - circleStream(stream, radius, delta, direction, from, to); - } - - function visible(lambda, phi) { - return cos$1(lambda) * cos$1(phi) > cr; - } - - // Takes a line and cuts into visible segments. Return values used for polygon - // clipping: 0 - there were intersections or the line was empty; 1 - no - // intersections 2 - there were intersections, and the first and last segments - // should be rejoined. - function clipLine(stream) { - var point0, // previous point - c0, // code for previous point - v0, // visibility of previous point - v00, // visibility of first point - clean; // no intersections - return { - lineStart: function() { - v00 = v0 = false; - clean = 1; - }, - point: function(lambda, phi) { - var point1 = [lambda, phi], - point2, - v = visible(lambda, phi), - c = smallRadius - ? v ? 0 : code(lambda, phi) - : v ? code(lambda + (lambda < 0 ? pi$3 : -pi$3), phi) : 0; - if (!point0 && (v00 = v0 = v)) stream.lineStart(); - // Handle degeneracies. - // TODO ignore if not clipping polygons. - if (v !== v0) { - point2 = intersect(point0, point1); - if (pointEqual(point0, point2) || pointEqual(point1, point2)) { - point1[0] += epsilon$2; - point1[1] += epsilon$2; - v = visible(point1[0], point1[1]); - } - } - if (v !== v0) { - clean = 0; - if (v) { - // outside going in - stream.lineStart(); - point2 = intersect(point1, point0); - stream.point(point2[0], point2[1]); - } else { - // inside going out - point2 = intersect(point0, point1); - stream.point(point2[0], point2[1]); - stream.lineEnd(); - } - point0 = point2; - } else if (notHemisphere && point0 && smallRadius ^ v) { - var t; - // If the codes for two points are different, or are both zero, - // and there this segment intersects with the small circle. - if (!(c & c0) && (t = intersect(point1, point0, true))) { - clean = 0; - if (smallRadius) { - stream.lineStart(); - stream.point(t[0][0], t[0][1]); - stream.point(t[1][0], t[1][1]); - stream.lineEnd(); - } else { - stream.point(t[1][0], t[1][1]); - stream.lineEnd(); - stream.lineStart(); - stream.point(t[0][0], t[0][1]); - } - } - } - if (v && (!point0 || !pointEqual(point0, point1))) { - stream.point(point1[0], point1[1]); - } - point0 = point1, v0 = v, c0 = c; - }, - lineEnd: function() { - if (v0) stream.lineEnd(); - point0 = null; - }, - // Rejoin first and last segments if there were intersections and the first - // and last points were visible. - clean: function() { - return clean | ((v00 && v0) << 1); - } - }; - } - - // Intersects the great circle between a and b with the clip circle. - function intersect(a, b, two) { - var pa = cartesian(a), - pb = cartesian(b); - - // We have two planes, n1.p = d1 and n2.p = d2. - // Find intersection line p(t) = c1 n1 + c2 n2 + t (n1 ⨯ n2). - var n1 = [1, 0, 0], // normal - n2 = cartesianCross(pa, pb), - n2n2 = cartesianDot(n2, n2), - n1n2 = n2[0], // cartesianDot(n1, n2), - determinant = n2n2 - n1n2 * n1n2; - - // Two polar points. - if (!determinant) return !two && a; - - var c1 = cr * n2n2 / determinant, - c2 = -cr * n1n2 / determinant, - n1xn2 = cartesianCross(n1, n2), - A = cartesianScale(n1, c1), - B = cartesianScale(n2, c2); - cartesianAddInPlace(A, B); - - // Solve |p(t)|^2 = 1. - var u = n1xn2, - w = cartesianDot(A, u), - uu = cartesianDot(u, u), - t2 = w * w - uu * (cartesianDot(A, A) - 1); - - if (t2 < 0) return; - - var t = sqrt(t2), - q = cartesianScale(u, (-w - t) / uu); - cartesianAddInPlace(q, A); - q = spherical(q); - - if (!two) return q; - - // Two intersection points. - var lambda0 = a[0], - lambda1 = b[0], - phi0 = a[1], - phi1 = b[1], - z; - - if (lambda1 < lambda0) z = lambda0, lambda0 = lambda1, lambda1 = z; - - var delta = lambda1 - lambda0, - polar = abs(delta - pi$3) < epsilon$2, - meridian = polar || delta < epsilon$2; - - if (!polar && phi1 < phi0) z = phi0, phi0 = phi1, phi1 = z; - - // Check that the first point is between a and b. - if (meridian - ? polar - ? phi0 + phi1 > 0 ^ q[1] < (abs(q[0] - lambda0) < epsilon$2 ? phi0 : phi1) - : phi0 <= q[1] && q[1] <= phi1 - : delta > pi$3 ^ (lambda0 <= q[0] && q[0] <= lambda1)) { - var q1 = cartesianScale(u, (-w + t) / uu); - cartesianAddInPlace(q1, A); - return [q, spherical(q1)]; - } - } - - // Generates a 4-bit vector representing the location of a point relative to - // the small circle's bounding box. - function code(lambda, phi) { - var r = smallRadius ? radius : pi$3 - radius, - code = 0; - if (lambda < -r) code |= 1; // left - else if (lambda > r) code |= 2; // right - if (phi < -r) code |= 4; // below - else if (phi > r) code |= 8; // above - return code; - } - - return clip(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi$3, radius - pi$3]); -}; - -function transformer(methods) { - return function(stream) { - var s = new TransformStream; - for (var key in methods) s[key] = methods[key]; - s.stream = stream; - return s; - }; -} - -function TransformStream() {} - -TransformStream.prototype = { - constructor: TransformStream, - point: function(x, y) { this.stream.point(x, y); }, - 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(); } -}; - -function fitExtent(projection, extent, object) { - var w = extent[1][0] - extent[0][0], - h = extent[1][1] - extent[0][1], - clip = projection.clipExtent && projection.clipExtent(); - - projection - .scale(150) - .translate([0, 0]); - - if (clip != null) projection.clipExtent(null); - - geoStream(object, projection.stream(boundsStream$1)); - - var b = boundsStream$1.result(), - k = Math.min(w / (b[1][0] - b[0][0]), h / (b[1][1] - b[0][1])), - x = +extent[0][0] + (w - k * (b[1][0] + b[0][0])) / 2, - y = +extent[0][1] + (h - k * (b[1][1] + b[0][1])) / 2; - - if (clip != null) projection.clipExtent(clip); - - return projection - .scale(k * 150) - .translate([x, y]); -} - -function fitSize(projection, size, object) { - return fitExtent(projection, [[0, 0], size], object); -} - -var maxDepth = 16; var cosMinDistance = cos$1(30 * radians); // cos(minimum angular distance) -var resample = function(project, delta2) { - return +delta2 ? resample$1(project, delta2) : resampleNone(project); -}; - -function resampleNone(project) { - return transformer({ - point: function(x, y) { - x = project(x, y); - this.stream.point(x[0], x[1]); - } - }); -} - -function resample$1(project, delta2) { - - function resampleLineTo(x0, y0, lambda0, a0, b0, c0, x1, y1, lambda1, a1, b1, c1, depth, stream) { - var dx = x1 - x0, - dy = y1 - y0, - d2 = dx * dx + dy * dy; - if (d2 > 4 * delta2 && depth--) { - var a = a0 + a1, - b = b0 + b1, - c = c0 + c1, - m = sqrt(a * a + b * b + c * c), - phi2 = asin(c /= m), - lambda2 = abs(abs(c) - 1) < epsilon$2 || abs(lambda0 - lambda1) < epsilon$2 ? (lambda0 + lambda1) / 2 : atan2(b, a), - p = project(lambda2, phi2), - x2 = p[0], - y2 = p[1], - dx2 = x2 - x0, - dy2 = y2 - y0, - dz = dy * dx2 - dx * dy2; - if (dz * dz / d2 > delta2 // perpendicular projected distance - || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 // midpoint close to an end - || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { // angular distance - resampleLineTo(x0, y0, lambda0, a0, b0, c0, x2, y2, lambda2, a /= m, b /= m, c, depth, stream); - stream.point(x2, y2); - resampleLineTo(x2, y2, lambda2, a, b, c, x1, y1, lambda1, a1, b1, c1, depth, stream); - } - } - } - return function(stream) { - var lambda00, x00, y00, a00, b00, c00, // first point - lambda0, x0, y0, a0, b0, c0; // previous point - - var resampleStream = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { stream.polygonStart(); resampleStream.lineStart = ringStart; }, - polygonEnd: function() { stream.polygonEnd(); resampleStream.lineStart = lineStart; } - }; - - function point(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - } - - function lineStart() { - x0 = NaN; - resampleStream.point = linePoint; - stream.lineStart(); - } - - function linePoint(lambda, phi) { - var c = cartesian([lambda, phi]), p = project(lambda, phi); - resampleLineTo(x0, y0, lambda0, a0, b0, c0, x0 = p[0], y0 = p[1], lambda0 = lambda, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); - stream.point(x0, y0); - } - - function lineEnd() { - resampleStream.point = point; - stream.lineEnd(); - } - - function ringStart() { - lineStart(); - resampleStream.point = ringPoint; - resampleStream.lineEnd = ringEnd; - } - - function ringPoint(lambda, phi) { - linePoint(lambda00 = lambda, phi), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; - resampleStream.point = linePoint; - } - - function ringEnd() { - resampleLineTo(x0, y0, lambda0, a0, b0, c0, x00, y00, lambda00, a00, b00, c00, maxDepth, stream); - resampleStream.lineEnd = lineEnd; - lineEnd(); - } - - return resampleStream; - }; -} - -var transformRadians = transformer({ - point: function(x, y) { - this.stream.point(x * radians, y * radians); - } -}); - -function projection(project) { - return projectionMutator(function() { return project; })(); -} - -function projectionMutator(projectAt) { - var project, - k = 150, // scale - x = 480, y = 250, // translate - dx, dy, lambda = 0, phi = 0, // center - deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, projectRotate, // rotate - theta = null, preclip = clipAntimeridian, // clip angle - x0 = null, y0, x1, y1, postclip = identity$4, // clip extent - delta2 = 0.5, projectResample = resample(projectTransform, delta2), // precision - cache, - cacheStream; - - function projection(point) { - point = projectRotate(point[0] * radians, point[1] * radians); - return [point[0] * k + dx, dy - point[1] * k]; - } - - function invert(point) { - point = projectRotate.invert((point[0] - dx) / k, (dy - point[1]) / k); - return point && [point[0] * degrees$1, point[1] * degrees$1]; - } - - function projectTransform(x, y) { - return x = project(x, y), [x[0] * k + dx, dy - x[1] * k]; - } - - projection.stream = function(stream) { - return cache && cacheStream === stream ? cache : cache = transformRadians(preclip(rotate, projectResample(postclip(cacheStream = stream)))); - }; - - projection.clipAngle = function(_) { - return arguments.length ? (preclip = +_ ? clipCircle(theta = _ * radians, 6 * radians) : (theta = null, clipAntimeridian), reset()) : theta * degrees$1; - }; - - projection.clipExtent = function(_) { - return arguments.length ? (postclip = _ == null ? (x0 = y0 = x1 = y1 = null, identity$4) : clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]), reset()) : x0 == null ? null : [[x0, y0], [x1, y1]]; - }; - - projection.scale = function(_) { - return arguments.length ? (k = +_, recenter()) : k; - }; - - projection.translate = function(_) { - return arguments.length ? (x = +_[0], y = +_[1], recenter()) : [x, y]; - }; - - projection.center = function(_) { - return arguments.length ? (lambda = _[0] % 360 * radians, phi = _[1] % 360 * radians, recenter()) : [lambda * degrees$1, phi * degrees$1]; - }; - - projection.rotate = function(_) { - return arguments.length ? (deltaLambda = _[0] % 360 * radians, deltaPhi = _[1] % 360 * radians, deltaGamma = _.length > 2 ? _[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees$1, deltaPhi * degrees$1, deltaGamma * degrees$1]; - }; - - projection.precision = function(_) { - return arguments.length ? (projectResample = resample(projectTransform, delta2 = _ * _), reset()) : sqrt(delta2); - }; - - projection.fitExtent = function(extent, object) { - return fitExtent(projection, extent, object); - }; - - projection.fitSize = function(size, object) { - return fitSize(projection, size, object); - }; - - function recenter() { - projectRotate = compose(rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma), project); - var center = project(lambda, phi); - dx = x - center[0] * k; - dy = y + center[1] * k; - return reset(); - } - - function reset() { - cache = cacheStream = null; - return projection; - } - - return function() { - project = projectAt.apply(this, arguments); - projection.invert = project.invert && invert; - return recenter(); - }; -} - -function conicProjection(projectAt) { - var phi0 = 0, - phi1 = pi$3 / 3, - m = projectionMutator(projectAt), - p = m(phi0, phi1); - - p.parallels = function(_) { - return arguments.length ? m(phi0 = _[0] * radians, phi1 = _[1] * radians) : [phi0 * degrees$1, phi1 * degrees$1]; - }; - - return p; -} - -function cylindricalEqualAreaRaw(phi0) { - var cosPhi0 = cos$1(phi0); - - function forward(lambda, phi) { - return [lambda * cosPhi0, sin$1(phi) / cosPhi0]; - } - - forward.invert = function(x, y) { - return [x / cosPhi0, asin(y * cosPhi0)]; - }; - - return forward; -} - -function conicEqualAreaRaw(y0, y1) { - var sy0 = sin$1(y0), n = (sy0 + sin$1(y1)) / 2; - - // Are the parallels symmetrical around the Equator? - if (abs(n) < epsilon$2) return cylindricalEqualAreaRaw(y0); - - var c = 1 + sy0 * (2 * n - sy0), r0 = sqrt(c) / n; - - function project(x, y) { - var r = sqrt(c - 2 * n * sin$1(y)) / n; - return [r * sin$1(x *= n), r0 - r * cos$1(x)]; - } - - project.invert = function(x, y) { - var r0y = r0 - y; - return [atan2(x, abs(r0y)) / n * sign(r0y), asin((c - (x * x + r0y * r0y) * n * n) / (2 * n))]; - }; - - return project; -} - -var conicEqualArea = function() { - return conicProjection(conicEqualAreaRaw) - .scale(155.424) - .center([0, 33.6442]); -}; - -var albers = function() { - return conicEqualArea() - .parallels([29.5, 45.5]) - .scale(1070) - .translate([480, 250]) - .rotate([96, 0]) - .center([-0.6, 38.7]); -}; - -// The projections must have mutually exclusive clip regions on the sphere, -// as this will avoid emitting interleaving lines and polygons. -function multiplex(streams) { - var n = streams.length; - return { - point: function(x, y) { var i = -1; while (++i < n) streams[i].point(x, y); }, - sphere: function() { var i = -1; while (++i < n) streams[i].sphere(); }, - lineStart: function() { var i = -1; while (++i < n) streams[i].lineStart(); }, - lineEnd: function() { var i = -1; while (++i < n) streams[i].lineEnd(); }, - polygonStart: function() { var i = -1; while (++i < n) streams[i].polygonStart(); }, - polygonEnd: function() { var i = -1; while (++i < n) streams[i].polygonEnd(); } - }; -} - // A composite projection for the United States, configured by default for // 960×500. The projection also works quite well at 960×600 if you change the // scale to 1285 and adjust the translate accordingly. The set of standard @@ -6849,87 +5136,6 @@ azimuthalEquidistantRaw.invert = azimuthalInvert(function(z) { return z; }); -function mercatorProjection(project) { - var m = projection(project), - scale = m.scale, - translate = m.translate, - clipExtent = m.clipExtent, - clipAuto; - - m.scale = function(_) { - return arguments.length ? (scale(_), clipAuto && m.clipExtent(null), m) : scale(); - }; - - m.translate = function(_) { - return arguments.length ? (translate(_), clipAuto && m.clipExtent(null), m) : translate(); - }; - - m.clipExtent = function(_) { - if (!arguments.length) return clipAuto ? null : clipExtent(); - if (clipAuto = _ == null) { - var k = pi$3 * scale(), - t = translate(); - _ = [[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]]; - } - clipExtent(_); - return m; - }; - - return m.clipExtent(null); -} - -function tany(y) { - return tan((halfPi$2 + y) / 2); -} - -function scaleTranslate(kx, ky, tx, ty) { - return kx === 1 && ky === 1 && tx === 0 && ty === 0 ? identity$4 : transformer({ - point: function(x, y) { - this.stream.point(x * kx + tx, y * ky + ty); - } - }); -} - -function transverseMercatorRaw(lambda, phi) { - return [log(tan((halfPi$2 + phi) / 2)), -lambda]; -} - -transverseMercatorRaw.invert = function(x, y) { - return [-y, 2 * atan(exp(x)) - halfPi$2]; -}; - -function defaultSeparation(a, b) { - return a.parent === b.parent ? 1 : 2; -} - -function meanX(children) { - return children.reduce(meanXReduce, 0) / children.length; -} - -function meanXReduce(x, c) { - return x + c.x; -} - -function maxY(children) { - return 1 + children.reduce(maxYReduce, 0); -} - -function maxYReduce(y, c) { - return Math.max(y, c.y); -} - -function leafLeft(node) { - var children; - while (children = node.children) node = children[0]; - return node; -} - -function leafRight(node) { - var children; - while (children = node.children) node = children[children.length - 1]; - return node; -} - function count(node) { var sum = 0, children = node.children, @@ -7140,322 +5346,6 @@ function Node$2(value) { this.next = null; } -var shuffle$1 = function(array) { - var i, - n = (array = array.slice()).length, - head = null, - node = head; - - while (n) { - var next = new Node$2(array[n - 1]); - if (node) node = node.next = next; - else node = head = next; - array[i] = array[--n]; - } - - return { - head: head, - tail: node - }; -}; - -var enclose = function(circles) { - return encloseN(shuffle$1(circles), []); -}; - -function encloses(a, b) { - var dx = b.x - a.x, - dy = b.y - a.y, - dr = a.r - b.r; - return dr * dr + 1e-6 > dx * dx + dy * dy; -} - -// Returns the smallest circle that contains circles L and intersects circles B. -function encloseN(L, B) { - var circle, - l0 = null, - l1 = L.head, - l2, - p1; - - switch (B.length) { - case 1: circle = enclose1(B[0]); break; - case 2: circle = enclose2(B[0], B[1]); break; - case 3: circle = enclose3(B[0], B[1], B[2]); break; - } - - while (l1) { - p1 = l1._, l2 = l1.next; - if (!circle || !encloses(circle, p1)) { - - // Temporarily truncate L before l1. - if (l0) L.tail = l0, l0.next = null; - else L.head = L.tail = null; - - B.push(p1); - circle = encloseN(L, B); // Note: reorders L! - B.pop(); - - // Move l1 to the front of L and reconnect the truncated list L. - if (L.head) l1.next = L.head, L.head = l1; - else l1.next = null, L.head = L.tail = l1; - l0 = L.tail, l0.next = l2; - - } else { - l0 = l1; - } - l1 = l2; - } - - L.tail = l0; - return circle; -} - -function enclose1(a) { - return { - x: a.x, - y: a.y, - r: a.r - }; -} - -function enclose2(a, b) { - var x1 = a.x, y1 = a.y, r1 = a.r, - x2 = b.x, y2 = b.y, r2 = b.r, - x21 = x2 - x1, y21 = y2 - y1, r21 = r2 - r1, - l = Math.sqrt(x21 * x21 + y21 * y21); - return { - x: (x1 + x2 + x21 / l * r21) / 2, - y: (y1 + y2 + y21 / l * r21) / 2, - r: (l + r1 + r2) / 2 - }; -} - -function enclose3(a, b, c) { - var x1 = a.x, y1 = a.y, r1 = a.r, - x2 = b.x, y2 = b.y, r2 = b.r, - x3 = c.x, y3 = c.y, r3 = c.r, - a2 = 2 * (x1 - x2), - b2 = 2 * (y1 - y2), - c2 = 2 * (r2 - r1), - d2 = x1 * x1 + y1 * y1 - r1 * r1 - x2 * x2 - y2 * y2 + r2 * r2, - a3 = 2 * (x1 - x3), - b3 = 2 * (y1 - y3), - c3 = 2 * (r3 - r1), - d3 = x1 * x1 + y1 * y1 - r1 * r1 - x3 * x3 - y3 * y3 + r3 * r3, - ab = a3 * b2 - a2 * b3, - xa = (b2 * d3 - b3 * d2) / ab - x1, - xb = (b3 * c2 - b2 * c3) / ab, - ya = (a3 * d2 - a2 * d3) / ab - y1, - yb = (a2 * c3 - a3 * c2) / ab, - A = xb * xb + yb * yb - 1, - B = 2 * (xa * xb + ya * yb + r1), - C = xa * xa + ya * ya - r1 * r1, - r = (-B - Math.sqrt(B * B - 4 * A * C)) / (2 * A); - return { - x: xa + xb * r + x1, - y: ya + yb * r + y1, - r: r - }; -} - -function place(a, b, c) { - var ax = a.x, - ay = a.y, - da = b.r + c.r, - db = a.r + c.r, - dx = b.x - ax, - dy = b.y - ay, - dc = dx * dx + dy * dy; - if (dc) { - var x = 0.5 + ((db *= db) - (da *= da)) / (2 * dc), - y = Math.sqrt(Math.max(0, 2 * da * (db + dc) - (db -= dc) * db - da * da)) / (2 * dc); - c.x = ax + x * dx + y * dy; - c.y = ay + x * dy - y * dx; - } else { - c.x = ax + db; - c.y = ay; - } -} - -function intersects(a, b) { - var dx = b.x - a.x, - dy = b.y - a.y, - dr = a.r + b.r; - return dr * dr - 1e-6 > dx * dx + dy * dy; -} - -function distance1(a, b) { - var l = a._.r; - while (a !== b) l += 2 * (a = a.next)._.r; - return l - b._.r; -} - -function distance2(node, x, y) { - var a = node._, - b = node.next._, - ab = a.r + b.r, - dx = (a.x * b.r + b.x * a.r) / ab - x, - dy = (a.y * b.r + b.y * a.r) / ab - y; - return dx * dx + dy * dy; -} - -function Node$1(circle) { - this._ = circle; - this.next = null; - this.previous = null; -} - -function packEnclose(circles) { - if (!(n = circles.length)) return 0; - - var a, b, c, n; - - // Place the first circle. - a = circles[0], a.x = 0, a.y = 0; - if (!(n > 1)) return a.r; - - // Place the second circle. - b = circles[1], a.x = -b.r, b.x = a.r, b.y = 0; - if (!(n > 2)) return a.r + b.r; - - // Place the third circle. - place(b, a, c = circles[2]); - - // Initialize the weighted centroid. - var aa = a.r * a.r, - ba = b.r * b.r, - ca = c.r * c.r, - oa = aa + ba + ca, - ox = aa * a.x + ba * b.x + ca * c.x, - oy = aa * a.y + ba * b.y + ca * c.y, - cx, cy, i, j, k, sj, sk; - - // Initialize the front-chain using the first three circles a, b and c. - a = new Node$1(a), b = new Node$1(b), c = new Node$1(c); - a.next = c.previous = b; - b.next = a.previous = c; - c.next = b.previous = a; - - // Attempt to place each remaining circle… - pack: for (i = 3; i < n; ++i) { - place(a._, b._, c = circles[i]), c = new Node$1(c); - - // Find the closest intersecting circle on the front-chain, if any. - // “Closeness” is determined by linear distance along the front-chain. - // “Ahead” or “behind” is likewise determined by linear distance. - j = b.next, k = a.previous, sj = b._.r, sk = a._.r; - do { - if (sj <= sk) { - if (intersects(j._, c._)) { - if (sj + a._.r + b._.r > distance1(j, b)) a = j; else b = j; - a.next = b, b.previous = a, --i; - continue pack; - } - sj += j._.r, j = j.next; - } else { - if (intersects(k._, c._)) { - if (distance1(a, k) > sk + a._.r + b._.r) a = k; else b = k; - a.next = b, b.previous = a, --i; - continue pack; - } - sk += k._.r, k = k.previous; - } - } while (j !== k.next); - - // Success! Insert the new circle c between a and b. - c.previous = a, c.next = b, a.next = b.previous = b = c; - - // Update the weighted centroid. - oa += ca = c._.r * c._.r; - ox += ca * c._.x; - oy += ca * c._.y; - - // Compute the new closest circle pair to the centroid. - aa = distance2(a, cx = ox / oa, cy = oy / oa); - while ((c = c.next) !== b) { - if ((ca = distance2(c, cx, cy)) < aa) { - a = c, aa = ca; - } - } - b = a.next; - } - - // Compute the enclosing circle of the front chain. - a = [b._], c = b; while ((c = c.next) !== b) a.push(c._); c = enclose(a); - - // Translate the circles to put the enclosing circle around the origin. - for (i = 0; i < n; ++i) a = circles[i], a.x -= c.x, a.y -= c.y; - - return c.r; -} - -function optional(f) { - return f == null ? null : required(f); -} - -function required(f) { - if (typeof f !== "function") throw new Error; - return f; -} - -function constantZero() { - return 0; -} - -var constant$9 = function(x) { - return function() { - return x; - }; -}; - -function defaultRadius$1(d) { - return Math.sqrt(d.value); -} - -function radiusLeaf(radius) { - return function(node) { - if (!node.children) { - node.r = Math.max(0, +radius(node) || 0); - } - }; -} - -function packChildren(padding, k) { - return function(node) { - if (children = node.children) { - var children, - i, - n = children.length, - r = padding(node) * k || 0, - e; - - if (r) for (i = 0; i < n; ++i) children[i].r += r; - e = packEnclose(children); - if (r) for (i = 0; i < n; ++i) children[i].r -= r; - node.r = e + r; - } - }; -} - -function translateChild(k) { - return function(node) { - var parent = node.parent; - node.r *= k; - if (parent) { - node.x = parent.x + k * node.x; - node.y = parent.y + k * node.y; - } - }; -} - -var roundNode = function(node) { - node.x0 = Math.round(node.x0); - node.y0 = Math.round(node.y0); - node.x1 = Math.round(node.x1); - node.y1 = Math.round(node.y1); -}; - var treemapDice = function(parent, x0, y0, x1, y1) { var nodes = parent.children, node, @@ -7469,75 +5359,6 @@ var treemapDice = function(parent, x0, y0, x1, y1) { } }; -var keyPrefix$1 = "$"; -var preroot = {depth: -1}; -var ambiguous = {}; - -function defaultId(d) { - return d.id; -} - -function defaultParentId(d) { - return d.parentId; -} - -function defaultSeparation$1(a, b) { - return a.parent === b.parent ? 1 : 2; -} - -// function radialSeparation(a, b) { -// return (a.parent === b.parent ? 1 : 2) / a.depth; -// } - -// This function is used to traverse the left contour of a subtree (or -// subforest). It returns the successor of v on this contour. This successor is -// either given by the leftmost child of v or by the thread of v. The function -// returns null if and only if v is on the highest level of its subtree. -function nextLeft(v) { - var children = v.children; - return children ? children[0] : v.t; -} - -// This function works analogously to nextLeft. -function nextRight(v) { - var children = v.children; - return children ? children[children.length - 1] : v.t; -} - -// Shifts the current subtree rooted at w+. This is done by increasing -// prelim(w+) and mod(w+) by shift. -function moveSubtree(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; -} - -// All other shifts, applied to the smaller subtrees between w- and w+, are -// performed by this function. To prepare the shifts, we have to adjust -// change(w+), shift(w+), and change(w-). -function executeShifts(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); - } -} - -// If vi-’s ancestor is a sibling of v, returns vi-’s ancestor. Otherwise, -// returns the specified (default) ancestor. -function nextAncestor(vim, v, ancestor) { - return vim.a.parent === v.parent ? vim.a : ancestor; -} - function TreeNode(node, i) { this._ = node; this.parent = null; @@ -7554,29 +5375,6 @@ function TreeNode(node, i) { TreeNode.prototype = Object.create(Node.prototype); -function treeRoot(root) { - var tree = new TreeNode(root, 0), - node, - nodes = [tree], - child, - children, - i, - n; - - while (node = nodes.pop()) { - if (children = node._.children) { - node.children = new Array(n = children.length); - for (i = n - 1; i >= 0; --i) { - nodes.push(child = node.children[i] = new TreeNode(children[i], i)); - child.parent = node; - } - } - } - - (tree.parent = new TreeNode(null, 0)).children = [tree]; - return tree; -} - // Node-link tree diagram using the Reingold-Tilford "tidy" algorithm var treemapSlice = function(parent, x0, y0, x1, y1) { @@ -7592,8 +5390,6 @@ var treemapSlice = function(parent, x0, y0, x1, y1) { } }; -var phi = (1 + Math.sqrt(5)) / 2; - function squarifyRatio(ratio, parent, x0, y0, x1, y1) { var rows = [], nodes = parent.children, @@ -7643,57 +5439,11 @@ function squarifyRatio(ratio, parent, x0, y0, x1, y1) { return rows; } -var squarify = (function custom(ratio) { - - function squarify(parent, x0, y0, x1, y1) { - squarifyRatio(ratio, parent, x0, y0, x1, y1); - } - - squarify.ratio = function(x) { - return custom((x = +x) > 1 ? x : 1); - }; - - return squarify; -})(phi); - -(function custom(ratio) { - - function resquarify(parent, x0, y0, x1, y1) { - if ((rows = parent._squarify) && (rows.ratio === ratio)) { - var rows, - row, - nodes, - i, - j = -1, - n, - m = rows.length, - value = parent.value; - - while (++j < m) { - row = rows[j], nodes = row.children; - for (i = row.value = 0, n = nodes.length; i < n; ++i) row.value += nodes[i].value; - if (row.dice) treemapDice(row, x0, y0, x1, y0 += (y1 - y0) * row.value / value); - else treemapSlice(row, x0, y0, x0 += (x1 - x0) * row.value / value, y1); - value -= row.value; - } - } else { - parent._squarify = rows = squarifyRatio(ratio, parent, x0, y0, x1, y1); - rows.ratio = ratio; - } - } - - resquarify.ratio = function(x) { - return custom((x = +x) > 1 ? x : 1); - }; - - return resquarify; -})(phi); - // Returns the 2D cross product of AB and AC vectors, i.e., the z-component of // the 3D cross product in a quadrant I Cartesian coordinate system (+x is // right, +y is up). Returns a positive value if ABC is counter-clockwise, // negative if clockwise, and zero if the points are collinear. -var cross = function(a, b, c) { +var cross$1 = function(a, b, c) { return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]); }; @@ -7710,7 +5460,7 @@ function computeUpperHullIndexes(points) { size = 2; for (var i = 2; i < n; ++i) { - while (size > 1 && cross(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size; + while (size > 1 && cross$1(points[indexes[size - 2]], points[indexes[size - 1]], points[i]) <= 0) --size; indexes[size++] = i; } @@ -8117,21 +5867,7 @@ function band() { return rescale(); } -function pointish(scale) { - var copy = scale.copy; - - scale.padding = scale.paddingOuter; - delete scale.paddingInner; - delete scale.paddingOuter; - - scale.copy = function() { - return pointish(copy()); - }; - - return scale; -} - -var constant$10 = function(x) { +var constant$9 = function(x) { return function() { return x; }; @@ -8146,7 +5882,7 @@ var unit = [0, 1]; function deinterpolateLinear(a, b) { return (b -= (a = +a)) ? function(x) { return (x - a) / b; } - : constant$10(b); + : constant$9(b); } function deinterpolateClamp(deinterpolate) { @@ -8321,49 +6057,10 @@ function linear$2() { return linearish(scale); } -function identity$6() { - var domain = [0, 1]; - - function scale(x) { - return +x; - } - - scale.invert = scale; - - scale.domain = scale.range = function(_) { - return arguments.length ? (domain = map$3.call(_, number$1), scale) : domain.slice(); - }; - - scale.copy = function() { - return identity$6().domain(domain); - }; - - return linearish(scale); -} - -var nice = function(domain, interval) { - domain = domain.slice(); - - var i0 = 0, - i1 = domain.length - 1, - x0 = domain[i0], - x1 = domain[i1], - t; - - if (x1 < x0) { - t = i0, i0 = i1, i1 = t; - t = x0, x0 = x1, x1 = t; - } - - domain[i0] = interval.floor(x0); - domain[i1] = interval.ceil(x1); - return domain; -}; - function deinterpolate(a, b) { return (b = Math.log(b / a)) ? function(x) { return Math.log(x / a) / b; } - : constant$10(b); + : constant$9(b); } function reinterpolate$1(a, b) { @@ -8389,254 +6086,6 @@ function logp(base) { || (base = Math.log(base), function(x) { return Math.log(x) / base; }); } -function reflect(f) { - return function(x) { - return -f(-x); - }; -} - -function log$1() { - var scale = continuous(deinterpolate, reinterpolate$1).domain([1, 10]), - domain = scale.domain, - base = 10, - logs = logp(10), - pows = powp(10); - - function rescale() { - logs = logp(base), pows = powp(base); - if (domain()[0] < 0) logs = reflect(logs), pows = reflect(pows); - return scale; - } - - scale.base = function(_) { - return arguments.length ? (base = +_, rescale()) : base; - }; - - scale.domain = function(_) { - return arguments.length ? (domain(_), rescale()) : domain(); - }; - - scale.ticks = function(count) { - var d = domain(), - u = d[0], - v = d[d.length - 1], - r; - - if (r = v < u) i = u, u = v, v = i; - - var i = logs(u), - j = logs(v), - p, - k, - t, - n = count == null ? 10 : +count, - z = []; - - if (!(base % 1) && j - i < n) { - i = Math.round(i) - 1, j = Math.round(j) + 1; - if (u > 0) for (; i < j; ++i) { - for (k = 1, p = pows(i); k < base; ++k) { - t = p * k; - if (t < u) continue; - if (t > v) break; - z.push(t); - } - } else for (; i < j; ++i) { - for (k = base - 1, p = pows(i); k >= 1; --k) { - t = p * k; - if (t < u) continue; - if (t > v) break; - z.push(t); - } - } - } else { - z = ticks(i, j, Math.min(j - i, n)).map(pows); - } - - return r ? z.reverse() : z; - }; - - scale.tickFormat = function(count, specifier) { - if (specifier == null) specifier = base === 10 ? ".0e" : ","; - if (typeof specifier !== "function") specifier = format(specifier); - if (count === Infinity) return specifier; - if (count == null) count = 10; - var k = Math.max(1, base * count / scale.ticks().length); // TODO fast estimate? - return function(d) { - var i = d / pows(Math.round(logs(d))); - if (i * base < base - 0.5) i *= base; - return i <= k ? specifier(d) : ""; - }; - }; - - scale.nice = function() { - return domain(nice(domain(), { - floor: function(x) { return pows(Math.floor(logs(x))); }, - ceil: function(x) { return pows(Math.ceil(logs(x))); } - })); - }; - - scale.copy = function() { - return copy(scale, log$1().base(base)); - }; - - return scale; -} - -function raise$1(x, exponent) { - return x < 0 ? -Math.pow(-x, exponent) : Math.pow(x, exponent); -} - -function pow$1() { - var exponent = 1, - scale = continuous(deinterpolate, reinterpolate), - domain = scale.domain; - - function deinterpolate(a, b) { - return (b = raise$1(b, exponent) - (a = raise$1(a, exponent))) - ? function(x) { return (raise$1(x, exponent) - a) / b; } - : constant$10(b); - } - - function reinterpolate(a, b) { - b = raise$1(b, exponent) - (a = raise$1(a, exponent)); - return function(t) { return raise$1(a + b * t, 1 / exponent); }; - } - - scale.exponent = function(_) { - return arguments.length ? (exponent = +_, domain(domain())) : exponent; - }; - - scale.copy = function() { - return copy(scale, pow$1().exponent(exponent)); - }; - - return linearish(scale); -} - -function quantile$$1() { - var domain = [], - range$$1 = [], - thresholds = []; - - function rescale() { - var i = 0, n = Math.max(1, range$$1.length); - thresholds = new Array(n - 1); - while (++i < n) thresholds[i - 1] = threshold(domain, i / n); - return scale; - } - - function scale(x) { - if (!isNaN(x = +x)) return range$$1[bisectRight(thresholds, x)]; - } - - scale.invertExtent = function(y) { - var i = range$$1.indexOf(y); - return i < 0 ? [NaN, NaN] : [ - i > 0 ? thresholds[i - 1] : domain[0], - i < thresholds.length ? thresholds[i] : domain[domain.length - 1] - ]; - }; - - scale.domain = function(_) { - if (!arguments.length) return domain.slice(); - domain = []; - for (var i = 0, n = _.length, d; i < n; ++i) if (d = _[i], d != null && !isNaN(d = +d)) domain.push(d); - domain.sort(ascending); - return rescale(); - }; - - scale.range = function(_) { - return arguments.length ? (range$$1 = slice$4.call(_), rescale()) : range$$1.slice(); - }; - - scale.quantiles = function() { - return thresholds.slice(); - }; - - scale.copy = function() { - return quantile$$1() - .domain(domain) - .range(range$$1); - }; - - return scale; -} - -function quantize$1() { - var x0 = 0, - x1 = 1, - n = 1, - domain = [0.5], - range$$1 = [0, 1]; - - function scale(x) { - if (x <= x) return range$$1[bisectRight(domain, x, 0, n)]; - } - - function rescale() { - var i = -1; - domain = new Array(n); - while (++i < n) domain[i] = ((i + 1) * x1 - (i - n) * x0) / (n + 1); - return scale; - } - - scale.domain = function(_) { - return arguments.length ? (x0 = +_[0], x1 = +_[1], rescale()) : [x0, x1]; - }; - - scale.range = function(_) { - return arguments.length ? (n = (range$$1 = slice$4.call(_)).length - 1, rescale()) : range$$1.slice(); - }; - - scale.invertExtent = function(y) { - var i = range$$1.indexOf(y); - return i < 0 ? [NaN, NaN] - : i < 1 ? [x0, domain[0]] - : i >= n ? [domain[n - 1], x1] - : [domain[i - 1], domain[i]]; - }; - - scale.copy = function() { - return quantize$1() - .domain([x0, x1]) - .range(range$$1); - }; - - return linearish(scale); -} - -function threshold$1() { - var domain = [0.5], - range$$1 = [0, 1], - n = 1; - - function scale(x) { - if (x <= x) return range$$1[bisectRight(domain, x, 0, n)]; - } - - scale.domain = function(_) { - return arguments.length ? (domain = slice$4.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : domain.slice(); - }; - - scale.range = function(_) { - return arguments.length ? (range$$1 = slice$4.call(_), n = Math.min(domain.length, range$$1.length - 1), scale) : range$$1.slice(); - }; - - scale.invertExtent = function(y) { - var i = range$$1.indexOf(y); - return [domain[i - 1], domain[i]]; - }; - - scale.copy = function() { - return threshold$1() - .domain(domain) - .range(range$$1); - }; - - return scale; -} - var t0$1 = new Date; var t1$1 = new Date; @@ -9476,130 +6925,6 @@ var parseIso = +new Date("2000-01-01T00:00:00.000Z") ? parseIsoNative : utcParse(isoSpecifier); -var durationSecond = 1000; -var durationMinute = durationSecond * 60; -var durationHour = durationMinute * 60; -var durationDay = durationHour * 24; -var durationWeek = durationDay * 7; -var durationMonth = durationDay * 30; -var durationYear = durationDay * 365; - -function date$1(t) { - return new Date(t); -} - -function number$2(t) { - return t instanceof Date ? +t : +new Date(+t); -} - -function calendar(year$$1, month$$1, week, day$$1, hour$$1, minute$$1, second$$1, millisecond$$1, format) { - var scale = continuous(deinterpolateLinear, reinterpolate), - invert = scale.invert, - domain = scale.domain; - - var formatMillisecond = format(".%L"), - formatSecond = format(":%S"), - formatMinute = format("%I:%M"), - formatHour = format("%I %p"), - formatDay = format("%a %d"), - formatWeek = format("%b %d"), - formatMonth = format("%B"), - formatYear = format("%Y"); - - var tickIntervals = [ - [second$$1, 1, durationSecond], - [second$$1, 5, 5 * durationSecond], - [second$$1, 15, 15 * durationSecond], - [second$$1, 30, 30 * durationSecond], - [minute$$1, 1, durationMinute], - [minute$$1, 5, 5 * durationMinute], - [minute$$1, 15, 15 * durationMinute], - [minute$$1, 30, 30 * durationMinute], - [ hour$$1, 1, durationHour ], - [ hour$$1, 3, 3 * durationHour ], - [ hour$$1, 6, 6 * durationHour ], - [ hour$$1, 12, 12 * durationHour ], - [ day$$1, 1, durationDay ], - [ day$$1, 2, 2 * durationDay ], - [ week, 1, durationWeek ], - [ month$$1, 1, durationMonth ], - [ month$$1, 3, 3 * durationMonth ], - [ year$$1, 1, durationYear ] - ]; - - function tickFormat(date) { - return (second$$1(date) < date ? formatMillisecond - : minute$$1(date) < date ? formatSecond - : hour$$1(date) < date ? formatMinute - : day$$1(date) < date ? formatHour - : month$$1(date) < date ? (week(date) < date ? formatDay : formatWeek) - : year$$1(date) < date ? formatMonth - : formatYear)(date); - } - - function tickInterval(interval, start, stop, step) { - if (interval == null) interval = 10; - - // If a desired tick count is specified, pick a reasonable tick interval - // based on the extent of the domain and a rough estimate of tick size. - // Otherwise, assume interval is already a time interval and use it. - if (typeof interval === "number") { - var target = Math.abs(stop - start) / interval, - i = bisector(function(i) { return i[2]; }).right(tickIntervals, target); - if (i === tickIntervals.length) { - step = tickStep(start / durationYear, stop / durationYear, interval); - interval = year$$1; - } else if (i) { - i = tickIntervals[target / tickIntervals[i - 1][2] < tickIntervals[i][2] / target ? i - 1 : i]; - step = i[1]; - interval = i[0]; - } else { - step = tickStep(start, stop, interval); - interval = millisecond$$1; - } - } - - return step == null ? interval : interval.every(step); - } - - scale.invert = function(y) { - return new Date(invert(y)); - }; - - scale.domain = function(_) { - return arguments.length ? domain(map$3.call(_, number$2)) : domain().map(date$1); - }; - - scale.ticks = function(interval, step) { - var d = domain(), - t0 = d[0], - t1 = d[d.length - 1], - r = t1 < t0, - t; - if (r) t = t0, t0 = t1, t1 = t; - t = tickInterval(interval, t0, t1, step); - t = t ? t.range(t0, t1 + 1) : []; // inclusive stop - return r ? t.reverse() : t; - }; - - scale.tickFormat = function(count, specifier) { - return specifier == null ? tickFormat : format(specifier); - }; - - scale.nice = function(interval, step) { - var d = domain(); - return (interval = tickInterval(interval, d[0], d[d.length - 1], step)) - ? domain(nice(d, interval)) - : scale; - }; - - scale.copy = function() { - return copy(scale, calendar(year$$1, month$$1, week, day$$1, hour$$1, minute$$1, second$$1, millisecond$$1, format)); - }; - - return scale; -} - var colors = function(s) { return s.match(/.{6}/g).map(function(x) { return "#" + x; @@ -9622,120 +6947,866 @@ var cool = cubehelixLong(cubehelix(260, 0.75, 0.35), cubehelix(80, 1.50, 0.8)); var rainbow = cubehelix(); -function sequential(interpolator) { - var x0 = 0, - x1 = 1, - clamp = false; +var xhtml$1 = "http://www.w3.org/1999/xhtml"; - function scale(x) { - var t = (x - x0) / (x1 - x0); - return interpolator(clamp ? Math.max(0, Math.min(1, t)) : t); +var namespaces$1 = { + svg: "http://www.w3.org/2000/svg", + xhtml: xhtml$1, + xlink: "http://www.w3.org/1999/xlink", + xml: "http://www.w3.org/XML/1998/namespace", + xmlns: "http://www.w3.org/2000/xmlns/" +}; + +var namespace$1 = function(name) { + var prefix = name += "", i = prefix.indexOf(":"); + if (i >= 0 && (prefix = name.slice(0, i)) !== "xmlns") name = name.slice(i + 1); + return namespaces$1.hasOwnProperty(prefix) ? {space: namespaces$1[prefix], local: name} : name; +}; + +function creatorInherit$1(name) { + return function() { + var document = this.ownerDocument, + uri = this.namespaceURI; + return uri === xhtml$1 && document.documentElement.namespaceURI === xhtml$1 + ? document.createElement(name) + : document.createElementNS(uri, name); + }; +} + +function creatorFixed$1(fullname) { + return function() { + return this.ownerDocument.createElementNS(fullname.space, fullname.local); + }; +} + +var creator$1 = function(name) { + var fullname = namespace$1(name); + return (fullname.local + ? creatorFixed$1 + : creatorInherit$1)(fullname); +}; + +var matcher$2 = function(selector) { + return function() { + return this.matches(selector); + }; +}; + +if (typeof document !== "undefined") { + var element$2 = document.documentElement; + if (!element$2.matches) { + var vendorMatches$1 = element$2.webkitMatchesSelector + || element$2.msMatchesSelector + || element$2.mozMatchesSelector + || element$2.oMatchesSelector; + matcher$2 = function(selector) { + return function() { + return vendorMatches$1.call(this, selector); + }; + }; + } +} + +var matcher$3 = matcher$2; + +var filterEvents$1 = {}; + +var event$1 = null; + +if (typeof document !== "undefined") { + var element$3 = document.documentElement; + if (!("onmouseenter" in element$3)) { + filterEvents$1 = {mouseenter: "mouseover", mouseleave: "mouseout"}; + } +} + +function filterContextListener$1(listener, index, group) { + listener = contextListener$1(listener, index, group); + return function(event) { + var related = event.relatedTarget; + if (!related || (related !== this && !(related.compareDocumentPosition(this) & 8))) { + listener.call(this, event); + } + }; +} + +function contextListener$1(listener, index, group) { + return function(event1) { + var event0 = event$1; // Events can be reentrant (e.g., focus). + event$1 = event1; + try { + listener.call(this, this.__data__, index, group); + } finally { + event$1 = event0; + } + }; +} + +function parseTypenames$2(typenames) { + return typenames.trim().split(/^|\s+/).map(function(t) { + var name = "", i = t.indexOf("."); + if (i >= 0) name = t.slice(i + 1), t = t.slice(0, i); + return {type: t, name: name}; + }); +} + +function onRemove$1(typename) { + return function() { + var on = this.__on; + if (!on) return; + for (var j = 0, i = -1, m = on.length, o; j < m; ++j) { + if (o = on[j], (!typename.type || o.type === typename.type) && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.capture); + } else { + on[++i] = o; + } + } + if (++i) on.length = i; + else delete this.__on; + }; +} + +function onAdd$1(typename, value, capture) { + var wrap = filterEvents$1.hasOwnProperty(typename.type) ? filterContextListener$1 : contextListener$1; + return function(d, i, group) { + var on = this.__on, o, listener = wrap(value, i, group); + if (on) for (var j = 0, m = on.length; j < m; ++j) { + if ((o = on[j]).type === typename.type && o.name === typename.name) { + this.removeEventListener(o.type, o.listener, o.capture); + this.addEventListener(o.type, o.listener = listener, o.capture = capture); + o.value = value; + return; + } + } + this.addEventListener(typename.type, listener, capture); + o = {type: typename.type, name: typename.name, value: value, listener: listener, capture: capture}; + if (!on) this.__on = [o]; + else on.push(o); + }; +} + +var selection_on$1 = function(typename, value, capture) { + var typenames = parseTypenames$2(typename + ""), i, n = typenames.length, t; + + if (arguments.length < 2) { + var on = this.node().__on; + if (on) for (var j = 0, m = on.length, o; j < m; ++j) { + for (i = 0, o = on[j]; i < n; ++i) { + if ((t = typenames[i]).type === o.type && t.name === o.name) { + return o.value; + } + } + } + return; } - scale.domain = function(_) { - return arguments.length ? (x0 = +_[0], x1 = +_[1], scale) : [x0, x1]; - }; + on = value ? onAdd$1 : onRemove$1; + if (capture == null) capture = false; + for (i = 0; i < n; ++i) this.each(on(typenames[i], value, capture)); + return this; +}; - scale.clamp = function(_) { - return arguments.length ? (clamp = !!_, scale) : clamp; - }; +function none$1() {} - scale.interpolator = function(_) { - return arguments.length ? (interpolator = _, scale) : interpolator; +var selector$1 = function(selector) { + return selector == null ? none$1 : function() { + return this.querySelector(selector); }; +}; - scale.copy = function() { - return sequential(interpolator).domain([x0, x1]).clamp(clamp); - }; +var selection_select$1 = function(select) { + if (typeof select !== "function") select = selector$1(select); - return linearish(scale); + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = new Array(n), node, subnode, i = 0; i < n; ++i) { + if ((node = group[i]) && (subnode = select.call(node, node.__data__, i, group))) { + if ("__data__" in node) subnode.__data__ = node.__data__; + subgroup[i] = subnode; + } + } + } + + return new Selection$2(subgroups, this._parents); +}; + +function empty$2() { + return []; } +var selectorAll$1 = function(selector) { + return selector == null ? empty$2 : function() { + return this.querySelectorAll(selector); + }; +}; + +var selection_selectAll$1 = function(select) { + if (typeof select !== "function") select = selectorAll$1(select); + + for (var groups = this._groups, m = groups.length, subgroups = [], parents = [], j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, node, i = 0; i < n; ++i) { + if (node = group[i]) { + subgroups.push(select.call(node, node.__data__, i, group)); + parents.push(node); + } + } + } + + return new Selection$2(subgroups, parents); +}; + +var selection_filter$1 = function(match) { + if (typeof match !== "function") match = matcher$3(match); + + for (var groups = this._groups, m = groups.length, subgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, subgroup = subgroups[j] = [], node, i = 0; i < n; ++i) { + if ((node = group[i]) && match.call(node, node.__data__, i, group)) { + subgroup.push(node); + } + } + } + + return new Selection$2(subgroups, this._parents); +}; + +var sparse$1 = function(update) { + return new Array(update.length); +}; + +var selection_enter$1 = function() { + return new Selection$2(this._enter || this._groups.map(sparse$1), this._parents); +}; + +function EnterNode$1(parent, datum) { + this.ownerDocument = parent.ownerDocument; + this.namespaceURI = parent.namespaceURI; + this._next = null; + this._parent = parent; + this.__data__ = datum; +} + +EnterNode$1.prototype = { + constructor: EnterNode$1, + appendChild: function(child) { return this._parent.insertBefore(child, this._next); }, + insertBefore: function(child, next) { return this._parent.insertBefore(child, next); }, + querySelector: function(selector) { return this._parent.querySelector(selector); }, + querySelectorAll: function(selector) { return this._parent.querySelectorAll(selector); } +}; + +var constant$10 = function(x) { + return function() { + return x; + }; +}; + +var keyPrefix$2 = "$"; // Protect against keys like “__proto__”. + +function bindIndex$1(parent, group, enter, update, exit, data) { + var i = 0, + node, + groupLength = group.length, + dataLength = data.length; + + // Put any non-null nodes that fit into update. + // Put any null nodes into enter. + // Put any remaining data into enter. + for (; i < dataLength; ++i) { + if (node = group[i]) { + node.__data__ = data[i]; + update[i] = node; + } else { + enter[i] = new EnterNode$1(parent, data[i]); + } + } + + // Put any non-null nodes that don’t fit into exit. + for (; i < groupLength; ++i) { + if (node = group[i]) { + exit[i] = node; + } + } +} + +function bindKey$1(parent, group, enter, update, exit, data, key) { + var i, + node, + nodeByKeyValue = {}, + groupLength = group.length, + dataLength = data.length, + keyValues = new Array(groupLength), + keyValue; + + // Compute the key for each node. + // If multiple nodes have the same key, the duplicates are added to exit. + for (i = 0; i < groupLength; ++i) { + if (node = group[i]) { + keyValues[i] = keyValue = keyPrefix$2 + key.call(node, node.__data__, i, group); + if (keyValue in nodeByKeyValue) { + exit[i] = node; + } else { + nodeByKeyValue[keyValue] = node; + } + } + } + + // Compute the key for each datum. + // If there a node associated with this key, join and add it to update. + // If there is not (or the key is a duplicate), add it to enter. + for (i = 0; i < dataLength; ++i) { + keyValue = keyPrefix$2 + key.call(parent, data[i], i, data); + if (node = nodeByKeyValue[keyValue]) { + update[i] = node; + node.__data__ = data[i]; + nodeByKeyValue[keyValue] = null; + } else { + enter[i] = new EnterNode$1(parent, data[i]); + } + } + + // Add any remaining nodes that were not bound to data to exit. + for (i = 0; i < groupLength; ++i) { + if ((node = group[i]) && (nodeByKeyValue[keyValues[i]] === node)) { + exit[i] = node; + } + } +} + +var selection_data$1 = function(value, key) { + if (!value) { + data = new Array(this.size()), j = -1; + this.each(function(d) { data[++j] = d; }); + return data; + } + + var bind = key ? bindKey$1 : bindIndex$1, + parents = this._parents, + groups = this._groups; + + if (typeof value !== "function") value = constant$10(value); + + for (var m = groups.length, update = new Array(m), enter = new Array(m), exit = new Array(m), j = 0; j < m; ++j) { + var parent = parents[j], + group = groups[j], + groupLength = group.length, + data = value.call(parent, parent && parent.__data__, j, parents), + dataLength = data.length, + enterGroup = enter[j] = new Array(dataLength), + updateGroup = update[j] = new Array(dataLength), + exitGroup = exit[j] = new Array(groupLength); + + bind(parent, group, enterGroup, updateGroup, exitGroup, data, key); + + // Now connect the enter nodes to their following update node, such that + // appendChild can insert the materialized enter node before this node, + // rather than at the end of the parent node. + for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) { + if (previous = enterGroup[i0]) { + if (i0 >= i1) i1 = i0 + 1; + while (!(next = updateGroup[i1]) && ++i1 < dataLength); + previous._next = next || null; + } + } + } + + update = new Selection$2(update, parents); + update._enter = enter; + update._exit = exit; + return update; +}; + +var selection_exit$1 = function() { + return new Selection$2(this._exit || this._groups.map(sparse$1), this._parents); +}; + +var selection_merge$1 = function(selection) { + + for (var groups0 = this._groups, groups1 = selection._groups, m0 = groups0.length, m1 = groups1.length, m = Math.min(m0, m1), merges = new Array(m0), j = 0; j < m; ++j) { + for (var group0 = groups0[j], group1 = groups1[j], n = group0.length, merge = merges[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group0[i] || group1[i]) { + merge[i] = node; + } + } + } + + for (; j < m0; ++j) { + merges[j] = groups0[j]; + } + + return new Selection$2(merges, this._parents); +}; + +var selection_order$1 = function() { + + for (var groups = this._groups, j = -1, m = groups.length; ++j < m;) { + for (var group = groups[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; +}; + +var selection_sort$1 = function(compare) { + if (!compare) compare = ascending$2; + + function compareNode(a, b) { + return a && b ? compare(a.__data__, b.__data__) : !a - !b; + } + + for (var groups = this._groups, m = groups.length, sortgroups = new Array(m), j = 0; j < m; ++j) { + for (var group = groups[j], n = group.length, sortgroup = sortgroups[j] = new Array(n), node, i = 0; i < n; ++i) { + if (node = group[i]) { + sortgroup[i] = node; + } + } + sortgroup.sort(compareNode); + } + + return new Selection$2(sortgroups, this._parents).order(); +}; + +function ascending$2(a, b) { + return a < b ? -1 : a > b ? 1 : a >= b ? 0 : NaN; +} + +var selection_call$1 = function() { + var callback = arguments[0]; + arguments[0] = this; + callback.apply(null, arguments); + return this; +}; + +var selection_nodes$1 = function() { + var nodes = new Array(this.size()), i = -1; + this.each(function() { nodes[++i] = this; }); + return nodes; +}; + +var selection_node$1 = function() { + + for (var groups = this._groups, j = 0, m = groups.length; j < m; ++j) { + for (var group = groups[j], i = 0, n = group.length; i < n; ++i) { + var node = group[i]; + if (node) return node; + } + } + + return null; +}; + +var selection_size$1 = function() { + var size = 0; + this.each(function() { ++size; }); + return size; +}; + +var selection_empty$1 = function() { + return !this.node(); +}; + +var selection_each$1 = function(callback) { + + for (var groups = this._groups, 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.call(node, node.__data__, i, group); + } + } + + return this; +}; + +function attrRemove$2(name) { + return function() { + this.removeAttribute(name); + }; +} + +function attrRemoveNS$2(fullname) { + return function() { + this.removeAttributeNS(fullname.space, fullname.local); + }; +} + +function attrConstant$2(name, value) { + return function() { + this.setAttribute(name, value); + }; +} + +function attrConstantNS$2(fullname, value) { + return function() { + this.setAttributeNS(fullname.space, fullname.local, value); + }; +} + +function attrFunction$2(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttribute(name); + else this.setAttribute(name, v); + }; +} + +function attrFunctionNS$2(fullname, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.removeAttributeNS(fullname.space, fullname.local); + else this.setAttributeNS(fullname.space, fullname.local, v); + }; +} + +var selection_attr$1 = function(name, value) { + var fullname = namespace$1(name); + + if (arguments.length < 2) { + var node = this.node(); + return fullname.local + ? node.getAttributeNS(fullname.space, fullname.local) + : node.getAttribute(fullname); + } + + return this.each((value == null + ? (fullname.local ? attrRemoveNS$2 : attrRemove$2) : (typeof value === "function" + ? (fullname.local ? attrFunctionNS$2 : attrFunction$2) + : (fullname.local ? attrConstantNS$2 : attrConstant$2)))(fullname, value)); +}; + +var defaultView = function(node) { + return (node.ownerDocument && node.ownerDocument.defaultView) // node is a Node + || (node.document && node) // node is a Window + || node.defaultView; // node is a Document +}; + +function styleRemove$2(name) { + return function() { + this.style.removeProperty(name); + }; +} + +function styleConstant$2(name, value, priority) { + return function() { + this.style.setProperty(name, value, priority); + }; +} + +function styleFunction$2(name, value, priority) { + return function() { + var v = value.apply(this, arguments); + if (v == null) this.style.removeProperty(name); + else this.style.setProperty(name, v, priority); + }; +} + +var selection_style$1 = function(name, value, priority) { + var node; + return arguments.length > 1 + ? this.each((value == null + ? styleRemove$2 : typeof value === "function" + ? styleFunction$2 + : styleConstant$2)(name, value, priority == null ? "" : priority)) + : defaultView(node = this.node()) + .getComputedStyle(node, null) + .getPropertyValue(name); +}; + +function propertyRemove$1(name) { + return function() { + delete this[name]; + }; +} + +function propertyConstant$1(name, value) { + return function() { + this[name] = value; + }; +} + +function propertyFunction$1(name, value) { + return function() { + var v = value.apply(this, arguments); + if (v == null) delete this[name]; + else this[name] = v; + }; +} + +var selection_property$1 = function(name, value) { + return arguments.length > 1 + ? this.each((value == null + ? propertyRemove$1 : typeof value === "function" + ? propertyFunction$1 + : propertyConstant$1)(name, value)) + : this.node()[name]; +}; + +function classArray$1(string) { + return string.trim().split(/^|\s+/); +} + +function classList$1(node) { + return node.classList || new ClassList$1(node); +} + +function ClassList$1(node) { + this._node = node; + this._names = classArray$1(node.getAttribute("class") || ""); +} + +ClassList$1.prototype = { + add: function(name) { + var i = this._names.indexOf(name); + if (i < 0) { + this._names.push(name); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + remove: function(name) { + var i = this._names.indexOf(name); + if (i >= 0) { + this._names.splice(i, 1); + this._node.setAttribute("class", this._names.join(" ")); + } + }, + contains: function(name) { + return this._names.indexOf(name) >= 0; + } +}; + +function classedAdd$1(node, names) { + var list = classList$1(node), i = -1, n = names.length; + while (++i < n) list.add(names[i]); +} + +function classedRemove$1(node, names) { + var list = classList$1(node), i = -1, n = names.length; + while (++i < n) list.remove(names[i]); +} + +function classedTrue$1(names) { + return function() { + classedAdd$1(this, names); + }; +} + +function classedFalse$1(names) { + return function() { + classedRemove$1(this, names); + }; +} + +function classedFunction$1(names, value) { + return function() { + (value.apply(this, arguments) ? classedAdd$1 : classedRemove$1)(this, names); + }; +} + +var selection_classed$1 = function(name, value) { + var names = classArray$1(name + ""); + + if (arguments.length < 2) { + var list = classList$1(this.node()), i = -1, n = names.length; + while (++i < n) if (!list.contains(names[i])) return false; + return true; + } + + return this.each((typeof value === "function" + ? classedFunction$1 : value + ? classedTrue$1 + : classedFalse$1)(names, value)); +}; + +function textRemove$1() { + this.textContent = ""; +} + +function textConstant$2(value) { + return function() { + this.textContent = value; + }; +} + +function textFunction$2(value) { + return function() { + var v = value.apply(this, arguments); + this.textContent = v == null ? "" : v; + }; +} + +var selection_text$1 = function(value) { + return arguments.length + ? this.each(value == null + ? textRemove$1 : (typeof value === "function" + ? textFunction$2 + : textConstant$2)(value)) + : this.node().textContent; +}; + +function htmlRemove$1() { + this.innerHTML = ""; +} + +function htmlConstant$1(value) { + return function() { + this.innerHTML = value; + }; +} + +function htmlFunction$1(value) { + return function() { + var v = value.apply(this, arguments); + this.innerHTML = v == null ? "" : v; + }; +} + +var selection_html$1 = function(value) { + return arguments.length + ? this.each(value == null + ? htmlRemove$1 : (typeof value === "function" + ? htmlFunction$1 + : htmlConstant$1)(value)) + : this.node().innerHTML; +}; + +function raise$2() { + if (this.nextSibling) this.parentNode.appendChild(this); +} + +var selection_raise$1 = function() { + return this.each(raise$2); +}; + +function lower$1() { + if (this.previousSibling) this.parentNode.insertBefore(this, this.parentNode.firstChild); +} + +var selection_lower$1 = function() { + return this.each(lower$1); +}; + +var selection_append$1 = function(name) { + var create = typeof name === "function" ? name : creator$1(name); + return this.select(function() { + return this.appendChild(create.apply(this, arguments)); + }); +}; + +function constantNull$1() { + return null; +} + +var selection_insert$1 = function(name, before) { + var create = typeof name === "function" ? name : creator$1(name), + select = before == null ? constantNull$1 : typeof before === "function" ? before : selector$1(before); + return this.select(function() { + return this.insertBefore(create.apply(this, arguments), select.apply(this, arguments) || null); + }); +}; + +function remove$1() { + var parent = this.parentNode; + if (parent) parent.removeChild(this); +} + +var selection_remove$1 = function() { + return this.each(remove$1); +}; + +var selection_datum$1 = function(value) { + return arguments.length + ? this.property("__data__", value) + : this.node().__data__; +}; + +function dispatchEvent$1(node, type, params) { + var window = defaultView(node), + event = window.CustomEvent; + + if (event) { + event = new event(type, params); + } else { + event = window.document.createEvent("Event"); + if (params) event.initEvent(type, params.bubbles, params.cancelable), event.detail = params.detail; + else event.initEvent(type, false, false); + } + + node.dispatchEvent(event); +} + +function dispatchConstant$1(type, params) { + return function() { + return dispatchEvent$1(this, type, params); + }; +} + +function dispatchFunction$1(type, params) { + return function() { + return dispatchEvent$1(this, type, params.apply(this, arguments)); + }; +} + +var selection_dispatch$1 = function(type, params) { + return this.each((typeof params === "function" + ? dispatchFunction$1 + : dispatchConstant$1)(type, params)); +}; + +var root$2 = [null]; + +function Selection$2(groups, parents) { + this._groups = groups; + this._parents = parents; +} + +function selection$2() { + return new Selection$2([[document.documentElement]], root$2); +} + +Selection$2.prototype = selection$2.prototype = { + constructor: Selection$2, + select: selection_select$1, + selectAll: selection_selectAll$1, + filter: selection_filter$1, + data: selection_data$1, + enter: selection_enter$1, + exit: selection_exit$1, + merge: selection_merge$1, + order: selection_order$1, + sort: selection_sort$1, + call: selection_call$1, + nodes: selection_nodes$1, + node: selection_node$1, + size: selection_size$1, + empty: selection_empty$1, + each: selection_each$1, + attr: selection_attr$1, + style: selection_style$1, + property: selection_property$1, + classed: selection_classed$1, + text: selection_text$1, + html: selection_html$1, + raise: selection_raise$1, + lower: selection_lower$1, + append: selection_append$1, + insert: selection_insert$1, + remove: selection_remove$1, + datum: selection_datum$1, + on: selection_on$1, + dispatch: selection_dispatch$1 +}; + +var select$1 = function(selector) { + return typeof selector === "string" + ? new Selection$2([[document.querySelector(selector)]], [document.documentElement]) + : new Selection$2([[selector]], root$2); +}; + var constant$11 = function(x) { return function constant() { return x; }; }; -var epsilon$3 = 1e-12; -var pi$4 = Math.PI; -var halfPi$3 = pi$4 / 2; -var tau$4 = 2 * pi$4; - -function arcInnerRadius(d) { - return d.innerRadius; -} - -function arcOuterRadius(d) { - return d.outerRadius; -} - -function arcStartAngle(d) { - return d.startAngle; -} - -function arcEndAngle(d) { - return d.endAngle; -} - -function arcPadAngle(d) { - return d && d.padAngle; // Note: optional! -} - -function asin$1(x) { - return x >= 1 ? halfPi$3 : x <= -1 ? -halfPi$3 : Math.asin(x); -} - -function intersect(x0, y0, x1, y1, x2, y2, x3, y3) { - var x10 = x1 - x0, y10 = y1 - y0, - x32 = x3 - x2, y32 = y3 - y2, - t = (x32 * (y0 - y2) - y32 * (x0 - x2)) / (y32 * x10 - x32 * y10); - return [x0 + t * x10, y0 + t * y10]; -} - -// Compute perpendicular offset line of length rc. -// http://mathworld.wolfram.com/Circle-LineIntersection.html -function cornerTangents(x0, y0, x1, y1, r1, rc, cw) { - var x01 = x0 - x1, - y01 = y0 - y1, - lo = (cw ? rc : -rc) / Math.sqrt(x01 * x01 + y01 * y01), - ox = lo * y01, - oy = -lo * x01, - x11 = x0 + ox, - y11 = y0 + oy, - x10 = x1 + ox, - y10 = y1 + oy, - x00 = (x11 + x10) / 2, - y00 = (y11 + y10) / 2, - dx = x10 - x11, - dy = y10 - y11, - d2 = dx * dx + dy * dy, - r = r1 - rc, - D = x11 * y10 - x10 * y11, - d = (dy < 0 ? -1 : 1) * Math.sqrt(Math.max(0, 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 - x00, - dy0 = cy0 - y00, - dx1 = cx1 - x00, - dy1 = cy1 - y00; - - // Pick the closer of the two intersection points. - // TODO Is there a faster way to determine which intersection to use? - if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; - - return { - cx: cx0, - cy: cy0, - x01: -ox, - y01: -oy, - x11: cx0 * (r1 / r - 1), - y11: cy0 * (r1 / r - 1) - }; -} - function Linear(context) { this._context = context; } @@ -9827,665 +7898,6 @@ var line = function() { return line; }; -var area$2 = function() { - var x0 = x$3, - x1 = null, - y0 = constant$11(0), - y1 = y$3, - defined = constant$11(true), - context = null, - curve = curveLinear, - output = null; - - function area(data) { - var i, - j, - k, - n = data.length, - d, - defined0 = false, - buffer, - x0z = new Array(n), - y0z = new Array(n); - - if (context == null) output = curve(buffer = path()); - - for (i = 0; i <= n; ++i) { - if (!(i < n && defined(d = data[i], i, data)) === defined0) { - if (defined0 = !defined0) { - j = i; - output.areaStart(); - output.lineStart(); - } else { - output.lineEnd(); - output.lineStart(); - for (k = i - 1; k >= j; --k) { - output.point(x0z[k], y0z[k]); - } - output.lineEnd(); - output.areaEnd(); - } - } - if (defined0) { - x0z[i] = +x0(d, i, data), y0z[i] = +y0(d, i, data); - output.point(x1 ? +x1(d, i, data) : x0z[i], y1 ? +y1(d, i, data) : y0z[i]); - } - } - - if (buffer) return output = null, buffer + "" || null; - } - - function arealine() { - return line().defined(defined).curve(curve).context(context); - } - - area.x = function(_) { - return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$11(+_), x1 = null, area) : x0; - }; - - area.x0 = function(_) { - return arguments.length ? (x0 = typeof _ === "function" ? _ : constant$11(+_), area) : x0; - }; - - area.x1 = function(_) { - return arguments.length ? (x1 = _ == null ? null : typeof _ === "function" ? _ : constant$11(+_), area) : x1; - }; - - area.y = function(_) { - return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$11(+_), y1 = null, area) : y0; - }; - - area.y0 = function(_) { - return arguments.length ? (y0 = typeof _ === "function" ? _ : constant$11(+_), area) : y0; - }; - - area.y1 = function(_) { - return arguments.length ? (y1 = _ == null ? null : typeof _ === "function" ? _ : constant$11(+_), area) : y1; - }; - - area.lineX0 = - area.lineY0 = function() { - return arealine().x(x0).y(y0); - }; - - area.lineY1 = function() { - return arealine().x(x0).y(y1); - }; - - area.lineX1 = function() { - return arealine().x(x1).y(y0); - }; - - area.defined = function(_) { - return arguments.length ? (defined = typeof _ === "function" ? _ : constant$11(!!_), area) : defined; - }; - - area.curve = function(_) { - return arguments.length ? (curve = _, context != null && (output = curve(context)), area) : curve; - }; - - area.context = function(_) { - return arguments.length ? (_ == null ? context = output = null : output = curve(context = _), area) : context; - }; - - return area; -}; - -var descending$1 = function(a, b) { - return b < a ? -1 : b > a ? 1 : b >= a ? 0 : NaN; -}; - -var identity$7 = function(d) { - return d; -}; - -var curveRadialLinear = curveRadial(curveLinear); - -function Radial(curve) { - this._curve = curve; -} - -Radial.prototype = { - areaStart: function() { - this._curve.areaStart(); - }, - areaEnd: function() { - this._curve.areaEnd(); - }, - lineStart: function() { - this._curve.lineStart(); - }, - lineEnd: function() { - this._curve.lineEnd(); - }, - point: function(a, r) { - this._curve.point(r * Math.sin(a), r * -Math.cos(a)); - } -}; - -function curveRadial(curve) { - - function radial(context) { - return new Radial(curve(context)); - } - - radial._curve = curve; - - return radial; -} - -function radialLine(l) { - var c = l.curve; - - l.angle = l.x, delete l.x; - l.radius = l.y, delete l.y; - - l.curve = function(_) { - return arguments.length ? c(curveRadial(_)) : c()._curve; - }; - - return l; -} - -var circle$2 = { - draw: function(context, size) { - var r = Math.sqrt(size / pi$4); - context.moveTo(r, 0); - context.arc(0, 0, r, 0, tau$4); - } -}; - -var noop$2 = function() {}; - -function point$2(that, x, y) { - that._context.bezierCurveTo( - (2 * that._x0 + that._x1) / 3, - (2 * that._y0 + that._y1) / 3, - (that._x0 + 2 * that._x1) / 3, - (that._y0 + 2 * that._y1) / 3, - (that._x0 + 4 * that._x1 + x) / 6, - (that._y0 + 4 * that._y1 + y) / 6 - ); -} - -function Basis(context) { - this._context = context; -} - -Basis.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = - this._y0 = this._y1 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 3: point$2(this, this._x1, this._y1); // proceed - case 2: this._context.lineTo(this._x1, this._y1); break; - } - if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x, y) { - x = +x, y = +y; - switch (this._point) { - case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; - case 1: this._point = 2; break; - case 2: this._point = 3; this._context.lineTo((5 * this._x0 + this._x1) / 6, (5 * this._y0 + this._y1) / 6); // proceed - default: point$2(this, x, y); break; - } - this._x0 = this._x1, this._x1 = x; - this._y0 = this._y1, this._y1 = y; - } -}; - -function Bundle(context, beta) { - this._basis = new Basis(context); - this._beta = beta; -} - -Bundle.prototype = { - lineStart: function() { - this._x = []; - this._y = []; - this._basis.lineStart(); - }, - lineEnd: function() { - var x = this._x, - y = this._y, - j = x.length - 1; - - if (j > 0) { - var x0 = x[0], - y0 = y[0], - dx = x[j] - x0, - dy = y[j] - y0, - i = -1, - t; - - while (++i <= j) { - t = i / j; - this._basis.point( - this._beta * x[i] + (1 - this._beta) * (x0 + t * dx), - this._beta * y[i] + (1 - this._beta) * (y0 + t * dy) - ); - } - } - - this._x = this._y = null; - this._basis.lineEnd(); - }, - point: function(x, y) { - this._x.push(+x); - this._y.push(+y); - } -}; - -(function custom(beta) { - - function bundle(context) { - return beta === 1 ? new Basis(context) : new Bundle(context, beta); - } - - bundle.beta = function(beta) { - return custom(+beta); - }; - - return bundle; -})(0.85); - -function point$3(that, x, y) { - that._context.bezierCurveTo( - that._x1 + that._k * (that._x2 - that._x0), - that._y1 + that._k * (that._y2 - that._y0), - that._x2 + that._k * (that._x1 - x), - that._y2 + that._k * (that._y1 - y), - that._x2, - that._y2 - ); -} - -function Cardinal(context, tension) { - this._context = context; - this._k = (1 - tension) / 6; -} - -Cardinal.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = - this._y0 = this._y1 = this._y2 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 2: this._context.lineTo(this._x2, this._y2); break; - case 3: point$3(this, this._x1, this._y1); break; - } - if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x, y) { - x = +x, y = +y; - switch (this._point) { - case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; - case 1: this._point = 2; this._x1 = x, this._y1 = y; break; - case 2: this._point = 3; // proceed - default: point$3(this, x, y); break; - } - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; - } -}; - -(function custom(tension) { - - function cardinal(context) { - return new Cardinal(context, tension); - } - - cardinal.tension = function(tension) { - return custom(+tension); - }; - - return cardinal; -})(0); - -function CardinalClosed(context, tension) { - this._context = context; - this._k = (1 - tension) / 6; -} - -CardinalClosed.prototype = { - areaStart: noop$2, - areaEnd: noop$2, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = - this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 1: { - this._context.moveTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 2: { - this._context.lineTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 3: { - this.point(this._x3, this._y3); - this.point(this._x4, this._y4); - this.point(this._x5, this._y5); - break; - } - } - }, - point: function(x, y) { - x = +x, y = +y; - switch (this._point) { - case 0: this._point = 1; this._x3 = x, this._y3 = y; break; - case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; - case 2: this._point = 3; this._x5 = x, this._y5 = y; break; - default: point$3(this, x, y); break; - } - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; - } -}; - -(function custom(tension) { - - function cardinal(context) { - return new CardinalClosed(context, tension); - } - - cardinal.tension = function(tension) { - return custom(+tension); - }; - - return cardinal; -})(0); - -function CardinalOpen(context, tension) { - this._context = context; - this._k = (1 - tension) / 6; -} - -CardinalOpen.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = - this._y0 = this._y1 = this._y2 = NaN; - this._point = 0; - }, - lineEnd: function() { - if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x, y) { - x = +x, y = +y; - switch (this._point) { - case 0: this._point = 1; break; - case 1: this._point = 2; break; - case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; - case 3: this._point = 4; // proceed - default: point$3(this, x, y); break; - } - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; - } -}; - -(function custom(tension) { - - function cardinal(context) { - return new CardinalOpen(context, tension); - } - - cardinal.tension = function(tension) { - return custom(+tension); - }; - - return cardinal; -})(0); - -function point$4(that, x, y) { - var x1 = that._x1, - y1 = that._y1, - x2 = that._x2, - y2 = that._y2; - - if (that._l01_a > epsilon$3) { - var a = 2 * that._l01_2a + 3 * that._l01_a * that._l12_a + that._l12_2a, - n = 3 * that._l01_a * (that._l01_a + that._l12_a); - x1 = (x1 * a - that._x0 * that._l12_2a + that._x2 * that._l01_2a) / n; - y1 = (y1 * a - that._y0 * that._l12_2a + that._y2 * that._l01_2a) / n; - } - - if (that._l23_a > epsilon$3) { - var b = 2 * that._l23_2a + 3 * that._l23_a * that._l12_a + that._l12_2a, - m = 3 * that._l23_a * (that._l23_a + that._l12_a); - x2 = (x2 * b + that._x1 * that._l23_2a - x * that._l12_2a) / m; - y2 = (y2 * b + that._y1 * that._l23_2a - y * that._l12_2a) / m; - } - - that._context.bezierCurveTo(x1, y1, x2, y2, that._x2, that._y2); -} - -function CatmullRom(context, alpha) { - this._context = context; - this._alpha = alpha; -} - -CatmullRom.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = - this._y0 = this._y1 = this._y2 = NaN; - this._l01_a = this._l12_a = this._l23_a = - this._l01_2a = this._l12_2a = this._l23_2a = - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 2: this._context.lineTo(this._x2, this._y2); break; - case 3: this.point(this._x2, this._y2); break; - } - if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x, y) { - x = +x, y = +y; - - if (this._point) { - var x23 = this._x2 - x, - y23 = this._y2 - y; - this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); - } - - switch (this._point) { - case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; - case 1: this._point = 2; break; - case 2: this._point = 3; // proceed - default: point$4(this, x, y); break; - } - - this._l01_a = this._l12_a, this._l12_a = this._l23_a; - this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; - } -}; - -(function custom(alpha) { - - function catmullRom(context) { - return alpha ? new CatmullRom(context, alpha) : new Cardinal(context, 0); - } - - catmullRom.alpha = function(alpha) { - return custom(+alpha); - }; - - return catmullRom; -})(0.5); - -function CatmullRomClosed(context, alpha) { - this._context = context; - this._alpha = alpha; -} - -CatmullRomClosed.prototype = { - areaStart: noop$2, - areaEnd: noop$2, - lineStart: function() { - this._x0 = this._x1 = this._x2 = this._x3 = this._x4 = this._x5 = - this._y0 = this._y1 = this._y2 = this._y3 = this._y4 = this._y5 = NaN; - this._l01_a = this._l12_a = this._l23_a = - this._l01_2a = this._l12_2a = this._l23_2a = - this._point = 0; - }, - lineEnd: function() { - switch (this._point) { - case 1: { - this._context.moveTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 2: { - this._context.lineTo(this._x3, this._y3); - this._context.closePath(); - break; - } - case 3: { - this.point(this._x3, this._y3); - this.point(this._x4, this._y4); - this.point(this._x5, this._y5); - break; - } - } - }, - point: function(x, y) { - x = +x, y = +y; - - if (this._point) { - var x23 = this._x2 - x, - y23 = this._y2 - y; - this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); - } - - switch (this._point) { - case 0: this._point = 1; this._x3 = x, this._y3 = y; break; - case 1: this._point = 2; this._context.moveTo(this._x4 = x, this._y4 = y); break; - case 2: this._point = 3; this._x5 = x, this._y5 = y; break; - default: point$4(this, x, y); break; - } - - this._l01_a = this._l12_a, this._l12_a = this._l23_a; - this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; - } -}; - -(function custom(alpha) { - - function catmullRom(context) { - return alpha ? new CatmullRomClosed(context, alpha) : new CardinalClosed(context, 0); - } - - catmullRom.alpha = function(alpha) { - return custom(+alpha); - }; - - return catmullRom; -})(0.5); - -function CatmullRomOpen(context, alpha) { - this._context = context; - this._alpha = alpha; -} - -CatmullRomOpen.prototype = { - areaStart: function() { - this._line = 0; - }, - areaEnd: function() { - this._line = NaN; - }, - lineStart: function() { - this._x0 = this._x1 = this._x2 = - this._y0 = this._y1 = this._y2 = NaN; - this._l01_a = this._l12_a = this._l23_a = - this._l01_2a = this._l12_2a = this._l23_2a = - this._point = 0; - }, - lineEnd: function() { - if (this._line || (this._line !== 0 && this._point === 3)) this._context.closePath(); - this._line = 1 - this._line; - }, - point: function(x, y) { - x = +x, y = +y; - - if (this._point) { - var x23 = this._x2 - x, - y23 = this._y2 - y; - this._l23_a = Math.sqrt(this._l23_2a = Math.pow(x23 * x23 + y23 * y23, this._alpha)); - } - - switch (this._point) { - case 0: this._point = 1; break; - case 1: this._point = 2; break; - case 2: this._point = 3; this._line ? this._context.lineTo(this._x2, this._y2) : this._context.moveTo(this._x2, this._y2); break; - case 3: this._point = 4; // proceed - default: point$4(this, x, y); break; - } - - this._l01_a = this._l12_a, this._l12_a = this._l23_a; - this._l01_2a = this._l12_2a, this._l12_2a = this._l23_2a; - this._x0 = this._x1, this._x1 = this._x2, this._x2 = x; - this._y0 = this._y1, this._y1 = this._y2, this._y2 = y; - } -}; - -(function custom(alpha) { - - function catmullRom(context) { - return alpha ? new CatmullRomOpen(context, alpha) : new CardinalOpen(context, 0); - } - - catmullRom.alpha = function(alpha) { - return custom(+alpha); - }; - - return catmullRom; -})(0.5); - function sign$1(x) { return x < 0 ? -1 : 1; } @@ -10512,7 +7924,7 @@ function slope2(that, t) { // According to https://en.wikipedia.org/wiki/Cubic_Hermite_spline#Representations // "you can express cubic Hermite interpolation in terms of cubic Bézier curves // with respect to the four values p0, p0 + m0 / 3, p1 - m1 / 3, p1". -function point$5(that, t0, t1) { +function point$6(that, t0, t1) { var x0 = that._x0, y0 = that._y0, x1 = that._x1, @@ -10541,7 +7953,7 @@ MonotoneX.prototype = { lineEnd: function() { switch (this._point) { case 2: this._context.lineTo(this._x1, this._y1); break; - case 3: point$5(this, this._t0, slope2(this, this._t0)); break; + case 3: point$6(this, this._t0, slope2(this, this._t0)); break; } if (this._line || (this._line !== 0 && this._point === 1)) this._context.closePath(); this._line = 1 - this._line; @@ -10554,8 +7966,8 @@ MonotoneX.prototype = { switch (this._point) { case 0: this._point = 1; this._line ? this._context.lineTo(x, y) : this._context.moveTo(x, y); break; case 1: this._point = 2; break; - case 2: this._point = 3; point$5(this, slope2(this, t1 = slope3(this, x, y)), t1); break; - default: point$5(this, this._t0, t1 = slope3(this, x, y)); break; + case 2: this._point = 3; point$6(this, slope2(this, t1 = slope3(this, x, y)), t1); break; + default: point$6(this, this._t0, t1 = slope3(this, x, y)); break; } this._x0 = this._x1, this._x1 = x; @@ -10583,332 +7995,13 @@ ReflectContext.prototype = { bezierCurveTo: function(x1, y1, x2, y2, x, y) { this._context.bezierCurveTo(y1, x1, y2, x2, y, x); } }; -// See https://www.particleincell.com/2012/bezier-splines/ for derivation. -function controlPoints(x) { - var i, - n = x.length - 1, - m, - a = new Array(n), - b = new Array(n), - r = new Array(n); - a[0] = 0, b[0] = 2, r[0] = x[0] + 2 * x[1]; - for (i = 1; i < n - 1; ++i) a[i] = 1, b[i] = 4, r[i] = 4 * x[i] + 2 * x[i + 1]; - a[n - 1] = 2, b[n - 1] = 7, r[n - 1] = 8 * x[n - 1] + x[n]; - for (i = 1; i < n; ++i) m = a[i] / b[i - 1], b[i] -= m, r[i] -= m * r[i - 1]; - a[n - 1] = r[n - 1] / b[n - 1]; - for (i = n - 2; i >= 0; --i) a[i] = (r[i] - a[i + 1]) / b[i]; - b[n - 1] = (x[n] + a[n - 1]) / 2; - for (i = 0; i < n - 1; ++i) b[i] = 2 * x[i + 1] - a[i + 1]; - return [a, b]; -} - -var slice$5 = Array.prototype.slice; - -var none$1 = function(series, order) { - if (!((n = series.length) > 1)) return; - for (var i = 1, s0, s1 = series[order[0]], n, m = s1.length; i < n; ++i) { - s0 = s1, s1 = series[order[i]]; - for (var j = 0; j < m; ++j) { - s1[j][1] += s1[j][0] = isNaN(s0[j][1]) ? s0[j][0] : s0[j][1]; - } - } -}; - -var none$2 = function(series) { - var n = series.length, o = new Array(n); - while (--n >= 0) o[n] = n; - return o; -}; - -function stackValue(d, key) { - return d[key]; -} - -function sum$2(series) { - var s = 0, i = -1, n = series.length, v; - while (++i < n) if (v = +series[i][1]) s += v; - return s; -} - -var constant$12 = function(x) { - return function() { - return x; - }; -}; - -function x$4(d) { - return d[0]; -} - -function y$4(d) { - return d[1]; -} - -function RedBlackTree() { - this._ = null; // root node -} - -function RedBlackNode(node) { - node.U = // parent node - node.C = // color - true for red, false for black - node.L = // left node - node.R = // right node - node.P = // previous node - node.N = null; // next node -} - -RedBlackTree.prototype = { - constructor: RedBlackTree, - - insert: function(after, node) { - var parent, grandpa, uncle; - - if (after) { - node.P = after; - node.N = after.N; - if (after.N) after.N.P = node; - after.N = node; - if (after.R) { - after = after.R; - while (after.L) after = after.L; - after.L = node; - } else { - after.R = node; - } - parent = after; - } else if (this._) { - after = RedBlackFirst(this._); - node.P = null; - node.N = after; - after.P = after.L = node; - parent = after; - } else { - node.P = node.N = null; - this._ = node; - parent = null; - } - node.L = node.R = null; - node.U = parent; - node.C = true; - - after = node; - while (parent && parent.C) { - grandpa = parent.U; - if (parent === grandpa.L) { - uncle = grandpa.R; - if (uncle && uncle.C) { - parent.C = uncle.C = false; - grandpa.C = true; - after = grandpa; - } else { - if (after === parent.R) { - RedBlackRotateLeft(this, parent); - after = parent; - parent = after.U; - } - parent.C = false; - grandpa.C = true; - RedBlackRotateRight(this, grandpa); - } - } else { - uncle = grandpa.L; - if (uncle && uncle.C) { - parent.C = uncle.C = false; - grandpa.C = true; - after = grandpa; - } else { - if (after === parent.L) { - RedBlackRotateRight(this, parent); - after = parent; - parent = after.U; - } - parent.C = false; - grandpa.C = true; - RedBlackRotateLeft(this, grandpa); - } - } - parent = after.U; - } - this._.C = false; - }, - - remove: function(node) { - if (node.N) node.N.P = node.P; - if (node.P) node.P.N = node.N; - node.N = node.P = null; - - var parent = node.U, - sibling, - left = node.L, - right = node.R, - next, - red; - - if (!left) next = right; - else if (!right) next = left; - else next = RedBlackFirst(right); - - if (parent) { - if (parent.L === node) parent.L = next; - else parent.R = next; - } else { - this._ = next; - } - - if (left && right) { - red = next.C; - next.C = node.C; - next.L = left; - left.U = next; - if (next !== right) { - parent = next.U; - next.U = node.U; - node = next.R; - parent.L = node; - next.R = right; - right.U = next; - } else { - next.U = parent; - parent = next; - node = next.R; - } - } else { - red = node.C; - node = next; - } - - if (node) node.U = parent; - if (red) return; - if (node && node.C) { node.C = false; return; } - - do { - if (node === this._) break; - if (node === parent.L) { - sibling = parent.R; - if (sibling.C) { - sibling.C = false; - parent.C = true; - RedBlackRotateLeft(this, parent); - sibling = parent.R; - } - if ((sibling.L && sibling.L.C) - || (sibling.R && sibling.R.C)) { - if (!sibling.R || !sibling.R.C) { - sibling.L.C = false; - sibling.C = true; - RedBlackRotateRight(this, sibling); - sibling = parent.R; - } - sibling.C = parent.C; - parent.C = sibling.R.C = false; - RedBlackRotateLeft(this, parent); - node = this._; - break; - } - } else { - sibling = parent.L; - if (sibling.C) { - sibling.C = false; - parent.C = true; - RedBlackRotateRight(this, parent); - sibling = parent.L; - } - if ((sibling.L && sibling.L.C) - || (sibling.R && sibling.R.C)) { - if (!sibling.L || !sibling.L.C) { - sibling.R.C = false; - sibling.C = true; - RedBlackRotateLeft(this, sibling); - sibling = parent.L; - } - sibling.C = parent.C; - parent.C = sibling.L.C = false; - RedBlackRotateRight(this, parent); - node = this._; - break; - } - } - sibling.C = true; - node = parent; - parent = parent.U; - } while (!node.C); - - if (node) node.C = false; - } -}; - -function RedBlackRotateLeft(tree, node) { - var p = node, - q = node.R, - parent = p.U; - - if (parent) { - if (parent.L === p) parent.L = q; - else parent.R = q; - } else { - tree._ = q; - } - - q.U = parent; - p.U = q; - p.R = q.L; - if (p.R) p.R.U = p; - q.L = p; -} - -function RedBlackRotateRight(tree, node) { - var p = node, - q = node.L, - parent = p.U; - - if (parent) { - if (parent.L === p) parent.L = q; - else parent.R = q; - } else { - tree._ = q; - } - - q.U = parent; - p.U = q; - p.L = q.R; - if (p.L) p.L.U = p; - q.R = p; -} - -function RedBlackFirst(node) { - while (node.L) node = node.L; - return node; -} - -function createEdge(left, right, v0, v1) { - var edge = [null, null], - index = edges.push(edge) - 1; - edge.left = left; - edge.right = right; - if (v0) setEdgeEnd(edge, left, right, v0); - if (v1) setEdgeEnd(edge, right, left, v1); - cells[left.index].halfedges.push(index); - cells[right.index].halfedges.push(index); - return edge; -} - function createBorderEdge(left, v0, v1) { var edge = [v0, v1]; edge.left = left; return edge; } -function setEdgeEnd(edge, left, right, vertex) { - if (!edge[0] && !edge[1]) { - edge[0] = vertex; - edge.left = left; - edge.right = right; - } else if (edge.left === right) { - edge[1] = vertex; - } else { - edge[0] = vertex; - } -} + // Liang–Barsky line clipping. function clipEdge(edge, x0, y0, x1, y1) { @@ -11033,38 +8126,6 @@ function connectEdge(edge, x0, y0, x1, y1) { return true; } -function clipEdges(x0, y0, x1, y1) { - var i = edges.length, - edge; - - while (i--) { - if (!connectEdge(edge = edges[i], x0, y0, x1, y1) - || !clipEdge(edge, x0, y0, x1, y1) - || !(Math.abs(edge[0][0] - edge[1][0]) > epsilon$4 - || Math.abs(edge[0][1] - edge[1][1]) > epsilon$4)) { - delete edges[i]; - } - } -} - -function createCell(site) { - return cells[site.index] = { - site: site, - halfedges: [] - }; -} - -function cellHalfedgeAngle(cell, edge) { - var site = cell.site, - va = edge.left, - vb = edge.right; - if (site === vb) vb = va, va = site; - if (vb) return Math.atan2(vb[1] - va[1], vb[0] - va[0]); - if (site === va) va = edge[1], vb = edge[0]; - else va = edge[0], vb = edge[1]; - return Math.atan2(va[0] - vb[0], vb[1] - va[1]); -} - function cellHalfedgeStart(cell, edge) { return edge[+(edge.left !== cell.site)]; } @@ -11073,593 +8134,17 @@ function cellHalfedgeEnd(cell, edge) { return edge[+(edge.left === cell.site)]; } -function sortCellHalfedges() { - for (var i = 0, n = cells.length, cell, halfedges, j, m; i < n; ++i) { - if ((cell = cells[i]) && (m = (halfedges = cell.halfedges).length)) { - var index = new Array(m), - array = new Array(m); - for (j = 0; j < m; ++j) index[j] = j, array[j] = cellHalfedgeAngle(cell, edges[halfedges[j]]); - index.sort(function(i, j) { return array[j] - array[i]; }); - for (j = 0; j < m; ++j) array[j] = halfedges[index[j]]; - for (j = 0; j < m; ++j) halfedges[j] = array[j]; - } - } -} - -function clipCells(x0, y0, x1, y1) { - var nCells = cells.length, - iCell, - cell, - site, - iHalfedge, - halfedges, - nHalfedges, - start, - startX, - startY, - end, - endX, - endY, - cover = true; - - for (iCell = 0; iCell < nCells; ++iCell) { - if (cell = cells[iCell]) { - site = cell.site; - halfedges = cell.halfedges; - iHalfedge = halfedges.length; - - // Remove any dangling clipped edges. - while (iHalfedge--) { - if (!edges[halfedges[iHalfedge]]) { - halfedges.splice(iHalfedge, 1); - } - } - - // Insert any border edges as necessary. - iHalfedge = 0, nHalfedges = halfedges.length; - while (iHalfedge < nHalfedges) { - end = cellHalfedgeEnd(cell, edges[halfedges[iHalfedge]]), endX = end[0], endY = end[1]; - start = cellHalfedgeStart(cell, edges[halfedges[++iHalfedge % nHalfedges]]), startX = start[0], startY = start[1]; - if (Math.abs(endX - startX) > epsilon$4 || Math.abs(endY - startY) > epsilon$4) { - halfedges.splice(iHalfedge, 0, edges.push(createBorderEdge(site, end, - Math.abs(endX - x0) < epsilon$4 && y1 - endY > epsilon$4 ? [x0, Math.abs(startX - x0) < epsilon$4 ? startY : y1] - : Math.abs(endY - y1) < epsilon$4 && x1 - endX > epsilon$4 ? [Math.abs(startY - y1) < epsilon$4 ? startX : x1, y1] - : Math.abs(endX - x1) < epsilon$4 && endY - y0 > epsilon$4 ? [x1, Math.abs(startX - x1) < epsilon$4 ? startY : y0] - : Math.abs(endY - y0) < epsilon$4 && endX - x0 > epsilon$4 ? [Math.abs(startY - y0) < epsilon$4 ? startX : x0, y0] - : null)) - 1); - ++nHalfedges; - } - } - - if (nHalfedges) cover = false; - } - } - - // If there weren’t any edges, have the closest site cover the extent. - // It doesn’t matter which corner of the extent we measure! - if (cover) { - var dx, dy, d2, dc = Infinity; - - for (iCell = 0, cover = null; iCell < nCells; ++iCell) { - if (cell = cells[iCell]) { - site = cell.site; - dx = site[0] - x0; - dy = site[1] - y0; - d2 = dx * dx + dy * dy; - if (d2 < dc) dc = d2, cover = cell; - } - } - - if (cover) { - var v00 = [x0, y0], v01 = [x0, y1], v11 = [x1, y1], v10 = [x1, y0]; - cover.halfedges.push( - edges.push(createBorderEdge(site = cover.site, v00, v01)) - 1, - edges.push(createBorderEdge(site, v01, v11)) - 1, - edges.push(createBorderEdge(site, v11, v10)) - 1, - edges.push(createBorderEdge(site, v10, v00)) - 1 - ); - } - } - - // Lastly delete any cells with no edges; these were entirely clipped. - for (iCell = 0; iCell < nCells; ++iCell) { - if (cell = cells[iCell]) { - if (!cell.halfedges.length) { - delete cells[iCell]; - } - } - } -} - -var circlePool = []; - -var firstCircle; - -function Circle() { - RedBlackNode(this); - this.x = - this.y = - this.arc = - this.site = - this.cy = null; -} - -function attachCircle(arc) { - var lArc = arc.P, - rArc = arc.N; - - if (!lArc || !rArc) return; - - var lSite = lArc.site, - cSite = arc.site, - rSite = rArc.site; - - if (lSite === rSite) return; - - var bx = cSite[0], - by = cSite[1], - ax = lSite[0] - bx, - ay = lSite[1] - by, - cx = rSite[0] - bx, - cy = rSite[1] - by; - - var d = 2 * (ax * cy - ay * cx); - if (d >= -epsilon2$2) return; - - var ha = ax * ax + ay * ay, - hc = cx * cx + cy * cy, - x = (cy * ha - ay * hc) / d, - y = (ax * hc - cx * ha) / d; - - var circle = circlePool.pop() || new Circle; - circle.arc = arc; - circle.site = cSite; - circle.x = x + bx; - circle.y = (circle.cy = y + by) + Math.sqrt(x * x + y * y); // y bottom - - arc.circle = circle; - - var before = null, - node = circles._; - - while (node) { - if (circle.y < node.y || (circle.y === node.y && circle.x <= node.x)) { - if (node.L) node = node.L; - else { before = node.P; break; } - } else { - if (node.R) node = node.R; - else { before = node; break; } - } - } - - circles.insert(before, circle); - if (!before) firstCircle = circle; -} - -function detachCircle(arc) { - var circle = arc.circle; - if (circle) { - if (!circle.P) firstCircle = circle.N; - circles.remove(circle); - circlePool.push(circle); - RedBlackNode(circle); - arc.circle = null; - } -} - -var beachPool = []; - -function Beach() { - RedBlackNode(this); - this.edge = - this.site = - this.circle = null; -} - -function createBeach(site) { - var beach = beachPool.pop() || new Beach; - beach.site = site; - return beach; -} - -function detachBeach(beach) { - detachCircle(beach); - beaches.remove(beach); - beachPool.push(beach); - RedBlackNode(beach); -} - -function removeBeach(beach) { - var circle = beach.circle, - x = circle.x, - y = circle.cy, - vertex = [x, y], - previous = beach.P, - next = beach.N, - disappearing = [beach]; - - detachBeach(beach); - - var lArc = previous; - while (lArc.circle - && Math.abs(x - lArc.circle.x) < epsilon$4 - && Math.abs(y - lArc.circle.cy) < epsilon$4) { - previous = lArc.P; - disappearing.unshift(lArc); - detachBeach(lArc); - lArc = previous; - } - - disappearing.unshift(lArc); - detachCircle(lArc); - - var rArc = next; - while (rArc.circle - && Math.abs(x - rArc.circle.x) < epsilon$4 - && Math.abs(y - rArc.circle.cy) < epsilon$4) { - next = rArc.N; - disappearing.push(rArc); - detachBeach(rArc); - rArc = next; - } - - disappearing.push(rArc); - detachCircle(rArc); - - var nArcs = disappearing.length, - iArc; - for (iArc = 1; iArc < nArcs; ++iArc) { - rArc = disappearing[iArc]; - lArc = disappearing[iArc - 1]; - setEdgeEnd(rArc.edge, lArc.site, rArc.site, vertex); - } - - lArc = disappearing[0]; - rArc = disappearing[nArcs - 1]; - rArc.edge = createEdge(lArc.site, rArc.site, null, vertex); - - attachCircle(lArc); - attachCircle(rArc); -} - -function addBeach(site) { - var x = site[0], - directrix = site[1], - lArc, - rArc, - dxl, - dxr, - node = beaches._; - - while (node) { - dxl = leftBreakPoint(node, directrix) - x; - if (dxl > epsilon$4) node = node.L; else { - dxr = x - rightBreakPoint(node, directrix); - if (dxr > epsilon$4) { - if (!node.R) { - lArc = node; - break; - } - node = node.R; - } else { - if (dxl > -epsilon$4) { - lArc = node.P; - rArc = node; - } else if (dxr > -epsilon$4) { - lArc = node; - rArc = node.N; - } else { - lArc = rArc = node; - } - break; - } - } - } - - createCell(site); - var newArc = createBeach(site); - beaches.insert(lArc, newArc); - - if (!lArc && !rArc) return; - - if (lArc === rArc) { - detachCircle(lArc); - rArc = createBeach(lArc.site); - beaches.insert(newArc, rArc); - newArc.edge = rArc.edge = createEdge(lArc.site, newArc.site); - attachCircle(lArc); - attachCircle(rArc); - return; - } - - if (!rArc) { // && lArc - newArc.edge = createEdge(lArc.site, newArc.site); - return; - } - - // else lArc !== rArc - detachCircle(lArc); - detachCircle(rArc); - - var lSite = lArc.site, - ax = lSite[0], - ay = lSite[1], - bx = site[0] - ax, - by = site[1] - ay, - rSite = rArc.site, - cx = rSite[0] - ax, - cy = rSite[1] - ay, - d = 2 * (bx * cy - by * cx), - hb = bx * bx + by * by, - hc = cx * cx + cy * cy, - vertex = [(cy * hb - by * hc) / d + ax, (bx * hc - cx * hb) / d + ay]; - - setEdgeEnd(rArc.edge, lSite, rSite, vertex); - newArc.edge = createEdge(lSite, site, null, vertex); - rArc.edge = createEdge(site, rSite, null, vertex); - attachCircle(lArc); - attachCircle(rArc); -} - -function leftBreakPoint(arc, directrix) { - var site = arc.site, - rfocx = site[0], - rfocy = site[1], - pby2 = rfocy - directrix; - - if (!pby2) return rfocx; - - var lArc = arc.P; - if (!lArc) return -Infinity; - - site = lArc.site; - var lfocx = site[0], - lfocy = site[1], - plby2 = lfocy - directrix; - - if (!plby2) return lfocx; - - var hl = lfocx - rfocx, - aby2 = 1 / pby2 - 1 / plby2, - b = hl / plby2; - - if (aby2) return (-b + Math.sqrt(b * b - 2 * aby2 * (hl * hl / (-2 * plby2) - lfocy + plby2 / 2 + rfocy - pby2 / 2))) / aby2 + rfocx; - - return (rfocx + lfocx) / 2; -} - -function rightBreakPoint(arc, directrix) { - var rArc = arc.N; - if (rArc) return leftBreakPoint(rArc, directrix); - var site = arc.site; - return site[1] === directrix ? site[0] : Infinity; -} - var epsilon$4 = 1e-6; -var epsilon2$2 = 1e-12; -var beaches; + + var cells; -var circles; + var edges; function triangleArea(a, b, c) { return (a[0] - c[0]) * (b[1] - a[1]) - (a[0] - b[0]) * (c[1] - a[1]); } -function lexicographic(a, b) { - return b[1] - a[1] - || b[0] - a[0]; -} - -function Diagram(sites, extent) { - var site = sites.sort(lexicographic).pop(), - x, - y, - circle; - - edges = []; - cells = new Array(sites.length); - beaches = new RedBlackTree; - circles = new RedBlackTree; - - while (true) { - circle = firstCircle; - if (site && (!circle || site[1] < circle.y || (site[1] === circle.y && site[0] < circle.x))) { - if (site[0] !== x || site[1] !== y) { - addBeach(site); - x = site[0], y = site[1]; - } - site = sites.pop(); - } else if (circle) { - removeBeach(circle.arc); - } else { - break; - } - } - - sortCellHalfedges(); - - if (extent) { - var x0 = +extent[0][0], - y0 = +extent[0][1], - x1 = +extent[1][0], - y1 = +extent[1][1]; - clipEdges(x0, y0, x1, y1); - clipCells(x0, y0, x1, y1); - } - - this.edges = edges; - this.cells = cells; - - beaches = - circles = - edges = - cells = null; -} - -Diagram.prototype = { - constructor: Diagram, - - polygons: function() { - var edges = this.edges; - - return this.cells.map(function(cell) { - var polygon = cell.halfedges.map(function(i) { return cellHalfedgeStart(cell, edges[i]); }); - polygon.data = cell.site.data; - return polygon; - }); - }, - - triangles: function() { - var triangles = [], - edges = this.edges; - - this.cells.forEach(function(cell, i) { - if (!(m = (halfedges = cell.halfedges).length)) return; - var site = cell.site, - halfedges, - j = -1, - m, - s0, - e1 = edges[halfedges[m - 1]], - s1 = e1.left === site ? e1.right : e1.left; - - while (++j < m) { - s0 = s1; - e1 = edges[halfedges[j]]; - s1 = e1.left === site ? e1.right : e1.left; - if (s0 && s1 && i < s0.index && i < s1.index && triangleArea(site, s0, s1) < 0) { - triangles.push([site.data, s0.data, s1.data]); - } - } - }); - - return triangles; - }, - - links: function() { - return this.edges.filter(function(edge) { - return edge.right; - }).map(function(edge) { - return { - source: edge.left.data, - target: edge.right.data - }; - }); - }, - - find: function(x, y, radius) { - var that = this, i0, i1 = that._found || 0, n = that.cells.length, cell; - - // Use the previously-found cell, or start with an arbitrary one. - while (!(cell = that.cells[i1])) if (++i1 >= n) return null; - var dx = x - cell.site[0], dy = y - cell.site[1], d2 = dx * dx + dy * dy; - - // Traverse the half-edges to find a closer cell, if any. - do { - cell = that.cells[i0 = i1], i1 = null; - cell.halfedges.forEach(function(e) { - var edge = that.edges[e], v = edge.left; - if ((v === cell.site || !v) && !(v = edge.right)) return; - var vx = x - v[0], vy = y - v[1], v2 = vx * vx + vy * vy; - if (v2 < d2) d2 = v2, i1 = v.index; - }); - } while (i1 !== null); - - that._found = i0; - - return radius == null || d2 <= radius * radius ? cell.site : null; - } -}; - -var constant$13 = function(x) { - return function() { - return x; - }; -}; - -function ZoomEvent(target, type, transform) { - this.target = target; - this.type = type; - this.transform = transform; -} - -function Transform(k, x, y) { - this.k = k; - this.x = x; - this.y = y; -} - -Transform.prototype = { - constructor: Transform, - scale: function(k) { - return k === 1 ? this : new Transform(this.k * k, this.x, this.y); - }, - translate: function(x, y) { - return x === 0 & y === 0 ? this : new Transform(this.k, this.x + this.k * x, this.y + this.k * y); - }, - apply: function(point) { - return [point[0] * this.k + this.x, point[1] * this.k + this.y]; - }, - applyX: function(x) { - return x * this.k + this.x; - }, - applyY: function(y) { - return y * this.k + this.y; - }, - invert: function(location) { - return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k]; - }, - invertX: function(x) { - return (x - this.x) / this.k; - }, - invertY: function(y) { - return (y - this.y) / this.k; - }, - rescaleX: function(x) { - return x.copy().domain(x.range().map(this.invertX, this).map(x.invert, x)); - }, - rescaleY: function(y) { - return y.copy().domain(y.range().map(this.invertY, this).map(y.invert, y)); - }, - toString: function() { - return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")"; - } -}; - -var identity$8 = new Transform(1, 0, 0); - -function nopropagation$2() { - event.stopImmediatePropagation(); -} - -var noevent$2 = function() { - event.preventDefault(); - event.stopImmediatePropagation(); -}; - -// Ignore right-click, since that should open the context menu. -function defaultFilter$2() { - return !event.button; -} - -function defaultExtent$1() { - var e = this, w, h; - if (e instanceof SVGElement) { - e = e.ownerSVGElement || e; - w = e.width.baseVal.value; - h = e.height.baseVal.value; - } else { - w = e.clientWidth; - h = e.clientHeight; - } - return [[0, 0], [w, h]]; -} - -function defaultTransform() { - return this.__zoom || identity$8; -} - exports.axisBottom = axisBottom; exports.axisLeft = axisLeft; exports.axisTop = axisTop; @@ -11668,7 +8153,7 @@ exports.line = line; exports.scaleBand = band; exports.scaleLinear = linear$2; exports.scaleOrdinal = ordinal; -exports.select = select; +exports.select = select$1; Object.defineProperty(exports, '__esModule', { value: true }); diff --git a/d3.min.js b/d3.min.js index 84488a47..59e42d02 100644 --- a/d3.min.js +++ b/d3.min.js @@ -1,4 +1,3 @@ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.d3=t.d3||{})}(this,function(t){"use strict";function n(t){return function(n,e){return uo(t(n),e)}}function e(t,n,e){var i=Math.abs(n-t)/Math.max(0,e),r=Math.pow(10,Math.floor(Math.log(i)/Math.LN10)),o=i/r;return o>=fo?r*=10:o>=_o?r*=5:o>=po&&(r*=2),n=0&&(e=t.slice(i+1),t=t.slice(0,i)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})}function p(t,n){for(var e,i=0,r=t.length;i=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}function w(t){return function(){var n=this.__on;if(n){for(var e,i=0,r=-1,o=n.length;in?1:t>=n?0:NaN}function A(t){return function(){this.removeAttribute(t)}}function E(t){return function(){this.removeAttributeNS(t.space,t.local)}}function U(t,n){return function(){this.setAttribute(t,n)}}function L(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function P(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function D(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function R(t){return function(){this.style.removeProperty(t)}}function F(t,n,e){return function(){this.style.setProperty(t,n,e)}}function Y(t,n,e){return function(){var i=n.apply(this,arguments);null==i?this.style.removeProperty(t):this.style.setProperty(t,i,e)}}function q(t){return function(){delete this[t]}}function H(t,n){return function(){this[t]=n}}function z(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function O(t){return t.trim().split(/^|\s+/)}function j(t){return t.classList||new X(t)}function X(t){this._node=t,this._names=O(t.getAttribute("class")||"")}function I(t,n){for(var e=j(t),i=-1,r=n.length;++i>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1)):(n=Nu.exec(t))?pt(parseInt(n[1],16)):(n=ku.exec(t))?new gt(n[1],n[2],n[3],1):(n=Tu.exec(t))?new gt(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=Cu.exec(t))?dt(n[1],n[2],n[3],n[4]):(n=Su.exec(t))?dt(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=Au.exec(t))?xt(n[1],n[2]/100,n[3]/100,1):(n=Eu.exec(t))?xt(n[1],n[2]/100,n[3]/100,n[4]):Uu.hasOwnProperty(t)?pt(Uu[t]):"transparent"===t?new gt(NaN,NaN,NaN,0):null}function pt(t){return new gt(t>>16&255,t>>8&255,255&t,1)}function dt(t,n,e,i){return i<=0&&(t=n=e=NaN),new gt(t,n,e,i)}function yt(t){return t instanceof ft||(t=_t(t)),t?(t=t.rgb(),new gt(t.r,t.g,t.b,t.opacity)):new gt}function vt(t,n,e,i){return 1===arguments.length?yt(t):new gt(t,n,e,null==i?1:i)}function gt(t,n,e,i){this.r=+t,this.g=+n,this.b=+e,this.opacity=+i}function xt(t,n,e,i){return i<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new bt(t,n,e,i)}function mt(t){if(t instanceof bt)return new bt(t.h,t.s,t.l,t.opacity);if(t instanceof ft||(t=_t(t)),!t)return new bt;if(t instanceof bt)return t;t=t.rgb();var n=t.r/255,e=t.g/255,i=t.b/255,r=Math.min(n,e,i),o=Math.max(n,e,i),u=NaN,a=o-r,s=(o+r)/2;return a?(u=n===o?(e-i)/a+6*(e0&&s<1?0:u,new bt(u,a,s,t.opacity)}function wt(t,n,e,i){return 1===arguments.length?mt(t):new bt(t,n,e,null==i?1:i)}function bt(t,n,e,i){this.h=+t,this.s=+n,this.l=+e,this.opacity=+i}function Mt(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}function Nt(t){if(t instanceof Tt)return new Tt(t.l,t.a,t.b,t.opacity);if(t instanceof Pt){var n=t.h*Lu;return new Tt(t.l,Math.cos(n)*t.c,Math.sin(n)*t.c,t.opacity)}t instanceof gt||(t=yt(t));var e=Et(t.r),i=Et(t.g),r=Et(t.b),o=Ct((.4124564*e+.3575761*i+.1804375*r)/Du),u=Ct((.2126729*e+.7151522*i+.072175*r)/Ru);return new Tt(116*u-16,500*(o-u),200*(u-Ct((.0193339*e+.119192*i+.9503041*r)/Fu)),t.opacity)}function kt(t,n,e,i){return 1===arguments.length?Nt(t):new Tt(t,n,e,null==i?1:i)}function Tt(t,n,e,i){this.l=+t,this.a=+n,this.b=+e,this.opacity=+i}function Ct(t){return t>zu?Math.pow(t,1/3):t/Hu+Yu}function St(t){return t>qu?t*t*t:Hu*(t-Yu)}function At(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Et(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ut(t){if(t instanceof Pt)return new Pt(t.h,t.c,t.l,t.opacity);t instanceof Tt||(t=Nt(t));var n=Math.atan2(t.b,t.a)*Pu;return new Pt(n<0?n+360:n,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function Lt(t,n,e,i){return 1===arguments.length?Ut(t):new Pt(t,n,e,null==i?1:i)}function Pt(t,n,e,i){this.h=+t,this.c=+n,this.l=+e,this.opacity=+i}function Dt(t){if(t instanceof Ft)return new Ft(t.h,t.s,t.l,t.opacity);t instanceof gt||(t=yt(t));var n=t.r/255,e=t.g/255,i=t.b/255,r=(Zu*i+Bu*n-Vu*e)/(Zu+Bu-Vu),o=i-r,u=($u*(e-r)-Xu*o)/Iu,a=Math.sqrt(u*u+o*o)/($u*r*(1-r)),s=a?Math.atan2(u,o)*Pu-120:NaN;return new Ft(s<0?s+360:s,a,r,t.opacity)}function Rt(t,n,e,i){return 1===arguments.length?Dt(t):new Ft(t,n,e,null==i?1:i)}function Ft(t,n,e,i){this.h=+t,this.s=+n,this.l=+e,this.opacity=+i}function Yt(t,n){return function(e){return t+e*n}}function qt(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(i){return Math.pow(t+i*n,e)}}function Ht(t,n){var e=n-t;return e?Yt(t,e>180||e<-180?e-360*Math.round(e/360):e):Ku(isNaN(t)?n:t)}function zt(t){return 1==(t=+t)?Ot:function(n,e){return e-n?qt(n,e,t):Ku(isNaN(n)?e:n)}}function Ot(t,n){var e=n-t;return e?Yt(t,e):Ku(isNaN(t)?n:t)}function jt(t){return function(){return t}}function Xt(t){return function(n){return t(n)+""}}function It(t){return"none"===t?la:(Wu||(Wu=document.createElement("DIV"),Ju=document.documentElement,Gu=document.defaultView),Wu.style.transform=t,t=Gu.getComputedStyle(Ju.appendChild(Wu),null).getPropertyValue("transform"),Ju.removeChild(Wu),t=t.slice(7,-1).split(","),fa(+t[0],+t[1],+t[2],+t[3],+t[4],+t[5]))}function $t(t){return null==t?la:(Qu||(Qu=document.createElementNS("http://www.w3.org/2000/svg","g")),Qu.setAttribute("transform",t),(t=Qu.transform.baseVal.consolidate())?(t=t.matrix,fa(t.a,t.b,t.c,t.d,t.e,t.f)):la)}function Bt(t,n,e,i){function r(t){return t.length?t.pop()+" ":""}function o(t,i,r,o,u,a){if(t!==r||i!==o){var s=u.push("translate(",null,n,null,e);a.push({i:s-4,x:ia(t,r)},{i:s-2,x:ia(i,o)})}else(r||o)&&u.push("translate("+r+n+o+e)}function u(t,n,e,o){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(r(e)+"rotate(",null,i)-2,x:ia(t,n)})):n&&e.push(r(e)+"rotate("+n+i)}function a(t,n,e,o){t!==n?o.push({i:e.push(r(e)+"skewX(",null,i)-2,x:ia(t,n)}):n&&e.push(r(e)+"skewX("+n+i)}function s(t,n,e,i,o,u){if(t!==e||n!==i){var a=o.push(r(o)+"scale(",null,",",null,")");u.push({i:a-4,x:ia(t,e)},{i:a-2,x:ia(n,i)})}else 1===e&&1===i||o.push(r(o)+"scale("+e+","+i+")")}return function(n,e){var i=[],r=[];return n=t(n),e=t(e),o(n.translateX,n.translateY,e.translateX,e.translateY,i,r),u(n.rotate,e.rotate,i,r),a(n.skewX,e.skewX,i,r),s(n.scaleX,n.scaleY,e.scaleX,e.scaleY,i,r),n=e=null,function(t){for(var n,e=-1,o=r.length;++e=0&&n._call.call(null,t),n=n._next;--ga}function Kt(){Ma=(ba=ka.now())+Na,ga=xa=0;try{Qt()}finally{ga=0,nn(),Ma=0}}function tn(){var t=ka.now(),n=t-ba;n>wa&&(Na-=n,ba=t)}function nn(){for(var t,n,e=da,i=1/0;e;)e._call?(i>e._time&&(i=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:da=n);ya=t,en(i)}function en(t){if(!ga){xa&&(xa=clearTimeout(xa));var n=t-Ma;n>24?(t<1/0&&(xa=setTimeout(Kt,n)),ma&&(ma=clearInterval(ma))):(ma||(ba=Ma,ma=setInterval(tn,wa)),ga=1,Ta(Kt))}}function rn(t,n){var e=t.__transition;if(!e||!(e=e[n])||e.state>Ea)throw new Error("too late");return e}function on(t,n){var e=t.__transition;if(!e||!(e=e[n])||e.state>La)throw new Error("too late");return e}function un(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("too late");return e}function an(t,n,e){function i(t){e.state=Ua,e.timer.restart(r,e.delay,e.time),e.delay<=t&&r(t-e.delay)}function r(i){var h,c,l,f;if(e.state!==Ua)return u();for(h in s)if(f=s[h],f.name===e.name){if(f.state===Pa)return Ca(r);f.state===Da?(f.state=Fa,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete s[h]):+h=0&&(t=t.slice(0,n)),!t||"start"===t})}function kn(t,n,e){var i,r,o=Nn(n)?rn:on;return function(){var u=o(this,t),a=u.on;a!==i&&(r=(i=a).copy()).on(n,e),u.on=r}}function Tn(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}function Cn(t,n){var e,i,r;return function(){var o=ru(this).getComputedStyle(this,null),u=o.getPropertyValue(t),a=(this.style.removeProperty(t),o.getPropertyValue(t));return u===a?null:u===e&&a===i?r:r=n(e=u,i=a)}}function Sn(t){return function(){this.style.removeProperty(t)}}function An(t,n,e){var i,r;return function(){var o=ru(this).getComputedStyle(this,null).getPropertyValue(t);return o===e?null:o===i?r:r=n(i=o,e)}}function En(t,n,e){var i,r,o;return function(){var u=ru(this).getComputedStyle(this,null),a=u.getPropertyValue(t),s=e(this);return null==s&&(this.style.removeProperty(t),s=u.getPropertyValue(t)),a===s?null:a===i&&s===r?o:o=n(i=a,r=s)}}function Un(t,n,e){function i(){var i=this,r=n.apply(i,arguments);return r&&function(n){i.style.setProperty(t,r(n),e)}}return i._value=n,i}function Ln(t){return function(){this.textContent=t}}function Pn(t){return function(){var n=t(this);this.textContent=null==n?"":n}}function Dn(t,n,e,i){this._groups=t,this._parents=n,this._name=e,this._id=i}function Rn(t){return ht().transition(t)}function Fn(){return++os}function Yn(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}function qn(t,n){for(var e;!(e=t.__transition)||!(e=e[n]);)if(!(t=t.parentNode))return ss.time=Zt(),ss;return e}function Hn(t){return{type:t}}function zn(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function On(){return new zn}function jn(){}function Xn(t,n){var e=new jn;if(t instanceof jn)t.each(function(t,n){e.set(n,t)});else if(Array.isArray(t)){var i,r=-1,o=t.length;if(null==n)for(;++r=(o=(d+v)/2))?d=o:v=o,(c=e>=(u=(y+g)/2))?y=u:g=u,r=_,!(_=_[l=c<<1|h]))return r[l]=p,t;if(a=+t._x.call(null,_.data),s=+t._y.call(null,_.data),n===a&&e===s)return p.next=_,r?r[l]=p:t._root=p,t;do{r=r?r[l]=new Array(4):t._root=new Array(4),(h=n>=(o=(d+v)/2))?d=o:v=o,(c=e>=(u=(y+g)/2))?y=u:g=u}while((l=c<<1|h)==(f=(s>=u)<<1|a>=o));return r[f]=_,r[l]=p,t}function Jn(t){var n,e,i,r,o=t.length,u=new Array(o),a=new Array(o),s=1/0,h=1/0,c=-1/0,l=-1/0;for(e=0;ec&&(c=i),rl&&(l=r));for(c",r=n[3]||"-",o=n[4]||"",u=!!n[5],a=n[6]&&+n[6],s=!!n[7],h=n[8]&&+n[8].slice(1),c=n[9]||"";"n"===c?(s=!0,c="g"):zs[c]||(c=""),(u||"0"===e&&"="===i)&&(u=!0,e="0",i="="),this.fill=e,this.align=i,this.sign=r,this.symbol=o,this.zero=u,this.width=a,this.comma=s,this.precision=h,this.type=c}function re(t){return t}function oe(){this.reset()}function ue(t,n,e){var i=t.s=n+e,r=i-n,o=i-r;t.t=n-o+(e-r)}function ae(t){return t>1?0:t<-1?th:Math.acos(t)}function se(t){return t>1?nh:t<-1?-nh:Math.asin(t)}function he(){}function ce(t){var n=t[0],e=t[1],i=sh(e);return[i*sh(n),i*lh(n),lh(e)]}function le(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function fe(t){var n=fh(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function _e(t,n){return[t>th?t-ih:t<-th?t+ih:t,n]}function pe(t,n,e,i){this.x=t,this.z=n,this.o=e,this.e=i,this.v=!1,this.n=this.p=null}function de(t){if(n=t.length){for(var n,e,i=0,r=t[0];++i1}function me(t,n){return((t=t.x)[0]<0?t[1]-nh-Ks:nh-t[1])-((n=n.x)[0]<0?n[1]-nh-Ks:nh-n[1])}function we(t){var n,e=NaN,i=NaN,r=NaN;return{lineStart:function(){t.lineStart(),n=1},point:function(o,u){var a=o>0?th:-th,s=oh(o-e);oh(s-th)0?nh:-nh),t.point(r,i),t.lineEnd(),t.lineStart(),t.point(a,i),t.point(o,i),n=0):r!==a&&s>=th&&(oh(e-r)Ks?uh((lh(n)*(o=sh(i))*lh(e)-lh(i)*(r=sh(n))*lh(t))/(r*o*u)):(n+i)/2}function Me(t,n,e,i){var r;if(null==t)r=e*nh,i.point(-th,r),i.point(0,r),i.point(th,r),i.point(th,0),i.point(th,-r),i.point(0,-r),i.point(-th,-r),i.point(-th,0),i.point(-th,r);else if(oh(t[0]-n[0])>Ks){var o=t[0]=0;)n+=e[i].value;else n=1;t.value=n}function Ee(t,n){if(t===n)return t;var e=t.ancestors(),i=n.ancestors(),r=null;for(t=e.pop(),n=i.pop();t===n;)r=t,t=e.pop(),n=i.pop();return r}function Ue(t,n){var e,i,r,o,u,a=new Fe(t),s=+t.value&&(a.value=t.value),h=[a];for(null==n&&(n=Pe);e=h.pop();)if(s&&(e.value=+e.data.value),(r=n(e.data))&&(u=r.length))for(e.children=new Array(u),o=u-1;o>=0;--o)h.push(i=e.children[o]=new Fe(r[o])),i.parent=e,i.depth=e.depth+1;return a.eachBefore(Re)}function Le(){return Ue(this).eachBefore(De)}function Pe(t){return t.children}function De(t){t.data=t.data.data}function Re(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function Fe(t){this.data=t,this.depth=this.height=0,this.parent=null}function Ye(t,n){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=n}function qe(t,n,e,i,r,o){for(var u,a,s,h,c,l,f,_,p,d,y,v=[],g=n.children,x=0,m=0,w=g.length,b=n.value;xf&&(f=a),y=c*c*d,(_=Math.max(f/y,y/l))>p){c-=a;break}p=_}v.push(u={value:c,dice:s=0;)if((e=t._tasks[i])&&(t._tasks[i]=null,e.abort))try{e.abort()}catch(n){}t._active=NaN,Xe(t)}function Xe(t){if(!t._active&&t._call){var n=t._data;t._data=void 0,t._call(t._error,n)}}function Ie(t){return function(n,e){t(null==n?e:null)}}function $e(t){var n=t.responseType;return n&&"text"!==n?t.response:t.responseText}function Be(t,n){return function(e){return t(e.responseText,n)}}function Ve(t){function n(n){var o=n+"",u=e.get(o);if(!u){if(r!==Xh)return r;e.set(o,u=i.push(n))}return t[(u-1)%t.length]}var e=Xn(),i=[],r=Xh;return t=null==t?[]:jh.call(t),n.domain=function(t){if(!arguments.length)return i.slice();i=[],e=Xn();for(var r,o,u=-1,a=t.length;++u=e?1:i(t)}}}function Ge(t){return function(n,e){var i=t(n=+n,e=+e);return function(t){return t<=0?n:t>=1?e:i(t)}}}function Qe(t,n,e,i){var r=t[0],o=t[1],u=n[0],a=n[1];return o2?Ke:Qe,o=u=null,i}function i(n){return(o||(o=r(a,s,c?Je(t):t,h)))(+n)}var r,o,u,a=Bh,s=Bh,h=sa,c=!1;return i.invert=function(t){return(u||(u=r(s,a,We,c?Ge(n):n)))(+t)},i.domain=function(t){return arguments.length?(a=Oh.call(t,$h),e()):a.slice()},i.range=function(t){return arguments.length?(s=jh.call(t),e()):s.slice()},i.rangeRound=function(t){return s=jh.call(t),h=ha,e()},i.clamp=function(t){return arguments.length?(c=!!t,e()):c},i.interpolate=function(t){return arguments.length?(h=t,e()):h},e()}function ei(t){var n=t.domain;return t.ticks=function(t){var e=n();return yo(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){return Vh(n(),t,e)},t.nice=function(i){var r=n(),o=r.length-1,u=null==i?10:i,a=r[0],s=r[o],h=e(a,s,u);return h&&(h=e(Math.floor(a/h)*h,Math.ceil(s/h)*h,u),r[0]=Math.floor(a/h)*h,r[o]=Math.ceil(s/h)*h,n(r)),t},t}function ii(){var t=ni(We,ia);return t.copy=function(){return ti(t,ii())},ei(t)}function ri(t,n,e,i){function r(n){return t(n=new Date(+n)),n}return r.floor=r,r.ceil=function(e){return t(e=new Date(e-1)),n(e,1),t(e),e},r.round=function(t){var n=r(t),e=r.ceil(t);return t-n0))return u;do{u.push(new Date(+e))}while(n(e,o),t(e),e=n)for(;t(n),!e(n);)n.setTime(n-1)},function(t,i){if(t>=t)for(;--i>=0;)for(;n(t,1),!e(t););})},e&&(r.count=function(n,i){return Zh.setTime(+n),Wh.setTime(+i),t(Zh),t(Wh),Math.floor(e(Zh,Wh))},r.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?r.filter(i?function(n){return i(n)%t==0}:function(n){return r.count(0,n)%t==0}):r:null}),r}function oi(t){return ri(function(n){n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+7*n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Gh)/Qh})}function ui(t){return ri(function(n){n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+7*n)},function(t,n){return(n-t)/Qh})}function ai(t){if(0<=t.y&&t.y<100){var n=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return n.setFullYear(t.y),n}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function si(t){if(0<=t.y&&t.y<100){var n=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return n.setUTCFullYear(t.y),n}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function hi(t){return{y:t,m:0,d:1,H:0,M:0,S:0,L:0}}function ci(t){function n(t,n){return function(e){var i,r,o,u=[],a=-1,s=0,h=t.length;for(e instanceof Date||(e=new Date(+e));++a=s)return-1;if(37===(r=n.charCodeAt(u++))){if(r=n.charAt(u++),!(o=j[r in fc?n.charAt(u++):r])||(i=o(t,e,i))<0)return-1}else if(r!=e.charCodeAt(i++))return-1}return i}function r(t,n,e){var i=E.exec(n.slice(e));return i?(t.p=U[i[0].toLowerCase()],e+i[0].length):-1}function o(t,n,e){var i=D.exec(n.slice(e));return i?(t.w=R[i[0].toLowerCase()],e+i[0].length):-1}function u(t,n,e){var i=L.exec(n.slice(e));return i?(t.w=P[i[0].toLowerCase()],e+i[0].length):-1}function a(t,n,e){var i=q.exec(n.slice(e));return i?(t.m=H[i[0].toLowerCase()],e+i[0].length):-1}function s(t,n,e){var i=F.exec(n.slice(e));return i?(t.m=Y[i[0].toLowerCase()],e+i[0].length):-1}function h(t,n,e){return i(t,b,n,e)}function c(t,n,e){return i(t,M,n,e)}function l(t,n,e){return i(t,N,n,e)}function f(t){return C[t.getDay()]}function _(t){return T[t.getDay()]}function p(t){return A[t.getMonth()]}function d(t){return S[t.getMonth()]}function y(t){return k[+(t.getHours()>=12)]}function v(t){return C[t.getUTCDay()]}function g(t){return T[t.getUTCDay()]}function x(t){return A[t.getUTCMonth()]}function m(t){return S[t.getUTCMonth()]}function w(t){return k[+(t.getUTCHours()>=12)]}var b=t.dateTime,M=t.date,N=t.time,k=t.periods,T=t.days,C=t.shortDays,S=t.months,A=t.shortMonths,E=_i(k),U=pi(k),L=_i(T),P=pi(T),D=_i(C),R=pi(C),F=_i(S),Y=pi(S),q=_i(A),H=pi(A),z={a:f,A:_,b:p,B:d,c:null,d:Ai,e:Ai,H:Ei,I:Ui,j:Li,L:Pi,m:Di,M:Ri,p:y,S:Fi,U:Yi,w:qi,W:Hi,x:null,X:null,y:zi,Y:Oi,Z:ji,"%":ir},O={a:v,A:g,b:x,B:m,c:null,d:Xi,e:Xi,H:Ii,I:$i,j:Bi,L:Vi,m:Zi,M:Wi,p:w,S:Ji,U:Gi,w:Qi,W:Ki,x:null,X:null,y:tr,Y:nr,Z:er,"%":ir},j={a:o,A:u,b:a,B:s,c:h,d:bi,e:bi,H:Ni,I:Ni,j:Mi,L:Ci,m:wi,M:ki,p:r,S:Ti,U:yi,w:di,W:vi,x:c,X:l,y:xi,Y:gi,Z:mi,"%":Si};return z.x=n(M,z),z.X=n(N,z),z.c=n(b,z),O.x=n(M,O),O.X=n(N,O),O.c=n(b,O),{format:function(t){var e=n(t+="",z);return e.toString=function(){return t},e},parse:function(t){var n=e(t+="",ai);return n.toString=function(){return t},n},utcFormat:function(t){var e=n(t+="",O);return e.toString=function(){return t},e},utcParse:function(t){var n=e(t,si);return n.toString=function(){return t},n}}}function li(t,n,e){var i=t<0?"-":"",r=(i?-t:t)+"",o=r.length;return i+(o68?1900:2e3),e+i[0].length):-1}function mi(t,n,e){var i=/^(Z)|([+-]\d\d)(?:\:?(\d\d))?/.exec(n.slice(e,e+6));return i?(t.Z=i[1]?0:-(i[2]+(i[3]||"00")),e+i[0].length):-1}function wi(t,n,e){var i=_c.exec(n.slice(e,e+2));return i?(t.m=i[0]-1,e+i[0].length):-1}function bi(t,n,e){var i=_c.exec(n.slice(e,e+2));return i?(t.d=+i[0],e+i[0].length):-1}function Mi(t,n,e){var i=_c.exec(n.slice(e,e+3));return i?(t.m=0,t.d=+i[0],e+i[0].length):-1}function Ni(t,n,e){var i=_c.exec(n.slice(e,e+2));return i?(t.H=+i[0],e+i[0].length):-1}function ki(t,n,e){var i=_c.exec(n.slice(e,e+2));return i?(t.M=+i[0],e+i[0].length):-1}function Ti(t,n,e){var i=_c.exec(n.slice(e,e+2));return i?(t.S=+i[0],e+i[0].length):-1}function Ci(t,n,e){var i=_c.exec(n.slice(e,e+3));return i?(t.L=+i[0],e+i[0].length):-1}function Si(t,n,e){var i=pc.exec(n.slice(e,e+1));return i?e+i[0].length:-1}function Ai(t,n){return li(t.getDate(),n,2)}function Ei(t,n){return li(t.getHours(),n,2)}function Ui(t,n){return li(t.getHours()%12||12,n,2)}function Li(t,n){return li(1+Kh.count(ec(t),t),n,3)}function Pi(t,n){return li(t.getMilliseconds(),n,3)}function Di(t,n){return li(t.getMonth()+1,n,2)}function Ri(t,n){return li(t.getMinutes(),n,2)}function Fi(t,n){return li(t.getSeconds(),n,2)}function Yi(t,n){return li(tc.count(ec(t),t),n,2)}function qi(t){return t.getDay()}function Hi(t,n){return li(nc.count(ec(t),t),n,2)}function zi(t,n){return li(t.getFullYear()%100,n,2)}function Oi(t,n){return li(t.getFullYear()%1e4,n,4)}function ji(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+li(n/60|0,"0",2)+li(n%60,"0",2)}function Xi(t,n){return li(t.getUTCDate(),n,2)}function Ii(t,n){return li(t.getUTCHours(),n,2)}function $i(t,n){return li(t.getUTCHours()%12||12,n,2)}function Bi(t,n){return li(1+ic.count(uc(t),t),n,3)}function Vi(t,n){return li(t.getUTCMilliseconds(),n,3)}function Zi(t,n){return li(t.getUTCMonth()+1,n,2)}function Wi(t,n){return li(t.getUTCMinutes(),n,2)}function Ji(t,n){return li(t.getUTCSeconds(),n,2)}function Gi(t,n){return li(rc.count(uc(t),t),n,2)}function Qi(t){return t.getUTCDay()}function Ki(t,n){return li(oc.count(uc(t),t),n,2)}function tr(t,n){return li(t.getUTCFullYear()%100,n,2)}function nr(t,n){return li(t.getUTCFullYear()%1e4,n,4)}function er(){return"+0000"}function ir(){return"%"}function rr(t){return t.toISOString()}function or(t){var n=new Date(t);return isNaN(n)?null:n}function ur(t){this._context=t}function ar(t){return t[0]}function sr(t){return t[1]}function hr(t){this._curve=t}function cr(t){function n(n){return new hr(t(n))}return n._curve=t,n}function lr(t,n,e){t._context.bezierCurveTo((2*t._x0+t._x1)/3,(2*t._y0+t._y1)/3,(t._x0+2*t._x1)/3,(t._y0+2*t._y1)/3,(t._x0+4*t._x1+n)/6,(t._y0+4*t._y1+e)/6)}function fr(t){this._context=t}function _r(t,n){this._basis=new fr(t),this._beta=n}function pr(t,n,e){t._context.bezierCurveTo(t._x1+t._k*(t._x2-t._x0),t._y1+t._k*(t._y2-t._y0),t._x2+t._k*(t._x1-n),t._y2+t._k*(t._y1-e),t._x2,t._y2)}function dr(t,n){this._context=t,this._k=(1-n)/6}function yr(t,n){this._context=t,this._k=(1-n)/6}function vr(t,n){this._context=t,this._k=(1-n)/6}function gr(t,n,e){var i=t._x1,r=t._y1,o=t._x2,u=t._y2;if(t._l01_a>gc){var a=2*t._l01_2a+3*t._l01_a*t._l12_a+t._l12_2a,s=3*t._l01_a*(t._l01_a+t._l12_a);i=(i*a-t._x0*t._l12_2a+t._x2*t._l01_2a)/s,r=(r*a-t._y0*t._l12_2a+t._y2*t._l01_2a)/s}if(t._l23_a>gc){var h=2*t._l23_2a+3*t._l23_a*t._l12_a+t._l12_2a,c=3*t._l23_a*(t._l23_a+t._l12_a);o=(o*h+t._x1*t._l23_2a-n*t._l12_2a)/c,u=(u*h+t._y1*t._l23_2a-e*t._l12_2a)/c}t._context.bezierCurveTo(i,r,o,u,t._x2,t._y2)}function xr(t,n){this._context=t,this._alpha=n}function mr(t,n){this._context=t,this._alpha=n}function wr(t,n){this._context=t,this._alpha=n}function br(t){return t<0?-1:1}function Mr(t,n,e){var i=t._x1-t._x0,r=n-t._x1,o=(t._y1-t._y0)/(i||r<0&&-0),u=(e-t._y1)/(r||i<0&&-0),a=(o*r+u*i)/(i+r);return(br(o)+br(u))*Math.min(Math.abs(o),Math.abs(u),.5*Math.abs(a))||0}function Nr(t,n){var e=t._x1-t._x0;return e?(3*(t._y1-t._y0)/e-n)/2:n}function kr(t,n,e){var i=t._x0,r=t._y0,o=t._x1,u=t._y1,a=(o-i)/3;t._context.bezierCurveTo(i+a,r+a*n,o-a,u-a*e,o,u)}function Tr(t){this._context=t}function Cr(t){this._context=new Sr(t)}function Sr(t){this._context=t}function Ar(){this._=null}function Er(t){t.U=t.C=t.L=t.R=t.P=t.N=null}function Ur(t,n){var e=n,i=n.R,r=e.U;r?r.L===e?r.L=i:r.R=i:t._=i,i.U=r,e.U=i,e.R=i.L,e.R&&(e.R.U=e),i.L=e}function Lr(t,n){var e=n,i=n.L,r=e.U;r?r.L===e?r.L=i:r.R=i:t._=i,i.U=r,e.U=i,e.L=i.R,e.L&&(e.L.U=e),i.R=e}function Pr(t){for(;t.L;)t=t.L;return t}function Dr(t,n,e,i){var r=[null,null],o=Tc.push(r)-1;return r.left=t,r.right=n,e&&Fr(r,t,n,e),i&&Fr(r,n,t,i),Nc[t.index].halfedges.push(o),Nc[n.index].halfedges.push(o),r}function Rr(t,n,e){var i=[n,e];return i.left=t,i}function Fr(t,n,e,i){t[0]||t[1]?t.left===e?t[1]=i:t[0]=i:(t[0]=i,t.left=n,t.right=e)}function Yr(t,n,e,i,r){var o,u=t[0],a=t[1],s=u[0],h=u[1],c=a[0],l=a[1],f=0,_=1,p=c-s,d=l-h;if(o=n-s,p||!(o>0)){if(o/=p,p<0){if(o0){if(o>_)return;o>f&&(f=o)}if(o=i-s,p||!(o<0)){if(o/=p,p<0){if(o>_)return;o>f&&(f=o)}else if(p>0){if(o0)){if(o/=d,d<0){if(o0){if(o>_)return;o>f&&(f=o)}if(o=r-h,d||!(o<0)){if(o/=d,d<0){if(o>_)return;o>f&&(f=o)}else if(d>0){if(o0||_<1)||(f>0&&(t[0]=[s+f*p,h+f*d]),_<1&&(t[1]=[s+_*p,h+_*d]),!0)}}}}}function qr(t,n,e,i,r){var o=t[1];if(o)return!0;var u,a,s=t[0],h=t.left,c=t.right,l=h[0],f=h[1],_=c[0],p=c[1],d=(l+_)/2,y=(f+p)/2;if(p===f){if(d=i)return;if(l>_){if(s){if(s[1]>=r)return}else s=[d,e];o=[d,r]}else{if(s){if(s[1]1)if(l>_){if(s){if(s[1]>=r)return}else s=[(e-a)/u,e];o=[(r-a)/u,r]}else{if(s){if(s[1]=i)return}else s=[n,u*n+a];o=[i,u*i+a]}else{if(s){if(s[0]Ac||Math.abs(r[0][1]-r[1][1])>Ac)||delete Tc[o]}function zr(t){return Nc[t.index]={site:t,halfedges:[]}}function Or(t,n){var e=t.site,i=n.left,r=n.right;return e===r&&(r=i,i=e),r?Math.atan2(r[1]-i[1],r[0]-i[0]):(e===i?(i=n[1],r=n[0]):(i=n[0],r=n[1]),Math.atan2(i[0]-r[0],r[1]-i[1]))}function jr(t,n){return n[+(n.left!==t.site)]}function Xr(t,n){return n[+(n.left===t.site)]}function Ir(){for(var t,n,e,i,r=0,o=Nc.length;rAc||Math.abs(d-f)>Ac)&&(s.splice(a,0,Tc.push(Rr(u,_,Math.abs(p-t)Ac?[t,Math.abs(l-t)Ac?[Math.abs(f-i)Ac?[e,Math.abs(l-e)Ac?[Math.abs(f-n)=-Ec)){var _=s*s+h*h,p=c*c+l*l,d=(l*_-h*p)/f,y=(s*p-c*_)/f,v=Cc.pop()||new Br;v.arc=t,v.site=r,v.x=d+u,v.y=(v.cy=y+a)+Math.sqrt(d*d+y*y),t.circle=v;for(var g=null,x=kc._;x;)if(v.yAc)a=a.L;else{if(!((r=o-no(a,u))>Ac)){i>-Ac?(n=a.P,e=a):r>-Ac?(n=a,e=a.N):n=e=a;break}if(!a.R){n=a;break}a=a.R}zr(t);var s=Jr(t);if(Mc.insert(n,s),n||e){if(n===e)return Zr(n),e=Jr(n.site),Mc.insert(s,e),s.edge=e.edge=Dr(n.site,s.site),Vr(n),void Vr(e);if(!e)return void(s.edge=Dr(n.site,s.site));Zr(n),Zr(e);var h=n.site,c=h[0],l=h[1],f=t[0]-c,_=t[1]-l,p=e.site,d=p[0]-c,y=p[1]-l,v=2*(f*y-_*d),g=f*f+_*_,x=d*d+y*y,m=[(y*g-_*x)/v+c,(f*x-d*g)/v+l];Fr(e.edge,h,p,m),s.edge=Dr(h,t,null,m),e.edge=Dr(t,p,null,m),Vr(n),Vr(e)}}function to(t,n){var e=t.site,i=e[0],r=e[1],o=r-n;if(!o)return i;var u=t.P;if(!u)return-1/0;e=u.site;var a=e[0],s=e[1],h=s-n;if(!h)return a;var c=a-i,l=1/o-1/h,f=c/h;return l?(-f+Math.sqrt(f*f-2*l*(c*c/(-2*h)-s+h/2+r-o/2)))/l+i:(i+a)/2}function no(t,n){var e=t.N;if(e)return to(e,n);var i=t.site;return i[1]===n?i[0]:1/0}function eo(t,n,e){return(t[0]-e[0])*(n[1]-t[1])-(t[0]-n[0])*(e[1]-t[1])}function io(t,n){return n[1]-t[1]||n[0]-t[0]}function ro(t,n){var e,i,r,o=t.sort(io).pop();for(Tc=[],Nc=new Array(t.length),Mc=new Ar,kc=new Ar;;)if(r=bc,o&&(!r||o[1]n?1:t>=n?0:NaN},ao=function(t){return 1===t.length&&(t=n(t)),{left:function(n,e,i,r){for(null==i&&(i=0),null==r&&(r=n.length);i>>1;t(n[o],e)<0?i=o+1:r=o}return i},right:function(n,e,i,r){for(null==i&&(i=0),null==r&&(r=n.length);i>>1;t(n[o],e)>0?r=o:i=o+1}return i}}},so=ao(uo),ho=so.right,co=Array.prototype,lo=(co.slice,co.map,function(t,n,e){t=+t,n=+n,e=(r=arguments.length)<2?(n=t,t=0,1):r<3?1:+e;for(var i=-1,r=0|Math.max(0,Math.ceil((n-t)/e)),o=new Array(r);++i=0;)for(i=t[r],n=i.length;--n>=0;)e[--u]=i[n];return e},go=Array.prototype.slice,xo=function(t){return t},mo=1,wo=2,bo=3,Mo=4,No=1e-6,ko={value:function(){}};f.prototype=l.prototype={constructor:f,on:function(t,n){var e,i=this._,r=_(t+"",i),o=-1,u=r.length;{if(!(arguments.length<2)){if(null!=n&&"function"!=typeof n)throw new Error("invalid callback: "+n);for(;++o0)for(var e,i,r=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Co.hasOwnProperty(n)?{space:Co[n],local:t}:t},Ao=function(t){var n=So(t);return(n.local?v:y)(n)},Eo=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var Uo=document.documentElement;if(!Uo.matches){var Lo=Uo.webkitMatchesSelector||Uo.msMatchesSelector||Uo.mozMatchesSelector||Uo.oMatchesSelector;Eo=function(t){return function(){return Lo.call(this,t)}}}}var Po=Eo,Do={},Ro=null;if("undefined"!=typeof document){"onmouseenter"in document.documentElement||(Do={mouseenter:"mouseover",mouseleave:"mouseout"})}var Fo=function(t,n,e){var i,r,o=m(t+""),u=o.length;{if(!(arguments.length<2)){for(a=n?b:w,null==e&&(e=!1),i=0;i=m&&(m=x+1);!(g=y[m])&&++m=0;)(i=r[o])&&(u&&u!==i.nextSibling&&u.parentNode.insertBefore(i,u),u=i);return this},Jo=function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=S);for(var e=this._groups,i=e.length,r=new Array(i),o=0;o1?this.each((null==n?R:"function"==typeof n?Y:F)(t,n,null==e?"":e)):ru(i=this.node()).getComputedStyle(i,null).getPropertyValue(t)},uu=function(t,n){return arguments.length>1?this.each((null==n?q:"function"==typeof n?z:H)(t,n)):this.node()[t]};X.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var au=function(t,n){var e=O(t+"");if(arguments.length<2){for(var i=j(this.node()),r=-1,o=e.length;++r=240?t-240:t+120,r,i),Mt(t,r,i),Mt(t<120?t+240:t-120,r,i),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var Lu=Math.PI/180,Pu=180/Math.PI,Du=.95047,Ru=1,Fu=1.08883,Yu=4/29,qu=6/29,Hu=3*qu*qu,zu=qu*qu*qu;xu(Tt,kt,lt(ft,{brighter:function(t){return new Tt(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new Tt(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,n=isNaN(this.a)?t:t+this.a/500,e=isNaN(this.b)?t:t-this.b/200;return t=Ru*St(t),n=Du*St(n),e=Fu*St(e),new gt(At(3.2404542*n-1.5371385*t-.4985314*e),At(-.969266*n+1.8760108*t+.041556*e),At(.0556434*n-.2040259*t+1.0572252*e),this.opacity)}})),xu(Pt,Lt,lt(ft,{brighter:function(t){return new Pt(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new Pt(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return Nt(this).rgb()}}));var Ou=-.14861,ju=1.78277,Xu=-.29227,Iu=-.90649,$u=1.97294,Bu=$u*Iu,Vu=$u*ju,Zu=ju*Xu-Iu*Ou;xu(Ft,Rt,lt(ft,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Ft(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Ft(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*Lu,n=+this.l,e=isNaN(this.s)?0:this.s*n*(1-n),i=Math.cos(t),r=Math.sin(t);return new gt(255*(n+e*(Ou*i+ju*r)),255*(n+e*(Xu*i+Iu*r)),255*(n+e*($u*i)),this.opacity)}}));var Wu,Ju,Gu,Qu,Ku=function(t){return function(){return t}},ta=function t(n){function e(t,n){var e=i((t=vt(t)).r,(n=vt(n)).r),r=i(t.g,n.g),o=i(t.b,n.b),u=Ot(t.opacity,n.opacity);return function(n){return t.r=e(n),t.g=r(n),t.b=o(n),t.opacity=u(n),t+""}}var i=zt(n);return e.gamma=t,e}(1),na=function(t,n){var e,i=n?n.length:0,r=t?Math.min(i,t.length):0,o=new Array(i),u=new Array(i);for(e=0;eo&&(r=n.slice(o,r),a[u]?a[u]+=r:a[++u]=r),(e=e[0])===(i=i[0])?a[u]?a[u]+=i:a[++u]=i:(a[++u]=null,s.push({i:u,x:ia(e,i)})),o=ua.lastIndex;return oLa&&e.state1e-6)if(Math.abs(c*a-s*h)>1e-6&&r){var f=e-o,_=i-u,p=a*a+s*s,d=f*f+_*_,y=Math.sqrt(p),v=Math.sqrt(l),g=r*Math.tan((cs-Math.acos((p+l-d)/(2*y*v)))/2),x=g/v,m=g/y;Math.abs(x-1)>1e-6&&(this._+="L"+(t+x*h)+","+(n+x*c)),this._+="A"+r+","+r+",0,0,"+ +(c*f>h*_)+","+(this._x1=t+m*a)+","+(this._y1=n+m*s)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,i,r,o){t=+t,n=+n,e=+e;var u=e*Math.cos(i),a=e*Math.sin(i),s=t+u,h=n+a,c=1^o,l=o?i-r:r-i;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+s+","+h:(Math.abs(this._x1-s)>1e-6||Math.abs(this._y1-h)>1e-6)&&(this._+="L"+s+","+h),e&&(l>fs?this._+="A"+e+","+e+",0,1,"+c+","+(t-u)+","+(n-a)+"A"+e+","+e+",0,1,"+c+","+(this._x1=s)+","+(this._y1=h):(l<0&&(l=l%ls+ls),this._+="A"+e+","+e+",0,"+ +(l>=cs)+","+c+","+(this._x1=t+e*Math.cos(r))+","+(this._y1=n+e*Math.sin(r))))},rect:function(t,n,e,i){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +i+"h"+-e+"Z"},toString:function(){return this._}};jn.prototype=Xn.prototype={constructor:jn,has:function(t){return"$"+t in this},get:function(t){return this["$"+t]},set:function(t,n){return this["$"+t]=n,this},remove:function(t){var n="$"+t;return n in this&&delete this[n]},clear:function(){for(var t in this)"$"===t[0]&&delete this[t]},keys:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(n.slice(1));return t},values:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(this[n]);return t},entries:function(){var t=[];for(var n in this)"$"===n[0]&&t.push({key:n.slice(1),value:this[n]});return t},size:function(){var t=0;for(var n in this)"$"===n[0]&&++t;return t},empty:function(){for(var t in this)if("$"===t[0])return!1;return!0},each:function(t){for(var n in this)"$"===n[0]&&t(this[n],n.slice(1),this)}};var _s=Xn.prototype;In.prototype=$n.prototype={constructor:In,has:_s.has,add:function(t){return t+="",this["$"+t]=t,this},remove:_s.remove,clear:_s.clear,values:_s.keys,size:_s.size,empty:_s.empty,each:_s.each};var ps=function(t){function n(t,n){var i,r,o=e(t,function(t,e){if(i)return i(t,e-1);r=t,i=n?Vn(t,n):Bn(t)});return o.columns=r,o}function e(t,n){function e(){if(c>=h)return u;if(r)return r=!1,o;var n,e=c;if(34===t.charCodeAt(e)){for(var i=e;i++t||t>r||i>n||n>o))return this;var u,a,s=r-e,h=this._root;switch(a=(n<(i+o)/2)<<1|t<(e+r)/2){case 0:do{u=new Array(4),u[a]=h,h=u}while(s*=2,r=e+s,o=i+s,t>r||n>o);break;case 1:do{u=new Array(4),u[a]=h,h=u}while(s*=2,e=r-s,o=i+s,e>t||n>o);break;case 2:do{u=new Array(4),u[a]=h,h=u}while(s*=2,r=e+s,i=o-s,t>r||i>n);break;case 3:do{u=new Array(4),u[a]=h,h=u}while(s*=2,e=r-s,i=o-s,e>t||i>n)}this._root&&this._root.length&&(this._root=h)}return this._x0=e,this._y0=i,this._x1=r,this._y1=o,this},ws=function(){var t=[];return this.visit(function(n){if(!n.length)do{t.push(n.data)}while(n=n.next)}),t},bs=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},Ms=function(t,n,e,i,r){this.node=t,this.x0=n,this.y0=e,this.x1=i,this.y1=r},Ns=function(t,n,e){var i,r,o,u,a,s,h,c=this._x0,l=this._y0,f=this._x1,_=this._y1,p=[],d=this._root;for(d&&p.push(new Ms(d,c,l,f,_)),null==e?e=1/0:(c=t-e,l=n-e,f=t+e,_=n+e,e*=e);s=p.pop();)if(!(!(d=s.node)||(r=s.x0)>f||(o=s.y0)>_||(u=s.x1)=v)<<1|t>=y)&&(s=p[p.length-1],p[p.length-1]=p[p.length-1-h],p[p.length-1-h]=s)}else{var g=t-+this._x.call(null,d.data),x=n-+this._y.call(null,d.data),m=g*g+x*x;if(m=(a=(p+y)/2))?p=a:y=a,(c=u>=(s=(d+v)/2))?d=s:v=s,n=_,!(_=_[l=c<<1|h]))return this;if(!_.length)break;(n[l+1&3]||n[l+2&3]||n[l+3&3])&&(e=n,f=l)}for(;_.data!==t;)if(i=_,!(_=_.next))return this;return(r=_.next)&&delete _.next,i?(r?i.next=r:delete i.next,this):n?(r?n[l]=r:delete n[l],(_=n[0]||n[1]||n[2]||n[3])&&_===(n[3]||n[2]||n[1]||n[0])&&!_.length&&(e?e[f]=_:this._root=_),this):(this._root=r,this)},Ts=function(){return this._root},Cs=function(){var t=0;return this.visit(function(n){if(!n.length)do{++t}while(n=n.next)}),t},Ss=function(t){var n,e,i,r,o,u,a=[],s=this._root;for(s&&a.push(new Ms(s,this._x0,this._y0,this._x1,this._y1));n=a.pop();)if(!t(s=n.node,i=n.x0,r=n.y0,o=n.x1,u=n.y1)&&s.length){var h=(i+o)/2,c=(r+u)/2;(e=s[3])&&a.push(new Ms(e,h,c,o,u)),(e=s[2])&&a.push(new Ms(e,i,c,h,u)),(e=s[1])&&a.push(new Ms(e,h,r,o,c)),(e=s[0])&&a.push(new Ms(e,i,r,h,c))}return this},As=function(t){var n,e=[],i=[];for(this._root&&e.push(new Ms(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var r=n.node;if(r.length){var o,u=n.x0,a=n.y0,s=n.x1,h=n.y1,c=(u+s)/2,l=(a+h)/2;(o=r[0])&&e.push(new Ms(o,u,a,c,l)),(o=r[1])&&e.push(new Ms(o,c,a,s,l)),(o=r[2])&&e.push(new Ms(o,u,l,c,h)),(o=r[3])&&e.push(new Ms(o,c,l,s,h))}i.push(n)}for(;n=i.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this},Es=function(t){return arguments.length?(this._x=t,this):this._x},Us=function(t){return arguments.length?(this._y=t,this):this._y},Ls=te.prototype=ne.prototype;Ls.copy=function(){var t,n,e=new ne(this._x,this._y,this._x0,this._y0,this._x1,this._y1),i=this._root;if(!i)return e;if(!i.length)return e._root=ee(i),e;for(t=[{source:i,target:e._root=new Array(4)}];i=t.pop();)for(var r=0;r<4;++r)(n=i.source[r])&&(n.length?t.push({source:n,target:i.target[r]=new Array(4)}):i.target[r]=ee(n));return e},Ls.add=xs,Ls.addAll=Jn,Ls.cover=ms,Ls.data=ws,Ls.extent=bs,Ls.find=Ns,Ls.remove=ks,Ls.removeAll=Gn,Ls.root=Ts,Ls.size=Cs,Ls.visit=Ss,Ls.visitAfter=As,Ls.x=Es,Ls.y=Us;var Ps,Ds=(Math.PI,Math.sqrt(5),function(t,n){if((e=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var e,i=t.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+t.slice(e+1)]}),Rs=function(t){return t=Ds(Math.abs(t)),t?t[1]:NaN},Fs=function(t,n){return function(e,i){for(var r=e.length,o=[],u=0,a=t[0],s=0;r>0&&a>0&&(s+a+1>i&&(a=Math.max(1,i-s)),o.push(e.substring(r-=a,r+a)),!((s+=a+1)>i));)a=t[u=(u+1)%t.length];return o.reverse().join(n)}},Ys=function(t,n){t=t.toPrecision(n);t:for(var e,i=t.length,r=1,o=-1;r0&&(o=0)}return o>0?t.slice(0,o)+t.slice(e+1):t},qs=function(t,n){var e=Ds(t,n);if(!e)return t+"";var i=e[0],r=e[1],o=r-(Ps=3*Math.max(-8,Math.min(8,Math.floor(r/3))))+1,u=i.length;return o===u?i:o>u?i+new Array(o-u+1).join("0"):o>0?i.slice(0,o)+"."+i.slice(o):"0."+new Array(1-o).join("0")+Ds(t,Math.max(0,n+o-1))[0]},Hs=function(t,n){var e=Ds(t,n);if(!e)return t+"";var i=e[0],r=e[1];return r<0?"0."+new Array(-r).join("0")+i:i.length>r+1?i.slice(0,r+1)+"."+i.slice(r+1):i+new Array(r-i.length+2).join("0")},zs={"":Ys,"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return Hs(100*t,n)},r:Hs,s:qs,X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},Os=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i,js=function(t){return new ie(t)};ie.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+this.type};var Xs,Is,$s,Bs=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],Vs=function(t){function n(t){function n(t){var n,r,s,g=p,x=d;if("c"===_)x=y(t)+x,t="";else{t=+t;var m=(t<0||1/t<0)&&(t*=-1,!0);if(t=y(t,f),m)for(n=-1,r=t.length,m=!1;++n(s=t.charCodeAt(n))||s>57){x=(46===s?o+t.slice(n+1):t.slice(n))+x,t=t.slice(0,n);break}}l&&!h&&(t=i(t,1/0));var w=g.length+t.length+x.length,b=w>1)+g+t+x+b.slice(w)}return b+g+t+x}t=js(t);var e=t.fill,u=t.align,a=t.sign,s=t.symbol,h=t.zero,c=t.width,l=t.comma,f=t.precision,_=t.type,p="$"===s?r[0]:"#"===s&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",d="$"===s?r[1]:/[%p]/.test(_)?"%":"",y=zs[_],v=!_||/[defgprs%]/.test(_);return f=null==f?_?6:12:/[gprs]/.test(_)?Math.max(1,Math.min(21,f)):Math.max(0,Math.min(20,f)),n.toString=function(){return t+""},n}function e(t,e){var i=n((t=js(t),t.type="f",t)),r=3*Math.max(-8,Math.min(8,Math.floor(Rs(e)/3))),o=Math.pow(10,-r),u=Bs[8+r/3];return function(t){return i(o*t)+u}}var i=t.grouping&&t.thousands?Fs(t.grouping,t.thousands):re,r=t.currency,o=t.decimal;return{format:n,formatPrefix:e}};!function(t){Xs=Vs(t),Is=Xs.format,$s=Xs.formatPrefix}({decimal:".",thousands:",",grouping:[3],currency:["$",""]});var Zs=function(t){return Math.max(0,-Rs(Math.abs(t)))},Ws=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(Rs(n)/3)))-Rs(Math.abs(t)))},Js=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,Rs(n)-Rs(t))+1},Gs=function(){return new oe};oe.prototype={constructor:oe,reset:function(){this.s=this.t=0},add:function(t){ue(Qs,t,this.t),ue(this,Qs.s,this.s),this.s?this.t+=Qs.t:this.s=Qs.t},valueOf:function(){return this.s}};var Qs=new oe,Ks=1e-6,th=Math.PI,nh=th/2,eh=th/4,ih=2*th,rh=th/180,oh=Math.abs,uh=Math.atan,ah=Math.atan2,sh=Math.cos,hh=(Math.ceil,Math.exp),ch=Math.log,lh=(Math.pow,Math.sin),fh=(Math.sign,Math.sqrt),_h=Math.tan;Gs(),Gs(),Gs();_e.invert=_e;var ph=function(){var t,n=[];return{point:function(n,e){t.push([n,e])},lineStart:function(){n.push(t=[])},lineEnd:he,rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))},result:function(){var e=n;return n=[],t=null,e}}},dh=function(t,n){return oh(t[0]-n[0])=0;--o)r.point((c=h[o])[0],c[1]);else i(f.x,f.p.x,-1,r);f=f.p}f=f.o,h=f.z,_=!_}while(!f.v);r.lineEnd()}}},vh=(Gs(),Gs(),Gs(),1/0),gh=-vh;ye.prototype={_radius:4.5,pointRadius:function(t){return this._radius=t,this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._context.closePath(),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._context.moveTo(t,n),this._point=1;break;case 1:this._context.lineTo(t,n);break;default:this._context.moveTo(t+this._radius,n),this._context.arc(t,n,this._radius,0,ih)}},result:he};Gs();ve.prototype={_circle:ge(4.5),pointRadius:function(t){return this._circle=ge(t),this},polygonStart:function(){this._line=0},polygonEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){0===this._line&&this._string.push("Z"),this._point=NaN},point:function(t,n){switch(this._point){case 0:this._string.push("M",t,",",n),this._point=1;break;case 1:this._string.push("L",t,",",n);break;default:this._string.push("M",t,",",n,this._circle)}},result:function(){if(this._string.length){var t=this._string.join("");return this._string=[],t}}};var xh=Gs(),mh=function(t,n){var e=n[0],i=n[1],r=[lh(e),-sh(e),0],o=0,u=0;xh.reset();for(var a=0,s=t.length;a=0?1:-1,N=M*b,k=N>th,T=p*m;if(xh.add(ah(T*M*lh(N),d*w+T*sh(N))),o+=k?b+M*ih:b,k^f>=e^g>=e){var C=le(ce(l),ce(v));fe(C);var S=le(r,C);fe(S);var A=(k^b>=0?-1:1)*se(S[2]);(i>A||i===A&&(C[0]||C[1]))&&(u+=k^b>=0?1:-1)}}return(o<-Ks||o0){for(m||(o.polygonStart(),m=!0),o.lineStart(),t=0;t1&&2&r&&u.push(u.pop().concat(u.shift())),p.push(u.filter(xe))}var _,p,d,y=n(o),v=r.invert(i[0],i[1]),g=ph(),x=n(g),m=!1,w={point:u,lineStart:s,lineEnd:h,polygonStart:function(){w.point=c,w.lineStart=l,w.lineEnd=f,p=[],_=[]},polygonEnd:function(){w.point=u,w.lineStart=s,w.lineEnd=h,p=vo(p);var t=mh(_,v);p.length?(m||(o.polygonStart(),m=!0),yh(p,me,t,e,o)):t&&(m||(o.polygonStart(),m=!0),o.lineStart(),e(null,null,1,o),o.lineEnd()),m&&(o.polygonEnd(),m=!1),p=_=null},sphere:function(){o.polygonStart(),o.lineStart(),e(null,null,1,o),o.lineEnd(),o.polygonEnd()}};return w}};wh(function(){return!0},we,Me,[-th,-nh]);ke.prototype={constructor:ke,point:function(t,n){this.stream.point(t,n)},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()}};sh(30*rh),Ne({point:function(t,n){this.stream.point(t*rh,n*rh)}});Te(function(t){return fh(2/(1+t))}).invert=Ce(function(t){return 2*se(t/2)}),Te(function(t){return(t=ae(t))&&t/lh(t)}).invert=Ce(function(t){return t}),Se.invert=function(t,n){return[-n,2*uh(hh(t))-nh]};var bh=function(){return this.eachAfter(Ae)},Mh=function(t){var n,e,i,r,o=this,u=[o];do{for(n=u.reverse(),u=[];o=n.pop();)if(t(o),e=o.children)for(i=0,r=e.length;i=0;--e)r.push(n[e]);return this},kh=function(t){for(var n,e,i,r=this,o=[r],u=[];r=o.pop();)if(u.push(r),n=r.children)for(e=0,i=n.length;e=0;)e+=i[r].value;n.value=e})},Ch=function(t){return this.eachBefore(function(n){n.children&&n.children.sort(t)})},Sh=function(t){for(var n=this,e=Ee(n,t),i=[n];n!==e;)n=n.parent,i.push(n);for(var r=i.length;t!==e;)i.splice(r,0,t),t=t.parent;return i},Ah=function(){for(var t=this,n=[t];t=t.parent;)n.push(t);return n},Eh=function(){var t=[];return this.each(function(n){t.push(n)}),t},Uh=function(){var t=[];return this.eachBefore(function(n){n.children||t.push(n)}),t},Lh=function(){var t=this,n=[];return t.each(function(e){e!==t&&n.push({source:e.parent,target:e})}),n};Fe.prototype=Ue.prototype={constructor:Fe,count:bh,each:Mh,eachAfter:kh,eachBefore:Nh,sum:Th,sort:Ch,path:Sh,ancestors:Ah,descendants:Eh,leaves:Uh,links:Lh,copy:Le};var Ph=function(t,n,e,i,r){for(var o,u=t.children,a=-1,s=u.length,h=t.value&&(i-n)/t.value;++a1?n:1)},e}(Rh);!function t(n){function e(t,e,i,r,o){if((u=t._squarify)&&u.ratio===n)for(var u,a,s,h,c,l=-1,f=u.length,_=t.value;++l1?n:1)},e}(Rh);var Fh={},Yh=function(t,n){function e(t){var n,e=h.status;if(!e&&$e(h)||e>=200&&e<300||304===e){if(o)try{n=o.call(i,h)}catch(t){return void a.call("error",i,t)}else n=h;a.call("load",i,n)}else a.call("error",i,t)}var i,r,o,u,a=l("beforesend","progress","load","error"),s=Xn(),h=new XMLHttpRequest,c=null,f=null,_=0;if("undefined"==typeof XDomainRequest||"withCredentials"in h||!/^(http(s)?:)?\/\//.test(t)||(h=new XDomainRequest),"onload"in h?h.onload=h.onerror=h.ontimeout=e:h.onreadystatechange=function(t){h.readyState>3&&e(t)},h.onprogress=function(t){a.call("progress",i,t)},i={header:function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==n?s.remove(t):s.set(t,n+""),i)},mimeType:function(t){return arguments.length?(r=null==t?null:t+"",i):r},responseType:function(t){return arguments.length?(u=t,i):u},timeout:function(t){return arguments.length?(_=+t,i):_},user:function(t){return arguments.length<1?c:(c=null==t?null:t+"",i)},password:function(t){return arguments.length<1?f:(f=null==t?null:t+"",i)},response:function(t){return o=t,i},get:function(t,n){return i.send("GET",t,n)},post:function(t,n){return i.send("POST",t,n)},send:function(n,e,o){return h.open(n,t,!0,c,f),null==r||s.has("accept")||s.set("accept",r+",*/*"),h.setRequestHeader&&s.each(function(t,n){h.setRequestHeader(n,t)}),null!=r&&h.overrideMimeType&&h.overrideMimeType(r),null!=u&&(h.responseType=u),_>0&&(h.timeout=_),null==o&&"function"==typeof e&&(o=e,e=null),null!=o&&1===o.length&&(o=Ie(o)),null!=o&&i.on("error",o).on("load",function(t){o(null,t)}),a.call("beforesend",i,h),h.send(null==e?null:e),i},abort:function(){return h.abort(),i},on:function(){var t=a.on.apply(a,arguments);return t===a?i:t}},null!=n){if("function"!=typeof n)throw new Error("invalid callback: "+n);return i.get(n)}return i},qh=function(t,n){return function(e,i){var r=Yh(e).mimeType(t).response(n);if(null!=i){if("function"!=typeof i)throw new Error("invalid callback: "+i);return r.get(i)}return r}};qh("text/html",function(t){return document.createRange().createContextualFragment(t.responseText)}),qh("application/json",function(t){return JSON.parse(t.responseText)}),qh("text/plain",function(t){return t.responseText}),qh("application/xml",function(t){var n=t.responseXML;if(!n)throw new Error("parse error");return n});var Hh=function(t,n){return function(e,i,r){arguments.length<3&&(r=i,i=null);var o=Yh(e).mimeType(t);return o.row=function(t){return arguments.length?o.response(Be(n,i=t)):i},o.row(i),r?o.get(r):o}};Hh("text/csv",ys),Hh("text/tab-separated-values",gs);var zh=Array.prototype,Oh=zh.map,jh=zh.slice,Xh={name:"implicit"},Ih=function(t){return function(){return t}},$h=function(t){return+t},Bh=[0,1],Vh=function(t,n,i){var r,o=t[0],u=t[t.length-1],a=e(o,u,null==n?10:n);switch(i=js(null==i?",f":i),i.type){case"s":var s=Math.max(Math.abs(o),Math.abs(u));return null!=i.precision||isNaN(r=Ws(a,s))||(i.precision=r),$s(i,s);case"":case"e":case"g":case"p":case"r":null!=i.precision||isNaN(r=Js(a,Math.max(Math.abs(o),Math.abs(u))))||(i.precision=r-("e"===i.type));break;case"f":case"%":null!=i.precision||isNaN(r=Zs(a))||(i.precision=r-2*("%"===i.type))}return Is(i)},Zh=new Date,Wh=new Date,Jh=ri(function(){},function(t,n){t.setTime(+t+n)},function(t,n){return n-t});Jh.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?ri(function(n){n.setTime(Math.floor(n/t)*t)},function(n,e){n.setTime(+n+e*t)},function(n,e){return(e-n)/t}):Jh:null};var Gh=6e4,Qh=6048e5,Kh=(ri(function(t){t.setTime(1e3*Math.floor(t/1e3))},function(t,n){t.setTime(+t+1e3*n)},function(t,n){return(n-t)/1e3},function(t){return t.getUTCSeconds()}),ri(function(t){t.setTime(Math.floor(t/Gh)*Gh)},function(t,n){t.setTime(+t+n*Gh)},function(t,n){return(n-t)/Gh},function(t){return t.getMinutes()}),ri(function(t){var n=t.getTimezoneOffset()*Gh%36e5;n<0&&(n+=36e5),t.setTime(36e5*Math.floor((+t-n)/36e5)+n)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getHours()}),ri(function(t){t.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*Gh)/864e5},function(t){return t.getDate()-1})),tc=oi(0),nc=oi(1),ec=(oi(2),oi(3),oi(4),oi(5),oi(6),ri(function(t){t.setDate(1),t.setHours(0,0,0,0)},function(t,n){t.setMonth(t.getMonth()+n)},function(t,n){return n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())},function(t){return t.getMonth()}),ri(function(t){t.setMonth(0,1),t.setHours(0,0,0,0)},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t,n){return n.getFullYear()-t.getFullYear()},function(t){return t.getFullYear()}));ec.every=function(t){return isFinite(t=Math.floor(t))&&t>0?ri(function(n){n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)},function(n,e){n.setFullYear(n.getFullYear()+e*t)}):null};var ic=(ri(function(t){t.setUTCSeconds(0,0)},function(t,n){t.setTime(+t+n*Gh)},function(t,n){return(n-t)/Gh},function(t){return t.getUTCMinutes()}),ri(function(t){t.setUTCMinutes(0,0,0)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getUTCHours()}),ri(function(t){t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+n)},function(t,n){return(n-t)/864e5},function(t){return t.getUTCDate()-1})),rc=ui(0),oc=ui(1),uc=(ui(2),ui(3),ui(4),ui(5),ui(6),ri(function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCMonth(t.getUTCMonth()+n)},function(t,n){return n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())},function(t){return t.getUTCMonth()}),ri(function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n)},function(t,n){return n.getUTCFullYear()-t.getUTCFullYear()},function(t){return t.getUTCFullYear()}));uc.every=function(t){return isFinite(t=Math.floor(t))&&t>0?ri(function(n){n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e*t)}):null};var ac,sc,hc,cc,lc,fc={"-":"",_:" ",0:"0"},_c=/^\s*\d+/,pc=/^%/,dc=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;!function(t){ac=ci(t),sc=ac.format,hc=ac.parse,cc=ac.utcFormat,lc=ac.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",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"]});var yc=(Date.prototype.toISOString||cc("%Y-%m-%dT%H:%M:%S.%LZ"),+new Date("2000-01-01T00:00:00.000Z")||lc("%Y-%m-%dT%H:%M:%S.%LZ"),function(t){return t.match(/.{6}/g).map(function(t){return"#"+t})});yc("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),yc("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6"),yc("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9"),yc("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5"),va(Rt(300,.5,0),Rt(-240,.5,1));var vc=(va(Rt(-100,.75,.35),Rt(80,1.5,.8)),va(Rt(260,.75,.35),Rt(80,1.5,.8)),Rt(),function(t){return function(){return t}}),gc=1e-12;Math.PI;ur.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._point=0},lineEnd:function(){(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;default:this._context.lineTo(t,n)}}};var xc=function(t){return new ur(t)},mc=function(){function t(t){var a,s,h,c=t.length,l=!1;for(null==r&&(u=o(h=On())),a=0;a<=c;++a)!(a0)for(var i,r=t[0],o=n[0],u=t[e]-r,a=n[e]-o,s=-1;++s<=e;)i=s/e,this._basis.point(this._beta*t[s]+(1-this._beta)*(r+i*u),this._beta*n[s]+(1-this._beta)*(o+i*a));this._x=this._y=null,this._basis.lineEnd()},point:function(t,n){this._x.push(+t),this._y.push(+n)}},function t(n){function e(t){return 1===n?new fr(t):new _r(t,n)}return e.beta=function(n){return t(+n)},e}(.85),dr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:pr(this,this._x1,this._y1)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2,this._x1=t,this._y1=n;break;case 2:this._point=3;default:pr(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}},function t(n){function e(t){return new dr(t,n)}return e.tension=function(n){return t(+n)},e}(0),yr.prototype={areaStart:wc,areaEnd:wc,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:pr(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}},function t(n){function e(t){return new yr(t,n)}return e.tension=function(n){return t(+n)},e}(0),vr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){switch(t=+t,n=+n,this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:pr(this,t,n)}this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}},function t(n){function e(t){return new vr(t,n)}return e.tension=function(n){return t(+n)},e}(0),xr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x2,this._y2);break;case 3:this.point(this._x2,this._y2)}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,i=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3;default:gr(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}},function t(n){function e(t){return n?new xr(t,n):new dr(t,0)}return e.alpha=function(n){return t(+n)},e}(.5),mr.prototype={areaStart:wc,areaEnd:wc,lineStart:function(){this._x0=this._x1=this._x2=this._x3=this._x4=this._x5=this._y0=this._y1=this._y2=this._y3=this._y4=this._y5=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){switch(this._point){case 1:this._context.moveTo(this._x3,this._y3),this._context.closePath();break;case 2:this._context.lineTo(this._x3,this._y3),this._context.closePath();break;case 3:this.point(this._x3,this._y3),this.point(this._x4,this._y4),this.point(this._x5,this._y5)}},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,i=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1,this._x3=t,this._y3=n;break;case 1:this._point=2,this._context.moveTo(this._x4=t,this._y4=n);break;case 2:this._point=3,this._x5=t,this._y5=n;break;default:gr(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}},function t(n){function e(t){return n?new mr(t,n):new yr(t,0)}return e.alpha=function(n){return t(+n)},e}(.5),wr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._x2=this._y0=this._y1=this._y2=NaN,this._l01_a=this._l12_a=this._l23_a=this._l01_2a=this._l12_2a=this._l23_2a=this._point=0},lineEnd:function(){(this._line||0!==this._line&&3===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){if(t=+t,n=+n,this._point){var e=this._x2-t,i=this._y2-n;this._l23_a=Math.sqrt(this._l23_2a=Math.pow(e*e+i*i,this._alpha))}switch(this._point){case 0:this._point=1;break;case 1:this._point=2;break;case 2:this._point=3,this._line?this._context.lineTo(this._x2,this._y2):this._context.moveTo(this._x2,this._y2);break;case 3:this._point=4;default:gr(this,t,n)}this._l01_a=this._l12_a,this._l12_a=this._l23_a,this._l01_2a=this._l12_2a,this._l12_2a=this._l23_2a,this._x0=this._x1,this._x1=this._x2,this._x2=t,this._y0=this._y1,this._y1=this._y2,this._y2=n}},function t(n){function e(t){return n?new wr(t,n):new vr(t,0)}return e.alpha=function(n){return t(+n)},e}(.5),Tr.prototype={areaStart:function(){this._line=0},areaEnd:function(){this._line=NaN},lineStart:function(){this._x0=this._x1=this._y0=this._y1=this._t0=NaN,this._point=0},lineEnd:function(){switch(this._point){case 2:this._context.lineTo(this._x1,this._y1);break;case 3:kr(this,this._t0,Nr(this,this._t0))}(this._line||0!==this._line&&1===this._point)&&this._context.closePath(),this._line=1-this._line},point:function(t,n){var e=NaN;if(t=+t,n=+n,t!==this._x1||n!==this._y1){switch(this._point){case 0:this._point=1,this._line?this._context.lineTo(t,n):this._context.moveTo(t,n);break;case 1:this._point=2;break;case 2:this._point=3,kr(this,Nr(this,e=Mr(this,t,n)),e);break;default:kr(this,this._t0,e=Mr(this,t,n))}this._x0=this._x1,this._x1=t,this._y0=this._y1,this._y1=n,this._t0=e}}},(Cr.prototype=Object.create(Tr.prototype)).point=function(t,n){Tr.prototype.point.call(this,n,t)},Sr.prototype={moveTo:function(t,n){this._context.moveTo(n,t)},closePath:function(){this._context.closePath()},lineTo:function(t,n){this._context.lineTo(n,t)},bezierCurveTo:function(t,n,e,i,r,o){this._context.bezierCurveTo(n,t,i,e,o,r)}};Array.prototype.slice;Ar.prototype={constructor:Ar,insert:function(t,n){var e,i,r;if(t){if(n.P=t,n.N=t.N,t.N&&(t.N.P=n),t.N=n,t.R){for(t=t.R;t.L;)t=t.L;t.L=n}else t.R=n;e=t}else this._?(t=Pr(this._),n.P=null,n.N=t,t.P=t.L=n,e=t):(n.P=n.N=null,this._=n,e=null);for(n.L=n.R=null,n.U=e,n.C=!0,t=n;e&&e.C;)i=e.U,e===i.L?(r=i.R,r&&r.C?(e.C=r.C=!1,i.C=!0,t=i):(t===e.R&&(Ur(this,e),t=e,e=t.U),e.C=!1,i.C=!0,Lr(this,i))):(r=i.L,r&&r.C?(e.C=r.C=!1,i.C=!0,t=i):(t===e.L&&(Lr(this,e),t=e,e=t.U),e.C=!1,i.C=!0,Ur(this,i))),e=t.U;this._.C=!1},remove:function(t){t.N&&(t.N.P=t.P),t.P&&(t.P.N=t.N),t.N=t.P=null;var n,e,i,r=t.U,o=t.L,u=t.R;if(e=o?u?Pr(u):o:u,r?r.L===t?r.L=e:r.R=e:this._=e,o&&u?(i=e.C,e.C=t.C,e.L=o,o.U=e,e!==u?(r=e.U,e.U=t.U,t=e.R,r.L=t,e.R=u,u.U=e):(e.U=r,r=e,t=e.R)):(i=t.C,t=e),t&&(t.U=r),!i){if(t&&t.C)return void(t.C=!1);do{if(t===this._)break;if(t===r.L){if(n=r.R,n.C&&(n.C=!1,r.C=!0,Ur(this,r),n=r.R),n.L&&n.L.C||n.R&&n.R.C){n.R&&n.R.C||(n.L.C=!1,n.C=!0,Lr(this,n),n=r.R),n.C=r.C,r.C=n.R.C=!1,Ur(this,r),t=this._;break}}else if(n=r.L,n.C&&(n.C=!1,r.C=!0,Lr(this,r),n=r.L),n.L&&n.L.C||n.R&&n.R.C){n.L&&n.L.C||(n.R.C=!1,n.C=!0,Ur(this,n),n=r.L),n.C=r.C,r.C=n.L.C=!1,Lr(this,r),t=this._;break}n.C=!0,t=r,r=r.U}while(!t.C);t&&(t.C=!1)}}};var bc,Mc,Nc,kc,Tc,Cc=[],Sc=[],Ac=1e-6,Ec=1e-12;ro.prototype={constructor:ro,polygons:function(){var t=this.edges;return this.cells.map(function(n){var e=n.halfedges.map(function(e){return jr(n,t[e])});return e.data=n.site.data,e})},triangles:function(){var t=[],n=this.edges;return this.cells.forEach(function(e,i){if(o=(r=e.halfedges).length)for(var r,o,u,a=e.site,s=-1,h=n[r[o-1]],c=h.left===a?h.right:h.left;++s=a)return null;var s=t-r.site[0],h=n-r.site[1],c=s*s+h*h;do{r=o.cells[i=u],u=null,r.halfedges.forEach(function(e){var i=o.edges[e],a=i.left;if(a!==r.site&&a||(a=i.right)){var s=t-a[0],h=n-a[1],l=s*s+h*h;l=0?(o>=Wi?10:o>=Ji?5:o>=Gi?2:1)*Math.pow(10,i):-Math.pow(10,-i)/(o>=Wi?10:o>=Ji?5:o>=Gi?2:1)}function r(t,n,e){var r=Math.abs(n-t)/Math.max(0,e),i=Math.pow(10,Math.floor(Math.log(r)/Math.LN10)),o=r/i;return o>=Wi?i*=10:o>=Ji?i*=5:o>=Gi&&(i*=2),n=0&&(e=t.slice(r+1),t=t.slice(0,r)),t&&!n.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:e}})}function _(t,n){for(var e,r=0,i=t.length;r=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}function M(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;rn?1:t>=n?0:NaN}function E(t){return function(){this.removeAttribute(t)}}function U(t){return function(){this.removeAttributeNS(t.space,t.local)}}function D(t,n){return function(){this.setAttribute(t,n)}}function P(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function F(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function L(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function H(t){return function(){this.style.removeProperty(t)}}function O(t,n,e){return function(){this.style.setProperty(t,n,e)}}function Y(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function q(t){return function(){delete this[t]}}function z(t,n){return function(){this[t]=n}}function j(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function I(t){return t.trim().split(/^|\s+/)}function $(t){return t.classList||new X(t)}function X(t){this._node=t,this._names=I(t.getAttribute("class")||"")}function R(t,n){for(var e=$(t),r=-1,i=n.length;++r>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n,1)):(n=ou.exec(t))?dt(parseInt(n[1],16)):(n=uu.exec(t))?new yt(n[1],n[2],n[3],1):(n=au.exec(t))?new yt(255*n[1]/100,255*n[2]/100,255*n[3]/100,1):(n=su.exec(t))?_t(n[1],n[2],n[3],n[4]):(n=cu.exec(t))?_t(255*n[1]/100,255*n[2]/100,255*n[3]/100,n[4]):(n=lu.exec(t))?mt(n[1],n[2]/100,n[3]/100,1):(n=hu.exec(t))?mt(n[1],n[2]/100,n[3]/100,n[4]):fu.hasOwnProperty(t)?dt(fu[t]):"transparent"===t?new yt(NaN,NaN,NaN,0):null}function dt(t){return new yt(t>>16&255,t>>8&255,255&t,1)}function _t(t,n,e,r){return r<=0&&(t=n=e=NaN),new yt(t,n,e,r)}function gt(t){return t instanceof ft||(t=pt(t)),t?(t=t.rgb(),new yt(t.r,t.g,t.b,t.opacity)):new yt}function vt(t,n,e,r){return 1===arguments.length?gt(t):new yt(t,n,e,null==r?1:r)}function yt(t,n,e,r){this.r=+t,this.g=+n,this.b=+e,this.opacity=+r}function mt(t,n,e,r){return r<=0?t=n=e=NaN:e<=0||e>=1?t=n=NaN:n<=0&&(t=NaN),new Mt(t,n,e,r)}function wt(t){if(t instanceof Mt)return new Mt(t.h,t.s,t.l,t.opacity);if(t instanceof ft||(t=pt(t)),!t)return new Mt;if(t instanceof Mt)return t;t=t.rgb();var n=t.r/255,e=t.g/255,r=t.b/255,i=Math.min(n,e,r),o=Math.max(n,e,r),u=NaN,a=o-i,s=(o+i)/2;return a?(u=n===o?(e-r)/a+6*(e0&&s<1?0:u,new Mt(u,a,s,t.opacity)}function xt(t,n,e,r){return 1===arguments.length?wt(t):new Mt(t,n,e,null==r?1:r)}function Mt(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function bt(t,n,e){return 255*(t<60?n+(e-n)*t/60:t<180?e:t<240?n+(e-n)*(240-t)/60:n)}function At(t){if(t instanceof Nt)return new Nt(t.l,t.a,t.b,t.opacity);if(t instanceof Pt){var n=t.h*pu;return new Nt(t.l,Math.cos(n)*t.c,Math.sin(n)*t.c,t.opacity)}t instanceof yt||(t=gt(t));var e=Et(t.r),r=Et(t.g),i=Et(t.b),o=Ct((.4124564*e+.3575761*r+.1804375*i)/_u),u=Ct((.2126729*e+.7151522*r+.072175*i)/gu);return new Nt(116*u-16,500*(o-u),200*(u-Ct((.0193339*e+.119192*r+.9503041*i)/vu)),t.opacity)}function Tt(t,n,e,r){return 1===arguments.length?At(t):new Nt(t,n,e,null==r?1:r)}function Nt(t,n,e,r){this.l=+t,this.a=+n,this.b=+e,this.opacity=+r}function Ct(t){return t>xu?Math.pow(t,1/3):t/wu+yu}function kt(t){return t>mu?t*t*t:wu*(t-yu)}function St(t){return 255*(t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055)}function Et(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function Ut(t){if(t instanceof Pt)return new Pt(t.h,t.c,t.l,t.opacity);t instanceof Nt||(t=At(t));var n=Math.atan2(t.b,t.a)*du;return new Pt(n<0?n+360:n,Math.sqrt(t.a*t.a+t.b*t.b),t.l,t.opacity)}function Dt(t,n,e,r){return 1===arguments.length?Ut(t):new Pt(t,n,e,null==r?1:r)}function Pt(t,n,e,r){this.h=+t,this.c=+n,this.l=+e,this.opacity=+r}function Ft(t){if(t instanceof Ht)return new Ht(t.h,t.s,t.l,t.opacity);t instanceof yt||(t=gt(t));var n=t.r/255,e=t.g/255,r=t.b/255,i=(Su*r+Cu*n-ku*e)/(Su+Cu-ku),o=r-i,u=(Nu*(e-i)-Au*o)/Tu,a=Math.sqrt(u*u+o*o)/(Nu*i*(1-i)),s=a?Math.atan2(u,o)*du-120:NaN;return new Ht(s<0?s+360:s,a,i,t.opacity)}function Lt(t,n,e,r){return 1===arguments.length?Ft(t):new Ht(t,n,e,null==r?1:r)}function Ht(t,n,e,r){this.h=+t,this.s=+n,this.l=+e,this.opacity=+r}function Ot(t,n){return function(e){return t+e*n}}function Yt(t,n,e){return t=Math.pow(t,e),n=Math.pow(n,e)-t,e=1/e,function(r){return Math.pow(t+r*n,e)}}function qt(t,n){var e=n-t;return e?Ot(t,e>180||e<-180?e-360*Math.round(e/360):e):Fu(isNaN(t)?n:t)}function zt(t){return 1==(t=+t)?jt:function(n,e){return e-n?Yt(n,e,t):Fu(isNaN(n)?e:n)}}function jt(t,n){var e=n-t;return e?Ot(t,e):Fu(isNaN(t)?n:t)}function It(t){return function(){return t}}function $t(t){return function(n){return t(n)+""}}function Xt(t){return"none"===t?Bu:(Eu||(Eu=document.createElement("DIV"),Uu=document.documentElement,Du=document.defaultView),Eu.style.transform=t,t=Du.getComputedStyle(Uu.appendChild(Eu),null).getPropertyValue("transform"),Uu.removeChild(Eu),t=t.slice(7,-1).split(","),Vu(+t[0],+t[1],+t[2],+t[3],+t[4],+t[5]))}function Rt(t){return null==t?Bu:(Pu||(Pu=document.createElementNS("http://www.w3.org/2000/svg","g")),Pu.setAttribute("transform",t),(t=Pu.transform.baseVal.consolidate())?(t=t.matrix,Vu(t.a,t.b,t.c,t.d,t.e,t.f)):Bu)}function Bt(t,n,e,r){function i(t){return t.length?t.pop()+" ":""}function o(t,r,i,o,u,a){if(t!==i||r!==o){var s=u.push("translate(",null,n,null,e);a.push({i:s-4,x:Yu(t,i)},{i:s-2,x:Yu(r,o)})}else(i||o)&&u.push("translate("+i+n+o+e)}function u(t,n,e,o){t!==n?(t-n>180?n+=360:n-t>180&&(t+=360),o.push({i:e.push(i(e)+"rotate(",null,r)-2,x:Yu(t,n)})):n&&e.push(i(e)+"rotate("+n+r)}function a(t,n,e,o){t!==n?o.push({i:e.push(i(e)+"skewX(",null,r)-2,x:Yu(t,n)}):n&&e.push(i(e)+"skewX("+n+r)}function s(t,n,e,r,o,u){if(t!==e||n!==r){var a=o.push(i(o)+"scale(",null,",",null,")");u.push({i:a-4,x:Yu(t,e)},{i:a-2,x:Yu(n,r)})}else 1===e&&1===r||o.push(i(o)+"scale("+e+","+r+")")}return function(n,e){var r=[],i=[];return n=t(n),e=t(e),o(n.translateX,n.translateY,e.translateX,e.translateY,r,i),u(n.rotate,e.rotate,r,i),a(n.skewX,e.skewX,r,i),s(n.scaleX,n.scaleY,e.scaleX,e.scaleY,r,i),n=e=null,function(t){for(var n,e=-1,o=i.length;++e=0&&n._call.call(null,t),n=n._next;--Ku}function Kt(){ia=(ra=ua.now())+oa,Ku=ta=0;try{Qt()}finally{Ku=0,nn(),ia=0}}function tn(){var t=ua.now(),n=t-ra;n>ea&&(oa-=n,ra=t)}function nn(){for(var t,n,e=Ju,r=1/0;e;)e._call?(r>e._time&&(r=e._time),t=e,e=e._next):(n=e._next,e._next=null,e=t?t._next=n:Ju=n);Gu=t,en(r)}function en(t){if(!Ku){ta&&(ta=clearTimeout(ta));var n=t-ia;n>24?(t<1/0&&(ta=setTimeout(Kt,n)),na&&(na=clearInterval(na))):(na||(ra=ia,na=setInterval(tn,ea)),Ku=1,aa(Kt))}}function rn(t,n){var e=t.__transition;if(!e||!(e=e[n])||e.state>ha)throw new Error("too late");return e}function on(t,n){var e=t.__transition;if(!e||!(e=e[n])||e.state>pa)throw new Error("too late");return e}function un(t,n){var e=t.__transition;if(!e||!(e=e[n]))throw new Error("too late");return e}function an(t,n,e){function r(t){e.state=fa,e.timer.restart(i,e.delay,e.time),e.delay<=t&&i(t-e.delay)}function i(r){var c,l,h,f;if(e.state!==fa)return u();for(c in s)if(f=s[c],f.name===e.name){if(f.state===da)return sa(i);f.state===_a?(f.state=va,f.timer.stop(),f.on.call("interrupt",t,t.__data__,f.index,f.group),delete s[c]):+c=0&&(t=t.slice(0,n)),!t||"start"===t})}function Tn(t,n,e){var r,i,o=An(n)?rn:on;return function(){var u=o(this,t),a=u.on;a!==r&&(i=(r=a).copy()).on(n,e),u.on=i}}function Nn(t){return function(){var n=this.parentNode;for(var e in this.__transition)if(+e!==t)return;n&&n.removeChild(this)}}function Cn(t,n){var e,r,i;return function(){var o=zo(this).getComputedStyle(this,null),u=o.getPropertyValue(t),a=(this.style.removeProperty(t),o.getPropertyValue(t));return u===a?null:u===e&&a===r?i:i=n(e=u,r=a)}}function kn(t){return function(){this.style.removeProperty(t)}}function Sn(t,n,e){var r,i;return function(){var o=zo(this).getComputedStyle(this,null).getPropertyValue(t);return o===e?null:o===r?i:i=n(r=o,e)}}function En(t,n,e){var r,i,o;return function(){var u=zo(this).getComputedStyle(this,null),a=u.getPropertyValue(t),s=e(this);return null==s&&(this.style.removeProperty(t),s=u.getPropertyValue(t)),a===s?null:a===r&&s===i?o:o=n(r=a,i=s)}}function Un(t,n,e){function r(){var r=this,i=n.apply(r,arguments);return i&&function(n){r.style.setProperty(t,i(n),e)}}return r._value=n,r}function Dn(t){return function(){this.textContent=t}}function Pn(t){return function(){var n=t(this);this.textContent=null==n?"":n}}function Fn(t,n,e,r){this._groups=t,this._parents=n,this._name=e,this._id=r}function Ln(t){return lt().transition(t)}function Hn(){return++za}function On(t){return((t*=2)<=1?t*t*t:(t-=2)*t*t+2)/2}function Yn(t,n){for(var e;!(e=t.__transition)||!(e=e[n]);)if(!(t=t.parentNode))return $a.time=Zt(),$a;return e}function qn(t){return{type:t}}function zn(){this._x0=this._y0=this._x1=this._y1=null,this._=""}function jn(){return new zn}function In(){}function $n(t,n){var e=new In;if(t instanceof In)t.each(function(t,n){e.set(n,t)});else if(Array.isArray(t)){var r,i=-1,o=t.length;if(null==n)for(;++i=(o=(_+v)/2))?_=o:v=o,(l=e>=(u=(g+y)/2))?g=u:y=u,i=p,!(p=p[h=l<<1|c]))return i[h]=d,t;if(a=+t._x.call(null,p.data),s=+t._y.call(null,p.data),n===a&&e===s)return d.next=p,i?i[h]=d:t._root=d,t;do{i=i?i[h]=new Array(4):t._root=new Array(4),(c=n>=(o=(_+v)/2))?_=o:v=o,(l=e>=(u=(g+y)/2))?g=u:y=u}while((h=l<<1|c)==(f=(s>=u)<<1|a>=o));return i[f]=p,i[h]=d,t}function Jn(t){var n,e,r,i,o=t.length,u=new Array(o),a=new Array(o),s=1/0,c=1/0,l=-1/0,h=-1/0;for(e=0;el&&(l=r),ih&&(h=i));for(l",i=n[3]||"-",o=n[4]||"",u=!!n[5],a=n[6]&&+n[6],s=!!n[7],c=n[8]&&+n[8].slice(1),l=n[9]||"";"n"===l?(s=!0,l="g"):Ms[l]||(l=""),(u||"0"===e&&"="===r)&&(u=!0,e="0",r="="),this.fill=e,this.align=r,this.sign=i,this.symbol=o,this.zero=u,this.width=a,this.comma=s,this.precision=c,this.type=l}function oe(){this.reset()}function ue(t,n,e){var r=t.s=n+e,i=r-n,o=r-i;t.t=n-o+(e-i)}function ae(t){return t>1?0:t<-1?Ls:Math.acos(t)}function se(t){return t>1?Hs:t<-1?-Hs:Math.asin(t)}function ce(t){return function(n,e){var r=qs(n),i=qs(e),o=t(r*i);return[o*i*zs(n),o*zs(e)]}}function le(t){return function(n,e){var r=js(n*n+e*e),i=t(r),o=zs(i),u=qs(i);return[Ys(n*o,r*u),se(r&&e*o/r)]}}function he(t){var n=0,e=t.children,r=e&&e.length;if(r)for(;--r>=0;)n+=e[r].value;else n=1;t.value=n}function fe(t,n){if(t===n)return t;var e=t.ancestors(),r=n.ancestors(),i=null;for(t=e.pop(),n=r.pop();t===n;)i=t,t=e.pop(),n=r.pop();return i}function pe(t,n){var e,r,i,o,u,a=new ye(t),s=+t.value&&(a.value=t.value),c=[a];for(null==n&&(n=_e);e=c.pop();)if(s&&(e.value=+e.data.value),(i=n(e.data))&&(u=i.length))for(e.children=new Array(u),o=u-1;o>=0;--o)c.push(r=e.children[o]=new ye(i[o])),r.parent=e,r.depth=e.depth+1;return a.eachBefore(ve)}function de(){return pe(this).eachBefore(ge)}function _e(t){return t.children}function ge(t){t.data=t.data.data}function ve(t){var n=0;do{t.height=n}while((t=t.parent)&&t.height<++n)}function ye(t){this.data=t,this.depth=this.height=0,this.parent=null}function me(t,n){this._=t,this.parent=null,this.children=null,this.A=null,this.a=this,this.z=0,this.m=0,this.c=0,this.s=0,this.t=null,this.i=n}function we(t){if(!t._start)try{xe(t)}catch(n){if(t._tasks[t._ended+t._active-1])be(t,n);else if(!t._data)throw n}}function xe(t){for(;t._start=t._waiting&&t._active=0;)if((e=t._tasks[r])&&(t._tasks[r]=null,e.abort))try{e.abort()}catch(n){}t._active=NaN,Ae(t)}function Ae(t){if(!t._active&&t._call){var n=t._data;t._data=void 0,t._call(t._error,n)}}function Te(t){return function(n,e){t(null==n?e:null)}}function Ne(t){var n=t.responseType;return n&&"text"!==n?t.response:t.responseText}function Ce(t,n){return function(e){return t(e.responseText,n)}}function ke(t){function n(n){var o=n+"",u=e.get(o);if(!u){if(i!==uc)return i;e.set(o,u=r.push(n))}return t[(u-1)%t.length]}var e=$n(),r=[],i=uc;return t=null==t?[]:oc.call(t),n.domain=function(t){if(!arguments.length)return r.slice();r=[],e=$n();for(var i,o,u=-1,a=t.length;++u=e?1:r(t)}}}function De(t){return function(n,e){var r=t(n=+n,e=+e);return function(t){return t<=0?n:t>=1?e:r(t)}}}function Pe(t,n,e,r){var i=t[0],o=t[1],u=n[0],a=n[1];return o2?Fe:Pe,o=u=null,r}function r(n){return(o||(o=i(a,s,l?Ue(t):t,c)))(+n)}var i,o,u,a=cc,s=cc,c=$u,l=!1;return r.invert=function(t){return(u||(u=i(s,a,Ee,l?De(n):n)))(+t)},r.domain=function(t){return arguments.length?(a=ic.call(t,sc),e()):a.slice()},r.range=function(t){return arguments.length?(s=oc.call(t),e()):s.slice()},r.rangeRound=function(t){return s=oc.call(t),c=Xu,e()},r.clamp=function(t){return arguments.length?(l=!!t,e()):l},r.interpolate=function(t){return arguments.length?(c=t,e()):c},e()}function Oe(t){var n=t.domain;return t.ticks=function(t){var e=n();return Qi(e[0],e[e.length-1],null==t?10:t)},t.tickFormat=function(t,e){return lc(n(),t,e)},t.nice=function(e){var i=n(),o=i.length-1,u=null==e?10:e,a=i[0],s=i[o],c=r(a,s,u);return c&&(c=r(Math.floor(a/c)*c,Math.ceil(s/c)*c,u),i[0]=Math.floor(a/c)*c,i[o]=Math.ceil(s/c)*c,n(i)),t},t}function Ye(){var t=He(Ee,Yu);return t.copy=function(){return Le(t,Ye())},Oe(t)}function qe(t,n,e,r){function i(n){return t(n=new Date(+n)),n}return i.floor=i,i.ceil=function(e){return t(e=new Date(e-1)),n(e,1),t(e),e},i.round=function(t){var n=i(t),e=i.ceil(t);return t-n0))return u;do{u.push(new Date(+e))}while(n(e,o),t(e),e=n)for(;t(n),!e(n);)n.setTime(n-1)},function(t,r){if(t>=t)for(;--r>=0;)for(;n(t,1),!e(t););})},e&&(i.count=function(n,r){return hc.setTime(+n),fc.setTime(+r),t(hc),t(fc),Math.floor(e(hc,fc))},i.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?i.filter(r?function(n){return r(n)%t==0}:function(n){return i.count(0,n)%t==0}):i:null}),i}function ze(t){return qe(function(n){n.setDate(n.getDate()-(n.getDay()+7-t)%7),n.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+7*n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*dc)/_c})}function je(t){return qe(function(n){n.setUTCDate(n.getUTCDate()-(n.getUTCDay()+7-t)%7),n.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+7*n)},function(t,n){return(n-t)/_c})}function Ie(t){if(0<=t.y&&t.y<100){var n=new Date(-1,t.m,t.d,t.H,t.M,t.S,t.L);return n.setFullYear(t.y),n}return new Date(t.y,t.m,t.d,t.H,t.M,t.S,t.L)}function $e(t){if(0<=t.y&&t.y<100){var n=new Date(Date.UTC(-1,t.m,t.d,t.H,t.M,t.S,t.L));return n.setUTCFullYear(t.y),n}return new Date(Date.UTC(t.y,t.m,t.d,t.H,t.M,t.S,t.L))}function Xe(t){return{y:t,m:0,d:1,H:0,M:0,S:0,L:0}}function Re(t){function n(t,n){return function(e){var r,i,o,u=[],a=-1,s=0,c=t.length;for(e instanceof Date||(e=new Date(+e));++a=s)return-1;if(37===(i=n.charCodeAt(u++))){if(i=n.charAt(u++),!(o=I[i in Sc?n.charAt(u++):i])||(r=o(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function i(t,n,e){var r=E.exec(n.slice(e));return r?(t.p=U[r[0].toLowerCase()],e+r[0].length):-1}function o(t,n,e){var r=F.exec(n.slice(e));return r?(t.w=L[r[0].toLowerCase()],e+r[0].length):-1}function u(t,n,e){var r=D.exec(n.slice(e));return r?(t.w=P[r[0].toLowerCase()],e+r[0].length):-1}function a(t,n,e){var r=Y.exec(n.slice(e));return r?(t.m=q[r[0].toLowerCase()],e+r[0].length):-1}function s(t,n,e){var r=H.exec(n.slice(e));return r?(t.m=O[r[0].toLowerCase()],e+r[0].length):-1}function c(t,n,e){return r(t,M,n,e)}function l(t,n,e){return r(t,b,n,e)}function h(t,n,e){return r(t,A,n,e)}function f(t){return C[t.getDay()]}function p(t){return N[t.getDay()]}function d(t){return S[t.getMonth()]}function _(t){return k[t.getMonth()]}function g(t){return T[+(t.getHours()>=12)]}function v(t){return C[t.getUTCDay()]}function y(t){return N[t.getUTCDay()]}function m(t){return S[t.getUTCMonth()]}function w(t){return k[t.getUTCMonth()]}function x(t){return T[+(t.getUTCHours()>=12)]}var M=t.dateTime,b=t.date,A=t.time,T=t.periods,N=t.days,C=t.shortDays,k=t.months,S=t.shortMonths,E=Ze(T),U=We(T),D=Ze(N),P=We(N),F=Ze(C),L=We(C),H=Ze(k),O=We(k),Y=Ze(S),q=We(S),z={a:f,A:p,b:d,B:_,c:null,d:lr,e:lr,H:hr,I:fr,j:pr,L:dr,m:_r,M:gr,p:g,S:vr,U:yr,w:mr,W:wr,x:null,X:null,y:xr,Y:Mr,Z:br,"%":Yr},j={a:v,A:y,b:m,B:w,c:null,d:Ar,e:Ar,H:Tr,I:Nr,j:Cr,L:kr,m:Sr,M:Er,p:x,S:Ur,U:Dr,w:Pr,W:Fr,x:null,X:null,y:Lr,Y:Hr,Z:Or,"%":Yr},I={a:o,A:u,b:a,B:s,c:c,d:rr,e:rr,H:or,I:or,j:ir,L:sr,m:er,M:ur,p:i,S:ar,U:Ge,w:Je,W:Qe,x:l,X:h,y:tr,Y:Ke,Z:nr,"%":cr};return z.x=n(b,z),z.X=n(A,z),z.c=n(M,z),j.x=n(b,j),j.X=n(A,j),j.c=n(M,j),{format:function(t){var e=n(t+="",z);return e.toString=function(){return t},e}, +parse:function(t){var n=e(t+="",Ie);return n.toString=function(){return t},n},utcFormat:function(t){var e=n(t+="",j);return e.toString=function(){return t},e},utcParse:function(t){var n=e(t,$e);return n.toString=function(){return t},n}}}function Be(t,n,e){var r=t<0?"-":"",i=(r?-t:t)+"",o=i.length;return r+(o68?1900:2e3),e+r[0].length):-1}function nr(t,n,e){var r=/^(Z)|([+-]\d\d)(?:\:?(\d\d))?/.exec(n.slice(e,e+6));return r?(t.Z=r[1]?0:-(r[2]+(r[3]||"00")),e+r[0].length):-1}function er(t,n,e){var r=Ec.exec(n.slice(e,e+2));return r?(t.m=r[0]-1,e+r[0].length):-1}function rr(t,n,e){var r=Ec.exec(n.slice(e,e+2));return r?(t.d=+r[0],e+r[0].length):-1}function ir(t,n,e){var r=Ec.exec(n.slice(e,e+3));return r?(t.m=0,t.d=+r[0],e+r[0].length):-1}function or(t,n,e){var r=Ec.exec(n.slice(e,e+2));return r?(t.H=+r[0],e+r[0].length):-1}function ur(t,n,e){var r=Ec.exec(n.slice(e,e+2));return r?(t.M=+r[0],e+r[0].length):-1}function ar(t,n,e){var r=Ec.exec(n.slice(e,e+2));return r?(t.S=+r[0],e+r[0].length):-1}function sr(t,n,e){var r=Ec.exec(n.slice(e,e+3));return r?(t.L=+r[0],e+r[0].length):-1}function cr(t,n,e){var r=Uc.exec(n.slice(e,e+1));return r?e+r[0].length:-1}function lr(t,n){return Be(t.getDate(),n,2)}function hr(t,n){return Be(t.getHours(),n,2)}function fr(t,n){return Be(t.getHours()%12||12,n,2)}function pr(t,n){return Be(1+gc.count(mc(t),t),n,3)}function dr(t,n){return Be(t.getMilliseconds(),n,3)}function _r(t,n){return Be(t.getMonth()+1,n,2)}function gr(t,n){return Be(t.getMinutes(),n,2)}function vr(t,n){return Be(t.getSeconds(),n,2)}function yr(t,n){return Be(vc.count(mc(t),t),n,2)}function mr(t){return t.getDay()}function wr(t,n){return Be(yc.count(mc(t),t),n,2)}function xr(t,n){return Be(t.getFullYear()%100,n,2)}function Mr(t,n){return Be(t.getFullYear()%1e4,n,4)}function br(t){var n=t.getTimezoneOffset();return(n>0?"-":(n*=-1,"+"))+Be(n/60|0,"0",2)+Be(n%60,"0",2)}function Ar(t,n){return Be(t.getUTCDate(),n,2)}function Tr(t,n){return Be(t.getUTCHours(),n,2)}function Nr(t,n){return Be(t.getUTCHours()%12||12,n,2)}function Cr(t,n){return Be(1+wc.count(bc(t),t),n,3)}function kr(t,n){return Be(t.getUTCMilliseconds(),n,3)}function Sr(t,n){return Be(t.getUTCMonth()+1,n,2)}function Er(t,n){return Be(t.getUTCMinutes(),n,2)}function Ur(t,n){return Be(t.getUTCSeconds(),n,2)}function Dr(t,n){return Be(xc.count(bc(t),t),n,2)}function Pr(t){return t.getUTCDay()}function Fr(t,n){return Be(Mc.count(bc(t),t),n,2)}function Lr(t,n){return Be(t.getUTCFullYear()%100,n,2)}function Hr(t,n){return Be(t.getUTCFullYear()%1e4,n,4)}function Or(){return"+0000"}function Yr(){return"%"}function qr(t){return t.toISOString()}function zr(t){var n=new Date(t);return isNaN(n)?null:n}function jr(t){return function(){var n=this.ownerDocument,e=this.namespaceURI;return e===Fc&&n.documentElement.namespaceURI===Fc?n.createElement(t):n.createElementNS(e,t)}}function Ir(t){return function(){return this.ownerDocument.createElementNS(t.space,t.local)}}function $r(t,n,e){return t=Xr(t,n,e),function(n){var e=n.relatedTarget;e&&(e===this||8&e.compareDocumentPosition(this))||t.call(this,n)}}function Xr(t,n,e){return function(r){var i=$c;$c=r;try{t.call(this,this.__data__,n,e)}finally{$c=i}}}function Rr(t){return t.trim().split(/^|\s+/).map(function(t){var n="",e=t.indexOf(".");return e>=0&&(n=t.slice(e+1),t=t.slice(0,e)),{type:t,name:n}})}function Br(t){return function(){var n=this.__on;if(n){for(var e,r=0,i=-1,o=n.length;rn?1:t>=n?0:NaN}function ti(t){return function(){this.removeAttribute(t)}}function ni(t){return function(){this.removeAttributeNS(t.space,t.local)}}function ei(t,n){return function(){this.setAttribute(t,n)}}function ri(t,n){return function(){this.setAttributeNS(t.space,t.local,n)}}function ii(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}}function oi(t,n){return function(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}}function ui(t){return function(){this.style.removeProperty(t)}}function ai(t,n,e){return function(){this.style.setProperty(t,n,e)}}function si(t,n,e){return function(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}}function ci(t){return function(){delete this[t]}}function li(t,n){return function(){this[t]=n}}function hi(t,n){return function(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}}function fi(t){return t.trim().split(/^|\s+/)}function pi(t){return t.classList||new di(t)}function di(t){this._node=t,this._names=fi(t.getAttribute("class")||"")}function _i(t,n){for(var e=pi(t),r=-1,i=n.length;++rn?1:t>=n?0:NaN},Bi=function(t){return 1===t.length&&(t=n(t)),{left:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r>>1;t(n[o],e)<0?r=o+1:i=o}return r},right:function(n,e,r,i){for(null==r&&(r=0),null==i&&(i=n.length);r>>1;t(n[o],e)>0?i=o:r=o+1}return r}}}(Ri),Vi=Bi.right,Zi=function(t,n,e){t=+t,n=+n,e=(i=arguments.length)<2?(n=t,t=0,1):i<3?1:+e;for(var r=-1,i=0|Math.max(0,Math.ceil((n-t)/e)),o=new Array(i);++r0)for(t=Math.ceil(t/u),n=Math.floor(n/u),o=new Array(i=Math.ceil(n-t+1));++s0)for(var e,r,i=new Array(e),o=0;o=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),so.hasOwnProperty(n)?{space:so[n],local:t}:t},lo=function(t){var n=co(t);return(n.local?y:v)(n)},ho=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var fo=document.documentElement;if(!fo.matches){var po=fo.webkitMatchesSelector||fo.msMatchesSelector||fo.mozMatchesSelector||fo.oMatchesSelector;ho=function(t){return function(){return po.call(this,t)}}}}var _o=ho,go={},vo=null;if("undefined"!=typeof document){"onmouseenter"in document.documentElement||(go={mouseenter:"mouseover",mouseleave:"mouseout"})}var yo=function(t,n,e){var r,i,o=x(t+""),u=o.length;{if(!(arguments.length<2)){for(a=n?b:M,null==e&&(e=!1),r=0;r=w&&(w=m+1);!(y=g[w])&&++w=0;)(r=i[o])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this},Do=function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=S);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?H:"function"==typeof n?Y:O)(t,n,null==e?"":e)):zo(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)},Io=function(t,n){return arguments.length>1?this.each((null==n?q:"function"==typeof n?j:z)(t,n)):this.node()[t]};X.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var $o=function(t,n){var e=I(t+"");if(arguments.length<2){for(var r=$(this.node()),i=-1,o=e.length;++i=240?t-240:t+120,i,r),bt(t,i,r),bt(t<120?t+240:t-120,i,r),this.opacity)},displayable:function(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1}}));var pu=Math.PI/180,du=180/Math.PI,_u=.95047,gu=1,vu=1.08883,yu=4/29,mu=6/29,wu=3*mu*mu,xu=mu*mu*mu;tu(Nt,Tt,ht(ft,{brighter:function(t){return new Nt(this.l+18*(null==t?1:t),this.a,this.b,this.opacity)},darker:function(t){return new Nt(this.l-18*(null==t?1:t),this.a,this.b,this.opacity)},rgb:function(){var t=(this.l+16)/116,n=isNaN(this.a)?t:t+this.a/500,e=isNaN(this.b)?t:t-this.b/200;return t=gu*kt(t),n=_u*kt(n),e=vu*kt(e),new yt(St(3.2404542*n-1.5371385*t-.4985314*e),St(-.969266*n+1.8760108*t+.041556*e),St(.0556434*n-.2040259*t+1.0572252*e),this.opacity)}})),tu(Pt,Dt,ht(ft,{brighter:function(t){return new Pt(this.h,this.c,this.l+18*(null==t?1:t),this.opacity)},darker:function(t){return new Pt(this.h,this.c,this.l-18*(null==t?1:t),this.opacity)},rgb:function(){return At(this).rgb()}}));var Mu=-.14861,bu=1.78277,Au=-.29227,Tu=-.90649,Nu=1.97294,Cu=Nu*Tu,ku=Nu*bu,Su=bu*Au-Tu*Mu;tu(Ht,Lt,ht(ft,{brighter:function(t){return t=null==t?1/.7:Math.pow(1/.7,t),new Ht(this.h,this.s,this.l*t,this.opacity)},darker:function(t){return t=null==t?.7:Math.pow(.7,t),new Ht(this.h,this.s,this.l*t,this.opacity)},rgb:function(){var t=isNaN(this.h)?0:(this.h+120)*pu,n=+this.l,e=isNaN(this.s)?0:this.s*n*(1-n),r=Math.cos(t),i=Math.sin(t);return new yt(255*(n+e*(Mu*r+bu*i)),255*(n+e*(Au*r+Tu*i)),255*(n+e*(Nu*r)),this.opacity)}}));var Eu,Uu,Du,Pu,Fu=function(t){return function(){return t}},Lu=function t(n){function e(t,n){var e=r((t=vt(t)).r,(n=vt(n)).r),i=r(t.g,n.g),o=r(t.b,n.b),u=jt(t.opacity,n.opacity);return function(n){return t.r=e(n),t.g=i(n),t.b=o(n),t.opacity=u(n),t+""}}var r=zt(n);return e.gamma=t,e}(1),Hu=function(t,n){var e,r=n?n.length:0,i=t?Math.min(r,t.length):0,o=new Array(r),u=new Array(r);for(e=0;eo&&(i=n.slice(o,i),a[u]?a[u]+=i:a[++u]=i),(e=e[0])===(r=r[0])?a[u]?a[u]+=r:a[++u]=r:(a[++u]=null,s.push({i:u,x:Yu(e,r)})),o=ju.lastIndex;return opa&&e.state1e-6)if(Math.abs(l*a-s*c)>1e-6&&i){var f=e-o,p=r-u,d=a*a+s*s,_=f*f+p*p,g=Math.sqrt(d),v=Math.sqrt(h),y=i*Math.tan((Ra-Math.acos((d+h-_)/(2*g*v)))/2),m=y/v,w=y/g;Math.abs(m-1)>1e-6&&(this._+="L"+(t+m*c)+","+(n+m*l)),this._+="A"+i+","+i+",0,0,"+ +(l*f>c*p)+","+(this._x1=t+w*a)+","+(this._y1=n+w*s)}else this._+="L"+(this._x1=t)+","+(this._y1=n);else;},arc:function(t,n,e,r,i,o){t=+t,n=+n,e=+e;var u=e*Math.cos(r),a=e*Math.sin(r),s=t+u,c=n+a,l=1^o,h=o?r-i:i-r;if(e<0)throw new Error("negative radius: "+e);null===this._x1?this._+="M"+s+","+c:(Math.abs(this._x1-s)>1e-6||Math.abs(this._y1-c)>1e-6)&&(this._+="L"+s+","+c),e&&(h<0&&(h=h%Ba+Ba),h>Va?this._+="A"+e+","+e+",0,1,"+l+","+(t-u)+","+(n-a)+"A"+e+","+e+",0,1,"+l+","+(this._x1=s)+","+(this._y1=c):h>1e-6&&(this._+="A"+e+","+e+",0,"+ +(h>=Ra)+","+l+","+(this._x1=t+e*Math.cos(i))+","+(this._y1=n+e*Math.sin(i))))},rect:function(t,n,e,r){this._+="M"+(this._x0=this._x1=+t)+","+(this._y0=this._y1=+n)+"h"+ +e+"v"+ +r+"h"+-e+"Z"},toString:function(){return this._}};In.prototype=$n.prototype={constructor:In,has:function(t){return"$"+t in this},get:function(t){return this["$"+t]},set:function(t,n){return this["$"+t]=n,this},remove:function(t){var n="$"+t;return n in this&&delete this[n]},clear:function(){for(var t in this)"$"===t[0]&&delete this[t]},keys:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(n.slice(1));return t},values:function(){var t=[];for(var n in this)"$"===n[0]&&t.push(this[n]);return t},entries:function(){var t=[];for(var n in this)"$"===n[0]&&t.push({key:n.slice(1),value:this[n]});return t},size:function(){var t=0;for(var n in this)"$"===n[0]&&++t;return t},empty:function(){for(var t in this)if("$"===t[0])return!1;return!0},each:function(t){for(var n in this)"$"===n[0]&&t(this[n],n.slice(1),this)}};var Za=$n.prototype;Xn.prototype=Rn.prototype={constructor:Xn,has:Za.has,add:function(t){return t+="",this["$"+t]=t,this},remove:Za.remove,clear:Za.clear,values:Za.keys,size:Za.size,empty:Za.empty,each:Za.each};var Wa=function(t){function n(t,n){var r,i,o=e(t,function(t,e){if(r)return r(t,e-1);i=t,r=n?Vn(t,n):Bn(t)});return o.columns=i,o}function e(t,n){function e(){if(l>=c)return u;if(i)return i=!1,o;var n,e=l;if(34===t.charCodeAt(e)){for(var r=e;r++t||t>i||r>n||n>o))return this;var u,a,s=i-e,c=this._root;switch(a=(n<(r+o)/2)<<1|t<(e+i)/2){case 0:do{u=new Array(4),u[a]=c,c=u}while(s*=2,i=e+s,o=r+s,t>i||n>o);break;case 1:do{u=new Array(4),u[a]=c,c=u}while(s*=2,e=i-s,o=r+s,e>t||n>o);break;case 2:do{u=new Array(4),u[a]=c,c=u}while(s*=2,i=e+s,r=o-s,t>i||r>n);break;case 3:do{u=new Array(4),u[a]=c,c=u}while(s*=2,e=i-s,r=o-s,e>t||r>n)}this._root&&this._root.length&&(this._root=c)}return this._x0=e,this._y0=r,this._x1=i,this._y1=o,this},es=function(){var t=[];return this.visit(function(n){if(!n.length)do{t.push(n.data)}while(n=n.next)}),t},rs=function(t){return arguments.length?this.cover(+t[0][0],+t[0][1]).cover(+t[1][0],+t[1][1]):isNaN(this._x0)?void 0:[[this._x0,this._y0],[this._x1,this._y1]]},is=function(t,n,e,r,i){this.node=t,this.x0=n,this.y0=e,this.x1=r,this.y1=i},os=function(t,n,e){var r,i,o,u,a,s,c,l=this._x0,h=this._y0,f=this._x1,p=this._y1,d=[],_=this._root;for(_&&d.push(new is(_,l,h,f,p)),null==e?e=1/0:(l=t-e,h=n-e,f=t+e,p=n+e,e*=e);s=d.pop();)if(!(!(_=s.node)||(i=s.x0)>f||(o=s.y0)>p||(u=s.x1)=v)<<1|t>=g)&&(s=d[d.length-1],d[d.length-1]=d[d.length-1-c],d[d.length-1-c]=s)}else{var y=t-+this._x.call(null,_.data),m=n-+this._y.call(null,_.data),w=y*y+m*m;if(w=(a=(d+g)/2))?d=a:g=a,(l=u>=(s=(_+v)/2))?_=s:v=s,n=p,!(p=p[h=l<<1|c]))return this;if(!p.length)break;(n[h+1&3]||n[h+2&3]||n[h+3&3])&&(e=n,f=h)}for(;p.data!==t;)if(r=p,!(p=p.next))return this;return(i=p.next)&&delete p.next,r?(i?r.next=i:delete r.next,this):n?(i?n[h]=i:delete n[h],(p=n[0]||n[1]||n[2]||n[3])&&p===(n[3]||n[2]||n[1]||n[0])&&!p.length&&(e?e[f]=p:this._root=p),this):(this._root=i,this)},as=function(){return this._root},ss=function(){var t=0;return this.visit(function(n){if(!n.length)do{++t}while(n=n.next)}),t},cs=function(t){var n,e,r,i,o,u,a=[],s=this._root;for(s&&a.push(new is(s,this._x0,this._y0,this._x1,this._y1));n=a.pop();)if(!t(s=n.node,r=n.x0,i=n.y0,o=n.x1,u=n.y1)&&s.length){var c=(r+o)/2,l=(i+u)/2;(e=s[3])&&a.push(new is(e,c,l,o,u)),(e=s[2])&&a.push(new is(e,r,l,c,u)),(e=s[1])&&a.push(new is(e,c,i,o,l)),(e=s[0])&&a.push(new is(e,r,i,c,l))}return this},ls=function(t){var n,e=[],r=[];for(this._root&&e.push(new is(this._root,this._x0,this._y0,this._x1,this._y1));n=e.pop();){var i=n.node;if(i.length){var o,u=n.x0,a=n.y0,s=n.x1,c=n.y1,l=(u+s)/2,h=(a+c)/2;(o=i[0])&&e.push(new is(o,u,a,l,h)),(o=i[1])&&e.push(new is(o,l,a,s,h)),(o=i[2])&&e.push(new is(o,u,h,l,c)),(o=i[3])&&e.push(new is(o,l,h,s,c))}r.push(n)}for(;n=r.pop();)t(n.node,n.x0,n.y0,n.x1,n.y1);return this},hs=function(t){return arguments.length?(this._x=t,this):this._x},fs=function(t){return arguments.length?(this._y=t,this):this._y},ps=te.prototype=ne.prototype;ps.copy=function(){var t,n,e=new ne(this._x,this._y,this._x0,this._y0,this._x1,this._y1),r=this._root;if(!r)return e;if(!r.length)return e._root=ee(r),e;for(t=[{source:r,target:e._root=new Array(4)}];r=t.pop();)for(var i=0;i<4;++i)(n=r.source[i])&&(n.length?t.push({source:n,target:r.target[i]=new Array(4)}):r.target[i]=ee(n));return e},ps.add=ts,ps.addAll=Jn,ps.cover=ns,ps.data=es,ps.extent=rs,ps.find=os,ps.remove=us,ps.removeAll=Gn,ps.root=as,ps.size=ss,ps.visit=cs,ps.visitAfter=ls,ps.x=hs,ps.y=fs;var ds,_s=function(t,n){if((e=(t=n?t.toExponential(n-1):t.toExponential()).indexOf("e"))<0)return null;var e,r=t.slice(0,e);return[r.length>1?r[0]+r.slice(2):r,+t.slice(e+1)]},gs=function(t){return t=_s(Math.abs(t)),t?t[1]:NaN},vs=function(t,n){return function(e,r){for(var i=e.length,o=[],u=0,a=t[0],s=0;i>0&&a>0&&(s+a+1>r&&(a=Math.max(1,r-s)),o.push(e.substring(i-=a,i+a)),!((s+=a+1)>r));)a=t[u=(u+1)%t.length];return o.reverse().join(n)}},ys=function(t){return function(n){return n.replace(/[0-9]/g,function(n){return t[+n]})}},ms=function(t,n){t=t.toPrecision(n);t:for(var e,r=t.length,i=1,o=-1;i0&&(o=0)}return o>0?t.slice(0,o)+t.slice(e+1):t},ws=function(t,n){var e=_s(t,n);if(!e)return t+"";var r=e[0],i=e[1],o=i-(ds=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,u=r.length;return o===u?r:o>u?r+new Array(o-u+1).join("0"):o>0?r.slice(0,o)+"."+r.slice(o):"0."+new Array(1-o).join("0")+_s(t,Math.max(0,n+o-1))[0]},xs=function(t,n){var e=_s(t,n);if(!e)return t+"";var r=e[0],i=e[1];return i<0?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")},Ms={"":ms,"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return xs(100*t,n)},r:xs,s:ws,X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},bs=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;re.prototype=ie.prototype,ie.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+this.type};var As,Ts,Ns,Cs=function(t){return t},ks=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],Ss=function(t){function n(t){function n(t){var n,i,a,l=g,w=v;if("c"===_)w=y(t)+w,t="";else{t=+t;var x=t<0;if(t=y(Math.abs(t),d),x&&0==+t&&(x=!1),l=(x?"("===c?c:"-":"-"===c||"("===c?"":c)+l,w=w+("s"===_?ks[8+ds/3]:"")+(x&&"("===c?")":""),m)for(n=-1,i=t.length;++n(a=t.charCodeAt(n))||a>57){w=(46===a?o+t.slice(n+1):t.slice(n))+w,t=t.slice(0,n);break}}p&&!h&&(t=r(t,1/0));var M=l.length+t.length+w.length,b=M>1)+l+t+w+b.slice(M);break;default:t=b+l+t+w}return u(t)}t=re(t);var e=t.fill,s=t.align,c=t.sign,l=t.symbol,h=t.zero,f=t.width,p=t.comma,d=t.precision,_=t.type,g="$"===l?i[0]:"#"===l&&/[boxX]/.test(_)?"0"+_.toLowerCase():"",v="$"===l?i[1]:/[%p]/.test(_)?a:"",y=Ms[_],m=!_||/[defgprs%]/.test(_);return d=null==d?_?6:12:/[gprs]/.test(_)?Math.max(1,Math.min(21,d)):Math.max(0,Math.min(20,d)),n.toString=function(){return t+""},n}function e(t,e){var r=n((t=re(t),t.type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(gs(e)/3))),o=Math.pow(10,-i),u=ks[8+i/3];return function(t){return r(o*t)+u}}var r=t.grouping&&t.thousands?vs(t.grouping,t.thousands):Cs,i=t.currency,o=t.decimal,u=t.numerals?ys(t.numerals):Cs,a=t.percent||"%";return{format:n,formatPrefix:e}};!function(t){As=Ss(t),Ts=As.format,Ns=As.formatPrefix}({decimal:".",thousands:",",grouping:[3],currency:["$",""]});var Es=function(t){return Math.max(0,-gs(Math.abs(t)))},Us=function(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(gs(n)/3)))-gs(Math.abs(t)))},Ds=function(t,n){return t=Math.abs(t),n=Math.abs(n)-t,Math.max(0,gs(n)-gs(t))+1},Ps=function(){return new oe};oe.prototype={constructor:oe,reset:function(){this.s=this.t=0},add:function(t){ue(Fs,t,this.t),ue(this,Fs.s,this.s),this.s?this.t+=Fs.t:this.s=Fs.t},valueOf:function(){return this.s}};var Fs=new oe,Ls=Math.PI,Hs=Ls/2,Os=Ls/180,Ys=(Math.abs,Math.atan,Math.atan2),qs=Math.cos,zs=Math.sin,js=Math.sqrt;Ps(),Ps(),Ps(),Ps(),Ps(),Ps(),Ps(),Ps();qs(30*Os);ce(function(t){return js(2/(1+t))}).invert=le(function(t){return 2*se(t/2)}),ce(function(t){return(t=ae(t))&&t/zs(t)}).invert=le(function(t){return t});var Is=function(){return this.eachAfter(he)},$s=function(t){var n,e,r,i,o=this,u=[o];do{for(n=u.reverse(),u=[];o=n.pop();)if(t(o),e=o.children)for(r=0,i=e.length;r=0;--e)i.push(n[e]);return this},Rs=function(t){for(var n,e,r,i=this,o=[i],u=[];i=o.pop();)if(u.push(i),n=i.children)for(e=0,r=n.length;e=0;)e+=r[i].value;n.value=e})},Vs=function(t){return this.eachBefore(function(n){n.children&&n.children.sort(t)})},Zs=function(t){for(var n=this,e=fe(n,t),r=[n];n!==e;)n=n.parent,r.push(n);for(var i=r.length;t!==e;)r.splice(i,0,t),t=t.parent;return r},Ws=function(){for(var t=this,n=[t];t=t.parent;)n.push(t);return n},Js=function(){var t=[];return this.each(function(n){t.push(n)}),t},Gs=function(){var t=[];return this.eachBefore(function(n){n.children||t.push(n)}),t},Qs=function(){var t=this,n=[];return t.each(function(e){e!==t&&n.push({source:e.parent,target:e})}),n};ye.prototype=pe.prototype={constructor:ye,count:Is,each:$s,eachAfter:Rs,eachBefore:Xs,sum:Bs,sort:Vs,path:Zs,ancestors:Ws,descendants:Js,leaves:Gs,links:Qs,copy:de};me.prototype=Object.create(ye.prototype);var Ks={},tc=function(t,n){function e(t){var n,e=c.status;if(!e&&Ne(c)||e>=200&&e<300||304===e){if(o)try{n=o.call(r,c)}catch(t){return void a.call("error",r,t)}else n=c;a.call("load",r,n)}else a.call("error",r,t)}var r,i,o,u,a=f("beforesend","progress","load","error"),s=$n(),c=new XMLHttpRequest,l=null,h=null,p=0;if("undefined"==typeof XDomainRequest||"withCredentials"in c||!/^(http(s)?:)?\/\//.test(t)||(c=new XDomainRequest),"onload"in c?c.onload=c.onerror=c.ontimeout=e:c.onreadystatechange=function(t){c.readyState>3&&e(t)},c.onprogress=function(t){a.call("progress",r,t)},r={header:function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?s.get(t):(null==n?s.remove(t):s.set(t,n+""),r)},mimeType:function(t){return arguments.length?(i=null==t?null:t+"",r):i},responseType:function(t){return arguments.length?(u=t,r):u},timeout:function(t){return arguments.length?(p=+t,r):p},user:function(t){return arguments.length<1?l:(l=null==t?null:t+"",r)},password:function(t){return arguments.length<1?h:(h=null==t?null:t+"",r)},response:function(t){return o=t,r},get:function(t,n){return r.send("GET",t,n)},post:function(t,n){return r.send("POST",t,n)},send:function(n,e,o){return c.open(n,t,!0,l,h),null==i||s.has("accept")||s.set("accept",i+",*/*"),c.setRequestHeader&&s.each(function(t,n){c.setRequestHeader(n,t)}),null!=i&&c.overrideMimeType&&c.overrideMimeType(i),null!=u&&(c.responseType=u),p>0&&(c.timeout=p),null==o&&"function"==typeof e&&(o=e,e=null),null!=o&&1===o.length&&(o=Te(o)),null!=o&&r.on("error",o).on("load",function(t){o(null,t)}),a.call("beforesend",r,c),c.send(null==e?null:e),r},abort:function(){return c.abort(),r},on:function(){var t=a.on.apply(a,arguments);return t===a?r:t}},null!=n){if("function"!=typeof n)throw new Error("invalid callback: "+n);return r.get(n)}return r},nc=function(t,n){return function(e,r){var i=tc(e).mimeType(t).response(n);if(null!=r){if("function"!=typeof r)throw new Error("invalid callback: "+r);return i.get(r)}return i}};nc("text/html",function(t){return document.createRange().createContextualFragment(t.responseText)}),nc("application/json",function(t){return JSON.parse(t.responseText)}),nc("text/plain",function(t){return t.responseText}),nc("application/xml",function(t){var n=t.responseXML;if(!n)throw new Error("parse error");return n});var ec=function(t,n){return function(e,r,i){arguments.length<3&&(i=r,r=null);var o=tc(e).mimeType(t);return o.row=function(t){return arguments.length?o.response(Ce(n,r=t)):r},o.row(r),i?o.get(i):o}};ec("text/csv",Ga),ec("text/tab-separated-values",Ka);var rc=Array.prototype,ic=rc.map,oc=rc.slice,uc={name:"implicit"},ac=function(t){return function(){return t}},sc=function(t){return+t},cc=[0,1],lc=function(t,n,e){var i,o=t[0],u=t[t.length-1],a=r(o,u,null==n?10:n);switch(e=re(null==e?",f":e),e.type){case"s":var s=Math.max(Math.abs(o),Math.abs(u));return null!=e.precision||isNaN(i=Us(a,s))||(e.precision=i),Ns(e,s);case"":case"e":case"g":case"p":case"r":null!=e.precision||isNaN(i=Ds(a,Math.max(Math.abs(o),Math.abs(u))))||(e.precision=i-("e"===e.type));break;case"f":case"%":null!=e.precision||isNaN(i=Es(a))||(e.precision=i-2*("%"===e.type))}return Ts(e)},hc=new Date,fc=new Date,pc=qe(function(){},function(t,n){t.setTime(+t+n)},function(t,n){return n-t});pc.every=function(t){return t=Math.floor(t),isFinite(t)&&t>0?t>1?qe(function(n){n.setTime(Math.floor(n/t)*t)},function(n,e){n.setTime(+n+e*t)},function(n,e){return(e-n)/t}):pc:null};var dc=6e4,_c=6048e5,gc=(qe(function(t){t.setTime(1e3*Math.floor(t/1e3))},function(t,n){t.setTime(+t+1e3*n)},function(t,n){return(n-t)/1e3},function(t){return t.getUTCSeconds()}),qe(function(t){t.setTime(Math.floor(t/dc)*dc)},function(t,n){t.setTime(+t+n*dc)},function(t,n){return(n-t)/dc},function(t){return t.getMinutes()}),qe(function(t){var n=t.getTimezoneOffset()*dc%36e5;n<0&&(n+=36e5),t.setTime(36e5*Math.floor((+t-n)/36e5)+n)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getHours()}),qe(function(t){t.setHours(0,0,0,0)},function(t,n){t.setDate(t.getDate()+n)},function(t,n){return(n-t-(n.getTimezoneOffset()-t.getTimezoneOffset())*dc)/864e5},function(t){return t.getDate()-1})),vc=ze(0),yc=ze(1),mc=(ze(2),ze(3),ze(4),ze(5),ze(6),qe(function(t){t.setDate(1),t.setHours(0,0,0,0)},function(t,n){t.setMonth(t.getMonth()+n)},function(t,n){return n.getMonth()-t.getMonth()+12*(n.getFullYear()-t.getFullYear())},function(t){return t.getMonth()}),qe(function(t){t.setMonth(0,1),t.setHours(0,0,0,0)},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t,n){return n.getFullYear()-t.getFullYear()},function(t){return t.getFullYear()}));mc.every=function(t){return isFinite(t=Math.floor(t))&&t>0?qe(function(n){n.setFullYear(Math.floor(n.getFullYear()/t)*t),n.setMonth(0,1),n.setHours(0,0,0,0)},function(n,e){n.setFullYear(n.getFullYear()+e*t)}):null};var wc=(qe(function(t){t.setUTCSeconds(0,0)},function(t,n){t.setTime(+t+n*dc)},function(t,n){return(n-t)/dc},function(t){return t.getUTCMinutes()}),qe(function(t){t.setUTCMinutes(0,0,0)},function(t,n){t.setTime(+t+36e5*n)},function(t,n){return(n-t)/36e5},function(t){return t.getUTCHours()}),qe(function(t){t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCDate(t.getUTCDate()+n)},function(t,n){return(n-t)/864e5},function(t){return t.getUTCDate()-1})),xc=je(0),Mc=je(1),bc=(je(2),je(3),je(4),je(5),je(6),qe(function(t){t.setUTCDate(1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCMonth(t.getUTCMonth()+n)},function(t,n){return n.getUTCMonth()-t.getUTCMonth()+12*(n.getUTCFullYear()-t.getUTCFullYear())},function(t){return t.getUTCMonth()}),qe(function(t){t.setUTCMonth(0,1),t.setUTCHours(0,0,0,0)},function(t,n){t.setUTCFullYear(t.getUTCFullYear()+n)},function(t,n){return n.getUTCFullYear()-t.getUTCFullYear()},function(t){return t.getUTCFullYear()}));bc.every=function(t){return isFinite(t=Math.floor(t))&&t>0?qe(function(n){n.setUTCFullYear(Math.floor(n.getUTCFullYear()/t)*t),n.setUTCMonth(0,1),n.setUTCHours(0,0,0,0)},function(n,e){n.setUTCFullYear(n.getUTCFullYear()+e*t)}):null};var Ac,Tc,Nc,Cc,kc,Sc={"-":"",_:" ",0:"0"},Ec=/^\s*\d+/,Uc=/^%/,Dc=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;!function(t){Ac=Re(t),Tc=Ac.format,Nc=Ac.parse,Cc=Ac.utcFormat,kc=Ac.utcParse}({dateTime:"%x, %X",date:"%-m/%-d/%Y",time:"%-I:%M:%S %p",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"]});var Pc=(Date.prototype.toISOString||Cc("%Y-%m-%dT%H:%M:%S.%LZ"),+new Date("2000-01-01T00:00:00.000Z")||kc("%Y-%m-%dT%H:%M:%S.%LZ"),function(t){return t.match(/.{6}/g).map(function(t){return"#"+t})});Pc("1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf"),Pc("393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6"),Pc("3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9"),Pc("1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5"),Qu(Lt(300,.5,0),Lt(-240,.5,1));var Fc=(Qu(Lt(-100,.75,.35),Lt(80,1.5,.8)),Qu(Lt(260,.75,.35),Lt(80,1.5,.8)),Lt(),"http://www.w3.org/1999/xhtml"),Lc={svg:"http://www.w3.org/2000/svg",xhtml:Fc,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},Hc=function(t){var n=t+="",e=n.indexOf(":");return e>=0&&"xmlns"!==(n=t.slice(0,e))&&(t=t.slice(e+1)),Lc.hasOwnProperty(n)?{space:Lc[n],local:t}:t},Oc=function(t){var n=Hc(t);return(n.local?Ir:jr)(n)},Yc=function(t){return function(){return this.matches(t)}};if("undefined"!=typeof document){var qc=document.documentElement;if(!qc.matches){var zc=qc.webkitMatchesSelector||qc.msMatchesSelector||qc.mozMatchesSelector||qc.oMatchesSelector;Yc=function(t){return function(){return zc.call(this,t)}}}}var jc=Yc,Ic={},$c=null;if("undefined"!=typeof document){"onmouseenter"in document.documentElement||(Ic={mouseenter:"mouseover",mouseleave:"mouseout"})}var Xc=function(t,n,e){var r,i,o=Rr(t+""),u=o.length;{if(!(arguments.length<2)){for(a=n?Vr:Br,null==e&&(e=!1),r=0;r=w&&(w=m+1);!(y=g[w])&&++w=0;)(r=i[o])&&(u&&u!==r.nextSibling&&u.parentNode.insertBefore(r,u),u=r);return this},il=function(t){function n(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}t||(t=Kr);for(var e=this._groups,r=e.length,i=new Array(r),o=0;o1?this.each((null==n?ui:"function"==typeof n?si:ai)(t,n,null==e?"":e)):fl(r=this.node()).getComputedStyle(r,null).getPropertyValue(t)},dl=function(t,n){return arguments.length>1?this.each((null==n?ci:"function"==typeof n?hi:li)(t,n)):this.node()[t]};di.prototype={add:function(t){this._names.indexOf(t)<0&&(this._names.push(t),this._node.setAttribute("class",this._names.join(" ")))},remove:function(t){var n=this._names.indexOf(t);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(t){return this._names.indexOf(t)>=0}};var _l=function(t,n){var e=fi(t+"");if(arguments.length<2){for(var r=pi(this.node()),i=-1,o=e.length;++i