From e792de9ae52d956d18582cac8a49ea6a03c7e010 Mon Sep 17 00:00:00 2001 From: archmoj Date: Wed, 13 Jan 2021 23:31:33 -0500 Subject: [PATCH 1/2] drop d3.v3/geo src and tests --- d3.js | 2010 +----------------------- d3.min.js | 9 +- src/d3.js | 1 - src/geo/albers-usa.js | 129 -- src/geo/albers.js | 11 - src/geo/area.js | 69 - src/geo/azimuthal-equal-area.js | 12 - src/geo/azimuthal-equidistant.js | 13 - src/geo/azimuthal.js | 25 - src/geo/bounds.js | 168 -- src/geo/cartesian.js | 47 - src/geo/centroid.js | 149 -- src/geo/circle.js | 81 - src/geo/clip-antimeridian.js | 95 -- src/geo/clip-circle.js | 178 --- src/geo/clip-extent.js | 196 --- src/geo/clip-polygon.js | 104 -- src/geo/clip.js | 149 -- src/geo/compose.js | 12 - src/geo/conic-conformal.js | 39 - src/geo/conic-equal-area.js | 33 - src/geo/conic-equidistant.js | 36 - src/geo/conic.js | 16 - src/geo/distance.js | 13 - src/geo/equirectangular.js | 10 - src/geo/geo.js | 1 - src/geo/gnomonic.js | 12 - src/geo/graticule.js | 103 -- src/geo/greatArc.js | 42 - src/geo/index.js | 33 - src/geo/interpolate.js | 38 - src/geo/length.js | 44 - src/geo/mercator.js | 48 - src/geo/orthographic.js | 12 - src/geo/path-area.js | 41 - src/geo/path-bounds.js | 21 - src/geo/path-buffer.js | 59 - src/geo/path-centroid.js | 78 - src/geo/path-context.js | 49 - src/geo/path.js | 87 - src/geo/point-in-polygon.js | 71 - src/geo/projection.js | 121 -- src/geo/resample.js | 109 -- src/geo/rotation.js | 79 - src/geo/spherical.js | 13 - src/geo/stereographic.js | 12 - src/geo/stream.js | 71 - src/geo/transform.js | 36 - src/geo/transverse-mercator.js | 31 - test/geo/albers-test.js | 40 - test/geo/albers-usa-test.js | 33 - test/geo/area-benchmark.js | 12 - test/geo/area-test.js | 185 --- test/geo/azimuthal-equal-area-test.js | 38 - test/geo/azimuthal-equidistant-test.js | 38 - test/geo/bounds-test.js | 265 ---- test/geo/centroid-test.js | 187 --- test/geo/circle-test.js | 33 - test/geo/clip-extent-test.js | 163 -- test/geo/conic-conformal-test.js | 38 - test/geo/conic-equal-area-test.js | 38 - test/geo/conic-equidistant-test.js | 38 - test/geo/distance-test.js | 20 - test/geo/equirectangular-test.js | 38 - test/geo/gnomonic-test.js | 38 - test/geo/graticule-test.js | 188 --- test/geo/greatArc-test.js | 35 - test/geo/interpolate-test.js | 22 - test/geo/length-test.js | 44 - test/geo/mercator-test.js | 38 - test/geo/orthographic-test.js | 34 - test/geo/path-benchmark | 113 -- test/geo/path-test.js | 836 ---------- test/geo/point-in-polygon-mock.js | 18 - test/geo/point-in-polygon-test.js | 382 ----- test/geo/projection-test-suite.js | 29 - test/geo/projection-test.js | 58 - test/geo/rotation-test.js | 35 - test/geo/stereographic-test.js | 38 - test/geo/stream-test.js | 214 --- test/geo/transverse-mercator-test.js | 45 - 81 files changed, 67 insertions(+), 8082 deletions(-) delete mode 100644 src/geo/albers-usa.js delete mode 100644 src/geo/albers.js delete mode 100644 src/geo/area.js delete mode 100644 src/geo/azimuthal-equal-area.js delete mode 100644 src/geo/azimuthal-equidistant.js delete mode 100644 src/geo/azimuthal.js delete mode 100644 src/geo/bounds.js delete mode 100644 src/geo/cartesian.js delete mode 100644 src/geo/centroid.js delete mode 100644 src/geo/circle.js delete mode 100644 src/geo/clip-antimeridian.js delete mode 100644 src/geo/clip-circle.js delete mode 100644 src/geo/clip-extent.js delete mode 100644 src/geo/clip-polygon.js delete mode 100644 src/geo/clip.js delete mode 100644 src/geo/compose.js delete mode 100644 src/geo/conic-conformal.js delete mode 100644 src/geo/conic-equal-area.js delete mode 100644 src/geo/conic-equidistant.js delete mode 100644 src/geo/conic.js delete mode 100644 src/geo/distance.js delete mode 100644 src/geo/equirectangular.js delete mode 100644 src/geo/geo.js delete mode 100644 src/geo/gnomonic.js delete mode 100644 src/geo/graticule.js delete mode 100644 src/geo/greatArc.js delete mode 100644 src/geo/index.js delete mode 100644 src/geo/interpolate.js delete mode 100644 src/geo/length.js delete mode 100644 src/geo/mercator.js delete mode 100644 src/geo/orthographic.js delete mode 100644 src/geo/path-area.js delete mode 100644 src/geo/path-bounds.js delete mode 100644 src/geo/path-buffer.js delete mode 100644 src/geo/path-centroid.js delete mode 100644 src/geo/path-context.js delete mode 100644 src/geo/path.js delete mode 100644 src/geo/point-in-polygon.js delete mode 100644 src/geo/projection.js delete mode 100644 src/geo/resample.js delete mode 100644 src/geo/rotation.js delete mode 100644 src/geo/spherical.js delete mode 100644 src/geo/stereographic.js delete mode 100644 src/geo/stream.js delete mode 100644 src/geo/transform.js delete mode 100644 src/geo/transverse-mercator.js delete mode 100644 test/geo/albers-test.js delete mode 100644 test/geo/albers-usa-test.js delete mode 100644 test/geo/area-benchmark.js delete mode 100644 test/geo/area-test.js delete mode 100644 test/geo/azimuthal-equal-area-test.js delete mode 100644 test/geo/azimuthal-equidistant-test.js delete mode 100644 test/geo/bounds-test.js delete mode 100644 test/geo/centroid-test.js delete mode 100644 test/geo/circle-test.js delete mode 100644 test/geo/clip-extent-test.js delete mode 100644 test/geo/conic-conformal-test.js delete mode 100644 test/geo/conic-equal-area-test.js delete mode 100644 test/geo/conic-equidistant-test.js delete mode 100644 test/geo/distance-test.js delete mode 100644 test/geo/equirectangular-test.js delete mode 100644 test/geo/gnomonic-test.js delete mode 100644 test/geo/graticule-test.js delete mode 100644 test/geo/greatArc-test.js delete mode 100644 test/geo/interpolate-test.js delete mode 100644 test/geo/length-test.js delete mode 100644 test/geo/mercator-test.js delete mode 100644 test/geo/orthographic-test.js delete mode 100755 test/geo/path-benchmark delete mode 100644 test/geo/path-test.js delete mode 100644 test/geo/point-in-polygon-mock.js delete mode 100644 test/geo/point-in-polygon-test.js delete mode 100644 test/geo/projection-test-suite.js delete mode 100644 test/geo/projection-test.js delete mode 100644 test/geo/rotation-test.js delete mode 100644 test/geo/stereographic-test.js delete mode 100644 test/geo/stream-test.js delete mode 100644 test/geo/transverse-mercator-test.js diff --git a/d3.js b/d3.js index c7fc9d856dbc5f..afadca95a5c0c2 100644 --- a/d3.js +++ b/d3.js @@ -2852,1953 +2852,6 @@ shortMonths: [ "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ] }); d3.format = d3_locale_enUS.numberFormat; - d3.geo = {}; - function d3_adder() {} - d3_adder.prototype = { - s: 0, - t: 0, - add: function(y) { - d3_adderSum(y, this.t, d3_adderTemp); - d3_adderSum(d3_adderTemp.s, this.s, this); - if (this.s) this.t += d3_adderTemp.t; else this.s = d3_adderTemp.t; - }, - reset: function() { - this.s = this.t = 0; - }, - valueOf: function() { - return this.s; - } - }; - var d3_adderTemp = new d3_adder(); - function d3_adderSum(a, b, o) { - var x = o.s = a + b, bv = x - a, av = x - bv; - o.t = a - av + (b - bv); - } - d3.geo.stream = function(object, listener) { - if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { - d3_geo_streamObjectType[object.type](object, listener); - } else { - d3_geo_streamGeometry(object, listener); - } - }; - function d3_geo_streamGeometry(geometry, listener) { - if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { - d3_geo_streamGeometryType[geometry.type](geometry, listener); - } - } - var d3_geo_streamObjectType = { - Feature: function(feature, listener) { - d3_geo_streamGeometry(feature.geometry, listener); - }, - FeatureCollection: function(object, listener) { - var features = object.features, i = -1, n = features.length; - while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); - } - }; - var d3_geo_streamGeometryType = { - Sphere: function(object, listener) { - listener.sphere(); - }, - Point: function(object, listener) { - object = object.coordinates; - listener.point(object[0], object[1], object[2]); - }, - MultiPoint: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]); - }, - LineString: function(object, listener) { - d3_geo_streamLine(object.coordinates, listener, 0); - }, - MultiLineString: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); - }, - Polygon: function(object, listener) { - d3_geo_streamPolygon(object.coordinates, listener); - }, - MultiPolygon: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); - }, - GeometryCollection: function(object, listener) { - var geometries = object.geometries, i = -1, n = geometries.length; - while (++i < n) d3_geo_streamGeometry(geometries[i], listener); - } - }; - function d3_geo_streamLine(coordinates, listener, closed) { - var i = -1, n = coordinates.length - closed, coordinate; - listener.lineStart(); - while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]); - listener.lineEnd(); - } - function d3_geo_streamPolygon(coordinates, listener) { - var i = -1, n = coordinates.length; - listener.polygonStart(); - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); - listener.polygonEnd(); - } - d3.geo.area = function(object) { - d3_geo_areaSum = 0; - d3.geo.stream(object, d3_geo_area); - return d3_geo_areaSum; - }; - var d3_geo_areaSum, d3_geo_areaRingSum = new d3_adder(); - var d3_geo_area = { - sphere: function() { - d3_geo_areaSum += 4 * π; - }, - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: function() { - d3_geo_areaRingSum.reset(); - d3_geo_area.lineStart = d3_geo_areaRingStart; - }, - polygonEnd: function() { - var area = 2 * d3_geo_areaRingSum; - d3_geo_areaSum += area < 0 ? 4 * π + area : area; - d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; - } - }; - function d3_geo_areaRingStart() { - var λ00, φ00, λ0, cosφ0, sinφ0; - d3_geo_area.point = function(λ, φ) { - d3_geo_area.point = nextPoint; - λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), - sinφ0 = Math.sin(φ); - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - φ = φ * d3_radians / 2 + π / 4; - var dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, cosφ = Math.cos(φ), sinφ = Math.sin(φ), k = sinφ0 * sinφ, u = cosφ0 * cosφ + k * Math.cos(adλ), v = k * sdλ * Math.sin(adλ); - d3_geo_areaRingSum.add(Math.atan2(v, u)); - λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; - } - d3_geo_area.lineEnd = function() { - nextPoint(λ00, φ00); - }; - } - function d3_geo_cartesian(spherical) { - var λ = spherical[0], φ = spherical[1], cosφ = Math.cos(φ); - return [ cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ) ]; - } - function d3_geo_cartesianDot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; - } - function d3_geo_cartesianCross(a, b) { - return [ a[1] * b[2] - a[2] * b[1], a[2] * b[0] - a[0] * b[2], a[0] * b[1] - a[1] * b[0] ]; - } - function d3_geo_cartesianAdd(a, b) { - a[0] += b[0]; - a[1] += b[1]; - a[2] += b[2]; - } - function d3_geo_cartesianScale(vector, k) { - return [ vector[0] * k, vector[1] * k, vector[2] * k ]; - } - function d3_geo_cartesianNormalize(d) { - var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); - d[0] /= l; - d[1] /= l; - d[2] /= l; - } - function d3_geo_spherical(cartesian) { - return [ Math.atan2(cartesian[1], cartesian[0]), d3_asin(cartesian[2]) ]; - } - function d3_geo_sphericalEqual(a, b) { - return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε; - } - d3.geo.bounds = function() { - var λ0, φ0, λ1, φ1, λ_, λ__, φ__, p0, dλSum, ranges, range; - var bound = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - bound.point = ringPoint; - bound.lineStart = ringStart; - bound.lineEnd = ringEnd; - dλSum = 0; - d3_geo_area.polygonStart(); - }, - polygonEnd: function() { - d3_geo_area.polygonEnd(); - bound.point = point; - bound.lineStart = lineStart; - bound.lineEnd = lineEnd; - if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); else if (dλSum > ε) φ1 = 90; else if (dλSum < -ε) φ0 = -90; - range[0] = λ0, range[1] = λ1; - } - }; - function point(λ, φ) { - ranges.push(range = [ λ0 = λ, λ1 = λ ]); - if (φ < φ0) φ0 = φ; - if (φ > φ1) φ1 = φ; - } - function linePoint(λ, φ) { - var p = d3_geo_cartesian([ λ * d3_radians, φ * d3_radians ]); - if (p0) { - var normal = d3_geo_cartesianCross(p0, p), equatorial = [ normal[1], -normal[0], 0 ], inflection = d3_geo_cartesianCross(equatorial, normal); - d3_geo_cartesianNormalize(inflection); - inflection = d3_geo_spherical(inflection); - var dλ = λ - λ_, s = dλ > 0 ? 1 : -1, λi = inflection[0] * d3_degrees * s, antimeridian = abs(dλ) > 180; - if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) { - var φi = inflection[1] * d3_degrees; - if (φi > φ1) φ1 = φi; - } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) { - var φi = -inflection[1] * d3_degrees; - if (φi < φ0) φ0 = φi; - } else { - if (φ < φ0) φ0 = φ; - if (φ > φ1) φ1 = φ; - } - if (antimeridian) { - if (λ < λ_) { - if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; - } else { - if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; - } - } else { - if (λ1 >= λ0) { - if (λ < λ0) λ0 = λ; - if (λ > λ1) λ1 = λ; - } else { - if (λ > λ_) { - if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; - } else { - if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; - } - } - } - } else { - point(λ, φ); - } - p0 = p, λ_ = λ; - } - function lineStart() { - bound.point = linePoint; - } - function lineEnd() { - range[0] = λ0, range[1] = λ1; - bound.point = point; - p0 = null; - } - function ringPoint(λ, φ) { - if (p0) { - var dλ = λ - λ_; - dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ; - } else λ__ = λ, φ__ = φ; - d3_geo_area.point(λ, φ); - linePoint(λ, φ); - } - function ringStart() { - d3_geo_area.lineStart(); - } - function ringEnd() { - ringPoint(λ__, φ__); - d3_geo_area.lineEnd(); - if (abs(dλSum) > ε) λ0 = -(λ1 = 180); - range[0] = λ0, range[1] = λ1; - p0 = null; - } - function angle(λ0, λ1) { - return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1; - } - function compareRanges(a, b) { - return a[0] - b[0]; - } - function withinRange(x, range) { - return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; - } - return function(feature) { - φ1 = λ1 = -(λ0 = φ0 = Infinity); - ranges = []; - d3.geo.stream(feature, bound); - var n = ranges.length; - if (n) { - ranges.sort(compareRanges); - for (var i = 1, a = ranges[0], b, merged = [ a ]; i < n; ++i) { - b = ranges[i]; - if (withinRange(b[0], a) || withinRange(b[1], a)) { - if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; - if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; - } else { - merged.push(a = b); - } - } - var best = -Infinity, dλ; - for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) { - b = merged[i]; - if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1]; - } - } - ranges = range = null; - return λ0 === Infinity || φ0 === Infinity ? [ [ NaN, NaN ], [ NaN, NaN ] ] : [ [ λ0, φ0 ], [ λ1, φ1 ] ]; - }; - }(); - d3.geo.centroid = function(object) { - d3_geo_centroidW0 = d3_geo_centroidW1 = d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; - d3.geo.stream(object, d3_geo_centroid); - var x = d3_geo_centroidX2, y = d3_geo_centroidY2, z = d3_geo_centroidZ2, m = x * x + y * y + z * z; - if (m < ε2) { - x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1; - if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0; - m = x * x + y * y + z * z; - if (m < ε2) return [ NaN, NaN ]; - } - return [ Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees ]; - }; - var d3_geo_centroidW0, d3_geo_centroidW1, d3_geo_centroidX0, d3_geo_centroidY0, d3_geo_centroidZ0, d3_geo_centroidX1, d3_geo_centroidY1, d3_geo_centroidZ1, d3_geo_centroidX2, d3_geo_centroidY2, d3_geo_centroidZ2; - var d3_geo_centroid = { - sphere: d3_noop, - point: d3_geo_centroidPoint, - lineStart: d3_geo_centroidLineStart, - lineEnd: d3_geo_centroidLineEnd, - polygonStart: function() { - d3_geo_centroid.lineStart = d3_geo_centroidRingStart; - }, - polygonEnd: function() { - d3_geo_centroid.lineStart = d3_geo_centroidLineStart; - } - }; - function d3_geo_centroidPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)); - } - function d3_geo_centroidPointXYZ(x, y, z) { - ++d3_geo_centroidW0; - d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0; - d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0; - d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0; - } - function d3_geo_centroidLineStart() { - var x0, y0, z0; - d3_geo_centroid.point = function(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - x0 = cosφ * Math.cos(λ); - y0 = cosφ * Math.sin(λ); - z0 = Math.sin(φ); - d3_geo_centroid.point = nextPoint; - d3_geo_centroidPointXYZ(x0, y0, z0); - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), w = Math.atan2(Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), x0 * x + y0 * y + z0 * z); - d3_geo_centroidW1 += w; - d3_geo_centroidX1 += w * (x0 + (x0 = x)); - d3_geo_centroidY1 += w * (y0 + (y0 = y)); - d3_geo_centroidZ1 += w * (z0 + (z0 = z)); - d3_geo_centroidPointXYZ(x0, y0, z0); - } - } - function d3_geo_centroidLineEnd() { - d3_geo_centroid.point = d3_geo_centroidPoint; - } - function d3_geo_centroidRingStart() { - var λ00, φ00, x0, y0, z0; - d3_geo_centroid.point = function(λ, φ) { - λ00 = λ, φ00 = φ; - d3_geo_centroid.point = nextPoint; - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - x0 = cosφ * Math.cos(λ); - y0 = cosφ * Math.sin(λ); - z0 = Math.sin(φ); - d3_geo_centroidPointXYZ(x0, y0, z0); - }; - d3_geo_centroid.lineEnd = function() { - nextPoint(λ00, φ00); - d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; - d3_geo_centroid.point = d3_geo_centroidPoint; - }; - function nextPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians), x = cosφ * Math.cos(λ), y = cosφ * Math.sin(λ), z = Math.sin(φ), cx = y0 * z - z0 * y, cy = z0 * x - x0 * z, cz = x0 * y - y0 * x, m = Math.sqrt(cx * cx + cy * cy + cz * cz), u = x0 * x + y0 * y + z0 * z, v = m && -d3_acos(u) / m, w = Math.atan2(m, u); - d3_geo_centroidX2 += v * cx; - d3_geo_centroidY2 += v * cy; - d3_geo_centroidZ2 += v * cz; - d3_geo_centroidW1 += w; - d3_geo_centroidX1 += w * (x0 + (x0 = x)); - d3_geo_centroidY1 += w * (y0 + (y0 = y)); - d3_geo_centroidZ1 += w * (z0 + (z0 = z)); - d3_geo_centroidPointXYZ(x0, y0, z0); - } - } - function d3_geo_compose(a, b) { - function compose(x, y) { - return x = a(x, y), b(x[0], x[1]); - } - if (a.invert && b.invert) compose.invert = function(x, y) { - return x = b.invert(x, y), x && a.invert(x[0], x[1]); - }; - return compose; - } - function d3_true() { - return true; - } - function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) { - var subject = [], clip = []; - segments.forEach(function(segment) { - if ((n = segment.length - 1) <= 0) return; - var n, p0 = segment[0], p1 = segment[n]; - if (d3_geo_sphericalEqual(p0, p1)) { - listener.lineStart(); - for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); - listener.lineEnd(); - return; - } - var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), b = new d3_geo_clipPolygonIntersection(p0, null, a, false); - a.o = b; - subject.push(a); - clip.push(b); - a = new d3_geo_clipPolygonIntersection(p1, segment, null, false); - b = new d3_geo_clipPolygonIntersection(p1, null, a, true); - a.o = b; - subject.push(a); - clip.push(b); - }); - clip.sort(compare); - d3_geo_clipPolygonLinkCircular(subject); - d3_geo_clipPolygonLinkCircular(clip); - if (!subject.length) return; - for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) { - clip[i].e = entry = !entry; - } - var start = subject[0], points, point; - while (1) { - var current = start, isSubject = true; - while (current.v) if ((current = current.n) === start) return; - points = current.z; - listener.lineStart(); - do { - current.v = current.o.v = true; - if (current.e) { - if (isSubject) { - for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.x, current.n.x, 1, listener); - } - current = current.n; - } else { - if (isSubject) { - points = current.p.z; - for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.x, current.p.x, -1, listener); - } - current = current.p; - } - current = current.o; - points = current.z; - isSubject = !isSubject; - } while (!current.v); - listener.lineEnd(); - } - } - function d3_geo_clipPolygonLinkCircular(array) { - if (!(n = array.length)) return; - var n, i = 0, a = array[0], b; - while (++i < n) { - a.n = b = array[i]; - b.p = a; - a = b; - } - a.n = b = array[0]; - b.p = a; - } - function d3_geo_clipPolygonIntersection(point, points, other, entry) { - this.x = point; - this.z = points; - this.o = other; - this.e = entry; - this.v = false; - this.n = this.p = null; - } - function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) { - return function(rotate, listener) { - var line = clipLine(listener), rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]); - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - clip.point = pointRing; - clip.lineStart = ringStart; - clip.lineEnd = ringEnd; - segments = []; - polygon = []; - }, - polygonEnd: function() { - clip.point = point; - clip.lineStart = lineStart; - clip.lineEnd = lineEnd; - segments = d3.merge(segments); - var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon); - if (segments.length) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; - d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener); - } else if (clipStartInside) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - } - if (polygonStarted) listener.polygonEnd(), polygonStarted = false; - segments = polygon = null; - }, - sphere: function() { - listener.polygonStart(); - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - listener.polygonEnd(); - } - }; - function point(λ, φ) { - var point = rotate(λ, φ); - if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ); - } - function pointLine(λ, φ) { - var point = rotate(λ, φ); - line.point(point[0], point[1]); - } - function lineStart() { - clip.point = pointLine; - line.lineStart(); - } - function lineEnd() { - clip.point = point; - line.lineEnd(); - } - var segments; - var buffer = d3_geo_clipBufferListener(), ringListener = clipLine(buffer), polygonStarted = false, polygon, ring; - function pointRing(λ, φ) { - ring.push([ λ, φ ]); - var point = rotate(λ, φ); - ringListener.point(point[0], point[1]); - } - function ringStart() { - ringListener.lineStart(); - ring = []; - } - function ringEnd() { - pointRing(ring[0][0], ring[0][1]); - ringListener.lineEnd(); - var clean = ringListener.clean(), ringSegments = buffer.buffer(), segment, n = ringSegments.length; - ring.pop(); - polygon.push(ring); - ring = null; - if (!n) return; - if (clean & 1) { - segment = ringSegments[0]; - var n = segment.length - 1, i = -1, point; - if (n > 0) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; - listener.lineStart(); - while (++i < n) listener.point((point = segment[i])[0], point[1]); - listener.lineEnd(); - } - return; - } - if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); - segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); - } - return clip; - }; - } - function d3_geo_clipSegmentLength1(segment) { - return segment.length > 1; - } - function d3_geo_clipBufferListener() { - var lines = [], line; - return { - lineStart: function() { - lines.push(line = []); - }, - point: function(λ, φ) { - line.push([ λ, φ ]); - }, - lineEnd: d3_noop, - buffer: function() { - var buffer = lines; - lines = []; - line = null; - return buffer; - }, - rejoin: function() { - if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); - } - }; - } - function d3_geo_clipSort(a, b) { - return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]); - } - var d3_geo_clipAntimeridian = d3_geo_clip(d3_true, d3_geo_clipAntimeridianLine, d3_geo_clipAntimeridianInterpolate, [ -π, -π / 2 ]); - function d3_geo_clipAntimeridianLine(listener) { - var λ0 = NaN, φ0 = NaN, sλ0 = NaN, clean; - return { - lineStart: function() { - listener.lineStart(); - clean = 1; - }, - point: function(λ1, φ1) { - var sλ1 = λ1 > 0 ? π : -π, dλ = abs(λ1 - λ0); - if (abs(dλ - π) < ε) { - listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - listener.point(λ1, φ0); - clean = 0; - } else if (sλ0 !== sλ1 && dλ >= π) { - if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; - if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; - φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - clean = 0; - } - listener.point(λ0 = λ1, φ0 = φ1); - sλ0 = sλ1; - }, - lineEnd: function() { - listener.lineEnd(); - λ0 = φ0 = NaN; - }, - clean: function() { - return 2 - clean; - } - }; - } - function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) { - var cosφ0, cosφ1, sinλ0_λ1 = Math.sin(λ0 - λ1); - return abs(sinλ0_λ1) > ε ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) / (cosφ0 * cosφ1 * sinλ0_λ1)) : (φ0 + φ1) / 2; - } - function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { - var φ; - if (from == null) { - φ = direction * halfπ; - listener.point(-π, φ); - listener.point(0, φ); - listener.point(π, φ); - listener.point(π, 0); - listener.point(π, -φ); - listener.point(0, -φ); - listener.point(-π, -φ); - listener.point(-π, 0); - listener.point(-π, φ); - } else if (abs(from[0] - to[0]) > ε) { - var s = from[0] < to[0] ? π : -π; - φ = direction * s / 2; - listener.point(-s, φ); - listener.point(0, φ); - listener.point(s, φ); - } else { - listener.point(to[0], to[1]); - } - } - function d3_geo_pointInPolygon(point, polygon) { - var meridian = point[0], parallel = point[1], meridianNormal = [ Math.sin(meridian), -Math.cos(meridian), 0 ], polarAngle = 0, winding = 0; - d3_geo_areaRingSum.reset(); - for (var i = 0, n = polygon.length; i < n; ++i) { - var ring = polygon[i], m = ring.length; - if (!m) continue; - var point0 = ring[0], λ0 = point0[0], φ0 = point0[1] / 2 + π / 4, sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), j = 1; - while (true) { - if (j === m) j = 0; - point = ring[j]; - var λ = point[0], φ = point[1] / 2 + π / 4, sinφ = Math.sin(φ), cosφ = Math.cos(φ), dλ = λ - λ0, sdλ = dλ >= 0 ? 1 : -1, adλ = sdλ * dλ, antimeridian = adλ > π, k = sinφ0 * sinφ; - d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ))); - polarAngle += antimeridian ? dλ + sdλ * τ : dλ; - if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { - var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); - d3_geo_cartesianNormalize(arc); - var intersection = d3_geo_cartesianCross(meridianNormal, arc); - d3_geo_cartesianNormalize(intersection); - var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); - if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { - winding += antimeridian ^ dλ >= 0 ? 1 : -1; - } - } - if (!j++) break; - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; - } - } - return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ winding & 1; - } - function d3_geo_clipCircle(radius) { - var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); - return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [ 0, -radius ] : [ -π, radius - π ]); - function visible(λ, φ) { - return Math.cos(λ) * Math.cos(φ) > cr; - } - function clipLine(listener) { - var point0, c0, v0, v00, clean; - return { - lineStart: function() { - v00 = v0 = false; - clean = 1; - }, - point: function(λ, φ) { - var point1 = [ λ, φ ], point2, v = visible(λ, φ), c = smallRadius ? v ? 0 : code(λ, φ) : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; - if (!point0 && (v00 = v0 = v)) listener.lineStart(); - if (v !== v0) { - point2 = intersect(point0, point1); - if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { - point1[0] += ε; - point1[1] += ε; - v = visible(point1[0], point1[1]); - } - } - if (v !== v0) { - clean = 0; - if (v) { - listener.lineStart(); - point2 = intersect(point1, point0); - listener.point(point2[0], point2[1]); - } else { - point2 = intersect(point0, point1); - listener.point(point2[0], point2[1]); - listener.lineEnd(); - } - point0 = point2; - } else if (notHemisphere && point0 && smallRadius ^ v) { - var t; - if (!(c & c0) && (t = intersect(point1, point0, true))) { - clean = 0; - if (smallRadius) { - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - } else { - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - } - } - } - if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { - listener.point(point1[0], point1[1]); - } - point0 = point1, v0 = v, c0 = c; - }, - lineEnd: function() { - if (v0) listener.lineEnd(); - point0 = null; - }, - clean: function() { - return clean | (v00 && v0) << 1; - } - }; - } - function intersect(a, b, two) { - var pa = d3_geo_cartesian(a), pb = d3_geo_cartesian(b); - var n1 = [ 1, 0, 0 ], n2 = d3_geo_cartesianCross(pa, pb), n2n2 = d3_geo_cartesianDot(n2, n2), n1n2 = n2[0], determinant = n2n2 - n1n2 * n1n2; - if (!determinant) return !two && a; - var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = d3_geo_cartesianCross(n1, n2), A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); - d3_geo_cartesianAdd(A, B); - var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); - if (t2 < 0) return; - var t = Math.sqrt(t2), q = d3_geo_cartesianScale(u, (-w - t) / uu); - d3_geo_cartesianAdd(q, A); - q = d3_geo_spherical(q); - if (!two) return q; - var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z; - if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; - var δλ = λ1 - λ0, polar = abs(δλ - π) < ε, meridian = polar || δλ < ε; - if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; - if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { - var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); - d3_geo_cartesianAdd(q1, A); - return [ q, d3_geo_spherical(q1) ]; - } - } - function code(λ, φ) { - var r = smallRadius ? radius : π - radius, code = 0; - if (λ < -r) code |= 1; else if (λ > r) code |= 2; - if (φ < -r) code |= 4; else if (φ > r) code |= 8; - return code; - } - } - function d3_geom_clipLine(x0, y0, x1, y1) { - return function(line) { - var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, 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) line.a = { - x: ax + t0 * dx, - y: ay + t0 * dy - }; - if (t1 < 1) line.b = { - x: ax + t1 * dx, - y: ay + t1 * dy - }; - return line; - }; - } - var d3_geo_clipExtentMAX = 1e9; - d3.geo.clipExtent = function() { - var x0, y0, x1, y1, stream, clip, clipExtent = { - stream: function(output) { - if (stream) stream.valid = false; - stream = clip(output); - stream.valid = true; - return stream; - }, - extent: function(_) { - if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; - clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]); - if (stream) stream.valid = false, stream = null; - return clipExtent; - } - }; - return clipExtent.extent([ [ 0, 0 ], [ 960, 500 ] ]); - }; - function d3_geo_clipExtent(x0, y0, x1, y1) { - return function(listener) { - var listener_ = listener, bufferListener = d3_geo_clipBufferListener(), clipLine = d3_geom_clipLine(x0, y0, x1, y1), segments, polygon, ring; - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - listener = bufferListener; - segments = []; - polygon = []; - clean = true; - }, - polygonEnd: function() { - listener = listener_; - segments = d3.merge(segments); - var clipStartInside = insidePolygon([ x0, y1 ]), inside = clean && clipStartInside, visible = segments.length; - if (inside || visible) { - listener.polygonStart(); - if (inside) { - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - } - if (visible) { - d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener); - } - listener.polygonEnd(); - } - segments = polygon = ring = null; - } - }; - function insidePolygon(p) { - var wn = 0, n = polygon.length, y = p[1]; - for (var i = 0; i < n; ++i) { - for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { - b = v[j]; - if (a[1] <= y) { - if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn; - } else { - if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn; - } - a = b; - } - } - return wn !== 0; - } - function interpolate(from, to, direction, listener) { - var a = 0, a1 = 0; - if (from == null || (a = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoints(from, to) < 0 ^ direction > 0) { - do { - listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); - } while ((a = (a + direction + 4) % 4) !== a1); - } else { - listener.point(to[0], to[1]); - } - } - function pointVisible(x, y) { - return x0 <= x && x <= x1 && y0 <= y && y <= y1; - } - function point(x, y) { - if (pointVisible(x, y)) listener.point(x, y); - } - var x__, y__, v__, x_, y_, v_, first, clean; - function lineStart() { - clip.point = linePoint; - if (polygon) polygon.push(ring = []); - first = true; - v_ = false; - x_ = y_ = NaN; - } - function lineEnd() { - if (segments) { - linePoint(x__, y__); - if (v__ && v_) bufferListener.rejoin(); - segments.push(bufferListener.buffer()); - } - clip.point = point; - if (v_) listener.lineEnd(); - } - function linePoint(x, y) { - x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x)); - y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y)); - var v = pointVisible(x, y); - if (polygon) ring.push([ x, y ]); - if (first) { - x__ = x, y__ = y, v__ = v; - first = false; - if (v) { - listener.lineStart(); - listener.point(x, y); - } - } else { - if (v && v_) listener.point(x, y); else { - var l = { - a: { - x: x_, - y: y_ - }, - b: { - x: x, - y: y - } - }; - if (clipLine(l)) { - if (!v_) { - listener.lineStart(); - listener.point(l.a.x, l.a.y); - } - listener.point(l.b.x, l.b.y); - if (!v) listener.lineEnd(); - clean = false; - } else if (v) { - listener.lineStart(); - listener.point(x, y); - clean = false; - } - } - } - x_ = x, y_ = y, v_ = v; - } - return clip; - }; - function corner(p, direction) { - return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2; - } - function compare(a, b) { - return comparePoints(a.x, b.x); - } - function comparePoints(a, b) { - var ca = corner(a, 1), cb = corner(b, 1); - return ca !== cb ? ca - cb : ca === 0 ? b[1] - a[1] : ca === 1 ? a[0] - b[0] : ca === 2 ? a[1] - b[1] : b[0] - a[0]; - } - } - function d3_geo_conic(projectAt) { - var φ0 = 0, φ1 = π / 3, m = d3_geo_projectionMutator(projectAt), p = m(φ0, φ1); - p.parallels = function(_) { - if (!arguments.length) return [ φ0 / π * 180, φ1 / π * 180 ]; - return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180); - }; - return p; - } - function d3_geo_conicEqualArea(φ0, φ1) { - var sinφ0 = Math.sin(φ0), n = (sinφ0 + Math.sin(φ1)) / 2, C = 1 + sinφ0 * (2 * n - sinφ0), ρ0 = Math.sqrt(C) / n; - function forward(λ, φ) { - var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n; - return [ ρ * Math.sin(λ *= n), ρ0 - ρ * Math.cos(λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = ρ0 - y; - return [ Math.atan2(x, ρ0_y) / n, d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) ]; - }; - return forward; - } - (d3.geo.conicEqualArea = function() { - return d3_geo_conic(d3_geo_conicEqualArea); - }).raw = d3_geo_conicEqualArea; - d3.geo.albers = function() { - return d3.geo.conicEqualArea().rotate([ 96, 0 ]).center([ -.6, 38.7 ]).parallels([ 29.5, 45.5 ]).scale(1070); - }; - d3.geo.albersUsa = function() { - var lower48 = d3.geo.albers(); - var alaska = d3.geo.conicEqualArea().rotate([ 154, 0 ]).center([ -2, 58.5 ]).parallels([ 55, 65 ]); - var hawaii = d3.geo.conicEqualArea().rotate([ 157, 0 ]).center([ -3, 19.9 ]).parallels([ 8, 18 ]); - var point, pointStream = { - point: function(x, y) { - point = [ x, y ]; - } - }, lower48Point, alaskaPoint, hawaiiPoint; - function albersUsa(coordinates) { - var x = coordinates[0], y = coordinates[1]; - point = null; - (lower48Point(x, y), point) || (alaskaPoint(x, y), point) || hawaiiPoint(x, y); - return point; - } - albersUsa.invert = function(coordinates) { - var k = lower48.scale(), t = lower48.translate(), x = (coordinates[0] - t[0]) / k, y = (coordinates[1] - t[1]) / k; - return (y >= .12 && y < .234 && x >= -.425 && x < -.214 ? alaska : y >= .166 && y < .234 && x >= -.214 && x < -.115 ? hawaii : lower48).invert(coordinates); - }; - albersUsa.stream = function(stream) { - var lower48Stream = lower48.stream(stream), alaskaStream = alaska.stream(stream), hawaiiStream = hawaii.stream(stream); - return { - point: function(x, y) { - lower48Stream.point(x, y); - alaskaStream.point(x, y); - hawaiiStream.point(x, y); - }, - sphere: function() { - lower48Stream.sphere(); - alaskaStream.sphere(); - hawaiiStream.sphere(); - }, - lineStart: function() { - lower48Stream.lineStart(); - alaskaStream.lineStart(); - hawaiiStream.lineStart(); - }, - lineEnd: function() { - lower48Stream.lineEnd(); - alaskaStream.lineEnd(); - hawaiiStream.lineEnd(); - }, - polygonStart: function() { - lower48Stream.polygonStart(); - alaskaStream.polygonStart(); - hawaiiStream.polygonStart(); - }, - polygonEnd: function() { - lower48Stream.polygonEnd(); - alaskaStream.polygonEnd(); - hawaiiStream.polygonEnd(); - } - }; - }; - albersUsa.precision = function(_) { - if (!arguments.length) return lower48.precision(); - lower48.precision(_); - alaska.precision(_); - hawaii.precision(_); - return albersUsa; - }; - albersUsa.scale = function(_) { - if (!arguments.length) return lower48.scale(); - lower48.scale(_); - alaska.scale(_ * .35); - hawaii.scale(_); - return albersUsa.translate(lower48.translate()); - }; - albersUsa.translate = function(_) { - if (!arguments.length) return lower48.translate(); - var k = lower48.scale(), x = +_[0], y = +_[1]; - lower48Point = lower48.translate(_).clipExtent([ [ x - .455 * k, y - .238 * k ], [ x + .455 * k, y + .238 * k ] ]).stream(pointStream).point; - alaskaPoint = alaska.translate([ x - .307 * k, y + .201 * k ]).clipExtent([ [ x - .425 * k + ε, y + .12 * k + ε ], [ x - .214 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; - hawaiiPoint = hawaii.translate([ x - .205 * k, y + .212 * k ]).clipExtent([ [ x - .214 * k + ε, y + .166 * k + ε ], [ x - .115 * k - ε, y + .234 * k - ε ] ]).stream(pointStream).point; - return albersUsa; - }; - return albersUsa.scale(1070); - }; - var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: function() { - d3_geo_pathAreaPolygon = 0; - d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; - }, - polygonEnd: function() { - d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; - d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2); - } - }; - function d3_geo_pathAreaRingStart() { - var x00, y00, x0, y0; - d3_geo_pathArea.point = function(x, y) { - d3_geo_pathArea.point = nextPoint; - x00 = x0 = x, y00 = y0 = y; - }; - function nextPoint(x, y) { - d3_geo_pathAreaPolygon += y0 * x - x0 * y; - x0 = x, y0 = y; - } - d3_geo_pathArea.lineEnd = function() { - nextPoint(x00, y00); - }; - } - var d3_geo_pathBoundsX0, d3_geo_pathBoundsY0, d3_geo_pathBoundsX1, d3_geo_pathBoundsY1; - var d3_geo_pathBounds = { - point: d3_geo_pathBoundsPoint, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: d3_noop, - polygonEnd: d3_noop - }; - function d3_geo_pathBoundsPoint(x, y) { - if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x; - if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x; - if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y; - if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y; - } - function d3_geo_pathBuffer() { - var pointCircle = d3_geo_pathBufferCircle(4.5), buffer = []; - var stream = { - point: point, - lineStart: function() { - stream.point = pointLineStart; - }, - lineEnd: lineEnd, - polygonStart: function() { - stream.lineEnd = lineEndPolygon; - }, - polygonEnd: function() { - stream.lineEnd = lineEnd; - stream.point = point; - }, - pointRadius: function(_) { - pointCircle = d3_geo_pathBufferCircle(_); - return stream; - }, - result: function() { - if (buffer.length) { - var result = buffer.join(""); - buffer = []; - return result; - } - } - }; - function point(x, y) { - buffer.push("M", x, ",", y, pointCircle); - } - function pointLineStart(x, y) { - buffer.push("M", x, ",", y); - stream.point = pointLine; - } - function pointLine(x, y) { - buffer.push("L", x, ",", y); - } - function lineEnd() { - stream.point = point; - } - function lineEndPolygon() { - buffer.push("Z"); - } - return stream; - } - function d3_geo_pathBufferCircle(radius) { - return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z"; - } - var d3_geo_pathCentroid = { - point: d3_geo_pathCentroidPoint, - lineStart: d3_geo_pathCentroidLineStart, - lineEnd: d3_geo_pathCentroidLineEnd, - polygonStart: function() { - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; - }, - polygonEnd: function() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; - d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; - } - }; - function d3_geo_pathCentroidPoint(x, y) { - d3_geo_centroidX0 += x; - d3_geo_centroidY0 += y; - ++d3_geo_centroidZ0; - } - function d3_geo_pathCentroidLineStart() { - var x0, y0; - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - }; - function nextPoint(x, y) { - var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); - d3_geo_centroidX1 += z * (x0 + x) / 2; - d3_geo_centroidY1 += z * (y0 + y) / 2; - d3_geo_centroidZ1 += z; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - } - } - function d3_geo_pathCentroidLineEnd() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; - } - function d3_geo_pathCentroidRingStart() { - var x00, y00, x0, y0; - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y); - }; - function nextPoint(x, y) { - var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); - d3_geo_centroidX1 += z * (x0 + x) / 2; - d3_geo_centroidY1 += z * (y0 + y) / 2; - d3_geo_centroidZ1 += z; - z = y0 * x - x0 * y; - d3_geo_centroidX2 += z * (x0 + x); - d3_geo_centroidY2 += z * (y0 + y); - d3_geo_centroidZ2 += z * 3; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - } - d3_geo_pathCentroid.lineEnd = function() { - nextPoint(x00, y00); - }; - } - function d3_geo_pathContext(context) { - var pointRadius = 4.5; - var stream = { - point: point, - lineStart: function() { - stream.point = pointLineStart; - }, - lineEnd: lineEnd, - polygonStart: function() { - stream.lineEnd = lineEndPolygon; - }, - polygonEnd: function() { - stream.lineEnd = lineEnd; - stream.point = point; - }, - pointRadius: function(_) { - pointRadius = _; - return stream; - }, - result: d3_noop - }; - function point(x, y) { - context.moveTo(x + pointRadius, y); - context.arc(x, y, pointRadius, 0, τ); - } - function pointLineStart(x, y) { - context.moveTo(x, y); - stream.point = pointLine; - } - function pointLine(x, y) { - context.lineTo(x, y); - } - function lineEnd() { - stream.point = point; - } - function lineEndPolygon() { - context.closePath(); - } - return stream; - } - function d3_geo_resample(project) { - var δ2 = .5, cosMinDistance = Math.cos(30 * d3_radians), maxDepth = 16; - function resample(stream) { - return (maxDepth ? resampleRecursive : resampleNone)(stream); - } - function resampleNone(stream) { - return d3_geo_transformPoint(stream, function(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - }); - } - function resampleRecursive(stream) { - var λ00, φ00, x00, y00, a00, b00, c00, λ0, x0, y0, a0, b0, c0; - var resample = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - stream.polygonStart(); - resample.lineStart = ringStart; - }, - polygonEnd: function() { - stream.polygonEnd(); - resample.lineStart = lineStart; - } - }; - function point(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - } - function lineStart() { - x0 = NaN; - resample.point = linePoint; - stream.lineStart(); - } - function linePoint(λ, φ) { - var c = d3_geo_cartesian([ λ, φ ]), p = project(λ, φ); - resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); - stream.point(x0, y0); - } - function lineEnd() { - resample.point = point; - stream.lineEnd(); - } - function ringStart() { - lineStart(); - resample.point = ringPoint; - resample.lineEnd = ringEnd; - } - function ringPoint(λ, φ) { - linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; - resample.point = linePoint; - } - function ringEnd() { - resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); - resample.lineEnd = lineEnd; - lineEnd(); - } - return resample; - } - function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { - var dx = x1 - x0, dy = y1 - y0, d2 = dx * dx + dy * dy; - if (d2 > 4 * δ2 && depth--) { - var a = a0 + a1, b = b0 + b1, c = c0 + c1, m = Math.sqrt(a * a + b * b + c * c), φ2 = Math.asin(c /= m), λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), p = project(λ2, φ2), x2 = p[0], y2 = p[1], dx2 = x2 - x0, dy2 = y2 - y0, dz = dy * dx2 - dx * dy2; - if (dz * dz / d2 > δ2 || abs((dx * dx2 + dy * dy2) / d2 - .5) > .3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) { - resampleLineTo(x0, y0, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream); - stream.point(x2, y2); - resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream); - } - } - } - resample.precision = function(_) { - if (!arguments.length) return Math.sqrt(δ2); - maxDepth = (δ2 = _ * _) > 0 && 16; - return resample; - }; - return resample; - } - d3.geo.path = function() { - var pointRadius = 4.5, projection, context, projectStream, contextStream, cacheStream; - function path(object) { - if (object) { - if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); - if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream); - d3.geo.stream(object, cacheStream); - } - return contextStream.result(); - } - path.area = function(object) { - d3_geo_pathAreaSum = 0; - d3.geo.stream(object, projectStream(d3_geo_pathArea)); - return d3_geo_pathAreaSum; - }; - path.centroid = function(object) { - d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; - d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); - return d3_geo_centroidZ2 ? [ d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2 ] : d3_geo_centroidZ1 ? [ d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1 ] : d3_geo_centroidZ0 ? [ d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0 ] : [ NaN, NaN ]; - }; - path.bounds = function(object) { - d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity); - d3.geo.stream(object, projectStream(d3_geo_pathBounds)); - return [ [ d3_geo_pathBoundsX0, d3_geo_pathBoundsY0 ], [ d3_geo_pathBoundsX1, d3_geo_pathBoundsY1 ] ]; - }; - path.projection = function(_) { - if (!arguments.length) return projection; - projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; - return reset(); - }; - path.context = function(_) { - if (!arguments.length) return context; - contextStream = (context = _) == null ? new d3_geo_pathBuffer() : new d3_geo_pathContext(_); - if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); - return reset(); - }; - path.pointRadius = function(_) { - if (!arguments.length) return pointRadius; - pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); - return path; - }; - function reset() { - cacheStream = null; - return path; - } - return path.projection(d3.geo.albersUsa()).context(null); - }; - function d3_geo_pathProjectStream(project) { - var resample = d3_geo_resample(function(x, y) { - return project([ x * d3_degrees, y * d3_degrees ]); - }); - return function(stream) { - return d3_geo_projectionRadians(resample(stream)); - }; - } - d3.geo.transform = function(methods) { - return { - stream: function(stream) { - var transform = new d3_geo_transform(stream); - for (var k in methods) transform[k] = methods[k]; - return transform; - } - }; - }; - function d3_geo_transform(stream) { - this.stream = stream; - } - d3_geo_transform.prototype = { - 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 d3_geo_transformPoint(stream, point) { - return { - point: point, - sphere: function() { - stream.sphere(); - }, - lineStart: function() { - stream.lineStart(); - }, - lineEnd: function() { - stream.lineEnd(); - }, - polygonStart: function() { - stream.polygonStart(); - }, - polygonEnd: function() { - stream.polygonEnd(); - } - }; - } - d3.geo.projection = d3_geo_projection; - d3.geo.projectionMutator = d3_geo_projectionMutator; - function d3_geo_projection(project) { - return d3_geo_projectionMutator(function() { - return project; - })(); - } - function d3_geo_projectionMutator(projectAt) { - var project, rotate, projectRotate, projectResample = d3_geo_resample(function(x, y) { - x = project(x, y); - return [ x[0] * k + δx, δy - x[1] * k ]; - }), k = 150, x = 480, y = 250, λ = 0, φ = 0, δλ = 0, δφ = 0, δγ = 0, δx, δy, preclip = d3_geo_clipAntimeridian, postclip = d3_identity, clipAngle = null, clipExtent = null, stream; - function projection(point) { - point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); - return [ point[0] * k + δx, δy - point[1] * k ]; - } - function invert(point) { - point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); - return point && [ point[0] * d3_degrees, point[1] * d3_degrees ]; - } - projection.stream = function(output) { - if (stream) stream.valid = false; - stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output)))); - stream.valid = true; - return stream; - }; - projection.clipAngle = function(_) { - if (!arguments.length) return clipAngle; - preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); - return invalidate(); - }; - projection.clipExtent = function(_) { - if (!arguments.length) return clipExtent; - clipExtent = _; - postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity; - return invalidate(); - }; - projection.scale = function(_) { - if (!arguments.length) return k; - k = +_; - return reset(); - }; - projection.translate = function(_) { - if (!arguments.length) return [ x, y ]; - x = +_[0]; - y = +_[1]; - return reset(); - }; - projection.center = function(_) { - if (!arguments.length) return [ λ * d3_degrees, φ * d3_degrees ]; - λ = _[0] % 360 * d3_radians; - φ = _[1] % 360 * d3_radians; - return reset(); - }; - projection.rotate = function(_) { - if (!arguments.length) return [ δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees ]; - δλ = _[0] % 360 * d3_radians; - δφ = _[1] % 360 * d3_radians; - δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; - return reset(); - }; - d3.rebind(projection, projectResample, "precision"); - function reset() { - projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project); - var center = project(λ, φ); - δx = x - center[0] * k; - δy = y + center[1] * k; - return invalidate(); - } - function invalidate() { - if (stream) stream.valid = false, stream = null; - return projection; - } - return function() { - project = projectAt.apply(this, arguments); - projection.invert = project.invert && invert; - return reset(); - }; - } - function d3_geo_projectionRadians(stream) { - return d3_geo_transformPoint(stream, function(x, y) { - stream.point(x * d3_radians, y * d3_radians); - }); - } - function d3_geo_equirectangular(λ, φ) { - return [ λ, φ ]; - } - (d3.geo.equirectangular = function() { - return d3_geo_projection(d3_geo_equirectangular); - }).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; - d3.geo.rotation = function(rotate) { - rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); - function forward(coordinates) { - coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - } - forward.invert = function(coordinates) { - coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - }; - return forward; - }; - function d3_geo_identityRotation(λ, φ) { - return [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; - } - d3_geo_identityRotation.invert = d3_geo_equirectangular; - function d3_geo_rotation(δλ, δφ, δγ) { - return δλ ? δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) : d3_geo_rotationλ(δλ) : δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) : d3_geo_identityRotation; - } - function d3_geo_forwardRotationλ(δλ) { - return function(λ, φ) { - return λ += δλ, [ λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ ]; - }; - } - function d3_geo_rotationλ(δλ) { - var rotation = d3_geo_forwardRotationλ(δλ); - rotation.invert = d3_geo_forwardRotationλ(-δλ); - return rotation; - } - function d3_geo_rotationφγ(δφ, δγ) { - var cosδφ = Math.cos(δφ), sinδφ = Math.sin(δφ), cosδγ = Math.cos(δγ), sinδγ = Math.sin(δγ); - function rotation(λ, φ) { - var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδφ + x * sinδφ; - return [ Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), d3_asin(k * cosδγ + y * sinδγ) ]; - } - rotation.invert = function(λ, φ) { - var cosφ = Math.cos(φ), x = Math.cos(λ) * cosφ, y = Math.sin(λ) * cosφ, z = Math.sin(φ), k = z * cosδγ - y * sinδγ; - return [ Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), d3_asin(k * cosδφ - x * sinδφ) ]; - }; - return rotation; - } - d3.geo.circle = function() { - var origin = [ 0, 0 ], angle, precision = 6, interpolate; - function circle() { - var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, ring = []; - interpolate(null, null, 1, { - point: function(x, y) { - ring.push(x = rotate(x, y)); - x[0] *= d3_degrees, x[1] *= d3_degrees; - } - }); - return { - type: "Polygon", - coordinates: [ ring ] - }; - } - circle.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - return circle; - }; - circle.angle = function(x) { - if (!arguments.length) return angle; - interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); - return circle; - }; - circle.precision = function(_) { - if (!arguments.length) return precision; - interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); - return circle; - }; - return circle.angle(90); - }; - function d3_geo_circleInterpolate(radius, precision) { - var cr = Math.cos(radius), sr = Math.sin(radius); - return function(from, to, direction, listener) { - var step = direction * precision; - if (from != null) { - from = d3_geo_circleAngle(cr, from); - to = d3_geo_circleAngle(cr, to); - if (direction > 0 ? from < to : from > to) from += direction * τ; - } else { - from = radius + direction * τ; - to = radius - .5 * step; - } - for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) { - listener.point((point = d3_geo_spherical([ cr, -sr * Math.cos(t), -sr * Math.sin(t) ]))[0], point[1]); - } - }; - } - function d3_geo_circleAngle(cr, point) { - var a = d3_geo_cartesian(point); - a[0] -= cr; - d3_geo_cartesianNormalize(a); - var angle = d3_acos(-a[1]); - return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); - } - d3.geo.distance = function(a, b) { - var Δλ = (b[0] - a[0]) * d3_radians, φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), t; - return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ); - }; - d3.geo.graticule = function() { - var x1, x0, X1, X0, y1, y0, Y1, Y0, dx = 10, dy = dx, DX = 90, DY = 360, x, y, X, Y, precision = 2.5; - function graticule() { - return { - type: "MultiLineString", - coordinates: lines() - }; - } - function lines() { - return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X).concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)).concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { - return abs(x % DX) > ε; - }).map(x)).concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { - return abs(y % DY) > ε; - }).map(y)); - } - graticule.lines = function() { - return lines().map(function(coordinates) { - return { - type: "LineString", - coordinates: coordinates - }; - }); - }; - graticule.outline = function() { - return { - type: "Polygon", - coordinates: [ X(X0).concat(Y(Y1).slice(1), X(X1).reverse().slice(1), Y(Y0).reverse().slice(1)) ] - }; - }; - graticule.extent = function(_) { - if (!arguments.length) return graticule.minorExtent(); - return graticule.majorExtent(_).minorExtent(_); - }; - graticule.majorExtent = function(_) { - if (!arguments.length) return [ [ X0, Y0 ], [ X1, Y1 ] ]; - X0 = +_[0][0], X1 = +_[1][0]; - Y0 = +_[0][1], Y1 = +_[1][1]; - if (X0 > X1) _ = X0, X0 = X1, X1 = _; - if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; - return graticule.precision(precision); - }; - graticule.minorExtent = function(_) { - if (!arguments.length) return [ [ x0, y0 ], [ x1, y1 ] ]; - x0 = +_[0][0], x1 = +_[1][0]; - y0 = +_[0][1], y1 = +_[1][1]; - if (x0 > x1) _ = x0, x0 = x1, x1 = _; - if (y0 > y1) _ = y0, y0 = y1, y1 = _; - return graticule.precision(precision); - }; - graticule.step = function(_) { - if (!arguments.length) return graticule.minorStep(); - return graticule.majorStep(_).minorStep(_); - }; - graticule.majorStep = function(_) { - if (!arguments.length) return [ DX, DY ]; - DX = +_[0], DY = +_[1]; - return graticule; - }; - graticule.minorStep = function(_) { - if (!arguments.length) return [ dx, dy ]; - dx = +_[0], dy = +_[1]; - return graticule; - }; - graticule.precision = function(_) { - if (!arguments.length) return precision; - precision = +_; - x = d3_geo_graticuleX(y0, y1, 90); - y = d3_geo_graticuleY(x0, x1, precision); - X = d3_geo_graticuleX(Y0, Y1, 90); - Y = d3_geo_graticuleY(X0, X1, precision); - return graticule; - }; - return graticule.majorExtent([ [ -180, -90 + ε ], [ 180, 90 - ε ] ]).minorExtent([ [ -180, -80 - ε ], [ 180, 80 + ε ] ]); - }; - function d3_geo_graticuleX(y0, y1, dy) { - var y = d3.range(y0, y1 - ε, dy).concat(y1); - return function(x) { - return y.map(function(y) { - return [ x, y ]; - }); - }; - } - function d3_geo_graticuleY(x0, x1, dx) { - var x = d3.range(x0, x1 - ε, dx).concat(x1); - return function(y) { - return x.map(function(x) { - return [ x, y ]; - }); - }; - } - function d3_source(d) { - return d.source; - } - function d3_target(d) { - return d.target; - } - d3.geo.greatArc = function() { - var source = d3_source, source_, target = d3_target, target_; - function greatArc() { - return { - type: "LineString", - coordinates: [ source_ || source.apply(this, arguments), target_ || target.apply(this, arguments) ] - }; - } - greatArc.distance = function() { - return d3.geo.distance(source_ || source.apply(this, arguments), target_ || target.apply(this, arguments)); - }; - greatArc.source = function(_) { - if (!arguments.length) return source; - source = _, source_ = typeof _ === "function" ? null : _; - return greatArc; - }; - greatArc.target = function(_) { - if (!arguments.length) return target; - target = _, target_ = typeof _ === "function" ? null : _; - return greatArc; - }; - greatArc.precision = function() { - return arguments.length ? greatArc : 0; - }; - return greatArc; - }; - d3.geo.interpolate = function(source, target) { - return d3_geo_interpolate(source[0] * d3_radians, source[1] * d3_radians, target[0] * d3_radians, target[1] * d3_radians); - }; - function d3_geo_interpolate(x0, y0, x1, y1) { - var cy0 = Math.cos(y0), sy0 = Math.sin(y0), cy1 = Math.cos(y1), sy1 = Math.sin(y1), kx0 = cy0 * Math.cos(x0), ky0 = cy0 * Math.sin(x0), kx1 = cy1 * Math.cos(x1), ky1 = cy1 * Math.sin(x1), d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), k = 1 / Math.sin(d); - var interpolate = d ? function(t) { - var B = Math.sin(t *= d) * k, A = Math.sin(d - t) * k, x = A * kx0 + B * kx1, y = A * ky0 + B * ky1, z = A * sy0 + B * sy1; - return [ Math.atan2(y, x) * d3_degrees, Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees ]; - } : function() { - return [ x0 * d3_degrees, y0 * d3_degrees ]; - }; - interpolate.distance = d; - return interpolate; - } - d3.geo.length = function(object) { - d3_geo_lengthSum = 0; - d3.geo.stream(object, d3_geo_length); - return d3_geo_lengthSum; - }; - var d3_geo_lengthSum; - var d3_geo_length = { - sphere: d3_noop, - point: d3_noop, - lineStart: d3_geo_lengthLineStart, - lineEnd: d3_noop, - polygonStart: d3_noop, - polygonEnd: d3_noop - }; - function d3_geo_lengthLineStart() { - var λ0, sinφ0, cosφ0; - d3_geo_length.point = function(λ, φ) { - λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ); - d3_geo_length.point = nextPoint; - }; - d3_geo_length.lineEnd = function() { - d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; - }; - function nextPoint(λ, φ) { - var sinφ = Math.sin(φ *= d3_radians), cosφ = Math.cos(φ), t = abs((λ *= d3_radians) - λ0), cosΔλ = Math.cos(t); - d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ); - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ; - } - } - function d3_geo_azimuthal(scale, angle) { - function azimuthal(λ, φ) { - var cosλ = Math.cos(λ), cosφ = Math.cos(φ), k = scale(cosλ * cosφ); - return [ k * cosφ * Math.sin(λ), k * Math.sin(φ) ]; - } - azimuthal.invert = function(x, y) { - var ρ = Math.sqrt(x * x + y * y), c = angle(ρ), sinc = Math.sin(c), cosc = Math.cos(c); - return [ Math.atan2(x * sinc, ρ * cosc), Math.asin(ρ && y * sinc / ρ) ]; - }; - return azimuthal; - } - var d3_geo_azimuthalEqualArea = d3_geo_azimuthal(function(cosλcosφ) { - return Math.sqrt(2 / (1 + cosλcosφ)); - }, function(ρ) { - return 2 * Math.asin(ρ / 2); - }); - (d3.geo.azimuthalEqualArea = function() { - return d3_geo_projection(d3_geo_azimuthalEqualArea); - }).raw = d3_geo_azimuthalEqualArea; - var d3_geo_azimuthalEquidistant = d3_geo_azimuthal(function(cosλcosφ) { - var c = Math.acos(cosλcosφ); - return c && c / Math.sin(c); - }, d3_identity); - (d3.geo.azimuthalEquidistant = function() { - return d3_geo_projection(d3_geo_azimuthalEquidistant); - }).raw = d3_geo_azimuthalEquidistant; - function d3_geo_conicConformal(φ0, φ1) { - var cosφ0 = Math.cos(φ0), t = function(φ) { - return Math.tan(π / 4 + φ / 2); - }, n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), F = cosφ0 * Math.pow(t(φ0), n) / n; - if (!n) return d3_geo_mercator; - function forward(λ, φ) { - if (F > 0) { - if (φ < -halfπ + ε) φ = -halfπ + ε; - } else { - if (φ > halfπ - ε) φ = halfπ - ε; - } - var ρ = F / Math.pow(t(φ), n); - return [ ρ * Math.sin(n * λ), F - ρ * Math.cos(n * λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = F - y, ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y); - return [ Math.atan2(x, ρ0_y) / n, 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ ]; - }; - return forward; - } - (d3.geo.conicConformal = function() { - return d3_geo_conic(d3_geo_conicConformal); - }).raw = d3_geo_conicConformal; - function d3_geo_conicEquidistant(φ0, φ1) { - var cosφ0 = Math.cos(φ0), n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), G = cosφ0 / n + φ0; - if (abs(n) < ε) return d3_geo_equirectangular; - function forward(λ, φ) { - var ρ = G - φ; - return [ ρ * Math.sin(n * λ), G - ρ * Math.cos(n * λ) ]; - } - forward.invert = function(x, y) { - var ρ0_y = G - y; - return [ Math.atan2(x, ρ0_y) / n, G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) ]; - }; - return forward; - } - (d3.geo.conicEquidistant = function() { - return d3_geo_conic(d3_geo_conicEquidistant); - }).raw = d3_geo_conicEquidistant; - var d3_geo_gnomonic = d3_geo_azimuthal(function(cosλcosφ) { - return 1 / cosλcosφ; - }, Math.atan); - (d3.geo.gnomonic = function() { - return d3_geo_projection(d3_geo_gnomonic); - }).raw = d3_geo_gnomonic; - function d3_geo_mercator(λ, φ) { - return [ λ, Math.log(Math.tan(π / 4 + φ / 2)) ]; - } - d3_geo_mercator.invert = function(x, y) { - return [ x, 2 * Math.atan(Math.exp(y)) - halfπ ]; - }; - function d3_geo_mercatorProjection(project) { - var m = d3_geo_projection(project), scale = m.scale, translate = m.translate, clipExtent = m.clipExtent, clipAuto; - m.scale = function() { - var v = scale.apply(m, arguments); - return v === m ? clipAuto ? m.clipExtent(null) : m : v; - }; - m.translate = function() { - var v = translate.apply(m, arguments); - return v === m ? clipAuto ? m.clipExtent(null) : m : v; - }; - m.clipExtent = function(_) { - var v = clipExtent.apply(m, arguments); - if (v === m) { - if (clipAuto = _ == null) { - var k = π * scale(), t = translate(); - clipExtent([ [ t[0] - k, t[1] - k ], [ t[0] + k, t[1] + k ] ]); - } - } else if (clipAuto) { - v = null; - } - return v; - }; - return m.clipExtent(null); - } - (d3.geo.mercator = function() { - return d3_geo_mercatorProjection(d3_geo_mercator); - }).raw = d3_geo_mercator; - var d3_geo_orthographic = d3_geo_azimuthal(function() { - return 1; - }, Math.asin); - (d3.geo.orthographic = function() { - return d3_geo_projection(d3_geo_orthographic); - }).raw = d3_geo_orthographic; - var d3_geo_stereographic = d3_geo_azimuthal(function(cosλcosφ) { - return 1 / (1 + cosλcosφ); - }, function(ρ) { - return 2 * Math.atan(ρ); - }); - (d3.geo.stereographic = function() { - return d3_geo_projection(d3_geo_stereographic); - }).raw = d3_geo_stereographic; - function d3_geo_transverseMercator(λ, φ) { - return [ Math.log(Math.tan(π / 4 + φ / 2)), -λ ]; - } - d3_geo_transverseMercator.invert = function(x, y) { - return [ -y, 2 * Math.atan(Math.exp(x)) - halfπ ]; - }; - (d3.geo.transverseMercator = function() { - var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), center = projection.center, rotate = projection.rotate; - projection.center = function(_) { - return _ ? center([ -_[1], _[0] ]) : (_ = center(), [ _[1], -_[0] ]); - }; - projection.rotate = function(_) { - return _ ? rotate([ _[0], _[1], _.length > 2 ? _[2] + 90 : 90 ]) : (_ = rotate(), - [ _[0], _[1], _[2] - 90 ]); - }; - return rotate([ 0, 0, 90 ]); - }).raw = d3_geo_transverseMercator; d3.geom = {}; function d3_geom_pointX(d) { return d[0]; @@ -5121,6 +3174,60 @@ arc.circle = null; } } + function d3_geom_clipLine(x0, y0, x1, y1) { + return function(line) { + var a = line.a, b = line.b, ax = a.x, ay = a.y, bx = b.x, by = b.y, 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) line.a = { + x: ax + t0 * dx, + y: ay + t0 * dy + }; + if (t1 < 1) line.b = { + x: ax + t1 * dx, + y: ay + t1 * dy + }; + return line; + }; + } function d3_geom_voronoiClipEdges(extent) { var edges = d3_geom_voronoiEdges, clip = d3_geom_clipLine(extent[0][0], extent[0][1], extent[1][0], extent[1][1]), i = edges.length, e; while (i--) { @@ -8123,6 +6230,9 @@ if (dx0 * dx0 + dy0 * dy0 > dx1 * dx1 + dy1 * dy1) cx0 = cx1, cy0 = cy1; return [ [ cx0 - ox, cy0 - oy ], [ cx0 * r1 / r, cy0 * r1 / r ] ]; } + function d3_true() { + return true; + } function d3_svg_line(projection) { var x = d3_geom_pointX, y = d3_geom_pointY, defined = d3_true, interpolate = d3_svg_lineLinear, interpolateKey = interpolate.key, tension = .7; function line(data) { @@ -8477,6 +6587,12 @@ area.endAngle = area.y1, delete area.y1; return area; }; + function d3_source(d) { + return d.source; + } + function d3_target(d) { + return d.target; + } d3.svg.chord = function() { var source = d3_source, target = d3_target, radius = d3_svg_chordRadius, startAngle = d3_svg_arcStartAngle, endAngle = d3_svg_arcEndAngle; function chord(d, i) { diff --git a/d3.min.js b/d3.min.js index b17878644e1ef5..bade035b7f0d3f 100644 --- a/d3.min.js +++ b/d3.min.js @@ -1,5 +1,4 @@ -!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function i(n){return!isNaN(n)}function u(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)<0?r=u+1:i=u}return r},right:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)>0?i=u:r=u+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function f(n){return(n+="")===bo||n[0]===_o?_o+n:n}function s(n){return(n+="")[0]===_o?n.slice(1):n}function h(n){return f(n)in this._}function p(n){return(n=f(n))in this._&&delete this._[n]}function g(){var n=[];for(var t in this._)n.push(s(t));return n}function v(){var n=0;for(var t in this._)++n;return n}function d(){for(var n in this._)return!1;return!0}function y(){this._=Object.create(null)}function m(n){return n}function M(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function x(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=wo.length;r>e;++e){var i=wo[e]+t;if(i in n)return i}}function b(){}function _(){}function w(n){function t(){for(var t,r=e,i=-1,u=r.length;++ie;e++)for(var i,u=n[e],o=0,a=u.length;a>o;o++)(i=u[o])&&t(i,o,e);return n}function Z(n){return ko(n,qo),n}function V(n){var t,e;return function(r,i,u){var o,a=n[u].update,l=a.length;for(u!=e&&(e=u,t=0),i>=t&&(t=i+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var c=To.get(n);return c&&(n=c,l=B),a?t?i:r:t?b:u}function $(n,t){return function(e){var r=ao.event;ao.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ao.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++Do,i="click"+r,u=ao.select(t(e)).on("touchmove"+r,S).on("dragstart"+r,S).on("selectstart"+r,S);if(null==Ro&&(Ro="onselectstart"in e?!1:x(e.style,"userSelect")),Ro){var o=n(e).style,a=o[Ro];o[Ro]="none"}return function(n){if(u.on(r,null),Ro&&(o[Ro]=a),n){var t=function(){u.on(i,null)};u.on(i,function(){S(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Po){var u=t(n);if(u.scrollX||u.scrollY){r=ao.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Po=!(o.f||o.e),r.remove()}}return Po?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}function G(){return ao.event.changedTouches[0].identifier}function K(n){return n>0?1:0>n?-1:0}function Q(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function nn(n){return n>1?0:-1>n?Fo:Math.acos(n)}function tn(n){return n>1?Io:-1>n?-Io:Math.asin(n)}function en(n){return((n=Math.exp(n))-1/n)/2}function rn(n){return((n=Math.exp(n))+1/n)/2}function un(n){return((n=Math.exp(2*n))-1)/(n+1)}function on(n){return(n=Math.sin(n/2))*n}function an(){}function ln(n,t,e){return this instanceof ln?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ln?new ln(n.h,n.s,n.l):_n(""+n,wn,ln):new ln(n,t,e)}function cn(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?u+(o-u)*n/60:180>n?o:240>n?u+(o-u)*(240-n)/60:u}function i(n){return Math.round(255*r(n))}var u,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,u=2*e-o,new mn(i(n+120),i(n),i(n-120))}function fn(n,t,e){return this instanceof fn?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof fn?new fn(n.h,n.c,n.l):n instanceof hn?gn(n.l,n.a,n.b):gn((n=Sn((n=ao.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new fn(n,t,e)}function sn(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new hn(e,Math.cos(n*=Yo)*t,Math.sin(n)*t)}function hn(n,t,e){return this instanceof hn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof hn?new hn(n.l,n.a,n.b):n instanceof fn?sn(n.h,n.c,n.l):Sn((n=mn(n)).r,n.g,n.b):new hn(n,t,e)}function pn(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return i=vn(i)*na,r=vn(r)*ta,u=vn(u)*ea,new mn(yn(3.2404542*i-1.5371385*r-.4985314*u),yn(-.969266*i+1.8760108*r+.041556*u),yn(.0556434*i-.2040259*r+1.0572252*u))}function gn(n,t,e){return n>0?new fn(Math.atan2(e,t)*Zo,Math.sqrt(t*t+e*e),n):new fn(NaN,NaN,n)}function vn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function dn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function yn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function mn(n,t,e){return this instanceof mn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof mn?new mn(n.r,n.g,n.b):_n(""+n,mn,cn):new mn(n,t,e)}function Mn(n){return new mn(n>>16,n>>8&255,255&n)}function xn(n){return Mn(n)+""}function bn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function _n(n,t,e){var r,i,u,o=0,a=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(Nn(i[0]),Nn(i[1]),Nn(i[2]))}return(u=ua.get(n))?t(u.r,u.g,u.b):(null==n||"#"!==n.charAt(0)||isNaN(u=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&u)>>4,o=o>>4|o,a=240&u,a=a>>4|a,l=15&u,l=l<<4|l):7===n.length&&(o=(16711680&u)>>16,a=(65280&u)>>8,l=255&u)),t(o,a,l))}function wn(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-u,l=(o+u)/2;return a?(i=.5>l?a/(o+u):a/(2-o-u),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=NaN,i=l>0&&1>l?0:r),new ln(r,i,l)}function Sn(n,t,e){n=kn(n),t=kn(t),e=kn(e);var r=dn((.4124564*n+.3575761*t+.1804375*e)/na),i=dn((.2126729*n+.7151522*t+.072175*e)/ta),u=dn((.0193339*n+.119192*t+.9503041*e)/ea);return hn(116*i-16,500*(r-i),200*(i-u))}function kn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Nn(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function En(n){return"function"==typeof n?n:function(){return n}}function An(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Cn(t,e,n,r)}}function Cn(n,t,e,r){function i(){var n,t=l.status;if(!t&&Ln(l)||t>=200&&300>t||304===t){try{n=e.call(u,l)}catch(r){return void o.error.call(u,r)}o.load.call(u,n)}else o.error.call(u,l)}var u={},o=ao.dispatch("beforesend","progress","load","error"),a={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(n)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(n){var t=ao.event;ao.event=n;try{o.progress.call(u,l)}finally{ao.event=t}},u.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",u)},u.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",u):t},u.responseType=function(n){return arguments.length?(c=n,u):c},u.response=function(n){return e=n,u},["get","post"].forEach(function(n){u[n]=function(){return u.send.apply(u,[n].concat(co(arguments)))}}),u.send=function(e,r,i){if(2===arguments.length&&"function"==typeof r&&(i=r,r=null),l.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),l.setRequestHeader)for(var f in a)l.setRequestHeader(f,a[f]);return null!=t&&l.overrideMimeType&&l.overrideMimeType(t),null!=c&&(l.responseType=c),null!=i&&u.on("error",i).on("load",function(n){i(null,n)}),o.beforesend.call(u,l),l.send(null==r?null:r),u},u.abort=function(){return l.abort(),u},ao.rebind(u,o,"on"),null==r?u:u.get(zn(r))}function zn(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function Ln(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qn(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var i=e+t,u={c:n,t:i,n:null};return aa?aa.n=u:oa=u,aa=u,la||(ca=clearTimeout(ca),la=1,fa(Tn)),u}function Tn(){var n=Rn(),t=Dn()-n;t>24?(isFinite(t)&&(clearTimeout(ca),ca=setTimeout(Tn,t)),la=0):(la=1,fa(Tn))}function Rn(){for(var n=Date.now(),t=oa;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Dn(){for(var n,t=oa,e=1/0;t;)t.c?(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function jn(n){var t=n.decimal,e=n.thousands,r=n.grouping,i=n.currency,u=r&&e?function(n,t){for(var i=n.length,u=[],o=0,a=r[0],l=0;i>0&&a>0&&(l+a+1>t&&(a=Math.max(1,t-l)),u.push(n.substring(i-=a,i+a)),!((l+=a+1)>t));)a=r[o=(o+1)%r.length];return u.reverse().join(e)}:m;return function(n){var e=ha.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",l=e[4]||"",c=e[5],f=+e[6],s=e[7],h=e[8],p=e[9],g=1,v="",d="",y=!1,m=!0;switch(h&&(h=+h.substring(1)),(c||"0"===r&&"="===o)&&(c=r="0",o="="),p){case"n":s=!0,p="g";break;case"%":g=100,d="%",p="f";break;case"p":g=100,d="%",p="r";break;case"b":case"o":case"x":case"X":"#"===l&&(v="0"+p.toLowerCase());case"c":m=!1;case"d":y=!0,h=0;break;case"s":g=-1,p="r"}"$"===l&&(v=i[0],d=i[1]),"r"!=p||h||(p="g"),null!=h&&("g"==p?h=Math.max(1,Math.min(21,h)):"e"!=p&&"f"!=p||(h=Math.max(0,Math.min(20,h)))),p=pa.get(p)||Fn;var M=c&&s;return function(n){var e=d;if(y&&n%1)return"";var i=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>g){var l=ao.formatPrefix(n,h);n=l.scale(n),e=l.symbol+d}else n*=g;n=p(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=m?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!c&&s&&(x=u(x,1/0));var S=v.length+x.length+b.length+(M?0:i.length),k=f>S?new Array(S=f-S+1).join(r):"";return M&&(x=u(k+x,k.length?f-b.length:1/0)),i+=v,n=x+b,("<"===o?i+n+k:">"===o?k+i+n:"^"===o?k.substring(0,S>>=1)+i+n+k.substring(S):i+(M?n:k+n))+e}}}function Fn(n){return n+""}function Hn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function On(n,t,e){function r(t){var e=n(t),r=u(e,1);return r-t>t-e?e:r}function i(e){return t(e=n(new va(e-1)),1),e}function u(n,e){return t(n=new va(+n),e),n}function o(n,r,u){var o=i(n),a=[];if(u>1)for(;r>o;)e(o)%u||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{va=Hn;var r=new Hn;return r._=n,o(r,t,e)}finally{va=Date}}n.floor=n,n.round=r,n.ceil=i,n.offset=u,n.range=o;var l=n.utc=In(n);return l.floor=l,l.round=In(r),l.ceil=In(i),l.offset=In(u),l.range=a,n}function In(n){return function(t,e){try{va=Hn;var r=new Hn;return r._=t,n(r,e)._}finally{va=Date}}}function Yn(n){function t(n){function t(t){for(var e,i,u,o=[],a=-1,l=0;++aa;){if(r>=c)return-1;if(i=t.charCodeAt(a++),37===i){if(o=t.charAt(a++),u=C[o in ya?t.charAt(a++):o],!u||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){N.lastIndex=0;var r=N.exec(t.slice(e));return r?(n.m=E.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,A.c.toString(),t,r)}function l(n,t,r){return e(n,A.x.toString(),t,r)}function c(n,t,r){return e(n,A.X.toString(),t,r)}function f(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var s=n.dateTime,h=n.date,p=n.time,g=n.periods,v=n.days,d=n.shortDays,y=n.months,m=n.shortMonths;t.utc=function(n){function e(n){try{va=Hn;var t=new va;return t._=n,r(t)}finally{va=Date}}var r=t(n);return e.parse=function(n){try{va=Hn;var t=r.parse(n);return t&&t._}finally{va=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ct;var M=ao.map(),x=Vn(v),b=Xn(v),_=Vn(d),w=Xn(d),S=Vn(y),k=Xn(y),N=Vn(m),E=Xn(m);g.forEach(function(n,t){M.set(n.toLowerCase(),t)});var A={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return m[n.getMonth()]},B:function(n){return y[n.getMonth()]},c:t(s),d:function(n,t){return Zn(n.getDate(),t,2)},e:function(n,t){return Zn(n.getDate(),t,2)},H:function(n,t){return Zn(n.getHours(),t,2)},I:function(n,t){return Zn(n.getHours()%12||12,t,2)},j:function(n,t){return Zn(1+ga.dayOfYear(n),t,3)},L:function(n,t){return Zn(n.getMilliseconds(),t,3)},m:function(n,t){return Zn(n.getMonth()+1,t,2)},M:function(n,t){return Zn(n.getMinutes(),t,2)},p:function(n){return g[+(n.getHours()>=12)]},S:function(n,t){return Zn(n.getSeconds(),t,2)},U:function(n,t){return Zn(ga.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Zn(ga.mondayOfYear(n),t,2)},x:t(h),X:t(p),y:function(n,t){return Zn(n.getFullYear()%100,t,2)},Y:function(n,t){return Zn(n.getFullYear()%1e4,t,4)},Z:at,"%":function(){return"%"}},C={a:r,A:i,b:u,B:o,c:a,d:tt,e:tt,H:rt,I:rt,j:et,L:ot,m:nt,M:it,p:f,S:ut,U:Bn,w:$n,W:Wn,x:l,X:c,y:Gn,Y:Jn,Z:Kn,"%":lt};return t}function Zn(n,t,e){var r=0>n?"-":"",i=(r?-n:n)+"",u=i.length;return r+(e>u?new Array(e-u+1).join(t)+i:i)}function Vn(n){return new RegExp("^(?:"+n.map(ao.requote).join("|")+")","i")}function Xn(n){for(var t=new c,e=-1,r=n.length;++e68?1900:2e3)}function nt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function tt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function et(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function rt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function it(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function ut(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ot(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function at(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=xo(t)/60|0,i=xo(t)%60;return e+Zn(r,"0",2)+Zn(i,"0",2)}function lt(n,t,e){Ma.lastIndex=0;var r=Ma.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ct(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,l=Math.cos(t),c=Math.sin(t),f=u*c,s=i*l+f*Math.cos(a),h=f*o*Math.sin(a);ka.add(Math.atan2(h,s)),r=n,i=l,u=c}var t,e,r,i,u;Na.point=function(o,a){Na.point=n,r=(t=o)*Yo,i=Math.cos(a=(e=a)*Yo/2+Fo/4),u=Math.sin(a)},Na.lineEnd=function(){n(t,e)}}function dt(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function yt(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function mt(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Mt(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function xt(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function bt(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function _t(n){return[Math.atan2(n[1],n[0]),tn(n[2])]}function wt(n,t){return xo(n[0]-t[0])a;++a)i.point((e=n[a])[0],e[1]);return void i.lineEnd()}var l=new Tt(e,n,null,!0),c=new Tt(e,null,l,!1);l.o=c,u.push(l),o.push(c),l=new Tt(r,n,null,!1),c=new Tt(r,null,l,!0),l.o=c,u.push(l),o.push(c)}}),o.sort(t),qt(u),qt(o),u.length){for(var a=0,l=e,c=o.length;c>a;++a)o[a].e=l=!l;for(var f,s,h=u[0];;){for(var p=h,g=!0;p.v;)if((p=p.n)===h)return;f=p.z,i.lineStart();do{if(p.v=p.o.v=!0,p.e){if(g)for(var a=0,c=f.length;c>a;++a)i.point((s=f[a])[0],s[1]);else r(p.x,p.n.x,1,i);p=p.n}else{if(g){f=p.p.z;for(var a=f.length-1;a>=0;--a)i.point((s=f[a])[0],s[1])}else r(p.x,p.p.x,-1,i);p=p.p}p=p.o,f=p.z,g=!g}while(!p.v);i.lineEnd()}}}function qt(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r0){for(b||(u.polygonStart(),b=!0),u.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),p.push(e.filter(Dt))}var p,g,v,d=t(u),y=i.invert(r[0],r[1]),m={point:o,lineStart:l,lineEnd:c,polygonStart:function(){m.point=f,m.lineStart=s,m.lineEnd=h,p=[],g=[]},polygonEnd:function(){m.point=o,m.lineStart=l,m.lineEnd=c,p=ao.merge(p);var n=Ot(y,g);p.length?(b||(u.polygonStart(),b=!0),Lt(p,Ut,n,e,u)):n&&(b||(u.polygonStart(),b=!0),u.lineStart(),e(null,null,1,u),u.lineEnd()),b&&(u.polygonEnd(),b=!1),p=g=null},sphere:function(){u.polygonStart(),u.lineStart(),e(null,null,1,u),u.lineEnd(),u.polygonEnd()}},M=Pt(),x=t(M),b=!1;return m}}function Dt(n){return n.length>1}function Pt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:b,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Ut(n,t){return((n=n.x)[0]<0?n[1]-Io-Uo:Io-n[1])-((t=t.x)[0]<0?t[1]-Io-Uo:Io-t[1])}function jt(n){var t,e=NaN,r=NaN,i=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(u,o){var a=u>0?Fo:-Fo,l=xo(u-e);xo(l-Fo)0?Io:-Io),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(u,r),t=0):i!==a&&l>=Fo&&(xo(e-i)Uo?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*o)):(t+r)/2}function Ht(n,t,e,r){var i;if(null==n)i=e*Io,r.point(-Fo,i),r.point(0,i),r.point(Fo,i),r.point(Fo,0),r.point(Fo,-i),r.point(0,-i),r.point(-Fo,-i),r.point(-Fo,0),r.point(-Fo,i);else if(xo(n[0]-t[0])>Uo){var u=n[0]a;++a){var c=t[a],f=c.length;if(f)for(var s=c[0],h=s[0],p=s[1]/2+Fo/4,g=Math.sin(p),v=Math.cos(p),d=1;;){d===f&&(d=0),n=c[d];var y=n[0],m=n[1]/2+Fo/4,M=Math.sin(m),x=Math.cos(m),b=y-h,_=b>=0?1:-1,w=_*b,S=w>Fo,k=g*M;if(ka.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),u+=S?b+_*Ho:b,S^h>=e^y>=e){var N=mt(dt(s),dt(n));bt(N);var E=mt(i,N);bt(E);var A=(S^b>=0?-1:1)*tn(E[2]);(r>A||r===A&&(N[0]||N[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=y,g=M,v=x,s=n}}return(-Uo>u||Uo>u&&-Uo>ka)^1&o}function It(n){function t(n,t){return Math.cos(n)*Math.cos(t)>u}function e(n){var e,u,l,c,f;return{lineStart:function(){c=l=!1,f=1},point:function(s,h){var p,g=[s,h],v=t(s,h),d=o?v?0:i(s,h):v?i(s+(0>s?Fo:-Fo),h):0;if(!e&&(c=l=v)&&n.lineStart(),v!==l&&(p=r(e,g),(wt(e,p)||wt(g,p))&&(g[0]+=Uo,g[1]+=Uo,v=t(g[0],g[1]))),v!==l)f=0,v?(n.lineStart(),p=r(g,e),n.point(p[0],p[1])):(p=r(e,g),n.point(p[0],p[1]),n.lineEnd()),e=p;else if(a&&e&&o^v){var y;d&u||!(y=r(g,e,!0))||(f=0,o?(n.lineStart(),n.point(y[0][0],y[0][1]),n.point(y[1][0],y[1][1]),n.lineEnd()):(n.point(y[1][0],y[1][1]),n.lineEnd(),n.lineStart(),n.point(y[0][0],y[0][1])))}!v||e&&wt(e,g)||n.point(g[0],g[1]),e=g,l=v,u=d},lineEnd:function(){l&&n.lineEnd(),e=null},clean:function(){return f|(c&&l)<<1}}}function r(n,t,e){var r=dt(n),i=dt(t),o=[1,0,0],a=mt(r,i),l=yt(a,a),c=a[0],f=l-c*c;if(!f)return!e&&n;var s=u*l/f,h=-u*c/f,p=mt(o,a),g=xt(o,s),v=xt(a,h);Mt(g,v);var d=p,y=yt(g,d),m=yt(d,d),M=y*y-m*(yt(g,g)-1);if(!(0>M)){var x=Math.sqrt(M),b=xt(d,(-y-x)/m);if(Mt(b,g),b=_t(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],N=t[1];w>S&&(_=w,w=S,S=_);var E=S-w,A=xo(E-Fo)E;if(!A&&k>N&&(_=k,k=N,N=_),C?A?k+N>0^b[1]<(xo(b[0]-w)Fo^(w<=b[0]&&b[0]<=S)){var z=xt(d,(-y+x)/m);return Mt(z,g),[b,_t(z)]}}}function i(t,e){var r=o?n:Fo-n,i=0;return-r>t?i|=1:t>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}var u=Math.cos(n),o=u>0,a=xo(u)>Uo,l=ve(n,6*Yo);return Rt(t,e,l,o?[0,-n]:[-Fo,n-Fo])}function Yt(n,t,e,r){return function(i){var u,o=i.a,a=i.b,l=o.x,c=o.y,f=a.x,s=a.y,h=0,p=1,g=f-l,v=s-c;if(u=n-l,g||!(u>0)){if(u/=g,0>g){if(h>u)return;p>u&&(p=u)}else if(g>0){if(u>p)return;u>h&&(h=u)}if(u=e-l,g||!(0>u)){if(u/=g,0>g){if(u>p)return;u>h&&(h=u)}else if(g>0){if(h>u)return;p>u&&(p=u)}if(u=t-c,v||!(u>0)){if(u/=v,0>v){if(h>u)return;p>u&&(p=u)}else if(v>0){if(u>p)return;u>h&&(h=u)}if(u=r-c,v||!(0>u)){if(u/=v,0>v){if(u>p)return;u>h&&(h=u)}else if(v>0){if(h>u)return;p>u&&(p=u)}return h>0&&(i.a={x:l+h*g,y:c+h*v}),1>p&&(i.b={x:l+p*g,y:c+p*v}),i}}}}}}function Zt(n,t,e,r){function i(r,i){return xo(r[0]-n)0?0:3:xo(r[0]-e)0?2:1:xo(r[1]-t)0?1:0:i>0?3:2}function u(n,t){return o(n.x,t.x)}function o(n,t){var e=i(n,1),r=i(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function l(n){for(var t=0,e=d.length,r=n[1],i=0;e>i;++i)for(var u,o=1,a=d[i],l=a.length,c=a[0];l>o;++o)u=a[o],c[1]<=r?u[1]>r&&Q(c,u,n)>0&&++t:u[1]<=r&&Q(c,u,n)<0&&--t,c=u;return 0!==t}function c(u,a,l,c){var f=0,s=0;if(null==u||(f=i(u,l))!==(s=i(a,l))||o(u,a)<0^l>0){do c.point(0===f||3===f?n:e,f>1?r:t);while((f=(f+l+4)%4)!==s)}else c.point(a[0],a[1])}function f(i,u){return i>=n&&e>=i&&u>=t&&r>=u}function s(n,t){f(n,t)&&a.point(n,t)}function h(){C.point=g,d&&d.push(y=[]),S=!0,w=!1,b=_=NaN}function p(){v&&(g(m,M),x&&w&&E.rejoin(),v.push(E.buffer())),C.point=s,w&&a.lineEnd()}function g(n,t){n=Math.max(-Ha,Math.min(Ha,n)),t=Math.max(-Ha,Math.min(Ha,t));var e=f(n,t);if(d&&y.push([n,t]),S)m=n,M=t,x=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};A(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,y,m,M,x,b,_,w,S,k,N=a,E=Pt(),A=Yt(n,t,e,r),C={point:s,lineStart:h,lineEnd:p,polygonStart:function(){a=E,v=[],d=[],k=!0},polygonEnd:function(){a=N,v=ao.merge(v);var t=l([n,r]),e=k&&t,i=v.length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),c(null,null,1,a),a.lineEnd()),i&&Lt(v,u,t,c,a),a.polygonEnd()),v=d=y=null}};return C}}function Vt(n){var t=0,e=Fo/3,r=ae(n),i=r(t,e);return i.parallels=function(n){return arguments.length?r(t=n[0]*Fo/180,e=n[1]*Fo/180):[t/Fo*180,e/Fo*180]},i}function Xt(n,t){function e(n,t){var e=Math.sqrt(u-2*i*Math.sin(t))/i;return[e*Math.sin(n*=i),o-e*Math.cos(n)]}var r=Math.sin(n),i=(r+Math.sin(t))/2,u=1+r*(2*i-r),o=Math.sqrt(u)/i;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/i,tn((u-(n*n+e*e)*i*i)/(2*i))]},e}function $t(){function n(n,t){Ia+=i*n-r*t,r=n,i=t}var t,e,r,i;$a.point=function(u,o){$a.point=n,t=r=u,e=i=o},$a.lineEnd=function(){n(t,e)}}function Bt(n,t){Ya>n&&(Ya=n),n>Va&&(Va=n),Za>t&&(Za=t),t>Xa&&(Xa=t)}function Wt(){function n(n,t){o.push("M",n,",",t,u)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function i(){o.push("Z")}var u=Jt(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return u=Jt(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Jt(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function Gt(n,t){Ca+=n,za+=t,++La}function Kt(){function n(n,r){var i=n-t,u=r-e,o=Math.sqrt(i*i+u*u);qa+=o*(t+n)/2,Ta+=o*(e+r)/2,Ra+=o,Gt(t=n,e=r)}var t,e;Wa.point=function(r,i){Wa.point=n,Gt(t=r,e=i)}}function Qt(){Wa.point=Gt}function ne(){function n(n,t){var e=n-r,u=t-i,o=Math.sqrt(e*e+u*u);qa+=o*(r+n)/2,Ta+=o*(i+t)/2,Ra+=o,o=i*n-r*t,Da+=o*(r+n),Pa+=o*(i+t),Ua+=3*o,Gt(r=n,i=t)}var t,e,r,i;Wa.point=function(u,o){Wa.point=n,Gt(t=r=u,e=i=o)},Wa.lineEnd=function(){n(t,e)}}function te(n){function t(t,e){n.moveTo(t+o,e),n.arc(t,e,o,0,Ho)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function i(){a.point=t}function u(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:i,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=i,a.point=t},pointRadius:function(n){return o=n,a},result:b};return a}function ee(n){function t(n){return(a?r:e)(n)}function e(t){return ue(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=NaN,S.point=u,t.lineStart()}function u(e,r){var u=dt([e,r]),o=n(e,r);i(M,x,m,b,_,w,M=o[0],x=o[1],m=e,b=u[0],_=u[1],w=u[2],a,t),t.point(M,x)}function o(){S.point=e,t.lineEnd()}function l(){ -r(),S.point=c,S.lineEnd=f}function c(n,t){u(s=n,h=t),p=M,g=x,v=b,d=_,y=w,S.point=u}function f(){i(M,x,m,b,_,w,p,g,s,v,d,y,a,t),S.lineEnd=o,o()}var s,h,p,g,v,d,y,m,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=l},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function i(t,e,r,a,l,c,f,s,h,p,g,v,d,y){var m=f-t,M=s-e,x=m*m+M*M;if(x>4*u&&d--){var b=a+p,_=l+g,w=c+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),N=xo(xo(w)-1)u||xo((m*z+M*L)/x-.5)>.3||o>a*p+l*g+c*v)&&(i(t,e,r,a,l,c,A,C,N,b/=S,_/=S,w,d,y),y.point(A,C),i(A,C,N,b,_,w,f,s,h,p,g,v,d,y))}}var u=.5,o=Math.cos(30*Yo),a=16;return t.precision=function(n){return arguments.length?(a=(u=n*n)>0&&16,t):Math.sqrt(u)},t}function re(n){var t=ee(function(t,e){return n([t*Zo,e*Zo])});return function(n){return le(t(n))}}function ie(n){this.stream=n}function ue(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function oe(n){return ae(function(){return n})()}function ae(n){function t(n){return n=a(n[0]*Yo,n[1]*Yo),[n[0]*h+l,c-n[1]*h]}function e(n){return n=a.invert((n[0]-l)/h,(c-n[1])/h),n&&[n[0]*Zo,n[1]*Zo]}function r(){a=Ct(o=se(y,M,x),u);var n=u(v,d);return l=p-n[0]*h,c=g+n[1]*h,i()}function i(){return f&&(f.valid=!1,f=null),t}var u,o,a,l,c,f,s=ee(function(n,t){return n=u(n,t),[n[0]*h+l,c-n[1]*h]}),h=150,p=480,g=250,v=0,d=0,y=0,M=0,x=0,b=Fa,_=m,w=null,S=null;return t.stream=function(n){return f&&(f.valid=!1),f=le(b(o,s(_(n)))),f.valid=!0,f},t.clipAngle=function(n){return arguments.length?(b=null==n?(w=n,Fa):It((w=+n)*Yo),i()):w},t.clipExtent=function(n){return arguments.length?(S=n,_=n?Zt(n[0][0],n[0][1],n[1][0],n[1][1]):m,i()):S},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(p=+n[0],g=+n[1],r()):[p,g]},t.center=function(n){return arguments.length?(v=n[0]%360*Yo,d=n[1]%360*Yo,r()):[v*Zo,d*Zo]},t.rotate=function(n){return arguments.length?(y=n[0]%360*Yo,M=n[1]%360*Yo,x=n.length>2?n[2]%360*Yo:0,r()):[y*Zo,M*Zo,x*Zo]},ao.rebind(t,s,"precision"),function(){return u=n.apply(this,arguments),t.invert=u.invert&&e,r()}}function le(n){return ue(n,function(t,e){n.point(t*Yo,e*Yo)})}function ce(n,t){return[n,t]}function fe(n,t){return[n>Fo?n-Ho:-Fo>n?n+Ho:n,t]}function se(n,t,e){return n?t||e?Ct(pe(n),ge(t,e)):pe(n):t||e?ge(t,e):fe}function he(n){return function(t,e){return t+=n,[t>Fo?t-Ho:-Fo>t?t+Ho:t,e]}}function pe(n){var t=he(n);return t.invert=he(-n),t}function ge(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),f=c*r+a*i;return[Math.atan2(l*u-f*o,a*r-c*i),tn(f*u+l*o)]}var r=Math.cos(n),i=Math.sin(n),u=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),f=c*u-l*o;return[Math.atan2(l*u+c*o,a*r+f*i),tn(f*r-a*i)]},e}function ve(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,o,a){var l=o*t;null!=i?(i=de(e,i),u=de(e,u),(o>0?u>i:i>u)&&(i+=o*Ho)):(i=n+o*Ho,u=n-.5*l);for(var c,f=i;o>0?f>u:u>f;f-=l)a.point((c=_t([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function de(n,t){var e=dt(t);e[0]-=n,bt(e);var r=nn(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Uo)%(2*Math.PI)}function ye(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function me(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function Me(n){return n.source}function xe(n){return n.target}function be(n,t,e,r){var i=Math.cos(t),u=Math.sin(t),o=Math.cos(r),a=Math.sin(r),l=i*Math.cos(n),c=i*Math.sin(n),f=o*Math.cos(e),s=o*Math.sin(e),h=2*Math.asin(Math.sqrt(on(r-t)+i*o*on(e-n))),p=1/Math.sin(h),g=h?function(n){var t=Math.sin(n*=h)*p,e=Math.sin(h-n)*p,r=e*l+t*f,i=e*c+t*s,o=e*u+t*a;return[Math.atan2(i,r)*Zo,Math.atan2(o,Math.sqrt(r*r+i*i))*Zo]}:function(){return[n*Zo,t*Zo]};return g.distance=h,g}function _e(){function n(n,i){var u=Math.sin(i*=Yo),o=Math.cos(i),a=xo((n*=Yo)-t),l=Math.cos(a);Ja+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*u-e*o*l)*a),e*u+r*o*l),t=n,e=u,r=o}var t,e,r;Ga.point=function(i,u){t=i*Yo,e=Math.sin(u*=Yo),r=Math.cos(u),Ga.point=n},Ga.lineEnd=function(){Ga.point=Ga.lineEnd=b}}function we(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),o=Math.cos(i);return[Math.atan2(n*u,r*o),Math.asin(r&&e*u/r)]},e}function Se(n,t){function e(n,t){o>0?-Io+Uo>t&&(t=-Io+Uo):t>Io-Uo&&(t=Io-Uo);var e=o/Math.pow(i(t),u);return[e*Math.sin(u*n),o-e*Math.cos(u*n)]}var r=Math.cos(n),i=function(n){return Math.tan(Fo/4+n/2)},u=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(i(t)/i(n)),o=r*Math.pow(i(n),u)/u;return u?(e.invert=function(n,t){var e=o-t,r=K(u)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/u,2*Math.atan(Math.pow(o/r,1/u))-Io]},e):Ne}function ke(n,t){function e(n,t){var e=u-t;return[e*Math.sin(i*n),u-e*Math.cos(i*n)]}var r=Math.cos(n),i=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),u=r/i+n;return xo(i)i;i++){for(;r>1&&Q(n[e[r-2]],n[e[r-1]],n[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function qe(n,t){return n[0]-t[0]||n[1]-t[1]}function Te(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Re(n,t,e,r){var i=n[0],u=e[0],o=t[0]-i,a=r[0]-u,l=n[1],c=e[1],f=t[1]-l,s=r[1]-c,h=(a*(l-c)-s*(i-u))/(s*o-a*f);return[i+h*o,l+h*f]}function De(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Pe(){rr(this),this.edge=this.site=this.circle=null}function Ue(n){var t=cl.pop()||new Pe;return t.site=n,t}function je(n){Be(n),ol.remove(n),cl.push(n),rr(n)}function Fe(n){var t=n.circle,e=t.x,r=t.cy,i={x:e,y:r},u=n.P,o=n.N,a=[n];je(n);for(var l=u;l.circle&&xo(e-l.circle.x)f;++f)c=a[f],l=a[f-1],nr(c.edge,l.site,c.site,i);l=a[0],c=a[s-1],c.edge=Ke(l.site,c.site,null,i),$e(l),$e(c)}function He(n){for(var t,e,r,i,u=n.x,o=n.y,a=ol._;a;)if(r=Oe(a,o)-u,r>Uo)a=a.L;else{if(i=u-Ie(a,o),!(i>Uo)){r>-Uo?(t=a.P,e=a):i>-Uo?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var l=Ue(n);if(ol.insert(t,l),t||e){if(t===e)return Be(t),e=Ue(t.site),ol.insert(l,e),l.edge=e.edge=Ke(t.site,l.site),$e(t),void $e(e);if(!e)return void(l.edge=Ke(t.site,l.site));Be(t),Be(e);var c=t.site,f=c.x,s=c.y,h=n.x-f,p=n.y-s,g=e.site,v=g.x-f,d=g.y-s,y=2*(h*d-p*v),m=h*h+p*p,M=v*v+d*d,x={x:(d*m-p*M)/y+f,y:(h*M-v*m)/y+s};nr(e.edge,c,g,x),l.edge=Ke(c,n,null,x),e.edge=Ke(n,g,null,x),$e(t),$e(e)}}function Oe(n,t){var e=n.site,r=e.x,i=e.y,u=i-t;if(!u)return r;var o=n.P;if(!o)return-(1/0);e=o.site;var a=e.x,l=e.y,c=l-t;if(!c)return a;var f=a-r,s=1/u-1/c,h=f/c;return s?(-h+Math.sqrt(h*h-2*s*(f*f/(-2*c)-l+c/2+i-u/2)))/s+r:(r+a)/2}function Ie(n,t){var e=n.N;if(e)return Oe(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ye(n){this.site=n,this.edges=[]}function Ze(n){for(var t,e,r,i,u,o,a,l,c,f,s=n[0][0],h=n[1][0],p=n[0][1],g=n[1][1],v=ul,d=v.length;d--;)if(u=v[d],u&&u.prepare())for(a=u.edges,l=a.length,o=0;l>o;)f=a[o].end(),r=f.x,i=f.y,c=a[++o%l].start(),t=c.x,e=c.y,(xo(r-t)>Uo||xo(i-e)>Uo)&&(a.splice(o,0,new tr(Qe(u.site,f,xo(r-s)Uo?{x:s,y:xo(t-s)Uo?{x:xo(e-g)Uo?{x:h,y:xo(t-h)Uo?{x:xo(e-p)=-jo)){var p=l*l+c*c,g=f*f+s*s,v=(s*p-c*g)/h,d=(l*g-f*p)/h,s=d+a,y=fl.pop()||new Xe;y.arc=n,y.site=i,y.x=v+o,y.y=s+Math.sqrt(v*v+d*d),y.cy=s,n.circle=y;for(var m=null,M=ll._;M;)if(y.yd||d>=a)return;if(h>g){if(u){if(u.y>=c)return}else u={x:d,y:l};e={x:d,y:c}}else{if(u){if(u.yr||r>1)if(h>g){if(u){if(u.y>=c)return}else u={x:(l-i)/r,y:l};e={x:(c-i)/r,y:c}}else{if(u){if(u.yp){if(u){if(u.x>=a)return}else u={x:o,y:r*o+i};e={x:a,y:r*a+i}}else{if(u){if(u.xu||s>o||r>h||i>p)){if(g=n.point){var g,v=t-n.x,d=e-n.y,y=v*v+d*d;if(l>y){var m=Math.sqrt(l=y);r=t-m,i=e-m,u=t+m,o=e+m,a=g}}for(var M=n.nodes,x=.5*(f+h),b=.5*(s+p),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:c(n,f,s,x,b);break;case 1:c(n,x,s,h,b);break;case 2:c(n,f,b,x,p);break;case 3:c(n,x,b,h,p)}}}(n,r,i,u,o),a}function vr(n,t){n=ao.rgb(n),t=ao.rgb(t);var e=n.r,r=n.g,i=n.b,u=t.r-e,o=t.g-r,a=t.b-i;return function(n){return"#"+bn(Math.round(e+u*n))+bn(Math.round(r+o*n))+bn(Math.round(i+a*n))}}function dr(n,t){var e,r={},i={};for(e in n)e in t?r[e]=Mr(n[e],t[e]):i[e]=n[e];for(e in t)e in n||(i[e]=t[e]);return function(n){for(e in r)i[e]=r[e](n);return i}}function yr(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function mr(n,t){var e,r,i,u=hl.lastIndex=pl.lastIndex=0,o=-1,a=[],l=[];for(n+="",t+="";(e=hl.exec(n))&&(r=pl.exec(t));)(i=r.index)>u&&(i=t.slice(u,i),a[o]?a[o]+=i:a[++o]=i),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:yr(e,r)})),u=pl.lastIndex;return ur;++r)a[(e=l[r]).i]=e.x(n);return a.join("")})}function Mr(n,t){for(var e,r=ao.interpolators.length;--r>=0&&!(e=ao.interpolators[r](n,t)););return e}function xr(n,t){var e,r=[],i=[],u=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(Mr(n[e],t[e]));for(;u>e;++e)i[e]=n[e];for(;o>e;++e)i[e]=t[e];return function(n){for(e=0;a>e;++e)i[e]=r[e](n);return i}}function br(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function _r(n){return function(t){return 1-n(1-t)}}function wr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function Sr(n){return n*n}function kr(n){return n*n*n}function Nr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Er(n){return function(t){return Math.pow(t,n)}}function Ar(n){return 1-Math.cos(n*Io)}function Cr(n){return Math.pow(2,10*(n-1))}function zr(n){return 1-Math.sqrt(1-n*n)}function Lr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Ho*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Ho/t)}}function qr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Tr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Rr(n,t){n=ao.hcl(n),t=ao.hcl(t);var e=n.h,r=n.c,i=n.l,u=t.h-e,o=t.c-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return sn(e+u*n,r+o*n,i+a*n)+""}}function Dr(n,t){n=ao.hsl(n),t=ao.hsl(t);var e=n.h,r=n.s,i=n.l,u=t.h-e,o=t.s-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return cn(e+u*n,r+o*n,i+a*n)+""}}function Pr(n,t){n=ao.lab(n),t=ao.lab(t);var e=n.l,r=n.a,i=n.b,u=t.l-e,o=t.a-r,a=t.b-i;return function(n){return pn(e+u*n,r+o*n,i+a*n)+""}}function Ur(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function jr(n){var t=[n.a,n.b],e=[n.c,n.d],r=Hr(t),i=Fr(t,e),u=Hr(Or(e,t,-i))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(Ir(e)+"rotate(",null,")")-2,x:yr(n,t)})):t&&e.push(Ir(e)+"rotate("+t+")")}function Vr(n,t,e,r){n!==t?r.push({i:e.push(Ir(e)+"skewX(",null,")")-2,x:yr(n,t)}):t&&e.push(Ir(e)+"skewX("+t+")")}function Xr(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var i=e.push(Ir(e)+"scale(",null,",",null,")");r.push({i:i-4,x:yr(n[0],t[0])},{i:i-2,x:yr(n[1],t[1])})}else 1===t[0]&&1===t[1]||e.push(Ir(e)+"scale("+t+")")}function $r(n,t){var e=[],r=[];return n=ao.transform(n),t=ao.transform(t),Yr(n.translate,t.translate,e,r),Zr(n.rotate,t.rotate,e,r),Vr(n.skew,t.skew,e,r),Xr(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,i=-1,u=r.length;++i=0;)e.push(i[r])}function oi(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(u=n.children)&&(i=u.length))for(var i,u,o=-1;++oe;++e)(t=n[e][1])>i&&(r=e,i=t);return r}function yi(n){return n.reduce(mi,0)}function mi(n,t){return n+t[1]}function Mi(n,t){return xi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function xi(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function bi(n){return[ao.min(n),ao.max(n)]}function _i(n,t){return n.value-t.value}function wi(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Si(n,t){n._pack_next=t,t._pack_prev=n}function ki(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return.999*i*i>e*e+r*r}function Ni(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),p=Math.max(n.y+n.r,p)}if((e=n.children)&&(c=e.length)){var e,r,i,u,o,a,l,c,f=1/0,s=-(1/0),h=1/0,p=-(1/0);if(e.forEach(Ei),r=e[0],r.x=-r.r,r.y=0,t(r),c>1&&(i=e[1],i.x=i.r,i.y=0,t(i),c>2))for(u=e[2],zi(r,i,u),t(u),wi(r,u),r._pack_prev=u,wi(u,i),i=r._pack_next,o=3;c>o;o++){zi(r,i,u=e[o]);var g=0,v=1,d=1;for(a=i._pack_next;a!==i;a=a._pack_next,v++)if(ki(a,u)){g=1;break}if(1==g)for(l=r._pack_prev;l!==a._pack_prev&&!ki(l,u);l=l._pack_prev,d++);g?(d>v||v==d&&i.ro;o++)u=e[o],u.x-=y,u.y-=m,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));n.r=M,e.forEach(Ai)}}function Ei(n){n._pack_next=n._pack_prev=n}function Ai(n){delete n._pack_next,delete n._pack_prev}function Ci(n,t,e,r){var i=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,i)for(var u=-1,o=i.length;++u=0;)t=i[u],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Pi(n,t,e){return n.a.parent===t.parent?n.a:e}function Ui(n){return 1+ao.max(n,function(n){return n.y})}function ji(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Fi(n){var t=n.children;return t&&t.length?Fi(t[0]):n}function Hi(n){var t,e=n.children;return e&&(t=e.length)?Hi(e[t-1]):n}function Oi(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Ii(n,t){var e=n.x+t[3],r=n.y+t[0],i=n.dx-t[1]-t[3],u=n.dy-t[0]-t[2];return 0>i&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Yi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Zi(n){return n.rangeExtent?n.rangeExtent():Yi(n.range())}function Vi(n,t,e,r){var i=e(n[0],n[1]),u=r(t[0],t[1]);return function(n){return u(i(n))}}function Xi(n,t){var e,r=0,i=n.length-1,u=n[r],o=n[i];return u>o&&(e=r,r=i,i=e,e=u,u=o,o=e),n[r]=t.floor(u),n[i]=t.ceil(o),n}function $i(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:Sl}function Bi(n,t,e,r){var i=[],u=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Bi:Vi,l=r?Wr:Br;return o=i(n,t,l,e),a=i(t,n,l,Mr),u}function u(n){return o(n)}var o,a;return u.invert=function(n){return a(n)},u.domain=function(t){return arguments.length?(n=t.map(Number),i()):n},u.range=function(n){return arguments.length?(t=n,i()):t},u.rangeRound=function(n){return u.range(n).interpolate(Ur)},u.clamp=function(n){return arguments.length?(r=n,i()):r},u.interpolate=function(n){return arguments.length?(e=n,i()):e},u.ticks=function(t){return Qi(n,t)},u.tickFormat=function(t,e){return nu(n,t,e)},u.nice=function(t){return Gi(n,t),i()},u.copy=function(){return Wi(n,t,e,r)},i()}function Ji(n,t){return ao.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Gi(n,t){return Xi(n,$i(Ki(n,t)[2])),Xi(n,$i(Ki(n,t)[2])),n}function Ki(n,t){null==t&&(t=10);var e=Yi(n),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),u=t/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Qi(n,t){return ao.range.apply(ao,Ki(n,t))}function nu(n,t,e){var r=Ki(n,t);if(e){var i=ha.exec(e);if(i.shift(),"s"===i[8]){var u=ao.formatPrefix(Math.max(xo(r[0]),xo(r[1])));return i[7]||(i[7]="."+tu(u.scale(r[2]))),i[8]="f",e=ao.format(i.join("")),function(n){return e(u.scale(n))+u.symbol}}i[7]||(i[7]="."+eu(i[8],r)),e=i.join("")}else e=",."+tu(r[2])+"f";return ao.format(e)}function tu(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function eu(n,t){var e=tu(t[2]);return n in kl?Math.abs(e-tu(Math.max(xo(t[0]),xo(t[1]))))+ +("e"!==n):e-2*("%"===n)}function ru(n,t,e,r){function i(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function u(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(i(t))}return o.invert=function(t){return u(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(i)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(i)),o):t},o.nice=function(){var t=Xi(r.map(i),e?Math:El);return n.domain(t),r=t.map(u),o},o.ticks=function(){var n=Yi(r),o=[],a=n[0],l=n[1],c=Math.floor(i(a)),f=Math.ceil(i(l)),s=t%1?2:t;if(isFinite(f-c)){if(e){for(;f>c;c++)for(var h=1;s>h;h++)o.push(u(c)*h);o.push(u(c))}else for(o.push(u(c));c++0;h--)o.push(u(c)*h);for(c=0;o[c]l;f--);o=o.slice(c,f)}return o},o.tickFormat=function(n,e){if(!arguments.length)return Nl;arguments.length<2?e=Nl:"function"!=typeof e&&(e=ao.format(e));var r=Math.max(1,t*n/o.ticks().length);return function(n){var o=n/u(Math.round(i(n)));return t-.5>o*t&&(o*=t),r>=o?e(n):""}},o.copy=function(){return ru(n.copy(),t,e,r)},Ji(o,n)}function iu(n,t,e){function r(t){return n(i(t))}var i=uu(t),u=uu(1/t);return r.invert=function(t){return u(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(i)),r):e},r.ticks=function(n){return Qi(e,n)},r.tickFormat=function(n,t){return nu(e,n,t)},r.nice=function(n){return r.domain(Gi(e,n))},r.exponent=function(o){return arguments.length?(i=uu(t=o),u=uu(1/t),n.domain(e.map(i)),r):t},r.copy=function(){return iu(n.copy(),t,e)},Ji(r,n)}function uu(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function ou(n,t){function e(e){return u[((i.get(e)||("range"===t.t?i.set(e,n.push(e)):NaN))-1)%u.length]}function r(t,e){return ao.range(n.length).map(function(n){return t+e*n})}var i,u,o;return e.domain=function(r){if(!arguments.length)return n;n=[],i=new c;for(var u,o=-1,a=r.length;++oe?[NaN,NaN]:[e>0?a[e-1]:n[0],et?NaN:t/u+n,[t,t+1/u]},r.copy=function(){return lu(n,t,e)},i()}function cu(n,t){function e(e){return e>=e?t[ao.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return cu(n,t)},e}function fu(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Qi(n,t)},t.tickFormat=function(t,e){return nu(n,t,e)},t.copy=function(){return fu(n)},t}function su(){return 0}function hu(n){return n.innerRadius}function pu(n){return n.outerRadius}function gu(n){return n.startAngle}function vu(n){return n.endAngle}function du(n){return n&&n.padAngle}function yu(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function mu(n,t,e,r,i){var u=n[0]-t[0],o=n[1]-t[1],a=(i?r:-r)/Math.sqrt(u*u+o*o),l=a*o,c=-a*u,f=n[0]+l,s=n[1]+c,h=t[0]+l,p=t[1]+c,g=(f+h)/2,v=(s+p)/2,d=h-f,y=p-s,m=d*d+y*y,M=e-r,x=f*p-h*s,b=(0>y?-1:1)*Math.sqrt(Math.max(0,M*M*m-x*x)),_=(x*y-d*b)/m,w=(-x*d-y*b)/m,S=(x*y+d*b)/m,k=(-x*d+y*b)/m,N=_-g,E=w-v,A=S-g,C=k-v;return N*N+E*E>A*A+C*C&&(_=S,w=k),[[_-l,w-c],[_*e/M,w*e/M]]}function Mu(n){function t(t){function o(){c.push("M",u(n(f),a))}for(var l,c=[],f=[],s=-1,h=t.length,p=En(e),g=En(r);++s1?n.join("L"):n+"Z"}function bu(n){return n.join("L")+"Z"}function _u(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1&&i.push("H",r[0]),i.join("")}function wu(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1){a=t[1],u=n[l],l++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(u[0]-a[0])+","+(u[1]-a[1])+","+u[0]+","+u[1];for(var c=2;c9&&(i=3*t/Math.sqrt(i),o[a]=i*e,o[a+1]=i*r));for(a=-1;++a<=l;)i=(n[Math.min(l,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),u.push([i||0,o[a]*i||0]);return u}function Fu(n){return n.length<3?xu(n):n[0]+Au(n,ju(n))}function Hu(n){for(var t,e,r,i=-1,u=n.length;++i=t?o(n-t):void(f.c=o)}function o(e){var i=g.active,u=g[i];u&&(u.timer.c=null,u.timer.t=NaN,--g.count,delete g[i],u.event&&u.event.interrupt.call(n,n.__data__,u.index));for(var o in g)if(r>+o){var c=g[o];c.timer.c=null,c.timer.t=NaN,--g.count,delete g[o]}f.c=a,qn(function(){return f.c&&a(e||1)&&(f.c=null,f.t=NaN),1},0,l),g.active=r,v.event&&v.event.start.call(n,n.__data__,t),p=[],v.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&p.push(r)}),h=v.ease,s=v.duration}function a(i){for(var u=i/s,o=h(u),a=p.length;a>0;)p[--a].call(n,o);return u>=1?(v.event&&v.event.end.call(n,n.__data__,t),--g.count?delete g[r]:delete n[e],1):void 0}var l,f,s,h,p,g=n[e]||(n[e]={active:0,count:0}),v=g[r];v||(l=i.time,f=qn(u,0,l),v=g[r]={tween:new c,time:l,timer:f,delay:i.delay,duration:i.duration,ease:i.ease,index:t},i=null,++g.count)}function no(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function to(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function eo(n){return n.toISOString()}function ro(n,t,e){function r(t){return n(t)}function i(n,e){var r=n[1]-n[0],i=r/e,u=ao.bisect(Kl,i);return u==Kl.length?[t.year,Ki(n.map(function(n){return n/31536e6}),e)[2]]:u?t[i/Kl[u-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=io(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=io(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Yi(r.domain()),u=null==n?i(e,10):"number"==typeof n?i(e,n):!n.range&&[{range:n},t];return u&&(n=u[0],t=u[1]),n.range(e[0],io(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return ro(n.copy(),t,e)},Ji(r,n)}function io(n){return new Date(n)}function uo(n){return JSON.parse(n.responseText)}function oo(n){var t=fo.createRange();return t.selectNode(fo.body),t.createContextualFragment(n.responseText)}var ao={version:"3.5.18"},lo=[].slice,co=function(n){return lo.call(n)},fo=this.document;if(fo)try{co(fo.documentElement.childNodes)[0].nodeType}catch(so){co=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),fo)try{fo.createElement("DIV").style.setProperty("opacity",0,"")}catch(ho){var po=this.Element.prototype,go=po.setAttribute,vo=po.setAttributeNS,yo=this.CSSStyleDeclaration.prototype,mo=yo.setProperty;po.setAttribute=function(n,t){go.call(this,n,t+"")},po.setAttributeNS=function(n,t,e){vo.call(this,n,t,e+"")},yo.setProperty=function(n,t,e){mo.call(this,n,t+"",e)}}ao.ascending=e,ao.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},ao.min=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ir&&(e=r)}else{for(;++i=r){e=r;break}for(;++ir&&(e=r)}return e},ao.max=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ie&&(e=r)}else{for(;++i=r){e=r;break}for(;++ie&&(e=r)}return e},ao.extent=function(n,t){var e,r,i,u=-1,o=n.length;if(1===arguments.length){for(;++u=r){e=i=r;break}for(;++ur&&(e=r),r>i&&(i=r))}else{for(;++u=r){e=i=r;break}for(;++ur&&(e=r),r>i&&(i=r))}return[e,i]},ao.sum=function(n,t){var e,r=0,u=n.length,o=-1;if(1===arguments.length)for(;++o1?l/(f-1):void 0},ao.deviation=function(){var n=ao.variance.apply(this,arguments);return n?Math.sqrt(n):n};var Mo=u(e);ao.bisectLeft=Mo.left,ao.bisect=ao.bisectRight=Mo.right,ao.bisector=function(n){return u(1===n.length?function(t,r){return e(n(t),r)}:n)},ao.shuffle=function(n,t,e){(u=arguments.length)<3&&(e=n.length,2>u&&(t=0));for(var r,i,u=e-t;u;)i=Math.random()*u--|0,r=n[u+t],n[u+t]=n[i+t],n[i+t]=r;return n},ao.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ao.pairs=function(n){for(var t,e=0,r=n.length-1,i=n[0],u=new Array(0>r?0:r);r>e;)u[e]=[t=i,i=n[++e]];return u},ao.transpose=function(n){if(!(i=n.length))return[];for(var t=-1,e=ao.min(n,o),r=new Array(e);++t=0;)for(r=n[i],t=r.length;--t>=0;)e[--o]=r[t];return e};var xo=Math.abs;ao.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,i=[],u=a(xo(e)),o=-1;if(n*=u,t*=u,e*=u,0>e)for(;(r=n+e*++o)>t;)i.push(r/u);else for(;(r=n+e*++o)=u.length)return r?r.call(i,o):e?o.sort(e):o;for(var l,f,s,h,p=-1,g=o.length,v=u[a++],d=new c;++p=u.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,i={},u=[],o=[];return i.map=function(t,e){return n(e,t,0)},i.entries=function(e){return t(n(ao.map,e,0),0)},i.key=function(n){return u.push(n),i},i.sortKeys=function(n){return o[u.length-1]=n,i},i.sortValues=function(n){return e=n,i},i.rollup=function(n){return r=n,i},i},ao.set=function(n){var t=new y;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(y,{has:h,add:function(n){return this._[f(n+="")]=!0,n},remove:p,values:g,size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,s(t))}}),ao.behavior={},ao.rebind=function(n,t){for(var e,r=1,i=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ao.event=null,ao.requote=function(n){return n.replace(So,"\\$&")};var So=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ko={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},No=function(n,t){return t.querySelector(n)},Eo=function(n,t){return t.querySelectorAll(n)},Ao=function(n,t){var e=n.matches||n[x(n,"matchesSelector")];return(Ao=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(No=function(n,t){return Sizzle(n,t)[0]||null},Eo=Sizzle,Ao=Sizzle.matchesSelector),ao.selection=function(){return ao.select(fo.documentElement)};var Co=ao.selection.prototype=[];Co.select=function(n){var t,e,r,i,u=[];n=A(n);for(var o=-1,a=this.length;++o=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),Lo.hasOwnProperty(e)?{space:Lo[e],local:n}:n}},Co.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ao.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(z(t,n[t]));return this}return this.each(z(n,t))},Co.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=T(n)).length,i=-1;if(t=e.classList){for(;++ii){if("string"!=typeof n){2>i&&(e="");for(r in n)this.each(P(r,n[r],e));return this}if(2>i){var u=this.node();return t(u).getComputedStyle(u,null).getPropertyValue(n)}r=""}return this.each(P(n,e,r))},Co.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(U(t,n[t]));return this}return this.each(U(n,t))},Co.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},Co.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},Co.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},Co.insert=function(n,t){return n=j(n),t=A(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},Co.remove=function(){return this.each(F)},Co.data=function(n,t){function e(n,e){var r,i,u,o=n.length,s=e.length,h=Math.min(o,s),p=new Array(s),g=new Array(s),v=new Array(o);if(t){var d,y=new c,m=new Array(o);for(r=-1;++rr;++r)g[r]=H(e[r]);for(;o>r;++r)v[r]=n[r]}g.update=p,g.parentNode=p.parentNode=v.parentNode=n.parentNode,a.push(g),l.push(p),f.push(v)}var r,i,u=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++uu;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return E(i)},Co.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},Co.sort=function(n){n=I.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},Co.size=function(){var n=0;return Y(this,function(){++n}),n};var qo=[];ao.selection.enter=Z,ao.selection.enter.prototype=qo,qo.append=Co.append,qo.empty=Co.empty,qo.node=Co.node,qo.call=Co.call,qo.size=Co.size,qo.select=function(n){for(var t,e,r,i,u,o=[],a=-1,l=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var To=ao.map({mouseenter:"mouseover",mouseleave:"mouseout"});fo&&To.forEach(function(n){"on"+n in fo&&To.remove(n)});var Ro,Do=0;ao.mouse=function(n){return J(n,k())};var Po=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ao.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=k().changedTouches),t)for(var r,i=0,u=t.length;u>i;++i)if((r=t[i]).identifier===e)return J(n,r)},ao.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",o)}function e(n,t,e,u,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],g|=n|e,M=r,p({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,v)&&(y.on(u+d,null).on(o+d,null),m(g),p({type:"dragend"}))}var c,f=this,s=ao.event.target.correspondingElement||ao.event.target,h=f.parentNode,p=r.of(f,arguments),g=0,v=n(),d=".drag"+(null==v?"":"-"+v),y=ao.select(e(s)).on(u+d,a).on(o+d,l),m=W(s),M=t(h,v);i?(c=i.apply(f,arguments),c=[c.x-M[0],c.y-M[1]]):c=[0,0],p({type:"dragstart"})}}var r=N(n,"drag","dragstart","dragend"),i=null,u=e(b,ao.mouse,t,"mousemove","mouseup"),o=e(G,ao.touch,m,"touchmove","touchend");return n.origin=function(t){return arguments.length?(i=t,n):i},ao.rebind(n,r,"on")},ao.touches=function(n,t){return arguments.length<2&&(t=k().touches),t?co(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier,e}):[]};var Uo=1e-6,jo=Uo*Uo,Fo=Math.PI,Ho=2*Fo,Oo=Ho-Uo,Io=Fo/2,Yo=Fo/180,Zo=180/Fo,Vo=Math.SQRT2,Xo=2,$o=4;ao.interpolateZoom=function(n,t){var e,r,i=n[0],u=n[1],o=n[2],a=t[0],l=t[1],c=t[2],f=a-i,s=l-u,h=f*f+s*s;if(jo>h)r=Math.log(c/o)/Vo,e=function(n){return[i+n*f,u+n*s,o*Math.exp(Vo*n*r)]};else{var p=Math.sqrt(h),g=(c*c-o*o+$o*h)/(2*o*Xo*p),v=(c*c-o*o-$o*h)/(2*c*Xo*p),d=Math.log(Math.sqrt(g*g+1)-g),y=Math.log(Math.sqrt(v*v+1)-v);r=(y-d)/Vo,e=function(n){var t=n*r,e=rn(d),a=o/(Xo*p)*(e*un(Vo*t+d)-en(d));return[i+a*f,u+a*s,o*e/rn(Vo*t+d)]}}return e.duration=1e3*r,e},ao.behavior.zoom=function(){function n(n){n.on(L,s).on(Wo+".zoom",p).on("dblclick.zoom",g).on(R,h)}function e(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function r(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function i(n){k.k=Math.max(A[0],Math.min(A[1],n))}function u(n,t){t=r(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function o(t,e,r,o){t.__chart__={x:k.x,y:k.y,k:k.k},i(Math.pow(2,o)),u(d=e,r),t=ao.select(t),C>0&&(t=t.transition().duration(C)),t.call(n.event)}function a(){b&&b.domain(x.range().map(function(n){return(n-k.x)/k.k}).map(x.invert)),w&&w.domain(_.range().map(function(n){return(n-k.y)/k.k}).map(_.invert))}function l(n){z++||n({type:"zoomstart"})}function c(n){a(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function f(n){--z||(n({type:"zoomend"}),d=null)}function s(){function n(){a=1,u(ao.mouse(i),h),c(o)}function r(){s.on(q,null).on(T,null),p(a),f(o)}var i=this,o=D.of(i,arguments),a=0,s=ao.select(t(i)).on(q,n).on(T,r),h=e(ao.mouse(i)),p=W(i);Il.call(i),l(o)}function h(){function n(){var n=ao.touches(g);return p=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=e(n))}),n}function t(){var t=ao.event.target;ao.select(t).on(x,r).on(b,a),_.push(t);for(var e=ao.event.changedTouches,i=0,u=e.length;u>i;++i)d[e[i].identifier]=null;var l=n(),c=Date.now();if(1===l.length){if(500>c-M){var f=l[0];o(g,f,d[f.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),S()}M=c}else if(l.length>1){var f=l[0],s=l[1],h=f[0]-s[0],p=f[1]-s[1];y=h*h+p*p}}function r(){var n,t,e,r,o=ao.touches(g);Il.call(g);for(var a=0,l=o.length;l>a;++a,r=null)if(e=o[a],r=d[e.identifier]){if(t)break;n=e,t=r}if(r){var f=(f=e[0]-n[0])*f+(f=e[1]-n[1])*f,s=y&&Math.sqrt(f/y);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],i(s*p)}M=null,u(n,t),c(v)}function a(){if(ao.event.touches.length){for(var t=ao.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var i in d)return void n()}ao.selectAll(_).on(m,null),w.on(L,s).on(R,h),N(),f(v)}var p,g=this,v=D.of(g,arguments),d={},y=0,m=".zoom-"+ao.event.changedTouches[0].identifier,x="touchmove"+m,b="touchend"+m,_=[],w=ao.select(g),N=W(g);t(),l(v),w.on(L,null).on(R,t)}function p(){var n=D.of(this,arguments);m?clearTimeout(m):(Il.call(this),v=e(d=y||ao.mouse(this)),l(n)),m=setTimeout(function(){m=null,f(n)},50),S(),i(Math.pow(2,.002*Bo())*k.k),u(d,v),c(n)}function g(){var n=ao.mouse(this),t=Math.log(k.k)/Math.LN2;o(this,n,e(n),ao.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var v,d,y,m,M,x,b,_,w,k={x:0,y:0,k:1},E=[960,500],A=Jo,C=250,z=0,L="mousedown.zoom",q="mousemove.zoom",T="mouseup.zoom",R="touchstart.zoom",D=N(n,"zoomstart","zoom","zoomend");return Wo||(Wo="onwheel"in fo?(Bo=function(){return-ao.event.deltaY*(ao.event.deltaMode?120:1)},"wheel"):"onmousewheel"in fo?(Bo=function(){return ao.event.wheelDelta},"mousewheel"):(Bo=function(){return-ao.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=D.of(this,arguments),t=k;Hl?ao.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},l(n)}).tween("zoom:zoom",function(){var e=E[0],r=E[1],i=d?d[0]:e/2,u=d?d[1]:r/2,o=ao.interpolateZoom([(i-k.x)/k.k,(u-k.y)/k.k,e/k.k],[(i-t.x)/t.k,(u-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=k={x:i-r[0]*a,y:u-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){f(n)}).each("end.zoom",function(){f(n)}):(this.__chart__=k,l(n),c(n),f(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},a(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:null},i(+t),a(),n):k.k},n.scaleExtent=function(t){return arguments.length?(A=null==t?Jo:[+t[0],+t[1]],n):A},n.center=function(t){return arguments.length?(y=t&&[+t[0],+t[1]],n):y},n.size=function(t){return arguments.length?(E=t&&[+t[0],+t[1]],n):E},n.duration=function(t){return arguments.length?(C=+t,n):C},n.x=function(t){return arguments.length?(b=t,x=t.copy(),k={x:0,y:0,k:1},n):b},n.y=function(t){return arguments.length?(w=t,_=t.copy(),k={x:0,y:0,k:1},n):w},ao.rebind(n,D,"on")};var Bo,Wo,Jo=[0,1/0];ao.color=an,an.prototype.toString=function(){return this.rgb()+""},ao.hsl=ln;var Go=ln.prototype=new an;Go.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,this.l/n)},Go.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,n*this.l)},Go.rgb=function(){return cn(this.h,this.s,this.l)},ao.hcl=fn;var Ko=fn.prototype=new an;Ko.brighter=function(n){return new fn(this.h,this.c,Math.min(100,this.l+Qo*(arguments.length?n:1)))},Ko.darker=function(n){return new fn(this.h,this.c,Math.max(0,this.l-Qo*(arguments.length?n:1)))},Ko.rgb=function(){return sn(this.h,this.c,this.l).rgb()},ao.lab=hn;var Qo=18,na=.95047,ta=1,ea=1.08883,ra=hn.prototype=new an;ra.brighter=function(n){return new hn(Math.min(100,this.l+Qo*(arguments.length?n:1)),this.a,this.b)},ra.darker=function(n){return new hn(Math.max(0,this.l-Qo*(arguments.length?n:1)),this.a,this.b)},ra.rgb=function(){return pn(this.l,this.a,this.b)},ao.rgb=mn;var ia=mn.prototype=new an;ia.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&i>t&&(t=i),e&&i>e&&(e=i),r&&i>r&&(r=i),new mn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new mn(i,i,i)},ia.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new mn(n*this.r,n*this.g,n*this.b)},ia.hsl=function(){return wn(this.r,this.g,this.b)},ia.toString=function(){return"#"+bn(this.r)+bn(this.g)+bn(this.b)};var ua=ao.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ua.forEach(function(n,t){ua.set(n,Mn(t))}),ao.functor=En,ao.xhr=An(m),ao.dsv=function(n,t){function e(n,e,u){arguments.length<3&&(u=e,e=null);var o=Cn(n,t,null==e?r:i(e),u);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:i(n)):e},o}function r(n){return e.parse(n.responseText)}function i(n){return function(t){return e.parse(t.responseText,n)}}function u(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var i=function(t){for(var e={},r=n.length,i=0;r>i;++i)e[n[i]]=t[i];return e};r=t?function(n,e){return t(i(n),e)}:i})},e.parseRows=function(n,t){function e(){if(f>=c)return o;if(i)return i=!1,u;var t=f;if(34===n.charCodeAt(t)){for(var e=t;e++f;){var r=n.charCodeAt(f++),a=1;if(10===r)i=!0;else if(13===r)i=!0,10===n.charCodeAt(f)&&(++f,++a);else if(r!==l)continue;return n.slice(t,f-a)}return n.slice(t)}for(var r,i,u={},o={},a=[],c=n.length,f=0,s=0;(r=e())!==o;){for(var h=[];r!==u&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,s++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new y,i=[];return t.forEach(function(n){for(var t in n)r.has(t)||i.push(r.add(t))}),[i.map(o).join(n)].concat(t.map(function(t){return i.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(u).join("\n")},e},ao.csv=ao.dsv(",","text/csv"),ao.tsv=ao.dsv(" ","text/tab-separated-values");var oa,aa,la,ca,fa=this[x(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ao.timer=function(){qn.apply(this,arguments)},ao.timer.flush=function(){Rn(),Dn()},ao.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var sa=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Un);ao.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=ao.round(n,Pn(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),sa[8+e/3]};var ha=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,pa=ao.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ao.round(n,Pn(n,t))).toFixed(Math.max(0,Math.min(20,Pn(n*(1+1e-15),t))))}}),ga=ao.time={},va=Date;Hn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){da.setUTCDate.apply(this._,arguments)},setDay:function(){da.setUTCDay.apply(this._,arguments)},setFullYear:function(){da.setUTCFullYear.apply(this._,arguments)},setHours:function(){da.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){da.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){da.setUTCMinutes.apply(this._,arguments)},setMonth:function(){da.setUTCMonth.apply(this._,arguments)},setSeconds:function(){da.setUTCSeconds.apply(this._,arguments)},setTime:function(){da.setTime.apply(this._,arguments)}};var da=Date.prototype;ga.year=On(function(n){return n=ga.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),ga.years=ga.year.range,ga.years.utc=ga.year.utc.range,ga.day=On(function(n){var t=new va(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),ga.days=ga.day.range,ga.days.utc=ga.day.utc.range,ga.dayOfYear=function(n){var t=ga.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=ga[n]=On(function(n){return(n=ga.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=ga.year(n).getDay();return Math.floor((ga.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});ga[n+"s"]=e.range,ga[n+"s"].utc=e.utc.range,ga[n+"OfYear"]=function(n){var e=ga.year(n).getDay();return Math.floor((ga.dayOfYear(n)+(e+t)%7)/7)}}),ga.week=ga.sunday,ga.weeks=ga.sunday.range,ga.weeks.utc=ga.sunday.utc.range,ga.weekOfYear=ga.sundayOfYear;var ya={"-":"",_:" ",0:"0"},ma=/^\s*\d+/,Ma=/^%/;ao.locale=function(n){return{numberFormat:jn(n),timeFormat:Yn(n)}};var xa=ao.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"], -shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ao.format=xa.numberFormat,ao.geo={},ft.prototype={s:0,t:0,add:function(n){st(n,this.t,ba),st(ba.s,this.s,this),this.s?this.t+=ba.t:this.s=ba.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ba=new ft;ao.geo.stream=function(n,t){n&&_a.hasOwnProperty(n.type)?_a[n.type](n,t):ht(n,t)};var _a={Feature:function(n,t){ht(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++rn?4*Fo+n:n,Na.lineStart=Na.lineEnd=Na.point=b}};ao.geo.bounds=function(){function n(n,t){M.push(x=[f=n,h=n]),s>t&&(s=t),t>p&&(p=t)}function t(t,e){var r=dt([t*Yo,e*Yo]);if(y){var i=mt(y,r),u=[i[1],-i[0],0],o=mt(u,i);bt(o),o=_t(o);var l=t-g,c=l>0?1:-1,v=o[0]*Zo*c,d=xo(l)>180;if(d^(v>c*g&&c*t>v)){var m=o[1]*Zo;m>p&&(p=m)}else if(v=(v+360)%360-180,d^(v>c*g&&c*t>v)){var m=-o[1]*Zo;s>m&&(s=m)}else s>e&&(s=e),e>p&&(p=e);d?g>t?a(f,t)>a(f,h)&&(h=t):a(t,h)>a(f,h)&&(f=t):h>=f?(f>t&&(f=t),t>h&&(h=t)):t>g?a(f,t)>a(f,h)&&(h=t):a(t,h)>a(f,h)&&(f=t)}else n(t,e);y=r,g=t}function e(){b.point=t}function r(){x[0]=f,x[1]=h,b.point=n,y=null}function i(n,e){if(y){var r=n-g;m+=xo(r)>180?r+(r>0?360:-360):r}else v=n,d=e;Na.point(n,e),t(n,e)}function u(){Na.lineStart()}function o(){i(v,d),Na.lineEnd(),xo(m)>Uo&&(f=-(h=180)),x[0]=f,x[1]=h,y=null}function a(n,t){return(t-=n)<0?t+360:t}function l(n,t){return n[0]-t[0]}function c(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nka?(f=-(h=180),s=-(p=90)):m>Uo?p=90:-Uo>m&&(s=-90),x[0]=f,x[1]=h}};return function(n){p=h=-(f=s=1/0),M=[],ao.geo.stream(n,b);var t=M.length;if(t){M.sort(l);for(var e,r=1,i=M[0],u=[i];t>r;++r)e=M[r],c(e[0],i)||c(e[1],i)?(a(i[0],e[1])>a(i[0],i[1])&&(i[1]=e[1]),a(e[0],i[1])>a(i[0],i[1])&&(i[0]=e[0])):u.push(i=e);for(var o,e,g=-(1/0),t=u.length-1,r=0,i=u[t];t>=r;i=e,++r)e=u[r],(o=a(i[1],e[0]))>g&&(g=o,f=e[0],h=i[1])}return M=x=null,f===1/0||s===1/0?[[NaN,NaN],[NaN,NaN]]:[[f,s],[h,p]]}}(),ao.geo.centroid=function(n){Ea=Aa=Ca=za=La=qa=Ta=Ra=Da=Pa=Ua=0,ao.geo.stream(n,ja);var t=Da,e=Pa,r=Ua,i=t*t+e*e+r*r;return jo>i&&(t=qa,e=Ta,r=Ra,Uo>Aa&&(t=Ca,e=za,r=La),i=t*t+e*e+r*r,jo>i)?[NaN,NaN]:[Math.atan2(e,t)*Zo,tn(r/Math.sqrt(i))*Zo]};var Ea,Aa,Ca,za,La,qa,Ta,Ra,Da,Pa,Ua,ja={sphere:b,point:St,lineStart:Nt,lineEnd:Et,polygonStart:function(){ja.lineStart=At},polygonEnd:function(){ja.lineStart=Nt}},Fa=Rt(zt,jt,Ht,[-Fo,-Fo/2]),Ha=1e9;ao.geo.clipExtent=function(){var n,t,e,r,i,u,o={stream:function(n){return i&&(i.valid=!1),i=u(n),i.valid=!0,i},extent:function(a){return arguments.length?(u=Zt(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),i&&(i.valid=!1,i=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(ao.geo.conicEqualArea=function(){return Vt(Xt)}).raw=Xt,ao.geo.albers=function(){return ao.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ao.geo.albersUsa=function(){function n(n){var u=n[0],o=n[1];return t=null,e(u,o),t||(r(u,o),t)||i(u,o),t}var t,e,r,i,u=ao.geo.albers(),o=ao.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ao.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=u.scale(),e=u.translate(),r=(n[0]-e[0])/t,i=(n[1]-e[1])/t;return(i>=.12&&.234>i&&r>=-.425&&-.214>r?o:i>=.166&&.234>i&&r>=-.214&&-.115>r?a:u).invert(n)},n.stream=function(n){var t=u.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,i){t.point(n,i),e.point(n,i),r.point(n,i)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(u.precision(t),o.precision(t),a.precision(t),n):u.precision()},n.scale=function(t){return arguments.length?(u.scale(t),o.scale(.35*t),a.scale(t),n.translate(u.translate())):u.scale()},n.translate=function(t){if(!arguments.length)return u.translate();var c=u.scale(),f=+t[0],s=+t[1];return e=u.translate(t).clipExtent([[f-.455*c,s-.238*c],[f+.455*c,s+.238*c]]).stream(l).point,r=o.translate([f-.307*c,s+.201*c]).clipExtent([[f-.425*c+Uo,s+.12*c+Uo],[f-.214*c-Uo,s+.234*c-Uo]]).stream(l).point,i=a.translate([f-.205*c,s+.212*c]).clipExtent([[f-.214*c+Uo,s+.166*c+Uo],[f-.115*c-Uo,s+.234*c-Uo]]).stream(l).point,n},n.scale(1070)};var Oa,Ia,Ya,Za,Va,Xa,$a={point:b,lineStart:b,lineEnd:b,polygonStart:function(){Ia=0,$a.lineStart=$t},polygonEnd:function(){$a.lineStart=$a.lineEnd=$a.point=b,Oa+=xo(Ia/2)}},Ba={point:Bt,lineStart:b,lineEnd:b,polygonStart:b,polygonEnd:b},Wa={point:Gt,lineStart:Kt,lineEnd:Qt,polygonStart:function(){Wa.lineStart=ne},polygonEnd:function(){Wa.point=Gt,Wa.lineStart=Kt,Wa.lineEnd=Qt}};ao.geo.path=function(){function n(n){return n&&("function"==typeof a&&u.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=i(u)),ao.geo.stream(n,o)),u.result()}function t(){return o=null,n}var e,r,i,u,o,a=4.5;return n.area=function(n){return Oa=0,ao.geo.stream(n,i($a)),Oa},n.centroid=function(n){return Ca=za=La=qa=Ta=Ra=Da=Pa=Ua=0,ao.geo.stream(n,i(Wa)),Ua?[Da/Ua,Pa/Ua]:Ra?[qa/Ra,Ta/Ra]:La?[Ca/La,za/La]:[NaN,NaN]},n.bounds=function(n){return Va=Xa=-(Ya=Za=1/0),ao.geo.stream(n,i(Ba)),[[Ya,Za],[Va,Xa]]},n.projection=function(n){return arguments.length?(i=(e=n)?n.stream||re(n):m,t()):e},n.context=function(n){return arguments.length?(u=null==(r=n)?new Wt:new te(n),"function"!=typeof a&&u.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(u.pointRadius(+t),+t),n):a},n.projection(ao.geo.albersUsa()).context(null)},ao.geo.transform=function(n){return{stream:function(t){var e=new ie(t);for(var r in n)e[r]=n[r];return e}}},ie.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ao.geo.projection=oe,ao.geo.projectionMutator=ae,(ao.geo.equirectangular=function(){return oe(ce)}).raw=ce.invert=ce,ao.geo.rotation=function(n){function t(t){return t=n(t[0]*Yo,t[1]*Yo),t[0]*=Zo,t[1]*=Zo,t}return n=se(n[0]%360*Yo,n[1]*Yo,n.length>2?n[2]*Yo:0),t.invert=function(t){return t=n.invert(t[0]*Yo,t[1]*Yo),t[0]*=Zo,t[1]*=Zo,t},t},fe.invert=ce,ao.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=se(-n[0]*Yo,-n[1]*Yo,0).invert,i=[];return e(null,null,1,{point:function(n,e){i.push(n=t(n,e)),n[0]*=Zo,n[1]*=Zo}}),{type:"Polygon",coordinates:[i]}}var t,e,r=[0,0],i=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=ve((t=+r)*Yo,i*Yo),n):t},n.precision=function(r){return arguments.length?(e=ve(t*Yo,(i=+r)*Yo),n):i},n.angle(90)},ao.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Yo,i=n[1]*Yo,u=t[1]*Yo,o=Math.sin(r),a=Math.cos(r),l=Math.sin(i),c=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*o)*e+(e=c*f-l*s*a)*e),l*f+c*s*a)},ao.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ao.range(Math.ceil(u/d)*d,i,d).map(h).concat(ao.range(Math.ceil(c/y)*y,l,y).map(p)).concat(ao.range(Math.ceil(r/g)*g,e,g).filter(function(n){return xo(n%d)>Uo}).map(f)).concat(ao.range(Math.ceil(a/v)*v,o,v).filter(function(n){return xo(n%y)>Uo}).map(s))}var e,r,i,u,o,a,l,c,f,s,h,p,g=10,v=g,d=90,y=360,m=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(p(l).slice(1),h(i).reverse().slice(1),p(c).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(u=+t[0][0],i=+t[1][0],c=+t[0][1],l=+t[1][1],u>i&&(t=u,u=i,i=t),c>l&&(t=c,c=l,l=t),n.precision(m)):[[u,c],[i,l]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(m)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],y=+t[1],n):[d,y]},n.minorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],n):[g,v]},n.precision=function(t){return arguments.length?(m=+t,f=ye(a,o,90),s=me(r,e,m),h=ye(c,l,90),p=me(u,i,m),n):m},n.majorExtent([[-180,-90+Uo],[180,90-Uo]]).minorExtent([[-180,-80-Uo],[180,80+Uo]])},ao.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||i.apply(this,arguments)]}}var t,e,r=Me,i=xe;return n.distance=function(){return ao.geo.distance(t||r.apply(this,arguments),e||i.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,n):i},n.precision=function(){return arguments.length?n:0},n},ao.geo.interpolate=function(n,t){return be(n[0]*Yo,n[1]*Yo,t[0]*Yo,t[1]*Yo)},ao.geo.length=function(n){return Ja=0,ao.geo.stream(n,Ga),Ja};var Ja,Ga={sphere:b,point:b,lineStart:_e,lineEnd:b,polygonStart:b,polygonEnd:b},Ka=we(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ao.geo.azimuthalEqualArea=function(){return oe(Ka)}).raw=Ka;var Qa=we(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},m);(ao.geo.azimuthalEquidistant=function(){return oe(Qa)}).raw=Qa,(ao.geo.conicConformal=function(){return Vt(Se)}).raw=Se,(ao.geo.conicEquidistant=function(){return Vt(ke)}).raw=ke;var nl=we(function(n){return 1/n},Math.atan);(ao.geo.gnomonic=function(){return oe(nl)}).raw=nl,Ne.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Io]},(ao.geo.mercator=function(){return Ee(Ne)}).raw=Ne;var tl=we(function(){return 1},Math.asin);(ao.geo.orthographic=function(){return oe(tl)}).raw=tl;var el=we(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ao.geo.stereographic=function(){return oe(el)}).raw=el,Ae.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Io]},(ao.geo.transverseMercator=function(){var n=Ee(Ae),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Ae,ao.geom={},ao.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,i=En(e),u=En(r),o=n.length,a=[],l=[];for(t=0;o>t;t++)a.push([+i.call(this,n[t],t),+u.call(this,n[t],t),t]);for(a.sort(qe),t=0;o>t;t++)l.push([a[t][0],-a[t][1]]);var c=Le(a),f=Le(l),s=f[0]===c[0],h=f[f.length-1]===c[c.length-1],p=[];for(t=c.length-1;t>=0;--t)p.push(n[a[c[t]][2]]);for(t=+s;t=r&&c.x<=u&&c.y>=i&&c.y<=o?[[r,o],[u,o],[u,i],[r,i]]:[];f.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(u(n,t)/Uo)*Uo,y:Math.round(o(n,t)/Uo)*Uo,i:t}})}var r=Ce,i=ze,u=r,o=i,a=sl;return n?t(n):(t.links=function(n){return ar(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return ar(e(n)).cells.forEach(function(e,r){for(var i,u,o=e.site,a=e.edges.sort(Ve),l=-1,c=a.length,f=a[c-1].edge,s=f.l===o?f.r:f.l;++l=c,h=r>=f,p=h<<1|s;n.leaf=!1,n=n.nodes[p]||(n.nodes[p]=hr()),s?i=c:a=c,h?o=f:l=f,u(n,t,e,r,i,o,a,l)}var f,s,h,p,g,v,d,y,m,M=En(a),x=En(l);if(null!=t)v=t,d=e,y=r,m=i;else if(y=m=-(v=d=1/0),s=[],h=[],g=n.length,o)for(p=0;g>p;++p)f=n[p],f.xy&&(y=f.x),f.y>m&&(m=f.y),s.push(f.x),h.push(f.y);else for(p=0;g>p;++p){var b=+M(f=n[p],p),_=+x(f,p);v>b&&(v=b),d>_&&(d=_),b>y&&(y=b),_>m&&(m=_),s.push(b),h.push(_)}var w=y-v,S=m-d;w>S?m=d+w:y=v+S;var k=hr();if(k.add=function(n){u(k,n,+M(n,++p),+x(n,p),v,d,y,m)},k.visit=function(n){pr(n,k,v,d,y,m)},k.find=function(n){return gr(k,n[0],n[1],v,d,y,m)},p=-1,null==t){for(;++p=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=vl.get(e)||gl,r=dl.get(r)||m,br(r(e.apply(null,lo.call(arguments,1))))},ao.interpolateHcl=Rr,ao.interpolateHsl=Dr,ao.interpolateLab=Pr,ao.interpolateRound=Ur,ao.transform=function(n){var t=fo.createElementNS(ao.ns.prefix.svg,"g");return(ao.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new jr(e?e.matrix:yl)})(n)},jr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var yl={a:1,b:0,c:0,d:1,e:0,f:0};ao.interpolateTransform=$r,ao.layout={},ao.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/y){if(v>l){var c=t.charge/l;n.px-=u*c,n.py-=o*c}return!0}if(t.point&&l&&v>l){var c=t.pointCharge/l;n.px-=u*c,n.py-=o*c}}return!t.charge}}function t(n){n.px=ao.event.x,n.py=ao.event.y,l.resume()}var e,r,i,u,o,a,l={},c=ao.dispatch("start","tick","end"),f=[1,1],s=.9,h=ml,p=Ml,g=-30,v=xl,d=.1,y=.64,M=[],x=[];return l.tick=function(){if((i*=.99)<.005)return e=null,c.end({type:"end",alpha:i=0}),!0;var t,r,l,h,p,v,y,m,b,_=M.length,w=x.length;for(r=0;w>r;++r)l=x[r],h=l.source,p=l.target,m=p.x-h.x,b=p.y-h.y,(v=m*m+b*b)&&(v=i*o[r]*((v=Math.sqrt(v))-u[r])/v,m*=v,b*=v,p.x-=m*(y=h.weight+p.weight?h.weight/(h.weight+p.weight):.5),p.y-=b*y,h.x+=m*(y=1-y),h.y+=b*y);if((y=i*d)&&(m=f[0]/2,b=f[1]/2,r=-1,y))for(;++r<_;)l=M[r],l.x+=(m-l.x)*y,l.y+=(b-l.y)*y;if(g)for(ri(t=ao.geom.quadtree(M),i,a),r=-1;++r<_;)(l=M[r]).fixed||t.visit(n(l));for(r=-1;++r<_;)l=M[r],l.fixed?(l.x=l.px,l.y=l.py):(l.x-=(l.px-(l.px=l.x))*s,l.y-=(l.py-(l.py=l.y))*s);c.tick({type:"tick",alpha:i})},l.nodes=function(n){return arguments.length?(M=n,l):M},l.links=function(n){return arguments.length?(x=n,l):x},l.size=function(n){return arguments.length?(f=n,l):f},l.linkDistance=function(n){return arguments.length?(h="function"==typeof n?n:+n,l):h},l.distance=l.linkDistance,l.linkStrength=function(n){return arguments.length?(p="function"==typeof n?n:+n,l):p},l.friction=function(n){return arguments.length?(s=+n,l):s},l.charge=function(n){return arguments.length?(g="function"==typeof n?n:+n,l):g},l.chargeDistance=function(n){return arguments.length?(v=n*n,l):Math.sqrt(v)},l.gravity=function(n){return arguments.length?(d=+n,l):d},l.theta=function(n){return arguments.length?(y=n*n,l):Math.sqrt(y)},l.alpha=function(n){return arguments.length?(n=+n,i?n>0?i=n:(e.c=null,e.t=NaN,e=null,c.end({type:"end",alpha:i=0})):n>0&&(c.start({type:"start",alpha:i=n}),e=qn(l.tick)),l):i},l.start=function(){function n(n,r){if(!e){for(e=new Array(i),l=0;i>l;++l)e[l]=[];for(l=0;c>l;++l){var u=x[l];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var o,a=e[t],l=-1,f=a.length;++lt;++t)(r=M[t]).index=t,r.weight=0;for(t=0;c>t;++t)r=x[t],"number"==typeof r.source&&(r.source=M[r.source]),"number"==typeof r.target&&(r.target=M[r.target]),++r.source.weight,++r.target.weight;for(t=0;i>t;++t)r=M[t],isNaN(r.x)&&(r.x=n("x",s)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof h)for(t=0;c>t;++t)u[t]=+h.call(this,x[t],t);else for(t=0;c>t;++t)u[t]=h;if(o=[],"function"==typeof p)for(t=0;c>t;++t)o[t]=+p.call(this,x[t],t);else for(t=0;c>t;++t)o[t]=p;if(a=[],"function"==typeof g)for(t=0;i>t;++t)a[t]=+g.call(this,M[t],t);else for(t=0;i>t;++t)a[t]=g;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return r||(r=ao.behavior.drag().origin(m).on("dragstart.force",Qr).on("drag.force",t).on("dragend.force",ni)),arguments.length?void this.on("mouseover.force",ti).on("mouseout.force",ei).call(r):r},ao.rebind(l,c,"on")};var ml=20,Ml=1,xl=1/0;ao.layout.hierarchy=function(){function n(i){var u,o=[i],a=[];for(i.depth=0;null!=(u=o.pop());)if(a.push(u),(c=e.call(n,u,u.depth))&&(l=c.length)){for(var l,c,f;--l>=0;)o.push(f=c[l]),f.parent=u,f.depth=u.depth+1;r&&(u.value=0),u.children=c}else r&&(u.value=+r.call(n,u,u.depth)||0),delete u.children;return oi(i,function(n){var e,i;t&&(e=n.children)&&e.sort(t),r&&(i=n.parent)&&(i.value+=n.value)}),a}var t=ci,e=ai,r=li;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(ui(t,function(n){n.children&&(n.value=0)}),oi(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ao.layout.partition=function(){function n(t,e,r,i){var u=t.children;if(t.x=e,t.y=t.depth*i,t.dx=r,t.dy=i,u&&(o=u.length)){var o,a,l,c=-1;for(r=t.value?r/t.value:0;++cs?-1:1),g=ao.sum(c),v=g?(s-l*p)/g:0,d=ao.range(l),y=[];return null!=e&&d.sort(e===bl?function(n,t){return c[t]-c[n]}:function(n,t){return e(o[n],o[t])}),d.forEach(function(n){y[n]={data:o[n],value:a=c[n],startAngle:f,endAngle:f+=a*v+p,padAngle:h}}),y}var t=Number,e=bl,r=0,i=Ho,u=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(i=t,n):i},n.padAngle=function(t){return arguments.length?(u=t,n):u},n};var bl={};ao.layout.stack=function(){function n(a,l){if(!(h=a.length))return a;var c=a.map(function(e,r){return t.call(n,e,r)}),f=c.map(function(t){return t.map(function(t,e){return[u.call(n,t,e),o.call(n,t,e)]})}),s=e.call(n,f,l);c=ao.permute(c,s),f=ao.permute(f,s);var h,p,g,v,d=r.call(n,f,l),y=c[0].length;for(g=0;y>g;++g)for(i.call(n,c[0][g],v=d[g],f[0][g][1]),p=1;h>p;++p)i.call(n,c[p][g],v+=f[p-1][g][1],f[p][g][1]);return a}var t=m,e=gi,r=vi,i=pi,u=si,o=hi;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:_l.get(t)||gi,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:wl.get(t)||vi,n):r},n.x=function(t){return arguments.length?(u=t,n):u},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(i=t,n):i},n};var _l=ao.map({"inside-out":function(n){var t,e,r=n.length,i=n.map(di),u=n.map(yi),o=ao.range(r).sort(function(n,t){return i[n]-i[t]}),a=0,l=0,c=[],f=[];for(t=0;r>t;++t)e=o[t],l>a?(a+=u[e],c.push(e)):(l+=u[e],f.push(e));return f.reverse().concat(c)},reverse:function(n){return ao.range(n.length).reverse()},"default":gi}),wl=ao.map({silhouette:function(n){var t,e,r,i=n.length,u=n[0].length,o=[],a=0,l=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;u>e;++e)l[e]=(a-o[e])/2;return l},wiggle:function(n){var t,e,r,i,u,o,a,l,c,f=n.length,s=n[0],h=s.length,p=[];for(p[0]=l=c=0,e=1;h>e;++e){for(t=0,i=0;f>t;++t)i+=n[t][e][1];for(t=0,u=0,a=s[e][0]-s[e-1][0];f>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;u+=o*n[t][e][1]}p[e]=l-=i?u/i*a:0,c>l&&(c=l)}for(e=0;h>e;++e)p[e]-=c;return p},expand:function(n){var t,e,r,i=n.length,u=n[0].length,o=1/i,a=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];if(r)for(t=0;i>t;t++)n[t][e][1]/=r;else for(t=0;i>t;t++)n[t][e][1]=o}for(e=0;u>e;++e)a[e]=0;return a},zero:vi});ao.layout.histogram=function(){function n(n,u){for(var o,a,l=[],c=n.map(e,this),f=r.call(this,c,u),s=i.call(this,f,c,u),u=-1,h=c.length,p=s.length-1,g=t?1:1/h;++u0)for(u=-1;++u=f[0]&&a<=f[1]&&(o=l[ao.bisect(s,a,1,p)-1],o.y+=g,o.push(n[u]));return l}var t=!0,e=Number,r=bi,i=Mi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=En(t),n):r},n.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return xi(n,t)}:En(t),n):i},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ao.layout.pack=function(){function n(n,u){var o=e.call(this,n,u),a=o[0],l=i[0],c=i[1],f=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,oi(a,function(n){n.r=+f(n.value)}),oi(a,Ni),r){var s=r*(t?1:Math.max(2*a.r/l,2*a.r/c))/2;oi(a,function(n){n.r+=s}),oi(a,Ni),oi(a,function(n){n.r-=s})}return Ci(a,l/2,c/2,t?1:1/Math.max(2*a.r/l,2*a.r/c)),o}var t,e=ao.layout.hierarchy().sort(_i),r=0,i=[1,1];return n.size=function(t){return arguments.length?(i=t,n):i},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},ii(n,e)},ao.layout.tree=function(){function n(n,i){var f=o.call(this,n,i),s=f[0],h=t(s);if(oi(h,e),h.parent.m=-h.z,ui(h,r),c)ui(s,u);else{var p=s,g=s,v=s;ui(s,function(n){n.xg.x&&(g=n),n.depth>v.depth&&(v=n)});var d=a(p,g)/2-p.x,y=l[0]/(g.x+a(g,p)/2+d),m=l[1]/(v.depth||1);ui(s,function(n){n.x=(n.x+d)*y,n.y=n.depth*m})}return f}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var i,u=t.children,o=0,a=u.length;a>o;++o)r.push((u[o]=i={_:u[o],parent:t,children:(i=u[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Di(n);var u=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-u):n.z=u}else r&&(n.z=r.z+a(n._,r._));n.parent.A=i(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function i(n,t,e){if(t){for(var r,i=n,u=n,o=t,l=i.parent.children[0],c=i.m,f=u.m,s=o.m,h=l.m;o=Ti(o),i=qi(i),o&&i;)l=qi(l),u=Ti(u),u.a=n,r=o.z+s-i.z-c+a(o._,i._),r>0&&(Ri(Pi(o,n,e),n,r),c+=r,f+=r),s+=o.m,c+=i.m,h+=l.m,f+=u.m;o&&!Ti(u)&&(u.t=o,u.m+=s-f),i&&!qi(l)&&(l.t=i,l.m+=c-h,e=n)}return e}function u(n){n.x*=l[0],n.y=n.depth*l[1]}var o=ao.layout.hierarchy().sort(null).value(null),a=Li,l=[1,1],c=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(c=null==(l=t)?u:null,n):c?null:l},n.nodeSize=function(t){return arguments.length?(c=null==(l=t)?null:u,n):c?l:null},ii(n,o)},ao.layout.cluster=function(){function n(n,u){var o,a=t.call(this,n,u),l=a[0],c=0;oi(l,function(n){var t=n.children;t&&t.length?(n.x=ji(t),n.y=Ui(t)):(n.x=o?c+=e(n,o):0,n.y=0,o=n)});var f=Fi(l),s=Hi(l),h=f.x-e(f,s)/2,p=s.x+e(s,f)/2;return oi(l,i?function(n){n.x=(n.x-l.x)*r[0],n.y=(l.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(p-h)*r[0],n.y=(1-(l.y?n.y/l.y:1))*r[1]}),a}var t=ao.layout.hierarchy().sort(null).value(null),e=Li,r=[1,1],i=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(i=null==(r=t),n):i?null:r},n.nodeSize=function(t){return arguments.length?(i=null!=(r=t),n):i?r:null},ii(n,t)},ao.layout.treemap=function(){function n(n,t){for(var e,r,i=-1,u=n.length;++it?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var u=e.children;if(u&&u.length){var o,a,l,c=s(e),f=[],h=u.slice(),g=1/0,v="slice"===p?c.dx:"dice"===p?c.dy:"slice-dice"===p?1&e.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(n(h,c.dx*c.dy/e.value),f.area=0;(l=h.length)>0;)f.push(o=h[l-1]),f.area+=o.area,"squarify"!==p||(a=r(f,v))<=g?(h.pop(),g=a):(f.area-=f.pop().area,i(f,v,c,!1),v=Math.min(c.dx,c.dy),f.length=f.area=0,g=1/0);f.length&&(i(f,v,c,!0),f.length=f.area=0),u.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var u,o=s(t),a=r.slice(),l=[];for(n(a,o.dx*o.dy/t.value),l.area=0;u=a.pop();)l.push(u),l.area+=u.area,null!=u.z&&(i(l,u.z?o.dx:o.dy,o,!a.length),l.length=l.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,i=0,u=1/0,o=-1,a=n.length;++oe&&(u=e),e>i&&(i=e));return r*=r,t*=t,r?Math.max(t*i*g/r,r/(t*u*g)):1/0}function i(n,t,e,r){var i,u=-1,o=n.length,a=e.x,c=e.y,f=t?l(n.area/t):0; -if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ue.dx)&&(f=e.dx);++ue&&(t=1),1>e&&(n=0),function(){var e,r,i;do e=2*Math.random()-1,r=2*Math.random()-1,i=e*e+r*r;while(!i||i>1);return n+t*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=ao.random.normal.apply(ao,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ao.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ao.scale={};var Sl={floor:m,ceil:m};ao.scale.linear=function(){return Wi([0,1],[0,1],Mr,!1)};var kl={s:1,g:1,p:1,r:1,e:1};ao.scale.log=function(){return ru(ao.scale.linear().domain([0,1]),10,!0,[1,10])};var Nl=ao.format(".0e"),El={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ao.scale.pow=function(){return iu(ao.scale.linear(),1,[0,1])},ao.scale.sqrt=function(){return ao.scale.pow().exponent(.5)},ao.scale.ordinal=function(){return ou([],{t:"range",a:[[]]})},ao.scale.category10=function(){return ao.scale.ordinal().range(Al)},ao.scale.category20=function(){return ao.scale.ordinal().range(Cl)},ao.scale.category20b=function(){return ao.scale.ordinal().range(zl)},ao.scale.category20c=function(){return ao.scale.ordinal().range(Ll)};var Al=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(xn),Cl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(xn),zl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(xn),Ll=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(xn);ao.scale.quantile=function(){return au([],[])},ao.scale.quantize=function(){return lu(0,1,[0,1])},ao.scale.threshold=function(){return cu([.5],[0,1])},ao.scale.identity=function(){return fu([0,1])},ao.svg={},ao.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),f=o.apply(this,arguments)-Io,s=a.apply(this,arguments)-Io,h=Math.abs(s-f),p=f>s?0:1;if(n>c&&(g=c,c=n,n=g),h>=Oo)return t(c,p)+(n?t(n,1-p):"")+"Z";var g,v,d,y,m,M,x,b,_,w,S,k,N=0,E=0,A=[];if((y=(+l.apply(this,arguments)||0)/2)&&(d=u===ql?Math.sqrt(n*n+c*c):+u.apply(this,arguments),p||(E*=-1),c&&(E=tn(d/c*Math.sin(y))),n&&(N=tn(d/n*Math.sin(y)))),c){m=c*Math.cos(f+E),M=c*Math.sin(f+E),x=c*Math.cos(s-E),b=c*Math.sin(s-E);var C=Math.abs(s-f-2*E)<=Fo?0:1;if(E&&yu(m,M,x,b)===p^C){var z=(f+s)/2;m=c*Math.cos(z),M=c*Math.sin(z),x=b=null}}else m=M=0;if(n){_=n*Math.cos(s-N),w=n*Math.sin(s-N),S=n*Math.cos(f+N),k=n*Math.sin(f+N);var L=Math.abs(f-s+2*N)<=Fo?0:1;if(N&&yu(_,w,S,k)===1-p^L){var q=(f+s)/2;_=n*Math.cos(q),w=n*Math.sin(q),S=k=null}}else _=w=0;if(h>Uo&&(g=Math.min(Math.abs(c-n)/2,+i.apply(this,arguments)))>.001){v=c>n^p?0:1;var T=g,R=g;if(Fo>h){var D=null==S?[_,w]:null==x?[m,M]:Re([m,M],[S,k],[x,b],[_,w]),P=m-D[0],U=M-D[1],j=x-D[0],F=b-D[1],H=1/Math.sin(Math.acos((P*j+U*F)/(Math.sqrt(P*P+U*U)*Math.sqrt(j*j+F*F)))/2),O=Math.sqrt(D[0]*D[0]+D[1]*D[1]);R=Math.min(g,(n-O)/(H-1)),T=Math.min(g,(c-O)/(H+1))}if(null!=x){var I=mu(null==S?[_,w]:[S,k],[m,M],c,T,p),Y=mu([x,b],[_,w],c,T,p);g===T?A.push("M",I[0],"A",T,",",T," 0 0,",v," ",I[1],"A",c,",",c," 0 ",1-p^yu(I[1][0],I[1][1],Y[1][0],Y[1][1]),",",p," ",Y[1],"A",T,",",T," 0 0,",v," ",Y[0]):A.push("M",I[0],"A",T,",",T," 0 1,",v," ",Y[0])}else A.push("M",m,",",M);if(null!=S){var Z=mu([m,M],[S,k],n,-R,p),V=mu([_,w],null==x?[m,M]:[x,b],n,-R,p);g===R?A.push("L",V[0],"A",R,",",R," 0 0,",v," ",V[1],"A",n,",",n," 0 ",p^yu(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-p," ",Z[1],"A",R,",",R," 0 0,",v," ",Z[0]):A.push("L",V[0],"A",R,",",R," 0 0,",v," ",Z[0])}else A.push("L",_,",",w)}else A.push("M",m,",",M),null!=x&&A.push("A",c,",",c," 0 ",C,",",p," ",x,",",b),A.push("L",_,",",w),null!=S&&A.push("A",n,",",n," 0 ",L,",",1-p," ",S,",",k);return A.push("Z"),A.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=hu,r=pu,i=su,u=ql,o=gu,a=vu,l=du;return n.innerRadius=function(t){return arguments.length?(e=En(t),n):e},n.outerRadius=function(t){return arguments.length?(r=En(t),n):r},n.cornerRadius=function(t){return arguments.length?(i=En(t),n):i},n.padRadius=function(t){return arguments.length?(u=t==ql?ql:En(t),n):u},n.startAngle=function(t){return arguments.length?(o=En(t),n):o},n.endAngle=function(t){return arguments.length?(a=En(t),n):a},n.padAngle=function(t){return arguments.length?(l=En(t),n):l},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-Io;return[Math.cos(t)*n,Math.sin(t)*n]},n};var ql="auto";ao.svg.line=function(){return Mu(m)};var Tl=ao.map({linear:xu,"linear-closed":bu,step:_u,"step-before":wu,"step-after":Su,basis:zu,"basis-open":Lu,"basis-closed":qu,bundle:Tu,cardinal:Eu,"cardinal-open":ku,"cardinal-closed":Nu,monotone:Fu});Tl.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Rl=[0,2/3,1/3,0],Dl=[0,1/3,2/3,0],Pl=[0,1/6,2/3,1/6];ao.svg.line.radial=function(){var n=Mu(Hu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},wu.reverse=Su,Su.reverse=wu,ao.svg.area=function(){return Ou(m)},ao.svg.area.radial=function(){var n=Ou(Hu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ao.svg.chord=function(){function n(n,a){var l=t(this,u,n,a),c=t(this,o,n,a);return"M"+l.p0+r(l.r,l.p1,l.a1-l.a0)+(e(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function t(n,t,e,r){var i=t.call(n,e,r),u=a.call(n,i,r),o=l.call(n,i,r)-Io,f=c.call(n,i,r)-Io;return{r:u,a0:o,a1:f,p0:[u*Math.cos(o),u*Math.sin(o)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Fo)+",1 "+t}function i(n,t,e,r){return"Q 0,0 "+r}var u=Me,o=xe,a=Iu,l=gu,c=vu;return n.radius=function(t){return arguments.length?(a=En(t),n):a},n.source=function(t){return arguments.length?(u=En(t),n):u},n.target=function(t){return arguments.length?(o=En(t),n):o},n.startAngle=function(t){return arguments.length?(l=En(t),n):l},n.endAngle=function(t){return arguments.length?(c=En(t),n):c},n},ao.svg.diagonal=function(){function n(n,i){var u=t.call(this,n,i),o=e.call(this,n,i),a=(u.y+o.y)/2,l=[u,{x:u.x,y:a},{x:o.x,y:a},o];return l=l.map(r),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var t=Me,e=xe,r=Yu;return n.source=function(e){return arguments.length?(t=En(e),n):t},n.target=function(t){return arguments.length?(e=En(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ao.svg.diagonal.radial=function(){var n=ao.svg.diagonal(),t=Yu,e=n.projection;return n.projection=function(n){return arguments.length?e(Zu(t=n)):t},n},ao.svg.symbol=function(){function n(n,r){return(Ul.get(t.call(this,n,r))||$u)(e.call(this,n,r))}var t=Xu,e=Vu;return n.type=function(e){return arguments.length?(t=En(e),n):t},n.size=function(t){return arguments.length?(e=En(t),n):e},n};var Ul=ao.map({circle:$u,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Fl)),e=t*Fl;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ao.svg.symbolTypes=Ul.keys();var jl=Math.sqrt(3),Fl=Math.tan(30*Yo);Co.transition=function(n){for(var t,e,r=Hl||++Zl,i=Ku(n),u=[],o=Ol||{time:Date.now(),ease:Nr,delay:0,duration:250},a=-1,l=this.length;++au;u++){i.push(t=[]);for(var e=this[u],a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return Wu(i,this.namespace,this.id)},Yl.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):Y(this,null==t?function(t){t[r][e].tween.remove(n)}:function(i){i[r][e].tween.set(n,t)})},Yl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function i(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function u(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?$r:Mr,a=ao.ns.qualify(n);return Ju(this,"attr."+n,t,a.local?u:i)},Yl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(i));return r&&function(n){this.setAttribute(i,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(i.space,i.local));return r&&function(n){this.setAttributeNS(i.space,i.local,r(n))}}var i=ao.ns.qualify(n);return this.tween("attr."+n,i.local?r:e)},Yl.style=function(n,e,r){function i(){this.style.removeProperty(n)}function u(e){return null==e?i:(e+="",function(){var i,u=t(this).getComputedStyle(this,null).getPropertyValue(n);return u!==e&&(i=Mr(u,e),function(t){this.style.setProperty(n,i(t),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof n){2>o&&(e="");for(r in n)this.style(r,n[r],e);return this}r=""}return Ju(this,"style."+n,e,u)},Yl.styleTween=function(n,e,r){function i(i,u){var o=e.call(this,i,u,t(this).getComputedStyle(this,null).getPropertyValue(n));return o&&function(t){this.style.setProperty(n,o(t),r)}}return arguments.length<3&&(r=""),this.tween("style."+n,i)},Yl.text=function(n){return Ju(this,"text",n,Gu)},Yl.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Yl.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ao.ease.apply(ao,arguments)),Y(this,function(r){r[e][t].ease=n}))},Yl.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:Y(this,"function"==typeof n?function(r,i,u){r[e][t].delay=+n.call(r,r.__data__,i,u)}:(n=+n,function(r){r[e][t].delay=n}))},Yl.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:Y(this,"function"==typeof n?function(r,i,u){r[e][t].duration=Math.max(1,n.call(r,r.__data__,i,u))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Yl.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var i=Ol,u=Hl;try{Hl=e,Y(this,function(t,i,u){Ol=t[r][e],n.call(t,t.__data__,i,u)})}finally{Ol=i,Hl=u}}else Y(this,function(i){var u=i[r][e];(u.event||(u.event=ao.dispatch("start","end","interrupt"))).on(n,t)});return this},Yl.transition=function(){for(var n,t,e,r,i=this.id,u=++Zl,o=this.namespace,a=[],l=0,c=this.length;c>l;l++){a.push(n=[]);for(var t=this[l],f=0,s=t.length;s>f;f++)(e=t[f])&&(r=e[o][i],Qu(e,f,o,u,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Wu(a,o,u)},ao.svg.axis=function(){function n(n){n.each(function(){var n,c=ao.select(this),f=this.__chart__||e,s=this.__chart__=e.copy(),h=null==l?s.ticks?s.ticks.apply(s,a):s.domain():l,p=null==t?s.tickFormat?s.tickFormat.apply(s,a):m:t,g=c.selectAll(".tick").data(h,s),v=g.enter().insert("g",".domain").attr("class","tick").style("opacity",Uo),d=ao.transition(g.exit()).style("opacity",Uo).remove(),y=ao.transition(g.order()).style("opacity",1),M=Math.max(i,0)+o,x=Zi(s),b=c.selectAll(".domain").data([0]),_=(b.enter().append("path").attr("class","domain"),ao.transition(b));v.append("line"),v.append("text");var w,S,k,N,E=v.select("line"),A=y.select("line"),C=g.select("text").text(p),z=v.select("text"),L=y.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=no,w="x",k="y",S="x2",N="y2",C.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),_.attr("d","M"+x[0]+","+q*u+"V0H"+x[1]+"V"+q*u)):(n=to,w="y",k="x",S="y2",N="x2",C.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),_.attr("d","M"+q*u+","+x[0]+"H0V"+x[1]+"H"+q*u)),E.attr(N,q*i),z.attr(k,q*M),A.attr(S,0).attr(N,q*i),L.attr(w,0).attr(k,q*M),s.rangeBand){var T=s,R=T.rangeBand()/2;f=s=function(n){return T(n)+R}}else f.rangeBand?f=s:d.call(n,s,f);v.call(n,f,s),y.call(n,s,s)})}var t,e=ao.scale.linear(),r=Vl,i=6,u=6,o=3,a=[10],l=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Xl?t+"":Vl,n):r},n.ticks=function(){return arguments.length?(a=co(arguments),n):a},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(i=+t,u=+arguments[e-1],n):i},n.innerTickSize=function(t){return arguments.length?(i=+t,n):i},n.outerTickSize=function(t){return arguments.length?(u=+t,n):u},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Vl="bottom",Xl={top:1,right:1,bottom:1,left:1};ao.svg.brush=function(){function n(t){t.each(function(){var t=ao.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=t.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=t.selectAll(".resize").data(v,m);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return $l[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var l,s=ao.transition(t),h=ao.transition(o);c&&(l=Zi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(s)),f&&(l=Zi(f),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(s)),e(s)})}function e(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function r(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function i(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function u(){function u(){32==ao.event.keyCode&&(C||(M=null,L[0]-=s[1],L[1]-=h[1],C=2),S())}function v(){32==ao.event.keyCode&&2==C&&(L[0]+=s[1],L[1]+=h[1],C=0,S())}function d(){var n=ao.mouse(b),t=!1;x&&(n[0]+=x[0],n[1]+=x[1]),C||(ao.event.altKey?(M||(M=[(s[0]+s[1])/2,(h[0]+h[1])/2]),L[0]=s[+(n[0]f?(i=r,r=f):i=f),v[0]!=r||v[1]!=i?(e?a=null:o=null,v[0]=r,v[1]=i,!0):void 0}function m(){d(),k.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ao.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),z(),w({type:"brushend"})}var M,x,b=this,_=ao.select(ao.event.target),w=l.of(b,arguments),k=ao.select(b),N=_.datum(),E=!/^(n|s)$/.test(N)&&c,A=!/^(e|w)$/.test(N)&&f,C=_.classed("extent"),z=W(b),L=ao.mouse(b),q=ao.select(t(b)).on("keydown.brush",u).on("keyup.brush",v);if(ao.event.changedTouches?q.on("touchmove.brush",d).on("touchend.brush",m):q.on("mousemove.brush",d).on("mouseup.brush",m),k.interrupt().selectAll("*").interrupt(),C)L[0]=s[0]-L[0],L[1]=h[0]-L[1];else if(N){var T=+/w$/.test(N),R=+/^n/.test(N);x=[s[1-T]-L[0],h[1-R]-L[1]],L[0]=s[T],L[1]=h[R]}else ao.event.altKey&&(M=L.slice());k.style("pointer-events","none").selectAll(".resize").style("display",null),ao.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),d()}var o,a,l=N(n,"brushstart","brush","brushend"),c=null,f=null,s=[0,0],h=[0,0],p=!0,g=!0,v=Bl[0];return n.event=function(n){n.each(function(){var n=l.of(this,arguments),t={x:s,y:h,i:o,j:a},e=this.__chart__||t;this.__chart__=t,Hl?ao.select(this).transition().each("start.brush",function(){o=e.i,a=e.j,s=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=xr(s,t.x),r=xr(h,t.y);return o=a=null,function(i){s=t.x=e(i),h=t.y=r(i),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=t.i,a=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,v=Bl[!c<<1|!f],n):c},n.y=function(t){return arguments.length?(f=t,v=Bl[!c<<1|!f],n):f},n.clamp=function(t){return arguments.length?(c&&f?(p=!!t[0],g=!!t[1]):c?p=!!t:f&&(g=!!t),n):c&&f?[p,g]:c?p:f?g:null},n.extent=function(t){var e,r,i,u,l;return arguments.length?(c&&(e=t[0],r=t[1],f&&(e=e[0],r=r[0]),o=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(l=e,e=r,r=l),e==s[0]&&r==s[1]||(s=[e,r])),f&&(i=t[0],u=t[1],c&&(i=i[1],u=u[1]),a=[i,u],f.invert&&(i=f(i),u=f(u)),i>u&&(l=i,i=u,u=l),i==h[0]&&u==h[1]||(h=[i,u])),n):(c&&(o?(e=o[0],r=o[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(l=e,e=r,r=l))),f&&(a?(i=a[0],u=a[1]):(i=h[0],u=h[1],f.invert&&(i=f.invert(i),u=f.invert(u)),i>u&&(l=i,i=u,u=l))),c&&f?[[e,i],[r,u]]:c?[e,r]:f&&[i,u])},n.clear=function(){return n.empty()||(s=[0,0],h=[0,0],o=a=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!f&&h[0]==h[1]},ao.rebind(n,l,"on")};var $l={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Bl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Wl=ga.format=xa.timeFormat,Jl=Wl.utc,Gl=Jl("%Y-%m-%dT%H:%M:%S.%LZ");Wl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?eo:Gl,eo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},eo.toString=Gl.toString,ga.second=On(function(n){return new va(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),ga.seconds=ga.second.range,ga.seconds.utc=ga.second.utc.range,ga.minute=On(function(n){return new va(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),ga.minutes=ga.minute.range,ga.minutes.utc=ga.minute.utc.range,ga.hour=On(function(n){var t=n.getTimezoneOffset()/60;return new va(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),ga.hours=ga.hour.range,ga.hours.utc=ga.hour.utc.range,ga.month=On(function(n){return n=ga.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ga.months=ga.month.range,ga.months.utc=ga.month.utc.range;var Kl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ql=[[ga.second,1],[ga.second,5],[ga.second,15],[ga.second,30],[ga.minute,1],[ga.minute,5],[ga.minute,15],[ga.minute,30],[ga.hour,1],[ga.hour,3],[ga.hour,6],[ga.hour,12],[ga.day,1],[ga.day,2],[ga.week,1],[ga.month,1],[ga.month,3],[ga.year,1]],nc=Wl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",zt]]),tc={range:function(n,t,e){return ao.range(Math.ceil(n/e)*e,+t,e).map(io)},floor:m,ceil:m};Ql.year=ga.year,ga.scale=function(){return ro(ao.scale.linear(),Ql,nc)};var ec=Ql.map(function(n){return[n[0].utc,n[1]]}),rc=Jl.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",zt]]);ec.year=ga.year.utc,ga.scale.utc=function(){return ro(ao.scale.linear(),ec,rc)},ao.text=An(function(n){return n.responseText}),ao.json=function(n,t){return Cn(n,"application/json",uo,t)},ao.html=function(n,t){return Cn(n,"text/html",oo,t)},ao.xml=An(function(n){return n.responseXML}),"function"==typeof define&&define.amd?(this.d3=ao,define(ao)):"object"==typeof module&&module.exports?module.exports=ao:this.d3=ao}(); \ No newline at end of file +!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function u(n){return!isNaN(n)}function i(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function f(n){return(n+="")===ei||n[0]===ri?ri+n:n}function s(n){return(n+="")[0]===ri?n.slice(1):n}function h(n){return f(n)in this._}function g(n){return(n=f(n))in this._&&delete this._[n]}function p(){var n=[];for(var t in this._)n.push(s(t));return n}function d(){var n=0;for(var t in this._)++n;return n}function v(){for(var n in this._)return!1;return!0}function y(){this._=Object.create(null)}function m(n){return n}function x(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function M(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=ui.length;r>e;++e){var u=ui[e]+t;if(u in n)return u}}function _(){}function b(){}function w(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function Z(n){return oi(n,gi),n}function V(n){var t,e;return function(r,u,i){var o,a=n[i].update,l=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var c=pi.get(n);return c&&(n=c,l=B),a?t?u:r:t?_:i}function $(n,t){return function(e){var r=Iu.event;Iu.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{Iu.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++vi,u="click"+r,i=Iu.select(t(e)).on("touchmove"+r,k).on("dragstart"+r,k).on("selectstart"+r,k);if(null==di&&(di="onselectstart"in e?!1:M(e.style,"userSelect")),di){var o=n(e).style,a=o[di];o[di]="none"}return function(n){if(i.on(r,null),di&&(o[di]=a),n){var t=function(){i.on(u,null)};i.on(u,function(){k(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var u=r.createSVGPoint();if(0>yi){var i=t(n);if(i.scrollX||i.scrollY){r=Iu.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();yi=!(o.f||o.e),r.remove()}}return yi?(u.x=e.pageX,u.y=e.pageY):(u.x=e.clientX,u.y=e.clientY),u=u.matrixTransform(n.getScreenCTM().inverse()),[u.x,u.y]}var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}function G(){return Iu.event.changedTouches[0].identifier}function K(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function Q(n){return n>1?wi:-1>n?-wi:Math.asin(n)}function nn(n){return((n=Math.exp(n))-1/n)/2}function tn(n){return((n=Math.exp(n))+1/n)/2}function en(n){return((n=Math.exp(2*n))-1)/(n+1)}function rn(){}function un(n,t,e){return this instanceof un?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof un?new un(n.h,n.s,n.l):xn(""+n,Mn,un):new un(n,t,e)}function on(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new dn(u(n+120),u(n),u(n-120))}function an(n,t,e){return this instanceof an?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof an?new an(n.h,n.c,n.l):n instanceof cn?sn(n.l,n.a,n.b):sn((n=_n((n=Iu.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new an(n,t,e)}function ln(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new cn(e,Math.cos(n*=ki)*t,Math.sin(n)*t)}function cn(n,t,e){return this instanceof cn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof cn?new cn(n.l,n.a,n.b):n instanceof an?ln(n.h,n.c,n.l):_n((n=dn(n)).r,n.g,n.b):new cn(n,t,e)}function fn(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=hn(u)*Ei,r=hn(r)*Ui,i=hn(i)*Pi,new dn(pn(3.2404542*u-1.5371385*r-.4985314*i),pn(-.969266*u+1.8760108*r+.041556*i),pn(.0556434*u-.2040259*r+1.0572252*i))}function sn(n,t,e){return n>0?new an(Math.atan2(e,t)*Ni,Math.sqrt(t*t+e*e),n):new an(NaN,NaN,n)}function hn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function gn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function pn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function dn(n,t,e){return this instanceof dn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof dn?new dn(n.r,n.g,n.b):xn(""+n,dn,on):new dn(n,t,e)}function vn(n){return new dn(n>>16,n>>8&255,255&n)}function yn(n){return vn(n)+""}function mn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function xn(n,t,e){var r,u,i,o=0,a=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(wn(u[0]),wn(u[1]),wn(u[2]))}return(i=Fi.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,l=15&i,l=l<<4|l):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,l=255&i)),t(o,a,l))}function Mn(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,l=(o+i)/2;return a?(u=.5>l?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=NaN,u=l>0&&1>l?0:r),new un(r,u,l)}function _n(n,t,e){n=bn(n),t=bn(t),e=bn(e);var r=gn((.4124564*n+.3575761*t+.1804375*e)/Ei),u=gn((.2126729*n+.7151522*t+.072175*e)/Ui),i=gn((.0193339*n+.119192*t+.9503041*e)/Pi);return cn(116*u-16,500*(r-u),200*(u-i))}function bn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function wn(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function kn(n){return"function"==typeof n?n:function(){return n}}function Nn(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),An(t,e,n,r)}}function An(n,t,e,r){function u(){var n,t=l.status;if(!t&&zn(l)||t>=200&&300>t||304===t){try{n=e.call(i,l)}catch(r){return void o.error.call(i,r)}o.load.call(i,n)}else o.error.call(i,l)}var i={},o=Iu.dispatch("beforesend","progress","load","error"),a={},l=new XMLHttpRequest,c=null;return!this.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(n)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=u:l.onreadystatechange=function(){l.readyState>3&&u()},l.onprogress=function(n){var t=Iu.event;Iu.event=n;try{o.progress.call(i,l)}finally{Iu.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(c=n,i):c},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(Vu(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),l.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),l.setRequestHeader)for(var f in a)l.setRequestHeader(f,a[f]);return null!=t&&l.overrideMimeType&&l.overrideMimeType(t),null!=c&&(l.responseType=c),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,l),l.send(null==r?null:r),i},i.abort=function(){return l.abort(),i},Iu.rebind(i,o,"on"),null==r?i:i.get(Cn(r))}function Cn(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function zn(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function Ln(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,n:null};return Yi?Yi.n=i:Oi=i,Yi=i,Ii||(Zi=clearTimeout(Zi),Ii=1,Vi(Sn)),i}function Sn(){var n=Tn(),t=qn()-n;t>24?(isFinite(t)&&(clearTimeout(Zi),Zi=setTimeout(Sn,t)),Ii=0):(Ii=1,Vi(Sn))}function Tn(){for(var n=Date.now(),t=Oi;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function qn(){for(var n,t=Oi,e=1/0;t;)t.c?(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function En(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],o=0,a=r[0],l=0;u>0&&a>0&&(l+a+1>t&&(a=Math.max(1,t-l)),i.push(n.substring(u-=a,u+a)),!((l+=a+1)>t));)a=r[o=(o+1)%r.length];return i.reverse().join(e)}:m;return function(n){var e=$i.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",l=e[4]||"",c=e[5],f=+e[6],s=e[7],h=e[8],g=e[9],p=1,d="",v="",y=!1,m=!0;switch(h&&(h=+h.substring(1)),(c||"0"===r&&"="===o)&&(c=r="0",o="="),g){case"n":s=!0,g="g";break;case"%":p=100,v="%",g="f";break;case"p":p=100,v="%",g="r";break;case"b":case"o":case"x":case"X":"#"===l&&(d="0"+g.toLowerCase());case"c":m=!1;case"d":y=!0,h=0;break;case"s":p=-1,g="r"}"$"===l&&(d=u[0],v=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):"e"!=g&&"f"!=g||(h=Math.max(0,Math.min(20,h)))),g=Bi.get(g)||Un;var x=c&&s;return function(n){var e=v;if(y&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>p){var l=Iu.formatPrefix(n,h);n=l.scale(n),e=l.symbol+v}else n*=p;n=g(n,h);var M,_,b=n.lastIndexOf(".");if(0>b){var w=m?n.lastIndexOf("e"):-1;0>w?(M=n,_=""):(M=n.substring(0,w),_=n.substring(w))}else M=n.substring(0,b),_=t+n.substring(b+1);!c&&s&&(M=i(M,1/0));var k=d.length+M.length+_.length+(x?0:u.length),N=f>k?new Array(k=f-k+1).join(r):"";return x&&(M=i(N+M,N.length?f-_.length:1/0)),u+=d,n=M+_,("<"===o?u+n+N:">"===o?N+u+n:"^"===o?N.substring(0,k>>=1)+u+n+N.substring(k):u+(x?n:N+n))+e}}}function Un(n){return n+""}function Pn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function jn(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new Ji(e-1)),1),e}function i(n,e){return t(n=new Ji(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{Ji=Pn;var r=new Pn;return r._=n,o(r,t,e)}finally{Ji=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var l=n.utc=Hn(n);return l.floor=l,l.round=Hn(r),l.ceil=Hn(u),l.offset=Hn(i),l.range=a,n}function Hn(n){return function(t,e){try{Ji=Pn;var r=new Pn;return r._=t,n(r,e)._}finally{Ji=Date}}}function Fn(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,l=0;++aa;){if(r>=c)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=L[o in Ki?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){b.lastIndex=0;var r=b.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){M.lastIndex=0;var r=M.exec(t.slice(e));return r?(n.w=_.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){A.lastIndex=0;var r=A.exec(t.slice(e));return r?(n.m=C.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){k.lastIndex=0;var r=k.exec(t.slice(e));return r?(n.m=N.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,z.c.toString(),t,r)}function l(n,t,r){return e(n,z.x.toString(),t,r)}function c(n,t,r){return e(n,z.X.toString(),t,r)}function f(n,t,e){var r=x.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var s=n.dateTime,h=n.date,g=n.time,p=n.periods,d=n.days,v=n.shortDays,y=n.months,m=n.shortMonths;t.utc=function(n){function e(n){try{Ji=Pn;var t=new Ji;return t._=n,r(t)}finally{Ji=Date}}var r=t(n);return e.parse=function(n){try{Ji=Pn;var t=r.parse(n);return t&&t._}finally{Ji=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ot;var x=Iu.map(),M=Yn(d),_=In(d),b=Yn(v),w=In(v),k=Yn(y),N=In(y),A=Yn(m),C=In(m);p.forEach(function(n,t){x.set(n.toLowerCase(),t)});var z={a:function(n){return v[n.getDay()]},A:function(n){return d[n.getDay()]},b:function(n){return m[n.getMonth()]},B:function(n){return y[n.getMonth()]},c:t(s),d:function(n,t){return On(n.getDate(),t,2)},e:function(n,t){return On(n.getDate(),t,2)},H:function(n,t){return On(n.getHours(),t,2)},I:function(n,t){return On(n.getHours()%12||12,t,2)},j:function(n,t){return On(1+Wi.dayOfYear(n),t,3)},L:function(n,t){return On(n.getMilliseconds(),t,3)},m:function(n,t){return On(n.getMonth()+1,t,2)},M:function(n,t){return On(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return On(n.getSeconds(),t,2)},U:function(n,t){return On(Wi.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return On(Wi.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return On(n.getFullYear()%100,t,2)},Y:function(n,t){return On(n.getFullYear()%1e4,t,4)},Z:ut,"%":function(){return"%"}},L={a:r,A:u,b:i,B:o,c:a,d:Kn,e:Kn,H:nt,I:nt,j:Qn,L:rt,m:Gn,M:tt,p:f,S:et,U:Vn,w:Zn,W:Xn,x:l,X:c,y:Bn,Y:$n,Z:Wn,"%":it};return t}function On(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function Yn(n){return new RegExp("^(?:"+n.map(Iu.requote).join("|")+")","i")}function In(n){for(var t=new c,e=-1,r=n.length;++e68?1900:2e3)}function Gn(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Kn(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function Qn(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function nt(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function tt(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function et(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function rt(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ut(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=ti(t)/60|0,u=ti(t)%60;return e+On(r,"0",2)+On(u,"0",2)}function it(n,t,e){no.lastIndex=0;var r=no.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ot(n){for(var t=n.length,e=-1;++eu;u++){for(;r>1&&K(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function ft(n,t){return n[0]-t[0]||n[1]-t[1]}function st(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function ht(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,l=n[1],c=e[1],f=t[1]-l,s=r[1]-c,h=(a*(l-c)-s*(u-i))/(s*o-a*f);return[u+h*o,l+h*f]}function gt(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function pt(){Ut(this),this.edge=this.site=this.circle=null}function dt(n){var t=lo.pop()||new pt;return t.site=n,t}function vt(n){At(n),io.remove(n),lo.push(n),Ut(n)}function yt(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];vt(n);for(var l=i;l.circle&&ti(e-l.circle.x)f;++f)c=a[f],l=a[f-1],Dt(c.edge,l.site,c.site,u);l=a[0],c=a[s-1],c.edge=Tt(l.site,c.site,null,u),Nt(l),Nt(c)}function mt(n){for(var t,e,r,u,i=n.x,o=n.y,a=io._;a;)if(r=xt(a,o)-i,r>mi)a=a.L;else{if(u=i-Mt(a,o),!(u>mi)){r>-mi?(t=a.P,e=a):u>-mi?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var l=dt(n);if(io.insert(t,l),t||e){if(t===e)return At(t),e=dt(t.site),io.insert(l,e),l.edge=e.edge=Tt(t.site,l.site),Nt(t),void Nt(e);if(!e)return void(l.edge=Tt(t.site,l.site));At(t),At(e);var c=t.site,f=c.x,s=c.y,h=n.x-f,g=n.y-s,p=e.site,d=p.x-f,v=p.y-s,y=2*(h*v-g*d),m=h*h+g*g,x=d*d+v*v,M={x:(v*m-g*x)/y+f,y:(h*x-d*m)/y+s};Dt(e.edge,c,p,M),l.edge=Tt(c,n,null,M),e.edge=Tt(n,p,null,M),Nt(t),Nt(e)}}function xt(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-(1/0);e=o.site;var a=e.x,l=e.y,c=l-t;if(!c)return a;var f=a-r,s=1/i-1/c,h=f/c;return s?(-h+Math.sqrt(h*h-2*s*(f*f/(-2*c)-l+c/2+u-i/2)))/s+r:(r+a)/2}function Mt(n,t){var e=n.N;if(e)return xt(e,t);var r=n.site;return r.y===t?r.x:1/0}function _t(n){this.site=n,this.edges=[]}function bt(n){for(var t,e,r,u,i,o,a,l,c,f,s=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],d=uo,v=d.length;v--;)if(i=d[v],i&&i.prepare())for(a=i.edges,l=a.length,o=0;l>o;)f=a[o].end(),r=f.x,u=f.y,c=a[++o%l].start(),t=c.x,e=c.y,(ti(r-t)>mi||ti(u-e)>mi)&&(a.splice(o,0,new Rt(qt(i.site,f,ti(r-s)mi?{x:s,y:ti(t-s)mi?{x:ti(e-p)mi?{x:h,y:ti(t-h)mi?{x:ti(e-g)=-xi)){var g=l*l+c*c,p=f*f+s*s,d=(s*g-c*p)/h,v=(l*p-f*g)/h,s=v+a,y=co.pop()||new kt;y.arc=n,y.site=u,y.x=d+o,y.y=s+Math.sqrt(d*d+v*v),y.cy=s,n.circle=y;for(var m=null,x=ao._;x;)if(y.y0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-l,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-c,d||!(i>0)){if(i/=d,0>d){if(h>i)return;g>i&&(g=i)}else if(d>0){if(i>g)return;i>h&&(h=i)}if(i=r-c,d||!(0>i)){if(i/=d,0>d){if(i>g)return;i>h&&(h=i)}else if(d>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:l+h*p,y:c+h*d}),1>g&&(u.b={x:l+g*p,y:c+g*d}),u}}}}}}function zt(n){for(var t,e=ro,r=Ct(n[0][0],n[0][1],n[1][0],n[1][1]),u=e.length;u--;)t=e[u],(!Lt(t,n)||!r(t)||ti(t.a.x-t.b.x)v||v>=a)return;if(h>p){if(i){if(i.y>=c)return}else i={x:v,y:l};e={x:v,y:c}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=c)return}else i={x:(l-u)/r,y:l};e={x:(c-u)/r,y:c}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi||s>o||r>h||u>g)){if(p=n.point){var p,d=t-n.x,v=e-n.y,y=d*d+v*v;if(l>y){var m=Math.sqrt(l=y);r=t-m,u=e-m,i=t+m,o=e+m,a=p}}for(var x=n.nodes,M=.5*(f+h),_=.5*(s+g),b=t>=M,w=e>=_,k=w<<1|b,N=k+4;N>k;++k)if(n=x[3&k])switch(3&k){case 0:c(n,f,s,M,_);break;case 1:c(n,M,s,h,_);break;case 2:c(n,f,_,M,g);break;case 3:c(n,M,_,h,g)}}}(n,r,u,i,o),a}function Bt(n,t){n=Iu.rgb(n),t=Iu.rgb(t);var e=n.r,r=n.g,u=n.b,i=t.r-e,o=t.g-r,a=t.b-u;return function(n){return"#"+mn(Math.round(e+i*n))+mn(Math.round(r+o*n))+mn(Math.round(u+a*n))}}function Wt(n,t){var e,r={},u={};for(e in n)e in t?r[e]=Kt(n[e],t[e]):u[e]=n[e];for(e in t)e in n||(u[e]=t[e]);return function(n){for(e in r)u[e]=r[e](n);return u}}function Jt(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function Gt(n,t){var e,r,u,i=so.lastIndex=ho.lastIndex=0,o=-1,a=[],l=[];for(n+="",t+="";(e=so.exec(n))&&(r=ho.exec(t));)(u=r.index)>i&&(u=t.slice(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:Jt(e,r)})),i=ho.lastIndex;return ir;++r)a[(e=l[r]).i]=e.x(n);return a.join("")})}function Kt(n,t){for(var e,r=Iu.interpolators.length;--r>=0&&!(e=Iu.interpolators[r](n,t)););return e}function Qt(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(Kt(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function ne(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function te(n){return function(t){return 1-n(1-t)}}function ee(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function re(n){return n*n}function ue(n){return n*n*n}function ie(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function oe(n){return function(t){return Math.pow(t,n)}}function ae(n){return 1-Math.cos(n*wi)}function le(n){return Math.pow(2,10*(n-1))}function ce(n){return 1-Math.sqrt(1-n*n)}function fe(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/_i*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*_i/t)}}function se(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function he(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function ge(n,t){n=Iu.hcl(n),t=Iu.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return ln(e+i*n,r+o*n,u+a*n)+""}}function pe(n,t){n=Iu.hsl(n),t=Iu.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return on(e+i*n,r+o*n,u+a*n)+""}}function de(n,t){n=Iu.lab(n),t=Iu.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return fn(e+i*n,r+o*n,u+a*n)+""}}function ve(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function ye(n){var t=[n.a,n.b],e=[n.c,n.d],r=xe(t),u=me(t,e),i=xe(Me(e,t,-u))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(_e(e)+"rotate(",null,")")-2,x:Jt(n,t)})):t&&e.push(_e(e)+"rotate("+t+")")}function ke(n,t,e,r){n!==t?r.push({i:e.push(_e(e)+"skewX(",null,")")-2,x:Jt(n,t)}):t&&e.push(_e(e)+"skewX("+t+")")}function Ne(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var u=e.push(_e(e)+"scale(",null,",",null,")");r.push({i:u-4,x:Jt(n[0],t[0])},{i:u-2,x:Jt(n[1],t[1])})}else 1===t[0]&&1===t[1]||e.push(_e(e)+"scale("+t+")")}function Ae(n,t){var e=[],r=[];return n=Iu.transform(n),t=Iu.transform(t),be(n.translate,t.translate,e,r),we(n.rotate,t.rotate,e,r),ke(n.skew,t.skew,e,r),Ne(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,u=-1,i=r.length;++u=0;)e.push(u[r])}function He(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function Je(n){return n.reduce(Ge,0)}function Ge(n,t){return n+t[1]}function Ke(n,t){return Qe(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function Qe(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function nr(n){return[Iu.min(n),Iu.max(n)]}function tr(n,t){return n.value-t.value}function er(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function rr(n,t){n._pack_next=t,t._pack_prev=n}function ur(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function ir(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(c=e.length)){var e,r,u,i,o,a,l,c,f=1/0,s=-(1/0),h=1/0,g=-(1/0);if(e.forEach(or),r=e[0],r.x=-r.r,r.y=0,t(r),c>1&&(u=e[1],u.x=u.r,u.y=0,t(u),c>2))for(i=e[2],cr(r,u,i),t(i),er(r,i),r._pack_prev=i,er(i,u),u=r._pack_next,o=3;c>o;o++){cr(r,u,i=e[o]);var p=0,d=1,v=1;for(a=u._pack_next;a!==u;a=a._pack_next,d++)if(ur(a,i)){p=1;break}if(1==p)for(l=r._pack_prev;l!==a._pack_prev&&!ur(l,i);l=l._pack_prev,v++);p?(v>d||d==v&&u.ro;o++)i=e[o],i.x-=y,i.y-=m,x=Math.max(x,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=x,e.forEach(ar)}}function or(n){n._pack_next=n._pack_prev=n}function ar(n){delete n._pack_next,delete n._pack_prev}function lr(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function dr(n,t,e){return n.a.parent===t.parent?n.a:e}function vr(n){return 1+Iu.max(n,function(n){return n.y})}function yr(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function mr(n){var t=n.children;return t&&t.length?mr(t[0]):n}function xr(n){var t,e=n.children;return e&&(t=e.length)?xr(e[t-1]):n}function Mr(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function _r(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function br(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function wr(n){return n.rangeExtent?n.rangeExtent():br(n.range())}function kr(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function Nr(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Ar(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:ko}function Cr(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Cr:kr,l=r?ze:Ce;return o=u(n,t,l,e),a=u(t,n,l,Kt),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(ve)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return qr(n,t)},i.tickFormat=function(t,e){return Dr(n,t,e)},i.nice=function(t){return Sr(n,t),u()},i.copy=function(){return zr(n,t,e,r)},u()}function Lr(n,t){return Iu.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Sr(n,t){return Nr(n,Ar(Tr(n,t)[2])),Nr(n,Ar(Tr(n,t)[2])),n}function Tr(n,t){null==t&&(t=10);var e=br(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function qr(n,t){return Iu.range.apply(Iu,Tr(n,t))}function Dr(n,t,e){var r=Tr(n,t);if(e){var u=$i.exec(e);if(u.shift(),"s"===u[8]){var i=Iu.formatPrefix(Math.max(ti(r[0]),ti(r[1])));return u[7]||(u[7]="."+Rr(i.scale(r[2]))),u[8]="f",e=Iu.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Er(u[8],r)),e=u.join("")}else e=",."+Rr(r[2])+"f";return Iu.format(e)}function Rr(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Er(n,t){var e=Rr(t[2]);return n in No?Math.abs(e-Rr(Math.max(ti(t[0]),ti(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Ur(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=Nr(r.map(u),e?Math:Co);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=br(r),o=[],a=n[0],l=n[1],c=Math.floor(u(a)),f=Math.ceil(u(l)),s=t%1?2:t;if(isFinite(f-c)){if(e){for(;f>c;c++)for(var h=1;s>h;h++)o.push(i(c)*h);o.push(i(c))}else for(o.push(i(c));c++0;h--)o.push(i(c)*h);for(c=0;o[c]l;f--);o=o.slice(c,f)}return o},o.tickFormat=function(n,e){if(!arguments.length)return Ao;arguments.length<2?e=Ao:"function"!=typeof e&&(e=Iu.format(e));var r=Math.max(1,t*n/o.ticks().length);return function(n){var o=n/i(Math.round(u(n)));return t-.5>o*t&&(o*=t),r>=o?e(n):""}},o.copy=function(){return Ur(n.copy(),t,e,r)},Lr(o,n)}function Pr(n,t,e){function r(t){return n(u(t))}var u=jr(t),i=jr(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return qr(e,n)},r.tickFormat=function(n,t){return Dr(e,n,t)},r.nice=function(n){return r.domain(Sr(e,n))},r.exponent=function(o){return arguments.length?(u=jr(t=o),i=jr(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Pr(n.copy(),t,e)},Lr(r,n)}function jr(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Hr(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):NaN))-1)%i.length]}function r(t,e){return Iu.range(n.length).map(function(n){return t+e*n})}var u,i,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new c;for(var i,o=-1,a=r.length;++oe?[NaN,NaN]:[e>0?a[e-1]:n[0],et?NaN:t/i+n,[t,t+1/i]},r.copy=function(){return Or(n,t,e)},u()}function Yr(n,t){function e(e){return e>=e?t[Iu.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return Yr(n,t)},e}function Ir(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return qr(n,t)},t.tickFormat=function(t,e){return Dr(n,t,e)},t.copy=function(){return Ir(n)},t}function Zr(){return 0}function Vr(n){return n.innerRadius}function Xr(n){return n.outerRadius}function $r(n){return n.startAngle}function Br(n){return n.endAngle}function Wr(n){return n&&n.padAngle}function Jr(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function Gr(n,t,e,r,u){var i=n[0]-t[0],o=n[1]-t[1],a=(u?r:-r)/Math.sqrt(i*i+o*o),l=a*o,c=-a*i,f=n[0]+l,s=n[1]+c,h=t[0]+l,g=t[1]+c,p=(f+h)/2,d=(s+g)/2,v=h-f,y=g-s,m=v*v+y*y,x=e-r,M=f*g-h*s,_=(0>y?-1:1)*Math.sqrt(Math.max(0,x*x*m-M*M)),b=(M*y-v*_)/m,w=(-M*v-y*_)/m,k=(M*y+v*_)/m,N=(-M*v+y*_)/m,A=b-p,C=w-d,z=k-p,L=N-d;return A*A+C*C>z*z+L*L&&(b=k,w=N),[[b-l,w-c],[b*e/x,w*e/x]]}function Kr(){return!0}function Qr(n){function t(t){function o(){c.push("M",i(n(f),a))}for(var l,c=[],f=[],s=-1,h=t.length,g=kn(e),p=kn(r);++s1?n.join("L"):n+"Z"}function tu(n){return n.join("L")+"Z"}function eu(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1&&u.push("H",r[0]),u.join("")}function ru(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[l],l++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var c=2;c9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=l;)u=(n[Math.min(l,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function xu(n){return n.length<3?nu(n):n[0]+lu(n,mu(n))}function Mu(n){for(var t,e,r,u=-1,i=n.length;++u=t?o(n-t):void(f.c=o)}function o(e){var u=p.active,i=p[u];i&&(i.timer.c=null,i.timer.t=NaN,--p.count,delete p[u],i.event&&i.event.interrupt.call(n,n.__data__,i.index));for(var o in p)if(r>+o){var c=p[o];c.timer.c=null,c.timer.t=NaN,--p.count,delete p[o]}f.c=a,Ln(function(){return f.c&&a(e||1)&&(f.c=null,f.t=NaN),1},0,l),p.active=r,d.event&&d.event.start.call(n,n.__data__,t),g=[],d.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&g.push(r)}),h=d.ease,s=d.duration}function a(u){for(var i=u/s,o=h(i),a=g.length;a>0;)g[--a].call(n,o);return i>=1?(d.event&&d.event.end.call(n,n.__data__,t),--p.count?delete p[r]:delete n[e],1):void 0}var l,f,s,h,g,p=n[e]||(n[e]={active:0,count:0}),d=p[r];d||(l=u.time,f=Ln(i,0,l),d=p[r]={tween:new c,time:l,timer:f,delay:u.delay,duration:u.duration,ease:u.ease,index:t},u=null,++p.count)}function Uu(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Pu(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function ju(n){return n.toISOString()}function Hu(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=Iu.bisect(Ko,u);return i==Ko.length?[t.year,Tr(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Ko[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Fu(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Fu(+t+1);return t}}:n))},r.ticks=function(n,t){var e=br(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Fu(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Hu(n.copy(),t,e)},Lr(r,n)}function Fu(n){return new Date(n)}function Ou(n){return JSON.parse(n.responseText)}function Yu(n){var t=Xu.createRange();return t.selectNode(Xu.body),t.createContextualFragment(n.responseText)}var Iu={version:"3.5.18"},Zu=[].slice,Vu=function(n){return Zu.call(n)},Xu=this.document;if(Xu)try{Vu(Xu.documentElement.childNodes)[0].nodeType}catch($u){Vu=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),Xu)try{Xu.createElement("DIV").style.setProperty("opacity",0,"")}catch(Bu){var Wu=this.Element.prototype,Ju=Wu.setAttribute,Gu=Wu.setAttributeNS,Ku=this.CSSStyleDeclaration.prototype,Qu=Ku.setProperty;Wu.setAttribute=function(n,t){Ju.call(this,n,t+"")},Wu.setAttributeNS=function(n,t,e){Gu.call(this,n,t,e+"")},Ku.setProperty=function(n,t,e){Qu.call(this,n,t+"",e)}}Iu.ascending=e,Iu.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},Iu.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ur&&(e=r)}else{for(;++u=r){e=r;break}for(;++ur&&(e=r)}return e},Iu.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ue&&(e=r)}else{for(;++u=r){e=r;break}for(;++ue&&(e=r)}return e},Iu.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},Iu.sum=function(n,t){var e,r=0,i=n.length,o=-1;if(1===arguments.length)for(;++o1?l/(f-1):void 0},Iu.deviation=function(){var n=Iu.variance.apply(this,arguments);return n?Math.sqrt(n):n};var ni=i(e);Iu.bisectLeft=ni.left,Iu.bisect=Iu.bisectRight=ni.right,Iu.bisector=function(n){return i(1===n.length?function(t,r){return e(n(t),r)}:n)},Iu.shuffle=function(n,t,e){(i=arguments.length)<3&&(e=n.length,2>i&&(t=0));for(var r,u,i=e-t;i;)u=Math.random()*i--|0,r=n[i+t],n[i+t]=n[u+t],n[u+t]=r;return n},Iu.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},Iu.pairs=function(n){for(var t,e=0,r=n.length-1,u=n[0],i=new Array(0>r?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},Iu.transpose=function(n){if(!(u=n.length))return[];for(var t=-1,e=Iu.min(n,o),r=new Array(e);++t=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var ti=Math.abs;Iu.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,u=[],i=a(ti(e)),o=-1;if(n*=i,t*=i,e*=i,0>e)for(;(r=n+e*++o)>t;)u.push(r/i);else for(;(r=n+e*++o)=i.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,f,s,h,g=-1,p=o.length,d=i[a++],v=new c;++g=i.length)return n;var r=[],u=o[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(Iu.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return o[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},Iu.set=function(n){var t=new y;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(y,{has:h,add:function(n){return this._[f(n+="")]=!0,n},remove:g,values:p,size:d,empty:v,forEach:function(n){for(var t in this._)n.call(this,s(t))}}),Iu.behavior={},Iu.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},Iu.event=null,Iu.requote=function(n){return n.replace(ii,"\\$&")};var ii=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,oi={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},ai=function(n,t){return t.querySelector(n)},li=function(n,t){return t.querySelectorAll(n)},ci=function(n,t){var e=n.matches||n[M(n,"matchesSelector")];return(ci=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(ai=function(n,t){return Sizzle(n,t)[0]||null},li=Sizzle,ci=Sizzle.matchesSelector),Iu.selection=function(){return Iu.select(Xu.documentElement)};var fi=Iu.selection.prototype=[];fi.select=function(n){var t,e,r,u,i=[];n=z(n);for(var o=-1,a=this.length;++o=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),hi.hasOwnProperty(e)?{space:hi[e],local:n}:n}},fi.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=Iu.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(S(t,n[t]));return this}return this.each(S(n,t))},fi.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=D(n)).length,u=-1;if(t=e.classList){for(;++uu){if("string"!=typeof n){2>u&&(e="");for(r in n)this.each(U(r,n[r],e));return this}if(2>u){var i=this.node();return t(i).getComputedStyle(i,null).getPropertyValue(n)}r=""}return this.each(U(n,e,r))},fi.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(P(t,n[t]));return this}return this.each(P(n,t))},fi.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},fi.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},fi.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},fi.insert=function(n,t){return n=j(n),t=z(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},fi.remove=function(){return this.each(H)},fi.data=function(n,t){function e(n,e){var r,u,i,o=n.length,s=e.length,h=Math.min(o,s),g=new Array(s),p=new Array(s),d=new Array(o);if(t){var v,y=new c,m=new Array(o);for(r=-1;++rr;++r)p[r]=F(e[r]);for(;o>r;++r)d[r]=n[r]}p.update=g,p.parentNode=g.parentNode=d.parentNode=n.parentNode,a.push(p),l.push(g),f.push(d)}var r,u,i=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return C(u)},fi.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},fi.sort=function(n){n=Y.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},fi.size=function(){var n=0;return I(this,function(){++n}),n};var gi=[];Iu.selection.enter=Z,Iu.selection.enter.prototype=gi,gi.append=fi.append,gi.empty=fi.empty,gi.node=fi.node,gi.call=fi.call,gi.size=fi.size,gi.select=function(n){for(var t,e,r,u,i,o=[],a=-1,l=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var pi=Iu.map({mouseenter:"mouseover",mouseleave:"mouseout"});Xu&&pi.forEach(function(n){"on"+n in Xu&&pi.remove(n)});var di,vi=0;Iu.mouse=function(n){return J(n,N())};var yi=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;Iu.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=N().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return J(n,r)},Iu.behavior.drag=function(){function n(){this.on("mousedown.drag",i).on("touchstart.drag",o)}function e(n,t,e,i,o){return function(){function a(){var n,e,r=t(h,d);r&&(n=r[0]-x[0],e=r[1]-x[1],p|=n|e,x=r,g({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,d)&&(y.on(i+v,null).on(o+v,null),m(p),g({type:"dragend"}))}var c,f=this,s=Iu.event.target.correspondingElement||Iu.event.target,h=f.parentNode,g=r.of(f,arguments),p=0,d=n(),v=".drag"+(null==d?"":"-"+d),y=Iu.select(e(s)).on(i+v,a).on(o+v,l),m=W(s),x=t(h,d);u?(c=u.apply(f,arguments),c=[c.x-x[0],c.y-x[1]]):c=[0,0],g({type:"dragstart"})}}var r=A(n,"drag","dragstart","dragend"),u=null,i=e(_,Iu.mouse,t,"mousemove","mouseup"),o=e(G,Iu.touch,m,"touchmove","touchend");return n.origin=function(t){return arguments.length?(u=t,n):u},Iu.rebind(n,r,"on")},Iu.touches=function(n,t){return arguments.length<2&&(t=N().touches),t?Vu(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier, +e}):[]};var mi=1e-6,xi=mi*mi,Mi=Math.PI,_i=2*Mi,bi=_i-mi,wi=Mi/2,ki=Mi/180,Ni=180/Mi,Ai=Math.SQRT2,Ci=2,zi=4;Iu.interpolateZoom=function(n,t){var e,r,u=n[0],i=n[1],o=n[2],a=t[0],l=t[1],c=t[2],f=a-u,s=l-i,h=f*f+s*s;if(xi>h)r=Math.log(c/o)/Ai,e=function(n){return[u+n*f,i+n*s,o*Math.exp(Ai*n*r)]};else{var g=Math.sqrt(h),p=(c*c-o*o+zi*h)/(2*o*Ci*g),d=(c*c-o*o-zi*h)/(2*c*Ci*g),v=Math.log(Math.sqrt(p*p+1)-p),y=Math.log(Math.sqrt(d*d+1)-d);r=(y-v)/Ai,e=function(n){var t=n*r,e=tn(v),a=o/(Ci*g)*(e*en(Ai*t+v)-nn(v));return[u+a*f,i+a*s,o*e/tn(Ai*t+v)]}}return e.duration=1e3*r,e},Iu.behavior.zoom=function(){function n(n){n.on(T,s).on(Si+".zoom",g).on("dblclick.zoom",p).on(R,h)}function e(n){return[(n[0]-N.x)/N.k,(n[1]-N.y)/N.k]}function r(n){return[n[0]*N.k+N.x,n[1]*N.k+N.y]}function u(n){N.k=Math.max(z[0],Math.min(z[1],n))}function i(n,t){t=r(t),N.x+=n[0]-t[0],N.y+=n[1]-t[1]}function o(t,e,r,o){t.__chart__={x:N.x,y:N.y,k:N.k},u(Math.pow(2,o)),i(v=e,r),t=Iu.select(t),L>0&&(t=t.transition().duration(L)),t.call(n.event)}function a(){_&&_.domain(M.range().map(function(n){return(n-N.x)/N.k}).map(M.invert)),w&&w.domain(b.range().map(function(n){return(n-N.y)/N.k}).map(b.invert))}function l(n){S++||n({type:"zoomstart"})}function c(n){a(),n({type:"zoom",scale:N.k,translate:[N.x,N.y]})}function f(n){--S||(n({type:"zoomend"}),v=null)}function s(){function n(){a=1,i(Iu.mouse(u),h),c(o)}function r(){s.on(q,null).on(D,null),g(a),f(o)}var u=this,o=E.of(u,arguments),a=0,s=Iu.select(t(u)).on(q,n).on(D,r),h=e(Iu.mouse(u)),g=W(u);Yo.call(u),l(o)}function h(){function n(){var n=Iu.touches(p);return g=N.k,n.forEach(function(n){n.identifier in v&&(v[n.identifier]=e(n))}),n}function t(){var t=Iu.event.target;Iu.select(t).on(M,r).on(_,a),b.push(t);for(var e=Iu.event.changedTouches,u=0,i=e.length;i>u;++u)v[e[u].identifier]=null;var l=n(),c=Date.now();if(1===l.length){if(500>c-x){var f=l[0];o(p,f,v[f.identifier],Math.floor(Math.log(N.k)/Math.LN2)+1),k()}x=c}else if(l.length>1){var f=l[0],s=l[1],h=f[0]-s[0],g=f[1]-s[1];y=h*h+g*g}}function r(){var n,t,e,r,o=Iu.touches(p);Yo.call(p);for(var a=0,l=o.length;l>a;++a,r=null)if(e=o[a],r=v[e.identifier]){if(t)break;n=e,t=r}if(r){var f=(f=e[0]-n[0])*f+(f=e[1]-n[1])*f,s=y&&Math.sqrt(f/y);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],u(s*g)}x=null,i(n,t),c(d)}function a(){if(Iu.event.touches.length){for(var t=Iu.event.changedTouches,e=0,r=t.length;r>e;++e)delete v[t[e].identifier];for(var u in v)return void n()}Iu.selectAll(b).on(m,null),w.on(T,s).on(R,h),A(),f(d)}var g,p=this,d=E.of(p,arguments),v={},y=0,m=".zoom-"+Iu.event.changedTouches[0].identifier,M="touchmove"+m,_="touchend"+m,b=[],w=Iu.select(p),A=W(p);t(),l(d),w.on(T,null).on(R,t)}function g(){var n=E.of(this,arguments);m?clearTimeout(m):(Yo.call(this),d=e(v=y||Iu.mouse(this)),l(n)),m=setTimeout(function(){m=null,f(n)},50),k(),u(Math.pow(2,.002*Li())*N.k),i(v,d),c(n)}function p(){var n=Iu.mouse(this),t=Math.log(N.k)/Math.LN2;o(this,n,e(n),Iu.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var d,v,y,m,x,M,_,b,w,N={x:0,y:0,k:1},C=[960,500],z=Ti,L=250,S=0,T="mousedown.zoom",q="mousemove.zoom",D="mouseup.zoom",R="touchstart.zoom",E=A(n,"zoomstart","zoom","zoomend");return Si||(Si="onwheel"in Xu?(Li=function(){return-Iu.event.deltaY*(Iu.event.deltaMode?120:1)},"wheel"):"onmousewheel"in Xu?(Li=function(){return Iu.event.wheelDelta},"mousewheel"):(Li=function(){return-Iu.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=E.of(this,arguments),t=N;Fo?Iu.select(this).transition().each("start.zoom",function(){N=this.__chart__||{x:0,y:0,k:1},l(n)}).tween("zoom:zoom",function(){var e=C[0],r=C[1],u=v?v[0]:e/2,i=v?v[1]:r/2,o=Iu.interpolateZoom([(u-N.x)/N.k,(i-N.y)/N.k,e/N.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=N={x:u-r[0]*a,y:i-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){f(n)}).each("end.zoom",function(){f(n)}):(this.__chart__=N,l(n),c(n),f(n))})},n.translate=function(t){return arguments.length?(N={x:+t[0],y:+t[1],k:N.k},a(),n):[N.x,N.y]},n.scale=function(t){return arguments.length?(N={x:N.x,y:N.y,k:null},u(+t),a(),n):N.k},n.scaleExtent=function(t){return arguments.length?(z=null==t?Ti:[+t[0],+t[1]],n):z},n.center=function(t){return arguments.length?(y=t&&[+t[0],+t[1]],n):y},n.size=function(t){return arguments.length?(C=t&&[+t[0],+t[1]],n):C},n.duration=function(t){return arguments.length?(L=+t,n):L},n.x=function(t){return arguments.length?(_=t,M=t.copy(),N={x:0,y:0,k:1},n):_},n.y=function(t){return arguments.length?(w=t,b=t.copy(),N={x:0,y:0,k:1},n):w},Iu.rebind(n,E,"on")};var Li,Si,Ti=[0,1/0];Iu.color=rn,rn.prototype.toString=function(){return this.rgb()+""},Iu.hsl=un;var qi=un.prototype=new rn;qi.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new un(this.h,this.s,this.l/n)},qi.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new un(this.h,this.s,n*this.l)},qi.rgb=function(){return on(this.h,this.s,this.l)},Iu.hcl=an;var Di=an.prototype=new rn;Di.brighter=function(n){return new an(this.h,this.c,Math.min(100,this.l+Ri*(arguments.length?n:1)))},Di.darker=function(n){return new an(this.h,this.c,Math.max(0,this.l-Ri*(arguments.length?n:1)))},Di.rgb=function(){return ln(this.h,this.c,this.l).rgb()},Iu.lab=cn;var Ri=18,Ei=.95047,Ui=1,Pi=1.08883,ji=cn.prototype=new rn;ji.brighter=function(n){return new cn(Math.min(100,this.l+Ri*(arguments.length?n:1)),this.a,this.b)},ji.darker=function(n){return new cn(Math.max(0,this.l-Ri*(arguments.length?n:1)),this.a,this.b)},ji.rgb=function(){return fn(this.l,this.a,this.b)},Iu.rgb=dn;var Hi=dn.prototype=new rn;Hi.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new dn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new dn(u,u,u)},Hi.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new dn(n*this.r,n*this.g,n*this.b)},Hi.hsl=function(){return Mn(this.r,this.g,this.b)},Hi.toString=function(){return"#"+mn(this.r)+mn(this.g)+mn(this.b)};var Fi=Iu.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});Fi.forEach(function(n,t){Fi.set(n,vn(t))}),Iu.functor=kn,Iu.xhr=Nn(m),Iu.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=An(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=function(t){for(var e={},r=n.length,u=0;r>u;++u)e[n[u]]=t[u];return e};r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(f>=c)return o;if(u)return u=!1,i;var t=f;if(34===n.charCodeAt(t)){for(var e=t;e++f;){var r=n.charCodeAt(f++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(f)&&(++f,++a);else if(r!==l)continue;return n.slice(t,f-a)}return n.slice(t)}for(var r,u,i={},o={},a=[],c=n.length,f=0,s=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,s++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new y,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},Iu.csv=Iu.dsv(",","text/csv"),Iu.tsv=Iu.dsv(" ","text/tab-separated-values");var Oi,Yi,Ii,Zi,Vi=this[M(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};Iu.timer=function(){Ln.apply(this,arguments)},Iu.timer.flush=function(){Tn(),qn()},Iu.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var Xi=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Rn);Iu.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=Iu.round(n,Dn(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),Xi[8+e/3]};var $i=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Bi=Iu.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=Iu.round(n,Dn(n,t))).toFixed(Math.max(0,Math.min(20,Dn(n*(1+1e-15),t))))}}),Wi=Iu.time={},Ji=Date;Pn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Gi.setUTCDate.apply(this._,arguments)},setDay:function(){Gi.setUTCDay.apply(this._,arguments)},setFullYear:function(){Gi.setUTCFullYear.apply(this._,arguments)},setHours:function(){Gi.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Gi.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Gi.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Gi.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Gi.setUTCSeconds.apply(this._,arguments)},setTime:function(){Gi.setTime.apply(this._,arguments)}};var Gi=Date.prototype;Wi.year=jn(function(n){return n=Wi.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),Wi.years=Wi.year.range,Wi.years.utc=Wi.year.utc.range,Wi.day=jn(function(n){var t=new Ji(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),Wi.days=Wi.day.range,Wi.days.utc=Wi.day.utc.range,Wi.dayOfYear=function(n){var t=Wi.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=Wi[n]=jn(function(n){return(n=Wi.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=Wi.year(n).getDay();return Math.floor((Wi.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});Wi[n+"s"]=e.range,Wi[n+"s"].utc=e.utc.range,Wi[n+"OfYear"]=function(n){var e=Wi.year(n).getDay();return Math.floor((Wi.dayOfYear(n)+(e+t)%7)/7)}}),Wi.week=Wi.sunday,Wi.weeks=Wi.sunday.range,Wi.weeks.utc=Wi.sunday.utc.range,Wi.weekOfYear=Wi.sundayOfYear;var Ki={"-":"",_:" ",0:"0"},Qi=/^\s*\d+/,no=/^%/;Iu.locale=function(n){return{numberFormat:En(n),timeFormat:Fn(n)}};var to=Iu.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});Iu.format=to.numberFormat,Iu.geom={},Iu.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=kn(e),i=kn(r),o=n.length,a=[],l=[];for(t=0;o>t;t++)a.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(a.sort(ft),t=0;o>t;t++)l.push([a[t][0],-a[t][1]]);var c=ct(a),f=ct(l),s=f[0]===c[0],h=f[f.length-1]===c[c.length-1],g=[];for(t=c.length-1;t>=0;--t)g.push(n[a[c[t]][2]]);for(t=+s;t=r&&c.x<=i&&c.y>=u&&c.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];f.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/mi)*mi,y:Math.round(o(n,t)/mi)*mi,i:t}})}var r=at,u=lt,i=r,o=u,a=fo;return n?t(n):(t.links=function(n){return Ft(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return Ft(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(wt),l=-1,c=a.length,f=a[c-1].edge,s=f.l===o?f.r:f.l;++l=c,h=r>=f,g=h<<1|s;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=Vt()),s?u=c:a=c,h?o=f:l=f,i(n,t,e,r,u,o,a,l)}var f,s,h,g,p,d,v,y,m,x=kn(a),M=kn(l);if(null!=t)d=t,v=e,y=r,m=u;else if(y=m=-(d=v=1/0),s=[],h=[],p=n.length,o)for(g=0;p>g;++g)f=n[g],f.xy&&(y=f.x),f.y>m&&(m=f.y),s.push(f.x),h.push(f.y);else for(g=0;p>g;++g){var _=+x(f=n[g],g),b=+M(f,g);d>_&&(d=_),v>b&&(v=b),_>y&&(y=_),b>m&&(m=b),s.push(_),h.push(b)}var w=y-d,k=m-v;w>k?m=v+w:y=d+k;var N=Vt();if(N.add=function(n){i(N,n,+x(n,++g),+M(n,g),d,v,y,m)},N.visit=function(n){Xt(n,N,d,v,y,m)},N.find=function(n){return $t(N,n[0],n[1],d,v,y,m)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=po.get(e)||go,r=vo.get(r)||m,ne(r(e.apply(null,Zu.call(arguments,1))))},Iu.interpolateHcl=ge,Iu.interpolateHsl=pe,Iu.interpolateLab=de,Iu.interpolateRound=ve,Iu.transform=function(n){var t=Xu.createElementNS(Iu.ns.prefix.svg,"g");return(Iu.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new ye(e?e.matrix:yo)})(n)},ye.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var yo={a:1,b:0,c:0,d:1,e:0,f:0};Iu.interpolateTransform=Ae,Iu.layout={},Iu.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/y){if(d>l){var c=t.charge/l;n.px-=i*c,n.py-=o*c}return!0}if(t.point&&l&&d>l){var c=t.pointCharge/l;n.px-=i*c,n.py-=o*c}}return!t.charge}}function t(n){n.px=Iu.event.x,n.py=Iu.event.y,l.resume()}var e,r,u,i,o,a,l={},c=Iu.dispatch("start","tick","end"),f=[1,1],s=.9,h=mo,g=xo,p=-30,d=Mo,v=.1,y=.64,x=[],M=[];return l.tick=function(){if((u*=.99)<.005)return e=null,c.end({type:"end",alpha:u=0}),!0;var t,r,l,h,g,d,y,m,_,b=x.length,w=M.length;for(r=0;w>r;++r)l=M[r],h=l.source,g=l.target,m=g.x-h.x,_=g.y-h.y,(d=m*m+_*_)&&(d=u*o[r]*((d=Math.sqrt(d))-i[r])/d,m*=d,_*=d,g.x-=m*(y=h.weight+g.weight?h.weight/(h.weight+g.weight):.5),g.y-=_*y,h.x+=m*(y=1-y),h.y+=_*y);if((y=u*v)&&(m=f[0]/2,_=f[1]/2,r=-1,y))for(;++r0?u=n:(e.c=null,e.t=NaN,e=null,c.end({type:"end",alpha:u=0})):n>0&&(c.start({type:"start",alpha:u=n}),e=Ln(l.tick)),l):u},l.start=function(){function n(n,r){if(!e){for(e=new Array(u),l=0;u>l;++l)e[l]=[];for(l=0;c>l;++l){var i=M[l];e[i.source.index].push(i.target),e[i.target.index].push(i.source)}}for(var o,a=e[t],l=-1,f=a.length;++lt;++t)(r=x[t]).index=t,r.weight=0;for(t=0;c>t;++t)r=M[t],"number"==typeof r.source&&(r.source=x[r.source]),"number"==typeof r.target&&(r.target=x[r.target]),++r.source.weight,++r.target.weight;for(t=0;u>t;++t)r=x[t],isNaN(r.x)&&(r.x=n("x",s)),isNaN(r.y)&&(r.y=n("y",d)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(i=[],"function"==typeof h)for(t=0;c>t;++t)i[t]=+h.call(this,M[t],t);else for(t=0;c>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,M[t],t);else for(t=0;c>t;++t)o[t]=g;if(a=[],"function"==typeof p)for(t=0;u>t;++t)a[t]=+p.call(this,x[t],t);else for(t=0;u>t;++t)a[t]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return r||(r=Iu.behavior.drag().origin(m).on("dragstart.force",qe).on("drag.force",t).on("dragend.force",De)),arguments.length?void this.on("mouseover.force",Re).on("mouseout.force",Ee).call(r):r},Iu.rebind(l,c,"on")};var mo=20,xo=1,Mo=1/0;Iu.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(c=e.call(n,i,i.depth))&&(l=c.length)){for(var l,c,f;--l>=0;)o.push(f=c[l]),f.parent=i,f.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return He(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=Ye,e=Fe,r=Oe;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(je(t,function(n){n.children&&(n.value=0)}),He(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},Iu.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,l,c=-1;for(r=t.value?r/t.value:0;++cs?-1:1),p=Iu.sum(c),d=p?(s-l*g)/p:0,v=Iu.range(l),y=[];return null!=e&&v.sort(e===_o?function(n,t){return c[t]-c[n]}:function(n,t){return e(o[n],o[t])}),v.forEach(function(n){y[n]={data:o[n],value:a=c[n],startAngle:f,endAngle:f+=a*d+g,padAngle:h}}),y}var t=Number,e=_o,r=0,u=_i,i=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(u=t,n):u},n.padAngle=function(t){return arguments.length?(i=t,n):i},n};var _o={};Iu.layout.stack=function(){function n(a,l){if(!(h=a.length))return a;var c=a.map(function(e,r){return t.call(n,e,r)}),f=c.map(function(t){return t.map(function(t,e){return[i.call(n,t,e),o.call(n,t,e)]})}),s=e.call(n,f,l);c=Iu.permute(c,s),f=Iu.permute(f,s);var h,g,p,d,v=r.call(n,f,l),y=c[0].length;for(p=0;y>p;++p)for(u.call(n,c[0][p],d=v[p],f[0][p][1]),g=1;h>g;++g)u.call(n,c[g][p],d+=f[g-1][p][1],f[g][p][1]);return a}var t=m,e=$e,r=Be,u=Xe,i=Ze,o=Ve;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:bo.get(t)||$e,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:wo.get(t)||Be,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var bo=Iu.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(We),i=n.map(Je),o=Iu.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,l=0,c=[],f=[];for(t=0;r>t;++t)e=o[t],l>a?(a+=i[e],c.push(e)):(l+=i[e],f.push(e));return f.reverse().concat(c)},reverse:function(n){return Iu.range(n.length).reverse()},"default":$e}),wo=Iu.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,l=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)l[e]=(a-o[e])/2;return l},wiggle:function(n){var t,e,r,u,i,o,a,l,c,f=n.length,s=n[0],h=s.length,g=[];for(g[0]=l=c=0,e=1;h>e;++e){for(t=0,u=0;f>t;++t)u+=n[t][e][1];for(t=0,i=0,a=s[e][0]-s[e-1][0];f>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=l-=u?i/u*a:0,c>l&&(c=l)}for(e=0;h>e;++e)g[e]-=c;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:Be});Iu.layout.histogram=function(){function n(n,i){for(var o,a,l=[],c=n.map(e,this),f=r.call(this,c,i),s=u.call(this,f,c,i),i=-1,h=c.length,g=s.length-1,p=t?1:1/h;++i0)for(i=-1;++i=f[0]&&a<=f[1]&&(o=l[Iu.bisect(s,a,1,g)-1],o.y+=p,o.push(n[i]));return l}var t=!0,e=Number,r=nr,u=Ke;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=kn(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return Qe(n,t)}:kn(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},Iu.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],l=u[0],c=u[1],f=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,He(a,function(n){n.r=+f(n.value)}),He(a,ir),r){var s=r*(t?1:Math.max(2*a.r/l,2*a.r/c))/2;He(a,function(n){n.r+=s}),He(a,ir),He(a,function(n){n.r-=s})}return lr(a,l/2,c/2,t?1:1/Math.max(2*a.r/l,2*a.r/c)),o}var t,e=Iu.layout.hierarchy().sort(tr),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Pe(n,e)},Iu.layout.tree=function(){function n(n,u){var f=o.call(this,n,u),s=f[0],h=t(s);if(He(h,e),h.parent.m=-h.z,je(h,r),c)je(s,i);else{var g=s,p=s,d=s;je(s,function(n){n.xp.x&&(p=n),n.depth>d.depth&&(d=n)});var v=a(g,p)/2-g.x,y=l[0]/(p.x+a(p,g)/2+v),m=l[1]/(d.depth||1);je(s,function(n){n.x=(n.x+v)*y,n.y=n.depth*m})}return f}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={ +_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){pr(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,l=u.parent.children[0],c=u.m,f=i.m,s=o.m,h=l.m;o=hr(o),u=sr(u),o&&u;)l=sr(l),i=hr(i),i.a=n,r=o.z+s-u.z-c+a(o._,u._),r>0&&(gr(dr(o,n,e),n,r),c+=r,f+=r),s+=o.m,c+=u.m,h+=l.m,f+=i.m;o&&!hr(i)&&(i.t=o,i.m+=s-f),u&&!sr(l)&&(l.t=u,l.m+=c-h,e=n)}return e}function i(n){n.x*=l[0],n.y=n.depth*l[1]}var o=Iu.layout.hierarchy().sort(null).value(null),a=fr,l=[1,1],c=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(c=null==(l=t)?i:null,n):c?null:l},n.nodeSize=function(t){return arguments.length?(c=null==(l=t)?null:i,n):c?l:null},Pe(n,o)},Iu.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),l=a[0],c=0;He(l,function(n){var t=n.children;t&&t.length?(n.x=yr(t),n.y=vr(t)):(n.x=o?c+=e(n,o):0,n.y=0,o=n)});var f=mr(l),s=xr(l),h=f.x-e(f,s)/2,g=s.x+e(s,f)/2;return He(l,u?function(n){n.x=(n.x-l.x)*r[0],n.y=(l.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(l.y?n.y/l.y:1))*r[1]}),a}var t=Iu.layout.hierarchy().sort(null).value(null),e=fr,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Pe(n,t)},Iu.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,l,c=s(e),f=[],h=i.slice(),p=1/0,d="slice"===g?c.dx:"dice"===g?c.dy:"slice-dice"===g?1&e.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(n(h,c.dx*c.dy/e.value),f.area=0;(l=h.length)>0;)f.push(o=h[l-1]),f.area+=o.area,"squarify"!==g||(a=r(f,d))<=p?(h.pop(),p=a):(f.area-=f.pop().area,u(f,d,c,!1),d=Math.min(c.dx,c.dy),f.length=f.area=0,p=1/0);f.length&&(u(f,d,c,!0),f.length=f.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=s(t),a=r.slice(),l=[];for(n(a,o.dx*o.dy/t.value),l.area=0;i=a.pop();)l.push(i),l.area+=i.area,null!=i.z&&(u(l,i.z?o.dx:o.dy,o,!a.length),l.length=l.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,c=e.y,f=t?l(n.area/t):0;if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ie.dx)&&(f=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=Iu.random.normal.apply(Iu,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=Iu.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},Iu.scale={};var ko={floor:m,ceil:m};Iu.scale.linear=function(){return zr([0,1],[0,1],Kt,!1)};var No={s:1,g:1,p:1,r:1,e:1};Iu.scale.log=function(){return Ur(Iu.scale.linear().domain([0,1]),10,!0,[1,10])};var Ao=Iu.format(".0e"),Co={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};Iu.scale.pow=function(){return Pr(Iu.scale.linear(),1,[0,1])},Iu.scale.sqrt=function(){return Iu.scale.pow().exponent(.5)},Iu.scale.ordinal=function(){return Hr([],{t:"range",a:[[]]})},Iu.scale.category10=function(){return Iu.scale.ordinal().range(zo)},Iu.scale.category20=function(){return Iu.scale.ordinal().range(Lo)},Iu.scale.category20b=function(){return Iu.scale.ordinal().range(So)},Iu.scale.category20c=function(){return Iu.scale.ordinal().range(To)};var zo=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(yn),Lo=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(yn),So=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(yn),To=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(yn);Iu.scale.quantile=function(){return Fr([],[])},Iu.scale.quantize=function(){return Or(0,1,[0,1])},Iu.scale.threshold=function(){return Yr([.5],[0,1])},Iu.scale.identity=function(){return Ir([0,1])},Iu.svg={},Iu.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),f=o.apply(this,arguments)-wi,s=a.apply(this,arguments)-wi,h=Math.abs(s-f),g=f>s?0:1;if(n>c&&(p=c,c=n,n=p),h>=bi)return t(c,g)+(n?t(n,1-g):"")+"Z";var p,d,v,y,m,x,M,_,b,w,k,N,A=0,C=0,z=[];if((y=(+l.apply(this,arguments)||0)/2)&&(v=i===qo?Math.sqrt(n*n+c*c):+i.apply(this,arguments),g||(C*=-1),c&&(C=Q(v/c*Math.sin(y))),n&&(A=Q(v/n*Math.sin(y)))),c){m=c*Math.cos(f+C),x=c*Math.sin(f+C),M=c*Math.cos(s-C),_=c*Math.sin(s-C);var L=Math.abs(s-f-2*C)<=Mi?0:1;if(C&&Jr(m,x,M,_)===g^L){var S=(f+s)/2;m=c*Math.cos(S),x=c*Math.sin(S),M=_=null}}else m=x=0;if(n){b=n*Math.cos(s-A),w=n*Math.sin(s-A),k=n*Math.cos(f+A),N=n*Math.sin(f+A);var T=Math.abs(f-s+2*A)<=Mi?0:1;if(A&&Jr(b,w,k,N)===1-g^T){var q=(f+s)/2;b=n*Math.cos(q),w=n*Math.sin(q),k=N=null}}else b=w=0;if(h>mi&&(p=Math.min(Math.abs(c-n)/2,+u.apply(this,arguments)))>.001){d=c>n^g?0:1;var D=p,R=p;if(Mi>h){var E=null==k?[b,w]:null==M?[m,x]:ht([m,x],[k,N],[M,_],[b,w]),U=m-E[0],P=x-E[1],j=M-E[0],H=_-E[1],F=1/Math.sin(Math.acos((U*j+P*H)/(Math.sqrt(U*U+P*P)*Math.sqrt(j*j+H*H)))/2),O=Math.sqrt(E[0]*E[0]+E[1]*E[1]);R=Math.min(p,(n-O)/(F-1)),D=Math.min(p,(c-O)/(F+1))}if(null!=M){var Y=Gr(null==k?[b,w]:[k,N],[m,x],c,D,g),I=Gr([M,_],[b,w],c,D,g);p===D?z.push("M",Y[0],"A",D,",",D," 0 0,",d," ",Y[1],"A",c,",",c," 0 ",1-g^Jr(Y[1][0],Y[1][1],I[1][0],I[1][1]),",",g," ",I[1],"A",D,",",D," 0 0,",d," ",I[0]):z.push("M",Y[0],"A",D,",",D," 0 1,",d," ",I[0])}else z.push("M",m,",",x);if(null!=k){var Z=Gr([m,x],[k,N],n,-R,g),V=Gr([b,w],null==M?[m,x]:[M,_],n,-R,g);p===R?z.push("L",V[0],"A",R,",",R," 0 0,",d," ",V[1],"A",n,",",n," 0 ",g^Jr(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",R,",",R," 0 0,",d," ",Z[0]):z.push("L",V[0],"A",R,",",R," 0 0,",d," ",Z[0])}else z.push("L",b,",",w)}else z.push("M",m,",",x),null!=M&&z.push("A",c,",",c," 0 ",L,",",g," ",M,",",_),z.push("L",b,",",w),null!=k&&z.push("A",n,",",n," 0 ",T,",",1-g," ",k,",",N);return z.push("Z"),z.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=Vr,r=Xr,u=Zr,i=qo,o=$r,a=Br,l=Wr;return n.innerRadius=function(t){return arguments.length?(e=kn(t),n):e},n.outerRadius=function(t){return arguments.length?(r=kn(t),n):r},n.cornerRadius=function(t){return arguments.length?(u=kn(t),n):u},n.padRadius=function(t){return arguments.length?(i=t==qo?qo:kn(t),n):i},n.startAngle=function(t){return arguments.length?(o=kn(t),n):o},n.endAngle=function(t){return arguments.length?(a=kn(t),n):a},n.padAngle=function(t){return arguments.length?(l=kn(t),n):l},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-wi;return[Math.cos(t)*n,Math.sin(t)*n]},n};var qo="auto";Iu.svg.line=function(){return Qr(m)};var Do=Iu.map({linear:nu,"linear-closed":tu,step:eu,"step-before":ru,"step-after":uu,basis:fu,"basis-open":su,"basis-closed":hu,bundle:gu,cardinal:au,"cardinal-open":iu,"cardinal-closed":ou,monotone:xu});Do.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Ro=[0,2/3,1/3,0],Eo=[0,1/3,2/3,0],Uo=[0,1/6,2/3,1/6];Iu.svg.line.radial=function(){var n=Qr(Mu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},ru.reverse=uu,uu.reverse=ru,Iu.svg.area=function(){return _u(m)},Iu.svg.area.radial=function(){var n=_u(Mu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},Iu.svg.chord=function(){function n(n,a){var l=t(this,i,n,a),c=t(this,o,n,a);return"M"+l.p0+r(l.r,l.p1,l.a1-l.a0)+(e(l,c)?u(l.r,l.p1,l.r,l.p0):u(l.r,l.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+u(c.r,c.p1,l.r,l.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=l.call(n,u,r)-wi,f=c.call(n,u,r)-wi;return{r:i,a0:o,a1:f,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(f),i*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Mi)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=bu,o=wu,a=ku,l=$r,c=Br;return n.radius=function(t){return arguments.length?(a=kn(t),n):a},n.source=function(t){return arguments.length?(i=kn(t),n):i},n.target=function(t){return arguments.length?(o=kn(t),n):o},n.startAngle=function(t){return arguments.length?(l=kn(t),n):l},n.endAngle=function(t){return arguments.length?(c=kn(t),n):c},n},Iu.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,l=[i,{x:i.x,y:a},{x:o.x,y:a},o];return l=l.map(r),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var t=bu,e=wu,r=Nu;return n.source=function(e){return arguments.length?(t=kn(e),n):t},n.target=function(t){return arguments.length?(e=kn(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},Iu.svg.diagonal.radial=function(){var n=Iu.svg.diagonal(),t=Nu,e=n.projection;return n.projection=function(n){return arguments.length?e(Au(t=n)):t},n},Iu.svg.symbol=function(){function n(n,r){return(Po.get(t.call(this,n,r))||Lu)(e.call(this,n,r))}var t=zu,e=Cu;return n.type=function(e){return arguments.length?(t=kn(e),n):t},n.size=function(t){return arguments.length?(e=kn(t),n):e},n};var Po=Iu.map({circle:Lu,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Ho)),e=t*Ho;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/jo),e=t*jo/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/jo),e=t*jo/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});Iu.svg.symbolTypes=Po.keys();var jo=Math.sqrt(3),Ho=Math.tan(30*ki);fi.transition=function(n){for(var t,e,r=Fo||++Zo,u=Ru(n),i=[],o=Oo||{time:Date.now(),ease:ie,delay:0,duration:250},a=-1,l=this.length;++ai;i++){u.push(t=[]);for(var e=this[i],a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return Tu(u,this.namespace,this.id)},Io.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):I(this,null==t?function(t){t[r][e].tween.remove(n)}:function(u){u[r][e].tween.set(n,t)})},Io.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Ae:Kt,a=Iu.ns.qualify(n);return qu(this,"attr."+n,t,a.local?i:u)},Io.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=Iu.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Io.style=function(n,e,r){function u(){this.style.removeProperty(n)}function i(e){return null==e?u:(e+="",function(){var u,i=t(this).getComputedStyle(this,null).getPropertyValue(n);return i!==e&&(u=Kt(i,e),function(t){this.style.setProperty(n,u(t),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof n){2>o&&(e="");for(r in n)this.style(r,n[r],e);return this}r=""}return qu(this,"style."+n,e,i)},Io.styleTween=function(n,e,r){function u(u,i){var o=e.call(this,u,i,t(this).getComputedStyle(this,null).getPropertyValue(n));return o&&function(t){this.style.setProperty(n,o(t),r)}}return arguments.length<3&&(r=""),this.tween("style."+n,u)},Io.text=function(n){return qu(this,"text",n,Du)},Io.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Io.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=Iu.ease.apply(Iu,arguments)),I(this,function(r){r[e][t].ease=n}))},Io.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:I(this,"function"==typeof n?function(r,u,i){r[e][t].delay=+n.call(r,r.__data__,u,i)}:(n=+n,function(r){r[e][t].delay=n}))},Io.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:I(this,"function"==typeof n?function(r,u,i){r[e][t].duration=Math.max(1,n.call(r,r.__data__,u,i))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Io.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var u=Oo,i=Fo;try{Fo=e,I(this,function(t,u,i){Oo=t[r][e],n.call(t,t.__data__,u,i)})}finally{Oo=u,Fo=i}}else I(this,function(u){var i=u[r][e];(i.event||(i.event=Iu.dispatch("start","end","interrupt"))).on(n,t)});return this},Io.transition=function(){for(var n,t,e,r,u=this.id,i=++Zo,o=this.namespace,a=[],l=0,c=this.length;c>l;l++){a.push(n=[]);for(var t=this[l],f=0,s=t.length;s>f;f++)(e=t[f])&&(r=e[o][u],Eu(e,f,o,i,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Tu(a,o,i)},Iu.svg.axis=function(){function n(n){n.each(function(){var n,c=Iu.select(this),f=this.__chart__||e,s=this.__chart__=e.copy(),h=null==l?s.ticks?s.ticks.apply(s,a):s.domain():l,g=null==t?s.tickFormat?s.tickFormat.apply(s,a):m:t,p=c.selectAll(".tick").data(h,s),d=p.enter().insert("g",".domain").attr("class","tick").style("opacity",mi),v=Iu.transition(p.exit()).style("opacity",mi).remove(),y=Iu.transition(p.order()).style("opacity",1),x=Math.max(u,0)+o,M=wr(s),_=c.selectAll(".domain").data([0]),b=(_.enter().append("path").attr("class","domain"),Iu.transition(_));d.append("line"),d.append("text");var w,k,N,A,C=d.select("line"),z=y.select("line"),L=p.select("text").text(g),S=d.select("text"),T=y.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Uu,w="x",N="y",k="x2",A="y2",L.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),b.attr("d","M"+M[0]+","+q*i+"V0H"+M[1]+"V"+q*i)):(n=Pu,w="y",N="x",k="y2",A="x2",L.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),b.attr("d","M"+q*i+","+M[0]+"H0V"+M[1]+"H"+q*i)),C.attr(A,q*u),S.attr(N,q*x),z.attr(k,0).attr(A,q*u),T.attr(w,0).attr(N,q*x),s.rangeBand){var D=s,R=D.rangeBand()/2;f=s=function(n){return D(n)+R}}else f.rangeBand?f=s:v.call(n,s,f);d.call(n,f,s),y.call(n,s,s)})}var t,e=Iu.scale.linear(),r=Vo,u=6,i=6,o=3,a=[10],l=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Xo?t+"":Vo,n):r},n.ticks=function(){return arguments.length?(a=Vu(arguments),n):a},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Vo="bottom",Xo={top:1,right:1,bottom:1,left:1};Iu.svg.brush=function(){function n(t){t.each(function(){var t=Iu.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",i).on("touchstart.brush",i),o=t.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=t.selectAll(".resize").data(d,m);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return $o[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var l,s=Iu.transition(t),h=Iu.transition(o);c&&(l=wr(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(s)),f&&(l=wr(f),h.attr("y",l[0]).attr("height",l[1]-l[0]),u(s)),e(s)})}function e(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function r(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function u(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function i(){function i(){32==Iu.event.keyCode&&(L||(x=null,T[0]-=s[1],T[1]-=h[1],L=2),k())}function d(){32==Iu.event.keyCode&&2==L&&(T[0]+=s[1],T[1]+=h[1],L=0,k())}function v(){var n=Iu.mouse(_),t=!1;M&&(n[0]+=M[0],n[1]+=M[1]),L||(Iu.event.altKey?(x||(x=[(s[0]+s[1])/2,(h[0]+h[1])/2]),T[0]=s[+(n[0]f?(u=r,r=f):u=f),d[0]!=r||d[1]!=u?(e?a=null:o=null,d[0]=r,d[1]=u,!0):void 0}function m(){v(),N.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),Iu.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),S(),w({type:"brushend"})}var x,M,_=this,b=Iu.select(Iu.event.target),w=l.of(_,arguments),N=Iu.select(_),A=b.datum(),C=!/^(n|s)$/.test(A)&&c,z=!/^(e|w)$/.test(A)&&f,L=b.classed("extent"),S=W(_),T=Iu.mouse(_),q=Iu.select(t(_)).on("keydown.brush",i).on("keyup.brush",d);if(Iu.event.changedTouches?q.on("touchmove.brush",v).on("touchend.brush",m):q.on("mousemove.brush",v).on("mouseup.brush",m),N.interrupt().selectAll("*").interrupt(),L)T[0]=s[0]-T[0],T[1]=h[0]-T[1];else if(A){var D=+/w$/.test(A),R=+/^n/.test(A);M=[s[1-D]-T[0],h[1-R]-T[1]],T[0]=s[D],T[1]=h[R]}else Iu.event.altKey&&(x=T.slice());N.style("pointer-events","none").selectAll(".resize").style("display",null),Iu.select("body").style("cursor",b.style("cursor")),w({type:"brushstart"}),v()}var o,a,l=A(n,"brushstart","brush","brushend"),c=null,f=null,s=[0,0],h=[0,0],g=!0,p=!0,d=Bo[0];return n.event=function(n){n.each(function(){var n=l.of(this,arguments),t={x:s,y:h,i:o,j:a},e=this.__chart__||t;this.__chart__=t,Fo?Iu.select(this).transition().each("start.brush",function(){o=e.i,a=e.j,s=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=Qt(s,t.x),r=Qt(h,t.y);return o=a=null,function(u){s=t.x=e(u),h=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=t.i,a=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,d=Bo[!c<<1|!f],n):c},n.y=function(t){return arguments.length?(f=t,d=Bo[!c<<1|!f],n):f},n.clamp=function(t){return arguments.length?(c&&f?(g=!!t[0],p=!!t[1]):c?g=!!t:f&&(p=!!t),n):c&&f?[g,p]:c?g:f?p:null},n.extent=function(t){var e,r,u,i,l;return arguments.length?(c&&(e=t[0],r=t[1],f&&(e=e[0],r=r[0]),o=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(l=e,e=r,r=l),e==s[0]&&r==s[1]||(s=[e,r])),f&&(u=t[0],i=t[1],c&&(u=u[1],i=i[1]),a=[u,i],f.invert&&(u=f(u),i=f(i)),u>i&&(l=u,u=i,i=l),u==h[0]&&i==h[1]||(h=[u,i])),n):(c&&(o?(e=o[0],r=o[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(l=e,e=r,r=l))),f&&(a?(u=a[0],i=a[1]):(u=h[0],i=h[1],f.invert&&(u=f.invert(u),i=f.invert(i)),u>i&&(l=u,u=i,i=l))),c&&f?[[e,u],[r,i]]:c?[e,r]:f&&[u,i])},n.clear=function(){return n.empty()||(s=[0,0],h=[0,0],o=a=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!f&&h[0]==h[1]},Iu.rebind(n,l,"on")};var $o={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Bo=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Wo=Wi.format=to.timeFormat,Jo=Wo.utc,Go=Jo("%Y-%m-%dT%H:%M:%S.%LZ");Wo.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?ju:Go,ju.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},ju.toString=Go.toString,Wi.second=jn(function(n){return new Ji(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),Wi.seconds=Wi.second.range,Wi.seconds.utc=Wi.second.utc.range,Wi.minute=jn(function(n){return new Ji(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),Wi.minutes=Wi.minute.range,Wi.minutes.utc=Wi.minute.utc.range,Wi.hour=jn(function(n){var t=n.getTimezoneOffset()/60;return new Ji(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),Wi.hours=Wi.hour.range,Wi.hours.utc=Wi.hour.utc.range,Wi.month=jn(function(n){return n=Wi.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),Wi.months=Wi.month.range,Wi.months.utc=Wi.month.utc.range;var Ko=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Qo=[[Wi.second,1],[Wi.second,5],[Wi.second,15],[Wi.second,30],[Wi.minute,1],[Wi.minute,5],[Wi.minute,15],[Wi.minute,30],[Wi.hour,1],[Wi.hour,3],[Wi.hour,6],[Wi.hour,12],[Wi.day,1],[Wi.day,2],[Wi.week,1],[Wi.month,1],[Wi.month,3],[Wi.year,1]],na=Wo.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Kr]]),ta={range:function(n,t,e){return Iu.range(Math.ceil(n/e)*e,+t,e).map(Fu)},floor:m,ceil:m};Qo.year=Wi.year,Wi.scale=function(){return Hu(Iu.scale.linear(),Qo,na)};var ea=Qo.map(function(n){return[n[0].utc,n[1]]}),ra=Jo.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Kr]]);ea.year=Wi.year.utc,Wi.scale.utc=function(){return Hu(Iu.scale.linear(),ea,ra)},Iu.text=Nn(function(n){return n.responseText}),Iu.json=function(n,t){return An(n,"application/json",Ou,t)},Iu.html=function(n,t){return An(n,"text/html",Yu,t)},Iu.xml=Nn(function(n){return n.responseXML}),"function"==typeof define&&define.amd?(this.d3=Iu,define(Iu)):"object"==typeof module&&module.exports?module.exports=Iu:this.d3=Iu}(); \ No newline at end of file diff --git a/src/d3.js b/src/d3.js index d0ad7385077cad..a5442333d49414 100644 --- a/src/d3.js +++ b/src/d3.js @@ -8,7 +8,6 @@ import "core/"; import "dsv/"; import "event/"; import "format/"; -import "geo/"; import "geom/"; import "interpolate/"; import "layout/"; diff --git a/src/geo/albers-usa.js b/src/geo/albers-usa.js deleted file mode 100644 index 6de6c71013c7cf..00000000000000 --- a/src/geo/albers-usa.js +++ /dev/null @@ -1,129 +0,0 @@ -import "albers"; -import "conic-equal-area"; -import "geo"; - -// A composite projection for the United States, configured by default for -// 960×500. Also works quite well at 960×600 with scale 1285. The set of -// standard parallels for each region comes from USGS, which is published here: -// http://egsc.usgs.gov/isb/pubs/MapProjections/projections.html#albers -d3.geo.albersUsa = function() { - var lower48 = d3.geo.albers(); - - // EPSG:3338 - var alaska = d3.geo.conicEqualArea() - .rotate([154, 0]) - .center([-2, 58.5]) - .parallels([55, 65]); - - // ESRI:102007 - var hawaii = d3.geo.conicEqualArea() - .rotate([157, 0]) - .center([-3, 19.9]) - .parallels([8, 18]); - - var point, - pointStream = {point: function(x, y) { point = [x, y]; }}, - lower48Point, - alaskaPoint, - hawaiiPoint; - - function albersUsa(coordinates) { - var x = coordinates[0], y = coordinates[1]; - point = null; - (lower48Point(x, y), point) - || (alaskaPoint(x, y), point) - || hawaiiPoint(x, y); - return point; - } - - albersUsa.invert = function(coordinates) { - var k = lower48.scale(), - t = lower48.translate(), - x = (coordinates[0] - t[0]) / k, - y = (coordinates[1] - t[1]) / k; - return (y >= 0.120 && y < 0.234 && x >= -0.425 && x < -0.214 ? alaska - : y >= 0.166 && y < 0.234 && x >= -0.214 && x < -0.115 ? hawaii - : lower48).invert(coordinates); - }; - - // A naïve multi-projection stream. - // The projections must have mutually exclusive clip regions on the sphere, - // as this will avoid emitting interleaving lines and polygons. - albersUsa.stream = function(stream) { - var lower48Stream = lower48.stream(stream), - alaskaStream = alaska.stream(stream), - hawaiiStream = hawaii.stream(stream); - return { - point: function(x, y) { - lower48Stream.point(x, y); - alaskaStream.point(x, y); - hawaiiStream.point(x, y); - }, - sphere: function() { - lower48Stream.sphere(); - alaskaStream.sphere(); - hawaiiStream.sphere(); - }, - lineStart: function() { - lower48Stream.lineStart(); - alaskaStream.lineStart(); - hawaiiStream.lineStart(); - }, - lineEnd: function() { - lower48Stream.lineEnd(); - alaskaStream.lineEnd(); - hawaiiStream.lineEnd(); - }, - polygonStart: function() { - lower48Stream.polygonStart(); - alaskaStream.polygonStart(); - hawaiiStream.polygonStart(); - }, - polygonEnd: function() { - lower48Stream.polygonEnd(); - alaskaStream.polygonEnd(); - hawaiiStream.polygonEnd(); - } - }; - }; - - albersUsa.precision = function(_) { - if (!arguments.length) return lower48.precision(); - lower48.precision(_); - alaska.precision(_); - hawaii.precision(_); - return albersUsa; - }; - - albersUsa.scale = function(_) { - if (!arguments.length) return lower48.scale(); - lower48.scale(_); - alaska.scale(_ * 0.35); - hawaii.scale(_); - return albersUsa.translate(lower48.translate()); - }; - - albersUsa.translate = function(_) { - if (!arguments.length) return lower48.translate(); - var k = lower48.scale(), x = +_[0], y = +_[1]; - - lower48Point = lower48 - .translate(_) - .clipExtent([[x - 0.455 * k, y - 0.238 * k], [x + 0.455 * k, y + 0.238 * k]]) - .stream(pointStream).point; - - alaskaPoint = alaska - .translate([x - 0.307 * k, y + 0.201 * k]) - .clipExtent([[x - 0.425 * k + ε, y + 0.120 * k + ε], [x - 0.214 * k - ε, y + 0.234 * k - ε]]) - .stream(pointStream).point; - - hawaiiPoint = hawaii - .translate([x - 0.205 * k, y + 0.212 * k]) - .clipExtent([[x - 0.214 * k + ε, y + 0.166 * k + ε], [x - 0.115 * k - ε, y + 0.234 * k - ε]]) - .stream(pointStream).point; - - return albersUsa; - }; - - return albersUsa.scale(1070); -}; diff --git a/src/geo/albers.js b/src/geo/albers.js deleted file mode 100644 index a9c688633fd468..00000000000000 --- a/src/geo/albers.js +++ /dev/null @@ -1,11 +0,0 @@ -import "conic-equal-area"; -import "geo"; - -// ESRI:102003 -d3.geo.albers = function() { - return d3.geo.conicEqualArea() - .rotate([96, 0]) - .center([-0.6, 38.7]) - .parallels([29.5, 45.5]) - .scale(1070); -}; diff --git a/src/geo/area.js b/src/geo/area.js deleted file mode 100644 index 32f2c1c9cd12ed..00000000000000 --- a/src/geo/area.js +++ /dev/null @@ -1,69 +0,0 @@ -import "../core/noop"; -import "../math/adder"; -import "../math/trigonometry"; -import "geo"; -import "stream"; - -d3.geo.area = function(object) { - d3_geo_areaSum = 0; - d3.geo.stream(object, d3_geo_area); - return d3_geo_areaSum; -}; - -var d3_geo_areaSum, - d3_geo_areaRingSum = new d3_adder; - -var d3_geo_area = { - sphere: function() { d3_geo_areaSum += 4 * π; }, - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - - // Only count area for polygon rings. - polygonStart: function() { - d3_geo_areaRingSum.reset(); - d3_geo_area.lineStart = d3_geo_areaRingStart; - }, - polygonEnd: function() { - var area = 2 * d3_geo_areaRingSum; - d3_geo_areaSum += area < 0 ? 4 * π + area : area; - d3_geo_area.lineStart = d3_geo_area.lineEnd = d3_geo_area.point = d3_noop; - } -}; - -function d3_geo_areaRingStart() { - var λ00, φ00, λ0, cosφ0, sinφ0; // start point and previous point - - // For the first point, … - d3_geo_area.point = function(λ, φ) { - d3_geo_area.point = nextPoint; - λ0 = (λ00 = λ) * d3_radians, cosφ0 = Math.cos(φ = (φ00 = φ) * d3_radians / 2 + π / 4), sinφ0 = Math.sin(φ); - }; - - // For subsequent points, … - function nextPoint(λ, φ) { - λ *= d3_radians; - φ = φ * d3_radians / 2 + π / 4; // 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 dλ = λ - λ0, - sdλ = dλ >= 0 ? 1 : -1, - adλ = sdλ * dλ, - cosφ = Math.cos(φ), - sinφ = Math.sin(φ), - k = sinφ0 * sinφ, - u = cosφ0 * cosφ + k * Math.cos(adλ), - v = k * sdλ * Math.sin(adλ); - d3_geo_areaRingSum.add(Math.atan2(v, u)); - - // Advance the previous points. - λ0 = λ, cosφ0 = cosφ, sinφ0 = sinφ; - } - - // For the last point, return to the start. - d3_geo_area.lineEnd = function() { - nextPoint(λ00, φ00); - }; -} diff --git a/src/geo/azimuthal-equal-area.js b/src/geo/azimuthal-equal-area.js deleted file mode 100644 index 91bdcd66c42af0..00000000000000 --- a/src/geo/azimuthal-equal-area.js +++ /dev/null @@ -1,12 +0,0 @@ -import "azimuthal"; -import "geo"; -import "projection"; - -var d3_geo_azimuthalEqualArea = d3_geo_azimuthal( - function(cosλcosφ) { return Math.sqrt(2 / (1 + cosλcosφ)); }, - function(ρ) { return 2 * Math.asin(ρ / 2); } -); - -(d3.geo.azimuthalEqualArea = function() { - return d3_geo_projection(d3_geo_azimuthalEqualArea); -}).raw = d3_geo_azimuthalEqualArea; diff --git a/src/geo/azimuthal-equidistant.js b/src/geo/azimuthal-equidistant.js deleted file mode 100644 index 80b14a941603e8..00000000000000 --- a/src/geo/azimuthal-equidistant.js +++ /dev/null @@ -1,13 +0,0 @@ -import "../core/identity"; -import "azimuthal"; -import "geo"; -import "projection"; - -var d3_geo_azimuthalEquidistant = d3_geo_azimuthal( - function(cosλcosφ) { var c = Math.acos(cosλcosφ); return c && c / Math.sin(c); }, - d3_identity -); - -(d3.geo.azimuthalEquidistant = function() { - return d3_geo_projection(d3_geo_azimuthalEquidistant); -}).raw = d3_geo_azimuthalEquidistant; diff --git a/src/geo/azimuthal.js b/src/geo/azimuthal.js deleted file mode 100644 index 5c0d9f5a9d0f81..00000000000000 --- a/src/geo/azimuthal.js +++ /dev/null @@ -1,25 +0,0 @@ -// Abstract azimuthal projection. -function d3_geo_azimuthal(scale, angle) { - function azimuthal(λ, φ) { - var cosλ = Math.cos(λ), - cosφ = Math.cos(φ), - k = scale(cosλ * cosφ); - return [ - k * cosφ * Math.sin(λ), - k * Math.sin(φ) - ]; - } - - azimuthal.invert = function(x, y) { - var ρ = Math.sqrt(x * x + y * y), - c = angle(ρ), - sinc = Math.sin(c), - cosc = Math.cos(c); - return [ - Math.atan2(x * sinc, ρ * cosc), - Math.asin(ρ && y * sinc / ρ) - ]; - }; - - return azimuthal; -} diff --git a/src/geo/bounds.js b/src/geo/bounds.js deleted file mode 100644 index 2248d85b76b1d2..00000000000000 --- a/src/geo/bounds.js +++ /dev/null @@ -1,168 +0,0 @@ -import "../math/abs"; -import "geo"; -import "stream"; -import "area"; -import "cartesian"; -import "spherical"; - -d3.geo.bounds = (function() { - var λ0, φ0, λ1, φ1, // bounds - λ_, // previous λ-coordinate - λ__, φ__, // first point - p0, // previous 3D point - dλSum, - ranges, - range; - - var bound = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - - polygonStart: function() { - bound.point = ringPoint; - bound.lineStart = ringStart; - bound.lineEnd = ringEnd; - dλSum = 0; - d3_geo_area.polygonStart(); - }, - polygonEnd: function() { - d3_geo_area.polygonEnd(); - bound.point = point; - bound.lineStart = lineStart; - bound.lineEnd = lineEnd; - if (d3_geo_areaRingSum < 0) λ0 = -(λ1 = 180), φ0 = -(φ1 = 90); - else if (dλSum > ε) φ1 = 90; - else if (dλSum < -ε) φ0 = -90; - range[0] = λ0, range[1] = λ1; - } - }; - - function point(λ, φ) { - ranges.push(range = [λ0 = λ, λ1 = λ]); - if (φ < φ0) φ0 = φ; - if (φ > φ1) φ1 = φ; - } - - function linePoint(λ, φ) { - var p = d3_geo_cartesian([λ * d3_radians, φ * d3_radians]); - if (p0) { - var normal = d3_geo_cartesianCross(p0, p), - equatorial = [normal[1], -normal[0], 0], - inflection = d3_geo_cartesianCross(equatorial, normal); - d3_geo_cartesianNormalize(inflection); - inflection = d3_geo_spherical(inflection); - var dλ = λ - λ_, - s = dλ > 0 ? 1 : -1, - λi = inflection[0] * d3_degrees * s, - antimeridian = abs(dλ) > 180; - if (antimeridian ^ (s * λ_ < λi && λi < s * λ)) { - var φi = inflection[1] * d3_degrees; - if (φi > φ1) φ1 = φi; - } else if (λi = (λi + 360) % 360 - 180, antimeridian ^ (s * λ_ < λi && λi < s * λ)) { - var φi = -inflection[1] * d3_degrees; - if (φi < φ0) φ0 = φi; - } else { - if (φ < φ0) φ0 = φ; - if (φ > φ1) φ1 = φ; - } - if (antimeridian) { - if (λ < λ_) { - if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; - } else { - if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; - } - } else { - if (λ1 >= λ0) { - if (λ < λ0) λ0 = λ; - if (λ > λ1) λ1 = λ; - } else { - if (λ > λ_) { - if (angle(λ0, λ) > angle(λ0, λ1)) λ1 = λ; - } else { - if (angle(λ, λ1) > angle(λ0, λ1)) λ0 = λ; - } - } - } - } else { - point(λ, φ); - } - p0 = p, λ_ = λ; - } - - function lineStart() { bound.point = linePoint; } - function lineEnd() { - range[0] = λ0, range[1] = λ1; - bound.point = point; - p0 = null; - } - - function ringPoint(λ, φ) { - if (p0) { - var dλ = λ - λ_; - dλSum += abs(dλ) > 180 ? dλ + (dλ > 0 ? 360 : -360) : dλ; - } else λ__ = λ, φ__ = φ; - d3_geo_area.point(λ, φ); - linePoint(λ, φ); - } - - function ringStart() { - d3_geo_area.lineStart(); - } - - function ringEnd() { - ringPoint(λ__, φ__); - d3_geo_area.lineEnd(); - if (abs(dλSum) > ε) λ0 = -(λ1 = 180); - range[0] = λ0, range[1] = λ1; - p0 = null; - } - - // Finds the left-right distance between two longitudes. - // This is almost the same as (λ1 - λ0 + 360°) % 360°, except that we want - // the distance between ±180° to be 360°. - function angle(λ0, λ1) { return (λ1 -= λ0) < 0 ? λ1 + 360 : λ1; } - - function compareRanges(a, b) { return a[0] - b[0]; } - - function withinRange(x, range) { - return range[0] <= range[1] ? range[0] <= x && x <= range[1] : x < range[0] || range[1] < x; - } - - return function(feature) { - φ1 = λ1 = -(λ0 = φ0 = Infinity); - ranges = []; - - d3.geo.stream(feature, bound); - - var n = ranges.length; - if (n) { - // First, sort ranges by their minimum longitudes. - ranges.sort(compareRanges); - - // Then, merge any ranges that overlap. - for (var i = 1, a = ranges[0], b, merged = [a]; i < n; ++i) { - b = ranges[i]; - if (withinRange(b[0], a) || withinRange(b[1], a)) { - if (angle(a[0], b[1]) > angle(a[0], a[1])) a[1] = b[1]; - if (angle(b[0], a[1]) > angle(a[0], a[1])) a[0] = b[0]; - } else { - merged.push(a = b); - } - } - - // Finally, find the largest gap between the merged ranges. - // The final bounding box will be the inverse of this gap. - var best = -Infinity, dλ; - for (var n = merged.length - 1, i = 0, a = merged[n], b; i <= n; a = b, ++i) { - b = merged[i]; - if ((dλ = angle(a[1], b[0])) > best) best = dλ, λ0 = b[0], λ1 = a[1]; - } - } - ranges = range = null; - - return λ0 === Infinity || φ0 === Infinity - ? [[NaN, NaN], [NaN, NaN]] - : [[λ0, φ0], [λ1, φ1]]; - }; -})(); diff --git a/src/geo/cartesian.js b/src/geo/cartesian.js deleted file mode 100644 index f365a3dd0814e2..00000000000000 --- a/src/geo/cartesian.js +++ /dev/null @@ -1,47 +0,0 @@ -// TODO -// cross and scale return new vectors, -// whereas add and normalize operate in-place - -function d3_geo_cartesian(spherical) { - var λ = spherical[0], - φ = spherical[1], - cosφ = Math.cos(φ); - return [ - cosφ * Math.cos(λ), - cosφ * Math.sin(λ), - Math.sin(φ) - ]; -} - -function d3_geo_cartesianDot(a, b) { - return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]; -} - -function d3_geo_cartesianCross(a, b) { - return [ - a[1] * b[2] - a[2] * b[1], - a[2] * b[0] - a[0] * b[2], - a[0] * b[1] - a[1] * b[0] - ]; -} - -function d3_geo_cartesianAdd(a, b) { - a[0] += b[0]; - a[1] += b[1]; - a[2] += b[2]; -} - -function d3_geo_cartesianScale(vector, k) { - return [ - vector[0] * k, - vector[1] * k, - vector[2] * k - ]; -} - -function d3_geo_cartesianNormalize(d) { - var l = Math.sqrt(d[0] * d[0] + d[1] * d[1] + d[2] * d[2]); - d[0] /= l; - d[1] /= l; - d[2] /= l; -} diff --git a/src/geo/centroid.js b/src/geo/centroid.js deleted file mode 100644 index b764e9fd81f1ef..00000000000000 --- a/src/geo/centroid.js +++ /dev/null @@ -1,149 +0,0 @@ -import "../core/noop"; -import "../math/trigonometry"; -import "geo"; -import "stream"; - -d3.geo.centroid = function(object) { - d3_geo_centroidW0 = d3_geo_centroidW1 = - d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = - d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = - d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; - d3.geo.stream(object, d3_geo_centroid); - - var x = d3_geo_centroidX2, - y = d3_geo_centroidY2, - z = d3_geo_centroidZ2, - m = x * x + y * y + z * z; - - // If the area-weighted centroid is undefined, fall back to length-weighted centroid. - if (m < ε2) { - x = d3_geo_centroidX1, y = d3_geo_centroidY1, z = d3_geo_centroidZ1; - // If the feature has zero length, fall back to arithmetic mean of point vectors. - if (d3_geo_centroidW1 < ε) x = d3_geo_centroidX0, y = d3_geo_centroidY0, z = d3_geo_centroidZ0; - m = x * x + y * y + z * z; - // If the feature still has an undefined centroid, then return. - if (m < ε2) return [NaN, NaN]; - } - - return [Math.atan2(y, x) * d3_degrees, d3_asin(z / Math.sqrt(m)) * d3_degrees]; -}; - -var d3_geo_centroidW0, - d3_geo_centroidW1, - d3_geo_centroidX0, - d3_geo_centroidY0, - d3_geo_centroidZ0, - d3_geo_centroidX1, - d3_geo_centroidY1, - d3_geo_centroidZ1, - d3_geo_centroidX2, - d3_geo_centroidY2, - d3_geo_centroidZ2; - -var d3_geo_centroid = { - sphere: d3_noop, - point: d3_geo_centroidPoint, - lineStart: d3_geo_centroidLineStart, - lineEnd: d3_geo_centroidLineEnd, - polygonStart: function() { - d3_geo_centroid.lineStart = d3_geo_centroidRingStart; - }, - polygonEnd: function() { - d3_geo_centroid.lineStart = d3_geo_centroidLineStart; - } -}; - -// Arithmetic mean of Cartesian vectors. -function d3_geo_centroidPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - d3_geo_centroidPointXYZ(cosφ * Math.cos(λ), cosφ * Math.sin(λ), Math.sin(φ)); -} - -function d3_geo_centroidPointXYZ(x, y, z) { - ++d3_geo_centroidW0; - d3_geo_centroidX0 += (x - d3_geo_centroidX0) / d3_geo_centroidW0; - d3_geo_centroidY0 += (y - d3_geo_centroidY0) / d3_geo_centroidW0; - d3_geo_centroidZ0 += (z - d3_geo_centroidZ0) / d3_geo_centroidW0; -} - -function d3_geo_centroidLineStart() { - var x0, y0, z0; // previous point - - d3_geo_centroid.point = function(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - x0 = cosφ * Math.cos(λ); - y0 = cosφ * Math.sin(λ); - z0 = Math.sin(φ); - d3_geo_centroid.point = nextPoint; - d3_geo_centroidPointXYZ(x0, y0, z0); - }; - - function nextPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians), - x = cosφ * Math.cos(λ), - y = cosφ * Math.sin(λ), - z = Math.sin(φ), - w = Math.atan2( - Math.sqrt((w = y0 * z - z0 * y) * w + (w = z0 * x - x0 * z) * w + (w = x0 * y - y0 * x) * w), - x0 * x + y0 * y + z0 * z); - d3_geo_centroidW1 += w; - d3_geo_centroidX1 += w * (x0 + (x0 = x)); - d3_geo_centroidY1 += w * (y0 + (y0 = y)); - d3_geo_centroidZ1 += w * (z0 + (z0 = z)); - d3_geo_centroidPointXYZ(x0, y0, z0); - } -} - -function d3_geo_centroidLineEnd() { - d3_geo_centroid.point = d3_geo_centroidPoint; -} - -// See J. E. Brock, The Inertia Tensor for a Spherical Triangle, -// J. Applied Mechanics 42, 239 (1975). -function d3_geo_centroidRingStart() { - var λ00, φ00, // first point - x0, y0, z0; // previous point - - d3_geo_centroid.point = function(λ, φ) { - λ00 = λ, φ00 = φ; - d3_geo_centroid.point = nextPoint; - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians); - x0 = cosφ * Math.cos(λ); - y0 = cosφ * Math.sin(λ); - z0 = Math.sin(φ); - d3_geo_centroidPointXYZ(x0, y0, z0); - }; - - d3_geo_centroid.lineEnd = function() { - nextPoint(λ00, φ00); - d3_geo_centroid.lineEnd = d3_geo_centroidLineEnd; - d3_geo_centroid.point = d3_geo_centroidPoint; - }; - - function nextPoint(λ, φ) { - λ *= d3_radians; - var cosφ = Math.cos(φ *= d3_radians), - x = cosφ * Math.cos(λ), - y = cosφ * Math.sin(λ), - z = Math.sin(φ), - cx = y0 * z - z0 * y, - cy = z0 * x - x0 * z, - cz = x0 * y - y0 * x, - m = Math.sqrt(cx * cx + cy * cy + cz * cz), - u = x0 * x + y0 * y + z0 * z, - v = m && -d3_acos(u) / m, // area weight - w = Math.atan2(m, u); // line weight - d3_geo_centroidX2 += v * cx; - d3_geo_centroidY2 += v * cy; - d3_geo_centroidZ2 += v * cz; - d3_geo_centroidW1 += w; - d3_geo_centroidX1 += w * (x0 + (x0 = x)); - d3_geo_centroidY1 += w * (y0 + (y0 = y)); - d3_geo_centroidZ1 += w * (z0 + (z0 = z)); - d3_geo_centroidPointXYZ(x0, y0, z0); - } -} diff --git a/src/geo/circle.js b/src/geo/circle.js deleted file mode 100644 index e1d1186cb28caa..00000000000000 --- a/src/geo/circle.js +++ /dev/null @@ -1,81 +0,0 @@ -import "../math/trigonometry"; -import "cartesian"; -import "geo"; -import "rotation"; -import "spherical"; - -d3.geo.circle = function() { - var origin = [0, 0], - angle, - precision = 6, - interpolate; - - function circle() { - var center = typeof origin === "function" ? origin.apply(this, arguments) : origin, - rotate = d3_geo_rotation(-center[0] * d3_radians, -center[1] * d3_radians, 0).invert, - ring = []; - - interpolate(null, null, 1, { - point: function(x, y) { - ring.push(x = rotate(x, y)); - x[0] *= d3_degrees, x[1] *= d3_degrees; - } - }); - - return {type: "Polygon", coordinates: [ring]}; - } - - circle.origin = function(x) { - if (!arguments.length) return origin; - origin = x; - return circle; - }; - - circle.angle = function(x) { - if (!arguments.length) return angle; - interpolate = d3_geo_circleInterpolate((angle = +x) * d3_radians, precision * d3_radians); - return circle; - }; - - circle.precision = function(_) { - if (!arguments.length) return precision; - interpolate = d3_geo_circleInterpolate(angle * d3_radians, (precision = +_) * d3_radians); - return circle; - }; - - return circle.angle(90); -}; - -// Interpolates along a circle centered at [0°, 0°], with a given radius and -// precision. -function d3_geo_circleInterpolate(radius, precision) { - var cr = Math.cos(radius), - sr = Math.sin(radius); - return function(from, to, direction, listener) { - var step = direction * precision; - if (from != null) { - from = d3_geo_circleAngle(cr, from); - to = d3_geo_circleAngle(cr, to); - if (direction > 0 ? from < to: from > to) from += direction * τ; - } else { - from = radius + direction * τ; - to = radius - 0.5 * step; - } - for (var point, t = from; direction > 0 ? t > to : t < to; t -= step) { - listener.point((point = d3_geo_spherical([ - cr, - -sr * Math.cos(t), - -sr * Math.sin(t) - ]))[0], point[1]); - } - }; -} - -// Signed angle of a cartesian point relative to [cr, 0, 0]. -function d3_geo_circleAngle(cr, point) { - var a = d3_geo_cartesian(point); - a[0] -= cr; - d3_geo_cartesianNormalize(a); - var angle = d3_acos(-a[1]); - return ((-a[2] < 0 ? -angle : angle) + 2 * Math.PI - ε) % (2 * Math.PI); -} diff --git a/src/geo/clip-antimeridian.js b/src/geo/clip-antimeridian.js deleted file mode 100644 index 144a35d65a42bc..00000000000000 --- a/src/geo/clip-antimeridian.js +++ /dev/null @@ -1,95 +0,0 @@ -import "../core/true"; -import "../math/abs"; -import "../math/trigonometry"; -import "clip"; - -var d3_geo_clipAntimeridian = d3_geo_clip( - d3_true, - d3_geo_clipAntimeridianLine, - d3_geo_clipAntimeridianInterpolate, - [-π, -π / 2]); - -// Takes a line and cuts into visible segments. Return values: -// 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 d3_geo_clipAntimeridianLine(listener) { - var λ0 = NaN, - φ0 = NaN, - sλ0 = NaN, - clean; // no intersections - - return { - lineStart: function() { - listener.lineStart(); - clean = 1; - }, - point: function(λ1, φ1) { - var sλ1 = λ1 > 0 ? π : -π, - dλ = abs(λ1 - λ0); - if (abs(dλ - π) < ε) { // line crosses a pole - listener.point(λ0, φ0 = (φ0 + φ1) / 2 > 0 ? halfπ : -halfπ); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - listener.point(λ1, φ0); - clean = 0; - } else if (sλ0 !== sλ1 && dλ >= π) { // line crosses antimeridian - // handle degeneracies - if (abs(λ0 - sλ0) < ε) λ0 -= sλ0 * ε; - if (abs(λ1 - sλ1) < ε) λ1 -= sλ1 * ε; - φ0 = d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1); - listener.point(sλ0, φ0); - listener.lineEnd(); - listener.lineStart(); - listener.point(sλ1, φ0); - clean = 0; - } - listener.point(λ0 = λ1, φ0 = φ1); - sλ0 = sλ1; - }, - lineEnd: function() { - listener.lineEnd(); - λ0 = φ0 = NaN; - }, - // if there are intersections, we always rejoin the first and last segments. - clean: function() { return 2 - clean; } - }; -} - -function d3_geo_clipAntimeridianIntersect(λ0, φ0, λ1, φ1) { - var cosφ0, - cosφ1, - sinλ0_λ1 = Math.sin(λ0 - λ1); - return abs(sinλ0_λ1) > ε - ? Math.atan((Math.sin(φ0) * (cosφ1 = Math.cos(φ1)) * Math.sin(λ1) - - Math.sin(φ1) * (cosφ0 = Math.cos(φ0)) * Math.sin(λ0)) - / (cosφ0 * cosφ1 * sinλ0_λ1)) - : (φ0 + φ1) / 2; -} - -function d3_geo_clipAntimeridianInterpolate(from, to, direction, listener) { - var φ; - if (from == null) { - φ = direction * halfπ; - listener.point(-π, φ); - listener.point( 0, φ); - listener.point( π, φ); - listener.point( π, 0); - listener.point( π, -φ); - listener.point( 0, -φ); - listener.point(-π, -φ); - listener.point(-π, 0); - listener.point(-π, φ); - } else if (abs(from[0] - to[0]) > ε) { - var s = from[0] < to[0] ? π : -π; - φ = direction * s / 2; - listener.point(-s, φ); - listener.point( 0, φ); - listener.point( s, φ); - } else { - listener.point(to[0], to[1]); - } -} diff --git a/src/geo/clip-circle.js b/src/geo/clip-circle.js deleted file mode 100644 index d204a51a2e092e..00000000000000 --- a/src/geo/clip-circle.js +++ /dev/null @@ -1,178 +0,0 @@ -import "../math/abs"; -import "../math/trigonometry"; -import "cartesian"; -import "clip"; -import "circle"; -import "spherical"; -import "point-in-polygon"; - -// Clip features against a small circle centered at [0°, 0°]. -function d3_geo_clipCircle(radius) { - var cr = Math.cos(radius), - smallRadius = cr > 0, - notHemisphere = abs(cr) > ε, // TODO optimise for this common case - interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); - - return d3_geo_clip(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-π, radius - π]); - - function visible(λ, φ) { - return Math.cos(λ) * Math.cos(φ) > 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(listener) { - 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(λ, φ) { - var point1 = [λ, φ], - point2, - v = visible(λ, φ), - c = smallRadius - ? v ? 0 : code(λ, φ) - : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; - if (!point0 && (v00 = v0 = v)) listener.lineStart(); - // Handle degeneracies. - // TODO ignore if not clipping polygons. - if (v !== v0) { - point2 = intersect(point0, point1); - if (d3_geo_sphericalEqual(point0, point2) || d3_geo_sphericalEqual(point1, point2)) { - point1[0] += ε; - point1[1] += ε; - v = visible(point1[0], point1[1]); - } - } - if (v !== v0) { - clean = 0; - if (v) { - // outside going in - listener.lineStart(); - point2 = intersect(point1, point0); - listener.point(point2[0], point2[1]); - } else { - // inside going out - point2 = intersect(point0, point1); - listener.point(point2[0], point2[1]); - listener.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) { - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - } else { - listener.point(t[1][0], t[1][1]); - listener.lineEnd(); - listener.lineStart(); - listener.point(t[0][0], t[0][1]); - } - } - } - if (v && (!point0 || !d3_geo_sphericalEqual(point0, point1))) { - listener.point(point1[0], point1[1]); - } - point0 = point1, v0 = v, c0 = c; - }, - lineEnd: function() { - if (v0) listener.lineEnd(); - point0 = null; - }, - // 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 = d3_geo_cartesian(a), - pb = d3_geo_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 = d3_geo_cartesianCross(pa, pb), - n2n2 = d3_geo_cartesianDot(n2, n2), - n1n2 = n2[0], // d3_geo_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 = d3_geo_cartesianCross(n1, n2), - A = d3_geo_cartesianScale(n1, c1), - B = d3_geo_cartesianScale(n2, c2); - d3_geo_cartesianAdd(A, B); - - // Solve |p(t)|^2 = 1. - var u = n1xn2, - w = d3_geo_cartesianDot(A, u), - uu = d3_geo_cartesianDot(u, u), - t2 = w * w - uu * (d3_geo_cartesianDot(A, A) - 1); - - if (t2 < 0) return; - - var t = Math.sqrt(t2), - q = d3_geo_cartesianScale(u, (-w - t) / uu); - d3_geo_cartesianAdd(q, A); - q = d3_geo_spherical(q); - if (!two) return q; - - // Two intersection points. - var λ0 = a[0], - λ1 = b[0], - φ0 = a[1], - φ1 = b[1], - z; - if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; - var δλ = λ1 - λ0, - polar = abs(δλ - π) < ε, - meridian = polar || δλ < ε; - - if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; - - // Check that the first point is between a and b. - if (meridian - ? polar - ? φ0 + φ1 > 0 ^ q[1] < (abs(q[0] - λ0) < ε ? φ0 : φ1) - : φ0 <= q[1] && q[1] <= φ1 - : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { - var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); - d3_geo_cartesianAdd(q1, A); - return [q, d3_geo_spherical(q1)]; - } - } - - // Generates a 4-bit vector representing the location of a point relative to - // the small circle's bounding box. - function code(λ, φ) { - var r = smallRadius ? radius : π - radius, - code = 0; - if (λ < -r) code |= 1; // left - else if (λ > r) code |= 2; // right - if (φ < -r) code |= 4; // below - else if (φ > r) code |= 8; // above - return code; - } -} diff --git a/src/geo/clip-extent.js b/src/geo/clip-extent.js deleted file mode 100644 index cc69dd0fcf0e2d..00000000000000 --- a/src/geo/clip-extent.js +++ /dev/null @@ -1,196 +0,0 @@ -import "../arrays/merge"; -import "../math/abs"; -import "../math/trigonometry"; -import "../geom/clip-line"; -import "geo"; -import "clip"; -import "clip-polygon"; - -var d3_geo_clipExtentMAX = 1e9; - -d3.geo.clipExtent = function() { - var x0, y0, x1, y1, - stream, - clip, - clipExtent = { - stream: function(output) { - if (stream) stream.valid = false; - stream = clip(output); - stream.valid = true; // allow caching by d3.geo.path - return stream; - }, - extent: function(_) { - if (!arguments.length) return [[x0, y0], [x1, y1]]; - clip = d3_geo_clipExtent(x0 = +_[0][0], y0 = +_[0][1], x1 = +_[1][0], y1 = +_[1][1]); - if (stream) stream.valid = false, stream = null; - return clipExtent; - } - }; - return clipExtent.extent([[0, 0], [960, 500]]); -}; - -function d3_geo_clipExtent(x0, y0, x1, y1) { - return function(listener) { - var listener_ = listener, - bufferListener = d3_geo_clipBufferListener(), - clipLine = d3_geom_clipLine(x0, y0, x1, y1), - segments, - polygon, - ring; - - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - listener = bufferListener; - segments = []; - polygon = []; - clean = true; - }, - polygonEnd: function() { - listener = listener_; - segments = d3.merge(segments); - var clipStartInside = insidePolygon([x0, y1]), - inside = clean && clipStartInside, - visible = segments.length; - if (inside || visible) { - listener.polygonStart(); - if (inside) { - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - } - if (visible) { - d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener); - } - listener.polygonEnd(); - } - segments = polygon = ring = null; - } - }; - - function insidePolygon(p) { - var wn = 0, // the winding number counter - n = polygon.length, - y = p[1]; - - for (var i = 0; i < n; ++i) { - for (var j = 1, v = polygon[i], m = v.length, a = v[0], b; j < m; ++j) { - b = v[j]; - if (a[1] <= y) { - if (b[1] > y && d3_cross2d(a, b, p) > 0) ++wn; - } else { - if (b[1] <= y && d3_cross2d(a, b, p) < 0) --wn; - } - a = b; - } - } - return wn !== 0; - } - - function interpolate(from, to, direction, listener) { - var a = 0, a1 = 0; - if (from == null || - (a = corner(from, direction)) !== (a1 = corner(to, direction)) || - comparePoints(from, to) < 0 ^ direction > 0) { - do { - listener.point(a === 0 || a === 3 ? x0 : x1, a > 1 ? y1 : y0); - } while ((a = (a + direction + 4) % 4) !== a1); - } else { - listener.point(to[0], to[1]); - } - } - - function pointVisible(x, y) { - return x0 <= x && x <= x1 && y0 <= y && y <= y1; - } - - function point(x, y) { - if (pointVisible(x, y)) listener.point(x, y); - } - - var x__, y__, v__, // first point - x_, y_, v_, // previous point - first, - clean; - - function lineStart() { - clip.point = linePoint; - if (polygon) polygon.push(ring = []); - first = true; - v_ = false; - x_ = y_ = NaN; - } - - function lineEnd() { - // TODO rather than special-case polygons, simply handle them separately. - // Ideally, coincident intersection points should be jittered to avoid - // clipping issues. - if (segments) { - linePoint(x__, y__); - if (v__ && v_) bufferListener.rejoin(); - segments.push(bufferListener.buffer()); - } - clip.point = point; - if (v_) listener.lineEnd(); - } - - function linePoint(x, y) { - x = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, x)); - y = Math.max(-d3_geo_clipExtentMAX, Math.min(d3_geo_clipExtentMAX, y)); - var v = pointVisible(x, y); - if (polygon) ring.push([x, y]); - if (first) { - x__ = x, y__ = y, v__ = v; - first = false; - if (v) { - listener.lineStart(); - listener.point(x, y); - } - } else { - if (v && v_) listener.point(x, y); - else { - var l = {a: {x: x_, y: y_}, b: {x: x, y: y}}; - if (clipLine(l)) { - if (!v_) { - listener.lineStart(); - listener.point(l.a.x, l.a.y); - } - listener.point(l.b.x, l.b.y); - if (!v) listener.lineEnd(); - clean = false; - } else if (v) { - listener.lineStart(); - listener.point(x, y); - clean = false; - } - } - } - x_ = x, y_ = y, v_ = v; - } - - return clip; - }; - - function corner(p, direction) { - return abs(p[0] - x0) < ε ? direction > 0 ? 0 : 3 - : abs(p[0] - x1) < ε ? direction > 0 ? 2 : 1 - : abs(p[1] - y0) < ε ? direction > 0 ? 1 : 0 - : direction > 0 ? 3 : 2; // abs(p[1] - y1) < ε - } - - function compare(a, b) { - return comparePoints(a.x, b.x); - } - - function comparePoints(a, b) { - var ca = corner(a, 1), - cb = corner(b, 1); - return ca !== cb ? ca - cb - : ca === 0 ? b[1] - a[1] - : ca === 1 ? a[0] - b[0] - : ca === 2 ? a[1] - b[1] - : b[0] - a[0]; - } -} diff --git a/src/geo/clip-polygon.js b/src/geo/clip-polygon.js deleted file mode 100644 index 4dd960c6408da6..00000000000000 --- a/src/geo/clip-polygon.js +++ /dev/null @@ -1,104 +0,0 @@ -import "../math/trigonometry"; -import "spherical"; - -// General spherical polygon clipping algorithm: takes a polygon, cuts it into -// visible line segments and rejoins the segments by interpolating along the -// clip edge. -function d3_geo_clipPolygon(segments, compare, clipStartInside, interpolate, listener) { - var subject = [], - clip = []; - - segments.forEach(function(segment) { - if ((n = segment.length - 1) <= 0) return; - var n, p0 = segment[0], p1 = segment[n]; - - // If the first and last points of a segment are coincident, then treat as - // a closed ring. - // TODO if all rings are closed, then the winding order of the exterior - // ring should be checked. - if (d3_geo_sphericalEqual(p0, p1)) { - listener.lineStart(); - for (var i = 0; i < n; ++i) listener.point((p0 = segment[i])[0], p0[1]); - listener.lineEnd(); - return; - } - - var a = new d3_geo_clipPolygonIntersection(p0, segment, null, true), - b = new d3_geo_clipPolygonIntersection(p0, null, a, false); - a.o = b; - subject.push(a); - clip.push(b); - a = new d3_geo_clipPolygonIntersection(p1, segment, null, false); - b = new d3_geo_clipPolygonIntersection(p1, null, a, true); - a.o = b; - subject.push(a); - clip.push(b); - }); - clip.sort(compare); - d3_geo_clipPolygonLinkCircular(subject); - d3_geo_clipPolygonLinkCircular(clip); - if (!subject.length) return; - - for (var i = 0, entry = clipStartInside, n = clip.length; i < n; ++i) { - clip[i].e = entry = !entry; - } - - var start = subject[0], - points, - point; - while (1) { - // Find first unvisited intersection. - var current = start, - isSubject = true; - while (current.v) if ((current = current.n) === start) return; - points = current.z; - listener.lineStart(); - do { - current.v = current.o.v = true; - if (current.e) { - if (isSubject) { - for (var i = 0, n = points.length; i < n; ++i) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.x, current.n.x, 1, listener); - } - current = current.n; - } else { - if (isSubject) { - points = current.p.z; - for (var i = points.length - 1; i >= 0; --i) listener.point((point = points[i])[0], point[1]); - } else { - interpolate(current.x, current.p.x, -1, listener); - } - current = current.p; - } - current = current.o; - points = current.z; - isSubject = !isSubject; - } while (!current.v); - listener.lineEnd(); - } -} - -function d3_geo_clipPolygonLinkCircular(array) { - if (!(n = array.length)) return; - var n, - i = 0, - a = array[0], - b; - while (++i < n) { - a.n = b = array[i]; - b.p = a; - a = b; - } - a.n = b = array[0]; - b.p = a; -} - -function d3_geo_clipPolygonIntersection(point, points, other, entry) { - this.x = point; - this.z = points; - this.o = other; // another intersection - this.e = entry; // is an entry? - this.v = false; // visited - this.n = this.p = null; // next & previous -} diff --git a/src/geo/clip.js b/src/geo/clip.js deleted file mode 100644 index 9c54214e6bc15f..00000000000000 --- a/src/geo/clip.js +++ /dev/null @@ -1,149 +0,0 @@ -import "../arrays/merge"; -import "../core/noop"; -import "../math/trigonometry"; -import "clip-polygon"; - -function d3_geo_clip(pointVisible, clipLine, interpolate, clipStart) { - return function(rotate, listener) { - var line = clipLine(listener), - rotatedClipStart = rotate.invert(clipStart[0], clipStart[1]); - - var clip = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { - clip.point = pointRing; - clip.lineStart = ringStart; - clip.lineEnd = ringEnd; - segments = []; - polygon = []; - }, - polygonEnd: function() { - clip.point = point; - clip.lineStart = lineStart; - clip.lineEnd = lineEnd; - - segments = d3.merge(segments); - var clipStartInside = d3_geo_pointInPolygon(rotatedClipStart, polygon); - if (segments.length) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; - d3_geo_clipPolygon(segments, d3_geo_clipSort, clipStartInside, interpolate, listener); - } else if (clipStartInside) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - } - if (polygonStarted) listener.polygonEnd(), polygonStarted = false; - segments = polygon = null; - }, - sphere: function() { - listener.polygonStart(); - listener.lineStart(); - interpolate(null, null, 1, listener); - listener.lineEnd(); - listener.polygonEnd(); - } - }; - - function point(λ, φ) { - var point = rotate(λ, φ); - if (pointVisible(λ = point[0], φ = point[1])) listener.point(λ, φ); - } - function pointLine(λ, φ) { - var point = rotate(λ, φ); - line.point(point[0], point[1]); - } - function lineStart() { clip.point = pointLine; line.lineStart(); } - function lineEnd() { clip.point = point; line.lineEnd(); } - - var segments; - - var buffer = d3_geo_clipBufferListener(), - ringListener = clipLine(buffer), - polygonStarted = false, - polygon, - ring; - - function pointRing(λ, φ) { - ring.push([λ, φ]); - var point = rotate(λ, φ); - ringListener.point(point[0], point[1]); - } - - function ringStart() { - ringListener.lineStart(); - ring = []; - } - - function ringEnd() { - pointRing(ring[0][0], ring[0][1]); - ringListener.lineEnd(); - - var clean = ringListener.clean(), - ringSegments = buffer.buffer(), - segment, - n = ringSegments.length; - - ring.pop(); - polygon.push(ring); - ring = null; - - if (!n) return; - - // No intersections. - if (clean & 1) { - segment = ringSegments[0]; - var n = segment.length - 1, - i = -1, - point; - if (n > 0) { - if (!polygonStarted) listener.polygonStart(), polygonStarted = true; - listener.lineStart(); - while (++i < n) listener.point((point = segment[i])[0], point[1]); - listener.lineEnd(); - } - return; - } - - // Rejoin connected segments. - // TODO reuse bufferListener.rejoin()? - if (n > 1 && clean & 2) ringSegments.push(ringSegments.pop().concat(ringSegments.shift())); - - segments.push(ringSegments.filter(d3_geo_clipSegmentLength1)); - } - - return clip; - }; -} - -function d3_geo_clipSegmentLength1(segment) { - return segment.length > 1; -} - -function d3_geo_clipBufferListener() { - var lines = [], - line; - return { - lineStart: function() { lines.push(line = []); }, - point: function(λ, φ) { line.push([λ, φ]); }, - lineEnd: d3_noop, - buffer: function() { - var buffer = lines; - lines = []; - line = null; - return buffer; - }, - rejoin: function() { - if (lines.length > 1) lines.push(lines.pop().concat(lines.shift())); - } - }; -} - -// Intersection points are sorted along the clip edge. For both antimeridian -// cutting and circle clipping, the same comparison is used. -function d3_geo_clipSort(a, b) { - return ((a = a.x)[0] < 0 ? a[1] - halfπ - ε : halfπ - a[1]) - - ((b = b.x)[0] < 0 ? b[1] - halfπ - ε : halfπ - b[1]); -} diff --git a/src/geo/compose.js b/src/geo/compose.js deleted file mode 100644 index fe374ef820eeeb..00000000000000 --- a/src/geo/compose.js +++ /dev/null @@ -1,12 +0,0 @@ -function d3_geo_compose(a, b) { - - function compose(x, y) { - return x = a(x, y), b(x[0], x[1]); - } - - if (a.invert && b.invert) compose.invert = function(x, y) { - return x = b.invert(x, y), x && a.invert(x[0], x[1]); - }; - - return compose; -} diff --git a/src/geo/conic-conformal.js b/src/geo/conic-conformal.js deleted file mode 100644 index 80023221c7be0f..00000000000000 --- a/src/geo/conic-conformal.js +++ /dev/null @@ -1,39 +0,0 @@ -import "../math/abs"; -import "../math/trigonometry"; -import "conic"; -import "geo"; -import "projection"; - -function d3_geo_conicConformal(φ0, φ1) { - var cosφ0 = Math.cos(φ0), - t = function(φ) { return Math.tan(π / 4 + φ / 2); }, - n = φ0 === φ1 ? Math.sin(φ0) : Math.log(cosφ0 / Math.cos(φ1)) / Math.log(t(φ1) / t(φ0)), - F = cosφ0 * Math.pow(t(φ0), n) / n; - - if (!n) return d3_geo_mercator; - - function forward(λ, φ) { - if (F > 0) { if (φ < -halfπ + ε) φ = -halfπ + ε; } - else { if (φ > halfπ - ε) φ = halfπ - ε; } - var ρ = F / Math.pow(t(φ), n); - return [ - ρ * Math.sin(n * λ), - F - ρ * Math.cos(n * λ) - ]; - } - - forward.invert = function(x, y) { - var ρ0_y = F - y, - ρ = d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y); - return [ - Math.atan2(x, ρ0_y) / n, - 2 * Math.atan(Math.pow(F / ρ, 1 / n)) - halfπ - ]; - }; - - return forward; -} - -(d3.geo.conicConformal = function() { - return d3_geo_conic(d3_geo_conicConformal); -}).raw = d3_geo_conicConformal; diff --git a/src/geo/conic-equal-area.js b/src/geo/conic-equal-area.js deleted file mode 100644 index 7ccfb32ebbe44d..00000000000000 --- a/src/geo/conic-equal-area.js +++ /dev/null @@ -1,33 +0,0 @@ -import "../math/trigonometry"; -import "geo"; -import "conic"; -import "projection"; - -function d3_geo_conicEqualArea(φ0, φ1) { - var sinφ0 = Math.sin(φ0), - n = (sinφ0 + Math.sin(φ1)) / 2, - C = 1 + sinφ0 * (2 * n - sinφ0), - ρ0 = Math.sqrt(C) / n; - - function forward(λ, φ) { - var ρ = Math.sqrt(C - 2 * n * Math.sin(φ)) / n; - return [ - ρ * Math.sin(λ *= n), - ρ0 - ρ * Math.cos(λ) - ]; - } - - forward.invert = function(x, y) { - var ρ0_y = ρ0 - y; - return [ - Math.atan2(x, ρ0_y) / n, - d3_asin((C - (x * x + ρ0_y * ρ0_y) * n * n) / (2 * n)) - ]; - }; - - return forward; -} - -(d3.geo.conicEqualArea = function() { - return d3_geo_conic(d3_geo_conicEqualArea); -}).raw = d3_geo_conicEqualArea; diff --git a/src/geo/conic-equidistant.js b/src/geo/conic-equidistant.js deleted file mode 100644 index 24935b0e7d633a..00000000000000 --- a/src/geo/conic-equidistant.js +++ /dev/null @@ -1,36 +0,0 @@ -import "../math/abs"; -import "../math/trigonometry"; -import "conic"; -import "equirectangular"; -import "geo"; -import "projection"; - -function d3_geo_conicEquidistant(φ0, φ1) { - var cosφ0 = Math.cos(φ0), - n = φ0 === φ1 ? Math.sin(φ0) : (cosφ0 - Math.cos(φ1)) / (φ1 - φ0), - G = cosφ0 / n + φ0; - - if (abs(n) < ε) return d3_geo_equirectangular; - - function forward(λ, φ) { - var ρ = G - φ; - return [ - ρ * Math.sin(n * λ), - G - ρ * Math.cos(n * λ) - ]; - } - - forward.invert = function(x, y) { - var ρ0_y = G - y; - return [ - Math.atan2(x, ρ0_y) / n, - G - d3_sgn(n) * Math.sqrt(x * x + ρ0_y * ρ0_y) - ]; - }; - - return forward; -} - -(d3.geo.conicEquidistant = function() { - return d3_geo_conic(d3_geo_conicEquidistant); -}).raw = d3_geo_conicEquidistant; diff --git a/src/geo/conic.js b/src/geo/conic.js deleted file mode 100644 index 8377ec5bbeb977..00000000000000 --- a/src/geo/conic.js +++ /dev/null @@ -1,16 +0,0 @@ -import "../math/trigonometry"; -import "projection"; - -function d3_geo_conic(projectAt) { - var φ0 = 0, - φ1 = π / 3, - m = d3_geo_projectionMutator(projectAt), - p = m(φ0, φ1); - - p.parallels = function(_) { - if (!arguments.length) return [φ0 / π * 180, φ1 / π * 180]; - return m(φ0 = _[0] * π / 180, φ1 = _[1] * π / 180); - }; - - return p; -} diff --git a/src/geo/distance.js b/src/geo/distance.js deleted file mode 100644 index 805dda7b0e0dea..00000000000000 --- a/src/geo/distance.js +++ /dev/null @@ -1,13 +0,0 @@ -import "../math/trigonometry"; -import "geo"; - -// Length returned in radians; multiply by radius for distance. -d3.geo.distance = function(a, b) { - var Δλ = (b[0] - a[0]) * d3_radians, - φ0 = a[1] * d3_radians, φ1 = b[1] * d3_radians, - sinΔλ = Math.sin(Δλ), cosΔλ = Math.cos(Δλ), - sinφ0 = Math.sin(φ0), cosφ0 = Math.cos(φ0), - sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1), - t; - return Math.atan2(Math.sqrt((t = cosφ1 * sinΔλ) * t + (t = cosφ0 * sinφ1 - sinφ0 * cosφ1 * cosΔλ) * t), sinφ0 * sinφ1 + cosφ0 * cosφ1 * cosΔλ); -}; diff --git a/src/geo/equirectangular.js b/src/geo/equirectangular.js deleted file mode 100644 index eb9cfe08ba7029..00000000000000 --- a/src/geo/equirectangular.js +++ /dev/null @@ -1,10 +0,0 @@ -import "geo"; -import "projection"; - -function d3_geo_equirectangular(λ, φ) { - return [λ, φ]; -} - -(d3.geo.equirectangular = function() { - return d3_geo_projection(d3_geo_equirectangular); -}).raw = d3_geo_equirectangular.invert = d3_geo_equirectangular; diff --git a/src/geo/geo.js b/src/geo/geo.js deleted file mode 100644 index cf220ceb04e6a7..00000000000000 --- a/src/geo/geo.js +++ /dev/null @@ -1 +0,0 @@ -d3.geo = {}; diff --git a/src/geo/gnomonic.js b/src/geo/gnomonic.js deleted file mode 100644 index 8878ad810c7b61..00000000000000 --- a/src/geo/gnomonic.js +++ /dev/null @@ -1,12 +0,0 @@ -import "azimuthal"; -import "geo"; -import "projection"; - -var d3_geo_gnomonic = d3_geo_azimuthal( - function(cosλcosφ) { return 1 / cosλcosφ; }, - Math.atan -); - -(d3.geo.gnomonic = function() { - return d3_geo_projection(d3_geo_gnomonic); -}).raw = d3_geo_gnomonic; diff --git a/src/geo/graticule.js b/src/geo/graticule.js deleted file mode 100644 index 2522059e5eb732..00000000000000 --- a/src/geo/graticule.js +++ /dev/null @@ -1,103 +0,0 @@ -import "../arrays/range"; -import "../math/abs"; -import "../math/trigonometry"; -import "geo"; - -d3.geo.graticule = function() { - var x1, x0, X1, X0, - y1, y0, Y1, Y0, - dx = 10, dy = dx, DX = 90, DY = 360, - x, y, X, Y, - precision = 2.5; - - function graticule() { - return {type: "MultiLineString", coordinates: lines()}; - } - - function lines() { - return d3.range(Math.ceil(X0 / DX) * DX, X1, DX).map(X) - .concat(d3.range(Math.ceil(Y0 / DY) * DY, Y1, DY).map(Y)) - .concat(d3.range(Math.ceil(x0 / dx) * dx, x1, dx).filter(function(x) { return abs(x % DX) > ε; }).map(x)) - .concat(d3.range(Math.ceil(y0 / dy) * dy, y1, dy).filter(function(y) { return abs(y % DY) > ε; }).map(y)); - } - - graticule.lines = function() { - return lines().map(function(coordinates) { return {type: "LineString", coordinates: coordinates}; }); - }; - - graticule.outline = function() { - return { - type: "Polygon", - coordinates: [ - X(X0).concat( - Y(Y1).slice(1), - X(X1).reverse().slice(1), - Y(Y0).reverse().slice(1)) - ] - }; - }; - - graticule.extent = function(_) { - if (!arguments.length) return graticule.minorExtent(); - return graticule.majorExtent(_).minorExtent(_); - }; - - graticule.majorExtent = function(_) { - if (!arguments.length) return [[X0, Y0], [X1, Y1]]; - X0 = +_[0][0], X1 = +_[1][0]; - Y0 = +_[0][1], Y1 = +_[1][1]; - if (X0 > X1) _ = X0, X0 = X1, X1 = _; - if (Y0 > Y1) _ = Y0, Y0 = Y1, Y1 = _; - return graticule.precision(precision); - }; - - graticule.minorExtent = function(_) { - if (!arguments.length) return [[x0, y0], [x1, y1]]; - x0 = +_[0][0], x1 = +_[1][0]; - y0 = +_[0][1], y1 = +_[1][1]; - if (x0 > x1) _ = x0, x0 = x1, x1 = _; - if (y0 > y1) _ = y0, y0 = y1, y1 = _; - return graticule.precision(precision); - }; - - graticule.step = function(_) { - if (!arguments.length) return graticule.minorStep(); - return graticule.majorStep(_).minorStep(_); - }; - - graticule.majorStep = function(_) { - if (!arguments.length) return [DX, DY]; - DX = +_[0], DY = +_[1]; - return graticule; - }; - - graticule.minorStep = function(_) { - if (!arguments.length) return [dx, dy]; - dx = +_[0], dy = +_[1]; - return graticule; - }; - - graticule.precision = function(_) { - if (!arguments.length) return precision; - precision = +_; - x = d3_geo_graticuleX(y0, y1, 90); - y = d3_geo_graticuleY(x0, x1, precision); - X = d3_geo_graticuleX(Y0, Y1, 90); - Y = d3_geo_graticuleY(X0, X1, precision); - return graticule; - }; - - return graticule - .majorExtent([[-180, -90 + ε], [180, 90 - ε]]) - .minorExtent([[-180, -80 - ε], [180, 80 + ε]]); -}; - -function d3_geo_graticuleX(y0, y1, dy) { - var y = d3.range(y0, y1 - ε, dy).concat(y1); - return function(x) { return y.map(function(y) { return [x, y]; }); }; -} - -function d3_geo_graticuleY(x0, x1, dx) { - var x = d3.range(x0, x1 - ε, dx).concat(x1); - return function(y) { return x.map(function(x) { return [x, y]; }); }; -} diff --git a/src/geo/greatArc.js b/src/geo/greatArc.js deleted file mode 100644 index a60a4888896915..00000000000000 --- a/src/geo/greatArc.js +++ /dev/null @@ -1,42 +0,0 @@ -import "../core/source"; -import "../core/target"; -import "geo"; -import "distance"; - -// @deprecated use {type: "LineString"} or d3.geo.distance instead. -d3.geo.greatArc = function() { - var source = d3_source, source_, - target = d3_target, target_; - - function greatArc() { - return {type: "LineString", coordinates: [ - source_ || source.apply(this, arguments), - target_ || target.apply(this, arguments) - ]}; - } - - greatArc.distance = function() { - return d3.geo.distance( - source_ || source.apply(this, arguments), - target_ || target.apply(this, arguments) - ); - }; - - greatArc.source = function(_) { - if (!arguments.length) return source; - source = _, source_ = typeof _ === "function" ? null : _; - return greatArc; - }; - - greatArc.target = function(_) { - if (!arguments.length) return target; - target = _, target_ = typeof _ === "function" ? null : _; - return greatArc; - }; - - greatArc.precision = function() { - return arguments.length ? greatArc : 0; - }; - - return greatArc; -}; diff --git a/src/geo/index.js b/src/geo/index.js deleted file mode 100644 index c95f341623bfe0..00000000000000 --- a/src/geo/index.js +++ /dev/null @@ -1,33 +0,0 @@ -import "geo"; -import "area"; -import "bounds"; -import "centroid"; -import "circle"; -import "distance"; -import "graticule"; -import "greatArc"; -import "interpolate"; -import "length"; -import "path"; -import "path-area"; -import "path-buffer"; -import "path-centroid"; -import "path-context"; -import "projection"; -import "rotation"; -import "stream"; -import "transform"; -import "albers"; -import "albers-usa"; -import "azimuthal"; -import "azimuthal-equal-area"; -import "azimuthal-equidistant"; -import "conic-conformal"; -import "conic-equal-area"; -import "conic-equidistant"; -import "equirectangular"; -import "gnomonic"; -import "mercator"; -import "orthographic"; -import "stereographic"; -import "transverse-mercator"; diff --git a/src/geo/interpolate.js b/src/geo/interpolate.js deleted file mode 100644 index dba105baa0e9ee..00000000000000 --- a/src/geo/interpolate.js +++ /dev/null @@ -1,38 +0,0 @@ -import "../math/trigonometry"; -import "geo"; - -d3.geo.interpolate = function(source, target) { - return d3_geo_interpolate( - source[0] * d3_radians, source[1] * d3_radians, - target[0] * d3_radians, target[1] * d3_radians - ); -}; - -function d3_geo_interpolate(x0, y0, x1, y1) { - var cy0 = Math.cos(y0), - sy0 = Math.sin(y0), - cy1 = Math.cos(y1), - sy1 = Math.sin(y1), - kx0 = cy0 * Math.cos(x0), - ky0 = cy0 * Math.sin(x0), - kx1 = cy1 * Math.cos(x1), - ky1 = cy1 * Math.sin(x1), - d = 2 * Math.asin(Math.sqrt(d3_haversin(y1 - y0) + cy0 * cy1 * d3_haversin(x1 - x0))), - k = 1 / Math.sin(d); - - var interpolate = d ? function(t) { - var B = Math.sin(t *= d) * k, - A = Math.sin(d - t) * k, - x = A * kx0 + B * kx1, - y = A * ky0 + B * ky1, - z = A * sy0 + B * sy1; - return [ - Math.atan2(y, x) * d3_degrees, - Math.atan2(z, Math.sqrt(x * x + y * y)) * d3_degrees - ]; - } : function() { return [x0 * d3_degrees, y0 * d3_degrees]; }; - - interpolate.distance = d; - - return interpolate; -}; diff --git a/src/geo/length.js b/src/geo/length.js deleted file mode 100644 index d977d040704aff..00000000000000 --- a/src/geo/length.js +++ /dev/null @@ -1,44 +0,0 @@ -import "../core/noop"; -import "../math/abs"; -import "../math/trigonometry"; -import "geo"; -import "stream"; - -d3.geo.length = function(object) { - d3_geo_lengthSum = 0; - d3.geo.stream(object, d3_geo_length); - return d3_geo_lengthSum; -}; - -var d3_geo_lengthSum; - -var d3_geo_length = { - sphere: d3_noop, - point: d3_noop, - lineStart: d3_geo_lengthLineStart, - lineEnd: d3_noop, - polygonStart: d3_noop, - polygonEnd: d3_noop -}; - -function d3_geo_lengthLineStart() { - var λ0, sinφ0, cosφ0; - - d3_geo_length.point = function(λ, φ) { - λ0 = λ * d3_radians, sinφ0 = Math.sin(φ *= d3_radians), cosφ0 = Math.cos(φ); - d3_geo_length.point = nextPoint; - }; - - d3_geo_length.lineEnd = function() { - d3_geo_length.point = d3_geo_length.lineEnd = d3_noop; - }; - - function nextPoint(λ, φ) { - var sinφ = Math.sin(φ *= d3_radians), - cosφ = Math.cos(φ), - t = abs((λ *= d3_radians) - λ0), - cosΔλ = Math.cos(t); - d3_geo_lengthSum += Math.atan2(Math.sqrt((t = cosφ * Math.sin(t)) * t + (t = cosφ0 * sinφ - sinφ0 * cosφ * cosΔλ) * t), sinφ0 * sinφ + cosφ0 * cosφ * cosΔλ); - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ; - } -} diff --git a/src/geo/mercator.js b/src/geo/mercator.js deleted file mode 100644 index 7eb824d2a0156e..00000000000000 --- a/src/geo/mercator.js +++ /dev/null @@ -1,48 +0,0 @@ -import "../math/trigonometry"; -import "geo"; -import "projection"; - -function d3_geo_mercator(λ, φ) { - return [λ, Math.log(Math.tan(π / 4 + φ / 2))]; -} - -d3_geo_mercator.invert = function(x, y) { - return [x, 2 * Math.atan(Math.exp(y)) - halfπ]; -}; - -function d3_geo_mercatorProjection(project) { - var m = d3_geo_projection(project), - scale = m.scale, - translate = m.translate, - clipExtent = m.clipExtent, - clipAuto; - - m.scale = function() { - var v = scale.apply(m, arguments); - return v === m ? (clipAuto ? m.clipExtent(null) : m) : v; - }; - - m.translate = function() { - var v = translate.apply(m, arguments); - return v === m ? (clipAuto ? m.clipExtent(null) : m) : v; - }; - - m.clipExtent = function(_) { - var v = clipExtent.apply(m, arguments); - if (v === m) { - if (clipAuto = _ == null) { - var k = π * scale(), t = translate(); - clipExtent([[t[0] - k, t[1] - k], [t[0] + k, t[1] + k]]); - } - } else if (clipAuto) { - v = null; - } - return v; - }; - - return m.clipExtent(null); -} - -(d3.geo.mercator = function() { - return d3_geo_mercatorProjection(d3_geo_mercator); -}).raw = d3_geo_mercator; diff --git a/src/geo/orthographic.js b/src/geo/orthographic.js deleted file mode 100644 index f51b500634fdc1..00000000000000 --- a/src/geo/orthographic.js +++ /dev/null @@ -1,12 +0,0 @@ -import "azimuthal"; -import "geo"; -import "projection"; - -var d3_geo_orthographic = d3_geo_azimuthal( - function() { return 1; }, - Math.asin -); - -(d3.geo.orthographic = function() { - return d3_geo_projection(d3_geo_orthographic); -}).raw = d3_geo_orthographic; diff --git a/src/geo/path-area.js b/src/geo/path-area.js deleted file mode 100644 index 53b10e118a37c0..00000000000000 --- a/src/geo/path-area.js +++ /dev/null @@ -1,41 +0,0 @@ -import "../core/noop"; -import "../math/abs"; - -// TODO Unify this code with d3.geom.polygon area? - -var d3_geo_pathAreaSum, d3_geo_pathAreaPolygon, d3_geo_pathArea = { - point: d3_noop, - lineStart: d3_noop, - lineEnd: d3_noop, - - // Only count area for polygon rings. - polygonStart: function() { - d3_geo_pathAreaPolygon = 0; - d3_geo_pathArea.lineStart = d3_geo_pathAreaRingStart; - }, - polygonEnd: function() { - d3_geo_pathArea.lineStart = d3_geo_pathArea.lineEnd = d3_geo_pathArea.point = d3_noop; - d3_geo_pathAreaSum += abs(d3_geo_pathAreaPolygon / 2); - } -}; - -function d3_geo_pathAreaRingStart() { - var x00, y00, x0, y0; - - // For the first point, … - d3_geo_pathArea.point = function(x, y) { - d3_geo_pathArea.point = nextPoint; - x00 = x0 = x, y00 = y0 = y; - }; - - // For subsequent points, … - function nextPoint(x, y) { - d3_geo_pathAreaPolygon += y0 * x - x0 * y; - x0 = x, y0 = y; - } - - // For the last point, return to the start. - d3_geo_pathArea.lineEnd = function() { - nextPoint(x00, y00); - }; -} diff --git a/src/geo/path-bounds.js b/src/geo/path-bounds.js deleted file mode 100644 index 53c7a06b1676eb..00000000000000 --- a/src/geo/path-bounds.js +++ /dev/null @@ -1,21 +0,0 @@ -import "../core/noop"; - -var d3_geo_pathBoundsX0, - d3_geo_pathBoundsY0, - d3_geo_pathBoundsX1, - d3_geo_pathBoundsY1; - -var d3_geo_pathBounds = { - point: d3_geo_pathBoundsPoint, - lineStart: d3_noop, - lineEnd: d3_noop, - polygonStart: d3_noop, - polygonEnd: d3_noop -}; - -function d3_geo_pathBoundsPoint(x, y) { - if (x < d3_geo_pathBoundsX0) d3_geo_pathBoundsX0 = x; - if (x > d3_geo_pathBoundsX1) d3_geo_pathBoundsX1 = x; - if (y < d3_geo_pathBoundsY0) d3_geo_pathBoundsY0 = y; - if (y > d3_geo_pathBoundsY1) d3_geo_pathBoundsY1 = y; -} diff --git a/src/geo/path-buffer.js b/src/geo/path-buffer.js deleted file mode 100644 index d14a2fb2caa6b7..00000000000000 --- a/src/geo/path-buffer.js +++ /dev/null @@ -1,59 +0,0 @@ -function d3_geo_pathBuffer() { - var pointCircle = d3_geo_pathBufferCircle(4.5), - buffer = []; - - var stream = { - point: point, - - // While inside a line, override point to moveTo then lineTo. - lineStart: function() { stream.point = pointLineStart; }, - lineEnd: lineEnd, - - // While inside a polygon, override lineEnd to closePath. - polygonStart: function() { stream.lineEnd = lineEndPolygon; }, - polygonEnd: function() { stream.lineEnd = lineEnd; stream.point = point; }, - - pointRadius: function(_) { - pointCircle = d3_geo_pathBufferCircle(_); - return stream; - }, - - result: function() { - if (buffer.length) { - var result = buffer.join(""); - buffer = []; - return result; - } - } - }; - - function point(x, y) { - buffer.push("M", x, ",", y, pointCircle); - } - - function pointLineStart(x, y) { - buffer.push("M", x, ",", y); - stream.point = pointLine; - } - - function pointLine(x, y) { - buffer.push("L", x, ",", y); - } - - function lineEnd() { - stream.point = point; - } - - function lineEndPolygon() { - buffer.push("Z"); - } - - return stream; -} - -function d3_geo_pathBufferCircle(radius) { - return "m0," + radius - + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius - + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius - + "z"; -} diff --git a/src/geo/path-centroid.js b/src/geo/path-centroid.js deleted file mode 100644 index cda5897090efda..00000000000000 --- a/src/geo/path-centroid.js +++ /dev/null @@ -1,78 +0,0 @@ -import "centroid"; - -// TODO Unify this code with d3.geom.polygon centroid? -// TODO Enforce positive area for exterior, negative area for interior? - -var d3_geo_pathCentroid = { - point: d3_geo_pathCentroidPoint, - - // For lines, weight by length. - lineStart: d3_geo_pathCentroidLineStart, - lineEnd: d3_geo_pathCentroidLineEnd, - - // For polygons, weight by area. - polygonStart: function() { - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidRingStart; - }, - polygonEnd: function() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; - d3_geo_pathCentroid.lineStart = d3_geo_pathCentroidLineStart; - d3_geo_pathCentroid.lineEnd = d3_geo_pathCentroidLineEnd; - } -}; - -function d3_geo_pathCentroidPoint(x, y) { - d3_geo_centroidX0 += x; - d3_geo_centroidY0 += y; - ++d3_geo_centroidZ0; -} - -function d3_geo_pathCentroidLineStart() { - var x0, y0; - - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - }; - - function nextPoint(x, y) { - var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); - d3_geo_centroidX1 += z * (x0 + x) / 2; - d3_geo_centroidY1 += z * (y0 + y) / 2; - d3_geo_centroidZ1 += z; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - } -} - -function d3_geo_pathCentroidLineEnd() { - d3_geo_pathCentroid.point = d3_geo_pathCentroidPoint; -} - -function d3_geo_pathCentroidRingStart() { - var x00, y00, x0, y0; - - // For the first point, … - d3_geo_pathCentroid.point = function(x, y) { - d3_geo_pathCentroid.point = nextPoint; - d3_geo_pathCentroidPoint(x00 = x0 = x, y00 = y0 = y); - }; - - // For subsequent points, … - function nextPoint(x, y) { - var dx = x - x0, dy = y - y0, z = Math.sqrt(dx * dx + dy * dy); - d3_geo_centroidX1 += z * (x0 + x) / 2; - d3_geo_centroidY1 += z * (y0 + y) / 2; - d3_geo_centroidZ1 += z; - - z = y0 * x - x0 * y; - d3_geo_centroidX2 += z * (x0 + x); - d3_geo_centroidY2 += z * (y0 + y); - d3_geo_centroidZ2 += z * 3; - d3_geo_pathCentroidPoint(x0 = x, y0 = y); - } - - // For the last point, return to the start. - d3_geo_pathCentroid.lineEnd = function() { - nextPoint(x00, y00); - }; -} diff --git a/src/geo/path-context.js b/src/geo/path-context.js deleted file mode 100644 index d92086c484dfe4..00000000000000 --- a/src/geo/path-context.js +++ /dev/null @@ -1,49 +0,0 @@ -import "../core/noop"; -import "../math/trigonometry"; - -function d3_geo_pathContext(context) { - var pointRadius = 4.5; - - var stream = { - point: point, - - // While inside a line, override point to moveTo then lineTo. - lineStart: function() { stream.point = pointLineStart; }, - lineEnd: lineEnd, - - // While inside a polygon, override lineEnd to closePath. - polygonStart: function() { stream.lineEnd = lineEndPolygon; }, - polygonEnd: function() { stream.lineEnd = lineEnd; stream.point = point; }, - - pointRadius: function(_) { - pointRadius = _; - return stream; - }, - - result: d3_noop - }; - - function point(x, y) { - context.moveTo(x + pointRadius, y); - context.arc(x, y, pointRadius, 0, τ); - } - - function pointLineStart(x, y) { - context.moveTo(x, y); - stream.point = pointLine; - } - - function pointLine(x, y) { - context.lineTo(x, y); - } - - function lineEnd() { - stream.point = point; - } - - function lineEndPolygon() { - context.closePath(); - } - - return stream; -} diff --git a/src/geo/path.js b/src/geo/path.js deleted file mode 100644 index 51d08be26cbdf0..00000000000000 --- a/src/geo/path.js +++ /dev/null @@ -1,87 +0,0 @@ -import "../core/identity"; -import "../math/trigonometry"; -import "albers-usa"; -import "area"; -import "bounds"; -import "centroid"; -import "geo"; -import "path-area"; -import "path-bounds"; -import "path-buffer"; -import "path-centroid"; -import "path-context"; -import "projection"; -import "resample"; -import "stream"; - -d3.geo.path = function() { - var pointRadius = 4.5, - projection, - context, - projectStream, - contextStream, - cacheStream; - - function path(object) { - if (object) { - if (typeof pointRadius === "function") contextStream.pointRadius(+pointRadius.apply(this, arguments)); - if (!cacheStream || !cacheStream.valid) cacheStream = projectStream(contextStream); - d3.geo.stream(object, cacheStream); - } - return contextStream.result(); - } - - path.area = function(object) { - d3_geo_pathAreaSum = 0; - d3.geo.stream(object, projectStream(d3_geo_pathArea)); - return d3_geo_pathAreaSum; - }; - - path.centroid = function(object) { - d3_geo_centroidX0 = d3_geo_centroidY0 = d3_geo_centroidZ0 = - d3_geo_centroidX1 = d3_geo_centroidY1 = d3_geo_centroidZ1 = - d3_geo_centroidX2 = d3_geo_centroidY2 = d3_geo_centroidZ2 = 0; - d3.geo.stream(object, projectStream(d3_geo_pathCentroid)); - return d3_geo_centroidZ2 ? [d3_geo_centroidX2 / d3_geo_centroidZ2, d3_geo_centroidY2 / d3_geo_centroidZ2] - : d3_geo_centroidZ1 ? [d3_geo_centroidX1 / d3_geo_centroidZ1, d3_geo_centroidY1 / d3_geo_centroidZ1] - : d3_geo_centroidZ0 ? [d3_geo_centroidX0 / d3_geo_centroidZ0, d3_geo_centroidY0 / d3_geo_centroidZ0] - : [NaN, NaN]; - }; - - path.bounds = function(object) { - d3_geo_pathBoundsX1 = d3_geo_pathBoundsY1 = -(d3_geo_pathBoundsX0 = d3_geo_pathBoundsY0 = Infinity); - d3.geo.stream(object, projectStream(d3_geo_pathBounds)); - return [[d3_geo_pathBoundsX0, d3_geo_pathBoundsY0], [d3_geo_pathBoundsX1, d3_geo_pathBoundsY1]]; - }; - - path.projection = function(_) { - if (!arguments.length) return projection; - projectStream = (projection = _) ? _.stream || d3_geo_pathProjectStream(_) : d3_identity; - return reset(); - }; - - path.context = function(_) { - if (!arguments.length) return context; - contextStream = (context = _) == null ? new d3_geo_pathBuffer : new d3_geo_pathContext(_); - if (typeof pointRadius !== "function") contextStream.pointRadius(pointRadius); - return reset(); - }; - - path.pointRadius = function(_) { - if (!arguments.length) return pointRadius; - pointRadius = typeof _ === "function" ? _ : (contextStream.pointRadius(+_), +_); - return path; - }; - - function reset() { - cacheStream = null; - return path; - } - - return path.projection(d3.geo.albersUsa()).context(null); -}; - -function d3_geo_pathProjectStream(project) { - var resample = d3_geo_resample(function(x, y) { return project([x * d3_degrees, y * d3_degrees]); }); - return function(stream) { return d3_geo_projectionRadians(resample(stream)); }; -} diff --git a/src/geo/point-in-polygon.js b/src/geo/point-in-polygon.js deleted file mode 100644 index 3cc82972f9b1be..00000000000000 --- a/src/geo/point-in-polygon.js +++ /dev/null @@ -1,71 +0,0 @@ -import "geo"; -import "area"; -import "cartesian"; -import "../math/abs"; -import "../math/trigonometry"; - -function d3_geo_pointInPolygon(point, polygon) { - var meridian = point[0], - parallel = point[1], - meridianNormal = [Math.sin(meridian), -Math.cos(meridian), 0], - polarAngle = 0, - winding = 0; - d3_geo_areaRingSum.reset(); - - for (var i = 0, n = polygon.length; i < n; ++i) { - var ring = polygon[i], - m = ring.length; - if (!m) continue; - var point0 = ring[0], - λ0 = point0[0], - φ0 = point0[1] / 2 + π / 4, - sinφ0 = Math.sin(φ0), - cosφ0 = Math.cos(φ0), - j = 1; - - while (true) { - if (j === m) j = 0; - point = ring[j]; - var λ = point[0], - φ = point[1] / 2 + π / 4, - sinφ = Math.sin(φ), - cosφ = Math.cos(φ), - dλ = λ - λ0, - sdλ = dλ >= 0 ? 1 : -1, - adλ = sdλ * dλ, - antimeridian = adλ > π, - k = sinφ0 * sinφ; - d3_geo_areaRingSum.add(Math.atan2(k * sdλ * Math.sin(adλ), cosφ0 * cosφ + k * Math.cos(adλ))); - - polarAngle += antimeridian ? dλ + sdλ * τ : dλ; - - // Are the longitudes either side of the point's meridian, and are the - // latitudes smaller than the parallel? - if (antimeridian ^ λ0 >= meridian ^ λ >= meridian) { - var arc = d3_geo_cartesianCross(d3_geo_cartesian(point0), d3_geo_cartesian(point)); - d3_geo_cartesianNormalize(arc); - var intersection = d3_geo_cartesianCross(meridianNormal, arc); - d3_geo_cartesianNormalize(intersection); - var φarc = (antimeridian ^ dλ >= 0 ? -1 : 1) * d3_asin(intersection[2]); - if (parallel > φarc || parallel === φarc && (arc[0] || arc[1])) { - winding += antimeridian ^ dλ >= 0 ? 1 : -1; - } - } - if (!j++) break; - λ0 = λ, sinφ0 = sinφ, cosφ0 = cosφ, point0 = point; - } - } - - // First, determine whether the South pole is inside or outside: - // - // It is inside if: - // * the polygon winds around it in a clockwise direction. - // * the polygon does not (cumulatively) wind around it, but has a negative - // (counter-clockwise) area. - // - // Second, count the (signed) number of times a segment crosses a meridian - // from the point to the South pole. If it is zero, then the point is the - // same side as the South pole. - - return (polarAngle < -ε || polarAngle < ε && d3_geo_areaRingSum < -ε) ^ (winding & 1); -} diff --git a/src/geo/projection.js b/src/geo/projection.js deleted file mode 100644 index fe493a8c2f3e1a..00000000000000 --- a/src/geo/projection.js +++ /dev/null @@ -1,121 +0,0 @@ -import "../core/identity"; -import "../core/rebind"; -import "../math/trigonometry"; -import "clip-antimeridian"; -import "clip-circle"; -import "clip-extent"; -import "compose"; -import "geo"; -import "path"; -import "resample"; -import "rotation"; -import "transform"; - -d3.geo.projection = d3_geo_projection; -d3.geo.projectionMutator = d3_geo_projectionMutator; - -function d3_geo_projection(project) { - return d3_geo_projectionMutator(function() { return project; })(); -} - -function d3_geo_projectionMutator(projectAt) { - var project, - rotate, - projectRotate, - projectResample = d3_geo_resample(function(x, y) { x = project(x, y); return [x[0] * k + δx, δy - x[1] * k]; }), - k = 150, // scale - x = 480, y = 250, // translate - λ = 0, φ = 0, // center - δλ = 0, δφ = 0, δγ = 0, // rotate - δx, δy, // center - preclip = d3_geo_clipAntimeridian, - postclip = d3_identity, - clipAngle = null, - clipExtent = null, - stream; - - function projection(point) { - point = projectRotate(point[0] * d3_radians, point[1] * d3_radians); - return [point[0] * k + δx, δy - point[1] * k]; - } - - function invert(point) { - point = projectRotate.invert((point[0] - δx) / k, (δy - point[1]) / k); - return point && [point[0] * d3_degrees, point[1] * d3_degrees]; - } - - projection.stream = function(output) { - if (stream) stream.valid = false; - stream = d3_geo_projectionRadians(preclip(rotate, projectResample(postclip(output)))); - stream.valid = true; // allow caching by d3.geo.path - return stream; - }; - - projection.clipAngle = function(_) { - if (!arguments.length) return clipAngle; - preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); - return invalidate(); - }; - - projection.clipExtent = function(_) { - if (!arguments.length) return clipExtent; - clipExtent = _; - postclip = _ ? d3_geo_clipExtent(_[0][0], _[0][1], _[1][0], _[1][1]) : d3_identity; - return invalidate(); - }; - - projection.scale = function(_) { - if (!arguments.length) return k; - k = +_; - return reset(); - }; - - projection.translate = function(_) { - if (!arguments.length) return [x, y]; - x = +_[0]; - y = +_[1]; - return reset(); - }; - - projection.center = function(_) { - if (!arguments.length) return [λ * d3_degrees, φ * d3_degrees]; - λ = _[0] % 360 * d3_radians; - φ = _[1] % 360 * d3_radians; - return reset(); - }; - - projection.rotate = function(_) { - if (!arguments.length) return [δλ * d3_degrees, δφ * d3_degrees, δγ * d3_degrees]; - δλ = _[0] % 360 * d3_radians; - δφ = _[1] % 360 * d3_radians; - δγ = _.length > 2 ? _[2] % 360 * d3_radians : 0; - return reset(); - }; - - d3.rebind(projection, projectResample, "precision"); - - function reset() { - projectRotate = d3_geo_compose(rotate = d3_geo_rotation(δλ, δφ, δγ), project); - var center = project(λ, φ); - δx = x - center[0] * k; - δy = y + center[1] * k; - return invalidate(); - } - - function invalidate() { - if (stream) stream.valid = false, stream = null; - return projection; - } - - return function() { - project = projectAt.apply(this, arguments); - projection.invert = project.invert && invert; - return reset(); - }; -} - -function d3_geo_projectionRadians(stream) { - return d3_geo_transformPoint(stream, function(x, y) { - stream.point(x * d3_radians, y * d3_radians); - }); -} diff --git a/src/geo/resample.js b/src/geo/resample.js deleted file mode 100644 index ff6660ccc5cf3b..00000000000000 --- a/src/geo/resample.js +++ /dev/null @@ -1,109 +0,0 @@ -import "../math/abs"; -import "../math/trigonometry"; -import "cartesian"; - -function d3_geo_resample(project) { - var δ2 = 0.5, // precision, px² - cosMinDistance = Math.cos(30 * d3_radians), // cos(minimum angular distance) - maxDepth = 16; - - function resample(stream) { - return (maxDepth ? resampleRecursive : resampleNone)(stream); - } - - function resampleNone(stream) { - return d3_geo_transformPoint(stream, function(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - }); - } - - function resampleRecursive(stream) { - var λ00, φ00, x00, y00, a00, b00, c00, // first point - λ0, x0, y0, a0, b0, c0; // previous point - - var resample = { - point: point, - lineStart: lineStart, - lineEnd: lineEnd, - polygonStart: function() { stream.polygonStart(); resample.lineStart = ringStart; }, - polygonEnd: function() { stream.polygonEnd(); resample.lineStart = lineStart; } - }; - - function point(x, y) { - x = project(x, y); - stream.point(x[0], x[1]); - } - - function lineStart() { - x0 = NaN; - resample.point = linePoint; - stream.lineStart(); - } - - function linePoint(λ, φ) { - var c = d3_geo_cartesian([λ, φ]), p = project(λ, φ); - resampleLineTo(x0, y0, λ0, a0, b0, c0, x0 = p[0], y0 = p[1], λ0 = λ, a0 = c[0], b0 = c[1], c0 = c[2], maxDepth, stream); - stream.point(x0, y0); - } - - function lineEnd() { - resample.point = point; - stream.lineEnd(); - } - - function ringStart() { - lineStart(); - resample.point = ringPoint; - resample.lineEnd = ringEnd; - } - - function ringPoint(λ, φ) { - linePoint(λ00 = λ, φ00 = φ), x00 = x0, y00 = y0, a00 = a0, b00 = b0, c00 = c0; - resample.point = linePoint; - } - - function ringEnd() { - resampleLineTo(x0, y0, λ0, a0, b0, c0, x00, y00, λ00, a00, b00, c00, maxDepth, stream); - resample.lineEnd = lineEnd; - lineEnd(); - } - - return resample; - } - - function resampleLineTo(x0, y0, λ0, a0, b0, c0, x1, y1, λ1, a1, b1, c1, depth, stream) { - var dx = x1 - x0, - dy = y1 - y0, - d2 = dx * dx + dy * dy; - if (d2 > 4 * δ2 && depth--) { - var a = a0 + a1, - b = b0 + b1, - c = c0 + c1, - m = Math.sqrt(a * a + b * b + c * c), - φ2 = Math.asin(c /= m), - λ2 = abs(abs(c) - 1) < ε || abs(λ0 - λ1) < ε ? (λ0 + λ1) / 2 : Math.atan2(b, a), - p = project(λ2, φ2), - x2 = p[0], - y2 = p[1], - dx2 = x2 - x0, - dy2 = y2 - y0, - dz = dy * dx2 - dx * dy2; - if (dz * dz / d2 > δ2 // 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, λ0, a0, b0, c0, x2, y2, λ2, a /= m, b /= m, c, depth, stream); - stream.point(x2, y2); - resampleLineTo(x2, y2, λ2, a, b, c, x1, y1, λ1, a1, b1, c1, depth, stream); - } - } - } - - resample.precision = function(_) { - if (!arguments.length) return Math.sqrt(δ2); - maxDepth = (δ2 = _ * _) > 0 && 16; - return resample; - }; - - return resample; -} diff --git a/src/geo/rotation.js b/src/geo/rotation.js deleted file mode 100644 index 46ea8b62a8ec9a..00000000000000 --- a/src/geo/rotation.js +++ /dev/null @@ -1,79 +0,0 @@ -import "../math/trigonometry"; -import "compose"; -import "equirectangular"; -import "geo"; - -d3.geo.rotation = function(rotate) { - rotate = d3_geo_rotation(rotate[0] % 360 * d3_radians, rotate[1] * d3_radians, rotate.length > 2 ? rotate[2] * d3_radians : 0); - - function forward(coordinates) { - coordinates = rotate(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - } - - forward.invert = function(coordinates) { - coordinates = rotate.invert(coordinates[0] * d3_radians, coordinates[1] * d3_radians); - return coordinates[0] *= d3_degrees, coordinates[1] *= d3_degrees, coordinates; - }; - - return forward; -}; - -function d3_geo_identityRotation(λ, φ) { - return [λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ]; -} - -d3_geo_identityRotation.invert = d3_geo_equirectangular; - -// Note: |δλ| must be < 2π -function d3_geo_rotation(δλ, δφ, δγ) { - return δλ ? (δφ || δγ ? d3_geo_compose(d3_geo_rotationλ(δλ), d3_geo_rotationφγ(δφ, δγ)) - : d3_geo_rotationλ(δλ)) - : (δφ || δγ ? d3_geo_rotationφγ(δφ, δγ) - : d3_geo_identityRotation); -} - -function d3_geo_forwardRotationλ(δλ) { - return function(λ, φ) { - return λ += δλ, [λ > π ? λ - τ : λ < -π ? λ + τ : λ, φ]; - }; -} - -function d3_geo_rotationλ(δλ) { - var rotation = d3_geo_forwardRotationλ(δλ); - rotation.invert = d3_geo_forwardRotationλ(-δλ); - return rotation; -} - -function d3_geo_rotationφγ(δφ, δγ) { - var cosδφ = Math.cos(δφ), - sinδφ = Math.sin(δφ), - cosδγ = Math.cos(δγ), - sinδγ = Math.sin(δγ); - - function rotation(λ, φ) { - var cosφ = Math.cos(φ), - x = Math.cos(λ) * cosφ, - y = Math.sin(λ) * cosφ, - z = Math.sin(φ), - k = z * cosδφ + x * sinδφ; - return [ - Math.atan2(y * cosδγ - k * sinδγ, x * cosδφ - z * sinδφ), - d3_asin(k * cosδγ + y * sinδγ) - ]; - } - - rotation.invert = function(λ, φ) { - var cosφ = Math.cos(φ), - x = Math.cos(λ) * cosφ, - y = Math.sin(λ) * cosφ, - z = Math.sin(φ), - k = z * cosδγ - y * sinδγ; - return [ - Math.atan2(y * cosδγ + z * sinδγ, x * cosδφ + k * sinδφ), - d3_asin(k * cosδφ - x * sinδφ) - ]; - }; - - return rotation; -} diff --git a/src/geo/spherical.js b/src/geo/spherical.js deleted file mode 100644 index 9790a5a06c689f..00000000000000 --- a/src/geo/spherical.js +++ /dev/null @@ -1,13 +0,0 @@ -import "../math/abs"; -import "../math/trigonometry"; - -function d3_geo_spherical(cartesian) { - return [ - Math.atan2(cartesian[1], cartesian[0]), - d3_asin(cartesian[2]) - ]; -} - -function d3_geo_sphericalEqual(a, b) { - return abs(a[0] - b[0]) < ε && abs(a[1] - b[1]) < ε; -} diff --git a/src/geo/stereographic.js b/src/geo/stereographic.js deleted file mode 100644 index 052945f8672e35..00000000000000 --- a/src/geo/stereographic.js +++ /dev/null @@ -1,12 +0,0 @@ -import "azimuthal"; -import "geo"; -import "projection"; - -var d3_geo_stereographic = d3_geo_azimuthal( - function(cosλcosφ) { return 1 / (1 + cosλcosφ); }, - function(ρ) { return 2 * Math.atan(ρ); } -); - -(d3.geo.stereographic = function() { - return d3_geo_projection(d3_geo_stereographic); -}).raw = d3_geo_stereographic; diff --git a/src/geo/stream.js b/src/geo/stream.js deleted file mode 100644 index 2119c5dd592d25..00000000000000 --- a/src/geo/stream.js +++ /dev/null @@ -1,71 +0,0 @@ -import "geo"; - -d3.geo.stream = function(object, listener) { - if (object && d3_geo_streamObjectType.hasOwnProperty(object.type)) { - d3_geo_streamObjectType[object.type](object, listener); - } else { - d3_geo_streamGeometry(object, listener); - } -}; - -function d3_geo_streamGeometry(geometry, listener) { - if (geometry && d3_geo_streamGeometryType.hasOwnProperty(geometry.type)) { - d3_geo_streamGeometryType[geometry.type](geometry, listener); - } -} - -var d3_geo_streamObjectType = { - Feature: function(feature, listener) { - d3_geo_streamGeometry(feature.geometry, listener); - }, - FeatureCollection: function(object, listener) { - var features = object.features, i = -1, n = features.length; - while (++i < n) d3_geo_streamGeometry(features[i].geometry, listener); - } -}; - -var d3_geo_streamGeometryType = { - Sphere: function(object, listener) { - listener.sphere(); - }, - Point: function(object, listener) { - object = object.coordinates; - listener.point(object[0], object[1], object[2]); - }, - MultiPoint: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) object = coordinates[i], listener.point(object[0], object[1], object[2]); - }, - LineString: function(object, listener) { - d3_geo_streamLine(object.coordinates, listener, 0); - }, - MultiLineString: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 0); - }, - Polygon: function(object, listener) { - d3_geo_streamPolygon(object.coordinates, listener); - }, - MultiPolygon: function(object, listener) { - var coordinates = object.coordinates, i = -1, n = coordinates.length; - while (++i < n) d3_geo_streamPolygon(coordinates[i], listener); - }, - GeometryCollection: function(object, listener) { - var geometries = object.geometries, i = -1, n = geometries.length; - while (++i < n) d3_geo_streamGeometry(geometries[i], listener); - } -}; - -function d3_geo_streamLine(coordinates, listener, closed) { - var i = -1, n = coordinates.length - closed, coordinate; - listener.lineStart(); - while (++i < n) coordinate = coordinates[i], listener.point(coordinate[0], coordinate[1], coordinate[2]); - listener.lineEnd(); -} - -function d3_geo_streamPolygon(coordinates, listener) { - var i = -1, n = coordinates.length; - listener.polygonStart(); - while (++i < n) d3_geo_streamLine(coordinates[i], listener, 1); - listener.polygonEnd(); -} diff --git a/src/geo/transform.js b/src/geo/transform.js deleted file mode 100644 index a57af50841359e..00000000000000 --- a/src/geo/transform.js +++ /dev/null @@ -1,36 +0,0 @@ -import "geo"; -import "../core/array"; - -d3.geo.transform = function(methods) { - return { - stream: function(stream) { - var transform = new d3_geo_transform(stream); - for (var k in methods) transform[k] = methods[k]; - return transform; - } - }; -}; - -function d3_geo_transform(stream) { - this.stream = stream; -} - -d3_geo_transform.prototype = { - 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 d3_geo_transformPoint(stream, point) { - return { - point: point, - sphere: function() { stream.sphere(); }, - lineStart: function() { stream.lineStart(); }, - lineEnd: function() { stream.lineEnd(); }, - polygonStart: function() { stream.polygonStart(); }, - polygonEnd: function() { stream.polygonEnd(); }, - }; -} diff --git a/src/geo/transverse-mercator.js b/src/geo/transverse-mercator.js deleted file mode 100644 index eb292030fadddc..00000000000000 --- a/src/geo/transverse-mercator.js +++ /dev/null @@ -1,31 +0,0 @@ -import "../math/trigonometry"; -import "geo"; -import "mercator"; - -function d3_geo_transverseMercator(λ, φ) { - return [Math.log(Math.tan(π / 4 + φ / 2)), -λ]; -} - -d3_geo_transverseMercator.invert = function(x, y) { - return [-y, 2 * Math.atan(Math.exp(x)) - halfπ]; -}; - -(d3.geo.transverseMercator = function() { - var projection = d3_geo_mercatorProjection(d3_geo_transverseMercator), - center = projection.center, - rotate = projection.rotate; - - projection.center = function(_) { - return _ - ? center([-_[1], _[0]]) - : ((_ = center()), [_[1], -_[0]]); - }; - - projection.rotate = function(_) { - return _ - ? rotate([_[0], _[1], _.length > 2 ? _[2] + 90 : 90]) - : ((_ = rotate()), [_[0], _[1], _[2] - 90]); - }; - - return rotate([0, 0, 90]); -}).raw = d3_geo_transverseMercator; diff --git a/test/geo/albers-test.js b/test/geo/albers-test.js deleted file mode 100644 index 4f907f590be8c3..00000000000000 --- a/test/geo/albers-test.js +++ /dev/null @@ -1,40 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.albers"); - -suite.addBatch({ - "albers": { - topic: load("geo/albers").expression("d3.geo.albers"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); }, - "has the parallels 29.5°, 45.5°": function(p) { - assert.inDelta(p.parallels(), [29.5, 45.5], 1e-6); - }, - "has the rotation 96°, 0°": function(p) { - assert.inDelta(p.rotate(), [96, 0, 0], 1e-6); - }, - "has the center -0.6°, 38.7°": function(p) { - assert.inDelta(p.center(), [-0.6, 38.7], 1e-6); - }, - "has the scale 1070": function(p) { - assert.inDelta(p.scale(), 1070, 1e-6); - } - }, { - "Washington, DC": [[-120.50000000, 47.50000000], [ 181.00023857, 45.12748866]], - "San Francisco, CA": [[-122.42000000, 37.78000000], [ 107.44485839, 214.04820561]], - "the North Pole": [[ 0.00000000, 90.00000000], [1062.11670525, -761.71949818]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Washington, DC": [[-120.50000000, 47.50000000], [ -0.27943903, -0.19146964]], - "San Francisco, CA": [[-122.42000000, 37.78000000], [ -0.34818238, -0.03359981]], - "the North Pole": [[ 0.00000000, 90.00000000], [ 0.54403430, -0.94553224]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/albers-usa-test.js b/test/geo/albers-usa-test.js deleted file mode 100644 index 38db0b0832fc5e..00000000000000 --- a/test/geo/albers-usa-test.js +++ /dev/null @@ -1,33 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.albersUsa"); - -suite.addBatch({ - "albersUsa": { - topic: load("geo/albers-usa").expression("d3.geo.albersUsa"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); }, - "has the scale 1070": function(p) { - assert.inDelta(p.scale(), 1070, 1e-6); - } - }, { - "Washington, DC": [[-120.50000000, 47.50000000], [ 181.00023857, 45.12748866]], - "San Francisco, CA": [[-122.42000000, 37.78000000], [ 107.44485839, 214.04820561]], - "Juneau, AK": [[-134.22000000, 58.43000000], [ 224.79015007, 455.65860760]], - "Honolulu, HI": [[-157.82000000, 21.30000000], [ 299.14918225, 451.11762634]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Washington, DC": [[-120.50000000, 47.50000000], [ -0.27943903, -0.19146964]], - "San Francisco, CA": [[-122.42000000, 37.78000000], [ -0.34818238, -0.03359981]], - "Juneau, AK": [[-134.22000000, 58.43000000], [ -0.23851388, 0.19220431]], - "Honolulu, HI": [[-157.82000000, 21.30000000], [ -0.16901946, 0.18796040]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/area-benchmark.js b/test/geo/area-benchmark.js deleted file mode 100644 index fe7f414f930c2c..00000000000000 --- a/test/geo/area-benchmark.js +++ /dev/null @@ -1,12 +0,0 @@ -var d3 = require("../../"); - -var formatNumber = d3.format(",.02r"), - o = d3.geo.circle().angle(30).precision(0.1)(), - n = 1e3, - then = Date.now(); - -for (var i = 0; i < n; i++) { - d3.geo.area(o); -} - -console.log("circle.angle(30°): " + formatNumber((Date.now() - then) / i) + "ms/op."); diff --git a/test/geo/area-test.js b/test/geo/area-test.js deleted file mode 100644 index 86d95253c6da08..00000000000000 --- a/test/geo/area-test.js +++ /dev/null @@ -1,185 +0,0 @@ -var vows = require("vows"), - _ = require("../../"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.area"); - -var π = Math.PI; - -suite.addBatch({ - "area": { - topic: load("geo/area").expression("d3.geo.area"), - "Point": function(area) { - assert.equal(area({type: "Point", coordinates: [0, 0]}), 0); - }, - "MultiPoint": function(area) { - assert.equal(area({type: "MultiPoint", coordinates: [[0, 1], [2, 3]]}), 0); - }, - "LineString": function(area) { - assert.equal(area({type: "LineString", coordinates: [[0, 1], [2, 3]]}), 0); - }, - "MultiLineString": function(area) { - assert.equal(area({type: "MultiLineString", coordinates: [[[0, 1], [2, 3]], [[4, 5], [6, 7]]]}), 0); - }, - "Polygon": { - "tiny": function(area) { - assert.inDelta(area({type: "Polygon", coordinates: [[ - [-64.66070178517852, 18.33986913231323], - [-64.66079715091509, 18.33994007490749], - [-64.66074946804680, 18.33994007490749], - [-64.66070178517852, 18.33986913231323] - ]]}), 4.890516e-13, 1e-13); - }, - "zero area": function(area) { - assert.equal(area({ - "type": "Polygon", - "coordinates": [[ - [96.79142432523281, 5.262704519048153], - [96.81065389253769, 5.272455576551362], - [96.82988345984256, 5.272455576551362], - [96.81065389253769, 5.272455576551362], - [96.79142432523281, 5.262704519048153] - ]] - }), 0); - }, - "semilune": function(area) { - assert.inDelta(area({type: "Polygon", coordinates: [[[0, 0], [0, 90], [90, 0], [0, 0]]]}), π / 2, 1e-6); - }, - "lune": function(area) { - assert.inDelta(area({type: "Polygon", coordinates: [[[0, 0], [0, 90], [90, 0], [0, -90], [0, 0]]]}), π, 1e-6); - }, - "hemispheres": { - "North": function(area) { - assert.inDelta(area({type: "Polygon", coordinates: [[[0, 0], [-90, 0], [180, 0], [90, 0], [0, 0]]]}), 2 * π, 1e-6); - }, - "South": function(area) { - assert.inDelta(area({type: "Polygon", coordinates: [[[0, 0], [90, 0], [180, 0], [-90, 0], [0, 0]]]}), 2 * π, 1e-6); - }, - "East": function(area) { - assert.inDelta(area({type: "Polygon", coordinates: [[[0, 0], [0, 90], [180, 0], [0, -90], [0, 0]]]}), 2 * π, 1e-6); - }, - "West": function(area) { - assert.inDelta(area({type: "Polygon", coordinates: [[[0, 0], [0, -90], [180, 0], [0, 90], [0, 0]]]}), 2 * π, 1e-6); - } - }, - "graticule outline": { - "sphere": function(area) { - assert.inDelta(area(_.geo.graticule().extent([[-180, -90], [180, 90]]).outline()), 4 * π, 1e-5); - }, - "hemisphere": function(area) { - assert.inDelta(area(_.geo.graticule().extent([[-180, 0], [180, 90]]).outline()), 2 * π, 1e-5); - }, - "semilune": function(area) { - assert.inDelta(area(_.geo.graticule().extent([[0, 0], [90, 90]]).outline()), π / 2, 1e-5); - } - }, - "circles": { - "hemisphere": function(area) { - assert.inDelta(area(_.geo.circle().angle(90)()), 2 * π, 1e-5); - }, - "60°": function(area) { - assert.inDelta(area(_.geo.circle().angle(60).precision(0.1)()), π, 1e-5); - }, - "60° North": function(area) { - assert.inDelta(area(_.geo.circle().angle(60).precision(0.1).origin([0, 90])()), π, 1e-5); - }, - "45°": function(area) { - assert.inDelta(area(_.geo.circle().angle(45).precision(0.1)()), π * (2 - Math.SQRT2), 1e-5); - }, - "45° North": function(area) { - assert.inDelta(area(_.geo.circle().angle(45).precision(0.1).origin([0, 90])()), π * (2 - Math.SQRT2), 1e-5); - }, - "45° South": function(area) { - assert.inDelta(area(_.geo.circle().angle(45).precision(0.1).origin([0, -90])()), π * (2 - Math.SQRT2), 1e-5); - }, - "135°": function(area) { - assert.inDelta(area(_.geo.circle().angle(135).precision(0.1)()), π * (2 + Math.SQRT2), 1e-5); - }, - "135° North": function(area) { - assert.inDelta(area(_.geo.circle().angle(135).precision(0.1).origin([0, 90])()), π * (2 + Math.SQRT2), 1e-5); - }, - "135° South": function(area) { - assert.inDelta(area(_.geo.circle().angle(135).precision(0.1).origin([0, -90])()), π * (2 + Math.SQRT2), 1e-5); - }, - "tiny": function(area) { - assert.inDelta(area(_.geo.circle().angle(1e-6).precision(0.1)()), 0, 1e-6); - }, - "huge": function(area) { - assert.inDelta(area(_.geo.circle().angle(180 - 1e-6).precision(0.1)()), 4 * π, 1e-6); - }, - "60° with 45° hole": function(area) { - var circle = _.geo.circle().precision(0.1); - assert.inDelta(area({ - type: "Polygon", - coordinates: [ - circle.angle(60)().coordinates[0], - circle.angle(45)().coordinates[0].reverse() - ] - }), π * (Math.SQRT2 - 1), 1e-5); - }, - "45° holes at [0°, 0°] and [0°, 90°]": function(area) { - var circle = _.geo.circle().precision(0.1).angle(45); - assert.inDelta(area({ - type: "Polygon", - coordinates: [ - circle.origin([0, 0])().coordinates[0].reverse(), - circle.origin([0, 90])().coordinates[0].reverse() - ] - }), π * 2 * Math.SQRT2, 1e-5); - }, - "45° holes at [0°, 90°] and [0°, 0°]": function(area) { - var circle = _.geo.circle().precision(0.1).angle(45); - assert.inDelta(area({ - type: "Polygon", - coordinates: [ - circle.origin([0, 90])().coordinates[0].reverse(), - circle.origin([0, 0])().coordinates[0].reverse() - ] - }), π * 2 * Math.SQRT2, 1e-5); - } - }, - "stripes": { - "45°, -45°": function(area) { - assert.inDelta(area(stripes(45, -45)), π * 2 * Math.SQRT2, 1e-5); - }, - "-45°, 45°": function(area) { - assert.inDelta(area(stripes(-45, 45)), π * 2 * (2 - Math.SQRT2), 1e-5); - }, - "45°, 30°": function(area) { - assert.inDelta(area(stripes(45, 30)), π * (Math.SQRT2 - 1), 1e-5); - } - } - }, - "MultiPolygon": { - "two hemispheres": function(area) { - assert.equal(area({type: "MultiPolygon", coordinates: [ - [[[0, 0], [-90, 0], [180, 0], [90, 0], [0, 0]]], - [[[0, 0], [90, 0], [180, 0], [-90, 0], [0, 0]]] - ]}), 4 * π); - } - }, - "Sphere": function(area) { - assert.equal(area({type: "Sphere"}), 4 * π); - }, - "GeometryCollection": function(area) { - assert.equal(area({type: "GeometryCollection", geometries: [{type: "Sphere"}]}), 4 * π); - }, - "FeatureCollection": function(area) { - assert.equal(area({type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "Sphere"}}]}), 4 * π); - }, - "Feature": function(area) { - assert.equal(area({type: "Feature", geometry: {type: "Sphere"}}), 4 * π); - } - } -}); - -suite.export(module); - -function stripes(a, b) { - return {type: "Polygon", coordinates: [a, b].map(function(d, i) { - var stripe = _.range(-180, 180, 0.1).map(function(x) { return [x, d]; }); - stripe.push(stripe[0]); - return i ? stripe.reverse() : stripe; - })}; -} diff --git a/test/geo/azimuthal-equal-area-test.js b/test/geo/azimuthal-equal-area-test.js deleted file mode 100644 index 9199c3309fb3fd..00000000000000 --- a/test/geo/azimuthal-equal-area-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.azimuthalEqualArea"); - -suite.addBatch({ - "azimuthalEqualArea": { - topic: load("geo/azimuthal-equal-area").expression("d3.geo.azimuthalEqualArea"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 470.78325089, 51.18095336]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 448.09318291, 57.65281089]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 484.55622556, 96.45697185]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 428.30355841, 405.56446813]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 499.82677711, 55.68926131]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 452.67706228]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 47.32293772]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.06144499, -1.32546031]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.21271211, -1.28231459]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.03037484, -1.02362019]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.34464294, 1.03709645]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.13217851, -1.29540492]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 1.35118042]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -1.35118042]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/azimuthal-equidistant-test.js b/test/geo/azimuthal-equidistant-test.js deleted file mode 100644 index 8ba104db8c1728..00000000000000 --- a/test/geo/azimuthal-equidistant-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.azimuthalEquidistant"); - -suite.addBatch({ - "azimuthalEquidistant": { - topic: load("geo/azimuthal-equidistant").expression("d3.geo.azimuthalEquidistant"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 469.92237700, 32.61061747]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 445.26741926, 40.61796552]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 484.78328535, 88.80514528]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 425.30773539, 414.57947189]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 501.59066113, 38.40245747]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 472.52947963]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 27.47052037]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.06718415, -1.44926255]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.23155054, -1.39588023]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.03188857, -1.07463236]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.36461510, 1.09719648]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.14393774, -1.41065028]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 1.48352986]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -1.48352986]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/bounds-test.js b/test/geo/bounds-test.js deleted file mode 100644 index d18e347e7540e4..00000000000000 --- a/test/geo/bounds-test.js +++ /dev/null @@ -1,265 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.bounds"); - -suite.addBatch({ - "bounds": { - topic: load("geo/bounds").expression("d3.geo.bounds"), - "Feature": function(bounds) { - assert.deepEqual(bounds({ - type: "Feature", - geometry: { - type: "MultiPoint", - coordinates: [[-123, 39], [-122, 38]] - } - }), [[-123, 38], [-122, 39]]); - }, - "FeatureCollection": function(bounds) { - assert.deepEqual(bounds({ - type: "FeatureCollection", - features: [ - { - type: "Feature", - geometry: { - type: "Point", - coordinates: [-123, 39] - } - }, - { - type: "Feature", - geometry: { - type: "Point", - coordinates: [-122, 38] - } - } - ] - }), [[-123, 38], [-122, 39]]); - }, - "GeometryCollection": function(bounds) { - assert.deepEqual(bounds({ - type: "GeometryCollection", - geometries: [ - { - type: "Point", - coordinates: [-123, 39] - }, - { - type: "Point", - coordinates: [-122, 38] - } - ] - }), [[-123, 38], [-122, 39]]); - }, - "LineString": { - "simple": function(bounds) { - assert.deepEqual(bounds({ - type: "LineString", - coordinates: [[-123, 39], [-122, 38]] - }), [[-123, 38], [-122, 39]]); - }, - "containing coincident points": function(bounds) { - assert.deepEqual(bounds({ - type: "LineString", - coordinates: [[-123, 39], [-122, 38], [-122, 38]] - }), [[-123, 38], [-122, 39]]); - }, - "meridian": function(bounds) { - assert.deepEqual(bounds({ - type: "LineString", - coordinates: [[0, 0], [0, 1], [0, 60]] - }), [[0, 0], [0, 60]]); - }, - "equator": function(bounds) { - assert.deepEqual(bounds({ - type: "LineString", - coordinates: [[0, 0], [1, 0], [60, 0]] - }), [[0, 0], [60, 0]]); - }, - "containing an inflection point": { - "in the Northern hemisphere": function(bounds) { - assert.inDelta(bounds({ - type: "LineString", - coordinates: [[-45, 60], [45, 60]] - }), [[-45, 60], [45, 67.792345]], 1e-6); - }, - "in the Southern hemisphere": function(bounds) { - assert.inDelta(bounds({ - type: "LineString", - coordinates: [[-45, -60], [45, -60]] - }), [[-45, -67.792345], [45, -60]], 1e-6); - } - } - }, - "MultiLineString": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiLineString", - coordinates: [[[-123, 39], [-122, 38]]] - }), [[-123, 38], [-122, 39]]); - }, - "MultiPoint": { - "simple": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiPoint", - coordinates: [[-123, 39], [-122, 38]] - }), [[-123, 38], [-122, 39]]); - }, - "two points near antimeridian": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiPoint", - coordinates: [[-179, 39], [179, 38]] - }), [[179, 38], [-179, 39]]); - }, - "two points near antimeridian, two points near primary meridian": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiPoint", - coordinates: [[-179, 39], [179, 38], [-1, 0], [1, 0]] - }), [[-1, 0], [-179, 39]]); - }, - "two points near primary meridian, two points near antimeridian": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiPoint", - coordinates: [[-1, 0], [1, 0], [-179, 39], [179, 38]] - }), [[-1, 0], [-179, 39]]); - }, - "four mixed points near primary meridian and antimeridian": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiPoint", - coordinates: [[-1, 0], [-179, 39], [1, 0], [179, 38]] - }), [[-1, 0], [-179, 39]]); - }, - "three points near antimeridian": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiPoint", - coordinates: [[178, 38], [179, 39], [-179, 37]] - }), [[178, 37], [-179, 39]]); - }, - "various points near antimeridian": function(bounds) { - assert.deepEqual(bounds({ - type: "MultiPoint", - coordinates: [[-179, 39], [-179, 38], [178, 39], [-178, 38]] - }), [[178, 38], [-178, 39]]); - }, - }, - "MultiPolygon": function(bounds) { - assert.inDelta(bounds({ - type: "MultiPolygon", - coordinates: [ - [[[-123, 39], [-122, 39], [-122, 38], [-123, 39]], - [[10, 20], [20, 20], [20, 10], [10, 10], [10, 20]]] - ] - }), [[-123, 10], [20, 39.001067]], 1e-6); - }, - "Point": function(bounds) { - assert.deepEqual(bounds({ - type: "Point", - coordinates: [-123, 39] - }), [[-123, 39], [-123, 39]]); - }, - "Polygon": { - "simple": function(bounds) { - assert.inDelta(bounds({ - type: "Polygon", - coordinates: [[[-123, 39], [-122, 39], [-122, 38], [-123, 39]]] - }), [[-123, 38], [-122, 39.001067]], 1e-6); - }, - "larger than a hemisphere": { - "small, counter-clockwise": function(bounds) { - assert.deepEqual(bounds({ - type: "Polygon", - coordinates: [[[0, 0], [10, 0], [10, 10], [0, 10], [0, 0]]] - }), [[-180, -90], [180, 90]]); - }, - "large lat-lon rectangle": function(bounds) { - assert.inDelta(bounds({ - type: "Polygon", - coordinates: [[[-170, 80], [0, 80], [170, 80], [170, -80], [0, -80], [-170, -80], [-170, 80]]] - }), [[-170, -89.119552], [170, 89.119552]], 1e-6); - }, - "South pole": function(bounds) { - assert.inDelta(bounds({ - type: "Polygon", - coordinates: [[[10, 80], [170, 80], [-170, 80], [-10, 80], [10, 80]]] - }), [[-180, -90], [180, 88.246216]], 1e-6); - }, - "excluding both poles": function(bounds) { - assert.inDelta(bounds({ - type: "Polygon", - coordinates: [[[10, 80], [170, 80], [-170, 80], [-10, 80], [-10, 0], [-10, -80], [-170, -80], [170, -80], [10, -80], [10, 0], [10, 80]]] - }), [[10, -88.246216], [-10, 88.246216]], 1e-6); - } - }, - "South pole": function(bounds) { - assert.deepEqual(bounds({ - type: "Polygon", - coordinates: [[[-60, -80], [60, -80], [180, -80], [-60, -80]]] - }), [[-180, -90], [180, -80]]); - }, - "ring": function(bounds) { - assert.inDelta(bounds({ - type: "Polygon", - coordinates: [ - [[-60, -80], [60, -80], [180, -80], [-60, -80]], - [[-60, -89], [180, -89], [60, -89], [-60, -89]] - ] - }), [[-180, -89.499961], [180, -80]], 1e-6); - } - }, - "NestedCollection": function(bounds) { - assert.deepEqual(bounds({ - type: "FeatureCollection", - features: [ - { - type: "Feature", - geometry: { - type: "GeometryCollection", - geometries: [ - { - type: "Point", - coordinates: [-120,47] - }, - { - type: "Point", - coordinates: [-119,46] - } - ] - } - } - ] - }), [[-120,46], [-119,47]]); - }, - "null geometries": { - "Feature": function(bounds) { - var b = bounds({type: "Feature", geometry: null}); - assert.isNaN(b[0][0]); - assert.isNaN(b[0][1]); - assert.isNaN(b[1][0]); - assert.isNaN(b[1][1]); - }, - "MultiPoint": function(bounds) { - var b = bounds({type: "MultiPoint", coordinates: []}); - assert.isNaN(b[0][0]); - assert.isNaN(b[0][1]); - assert.isNaN(b[1][0]); - assert.isNaN(b[1][1]); - }, - "MultiLineString": function(bounds) { - var b = bounds({type: "MultiLineString", coordinates: []}); - assert.isNaN(b[0][0]); - assert.isNaN(b[0][1]); - assert.isNaN(b[1][0]); - assert.isNaN(b[1][1]); - }, - "MultiPolygon": function(bounds) { - var b = bounds({type: "MultiPolygon", coordinates: []}); - assert.isNaN(b[0][0]); - assert.isNaN(b[0][1]); - assert.isNaN(b[1][0]); - assert.isNaN(b[1][1]); - } - } - } -}); - -suite.export(module); diff --git a/test/geo/centroid-test.js b/test/geo/centroid-test.js deleted file mode 100644 index 8c1a392eab32fd..00000000000000 --- a/test/geo/centroid-test.js +++ /dev/null @@ -1,187 +0,0 @@ -var vows = require("vows"), - _ = require("../../"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.centroid"); - -suite.addBatch({ - "centroid": { - topic: load("geo/centroid").expression("d3.geo.centroid"), - - "the centroid of a point is itself": function(centroid) { - assert.inDelta(centroid({type: "Point", coordinates: [0, 0]}), [0, 0], 1e-6); - assert.inDelta(centroid({type: "Point", coordinates: [1, 1]}), [1, 1], 1e-6); - assert.inDelta(centroid({type: "Point", coordinates: [2, 3]}), [2, 3], 1e-6); - assert.inDelta(centroid({type: "Point", coordinates: [-4, -5]}), [-4, -5], 1e-6); - }, - - "the centroid of a set of points is the (spherical) average of its constituent members": function(centroid) { - assert.inDelta(centroid({type: "GeometryCollection", geometries: [{type: "Point", coordinates: [0, 0]}, {type: "Point", coordinates: [1, 2]}]}), [0.499847, 1.000038], 1e-6); - assert.inDelta(centroid({type: "MultiPoint", coordinates: [[0, 0], [1, 2]]}), [0.499847, 1.000038], 1e-6); - assert.inDelta(centroid({type: "MultiPoint", coordinates: [[179, 0], [-179, 0]]}), [180, 0], 1e-6); - }, - - "the centroid of a set of points and their antipodes is ambiguous": function(centroid) { - assert.ok(centroid({type: "MultiPoint", coordinates: [[0, 0], [180, 0]]}).every(isNaN)); - assert.ok(centroid({type: "MultiPoint", coordinates: [[0, 0], [90, 0], [180, 0], [-90, 0]]}).every(isNaN)); - assert.ok(centroid({type: "MultiPoint", coordinates: [[0, 0], [0, 90], [180, 0], [0, -90]]}).every(isNaN)); - }, - - "the centroid of the empty set of points is ambiguous": function(centroid) { - assert.ok(centroid({type: "MultiPoint", coordinates: []}).every(isNaN)); - }, - - "the centroid of a line string is the (spherical) average of its constituent great arc segments": function(centroid) { - assert.inDelta(centroid({type: "LineString", coordinates: [[0, 0], [1, 0]]}), [0.5, 0], 1e-6); - assert.inDelta(centroid({type: "LineString", coordinates: [[0, 0], [0, 90]]}), [0, 45], 1e-6); - assert.inDelta(centroid({type: "LineString", coordinates: [[0, 0], [0, 45], [0, 90]]}), [0, 45], 1e-6); - assert.inDelta(centroid({type: "LineString", coordinates: [[-1, -1], [1, 1]]}), [0, 0], 1e-6); - assert.inDelta(centroid({type: "LineString", coordinates: [[-60, -1], [60, 1]]}), [0, 0], 1e-6); - assert.inDelta(centroid({type: "LineString", coordinates: [[179, -1], [-179, 1]]}), [180, 0], 1e-6); - assert.inDelta(centroid({type: "LineString", coordinates: [[-179, 0], [0, 0], [179, 0]]}), [0, 0], 1e-6); - assert.inDelta(centroid({type: "LineString", coordinates: [[-180, -90], [0, 0], [0, 90]]}), [0, 0], 1e-6); - }, - - "the centroid of a great arc from a point to its antipode is ambiguous": function(centroid) { - assert.ok(centroid({type: "LineString", coordinates: [[180, 0], [0, 0]]}).every(isNaN)); - assert.ok(centroid({type: "MultiLineString", coordinates: [[[0, -90], [0, 90]]]}).every(isNaN)); - }, - - "the centroid of a set of line strings is the (spherical) average of its constituent great arc segments": function(centroid) { - assert.inDelta(centroid({type: "MultiLineString", coordinates: [[[0, 0], [0, 2]]]}), [0, 1], 1e-6); - }, - - "a line of zero length is treated as points": function(centroid) { - assert.inDelta(centroid({type: "LineString", coordinates: [[1, 1], [1, 1]]}), [1, 1], 1e-6); - assert.inDelta(centroid({type: "GeometryCollection", geometries: [{type: "Point", coordinates: [0, 0]}, {type: "LineString", coordinates: [[1, 2], [1, 2]]}]}), [0.666534, 1.333408], 1e-6); - }, - - "an empty polygon with non-zero extent is treated as a line": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[1, 1], [2, 1], [3, 1], [2, 1], [1, 1]]]}), [2, 1.000076], 1e-6); - assert.inDelta(centroid({type: "GeometryCollection", geometries: [{type: "Point", coordinates: [0, 0]}, {type: "Polygon", coordinates: [[[1, 2], [1, 2], [1, 2], [1, 2]]]}]}), [0.799907, 1.600077], 1e-6); - }, - - "an empty polygon with zero extent is treated as a point": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[1, 1], [1, 1], [1, 1], [1, 1]]]}), [1, 1], 1e-6); - assert.inDelta(centroid({type: "GeometryCollection", geometries: [{type: "Point", coordinates: [0, 0]}, {type: "Polygon", coordinates: [[[1, 2], [1, 2], [1, 2], [1, 2]]]}]}), [0.799907, 1.600077], 1e-6); - }, - - "the centroid of the equator is ambiguous": function(centroid) { - assert.ok(centroid({type: "LineString", coordinates: [[0, 0], [120, 0], [-120, 0], [0, 0]]}).every(isNaN)); - }, - - "the centroid of a polygon is the (spherical) average of its surface": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -90], [0, 0], [0, 90], [1, 0], [0, -90]]]}), [0.5, 0], 1e-6); - assert.inDelta(centroid({type: "Polygon", coordinates: [_.range(-180, 180 + 1 / 2, 1).map(function(x) { return [x, -60]; })]})[1], -90, 1e-6); - assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -10], [0, 10], [10, 10], [10, -10], [0, -10]]]}), [5, 0], 1e-6); - }, - - "the centroid of a set of polygons is the (spherical) average of its surface": function(centroid) { - var circle = _.geo.circle(); - assert.inDelta(centroid({ - type: "MultiPolygon", - coordinates: [ - circle.angle(45).origin([0, 0])().coordinates, - circle.angle(60).origin([180, 0])().coordinates - ] - }), [180, 0], 1e-6); - }, - - "the centroid of a lune is the (spherical) average of its surface": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -90], [0, 0], [0, 90], [1, 0], [0, -90]]]}), [0.5, 0], 1e-6); - }, - - "the centroid of a small circle is its origin": { - "5°": function(centroid) { - assert.inDelta(centroid(_.geo.circle().angle(5).origin([30, 45])()), [30, 45], 1e-6); - }, - "135°": function(centroid) { - assert.inDelta(centroid(_.geo.circle().angle(135).origin([30, 45])()), [30, 45], 1e-6); - }, - "South Pole": function(centroid) { - assert.equal(centroid({type: "Polygon", coordinates: [_.range(-180, 180 + 1 / 2, 1).map(function(x) { return [x, -60]; })]})[1], -90); - }, - "equator": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -10], [0, 10], [10, 10], [10, -10], [0, -10]]]}), [5, 0], 1e-6); - }, - "equator with coincident points": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -10], [0, 10], [0, 10], [10, 10], [10, -10], [0, -10]]]}), [5, 0], 1e-6); - }, - "other": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[-180, 0], [-180, 10], [-179, 10], [-179, 0], [-180, 0]]]}), [-179.5, 4.987448], 1e-6); - }, - "concentric rings": function(centroid) { - var circle = _.geo.circle().origin([0, 45]), - coordinates = circle.angle(60)().coordinates; - coordinates.push(circle.angle(45)().coordinates[0].reverse()); - assert.inDelta(centroid({type: "Polygon", coordinates: coordinates}), [0, 45], 1e-6); - } - }, - - "the centroid of a spherical square on the equator": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[0, -10], [0, 10], [10, 10], [10, -10], [0, -10]]]}), [5, 0], 1e-6); - }, - - "the centroid of a spherical square touching the antimeridian": function(centroid) { - assert.inDelta(centroid({type: "Polygon", coordinates: [[[-180, 0], [-180, 10], [-179, 10], [-179, 0], [-180, 0]]]}), [-179.5, 4.987448], 1e-6); - }, - - "concentric rings": function(centroid) { - var circle = _.geo.circle().origin([0, 45]), - coordinates = circle.angle(60)().coordinates; - coordinates.push(circle.angle(45)().coordinates[0].reverse()); - assert.inDelta(centroid({type: "Polygon", coordinates: coordinates}), [0, 45], 1e-6); - }, - - "the centroid of a sphere is ambiguous": function(centroid) { - assert.ok(centroid({type: "Sphere"}).every(isNaN)); - }, - - "the centroid of a feature is the centroid of its constituent geometry": function(centroid) { - assert.inDelta(centroid({type: "Feature", geometry: {type: "LineString", coordinates: [[1, 1], [1, 1]]}}), [1, 1], 1e-6); - assert.inDelta(centroid({type: "Feature", geometry: {type: "Point", coordinates: [1, 1]}}), [1, 1], 1e-6); - assert.inDelta(centroid({type: "Feature", geometry: {type: "Polygon", coordinates: [[[0, -90], [0, 0], [0, 90], [1, 0], [0, -90]]]}}), [0.5, 0], 1e-6); - }, - - "the centroid of a feature collection is the centroid of its constituent geometry": function(centroid) { - assert.inDelta(centroid({type: "FeatureCollection", features: [ - {type: "Feature", geometry: {type: "LineString", coordinates: [[179, 0], [180, 0]]}}, - {type: "Feature", geometry: {type: "Point", coordinates: [0, 0]}} - ]}), [179.5, 0], 1e-6); - }, - - "the centroid of a non-empty line string and a point only considers the line string": function(centroid) { - assert.inDelta(centroid({type: "GeometryCollection", geometries: [ - {type: "LineString", coordinates: [[179, 0], [180, 0]]}, - {type: "Point", coordinates: [0, 0]} - ]}), [179.5, 0], 1e-6); - }, - - "the centroid of a non-empty polygon, a non-empty line string and a point only considers the polygon": function(centroid) { - assert.inDelta(centroid({type: "GeometryCollection", geometries: [ - {type: "Polygon", coordinates: [[[-180, 0], [-180, 1], [-179, 1], [-179, 0], [-180, 0]]]}, - {type: "LineString", coordinates: [[179, 0], [180, 0]]}, - {type: "Point", coordinates: [0, 0]} - ]}), [-179.5, 0.500006], 1e-6); - assert.inDelta(centroid({type: "GeometryCollection", geometries: [ - {type: "Point", coordinates: [0, 0]}, - {type: "LineString", coordinates: [[179, 0], [180, 0]]}, - {type: "Polygon", coordinates: [[[-180, 0], [-180, 1], [-179, 1], [-179, 0], [-180, 0]]]} - ]}), [-179.5, 0.500006], 1e-6); - }, - - "the centroid of the sphere and a point is the point": function(centroid) { - assert.deepEqual(centroid({type: "GeometryCollection", geometries: [ - {type: "Sphere"}, - {type: "Point", coordinates: [0, 0]} - ]}), [0, 0]); - assert.deepEqual(centroid({type: "GeometryCollection", geometries: [ - {type: "Point", coordinates: [0, 0]}, - {type: "Sphere"} - ]}), [0, 0]); - } - } -}); - -suite.export(module); diff --git a/test/geo/circle-test.js b/test/geo/circle-test.js deleted file mode 100644 index 388ff8320da308..00000000000000 --- a/test/geo/circle-test.js +++ /dev/null @@ -1,33 +0,0 @@ -var vows = require("vows"), - _ = require("../../"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.circle"); - -suite.addBatch({ - "circle": { - topic: load("geo/circle").expression("d3.geo.circle"), - "generates a Polygon": function(circle) { - var o = circle()(); - assert.equal(o.type, "Polygon"); - assert.inDelta(o.coordinates, [[[-78.69007,-90],[-90,-84],[-90,-78],[-90,-72],[-90,-66],[-90,-60],[-90,-54],[-90,-48],[-90,-42],[-90,-36],[-90,-30],[-90,-24],[-90,-18],[-90,-12],[-90,-6],[-90,0],[-90,6],[-90,12],[-90,18],[-90,24],[-90,30],[-90,36],[-90,42],[-90,48],[-90,54],[-90,60],[-90,66],[-90,72],[-90,78],[-90,84],[-89.59666,90],[90,84],[90,78],[90,72],[90,66],[90,60],[90,54],[90,48],[90,42],[90,36],[90,30],[90,24],[90,18],[90,12],[90,6],[90,0],[90,-6],[90,-12],[90,-18],[90,-24],[90,-30],[90,-36],[90,-42],[90,-48],[90,-54],[90,-60],[90,-66],[90,-72],[90,-78],[90,-84],[89.56977,-90]]], 1e-5); - }, - "origin([0, 90])": function(circle) { - var o = circle().origin([0, 90])(); - assert.equal(o.type, "Polygon"); - assert.inDelta(o.coordinates, [_.range(360, -1, -6).map(function(x) { return [x >= 180 ? x - 360 : x, 0]; })], 1e-6); - }, - "origin([45, 45])": function(circle) { - var o = circle().origin([45, 45]).angle(0)(); - assert.equal(o.type, "Polygon"); - assert.inDelta(o.coordinates[0][0], [45, 45], 1e-6); - }, - "first and last points are coincident": function(circle) { - var o = circle().origin([0, 0]).angle(0.02).precision(45)(); - assert.inDelta(o.coordinates[0][0], o.coordinates[0].pop(), 1e-6); - } - } -}); - -suite.export(module); diff --git a/test/geo/clip-extent-test.js b/test/geo/clip-extent-test.js deleted file mode 100644 index 1877c13086f0de..00000000000000 --- a/test/geo/clip-extent-test.js +++ /dev/null @@ -1,163 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.clipExtent"); - -suite.addBatch({ - "clipExtent": { - topic: load("geo/clip-extent"), - - "extent": { - "defaults to [[0, 0], [960, 500]]": function(d3) { - var clip = d3.geo.clipExtent(); - assert.deepEqual(clip.extent(), [[0, 0], [960, 500]]); - }, - "coerces input values to numbers": function(d3) { - var clip = d3.geo.clipExtent().extent([["1", "2"], ["3", "4"]]), - extent = clip.extent(); - assert.strictEqual(extent[0][0], 1); - assert.strictEqual(extent[0][1], 2); - assert.strictEqual(extent[1][0], 3); - assert.strictEqual(extent[1][1], 4); - }, - "with no arguments, returns the current extent": function(d3) { - var clip = d3.geo.clipExtent(); - assert.deepEqual(clip.extent(), [[0, 0], [960, 500]]); - clip.extent([[1, 2], [3, 4]]); - assert.deepEqual(clip.extent(), [[1, 2], [3, 4]]); - }, - "with an argument, sets the current extent and returns this": function(d3) { - var clip = d3.geo.clipExtent(); - assert.strictEqual(clip.extent([[1, 2], [3, 4]]), clip); - } - }, - - "stream": { - "returns a stream that clips to the current extent": function(d3) { - var clip = d3.geo.clipExtent().extent([[100, 200], [300, 400]]), - stream = clip.stream(testContext); - stream.lineStart(); - stream.point(0, 0); - stream.point(500, 500); - stream.lineEnd(); - assert.deepEqual(testContext.buffer(), [ - {type: "lineStart"}, - {type: "point", x: 200, y: 200}, - {type: "point", x: 300, y: 300}, - {type: "lineEnd"} - ]); - }, - "can clip points": function(d3) { - var clip = d3.geo.clipExtent(), - stream = clip.stream(testContext); - stream.point(-100, -100); - stream.point(0, 0); - stream.point(480, 250); - stream.point(960, 500); - stream.point(1060, 6000); - assert.deepEqual(testContext.buffer(), [ - {type: "point", x: 0, y: 0}, - {type: "point", x: 480, y: 250}, - {type: "point", x: 960, y: 500} - ]); - }, - "can clip lines": function(d3) { - var clip = d3.geo.clipExtent(), - stream = clip.stream(testContext); - stream.lineStart(); - stream.point(-100, -100); - stream.point(1060, 600); - stream.lineEnd(); - assert.deepEqual(testContext.buffer(), [ - {type: "lineStart"}, - {type: "point", x: 66, y: 0}, - {type: "point", x: 894, y: 500}, - {type: "lineEnd"} - ]); - }, - "can clip polygons": function(d3) { - var clip = d3.geo.clipExtent(), - stream = clip.stream(testContext); - stream.polygonStart(); - stream.lineStart(); - stream.point(-100, -100); - stream.point(1060, -100); - stream.point(1060, 600); - stream.point(-100, 600); - stream.lineEnd(); - stream.polygonEnd(); - assert.deepEqual(testContext.buffer(), [ - {type: "polygonStart"}, - {type: "lineStart"}, - {type: "point", x: 0, y: 0}, - {type: "point", x: 960, y: 0}, - {type: "point", x: 960, y: 500}, - {type: "point", x: 0, y: 500}, - {type: "lineEnd"}, - {type: "polygonEnd"} - ]); - }, - "the returned stream is cacheable": function(d3) { - var clip = d3.geo.clipExtent().extent([[100, 200], [300, 400]]), - stream = clip.stream(testContext); - assert.isTrue(stream.valid); - }, - "the returned stream is invalidated when the extent changes": function(d3) { - var clip = d3.geo.clipExtent().extent([[100, 200], [300, 400]]), - stream = clip.stream(testContext); - assert.isTrue(stream.valid); - clip.extent([[0, 0], [960, 500]]); - assert.isFalse(stream.valid); - }, - "a polygon that encloses the extent, with a hole": function(d3) { - var clip = d3.geo.clipExtent().extent([[1, 1], [9, 9]]), - stream = clip.stream(testContext); - stream.polygonStart(); - stream.lineStart(); - stream.point(0, 0); - stream.point(10, 0); - stream.point(10, 10); - stream.point(0, 10); - stream.lineEnd(); - stream.lineStart(); - stream.point(4, 4); - stream.point(4, 6); - stream.point(6, 6); - stream.point(6, 4); - stream.lineEnd(); - stream.polygonEnd(); - assert.deepEqual(testContext.buffer(), [ - {type: "polygonStart"}, - {type: "lineStart"}, - {type: "point", x: 1, y: 1}, - {type: "point", x: 9, y: 1}, - {type: "point", x: 9, y: 9}, - {type: "point", x: 1, y: 9}, - {type: "lineEnd"}, - {type: "lineStart"}, - {type: "point", x: 4, y: 4}, - {type: "point", x: 4, y: 6}, - {type: "point", x: 6, y: 6}, - {type: "point", x: 6, y: 4}, - {type: "lineEnd"}, - {type: "polygonEnd"} - ]); - } - } - } -}); - -suite.export(module); - -var testBuffer = []; - -var testContext = { - point: function(x, y) { testBuffer.push({type: "point", x: Math.round(x), y: Math.round(y)}); }, - lineStart: function() { testBuffer.push({type: "lineStart"}); }, - lineEnd: function() { testBuffer.push({type: "lineEnd"}); }, - polygonStart: function() { testBuffer.push({type: "polygonStart"}); }, - polygonEnd: function() { testBuffer.push({type: "polygonEnd"}); }, - sphere: function() { testBuffer.push({type: "sphere"}); }, - buffer: function() { var result = testBuffer; testBuffer = []; return result; } -}; diff --git a/test/geo/conic-conformal-test.js b/test/geo/conic-conformal-test.js deleted file mode 100644 index c6598c7a475d1c..00000000000000 --- a/test/geo/conic-conformal-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.conicConformal"); - -suite.addBatch({ - "conicConformal": { - topic: load("geo/conic-conformal").expression("d3.geo.conicConformal"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 467.09545781, 31.02694219]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 442.69098342, 47.64115003]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 483.99106549, 103.34182093]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 295.79559728, 507.67642324]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 504.49928992, 42.36530945]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 1446.12378227]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 19.84318514]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.08603028, -1.45982039]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.24872678, -1.34905900]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.02660710, -0.97772119]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -1.22802935, 1.71784282]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.16332860, -1.38423127]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 7.97415855]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -1.53437877]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/conic-equal-area-test.js b/test/geo/conic-equal-area-test.js deleted file mode 100644 index c04bbfc1f2fb43..00000000000000 --- a/test/geo/conic-equal-area-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.conicEqualArea"); - -suite.addBatch({ - "conicEqualArea": { - topic: load("geo/conic-equal-area").expression("d3.geo.conicEqualArea"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 459.42118984, 32.08581547]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 433.22520615, 32.16847746]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 484.01431255, 72.73240059]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 358.03569713, 345.61858148]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 513.32546288, 32.84960593]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 376.37688344]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 31.93472588]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.13719207, -1.45276123]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.31183196, -1.45221015]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.02676208, -1.18178400]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.81309535, 0.63745721]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.22216975, -1.44766929]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 0.84251256]], - "the North Pole": [[ 0.00000000, 90.00000000], [ 0.00000000, -1.46410162]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/conic-equidistant-test.js b/test/geo/conic-equidistant-test.js deleted file mode 100644 index 8725059ffbe9a8..00000000000000 --- a/test/geo/conic-equidistant-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.conicEquidistant"); - -suite.addBatch({ - "conicEquidistant": { - topic: load("geo/conic-equidistant").expression("d3.geo.conicEquidistant"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 462.95768394, 32.17010277]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 437.79988730, 40.06576540]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 484.00316185, 88.80377979]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 341.92988745, 387.20169005]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 509.12411912, 37.80365327]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 472.52947963]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 27.47052037]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.11361544, -1.45219932]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.28133408, -1.39956156]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.02668775, -1.07464147]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.92046742, 0.91467793]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.19416079, -1.41464231]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 1.48352986]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -1.48352986]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/distance-test.js b/test/geo/distance-test.js deleted file mode 100644 index 508df6dc9cded8..00000000000000 --- a/test/geo/distance-test.js +++ /dev/null @@ -1,20 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("assert"); - -var suite = vows.describe("d3.geo.distance"); - -suite.addBatch({ - "distance": { - topic: load("geo/distance").expression("d3.geo.distance"), - "computes the great-arc distance": function(distance) { - assert.equal(distance([0, 0], [0, 0]), 0); - assert.inDelta(distance([118 + 24 / 60, 33 + 57 / 60], [ 73 + 47 / 60, 40 + 38 / 60]), 3973 / 6371, 0.5); - }, - "small distance": function(distance) { - assert.isTrue(distance([0, 0], [0, 1e-12]) > 0); - } - } -}); - -suite.export(module); diff --git a/test/geo/equirectangular-test.js b/test/geo/equirectangular-test.js deleted file mode 100644 index de204e1d68120d..00000000000000 --- a/test/geo/equirectangular-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.equirectangular"); - -suite.addBatch({ - "equirectangular": { - topic: load("geo/equirectangular").expression("d3.geo.equirectangular"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 424.98907000, 33.66602637]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 359.13715001, 48.28497214]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 488.21991600, 88.85615375]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 386.73919199, 407.84716262]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 567.40721901, 41.88153382]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 472.52947963]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 27.47052037]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.36673953, -1.44222649]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.80575233, -1.34476685]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.05479944, -1.07429231]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.62173872, 1.05231442]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.58271479, -1.38745644]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 1.48352986]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -1.48352986]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/gnomonic-test.js b/test/geo/gnomonic-test.js deleted file mode 100644 index d5f9aec406739a..00000000000000 --- a/test/geo/gnomonic-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.gnomonic"); - -suite.addBatch({ - "gnomonic": { - topic: load("geo/gnomonic").expression("d3.geo.gnomonic"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 422.38246174, -992.89637169]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 323.76600022, -691.84169545]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 488.22815397, -27.28558622]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 372.51942626, 573.42957804]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 578.85832181, -718.85305295]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 1964.50784541]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000,-1464.50784541]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.38411692, -8.28597600]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -1.04156000, -6.27894464]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.05485436, -1.84857057]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.71653716, 2.15619719]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.65905548, -6.45902035]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 11.43005230]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -11.43005230]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/graticule-test.js b/test/geo/graticule-test.js deleted file mode 100644 index 50e690d85c0f77..00000000000000 --- a/test/geo/graticule-test.js +++ /dev/null @@ -1,188 +0,0 @@ -var vows = require("vows"), - _ = require("../../"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.graticule"); - -var ε = 1e-6; - -suite.addBatch({ - "graticule": { - topic: load("geo/graticule").expression("d3.geo.graticule"), - - "extent": { - "sets minorExtent and majorExtent": function(graticule) { - var g = graticule().extent([[-90, -45], [90, 45]]); - assert.deepEqual(g.minorExtent(), [[-90, -45], [90, 45]]); - assert.deepEqual(g.majorExtent(), [[-90, -45], [90, 45]]); - }, - "gets minorExtent": function(graticule) { - var g = graticule().minorExtent([[-90, -45], [90, 45]]); - assert.deepEqual(g.extent(), [[-90, -45], [90, 45]]); - } - }, - - "majorExtent": { - "default longitude ranges from 180°W (inclusive) to 180°E (exclusive)": function(graticule) { - var extent = graticule().majorExtent(); - assert.equal(extent[0][0], -180); - assert.equal(extent[1][0], +180); - }, - "default latitude ranges from 90°S (exclusive) to 90°N (exclusive)": function(graticule) { - var extent = graticule().majorExtent(); - assert.equal(extent[0][1], -90 + ε); - assert.equal(extent[1][1], +90 - ε); - }, - "coerces input values to numbers": function(graticule) { - var g = graticule().majorExtent([["-90", "-45"], ["+90", "+45"]]), - extent = g.majorExtent(); - assert.strictEqual(extent[0][0], -90); - assert.strictEqual(extent[0][1], -45); - assert.strictEqual(extent[1][0], +90); - assert.strictEqual(extent[1][1], +45); - } - }, - - "minorExtent": { - "default longitude ranges from 180°W (inclusive) to 180°E (exclusive)": function(graticule) { - var extent = graticule().minorExtent(); - assert.equal(extent[0][0], -180); - assert.equal(extent[1][0], +180); - }, - "default latitude ranges from 80°S (inclusive) to 80°N (inclusive)": function(graticule) { - var extent = graticule().minorExtent(); - assert.equal(extent[0][1], -80 - ε); - assert.equal(extent[1][1], +80 + ε); - }, - "coerces input values to numbers": function(graticule) { - var g = graticule().minorExtent([["-90", "-45"], ["+90", "+45"]]), - extent = g.minorExtent(); - assert.strictEqual(extent[0][0], -90); - assert.strictEqual(extent[0][1], -45); - assert.strictEqual(extent[1][0], +90); - assert.strictEqual(extent[1][1], +45); - } - }, - - "step": { - "sets minorStep and majorStep": function(graticule) { - var g = graticule().step([22.5, 22.5]); - assert.deepEqual(g.minorStep(), [22.5, 22.5]); - assert.deepEqual(g.majorStep(), [22.5, 22.5]); - }, - "gets minorStep": function(graticule) { - var g = graticule().minorStep([22.5, 22.5]); - assert.deepEqual(g.step(), [22.5, 22.5]); - } - }, - - "minorStep": { - "defaults to 10°, 10°": function(graticule) { - assert.deepEqual(graticule().minorStep(), [10, 10]); - }, - "coerces input values to numbers": function(graticule) { - var g = graticule().minorStep(["45", "11.25"]), - step = g.minorStep(); - assert.strictEqual(step[0], 45); - assert.strictEqual(step[1], 11.25); - } - }, - - "majorStep": { - "defaults to 90°, 360°": function(graticule) { - assert.deepEqual(graticule().majorStep(), [90, 360]); - }, - "coerces input values to numbers": function(graticule) { - var g = graticule().majorStep(["45", "11.25"]), - step = g.majorStep(); - assert.strictEqual(step[0], 45); - assert.strictEqual(step[1], 11.25); - } - }, - - "lines": { - "default longitude ranges from 180°W (inclusive) to 180°E (exclusive)": function(graticule) { - var lines = graticule().lines() - .filter(function(line) { return line.coordinates[0][0] === line.coordinates[1][0]; }) - .sort(function(a, b) { return a.coordinates[0][0] - b.coordinates[0][0]; }); - assert.equal(lines[0].coordinates[0][0], -180); - assert.equal(lines[lines.length - 1].coordinates[0][0], +170); - }, - "default latitude ranges from 90°S (exclusive) to 90°N (exclusive)": function(graticule) { - var lines = graticule().lines() - .filter(function(line) { return line.coordinates[0][1] === line.coordinates[1][1]; }) - .sort(function(a, b) { return a.coordinates[0][1] - b.coordinates[0][1]; }); - assert.equal(lines[0].coordinates[0][1], -80); - assert.equal(lines[lines.length - 1].coordinates[0][1], +80); - }, - "default minor longitude lines extend from 80°S to 80°N": function(graticule) { - var lines = graticule().lines() - .filter(function(line) { return line.coordinates[0][0] === line.coordinates[1][0]; }) - .filter(function(line) { return Math.abs(line.coordinates[0][0] % 90) > ε; }); - lines.forEach(function(line) { - assert.deepEqual(_.extent(line.coordinates, function(p) { return p[1]; }), [-80 - ε, +80 + ε]); - }); - }, - "default major longitude lines extend from 90°S to 90°N": function(graticule) { - var lines = graticule().lines() - .filter(function(line) { return line.coordinates[0][0] === line.coordinates[1][0]; }) - .filter(function(line) { return Math.abs(line.coordinates[0][0] % 90) < ε; }); - lines.forEach(function(line) { - assert.deepEqual(_.extent(line.coordinates, function(p) { return p[1]; }), [-90 + ε, +90 - ε]); - }); - }, - "default latitude lines extend from 180°W to 180°E": function(graticule) { - var lines = graticule().lines() - .filter(function(line) { return line.coordinates[0][1] === line.coordinates[1][1]; }); - lines.forEach(function(line) { - assert.deepEqual(_.extent(line.coordinates, function(p) { return p[0]; }), [-180, +180]); - }); - }, - "returns an array of LineStrings": function(graticule) { - assert.deepEqual(graticule() - .extent([[-90, -45], [90, 45]]) - .step([45, 45]) - .precision(3) - .lines(), [ - {type: "LineString", coordinates: [[-90,-45],[-90,45]]}, // meridian - {type: "LineString", coordinates: [[-45,-45],[-45,45]]}, // meridian - {type: "LineString", coordinates: [[0,-45],[0,45]]}, // meridian - {type: "LineString", coordinates: [[45,-45],[45,45]]}, // meridian - {type: "LineString", coordinates: [[-90,-45],[-87,-45],[-84,-45],[-81,-45],[-78,-45],[-75,-45],[-72,-45],[-69,-45],[-66,-45],[-63,-45],[-60,-45],[-57,-45],[-54,-45],[-51,-45],[-48,-45],[-45,-45],[-42,-45],[-39,-45],[-36,-45],[-33,-45],[-30,-45],[-27,-45],[-24,-45],[-21,-45],[-18,-45],[-15,-45],[-12,-45],[-9,-45],[-6,-45],[-3,-45],[0,-45],[3,-45],[6,-45],[9,-45],[12,-45],[15,-45],[18,-45],[21,-45],[24,-45],[27,-45],[30,-45],[33,-45],[36,-45],[39,-45],[42,-45],[45,-45],[48,-45],[51,-45],[54,-45],[57,-45],[60,-45],[63,-45],[66,-45],[69,-45],[72,-45],[75,-45],[78,-45],[81,-45],[84,-45],[87,-45],[90,-45]]}, - {type: "LineString", coordinates: [[-90,0],[-87,0],[-84,0],[-81,0],[-78,0],[-75,0],[-72,0],[-69,0],[-66,0],[-63,0],[-60,0],[-57,0],[-54,0],[-51,0],[-48,0],[-45,0],[-42,0],[-39,0],[-36,0],[-33,0],[-30,0],[-27,0],[-24,0],[-21,0],[-18,0],[-15,0],[-12,0],[-9,0],[-6,0],[-3,0],[0,0],[3,0],[6,0],[9,0],[12,0],[15,0],[18,0],[21,0],[24,0],[27,0],[30,0],[33,0],[36,0],[39,0],[42,0],[45,0],[48,0],[51,0],[54,0],[57,0],[60,0],[63,0],[66,0],[69,0],[72,0],[75,0],[78,0],[81,0],[84,0],[87,0],[90,0]]} - ]); - } - }, - - "returns a MultiLineString of all lines": function(graticule) { - var g = graticule() - .extent([[-90, -45], [90, 45]]) - .step([45, 45]) - .precision(3); - assert.deepEqual(g(), { - type: "MultiLineString", - coordinates: g.lines().map(function(line) { return line.coordinates; }) - }); - }, - - "outline": { - "returns a Polygon encompassing the major extent": function(graticule) { - assert.deepEqual(graticule() - .majorExtent([[-90, -45], [90, 45]]) - .precision(3) - .outline(), { - type: "Polygon", - coordinates: [[ - [-90,-45],[-90,45], // meridian - [-87,45],[-84,45],[-81,45],[-78,45],[-75,45],[-72,45],[-69,45],[-66,45],[-63,45],[-60,45],[-57,45],[-54,45],[-51,45],[-48,45],[-45,45],[-42,45],[-39,45],[-36,45],[-33,45],[-30,45],[-27,45],[-24,45],[-21,45],[-18,45],[-15,45],[-12,45],[-9,45],[-6,45],[-3,45],[0,45],[3,45],[6,45],[9,45],[12,45],[15,45],[18,45],[21,45],[24,45],[27,45],[30,45],[33,45],[36,45],[39,45],[42,45],[45,45],[48,45],[51,45],[54,45],[57,45],[60,45],[63,45],[66,45],[69,45],[72,45],[75,45],[78,45],[81,45],[84,45],[87,45], - [90,45],[90,-45], // meridian - [87,-45],[84,-45],[81,-45],[78,-45],[75,-45],[72,-45],[69,-45],[66,-45],[63,-45],[60,-45],[57,-45],[54,-45],[51,-45],[48,-45],[45,-45],[42,-45],[39,-45],[36,-45],[33,-45],[30,-45],[27,-45],[24,-45],[21,-45],[18,-45],[15,-45],[12,-45],[9,-45],[6,-45],[3,-45],[0,-45],[-3,-45],[-6,-45],[-9,-45],[-12,-45],[-15,-45],[-18,-45],[-21,-45],[-24,-45],[-27,-45],[-30,-45],[-33,-45],[-36,-45],[-39,-45],[-42,-45],[-45,-45],[-48,-45],[-51,-45],[-54,-45],[-57,-45],[-60,-45],[-63,-45],[-66,-45],[-69,-45],[-72,-45],[-75,-45],[-78,-45],[-81,-45],[-84,-45],[-87,-45],[-90,-45] - ]] - }); - } - } - } -}); - -suite.export(module); diff --git a/test/geo/greatArc-test.js b/test/geo/greatArc-test.js deleted file mode 100644 index 0d79c86d07af05..00000000000000 --- a/test/geo/greatArc-test.js +++ /dev/null @@ -1,35 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.greatArc"); - -suite.addBatch({ - "greatArc": { - topic: load("geo/greatArc").expression("d3.geo.greatArc"), - "distance": function(arc) { - var a = arc(); - assert.equal(a.distance({source: [0, 0], target: [0, 0]}), 0); - assert.inDelta(a.distance({ - source: [118 + 24 / 60, 33 + 57 / 60], - target: [ 73 + 47 / 60, 40 + 38 / 60] - }), 3973 / 6371, 0.5); - }, - "source and target can be set as constants": function(arc) { - var a = arc().source([5, 52]).target([-120, 37]); - assert.inDelta(a().coordinates, [ - [ 5, 52 ], - [-120, 37 ] - ], 0.5); - }, - "geodesic": function(arc) { - var a = arc(); - assert.inDelta(a({source: [5, 52], target: [-120, 37]}).coordinates, [ - [ 5, 52 ], - [-120, 37 ] - ], 0.5); - } - } -}); - -suite.export(module); diff --git a/test/geo/interpolate-test.js b/test/geo/interpolate-test.js deleted file mode 100644 index 16987530611800..00000000000000 --- a/test/geo/interpolate-test.js +++ /dev/null @@ -1,22 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.interpolate"); - -suite.addBatch({ - "interpolate": { - topic: load("geo/interpolate").expression("d3.geo.interpolate"), - "zero distance": function(interpolate) { - assert.deepEqual(interpolate([140.63289, -29.95101], [140.63289, -29.95101])(0.5), [140.63289, -29.95101]); - }, - "equator": function(interpolate) { - assert.inDelta(interpolate([10, 0], [20, 0])(0.5), [15, 0], 1e-6); - }, - "meridian": function(interpolate) { - assert.inDelta(interpolate([10, -20], [10, 40])(0.5), [10, 10], 1e-6); - } - } -}); - -suite.export(module); diff --git a/test/geo/length-test.js b/test/geo/length-test.js deleted file mode 100644 index 8e974618702990..00000000000000 --- a/test/geo/length-test.js +++ /dev/null @@ -1,44 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("assert"); - -var suite = vows.describe("d3.geo.length"); - -var π = Math.PI; - -suite.addBatch({ - "length": { - topic: load("geo/length").expression("d3.geo.length"), - "the length of points are zero": function(length) { - assert.inDelta(length({type: "Point", coordinates: [0, 0]}), 0, 1e-6); - assert.inDelta(length({type: "MultiPoint", coordinates: [[0, 1], [2, 3]]}), 0, 1e-6); - }, - "the length of a line string is the sum of its great arc segments": function(length) { - assert.inDelta(length({type: "LineString", coordinates: [[-45, 0], [45, 0]]}), Math.PI / 2, 1e-6); - assert.inDelta(length({type: "LineString", coordinates: [[-45, 0], [-30, 0], [-15, 0], [0, 0]]}), Math.PI / 4, 1e-6); - assert.inDelta(length({type: "MultiLineString", coordinates: [[[-45, 0], [-30, 0]], [[-15, 0], [0, 0]]]}), Math.PI / 6, 1e-6); - }, - "the length of a polygon is its perimeter": function(length) { - assert.inDelta(length({type: "Polygon", coordinates: [[[0, 0], [3, 0], [3, 3], [0, 3], [0, 0]]]}), 0.157008, 1e-6); - assert.inDelta(length({type: "MultiPolygon", coordinates: [[[[0, 0], [3, 0], [3, 3], [0, 3], [0, 0]]]]}), 0.157008, 1e-6); - assert.inDelta(length({type: "MultiPolygon", coordinates: [[[[0, 0], [3, 0], [3, 3], [0, 3], [0, 0]]], [[[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]]]}), 0.209354, 1e-6); - }, - "the length of a polygon is its perimeter, including holes": function(length) { - assert.inDelta(length({type: "Polygon", coordinates: [[[0, 0], [3, 0], [3, 3], [0, 3], [0, 0]], [[1, 1], [2, 1], [2, 2], [1, 2], [1, 1]]]}), 0.209354, 1e-6); - }, - "the length of a feature collection is the sum of its features": function(length) { - assert.inDelta(length({type: "FeatureCollection", features: [ - {type: "Feature", geometry: {type: "LineString", coordinates: [[-45, 0], [0, 0]]}}, - {type: "Feature", geometry: {type: "LineString", coordinates: [[0, 0], [45, 0]]}} - ]}), Math.PI / 2, 1e-6); - }, - "the length of a geometry collection is the sum of its geometries": function(length) { - assert.inDelta(length({type: "GeometryCollection", geometries: [ - {type: "GeometryCollection", geometries: [{type: "LineString", coordinates: [[-45, 0], [0, 0]]}]}, - {type: "LineString", coordinates: [[0, 0], [45, 0]]} - ]}), Math.PI / 2, 1e-6); - } - } -}); - -suite.export(module); diff --git a/test/geo/mercator-test.js b/test/geo/mercator-test.js deleted file mode 100644 index 2847b59e8d0060..00000000000000 --- a/test/geo/mercator-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.mercator"); - -suite.addBatch({ - "mercator": { - topic: load("geo/mercator").expression("d3.geo.mercator"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 424.98907000, -161.45770791]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 359.13715001, -76.39503103]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 488.21991600, 44.12991498]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 386.73919199, 449.08559401]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 567.40721901, -108.01311493]], - "west antimeridian": [[-180.00000000, 0.00000000], [ 8.76110196, 250.00000000]], - "east antimeridian": [[ 180.00000000, 0.00000000], [ 951.23889804, 250.00000000]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262725, 82.63349099], [ -0.36673953, -2.74305138]], - "San Francisco, CA": [[ -46.16620841, 77.04946502], [ -0.80575234, -2.17596687]], - "Svalbard": [[ 3.13977663, 61.55241514], [ 0.05479944, -1.37246723]], - "Tierra del Fuego": [[ -35.62300462, -60.29317474], [ -0.62173872, 1.32723729]], - "Tokyo": [[ 33.38709813, 79.49539834], [ 0.58271479, -2.38675410]], - "west antimeridian": [[-180.00000000, 0.00000000], [ -3.14159265, 0.00000000]], - "east antimeridian": [[ 180.00000000, 0.00000000], [ 3.14159265, 0.00000000]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/orthographic-test.js b/test/geo/orthographic-test.js deleted file mode 100644 index cfe0c95b2cdf49..00000000000000 --- a/test/geo/orthographic-test.js +++ /dev/null @@ -1,34 +0,0 @@ -var vows = require("vows"), - assert = require("../assert"), - load = require("../load"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.orthographic"); - -suite.addBatch({ - "orthographic": { - topic: load("geo/orthographic").expression("d3.geo.orthographic"), - "default": projectionTestSuite(function(projection) { return projection(); }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 473.10377192, 101.23805835]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 455.75069916, 103.81541376]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 483.91363537, 118.11201123]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 436.70402041, 380.28587327]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 495.04895132, 102.51395975]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 399.42920471]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 100.57079529]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite(function(projection) { return projection().translate([0, 0]).scale(1); }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.04597485, -0.99174628]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.16166201, -0.97456391]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.02609090, -0.87925326]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.28863986, 0.86857249]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.10032634, -0.98324027]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 0.99619470]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -0.99619470]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/path-benchmark b/test/geo/path-benchmark deleted file mode 100755 index cc0b67c49a529c..00000000000000 --- a/test/geo/path-benchmark +++ /dev/null @@ -1,113 +0,0 @@ -#!/usr/bin/env node - -var fs = require("fs"), - d3 = require("../../"); - -var formatNumber = d3.format(",.02r"), - projection = d3.geo.stereographic().clipAngle(150).clipExtent([[0, 0], [960, 500]]), - path = d3.geo.path().projection(projection), - projection0 = d3.geo.mercator().precision(0), - path0 = d3.geo.path().projection(projection0), - graticule = d3.geo.graticule().step([1, 1]), - circle = d3.geo.circle().angle(30), - n = 10, - o, - then; - -o = circle(); -then = Date.now(); - -for (var i = 0, k = 0; i < n * 1000; i++, k++) { - path(o); -} - -console.log("Single circle: " + formatNumber((Date.now() - then) / k) + "ms/op."); - -o = JSON.parse(fs.readFileSync("./test/data/us-counties.json")).features; -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - for (var j = 0, m = o.length; j < m; ++j) { - path(o[j]); - } -} - -console.log("U.S. counties (separate): " + formatNumber((Date.now() - then) / k) + "ms/op."); - -o = JSON.parse(fs.readFileSync("./test/data/us-counties.json")); -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - path(o); -} - -console.log("U.S. counties: " + formatNumber((Date.now() - then) / k) + "ms/op."); - -o = JSON.parse(fs.readFileSync("./test/data/world-countries.json")); -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - path(o); -} - -console.log("World countries: " + formatNumber((Date.now() - then) / k) + "ms/op."); - -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - path0(o); -} - -console.log("World countries precision(0): " + formatNumber((Date.now() - then) / k) + "ms/op."); - -o = JSON.parse(fs.readFileSync("./test/data/ocean.json")); -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - path(o); -} - -console.log("Ocean: " + formatNumber((Date.now() - then) / k) + "ms/op."); - -o = graticule(); -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - path(o); -} - -console.log("Dense graticule: " + formatNumber((Date.now() - then) / k) + "ms/op."); - -o = {type: "GeometryCollection", geometries: d3.range(-180, 180, 1).map(function(x) { - return circle.origin([x, 0])(); -})}; -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - path(o); -} - -console.log("Circle polygons: " + formatNumber((Date.now() - then) / k) + "ms/op."); - -o = spiral(); -then = Date.now(); - -for (var i = 0, k = 0; i < n; i++, k++) { - path(o); -} - -console.log("Spiral polygons: " + formatNumber((Date.now() - then) / k) + "ms/op."); - -function spiral() { - var n = 1e4, - dy = 5; - - var spiral = d3.range(0, 1 + 1 / n, 1 / n).map(function(t) { - return [(360 * 10 * t) % 360 - 180, -90 + dy + (90 - dy) * 2 * t]; - }).concat(d3.range(1, 0, -1 / n).map(function(t) { - return [(360 * 10 * t) % 360 - 180, -90 + (90 - dy) * 2 * t]; - })); - spiral.push(spiral[0]); - - return {type: "Polygon", coordinates: [spiral]}; -} diff --git a/test/geo/path-test.js b/test/geo/path-test.js deleted file mode 100644 index 466120fa245989..00000000000000 --- a/test/geo/path-test.js +++ /dev/null @@ -1,836 +0,0 @@ -var vows = require("vows"), - _ = require("../../"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.path"); - -suite.addBatch({ - "path": { - topic: load("geo/path").expression("d3.geo.path"), - - "with an equirectangular projection": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .precision(0)); - }, - - "renders a point": function(p) { - p({ - type: "Point", - coordinates: [-63, 18] - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 170, y: 160}, - {type: "arc", x: 165, y: 160, r: 4.5} - ]); - }, - - "renders a multipoint": function(p) { - p({ - type: "MultiPoint", - coordinates: [[-63, 18], [-62, 18], [-62, 17]] - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 170, y: 160}, {type: "arc", x: 165, y: 160, r: 4.5}, - {type: "moveTo", x: 175, y: 160}, {type: "arc", x: 170, y: 160, r: 4.5}, - {type: "moveTo", x: 175, y: 165}, {type: "arc", x: 170, y: 165, r: 4.5} - ]); - }, - - "renders a line string": function(p) { - p({ - type: "Feature", - geometry: { - type: "LineString", - coordinates: [[-63, 18], [-62, 18], [-62, 17]] - } - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 165, y: 160}, - {type: "lineTo", x: 170, y: 160}, - {type: "lineTo", x: 170, y: 165} - ]); - }, - - "renders a polygon": function(p) { - p({ - type: "Feature", - geometry: { - type: "Polygon", - coordinates: [[[-63, 18], [-62, 18], [-62, 17], [-63, 18]]] - } - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 165, y: 160}, - {type: "lineTo", x: 170, y: 160}, - {type: "lineTo", x: 170, y: 165}, - {type: "closePath"} - ]); - }, - - "renders a geometry collection": function(p) { - p({ - type: "GeometryCollection", - geometries: [{type: "Point", coordinates: [0, 0]}] - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 485, y: 250}, {type: "arc", x: 480, y: 250, r: 4.5} - ]); - }, - - "renders a feature collection": function(p) { - p({ - type: "FeatureCollection", - features: [{type: "Feature", geometry: {type: "Point", coordinates: [0, 0]}}] - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 485, y: 250}, {type: "arc", x: 480, y: 250, r: 4.5} - ]); - }, - - "longitudes wrap at ±180°": function(p) { - p({type: "Point", coordinates: [180 + 1e-6, 0]}); - assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: -415, y: 250}, {type: "arc", x: -420, y: 250, r: 4.5}]); - }, - - "observes the correct winding order of a tiny polygon": function(p) { - p({type: "Polygon", coordinates: [[ - [-0.06904102953339501, 0.346043661846373], - [-6.725674252975136e-15, 0.3981303360336475], - [-6.742247658534323e-15, -0.08812465346531581], - [-0.17301258217724075, -0.12278150669440671], - [-0.06904102953339501, 0.346043661846373]]]}); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 1); - }, - - "area": { - topic: function(p) { - return p.area; - }, - "of a polygon with no holes": function(area) { - assert.strictEqual(area({type: "Polygon", coordinates: [[[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]]]}), 25); - }, - "of a polygon with holes": function(area) { - assert.strictEqual(area({type: "Polygon", coordinates: [[[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]], [[100.2, 0.2], [100.8, 0.2], [100.8, 0.8], [100.2, 0.8], [100.2, 0.2]]]}), 16); - }, - "area of a Sphere": function(area) { - assert.strictEqual(area({type: "Sphere"}), 1620000); - } - }, - - "centroid": { - topic: function(p) { - return p.centroid; - }, - "of a point": function(centroid) { - assert.deepEqual(centroid({type: "Point", coordinates: [0, 0]}), [480, 250]); - }, - "of an empty multipoint": function(centroid) { - assert.ok(centroid({type: "MultiPoint", coordinates: []}).every(isNaN)); - }, - "of a singleton multipoint": function(centroid) { - assert.deepEqual(centroid({type: "MultiPoint", coordinates: [[0, 0]]}), [480, 250]); - }, - "of a multipoint with two points": function(centroid) { - assert.deepEqual(centroid({type: "MultiPoint", coordinates: [[-122, 37], [-74, 40]]}), [-10, 57.5]); - }, - "of an empty linestring": function(centroid) { - assert.ok(centroid({type: "LineString", coordinates: []}).every(isNaN)); - }, - "of a linestring with two points": function(centroid) { - assert.deepEqual(centroid({type: "LineString", coordinates: [[100, 0], [0, 0]]}), [730, 250]); - assert.deepEqual(centroid({type: "LineString", coordinates: [[0, 0], [100, 0], [101, 0]]}), [732.5, 250]); - }, - "of a linestring with two points, one unique": function(centroid) { - assert.deepEqual(centroid({type: "LineString", coordinates: [[-122, 37], [-122, 37]]}), [-130, 65]); - assert.deepEqual(centroid({type: "LineString", coordinates: [[-74, 40], [-74, 40]]}), [110, 50]); - }, - "of a linestring with three points; two unique": function(centroid) { - assert.deepEqual(centroid({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-74, 40]]}), [-10, 57.5]); - }, - "of a linestring with three points": function(centroid) { - assert.inDelta(centroid({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-100, 0]]}), [17.389135, 103.563545], 1e-6); - }, - "of a multilinestring": function(centroid) { - assert.deepEqual(centroid({type: "MultiLineString", coordinates: [[[100, 0], [0, 0]], [[-10, 0], [0, 0]]]}), [705, 250]); - }, - "of a single-ring polygon": function(centroid) { - assert.deepEqual(centroid({type: "Polygon", coordinates: [[[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]]]}), [982.5, 247.5]); - }, - "of a zero-area polygon": function(centroid) { - assert.deepEqual(centroid({type: "Polygon", coordinates: [[[1, 0], [2, 0], [3, 0], [1, 0]]]}), [490, 250]); - }, - "of a polygon with two rings, one with zero area": function(centroid) { - assert.deepEqual(centroid({type: "Polygon", coordinates: [ - [[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]], - [[100.1, 0], [100.2, 0], [100.3, 0], [100.1, 0] - ]]}), [982.5, 247.5]); - }, - "of a polygon with clockwise exterior and anticlockwise interior": function(centroid) { - assert.inDelta(centroid({ - type: "Polygon", - coordinates: [ - [[-2, -2], [2, -2], [2, 2], [-2, 2], [-2, -2]].reverse(), - [[ 0, -1], [1, -1], [1, 1], [ 0, 1], [ 0, -1]] - ] - }), [479.642857, 250], 1e-6); - }, - "of an empty multipolygon": function(centroid) { - assert.ok(centroid({type: "MultiPolygon", coordinates: []}).every(isNaN)); - }, - "of a singleton multipolygon": function(centroid) { - assert.deepEqual(centroid({type: "MultiPolygon", coordinates: [[[[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]]]]}), [982.5, 247.5]); - }, - "of a multipolygon with two polygons": function(centroid) { - assert.deepEqual(centroid({type: "MultiPolygon", coordinates: [ - [[[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]]], - [[[0, 0], [1, 0], [1, -1], [0, -1], [0, 0]]] - ]}), [732.5, 250]); - }, - "of a multipolygon with two polygons, one zero area": function(centroid) { - assert.deepEqual(centroid({type: "MultiPolygon", coordinates: [ - [[[100, 0], [100, 1], [101, 1], [101, 0], [100, 0]]], - [[[0, 0], [1, 0], [2, 0], [0, 0]]] - ]}), [982.5, 247.5]); - }, - "of a geometry collection with a single point": function(centroid) { - assert.deepEqual(centroid({type: "GeometryCollection", geometries: [{type: "Point", coordinates: [0, 0]}]}), [480, 250]); - }, - "of a geometry collection with a point and a linestring": function(centroid) { - assert.deepEqual(centroid({type: "GeometryCollection", geometries: [ - {type: "LineString", coordinates: [[179, 0], [180, 0]]}, - {type: "Point", coordinates: [0, 0]} - ]}), [1377.5, 250]); - }, - "of a geometry collection with a point, linestring and polygon": function(centroid) { - assert.deepEqual(centroid({type: "GeometryCollection", geometries: [ - {type: "Polygon", coordinates: [[[-180, 0], [-180, 1], [-179, 1], [-179, 0], [-180, 0]]]}, - {type: "LineString", coordinates: [[179, 0], [180, 0]]}, - {type: "Point", coordinates: [0, 0]} - ]}), [-417.5, 247.5]); - }, - "of a feature collection with a point": function(centroid) { - assert.deepEqual(centroid({type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "Point", coordinates: [0, 0]}}]}), [480, 250]); - }, - "of a feature collection with a point and a line string": function(centroid) { - assert.deepEqual(centroid({type: "FeatureCollection", features: [ - {type: "Feature", geometry: {type: "LineString", coordinates: [[179, 0], [180, 0]]}}, - {type: "Feature", geometry: {type: "Point", coordinates: [0, 0]}} - ]}), [1377.5, 250]); - }, - "of a feature collection with a point, line string and polygon": function(centroid) { - assert.deepEqual(centroid({type: "FeatureCollection", features: [ - {type: "Feature", geometry: {type: "Polygon", coordinates: [[[-180, 0], [-180, 1], [-179, 1], [-179, 0], [-180, 0]]]}}, - {type: "Feature", geometry: {type: "LineString", coordinates: [[179, 0], [180, 0]]}}, - {type: "Feature", geometry: {type: "Point", coordinates: [0, 0]}} - ]}), [-417.5, 247.5]); - }, - "of a sphere": function(centroid) { - assert.deepEqual(centroid({type: "Sphere"}), [480, 250]); - } - } - }, - - "with a null (identity) projection": { - topic: function(path) { - return path() - .context(testContext) - .projection(null); - }, - "renders a Polygon": function(p) { - p({ - type: "Feature", - geometry: { - type: "Polygon", - coordinates: [[[-63, 18], [-62, 18], [-62, 17], [-63, 18]]] - } - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: -63, y: 18}, - {type: "lineTo", x: -62, y: 18}, - {type: "lineTo", x: -62, y: 17}, - {type: "closePath"} - ]); - } - }, - - "with the default context (null) and an identity projection": { - topic: function(path) { - return path() - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .precision(0)); - }, - "returns null when passed null or undefined": function(p) { - assert.equal(p(null), null); - assert.equal(p(undefined), null); - assert.equal(p(), null); - }, - "returns null with bogus type name": function(p) { - assert.equal(p({ - type: "Feature", - geometry: { - type: "__proto__", - coordinates: [[[-63.03, 18.02], [-63.14, 18.06], [-63.01, 18.07], [-63.03, 18.02]]] - } - }), null); - } - }, - - "with the default context (null) and default projection (albers-usa)": { - topic: function(path) { - return path(); - }, - "area of a polygon": function(p) { - var area = p.area({type: "Polygon", coordinates: [[[-122, 37], [-71, 42], [-80, 25], [-122, 37]]]}); - assert.inDelta(area, 124884.274, 1e-3); - }, - "bounds of a line string": function(p) { - assert.inDelta(p.bounds({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-100, 0]]}), - [[109.378, 189.584], [797.758, 504.660]], 1e-3); - }, - "centroid of a line string": function(p) { - assert.inDelta(p.centroid({type: "LineString", coordinates: [[-122, 37], [-74, 40], [-100, 0]]}), [545.131, 253.860], 1e-3); - } - }, - - "with an equirectangular projection rotated by [180, -248]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([-180, -248]) - .scale(900 / Math.PI) - .precision(0)); - }, - "renders a polygon": function(p) { - p({type: "Polygon", coordinates: [[[-175.03150315031502, 66.57410661866186], [-174.34743474347434, 66.33097912391239], [-174.5994599459946, 67.0603616081608], [-171.86318631863185, 66.90406536153614], [-169.9189918991899, 65.96628788178816], [-170.89108910891088, 65.53213164116411], [-172.54725472547256, 65.42793414341432], [-172.5832583258326, 64.45542416441643], [-172.97929792979298, 64.2470291689169], [-173.91539153915392, 64.28176166816681], [-174.67146714671466, 64.62908666066605], [-176.003600360036, 64.90694665466546], [-176.21962196219621, 65.34110289528951], [-177.22772277227722, 65.51476539153916], [-178.37983798379838, 65.37583539453945], [-178.91989198919893, 65.72316038703869], [-178.7038703870387, 66.10521787878787], [-179.8919891989199, 65.8620903840384], [-179.45994599459945, 65.3932016441644], [-180, 64.97641165316531], [-180, 68.95328281728172], [-177.55175517551754, 68.18916783378336], [-174.95949594959495, 67.19929160516051], [-175.03150315031502, 66.57410661866186]]]}); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 1370, y: 243}]); - } - }, - - "projection": { - "returns the current projection when called with no arguments": function(path) { - var p = path(), projection = _.geo.equirectangular(); - p.projection(projection); - assert.strictEqual(p.projection(), projection); - } - }, - - "pointRadius": { - "returns the current point radius when called with no arguments": function(path) { - var p = path(), radius = function() { return 5; }; - assert.strictEqual(p.pointRadius(), 4.5); - assert.strictEqual(p.pointRadius(radius).pointRadius(), radius); - }, - "coerces point radius to a number": { - "when the radius is specified as a constant": function(path) { - var p = path().projection(null).context(testContext).pointRadius("6"); - assert.strictEqual(p.pointRadius(), 6); - p({type: "Point", coordinates: [0, 0]}); - assert.strictEqual(testContext.buffer().filter(function(d) { return d.type === "arc"; })[0].r, 6); - }, - "when the radius is specified as a function": function(path) { - var p = path().projection(null).context(testContext).pointRadius(function() { return "6"; }); - p({type: "Point", coordinates: [0, 0]}); - assert.strictEqual(testContext.buffer().filter(function(d) { return d.type === "arc"; })[0].r, 6); - } - } - }, - - "with an equirectangular projection clipped to 90°": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - "renders a point": function(p) { - p({ - type: "Point", - coordinates: [-63, 18] - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 170, y: 160}, {type: "arc", x: 165, y: 160, r: 4.5} - ]); - }, - "renders a multipoint": function(p) { - p({ - type: "MultiPoint", - coordinates: [[-63, 18], [-62, 18], [-62, 17]] - }); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 170, y: 160}, {type: "arc", x: 165, y: 160, r: 4.5}, - {type: "moveTo", x: 175, y: 160}, {type: "arc", x: 170, y: 160, r: 4.5}, - {type: "moveTo", x: 175, y: 165}, {type: "arc", x: 170, y: 165, r: 4.5} - ]); - }, - "inserts exterior along clip edge if polygon interior surrounds it": function(p) { - p({type: "Polygon", coordinates: [[[80, -80], [80, 80], [-80, 80], [-80, -80], [80, -80]]]}); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 2); - }, - "inserts exterior along clip edge if polygon exterior surrounds it": function(p) { - p({type: "Polygon", coordinates: [[[100, -80], [-100, -80], [-100, 80], [100, 80], [100, -80]]]}); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 1); - }, - "renders a small circle of 60°": function(p) { - p(_.geo.circle().angle(60)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 276, y: 493}]); - }, - "renders a small circle of 120°": function(p) { - p(_.geo.circle().angle(120)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 87, y: 700}]); - }, - "degenerate polygon": function(p) { - p({type: "Polygon", coordinates: [[[0, 0], [0, 0], [0, 0], [0, 0]]]}); - assert.deepEqual(testContext.buffer(), []); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [-17°, -451°]": { - "renders a polygon": function(path) { - var pole = _.range(-180, 180, 10).map(function(x) { return [x, 70]; }); - pole.push(pole[0]); - path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([-17, -451]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90))({type: "Polygon", coordinates: [pole]}); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [ - {type: "moveTo", x: 510, y: 160}, - {type: "moveTo", x: 87, y: 700} - ]); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [71.03°, 42.37°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([71.03, 42.37]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - /* - "grid component": function(path) { - var yStepsBig = _.range(-90, 90, 10); - path({type: "LineString", coordinates: yStepsBig.map(function(y) { return [110, y]; })}); - assert.inDelta(testContext.buffer(), [[ - [109.538009, -90], - [110, -80], - [110, -70], - [110, -60], - [110, -50], - [110, -47.625390] - ]], 1e-6); - }, - */ - "can completely clip a LineString": function(p) { - p({type: "LineString", coordinates: [[90.0, -42.37], [95.0, -42.37], [90.0, -42.37]]}); - assert.deepEqual(testContext.buffer(), []); - }, - "doesn't insert a duplicate point": function(p) { - p({type: "LineString", coordinates: [[0, 0]]}); - assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: 859, y: 187}]); - }, - "renders a visible point": function(p) { - p({type: "Point", coordinates: [0, 0]}); - assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: 863, y: 187}, {type: "arc", x: 859, y: 187, r: 4.5}]); - }, - "does not render an invisible point": function(p) { - p({type: "Point", coordinates: [-180, 0]}); - assert.deepEqual(testContext.buffer(), []); - }, - "renders a multipoint": function(p) { - p({type: "MultiPoint", coordinates: [[0, 0], [-180, 0]]}); - assert.deepEqual(testContext.buffer(), [{type: "moveTo", x: 863, y: 187}, {type: "arc", x: 859, y: 187, r: 4.5}]); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [-24°, -175.5°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([-24, -175.5]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - "renders Antarctica with no gaps": function(p) { - p(antarctica); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 2); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [90°, 0°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([90, 0]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - "renders a small circle of 60°": function(p) { - p(_.geo.circle().angle(60)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 930, y: 550}]); - }, - "renders a small circle of 120°": function(p) { - p(_.geo.circle().angle(120)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 30, y: 550}]); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [180°, 0°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([180, 0]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - "does not render a small circle of 60°": function(p) { - p(_.geo.circle().angle(60)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), []); - }, - "renders a small circle of 120° in two parts": function(p) { - p(_.geo.circle().angle(120)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [ - {type: "moveTo", x: 276, y: 493}, - {type: "moveTo", x: 87, y: 700} - ]); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [270°, 0°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([270, 0]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - "renders a small circle of 60°": function(p) { - p(_.geo.circle().angle(60)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 30, y: -50}]); - }, - "renders a small circle of 120°": function(p) { - p(_.geo.circle().angle(120)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 930, y: -50}]); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [210°, 1°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([210, 1]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - "renders a small circle of 120°": function(p) { - p(_.geo.circle().angle(120)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 930, y: 250}]); - } - }, - - "with an equirectangular projection clipped to 90° and rotated by [-150°, 60°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .rotate([-150, 60]) - .scale(900 / Math.PI) - .precision(0) - .clipAngle(90)); - }, - "renders a small circle of 120°": function(p) { - p(_.geo.circle().angle(120)()); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 30, y: -87}]); - }, - "renders a sphere": function(p) { - p({type: "Sphere"}); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [{type: "moveTo", x: 87, y: 700}]); - } - }, - - "with an equirectangular projection clipped to 170°": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .precision(0) - .clipAngle(170)); - }, - "renders stripes": function(p) { - p(stripes(80, -80)); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [ - {type: "moveTo", x: -420, y: -150}, - {type: "moveTo", x: -420, y: 650}, - {type: "moveTo", x: 1331, y: 259} - ]); - } - }, - - "with an equirectangular projection clipped to 170° and rotated by [0°, -90°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .rotate([0, -90]) - .precision(0) - .clipAngle(170)); - }, - "renders stripes": function(p) { - p(stripes(80, -80)); - assert.deepEqual(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }), [ - {type: "moveTo", x: 480, y: 200}, - {type: "moveTo", x: 1350, y: 210} - ]); - } - }, - - "with an equirectangular projection clipped to 30°": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .precision(0) - .clipAngle(30)); - }, - "clips lines with two invisible endpoints and visible middle": function(p) { - p({type: "LineString", coordinates: [[-45, 0], [45, 0]]}); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 330, y: 250}, - {type: "lineTo", x: 630, y: 250} - ]); - } - }, - - "with an equirectangular projection clipped to 150°": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .precision(0) - .clipAngle(150)); - }, - "clips lines with two visible endpoints and invisible middle": function(p) { - p({type: "LineString", coordinates: [[135, 0], [-135, 0]]}); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 1155, y: 250}, - {type: "lineTo", x: 1230, y: 250}, - {type: "moveTo", x: -270, y: 250}, - {type: "lineTo", x: -195, y: 250} - ]); - } - }, - - "with an equirectangular projection rotated by [98°, 0°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .rotate([98, 0]) - .precision(0)); - }, - "renders Keweenaw, a small U.S. county": function(p) { - p({ - type: "Polygon", - coordinates: [[[-88.23013, 47.198326], [-88.514931, 47.285957], [-88.383484, 47.285957], [-88.23013, 47.198326]]] - }); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 1); - }, - "renders Accomack, a small U.S. county": function(p) { - p({ - type: "MultiPolygon", - coordinates: [ - [[[-75.397659, 38.013497], [-75.244304, 38.029928], [-75.666029, 37.465803], [-75.939876, 37.547957], [-75.671506, 37.95325], [-75.622213, 37.991589], [-75.397659, 38.013497]]], - [[[-76.016553, 37.95325], [-76.043938, 37.95325], [-75.994645, 37.95325], [-76.016553, 37.95325]]] - ] - }); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 2); - }, - "renders Hopewell, a small U.S. county": function(p) { - p({ - type: "Polygon", - coordinates: [[[-77.298157, 37.312448], [-77.298157, 37.312448], [-77.336496, 37.312448], [-77.281726, 37.312448], [-77.298157, 37.312448]]] - }); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 1); - } - }, - - "with an equirectangular projection rotated by [330°, 232°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .rotate([330, 232]) - .precision(0)); - }, - "renders degenerate points for a small circle of 30°": function(p) { - p(_.geo.circle().angle(30)()); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 2); - } - }, - - "with an equirectangular projection rotated by [34.5°, 90°]": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .rotate([34.5, 90]) - .precision(0)); - }, - "observes proper clip point ordering for lines": function(p) { - var line = _.range(-90, 180, 10).map(function(x) { return [x, 20]; }) - .concat(_.range(170, -100, -10).map(function(x) { return [x, 0]; })) - .concat([[-90, 20]]); - p({type: "Polygon", coordinates: [line]}); - assert.equal(testContext.buffer().filter(function(d) { return d.type === "moveTo"; }).length, 3); - } - }, - - "with an equirectangular projection with the viewport clipped to 960×500": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.equirectangular() - .scale(900 / Math.PI) - .clipExtent([[0, 0], [960, 500]]) - .precision(0)); - }, - "doesn't generate a redundant closing point": function(p) { - p({type: "Polygon", coordinates: [[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]}); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 480, y: 250}, - {type: "lineTo", x: 480, y: 245}, - {type: "lineTo", x: 485, y: 245}, - {type: "lineTo", x: 485, y: 250}, - {type: "closePath"} - ]); - } - }, - - "with a stereographic projection and adaptive resampling": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.stereographic() - .precision(1)); - }, - "correctly resamples points on antimeridian": function(p) { - p({type: "LineString", coordinates: [[0, 90], [90, 0]]}); - assert.deepEqual(testContext.buffer(), [ - {type: "moveTo", x: 480, y: 100}, - {type: "lineTo", x: 509, y: 103}, - {type: "lineTo", x: 537, y: 111}, - {type: "lineTo", x: 563, y: 125}, - {type: "lineTo", x: 586, y: 144}, - {type: "lineTo", x: 605, y: 167}, - {type: "lineTo", x: 619, y: 193}, - {type: "lineTo", x: 627, y: 221}, - {type: "lineTo", x: 630, y: 250} - ]); - } - }, - - "with an Albers projection and adaptive resampling": { - "correctly resamples near the poles": function(path) { - var p = path() - .context(testContext) - .projection(_.geo.albers() - .scale(140) - .rotate([0, 0]) - .precision(1)); - p({type: "LineString", coordinates: [[0, 88], [180, 89]]}); - assert.isTrue(testContext.buffer().filter(function(d) { return d.type === "lineTo"; }).length > 1); - p({type: "LineString", coordinates: [[180, 90], [1, 89.5]]}); - assert.isTrue(testContext.buffer().filter(function(d) { return d.type === "lineTo"; }).length > 1); - }, - "rotate([11.5, 285])": function(path) { - var p = path() - .context(testContext) - .projection(_.geo.albers() - .scale(140) - .rotate([11.5, 285]) - .precision(1)); - p({type: "LineString", coordinates: [[170, 20], [170, 0]]}); - assert.isTrue(testContext.buffer().filter(function(d) { return d.type === "lineTo"; }).length > 1); - }, - "wavy projection": function(path) { - var p = path() - .context(testContext) - .projection(_.geo.projection(function(λ, φ) { - return [λ, Math.sin(λ * 4)]; - }) - .scale(140) - .precision(1)); - p({type: "LineString", coordinates: [[-45, 0], [45, 0]]}); - assert.isTrue(testContext.buffer().filter(function(d) { return d.type === "lineTo"; }).length > 1); - } - }, - - "with an Albers projection rotated by [11.5°, 285°] and adaptive resampling": { - topic: function(path) { - return path() - .context(testContext) - .projection(_.geo.albers() - .scale(140) - .rotate([11.5, 285]) - .precision(1)); - }, - "correctly resamples near the poles": function(p) { - p({type: "LineString", coordinates: [[170, 20], [170, 0]]}); - assert.isTrue(testContext.buffer().filter(function(d) { return d.type === "lineTo"; }).length > 1); - } - } - } -}); - -var testBuffer = []; - -var testContext = { - arc: function(x, y, r, a0, a1) { testBuffer.push({type: "arc", x: Math.round(x), y: Math.round(y), r: r}); }, - moveTo: function(x, y) { testBuffer.push({type: "moveTo", x: Math.round(x), y: Math.round(y)}); }, - lineTo: function(x, y) { testBuffer.push({type: "lineTo", x: Math.round(x), y: Math.round(y)}); }, - closePath: function() { testBuffer.push({type: "closePath"}); }, - buffer: function() { var result = testBuffer; testBuffer = []; return result; } -}; - -function stripes(a, b) { - return {type: "Polygon", coordinates: [a, b].map(function(d, i) { - var stripe = _.range(-180, 180, 1).map(function(x) { return [x, d]; }); - stripe.push(stripe[0]); - return i ? stripe.reverse() : stripe; - })}; -} - -var antarctica = {type: "Polygon", coordinates: [[[-58.61414,-64.15246],[-59.04507,-64.36800],[-59.78934,-64.21122],[-60.61192,-64.30920],[-61.29741,-64.54432],[-62.02210,-64.79909],[-62.51176,-65.09302],[-62.64885,-65.48494],[-62.59012,-65.85721],[-62.12007,-66.19032],[-62.80556,-66.42550],[-63.74569,-66.50384],[-64.29410,-66.83700],[-64.88169,-67.15047],[-65.50842,-67.58161],[-65.66508,-67.95388],[-65.31254,-68.36533],[-64.78371,-68.67890],[-63.96110,-68.91398],[-63.19729,-69.22755],[-62.78595,-69.61941],[-62.57051,-69.99174],[-62.27673,-70.38366],[-61.80666,-70.71676],[-61.51290,-71.08904],[-61.37580,-72.01007],[-61.08197,-72.38235],[-61.00366,-72.77426],[-60.69026,-73.16617],[-60.82736,-73.69524],[-61.37580,-74.10674],[-61.96336,-74.43984],[-63.29520,-74.57699],[-63.74569,-74.92974],[-64.35283,-75.26284],[-65.86098,-75.63512],[-67.19281,-75.79191],[-68.44628,-76.00745],[-69.79772,-76.22299],[-70.60072,-76.63449],[-72.20677,-76.67366],[-73.96953,-76.63449],[-75.55597,-76.71288],[-77.24037,-76.71288],[-76.92697,-77.10480],[-75.39929,-77.28106],[-74.28287,-77.55542],[-73.65611,-77.90811],[-74.77253,-78.22163],[-76.49610,-78.12365],[-77.92585,-78.37841],[-77.98466,-78.78991],[-78.02378,-79.18183],[-76.84863,-79.51493],[-76.63322,-79.88721],[-75.36009,-80.25954],[-73.24485,-80.41633],[-71.44294,-80.69062],[-70.01316,-81.00415],[-68.19164,-81.31767],[-65.70427,-81.47445],[-63.25603,-81.74875],[-61.55202,-82.04269],[-59.69141,-82.37585],[-58.71212,-82.84610],[-58.22248,-83.21843],[-57.00811,-82.86569],[-55.36289,-82.57175],[-53.61977,-82.25823],[-51.54364,-82.00352],[-49.76134,-81.72917],[-47.27393,-81.70958],[-44.82570,-81.84673],[-42.80836,-82.08191],[-42.16202,-81.65082],[-40.77143,-81.35689],[-38.24481,-81.33730],[-36.26666,-81.12171],[-34.38639,-80.90617],[-32.31029,-80.76902],[-30.09709,-80.59265],[-28.54980,-80.33793],[-29.25490,-79.98519],[-29.68580,-79.63250],[-29.68580,-79.26022],[-31.62480,-79.29939],[-33.68132,-79.45613],[-35.63991,-79.45613],[-35.91410,-79.08385],[-35.77700,-78.33924],[-35.32654,-78.12365],[-33.89676,-77.88852],[-32.21236,-77.65345],[-30.99805,-77.35951],[-29.78373,-77.06557],[-28.88277,-76.67366],[-27.51175,-76.49734],[-26.16033,-76.36014],[-25.47482,-76.28180],[-23.92755,-76.24258],[-22.45859,-76.10543],[-21.22469,-75.90947],[-20.01037,-75.67434],[-18.91354,-75.43921],[-17.52298,-75.12569],[-16.64158,-74.79253],[-15.70149,-74.49860],[-15.40771,-74.10674],[-16.46532,-73.87161],[-16.11278,-73.46011],[-15.44685,-73.14654],[-14.40880,-72.95058],[-13.31197,-72.71545],[-12.29350,-72.40193],[-11.51006,-72.01007],[-11.02043,-71.53976],[-10.29577,-71.26541],[-9.10101,-71.32422],[-8.61138,-71.65733],[-7.41662,-71.69650],[-7.37745,-71.32422],[-6.86823,-70.93231],[-5.79098,-71.03028],[-5.53637,-71.40261],[-4.34166,-71.46137],[-3.04898,-71.28505],[-1.79549,-71.16743],[-0.65948,-71.22624],[-0.22863,-71.63774],[0.86819,-71.30463],[1.88668,-71.12826],[3.02263,-70.99111],[4.13905,-70.85391],[5.15754,-70.61878],[6.27391,-70.46205],[7.13571,-70.24651],[7.74286,-69.89376],[8.48711,-70.14853],[9.52513,-70.01133],[10.24984,-70.48163],[10.81782,-70.83433],[11.95382,-70.63837],[12.40428,-70.24651],[13.42277,-69.97216],[14.73499,-70.03091],[15.12675,-70.40324],[15.94934,-70.03091],[17.02658,-69.91335],[18.20171,-69.87418],[19.25937,-69.89376],[20.37573,-70.01133],[21.45298,-70.07014],[21.92303,-70.40324],[22.56940,-70.69718],[23.66618,-70.52081],[24.84135,-70.48163],[25.97730,-70.48163],[27.09372,-70.46205],[28.09258,-70.32485],[29.15024,-70.20728],[30.03158,-69.93293],[30.97173,-69.75661],[31.99017,-69.65864],[32.75405,-69.38429],[33.30244,-68.83564],[33.87041,-68.50258],[34.90849,-68.65927],[35.30020,-69.01201],[36.16201,-69.24714],[37.20003,-69.16874],[37.90510,-69.52144],[38.64940,-69.77620],[39.66789,-69.54107],[40.02043,-69.10994],[40.92135,-68.93362],[41.95943,-68.60051],[42.93870,-68.46331],[44.11387,-68.26740],[44.89729,-68.05186],[45.71992,-67.81673],[46.50334,-67.60119],[47.44344,-67.71875],[48.34441,-67.36606],[48.99073,-67.09171],[49.93088,-67.11130],[50.75347,-66.87617],[50.94932,-66.52348],[51.79154,-66.24913],[52.61413,-66.05317],[53.61303,-65.89639],[54.53355,-65.81804],[55.41494,-65.87680],[56.35504,-65.97478],[57.15809,-66.24913],[57.25596,-66.68021],[58.13736,-67.01332],[58.74450,-67.28767],[59.93931,-67.40523],[60.60522,-67.67958],[61.42780,-67.95388],[62.38748,-68.01269],[63.19048,-67.81673],[64.05234,-67.40523],[64.99244,-67.62072],[65.97171,-67.73834],[66.91186,-67.85590],[67.89113,-67.93430],[68.89003,-67.93430],[69.71262,-68.97279],[69.67345,-69.22755],[69.55594,-69.67822],[68.59625,-69.93293],[67.81273,-70.30526],[67.94988,-70.69718],[69.06630,-70.67754],[68.92915,-71.06945],[68.41998,-71.44178],[67.94988,-71.85328],[68.71376,-72.16680],[69.86930,-72.26478],[71.02489,-72.08841],[71.57328,-71.69650],[71.90628,-71.32422],[72.45462,-71.01070],[73.08141,-70.71676],[73.33602,-70.36402],[73.86487,-69.87418],[74.49155,-69.77620],[75.62755,-69.73703],[76.62646,-69.61941],[77.64490,-69.46268],[78.13453,-69.07076],[78.42837,-68.69844],[79.11385,-68.32621],[80.09312,-68.07150],[80.93534,-67.87554],[81.48379,-67.54238],[82.05176,-67.36606],[82.77642,-67.20928],[83.77533,-67.30726],[84.67620,-67.20928],[85.65552,-67.09171],[86.75235,-67.15047],[87.47701,-66.87617],[87.98628,-66.20991],[88.35841,-66.48426],[88.82840,-66.95456],[89.67063,-67.15047],[90.63036,-67.22886],[91.59009,-67.11130],[92.60853,-67.18969],[93.54863,-67.20928],[94.17541,-67.11130],[95.01759,-67.17011],[95.78147,-67.38565],[96.68239,-67.24850],[97.75964,-67.24850],[98.68020,-67.11130],[99.71818,-67.24850],[100.38418,-66.91534],[100.89335,-66.58223],[101.57889,-66.30788],[102.83241,-65.56328],[103.47867,-65.70048],[104.24255,-65.97478],[104.90845,-66.32752],[106.18156,-66.93493],[107.16088,-66.95456],[108.08139,-66.95456],[109.15863,-66.83700],[110.23583,-66.69980],[111.05847,-66.42550],[111.74395,-66.13156],[112.86037,-66.09234],[113.60467,-65.87680],[114.38808,-66.07276],[114.89730,-66.38628],[115.60238,-66.69980],[116.69916,-66.66063],[117.38470,-66.91534],[118.57946,-67.17011],[119.83292,-67.26808],[120.87099,-67.18969],[121.65441,-66.87617],[122.32036,-66.56265],[123.22129,-66.48426],[124.12227,-66.62146],[125.16024,-66.71938],[126.10039,-66.56265],[127.00142,-66.56265],[127.88276,-66.66063],[128.80328,-66.75861],[129.70425,-66.58223],[130.78145,-66.42550],[131.79994,-66.38628],[132.93589,-66.38628],[133.85646,-66.28830],[134.75738,-66.20996],[135.03158,-65.72007],[135.07075,-65.30857],[135.69748,-65.58286],[135.87380,-66.03359],[136.20670,-66.44509],[136.61804,-66.77819],[137.46027,-66.95456],[138.59622,-66.89576],[139.90844,-66.87617],[140.80942,-66.81736],[142.12169,-66.81736],[143.06184,-66.79778],[144.37406,-66.83700],[145.49042,-66.91534],[146.19555,-67.22886],[145.99969,-67.60119],[146.64606,-67.89513],[147.72326,-68.13025],[148.83962,-68.38502],[150.13231,-68.56129],[151.48370,-68.71812],[152.50224,-68.87481],[153.63819,-68.89450],[154.28456,-68.56129],[155.16585,-68.83564],[155.92979,-69.14921],[156.81113,-69.38429],[158.02552,-69.48226],[159.18101,-69.59983],[159.67069,-69.99174],[160.80665,-70.22687],[161.57047,-70.57961],[162.68689,-70.73635],[163.84243,-70.71676],[164.91968,-70.77552],[166.11443,-70.75593],[167.30909,-70.83433],[168.42561,-70.97148],[169.46358,-71.20666],[170.50166,-71.40261],[171.20679,-71.69650],[171.08922,-72.08841],[170.56042,-72.44115],[170.10995,-72.89182],[169.75736,-73.24452],[169.28732,-73.65601],[167.97510,-73.81280],[167.38748,-74.16549],[166.09480,-74.38104],[165.64439,-74.77295],[164.95885,-75.14528],[164.23419,-75.45880],[163.82279,-75.87030],[163.56823,-76.24258],[163.47026,-76.69330],[163.48989,-77.06557],[164.05787,-77.45744],[164.27336,-77.82977],[164.74346,-78.18251],[166.60412,-78.31961],[166.99578,-78.75074],[165.19387,-78.90748],[163.66621,-79.12302],[161.76638,-79.16224],[160.92416,-79.73048],[160.74789,-80.20073],[160.31696,-80.57306],[159.78821,-80.94539],[161.12001,-81.27850],[161.62928,-81.69000],[162.49099,-82.06227],[163.70533,-82.39543],[165.09594,-82.70895],[166.60412,-83.02247],[168.89566,-83.33599],[169.40478,-83.82589],[172.28393,-84.04143],[172.47704,-84.11791],[173.22408,-84.41371],[175.98567,-84.15899],[178.27721,-84.47251],[180.00000,-84.71338],[180.00000,-90.0],[-180.0,-90.0],[-180.0,-84.71338],[-179.94249,-84.72144],[-179.05867,-84.13941],[-177.25677,-84.45293],[-177.14080,-84.41794],[-176.86199,-84.33381],[-176.52395,-84.23181],[-176.23030,-84.14320],[-176.08467,-84.09925],[-175.93410,-84.10159],[-175.82988,-84.11791],[-174.38250,-84.53432],[-173.11655,-84.11791],[-172.88910,-84.06101],[-169.95122,-83.88464],[-168.99998,-84.11791],[-168.53019,-84.23739],[-167.02209,-84.57049],[-164.18214,-84.82520],[-161.92977,-85.13873],[-158.07137,-85.37391],[-155.19225,-85.09955],[-150.94209,-85.29551],[-148.53307,-85.60903],[-145.88891,-85.31510],[-143.10771,-85.04075],[-142.89227,-84.57049],[-146.82906,-84.53127],[-150.06073,-84.29614],[-150.90292,-83.90423],[-153.58620,-83.68868],[-153.40990,-83.23801],[-153.03775,-82.82652],[-152.66563,-82.45419],[-152.86151,-82.04269],[-154.52629,-81.76839],[-155.29017,-81.41565],[-156.83744,-81.10212],[-154.40878,-81.16093],[-152.09766,-81.00415],[-150.64829,-81.33730],[-148.86599,-81.04337],[-147.22074,-80.67104],[-146.41774,-80.33793],[-146.77028,-79.92643],[-148.06294,-79.65208],[-149.53190,-79.35820],[-151.58841,-79.29939],[-153.39032,-79.16224],[-155.32937,-79.06426],[-155.97566,-78.69193],[-157.26830,-78.37841],[-158.05176,-78.02567],[-158.36513,-76.88920],[-157.87547,-76.98723],[-156.97457,-77.30075],[-155.32937,-77.20272],[-153.74283,-77.06557],[-152.92024,-77.49666],[-151.33378,-77.39873],[-150.00194,-77.18314],[-148.74848,-76.90884],[-147.61248,-76.57573],[-146.10440,-76.47775],[-146.14352,-76.10543],[-146.49609,-75.73315],[-146.20230,-75.38041],[-144.90962,-75.20403],[-144.32203,-75.53719],[-142.79435,-75.34123],[-141.63876,-75.08647],[-140.20900,-75.06688],[-138.85759,-74.96891],[-137.50619,-74.73378],[-136.42890,-74.51824],[-135.21458,-74.30269],[-134.43119,-74.36145],[-133.74565,-74.43984],[-132.25716,-74.30269],[-130.92531,-74.47901],[-129.55428,-74.45943],[-128.24203,-74.32228],[-126.89062,-74.42026],[-125.40208,-74.51824],[-124.01149,-74.47901],[-122.56215,-74.49860],[-121.07361,-74.51824],[-119.70255,-74.47901],[-118.68414,-74.18508],[-117.46980,-74.02834],[-116.21631,-74.24389],[-115.02155,-74.06751],[-113.94433,-73.71482],[-113.29798,-74.02834],[-112.94545,-74.38104],[-112.29908,-74.71419],[-111.26105,-74.42026],[-110.06632,-74.79253],[-108.71490,-74.91010],[-107.55934,-75.18445],[-106.14914,-75.12569],[-104.87607,-74.94932],[-103.36794,-74.98849],[-102.01650,-75.12569],[-100.64553,-75.30201],[-100.11669,-74.87093],[-100.76304,-74.53782],[-101.25270,-74.18508],[-102.54533,-74.10674],[-103.11331,-73.73441],[-103.32875,-73.36208],[-103.68128,-72.61753],[-102.91748,-72.75467],[-101.60523,-72.81343],[-100.31252,-72.75467],[-99.13737,-72.91141],[-98.11888,-73.20534],[-97.68803,-73.55804],[-96.33659,-73.61684],[-95.04396,-73.47969],[-93.67290,-73.28374],[-92.43900,-73.16617],[-91.42056,-73.40130],[-90.08873,-73.32291],[-89.22695,-72.55872],[-88.42395,-73.00939],[-87.26833,-73.18576],[-86.01482,-73.08778],[-85.19223,-73.47969],[-83.87999,-73.51887],[-82.66564,-73.63643],[-81.47091,-73.85197],[-80.68744,-73.47969],[-80.29579,-73.12695],[-79.29688,-73.51887],[-77.92585,-73.42089],[-76.90736,-73.63643],[-76.22187,-73.96954],[-74.89004,-73.87161],[-73.85202,-73.65601],[-72.83353,-73.40130],[-71.61921,-73.26415],[-70.20904,-73.14654],[-68.93591,-73.00939],[-67.95662,-72.79385],[-67.36906,-72.48032],[-67.13403,-72.04924],[-67.25154,-71.63774],[-67.56494,-71.24583],[-67.91747,-70.85391],[-68.23084,-70.46205],[-68.48545,-70.10931],[-68.54420,-69.71739],[-68.44628,-69.32553],[-67.97623,-68.95320],[-67.58449,-68.54170],[-67.42784,-68.14984],[-67.62367,-67.71875],[-67.74118,-67.32684],[-67.25154,-66.87617],[-66.70318,-66.58223],[-66.05681,-66.20996],[-65.37132,-65.89639],[-64.56827,-65.60250],[-64.17654,-65.17142],[-63.62815,-64.89707],[-63.00139,-64.64230],[-62.04168,-64.58355],[-61.41492,-64.27003],[-60.70985,-64.07407],[-59.88726,-63.95651],[-59.16258,-63.70174],[-58.59455,-63.38822],[-57.81114,-63.27066],[-57.22358,-63.52542],[-57.59572,-63.85853],[-58.61414,-64.15246]]]}; - -suite.export(module); diff --git a/test/geo/point-in-polygon-mock.js b/test/geo/point-in-polygon-mock.js deleted file mode 100644 index c32a5a08d1ac68..00000000000000 --- a/test/geo/point-in-polygon-mock.js +++ /dev/null @@ -1,18 +0,0 @@ -import "../../src/geo/point-in-polygon"; -import "../../src/math/trigonometry"; - -d3.geo.pointInPolygon = function(polygon) { - polygon = polygon.map(function(ring) { - ring = ring.map(pointRadians); - ring.pop(); - return ring; - }); - - return function(point) { - return d3_geo_pointInPolygon(pointRadians(point), polygon); - }; - - function pointRadians(point) { - return [point[0] * d3_radians, point[1] * d3_radians]; - } -}; diff --git a/test/geo/point-in-polygon-test.js b/test/geo/point-in-polygon-test.js deleted file mode 100644 index a809d5b1465e0e..00000000000000 --- a/test/geo/point-in-polygon-test.js +++ /dev/null @@ -1,382 +0,0 @@ -var vows = require("vows"), - _ = require("../../"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.pointInPolygon"); - -suite.addBatch({ - "d3.geo.pointInPolygon": { - topic: load("../test/geo/point-in-polygon-mock").expression("d3.geo.pointInPolygon"), - "empty": function(pointInPolygon) { - assert.ok(!pointInPolygon([])([0, 0])); - }, - "simple": { - topic: function(pointInPolygon) { - return pointInPolygon([[[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]]]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0.1, 2])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0.1, 0.1])); - } - }, - "small circle": { - topic: function(pointInPolygon) { - return pointInPolygon(_.geo.circle().angle(60)().coordinates); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([-180, 0])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([1, 1])); - } - }, - "South pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[-60, -80], [60, -80], [180, -80], [-60, -80]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 0])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, -85])); - } - }, - "North pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[60, 80], [-60, 80], [-180, 80], [60, 80]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 0])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 85])); - } - }, - "larger than hemisphere": { - "near [0°, 0°]": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[0, 0], [1, 0], [1, 1], [0, 1], [0, 0]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0.1, 0.1])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([2, 0.1])); - } - }, - "South pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[-60, 80], [60, 80], [180, 80], [-60, 80]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 85])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 0])); - } - }, - "North pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[60, -80], [-60, -80], [-180, -80], [60, -80]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, -85])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 0])); - } - }, - "circle with radius 120°": { - topic: function(pointInPolygon) { - return pointInPolygon(_.geo.circle().angle(120)().coordinates); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([-180, 0])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([-90, 0])); - } - }, - "narrow strip hole, length 340°": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[-170, -1], [0, -1], [170, -1], [170, 1], [0, 1], [-170, 1], [-170, -1]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 0])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 20])); - } - }, - "narrow equatorial hole": { - topic: function(pointInPolygon) { - var circle = _.geo.circle().origin([0, -90]); - return pointInPolygon([ - circle.angle(90 - 0.01)().coordinates[0], - circle.angle(90 + 0.01)().coordinates[0].reverse() - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 0])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, -90])); - } - }, - "narrow equatorial strip": { - topic: function(pointInPolygon) { - var circle = _.geo.circle().origin([0, -90]); - return pointInPolygon([ - circle.angle(90 + 0.01)().coordinates[0], - circle.angle(90 - 0.01)().coordinates[0].reverse() - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, -90])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 0])); - } - } - }, - "ring": { - "near [0°, 0°]": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]], - [[0.4, 0.4], [0.6, 0.4], [0.6, 0.6], [0.4, 0.6], [0.4, 0.4]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0.5, 0.5])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0.1, 0.5])); - } - }, - "equatorial": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[0, -10], [-120, -10], [120, -10], [0, -10]], - [[0, 10], [120, 10], [-120, 10], [0, 10]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 20])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 0])); - } - }, - "excluding both poles": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[10, 10], [-10, 10], [-10, -10], [10, -10], [10, 10]].reverse(), - [[170, 10], [170, -10], [-170, -10], [-170, 10], [170, 10]].reverse() - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 90])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 0])); - } - }, - "containing both poles": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[10, 10], [-10, 10], [-10, -10], [10, -10], [10, 10]], - [[170, 10], [170, -10], [-170, -10], [-170, 10], [170, 10]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 0])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 20])); - } - }, - "containing the South pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[10, 10], [-10, 10], [-10, -10], [10, -10], [10, 10]], - [[0, 80], [120, 80], [-120, 80], [0, 80]] - ]); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 90])); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, -90])); - } - }, - "containing the North pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[10, 10], [-10, 10], [-10, -10], [10, -10], [10, 10]].reverse(), - [[0, 80], [120, 80], [-120, 80], [0, 80]].reverse() - ]); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 90])); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, -90])); - } - } - }, - "self-intersecting": { - "near [0°, 0°]": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[0, 0], [1, 0], [1, 3], [3, 3], [3, 1], [0, 1], [0, 0]] - ]); - }, - "inside": { - "counter-clockwise region": function(pointInPolygon) { - assert.ok(pointInPolygon([0.5, 0.5])); - }, - "clockwise region": function(pointInPolygon) { - assert.ok(pointInPolygon([2, 2])); - } - }, - "outside": { - "counter-clockwise region": function(pointInPolygon) { - assert.ok(!pointInPolygon([15, 0.5])); - }, - "clockwise region": function(pointInPolygon) { - assert.ok(!pointInPolygon([12, 2])); - } - } - }, - "near the South pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[-10, -80], [120, -80], [-120, -80], [10, -85], [10, -75], [-10, -75], [-10, -80]] - ]); - }, - "inside": { - "counter-clockwise region": function(pointInPolygon) { - assert.ok(pointInPolygon([0, -76])); - }, - "clockwise region": function(pointInPolygon) { - assert.ok(pointInPolygon([0, -89])); - } - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 0])); - } - }, - "near the North pole": { - topic: function(pointInPolygon) { - return pointInPolygon([ - [[-10, 80], [-10, 75], [10, 75], [10, 85], [-120, 80], [120, 80], [-10, 80]] - ]); - }, - "inside": { - "clockwise region": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 76])); - }, - "counter-clockwise region": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 89])); - } - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([0, 0])); - } - } - }, - "touching a pole": { - "hemisphere touching the South pole": { - topic: function(pointInPolygon) { - return pointInPolygon(_.geo.circle().angle(90)().coordinates); - }, - "origin is inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 0])); - } - }, - "triangle touching the South pole": { - topic: function(pointInPolygon) { - return pointInPolygon([[[180, -90], [-45, 0], [45, 0], [180, -90]]]); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([-44, 0])); - assert.ok(pointInPolygon([0, 0])); - assert.ok(pointInPolygon([0, -30])); - assert.ok(pointInPolygon([30, -80])); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([-46, 0])); - assert.ok(!pointInPolygon([0, 1])); - assert.ok(!pointInPolygon([-90, -80])); - } - }, - "triangle touching the South pole (2)": { - topic: function(pointInPolygon) { - return pointInPolygon([[[-45, 0], [45, 0], [180, -90], [-45, 0]]]); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([-44, 0])); - assert.ok(pointInPolygon([0, 0])); - assert.ok(pointInPolygon([0, -30])); - assert.ok(pointInPolygon([30, -80])); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([-46, 0])); - assert.ok(!pointInPolygon([0, 1])); - assert.ok(!pointInPolygon([-90, -80])); - } - }, - "triangle touching the South pole (3)": { - topic: function(pointInPolygon) { - return pointInPolygon([[[180, -90], [-135, 0], [135, 0], [180, -90]]]); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([0, 0])); - assert.ok(pointInPolygon([180, 1])); - assert.ok(pointInPolygon([-90, -80])); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([180, 0])); - assert.ok(!pointInPolygon([150, 0])); - assert.ok(!pointInPolygon([180, -30])); - assert.ok(!pointInPolygon([150, -80])); - } - }, - "triangle touching the North pole": { - topic: function(pointInPolygon) { - return pointInPolygon([[[180, 90], [45, 0], [-45, 0], [180, 90]]]); - }, - "inside": function(pointInPolygon) { - assert.ok(pointInPolygon([-44, 10])); - assert.ok(pointInPolygon([0, 10])); - assert.ok(pointInPolygon([30, 80])); - }, - "outside": function(pointInPolygon) { - assert.ok(!pointInPolygon([-90, 0])); - assert.ok(!pointInPolygon([0, -1])); - assert.ok(!pointInPolygon([0, -80])); - assert.ok(!pointInPolygon([-90, 1])); - assert.ok(!pointInPolygon([-90, 80])); - } - } - } - } -}); - -suite.export(module); diff --git a/test/geo/projection-test-suite.js b/test/geo/projection-test-suite.js deleted file mode 100644 index d780fd32c85bcd..00000000000000 --- a/test/geo/projection-test-suite.js +++ /dev/null @@ -1,29 +0,0 @@ -var assert = require("../assert"), - _ = require("../../"), - format = _.format("13.8f"); - -module.exports = function(suite, mapping) { - - for (var place in mapping) { - suite[place] = test(mapping[place][0], mapping[place][1]); - } - - function test(location, point) { - return function(projection) { - var actualLocation = projection.invert(point), - actualPoint = projection(location); - try { - assert.inDelta([actualPoint, actualLocation], [point, location], 1e-5); - } catch (e) { - e.message = "project [[" - + location.map(format).join(", ") + "], [" + actualPoint.map(format).join(", ") - + "]]\n invert [[" - + actualLocation.map(format).join(", ") + "], [" + point.map(format).join(", ") - + "]]"; - throw e; - } - }; - } - - return suite; -}; diff --git a/test/geo/projection-test.js b/test/geo/projection-test.js deleted file mode 100644 index b68d373855edc9..00000000000000 --- a/test/geo/projection-test.js +++ /dev/null @@ -1,58 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.projection"); - -suite.addBatch({ - "projection": { - topic: load("geo/projection").expression("d3.geo.projection"), - "a custom invertible projection": { - topic: function(projection) { - function forward(λ, φ) { return [λ, φ]; } - forward.invert = function(x, y) {}; - return projection(forward); - }, - - "invert": { - "can return undefined": function(projection) { - assert.isUndefined(projection.invert([0, 0])); - } - }, - - "scale": { - "defaults to 150": function(projection) { - assert.equal(projection.scale(), 150); - }, - "is coerced to a number": function(projection) { - assert.strictEqual(projection.scale("400"), projection); - assert.strictEqual(projection.scale(), 400); - } - }, - - "translate": { - "defaults to [480, 250]": function(projection) { - assert.deepEqual(projection.translate(), [480, 250]); - }, - "is coerced to two numbers": function(projection) { - assert.strictEqual(projection.translate(["23", "141"]), projection); - assert.strictEqual(projection.translate()[0], 23); - assert.strictEqual(projection.translate()[1], 141); - } - }, - - "rotate": { - "defaults to [0, 0, 0]": function(projection) { - assert.deepEqual(projection.rotate(), [0, 0, 0]); - }, - "is coerced to three numbers": function(projection) { - assert.strictEqual(projection.rotate(["23", "41"]), projection); - assert.strictEqual(projection.rotate()[0], 23); - assert.strictEqual(projection.rotate()[1], 41); - } - } - } - } -}); - -suite.export(module); diff --git a/test/geo/rotation-test.js b/test/geo/rotation-test.js deleted file mode 100644 index d664e43e8c0741..00000000000000 --- a/test/geo/rotation-test.js +++ /dev/null @@ -1,35 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.rotation"); - -suite.addBatch({ - "rotation": { - topic: load("geo/rotation").expression("d3.geo.rotation"), - "a rotation of [+90°, 0°]": { - topic: function(rotation) { - return rotation([90, 0]); - }, - "only rotates longitude": function(rotation) { - assert.inDelta(rotation([0, 0]), [90, 0], 1e-6); - }, - "wraps around when crossing the antimeridian": function(rotation) { - assert.inDelta(rotation([150, 0]), [-120, 0], 1e-6); - } - }, - "a rotation of [-45°, -45°]": { - topic: function(rotation) { - return rotation([-45, 45]); - }, - "rotates longitude and latitude": function(rotation) { - assert.inDelta(rotation([0, 0]), [-54.73561, 30], 1e-6); - }, - "inverse rotation of longitude and latitude": function(rotation) { - assert.inDelta(rotation.invert([-54.73561, 30]), [0, 0], 1e-6); - } - } - } -}); - -suite.export(module); diff --git a/test/geo/stereographic-test.js b/test/geo/stereographic-test.js deleted file mode 100644 index 098719834e5f6c..00000000000000 --- a/test/geo/stereographic-test.js +++ /dev/null @@ -1,38 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.stereographic"); - -suite.addBatch({ - "stereographic": { - topic: load("geo/stereographic").expression("d3.geo.stereographic"), - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 473.84094732, 117.14003304]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 459.00877672, 123.45642208]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 482.65216217, 160.62316700]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 449.13660231, 342.87385937]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 493.06074697, 121.99919699]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 387.44967610]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 112.55032390]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.04106035, -0.88573312]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.13994149, -0.84362385]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.01768108, -0.59584555]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.20575598, 0.61915906]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.08707165, -0.85333869]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 0.91633117]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -0.91633117]] - }) - } -}); - -suite.export(module); diff --git a/test/geo/stream-test.js b/test/geo/stream-test.js deleted file mode 100644 index e25318b0e5a972..00000000000000 --- a/test/geo/stream-test.js +++ /dev/null @@ -1,214 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"); - -var suite = vows.describe("d3.geo.stream"); - -suite.addBatch({ - "stream": { - topic: load("geo/stream").expression("d3.geo.stream"), - "does not allow null input": function(stream) { - try { - stream(null); - assert.fail("expected error"); - } catch (expected) {} - }, - "ignores unknown types": function(stream) { - stream({type: "Unknown"}, {}); - stream({type: "Feature", geometry: {type: "Unknown"}}, {}); - stream({type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "Unknown"}}]}, {}); - stream({type: "GeometryCollection", geometries: [{type: "Unknown"}]}, {}); - }, - "ignores null geometries": function(stream) { - stream(null, {}); - stream({type: "Feature", geometry: null}, {}); - stream({type: "FeatureCollection", features: [{type: "Feature", geometry: null}]}, {}); - stream({type: "GeometryCollection", geometries: [null]}, {}); - }, - "returns void": function(stream) { - assert.isUndefined(stream({type: "Point", coordinates: [1, 2]}, {point: function() { return true; }})); - }, - "allows empty multi-geometries": function(stream) { - stream({type: "MultiPoint", coordinates: []}, {}); - stream({type: "MultiLineString", coordinates: []}, {}); - stream({type: "MultiPolygon", coordinates: []}, {}); - }, - "Sphere ↦ sphere": function(stream) { - var calls = 0; - stream({type: "Sphere"}, { - sphere: function() { - assert.equal(arguments.length, 0); - assert.equal(++calls, 1); - } - }); - assert.equal(calls, 1); - }, - "Point ↦ point": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "Point", coordinates: [1, 2, 3]}, { - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.equal(++calls, 1); - } - }); - assert.equal(calls, 1); - }, - "MultiPoint ↦ point*": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "MultiPoint", coordinates: [[1, 2, 3], [4, 5, 6]]}, { - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.isTrue(1 <= ++calls && calls <= 2); - } - }); - assert.equal(calls, 2); - }, - "LineString ↦ lineStart, point{2,}, lineEnd": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "LineString", coordinates: [[1, 2, 3], [4, 5, 6]]}, { - lineStart: function() { - assert.equal(arguments.length, 0); - assert.equal(++calls, 1); - }, - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.isTrue(2 <= ++calls && calls <= 3); - }, - lineEnd: function() { - assert.equal(arguments.length, 0); - assert.equal(++calls, 4); - } - }); - assert.equal(calls, 4); - }, - "MultiLineString ↦ (lineStart, point{2,}, lineEnd)*": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "MultiLineString", coordinates: [[[1, 2, 3], [4, 5, 6]], [[7, 8, 9], [10, 11, 12]]]}, { - lineStart: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 1 || calls === 5); - }, - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.isTrue(2 <= ++calls && calls <= 3 || 6 <= calls && calls <= 7); - }, - lineEnd: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 4 || calls === 8); - } - }); - assert.equal(calls, 8); - }, - "Polygon ↦ polygonStart, lineStart, point{2,}, lineEnd, polygonEnd": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "Polygon", coordinates: [[[1, 2, 3], [4, 5, 6], [1, 2, 3]], [[7, 8, 9], [10, 11, 12], [7, 8, 9]]]}, { - polygonStart: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 1); - }, - lineStart: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 2 || calls === 6); - }, - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.isTrue(3 <= ++calls && calls <= 4 || 7 <= calls && calls <= 8); - }, - lineEnd: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 5 || calls === 9); - }, - polygonEnd: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 10); - } - }); - assert.equal(calls, 10); - }, - "MultiPolygon ↦ (polygonStart, lineStart, point{2,}, lineEnd, polygonEnd)*": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "MultiPolygon", coordinates: [[[[1, 2, 3], [4, 5, 6], [1, 2, 3]]], [[[7, 8, 9], [10, 11, 12], [7, 8, 9]]]]}, { - polygonStart: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 1 || calls === 7); - }, - lineStart: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 2 || calls === 8); - }, - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.isTrue(3 <= ++calls && calls <= 4 || 9 <= calls && calls <= 10); - }, - lineEnd: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 5 || calls === 11); - }, - polygonEnd: function() { - assert.equal(arguments.length, 0); - assert.isTrue(++calls === 6 || calls === 12); - } - }); - assert.equal(calls, 12); - }, - "Feature ↦ .*": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "Feature", geometry: {type: "Point", coordinates: [1, 2, 3]}}, { - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.equal(++calls, 1); - } - }); - assert.equal(calls, 1); - }, - "FeatureCollection ↦ .*": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "FeatureCollection", features: [{type: "Feature", geometry: {type: "Point", coordinates: [1, 2, 3]}}]}, { - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.equal(++calls, 1); - } - }); - assert.equal(calls, 1); - }, - "GeometryCollection ↦ .*": function(stream) { - var calls = 0, coordinates = 0; - stream({type: "GeometryCollection", geometries: [{type: "Point", coordinates: [1, 2, 3]}]}, { - point: function(x, y, z) { - assert.equal(arguments.length, 3); - assert.equal(x, ++coordinates); - assert.equal(y, ++coordinates); - assert.equal(z, ++coordinates); - assert.equal(++calls, 1); - } - }); - assert.equal(calls, 1); - } - } -}); - -suite.export(module); diff --git a/test/geo/transverse-mercator-test.js b/test/geo/transverse-mercator-test.js deleted file mode 100644 index 88ae3ac22c2b15..00000000000000 --- a/test/geo/transverse-mercator-test.js +++ /dev/null @@ -1,45 +0,0 @@ -var vows = require("vows"), - load = require("../load"), - assert = require("../assert"), - projectionTestSuite = require("./projection-test-suite"); - -var suite = vows.describe("d3.geo.transverseMercator"); - -suite.addBatch({ - "transverseMercator": { - topic: load("geo/transverse-mercator").expression("d3.geo.transverseMercator"), - "returns the expected rotation": function(projection) { - assert.deepEqual(projection().rotate([13, 27]).rotate(), [13, 27, 0]); - assert.deepEqual(projection().rotate([13, 27, 45]).rotate(), [13, 27, 45]); - }, - "returns the expected center": function(projection) { - assert.deepEqual(projection().center([13, 27]).center(), [13, 27]); - }, - "default": projectionTestSuite({ - topic: function(projection) { return projection(); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 480.00000000, 250.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349103], [ 473.09890692, 32.39629813]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ 455.53607488, 38.07095444]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 483.91452378, 88.76181349]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ 435.43771875, 420.48139861]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 495.09974957, 37.42095689]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 480.00000000, 472.52947963]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 480.00000000, 27.47052037]] - }), - "translated to 0,0 and at scale 1": projectionTestSuite({ - topic: function(projection) { return projection().translate([0, 0]).scale(1); } - }, { - "Null Island": [[ 0.00000000, 0.00000000], [ 0.00000000, 0.00000000]], - "Honolulu, HI": [[ -21.01262744, 82.63349120], [ -0.04600729, -1.45069135]], - "San Francisco, CA": [[ -46.16620803, 77.04946507], [ -0.16309283, -1.41286030]], - "Svalbard": [[ 3.13977663, 61.55241523], [ 0.02609683, -1.07492124]], - "Tierra del Fuego": [[ -35.62300462, -60.29317484], [ -0.29708188, 1.13654266]], - "Tokyo": [[ 33.38709832, 79.49539834], [ 0.10066500, -1.41719362]], - "the South Pole": [[ 0.00000000, -85.00000000], [ 0.00000000, 1.48352986]], - "the North Pole": [[ 0.00000000, 85.00000000], [ 0.00000000, -1.48352986]] - }) - } -}); - -suite.export(module); From d4fef4759a7d7dd29360cbb891ca53422f9f689e Mon Sep 17 00:00:00 2001 From: archmoj Date: Sat, 26 Jun 2021 11:04:00 -0400 Subject: [PATCH 2/2] regen d3.min.js --- d3.min.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/d3.min.js b/d3.min.js index 89154d91e3d727..d9414e41fe9f9e 100644 --- a/d3.min.js +++ b/d3.min.js @@ -1,5 +1,4 @@ -!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function i(n){return!isNaN(n)}function u(n){return{left:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)<0?r=u+1:i=u}return r},right:function(t,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=t.length);i>r;){var u=r+i>>>1;n(t[u],e)>0?i=u:r=u+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function f(n){return(n+="")===bo||n[0]===_o?_o+n:n}function s(n){return(n+="")[0]===_o?n.slice(1):n}function h(n){return f(n)in this._}function p(n){return(n=f(n))in this._&&delete this._[n]}function g(){var n=[];for(var t in this._)n.push(s(t));return n}function v(){var n=0;for(var t in this._)++n;return n}function d(){for(var n in this._)return!1;return!0}function y(){this._=Object.create(null)}function m(n){return n}function M(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function x(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=wo.length;r>e;++e){var i=wo[e]+t;if(i in n)return i}}function b(){}function _(){}function w(n){function t(){for(var t,r=e,i=-1,u=r.length;++ie;e++)for(var i,u=n[e],o=0,a=u.length;a>o;o++)(i=u[o])&&t(i,o,e);return n}function Z(n){return ko(n,qo),n}function V(n){var t,e;return function(r,i,u){var o,a=n[u].update,l=a.length;for(u!=e&&(e=u,t=0),i>=t&&(t=i+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var c=To.get(n);return c&&(n=c,l=B),a?t?i:r:t?b:u}function $(n,t){return function(e){var r=ao.event;ao.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{ao.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++Do,i="click"+r,u=ao.select(t(e)).on("touchmove"+r,S).on("dragstart"+r,S).on("selectstart"+r,S);if(null==Ro&&(Ro="onselectstart"in e?!1:x(e.style,"userSelect")),Ro){var o=n(e).style,a=o[Ro];o[Ro]="none"}return function(n){if(u.on(r,null),Ro&&(o[Ro]=a),n){var t=function(){u.on(i,null)};u.on(i,function(){S(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();if(0>Po){var u=t(n);if(u.scrollX||u.scrollY){r=ao.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();Po=!(o.f||o.e),r.remove()}}return Po?(i.x=e.pageX,i.y=e.pageY):(i.x=e.clientX,i.y=e.clientY),i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}function G(){return ao.event.changedTouches[0].identifier}function K(n){return n>0?1:0>n?-1:0}function Q(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function nn(n){return n>1?0:-1>n?Fo:Math.acos(n)}function tn(n){return n>1?Io:-1>n?-Io:Math.asin(n)}function en(n){return((n=Math.exp(n))-1/n)/2}function rn(n){return((n=Math.exp(n))+1/n)/2}function un(n){return((n=Math.exp(2*n))-1)/(n+1)}function on(n){return(n=Math.sin(n/2))*n}function an(){}function ln(n,t,e){return this instanceof ln?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof ln?new ln(n.h,n.s,n.l):_n(""+n,wn,ln):new ln(n,t,e)}function cn(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?u+(o-u)*n/60:180>n?o:240>n?u+(o-u)*(240-n)/60:u}function i(n){return Math.round(255*r(n))}var u,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,u=2*e-o,new mn(i(n+120),i(n),i(n-120))}function fn(n,t,e){return this instanceof fn?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof fn?new fn(n.h,n.c,n.l):n instanceof hn?gn(n.l,n.a,n.b):gn((n=Sn((n=ao.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new fn(n,t,e)}function sn(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new hn(e,Math.cos(n*=Yo)*t,Math.sin(n)*t)}function hn(n,t,e){return this instanceof hn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof hn?new hn(n.l,n.a,n.b):n instanceof fn?sn(n.h,n.c,n.l):Sn((n=mn(n)).r,n.g,n.b):new hn(n,t,e)}function pn(n,t,e){var r=(n+16)/116,i=r+t/500,u=r-e/200;return i=vn(i)*na,r=vn(r)*ta,u=vn(u)*ea,new mn(yn(3.2404542*i-1.5371385*r-.4985314*u),yn(-.969266*i+1.8760108*r+.041556*u),yn(.0556434*i-.2040259*r+1.0572252*u))}function gn(n,t,e){return n>0?new fn(Math.atan2(e,t)*Zo,Math.sqrt(t*t+e*e),n):new fn(NaN,NaN,n)}function vn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function dn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function yn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function mn(n,t,e){return this instanceof mn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof mn?new mn(n.r,n.g,n.b):_n(""+n,mn,cn):new mn(n,t,e)}function Mn(n){return new mn(n>>16,n>>8&255,255&n)}function xn(n){return Mn(n)+""}function bn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function _n(n,t,e){var r,i,u,o=0,a=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(i=r[2].split(","),r[1]){case"hsl":return e(parseFloat(i[0]),parseFloat(i[1])/100,parseFloat(i[2])/100);case"rgb":return t(Nn(i[0]),Nn(i[1]),Nn(i[2]))}return(u=ua.get(n))?t(u.r,u.g,u.b):(null==n||"#"!==n.charAt(0)||isNaN(u=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&u)>>4,o=o>>4|o,a=240&u,a=a>>4|a,l=15&u,l=l<<4|l):7===n.length&&(o=(16711680&u)>>16,a=(65280&u)>>8,l=255&u)),t(o,a,l))}function wn(n,t,e){var r,i,u=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-u,l=(o+u)/2;return a?(i=.5>l?a/(o+u):a/(2-o-u),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=NaN,i=l>0&&1>l?0:r),new ln(r,i,l)}function Sn(n,t,e){n=kn(n),t=kn(t),e=kn(e);var r=dn((.4124564*n+.3575761*t+.1804375*e)/na),i=dn((.2126729*n+.7151522*t+.072175*e)/ta),u=dn((.0193339*n+.119192*t+.9503041*e)/ea);return hn(116*i-16,500*(r-i),200*(i-u))}function kn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function Nn(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function En(n){return"function"==typeof n?n:function(){return n}}function An(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),Cn(t,e,n,r)}}function Cn(n,t,e,r){function i(){var n,t=l.status;if(!t&&Ln(l)||t>=200&&300>t||304===t){try{n=e.call(u,l)}catch(r){return void o.error.call(u,r)}o.load.call(u,n)}else o.error.call(u,l)}var u={},o=ao.dispatch("beforesend","progress","load","error"),a={},l=new XMLHttpRequest,c=null;return!self.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(n)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=i:l.onreadystatechange=function(){l.readyState>3&&i()},l.onprogress=function(n){var t=ao.event;ao.event=n;try{o.progress.call(u,l)}finally{ao.event=t}},u.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",u)},u.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",u):t},u.responseType=function(n){return arguments.length?(c=n,u):c},u.response=function(n){return e=n,u},["get","post"].forEach(function(n){u[n]=function(){return u.send.apply(u,[n].concat(co(arguments)))}}),u.send=function(e,r,i){if(2===arguments.length&&"function"==typeof r&&(i=r,r=null),l.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),l.setRequestHeader)for(var f in a)l.setRequestHeader(f,a[f]);return null!=t&&l.overrideMimeType&&l.overrideMimeType(t),null!=c&&(l.responseType=c),null!=i&&u.on("error",i).on("load",function(n){i(null,n)}),o.beforesend.call(u,l),l.send(null==r?null:r),u},u.abort=function(){return l.abort(),u},ao.rebind(u,o,"on"),null==r?u:u.get(zn(r))}function zn(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function Ln(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function qn(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var i=e+t,u={c:n,t:i,n:null};return aa?aa.n=u:oa=u,aa=u,la||(ca=clearTimeout(ca),la=1,fa(Tn)),u}function Tn(){var n=Rn(),t=Dn()-n;t>24?(isFinite(t)&&(clearTimeout(ca),ca=setTimeout(Tn,t)),la=0):(la=1,fa(Tn))}function Rn(){for(var n=Date.now(),t=oa;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function Dn(){for(var n,t=oa,e=1/0;t;)t.c?(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function jn(n){var t=n.decimal,e=n.thousands,r=n.grouping,i=n.currency,u=r&&e?function(n,t){for(var i=n.length,u=[],o=0,a=r[0],l=0;i>0&&a>0&&(l+a+1>t&&(a=Math.max(1,t-l)),u.push(n.substring(i-=a,i+a)),!((l+=a+1)>t));)a=r[o=(o+1)%r.length];return u.reverse().join(e)}:m;return function(n){var e=ha.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",l=e[4]||"",c=e[5],f=+e[6],s=e[7],h=e[8],p=e[9],g=1,v="",d="",y=!1,m=!0;switch(h&&(h=+h.substring(1)),(c||"0"===r&&"="===o)&&(c=r="0",o="="),p){case"n":s=!0,p="g";break;case"%":g=100,d="%",p="f";break;case"p":g=100,d="%",p="r";break;case"b":case"o":case"x":case"X":"#"===l&&(v="0"+p.toLowerCase());case"c":m=!1;case"d":y=!0,h=0;break;case"s":g=-1,p="r"}"$"===l&&(v=i[0],d=i[1]),"r"!=p||h||(p="g"),null!=h&&("g"==p?h=Math.max(1,Math.min(21,h)):"e"!=p&&"f"!=p||(h=Math.max(0,Math.min(20,h)))),p=pa.get(p)||Fn;var M=c&&s;return function(n){var e=d;if(y&&n%1)return"";var i=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>g){var l=ao.formatPrefix(n,h);n=l.scale(n),e=l.symbol+d}else n*=g;n=p(n,h);var x,b,_=n.lastIndexOf(".");if(0>_){var w=m?n.lastIndexOf("e"):-1;0>w?(x=n,b=""):(x=n.substring(0,w),b=n.substring(w))}else x=n.substring(0,_),b=t+n.substring(_+1);!c&&s&&(x=u(x,1/0));var S=v.length+x.length+b.length+(M?0:i.length),k=f>S?new Array(S=f-S+1).join(r):"";return M&&(x=u(k+x,k.length?f-b.length:1/0)),i+=v,n=x+b,("<"===o?i+n+k:">"===o?k+i+n:"^"===o?k.substring(0,S>>=1)+i+n+k.substring(S):i+(M?n:k+n))+e}}}function Fn(n){return n+""}function Hn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function On(n,t,e){function r(t){var e=n(t),r=u(e,1);return r-t>t-e?e:r}function i(e){return t(e=n(new va(e-1)),1),e}function u(n,e){return t(n=new va(+n),e),n}function o(n,r,u){var o=i(n),a=[];if(u>1)for(;r>o;)e(o)%u||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{va=Hn;var r=new Hn;return r._=n,o(r,t,e)}finally{va=Date}}n.floor=n,n.round=r,n.ceil=i,n.offset=u,n.range=o;var l=n.utc=In(n);return l.floor=l,l.round=In(r),l.ceil=In(i),l.offset=In(u),l.range=a,n}function In(n){return function(t,e){try{va=Hn;var r=new Hn;return r._=t,n(r,e)._}finally{va=Date}}}function Yn(n){function t(n){function t(t){for(var e,i,u,o=[],a=-1,l=0;++aa;){if(r>=c)return-1;if(i=t.charCodeAt(a++),37===i){if(o=t.charAt(a++),u=C[o in ya?t.charAt(a++):o],!u||(r=u(n,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){_.lastIndex=0;var r=_.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){x.lastIndex=0;var r=x.exec(t.slice(e));return r?(n.w=b.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){N.lastIndex=0;var r=N.exec(t.slice(e));return r?(n.m=E.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){S.lastIndex=0;var r=S.exec(t.slice(e));return r?(n.m=k.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,A.c.toString(),t,r)}function l(n,t,r){return e(n,A.x.toString(),t,r)}function c(n,t,r){return e(n,A.X.toString(),t,r)}function f(n,t,e){var r=M.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var s=n.dateTime,h=n.date,p=n.time,g=n.periods,v=n.days,d=n.shortDays,y=n.months,m=n.shortMonths;t.utc=function(n){function e(n){try{va=Hn;var t=new va;return t._=n,r(t)}finally{va=Date}}var r=t(n);return e.parse=function(n){try{va=Hn;var t=r.parse(n);return t&&t._}finally{va=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ct;var M=ao.map(),x=Vn(v),b=Xn(v),_=Vn(d),w=Xn(d),S=Vn(y),k=Xn(y),N=Vn(m),E=Xn(m);g.forEach(function(n,t){M.set(n.toLowerCase(),t)});var A={a:function(n){return d[n.getDay()]},A:function(n){return v[n.getDay()]},b:function(n){return m[n.getMonth()]},B:function(n){return y[n.getMonth()]},c:t(s),d:function(n,t){return Zn(n.getDate(),t,2)},e:function(n,t){return Zn(n.getDate(),t,2)},H:function(n,t){return Zn(n.getHours(),t,2)},I:function(n,t){return Zn(n.getHours()%12||12,t,2)},j:function(n,t){return Zn(1+ga.dayOfYear(n),t,3)},L:function(n,t){return Zn(n.getMilliseconds(),t,3)},m:function(n,t){return Zn(n.getMonth()+1,t,2)},M:function(n,t){return Zn(n.getMinutes(),t,2)},p:function(n){return g[+(n.getHours()>=12)]},S:function(n,t){return Zn(n.getSeconds(),t,2)},U:function(n,t){return Zn(ga.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return Zn(ga.mondayOfYear(n),t,2)},x:t(h),X:t(p),y:function(n,t){return Zn(n.getFullYear()%100,t,2)},Y:function(n,t){return Zn(n.getFullYear()%1e4,t,4)},Z:at,"%":function(){return"%"}},C={a:r,A:i,b:u,B:o,c:a,d:tt,e:tt,H:rt,I:rt,j:et,L:ot,m:nt,M:it,p:f,S:ut,U:Bn,w:$n,W:Wn,x:l,X:c,y:Gn,Y:Jn,Z:Kn,"%":lt};return t}function Zn(n,t,e){var r=0>n?"-":"",i=(r?-n:n)+"",u=i.length;return r+(e>u?new Array(e-u+1).join(t)+i:i)}function Vn(n){return new RegExp("^(?:"+n.map(ao.requote).join("|")+")","i")}function Xn(n){for(var t=new c,e=-1,r=n.length;++e68?1900:2e3)}function nt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function tt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function et(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function rt(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function it(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function ut(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function ot(n,t,e){ma.lastIndex=0;var r=ma.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function at(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=xo(t)/60|0,i=xo(t)%60;return e+Zn(r,"0",2)+Zn(i,"0",2)}function lt(n,t,e){Ma.lastIndex=0;var r=Ma.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ct(n){for(var t=n.length,e=-1;++e=0?1:-1,a=o*e,l=Math.cos(t),c=Math.sin(t),f=u*c,s=i*l+f*Math.cos(a),h=f*o*Math.sin(a);ka.add(Math.atan2(h,s)),r=n,i=l,u=c}var t,e,r,i,u;Na.point=function(o,a){Na.point=n,r=(t=o)*Yo,i=Math.cos(a=(e=a)*Yo/2+Fo/4),u=Math.sin(a)},Na.lineEnd=function(){n(t,e)}}function dt(n){var t=n[0],e=n[1],r=Math.cos(e);return[r*Math.cos(t),r*Math.sin(t),Math.sin(e)]}function yt(n,t){return n[0]*t[0]+n[1]*t[1]+n[2]*t[2]}function mt(n,t){return[n[1]*t[2]-n[2]*t[1],n[2]*t[0]-n[0]*t[2],n[0]*t[1]-n[1]*t[0]]}function Mt(n,t){n[0]+=t[0],n[1]+=t[1],n[2]+=t[2]}function xt(n,t){return[n[0]*t,n[1]*t,n[2]*t]}function bt(n){var t=Math.sqrt(n[0]*n[0]+n[1]*n[1]+n[2]*n[2]);n[0]/=t,n[1]/=t,n[2]/=t}function _t(n){return[Math.atan2(n[1],n[0]),tn(n[2])]}function wt(n,t){return xo(n[0]-t[0])a;++a)i.point((e=n[a])[0],e[1]);return void i.lineEnd()}var l=new Tt(e,n,null,!0),c=new Tt(e,null,l,!1);l.o=c,u.push(l),o.push(c),l=new Tt(r,n,null,!1),c=new Tt(r,null,l,!0),l.o=c,u.push(l),o.push(c)}}),o.sort(t),qt(u),qt(o),u.length){for(var a=0,l=e,c=o.length;c>a;++a)o[a].e=l=!l;for(var f,s,h=u[0];;){for(var p=h,g=!0;p.v;)if((p=p.n)===h)return;f=p.z,i.lineStart();do{if(p.v=p.o.v=!0,p.e){if(g)for(var a=0,c=f.length;c>a;++a)i.point((s=f[a])[0],s[1]);else r(p.x,p.n.x,1,i);p=p.n}else{if(g){f=p.p.z;for(var a=f.length-1;a>=0;--a)i.point((s=f[a])[0],s[1])}else r(p.x,p.p.x,-1,i);p=p.p}p=p.o,f=p.z,g=!g}while(!p.v);i.lineEnd()}}}function qt(n){if(t=n.length){for(var t,e,r=0,i=n[0];++r0){for(b||(u.polygonStart(),b=!0),u.lineStart();++o1&&2&t&&e.push(e.pop().concat(e.shift())),p.push(e.filter(Dt))}var p,g,v,d=t(u),y=i.invert(r[0],r[1]),m={point:o,lineStart:l,lineEnd:c,polygonStart:function(){m.point=f,m.lineStart=s,m.lineEnd=h,p=[],g=[]},polygonEnd:function(){m.point=o,m.lineStart=l,m.lineEnd=c,p=ao.merge(p);var n=Ot(y,g);p.length?(b||(u.polygonStart(),b=!0),Lt(p,Ut,n,e,u)):n&&(b||(u.polygonStart(),b=!0),u.lineStart(),e(null,null,1,u),u.lineEnd()),b&&(u.polygonEnd(),b=!1),p=g=null},sphere:function(){u.polygonStart(),u.lineStart(),e(null,null,1,u),u.lineEnd(),u.polygonEnd()}},M=Pt(),x=t(M),b=!1;return m}}function Dt(n){return n.length>1}function Pt(){var n,t=[];return{lineStart:function(){t.push(n=[])},point:function(t,e){n.push([t,e])},lineEnd:b,buffer:function(){var e=t;return t=[],n=null,e},rejoin:function(){t.length>1&&t.push(t.pop().concat(t.shift()))}}}function Ut(n,t){return((n=n.x)[0]<0?n[1]-Io-Uo:Io-n[1])-((t=t.x)[0]<0?t[1]-Io-Uo:Io-t[1])}function jt(n){var t,e=NaN,r=NaN,i=NaN;return{lineStart:function(){n.lineStart(),t=1},point:function(u,o){var a=u>0?Fo:-Fo,l=xo(u-e);xo(l-Fo)0?Io:-Io),n.point(i,r),n.lineEnd(),n.lineStart(),n.point(a,r),n.point(u,r),t=0):i!==a&&l>=Fo&&(xo(e-i)Uo?Math.atan((Math.sin(t)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(t))*Math.sin(n))/(i*u*o)):(t+r)/2}function Ht(n,t,e,r){var i;if(null==n)i=e*Io,r.point(-Fo,i),r.point(0,i),r.point(Fo,i),r.point(Fo,0),r.point(Fo,-i),r.point(0,-i),r.point(-Fo,-i),r.point(-Fo,0),r.point(-Fo,i);else if(xo(n[0]-t[0])>Uo){var u=n[0]a;++a){var c=t[a],f=c.length;if(f)for(var s=c[0],h=s[0],p=s[1]/2+Fo/4,g=Math.sin(p),v=Math.cos(p),d=1;;){d===f&&(d=0),n=c[d];var y=n[0],m=n[1]/2+Fo/4,M=Math.sin(m),x=Math.cos(m),b=y-h,_=b>=0?1:-1,w=_*b,S=w>Fo,k=g*M;if(ka.add(Math.atan2(k*_*Math.sin(w),v*x+k*Math.cos(w))),u+=S?b+_*Ho:b,S^h>=e^y>=e){var N=mt(dt(s),dt(n));bt(N);var E=mt(i,N);bt(E);var A=(S^b>=0?-1:1)*tn(E[2]);(r>A||r===A&&(N[0]||N[1]))&&(o+=S^b>=0?1:-1)}if(!d++)break;h=y,g=M,v=x,s=n}}return(-Uo>u||Uo>u&&-Uo>ka)^1&o}function It(n){function t(n,t){return Math.cos(n)*Math.cos(t)>u}function e(n){var e,u,l,c,f;return{lineStart:function(){c=l=!1,f=1},point:function(s,h){var p,g=[s,h],v=t(s,h),d=o?v?0:i(s,h):v?i(s+(0>s?Fo:-Fo),h):0;if(!e&&(c=l=v)&&n.lineStart(),v!==l&&(p=r(e,g),(wt(e,p)||wt(g,p))&&(g[0]+=Uo,g[1]+=Uo,v=t(g[0],g[1]))),v!==l)f=0,v?(n.lineStart(),p=r(g,e),n.point(p[0],p[1])):(p=r(e,g),n.point(p[0],p[1]),n.lineEnd()),e=p;else if(a&&e&&o^v){var y;d&u||!(y=r(g,e,!0))||(f=0,o?(n.lineStart(),n.point(y[0][0],y[0][1]),n.point(y[1][0],y[1][1]),n.lineEnd()):(n.point(y[1][0],y[1][1]),n.lineEnd(),n.lineStart(),n.point(y[0][0],y[0][1])))}!v||e&&wt(e,g)||n.point(g[0],g[1]),e=g,l=v,u=d},lineEnd:function(){l&&n.lineEnd(),e=null},clean:function(){return f|(c&&l)<<1}}}function r(n,t,e){var r=dt(n),i=dt(t),o=[1,0,0],a=mt(r,i),l=yt(a,a),c=a[0],f=l-c*c;if(!f)return!e&&n;var s=u*l/f,h=-u*c/f,p=mt(o,a),g=xt(o,s),v=xt(a,h);Mt(g,v);var d=p,y=yt(g,d),m=yt(d,d),M=y*y-m*(yt(g,g)-1);if(!(0>M)){var x=Math.sqrt(M),b=xt(d,(-y-x)/m);if(Mt(b,g),b=_t(b),!e)return b;var _,w=n[0],S=t[0],k=n[1],N=t[1];w>S&&(_=w,w=S,S=_);var E=S-w,A=xo(E-Fo)E;if(!A&&k>N&&(_=k,k=N,N=_),C?A?k+N>0^b[1]<(xo(b[0]-w)Fo^(w<=b[0]&&b[0]<=S)){var z=xt(d,(-y+x)/m);return Mt(z,g),[b,_t(z)]}}}function i(t,e){var r=o?n:Fo-n,i=0;return-r>t?i|=1:t>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}var u=Math.cos(n),o=u>0,a=xo(u)>Uo,l=ve(n,6*Yo);return Rt(t,e,l,o?[0,-n]:[-Fo,n-Fo])}function Yt(n,t,e,r){return function(i){var u,o=i.a,a=i.b,l=o.x,c=o.y,f=a.x,s=a.y,h=0,p=1,g=f-l,v=s-c;if(u=n-l,g||!(u>0)){if(u/=g,0>g){if(h>u)return;p>u&&(p=u)}else if(g>0){if(u>p)return;u>h&&(h=u)}if(u=e-l,g||!(0>u)){if(u/=g,0>g){if(u>p)return;u>h&&(h=u)}else if(g>0){if(h>u)return;p>u&&(p=u)}if(u=t-c,v||!(u>0)){if(u/=v,0>v){if(h>u)return;p>u&&(p=u)}else if(v>0){if(u>p)return;u>h&&(h=u)}if(u=r-c,v||!(0>u)){if(u/=v,0>v){if(u>p)return;u>h&&(h=u)}else if(v>0){if(h>u)return;p>u&&(p=u)}return h>0&&(i.a={x:l+h*g,y:c+h*v}),1>p&&(i.b={x:l+p*g,y:c+p*v}),i}}}}}}function Zt(n,t,e,r){function i(r,i){return xo(r[0]-n)0?0:3:xo(r[0]-e)0?2:1:xo(r[1]-t)0?1:0:i>0?3:2}function u(n,t){return o(n.x,t.x)}function o(n,t){var e=i(n,1),r=i(t,1);return e!==r?e-r:0===e?t[1]-n[1]:1===e?n[0]-t[0]:2===e?n[1]-t[1]:t[0]-n[0]}return function(a){function l(n){for(var t=0,e=d.length,r=n[1],i=0;e>i;++i)for(var u,o=1,a=d[i],l=a.length,c=a[0];l>o;++o)u=a[o],c[1]<=r?u[1]>r&&Q(c,u,n)>0&&++t:u[1]<=r&&Q(c,u,n)<0&&--t,c=u;return 0!==t}function c(u,a,l,c){var f=0,s=0;if(null==u||(f=i(u,l))!==(s=i(a,l))||o(u,a)<0^l>0){do c.point(0===f||3===f?n:e,f>1?r:t);while((f=(f+l+4)%4)!==s)}else c.point(a[0],a[1])}function f(i,u){return i>=n&&e>=i&&u>=t&&r>=u}function s(n,t){f(n,t)&&a.point(n,t)}function h(){C.point=g,d&&d.push(y=[]),S=!0,w=!1,b=_=NaN}function p(){v&&(g(m,M),x&&w&&E.rejoin(),v.push(E.buffer())),C.point=s,w&&a.lineEnd()}function g(n,t){n=Math.max(-Ha,Math.min(Ha,n)),t=Math.max(-Ha,Math.min(Ha,t));var e=f(n,t);if(d&&y.push([n,t]),S)m=n,M=t,x=e,S=!1,e&&(a.lineStart(),a.point(n,t));else if(e&&w)a.point(n,t);else{var r={a:{x:b,y:_},b:{x:n,y:t}};A(r)?(w||(a.lineStart(),a.point(r.a.x,r.a.y)),a.point(r.b.x,r.b.y),e||a.lineEnd(),k=!1):e&&(a.lineStart(),a.point(n,t),k=!1)}b=n,_=t,w=e}var v,d,y,m,M,x,b,_,w,S,k,N=a,E=Pt(),A=Yt(n,t,e,r),C={point:s,lineStart:h,lineEnd:p,polygonStart:function(){a=E,v=[],d=[],k=!0},polygonEnd:function(){a=N,v=ao.merge(v);var t=l([n,r]),e=k&&t,i=v.length;(e||i)&&(a.polygonStart(),e&&(a.lineStart(),c(null,null,1,a),a.lineEnd()),i&&Lt(v,u,t,c,a),a.polygonEnd()),v=d=y=null}};return C}}function Vt(n){var t=0,e=Fo/3,r=ae(n),i=r(t,e);return i.parallels=function(n){return arguments.length?r(t=n[0]*Fo/180,e=n[1]*Fo/180):[t/Fo*180,e/Fo*180]},i}function Xt(n,t){function e(n,t){var e=Math.sqrt(u-2*i*Math.sin(t))/i;return[e*Math.sin(n*=i),o-e*Math.cos(n)]}var r=Math.sin(n),i=(r+Math.sin(t))/2,u=1+r*(2*i-r),o=Math.sqrt(u)/i;return e.invert=function(n,t){var e=o-t;return[Math.atan2(n,e)/i,tn((u-(n*n+e*e)*i*i)/(2*i))]},e}function $t(){function n(n,t){Ia+=i*n-r*t,r=n,i=t}var t,e,r,i;$a.point=function(u,o){$a.point=n,t=r=u,e=i=o},$a.lineEnd=function(){n(t,e)}}function Bt(n,t){Ya>n&&(Ya=n),n>Va&&(Va=n),Za>t&&(Za=t),t>Xa&&(Xa=t)}function Wt(){function n(n,t){o.push("M",n,",",t,u)}function t(n,t){o.push("M",n,",",t),a.point=e}function e(n,t){o.push("L",n,",",t)}function r(){a.point=n}function i(){o.push("Z")}var u=Jt(4.5),o=[],a={point:n,lineStart:function(){a.point=t},lineEnd:r,polygonStart:function(){a.lineEnd=i},polygonEnd:function(){a.lineEnd=r,a.point=n},pointRadius:function(n){return u=Jt(n),a},result:function(){if(o.length){var n=o.join("");return o=[],n}}};return a}function Jt(n){return"m0,"+n+"a"+n+","+n+" 0 1,1 0,"+-2*n+"a"+n+","+n+" 0 1,1 0,"+2*n+"z"}function Gt(n,t){Ca+=n,za+=t,++La}function Kt(){function n(n,r){var i=n-t,u=r-e,o=Math.sqrt(i*i+u*u);qa+=o*(t+n)/2,Ta+=o*(e+r)/2,Ra+=o,Gt(t=n,e=r)}var t,e;Wa.point=function(r,i){Wa.point=n,Gt(t=r,e=i)}}function Qt(){Wa.point=Gt}function ne(){function n(n,t){var e=n-r,u=t-i,o=Math.sqrt(e*e+u*u);qa+=o*(r+n)/2,Ta+=o*(i+t)/2,Ra+=o,o=i*n-r*t,Da+=o*(r+n),Pa+=o*(i+t),Ua+=3*o,Gt(r=n,i=t)}var t,e,r,i;Wa.point=function(u,o){Wa.point=n,Gt(t=r=u,e=i=o)},Wa.lineEnd=function(){n(t,e)}}function te(n){function t(t,e){n.moveTo(t+o,e),n.arc(t,e,o,0,Ho)}function e(t,e){n.moveTo(t,e),a.point=r}function r(t,e){n.lineTo(t,e)}function i(){a.point=t}function u(){n.closePath()}var o=4.5,a={point:t,lineStart:function(){a.point=e},lineEnd:i,polygonStart:function(){a.lineEnd=u},polygonEnd:function(){a.lineEnd=i,a.point=t},pointRadius:function(n){return o=n,a},result:b};return a}function ee(n){function t(n){return(a?r:e)(n)}function e(t){return ue(t,function(e,r){e=n(e,r),t.point(e[0],e[1])})}function r(t){function e(e,r){e=n(e,r),t.point(e[0],e[1])}function r(){M=NaN,S.point=u,t.lineStart()}function u(e,r){var u=dt([e,r]),o=n(e,r);i(M,x,m,b,_,w,M=o[0],x=o[1],m=e,b=u[0],_=u[1],w=u[2],a,t),t.point(M,x)}function o(){S.point=e,t.lineEnd()}function l(){ -r(),S.point=c,S.lineEnd=f}function c(n,t){u(s=n,h=t),p=M,g=x,v=b,d=_,y=w,S.point=u}function f(){i(M,x,m,b,_,w,p,g,s,v,d,y,a,t),S.lineEnd=o,o()}var s,h,p,g,v,d,y,m,M,x,b,_,w,S={point:e,lineStart:r,lineEnd:o,polygonStart:function(){t.polygonStart(),S.lineStart=l},polygonEnd:function(){t.polygonEnd(),S.lineStart=r}};return S}function i(t,e,r,a,l,c,f,s,h,p,g,v,d,y){var m=f-t,M=s-e,x=m*m+M*M;if(x>4*u&&d--){var b=a+p,_=l+g,w=c+v,S=Math.sqrt(b*b+_*_+w*w),k=Math.asin(w/=S),N=xo(xo(w)-1)u||xo((m*z+M*L)/x-.5)>.3||o>a*p+l*g+c*v)&&(i(t,e,r,a,l,c,A,C,N,b/=S,_/=S,w,d,y),y.point(A,C),i(A,C,N,b,_,w,f,s,h,p,g,v,d,y))}}var u=.5,o=Math.cos(30*Yo),a=16;return t.precision=function(n){return arguments.length?(a=(u=n*n)>0&&16,t):Math.sqrt(u)},t}function re(n){var t=ee(function(t,e){return n([t*Zo,e*Zo])});return function(n){return le(t(n))}}function ie(n){this.stream=n}function ue(n,t){return{point:t,sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function oe(n){return ae(function(){return n})()}function ae(n){function t(n){return n=a(n[0]*Yo,n[1]*Yo),[n[0]*h+l,c-n[1]*h]}function e(n){return n=a.invert((n[0]-l)/h,(c-n[1])/h),n&&[n[0]*Zo,n[1]*Zo]}function r(){a=Ct(o=se(y,M,x),u);var n=u(v,d);return l=p-n[0]*h,c=g+n[1]*h,i()}function i(){return f&&(f.valid=!1,f=null),t}var u,o,a,l,c,f,s=ee(function(n,t){return n=u(n,t),[n[0]*h+l,c-n[1]*h]}),h=150,p=480,g=250,v=0,d=0,y=0,M=0,x=0,b=Fa,_=m,w=null,S=null;return t.stream=function(n){return f&&(f.valid=!1),f=le(b(o,s(_(n)))),f.valid=!0,f},t.clipAngle=function(n){return arguments.length?(b=null==n?(w=n,Fa):It((w=+n)*Yo),i()):w},t.clipExtent=function(n){return arguments.length?(S=n,_=n?Zt(n[0][0],n[0][1],n[1][0],n[1][1]):m,i()):S},t.scale=function(n){return arguments.length?(h=+n,r()):h},t.translate=function(n){return arguments.length?(p=+n[0],g=+n[1],r()):[p,g]},t.center=function(n){return arguments.length?(v=n[0]%360*Yo,d=n[1]%360*Yo,r()):[v*Zo,d*Zo]},t.rotate=function(n){return arguments.length?(y=n[0]%360*Yo,M=n[1]%360*Yo,x=n.length>2?n[2]%360*Yo:0,r()):[y*Zo,M*Zo,x*Zo]},ao.rebind(t,s,"precision"),function(){return u=n.apply(this,arguments),t.invert=u.invert&&e,r()}}function le(n){return ue(n,function(t,e){n.point(t*Yo,e*Yo)})}function ce(n,t){return[n,t]}function fe(n,t){return[n>Fo?n-Ho:-Fo>n?n+Ho:n,t]}function se(n,t,e){return n?t||e?Ct(pe(n),ge(t,e)):pe(n):t||e?ge(t,e):fe}function he(n){return function(t,e){return t+=n,[t>Fo?t-Ho:-Fo>t?t+Ho:t,e]}}function pe(n){var t=he(n);return t.invert=he(-n),t}function ge(n,t){function e(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),f=c*r+a*i;return[Math.atan2(l*u-f*o,a*r-c*i),tn(f*u+l*o)]}var r=Math.cos(n),i=Math.sin(n),u=Math.cos(t),o=Math.sin(t);return e.invert=function(n,t){var e=Math.cos(t),a=Math.cos(n)*e,l=Math.sin(n)*e,c=Math.sin(t),f=c*u-l*o;return[Math.atan2(l*u+c*o,a*r+f*i),tn(f*r-a*i)]},e}function ve(n,t){var e=Math.cos(n),r=Math.sin(n);return function(i,u,o,a){var l=o*t;null!=i?(i=de(e,i),u=de(e,u),(o>0?u>i:i>u)&&(i+=o*Ho)):(i=n+o*Ho,u=n-.5*l);for(var c,f=i;o>0?f>u:u>f;f-=l)a.point((c=_t([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function de(n,t){var e=dt(t);e[0]-=n,bt(e);var r=nn(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-Uo)%(2*Math.PI)}function ye(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[n,t]})}}function me(n,t,e){var r=ao.range(n,t-Uo,e).concat(t);return function(n){return r.map(function(t){return[t,n]})}}function Me(n){return n.source}function xe(n){return n.target}function be(n,t,e,r){var i=Math.cos(t),u=Math.sin(t),o=Math.cos(r),a=Math.sin(r),l=i*Math.cos(n),c=i*Math.sin(n),f=o*Math.cos(e),s=o*Math.sin(e),h=2*Math.asin(Math.sqrt(on(r-t)+i*o*on(e-n))),p=1/Math.sin(h),g=h?function(n){var t=Math.sin(n*=h)*p,e=Math.sin(h-n)*p,r=e*l+t*f,i=e*c+t*s,o=e*u+t*a;return[Math.atan2(i,r)*Zo,Math.atan2(o,Math.sqrt(r*r+i*i))*Zo]}:function(){return[n*Zo,t*Zo]};return g.distance=h,g}function _e(){function n(n,i){var u=Math.sin(i*=Yo),o=Math.cos(i),a=xo((n*=Yo)-t),l=Math.cos(a);Ja+=Math.atan2(Math.sqrt((a=o*Math.sin(a))*a+(a=r*u-e*o*l)*a),e*u+r*o*l),t=n,e=u,r=o}var t,e,r;Ga.point=function(i,u){t=i*Yo,e=Math.sin(u*=Yo),r=Math.cos(u),Ga.point=n},Ga.lineEnd=function(){Ga.point=Ga.lineEnd=b}}function we(n,t){function e(t,e){var r=Math.cos(t),i=Math.cos(e),u=n(r*i);return[u*i*Math.sin(t),u*Math.sin(e)]}return e.invert=function(n,e){var r=Math.sqrt(n*n+e*e),i=t(r),u=Math.sin(i),o=Math.cos(i);return[Math.atan2(n*u,r*o),Math.asin(r&&e*u/r)]},e}function Se(n,t){function e(n,t){o>0?-Io+Uo>t&&(t=-Io+Uo):t>Io-Uo&&(t=Io-Uo);var e=o/Math.pow(i(t),u);return[e*Math.sin(u*n),o-e*Math.cos(u*n)]}var r=Math.cos(n),i=function(n){return Math.tan(Fo/4+n/2)},u=n===t?Math.sin(n):Math.log(r/Math.cos(t))/Math.log(i(t)/i(n)),o=r*Math.pow(i(n),u)/u;return u?(e.invert=function(n,t){var e=o-t,r=K(u)*Math.sqrt(n*n+e*e);return[Math.atan2(n,e)/u,2*Math.atan(Math.pow(o/r,1/u))-Io]},e):Ne}function ke(n,t){function e(n,t){var e=u-t;return[e*Math.sin(i*n),u-e*Math.cos(i*n)]}var r=Math.cos(n),i=n===t?Math.sin(n):(r-Math.cos(t))/(t-n),u=r/i+n;return xo(i)i;i++){for(;r>1&&Q(n[e[r-2]],n[e[r-1]],n[i])<=0;)--r;e[r++]=i}return e.slice(0,r)}function qe(n,t){return n[0]-t[0]||n[1]-t[1]}function Te(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function Re(n,t,e,r){var i=n[0],u=e[0],o=t[0]-i,a=r[0]-u,l=n[1],c=e[1],f=t[1]-l,s=r[1]-c,h=(a*(l-c)-s*(i-u))/(s*o-a*f);return[i+h*o,l+h*f]}function De(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function Pe(){rr(this),this.edge=this.site=this.circle=null}function Ue(n){var t=cl.pop()||new Pe;return t.site=n,t}function je(n){Be(n),ol.remove(n),cl.push(n),rr(n)}function Fe(n){var t=n.circle,e=t.x,r=t.cy,i={x:e,y:r},u=n.P,o=n.N,a=[n];je(n);for(var l=u;l.circle&&xo(e-l.circle.x)f;++f)c=a[f],l=a[f-1],nr(c.edge,l.site,c.site,i);l=a[0],c=a[s-1],c.edge=Ke(l.site,c.site,null,i),$e(l),$e(c)}function He(n){for(var t,e,r,i,u=n.x,o=n.y,a=ol._;a;)if(r=Oe(a,o)-u,r>Uo)a=a.L;else{if(i=u-Ie(a,o),!(i>Uo)){r>-Uo?(t=a.P,e=a):i>-Uo?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var l=Ue(n);if(ol.insert(t,l),t||e){if(t===e)return Be(t),e=Ue(t.site),ol.insert(l,e),l.edge=e.edge=Ke(t.site,l.site),$e(t),void $e(e);if(!e)return void(l.edge=Ke(t.site,l.site));Be(t),Be(e);var c=t.site,f=c.x,s=c.y,h=n.x-f,p=n.y-s,g=e.site,v=g.x-f,d=g.y-s,y=2*(h*d-p*v),m=h*h+p*p,M=v*v+d*d,x={x:(d*m-p*M)/y+f,y:(h*M-v*m)/y+s};nr(e.edge,c,g,x),l.edge=Ke(c,n,null,x),e.edge=Ke(n,g,null,x),$e(t),$e(e)}}function Oe(n,t){var e=n.site,r=e.x,i=e.y,u=i-t;if(!u)return r;var o=n.P;if(!o)return-(1/0);e=o.site;var a=e.x,l=e.y,c=l-t;if(!c)return a;var f=a-r,s=1/u-1/c,h=f/c;return s?(-h+Math.sqrt(h*h-2*s*(f*f/(-2*c)-l+c/2+i-u/2)))/s+r:(r+a)/2}function Ie(n,t){var e=n.N;if(e)return Oe(e,t);var r=n.site;return r.y===t?r.x:1/0}function Ye(n){this.site=n,this.edges=[]}function Ze(n){for(var t,e,r,i,u,o,a,l,c,f,s=n[0][0],h=n[1][0],p=n[0][1],g=n[1][1],v=ul,d=v.length;d--;)if(u=v[d],u&&u.prepare())for(a=u.edges,l=a.length,o=0;l>o;)f=a[o].end(),r=f.x,i=f.y,c=a[++o%l].start(),t=c.x,e=c.y,(xo(r-t)>Uo||xo(i-e)>Uo)&&(a.splice(o,0,new tr(Qe(u.site,f,xo(r-s)Uo?{x:s,y:xo(t-s)Uo?{x:xo(e-g)Uo?{x:h,y:xo(t-h)Uo?{x:xo(e-p)=-jo)){var p=l*l+c*c,g=f*f+s*s,v=(s*p-c*g)/h,d=(l*g-f*p)/h,s=d+a,y=fl.pop()||new Xe;y.arc=n,y.site=i,y.x=v+o,y.y=s+Math.sqrt(v*v+d*d),y.cy=s,n.circle=y;for(var m=null,M=ll._;M;)if(y.yd||d>=a)return;if(h>g){if(u){if(u.y>=c)return}else u={x:d,y:l};e={x:d,y:c}}else{if(u){if(u.yr||r>1)if(h>g){if(u){if(u.y>=c)return}else u={x:(l-i)/r,y:l};e={x:(c-i)/r,y:c}}else{if(u){if(u.yp){if(u){if(u.x>=a)return}else u={x:o,y:r*o+i};e={x:a,y:r*a+i}}else{if(u){if(u.xu||s>o||r>h||i>p)){if(g=n.point){var g,v=t-n.x,d=e-n.y,y=v*v+d*d;if(l>y){var m=Math.sqrt(l=y);r=t-m,i=e-m,u=t+m,o=e+m,a=g}}for(var M=n.nodes,x=.5*(f+h),b=.5*(s+p),_=t>=x,w=e>=b,S=w<<1|_,k=S+4;k>S;++S)if(n=M[3&S])switch(3&S){case 0:c(n,f,s,x,b);break;case 1:c(n,x,s,h,b);break;case 2:c(n,f,b,x,p);break;case 3:c(n,x,b,h,p)}}}(n,r,i,u,o),a}function vr(n,t){n=ao.rgb(n),t=ao.rgb(t);var e=n.r,r=n.g,i=n.b,u=t.r-e,o=t.g-r,a=t.b-i;return function(n){return"#"+bn(Math.round(e+u*n))+bn(Math.round(r+o*n))+bn(Math.round(i+a*n))}}function dr(n,t){var e,r={},i={};for(e in n)e in t?r[e]=Mr(n[e],t[e]):i[e]=n[e];for(e in t)e in n||(i[e]=t[e]);return function(n){for(e in r)i[e]=r[e](n);return i}}function yr(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function mr(n,t){var e,r,i,u=hl.lastIndex=pl.lastIndex=0,o=-1,a=[],l=[];for(n+="",t+="";(e=hl.exec(n))&&(r=pl.exec(t));)(i=r.index)>u&&(i=t.slice(u,i),a[o]?a[o]+=i:a[++o]=i),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:yr(e,r)})),u=pl.lastIndex;return ur;++r)a[(e=l[r]).i]=e.x(n);return a.join("")})}function Mr(n,t){for(var e,r=ao.interpolators.length;--r>=0&&!(e=ao.interpolators[r](n,t)););return e}function xr(n,t){var e,r=[],i=[],u=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(Mr(n[e],t[e]));for(;u>e;++e)i[e]=n[e];for(;o>e;++e)i[e]=t[e];return function(n){for(e=0;a>e;++e)i[e]=r[e](n);return i}}function br(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function _r(n){return function(t){return 1-n(1-t)}}function wr(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function Sr(n){return n*n}function kr(n){return n*n*n}function Nr(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function Er(n){return function(t){return Math.pow(t,n)}}function Ar(n){return 1-Math.cos(n*Io)}function Cr(n){return Math.pow(2,10*(n-1))}function zr(n){return 1-Math.sqrt(1-n*n)}function Lr(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/Ho*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*Ho/t)}}function qr(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function Tr(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function Rr(n,t){n=ao.hcl(n),t=ao.hcl(t);var e=n.h,r=n.c,i=n.l,u=t.h-e,o=t.c-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return sn(e+u*n,r+o*n,i+a*n)+""}}function Dr(n,t){n=ao.hsl(n),t=ao.hsl(t);var e=n.h,r=n.s,i=n.l,u=t.h-e,o=t.s-r,a=t.l-i;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(u)?(u=0,e=isNaN(e)?t.h:e):u>180?u-=360:-180>u&&(u+=360),function(n){return cn(e+u*n,r+o*n,i+a*n)+""}}function Pr(n,t){n=ao.lab(n),t=ao.lab(t);var e=n.l,r=n.a,i=n.b,u=t.l-e,o=t.a-r,a=t.b-i;return function(n){return pn(e+u*n,r+o*n,i+a*n)+""}}function Ur(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function jr(n){var t=[n.a,n.b],e=[n.c,n.d],r=Hr(t),i=Fr(t,e),u=Hr(Or(e,t,-i))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(Ir(e)+"rotate(",null,")")-2,x:yr(n,t)})):t&&e.push(Ir(e)+"rotate("+t+")")}function Vr(n,t,e,r){n!==t?r.push({i:e.push(Ir(e)+"skewX(",null,")")-2,x:yr(n,t)}):t&&e.push(Ir(e)+"skewX("+t+")")}function Xr(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var i=e.push(Ir(e)+"scale(",null,",",null,")");r.push({i:i-4,x:yr(n[0],t[0])},{i:i-2,x:yr(n[1],t[1])})}else 1===t[0]&&1===t[1]||e.push(Ir(e)+"scale("+t+")")}function $r(n,t){var e=[],r=[];return n=ao.transform(n),t=ao.transform(t),Yr(n.translate,t.translate,e,r),Zr(n.rotate,t.rotate,e,r),Vr(n.skew,t.skew,e,r),Xr(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,i=-1,u=r.length;++i=0;)e.push(i[r])}function oi(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(u=n.children)&&(i=u.length))for(var i,u,o=-1;++oe;++e)(t=n[e][1])>i&&(r=e,i=t);return r}function yi(n){return n.reduce(mi,0)}function mi(n,t){return n+t[1]}function Mi(n,t){return xi(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function xi(n,t){for(var e=-1,r=+n[0],i=(n[1]-r)/t,u=[];++e<=t;)u[e]=i*e+r;return u}function bi(n){return[ao.min(n),ao.max(n)]}function _i(n,t){return n.value-t.value}function wi(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function Si(n,t){n._pack_next=t,t._pack_prev=n}function ki(n,t){var e=t.x-n.x,r=t.y-n.y,i=n.r+t.r;return.999*i*i>e*e+r*r}function Ni(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),p=Math.max(n.y+n.r,p)}if((e=n.children)&&(c=e.length)){var e,r,i,u,o,a,l,c,f=1/0,s=-(1/0),h=1/0,p=-(1/0);if(e.forEach(Ei),r=e[0],r.x=-r.r,r.y=0,t(r),c>1&&(i=e[1],i.x=i.r,i.y=0,t(i),c>2))for(u=e[2],zi(r,i,u),t(u),wi(r,u),r._pack_prev=u,wi(u,i),i=r._pack_next,o=3;c>o;o++){zi(r,i,u=e[o]);var g=0,v=1,d=1;for(a=i._pack_next;a!==i;a=a._pack_next,v++)if(ki(a,u)){g=1;break}if(1==g)for(l=r._pack_prev;l!==a._pack_prev&&!ki(l,u);l=l._pack_prev,d++);g?(d>v||v==d&&i.ro;o++)u=e[o],u.x-=y,u.y-=m,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));n.r=M,e.forEach(Ai)}}function Ei(n){n._pack_next=n._pack_prev=n}function Ai(n){delete n._pack_next,delete n._pack_prev}function Ci(n,t,e,r){var i=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,i)for(var u=-1,o=i.length;++u=0;)t=i[u],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function Pi(n,t,e){return n.a.parent===t.parent?n.a:e}function Ui(n){return 1+ao.max(n,function(n){return n.y})}function ji(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function Fi(n){var t=n.children;return t&&t.length?Fi(t[0]):n}function Hi(n){var t,e=n.children;return e&&(t=e.length)?Hi(e[t-1]):n}function Oi(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function Ii(n,t){var e=n.x+t[3],r=n.y+t[0],i=n.dx-t[1]-t[3],u=n.dy-t[0]-t[2];return 0>i&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Yi(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function Zi(n){return n.rangeExtent?n.rangeExtent():Yi(n.range())}function Vi(n,t,e,r){var i=e(n[0],n[1]),u=r(t[0],t[1]);return function(n){return u(i(n))}}function Xi(n,t){var e,r=0,i=n.length-1,u=n[r],o=n[i];return u>o&&(e=r,r=i,i=e,e=u,u=o,o=e),n[r]=t.floor(u),n[i]=t.ceil(o),n}function $i(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:Sl}function Bi(n,t,e,r){var i=[],u=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Bi:Vi,l=r?Wr:Br;return o=i(n,t,l,e),a=i(t,n,l,Mr),u}function u(n){return o(n)}var o,a;return u.invert=function(n){return a(n)},u.domain=function(t){return arguments.length?(n=t.map(Number),i()):n},u.range=function(n){return arguments.length?(t=n,i()):t},u.rangeRound=function(n){return u.range(n).interpolate(Ur)},u.clamp=function(n){return arguments.length?(r=n,i()):r},u.interpolate=function(n){return arguments.length?(e=n,i()):e},u.ticks=function(t){return Qi(n,t)},u.tickFormat=function(t,e){return nu(n,t,e)},u.nice=function(t){return Gi(n,t),i()},u.copy=function(){return Wi(n,t,e,r)},i()}function Ji(n,t){return ao.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Gi(n,t){return Xi(n,$i(Ki(n,t)[2])),Xi(n,$i(Ki(n,t)[2])),n}function Ki(n,t){null==t&&(t=10);var e=Yi(n),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),u=t/r*i;return.15>=u?i*=10:.35>=u?i*=5:.75>=u&&(i*=2),e[0]=Math.ceil(e[0]/i)*i,e[1]=Math.floor(e[1]/i)*i+.5*i,e[2]=i,e}function Qi(n,t){return ao.range.apply(ao,Ki(n,t))}function nu(n,t,e){var r=Ki(n,t);if(e){var i=ha.exec(e);if(i.shift(),"s"===i[8]){var u=ao.formatPrefix(Math.max(xo(r[0]),xo(r[1])));return i[7]||(i[7]="."+tu(u.scale(r[2]))),i[8]="f",e=ao.format(i.join("")),function(n){return e(u.scale(n))+u.symbol}}i[7]||(i[7]="."+eu(i[8],r)),e=i.join("")}else e=",."+tu(r[2])+"f";return ao.format(e)}function tu(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function eu(n,t){var e=tu(t[2]);return n in kl?Math.abs(e-tu(Math.max(xo(t[0]),xo(t[1]))))+ +("e"!==n):e-2*("%"===n)}function ru(n,t,e,r){function i(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function u(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(i(t))}return o.invert=function(t){return u(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(i)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(i)),o):t},o.nice=function(){var t=Xi(r.map(i),e?Math:El);return n.domain(t),r=t.map(u),o},o.ticks=function(){var n=Yi(r),o=[],a=n[0],l=n[1],c=Math.floor(i(a)),f=Math.ceil(i(l)),s=t%1?2:t;if(isFinite(f-c)){if(e){for(;f>c;c++)for(var h=1;s>h;h++)o.push(u(c)*h);o.push(u(c))}else for(o.push(u(c));c++0;h--)o.push(u(c)*h);for(c=0;o[c]l;f--);o=o.slice(c,f)}return o},o.tickFormat=function(n,e){if(!arguments.length)return Nl;arguments.length<2?e=Nl:"function"!=typeof e&&(e=ao.format(e));var r=Math.max(1,t*n/o.ticks().length);return function(n){var o=n/u(Math.round(i(n)));return t-.5>o*t&&(o*=t),r>=o?e(n):""}},o.copy=function(){return ru(n.copy(),t,e,r)},Ji(o,n)}function iu(n,t,e){function r(t){return n(i(t))}var i=uu(t),u=uu(1/t);return r.invert=function(t){return u(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(i)),r):e},r.ticks=function(n){return Qi(e,n)},r.tickFormat=function(n,t){return nu(e,n,t)},r.nice=function(n){return r.domain(Gi(e,n))},r.exponent=function(o){return arguments.length?(i=uu(t=o),u=uu(1/t),n.domain(e.map(i)),r):t},r.copy=function(){return iu(n.copy(),t,e)},Ji(r,n)}function uu(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function ou(n,t){function e(e){return u[((i.get(e)||("range"===t.t?i.set(e,n.push(e)):NaN))-1)%u.length]}function r(t,e){return ao.range(n.length).map(function(n){return t+e*n})}var i,u,o;return e.domain=function(r){if(!arguments.length)return n;n=[],i=new c;for(var u,o=-1,a=r.length;++oe?[NaN,NaN]:[e>0?a[e-1]:n[0],et?NaN:t/u+n,[t,t+1/u]},r.copy=function(){return lu(n,t,e)},i()}function cu(n,t){function e(e){return e>=e?t[ao.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return cu(n,t)},e}function fu(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return Qi(n,t)},t.tickFormat=function(t,e){return nu(n,t,e)},t.copy=function(){return fu(n)},t}function su(){return 0}function hu(n){return n.innerRadius}function pu(n){return n.outerRadius}function gu(n){return n.startAngle}function vu(n){return n.endAngle}function du(n){return n&&n.padAngle}function yu(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function mu(n,t,e,r,i){var u=n[0]-t[0],o=n[1]-t[1],a=(i?r:-r)/Math.sqrt(u*u+o*o),l=a*o,c=-a*u,f=n[0]+l,s=n[1]+c,h=t[0]+l,p=t[1]+c,g=(f+h)/2,v=(s+p)/2,d=h-f,y=p-s,m=d*d+y*y,M=e-r,x=f*p-h*s,b=(0>y?-1:1)*Math.sqrt(Math.max(0,M*M*m-x*x)),_=(x*y-d*b)/m,w=(-x*d-y*b)/m,S=(x*y+d*b)/m,k=(-x*d+y*b)/m,N=_-g,E=w-v,A=S-g,C=k-v;return N*N+E*E>A*A+C*C&&(_=S,w=k),[[_-l,w-c],[_*e/M,w*e/M]]}function Mu(n){function t(t){function o(){c.push("M",u(n(f),a))}for(var l,c=[],f=[],s=-1,h=t.length,p=En(e),g=En(r);++s1?n.join("L"):n+"Z"}function bu(n){return n.join("L")+"Z"}function _u(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1&&i.push("H",r[0]),i.join("")}function wu(n){for(var t=0,e=n.length,r=n[0],i=[r[0],",",r[1]];++t1){a=t[1],u=n[l],l++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(u[0]-a[0])+","+(u[1]-a[1])+","+u[0]+","+u[1];for(var c=2;c9&&(i=3*t/Math.sqrt(i),o[a]=i*e,o[a+1]=i*r));for(a=-1;++a<=l;)i=(n[Math.min(l,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),u.push([i||0,o[a]*i||0]);return u}function Fu(n){return n.length<3?xu(n):n[0]+Au(n,ju(n))}function Hu(n){for(var t,e,r,i=-1,u=n.length;++i=t?o(n-t):void(f.c=o)}function o(e){var i=g.active,u=g[i];u&&(u.timer.c=null,u.timer.t=NaN,--g.count,delete g[i],u.event&&u.event.interrupt.call(n,n.__data__,u.index));for(var o in g)if(r>+o){var c=g[o];c.timer.c=null,c.timer.t=NaN,--g.count,delete g[o]}f.c=a,qn(function(){return f.c&&a(e||1)&&(f.c=null,f.t=NaN),1},0,l),g.active=r,v.event&&v.event.start.call(n,n.__data__,t),p=[],v.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&p.push(r)}),h=v.ease,s=v.duration}function a(i){for(var u=i/s,o=h(u),a=p.length;a>0;)p[--a].call(n,o);return u>=1?(v.event&&v.event.end.call(n,n.__data__,t),--g.count?delete g[r]:delete n[e],1):void 0}var l,f,s,h,p,g=n[e]||(n[e]={active:0,count:0}),v=g[r];v||(l=i.time,f=qn(u,0,l),v=g[r]={tween:new c,time:l,timer:f,delay:i.delay,duration:i.duration,ease:i.ease,index:t},i=null,++g.count)}function no(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function to(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function eo(n){return n.toISOString()}function ro(n,t,e){function r(t){return n(t)}function i(n,e){var r=n[1]-n[0],i=r/e,u=ao.bisect(Kl,i);return u==Kl.length?[t.year,Ki(n.map(function(n){return n/31536e6}),e)[2]]:u?t[i/Kl[u-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=io(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=io(+t+1);return t}}:n))},r.ticks=function(n,t){var e=Yi(r.domain()),u=null==n?i(e,10):"number"==typeof n?i(e,n):!n.range&&[{range:n},t];return u&&(n=u[0],t=u[1]),n.range(e[0],io(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return ro(n.copy(),t,e)},Ji(r,n)}function io(n){return new Date(n)}function uo(n){return JSON.parse(n.responseText)}function oo(n){var t=fo.createRange();return t.selectNode(fo.body),t.createContextualFragment(n.responseText)}var ao={version:"3.6.1"},lo=[].slice,co=function(n){return lo.call(n)},fo=this.document;if(fo)try{co(fo.documentElement.childNodes)[0].nodeType}catch(so){co=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),fo)try{fo.createElement("DIV").style.setProperty("opacity",0,"")}catch(ho){var po=this.Element.prototype,go=po.setAttribute,vo=po.setAttributeNS,yo=this.CSSStyleDeclaration.prototype,mo=yo.setProperty;po.setAttribute=function(n,t){go.call(this,n,t+"")},po.setAttributeNS=function(n,t,e){vo.call(this,n,t,e+"")},yo.setProperty=function(n,t,e){mo.call(this,n,t+"",e)}}ao.ascending=e,ao.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},ao.min=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ir&&(e=r)}else{for(;++i=r){e=r;break}for(;++ir&&(e=r)}return e},ao.max=function(n,t){var e,r,i=-1,u=n.length;if(1===arguments.length){for(;++i=r){e=r;break}for(;++ie&&(e=r)}else{for(;++i=r){e=r;break}for(;++ie&&(e=r)}return e},ao.extent=function(n,t){var e,r,i,u=-1,o=n.length;if(1===arguments.length){for(;++u=r){e=i=r;break}for(;++ur&&(e=r),r>i&&(i=r))}else{for(;++u=r){e=i=r;break}for(;++ur&&(e=r),r>i&&(i=r))}return[e,i]},ao.sum=function(n,t){var e,r=0,u=n.length,o=-1;if(1===arguments.length)for(;++o1?l/(f-1):void 0},ao.deviation=function(){var n=ao.variance.apply(this,arguments);return n?Math.sqrt(n):n};var Mo=u(e);ao.bisectLeft=Mo.left,ao.bisect=ao.bisectRight=Mo.right,ao.bisector=function(n){return u(1===n.length?function(t,r){return e(n(t),r)}:n)},ao.shuffle=function(n,t,e){(u=arguments.length)<3&&(e=n.length,2>u&&(t=0));for(var r,i,u=e-t;u;)i=Math.random()*u--|0,r=n[u+t],n[u+t]=n[i+t],n[i+t]=r;return n},ao.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},ao.pairs=function(n){for(var t,e=0,r=n.length-1,i=n[0],u=new Array(0>r?0:r);r>e;)u[e]=[t=i,i=n[++e]];return u},ao.transpose=function(n){if(!(i=n.length))return[];for(var t=-1,e=ao.min(n,o),r=new Array(e);++t=0;)for(r=n[i],t=r.length;--t>=0;)e[--o]=r[t];return e};var xo=Math.abs;ao.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,i=[],u=a(xo(e)),o=-1;if(n*=u,t*=u,e*=u,0>e)for(;(r=n+e*++o)>t;)i.push(r/u);else for(;(r=n+e*++o)=u.length)return r?r.call(i,o):e?o.sort(e):o;for(var l,f,s,h,p=-1,g=o.length,v=u[a++],d=new c;++p=u.length)return n;var r=[],i=o[e++];return n.forEach(function(n,i){r.push({key:n,values:t(i,e)})}),i?r.sort(function(n,t){return i(n.key,t.key)}):r}var e,r,i={},u=[],o=[];return i.map=function(t,e){return n(e,t,0)},i.entries=function(e){return t(n(ao.map,e,0),0)},i.key=function(n){return u.push(n),i},i.sortKeys=function(n){return o[u.length-1]=n,i},i.sortValues=function(n){return e=n,i},i.rollup=function(n){return r=n,i},i},ao.set=function(n){var t=new y;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(y,{has:h,add:function(n){return this._[f(n+="")]=!0,n},remove:p,values:g,size:v,empty:d,forEach:function(n){for(var t in this._)n.call(this,s(t))}}),ao.behavior={},ao.rebind=function(n,t){for(var e,r=1,i=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},ao.event=null,ao.requote=function(n){return n.replace(So,"\\$&")};var So=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,ko={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},No=function(n,t){return t.querySelector(n)},Eo=function(n,t){return t.querySelectorAll(n)},Ao=function(n,t){var e=n.matches||n[x(n,"matchesSelector")];return(Ao=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(No=function(n,t){return Sizzle(n,t)[0]||null},Eo=Sizzle,Ao=Sizzle.matchesSelector),ao.selection=function(){return ao.select(fo.documentElement)};var Co=ao.selection.prototype=[];Co.select=function(n){var t,e,r,i,u=[];n=A(n);for(var o=-1,a=this.length;++o=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),Lo.hasOwnProperty(e)?{space:Lo[e],local:n}:n}},Co.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=ao.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(z(t,n[t]));return this}return this.each(z(n,t))},Co.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=T(n)).length,i=-1;if(t=e.classList){for(;++ii){if("string"!=typeof n){2>i&&(e="");for(r in n)this.each(P(r,n[r],e));return this}if(2>i){var u=this.node();return t(u).getComputedStyle(u,null).getPropertyValue(n)}r=""}return this.each(P(n,e,r))},Co.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(U(t,n[t]));return this}return this.each(U(n,t))},Co.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},Co.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},Co.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},Co.insert=function(n,t){return n=j(n),t=A(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},Co.remove=function(){return this.each(F)},Co.data=function(n,t){function e(n,e){var r,i,u,o=n.length,s=e.length,h=Math.min(o,s),p=new Array(s),g=new Array(s),v=new Array(o);if(t){var d,y=new c,m=new Array(o);for(r=-1;++rr;++r)g[r]=H(e[r]);for(;o>r;++r)v[r]=n[r]}g.update=p,g.parentNode=p.parentNode=v.parentNode=n.parentNode,a.push(g),l.push(p),f.push(v)}var r,i,u=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++uu;u++){i.push(t=[]),t.parentNode=(e=this[u]).parentNode;for(var a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return E(i)},Co.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},Co.sort=function(n){n=I.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},Co.size=function(){var n=0;return Y(this,function(){++n}),n};var qo=[];ao.selection.enter=Z,ao.selection.enter.prototype=qo,qo.append=Co.append,qo.empty=Co.empty,qo.node=Co.node,qo.call=Co.call,qo.size=Co.size,qo.select=function(n){for(var t,e,r,i,u,o=[],a=-1,l=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var To=ao.map({mouseenter:"mouseover",mouseleave:"mouseout"});fo&&To.forEach(function(n){"on"+n in fo&&To.remove(n)});var Ro,Do=0;ao.mouse=function(n){return J(n,k())};var Po=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;ao.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=k().changedTouches),t)for(var r,i=0,u=t.length;u>i;++i)if((r=t[i]).identifier===e)return J(n,r)},ao.behavior.drag=function(){function n(){this.on("mousedown.drag",u).on("touchstart.drag",o)}function e(n,t,e,u,o){return function(){function a(){var n,e,r=t(h,v);r&&(n=r[0]-M[0],e=r[1]-M[1],g|=n|e,M=r,p({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,v)&&(y.on(u+d,null).on(o+d,null),m(g),p({type:"dragend"}))}var c,f=this,s=ao.event.target.correspondingElement||ao.event.target,h=f.parentNode,p=r.of(f,arguments),g=0,v=n(),d=".drag"+(null==v?"":"-"+v),y=ao.select(e(s)).on(u+d,a).on(o+d,l),m=W(s),M=t(h,v);i?(c=i.apply(f,arguments),c=[c.x-M[0],c.y-M[1]]):c=[0,0],p({type:"dragstart"})}}var r=N(n,"drag","dragstart","dragend"),i=null,u=e(b,ao.mouse,t,"mousemove","mouseup"),o=e(G,ao.touch,m,"touchmove","touchend");return n.origin=function(t){return arguments.length?(i=t,n):i},ao.rebind(n,r,"on")},ao.touches=function(n,t){return arguments.length<2&&(t=k().touches),t?co(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier,e}):[]};var Uo=1e-6,jo=Uo*Uo,Fo=Math.PI,Ho=2*Fo,Oo=Ho-Uo,Io=Fo/2,Yo=Fo/180,Zo=180/Fo,Vo=Math.SQRT2,Xo=2,$o=4;ao.interpolateZoom=function(n,t){var e,r,i=n[0],u=n[1],o=n[2],a=t[0],l=t[1],c=t[2],f=a-i,s=l-u,h=f*f+s*s;if(jo>h)r=Math.log(c/o)/Vo,e=function(n){return[i+n*f,u+n*s,o*Math.exp(Vo*n*r)]};else{var p=Math.sqrt(h),g=(c*c-o*o+$o*h)/(2*o*Xo*p),v=(c*c-o*o-$o*h)/(2*c*Xo*p),d=Math.log(Math.sqrt(g*g+1)-g),y=Math.log(Math.sqrt(v*v+1)-v);r=(y-d)/Vo,e=function(n){var t=n*r,e=rn(d),a=o/(Xo*p)*(e*un(Vo*t+d)-en(d));return[i+a*f,u+a*s,o*e/rn(Vo*t+d)]}}return e.duration=1e3*r,e},ao.behavior.zoom=function(){function n(n){n.on(L,s).on(Wo+".zoom",p).on("dblclick.zoom",g).on(R,h)}function e(n){return[(n[0]-k.x)/k.k,(n[1]-k.y)/k.k]}function r(n){return[n[0]*k.k+k.x,n[1]*k.k+k.y]}function i(n){k.k=Math.max(A[0],Math.min(A[1],n))}function u(n,t){t=r(t),k.x+=n[0]-t[0],k.y+=n[1]-t[1]}function o(t,e,r,o){t.__chart__={x:k.x,y:k.y,k:k.k},i(Math.pow(2,o)),u(d=e,r),t=ao.select(t),C>0&&(t=t.transition().duration(C)),t.call(n.event)}function a(){b&&b.domain(x.range().map(function(n){return(n-k.x)/k.k}).map(x.invert)),w&&w.domain(_.range().map(function(n){return(n-k.y)/k.k}).map(_.invert))}function l(n){z++||n({type:"zoomstart"})}function c(n){a(),n({type:"zoom",scale:k.k,translate:[k.x,k.y]})}function f(n){--z||(n({type:"zoomend"}),d=null)}function s(){function n(){a=1,u(ao.mouse(i),h),c(o)}function r(){s.on(q,null).on(T,null),p(a),f(o)}var i=this,o=D.of(i,arguments),a=0,s=ao.select(t(i)).on(q,n).on(T,r),h=e(ao.mouse(i)),p=W(i);Il.call(i),l(o)}function h(){function n(){var n=ao.touches(g);return p=k.k,n.forEach(function(n){n.identifier in d&&(d[n.identifier]=e(n))}),n}function t(){var t=ao.event.target;ao.select(t).on(x,r).on(b,a),_.push(t);for(var e=ao.event.changedTouches,i=0,u=e.length;u>i;++i)d[e[i].identifier]=null;var l=n(),c=Date.now();if(1===l.length){if(500>c-M){var f=l[0];o(g,f,d[f.identifier],Math.floor(Math.log(k.k)/Math.LN2)+1),S()}M=c}else if(l.length>1){var f=l[0],s=l[1],h=f[0]-s[0],p=f[1]-s[1];y=h*h+p*p}}function r(){var n,t,e,r,o=ao.touches(g);Il.call(g);for(var a=0,l=o.length;l>a;++a,r=null)if(e=o[a],r=d[e.identifier]){if(t)break;n=e,t=r}if(r){var f=(f=e[0]-n[0])*f+(f=e[1]-n[1])*f,s=y&&Math.sqrt(f/y);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],i(s*p)}M=null,u(n,t),c(v)}function a(){if(ao.event.touches.length){for(var t=ao.event.changedTouches,e=0,r=t.length;r>e;++e)delete d[t[e].identifier];for(var i in d)return void n()}ao.selectAll(_).on(m,null),w.on(L,s).on(R,h),N(),f(v)}var p,g=this,v=D.of(g,arguments),d={},y=0,m=".zoom-"+ao.event.changedTouches[0].identifier,x="touchmove"+m,b="touchend"+m,_=[],w=ao.select(g),N=W(g);t(),l(v),w.on(L,null).on(R,t)}function p(){var n=D.of(this,arguments);m?clearTimeout(m):(Il.call(this),v=e(d=y||ao.mouse(this)),l(n)),m=setTimeout(function(){m=null,f(n)},50),S(),i(Math.pow(2,.002*Bo())*k.k),u(d,v),c(n)}function g(){var n=ao.mouse(this),t=Math.log(k.k)/Math.LN2;o(this,n,e(n),ao.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var v,d,y,m,M,x,b,_,w,k={x:0,y:0,k:1},E=[960,500],A=Jo,C=250,z=0,L="mousedown.zoom",q="mousemove.zoom",T="mouseup.zoom",R="touchstart.zoom",D=N(n,"zoomstart","zoom","zoomend");return Wo||(Wo="onwheel"in fo?(Bo=function(){return-ao.event.deltaY*(ao.event.deltaMode?120:1)},"wheel"):"onmousewheel"in fo?(Bo=function(){return ao.event.wheelDelta},"mousewheel"):(Bo=function(){return-ao.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=D.of(this,arguments),t=k;Hl?ao.select(this).transition().each("start.zoom",function(){k=this.__chart__||{x:0,y:0,k:1},l(n)}).tween("zoom:zoom",function(){var e=E[0],r=E[1],i=d?d[0]:e/2,u=d?d[1]:r/2,o=ao.interpolateZoom([(i-k.x)/k.k,(u-k.y)/k.k,e/k.k],[(i-t.x)/t.k,(u-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=k={x:i-r[0]*a,y:u-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){f(n)}).each("end.zoom",function(){f(n)}):(this.__chart__=k,l(n),c(n),f(n))})},n.translate=function(t){return arguments.length?(k={x:+t[0],y:+t[1],k:k.k},a(),n):[k.x,k.y]},n.scale=function(t){return arguments.length?(k={x:k.x,y:k.y,k:null},i(+t),a(),n):k.k},n.scaleExtent=function(t){return arguments.length?(A=null==t?Jo:[+t[0],+t[1]],n):A},n.center=function(t){return arguments.length?(y=t&&[+t[0],+t[1]],n):y},n.size=function(t){return arguments.length?(E=t&&[+t[0],+t[1]],n):E},n.duration=function(t){return arguments.length?(C=+t,n):C},n.x=function(t){return arguments.length?(b=t,x=t.copy(),k={x:0,y:0,k:1},n):b},n.y=function(t){return arguments.length?(w=t,_=t.copy(),k={x:0,y:0,k:1},n):w},ao.rebind(n,D,"on")};var Bo,Wo,Jo=[0,1/0];ao.color=an,an.prototype.toString=function(){return this.rgb()+""},ao.hsl=ln;var Go=ln.prototype=new an;Go.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,this.l/n)},Go.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new ln(this.h,this.s,n*this.l)},Go.rgb=function(){return cn(this.h,this.s,this.l)},ao.hcl=fn;var Ko=fn.prototype=new an;Ko.brighter=function(n){return new fn(this.h,this.c,Math.min(100,this.l+Qo*(arguments.length?n:1)))},Ko.darker=function(n){return new fn(this.h,this.c,Math.max(0,this.l-Qo*(arguments.length?n:1)))},Ko.rgb=function(){return sn(this.h,this.c,this.l).rgb()},ao.lab=hn;var Qo=18,na=.95047,ta=1,ea=1.08883,ra=hn.prototype=new an;ra.brighter=function(n){return new hn(Math.min(100,this.l+Qo*(arguments.length?n:1)),this.a,this.b)},ra.darker=function(n){return new hn(Math.max(0,this.l-Qo*(arguments.length?n:1)),this.a,this.b)},ra.rgb=function(){return pn(this.l,this.a,this.b)},ao.rgb=mn;var ia=mn.prototype=new an;ia.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,i=30;return t||e||r?(t&&i>t&&(t=i),e&&i>e&&(e=i),r&&i>r&&(r=i),new mn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new mn(i,i,i)},ia.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new mn(n*this.r,n*this.g,n*this.b)},ia.hsl=function(){return wn(this.r,this.g,this.b)},ia.toString=function(){return"#"+bn(this.r)+bn(this.g)+bn(this.b)};var ua=ao.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});ua.forEach(function(n,t){ua.set(n,Mn(t))}),ao.functor=En,ao.xhr=An(m),ao.dsv=function(n,t){function e(n,e,u){arguments.length<3&&(u=e,e=null);var o=Cn(n,t,null==e?r:i(e),u);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:i(n)):e},o}function r(n){return e.parse(n.responseText)}function i(n){return function(t){return e.parse(t.responseText,n)}}function u(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var i=function(t){for(var e={},r=n.length,i=0;r>i;++i)e[n[i]]=t[i];return e};r=t?function(n,e){return t(i(n),e)}:i})},e.parseRows=function(n,t){function e(){if(f>=c)return o;if(i)return i=!1,u;var t=f;if(34===n.charCodeAt(t)){for(var e=t;e++f;){var r=n.charCodeAt(f++),a=1;if(10===r)i=!0;else if(13===r)i=!0,10===n.charCodeAt(f)&&(++f,++a);else if(r!==l)continue;return n.slice(t,f-a)}return n.slice(t)}for(var r,i,u={},o={},a=[],c=n.length,f=0,s=0;(r=e())!==o;){for(var h=[];r!==u&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,s++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new y,i=[];return t.forEach(function(n){for(var t in n)r.has(t)||i.push(r.add(t))}),[i.map(o).join(n)].concat(t.map(function(t){return i.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(u).join("\n")},e},ao.csv=ao.dsv(",","text/csv"),ao.tsv=ao.dsv(" ","text/tab-separated-values");var oa,aa,la,ca,fa=this[x(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};ao.timer=function(){qn.apply(this,arguments)},ao.timer.flush=function(){Rn(),Dn()},ao.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var sa=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Un);ao.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=ao.round(n,Pn(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),sa[8+e/3]};var ha=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,pa=ao.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=ao.round(n,Pn(n,t))).toFixed(Math.max(0,Math.min(20,Pn(n*(1+1e-15),t))))}}),ga=ao.time={},va=Date;Hn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){da.setUTCDate.apply(this._,arguments)},setDay:function(){da.setUTCDay.apply(this._,arguments)},setFullYear:function(){da.setUTCFullYear.apply(this._,arguments)},setHours:function(){da.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){da.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){da.setUTCMinutes.apply(this._,arguments)},setMonth:function(){da.setUTCMonth.apply(this._,arguments)},setSeconds:function(){da.setUTCSeconds.apply(this._,arguments)},setTime:function(){da.setTime.apply(this._,arguments)}};var da=Date.prototype;ga.year=On(function(n){return n=ga.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),ga.years=ga.year.range,ga.years.utc=ga.year.utc.range,ga.day=On(function(n){var t=new va(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),ga.days=ga.day.range,ga.days.utc=ga.day.utc.range,ga.dayOfYear=function(n){var t=ga.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=ga[n]=On(function(n){return(n=ga.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=ga.year(n).getDay();return Math.floor((ga.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});ga[n+"s"]=e.range,ga[n+"s"].utc=e.utc.range,ga[n+"OfYear"]=function(n){var e=ga.year(n).getDay();return Math.floor((ga.dayOfYear(n)+(e+t)%7)/7)}}),ga.week=ga.sunday,ga.weeks=ga.sunday.range,ga.weeks.utc=ga.sunday.utc.range,ga.weekOfYear=ga.sundayOfYear;var ya={"-":"",_:" ",0:"0"},ma=/^\s*\d+/,Ma=/^%/;ao.locale=function(n){return{numberFormat:jn(n),timeFormat:Yn(n)}};var xa=ao.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"], -shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});ao.format=xa.numberFormat,ao.geo={},ft.prototype={s:0,t:0,add:function(n){st(n,this.t,ba),st(ba.s,this.s,this),this.s?this.t+=ba.t:this.s=ba.t},reset:function(){this.s=this.t=0},valueOf:function(){return this.s}};var ba=new ft;ao.geo.stream=function(n,t){n&&_a.hasOwnProperty(n.type)?_a[n.type](n,t):ht(n,t)};var _a={Feature:function(n,t){ht(n.geometry,t)},FeatureCollection:function(n,t){for(var e=n.features,r=-1,i=e.length;++rn?4*Fo+n:n,Na.lineStart=Na.lineEnd=Na.point=b}};ao.geo.bounds=function(){function n(n,t){M.push(x=[f=n,h=n]),s>t&&(s=t),t>p&&(p=t)}function t(t,e){var r=dt([t*Yo,e*Yo]);if(y){var i=mt(y,r),u=[i[1],-i[0],0],o=mt(u,i);bt(o),o=_t(o);var l=t-g,c=l>0?1:-1,v=o[0]*Zo*c,d=xo(l)>180;if(d^(v>c*g&&c*t>v)){var m=o[1]*Zo;m>p&&(p=m)}else if(v=(v+360)%360-180,d^(v>c*g&&c*t>v)){var m=-o[1]*Zo;s>m&&(s=m)}else s>e&&(s=e),e>p&&(p=e);d?g>t?a(f,t)>a(f,h)&&(h=t):a(t,h)>a(f,h)&&(f=t):h>=f?(f>t&&(f=t),t>h&&(h=t)):t>g?a(f,t)>a(f,h)&&(h=t):a(t,h)>a(f,h)&&(f=t)}else n(t,e);y=r,g=t}function e(){b.point=t}function r(){x[0]=f,x[1]=h,b.point=n,y=null}function i(n,e){if(y){var r=n-g;m+=xo(r)>180?r+(r>0?360:-360):r}else v=n,d=e;Na.point(n,e),t(n,e)}function u(){Na.lineStart()}function o(){i(v,d),Na.lineEnd(),xo(m)>Uo&&(f=-(h=180)),x[0]=f,x[1]=h,y=null}function a(n,t){return(t-=n)<0?t+360:t}function l(n,t){return n[0]-t[0]}function c(n,t){return t[0]<=t[1]?t[0]<=n&&n<=t[1]:nka?(f=-(h=180),s=-(p=90)):m>Uo?p=90:-Uo>m&&(s=-90),x[0]=f,x[1]=h}};return function(n){p=h=-(f=s=1/0),M=[],ao.geo.stream(n,b);var t=M.length;if(t){M.sort(l);for(var e,r=1,i=M[0],u=[i];t>r;++r)e=M[r],c(e[0],i)||c(e[1],i)?(a(i[0],e[1])>a(i[0],i[1])&&(i[1]=e[1]),a(e[0],i[1])>a(i[0],i[1])&&(i[0]=e[0])):u.push(i=e);for(var o,e,g=-(1/0),t=u.length-1,r=0,i=u[t];t>=r;i=e,++r)e=u[r],(o=a(i[1],e[0]))>g&&(g=o,f=e[0],h=i[1])}return M=x=null,f===1/0||s===1/0?[[NaN,NaN],[NaN,NaN]]:[[f,s],[h,p]]}}(),ao.geo.centroid=function(n){Ea=Aa=Ca=za=La=qa=Ta=Ra=Da=Pa=Ua=0,ao.geo.stream(n,ja);var t=Da,e=Pa,r=Ua,i=t*t+e*e+r*r;return jo>i&&(t=qa,e=Ta,r=Ra,Uo>Aa&&(t=Ca,e=za,r=La),i=t*t+e*e+r*r,jo>i)?[NaN,NaN]:[Math.atan2(e,t)*Zo,tn(r/Math.sqrt(i))*Zo]};var Ea,Aa,Ca,za,La,qa,Ta,Ra,Da,Pa,Ua,ja={sphere:b,point:St,lineStart:Nt,lineEnd:Et,polygonStart:function(){ja.lineStart=At},polygonEnd:function(){ja.lineStart=Nt}},Fa=Rt(zt,jt,Ht,[-Fo,-Fo/2]),Ha=1e9;ao.geo.clipExtent=function(){var n,t,e,r,i,u,o={stream:function(n){return i&&(i.valid=!1),i=u(n),i.valid=!0,i},extent:function(a){return arguments.length?(u=Zt(n=+a[0][0],t=+a[0][1],e=+a[1][0],r=+a[1][1]),i&&(i.valid=!1,i=null),o):[[n,t],[e,r]]}};return o.extent([[0,0],[960,500]])},(ao.geo.conicEqualArea=function(){return Vt(Xt)}).raw=Xt,ao.geo.albers=function(){return ao.geo.conicEqualArea().rotate([96,0]).center([-.6,38.7]).parallels([29.5,45.5]).scale(1070)},ao.geo.albersUsa=function(){function n(n){var u=n[0],o=n[1];return t=null,e(u,o),t||(r(u,o),t)||i(u,o),t}var t,e,r,i,u=ao.geo.albers(),o=ao.geo.conicEqualArea().rotate([154,0]).center([-2,58.5]).parallels([55,65]),a=ao.geo.conicEqualArea().rotate([157,0]).center([-3,19.9]).parallels([8,18]),l={point:function(n,e){t=[n,e]}};return n.invert=function(n){var t=u.scale(),e=u.translate(),r=(n[0]-e[0])/t,i=(n[1]-e[1])/t;return(i>=.12&&.234>i&&r>=-.425&&-.214>r?o:i>=.166&&.234>i&&r>=-.214&&-.115>r?a:u).invert(n)},n.stream=function(n){var t=u.stream(n),e=o.stream(n),r=a.stream(n);return{point:function(n,i){t.point(n,i),e.point(n,i),r.point(n,i)},sphere:function(){t.sphere(),e.sphere(),r.sphere()},lineStart:function(){t.lineStart(),e.lineStart(),r.lineStart()},lineEnd:function(){t.lineEnd(),e.lineEnd(),r.lineEnd()},polygonStart:function(){t.polygonStart(),e.polygonStart(),r.polygonStart()},polygonEnd:function(){t.polygonEnd(),e.polygonEnd(),r.polygonEnd()}}},n.precision=function(t){return arguments.length?(u.precision(t),o.precision(t),a.precision(t),n):u.precision()},n.scale=function(t){return arguments.length?(u.scale(t),o.scale(.35*t),a.scale(t),n.translate(u.translate())):u.scale()},n.translate=function(t){if(!arguments.length)return u.translate();var c=u.scale(),f=+t[0],s=+t[1];return e=u.translate(t).clipExtent([[f-.455*c,s-.238*c],[f+.455*c,s+.238*c]]).stream(l).point,r=o.translate([f-.307*c,s+.201*c]).clipExtent([[f-.425*c+Uo,s+.12*c+Uo],[f-.214*c-Uo,s+.234*c-Uo]]).stream(l).point,i=a.translate([f-.205*c,s+.212*c]).clipExtent([[f-.214*c+Uo,s+.166*c+Uo],[f-.115*c-Uo,s+.234*c-Uo]]).stream(l).point,n},n.scale(1070)};var Oa,Ia,Ya,Za,Va,Xa,$a={point:b,lineStart:b,lineEnd:b,polygonStart:function(){Ia=0,$a.lineStart=$t},polygonEnd:function(){$a.lineStart=$a.lineEnd=$a.point=b,Oa+=xo(Ia/2)}},Ba={point:Bt,lineStart:b,lineEnd:b,polygonStart:b,polygonEnd:b},Wa={point:Gt,lineStart:Kt,lineEnd:Qt,polygonStart:function(){Wa.lineStart=ne},polygonEnd:function(){Wa.point=Gt,Wa.lineStart=Kt,Wa.lineEnd=Qt}};ao.geo.path=function(){function n(n){return n&&("function"==typeof a&&u.pointRadius(+a.apply(this,arguments)),o&&o.valid||(o=i(u)),ao.geo.stream(n,o)),u.result()}function t(){return o=null,n}var e,r,i,u,o,a=4.5;return n.area=function(n){return Oa=0,ao.geo.stream(n,i($a)),Oa},n.centroid=function(n){return Ca=za=La=qa=Ta=Ra=Da=Pa=Ua=0,ao.geo.stream(n,i(Wa)),Ua?[Da/Ua,Pa/Ua]:Ra?[qa/Ra,Ta/Ra]:La?[Ca/La,za/La]:[NaN,NaN]},n.bounds=function(n){return Va=Xa=-(Ya=Za=1/0),ao.geo.stream(n,i(Ba)),[[Ya,Za],[Va,Xa]]},n.projection=function(n){return arguments.length?(i=(e=n)?n.stream||re(n):m,t()):e},n.context=function(n){return arguments.length?(u=null==(r=n)?new Wt:new te(n),"function"!=typeof a&&u.pointRadius(a),t()):r},n.pointRadius=function(t){return arguments.length?(a="function"==typeof t?t:(u.pointRadius(+t),+t),n):a},n.projection(ao.geo.albersUsa()).context(null)},ao.geo.transform=function(n){return{stream:function(t){var e=new ie(t);for(var r in n)e[r]=n[r];return e}}},ie.prototype={point:function(n,t){this.stream.point(n,t)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}},ao.geo.projection=oe,ao.geo.projectionMutator=ae,(ao.geo.equirectangular=function(){return oe(ce)}).raw=ce.invert=ce,ao.geo.rotation=function(n){function t(t){return t=n(t[0]*Yo,t[1]*Yo),t[0]*=Zo,t[1]*=Zo,t}return n=se(n[0]%360*Yo,n[1]*Yo,n.length>2?n[2]*Yo:0),t.invert=function(t){return t=n.invert(t[0]*Yo,t[1]*Yo),t[0]*=Zo,t[1]*=Zo,t},t},fe.invert=ce,ao.geo.circle=function(){function n(){var n="function"==typeof r?r.apply(this,arguments):r,t=se(-n[0]*Yo,-n[1]*Yo,0).invert,i=[];return e(null,null,1,{point:function(n,e){i.push(n=t(n,e)),n[0]*=Zo,n[1]*=Zo}}),{type:"Polygon",coordinates:[i]}}var t,e,r=[0,0],i=6;return n.origin=function(t){return arguments.length?(r=t,n):r},n.angle=function(r){return arguments.length?(e=ve((t=+r)*Yo,i*Yo),n):t},n.precision=function(r){return arguments.length?(e=ve(t*Yo,(i=+r)*Yo),n):i},n.angle(90)},ao.geo.distance=function(n,t){var e,r=(t[0]-n[0])*Yo,i=n[1]*Yo,u=t[1]*Yo,o=Math.sin(r),a=Math.cos(r),l=Math.sin(i),c=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*o)*e+(e=c*f-l*s*a)*e),l*f+c*s*a)},ao.geo.graticule=function(){function n(){return{type:"MultiLineString",coordinates:t()}}function t(){return ao.range(Math.ceil(u/d)*d,i,d).map(h).concat(ao.range(Math.ceil(c/y)*y,l,y).map(p)).concat(ao.range(Math.ceil(r/g)*g,e,g).filter(function(n){return xo(n%d)>Uo}).map(f)).concat(ao.range(Math.ceil(a/v)*v,o,v).filter(function(n){return xo(n%y)>Uo}).map(s))}var e,r,i,u,o,a,l,c,f,s,h,p,g=10,v=g,d=90,y=360,m=2.5;return n.lines=function(){return t().map(function(n){return{type:"LineString",coordinates:n}})},n.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(p(l).slice(1),h(i).reverse().slice(1),p(c).reverse().slice(1))]}},n.extent=function(t){return arguments.length?n.majorExtent(t).minorExtent(t):n.minorExtent()},n.majorExtent=function(t){return arguments.length?(u=+t[0][0],i=+t[1][0],c=+t[0][1],l=+t[1][1],u>i&&(t=u,u=i,i=t),c>l&&(t=c,c=l,l=t),n.precision(m)):[[u,c],[i,l]]},n.minorExtent=function(t){return arguments.length?(r=+t[0][0],e=+t[1][0],a=+t[0][1],o=+t[1][1],r>e&&(t=r,r=e,e=t),a>o&&(t=a,a=o,o=t),n.precision(m)):[[r,a],[e,o]]},n.step=function(t){return arguments.length?n.majorStep(t).minorStep(t):n.minorStep()},n.majorStep=function(t){return arguments.length?(d=+t[0],y=+t[1],n):[d,y]},n.minorStep=function(t){return arguments.length?(g=+t[0],v=+t[1],n):[g,v]},n.precision=function(t){return arguments.length?(m=+t,f=ye(a,o,90),s=me(r,e,m),h=ye(c,l,90),p=me(u,i,m),n):m},n.majorExtent([[-180,-90+Uo],[180,90-Uo]]).minorExtent([[-180,-80-Uo],[180,80+Uo]])},ao.geo.greatArc=function(){function n(){return{type:"LineString",coordinates:[t||r.apply(this,arguments),e||i.apply(this,arguments)]}}var t,e,r=Me,i=xe;return n.distance=function(){return ao.geo.distance(t||r.apply(this,arguments),e||i.apply(this,arguments))},n.source=function(e){return arguments.length?(r=e,t="function"==typeof e?null:e,n):r},n.target=function(t){return arguments.length?(i=t,e="function"==typeof t?null:t,n):i},n.precision=function(){return arguments.length?n:0},n},ao.geo.interpolate=function(n,t){return be(n[0]*Yo,n[1]*Yo,t[0]*Yo,t[1]*Yo)},ao.geo.length=function(n){return Ja=0,ao.geo.stream(n,Ga),Ja};var Ja,Ga={sphere:b,point:b,lineStart:_e,lineEnd:b,polygonStart:b,polygonEnd:b},Ka=we(function(n){return Math.sqrt(2/(1+n))},function(n){return 2*Math.asin(n/2)});(ao.geo.azimuthalEqualArea=function(){return oe(Ka)}).raw=Ka;var Qa=we(function(n){var t=Math.acos(n);return t&&t/Math.sin(t)},m);(ao.geo.azimuthalEquidistant=function(){return oe(Qa)}).raw=Qa,(ao.geo.conicConformal=function(){return Vt(Se)}).raw=Se,(ao.geo.conicEquidistant=function(){return Vt(ke)}).raw=ke;var nl=we(function(n){return 1/n},Math.atan);(ao.geo.gnomonic=function(){return oe(nl)}).raw=nl,Ne.invert=function(n,t){return[n,2*Math.atan(Math.exp(t))-Io]},(ao.geo.mercator=function(){return Ee(Ne)}).raw=Ne;var tl=we(function(){return 1},Math.asin);(ao.geo.orthographic=function(){return oe(tl)}).raw=tl;var el=we(function(n){return 1/(1+n)},function(n){return 2*Math.atan(n)});(ao.geo.stereographic=function(){return oe(el)}).raw=el,Ae.invert=function(n,t){return[-t,2*Math.atan(Math.exp(n))-Io]},(ao.geo.transverseMercator=function(){var n=Ee(Ae),t=n.center,e=n.rotate;return n.center=function(n){return n?t([-n[1],n[0]]):(n=t(),[n[1],-n[0]])},n.rotate=function(n){return n?e([n[0],n[1],n.length>2?n[2]+90:90]):(n=e(),[n[0],n[1],n[2]-90])},e([0,0,90])}).raw=Ae,ao.geom={},ao.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,i=En(e),u=En(r),o=n.length,a=[],l=[];for(t=0;o>t;t++)a.push([+i.call(this,n[t],t),+u.call(this,n[t],t),t]);for(a.sort(qe),t=0;o>t;t++)l.push([a[t][0],-a[t][1]]);var c=Le(a),f=Le(l),s=f[0]===c[0],h=f[f.length-1]===c[c.length-1],p=[];for(t=c.length-1;t>=0;--t)p.push(n[a[c[t]][2]]);for(t=+s;t=r&&c.x<=u&&c.y>=i&&c.y<=o?[[r,o],[u,o],[u,i],[r,i]]:[];f.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(u(n,t)/Uo)*Uo,y:Math.round(o(n,t)/Uo)*Uo,i:t}})}var r=Ce,i=ze,u=r,o=i,a=sl;return n?t(n):(t.links=function(n){return ar(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return ar(e(n)).cells.forEach(function(e,r){for(var i,u,o=e.site,a=e.edges.sort(Ve),l=-1,c=a.length,f=a[c-1].edge,s=f.l===o?f.r:f.l;++l=c,h=r>=f,p=h<<1|s;n.leaf=!1,n=n.nodes[p]||(n.nodes[p]=hr()),s?i=c:a=c,h?o=f:l=f,u(n,t,e,r,i,o,a,l)}var f,s,h,p,g,v,d,y,m,M=En(a),x=En(l);if(null!=t)v=t,d=e,y=r,m=i;else if(y=m=-(v=d=1/0),s=[],h=[],g=n.length,o)for(p=0;g>p;++p)f=n[p],f.xy&&(y=f.x),f.y>m&&(m=f.y),s.push(f.x),h.push(f.y);else for(p=0;g>p;++p){var b=+M(f=n[p],p),_=+x(f,p);v>b&&(v=b),d>_&&(d=_),b>y&&(y=b),_>m&&(m=_),s.push(b),h.push(_)}var w=y-v,S=m-d;w>S?m=d+w:y=v+S;var k=hr();if(k.add=function(n){u(k,n,+M(n,++p),+x(n,p),v,d,y,m)},k.visit=function(n){pr(n,k,v,d,y,m)},k.find=function(n){return gr(k,n[0],n[1],v,d,y,m)},p=-1,null==t){for(;++p=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=vl.get(e)||gl,r=dl.get(r)||m,br(r(e.apply(null,lo.call(arguments,1))))},ao.interpolateHcl=Rr,ao.interpolateHsl=Dr,ao.interpolateLab=Pr,ao.interpolateRound=Ur,ao.transform=function(n){var t=fo.createElementNS(ao.ns.prefix.svg,"g");return(ao.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new jr(e?e.matrix:yl)})(n)},jr.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var yl={a:1,b:0,c:0,d:1,e:0,f:0};ao.interpolateTransform=$r,ao.layout={},ao.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/y){if(v>l){var c=t.charge/l;n.px-=u*c,n.py-=o*c}return!0}if(t.point&&l&&v>l){var c=t.pointCharge/l;n.px-=u*c,n.py-=o*c}}return!t.charge}}function t(n){n.px=ao.event.x,n.py=ao.event.y,l.resume()}var e,r,i,u,o,a,l={},c=ao.dispatch("start","tick","end"),f=[1,1],s=.9,h=ml,p=Ml,g=-30,v=xl,d=.1,y=.64,M=[],x=[];return l.tick=function(){if((i*=.99)<.005)return e=null,c.end({type:"end",alpha:i=0}),!0;var t,r,l,h,p,v,y,m,b,_=M.length,w=x.length;for(r=0;w>r;++r)l=x[r],h=l.source,p=l.target,m=p.x-h.x,b=p.y-h.y,(v=m*m+b*b)&&(v=i*o[r]*((v=Math.sqrt(v))-u[r])/v,m*=v,b*=v,p.x-=m*(y=h.weight+p.weight?h.weight/(h.weight+p.weight):.5),p.y-=b*y,h.x+=m*(y=1-y),h.y+=b*y);if((y=i*d)&&(m=f[0]/2,b=f[1]/2,r=-1,y))for(;++r<_;)l=M[r],l.x+=(m-l.x)*y,l.y+=(b-l.y)*y;if(g)for(ri(t=ao.geom.quadtree(M),i,a),r=-1;++r<_;)(l=M[r]).fixed||t.visit(n(l));for(r=-1;++r<_;)l=M[r],l.fixed?(l.x=l.px,l.y=l.py):(l.x-=(l.px-(l.px=l.x))*s,l.y-=(l.py-(l.py=l.y))*s);c.tick({type:"tick",alpha:i})},l.nodes=function(n){return arguments.length?(M=n,l):M},l.links=function(n){return arguments.length?(x=n,l):x},l.size=function(n){return arguments.length?(f=n,l):f},l.linkDistance=function(n){return arguments.length?(h="function"==typeof n?n:+n,l):h},l.distance=l.linkDistance,l.linkStrength=function(n){return arguments.length?(p="function"==typeof n?n:+n,l):p},l.friction=function(n){return arguments.length?(s=+n,l):s},l.charge=function(n){return arguments.length?(g="function"==typeof n?n:+n,l):g},l.chargeDistance=function(n){return arguments.length?(v=n*n,l):Math.sqrt(v)},l.gravity=function(n){return arguments.length?(d=+n,l):d},l.theta=function(n){return arguments.length?(y=n*n,l):Math.sqrt(y)},l.alpha=function(n){return arguments.length?(n=+n,i?n>0?i=n:(e.c=null,e.t=NaN,e=null,c.end({type:"end",alpha:i=0})):n>0&&(c.start({type:"start",alpha:i=n}),e=qn(l.tick)),l):i},l.start=function(){function n(n,r){if(!e){for(e=new Array(i),l=0;i>l;++l)e[l]=[];for(l=0;c>l;++l){var u=x[l];e[u.source.index].push(u.target),e[u.target.index].push(u.source)}}for(var o,a=e[t],l=-1,f=a.length;++lt;++t)(r=M[t]).index=t,r.weight=0;for(t=0;c>t;++t)r=x[t],"number"==typeof r.source&&(r.source=M[r.source]),"number"==typeof r.target&&(r.target=M[r.target]),++r.source.weight,++r.target.weight;for(t=0;i>t;++t)r=M[t],isNaN(r.x)&&(r.x=n("x",s)),isNaN(r.y)&&(r.y=n("y",v)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(u=[],"function"==typeof h)for(t=0;c>t;++t)u[t]=+h.call(this,x[t],t);else for(t=0;c>t;++t)u[t]=h;if(o=[],"function"==typeof p)for(t=0;c>t;++t)o[t]=+p.call(this,x[t],t);else for(t=0;c>t;++t)o[t]=p;if(a=[],"function"==typeof g)for(t=0;i>t;++t)a[t]=+g.call(this,M[t],t);else for(t=0;i>t;++t)a[t]=g;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return r||(r=ao.behavior.drag().origin(m).on("dragstart.force",Qr).on("drag.force",t).on("dragend.force",ni)),arguments.length?void this.on("mouseover.force",ti).on("mouseout.force",ei).call(r):r},ao.rebind(l,c,"on")};var ml=20,Ml=1,xl=1/0;ao.layout.hierarchy=function(){function n(i){var u,o=[i],a=[];for(i.depth=0;null!=(u=o.pop());)if(a.push(u),(c=e.call(n,u,u.depth))&&(l=c.length)){for(var l,c,f;--l>=0;)o.push(f=c[l]),f.parent=u,f.depth=u.depth+1;r&&(u.value=0),u.children=c}else r&&(u.value=+r.call(n,u,u.depth)||0),delete u.children;return oi(i,function(n){var e,i;t&&(e=n.children)&&e.sort(t),r&&(i=n.parent)&&(i.value+=n.value)}),a}var t=ci,e=ai,r=li;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(ui(t,function(n){n.children&&(n.value=0)}),oi(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},ao.layout.partition=function(){function n(t,e,r,i){var u=t.children;if(t.x=e,t.y=t.depth*i,t.dx=r,t.dy=i,u&&(o=u.length)){var o,a,l,c=-1;for(r=t.value?r/t.value:0;++cs?-1:1),g=ao.sum(c),v=g?(s-l*p)/g:0,d=ao.range(l),y=[];return null!=e&&d.sort(e===bl?function(n,t){return c[t]-c[n]}:function(n,t){return e(o[n],o[t])}),d.forEach(function(n){y[n]={data:o[n],value:a=c[n],startAngle:f,endAngle:f+=a*v+p,padAngle:h}}),y}var t=Number,e=bl,r=0,i=Ho,u=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(i=t,n):i},n.padAngle=function(t){return arguments.length?(u=t,n):u},n};var bl={};ao.layout.stack=function(){function n(a,l){if(!(h=a.length))return a;var c=a.map(function(e,r){return t.call(n,e,r)}),f=c.map(function(t){return t.map(function(t,e){return[u.call(n,t,e),o.call(n,t,e)]})}),s=e.call(n,f,l);c=ao.permute(c,s),f=ao.permute(f,s);var h,p,g,v,d=r.call(n,f,l),y=c[0].length;for(g=0;y>g;++g)for(i.call(n,c[0][g],v=d[g],f[0][g][1]),p=1;h>p;++p)i.call(n,c[p][g],v+=f[p-1][g][1],f[p][g][1]);return a}var t=m,e=gi,r=vi,i=pi,u=si,o=hi;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:_l.get(t)||gi,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:wl.get(t)||vi,n):r},n.x=function(t){return arguments.length?(u=t,n):u},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(i=t,n):i},n};var _l=ao.map({"inside-out":function(n){var t,e,r=n.length,i=n.map(di),u=n.map(yi),o=ao.range(r).sort(function(n,t){return i[n]-i[t]}),a=0,l=0,c=[],f=[];for(t=0;r>t;++t)e=o[t],l>a?(a+=u[e],c.push(e)):(l+=u[e],f.push(e));return f.reverse().concat(c)},reverse:function(n){return ao.range(n.length).reverse()},"default":gi}),wl=ao.map({silhouette:function(n){var t,e,r,i=n.length,u=n[0].length,o=[],a=0,l=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;u>e;++e)l[e]=(a-o[e])/2;return l},wiggle:function(n){var t,e,r,i,u,o,a,l,c,f=n.length,s=n[0],h=s.length,p=[];for(p[0]=l=c=0,e=1;h>e;++e){for(t=0,i=0;f>t;++t)i+=n[t][e][1];for(t=0,u=0,a=s[e][0]-s[e-1][0];f>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;u+=o*n[t][e][1]}p[e]=l-=i?u/i*a:0,c>l&&(c=l)}for(e=0;h>e;++e)p[e]-=c;return p},expand:function(n){var t,e,r,i=n.length,u=n[0].length,o=1/i,a=[];for(e=0;u>e;++e){for(t=0,r=0;i>t;t++)r+=n[t][e][1];if(r)for(t=0;i>t;t++)n[t][e][1]/=r;else for(t=0;i>t;t++)n[t][e][1]=o}for(e=0;u>e;++e)a[e]=0;return a},zero:vi});ao.layout.histogram=function(){function n(n,u){for(var o,a,l=[],c=n.map(e,this),f=r.call(this,c,u),s=i.call(this,f,c,u),u=-1,h=c.length,p=s.length-1,g=t?1:1/h;++u0)for(u=-1;++u=f[0]&&a<=f[1]&&(o=l[ao.bisect(s,a,1,p)-1],o.y+=g,o.push(n[u]));return l}var t=!0,e=Number,r=bi,i=Mi;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=En(t),n):r},n.bins=function(t){return arguments.length?(i="number"==typeof t?function(n){return xi(n,t)}:En(t),n):i},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},ao.layout.pack=function(){function n(n,u){var o=e.call(this,n,u),a=o[0],l=i[0],c=i[1],f=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,oi(a,function(n){n.r=+f(n.value)}),oi(a,Ni),r){var s=r*(t?1:Math.max(2*a.r/l,2*a.r/c))/2;oi(a,function(n){n.r+=s}),oi(a,Ni),oi(a,function(n){n.r-=s})}return Ci(a,l/2,c/2,t?1:1/Math.max(2*a.r/l,2*a.r/c)),o}var t,e=ao.layout.hierarchy().sort(_i),r=0,i=[1,1];return n.size=function(t){return arguments.length?(i=t,n):i},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},ii(n,e)},ao.layout.tree=function(){function n(n,i){var f=o.call(this,n,i),s=f[0],h=t(s);if(oi(h,e),h.parent.m=-h.z,ui(h,r),c)ui(s,u);else{var p=s,g=s,v=s;ui(s,function(n){n.xg.x&&(g=n),n.depth>v.depth&&(v=n)});var d=a(p,g)/2-p.x,y=l[0]/(g.x+a(g,p)/2+d),m=l[1]/(v.depth||1);ui(s,function(n){n.x=(n.x+d)*y,n.y=n.depth*m})}return f}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var i,u=t.children,o=0,a=u.length;a>o;++o)r.push((u[o]=i={_:u[o],parent:t,children:(i=u[o].children)&&i.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=i);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){Di(n);var u=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-u):n.z=u}else r&&(n.z=r.z+a(n._,r._));n.parent.A=i(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function i(n,t,e){if(t){for(var r,i=n,u=n,o=t,l=i.parent.children[0],c=i.m,f=u.m,s=o.m,h=l.m;o=Ti(o),i=qi(i),o&&i;)l=qi(l),u=Ti(u),u.a=n,r=o.z+s-i.z-c+a(o._,i._),r>0&&(Ri(Pi(o,n,e),n,r),c+=r,f+=r),s+=o.m,c+=i.m,h+=l.m,f+=u.m;o&&!Ti(u)&&(u.t=o,u.m+=s-f),i&&!qi(l)&&(l.t=i,l.m+=c-h,e=n)}return e}function u(n){n.x*=l[0],n.y=n.depth*l[1]}var o=ao.layout.hierarchy().sort(null).value(null),a=Li,l=[1,1],c=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(c=null==(l=t)?u:null,n):c?null:l},n.nodeSize=function(t){return arguments.length?(c=null==(l=t)?null:u,n):c?l:null},ii(n,o)},ao.layout.cluster=function(){function n(n,u){var o,a=t.call(this,n,u),l=a[0],c=0;oi(l,function(n){var t=n.children;t&&t.length?(n.x=ji(t),n.y=Ui(t)):(n.x=o?c+=e(n,o):0,n.y=0,o=n)});var f=Fi(l),s=Hi(l),h=f.x-e(f,s)/2,p=s.x+e(s,f)/2;return oi(l,i?function(n){n.x=(n.x-l.x)*r[0],n.y=(l.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(p-h)*r[0],n.y=(1-(l.y?n.y/l.y:1))*r[1]}),a}var t=ao.layout.hierarchy().sort(null).value(null),e=Li,r=[1,1],i=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(i=null==(r=t),n):i?null:r},n.nodeSize=function(t){return arguments.length?(i=null!=(r=t),n):i?r:null},ii(n,t)},ao.layout.treemap=function(){function n(n,t){for(var e,r,i=-1,u=n.length;++it?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var u=e.children;if(u&&u.length){var o,a,l,c=s(e),f=[],h=u.slice(),g=1/0,v="slice"===p?c.dx:"dice"===p?c.dy:"slice-dice"===p?1&e.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(n(h,c.dx*c.dy/e.value),f.area=0;(l=h.length)>0;)f.push(o=h[l-1]),f.area+=o.area,"squarify"!==p||(a=r(f,v))<=g?(h.pop(),g=a):(f.area-=f.pop().area,i(f,v,c,!1),v=Math.min(c.dx,c.dy),f.length=f.area=0,g=1/0);f.length&&(i(f,v,c,!0),f.length=f.area=0),u.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var u,o=s(t),a=r.slice(),l=[];for(n(a,o.dx*o.dy/t.value),l.area=0;u=a.pop();)l.push(u),l.area+=u.area,null!=u.z&&(i(l,u.z?o.dx:o.dy,o,!a.length),l.length=l.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,i=0,u=1/0,o=-1,a=n.length;++oe&&(u=e),e>i&&(i=e));return r*=r,t*=t,r?Math.max(t*i*g/r,r/(t*u*g)):1/0}function i(n,t,e,r){var i,u=-1,o=n.length,a=e.x,c=e.y,f=t?l(n.area/t):0; -if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ue.dx)&&(f=e.dx);++ue&&(t=1),1>e&&(n=0),function(){var e,r,i;do e=2*Math.random()-1,r=2*Math.random()-1,i=e*e+r*r;while(!i||i>1);return n+t*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var n=ao.random.normal.apply(ao,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=ao.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},ao.scale={};var Sl={floor:m,ceil:m};ao.scale.linear=function(){return Wi([0,1],[0,1],Mr,!1)};var kl={s:1,g:1,p:1,r:1,e:1};ao.scale.log=function(){return ru(ao.scale.linear().domain([0,1]),10,!0,[1,10])};var Nl=ao.format(".0e"),El={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};ao.scale.pow=function(){return iu(ao.scale.linear(),1,[0,1])},ao.scale.sqrt=function(){return ao.scale.pow().exponent(.5)},ao.scale.ordinal=function(){return ou([],{t:"range",a:[[]]})},ao.scale.category10=function(){return ao.scale.ordinal().range(Al)},ao.scale.category20=function(){return ao.scale.ordinal().range(Cl)},ao.scale.category20b=function(){return ao.scale.ordinal().range(zl)},ao.scale.category20c=function(){return ao.scale.ordinal().range(Ll)};var Al=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(xn),Cl=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(xn),zl=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(xn),Ll=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(xn);ao.scale.quantile=function(){return au([],[])},ao.scale.quantize=function(){return lu(0,1,[0,1])},ao.scale.threshold=function(){return cu([.5],[0,1])},ao.scale.identity=function(){return fu([0,1])},ao.svg={},ao.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),f=o.apply(this,arguments)-Io,s=a.apply(this,arguments)-Io,h=Math.abs(s-f),p=f>s?0:1;if(n>c&&(g=c,c=n,n=g),h>=Oo)return t(c,p)+(n?t(n,1-p):"")+"Z";var g,v,d,y,m,M,x,b,_,w,S,k,N=0,E=0,A=[];if((y=(+l.apply(this,arguments)||0)/2)&&(d=u===ql?Math.sqrt(n*n+c*c):+u.apply(this,arguments),p||(E*=-1),c&&(E=tn(d/c*Math.sin(y))),n&&(N=tn(d/n*Math.sin(y)))),c){m=c*Math.cos(f+E),M=c*Math.sin(f+E),x=c*Math.cos(s-E),b=c*Math.sin(s-E);var C=Math.abs(s-f-2*E)<=Fo?0:1;if(E&&yu(m,M,x,b)===p^C){var z=(f+s)/2;m=c*Math.cos(z),M=c*Math.sin(z),x=b=null}}else m=M=0;if(n){_=n*Math.cos(s-N),w=n*Math.sin(s-N),S=n*Math.cos(f+N),k=n*Math.sin(f+N);var L=Math.abs(f-s+2*N)<=Fo?0:1;if(N&&yu(_,w,S,k)===1-p^L){var q=(f+s)/2;_=n*Math.cos(q),w=n*Math.sin(q),S=k=null}}else _=w=0;if(h>Uo&&(g=Math.min(Math.abs(c-n)/2,+i.apply(this,arguments)))>.001){v=c>n^p?0:1;var T=g,R=g;if(Fo>h){var D=null==S?[_,w]:null==x?[m,M]:Re([m,M],[S,k],[x,b],[_,w]),P=m-D[0],U=M-D[1],j=x-D[0],F=b-D[1],H=1/Math.sin(Math.acos((P*j+U*F)/(Math.sqrt(P*P+U*U)*Math.sqrt(j*j+F*F)))/2),O=Math.sqrt(D[0]*D[0]+D[1]*D[1]);R=Math.min(g,(n-O)/(H-1)),T=Math.min(g,(c-O)/(H+1))}if(null!=x){var I=mu(null==S?[_,w]:[S,k],[m,M],c,T,p),Y=mu([x,b],[_,w],c,T,p);g===T?A.push("M",I[0],"A",T,",",T," 0 0,",v," ",I[1],"A",c,",",c," 0 ",1-p^yu(I[1][0],I[1][1],Y[1][0],Y[1][1]),",",p," ",Y[1],"A",T,",",T," 0 0,",v," ",Y[0]):A.push("M",I[0],"A",T,",",T," 0 1,",v," ",Y[0])}else A.push("M",m,",",M);if(null!=S){var Z=mu([m,M],[S,k],n,-R,p),V=mu([_,w],null==x?[m,M]:[x,b],n,-R,p);g===R?A.push("L",V[0],"A",R,",",R," 0 0,",v," ",V[1],"A",n,",",n," 0 ",p^yu(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-p," ",Z[1],"A",R,",",R," 0 0,",v," ",Z[0]):A.push("L",V[0],"A",R,",",R," 0 0,",v," ",Z[0])}else A.push("L",_,",",w)}else A.push("M",m,",",M),null!=x&&A.push("A",c,",",c," 0 ",C,",",p," ",x,",",b),A.push("L",_,",",w),null!=S&&A.push("A",n,",",n," 0 ",L,",",1-p," ",S,",",k);return A.push("Z"),A.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=hu,r=pu,i=su,u=ql,o=gu,a=vu,l=du;return n.innerRadius=function(t){return arguments.length?(e=En(t),n):e},n.outerRadius=function(t){return arguments.length?(r=En(t),n):r},n.cornerRadius=function(t){return arguments.length?(i=En(t),n):i},n.padRadius=function(t){return arguments.length?(u=t==ql?ql:En(t),n):u},n.startAngle=function(t){return arguments.length?(o=En(t),n):o},n.endAngle=function(t){return arguments.length?(a=En(t),n):a},n.padAngle=function(t){return arguments.length?(l=En(t),n):l},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-Io;return[Math.cos(t)*n,Math.sin(t)*n]},n};var ql="auto";ao.svg.line=function(){return Mu(m)};var Tl=ao.map({linear:xu,"linear-closed":bu,step:_u,"step-before":wu,"step-after":Su,basis:zu,"basis-open":Lu,"basis-closed":qu,bundle:Tu,cardinal:Eu,"cardinal-open":ku,"cardinal-closed":Nu,monotone:Fu});Tl.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Rl=[0,2/3,1/3,0],Dl=[0,1/3,2/3,0],Pl=[0,1/6,2/3,1/6];ao.svg.line.radial=function(){var n=Mu(Hu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},wu.reverse=Su,Su.reverse=wu,ao.svg.area=function(){return Ou(m)},ao.svg.area.radial=function(){var n=Ou(Hu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},ao.svg.chord=function(){function n(n,a){var l=t(this,u,n,a),c=t(this,o,n,a);return"M"+l.p0+r(l.r,l.p1,l.a1-l.a0)+(e(l,c)?i(l.r,l.p1,l.r,l.p0):i(l.r,l.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+i(c.r,c.p1,l.r,l.p0))+"Z"}function t(n,t,e,r){var i=t.call(n,e,r),u=a.call(n,i,r),o=l.call(n,i,r)-Io,f=c.call(n,i,r)-Io;return{r:u,a0:o,a1:f,p0:[u*Math.cos(o),u*Math.sin(o)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Fo)+",1 "+t}function i(n,t,e,r){return"Q 0,0 "+r}var u=Me,o=xe,a=Iu,l=gu,c=vu;return n.radius=function(t){return arguments.length?(a=En(t),n):a},n.source=function(t){return arguments.length?(u=En(t),n):u},n.target=function(t){return arguments.length?(o=En(t),n):o},n.startAngle=function(t){return arguments.length?(l=En(t),n):l},n.endAngle=function(t){return arguments.length?(c=En(t),n):c},n},ao.svg.diagonal=function(){function n(n,i){var u=t.call(this,n,i),o=e.call(this,n,i),a=(u.y+o.y)/2,l=[u,{x:u.x,y:a},{x:o.x,y:a},o];return l=l.map(r),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var t=Me,e=xe,r=Yu;return n.source=function(e){return arguments.length?(t=En(e),n):t},n.target=function(t){return arguments.length?(e=En(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},ao.svg.diagonal.radial=function(){var n=ao.svg.diagonal(),t=Yu,e=n.projection;return n.projection=function(n){return arguments.length?e(Zu(t=n)):t},n},ao.svg.symbol=function(){function n(n,r){return(Ul.get(t.call(this,n,r))||$u)(e.call(this,n,r))}var t=Xu,e=Vu;return n.type=function(e){return arguments.length?(t=En(e),n):t},n.size=function(t){return arguments.length?(e=En(t),n):e},n};var Ul=ao.map({circle:$u,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Fl)),e=t*Fl;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/jl),e=t*jl/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});ao.svg.symbolTypes=Ul.keys();var jl=Math.sqrt(3),Fl=Math.tan(30*Yo);Co.transition=function(n){for(var t,e,r=Hl||++Zl,i=Ku(n),u=[],o=Ol||{time:Date.now(),ease:Nr,delay:0,duration:250},a=-1,l=this.length;++au;u++){i.push(t=[]);for(var e=this[u],a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,u)&&t.push(r)}return Wu(i,this.namespace,this.id)},Yl.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):Y(this,null==t?function(t){t[r][e].tween.remove(n)}:function(i){i[r][e].tween.set(n,t)})},Yl.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function i(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function u(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?$r:Mr,a=ao.ns.qualify(n);return Ju(this,"attr."+n,t,a.local?u:i)},Yl.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(i));return r&&function(n){this.setAttribute(i,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(i.space,i.local));return r&&function(n){this.setAttributeNS(i.space,i.local,r(n))}}var i=ao.ns.qualify(n);return this.tween("attr."+n,i.local?r:e)},Yl.style=function(n,e,r){function i(){this.style.removeProperty(n)}function u(e){return null==e?i:(e+="",function(){var i,u=t(this).getComputedStyle(this,null).getPropertyValue(n);return u!==e&&(i=Mr(u,e),function(t){this.style.setProperty(n,i(t),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof n){2>o&&(e="");for(r in n)this.style(r,n[r],e);return this}r=""}return Ju(this,"style."+n,e,u)},Yl.styleTween=function(n,e,r){function i(i,u){var o=e.call(this,i,u,t(this).getComputedStyle(this,null).getPropertyValue(n));return o&&function(t){this.style.setProperty(n,o(t),r)}}return arguments.length<3&&(r=""),this.tween("style."+n,i)},Yl.text=function(n){return Ju(this,"text",n,Gu)},Yl.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Yl.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=ao.ease.apply(ao,arguments)),Y(this,function(r){r[e][t].ease=n}))},Yl.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:Y(this,"function"==typeof n?function(r,i,u){r[e][t].delay=+n.call(r,r.__data__,i,u)}:(n=+n,function(r){r[e][t].delay=n}))},Yl.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:Y(this,"function"==typeof n?function(r,i,u){r[e][t].duration=Math.max(1,n.call(r,r.__data__,i,u))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Yl.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var i=Ol,u=Hl;try{Hl=e,Y(this,function(t,i,u){Ol=t[r][e],n.call(t,t.__data__,i,u)})}finally{Ol=i,Hl=u}}else Y(this,function(i){var u=i[r][e];(u.event||(u.event=ao.dispatch("start","end","interrupt"))).on(n,t)});return this},Yl.transition=function(){for(var n,t,e,r,i=this.id,u=++Zl,o=this.namespace,a=[],l=0,c=this.length;c>l;l++){a.push(n=[]);for(var t=this[l],f=0,s=t.length;s>f;f++)(e=t[f])&&(r=e[o][i],Qu(e,f,o,u,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Wu(a,o,u)},ao.svg.axis=function(){function n(n){n.each(function(){var n,c=ao.select(this),f=this.__chart__||e,s=this.__chart__=e.copy(),h=null==l?s.ticks?s.ticks.apply(s,a):s.domain():l,p=null==t?s.tickFormat?s.tickFormat.apply(s,a):m:t,g=c.selectAll(".tick").data(h,s),v=g.enter().insert("g",".domain").attr("class","tick").style("opacity",Uo),d=ao.transition(g.exit()).style("opacity",Uo).remove(),y=ao.transition(g.order()).style("opacity",1),M=Math.max(i,0)+o,x=Zi(s),b=c.selectAll(".domain").data([0]),_=(b.enter().append("path").attr("class","domain"),ao.transition(b));v.append("line"),v.append("text");var w,S,k,N,E=v.select("line"),A=y.select("line"),C=g.select("text").text(p),z=v.select("text"),L=y.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=no,w="x",k="y",S="x2",N="y2",C.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),_.attr("d","M"+x[0]+","+q*u+"V0H"+x[1]+"V"+q*u)):(n=to,w="y",k="x",S="y2",N="x2",C.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),_.attr("d","M"+q*u+","+x[0]+"H0V"+x[1]+"H"+q*u)),E.attr(N,q*i),z.attr(k,q*M),A.attr(S,0).attr(N,q*i),L.attr(w,0).attr(k,q*M),s.rangeBand){var T=s,R=T.rangeBand()/2;f=s=function(n){return T(n)+R}}else f.rangeBand?f=s:d.call(n,s,f);v.call(n,f,s),y.call(n,s,s)})}var t,e=ao.scale.linear(),r=Vl,i=6,u=6,o=3,a=[10],l=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Xl?t+"":Vl,n):r},n.ticks=function(){return arguments.length?(a=co(arguments),n):a},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(i=+t,u=+arguments[e-1],n):i},n.innerTickSize=function(t){return arguments.length?(i=+t,n):i},n.outerTickSize=function(t){return arguments.length?(u=+t,n):u},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Vl="bottom",Xl={top:1,right:1,bottom:1,left:1};ao.svg.brush=function(){function n(t){t.each(function(){var t=ao.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",u).on("touchstart.brush",u),o=t.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=t.selectAll(".resize").data(v,m);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return $l[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var l,s=ao.transition(t),h=ao.transition(o);c&&(l=Zi(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(s)),f&&(l=Zi(f),h.attr("y",l[0]).attr("height",l[1]-l[0]),i(s)),e(s)})}function e(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function r(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function i(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function u(){function u(){32==ao.event.keyCode&&(C||(M=null,L[0]-=s[1],L[1]-=h[1],C=2),S())}function v(){32==ao.event.keyCode&&2==C&&(L[0]+=s[1],L[1]+=h[1],C=0,S())}function d(){var n=ao.mouse(b),t=!1;x&&(n[0]+=x[0],n[1]+=x[1]),C||(ao.event.altKey?(M||(M=[(s[0]+s[1])/2,(h[0]+h[1])/2]),L[0]=s[+(n[0]f?(i=r,r=f):i=f),v[0]!=r||v[1]!=i?(e?a=null:o=null,v[0]=r,v[1]=i,!0):void 0}function m(){d(),k.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),ao.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),z(),w({type:"brushend"})}var M,x,b=this,_=ao.select(ao.event.target),w=l.of(b,arguments),k=ao.select(b),N=_.datum(),E=!/^(n|s)$/.test(N)&&c,A=!/^(e|w)$/.test(N)&&f,C=_.classed("extent"),z=W(b),L=ao.mouse(b),q=ao.select(t(b)).on("keydown.brush",u).on("keyup.brush",v);if(ao.event.changedTouches?q.on("touchmove.brush",d).on("touchend.brush",m):q.on("mousemove.brush",d).on("mouseup.brush",m),k.interrupt().selectAll("*").interrupt(),C)L[0]=s[0]-L[0],L[1]=h[0]-L[1];else if(N){var T=+/w$/.test(N),R=+/^n/.test(N);x=[s[1-T]-L[0],h[1-R]-L[1]],L[0]=s[T],L[1]=h[R]}else ao.event.altKey&&(M=L.slice());k.style("pointer-events","none").selectAll(".resize").style("display",null),ao.select("body").style("cursor",_.style("cursor")),w({type:"brushstart"}),d()}var o,a,l=N(n,"brushstart","brush","brushend"),c=null,f=null,s=[0,0],h=[0,0],p=!0,g=!0,v=Bl[0];return n.event=function(n){n.each(function(){var n=l.of(this,arguments),t={x:s,y:h,i:o,j:a},e=this.__chart__||t;this.__chart__=t,Hl?ao.select(this).transition().each("start.brush",function(){o=e.i,a=e.j,s=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=xr(s,t.x),r=xr(h,t.y);return o=a=null,function(i){s=t.x=e(i),h=t.y=r(i),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=t.i,a=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,v=Bl[!c<<1|!f],n):c},n.y=function(t){return arguments.length?(f=t,v=Bl[!c<<1|!f],n):f},n.clamp=function(t){return arguments.length?(c&&f?(p=!!t[0],g=!!t[1]):c?p=!!t:f&&(g=!!t),n):c&&f?[p,g]:c?p:f?g:null},n.extent=function(t){var e,r,i,u,l;return arguments.length?(c&&(e=t[0],r=t[1],f&&(e=e[0],r=r[0]),o=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(l=e,e=r,r=l),e==s[0]&&r==s[1]||(s=[e,r])),f&&(i=t[0],u=t[1],c&&(i=i[1],u=u[1]),a=[i,u],f.invert&&(i=f(i),u=f(u)),i>u&&(l=i,i=u,u=l),i==h[0]&&u==h[1]||(h=[i,u])),n):(c&&(o?(e=o[0],r=o[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(l=e,e=r,r=l))),f&&(a?(i=a[0],u=a[1]):(i=h[0],u=h[1],f.invert&&(i=f.invert(i),u=f.invert(u)),i>u&&(l=i,i=u,u=l))),c&&f?[[e,i],[r,u]]:c?[e,r]:f&&[i,u])},n.clear=function(){return n.empty()||(s=[0,0],h=[0,0],o=a=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!f&&h[0]==h[1]},ao.rebind(n,l,"on")};var $l={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Bl=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Wl=ga.format=xa.timeFormat,Jl=Wl.utc,Gl=Jl("%Y-%m-%dT%H:%M:%S.%LZ");Wl.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?eo:Gl,eo.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},eo.toString=Gl.toString,ga.second=On(function(n){return new va(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),ga.seconds=ga.second.range,ga.seconds.utc=ga.second.utc.range,ga.minute=On(function(n){return new va(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),ga.minutes=ga.minute.range,ga.minutes.utc=ga.minute.utc.range,ga.hour=On(function(n){var t=n.getTimezoneOffset()/60;return new va(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),ga.hours=ga.hour.range,ga.hours.utc=ga.hour.utc.range,ga.month=On(function(n){return n=ga.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),ga.months=ga.month.range,ga.months.utc=ga.month.utc.range;var Kl=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Ql=[[ga.second,1],[ga.second,5],[ga.second,15],[ga.second,30],[ga.minute,1],[ga.minute,5],[ga.minute,15],[ga.minute,30],[ga.hour,1],[ga.hour,3],[ga.hour,6],[ga.hour,12],[ga.day,1],[ga.day,2],[ga.week,1],[ga.month,1],[ga.month,3],[ga.year,1]],nc=Wl.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",zt]]),tc={range:function(n,t,e){return ao.range(Math.ceil(n/e)*e,+t,e).map(io)},floor:m,ceil:m};Ql.year=ga.year,ga.scale=function(){return ro(ao.scale.linear(),Ql,nc)};var ec=Ql.map(function(n){return[n[0].utc,n[1]]}),rc=Jl.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",zt]]);ec.year=ga.year.utc,ga.scale.utc=function(){return ro(ao.scale.linear(),ec,rc)},ao.text=An(function(n){return n.responseText}),ao.json=function(n,t){return Cn(n,"application/json",uo,t)},ao.html=function(n,t){return Cn(n,"text/html",oo,t)},ao.xml=An(function(n){return n.responseXML}),"function"==typeof define&&define.amd?(this.d3=ao,define(ao)):"object"==typeof module&&module.exports?module.exports=ao:this.d3=ao}.apply(self); +!function(){function n(n){return n&&(n.ownerDocument||n.document||n).documentElement}function t(n){return n&&(n.ownerDocument&&n.ownerDocument.defaultView||n.document&&n||n.defaultView)}function e(n,t){return t>n?-1:n>t?1:n>=t?0:NaN}function r(n){return null===n?NaN:+n}function u(n){return!isNaN(n)}function i(n){return{left:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)<0?r=i+1:u=i}return r},right:function(t,e,r,u){for(arguments.length<3&&(r=0),arguments.length<4&&(u=t.length);u>r;){var i=r+u>>>1;n(t[i],e)>0?u=i:r=i+1}return r}}}function o(n){return n.length}function a(n){for(var t=1;n*t%1;)t*=10;return t}function l(n,t){for(var e in t)Object.defineProperty(n.prototype,e,{value:t[e],enumerable:!1})}function c(){this._=Object.create(null)}function f(n){return(n+="")===ei||n[0]===ri?ri+n:n}function s(n){return(n+="")[0]===ri?n.slice(1):n}function h(n){return f(n)in this._}function g(n){return(n=f(n))in this._&&delete this._[n]}function p(){var n=[];for(var t in this._)n.push(s(t));return n}function d(){var n=0;for(var t in this._)++n;return n}function v(){for(var n in this._)return!1;return!0}function y(){this._=Object.create(null)}function m(n){return n}function x(n,t,e){return function(){var r=e.apply(t,arguments);return r===t?n:r}}function M(n,t){if(t in n)return t;t=t.charAt(0).toUpperCase()+t.slice(1);for(var e=0,r=ui.length;r>e;++e){var u=ui[e]+t;if(u in n)return u}}function _(){}function b(){}function w(n){function t(){for(var t,r=e,u=-1,i=r.length;++ue;e++)for(var u,i=n[e],o=0,a=i.length;a>o;o++)(u=i[o])&&t(u,o,e);return n}function Z(n){return oi(n,gi),n}function V(n){var t,e;return function(r,u,i){var o,a=n[i].update,l=a.length;for(i!=e&&(e=i,t=0),u>=t&&(t=u+1);!(o=a[t])&&++t0&&(n=n.slice(0,a));var c=pi.get(n);return c&&(n=c,l=B),a?t?u:r:t?_:i}function $(n,t){return function(e){var r=Iu.event;Iu.event=e,t[0]=this.__data__;try{n.apply(this,t)}finally{Iu.event=r}}}function B(n,t){var e=$(n,t);return function(n){var t=this,r=n.relatedTarget;r&&(r===t||8&r.compareDocumentPosition(t))||e.call(t,n)}}function W(e){var r=".dragsuppress-"+ ++vi,u="click"+r,i=Iu.select(t(e)).on("touchmove"+r,k).on("dragstart"+r,k).on("selectstart"+r,k);if(null==di&&(di="onselectstart"in e?!1:M(e.style,"userSelect")),di){var o=n(e).style,a=o[di];o[di]="none"}return function(n){if(i.on(r,null),di&&(o[di]=a),n){var t=function(){i.on(u,null)};i.on(u,function(){k(),t()},!0),setTimeout(t,0)}}}function J(n,e){e.changedTouches&&(e=e.changedTouches[0]);var r=n.ownerSVGElement||n;if(r.createSVGPoint){var u=r.createSVGPoint();if(0>yi){var i=t(n);if(i.scrollX||i.scrollY){r=Iu.select("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var o=r[0][0].getScreenCTM();yi=!(o.f||o.e),r.remove()}}return yi?(u.x=e.pageX,u.y=e.pageY):(u.x=e.clientX,u.y=e.clientY),u=u.matrixTransform(n.getScreenCTM().inverse()),[u.x,u.y]}var a=n.getBoundingClientRect();return[e.clientX-a.left-n.clientLeft,e.clientY-a.top-n.clientTop]}function G(){return Iu.event.changedTouches[0].identifier}function K(n,t,e){return(t[0]-n[0])*(e[1]-n[1])-(t[1]-n[1])*(e[0]-n[0])}function Q(n){return n>1?wi:-1>n?-wi:Math.asin(n)}function nn(n){return((n=Math.exp(n))-1/n)/2}function tn(n){return((n=Math.exp(n))+1/n)/2}function en(n){return((n=Math.exp(2*n))-1)/(n+1)}function rn(){}function un(n,t,e){return this instanceof un?(this.h=+n,this.s=+t,void(this.l=+e)):arguments.length<2?n instanceof un?new un(n.h,n.s,n.l):xn(""+n,Mn,un):new un(n,t,e)}function on(n,t,e){function r(n){return n>360?n-=360:0>n&&(n+=360),60>n?i+(o-i)*n/60:180>n?o:240>n?i+(o-i)*(240-n)/60:i}function u(n){return Math.round(255*r(n))}var i,o;return n=isNaN(n)?0:(n%=360)<0?n+360:n,t=isNaN(t)?0:0>t?0:t>1?1:t,e=0>e?0:e>1?1:e,o=.5>=e?e*(1+t):e+t-e*t,i=2*e-o,new dn(u(n+120),u(n),u(n-120))}function an(n,t,e){return this instanceof an?(this.h=+n,this.c=+t,void(this.l=+e)):arguments.length<2?n instanceof an?new an(n.h,n.c,n.l):n instanceof cn?sn(n.l,n.a,n.b):sn((n=_n((n=Iu.rgb(n)).r,n.g,n.b)).l,n.a,n.b):new an(n,t,e)}function ln(n,t,e){return isNaN(n)&&(n=0),isNaN(t)&&(t=0),new cn(e,Math.cos(n*=ki)*t,Math.sin(n)*t)}function cn(n,t,e){return this instanceof cn?(this.l=+n,this.a=+t,void(this.b=+e)):arguments.length<2?n instanceof cn?new cn(n.l,n.a,n.b):n instanceof an?ln(n.h,n.c,n.l):_n((n=dn(n)).r,n.g,n.b):new cn(n,t,e)}function fn(n,t,e){var r=(n+16)/116,u=r+t/500,i=r-e/200;return u=hn(u)*Ei,r=hn(r)*Ui,i=hn(i)*Pi,new dn(pn(3.2404542*u-1.5371385*r-.4985314*i),pn(-.969266*u+1.8760108*r+.041556*i),pn(.0556434*u-.2040259*r+1.0572252*i))}function sn(n,t,e){return n>0?new an(Math.atan2(e,t)*Ni,Math.sqrt(t*t+e*e),n):new an(NaN,NaN,n)}function hn(n){return n>.206893034?n*n*n:(n-4/29)/7.787037}function gn(n){return n>.008856?Math.pow(n,1/3):7.787037*n+4/29}function pn(n){return Math.round(255*(.00304>=n?12.92*n:1.055*Math.pow(n,1/2.4)-.055))}function dn(n,t,e){return this instanceof dn?(this.r=~~n,this.g=~~t,void(this.b=~~e)):arguments.length<2?n instanceof dn?new dn(n.r,n.g,n.b):xn(""+n,dn,on):new dn(n,t,e)}function vn(n){return new dn(n>>16,n>>8&255,255&n)}function yn(n){return vn(n)+""}function mn(n){return 16>n?"0"+Math.max(0,n).toString(16):Math.min(255,n).toString(16)}function xn(n,t,e){var r,u,i,o=0,a=0,l=0;if(r=/([a-z]+)\((.*)\)/.exec(n=n.toLowerCase()))switch(u=r[2].split(","),r[1]){case"hsl":return e(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(wn(u[0]),wn(u[1]),wn(u[2]))}return(i=Fi.get(n))?t(i.r,i.g,i.b):(null==n||"#"!==n.charAt(0)||isNaN(i=parseInt(n.slice(1),16))||(4===n.length?(o=(3840&i)>>4,o=o>>4|o,a=240&i,a=a>>4|a,l=15&i,l=l<<4|l):7===n.length&&(o=(16711680&i)>>16,a=(65280&i)>>8,l=255&i)),t(o,a,l))}function Mn(n,t,e){var r,u,i=Math.min(n/=255,t/=255,e/=255),o=Math.max(n,t,e),a=o-i,l=(o+i)/2;return a?(u=.5>l?a/(o+i):a/(2-o-i),r=n==o?(t-e)/a+(e>t?6:0):t==o?(e-n)/a+2:(n-t)/a+4,r*=60):(r=NaN,u=l>0&&1>l?0:r),new un(r,u,l)}function _n(n,t,e){n=bn(n),t=bn(t),e=bn(e);var r=gn((.4124564*n+.3575761*t+.1804375*e)/Ei),u=gn((.2126729*n+.7151522*t+.072175*e)/Ui),i=gn((.0193339*n+.119192*t+.9503041*e)/Pi);return cn(116*u-16,500*(r-u),200*(u-i))}function bn(n){return(n/=255)<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function wn(n){var t=parseFloat(n);return"%"===n.charAt(n.length-1)?Math.round(2.55*t):t}function kn(n){return"function"==typeof n?n:function(){return n}}function Nn(n){return function(t,e,r){return 2===arguments.length&&"function"==typeof e&&(r=e,e=null),An(t,e,n,r)}}function An(n,t,e,r){function u(){var n,t=l.status;if(!t&&zn(l)||t>=200&&300>t||304===t){try{n=e.call(i,l)}catch(r){return void o.error.call(i,r)}o.load.call(i,n)}else o.error.call(i,l)}var i={},o=Iu.dispatch("beforesend","progress","load","error"),a={},l=new XMLHttpRequest,c=null;return!self.XDomainRequest||"withCredentials"in l||!/^(http(s)?:)?\/\//.test(n)||(l=new XDomainRequest),"onload"in l?l.onload=l.onerror=u:l.onreadystatechange=function(){l.readyState>3&&u()},l.onprogress=function(n){var t=Iu.event;Iu.event=n;try{o.progress.call(i,l)}finally{Iu.event=t}},i.header=function(n,t){return n=(n+"").toLowerCase(),arguments.length<2?a[n]:(null==t?delete a[n]:a[n]=t+"",i)},i.mimeType=function(n){return arguments.length?(t=null==n?null:n+"",i):t},i.responseType=function(n){return arguments.length?(c=n,i):c},i.response=function(n){return e=n,i},["get","post"].forEach(function(n){i[n]=function(){return i.send.apply(i,[n].concat(Vu(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),l.open(e,n,!0),null==t||"accept"in a||(a.accept=t+",*/*"),l.setRequestHeader)for(var f in a)l.setRequestHeader(f,a[f]);return null!=t&&l.overrideMimeType&&l.overrideMimeType(t),null!=c&&(l.responseType=c),null!=u&&i.on("error",u).on("load",function(n){u(null,n)}),o.beforesend.call(i,l),l.send(null==r?null:r),i},i.abort=function(){return l.abort(),i},Iu.rebind(i,o,"on"),null==r?i:i.get(Cn(r))}function Cn(n){return 1===n.length?function(t,e){n(null==t?e:null)}:n}function zn(n){var t=n.responseType;return t&&"text"!==t?n.response:n.responseText}function Ln(n,t,e){var r=arguments.length;2>r&&(t=0),3>r&&(e=Date.now());var u=e+t,i={c:n,t:u,n:null};return Yi?Yi.n=i:Oi=i,Yi=i,Ii||(Zi=clearTimeout(Zi),Ii=1,Vi(Sn)),i}function Sn(){var n=Tn(),t=qn()-n;t>24?(isFinite(t)&&(clearTimeout(Zi),Zi=setTimeout(Sn,t)),Ii=0):(Ii=1,Vi(Sn))}function Tn(){for(var n=Date.now(),t=Oi;t;)n>=t.t&&t.c(n-t.t)&&(t.c=null),t=t.n;return n}function qn(){for(var n,t=Oi,e=1/0;t;)t.c?(t.t8?function(n){return n/e}:function(n){return n*e},symbol:n}}function En(n){var t=n.decimal,e=n.thousands,r=n.grouping,u=n.currency,i=r&&e?function(n,t){for(var u=n.length,i=[],o=0,a=r[0],l=0;u>0&&a>0&&(l+a+1>t&&(a=Math.max(1,t-l)),i.push(n.substring(u-=a,u+a)),!((l+=a+1)>t));)a=r[o=(o+1)%r.length];return i.reverse().join(e)}:m;return function(n){var e=$i.exec(n),r=e[1]||" ",o=e[2]||">",a=e[3]||"-",l=e[4]||"",c=e[5],f=+e[6],s=e[7],h=e[8],g=e[9],p=1,d="",v="",y=!1,m=!0;switch(h&&(h=+h.substring(1)),(c||"0"===r&&"="===o)&&(c=r="0",o="="),g){case"n":s=!0,g="g";break;case"%":p=100,v="%",g="f";break;case"p":p=100,v="%",g="r";break;case"b":case"o":case"x":case"X":"#"===l&&(d="0"+g.toLowerCase());case"c":m=!1;case"d":y=!0,h=0;break;case"s":p=-1,g="r"}"$"===l&&(d=u[0],v=u[1]),"r"!=g||h||(g="g"),null!=h&&("g"==g?h=Math.max(1,Math.min(21,h)):"e"!=g&&"f"!=g||(h=Math.max(0,Math.min(20,h)))),g=Bi.get(g)||Un;var x=c&&s;return function(n){var e=v;if(y&&n%1)return"";var u=0>n||0===n&&0>1/n?(n=-n,"-"):"-"===a?"":a;if(0>p){var l=Iu.formatPrefix(n,h);n=l.scale(n),e=l.symbol+v}else n*=p;n=g(n,h);var M,_,b=n.lastIndexOf(".");if(0>b){var w=m?n.lastIndexOf("e"):-1;0>w?(M=n,_=""):(M=n.substring(0,w),_=n.substring(w))}else M=n.substring(0,b),_=t+n.substring(b+1);!c&&s&&(M=i(M,1/0));var k=d.length+M.length+_.length+(x?0:u.length),N=f>k?new Array(k=f-k+1).join(r):"";return x&&(M=i(N+M,N.length?f-_.length:1/0)),u+=d,n=M+_,("<"===o?u+n+N:">"===o?N+u+n:"^"===o?N.substring(0,k>>=1)+u+n+N.substring(k):u+(x?n:N+n))+e}}}function Un(n){return n+""}function Pn(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function jn(n,t,e){function r(t){var e=n(t),r=i(e,1);return r-t>t-e?e:r}function u(e){return t(e=n(new Ji(e-1)),1),e}function i(n,e){return t(n=new Ji(+n),e),n}function o(n,r,i){var o=u(n),a=[];if(i>1)for(;r>o;)e(o)%i||a.push(new Date(+o)),t(o,1);else for(;r>o;)a.push(new Date(+o)),t(o,1);return a}function a(n,t,e){try{Ji=Pn;var r=new Pn;return r._=n,o(r,t,e)}finally{Ji=Date}}n.floor=n,n.round=r,n.ceil=u,n.offset=i,n.range=o;var l=n.utc=Hn(n);return l.floor=l,l.round=Hn(r),l.ceil=Hn(u),l.offset=Hn(i),l.range=a,n}function Hn(n){return function(t,e){try{Ji=Pn;var r=new Pn;return r._=t,n(r,e)._}finally{Ji=Date}}}function Fn(n){function t(n){function t(t){for(var e,u,i,o=[],a=-1,l=0;++aa;){if(r>=c)return-1;if(u=t.charCodeAt(a++),37===u){if(o=t.charAt(a++),i=L[o in Ki?t.charAt(a++):o],!i||(r=i(n,e,r))<0)return-1}else if(u!=e.charCodeAt(r++))return-1}return r}function r(n,t,e){b.lastIndex=0;var r=b.exec(t.slice(e));return r?(n.w=w.get(r[0].toLowerCase()),e+r[0].length):-1}function u(n,t,e){M.lastIndex=0;var r=M.exec(t.slice(e));return r?(n.w=_.get(r[0].toLowerCase()),e+r[0].length):-1}function i(n,t,e){A.lastIndex=0;var r=A.exec(t.slice(e));return r?(n.m=C.get(r[0].toLowerCase()),e+r[0].length):-1}function o(n,t,e){k.lastIndex=0;var r=k.exec(t.slice(e));return r?(n.m=N.get(r[0].toLowerCase()),e+r[0].length):-1}function a(n,t,r){return e(n,z.c.toString(),t,r)}function l(n,t,r){return e(n,z.x.toString(),t,r)}function c(n,t,r){return e(n,z.X.toString(),t,r)}function f(n,t,e){var r=x.get(t.slice(e,e+=2).toLowerCase());return null==r?-1:(n.p=r,e)}var s=n.dateTime,h=n.date,g=n.time,p=n.periods,d=n.days,v=n.shortDays,y=n.months,m=n.shortMonths;t.utc=function(n){function e(n){try{Ji=Pn;var t=new Ji;return t._=n,r(t)}finally{Ji=Date}}var r=t(n);return e.parse=function(n){try{Ji=Pn;var t=r.parse(n);return t&&t._}finally{Ji=Date}},e.toString=r.toString,e},t.multi=t.utc.multi=ot;var x=Iu.map(),M=Yn(d),_=In(d),b=Yn(v),w=In(v),k=Yn(y),N=In(y),A=Yn(m),C=In(m);p.forEach(function(n,t){x.set(n.toLowerCase(),t)});var z={a:function(n){return v[n.getDay()]},A:function(n){return d[n.getDay()]},b:function(n){return m[n.getMonth()]},B:function(n){return y[n.getMonth()]},c:t(s),d:function(n,t){return On(n.getDate(),t,2)},e:function(n,t){return On(n.getDate(),t,2)},H:function(n,t){return On(n.getHours(),t,2)},I:function(n,t){return On(n.getHours()%12||12,t,2)},j:function(n,t){return On(1+Wi.dayOfYear(n),t,3)},L:function(n,t){return On(n.getMilliseconds(),t,3)},m:function(n,t){return On(n.getMonth()+1,t,2)},M:function(n,t){return On(n.getMinutes(),t,2)},p:function(n){return p[+(n.getHours()>=12)]},S:function(n,t){return On(n.getSeconds(),t,2)},U:function(n,t){return On(Wi.sundayOfYear(n),t,2)},w:function(n){return n.getDay()},W:function(n,t){return On(Wi.mondayOfYear(n),t,2)},x:t(h),X:t(g),y:function(n,t){return On(n.getFullYear()%100,t,2)},Y:function(n,t){return On(n.getFullYear()%1e4,t,4)},Z:ut,"%":function(){return"%"}},L={a:r,A:u,b:i,B:o,c:a,d:Kn,e:Kn,H:nt,I:nt,j:Qn,L:rt,m:Gn,M:tt,p:f,S:et,U:Vn,w:Zn,W:Xn,x:l,X:c,y:Bn,Y:$n,Z:Wn,"%":it};return t}function On(n,t,e){var r=0>n?"-":"",u=(r?-n:n)+"",i=u.length;return r+(e>i?new Array(e-i+1).join(t)+u:u)}function Yn(n){return new RegExp("^(?:"+n.map(Iu.requote).join("|")+")","i")}function In(n){for(var t=new c,e=-1,r=n.length;++e68?1900:2e3)}function Gn(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.m=r[0]-1,e+r[0].length):-1}function Kn(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.d=+r[0],e+r[0].length):-1}function Qn(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+3));return r?(n.j=+r[0],e+r[0].length):-1}function nt(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.H=+r[0],e+r[0].length):-1}function tt(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.M=+r[0],e+r[0].length):-1}function et(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+2));return r?(n.S=+r[0],e+r[0].length):-1}function rt(n,t,e){Qi.lastIndex=0;var r=Qi.exec(t.slice(e,e+3));return r?(n.L=+r[0],e+r[0].length):-1}function ut(n){var t=n.getTimezoneOffset(),e=t>0?"-":"+",r=ti(t)/60|0,u=ti(t)%60;return e+On(r,"0",2)+On(u,"0",2)}function it(n,t,e){no.lastIndex=0;var r=no.exec(t.slice(e,e+1));return r?e+r[0].length:-1}function ot(n){for(var t=n.length,e=-1;++eu;u++){for(;r>1&&K(n[e[r-2]],n[e[r-1]],n[u])<=0;)--r;e[r++]=u}return e.slice(0,r)}function ft(n,t){return n[0]-t[0]||n[1]-t[1]}function st(n,t,e){return(e[0]-t[0])*(n[1]-t[1])<(e[1]-t[1])*(n[0]-t[0])}function ht(n,t,e,r){var u=n[0],i=e[0],o=t[0]-u,a=r[0]-i,l=n[1],c=e[1],f=t[1]-l,s=r[1]-c,h=(a*(l-c)-s*(u-i))/(s*o-a*f);return[u+h*o,l+h*f]}function gt(n){var t=n[0],e=n[n.length-1];return!(t[0]-e[0]||t[1]-e[1])}function pt(){Ut(this),this.edge=this.site=this.circle=null}function dt(n){var t=lo.pop()||new pt;return t.site=n,t}function vt(n){At(n),io.remove(n),lo.push(n),Ut(n)}function yt(n){var t=n.circle,e=t.x,r=t.cy,u={x:e,y:r},i=n.P,o=n.N,a=[n];vt(n);for(var l=i;l.circle&&ti(e-l.circle.x)f;++f)c=a[f],l=a[f-1],Dt(c.edge,l.site,c.site,u);l=a[0],c=a[s-1],c.edge=Tt(l.site,c.site,null,u),Nt(l),Nt(c)}function mt(n){for(var t,e,r,u,i=n.x,o=n.y,a=io._;a;)if(r=xt(a,o)-i,r>mi)a=a.L;else{if(u=i-Mt(a,o),!(u>mi)){r>-mi?(t=a.P,e=a):u>-mi?(t=a,e=a.N):t=e=a;break}if(!a.R){t=a;break}a=a.R}var l=dt(n);if(io.insert(t,l),t||e){if(t===e)return At(t),e=dt(t.site),io.insert(l,e),l.edge=e.edge=Tt(t.site,l.site),Nt(t),void Nt(e);if(!e)return void(l.edge=Tt(t.site,l.site));At(t),At(e);var c=t.site,f=c.x,s=c.y,h=n.x-f,g=n.y-s,p=e.site,d=p.x-f,v=p.y-s,y=2*(h*v-g*d),m=h*h+g*g,x=d*d+v*v,M={x:(v*m-g*x)/y+f,y:(h*x-d*m)/y+s};Dt(e.edge,c,p,M),l.edge=Tt(c,n,null,M),e.edge=Tt(n,p,null,M),Nt(t),Nt(e)}}function xt(n,t){var e=n.site,r=e.x,u=e.y,i=u-t;if(!i)return r;var o=n.P;if(!o)return-(1/0);e=o.site;var a=e.x,l=e.y,c=l-t;if(!c)return a;var f=a-r,s=1/i-1/c,h=f/c;return s?(-h+Math.sqrt(h*h-2*s*(f*f/(-2*c)-l+c/2+u-i/2)))/s+r:(r+a)/2}function Mt(n,t){var e=n.N;if(e)return xt(e,t);var r=n.site;return r.y===t?r.x:1/0}function _t(n){this.site=n,this.edges=[]}function bt(n){for(var t,e,r,u,i,o,a,l,c,f,s=n[0][0],h=n[1][0],g=n[0][1],p=n[1][1],d=uo,v=d.length;v--;)if(i=d[v],i&&i.prepare())for(a=i.edges,l=a.length,o=0;l>o;)f=a[o].end(),r=f.x,u=f.y,c=a[++o%l].start(),t=c.x,e=c.y,(ti(r-t)>mi||ti(u-e)>mi)&&(a.splice(o,0,new Rt(qt(i.site,f,ti(r-s)mi?{x:s,y:ti(t-s)mi?{x:ti(e-p)mi?{x:h,y:ti(t-h)mi?{x:ti(e-g)=-xi)){var g=l*l+c*c,p=f*f+s*s,d=(s*g-c*p)/h,v=(l*p-f*g)/h,s=v+a,y=co.pop()||new kt;y.arc=n,y.site=u,y.x=d+o,y.y=s+Math.sqrt(d*d+v*v),y.cy=s,n.circle=y;for(var m=null,x=ao._;x;)if(y.y0)){if(i/=p,0>p){if(h>i)return;g>i&&(g=i)}else if(p>0){if(i>g)return;i>h&&(h=i)}if(i=e-l,p||!(0>i)){if(i/=p,0>p){if(i>g)return;i>h&&(h=i)}else if(p>0){if(h>i)return;g>i&&(g=i)}if(i=t-c,d||!(i>0)){if(i/=d,0>d){if(h>i)return;g>i&&(g=i)}else if(d>0){if(i>g)return;i>h&&(h=i)}if(i=r-c,d||!(0>i)){if(i/=d,0>d){if(i>g)return;i>h&&(h=i)}else if(d>0){if(h>i)return;g>i&&(g=i)}return h>0&&(u.a={x:l+h*p,y:c+h*d}),1>g&&(u.b={x:l+g*p,y:c+g*d}),u}}}}}}function zt(n){for(var t,e=ro,r=Ct(n[0][0],n[0][1],n[1][0],n[1][1]),u=e.length;u--;)t=e[u],(!Lt(t,n)||!r(t)||ti(t.a.x-t.b.x)v||v>=a)return;if(h>p){if(i){if(i.y>=c)return}else i={x:v,y:l};e={x:v,y:c}}else{if(i){if(i.yr||r>1)if(h>p){if(i){if(i.y>=c)return}else i={x:(l-u)/r,y:l};e={x:(c-u)/r,y:c}}else{if(i){if(i.yg){if(i){if(i.x>=a)return}else i={x:o,y:r*o+u};e={x:a,y:r*a+u}}else{if(i){if(i.xi||s>o||r>h||u>g)){if(p=n.point){var p,d=t-n.x,v=e-n.y,y=d*d+v*v;if(l>y){var m=Math.sqrt(l=y);r=t-m,u=e-m,i=t+m,o=e+m,a=p}}for(var x=n.nodes,M=.5*(f+h),_=.5*(s+g),b=t>=M,w=e>=_,k=w<<1|b,N=k+4;N>k;++k)if(n=x[3&k])switch(3&k){case 0:c(n,f,s,M,_);break;case 1:c(n,M,s,h,_);break;case 2:c(n,f,_,M,g);break;case 3:c(n,M,_,h,g)}}}(n,r,u,i,o),a}function Bt(n,t){n=Iu.rgb(n),t=Iu.rgb(t);var e=n.r,r=n.g,u=n.b,i=t.r-e,o=t.g-r,a=t.b-u;return function(n){return"#"+mn(Math.round(e+i*n))+mn(Math.round(r+o*n))+mn(Math.round(u+a*n))}}function Wt(n,t){var e,r={},u={};for(e in n)e in t?r[e]=Kt(n[e],t[e]):u[e]=n[e];for(e in t)e in n||(u[e]=t[e]);return function(n){for(e in r)u[e]=r[e](n);return u}}function Jt(n,t){return n=+n,t=+t,function(e){return n*(1-e)+t*e}}function Gt(n,t){var e,r,u,i=so.lastIndex=ho.lastIndex=0,o=-1,a=[],l=[];for(n+="",t+="";(e=so.exec(n))&&(r=ho.exec(t));)(u=r.index)>i&&(u=t.slice(i,u),a[o]?a[o]+=u:a[++o]=u),(e=e[0])===(r=r[0])?a[o]?a[o]+=r:a[++o]=r:(a[++o]=null,l.push({i:o,x:Jt(e,r)})),i=ho.lastIndex;return ir;++r)a[(e=l[r]).i]=e.x(n);return a.join("")})}function Kt(n,t){for(var e,r=Iu.interpolators.length;--r>=0&&!(e=Iu.interpolators[r](n,t)););return e}function Qt(n,t){var e,r=[],u=[],i=n.length,o=t.length,a=Math.min(n.length,t.length);for(e=0;a>e;++e)r.push(Kt(n[e],t[e]));for(;i>e;++e)u[e]=n[e];for(;o>e;++e)u[e]=t[e];return function(n){for(e=0;a>e;++e)u[e]=r[e](n);return u}}function ne(n){return function(t){return 0>=t?0:t>=1?1:n(t)}}function te(n){return function(t){return 1-n(1-t)}}function ee(n){return function(t){return.5*(.5>t?n(2*t):2-n(2-2*t))}}function re(n){return n*n}function ue(n){return n*n*n}function ie(n){if(0>=n)return 0;if(n>=1)return 1;var t=n*n,e=t*n;return 4*(.5>n?e:3*(n-t)+e-.75)}function oe(n){return function(t){return Math.pow(t,n)}}function ae(n){return 1-Math.cos(n*wi)}function le(n){return Math.pow(2,10*(n-1))}function ce(n){return 1-Math.sqrt(1-n*n)}function fe(n,t){var e;return arguments.length<2&&(t=.45),arguments.length?e=t/_i*Math.asin(1/n):(n=1,e=t/4),function(r){return 1+n*Math.pow(2,-10*r)*Math.sin((r-e)*_i/t)}}function se(n){return n||(n=1.70158),function(t){return t*t*((n+1)*t-n)}}function he(n){return 1/2.75>n?7.5625*n*n:2/2.75>n?7.5625*(n-=1.5/2.75)*n+.75:2.5/2.75>n?7.5625*(n-=2.25/2.75)*n+.9375:7.5625*(n-=2.625/2.75)*n+.984375}function ge(n,t){n=Iu.hcl(n),t=Iu.hcl(t);var e=n.h,r=n.c,u=n.l,i=t.h-e,o=t.c-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.c:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return ln(e+i*n,r+o*n,u+a*n)+""}}function pe(n,t){n=Iu.hsl(n),t=Iu.hsl(t);var e=n.h,r=n.s,u=n.l,i=t.h-e,o=t.s-r,a=t.l-u;return isNaN(o)&&(o=0,r=isNaN(r)?t.s:r),isNaN(i)?(i=0,e=isNaN(e)?t.h:e):i>180?i-=360:-180>i&&(i+=360),function(n){return on(e+i*n,r+o*n,u+a*n)+""}}function de(n,t){n=Iu.lab(n),t=Iu.lab(t);var e=n.l,r=n.a,u=n.b,i=t.l-e,o=t.a-r,a=t.b-u;return function(n){return fn(e+i*n,r+o*n,u+a*n)+""}}function ve(n,t){return t-=n,function(e){return Math.round(n+t*e)}}function ye(n){var t=[n.a,n.b],e=[n.c,n.d],r=xe(t),u=me(t,e),i=xe(Me(e,t,-u))||0;t[0]*e[1]180?t+=360:t-n>180&&(n+=360),r.push({i:e.push(_e(e)+"rotate(",null,")")-2,x:Jt(n,t)})):t&&e.push(_e(e)+"rotate("+t+")")}function ke(n,t,e,r){n!==t?r.push({i:e.push(_e(e)+"skewX(",null,")")-2,x:Jt(n,t)}):t&&e.push(_e(e)+"skewX("+t+")")}function Ne(n,t,e,r){if(n[0]!==t[0]||n[1]!==t[1]){var u=e.push(_e(e)+"scale(",null,",",null,")");r.push({i:u-4,x:Jt(n[0],t[0])},{i:u-2,x:Jt(n[1],t[1])})}else 1===t[0]&&1===t[1]||e.push(_e(e)+"scale("+t+")")}function Ae(n,t){var e=[],r=[];return n=Iu.transform(n),t=Iu.transform(t),be(n.translate,t.translate,e,r),we(n.rotate,t.rotate,e,r),ke(n.skew,t.skew,e,r),Ne(n.scale,t.scale,e,r),n=t=null,function(n){for(var t,u=-1,i=r.length;++u=0;)e.push(u[r])}function He(n,t){for(var e=[n],r=[];null!=(n=e.pop());)if(r.push(n),(i=n.children)&&(u=i.length))for(var u,i,o=-1;++oe;++e)(t=n[e][1])>u&&(r=e,u=t);return r}function Je(n){return n.reduce(Ge,0)}function Ge(n,t){return n+t[1]}function Ke(n,t){return Qe(n,Math.ceil(Math.log(t.length)/Math.LN2+1))}function Qe(n,t){for(var e=-1,r=+n[0],u=(n[1]-r)/t,i=[];++e<=t;)i[e]=u*e+r;return i}function nr(n){return[Iu.min(n),Iu.max(n)]}function tr(n,t){return n.value-t.value}function er(n,t){var e=n._pack_next;n._pack_next=t,t._pack_prev=n,t._pack_next=e,e._pack_prev=t}function rr(n,t){n._pack_next=t,t._pack_prev=n}function ur(n,t){var e=t.x-n.x,r=t.y-n.y,u=n.r+t.r;return.999*u*u>e*e+r*r}function ir(n){function t(n){f=Math.min(n.x-n.r,f),s=Math.max(n.x+n.r,s),h=Math.min(n.y-n.r,h),g=Math.max(n.y+n.r,g)}if((e=n.children)&&(c=e.length)){var e,r,u,i,o,a,l,c,f=1/0,s=-(1/0),h=1/0,g=-(1/0);if(e.forEach(or),r=e[0],r.x=-r.r,r.y=0,t(r),c>1&&(u=e[1],u.x=u.r,u.y=0,t(u),c>2))for(i=e[2],cr(r,u,i),t(i),er(r,i),r._pack_prev=i,er(i,u),u=r._pack_next,o=3;c>o;o++){cr(r,u,i=e[o]);var p=0,d=1,v=1;for(a=u._pack_next;a!==u;a=a._pack_next,d++)if(ur(a,i)){p=1;break}if(1==p)for(l=r._pack_prev;l!==a._pack_prev&&!ur(l,i);l=l._pack_prev,v++);p?(v>d||d==v&&u.ro;o++)i=e[o],i.x-=y,i.y-=m,x=Math.max(x,i.r+Math.sqrt(i.x*i.x+i.y*i.y));n.r=x,e.forEach(ar)}}function or(n){n._pack_next=n._pack_prev=n}function ar(n){delete n._pack_next,delete n._pack_prev}function lr(n,t,e,r){var u=n.children;if(n.x=t+=r*n.x,n.y=e+=r*n.y,n.r*=r,u)for(var i=-1,o=u.length;++i=0;)t=u[i],t.z+=e,t.m+=e,e+=t.s+(r+=t.c)}function dr(n,t,e){return n.a.parent===t.parent?n.a:e}function vr(n){return 1+Iu.max(n,function(n){return n.y})}function yr(n){return n.reduce(function(n,t){return n+t.x},0)/n.length}function mr(n){var t=n.children;return t&&t.length?mr(t[0]):n}function xr(n){var t,e=n.children;return e&&(t=e.length)?xr(e[t-1]):n}function Mr(n){return{x:n.x,y:n.y,dx:n.dx,dy:n.dy}}function _r(n,t){var e=n.x+t[3],r=n.y+t[0],u=n.dx-t[1]-t[3],i=n.dy-t[0]-t[2];return 0>u&&(e+=u/2,u=0),0>i&&(r+=i/2,i=0),{x:e,y:r,dx:u,dy:i}}function br(n){var t=n[0],e=n[n.length-1];return e>t?[t,e]:[e,t]}function wr(n){return n.rangeExtent?n.rangeExtent():br(n.range())}function kr(n,t,e,r){var u=e(n[0],n[1]),i=r(t[0],t[1]);return function(n){return i(u(n))}}function Nr(n,t){var e,r=0,u=n.length-1,i=n[r],o=n[u];return i>o&&(e=r,r=u,u=e,e=i,i=o,o=e),n[r]=t.floor(i),n[u]=t.ceil(o),n}function Ar(n){return n?{floor:function(t){return Math.floor(t/n)*n},ceil:function(t){return Math.ceil(t/n)*n}}:ko}function Cr(n,t,e,r){var u=[],i=[],o=0,a=Math.min(n.length,t.length)-1;for(n[a]2?Cr:kr,l=r?ze:Ce;return o=u(n,t,l,e),a=u(t,n,l,Kt),i}function i(n){return o(n)}var o,a;return i.invert=function(n){return a(n)},i.domain=function(t){return arguments.length?(n=t.map(Number),u()):n},i.range=function(n){return arguments.length?(t=n,u()):t},i.rangeRound=function(n){return i.range(n).interpolate(ve)},i.clamp=function(n){return arguments.length?(r=n,u()):r},i.interpolate=function(n){return arguments.length?(e=n,u()):e},i.ticks=function(t){return qr(n,t)},i.tickFormat=function(t,e){return Dr(n,t,e)},i.nice=function(t){return Sr(n,t),u()},i.copy=function(){return zr(n,t,e,r)},u()}function Lr(n,t){return Iu.rebind(n,t,"range","rangeRound","interpolate","clamp")}function Sr(n,t){return Nr(n,Ar(Tr(n,t)[2])),Nr(n,Ar(Tr(n,t)[2])),n}function Tr(n,t){null==t&&(t=10);var e=br(n),r=e[1]-e[0],u=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),i=t/r*u;return.15>=i?u*=10:.35>=i?u*=5:.75>=i&&(u*=2),e[0]=Math.ceil(e[0]/u)*u,e[1]=Math.floor(e[1]/u)*u+.5*u,e[2]=u,e}function qr(n,t){return Iu.range.apply(Iu,Tr(n,t))}function Dr(n,t,e){var r=Tr(n,t);if(e){var u=$i.exec(e);if(u.shift(),"s"===u[8]){var i=Iu.formatPrefix(Math.max(ti(r[0]),ti(r[1])));return u[7]||(u[7]="."+Rr(i.scale(r[2]))),u[8]="f",e=Iu.format(u.join("")),function(n){return e(i.scale(n))+i.symbol}}u[7]||(u[7]="."+Er(u[8],r)),e=u.join("")}else e=",."+Rr(r[2])+"f";return Iu.format(e)}function Rr(n){return-Math.floor(Math.log(n)/Math.LN10+.01)}function Er(n,t){var e=Rr(t[2]);return n in No?Math.abs(e-Rr(Math.max(ti(t[0]),ti(t[1]))))+ +("e"!==n):e-2*("%"===n)}function Ur(n,t,e,r){function u(n){return(e?Math.log(0>n?0:n):-Math.log(n>0?0:-n))/Math.log(t)}function i(n){return e?Math.pow(t,n):-Math.pow(t,-n)}function o(t){return n(u(t))}return o.invert=function(t){return i(n.invert(t))},o.domain=function(t){return arguments.length?(e=t[0]>=0,n.domain((r=t.map(Number)).map(u)),o):r},o.base=function(e){return arguments.length?(t=+e,n.domain(r.map(u)),o):t},o.nice=function(){var t=Nr(r.map(u),e?Math:Co);return n.domain(t),r=t.map(i),o},o.ticks=function(){var n=br(r),o=[],a=n[0],l=n[1],c=Math.floor(u(a)),f=Math.ceil(u(l)),s=t%1?2:t;if(isFinite(f-c)){if(e){for(;f>c;c++)for(var h=1;s>h;h++)o.push(i(c)*h);o.push(i(c))}else for(o.push(i(c));c++0;h--)o.push(i(c)*h);for(c=0;o[c]l;f--);o=o.slice(c,f)}return o},o.tickFormat=function(n,e){if(!arguments.length)return Ao;arguments.length<2?e=Ao:"function"!=typeof e&&(e=Iu.format(e));var r=Math.max(1,t*n/o.ticks().length);return function(n){var o=n/i(Math.round(u(n)));return t-.5>o*t&&(o*=t),r>=o?e(n):""}},o.copy=function(){return Ur(n.copy(),t,e,r)},Lr(o,n)}function Pr(n,t,e){function r(t){return n(u(t))}var u=jr(t),i=jr(1/t);return r.invert=function(t){return i(n.invert(t))},r.domain=function(t){return arguments.length?(n.domain((e=t.map(Number)).map(u)),r):e},r.ticks=function(n){return qr(e,n)},r.tickFormat=function(n,t){return Dr(e,n,t)},r.nice=function(n){return r.domain(Sr(e,n))},r.exponent=function(o){return arguments.length?(u=jr(t=o),i=jr(1/t),n.domain(e.map(u)),r):t},r.copy=function(){return Pr(n.copy(),t,e)},Lr(r,n)}function jr(n){return function(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}}function Hr(n,t){function e(e){return i[((u.get(e)||("range"===t.t?u.set(e,n.push(e)):NaN))-1)%i.length]}function r(t,e){return Iu.range(n.length).map(function(n){return t+e*n})}var u,i,o;return e.domain=function(r){if(!arguments.length)return n;n=[],u=new c;for(var i,o=-1,a=r.length;++oe?[NaN,NaN]:[e>0?a[e-1]:n[0],et?NaN:t/i+n,[t,t+1/i]},r.copy=function(){return Or(n,t,e)},u()}function Yr(n,t){function e(e){return e>=e?t[Iu.bisect(n,e)]:void 0}return e.domain=function(t){return arguments.length?(n=t,e):n},e.range=function(n){return arguments.length?(t=n,e):t},e.invertExtent=function(e){return e=t.indexOf(e),[n[e-1],n[e]]},e.copy=function(){return Yr(n,t)},e}function Ir(n){function t(n){return+n}return t.invert=t,t.domain=t.range=function(e){return arguments.length?(n=e.map(t),t):n},t.ticks=function(t){return qr(n,t)},t.tickFormat=function(t,e){return Dr(n,t,e)},t.copy=function(){return Ir(n)},t}function Zr(){return 0}function Vr(n){return n.innerRadius}function Xr(n){return n.outerRadius}function $r(n){return n.startAngle}function Br(n){return n.endAngle}function Wr(n){return n&&n.padAngle}function Jr(n,t,e,r){return(n-e)*t-(t-r)*n>0?0:1}function Gr(n,t,e,r,u){var i=n[0]-t[0],o=n[1]-t[1],a=(u?r:-r)/Math.sqrt(i*i+o*o),l=a*o,c=-a*i,f=n[0]+l,s=n[1]+c,h=t[0]+l,g=t[1]+c,p=(f+h)/2,d=(s+g)/2,v=h-f,y=g-s,m=v*v+y*y,x=e-r,M=f*g-h*s,_=(0>y?-1:1)*Math.sqrt(Math.max(0,x*x*m-M*M)),b=(M*y-v*_)/m,w=(-M*v-y*_)/m,k=(M*y+v*_)/m,N=(-M*v+y*_)/m,A=b-p,C=w-d,z=k-p,L=N-d;return A*A+C*C>z*z+L*L&&(b=k,w=N),[[b-l,w-c],[b*e/x,w*e/x]]}function Kr(){return!0}function Qr(n){function t(t){function o(){c.push("M",i(n(f),a))}for(var l,c=[],f=[],s=-1,h=t.length,g=kn(e),p=kn(r);++s1?n.join("L"):n+"Z"}function tu(n){return n.join("L")+"Z"}function eu(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1&&u.push("H",r[0]),u.join("")}function ru(n){for(var t=0,e=n.length,r=n[0],u=[r[0],",",r[1]];++t1){a=t[1],i=n[l],l++,r+="C"+(u[0]+o[0])+","+(u[1]+o[1])+","+(i[0]-a[0])+","+(i[1]-a[1])+","+i[0]+","+i[1];for(var c=2;c9&&(u=3*t/Math.sqrt(u),o[a]=u*e,o[a+1]=u*r));for(a=-1;++a<=l;)u=(n[Math.min(l,a+1)][0]-n[Math.max(0,a-1)][0])/(6*(1+o[a]*o[a])),i.push([u||0,o[a]*u||0]);return i}function xu(n){return n.length<3?nu(n):n[0]+lu(n,mu(n))}function Mu(n){for(var t,e,r,u=-1,i=n.length;++u=t?o(n-t):void(f.c=o)}function o(e){var u=p.active,i=p[u];i&&(i.timer.c=null,i.timer.t=NaN,--p.count,delete p[u],i.event&&i.event.interrupt.call(n,n.__data__,i.index));for(var o in p)if(r>+o){var c=p[o];c.timer.c=null,c.timer.t=NaN,--p.count,delete p[o]}f.c=a,Ln(function(){return f.c&&a(e||1)&&(f.c=null,f.t=NaN),1},0,l),p.active=r,d.event&&d.event.start.call(n,n.__data__,t),g=[],d.tween.forEach(function(e,r){(r=r.call(n,n.__data__,t))&&g.push(r)}),h=d.ease,s=d.duration}function a(u){for(var i=u/s,o=h(i),a=g.length;a>0;)g[--a].call(n,o);return i>=1?(d.event&&d.event.end.call(n,n.__data__,t),--p.count?delete p[r]:delete n[e],1):void 0}var l,f,s,h,g,p=n[e]||(n[e]={active:0,count:0}),d=p[r];d||(l=u.time,f=Ln(i,0,l),d=p[r]={tween:new c,time:l,timer:f,delay:u.delay,duration:u.duration,ease:u.ease,index:t},u=null,++p.count)}function Uu(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate("+(isFinite(r)?r:e(n))+",0)"})}function Pu(n,t,e){n.attr("transform",function(n){var r=t(n);return"translate(0,"+(isFinite(r)?r:e(n))+")"})}function ju(n){return n.toISOString()}function Hu(n,t,e){function r(t){return n(t)}function u(n,e){var r=n[1]-n[0],u=r/e,i=Iu.bisect(Ko,u);return i==Ko.length?[t.year,Tr(n.map(function(n){return n/31536e6}),e)[2]]:i?t[u/Ko[i-1]1?{floor:function(t){for(;e(t=n.floor(t));)t=Fu(t-1);return t},ceil:function(t){for(;e(t=n.ceil(t));)t=Fu(+t+1);return t}}:n))},r.ticks=function(n,t){var e=br(r.domain()),i=null==n?u(e,10):"number"==typeof n?u(e,n):!n.range&&[{range:n},t];return i&&(n=i[0],t=i[1]),n.range(e[0],Fu(+e[1]+1),1>t?1:t)},r.tickFormat=function(){return e},r.copy=function(){return Hu(n.copy(),t,e)},Lr(r,n)}function Fu(n){return new Date(n)}function Ou(n){return JSON.parse(n.responseText)}function Yu(n){var t=Xu.createRange();return t.selectNode(Xu.body),t.createContextualFragment(n.responseText)}var Iu={version:"3.6.1"},Zu=[].slice,Vu=function(n){return Zu.call(n)},Xu=this.document;if(Xu)try{Vu(Xu.documentElement.childNodes)[0].nodeType}catch($u){Vu=function(n){for(var t=n.length,e=new Array(t);t--;)e[t]=n[t];return e}}if(Date.now||(Date.now=function(){return+new Date}),Xu)try{Xu.createElement("DIV").style.setProperty("opacity",0,"")}catch(Bu){var Wu=this.Element.prototype,Ju=Wu.setAttribute,Gu=Wu.setAttributeNS,Ku=this.CSSStyleDeclaration.prototype,Qu=Ku.setProperty;Wu.setAttribute=function(n,t){Ju.call(this,n,t+"")},Wu.setAttributeNS=function(n,t,e){Gu.call(this,n,t,e+"")},Ku.setProperty=function(n,t,e){Qu.call(this,n,t+"",e)}}Iu.ascending=e,Iu.descending=function(n,t){return n>t?-1:t>n?1:t>=n?0:NaN},Iu.min=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ur&&(e=r)}else{for(;++u=r){e=r;break}for(;++ur&&(e=r)}return e},Iu.max=function(n,t){var e,r,u=-1,i=n.length;if(1===arguments.length){for(;++u=r){e=r;break}for(;++ue&&(e=r)}else{for(;++u=r){e=r;break}for(;++ue&&(e=r)}return e},Iu.extent=function(n,t){var e,r,u,i=-1,o=n.length;if(1===arguments.length){for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}else{for(;++i=r){e=u=r;break}for(;++ir&&(e=r),r>u&&(u=r))}return[e,u]},Iu.sum=function(n,t){var e,r=0,i=n.length,o=-1;if(1===arguments.length)for(;++o1?l/(f-1):void 0},Iu.deviation=function(){var n=Iu.variance.apply(this,arguments);return n?Math.sqrt(n):n};var ni=i(e);Iu.bisectLeft=ni.left,Iu.bisect=Iu.bisectRight=ni.right,Iu.bisector=function(n){return i(1===n.length?function(t,r){return e(n(t),r)}:n)},Iu.shuffle=function(n,t,e){(i=arguments.length)<3&&(e=n.length,2>i&&(t=0));for(var r,u,i=e-t;i;)u=Math.random()*i--|0,r=n[i+t],n[i+t]=n[u+t],n[u+t]=r;return n},Iu.permute=function(n,t){for(var e=t.length,r=new Array(e);e--;)r[e]=n[t[e]];return r},Iu.pairs=function(n){for(var t,e=0,r=n.length-1,u=n[0],i=new Array(0>r?0:r);r>e;)i[e]=[t=u,u=n[++e]];return i},Iu.transpose=function(n){if(!(u=n.length))return[];for(var t=-1,e=Iu.min(n,o),r=new Array(e);++t=0;)for(r=n[u],t=r.length;--t>=0;)e[--o]=r[t];return e};var ti=Math.abs;Iu.range=function(n,t,e){if(arguments.length<3&&(e=1,arguments.length<2&&(t=n,n=0)),(t-n)/e===1/0)throw new Error("infinite range");var r,u=[],i=a(ti(e)),o=-1;if(n*=i,t*=i,e*=i,0>e)for(;(r=n+e*++o)>t;)u.push(r/i);else for(;(r=n+e*++o)=i.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,f,s,h,g=-1,p=o.length,d=i[a++],v=new c;++g=i.length)return n;var r=[],u=o[e++];return n.forEach(function(n,u){r.push({key:n,values:t(u,e)})}),u?r.sort(function(n,t){return u(n.key,t.key)}):r}var e,r,u={},i=[],o=[];return u.map=function(t,e){return n(e,t,0)},u.entries=function(e){return t(n(Iu.map,e,0),0)},u.key=function(n){return i.push(n),u},u.sortKeys=function(n){return o[i.length-1]=n,u},u.sortValues=function(n){return e=n,u},u.rollup=function(n){return r=n,u},u},Iu.set=function(n){var t=new y;if(n)for(var e=0,r=n.length;r>e;++e)t.add(n[e]);return t},l(y,{has:h,add:function(n){return this._[f(n+="")]=!0,n},remove:g,values:p,size:d,empty:v,forEach:function(n){for(var t in this._)n.call(this,s(t))}}),Iu.behavior={},Iu.rebind=function(n,t){for(var e,r=1,u=arguments.length;++r=0&&(r=n.slice(e+1),n=n.slice(0,e)),n)return arguments.length<2?this[n].on(r):this[n].on(r,t);if(2===arguments.length){if(null==t)for(n in this)this.hasOwnProperty(n)&&this[n].on(r,null);return this}},Iu.event=null,Iu.requote=function(n){return n.replace(ii,"\\$&")};var ii=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g,oi={}.__proto__?function(n,t){n.__proto__=t}:function(n,t){for(var e in t)n[e]=t[e]},ai=function(n,t){return t.querySelector(n)},li=function(n,t){return t.querySelectorAll(n)},ci=function(n,t){var e=n.matches||n[M(n,"matchesSelector")];return(ci=function(n,t){return e.call(n,t)})(n,t)};"function"==typeof Sizzle&&(ai=function(n,t){return Sizzle(n,t)[0]||null},li=Sizzle,ci=Sizzle.matchesSelector),Iu.selection=function(){return Iu.select(Xu.documentElement)};var fi=Iu.selection.prototype=[];fi.select=function(n){var t,e,r,u,i=[];n=z(n);for(var o=-1,a=this.length;++o=0&&"xmlns"!==(e=n.slice(0,t))&&(n=n.slice(t+1)),hi.hasOwnProperty(e)?{space:hi[e],local:n}:n}},fi.attr=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node();return n=Iu.ns.qualify(n),n.local?e.getAttributeNS(n.space,n.local):e.getAttribute(n)}for(t in n)this.each(S(t,n[t]));return this}return this.each(S(n,t))},fi.classed=function(n,t){if(arguments.length<2){if("string"==typeof n){var e=this.node(),r=(n=D(n)).length,u=-1;if(t=e.classList){for(;++uu){if("string"!=typeof n){2>u&&(e="");for(r in n)this.each(U(r,n[r],e));return this}if(2>u){var i=this.node();return t(i).getComputedStyle(i,null).getPropertyValue(n)}r=""}return this.each(U(n,e,r))},fi.property=function(n,t){if(arguments.length<2){if("string"==typeof n)return this.node()[n];for(t in n)this.each(P(t,n[t]));return this}return this.each(P(n,t))},fi.text=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.textContent=null==t?"":t}:null==n?function(){this.textContent=""}:function(){this.textContent=n}):this.node().textContent},fi.html=function(n){return arguments.length?this.each("function"==typeof n?function(){var t=n.apply(this,arguments);this.innerHTML=null==t?"":t}:null==n?function(){this.innerHTML=""}:function(){this.innerHTML=n}):this.node().innerHTML},fi.append=function(n){return n=j(n),this.select(function(){return this.appendChild(n.apply(this,arguments))})},fi.insert=function(n,t){return n=j(n),t=z(t),this.select(function(){return this.insertBefore(n.apply(this,arguments),t.apply(this,arguments)||null)})},fi.remove=function(){return this.each(H)},fi.data=function(n,t){function e(n,e){var r,u,i,o=n.length,s=e.length,h=Math.min(o,s),g=new Array(s),p=new Array(s),d=new Array(o);if(t){var v,y=new c,m=new Array(o);for(r=-1;++rr;++r)p[r]=F(e[r]);for(;o>r;++r)d[r]=n[r]}p.update=g,p.parentNode=g.parentNode=d.parentNode=n.parentNode,a.push(p),l.push(g),f.push(d)}var r,u,i=-1,o=this.length;if(!arguments.length){for(n=new Array(o=(r=this[0]).length);++ii;i++){u.push(t=[]),t.parentNode=(e=this[i]).parentNode;for(var a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return C(u)},fi.order=function(){for(var n=-1,t=this.length;++n=0;)(e=r[u])&&(i&&i!==e.nextSibling&&i.parentNode.insertBefore(e,i),i=e);return this},fi.sort=function(n){n=Y.apply(this,arguments);for(var t=-1,e=this.length;++tn;n++)for(var e=this[n],r=0,u=e.length;u>r;r++){var i=e[r];if(i)return i}return null},fi.size=function(){var n=0;return I(this,function(){++n}),n};var gi=[];Iu.selection.enter=Z,Iu.selection.enter.prototype=gi,gi.append=fi.append,gi.empty=fi.empty,gi.node=fi.node,gi.call=fi.call,gi.size=fi.size,gi.select=function(n){for(var t,e,r,u,i,o=[],a=-1,l=this.length;++ar){if("string"!=typeof n){2>r&&(t=!1);for(e in n)this.each(X(e,n[e],t));return this}if(2>r)return(r=this.node()["__on"+n])&&r._;e=!1}return this.each(X(n,t,e))};var pi=Iu.map({mouseenter:"mouseover",mouseleave:"mouseout"});Xu&&pi.forEach(function(n){"on"+n in Xu&&pi.remove(n)});var di,vi=0;Iu.mouse=function(n){return J(n,N())};var yi=this.navigator&&/WebKit/.test(this.navigator.userAgent)?-1:0;Iu.touch=function(n,t,e){if(arguments.length<3&&(e=t,t=N().changedTouches),t)for(var r,u=0,i=t.length;i>u;++u)if((r=t[u]).identifier===e)return J(n,r)},Iu.behavior.drag=function(){function n(){this.on("mousedown.drag",i).on("touchstart.drag",o)}function e(n,t,e,i,o){return function(){function a(){var n,e,r=t(h,d);r&&(n=r[0]-x[0],e=r[1]-x[1],p|=n|e,x=r,g({type:"drag",x:r[0]+c[0],y:r[1]+c[1],dx:n,dy:e}))}function l(){t(h,d)&&(y.on(i+v,null).on(o+v,null),m(p),g({type:"dragend"}))}var c,f=this,s=Iu.event.target.correspondingElement||Iu.event.target,h=f.parentNode,g=r.of(f,arguments),p=0,d=n(),v=".drag"+(null==d?"":"-"+d),y=Iu.select(e(s)).on(i+v,a).on(o+v,l),m=W(s),x=t(h,d);u?(c=u.apply(f,arguments),c=[c.x-x[0],c.y-x[1]]):c=[0,0],g({type:"dragstart"})}}var r=A(n,"drag","dragstart","dragend"),u=null,i=e(_,Iu.mouse,t,"mousemove","mouseup"),o=e(G,Iu.touch,m,"touchmove","touchend");return n.origin=function(t){return arguments.length?(u=t,n):u},Iu.rebind(n,r,"on")},Iu.touches=function(n,t){return arguments.length<2&&(t=N().touches),t?Vu(t).map(function(t){var e=J(n,t);return e.identifier=t.identifier, +e}):[]};var mi=1e-6,xi=mi*mi,Mi=Math.PI,_i=2*Mi,bi=_i-mi,wi=Mi/2,ki=Mi/180,Ni=180/Mi,Ai=Math.SQRT2,Ci=2,zi=4;Iu.interpolateZoom=function(n,t){var e,r,u=n[0],i=n[1],o=n[2],a=t[0],l=t[1],c=t[2],f=a-u,s=l-i,h=f*f+s*s;if(xi>h)r=Math.log(c/o)/Ai,e=function(n){return[u+n*f,i+n*s,o*Math.exp(Ai*n*r)]};else{var g=Math.sqrt(h),p=(c*c-o*o+zi*h)/(2*o*Ci*g),d=(c*c-o*o-zi*h)/(2*c*Ci*g),v=Math.log(Math.sqrt(p*p+1)-p),y=Math.log(Math.sqrt(d*d+1)-d);r=(y-v)/Ai,e=function(n){var t=n*r,e=tn(v),a=o/(Ci*g)*(e*en(Ai*t+v)-nn(v));return[u+a*f,i+a*s,o*e/tn(Ai*t+v)]}}return e.duration=1e3*r,e},Iu.behavior.zoom=function(){function n(n){n.on(T,s).on(Si+".zoom",g).on("dblclick.zoom",p).on(R,h)}function e(n){return[(n[0]-N.x)/N.k,(n[1]-N.y)/N.k]}function r(n){return[n[0]*N.k+N.x,n[1]*N.k+N.y]}function u(n){N.k=Math.max(z[0],Math.min(z[1],n))}function i(n,t){t=r(t),N.x+=n[0]-t[0],N.y+=n[1]-t[1]}function o(t,e,r,o){t.__chart__={x:N.x,y:N.y,k:N.k},u(Math.pow(2,o)),i(v=e,r),t=Iu.select(t),L>0&&(t=t.transition().duration(L)),t.call(n.event)}function a(){_&&_.domain(M.range().map(function(n){return(n-N.x)/N.k}).map(M.invert)),w&&w.domain(b.range().map(function(n){return(n-N.y)/N.k}).map(b.invert))}function l(n){S++||n({type:"zoomstart"})}function c(n){a(),n({type:"zoom",scale:N.k,translate:[N.x,N.y]})}function f(n){--S||(n({type:"zoomend"}),v=null)}function s(){function n(){a=1,i(Iu.mouse(u),h),c(o)}function r(){s.on(q,null).on(D,null),g(a),f(o)}var u=this,o=E.of(u,arguments),a=0,s=Iu.select(t(u)).on(q,n).on(D,r),h=e(Iu.mouse(u)),g=W(u);Yo.call(u),l(o)}function h(){function n(){var n=Iu.touches(p);return g=N.k,n.forEach(function(n){n.identifier in v&&(v[n.identifier]=e(n))}),n}function t(){var t=Iu.event.target;Iu.select(t).on(M,r).on(_,a),b.push(t);for(var e=Iu.event.changedTouches,u=0,i=e.length;i>u;++u)v[e[u].identifier]=null;var l=n(),c=Date.now();if(1===l.length){if(500>c-x){var f=l[0];o(p,f,v[f.identifier],Math.floor(Math.log(N.k)/Math.LN2)+1),k()}x=c}else if(l.length>1){var f=l[0],s=l[1],h=f[0]-s[0],g=f[1]-s[1];y=h*h+g*g}}function r(){var n,t,e,r,o=Iu.touches(p);Yo.call(p);for(var a=0,l=o.length;l>a;++a,r=null)if(e=o[a],r=v[e.identifier]){if(t)break;n=e,t=r}if(r){var f=(f=e[0]-n[0])*f+(f=e[1]-n[1])*f,s=y&&Math.sqrt(f/y);n=[(n[0]+e[0])/2,(n[1]+e[1])/2],t=[(t[0]+r[0])/2,(t[1]+r[1])/2],u(s*g)}x=null,i(n,t),c(d)}function a(){if(Iu.event.touches.length){for(var t=Iu.event.changedTouches,e=0,r=t.length;r>e;++e)delete v[t[e].identifier];for(var u in v)return void n()}Iu.selectAll(b).on(m,null),w.on(T,s).on(R,h),A(),f(d)}var g,p=this,d=E.of(p,arguments),v={},y=0,m=".zoom-"+Iu.event.changedTouches[0].identifier,M="touchmove"+m,_="touchend"+m,b=[],w=Iu.select(p),A=W(p);t(),l(d),w.on(T,null).on(R,t)}function g(){var n=E.of(this,arguments);m?clearTimeout(m):(Yo.call(this),d=e(v=y||Iu.mouse(this)),l(n)),m=setTimeout(function(){m=null,f(n)},50),k(),u(Math.pow(2,.002*Li())*N.k),i(v,d),c(n)}function p(){var n=Iu.mouse(this),t=Math.log(N.k)/Math.LN2;o(this,n,e(n),Iu.event.shiftKey?Math.ceil(t)-1:Math.floor(t)+1)}var d,v,y,m,x,M,_,b,w,N={x:0,y:0,k:1},C=[960,500],z=Ti,L=250,S=0,T="mousedown.zoom",q="mousemove.zoom",D="mouseup.zoom",R="touchstart.zoom",E=A(n,"zoomstart","zoom","zoomend");return Si||(Si="onwheel"in Xu?(Li=function(){return-Iu.event.deltaY*(Iu.event.deltaMode?120:1)},"wheel"):"onmousewheel"in Xu?(Li=function(){return Iu.event.wheelDelta},"mousewheel"):(Li=function(){return-Iu.event.detail},"MozMousePixelScroll")),n.event=function(n){n.each(function(){var n=E.of(this,arguments),t=N;Fo?Iu.select(this).transition().each("start.zoom",function(){N=this.__chart__||{x:0,y:0,k:1},l(n)}).tween("zoom:zoom",function(){var e=C[0],r=C[1],u=v?v[0]:e/2,i=v?v[1]:r/2,o=Iu.interpolateZoom([(u-N.x)/N.k,(i-N.y)/N.k,e/N.k],[(u-t.x)/t.k,(i-t.y)/t.k,e/t.k]);return function(t){var r=o(t),a=e/r[2];this.__chart__=N={x:u-r[0]*a,y:i-r[1]*a,k:a},c(n)}}).each("interrupt.zoom",function(){f(n)}).each("end.zoom",function(){f(n)}):(this.__chart__=N,l(n),c(n),f(n))})},n.translate=function(t){return arguments.length?(N={x:+t[0],y:+t[1],k:N.k},a(),n):[N.x,N.y]},n.scale=function(t){return arguments.length?(N={x:N.x,y:N.y,k:null},u(+t),a(),n):N.k},n.scaleExtent=function(t){return arguments.length?(z=null==t?Ti:[+t[0],+t[1]],n):z},n.center=function(t){return arguments.length?(y=t&&[+t[0],+t[1]],n):y},n.size=function(t){return arguments.length?(C=t&&[+t[0],+t[1]],n):C},n.duration=function(t){return arguments.length?(L=+t,n):L},n.x=function(t){return arguments.length?(_=t,M=t.copy(),N={x:0,y:0,k:1},n):_},n.y=function(t){return arguments.length?(w=t,b=t.copy(),N={x:0,y:0,k:1},n):w},Iu.rebind(n,E,"on")};var Li,Si,Ti=[0,1/0];Iu.color=rn,rn.prototype.toString=function(){return this.rgb()+""},Iu.hsl=un;var qi=un.prototype=new rn;qi.brighter=function(n){return n=Math.pow(.7,arguments.length?n:1),new un(this.h,this.s,this.l/n)},qi.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new un(this.h,this.s,n*this.l)},qi.rgb=function(){return on(this.h,this.s,this.l)},Iu.hcl=an;var Di=an.prototype=new rn;Di.brighter=function(n){return new an(this.h,this.c,Math.min(100,this.l+Ri*(arguments.length?n:1)))},Di.darker=function(n){return new an(this.h,this.c,Math.max(0,this.l-Ri*(arguments.length?n:1)))},Di.rgb=function(){return ln(this.h,this.c,this.l).rgb()},Iu.lab=cn;var Ri=18,Ei=.95047,Ui=1,Pi=1.08883,ji=cn.prototype=new rn;ji.brighter=function(n){return new cn(Math.min(100,this.l+Ri*(arguments.length?n:1)),this.a,this.b)},ji.darker=function(n){return new cn(Math.max(0,this.l-Ri*(arguments.length?n:1)),this.a,this.b)},ji.rgb=function(){return fn(this.l,this.a,this.b)},Iu.rgb=dn;var Hi=dn.prototype=new rn;Hi.brighter=function(n){n=Math.pow(.7,arguments.length?n:1);var t=this.r,e=this.g,r=this.b,u=30;return t||e||r?(t&&u>t&&(t=u),e&&u>e&&(e=u),r&&u>r&&(r=u),new dn(Math.min(255,t/n),Math.min(255,e/n),Math.min(255,r/n))):new dn(u,u,u)},Hi.darker=function(n){return n=Math.pow(.7,arguments.length?n:1),new dn(n*this.r,n*this.g,n*this.b)},Hi.hsl=function(){return Mn(this.r,this.g,this.b)},Hi.toString=function(){return"#"+mn(this.r)+mn(this.g)+mn(this.b)};var Fi=Iu.map({aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074});Fi.forEach(function(n,t){Fi.set(n,vn(t))}),Iu.functor=kn,Iu.xhr=Nn(m),Iu.dsv=function(n,t){function e(n,e,i){arguments.length<3&&(i=e,e=null);var o=An(n,t,null==e?r:u(e),i);return o.row=function(n){return arguments.length?o.response(null==(e=n)?r:u(n)):e},o}function r(n){return e.parse(n.responseText)}function u(n){return function(t){return e.parse(t.responseText,n)}}function i(t){return t.map(o).join(n)}function o(n){return a.test(n)?'"'+n.replace(/\"/g,'""')+'"':n}var a=new RegExp('["'+n+"\n]"),l=n.charCodeAt(0);return e.parse=function(n,t){var r;return e.parseRows(n,function(n,e){if(r)return r(n,e-1);var u=function(t){for(var e={},r=n.length,u=0;r>u;++u)e[n[u]]=t[u];return e};r=t?function(n,e){return t(u(n),e)}:u})},e.parseRows=function(n,t){function e(){if(f>=c)return o;if(u)return u=!1,i;var t=f;if(34===n.charCodeAt(t)){for(var e=t;e++f;){var r=n.charCodeAt(f++),a=1;if(10===r)u=!0;else if(13===r)u=!0,10===n.charCodeAt(f)&&(++f,++a);else if(r!==l)continue;return n.slice(t,f-a)}return n.slice(t)}for(var r,u,i={},o={},a=[],c=n.length,f=0,s=0;(r=e())!==o;){for(var h=[];r!==i&&r!==o;)h.push(r),r=e();t&&null==(h=t(h,s++))||a.push(h)}return a},e.format=function(t){if(Array.isArray(t[0]))return e.formatRows(t);var r=new y,u=[];return t.forEach(function(n){for(var t in n)r.has(t)||u.push(r.add(t))}),[u.map(o).join(n)].concat(t.map(function(t){return u.map(function(n){return o(t[n])}).join(n)})).join("\n")},e.formatRows=function(n){return n.map(i).join("\n")},e},Iu.csv=Iu.dsv(",","text/csv"),Iu.tsv=Iu.dsv(" ","text/tab-separated-values");var Oi,Yi,Ii,Zi,Vi=this[M(this,"requestAnimationFrame")]||function(n){setTimeout(n,17)};Iu.timer=function(){Ln.apply(this,arguments)},Iu.timer.flush=function(){Tn(),qn()},Iu.round=function(n,t){return t?Math.round(n*(t=Math.pow(10,t)))/t:Math.round(n)};var Xi=["y","z","a","f","p","n","\xb5","m","","k","M","G","T","P","E","Z","Y"].map(Rn);Iu.formatPrefix=function(n,t){var e=0;return(n=+n)&&(0>n&&(n*=-1),t&&(n=Iu.round(n,Dn(n,t))),e=1+Math.floor(1e-12+Math.log(n)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((e-1)/3)))),Xi[8+e/3]};var $i=/(?:([^{])?([<>=^]))?([+\- ])?([$#])?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Bi=Iu.map({b:function(n){return n.toString(2)},c:function(n){return String.fromCharCode(n)},o:function(n){return n.toString(8)},x:function(n){return n.toString(16)},X:function(n){return n.toString(16).toUpperCase()},g:function(n,t){return n.toPrecision(t)},e:function(n,t){return n.toExponential(t)},f:function(n,t){return n.toFixed(t)},r:function(n,t){return(n=Iu.round(n,Dn(n,t))).toFixed(Math.max(0,Math.min(20,Dn(n*(1+1e-15),t))))}}),Wi=Iu.time={},Ji=Date;Pn.prototype={getDate:function(){return this._.getUTCDate()},getDay:function(){return this._.getUTCDay()},getFullYear:function(){return this._.getUTCFullYear()},getHours:function(){return this._.getUTCHours()},getMilliseconds:function(){return this._.getUTCMilliseconds()},getMinutes:function(){return this._.getUTCMinutes()},getMonth:function(){return this._.getUTCMonth()},getSeconds:function(){return this._.getUTCSeconds()},getTime:function(){return this._.getTime()},getTimezoneOffset:function(){return 0},valueOf:function(){return this._.valueOf()},setDate:function(){Gi.setUTCDate.apply(this._,arguments)},setDay:function(){Gi.setUTCDay.apply(this._,arguments)},setFullYear:function(){Gi.setUTCFullYear.apply(this._,arguments)},setHours:function(){Gi.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){Gi.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){Gi.setUTCMinutes.apply(this._,arguments)},setMonth:function(){Gi.setUTCMonth.apply(this._,arguments)},setSeconds:function(){Gi.setUTCSeconds.apply(this._,arguments)},setTime:function(){Gi.setTime.apply(this._,arguments)}};var Gi=Date.prototype;Wi.year=jn(function(n){return n=Wi.day(n),n.setMonth(0,1),n},function(n,t){n.setFullYear(n.getFullYear()+t)},function(n){return n.getFullYear()}),Wi.years=Wi.year.range,Wi.years.utc=Wi.year.utc.range,Wi.day=jn(function(n){var t=new Ji(2e3,0);return t.setFullYear(n.getFullYear(),n.getMonth(),n.getDate()),t},function(n,t){n.setDate(n.getDate()+t)},function(n){return n.getDate()-1}),Wi.days=Wi.day.range,Wi.days.utc=Wi.day.utc.range,Wi.dayOfYear=function(n){var t=Wi.year(n);return Math.floor((n-t-6e4*(n.getTimezoneOffset()-t.getTimezoneOffset()))/864e5)},["sunday","monday","tuesday","wednesday","thursday","friday","saturday"].forEach(function(n,t){t=7-t;var e=Wi[n]=jn(function(n){return(n=Wi.day(n)).setDate(n.getDate()-(n.getDay()+t)%7),n},function(n,t){n.setDate(n.getDate()+7*Math.floor(t))},function(n){var e=Wi.year(n).getDay();return Math.floor((Wi.dayOfYear(n)+(e+t)%7)/7)-(e!==t)});Wi[n+"s"]=e.range,Wi[n+"s"].utc=e.utc.range,Wi[n+"OfYear"]=function(n){var e=Wi.year(n).getDay();return Math.floor((Wi.dayOfYear(n)+(e+t)%7)/7)}}),Wi.week=Wi.sunday,Wi.weeks=Wi.sunday.range,Wi.weeks.utc=Wi.sunday.utc.range,Wi.weekOfYear=Wi.sundayOfYear;var Ki={"-":"",_:" ",0:"0"},Qi=/^\s*\d+/,no=/^%/;Iu.locale=function(n){return{numberFormat:En(n),timeFormat:Fn(n)}};var to=Iu.locale({decimal:".",thousands:",",grouping:[3],currency:["$",""],dateTime:"%a %b %e %X %Y",date:"%m/%d/%Y",time:"%H:%M:%S",periods:["AM","PM"],days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],shortDays:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],shortMonths:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});Iu.format=to.numberFormat,Iu.geom={},Iu.geom.hull=function(n){function t(n){if(n.length<3)return[];var t,u=kn(e),i=kn(r),o=n.length,a=[],l=[];for(t=0;o>t;t++)a.push([+u.call(this,n[t],t),+i.call(this,n[t],t),t]);for(a.sort(ft),t=0;o>t;t++)l.push([a[t][0],-a[t][1]]);var c=ct(a),f=ct(l),s=f[0]===c[0],h=f[f.length-1]===c[c.length-1],g=[];for(t=c.length-1;t>=0;--t)g.push(n[a[c[t]][2]]);for(t=+s;t=r&&c.x<=i&&c.y>=u&&c.y<=o?[[r,o],[i,o],[i,u],[r,u]]:[];f.point=n[a]}),t}function e(n){return n.map(function(n,t){return{x:Math.round(i(n,t)/mi)*mi,y:Math.round(o(n,t)/mi)*mi,i:t}})}var r=at,u=lt,i=r,o=u,a=fo;return n?t(n):(t.links=function(n){return Ft(e(n)).edges.filter(function(n){return n.l&&n.r}).map(function(t){return{source:n[t.l.i],target:n[t.r.i]}})},t.triangles=function(n){var t=[];return Ft(e(n)).cells.forEach(function(e,r){for(var u,i,o=e.site,a=e.edges.sort(wt),l=-1,c=a.length,f=a[c-1].edge,s=f.l===o?f.r:f.l;++l=c,h=r>=f,g=h<<1|s;n.leaf=!1,n=n.nodes[g]||(n.nodes[g]=Vt()),s?u=c:a=c,h?o=f:l=f,i(n,t,e,r,u,o,a,l)}var f,s,h,g,p,d,v,y,m,x=kn(a),M=kn(l);if(null!=t)d=t,v=e,y=r,m=u;else if(y=m=-(d=v=1/0),s=[],h=[],p=n.length,o)for(g=0;p>g;++g)f=n[g],f.xy&&(y=f.x),f.y>m&&(m=f.y),s.push(f.x),h.push(f.y);else for(g=0;p>g;++g){var _=+x(f=n[g],g),b=+M(f,g);d>_&&(d=_),v>b&&(v=b),_>y&&(y=_),b>m&&(m=b),s.push(_),h.push(b)}var w=y-d,k=m-v;w>k?m=v+w:y=d+k;var N=Vt();if(N.add=function(n){i(N,n,+x(n,++g),+M(n,g),d,v,y,m)},N.visit=function(n){Xt(n,N,d,v,y,m)},N.find=function(n){return $t(N,n[0],n[1],d,v,y,m)},g=-1,null==t){for(;++g=0?n.slice(0,t):n,r=t>=0?n.slice(t+1):"in";return e=po.get(e)||go,r=vo.get(r)||m,ne(r(e.apply(null,Zu.call(arguments,1))))},Iu.interpolateHcl=ge,Iu.interpolateHsl=pe,Iu.interpolateLab=de,Iu.interpolateRound=ve,Iu.transform=function(n){var t=Xu.createElementNS(Iu.ns.prefix.svg,"g");return(Iu.transform=function(n){if(null!=n){t.setAttribute("transform",n);var e=t.transform.baseVal.consolidate()}return new ye(e?e.matrix:yo)})(n)},ye.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var yo={a:1,b:0,c:0,d:1,e:0,f:0};Iu.interpolateTransform=Ae,Iu.layout={},Iu.layout.bundle=function(){return function(n){for(var t=[],e=-1,r=n.length;++ea*a/y){if(d>l){var c=t.charge/l;n.px-=i*c,n.py-=o*c}return!0}if(t.point&&l&&d>l){var c=t.pointCharge/l;n.px-=i*c,n.py-=o*c}}return!t.charge}}function t(n){n.px=Iu.event.x,n.py=Iu.event.y,l.resume()}var e,r,u,i,o,a,l={},c=Iu.dispatch("start","tick","end"),f=[1,1],s=.9,h=mo,g=xo,p=-30,d=Mo,v=.1,y=.64,x=[],M=[];return l.tick=function(){if((u*=.99)<.005)return e=null,c.end({type:"end",alpha:u=0}),!0;var t,r,l,h,g,d,y,m,_,b=x.length,w=M.length;for(r=0;w>r;++r)l=M[r],h=l.source,g=l.target,m=g.x-h.x,_=g.y-h.y,(d=m*m+_*_)&&(d=u*o[r]*((d=Math.sqrt(d))-i[r])/d,m*=d,_*=d,g.x-=m*(y=h.weight+g.weight?h.weight/(h.weight+g.weight):.5),g.y-=_*y,h.x+=m*(y=1-y),h.y+=_*y);if((y=u*v)&&(m=f[0]/2,_=f[1]/2,r=-1,y))for(;++r0?u=n:(e.c=null,e.t=NaN,e=null,c.end({type:"end",alpha:u=0})):n>0&&(c.start({type:"start",alpha:u=n}),e=Ln(l.tick)),l):u},l.start=function(){function n(n,r){if(!e){for(e=new Array(u),l=0;u>l;++l)e[l]=[];for(l=0;c>l;++l){var i=M[l];e[i.source.index].push(i.target),e[i.target.index].push(i.source)}}for(var o,a=e[t],l=-1,f=a.length;++lt;++t)(r=x[t]).index=t,r.weight=0;for(t=0;c>t;++t)r=M[t],"number"==typeof r.source&&(r.source=x[r.source]),"number"==typeof r.target&&(r.target=x[r.target]),++r.source.weight,++r.target.weight;for(t=0;u>t;++t)r=x[t],isNaN(r.x)&&(r.x=n("x",s)),isNaN(r.y)&&(r.y=n("y",d)),isNaN(r.px)&&(r.px=r.x),isNaN(r.py)&&(r.py=r.y);if(i=[],"function"==typeof h)for(t=0;c>t;++t)i[t]=+h.call(this,M[t],t);else for(t=0;c>t;++t)i[t]=h;if(o=[],"function"==typeof g)for(t=0;c>t;++t)o[t]=+g.call(this,M[t],t);else for(t=0;c>t;++t)o[t]=g;if(a=[],"function"==typeof p)for(t=0;u>t;++t)a[t]=+p.call(this,x[t],t);else for(t=0;u>t;++t)a[t]=p;return l.resume()},l.resume=function(){return l.alpha(.1)},l.stop=function(){return l.alpha(0)},l.drag=function(){return r||(r=Iu.behavior.drag().origin(m).on("dragstart.force",qe).on("drag.force",t).on("dragend.force",De)),arguments.length?void this.on("mouseover.force",Re).on("mouseout.force",Ee).call(r):r},Iu.rebind(l,c,"on")};var mo=20,xo=1,Mo=1/0;Iu.layout.hierarchy=function(){function n(u){var i,o=[u],a=[];for(u.depth=0;null!=(i=o.pop());)if(a.push(i),(c=e.call(n,i,i.depth))&&(l=c.length)){for(var l,c,f;--l>=0;)o.push(f=c[l]),f.parent=i,f.depth=i.depth+1;r&&(i.value=0),i.children=c}else r&&(i.value=+r.call(n,i,i.depth)||0),delete i.children;return He(u,function(n){var e,u;t&&(e=n.children)&&e.sort(t),r&&(u=n.parent)&&(u.value+=n.value)}),a}var t=Ye,e=Fe,r=Oe;return n.sort=function(e){return arguments.length?(t=e,n):t},n.children=function(t){return arguments.length?(e=t,n):e},n.value=function(t){return arguments.length?(r=t,n):r},n.revalue=function(t){return r&&(je(t,function(n){n.children&&(n.value=0)}),He(t,function(t){var e;t.children||(t.value=+r.call(n,t,t.depth)||0),(e=t.parent)&&(e.value+=t.value)})),t},n},Iu.layout.partition=function(){function n(t,e,r,u){var i=t.children;if(t.x=e,t.y=t.depth*u,t.dx=r,t.dy=u,i&&(o=i.length)){var o,a,l,c=-1;for(r=t.value?r/t.value:0;++cs?-1:1),p=Iu.sum(c),d=p?(s-l*g)/p:0,v=Iu.range(l),y=[];return null!=e&&v.sort(e===_o?function(n,t){return c[t]-c[n]}:function(n,t){return e(o[n],o[t])}),v.forEach(function(n){y[n]={data:o[n],value:a=c[n],startAngle:f,endAngle:f+=a*d+g,padAngle:h}}),y}var t=Number,e=_o,r=0,u=_i,i=0;return n.value=function(e){return arguments.length?(t=e,n):t},n.sort=function(t){return arguments.length?(e=t,n):e},n.startAngle=function(t){return arguments.length?(r=t,n):r},n.endAngle=function(t){return arguments.length?(u=t,n):u},n.padAngle=function(t){return arguments.length?(i=t,n):i},n};var _o={};Iu.layout.stack=function(){function n(a,l){if(!(h=a.length))return a;var c=a.map(function(e,r){return t.call(n,e,r)}),f=c.map(function(t){return t.map(function(t,e){return[i.call(n,t,e),o.call(n,t,e)]})}),s=e.call(n,f,l);c=Iu.permute(c,s),f=Iu.permute(f,s);var h,g,p,d,v=r.call(n,f,l),y=c[0].length;for(p=0;y>p;++p)for(u.call(n,c[0][p],d=v[p],f[0][p][1]),g=1;h>g;++g)u.call(n,c[g][p],d+=f[g-1][p][1],f[g][p][1]);return a}var t=m,e=$e,r=Be,u=Xe,i=Ze,o=Ve;return n.values=function(e){return arguments.length?(t=e,n):t},n.order=function(t){return arguments.length?(e="function"==typeof t?t:bo.get(t)||$e,n):e},n.offset=function(t){return arguments.length?(r="function"==typeof t?t:wo.get(t)||Be,n):r},n.x=function(t){return arguments.length?(i=t,n):i},n.y=function(t){return arguments.length?(o=t,n):o},n.out=function(t){return arguments.length?(u=t,n):u},n};var bo=Iu.map({"inside-out":function(n){var t,e,r=n.length,u=n.map(We),i=n.map(Je),o=Iu.range(r).sort(function(n,t){return u[n]-u[t]}),a=0,l=0,c=[],f=[];for(t=0;r>t;++t)e=o[t],l>a?(a+=i[e],c.push(e)):(l+=i[e],f.push(e));return f.reverse().concat(c)},reverse:function(n){return Iu.range(n.length).reverse()},"default":$e}),wo=Iu.map({silhouette:function(n){var t,e,r,u=n.length,i=n[0].length,o=[],a=0,l=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];r>a&&(a=r),o.push(r)}for(e=0;i>e;++e)l[e]=(a-o[e])/2;return l},wiggle:function(n){var t,e,r,u,i,o,a,l,c,f=n.length,s=n[0],h=s.length,g=[];for(g[0]=l=c=0,e=1;h>e;++e){for(t=0,u=0;f>t;++t)u+=n[t][e][1];for(t=0,i=0,a=s[e][0]-s[e-1][0];f>t;++t){for(r=0,o=(n[t][e][1]-n[t][e-1][1])/(2*a);t>r;++r)o+=(n[r][e][1]-n[r][e-1][1])/a;i+=o*n[t][e][1]}g[e]=l-=u?i/u*a:0,c>l&&(c=l)}for(e=0;h>e;++e)g[e]-=c;return g},expand:function(n){var t,e,r,u=n.length,i=n[0].length,o=1/u,a=[];for(e=0;i>e;++e){for(t=0,r=0;u>t;t++)r+=n[t][e][1];if(r)for(t=0;u>t;t++)n[t][e][1]/=r;else for(t=0;u>t;t++)n[t][e][1]=o}for(e=0;i>e;++e)a[e]=0;return a},zero:Be});Iu.layout.histogram=function(){function n(n,i){for(var o,a,l=[],c=n.map(e,this),f=r.call(this,c,i),s=u.call(this,f,c,i),i=-1,h=c.length,g=s.length-1,p=t?1:1/h;++i0)for(i=-1;++i=f[0]&&a<=f[1]&&(o=l[Iu.bisect(s,a,1,g)-1],o.y+=p,o.push(n[i]));return l}var t=!0,e=Number,r=nr,u=Ke;return n.value=function(t){return arguments.length?(e=t,n):e},n.range=function(t){return arguments.length?(r=kn(t),n):r},n.bins=function(t){return arguments.length?(u="number"==typeof t?function(n){return Qe(n,t)}:kn(t),n):u},n.frequency=function(e){return arguments.length?(t=!!e,n):t},n},Iu.layout.pack=function(){function n(n,i){var o=e.call(this,n,i),a=o[0],l=u[0],c=u[1],f=null==t?Math.sqrt:"function"==typeof t?t:function(){return t};if(a.x=a.y=0,He(a,function(n){n.r=+f(n.value)}),He(a,ir),r){var s=r*(t?1:Math.max(2*a.r/l,2*a.r/c))/2;He(a,function(n){n.r+=s}),He(a,ir),He(a,function(n){n.r-=s})}return lr(a,l/2,c/2,t?1:1/Math.max(2*a.r/l,2*a.r/c)),o}var t,e=Iu.layout.hierarchy().sort(tr),r=0,u=[1,1];return n.size=function(t){return arguments.length?(u=t,n):u},n.radius=function(e){return arguments.length?(t=null==e||"function"==typeof e?e:+e,n):t},n.padding=function(t){return arguments.length?(r=+t,n):r},Pe(n,e)},Iu.layout.tree=function(){function n(n,u){var f=o.call(this,n,u),s=f[0],h=t(s);if(He(h,e),h.parent.m=-h.z,je(h,r),c)je(s,i);else{var g=s,p=s,d=s;je(s,function(n){n.xp.x&&(p=n),n.depth>d.depth&&(d=n)});var v=a(g,p)/2-g.x,y=l[0]/(p.x+a(p,g)/2+v),m=l[1]/(d.depth||1);je(s,function(n){n.x=(n.x+v)*y,n.y=n.depth*m})}return f}function t(n){for(var t,e={A:null,children:[n]},r=[e];null!=(t=r.pop());)for(var u,i=t.children,o=0,a=i.length;a>o;++o)r.push((i[o]=u={ +_:i[o],parent:t,children:(u=i[o].children)&&u.slice()||[],A:null,a:null,z:0,m:0,c:0,s:0,t:null,i:o}).a=u);return e.children[0]}function e(n){var t=n.children,e=n.parent.children,r=n.i?e[n.i-1]:null;if(t.length){pr(n);var i=(t[0].z+t[t.length-1].z)/2;r?(n.z=r.z+a(n._,r._),n.m=n.z-i):n.z=i}else r&&(n.z=r.z+a(n._,r._));n.parent.A=u(n,r,n.parent.A||e[0])}function r(n){n._.x=n.z+n.parent.m,n.m+=n.parent.m}function u(n,t,e){if(t){for(var r,u=n,i=n,o=t,l=u.parent.children[0],c=u.m,f=i.m,s=o.m,h=l.m;o=hr(o),u=sr(u),o&&u;)l=sr(l),i=hr(i),i.a=n,r=o.z+s-u.z-c+a(o._,u._),r>0&&(gr(dr(o,n,e),n,r),c+=r,f+=r),s+=o.m,c+=u.m,h+=l.m,f+=i.m;o&&!hr(i)&&(i.t=o,i.m+=s-f),u&&!sr(l)&&(l.t=u,l.m+=c-h,e=n)}return e}function i(n){n.x*=l[0],n.y=n.depth*l[1]}var o=Iu.layout.hierarchy().sort(null).value(null),a=fr,l=[1,1],c=null;return n.separation=function(t){return arguments.length?(a=t,n):a},n.size=function(t){return arguments.length?(c=null==(l=t)?i:null,n):c?null:l},n.nodeSize=function(t){return arguments.length?(c=null==(l=t)?null:i,n):c?l:null},Pe(n,o)},Iu.layout.cluster=function(){function n(n,i){var o,a=t.call(this,n,i),l=a[0],c=0;He(l,function(n){var t=n.children;t&&t.length?(n.x=yr(t),n.y=vr(t)):(n.x=o?c+=e(n,o):0,n.y=0,o=n)});var f=mr(l),s=xr(l),h=f.x-e(f,s)/2,g=s.x+e(s,f)/2;return He(l,u?function(n){n.x=(n.x-l.x)*r[0],n.y=(l.y-n.y)*r[1]}:function(n){n.x=(n.x-h)/(g-h)*r[0],n.y=(1-(l.y?n.y/l.y:1))*r[1]}),a}var t=Iu.layout.hierarchy().sort(null).value(null),e=fr,r=[1,1],u=!1;return n.separation=function(t){return arguments.length?(e=t,n):e},n.size=function(t){return arguments.length?(u=null==(r=t),n):u?null:r},n.nodeSize=function(t){return arguments.length?(u=null!=(r=t),n):u?r:null},Pe(n,t)},Iu.layout.treemap=function(){function n(n,t){for(var e,r,u=-1,i=n.length;++ut?0:t),e.area=isNaN(r)||0>=r?0:r}function t(e){var i=e.children;if(i&&i.length){var o,a,l,c=s(e),f=[],h=i.slice(),p=1/0,d="slice"===g?c.dx:"dice"===g?c.dy:"slice-dice"===g?1&e.depth?c.dy:c.dx:Math.min(c.dx,c.dy);for(n(h,c.dx*c.dy/e.value),f.area=0;(l=h.length)>0;)f.push(o=h[l-1]),f.area+=o.area,"squarify"!==g||(a=r(f,d))<=p?(h.pop(),p=a):(f.area-=f.pop().area,u(f,d,c,!1),d=Math.min(c.dx,c.dy),f.length=f.area=0,p=1/0);f.length&&(u(f,d,c,!0),f.length=f.area=0),i.forEach(t)}}function e(t){var r=t.children;if(r&&r.length){var i,o=s(t),a=r.slice(),l=[];for(n(a,o.dx*o.dy/t.value),l.area=0;i=a.pop();)l.push(i),l.area+=i.area,null!=i.z&&(u(l,i.z?o.dx:o.dy,o,!a.length),l.length=l.area=0);r.forEach(e)}}function r(n,t){for(var e,r=n.area,u=0,i=1/0,o=-1,a=n.length;++oe&&(i=e),e>u&&(u=e));return r*=r,t*=t,r?Math.max(t*u*p/r,r/(t*i*p)):1/0}function u(n,t,e,r){var u,i=-1,o=n.length,a=e.x,c=e.y,f=t?l(n.area/t):0;if(t==e.dx){for((r||f>e.dy)&&(f=e.dy);++ie.dx)&&(f=e.dx);++ie&&(t=1),1>e&&(n=0),function(){var e,r,u;do e=2*Math.random()-1,r=2*Math.random()-1,u=e*e+r*r;while(!u||u>1);return n+t*e*Math.sqrt(-2*Math.log(u)/u)}},logNormal:function(){var n=Iu.random.normal.apply(Iu,arguments);return function(){return Math.exp(n())}},bates:function(n){var t=Iu.random.irwinHall(n);return function(){return t()/n}},irwinHall:function(n){return function(){for(var t=0,e=0;n>e;e++)t+=Math.random();return t}}},Iu.scale={};var ko={floor:m,ceil:m};Iu.scale.linear=function(){return zr([0,1],[0,1],Kt,!1)};var No={s:1,g:1,p:1,r:1,e:1};Iu.scale.log=function(){return Ur(Iu.scale.linear().domain([0,1]),10,!0,[1,10])};var Ao=Iu.format(".0e"),Co={floor:function(n){return-Math.ceil(-n)},ceil:function(n){return-Math.floor(-n)}};Iu.scale.pow=function(){return Pr(Iu.scale.linear(),1,[0,1])},Iu.scale.sqrt=function(){return Iu.scale.pow().exponent(.5)},Iu.scale.ordinal=function(){return Hr([],{t:"range",a:[[]]})},Iu.scale.category10=function(){return Iu.scale.ordinal().range(zo)},Iu.scale.category20=function(){return Iu.scale.ordinal().range(Lo)},Iu.scale.category20b=function(){return Iu.scale.ordinal().range(So)},Iu.scale.category20c=function(){return Iu.scale.ordinal().range(To)};var zo=[2062260,16744206,2924588,14034728,9725885,9197131,14907330,8355711,12369186,1556175].map(yn),Lo=[2062260,11454440,16744206,16759672,2924588,10018698,14034728,16750742,9725885,12955861,9197131,12885140,14907330,16234194,8355711,13092807,12369186,14408589,1556175,10410725].map(yn),So=[3750777,5395619,7040719,10264286,6519097,9216594,11915115,13556636,9202993,12426809,15186514,15190932,8666169,11356490,14049643,15177372,8077683,10834324,13528509,14589654].map(yn),To=[3244733,7057110,10406625,13032431,15095053,16616764,16625259,16634018,3253076,7652470,10607003,13101504,7695281,10394312,12369372,14342891,6513507,9868950,12434877,14277081].map(yn);Iu.scale.quantile=function(){return Fr([],[])},Iu.scale.quantize=function(){return Or(0,1,[0,1])},Iu.scale.threshold=function(){return Yr([.5],[0,1])},Iu.scale.identity=function(){return Ir([0,1])},Iu.svg={},Iu.svg.arc=function(){function n(){var n=Math.max(0,+e.apply(this,arguments)),c=Math.max(0,+r.apply(this,arguments)),f=o.apply(this,arguments)-wi,s=a.apply(this,arguments)-wi,h=Math.abs(s-f),g=f>s?0:1;if(n>c&&(p=c,c=n,n=p),h>=bi)return t(c,g)+(n?t(n,1-g):"")+"Z";var p,d,v,y,m,x,M,_,b,w,k,N,A=0,C=0,z=[];if((y=(+l.apply(this,arguments)||0)/2)&&(v=i===qo?Math.sqrt(n*n+c*c):+i.apply(this,arguments),g||(C*=-1),c&&(C=Q(v/c*Math.sin(y))),n&&(A=Q(v/n*Math.sin(y)))),c){m=c*Math.cos(f+C),x=c*Math.sin(f+C),M=c*Math.cos(s-C),_=c*Math.sin(s-C);var L=Math.abs(s-f-2*C)<=Mi?0:1;if(C&&Jr(m,x,M,_)===g^L){var S=(f+s)/2;m=c*Math.cos(S),x=c*Math.sin(S),M=_=null}}else m=x=0;if(n){b=n*Math.cos(s-A),w=n*Math.sin(s-A),k=n*Math.cos(f+A),N=n*Math.sin(f+A);var T=Math.abs(f-s+2*A)<=Mi?0:1;if(A&&Jr(b,w,k,N)===1-g^T){var q=(f+s)/2;b=n*Math.cos(q),w=n*Math.sin(q),k=N=null}}else b=w=0;if(h>mi&&(p=Math.min(Math.abs(c-n)/2,+u.apply(this,arguments)))>.001){d=c>n^g?0:1;var D=p,R=p;if(Mi>h){var E=null==k?[b,w]:null==M?[m,x]:ht([m,x],[k,N],[M,_],[b,w]),U=m-E[0],P=x-E[1],j=M-E[0],H=_-E[1],F=1/Math.sin(Math.acos((U*j+P*H)/(Math.sqrt(U*U+P*P)*Math.sqrt(j*j+H*H)))/2),O=Math.sqrt(E[0]*E[0]+E[1]*E[1]);R=Math.min(p,(n-O)/(F-1)),D=Math.min(p,(c-O)/(F+1))}if(null!=M){var Y=Gr(null==k?[b,w]:[k,N],[m,x],c,D,g),I=Gr([M,_],[b,w],c,D,g);p===D?z.push("M",Y[0],"A",D,",",D," 0 0,",d," ",Y[1],"A",c,",",c," 0 ",1-g^Jr(Y[1][0],Y[1][1],I[1][0],I[1][1]),",",g," ",I[1],"A",D,",",D," 0 0,",d," ",I[0]):z.push("M",Y[0],"A",D,",",D," 0 1,",d," ",I[0])}else z.push("M",m,",",x);if(null!=k){var Z=Gr([m,x],[k,N],n,-R,g),V=Gr([b,w],null==M?[m,x]:[M,_],n,-R,g);p===R?z.push("L",V[0],"A",R,",",R," 0 0,",d," ",V[1],"A",n,",",n," 0 ",g^Jr(V[1][0],V[1][1],Z[1][0],Z[1][1]),",",1-g," ",Z[1],"A",R,",",R," 0 0,",d," ",Z[0]):z.push("L",V[0],"A",R,",",R," 0 0,",d," ",Z[0])}else z.push("L",b,",",w)}else z.push("M",m,",",x),null!=M&&z.push("A",c,",",c," 0 ",L,",",g," ",M,",",_),z.push("L",b,",",w),null!=k&&z.push("A",n,",",n," 0 ",T,",",1-g," ",k,",",N);return z.push("Z"),z.join("")}function t(n,t){return"M0,"+n+"A"+n+","+n+" 0 1,"+t+" 0,"+-n+"A"+n+","+n+" 0 1,"+t+" 0,"+n}var e=Vr,r=Xr,u=Zr,i=qo,o=$r,a=Br,l=Wr;return n.innerRadius=function(t){return arguments.length?(e=kn(t),n):e},n.outerRadius=function(t){return arguments.length?(r=kn(t),n):r},n.cornerRadius=function(t){return arguments.length?(u=kn(t),n):u},n.padRadius=function(t){return arguments.length?(i=t==qo?qo:kn(t),n):i},n.startAngle=function(t){return arguments.length?(o=kn(t),n):o},n.endAngle=function(t){return arguments.length?(a=kn(t),n):a},n.padAngle=function(t){return arguments.length?(l=kn(t),n):l},n.centroid=function(){var n=(+e.apply(this,arguments)+ +r.apply(this,arguments))/2,t=(+o.apply(this,arguments)+ +a.apply(this,arguments))/2-wi;return[Math.cos(t)*n,Math.sin(t)*n]},n};var qo="auto";Iu.svg.line=function(){return Qr(m)};var Do=Iu.map({linear:nu,"linear-closed":tu,step:eu,"step-before":ru,"step-after":uu,basis:fu,"basis-open":su,"basis-closed":hu,bundle:gu,cardinal:au,"cardinal-open":iu,"cardinal-closed":ou,monotone:xu});Do.forEach(function(n,t){t.key=n,t.closed=/-closed$/.test(n)});var Ro=[0,2/3,1/3,0],Eo=[0,1/3,2/3,0],Uo=[0,1/6,2/3,1/6];Iu.svg.line.radial=function(){var n=Qr(Mu);return n.radius=n.x,delete n.x,n.angle=n.y,delete n.y,n},ru.reverse=uu,uu.reverse=ru,Iu.svg.area=function(){return _u(m)},Iu.svg.area.radial=function(){var n=_u(Mu);return n.radius=n.x,delete n.x,n.innerRadius=n.x0,delete n.x0,n.outerRadius=n.x1,delete n.x1,n.angle=n.y,delete n.y,n.startAngle=n.y0,delete n.y0,n.endAngle=n.y1,delete n.y1,n},Iu.svg.chord=function(){function n(n,a){var l=t(this,i,n,a),c=t(this,o,n,a);return"M"+l.p0+r(l.r,l.p1,l.a1-l.a0)+(e(l,c)?u(l.r,l.p1,l.r,l.p0):u(l.r,l.p1,c.r,c.p0)+r(c.r,c.p1,c.a1-c.a0)+u(c.r,c.p1,l.r,l.p0))+"Z"}function t(n,t,e,r){var u=t.call(n,e,r),i=a.call(n,u,r),o=l.call(n,u,r)-wi,f=c.call(n,u,r)-wi;return{r:i,a0:o,a1:f,p0:[i*Math.cos(o),i*Math.sin(o)],p1:[i*Math.cos(f),i*Math.sin(f)]}}function e(n,t){return n.a0==t.a0&&n.a1==t.a1}function r(n,t,e){return"A"+n+","+n+" 0 "+ +(e>Mi)+",1 "+t}function u(n,t,e,r){return"Q 0,0 "+r}var i=bu,o=wu,a=ku,l=$r,c=Br;return n.radius=function(t){return arguments.length?(a=kn(t),n):a},n.source=function(t){return arguments.length?(i=kn(t),n):i},n.target=function(t){return arguments.length?(o=kn(t),n):o},n.startAngle=function(t){return arguments.length?(l=kn(t),n):l},n.endAngle=function(t){return arguments.length?(c=kn(t),n):c},n},Iu.svg.diagonal=function(){function n(n,u){var i=t.call(this,n,u),o=e.call(this,n,u),a=(i.y+o.y)/2,l=[i,{x:i.x,y:a},{x:o.x,y:a},o];return l=l.map(r),"M"+l[0]+"C"+l[1]+" "+l[2]+" "+l[3]}var t=bu,e=wu,r=Nu;return n.source=function(e){return arguments.length?(t=kn(e),n):t},n.target=function(t){return arguments.length?(e=kn(t),n):e},n.projection=function(t){return arguments.length?(r=t,n):r},n},Iu.svg.diagonal.radial=function(){var n=Iu.svg.diagonal(),t=Nu,e=n.projection;return n.projection=function(n){return arguments.length?e(Au(t=n)):t},n},Iu.svg.symbol=function(){function n(n,r){return(Po.get(t.call(this,n,r))||Lu)(e.call(this,n,r))}var t=zu,e=Cu;return n.type=function(e){return arguments.length?(t=kn(e),n):t},n.size=function(t){return arguments.length?(e=kn(t),n):e},n};var Po=Iu.map({circle:Lu,cross:function(n){var t=Math.sqrt(n/5)/2;return"M"+-3*t+","+-t+"H"+-t+"V"+-3*t+"H"+t+"V"+-t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+-t+"V"+t+"H"+-3*t+"Z"},diamond:function(n){var t=Math.sqrt(n/(2*Ho)),e=t*Ho;return"M0,"+-t+"L"+e+",0 0,"+t+" "+-e+",0Z"},square:function(n){var t=Math.sqrt(n)/2;return"M"+-t+","+-t+"L"+t+","+-t+" "+t+","+t+" "+-t+","+t+"Z"},"triangle-down":function(n){var t=Math.sqrt(n/jo),e=t*jo/2;return"M0,"+e+"L"+t+","+-e+" "+-t+","+-e+"Z"},"triangle-up":function(n){var t=Math.sqrt(n/jo),e=t*jo/2;return"M0,"+-e+"L"+t+","+e+" "+-t+","+e+"Z"}});Iu.svg.symbolTypes=Po.keys();var jo=Math.sqrt(3),Ho=Math.tan(30*ki);fi.transition=function(n){for(var t,e,r=Fo||++Zo,u=Ru(n),i=[],o=Oo||{time:Date.now(),ease:ie,delay:0,duration:250},a=-1,l=this.length;++ai;i++){u.push(t=[]);for(var e=this[i],a=0,l=e.length;l>a;a++)(r=e[a])&&n.call(r,r.__data__,a,i)&&t.push(r)}return Tu(u,this.namespace,this.id)},Io.tween=function(n,t){var e=this.id,r=this.namespace;return arguments.length<2?this.node()[r][e].tween.get(n):I(this,null==t?function(t){t[r][e].tween.remove(n)}:function(u){u[r][e].tween.set(n,t)})},Io.attr=function(n,t){function e(){this.removeAttribute(a)}function r(){this.removeAttributeNS(a.space,a.local)}function u(n){return null==n?e:(n+="",function(){var t,e=this.getAttribute(a);return e!==n&&(t=o(e,n),function(n){this.setAttribute(a,t(n))})})}function i(n){return null==n?r:(n+="",function(){var t,e=this.getAttributeNS(a.space,a.local);return e!==n&&(t=o(e,n),function(n){this.setAttributeNS(a.space,a.local,t(n))})})}if(arguments.length<2){for(t in n)this.attr(t,n[t]);return this}var o="transform"==n?Ae:Kt,a=Iu.ns.qualify(n);return qu(this,"attr."+n,t,a.local?i:u)},Io.attrTween=function(n,t){function e(n,e){var r=t.call(this,n,e,this.getAttribute(u));return r&&function(n){this.setAttribute(u,r(n))}}function r(n,e){var r=t.call(this,n,e,this.getAttributeNS(u.space,u.local));return r&&function(n){this.setAttributeNS(u.space,u.local,r(n))}}var u=Iu.ns.qualify(n);return this.tween("attr."+n,u.local?r:e)},Io.style=function(n,e,r){function u(){this.style.removeProperty(n)}function i(e){return null==e?u:(e+="",function(){var u,i=t(this).getComputedStyle(this,null).getPropertyValue(n);return i!==e&&(u=Kt(i,e),function(t){this.style.setProperty(n,u(t),r)})})}var o=arguments.length;if(3>o){if("string"!=typeof n){2>o&&(e="");for(r in n)this.style(r,n[r],e);return this}r=""}return qu(this,"style."+n,e,i)},Io.styleTween=function(n,e,r){function u(u,i){var o=e.call(this,u,i,t(this).getComputedStyle(this,null).getPropertyValue(n));return o&&function(t){this.style.setProperty(n,o(t),r)}}return arguments.length<3&&(r=""),this.tween("style."+n,u)},Io.text=function(n){return qu(this,"text",n,Du)},Io.remove=function(){var n=this.namespace;return this.each("end.transition",function(){var t;this[n].count<2&&(t=this.parentNode)&&t.removeChild(this)})},Io.ease=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].ease:("function"!=typeof n&&(n=Iu.ease.apply(Iu,arguments)),I(this,function(r){r[e][t].ease=n}))},Io.delay=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].delay:I(this,"function"==typeof n?function(r,u,i){r[e][t].delay=+n.call(r,r.__data__,u,i)}:(n=+n,function(r){r[e][t].delay=n}))},Io.duration=function(n){var t=this.id,e=this.namespace;return arguments.length<1?this.node()[e][t].duration:I(this,"function"==typeof n?function(r,u,i){r[e][t].duration=Math.max(1,n.call(r,r.__data__,u,i))}:(n=Math.max(1,n),function(r){r[e][t].duration=n}))},Io.each=function(n,t){var e=this.id,r=this.namespace;if(arguments.length<2){var u=Oo,i=Fo;try{Fo=e,I(this,function(t,u,i){Oo=t[r][e],n.call(t,t.__data__,u,i)})}finally{Oo=u,Fo=i}}else I(this,function(u){var i=u[r][e];(i.event||(i.event=Iu.dispatch("start","end","interrupt"))).on(n,t)});return this},Io.transition=function(){for(var n,t,e,r,u=this.id,i=++Zo,o=this.namespace,a=[],l=0,c=this.length;c>l;l++){a.push(n=[]);for(var t=this[l],f=0,s=t.length;s>f;f++)(e=t[f])&&(r=e[o][u],Eu(e,f,o,i,{time:r.time,ease:r.ease,delay:r.delay+r.duration,duration:r.duration})),n.push(e)}return Tu(a,o,i)},Iu.svg.axis=function(){function n(n){n.each(function(){var n,c=Iu.select(this),f=this.__chart__||e,s=this.__chart__=e.copy(),h=null==l?s.ticks?s.ticks.apply(s,a):s.domain():l,g=null==t?s.tickFormat?s.tickFormat.apply(s,a):m:t,p=c.selectAll(".tick").data(h,s),d=p.enter().insert("g",".domain").attr("class","tick").style("opacity",mi),v=Iu.transition(p.exit()).style("opacity",mi).remove(),y=Iu.transition(p.order()).style("opacity",1),x=Math.max(u,0)+o,M=wr(s),_=c.selectAll(".domain").data([0]),b=(_.enter().append("path").attr("class","domain"),Iu.transition(_));d.append("line"),d.append("text");var w,k,N,A,C=d.select("line"),z=y.select("line"),L=p.select("text").text(g),S=d.select("text"),T=y.select("text"),q="top"===r||"left"===r?-1:1;if("bottom"===r||"top"===r?(n=Uu,w="x",N="y",k="x2",A="y2",L.attr("dy",0>q?"0em":".71em").style("text-anchor","middle"),b.attr("d","M"+M[0]+","+q*i+"V0H"+M[1]+"V"+q*i)):(n=Pu,w="y",N="x",k="y2",A="x2",L.attr("dy",".32em").style("text-anchor",0>q?"end":"start"),b.attr("d","M"+q*i+","+M[0]+"H0V"+M[1]+"H"+q*i)),C.attr(A,q*u),S.attr(N,q*x),z.attr(k,0).attr(A,q*u),T.attr(w,0).attr(N,q*x),s.rangeBand){var D=s,R=D.rangeBand()/2;f=s=function(n){return D(n)+R}}else f.rangeBand?f=s:v.call(n,s,f);d.call(n,f,s),y.call(n,s,s)})}var t,e=Iu.scale.linear(),r=Vo,u=6,i=6,o=3,a=[10],l=null;return n.scale=function(t){return arguments.length?(e=t,n):e},n.orient=function(t){return arguments.length?(r=t in Xo?t+"":Vo,n):r},n.ticks=function(){return arguments.length?(a=Vu(arguments),n):a},n.tickValues=function(t){return arguments.length?(l=t,n):l},n.tickFormat=function(e){return arguments.length?(t=e,n):t},n.tickSize=function(t){var e=arguments.length;return e?(u=+t,i=+arguments[e-1],n):u},n.innerTickSize=function(t){return arguments.length?(u=+t,n):u},n.outerTickSize=function(t){return arguments.length?(i=+t,n):i},n.tickPadding=function(t){return arguments.length?(o=+t,n):o},n.tickSubdivide=function(){return arguments.length&&n},n};var Vo="bottom",Xo={top:1,right:1,bottom:1,left:1};Iu.svg.brush=function(){function n(t){t.each(function(){var t=Iu.select(this).style("pointer-events","all").style("-webkit-tap-highlight-color","rgba(0,0,0,0)").on("mousedown.brush",i).on("touchstart.brush",i),o=t.selectAll(".background").data([0]);o.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),t.selectAll(".extent").data([0]).enter().append("rect").attr("class","extent").style("cursor","move");var a=t.selectAll(".resize").data(d,m);a.exit().remove(),a.enter().append("g").attr("class",function(n){return"resize "+n}).style("cursor",function(n){return $o[n]}).append("rect").attr("x",function(n){return/[ew]$/.test(n)?-3:null}).attr("y",function(n){return/^[ns]/.test(n)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),a.style("display",n.empty()?"none":null);var l,s=Iu.transition(t),h=Iu.transition(o);c&&(l=wr(c),h.attr("x",l[0]).attr("width",l[1]-l[0]),r(s)),f&&(l=wr(f),h.attr("y",l[0]).attr("height",l[1]-l[0]),u(s)),e(s)})}function e(n){n.selectAll(".resize").attr("transform",function(n){return"translate("+s[+/e$/.test(n)]+","+h[+/^s/.test(n)]+")"})}function r(n){n.select(".extent").attr("x",s[0]),n.selectAll(".extent,.n>rect,.s>rect").attr("width",s[1]-s[0])}function u(n){n.select(".extent").attr("y",h[0]),n.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1]-h[0])}function i(){function i(){32==Iu.event.keyCode&&(L||(x=null,T[0]-=s[1],T[1]-=h[1],L=2),k())}function d(){32==Iu.event.keyCode&&2==L&&(T[0]+=s[1],T[1]+=h[1],L=0,k())}function v(){var n=Iu.mouse(_),t=!1;M&&(n[0]+=M[0],n[1]+=M[1]),L||(Iu.event.altKey?(x||(x=[(s[0]+s[1])/2,(h[0]+h[1])/2]),T[0]=s[+(n[0]f?(u=r,r=f):u=f),d[0]!=r||d[1]!=u?(e?a=null:o=null,d[0]=r,d[1]=u,!0):void 0}function m(){v(),N.style("pointer-events","all").selectAll(".resize").style("display",n.empty()?"none":null),Iu.select("body").style("cursor",null),q.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),S(),w({type:"brushend"})}var x,M,_=this,b=Iu.select(Iu.event.target),w=l.of(_,arguments),N=Iu.select(_),A=b.datum(),C=!/^(n|s)$/.test(A)&&c,z=!/^(e|w)$/.test(A)&&f,L=b.classed("extent"),S=W(_),T=Iu.mouse(_),q=Iu.select(t(_)).on("keydown.brush",i).on("keyup.brush",d);if(Iu.event.changedTouches?q.on("touchmove.brush",v).on("touchend.brush",m):q.on("mousemove.brush",v).on("mouseup.brush",m),N.interrupt().selectAll("*").interrupt(),L)T[0]=s[0]-T[0],T[1]=h[0]-T[1];else if(A){var D=+/w$/.test(A),R=+/^n/.test(A);M=[s[1-D]-T[0],h[1-R]-T[1]],T[0]=s[D],T[1]=h[R]}else Iu.event.altKey&&(x=T.slice());N.style("pointer-events","none").selectAll(".resize").style("display",null),Iu.select("body").style("cursor",b.style("cursor")),w({type:"brushstart"}),v()}var o,a,l=A(n,"brushstart","brush","brushend"),c=null,f=null,s=[0,0],h=[0,0],g=!0,p=!0,d=Bo[0];return n.event=function(n){n.each(function(){var n=l.of(this,arguments),t={x:s,y:h,i:o,j:a},e=this.__chart__||t;this.__chart__=t,Fo?Iu.select(this).transition().each("start.brush",function(){o=e.i,a=e.j,s=e.x,h=e.y,n({type:"brushstart"})}).tween("brush:brush",function(){var e=Qt(s,t.x),r=Qt(h,t.y);return o=a=null,function(u){s=t.x=e(u),h=t.y=r(u),n({type:"brush",mode:"resize"})}}).each("end.brush",function(){o=t.i,a=t.j,n({type:"brush",mode:"resize"}),n({type:"brushend"})}):(n({type:"brushstart"}),n({type:"brush",mode:"resize"}),n({type:"brushend"}))})},n.x=function(t){return arguments.length?(c=t,d=Bo[!c<<1|!f],n):c},n.y=function(t){return arguments.length?(f=t,d=Bo[!c<<1|!f],n):f},n.clamp=function(t){return arguments.length?(c&&f?(g=!!t[0],p=!!t[1]):c?g=!!t:f&&(p=!!t),n):c&&f?[g,p]:c?g:f?p:null},n.extent=function(t){var e,r,u,i,l;return arguments.length?(c&&(e=t[0],r=t[1],f&&(e=e[0],r=r[0]),o=[e,r],c.invert&&(e=c(e),r=c(r)),e>r&&(l=e,e=r,r=l),e==s[0]&&r==s[1]||(s=[e,r])),f&&(u=t[0],i=t[1],c&&(u=u[1],i=i[1]),a=[u,i],f.invert&&(u=f(u),i=f(i)),u>i&&(l=u,u=i,i=l),u==h[0]&&i==h[1]||(h=[u,i])),n):(c&&(o?(e=o[0],r=o[1]):(e=s[0],r=s[1],c.invert&&(e=c.invert(e),r=c.invert(r)),e>r&&(l=e,e=r,r=l))),f&&(a?(u=a[0],i=a[1]):(u=h[0],i=h[1],f.invert&&(u=f.invert(u),i=f.invert(i)),u>i&&(l=u,u=i,i=l))),c&&f?[[e,u],[r,i]]:c?[e,r]:f&&[u,i])},n.clear=function(){return n.empty()||(s=[0,0],h=[0,0],o=a=null),n},n.empty=function(){return!!c&&s[0]==s[1]||!!f&&h[0]==h[1]},Iu.rebind(n,l,"on")};var $o={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Bo=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]],Wo=Wi.format=to.timeFormat,Jo=Wo.utc,Go=Jo("%Y-%m-%dT%H:%M:%S.%LZ");Wo.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?ju:Go,ju.parse=function(n){var t=new Date(n);return isNaN(t)?null:t},ju.toString=Go.toString,Wi.second=jn(function(n){return new Ji(1e3*Math.floor(n/1e3))},function(n,t){n.setTime(n.getTime()+1e3*Math.floor(t))},function(n){return n.getSeconds()}),Wi.seconds=Wi.second.range,Wi.seconds.utc=Wi.second.utc.range,Wi.minute=jn(function(n){return new Ji(6e4*Math.floor(n/6e4))},function(n,t){n.setTime(n.getTime()+6e4*Math.floor(t))},function(n){return n.getMinutes()}),Wi.minutes=Wi.minute.range,Wi.minutes.utc=Wi.minute.utc.range,Wi.hour=jn(function(n){var t=n.getTimezoneOffset()/60;return new Ji(36e5*(Math.floor(n/36e5-t)+t))},function(n,t){n.setTime(n.getTime()+36e5*Math.floor(t))},function(n){return n.getHours()}),Wi.hours=Wi.hour.range,Wi.hours.utc=Wi.hour.utc.range,Wi.month=jn(function(n){return n=Wi.day(n),n.setDate(1),n},function(n,t){n.setMonth(n.getMonth()+t)},function(n){return n.getMonth()}),Wi.months=Wi.month.range,Wi.months.utc=Wi.month.utc.range;var Ko=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Qo=[[Wi.second,1],[Wi.second,5],[Wi.second,15],[Wi.second,30],[Wi.minute,1],[Wi.minute,5],[Wi.minute,15],[Wi.minute,30],[Wi.hour,1],[Wi.hour,3],[Wi.hour,6],[Wi.hour,12],[Wi.day,1],[Wi.day,2],[Wi.week,1],[Wi.month,1],[Wi.month,3],[Wi.year,1]],na=Wo.multi([[".%L",function(n){return n.getMilliseconds()}],[":%S",function(n){return n.getSeconds()}],["%I:%M",function(n){return n.getMinutes()}],["%I %p",function(n){return n.getHours()}],["%a %d",function(n){return n.getDay()&&1!=n.getDate()}],["%b %d",function(n){return 1!=n.getDate()}],["%B",function(n){return n.getMonth()}],["%Y",Kr]]),ta={range:function(n,t,e){return Iu.range(Math.ceil(n/e)*e,+t,e).map(Fu)},floor:m,ceil:m};Qo.year=Wi.year,Wi.scale=function(){return Hu(Iu.scale.linear(),Qo,na)};var ea=Qo.map(function(n){return[n[0].utc,n[1]]}),ra=Jo.multi([[".%L",function(n){return n.getUTCMilliseconds()}],[":%S",function(n){return n.getUTCSeconds()}],["%I:%M",function(n){return n.getUTCMinutes()}],["%I %p",function(n){return n.getUTCHours()}],["%a %d",function(n){return n.getUTCDay()&&1!=n.getUTCDate()}],["%b %d",function(n){return 1!=n.getUTCDate()}],["%B",function(n){return n.getUTCMonth()}],["%Y",Kr]]);ea.year=Wi.year.utc,Wi.scale.utc=function(){return Hu(Iu.scale.linear(),ea,ra)},Iu.text=Nn(function(n){return n.responseText}),Iu.json=function(n,t){return An(n,"application/json",Ou,t)},Iu.html=function(n,t){return An(n,"text/html",Yu,t)},Iu.xml=Nn(function(n){return n.responseXML}),"function"==typeof define&&define.amd?(this.d3=Iu,define(Iu)):"object"==typeof module&&module.exports?module.exports=Iu:this.d3=Iu}.apply(self); \ No newline at end of file