From d93f45ee82b2274cfbdcdfae81ef4e423e6053b8 Mon Sep 17 00:00:00 2001 From: Jason Davies Date: Wed, 13 Mar 2013 17:26:15 +0000 Subject: [PATCH] Fix small-circle clipping of lines. This corrects the handling of lines that are long enough to have two visible or invisible endpoints, but still cross the small circle and thus have an invisible or visible intermediate segment. Fixes #1127. --- d3.js | 68 +++++++++++++++++++------ d3.min.js | 10 ++-- src/geo/circle.js | 10 ++-- src/geo/clip-circle.js | 109 +++++++++++++++++++++++++++++++++-------- src/geo/projection.js | 2 +- test/geo/path-test.js | 36 ++++++++++++++ 6 files changed, 188 insertions(+), 47 deletions(-) diff --git a/d3.js b/d3.js index 1f4975f0..9615bf92 100644 --- a/d3.js +++ b/d3.js @@ -2245,16 +2245,16 @@ d3 = function() { }; return circle.angle(90); }; - function d3_geo_circleInterpolate(radians, precision) { - var cr = Math.cos(radians), sr = Math.sin(radians); + function d3_geo_circleInterpolate(radius, precision) { + var cr = Math.cos(radius), sr = Math.sin(radius); return function(from, to, direction, listener) { if (from != null) { from = d3_geo_circleAngle(cr, from); to = d3_geo_circleAngle(cr, to); if (direction > 0 ? from < to : from > to) from += direction * 2 * π; } else { - from = radians + direction * 2 * π; - to = radians; + from = radius + direction * 2 * π; + to = radius; } var point; for (var step = direction * precision, t = from; direction > 0 ? t > to : t < to; t -= step) { @@ -2737,21 +2737,21 @@ d3 = function() { listener.point(to[0], to[1]); } } - function d3_geo_clipCircle(degrees) { - var radians = degrees * d3_radians, cr = Math.cos(radians), interpolate = d3_geo_circleInterpolate(radians, 6 * d3_radians); + function d3_geo_clipCircle(radius) { + var cr = Math.cos(radius), smallRadius = cr > 0, notHemisphere = Math.abs(cr) > ε, interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); return d3_geo_clip(visible, clipLine, interpolate); function visible(λ, φ) { return Math.cos(λ) * Math.cos(φ) > cr; } function clipLine(listener) { - var point0, v0, v00, clean; + var point0, c0, v0, v00, clean; return { lineStart: function() { v00 = v0 = false; clean = 1; }, point: function(λ, φ) { - var point1 = [ λ, φ ], point2, v = visible(λ, φ); + 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); @@ -2763,7 +2763,7 @@ d3 = function() { } if (v !== v0) { clean = 0; - if (v0 = v) { + if (v) { listener.lineStart(); point2 = intersect(point1, point0); listener.point(point2[0], point2[1]); @@ -2773,9 +2773,27 @@ d3 = function() { 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; + 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(); @@ -2786,15 +2804,33 @@ d3 = function() { } }; } - function intersect(a, b) { + 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 a; + 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), t = Math.sqrt(w * w - uu * (d3_geo_cartesianDot(A, A) - 1)), q = d3_geo_cartesianScale(u, (-w - t) / uu); + 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); - return d3_geo_spherical(q); + q = d3_geo_spherical(q); + if (!two) return q; + var λ0 = a[0], λ1 = b[0], φ0 = a[1], φ1 = b[1], z; + if (λ1 < λ0) z = λ0, λ0 = λ1, λ1 = z; + var δλ = λ1 - λ0, polar = Math.abs(δλ - π) < ε, meridian = polar || δλ < ε; + if (!polar && φ1 < φ0) z = φ0, φ0 = φ1, φ1 = z; + if (meridian ? polar ? φ0 + φ1 > 0 ^ q[1] < (Math.abs(q[0] - λ0) < ε ? φ0 : φ1) : φ0 <= q[1] && q[1] <= φ1 : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { + var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); + d3_geo_cartesianAdd(q1, A); + return [ q, d3_geo_spherical(q1) ]; + } + } + function code(λ, φ) { + var r = smallRadius ? radius : π - radius, code = 0; + if (λ < -r) code |= 1; else if (λ > r) code |= 2; + if (φ < -r) code |= 4; else if (φ > r) code |= 8; + return code; } } function d3_geo_clipView(x0, y0, x1, y1) { @@ -3046,7 +3082,7 @@ d3 = function() { }; projection.clipAngle = function(_) { if (!arguments.length) return clipAngle; - preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle(clipAngle = +_); + preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); return projection; }; projection.clipExtent = function(_) { diff --git a/d3.min.js b/d3.min.js index ce04ccca..73c0566e 100644 --- a/d3.min.js +++ b/d3.min.js @@ -1,5 +1,5 @@ -d3=function(){function t(t){return null!=t&&!isNaN(t)}function n(t){return t.length}function e(t){for(var n=1;t*n%1;)n*=10;return n}function r(t,n){try{for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}catch(r){t.prototype=n}}function i(){}function u(){}function a(t,n,e){return function(){var r=e.apply(n,arguments);return r===n?t:r}}function o(){}function c(t){function n(){for(var n,r=e,i=-1,u=r.length;u>++i;)(n=r[i].on)&&n.apply(this,arguments);return t}var e=[],r=new i;return n.on=function(n,i){var u,a=r.get(n);return 2>arguments.length?a&&a.on:(a&&(a.on=null,e=e.slice(0,u=e.indexOf(a)).concat(e.slice(u+1)),r.remove(n)),i&&e.push(r.set(n,{on:i})),t)},n}function l(){$u.event.stopPropagation(),$u.event.preventDefault()}function f(){for(var t,n=$u.event;t=n.sourceEvent;)n=t;return n}function s(t){for(var n=new o,e=0,r=arguments.length;r>++e;)n[arguments[e]]=c(n);return n.of=function(e,r){return function(i){try{var u=i.sourceEvent=$u.event;i.target=t,$u.event=i,n[i.type].apply(e,r)}finally{$u.event=u}}},n}function h(t,n){var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>ra&&(Gu.scrollX||Gu.scrollY)){e=$u.select(Ju.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=e[0][0].getScreenCTM();ra=!(i.f||i.e),e.remove()}return ra?(r.x=n.pageX,r.y=n.pageY):(r.x=n.clientX,r.y=n.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var u=t.getBoundingClientRect();return[n.clientX-u.left-t.clientLeft,n.clientY-u.top-t.clientTop]}function g(t){for(var n=-1,e=t.length,r=[];e>++n;)r.push(t[n]);return r}function p(t){return Array.prototype.slice.call(t)}function d(t){return aa(t,ga),t}function m(t){return function(){return ca(t,this)}}function v(t){return function(){return la(t,this)}}function y(t,n){function e(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,n)}function u(){this.setAttributeNS(t.space,t.local,n)}function a(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}function o(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}return t=$u.ns.qualify(t),null==n?t.local?r:e:"function"==typeof n?t.local?o:a:t.local?u:i}function M(t){return t.trim().replace(/\s+/g," ")}function x(t){return RegExp("(?:^|\\s+)"+$u.requote(t)+"(?:\\s+|$)","g")}function _(t,n){function e(){for(var e=-1;i>++e;)t[e](this,n)}function r(){for(var e=-1,r=n.apply(this,arguments);i>++e;)t[e](this,r)}t=t.trim().split(/\s+/).map(w);var i=t.length;return"function"==typeof n?r:e}function w(t){var n=x(t);return function(e,r){if(i=e.classList)return r?i.add(t):i.remove(t);var i=e.className,u=null!=i.baseVal,a=u?i.baseVal:i;r?(n.lastIndex=0,n.test(a)||(a=M(a+" "+t),u?i.baseVal=a:e.className=a)):a&&(a=M(a.replace(n," ")),u?i.baseVal=a:e.className=a)}}function S(t,n,e){function r(){this.style.removeProperty(t)}function i(){this.style.setProperty(t,n,e)}function u(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}return null==n?r:"function"==typeof n?u:i}function E(t,n){function e(){delete this[t]}function r(){this[t]=n}function i(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}return null==n?e:"function"==typeof n?i:r}function k(t){return{__data__:t}}function A(t){return function(){return ha(this,t)}}function N(t){return arguments.length||(t=$u.ascending),function(n,e){return!n-!e||t(n.__data__,e.__data__)}}function q(t,n,e){function r(){var n=this[a];n&&(this.removeEventListener(t,n,n.$),delete this[a])}function i(){var i=c(n,ia(arguments));r.call(this),this.addEventListener(t,this[a]=i,i.$=e),i._=n}function u(){var n,e=RegExp("^__on([^.]+)"+$u.requote(t)+"$");for(var r in this)if(n=r.match(e)){var i=this[r];this.removeEventListener(n[1],i,i.$),delete this[r]}}var a="__on"+t,o=t.indexOf("."),c=T;o>0&&(t=t.substring(0,o));var l=da.get(t);return l&&(t=l,c=C),o?n?i:r:n?vn:u}function T(t,n){return function(e){var r=$u.event;$u.event=e,n[0]=this.__data__;try{t.apply(this,n)}finally{$u.event=r}}}function C(t,n){var e=T(t,n);return function(t){var n=this,r=t.relatedTarget;r&&(r===n||8&r.compareDocumentPosition(n))||e.call(n,t)}}function z(t,n){for(var e=0,r=t.length;r>e;e++)for(var i,u=t[e],a=0,o=u.length;o>a;a++)(i=u[a])&&n(i,a,e);return t}function D(t){return aa(t,va),t}function j(){}function L(t,n,e){return new F(t,n,e)}function F(t,n,e){this.h=t,this.s=n,this.l=e}function H(t,n,e){function r(t){return t>360?t-=360:0>t&&(t+=360),60>t?u+(a-u)*t/60:180>t?a:240>t?u+(a-u)*(240-t)/60:u}function i(t){return Math.round(255*r(t))}var u,a;return t%=360,0>t&&(t+=360),n=0>n?0:n>1?1:n,e=0>e?0:e>1?1:e,a=.5>=e?e*(1+n):e+n-e*n,u=2*e-a,tn(i(t+120),i(t),i(t-120))}function R(t){return t>0?1:0>t?-1:0}function P(t){return Math.acos(Math.max(-1,Math.min(1,t)))}function O(t){return t>1?_a/2:-1>t?-_a/2:Math.asin(t)}function Y(t){return(Math.exp(t)-Math.exp(-t))/2}function U(t){return(Math.exp(t)+Math.exp(-t))/2}function I(t){return(t=Math.sin(t/2))*t}function V(t,n,e){return new X(t,n,e)}function X(t,n,e){this.h=t,this.c=n,this.l=e}function Z(t,n,e){return B(e,Math.cos(t*=Sa)*n,Math.sin(t)*n)}function B(t,n,e){return new $(t,n,e)}function $(t,n,e){this.l=t,this.a=n,this.b=e}function J(t,n,e){var r=(t+16)/116,i=r+n/500,u=r-e/200;return i=K(i)*Na,r=K(r)*qa,u=K(u)*Ta,tn(Q(3.2404542*i-1.5371385*r-.4985314*u),Q(-.969266*i+1.8760108*r+.041556*u),Q(.0556434*i-.2040259*r+1.0572252*u))}function G(t,n,e){return V(Math.atan2(e,n)*Ea,Math.sqrt(n*n+e*e),t)}function K(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function W(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function Q(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function tn(t,n,e){return new nn(t,n,e)}function nn(t,n,e){this.r=t,this.g=n,this.b=e}function en(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function rn(t,n,e){var r,i,u,a=0,o=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(t))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 n(cn(i[0]),cn(i[1]),cn(i[2]))}return(u=Da.get(t))?n(u.r,u.g,u.b):(null!=t&&"#"===t.charAt(0)&&(4===t.length?(a=t.charAt(1),a+=a,o=t.charAt(2),o+=o,c=t.charAt(3),c+=c):7===t.length&&(a=t.substring(1,3),o=t.substring(3,5),c=t.substring(5,7)),a=parseInt(a,16),o=parseInt(o,16),c=parseInt(c,16)),n(a,o,c))}function un(t,n,e){var r,i,u=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),o=a-u,c=(a+u)/2;return o?(i=.5>c?o/(a+u):o/(2-a-u),r=t==a?(n-e)/o+(e>n?6:0):n==a?(e-t)/o+2:(t-n)/o+4,r*=60):i=r=0,L(r,i,c)}function an(t,n,e){t=on(t),n=on(n),e=on(e);var r=W((.4124564*t+.3575761*n+.1804375*e)/Na),i=W((.2126729*t+.7151522*n+.072175*e)/qa),u=W((.0193339*t+.119192*n+.9503041*e)/Ta);return B(116*i-16,500*(r-i),200*(i-u))}function on(t){return.04045>=(t/=255)?t/12.92:Math.pow((t+.055)/1.055,2.4)}function cn(t){var n=parseFloat(t);return"%"===t.charAt(t.length-1)?Math.round(2.55*n):n}function ln(t){return"function"==typeof t?t:function(){return t}}function fn(t,n){function e(t,e,u){3>arguments.length&&(u=e,e=null);var a=$u.xhr(t,n,u);return a.row=function(t){return arguments.length?a.response(null==(e=t)?r:i(t)):e},a.row(e)}function r(t){return e.parse(t.responseText)}function i(t){return function(n){return e.parse(n.responseText,t)}}function a(n){return n.map(o).join(t)}function o(t){return c.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var c=RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return e.parse=function(t,n){var r;return e.parseRows(t,function(t,e){if(r)return r(t,e-1);var i=Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+"]"}).join(",")+"}");r=n?function(t,e){return n(i(t),e)}:i})},e.parseRows=function(t,n){function e(){if(f>=c)return a;if(i)return i=!1,u;var n=f;if(34===t.charCodeAt(n)){for(var e=n;c>e++;)if(34===t.charCodeAt(e)){if(34!==t.charCodeAt(e+1))break;++e}f=e+2;var r=t.charCodeAt(e+1);return 13===r?(i=!0,10===t.charCodeAt(e+2)&&++f):10===r&&(i=!0),t.substring(n+1,e).replace(/""/g,'"')}for(;c>f;){var r=t.charCodeAt(f++),o=1;if(10===r)i=!0;else if(13===r)i=!0,10===t.charCodeAt(f)&&(++f,++o);else if(r!==l)continue;return t.substring(n,f-o)}return t.substring(n)}for(var r,i,u={},a={},o=[],c=t.length,f=0,s=0;(r=e())!==a;){for(var h=[];r!==u&&r!==a;)h.push(r),r=e();(!n||(h=n(h,s++)))&&o.push(h)}return o},e.format=function(n){if(Array.isArray(n[0]))return e.formatRows(n);var r=new u,i=[];return n.forEach(function(t){for(var n in t)r.has(n)||i.push(r.add(n))}),[i.map(o).join(t)].concat(n.map(function(n){return i.map(function(t){return o(n[t])}).join(t)})).join("\n")},e.formatRows=function(t){return t.map(a).join("\n")},e}function sn(){for(var t,n=Date.now(),e=Ra;e;)t=n-e.then,t>=e.delay&&(e.flush=e.callback(t)),e=e.next;var r=hn()-n;r>24?(isFinite(r)&&(clearTimeout(La),La=setTimeout(sn,r)),ja=0):(ja=1,Pa(sn))}function hn(){for(var t=null,n=Ra,e=1/0;n;)n.flush?(delete Ha[n.callback.id],n=t?t.next=n.next:Ra=n.next):(e=Math.min(e,n.then+n.delay),n=(t=n).next);return e}function gn(t){return t}function pn(t,n){var e=Math.pow(10,3*Math.abs(8-n));return{scale:n>8?function(t){return t/e}:function(t){return t*e},symbol:t}}function dn(t,n){return n-(t?Math.ceil(Math.log(t)/Math.LN10):1)}function mn(t){return t+""}function vn(){}function yn(t,n){Ja.hasOwnProperty(t.type)&&Ja[t.type](t,n)}function Mn(t,n,e){var r,i=-1,u=t.length-e;for(n.lineStart();u>++i;)r=t[i],n.point(r[0],r[1]);n.lineEnd()}function bn(t,n){var e=-1,r=t.length;for(n.polygonStart();r>++e;)Mn(t[e],n,1);n.polygonEnd()}function xn(){function t(t,n){t*=Sa,n=n*Sa/2+_a/4;var e=t-r,a=Math.cos(n),o=Math.sin(n),c=u*o,l=Ka,f=Wa,s=i*a+c*Math.cos(e),h=c*Math.sin(e);Ka=l*s-f*h,Wa=f*s+l*h,r=t,i=a,u=o}var n,e,r,i,u;Qa.point=function(a,o){Qa.point=t,r=(n=a)*Sa,i=Math.cos(o=(e=o)*Sa/2+_a/4),u=Math.sin(o)},Qa.lineEnd=function(){t(n,e)}}function _n(t){function n(t,n){r>t&&(r=t),t>u&&(u=t),i>n&&(i=n),n>a&&(a=n)}function e(){o.point=o.lineEnd=vn}var r,i,u,a,o={point:n,lineStart:vn,lineEnd:vn,polygonStart:function(){o.lineEnd=e},polygonEnd:function(){o.point=n}};return function(n){return a=u=-(r=i=1/0),$u.geo.stream(n,t(o)),[[r,i],[u,a]]}}function wn(t,n){if(!to){++no,t*=Sa;var e=Math.cos(n*=Sa);eo+=(e*Math.cos(t)-eo)/no,ro+=(e*Math.sin(t)-ro)/no,io+=(Math.sin(n)-io)/no}}function Sn(){var t,n;to=1,En(),to=2;var e=uo.point;uo.point=function(r,i){e(t=r,n=i)},uo.lineEnd=function(){uo.point(t,n),kn(),uo.lineEnd=kn}}function En(){function t(t,i){t*=Sa;var u=Math.cos(i*=Sa),a=u*Math.cos(t),o=u*Math.sin(t),c=Math.sin(i),l=Math.atan2(Math.sqrt((l=e*c-r*o)*l+(l=r*a-n*c)*l+(l=n*o-e*a)*l),n*a+e*o+r*c);no+=l,eo+=l*(n+(n=a)),ro+=l*(e+(e=o)),io+=l*(r+(r=c))}var n,e,r;to>1||(1>to&&(to=1,no=eo=ro=io=0),uo.point=function(i,u){i*=Sa;var a=Math.cos(u*=Sa);n=a*Math.cos(i),e=a*Math.sin(i),r=Math.sin(u),uo.point=t})}function kn(){uo.point=wn}function An(t){var n=t[0],e=t[1],r=Math.cos(e);return[r*Math.cos(n),r*Math.sin(n),Math.sin(e)]}function Nn(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function qn(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Tn(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Cn(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function zn(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function Dn(t,n,e){return t?n||e?oe(Ln(t),Fn(n,e)):Ln(t):n||e?Fn(n,e):Ae}function jn(t){return function(n,e){return n+=t,[n>_a?n-2*_a:-_a>n?n+2*_a:n,e]}}function Ln(t){var n=jn(t);return n.invert=jn(-t),n}function Fn(t,n){function e(t,n){var e=Math.cos(n),o=Math.cos(t)*e,c=Math.sin(t)*e,l=Math.sin(n),f=l*r+o*i;return[Math.atan2(c*u-f*a,o*r-l*i),Math.asin(Math.max(-1,Math.min(1,f*u+c*a)))]}var r=Math.cos(t),i=Math.sin(t),u=Math.cos(n),a=Math.sin(n);return e.invert=function(t,n){var e=Math.cos(n),o=Math.cos(t)*e,c=Math.sin(t)*e,l=Math.sin(n),f=l*u-c*a;return[Math.atan2(c*u+l*a,o*r+f*i),Math.asin(Math.max(-1,Math.min(1,f*r-o*i)))]},e}function Hn(t){return[Math.atan2(t[1],t[0]),Math.asin(Math.max(-1,Math.min(1,t[2])))]}function Rn(t,n){return wa>Math.abs(t[0]-n[0])&&wa>Math.abs(t[1]-n[1])}function Pn(t,n){var e=Math.cos(t),r=Math.sin(t);return function(i,u,a,o){null!=i?(i=On(e,i),u=On(e,u),(a>0?u>i:i>u)&&(i+=2*a*_a)):(i=t+2*a*_a,u=t);for(var c,l=a*n,f=i;a>0?f>u:u>f;f-=l)o.point((c=Hn([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function On(t,n){var e=An(n);e[0]-=t,zn(e);var r=P(-e[1]);return((0>-e[2]?-r:r)+2*Math.PI-wa)%(2*Math.PI)}function Yn(t,n,e){var r=$u.range(t,n-wa,e).concat(n);return function(t){return r.map(function(n){return[t,n]})}}function Un(t,n,e){var r=$u.range(t,n-wa,e).concat(n);return function(t){return r.map(function(n){return[n,t]})}}function In(t){return t.source}function Vn(t){return t.target}function Xn(t,n,e,r){var i=Math.cos(n),u=Math.sin(n),a=Math.cos(r),o=Math.sin(r),c=i*Math.cos(t),l=i*Math.sin(t),f=a*Math.cos(e),s=a*Math.sin(e),h=2*Math.asin(Math.sqrt(I(r-n)+i*a*I(e-t))),g=1/Math.sin(h),p=h?function(t){var n=Math.sin(t*=h)*g,e=Math.sin(h-t)*g,r=e*c+n*f,i=e*l+n*s,a=e*u+n*o;return[Math.atan2(i,r)*Ea,Math.atan2(a,Math.sqrt(r*r+i*i))*Ea]}:function(){return[t*Ea,n*Ea]};return p.distance=h,p}function Zn(){function t(t,i){var u=Math.sin(i*=Sa),a=Math.cos(i),o=Math.abs((t*=Sa)-n),c=Math.cos(o);ao+=Math.atan2(Math.sqrt((o=a*Math.sin(o))*o+(o=r*u-e*a*c)*o),e*u+r*a*c),n=t,e=u,r=a}var n,e,r;oo.point=function(i,u){n=i*Sa,e=Math.sin(u*=Sa),r=Math.cos(u),oo.point=t},oo.lineEnd=function(){oo.point=oo.lineEnd=vn}}function Bn(){return!0}function $n(t,n,e,r,i){var u=[],a=[];if(t.forEach(function(t){if(!(1>=(n=t.length))){var n,e=t[0],r=t[n-1];if(Rn(e,r)){i.lineStart();for(var o=0;n>o;++o)i.point((e=t[o])[0],e[1]);return i.lineEnd(),void 0}var c={point:e,points:t,other:null,visited:!1,entry:!0,subject:!0},l={point:e,points:[e],other:c,visited:!1,entry:!1,subject:!1};c.other=l,u.push(c),a.push(l),c={point:r,points:[r],other:null,visited:!1,entry:!1,subject:!0},l={point:r,points:[r],other:c,visited:!1,entry:!0,subject:!1},c.other=l,u.push(c),a.push(l)}}),a.sort(n),Jn(u),Jn(a),u.length){if(e)for(var o=1,c=!e(a[0].point),l=a.length;l>o;++o)a[o].entry=c=!c;for(var f,s,h,g=u[0];;){for(f=g;f.visited;)if((f=f.next)===g)return;s=f.points,i.lineStart();do{if(f.visited=f.other.visited=!0,f.entry){if(f.subject)for(var o=0;s.length>o;o++)i.point((h=s[o])[0],h[1]);else r(f.point,f.next.point,1,i);f=f.next}else{if(f.subject){s=f.prev.points;for(var o=s.length;--o>=0;)i.point((h=s[o])[0],h[1])}else r(f.point,f.prev.point,-1,i);f=f.prev}f=f.other,s=f.points}while(!f.visited);i.lineEnd()}}}function Jn(t){if(n=t.length){for(var n,e,r=0,i=t[0];n>++r;)i.next=e=t[r],e.prev=i,i=e;i.next=e=t[0],e.prev=i}}function Gn(t,n,e){return function(r){function i(n,e){t(n,e)&&r.point(n,e)}function u(t,n){m.point(t,n)}function a(){v.point=u,m.lineStart()}function o(){v.point=i,m.lineEnd()}function c(t,n){M.point(t,n),d.push([t,n])}function l(){M.lineStart(),d=[]}function f(){c(d[0][0],d[0][1]),M.lineEnd();var t,n=M.clean(),e=y.buffer(),i=e.length;if(!i)return p=!0,g+=Qn(d,-1),d=null,void 0;if(d=null,1&n){t=e[0],h+=Qn(t,1);var u,i=t.length-1,a=-1;for(r.lineStart();i>++a;)r.point((u=t[a])[0],u[1]);return r.lineEnd(),void 0}i>1&&2&n&&e.push(e.pop().concat(e.shift())),s.push(e.filter(Kn))}var s,h,g,p,d,m=n(r),v={point:i,lineStart:a,lineEnd:o,polygonStart:function(){v.point=c,v.lineStart=l,v.lineEnd=f,p=!1,g=h=0,s=[],r.polygonStart()},polygonEnd:function(){v.point=i,v.lineStart=a,v.lineEnd=o,s=$u.merge(s),s.length?$n(s,te,null,e,r):(-wa>h||p&&-wa>g)&&(r.lineStart(),e(null,null,1,r),r.lineEnd()),r.polygonEnd(),s=null},sphere:function(){r.polygonStart(),r.lineStart(),e(null,null,1,r),r.lineEnd(),r.polygonEnd()}},y=Wn(),M=n(y);return v}}function Kn(t){return t.length>1}function Wn(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:vn,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function Qn(t,n){if(!(e=t.length))return 0;for(var e,r,i,u=0,a=0,o=t[0],c=o[0],l=o[1],f=Math.cos(l),s=Math.atan2(n*Math.sin(c)*f,Math.sin(l)),h=1-n*Math.cos(c)*f,g=s;e>++u;)o=t[u],f=Math.cos(l=o[1]),r=Math.atan2(n*Math.sin(c=o[0])*f,Math.sin(l)),i=1-n*Math.cos(c)*f,wa>Math.abs(h-2)&&wa>Math.abs(i-2)||(wa>Math.abs(i)||wa>Math.abs(h)||(wa>Math.abs(Math.abs(r-s)-_a)?i+h>2&&(a+=4*(r-s)):a+=wa>Math.abs(h-2)?4*(r-g):((3*_a+r-s)%(2*_a)-_a)*(h+i)),g=s,s=r,h=i);return a}function te(t,n){return(0>(t=t.point)[0]?t[1]-_a/2-wa:_a/2-t[1])-(0>(n=n.point)[0]?n[1]-_a/2-wa:_a/2-n[1])}function ne(t){var n,e=0/0,r=0/0,i=0/0;return{lineStart:function(){t.lineStart(),n=1},point:function(u,a){var o=u>0?_a:-_a,c=Math.abs(u-e);wa>Math.abs(c-_a)?(t.point(e,r=(r+a)/2>0?_a/2:-_a/2),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(o,r),t.point(u,r),n=0):i!==o&&c>=_a&&(wa>Math.abs(e-i)&&(e-=i*wa),wa>Math.abs(u-o)&&(u-=o*wa),r=ee(e,r,u,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(o,r),n=0),t.point(e=u,r=a),i=o},lineEnd:function(){t.lineEnd(),e=r=0/0},clean:function(){return 2-n}}}function ee(t,n,e,r){var i,u,a=Math.sin(t-e);return Math.abs(a)>wa?Math.atan((Math.sin(n)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(n))*Math.sin(t))/(i*u*a)):(n+r)/2}function re(t,n,e,r){var i;if(null==t)i=e*_a/2,r.point(-_a,i),r.point(0,i),r.point(_a,i),r.point(_a,0),r.point(_a,-i),r.point(0,-i),r.point(-_a,-i),r.point(-_a,0),r.point(-_a,i);else if(Math.abs(t[0]-n[0])>wa){var u=(t[0]u}function e(t){var e,i,u,a;return{lineStart:function(){u=i=!1,a=1},point:function(o,c){var l,f=[o,c],s=n(o,c);!e&&(u=i=s)&&t.lineStart(),s!==i&&(l=r(e,f),(Rn(e,l)||Rn(f,l))&&(f[0]+=wa,f[1]+=wa,s=n(f[0],f[1]))),s!==i&&(a=0,(i=s)?(t.lineStart(),l=r(f,e),t.point(l[0],l[1])):(l=r(e,f),t.point(l[0],l[1]),t.lineEnd()),e=l),!s||e&&Rn(e,f)||t.point(f[0],f[1]),e=f},lineEnd:function(){i&&t.lineEnd(),e=null},clean:function(){return a|(u&&i)<<1}}}function r(t,n){var e=An(t),r=An(n),i=[1,0,0],a=qn(e,r),o=Nn(a,a),c=a[0],l=o-c*c;if(!l)return t;var f=u*o/l,s=-u*c/l,h=qn(i,a),g=Cn(i,f),p=Cn(a,s);Tn(g,p);var d=h,m=Nn(g,d),v=Nn(d,d),y=Math.sqrt(m*m-v*(Nn(g,g)-1)),M=Cn(d,(-m-y)/v);return Tn(M,g),Hn(M)}var i=t*Sa,u=Math.cos(i),a=Pn(i,6*Sa);return Gn(n,e,a)}function ue(t,n,e,r){function i(r,i){return wa>Math.abs(r[0]-t)?i>0?0:3:wa>Math.abs(r[0]-e)?i>0?2:1:wa>Math.abs(r[1]-n)?i>0?1:0:i>0?3:2}function u(t,n){return a(t.point,n.point)}function a(t,n){var e=i(t,1),r=i(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}function o(i,u){var a=u[0]-i[0],o=u[1]-i[1],c=[0,1];return wa>Math.abs(a)&&wa>Math.abs(o)?i[0]>=t&&e>=i[0]&&i[1]>=n&&r>=i[1]:ae(t-i[0],a,c)&&ae(i[0]-e,-a,c)&&ae(n-i[1],o,c)&&ae(i[1]-r,-o,c)?(1>c[1]&&(u[0]=i[0]+c[1]*a,u[1]=i[1]+c[1]*o),c[0]>0&&(i[0]+=c[0]*a,i[1]+=c[0]*o),!0):!1}return function(c){function l(u){var a=i(u,-1),o=f([0===a||3===a?t:e,a>1?r:n]);return o}function f(t){for(var n=0,e=M.length,r=t[1],i=0;e>i;++i)for(var u=1,a=M[i],o=a.length,c=a[0];o>u;++u)b=a[u],r>=c[1]?b[1]>r&&s(c,b,t)>0&&++n:r>=b[1]&&0>s(c,b,t)&&--n,c=b;return 0!==n}function s(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(e[0]-t[0])*(n[1]-t[1])}function h(u,o,c,l){var f=0,s=0;if(null==u||(f=i(u,c))!==(s=i(o,c))||0>a(u,o)^c>0){do l.point(0===f||3===f?t:e,f>1?r:n);while((f=(f+c+4)%4)!==s)}else l.point(o[0],o[1])}function g(i,u){return i>=t&&e>=i&&u>=n&&r>=u}function p(t,n){g(t,n)&&c.point(t,n)}function d(){C.point=v,M&&M.push(x=[]),N=!0,A=!1,E=k=0/0}function m(){y&&(v(_,w),S&&A&&T.rejoin(),y.push(T.buffer())),C.point=p,A&&c.lineEnd()}function v(t,n){var e=g(t,n);if(M&&x.push([t,n]),N)_=t,w=n,S=e,N=!1,e&&(c.lineStart(),c.point(t,n));else if(e&&A)c.point(t,n);else{var r=[E,k],i=[t,n];o(r,i)&&(A||(c.lineStart(),c.point(r[0],r[1])),c.point(i[0],i[1]),e||c.lineEnd())}E=t,k=n,A=e}var y,M,x,_,w,S,E,k,A,N,q=c,T=Wn(),C={point:p,lineStart:d,lineEnd:m,polygonStart:function(){c=T,y=[],M=[]},polygonEnd:function(){c=q,(y=$u.merge(y)).length?(c.polygonStart(),$n(y,u,l,h,c),c.polygonEnd()):f([t,n])&&(c.polygonStart(),c.lineStart(),h(null,null,1,c),c.lineEnd(),c.polygonEnd()),y=M=x=null}};return C}}function ae(t,n,e){if(wa>Math.abs(n))return 0>t;var r=t/n;if(n>0){if(r>e[1])return!1;r>e[0]&&(e[0]=r)}else{if(e[0]>r)return!1;e[1]>r&&(e[1]=r)}return!0}function oe(t,n){function e(e,r){return e=t(e,r),n(e[0],e[1])}return t.invert&&n.invert&&(e.invert=function(e,r){return e=n.invert(e,r),e&&t.invert(e[0],e[1])}),e}function ce(t){function n(n){function r(e,r){e=t(e,r),n.point(e[0],e[1])}function u(){f=0/0,d.point=a,n.lineStart()}function a(r,u){var a=An([r,u]),o=t(r,u);e(f,s,l,h,g,p,f=o[0],s=o[1],l=r,h=a[0],g=a[1],p=a[2],i,n),n.point(f,s)}function o(){d.point=r,n.lineEnd()}function c(){var t,r,c,m,v,y,M;u(),d.point=function(n,e){a(t=n,r=e),c=f,m=s,v=h,y=g,M=p,d.point=a},d.lineEnd=function(){e(f,s,l,h,g,p,c,m,t,v,y,M,i,n),d.lineEnd=o,o()}}var l,f,s,h,g,p,d={point:r,lineStart:u,lineEnd:o,polygonStart:function(){n.polygonStart(),d.lineStart=c},polygonEnd:function(){n.polygonEnd(),d.lineStart=u}};return d}function e(n,i,u,a,o,c,l,f,s,h,g,p,d,m){var v=l-n,y=f-i,M=v*v+y*y;if(M>4*r&&d--){var b=a+h,x=o+g,_=c+p,w=Math.sqrt(b*b+x*x+_*_),S=Math.asin(_/=w),E=wa>Math.abs(Math.abs(_)-1)?(u+s)/2:Math.atan2(x,b),k=t(E,S),A=k[0],N=k[1],q=A-n,T=N-i,C=y*q-v*T;(C*C/M>r||Math.abs((v*q+y*T)/M-.5)>.3)&&(e(n,i,u,a,o,c,A,N,E,b/=w,x/=w,_,d,m),m.point(A,N),e(A,N,E,b,x,_,l,f,s,h,g,p,d,m))}}var r=.5,i=16;return n.precision=function(t){return arguments.length?(i=(r=t*t)>0&&16,n):Math.sqrt(r)},n}function le(t){return fe(function(){return t})()}function fe(t){function n(t){return t=a(t[0]*Sa,t[1]*Sa),[t[0]*f+o,c-t[1]*f]}function e(t){return t=a.invert((t[0]-o)/f,(c-t[1])/f),t&&[t[0]*Ea,t[1]*Ea]}function r(){a=oe(u=Dn(d,m,v),i);var t=i(g,p);return o=s-t[0]*f,c=h+t[1]*f,n}var i,u,a,o,c,l=ce(function(t,n){return t=i(t,n),[t[0]*f+o,c-t[1]*f]}),f=150,s=480,h=250,g=0,p=0,d=0,m=0,v=0,y=co,M=gn,b=null,x=null;return n.stream=function(t){return se(u,y(l(M(t))))},n.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,co):ie(b=+t),n):b},n.clipExtent=function(t){return arguments.length?(x=t,M=null==t?gn:ue(t[0][0],t[0][1],t[1][0],t[1][1]),n):x},n.scale=function(t){return arguments.length?(f=+t,r()):f},n.translate=function(t){return arguments.length?(s=+t[0],h=+t[1],r()):[s,h]},n.center=function(t){return arguments.length?(g=t[0]%360*Sa,p=t[1]%360*Sa,r()):[g*Ea,p*Ea]},n.rotate=function(t){return arguments.length?(d=t[0]%360*Sa,m=t[1]%360*Sa,v=t.length>2?t[2]%360*Sa:0,r()):[d*Ea,m*Ea,v*Ea]},$u.rebind(n,l,"precision"),function(){return i=t.apply(this,arguments),n.invert=i.invert&&e,r()}}function se(t,n){return{point:function(e,r){r=t(e*Sa,r*Sa),e=r[0],n.point(e>_a?e-2*_a:-_a>e?e+2*_a:e,r[1])},sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function he(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function ge(t){var n=ce(function(n,e){return t([n*Ea,e*Ea])});return function(t){return t=n(t),{point:function(n,e){t.point(n*Sa,e*Sa)},sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}}function pe(){function t(t,n){fo+=i*t-r*n,r=t,i=n}var n,e,r,i;so.point=function(u,a){so.point=t,n=r=u,e=i=a},so.lineEnd=function(){t(n,e)}}function de(){function t(t,n){a.push("M",t,",",n,u)}function n(t,n){a.push("M",t,",",n),o.point=e}function e(t,n){a.push("L",t,",",n)}function r(){o.point=t}function i(){a.push("Z")}var u=he(4.5),a=[],o={point:t,lineStart:function(){o.point=n},lineEnd:r,polygonStart:function(){o.lineEnd=i},polygonEnd:function(){o.lineEnd=r,o.point=t},pointRadius:function(t){return u=he(t),o},result:function(){if(a.length){var t=a.join("");return a=[],t}}};return o}function me(t,n){to||(eo+=t,ro+=n,++io)}function ve(){function t(t,r){var i=t-n,u=r-e,a=Math.sqrt(i*i+u*u);eo+=a*(n+t)/2,ro+=a*(e+r)/2,io+=a,n=t,e=r}var n,e;if(1!==to){if(!(1>to))return;to=1,eo=ro=io=0}ho.point=function(r,i){ho.point=t,n=r,e=i}}function ye(){ho.point=me}function Me(){function t(t,n){var e=i*t-r*n;eo+=e*(r+t),ro+=e*(i+n),io+=3*e,r=t,i=n}var n,e,r,i;2>to&&(to=2,eo=ro=io=0),ho.point=function(u,a){ho.point=t,n=r=u,e=i=a},ho.lineEnd=function(){t(n,e)}}function be(t){function n(n,e){t.moveTo(n,e),t.arc(n,e,a,0,2*_a)}function e(n,e){t.moveTo(n,e),o.point=r}function r(n,e){t.lineTo(n,e)}function i(){o.point=n}function u(){t.closePath()}var a=4.5,o={point:n,lineStart:function(){o.point=e},lineEnd:i,polygonStart:function(){o.lineEnd=u},polygonEnd:function(){o.lineEnd=i,o.point=n},pointRadius:function(t){return a=t,o},result:vn};return o}function xe(t){var n=0,e=_a/3,r=fe(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*_a/180,e=t[1]*_a/180):[180*(n/_a),180*(e/_a)]},i}function _e(t,n){function e(t,n){var e=Math.sqrt(u-2*i*Math.sin(n))/i;return[e*Math.sin(t*=i),a-e*Math.cos(t)]}var r=Math.sin(t),i=(r+Math.sin(n))/2,u=1+r*(2*i-r),a=Math.sqrt(u)/i;return e.invert=function(t,n){var e=a-n;return[Math.atan2(t,e)/i,Math.asin((u-(t*t+e*e)*i*i)/(2*i))]},e}function we(t,n){var e=t(n[0]),r=t([.5*(n[0][0]+n[1][0]),n[0][1]]),i=t([n[1][0],n[0][1]]),u=t(n[1]),a=r[1]-e[1],o=r[0]-e[0],c=i[1]-r[1],l=i[0]-r[0],f=a/o,s=c/l,h=.5*(f*s*(e[1]-i[1])+s*(e[0]+r[0])-f*(r[0]+i[0]))/(s-f),g=(.5*(e[0]+r[0])-h)/f+.5*(e[1]+r[1]),p=u[0]-h,d=u[1]-g,m=e[0]-h,v=e[1]-g,y=p*p+d*d,M=m*m+v*v,b=Math.atan2(d,p),x=Math.atan2(v,m);return function(n){var e=n[0]-h,r=n[1]-g,i=e*e+r*r,u=Math.atan2(r,e);return i>y&&M>i&&u>b&&x>u?t.invert(n):void 0}}function Se(t,n){function e(n,e){var r=Math.cos(n),i=Math.cos(e),u=t(r*i);return[u*i*Math.sin(n),u*Math.sin(e)]}return e.invert=function(t,e){var r=Math.sqrt(t*t+e*e),i=n(r),u=Math.sin(i),a=Math.cos(i);return[Math.atan2(t*u,r*a),Math.asin(r&&e*u/r)]},e}function Ee(t,n){function e(t,n){var e=wa>Math.abs(Math.abs(n)-_a/2)?0:a/Math.pow(i(n),u);return[e*Math.sin(u*t),a-e*Math.cos(u*t)]}var r=Math.cos(t),i=function(t){return Math.tan(_a/4+t/2)},u=t===n?Math.sin(t):Math.log(r/Math.cos(n))/Math.log(i(n)/i(t)),a=r*Math.pow(i(t),u)/u;return u?(e.invert=function(t,n){var e=a-n,r=R(u)*Math.sqrt(t*t+e*e);return[Math.atan2(t,e)/u,2*Math.atan(Math.pow(a/r,1/u))-_a/2]},e):Ne}function ke(t,n){function e(t,n){var e=u-n;return[e*Math.sin(i*t),u-e*Math.cos(i*t)]}var r=Math.cos(t),i=t===n?Math.sin(t):(r-Math.cos(n))/(n-t),u=r/i+t;return wa>Math.abs(i)?Ae:(e.invert=function(t,n){var e=u-n;return[Math.atan2(t,e)/i,u-R(i)*Math.sqrt(t*t+e*e)]},e)}function Ae(t,n){return[t,n]}function Ne(t,n){return[t,Math.log(Math.tan(_a/4+n/2))]}function qe(t,n){var e=Math.cos(n)*Math.sin(t);return[Math.log((1+e)/(1-e))/2,Math.atan2(Math.tan(n),Math.cos(t))]}function Te(t,n,e,r){var i,u,a,o,c,l,f;return i=r[t],u=i[0],a=i[1],i=r[n],o=i[0],c=i[1],i=r[e],l=i[0],f=i[1],(f-a)*(o-u)-(c-a)*(l-u)>0}function Ce(t,n,e){return(e[0]-n[0])*(t[1]-n[1])<(e[1]-n[1])*(t[0]-n[0])}function ze(t,n,e,r){var i=t[0],u=e[0],a=n[0]-i,o=r[0]-u,c=t[1],l=e[1],f=n[1]-c,s=r[1]-l,h=(o*(c-l)-s*(i-u))/(s*a-o*f);return[i+h*a,c+h*f]}function De(t,n){var e={list:t.map(function(t,n){return{index:n,x:t[0],y:t[1]}}).sort(function(t,n){return t.yn.y?1:t.xn.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(t,n){return{edge:t,side:n,vertex:null,l:null,r:null}},insert:function(t,n){n.l=t,n.r=t.r,t.r.l=n,t.r=n},leftBound:function(t){var n=r.leftEnd;do n=n.r;while(n!=r.rightEnd&&i.rightOf(n,t));return n=n.l},del:function(t){t.l.r=t.r,t.r.l=t.l,t.edge=null},right:function(t){return t.r},left:function(t){return t.l},leftRegion:function(t){return null==t.edge?e.bottomSite:t.edge.region[t.side]},rightRegion:function(t){return null==t.edge?e.bottomSite:t.edge.region[Mo[t.side]]}},i={bisect:function(t,n){var e={region:{l:t,r:n},ep:{l:null,r:null}},r=n.x-t.x,i=n.y-t.y,u=r>0?r:-r,a=i>0?i:-i;return e.c=t.x*r+t.y*i+.5*(r*r+i*i),u>a?(e.a=1,e.b=i/r,e.c/=r):(e.b=1,e.a=r/i,e.c/=i),e},intersect:function(t,n){var e=t.edge,r=n.edge;if(!e||!r||e.region.r==r.region.r)return null;var i=e.a*r.b-e.b*r.a;if(1e-10>Math.abs(i))return null;var u,a,o=(e.c*r.b-r.c*e.b)/i,c=(r.c*e.a-e.c*r.a)/i,l=e.region.r,f=r.region.r;l.y=a.region.r.x;return s&&"l"===u.side||!s&&"r"===u.side?null:{x:o,y:c}},rightOf:function(t,n){var e=t.edge,r=e.region.r,i=n.x>r.x;if(i&&"l"===t.side)return 1;if(!i&&"r"===t.side)return 0;if(1===e.a){var u=n.y-r.y,a=n.x-r.x,o=0,c=0;if(!i&&0>e.b||i&&e.b>=0?c=o=u>=e.b*a:(c=n.x+n.y*e.b>e.c,0>e.b&&(c=!c),c||(o=1)),!o){var l=r.x-e.region.l.x;c=e.b*(a*a-u*u)e.b&&(c=!c)}}else{var f=e.c-e.a*n.x,s=n.y-f,h=n.x-r.x,g=f-r.y;c=s*s>h*h+g*g}return"l"===t.side?c:!c},endPoint:function(t,e,r){t.ep[e]=r,t.ep[Mo[e]]&&n(t)},distance:function(t,n){var e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)}},u={list:[],insert:function(t,n,e){t.vertex=n,t.ystar=n.y+e;for(var r=0,i=u.list,a=i.length;a>r;r++){var o=i[r];if(!(t.ystar>o.ystar||t.ystar==o.ystar&&n.x>o.vertex.x))break}i.splice(r,0,t)},del:function(t){for(var n=0,e=u.list,r=e.length;r>n&&e[n]!=t;++n);e.splice(n,1)},empty:function(){return 0===u.list.length},nextEvent:function(t){for(var n=0,e=u.list,r=e.length;r>n;++n)if(e[n]==t)return e[n+1];return null},min:function(){var t=u.list[0];return{x:t.vertex.x,y:t.ystar}},extractMin:function(){return u.list.shift()}};r.init(),e.bottomSite=e.list.shift();for(var a,o,c,l,f,s,h,g,p,d,m,v,y,M=e.list.shift();;)if(u.empty()||(a=u.min()),M&&(u.empty()||M.yg.y&&(p=h,h=g,g=p,y="r"),v=i.bisect(h,g),s=r.createHalfEdge(v,y),r.insert(l,s),i.endPoint(v,Mo[y],m),d=i.intersect(l,s),d&&(u.del(l),u.insert(l,d,i.distance(d,h))),d=i.intersect(s,f),d&&u.insert(s,d,i.distance(d,h))}for(o=r.right(r.leftEnd);o!=r.rightEnd;o=r.right(o))n(o.edge)}function je(){return{leaf:!0,nodes:[],point:null}}function Le(t,n,e,r,i,u){if(!t(n,e,r,i,u)){var a=.5*(e+i),o=.5*(r+u),c=n.nodes;c[0]&&Le(t,c[0],e,r,a,o),c[1]&&Le(t,c[1],a,r,i,o),c[2]&&Le(t,c[2],e,o,a,u),c[3]&&Le(t,c[3],a,o,i,u)}}function Fe(t){return function(n){return 0>=n?0:n>=1?1:t(n)}}function He(t){return function(n){return 1-t(1-n)}}function Re(t){return function(n){return.5*(.5>n?t(2*n):2-t(2-2*n))}}function Pe(t){return t*t}function Oe(t){return t*t*t}function Ye(t){if(0>=t)return 0;if(t>=1)return 1;var n=t*t,e=n*t;return 4*(.5>t?e:3*(t-n)+e-.75)}function Ue(t){return function(n){return Math.pow(n,t)}}function Ie(t){return 1-Math.cos(t*_a/2)}function Ve(t){return Math.pow(2,10*(t-1))}function Xe(t){return 1-Math.sqrt(1-t*t)}function Ze(t,n){var e;return 2>arguments.length&&(n=.45),arguments.length?e=n/(2*_a)*Math.asin(1/t):(t=1,e=n/4),function(r){return 1+t*Math.pow(2,10*-r)*Math.sin(2*(r-e)*_a/n)}}function Be(t){return t||(t=1.70158),function(n){return n*n*((t+1)*n-t)}}function $e(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Je(t){var n=[t.a,t.b],e=[t.c,t.d],r=Ke(n),i=Ge(n,e),u=Ke(We(e,n,-i))||0;n[0]*e[1]++c;)u=a[c],null!=u&&(or(u,n,e),t.charge+=u.charge,r+=u.charge*u.cx,i+=u.charge*u.cy);if(t.point){t.leaf||(t.point.x+=Math.random()-.5,t.point.y+=Math.random()-.5);var l=n*e[t.point.index];t.charge+=t.pointCharge=l,r+=l*t.point.x,i+=l*t.point.y}t.cx=r/t.charge,t.cy=i/t.charge}function cr(t,n){return $u.rebind(t,n,"sort","children","value"),t.nodes=t,t.links=hr,t}function lr(t){return t.children}function fr(t){return t.value}function sr(t,n){return n.value-t.value}function hr(t){return $u.merge(t.map(function(t){return(t.children||[]).map(function(n){return{source:t,target:n}})}))}function gr(t){return t.x}function pr(t){return t.y}function dr(t,n,e){t.y0=n,t.y=e}function mr(t){return $u.range(t.length)}function vr(t){for(var n=-1,e=t[0].length,r=[];e>++n;)r[n]=0;return r}function yr(t){for(var n,e=1,r=0,i=t[0][1],u=t.length;u>e;++e)(n=t[e][1])>i&&(r=e,i=n);return r}function Mr(t){return t.reduce(br,0)}function br(t,n){return t+n[1]}function xr(t,n){return _r(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function _r(t,n){for(var e=-1,r=+t[0],i=(t[1]-r)/n,u=[];n>=++e;)u[e]=i*e+r;return u}function wr(t){return[$u.min(t),$u.max(t)]}function Sr(t,n){return t.parent==n.parent?1:2}function Er(t){var n=t.children;return n&&n.length?n[0]:t._tree.thread}function kr(t){var n,e=t.children;return e&&(n=e.length)?e[n-1]:t._tree.thread}function Ar(t,n){var e=t.children;if(e&&(i=e.length))for(var r,i,u=-1;i>++u;)n(r=Ar(e[u],n),t)>0&&(t=r);return t}function Nr(t,n){return t.x-n.x}function qr(t,n){return n.x-t.x}function Tr(t,n){return t.depth-n.depth}function Cr(t,n){function e(t,r){var i=t.children;if(i&&(a=i.length))for(var u,a,o=null,c=-1;a>++c;)u=i[c],e(u,o),o=u;n(t,r)}e(t,null)}function zr(t){for(var n,e=0,r=0,i=t.children,u=i.length;--u>=0;)n=i[u]._tree,n.prelim+=e,n.mod+=e,e+=n.shift+(r+=n.change)}function Dr(t,n,e){t=t._tree,n=n._tree;var r=e/(n.number-t.number);t.change+=r,n.change-=r,n.shift+=e,n.prelim+=e,n.mod+=e}function jr(t,n,e){return t._tree.ancestor.parent==n.parent?t._tree.ancestor:e}function Lr(t,n){return t.value-n.value}function Fr(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function Hr(t,n){t._pack_next=n,n._pack_prev=t}function Rr(t,n){var e=n.x-t.x,r=n.y-t.y,i=t.r+n.r;return i*i-e*e-r*r>.001}function Pr(t){function n(t){f=Math.min(t.x-t.r,f),s=Math.max(t.x+t.r,s),h=Math.min(t.y-t.r,h),g=Math.max(t.y+t.r,g)}if((e=t.children)&&(l=e.length)){var e,r,i,u,a,o,c,l,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,n(r),l>1&&(i=e[1],i.x=i.r,i.y=0,n(i),l>2))for(u=e[2],Ir(r,i,u),n(u),Fr(r,u),r._pack_prev=u,Fr(u,i),i=r._pack_next,a=3;l>a;a++){Ir(r,i,u=e[a]);var p=0,d=1,m=1;for(o=i._pack_next;o!==i;o=o._pack_next,d++)if(Rr(o,u)){p=1;break}if(1==p)for(c=r._pack_prev;c!==o._pack_prev&&!Rr(c,u);c=c._pack_prev,m++);p?(m>d||d==m&&i.ra;a++)u=e[a],u.x-=v,u.y-=y,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));t.r=M,e.forEach(Yr)}}function Or(t){t._pack_next=t._pack_prev=t}function Yr(t){delete t._pack_next,delete t._pack_prev}function Ur(t,n,e,r){var i=t.children;if(t.x=n+=r*t.x,t.y=e+=r*t.y,t.r*=r,i)for(var u=-1,a=i.length;a>++u;)Ur(i[u],n,e,r)}function Ir(t,n,e){var r=t.r+e.r,i=n.x-t.x,u=n.y-t.y;if(r&&(i||u)){var a=n.r+e.r,o=i*i+u*u;a*=a,r*=r;var c=.5+(r-a)/(2*o),l=Math.sqrt(Math.max(0,2*a*(r+o)-(r-=o)*r-a*a))/(2*o);e.x=t.x+c*i+l*u,e.y=t.y+c*u-l*i}else e.x=t.x+r,e.y=t.y}function Vr(t){return 1+$u.max(t,function(t){return t.y})}function Xr(t){return t.reduce(function(t,n){return t+n.x},0)/t.length}function Zr(t){var n=t.children;return n&&n.length?Zr(n[0]):t}function Br(t){var n,e=t.children;return e&&(n=e.length)?Br(e[n-1]):t}function $r(t){return{x:t.x,y:t.y,dx:t.dx,dy:t.dy}}function Jr(t,n){var e=t.x+n[3],r=t.y+n[0],i=t.dx-n[1]-n[3],u=t.dy-n[0]-n[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 Gr(t){function n(n){function a(){l.push("M",u(t(f),o))}for(var c,l=[],f=[],s=-1,h=n.length,g=ln(e),p=ln(r);h>++s;)i.call(this,c=n[s],s)?f.push([+g.call(this,c,s),+p.call(this,c,s)]):f.length&&(a(),f=[]);return f.length&&a(),l.length?l.join(""):null}var e=Kr,r=Wr,i=Bn,u=Qr,a=u.key,o=.7;return n.x=function(t){return arguments.length?(e=t,n):e},n.y=function(t){return arguments.length?(r=t,n):r},n.defined=function(t){return arguments.length?(i=t,n):i},n.interpolate=function(t){return arguments.length?(a="function"==typeof t?u=t:(u=To.get(t)||Qr).key,n):a},n.tension=function(t){return arguments.length?(o=t,n):o},n}function Kr(t){return t[0]}function Wr(t){return t[1]}function Qr(t){return t.join("L")}function ti(t){return Qr(t)+"Z"}function ni(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];e>++n;)i.push("V",(r=t[n])[1],"H",r[0]);return i.join("")}function ei(t){for(var n=0,e=t.length,r=t[0],i=[r[0],",",r[1]];e>++n;)i.push("H",(r=t[n])[0],"V",r[1]);return i.join("")}function ri(t,n){return 4>t.length?Qr(t):t[1]+ai(t.slice(1,t.length-1),oi(t,n))}function ii(t,n){return 3>t.length?Qr(t):t[0]+ai((t.push(t[0]),t),oi([t[t.length-2]].concat(t,[t[1]]),n))}function ui(t,n){return 3>t.length?Qr(t):t[0]+ai(t,oi(t,n))}function ai(t,n){if(1>n.length||t.length!=n.length&&t.length!=n.length+2)return Qr(t);var e=t.length!=n.length,r="",i=t[0],u=t[1],a=n[0],o=a,c=1;if(e&&(r+="Q"+(u[0]-2*a[0]/3)+","+(u[1]-2*a[1]/3)+","+u[0]+","+u[1],i=t[1],c=2),n.length>1){o=n[1],u=t[c],c++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1];for(var l=2;n.length>l;l++,c++)u=t[c],o=n[l],r+="S"+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1]}if(e){var f=t[c];r+="Q"+(u[0]+2*o[0]/3)+","+(u[1]+2*o[1]/3)+","+f[0]+","+f[1]}return r}function oi(t,n){for(var e,r=[],i=(1-n)/2,u=t[0],a=t[1],o=1,c=t.length;c>++o;)e=u,u=a,a=t[o],r.push([i*(a[0]-e[0]),i*(a[1]-e[1])]);return r}function ci(t){if(3>t.length)return Qr(t);var n=1,e=t.length,r=t[0],i=r[0],u=r[1],a=[i,i,i,(r=t[1])[0]],o=[u,u,u,r[1]],c=[i,",",u];for(gi(c,a,o);e>++n;)r=t[n],a.shift(),a.push(r[0]),o.shift(),o.push(r[1]),gi(c,a,o);for(n=-1;2>++n;)a.shift(),a.push(r[0]),o.shift(),o.push(r[1]),gi(c,a,o);return c.join("")}function li(t){if(4>t.length)return Qr(t);for(var n,e=[],r=-1,i=t.length,u=[0],a=[0];3>++r;)n=t[r],u.push(n[0]),a.push(n[1]);for(e.push(hi(Do,u)+","+hi(Do,a)),--r;i>++r;)n=t[r],u.shift(),u.push(n[0]),a.shift(),a.push(n[1]),gi(e,u,a);return e.join("")}function fi(t){for(var n,e,r=-1,i=t.length,u=i+4,a=[],o=[];4>++r;)e=t[r%i],a.push(e[0]),o.push(e[1]);for(n=[hi(Do,a),",",hi(Do,o)],--r;u>++r;)e=t[r%i],a.shift(),a.push(e[0]),o.shift(),o.push(e[1]),gi(n,a,o);return n.join("")}function si(t,n){var e=t.length-1;if(e)for(var r,i,u=t[0][0],a=t[0][1],o=t[e][0]-u,c=t[e][1]-a,l=-1;e>=++l;)r=t[l],i=l/e,r[0]=n*r[0]+(1-n)*(u+i*o),r[1]=n*r[1]+(1-n)*(a+i*c);return ci(t)}function hi(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]+t[3]*n[3]}function gi(t,n,e){t.push("C",hi(Co,n),",",hi(Co,e),",",hi(zo,n),",",hi(zo,e),",",hi(Do,n),",",hi(Do,e))}function pi(t,n){return(n[1]-t[1])/(n[0]-t[0])}function di(t){for(var n=0,e=t.length-1,r=[],i=t[0],u=t[1],a=r[0]=pi(i,u);e>++n;)r[n]=(a+(a=pi(i=u,u=t[n+1])))/2;return r[n]=a,r}function mi(t){for(var n,e,r,i,u=[],a=di(t),o=-1,c=t.length-1;c>++o;)n=pi(t[o],t[o+1]),1e-6>Math.abs(n)?a[o]=a[o+1]=0:(e=a[o]/n,r=a[o+1]/n,i=e*e+r*r,i>9&&(i=3*n/Math.sqrt(i),a[o]=i*e,a[o+1]=i*r));for(o=-1;c>=++o;)i=(t[Math.min(c,o+1)][0]-t[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),u.push([i||0,a[o]*i||0]);return u}function vi(t){return 3>t.length?Qr(t):t[0]+ai(t,mi(t))}function yi(t){var n=t[0],e=t[t.length-1];return e>n?[n,e]:[e,n]}function Mi(t){return t.rangeExtent?t.rangeExtent():yi(t.range())}function bi(t,n){return n=n-(t=+t)?1/(n-t):0,function(e){return(e-t)*n}}function xi(t,n){return n=n-(t=+t)?1/(n-t):0,function(e){return Math.max(0,Math.min(1,(e-t)*n))}}function _i(t,n,e,r){var i=e(t[0],t[1]),u=r(n[0],n[1]);return function(t){return u(i(t))}}function wi(t,n){var e,r=0,i=t.length-1,u=t[r],a=t[i];return u>a&&(e=r,r=i,i=e,e=u,u=a,a=e),(n=n(a-u))&&(t[r]=n.floor(u),t[i]=n.ceil(a)),t}function Si(t,n,e,r){var i=[],u=[],a=0,o=Math.min(t.length,n.length)-1;for(t[o]=++a;)i.push(e(t[a-1],t[a])),u.push(r(n[a-1],n[a]));return function(n){var e=$u.bisect(t,n,1,o)-1;return u[e](i[e](n))}}function Ei(t,n,e,r){function i(){var i=Math.min(t.length,n.length)>2?Si:_i,c=r?xi:bi;return a=i(t,n,c,e),o=i(n,t,c,$u.interpolate),u}function u(t){return a(t)}var a,o;return u.invert=function(t){return o(t)},u.domain=function(n){return arguments.length?(t=n.map(Number),i()):t},u.range=function(t){return arguments.length?(n=t,i()):n},u.rangeRound=function(t){return u.range(t).interpolate($u.interpolateRound)},u.clamp=function(t){return arguments.length?(r=t,i()):r},u.interpolate=function(t){return arguments.length?(e=t,i()):e},u.ticks=function(n){return qi(t,n)},u.tickFormat=function(n,e){return Ti(t,n,e)},u.nice=function(){return wi(t,Ai),i()},u.copy=function(){return Ei(t,n,e,r)},i()}function ki(t,n){return $u.rebind(t,n,"range","rangeRound","interpolate","clamp")}function Ai(t){return t=Math.pow(10,Math.round(Math.log(t)/Math.LN10)-1),t&&{floor:function(n){return Math.floor(n/t)*t},ceil:function(n){return Math.ceil(n/t)*t}}}function Ni(t,n){var e=yi(t),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/n)/Math.LN10)),u=n/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(t,n){return $u.range.apply($u,Ni(t,n))}function Ti(t,n,e){var r=-Math.floor(Math.log(Ni(t,n)[2])/Math.LN10+.01);return $u.format(e?e.replace(Va,function(t,n,e,i,u,a,o,c,l,f){return[n,e,i,u,a,o,c,l||"."+(r-2*("%"===f)),f].join("")}):",."+r+"f")}function Ci(t,n,e,r){function i(n){return t(e(n))}return i.invert=function(n){return r(t.invert(n))},i.domain=function(n){return arguments.length?(0>n[0]?(e=ji,r=Li):(e=zi,r=Di),t.domain(n.map(e)),i):t.domain().map(r)},i.base=function(t){return arguments.length?(n=+t,i):n},i.nice=function(){return t.domain(wi(t.domain(),Fi(n))),i},i.ticks=function(){var i=yi(t.domain()),u=[];if(i.every(isFinite)){var a=Math.log(n),o=Math.floor(i[0]/a),c=Math.ceil(i[1]/a),l=r(i[0]),f=r(i[1]),s=n%1?2:n;if(e===ji)for(u.push(-Math.pow(n,-o));c>o++;)for(var h=s-1;h>0;h--)u.push(-Math.pow(n,-o)*h);else{for(;c>o;o++)for(var h=1;s>h;h++)u.push(Math.pow(n,o)*h);u.push(Math.pow(n,o))}for(o=0;l>u[o];o++);for(c=u.length;u[c-1]>f;c--);u=u.slice(o,c)}return u},i.tickFormat=function(t,u){if(2>arguments.length&&(u=jo),!arguments.length)return u;var a,o=Math.log(n),c=Math.max(.1,t/i.ticks().length),l=e===ji?(a=-1e-12,Math.floor):(a=1e-12,Math.ceil);return function(t){return c>=t/r(o*l(e(t)/o+a))?u(t):""}},i.copy=function(){return Ci(t.copy(),n,e,r)},ki(i,t)}function zi(t){return Math.log(0>t?0:t)}function Di(t){return Math.exp(t)}function ji(t){return-Math.log(t>0?0:-t)}function Li(t){return-Math.exp(-t)}function Fi(t){t=Math.log(t);var n={floor:function(n){return Math.floor(n/t)*t},ceil:function(n){return Math.ceil(n/t)*t}};return function(){return n}}function Hi(t,n){function e(n){return t(r(n))}var r=Ri(n),i=Ri(1/n);return e.invert=function(n){return i(t.invert(n))},e.domain=function(n){return arguments.length?(t.domain(n.map(r)),e):t.domain().map(i)},e.ticks=function(t){return qi(e.domain(),t)},e.tickFormat=function(t,n){return Ti(e.domain(),t,n)},e.nice=function(){return e.domain(wi(e.domain(),Ai))},e.exponent=function(t){if(!arguments.length)return n;var u=e.domain();return r=Ri(n=t),i=Ri(1/n),e.domain(u)},e.copy=function(){return Hi(t.copy(),n)},ki(e,t)}function Ri(t){return function(n){return 0>n?-Math.pow(-n,t):Math.pow(n,t)}}function Pi(t,n){function e(n){return a[((u.get(n)||u.set(n,t.push(n)))-1)%a.length]}function r(n,e){return $u.range(t.length).map(function(t){return n+e*t})}var u,a,o;return e.domain=function(r){if(!arguments.length)return t;t=[],u=new i;for(var a,o=-1,c=r.length;c>++o;)u.has(a=r[o])||u.set(a,t.push(a));return e[n.t].apply(e,n.a)},e.range=function(t){return arguments.length?(a=t,o=0,n={t:"range",a:arguments},e):a},e.rangePoints=function(i,u){2>arguments.length&&(u=0);var c=i[0],l=i[1],f=(l-c)/(Math.max(1,t.length-1)+u);return a=r(2>t.length?(c+l)/2:c+f*u/2,f),o=0,n={t:"rangePoints",a:arguments},e},e.rangeBands=function(i,u,c){2>arguments.length&&(u=0),3>arguments.length&&(c=u);var l=i[1]arguments.length&&(u=0),3>arguments.length&&(c=u);var l=i[1]++e;)i[e-1]=$u.quantile(t,e/u);return r}function r(t){return isNaN(t=+t)?0/0:n[$u.bisect(i,t)]}var i;return r.domain=function(n){return arguments.length?(t=n.filter(function(t){return!isNaN(t)}).sort($u.ascending),e()):t},r.range=function(t){return arguments.length?(n=t,e()):n},r.quantiles=function(){return i},r.copy=function(){return Oi(t,n)},e()}function Yi(t,n,e){function r(n){return e[Math.max(0,Math.min(a,Math.floor(u*(n-t))))]}function i(){return u=e.length/(n-t),a=e.length-1,r}var u,a;return r.domain=function(e){return arguments.length?(t=+e[0],n=+e[e.length-1],i()):[t,n]},r.range=function(t){return arguments.length?(e=t,i()):e},r.copy=function(){return Yi(t,n,e)},i()}function Ui(t,n){function e(e){return n[$u.bisect(t,e)]}return e.domain=function(n){return arguments.length?(t=n,e):t},e.range=function(t){return arguments.length?(n=t,e):n},e.copy=function(){return Ui(t,n)},e}function Ii(t){function n(t){return+t}return n.invert=n,n.domain=n.range=function(e){return arguments.length?(t=e.map(n),n):t},n.ticks=function(n){return qi(t,n)},n.tickFormat=function(n,e){return Ti(t,n,e)},n.copy=function(){return Ii(t)},n}function Vi(t){return t.innerRadius}function Xi(t){return t.outerRadius}function Zi(t){return t.startAngle}function Bi(t){return t.endAngle}function $i(t){for(var n,e,r,i=-1,u=t.length;u>++i;)n=t[i],e=n[0],r=n[1]+Po,n[0]=e*Math.cos(r),n[1]=e*Math.sin(r);return t}function Ji(t){function n(n){function c(){d.push("M",o(t(v),s),f,l(t(m.reverse()),s),"Z")}for(var h,g,p,d=[],m=[],v=[],y=-1,M=n.length,b=ln(e),x=ln(i),_=e===r?function(){return g}:ln(r),w=i===u?function(){return p}:ln(u);M>++y;)a.call(this,h=n[y],y)?(m.push([g=+b.call(this,h,y),p=+x.call(this,h,y)]),v.push([+_.call(this,h,y),+w.call(this,h,y)])):m.length&&(c(),m=[],v=[]);return m.length&&c(),d.length?d.join(""):null}var e=Kr,r=Kr,i=0,u=Wr,a=Bn,o=Qr,c=o.key,l=o,f="L",s=.7;return n.x=function(t){return arguments.length?(e=r=t,n):r},n.x0=function(t){return arguments.length?(e=t,n):e},n.x1=function(t){return arguments.length?(r=t,n):r},n.y=function(t){return arguments.length?(i=u=t,n):u},n.y0=function(t){return arguments.length?(i=t,n):i},n.y1=function(t){return arguments.length?(u=t,n):u},n.defined=function(t){return arguments.length?(a=t,n):a},n.interpolate=function(t){return arguments.length?(c="function"==typeof t?o=t:(o=To.get(t)||Qr).key,l=o.reverse||o,f=o.closed?"M":"L",n):c},n.tension=function(t){return arguments.length?(s=t,n):s},n}function Gi(t){return t.radius}function Ki(t){return[t.x,t.y]}function Wi(t){return function(){var n=t.apply(this,arguments),e=n[0],r=n[1]+Po;return[e*Math.cos(r),e*Math.sin(r)]}}function Qi(){return 64}function tu(){return"circle"}function nu(t){var n=Math.sqrt(t/_a);return"M0,"+n+"A"+n+","+n+" 0 1,1 0,"+-n+"A"+n+","+n+" 0 1,1 0,"+n+"Z"}function eu(t,n){return aa(t,Xo),t.id=n,t}function ru(t,n,e,r){var u=t.__transition__||(t.__transition__={active:0,count:0}),a=u[e];if(!a){var o=r.time;return a=u[e]={tween:new i,event:$u.dispatch("start","end"),time:o,ease:r.ease,delay:r.delay,duration:r.duration},++u.count,$u.timer(function(r){function i(r){return u.active>e?l():(u.active=e,h.start.call(t,f,n),a.tween.forEach(function(e,r){(r=r.call(t,f,n))&&d.push(r)}),c(r)||$u.timer(c,0,o),1)}function c(r){if(u.active!==e)return l();for(var i=(r-g)/p,a=s(i),o=d.length;o>0;)d[--o].call(t,a);return i>=1?(l(),h.end.call(t,f,n),1):void 0}function l(){return--u.count?delete u[e]:delete t.__transition__,1}var f=t.__data__,s=a.ease,h=a.event,g=a.delay,p=a.duration,d=[];return r>=g?i(r):$u.timer(i,g,o),1},0,o),a}}function iu(t,n,e,r){var i=t.id;return z(t,"function"==typeof e?function(t,u,a){t.__transition__[i].tween.set(n,r(e.call(t,t.__data__,u,a)))}:(e=r(e),function(t){t.__transition__[i].tween.set(n,e)}))}function uu(t){return null==t&&(t=""),function(){this.textContent=t}}function au(t,n){t.attr("transform",function(t){return"translate("+n(t)+",0)"})}function ou(t,n){t.attr("transform",function(t){return"translate(0,"+n(t)+")"})}function cu(t,n,e){if(r=[],e&&n.length>1){for(var r,i,u,a=yi(t.domain()),o=-1,c=n.length,l=(n[1]-n[0])/++e;c>++o;)for(i=e;--i>0;)(u=+n[o]-i*l)>=a[0]&&r.push(u);for(--o,i=0;e>++i&&(u=+n[o]+i*l)1?Date.UTC.apply(this,arguments):arguments[0])}function fu(t,n,e,r){for(var i,u,a=0,o=n.length,c=e.length;o>a;){if(r>=c)return-1;if(i=n.charCodeAt(a++),37===i){if(u=mc[n.charAt(a++)],!u||0>(r=u(t,e,r)))return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function su(t){return RegExp("^(?:"+t.map($u.requote).join("|")+")","i")}function hu(t){for(var n=new i,e=-1,r=t.length;r>++e;)n.set(t[e].toLowerCase(),e);return n}function gu(t,n,e){t+="";var r=t.length;return e>r?Array(e-r+1).join(n)+t:t}function pu(t,n,e){lc.lastIndex=0;var r=lc.exec(n.substring(e));return r?e+=r[0].length:-1}function du(t,n,e){cc.lastIndex=0;var r=cc.exec(n.substring(e));return r?e+=r[0].length:-1}function mu(t,n,e){hc.lastIndex=0;var r=hc.exec(n.substring(e));return r?(t.m=gc.get(r[0].toLowerCase()),e+=r[0].length):-1}function vu(t,n,e){fc.lastIndex=0;var r=fc.exec(n.substring(e));return r?(t.m=sc.get(r[0].toLowerCase()),e+=r[0].length):-1}function yu(t,n,e){return fu(t,""+dc.c,n,e)}function Mu(t,n,e){return fu(t,""+dc.x,n,e)}function bu(t,n,e){return fu(t,""+dc.X,n,e)}function xu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+4));return r?(t.y=+r[0],e+=r[0].length):-1}function _u(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.y=wu(+r[0]),e+=r[0].length):-1}function wu(t){return t+(t>68?1900:2e3)}function Su(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.m=r[0]-1,e+=r[0].length):-1}function Eu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.d=+r[0],e+=r[0].length):-1}function ku(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.H=+r[0],e+=r[0].length):-1}function Au(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.M=+r[0],e+=r[0].length):-1}function Nu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.S=+r[0],e+=r[0].length):-1}function qu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+3));return r?(t.L=+r[0],e+=r[0].length):-1}function Tu(t,n,e){var r=yc.get(n.substring(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)}function Cu(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=~~(Math.abs(n)/60),i=Math.abs(n)%60;return e+gu(r,"0",2)+gu(i,"0",2)}function zu(t){return t.toISOString()}function Du(t,n,e){function r(n){var e=t(n),r=u(e,1);return r-n>n-e?e:r}function i(e){return n(e=t(new Wo(e-1)),1),e}function u(t,e){return n(t=new Wo(+t),e),t}function a(t,r,u){var a=i(t),o=[];if(u>1)for(;r>a;)e(a)%u||o.push(new Date(+a)),n(a,1);else for(;r>a;)o.push(new Date(+a)),n(a,1);return o}function o(t,n,e){try{Wo=lu;var r=new lu;return r._=t,a(r,n,e)}finally{Wo=Date}}t.floor=t,t.round=r,t.ceil=i,t.offset=u,t.range=a;var c=t.utc=ju(t);return c.floor=c,c.round=ju(r),c.ceil=ju(i),c.offset=ju(u),c.range=o,t}function ju(t){return function(n,e){try{Wo=lu;var r=new lu;return r._=n,t(r,e)._}finally{Wo=Date}}}function Lu(t,n,e){function r(n){return t(n)}return r.invert=function(n){return Hu(t.invert(n))},r.domain=function(n){return arguments.length?(t.domain(n),r):t.domain().map(Hu)},r.nice=function(t){return r.domain(wi(r.domain(),function(){return t}))},r.ticks=function(e,i){var u=Fu(r.domain());if("function"!=typeof e){var a=u[1]-u[0],o=a/e,c=$u.bisect(bc,o);if(c==bc.length)return n.year(u,e);if(!c)return t.ticks(e).map(Hu);Math.log(o/bc[c-1])n?[n,e]:[e,n]}function Hu(t){return new Date(t)}function Ru(t){return function(n){for(var e=t.length-1,r=t[e];!r[1](n);)r=t[--e];return r[0](n)}}function Pu(t){var n=new Date(t,0,1);return n.setFullYear(t),n}function Ou(t){var n=t.getFullYear(),e=Pu(n),r=Pu(n+1);return n+(t-e)/(r-e)}function Yu(t){var n=new Date(Date.UTC(t,0,1));return n.setUTCFullYear(t),n}function Uu(t){var n=t.getUTCFullYear(),e=Yu(n),r=Yu(n+1);return n+(t-e)/(r-e)}function Iu(t){return 1===t.length?function(n,e){t(null==n?e:null)}:t}function Vu(t){return t.responseText}function Xu(t){return JSON.parse(t.responseText)}function Zu(t){var n=Ju.createRange();return n.selectNode(Ju.body),n.createContextualFragment(t.responseText)}function Bu(t){return t.responseXML}var $u={version:"3.0.8"};Date.now||(Date.now=function(){return+new Date});var Ju=document,Gu=window;try{Ju.createElement("div").style.setProperty("opacity",0,"")}catch(Ku){var Wu=Gu.CSSStyleDeclaration.prototype,Qu=Wu.setProperty;Wu.setProperty=function(t,n,e){Qu.call(this,t,n+"",e)}}$u.ascending=function(t,n){return n>t?-1:t>n?1:t>=n?0:0/0},$u.descending=function(t,n){return t>n?-1:n>t?1:n>=t?0:0/0},$u.min=function(t,n){var e,r,i=-1,u=t.length;if(1===arguments.length){for(;u>++i&&(null==(e=t[i])||e!=e);)e=void 0;for(;u>++i;)null!=(r=t[i])&&e>r&&(e=r)}else{for(;u>++i&&(null==(e=n.call(t,t[i],i))||e!=e);)e=void 0;for(;u>++i;)null!=(r=n.call(t,t[i],i))&&e>r&&(e=r)}return e},$u.max=function(t,n){var e,r,i=-1,u=t.length;if(1===arguments.length){for(;u>++i&&(null==(e=t[i])||e!=e);)e=void 0;for(;u>++i;)null!=(r=t[i])&&r>e&&(e=r)}else{for(;u>++i&&(null==(e=n.call(t,t[i],i))||e!=e);)e=void 0;for(;u>++i;)null!=(r=n.call(t,t[i],i))&&r>e&&(e=r)}return e},$u.extent=function(t,n){var e,r,i,u=-1,a=t.length;if(1===arguments.length){for(;a>++u&&(null==(e=i=t[u])||e!=e);)e=i=void 0;for(;a>++u;)null!=(r=t[u])&&(e>r&&(e=r),r>i&&(i=r))}else{for(;a>++u&&(null==(e=i=n.call(t,t[u],u))||e!=e);)e=void 0;for(;a>++u;)null!=(r=n.call(t,t[u],u))&&(e>r&&(e=r),r>i&&(i=r))}return[e,i]},$u.sum=function(t,n){var e,r=0,i=t.length,u=-1;if(1===arguments.length)for(;i>++u;)isNaN(e=+t[u])||(r+=e);else for(;i>++u;)isNaN(e=+n.call(t,t[u],u))||(r+=e);return r},$u.mean=function(n,e){var r,i=n.length,u=0,a=-1,o=0;if(1===arguments.length)for(;i>++a;)t(r=n[a])&&(u+=(r-u)/++o);else for(;i>++a;)t(r=e.call(n,n[a],a))&&(u+=(r-u)/++o);return o?u:void 0},$u.quantile=function(t,n){var e=(t.length-1)*n+1,r=Math.floor(e),i=+t[r-1],u=e-r;return u?i+u*(t[r]-i):i},$u.median=function(n,e){return arguments.length>1&&(n=n.map(e)),n=n.filter(t),n.length?$u.quantile(n.sort($u.ascending),.5):void 0},$u.bisector=function(t){return{left:function(n,e,r,i){for(3>arguments.length&&(r=0),4>arguments.length&&(i=n.length);i>r;){var u=r+i>>>1;e>t.call(n,n[u],u)?r=u+1:i=u}return r},right:function(n,e,r,i){for(3>arguments.length&&(r=0),4>arguments.length&&(i=n.length);i>r;){var u=r+i>>>1;t.call(n,n[u],u)>e?i=u:r=u+1}return r}}};var ta=$u.bisector(function(t){return t});$u.bisectLeft=ta.left,$u.bisect=$u.bisectRight=ta.right,$u.shuffle=function(t){for(var n,e,r=t.length;r;)e=0|Math.random()*r--,n=t[r],t[r]=t[e],t[e]=n;return t},$u.permute=function(t,n){for(var e=[],r=-1,i=n.length;i>++r;)e[r]=t[n[r]];return e},$u.zip=function(){if(!(i=arguments.length))return[];for(var t=-1,e=$u.min(arguments,n),r=Array(e);e>++t;)for(var i,u=-1,a=r[t]=Array(i);i>++u;)a[u]=arguments[u][t];return r},$u.transpose=function(t){return $u.zip.apply($u,t)},$u.keys=function(t){var n=[];for(var e in t)n.push(e);return n},$u.values=function(t){var n=[];for(var e in t)n.push(t[e]);return n},$u.entries=function(t){var n=[];for(var e in t)n.push({key:e,value:t[e]});return n},$u.merge=function(t){return Array.prototype.concat.apply([],t)},$u.range=function(t,n,r){if(3>arguments.length&&(r=1,2>arguments.length&&(n=t,t=0)),1/0===(n-t)/r)throw Error("infinite range");var i,u=[],a=e(Math.abs(r)),o=-1;if(t*=a,n*=a,r*=a,0>r)for(;(i=t+r*++o)>n;)u.push(i/a);else for(;n>(i=t+r*++o);)u.push(i/a);return u},$u.map=function(t){var n=new i;for(var e in t)n.set(e,t[e]);return n},r(i,{has:function(t){return na+t in this},get:function(t){return this[na+t]},set:function(t,n){return this[na+t]=n},remove:function(t){return t=na+t,t in this&&delete this[t]},keys:function(){var t=[];return this.forEach(function(n){t.push(n)}),t},values:function(){var t=[];return this.forEach(function(n,e){t.push(e)}),t},entries:function(){var t=[];return this.forEach(function(n,e){t.push({key:n,value:e})}),t},forEach:function(t){for(var n in this)n.charCodeAt(0)===ea&&t.call(this,n.substring(1),this[n])}});var na="\0",ea=na.charCodeAt(0);$u.nest=function(){function t(n,o,c){if(c>=a.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,f,s,h,g=-1,p=o.length,d=a[c++],m=new i;p>++g;)(h=m.get(l=d(f=o[g])))?h.push(f):m.set(l,[f]);return n?(f=n(),s=function(e,r){f.set(e,t(n,r,c))}):(f={},s=function(e,r){f[e]=t(n,r,c)}),m.forEach(s),f}function n(t,e){if(e>=a.length)return t;var r=[],i=o[e++];return t.forEach(function(t,i){r.push({key:t,values:n(i,e)})}),i?r.sort(function(t,n){return i(t.key,n.key)}):r}var e,r,u={},a=[],o=[];return u.map=function(n,e){return t(e,n,0)},u.entries=function(e){return n(t($u.map,e,0),0)},u.key=function(t){return a.push(t),u},u.sortKeys=function(t){return o[a.length-1]=t,u},u.sortValues=function(t){return e=t,u},u.rollup=function(t){return r=t,u},u},$u.set=function(t){var n=new u;if(t)for(var e=0;t.length>e;e++)n.add(t[e]);return n},r(u,{has:function(t){return na+t in this},add:function(t){return this[na+t]=!0,t},remove:function(t){return t=na+t,t in this&&delete this[t]},values:function(){var t=[];return this.forEach(function(n){t.push(n)}),t},forEach:function(t){for(var n in this)n.charCodeAt(0)===ea&&t.call(this,n.substring(1))}}),$u.behavior={},$u.rebind=function(t,n){for(var e,r=1,i=arguments.length;i>++r;)t[e=arguments[r]]=a(t,n,n[e]);return t},$u.dispatch=function(){for(var t=new o,n=-1,e=arguments.length;e>++n;)t[arguments[n]]=c(t);return t},o.prototype.on=function(t,n){var e=t.indexOf("."),r="";if(e>=0&&(r=t.substring(e+1),t=t.substring(0,e)),t)return 2>arguments.length?this[t].on(r):this[t].on(r,n);if(2===arguments.length){if(null==n)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},$u.event=null,$u.behavior.drag=function(){function t(){this.on("mousedown.drag",n).on("touchstart.drag",n)}function n(){function t(){var t=o.parentNode;return null!=s?$u.touches(t).filter(function(t){return t.identifier===s})[0]:$u.mouse(t)}function n(){if(!o.parentNode)return i();var n=t(),e=n[0]-h[0],r=n[1]-h[1];g|=e|r,h=n,l(),c({type:"drag",x:n[0]+a[0],y:n[1]+a[1],dx:e,dy:r})}function i(){c({type:"dragend"}),g&&(l(),$u.event.target===f&&p.on("click.drag",u,!0)),p.on(null!=s?"touchmove.drag-"+s:"mousemove.drag",null).on(null!=s?"touchend.drag-"+s:"mouseup.drag",null)}function u(){l(),p.on("click.drag",null)}var a,o=this,c=e.of(o,arguments),f=$u.event.target,s=$u.event.touches?$u.event.changedTouches[0].identifier:null,h=t(),g=0,p=$u.select(Gu).on(null!=s?"touchmove.drag-"+s:"mousemove.drag",n).on(null!=s?"touchend.drag-"+s:"mouseup.drag",i,!0);r?(a=r.apply(o,arguments),a=[a.x-h[0],a.y-h[1]]):a=[0,0],null==s&&l(),c({type:"dragstart"})}var e=s(t,"drag","dragstart","dragend"),r=null;return t.origin=function(n){return arguments.length?(r=n,t):r},$u.rebind(t,e,"on")},$u.mouse=function(t){return h(t,f())};var ra=/WebKit/.test(Gu.navigator.userAgent)?-1:0,ia=p;try{ia(Ju.documentElement.childNodes)[0].nodeType}catch(ua){ia=g}var aa=[].__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};$u.touches=function(t,n){return 2>arguments.length&&(n=f().touches),n?ia(n).map(function(n){var e=h(t,n);return e.identifier=n.identifier,e}):[]};var oa={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};$u.ns={prefix:oa,qualify:function(t){var n=t.indexOf(":"),e=t;return n>=0&&(e=t.substring(0,n),t=t.substring(n+1)),oa.hasOwnProperty(e)?{space:oa[e],local:t}:t}};var ca=function(t,n){return n.querySelector(t)},la=function(t,n){return n.querySelectorAll(t)},fa=Ju.documentElement,sa=fa.matchesSelector||fa.webkitMatchesSelector||fa.mozMatchesSelector||fa.msMatchesSelector||fa.oMatchesSelector,ha=function(t,n){return sa.call(t,n)};"function"==typeof Sizzle&&(ca=function(t,n){return Sizzle(t,n)[0]||null},la=function(t,n){return Sizzle.uniqueSort(Sizzle(t,n))},ha=Sizzle.matchesSelector);var ga=[];$u.selection=function(){return ma},$u.selection.prototype=ga,ga.select=function(t){var n,e,r,i,u=[];"function"!=typeof t&&(t=m(t));for(var a=-1,o=this.length;o>++a;){u.push(n=[]),n.parentNode=(r=this[a]).parentNode;for(var c=-1,l=r.length;l>++c;)(i=r[c])?(n.push(e=t.call(i,i.__data__,c)),e&&"__data__"in i&&(e.__data__=i.__data__)):n.push(null)}return d(u)},ga.selectAll=function(t){var n,e,r=[];"function"!=typeof t&&(t=v(t));for(var i=-1,u=this.length;u>++i;)for(var a=this[i],o=-1,c=a.length;c>++o;)(e=a[o])&&(r.push(n=ia(t.call(e,e.__data__,o))),n.parentNode=e);return d(r)},ga.attr=function(t,n){if(2>arguments.length){if("string"==typeof t){var e=this.node();return t=$u.ns.qualify(t),t.local?e.getAttributeNS(t.space,t.local):e.getAttribute(t)}for(n in t)this.each(y(n,t[n]));return this}return this.each(y(t,n))},$u.requote=function(t){return t.replace(pa,"\\$&")};var pa=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;ga.classed=function(t,n){if(2>arguments.length){if("string"==typeof t){var e=this.node(),r=(t=t.trim().split(/^|\s+/g)).length,i=-1;if(n=e.classList){for(;r>++i;)if(!n.contains(t[i]))return!1}else for(n=e.className,null!=n.baseVal&&(n=n.baseVal);r>++i;)if(!x(t[i]).test(n))return!1;return!0}for(n in t)this.each(_(n,t[n]));return this}return this.each(_(t,n))},ga.style=function(t,n,e){var r=arguments.length;if(3>r){if("string"!=typeof t){2>r&&(n="");for(e in t)this.each(S(e,t[e],n));return this}if(2>r)return Gu.getComputedStyle(this.node(),null).getPropertyValue(t);e=""}return this.each(S(t,n,e))},ga.property=function(t,n){if(2>arguments.length){if("string"==typeof t)return this.node()[t];for(n in t)this.each(E(n,t[n]));return this}return this.each(E(t,n))},ga.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},ga.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments); -this.innerHTML=null==n?"":n}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},ga.append=function(t){function n(){return this.appendChild(Ju.createElementNS(this.namespaceURI,t))}function e(){return this.appendChild(Ju.createElementNS(t.space,t.local))}return t=$u.ns.qualify(t),this.select(t.local?e:n)},ga.insert=function(t,n){function e(e,r){return this.insertBefore(Ju.createElementNS(this.namespaceURI,t),n.call(this,e,r))}function r(e,r){return this.insertBefore(Ju.createElementNS(t.space,t.local),n.call(this,e,r))}return t=$u.ns.qualify(t),"function"!=typeof n&&(n=m(n)),this.select(t.local?r:e)},ga.remove=function(){return this.each(function(){var t=this.parentNode;t&&t.removeChild(this)})},ga.data=function(t,n){function e(t,e){var r,u,a,o=t.length,s=e.length,h=Math.min(o,s),g=Array(s),p=Array(s),d=Array(o);if(n){var m,v=new i,y=new i,M=[];for(r=-1;o>++r;)m=n.call(u=t[r],u.__data__,r),v.has(m)?d[r]=u:v.set(m,u),M.push(m);for(r=-1;s>++r;)m=n.call(e,a=e[r],r),(u=v.get(m))?(g[r]=u,u.__data__=a):y.has(m)||(p[r]=k(a)),y.set(m,a),v.remove(m);for(r=-1;o>++r;)v.has(M[r])&&(d[r]=t[r])}else{for(r=-1;h>++r;)u=t[r],a=e[r],u?(u.__data__=a,g[r]=u):p[r]=k(a);for(;s>r;++r)p[r]=k(e[r]);for(;o>r;++r)d[r]=t[r]}p.update=g,p.parentNode=g.parentNode=d.parentNode=t.parentNode,c.push(p),l.push(g),f.push(d)}var r,u,a=-1,o=this.length;if(!arguments.length){for(t=Array(o=(r=this[0]).length);o>++a;)(u=r[a])&&(t[a]=u.__data__);return t}var c=D([]),l=d([]),f=d([]);if("function"==typeof t)for(;o>++a;)e(r=this[a],t.call(r,r.parentNode.__data__,a));else for(;o>++a;)e(r=this[a],t);return l.enter=function(){return c},l.exit=function(){return f},l},ga.datum=function(t){return arguments.length?this.property("__data__",t):this.property("__data__")},ga.filter=function(t){var n,e,r,i=[];"function"!=typeof t&&(t=A(t));for(var u=0,a=this.length;a>u;u++){i.push(n=[]),n.parentNode=(e=this[u]).parentNode;for(var o=0,c=e.length;c>o;o++)(r=e[o])&&t.call(r,r.__data__,o)&&n.push(r)}return d(i)},ga.order=function(){for(var t=-1,n=this.length;n>++t;)for(var e,r=this[t],i=r.length-1,u=r[i];--i>=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},ga.sort=function(t){t=N.apply(this,arguments);for(var n=-1,e=this.length;e>++n;)this[n].sort(t);return this.order()},ga.on=function(t,n,e){var r=arguments.length;if(3>r){if("string"!=typeof t){2>r&&(n=!1);for(e in t)this.each(q(e,t[e],n));return this}if(2>r)return(r=this.node()["__on"+t])&&r._;e=!1}return this.each(q(t,n,e))};var da=$u.map({mouseenter:"mouseover",mouseleave:"mouseout"});da.forEach(function(t){"on"+t in document&&da.remove(t)}),ga.each=function(t){return z(this,function(n,e,r){t.call(n,n.__data__,e,r)})},ga.call=function(t){var n=ia(arguments);return t.apply(n[0]=this,n),this},ga.empty=function(){return!this.node()},ga.node=function(){for(var t=0,n=this.length;n>t;t++)for(var e=this[t],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null};var ma=d([[Ju]]);ma[0].parentNode=fa,$u.select=function(t){return"string"==typeof t?ma.select(t):d([[t]])},$u.selectAll=function(t){return"string"==typeof t?ma.selectAll(t):d([ia(t)])};var va=[];$u.selection.enter=D,$u.selection.enter.prototype=va,va.append=ga.append,va.insert=ga.insert,va.empty=ga.empty,va.node=ga.node,va.select=function(t){for(var n,e,r,i,u,a=[],o=-1,c=this.length;c>++o;){r=(i=this[o]).update,a.push(n=[]),n.parentNode=i.parentNode;for(var l=-1,f=i.length;f>++l;)(u=i[l])?(n.push(r[l]=e=t.call(i.parentNode,u.__data__,l)),e.__data__=u.__data__):n.push(null)}return d(a)},$u.behavior.zoom=function(){function t(){this.on("mousedown.zoom",o).on("mousemove.zoom",f).on(ba+".zoom",c).on("dblclick.zoom",h).on("touchstart.zoom",g).on("touchmove.zoom",p).on("touchend.zoom",g)}function n(t){return[(t[0]-_[0])/w,(t[1]-_[1])/w]}function e(t){return[t[0]*w+_[0],t[1]*w+_[1]]}function r(t){w=Math.max(S[0],Math.min(S[1],t))}function i(t,n){n=e(n),_[0]+=t[0]-n[0],_[1]+=t[1]-n[1]}function u(){y&&y.domain(v.range().map(function(t){return(t-_[0])/w}).map(v.invert)),b&&b.domain(M.range().map(function(t){return(t-_[1])/w}).map(M.invert))}function a(t){u(),$u.event.preventDefault(),t({type:"zoom",scale:w,translate:_})}function o(){function t(){f=1,i($u.mouse(u),h),a(o)}function e(){f&&l(),s.on("mousemove.zoom",null).on("mouseup.zoom",null),f&&$u.event.target===c&&s.on("click.zoom",r,!0)}function r(){l(),s.on("click.zoom",null)}var u=this,o=E.of(u,arguments),c=$u.event.target,f=0,s=$u.select(Gu).on("mousemove.zoom",t).on("mouseup.zoom",e),h=n($u.mouse(u));Gu.focus(),l()}function c(){d||(d=n($u.mouse(this))),r(Math.pow(2,.002*ya())*w),i($u.mouse(this),d),a(E.of(this,arguments))}function f(){d=null}function h(){var t=$u.mouse(this),e=n(t),u=Math.log(w)/Math.LN2;r(Math.pow(2,$u.event.shiftKey?Math.ceil(u)-1:Math.floor(u)+1)),i(t,e),a(E.of(this,arguments))}function g(){var t=$u.touches(this),e=Date.now();if(m=w,d={},t.forEach(function(t){d[t.identifier]=n(t)}),l(),1===t.length){if(500>e-x){var u=t[0],o=n(t[0]);r(2*w),i(u,o),a(E.of(this,arguments))}x=e}}function p(){var t=$u.touches(this),n=t[0],e=d[n.identifier];if(u=t[1]){var u,o=d[u.identifier];n=[(n[0]+u[0])/2,(n[1]+u[1])/2],e=[(e[0]+o[0])/2,(e[1]+o[1])/2],r($u.event.scale*m)}i(n,e),x=null,a(E.of(this,arguments))}var d,m,v,y,M,b,x,_=[0,0],w=1,S=Ma,E=s(t,"zoom");return t.translate=function(n){return arguments.length?(_=n.map(Number),u(),t):_},t.scale=function(n){return arguments.length?(w=+n,u(),t):w},t.scaleExtent=function(n){return arguments.length?(S=null==n?Ma:n.map(Number),t):S},t.x=function(n){return arguments.length?(y=n,v=n.copy(),_=[0,0],w=1,t):y},t.y=function(n){return arguments.length?(b=n,M=n.copy(),_=[0,0],w=1,t):b},$u.rebind(t,E,"on")};var ya,Ma=[0,1/0],ba="onwheel"in document?(ya=function(){return-$u.event.deltaY*($u.event.deltaMode?120:1)},"wheel"):"onmousewheel"in document?(ya=function(){return $u.event.wheelDelta},"mousewheel"):(ya=function(){return-$u.event.detail},"MozMousePixelScroll");j.prototype.toString=function(){return this.rgb()+""},$u.hsl=function(t,n,e){return 1===arguments.length?t instanceof F?L(t.h,t.s,t.l):rn(""+t,un,L):L(+t,+n,+e)};var xa=F.prototype=new j;xa.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),L(this.h,this.s,this.l/t)},xa.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),L(this.h,this.s,t*this.l)},xa.rgb=function(){return H(this.h,this.s,this.l)};var _a=Math.PI,wa=1e-6,Sa=_a/180,Ea=180/_a;$u.hcl=function(t,n,e){return 1===arguments.length?t instanceof X?V(t.h,t.c,t.l):t instanceof $?G(t.l,t.a,t.b):G((t=an((t=$u.rgb(t)).r,t.g,t.b)).l,t.a,t.b):V(+t,+n,+e)};var ka=X.prototype=new j;ka.brighter=function(t){return V(this.h,this.c,Math.min(100,this.l+Aa*(arguments.length?t:1)))},ka.darker=function(t){return V(this.h,this.c,Math.max(0,this.l-Aa*(arguments.length?t:1)))},ka.rgb=function(){return Z(this.h,this.c,this.l).rgb()},$u.lab=function(t,n,e){return 1===arguments.length?t instanceof $?B(t.l,t.a,t.b):t instanceof X?Z(t.l,t.c,t.h):an((t=$u.rgb(t)).r,t.g,t.b):B(+t,+n,+e)};var Aa=18,Na=.95047,qa=1,Ta=1.08883,Ca=$.prototype=new j;Ca.brighter=function(t){return B(Math.min(100,this.l+Aa*(arguments.length?t:1)),this.a,this.b)},Ca.darker=function(t){return B(Math.max(0,this.l-Aa*(arguments.length?t:1)),this.a,this.b)},Ca.rgb=function(){return J(this.l,this.a,this.b)},$u.rgb=function(t,n,e){return 1===arguments.length?t instanceof nn?tn(t.r,t.g,t.b):rn(""+t,tn,H):tn(~~t,~~n,~~e)};var za=nn.prototype=new j;za.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var n=this.r,e=this.g,r=this.b,i=30;return n||e||r?(n&&i>n&&(n=i),e&&i>e&&(e=i),r&&i>r&&(r=i),tn(Math.min(255,Math.floor(n/t)),Math.min(255,Math.floor(e/t)),Math.min(255,Math.floor(r/t)))):tn(i,i,i)},za.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),tn(Math.floor(t*this.r),Math.floor(t*this.g),Math.floor(t*this.b))},za.hsl=function(){return un(this.r,this.g,this.b)},za.toString=function(){return"#"+en(this.r)+en(this.g)+en(this.b)};var Da=$u.map({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});Da.forEach(function(t,n){Da.set(t,rn(n,tn,H))}),$u.functor=ln,$u.csv=fn(",","text/csv"),$u.tsv=fn(" ","text/tab-separated-values");var ja,La,Fa=0,Ha={},Ra=null;$u.timer=function(t,n,e){if(3>arguments.length){if(2>arguments.length)n=0;else if(!isFinite(n))return;e=Date.now()}var r=Ha[t.id];r&&r.callback===t?(r.then=e,r.delay=n):Ha[t.id=++Fa]=Ra={callback:t,then:e,delay:n,next:Ra},ja||(La=clearTimeout(La),ja=1,Pa(sn))},$u.timer.flush=function(){for(var t,n=Date.now(),e=Ra;e;)t=n-e.then,e.delay||(e.flush=e.callback(t)),e=e.next;hn()};var Pa=Gu.requestAnimationFrame||Gu.webkitRequestAnimationFrame||Gu.mozRequestAnimationFrame||Gu.oRequestAnimationFrame||Gu.msRequestAnimationFrame||function(t){setTimeout(t,17)},Oa=".",Ya=",",Ua=[3,3],Ia=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(pn);$u.formatPrefix=function(t,n){var e=0;return t&&(0>t&&(t*=-1),n&&(t=$u.round(t,dn(t,n))),e=1+Math.floor(1e-12+Math.log(t)/Math.LN10),e=Math.max(-24,Math.min(24,3*Math.floor((0>=e?e+1:e-1)/3)))),Ia[8+e/3]},$u.round=function(t,n){return n?Math.round(t*(n=Math.pow(10,n)))/n:Math.round(t)},$u.format=function(t){var n=Va.exec(t),e=n[1]||" ",r=n[2]||">",i=n[3]||"",u=n[4]||"",a=n[5],o=+n[6],c=n[7],l=n[8],f=n[9],s=1,h="",g=!1;switch(l&&(l=+l.substring(1)),(a||"0"===e&&"="===r)&&(a=e="0",r="=",c&&(o-=Math.floor((o-1)/4))),f){case"n":c=!0,f="g";break;case"%":s=100,h="%",f="f";break;case"p":s=100,h="%",f="r";break;case"b":case"o":case"x":case"X":u&&(u="0"+f.toLowerCase());case"c":case"d":g=!0,l=0;break;case"s":s=-1,f="r"}"#"===u&&(u=""),"r"!=f||l||(f="g"),null!=l&&("g"==f?l=Math.max(1,Math.min(21,l)):("e"==f||"f"==f)&&(l=Math.max(0,Math.min(20,l)))),f=Xa.get(f)||mn;var p=a&&c;return function(t){if(g&&t%1)return"";var n=0>t||0===t&&0>1/t?(t=-t,"-"):i;if(0>s){var d=$u.formatPrefix(t,l);t=d.scale(t),h=d.symbol}else t*=s;t=f(t,l),!a&&c&&(t=Za(t));var m=u.length+t.length+(p?0:n.length),v=o>m?Array(m=o-m+1).join(e):"";return p&&(t=Za(v+t)),Oa&&t.replace(".",Oa),n+=u,("<"===r?n+t+v:">"===r?v+n+t:"^"===r?v.substring(0,m>>=1)+n+t+v.substring(m):n+(p?t:v+t))+h}};var Va=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Xa=$u.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,n){return t.toPrecision(n)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},r:function(t,n){return(t=$u.round(t,dn(t,n))).toFixed(Math.max(0,Math.min(20,dn(t*(1+1e-15),n))))}}),Za=gn;if(Ua){var Ba=Ua.length;Za=function(t){for(var n=t.lastIndexOf("."),e=n>=0?"."+t.substring(n+1):(n=t.length,""),r=[],i=0,u=Ua[0];n>0&&u>0;)r.push(t.substring(n-=u,n+u)),u=Ua[i=(i+1)%Ba];return r.reverse().join(Ya||"")+e}}$u.geo={},$u.geo.stream=function(t,n){$a.hasOwnProperty(t.type)?$a[t.type](t,n):yn(t,n)};var $a={Feature:function(t,n){yn(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;i>++r;)yn(e[r].geometry,n)}},Ja={Sphere:function(t,n){n.sphere()},Point:function(t,n){var e=t.coordinates;n.point(e[0],e[1])},MultiPoint:function(t,n){for(var e,r=t.coordinates,i=-1,u=r.length;u>++i;)e=r[i],n.point(e[0],e[1])},LineString:function(t,n){Mn(t.coordinates,n,0)},MultiLineString:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;i>++r;)Mn(e[r],n,0)},Polygon:function(t,n){bn(t.coordinates,n)},MultiPolygon:function(t,n){for(var e=t.coordinates,r=-1,i=e.length;i>++r;)bn(e[r],n)},GeometryCollection:function(t,n){for(var e=t.geometries,r=-1,i=e.length;i>++r;)yn(e[r],n)}};$u.geo.area=function(t){return Ga=0,$u.geo.stream(t,Qa),Ga};var Ga,Ka,Wa,Qa={sphere:function(){Ga+=4*_a},point:vn,lineStart:vn,lineEnd:vn,polygonStart:function(){Ka=1,Wa=0,Qa.lineStart=xn},polygonEnd:function(){var t=2*Math.atan2(Wa,Ka);Ga+=0>t?4*_a+t:t,Qa.lineStart=Qa.lineEnd=Qa.point=vn}};$u.geo.bounds=_n(gn),$u.geo.centroid=function(t){to=no=eo=ro=io=0,$u.geo.stream(t,uo);var n;return no&&Math.abs(n=Math.sqrt(eo*eo+ro*ro+io*io))>wa?[Math.atan2(ro,eo)*Ea,Math.asin(Math.max(-1,Math.min(1,io/n)))*Ea]:void 0};var to,no,eo,ro,io,uo={sphere:function(){2>to&&(to=2,no=eo=ro=io=0)},point:wn,lineStart:En,lineEnd:kn,polygonStart:function(){2>to&&(to=2,no=eo=ro=io=0),uo.lineStart=Sn},polygonEnd:function(){uo.lineStart=En}};$u.geo.rotation=function(t){function n(n){return n=t(n[0]*Sa,n[1]*Sa),n[0]*=Ea,n[1]*=Ea,n}return t=Dn(t[0]%360*Sa,t[1]*Sa,t.length>2?t[2]*Sa:0),n.invert=function(n){return n=t.invert(n[0]*Sa,n[1]*Sa),n[0]*=Ea,n[1]*=Ea,n},n},$u.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,n=Dn(-t[0]*Sa,-t[1]*Sa,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=n(t,e)),t[0]*=Ea,t[1]*=Ea}}),{type:"Polygon",coordinates:[i]}}var n,e,r=[0,0],i=6;return t.origin=function(n){return arguments.length?(r=n,t):r},t.angle=function(r){return arguments.length?(e=Pn((n=+r)*Sa,i*Sa),t):n},t.precision=function(r){return arguments.length?(e=Pn(n*Sa,(i=+r)*Sa),t):i},t.angle(90)},$u.geo.distance=function(t,n){var e,r=(n[0]-t[0])*Sa,i=t[1]*Sa,u=n[1]*Sa,a=Math.sin(r),o=Math.cos(r),c=Math.sin(i),l=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*a)*e+(e=l*f-c*s*o)*e),c*f+l*s*o)},$u.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:n()}}function n(){return $u.range(Math.ceil(u/m)*m,i,m).map(h).concat($u.range(Math.ceil(l/v)*v,c,v).map(g)).concat($u.range(Math.ceil(r/p)*p,e,p).filter(function(t){return Math.abs(t%m)>wa}).map(f)).concat($u.range(Math.ceil(o/d)*d,a,d).filter(function(t){return Math.abs(t%v)>wa}).map(s))}var e,r,i,u,a,o,c,l,f,s,h,g,p=10,d=p,m=90,v=360,y=2.5;return t.lines=function(){return n().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(g(c).slice(1),h(i).reverse().slice(1),g(l).reverse().slice(1))]}},t.extent=function(n){return arguments.length?t.majorExtent(n).minorExtent(n):t.minorExtent()},t.majorExtent=function(n){return arguments.length?(u=+n[0][0],i=+n[1][0],l=+n[0][1],c=+n[1][1],u>i&&(n=u,u=i,i=n),l>c&&(n=l,l=c,c=n),t.precision(y)):[[u,l],[i,c]]},t.minorExtent=function(n){return arguments.length?(r=+n[0][0],e=+n[1][0],o=+n[0][1],a=+n[1][1],r>e&&(n=r,r=e,e=n),o>a&&(n=o,o=a,a=n),t.precision(y)):[[r,o],[e,a]]},t.step=function(n){return arguments.length?t.majorStep(n).minorStep(n):t.minorStep()},t.majorStep=function(n){return arguments.length?(m=+n[0],v=+n[1],t):[m,v]},t.minorStep=function(n){return arguments.length?(p=+n[0],d=+n[1],t):[p,d]},t.precision=function(n){return arguments.length?(y=+n,f=Yn(o,a,90),s=Un(r,e,y),h=Yn(l,c,90),g=Un(u,i,y),t):y},t.majorExtent([[-180,-90+wa],[180,90-wa]]).minorExtent([[-180,-80-wa],[180,80+wa]])},$u.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[n||r.apply(this,arguments),e||i.apply(this,arguments)]}}var n,e,r=In,i=Vn;return t.distance=function(){return $u.geo.distance(n||r.apply(this,arguments),e||i.apply(this,arguments))},t.source=function(e){return arguments.length?(r=e,n="function"==typeof e?null:e,t):r},t.target=function(n){return arguments.length?(i=n,e="function"==typeof n?null:n,t):i},t.precision=function(){return arguments.length?t:0},t},$u.geo.interpolate=function(t,n){return Xn(t[0]*Sa,t[1]*Sa,n[0]*Sa,n[1]*Sa)},$u.geo.length=function(t){return ao=0,$u.geo.stream(t,oo),ao};var ao,oo={sphere:vn,point:vn,lineStart:Zn,lineEnd:vn,polygonStart:vn,polygonEnd:vn},co=Gn(Bn,ne,re);$u.geo.projection=le,$u.geo.projectionMutator=fe,$u.geo.path=function(){function t(t){return t&&$u.geo.stream(t,r(i.pointRadius("function"==typeof u?+u.apply(this,arguments):u))),i.result()}var n,e,r,i,u=4.5;return t.area=function(t){return lo=0,$u.geo.stream(t,r(so)),lo},t.centroid=function(t){return to=eo=ro=io=0,$u.geo.stream(t,r(ho)),io?[eo/io,ro/io]:void 0},t.bounds=function(t){return _n(r)(t)},t.projection=function(e){return arguments.length?(r=(n=e)?e.stream||ge(e):gn,t):n},t.context=function(n){return arguments.length?(i=null==(e=n)?new de:new be(n),t):e},t.pointRadius=function(n){return arguments.length?(u="function"==typeof n?n:+n,t):u},t.projection($u.geo.albersUsa()).context(null)};var lo,fo,so={point:vn,lineStart:vn,lineEnd:vn,polygonStart:function(){fo=0,so.lineStart=pe},polygonEnd:function(){so.lineStart=so.lineEnd=so.point=vn,lo+=Math.abs(fo/2)}},ho={point:me,lineStart:ve,lineEnd:ye,polygonStart:function(){ho.lineStart=Me},polygonEnd:function(){ho.point=me,ho.lineStart=ve,ho.lineEnd=ye}};($u.geo.conicEqualArea=function(){return xe(_e)}).raw=_e,$u.geo.albers=function(){return $u.geo.conicEqualArea().parallels([29.5,45.5]).rotate([98,0]).center([0,38]).scale(1e3)},$u.geo.albersUsa=function(){function t(t){return n(t)(t)}function n(t){var n=t[0],e=t[1];return e>50?a:-140>n?o:21>e?c:u}var e,r,i,u=$u.geo.conicEqualArea().rotate([98,0]).center([0,38]).parallels([29.5,45.5]),a=$u.geo.conicEqualArea().rotate([160,0]).center([0,60]).parallels([55,65]),o=$u.geo.conicEqualArea().rotate([160,0]).center([0,20]).parallels([8,18]),c=$u.geo.conicEqualArea().rotate([60,0]).center([0,10]).parallels([8,18]);return t.invert=function(t){return e(t)||r(t)||i(t)||u.invert(t)},t.scale=function(n){return arguments.length?(u.scale(n),a.scale(.6*n),o.scale(n),c.scale(1.5*n),t.translate(u.translate())):u.scale()},t.translate=function(n){if(!arguments.length)return u.translate();var l=u.scale(),f=n[0],s=n[1];return u.translate(n),a.translate([f-.4*l,s+.17*l]),o.translate([f-.19*l,s+.2*l]),c.translate([f+.58*l,s+.43*l]),e=we(a,[[-180,50],[-130,72]]),r=we(o,[[-164,18],[-154,24]]),i=we(c,[[-67.5,17.5],[-65,19]]),t},t.scale(1e3)};var go=Se(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});($u.geo.azimuthalEqualArea=function(){return le(go)}).raw=go;var po=Se(function(t){var n=Math.acos(t);return n&&n/Math.sin(n)},gn);($u.geo.azimuthalEquidistant=function(){return le(po)}).raw=po,($u.geo.conicConformal=function(){return xe(Ee)}).raw=Ee,($u.geo.conicEquidistant=function(){return xe(ke)}).raw=ke,($u.geo.equirectangular=function(){return le(Ae)}).raw=Ae.invert=Ae;var mo=Se(function(t){return 1/t},Math.atan);($u.geo.gnomonic=function(){return le(mo)}).raw=mo,Ne.invert=function(t,n){return[t,2*Math.atan(Math.exp(n))-_a/2]},($u.geo.mercator=function(){return le(Ne)}).raw=Ne;var vo=Se(function(){return 1},Math.asin);($u.geo.orthographic=function(){return le(vo)}).raw=vo;var yo=Se(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});($u.geo.stereographic=function(){return le(yo)}).raw=yo,qe.invert=function(t,n){return[Math.atan2(Y(t),Math.cos(n)),O(Math.sin(n)/U(t))]},($u.geo.transverseMercator=function(){return le(qe)}).raw=qe,$u.geom={},$u.geom.hull=function(t){if(3>t.length)return[];var n,e,r,i,u,a,o,c,l,f,s=t.length,h=s-1,g=[],p=[],d=0;for(n=1;s>n;++n)t[n][1]n;++n)n!==d&&(i=t[n][1]-t[d][1],r=t[n][0]-t[d][0],g.push({angle:Math.atan2(i,r),index:n}));for(g.sort(function(t,n){return t.angle-n.angle}),l=g[0].angle,c=g[0].index,o=0,n=1;h>n;++n)e=g[n].index,l==g[n].angle?(r=t[c][0]-t[d][0],i=t[c][1]-t[d][1],u=t[e][0]-t[d][0],a=t[e][1]-t[d][1],r*r+i*i>=u*u+a*a?g[n].index=-1:(g[o].index=-1,l=g[n].angle,o=n,c=e)):(l=g[n].angle,o=n,c=e);for(p.push(d),n=0,e=0;2>n;++e)-1!==g[e].index&&(p.push(g[e].index),n++);for(f=p.length;h>e;++e)if(-1!==g[e].index){for(;!Te(p[f-2],p[f-1],g[e].index,t);)--f;p[f++]=g[e].index}var m=[];for(n=0;f>n;++n)m.push(t[p[n]]);return m},$u.geom.polygon=function(t){return t.area=function(){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];e>++n;)r+=t[n-1][1]*t[n][0]-t[n-1][0]*t[n][1];return.5*r},t.centroid=function(n){var e,r,i=-1,u=t.length,a=0,o=0,c=t[u-1];for(arguments.length||(n=-1/(6*t.area()));u>++i;)e=c,c=t[i],r=e[0]*c[1]-c[0]*e[1],a+=(e[0]+c[0])*r,o+=(e[1]+c[1])*r;return[a*n,o*n]},t.clip=function(n){for(var e,r,i,u,a,o,c=-1,l=t.length,f=t[l-1];l>++c;){for(e=n.slice(),n.length=0,u=t[c],a=e[(i=e.length)-1],r=-1;i>++r;)o=e[r],Ce(o,f,u)?(Ce(a,f,u)||n.push(ze(a,o,f,u)),n.push(o)):Ce(a,f,u)&&n.push(ze(a,o,f,u)),a=o;f=u}return n},t},$u.geom.voronoi=function(t){var n=t.map(function(){return[]}),e=1e6;return De(t,function(t){var r,i,u,a,o,c;1===t.a&&t.b>=0?(r=t.ep.r,i=t.ep.l):(r=t.ep.l,i=t.ep.r),1===t.a?(o=r?r.y:-e,u=t.c-t.b*o,c=i?i.y:e,a=t.c-t.b*c):(u=r?r.x:-e,o=t.c-t.a*u,a=i?i.x:e,c=t.c-t.a*a);var l=[u,o],f=[a,c];n[t.region.l.index].push(l,f),n[t.region.r.index].push(l,f)}),n=n.map(function(n,e){var r=t[e][0],i=t[e][1],u=n.map(function(t){return Math.atan2(t[0]-r,t[1]-i)}),a=$u.range(n.length).sort(function(t,n){return u[t]-u[n]});return a.filter(function(t,n){return!n||u[t]-u[a[n-1]]>wa}).map(function(t){return n[t]})}),n.forEach(function(n,r){var i=n.length;if(!i)return n.push([-e,-e],[-e,e],[e,e],[e,-e]);if(!(i>2)){var u=t[r],a=n[0],o=n[1],c=u[0],l=u[1],f=a[0],s=a[1],h=o[0],g=o[1],p=Math.abs(h-f),d=g-s;if(wa>Math.abs(d)){var m=s>l?-e:e;n.push([-e,m],[e,m])}else if(wa>p){var v=f>c?-e:e;n.push([v,-e],[v,e])}else{var m=(f-c)*(g-s)>(h-f)*(s-l)?e:-e,y=Math.abs(d)-p;wa>Math.abs(y)?n.push([0>d?m:-m,m]):(y>0&&(m*=-1),n.push([-e,m],[e,m]))}}}),n};var Mo={l:"r",r:"l"};$u.geom.delaunay=function(t){var n=t.map(function(){return[]}),e=[];return De(t,function(e){n[e.region.l.index].push(t[e.region.r.index])}),n.forEach(function(n,r){var i=t[r],u=i[0],a=i[1];n.forEach(function(t){t.angle=Math.atan2(t[0]-u,t[1]-a)}),n.sort(function(t,n){return t.angle-n.angle});for(var o=0,c=n.length-1;c>o;o++)e.push([i,n[o],n[o+1]])}),e},$u.geom.quadtree=function(t,n,e,r,i){function u(t,n,e,r,i,u){if(!isNaN(n.x)&&!isNaN(n.y))if(t.leaf){var o=t.point;o?.01>Math.abs(o.x-n.x)+Math.abs(o.y-n.y)?a(t,n,e,r,i,u):(t.point=null,a(t,o,e,r,i,u),a(t,n,e,r,i,u)):t.point=n}else a(t,n,e,r,i,u)}function a(t,n,e,r,i,a){var o=.5*(e+i),c=.5*(r+a),l=n.x>=o,f=n.y>=c,s=(f<<1)+l;t.leaf=!1,t=t.nodes[s]||(t.nodes[s]=je()),l?e=o:i=o,f?r=c:a=c,u(t,n,e,r,i,a)}var o,c=-1,l=t.length;if(5>arguments.length)if(3===arguments.length)i=e,r=n,e=n=0;else for(n=e=1/0,r=i=-1/0;l>++c;)o=t[c],n>o.x&&(n=o.x),e>o.y&&(e=o.y),o.x>r&&(r=o.x),o.y>i&&(i=o.y);var f=r-n,s=i-e;f>s?i=e+f:r=n+s;var h=je();return h.add=function(t){u(h,t,n,e,r,i)},h.visit=function(t){Le(t,h,n,e,r,i)},t.forEach(h.add),h};var bo=function(){return gn},xo=$u.map({linear:bo,poly:Ue,quad:function(){return Pe},cubic:function(){return Oe},sin:function(){return Ie},exp:function(){return Ve},circle:function(){return Xe},elastic:Ze,back:Be,bounce:function(){return $e}}),_o=$u.map({"in":gn,out:He,"in-out":Re,"out-in":function(t){return Re(He(t))}});$u.ease=function(t){var n=t.indexOf("-"),e=n>=0?t.substring(0,n):t,r=n>=0?t.substring(n+1):"in";return e=xo.get(e)||bo,r=_o.get(r)||gn,Fe(r(e.apply(null,Array.prototype.slice.call(arguments,1))))},$u.transform=function(t){var n=Ju.createElementNS($u.ns.prefix.svg,"g");return($u.transform=function(t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate();return new Je(e?e.matrix:wo)})(t)},Je.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var wo={a:1,b:0,c:0,d:1,e:0,f:0};$u.interpolate=function(t,n){for(var e,r=$u.interpolators.length;--r>=0&&!(e=$u.interpolators[r](t,n)););return e},$u.interpolateNumber=function(t,n){return n-=t,function(e){return t+n*e}},$u.interpolateRound=function(t,n){return n-=t,function(e){return Math.round(t+n*e)}},$u.interpolateString=function(t,n){var e,r,i,u,a,o=0,c=0,l=[],f=[];for(So.lastIndex=0,r=0;e=So.exec(n);++r)e.index&&l.push(n.substring(o,c=e.index)),f.push({i:l.length,x:e[0]}),l.push(null),o=So.lastIndex;for(n.length>o&&l.push(n.substring(o)),r=0,u=f.length;(e=So.exec(t))&&u>r;++r)if(a=f[r],a.x==e[0]){if(a.i)if(null==l[a.i+1])for(l[a.i-1]+=a.x,l.splice(a.i,1),i=r+1;u>i;++i)f[i].i--;else for(l[a.i-1]+=a.x+l[a.i+1],l.splice(a.i,2),i=r+1;u>i;++i)f[i].i-=2;else if(null==l[a.i+1])l[a.i]=a.x;else for(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1),i=r+1;u>i;++i)f[i].i--;f.splice(r,1),u--,r--}else a.x=$u.interpolateNumber(parseFloat(e[0]),parseFloat(a.x));for(;u>r;)a=f.pop(),null==l[a.i+1]?l[a.i]=a.x:(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1)),u--;return 1===l.length?null==l[0]?f[0].x:function(){return n}:function(t){for(r=0;u>r;++r)l[(a=f[r]).i]=a.x(t);return l.join("")}},$u.interpolateTransform=function(t,n){var e,r=[],i=[],u=$u.transform(t),a=$u.transform(n),o=u.translate,c=a.translate,l=u.rotate,f=a.rotate,s=u.skew,h=a.skew,g=u.scale,p=a.scale;return o[0]!=c[0]||o[1]!=c[1]?(r.push("translate(",null,",",null,")"),i.push({i:1,x:$u.interpolateNumber(o[0],c[0])},{i:3,x:$u.interpolateNumber(o[1],c[1])})):c[0]||c[1]?r.push("translate("+c+")"):r.push(""),l!=f?(l-f>180?f+=360:f-l>180&&(l+=360),i.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:$u.interpolateNumber(l,f)})):f&&r.push(r.pop()+"rotate("+f+")"),s!=h?i.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:$u.interpolateNumber(s,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),i.push({i:e-4,x:$u.interpolateNumber(g[0],p[0])},{i:e-2,x:$u.interpolateNumber(g[1],p[1])})):(1!=p[0]||1!=p[1])&&r.push(r.pop()+"scale("+p+")"),e=i.length,function(t){for(var n,u=-1;e>++u;)r[(n=i[u]).i]=n.x(t);return r.join("")}},$u.interpolateRgb=function(t,n){t=$u.rgb(t),n=$u.rgb(n);var e=t.r,r=t.g,i=t.b,u=n.r-e,a=n.g-r,o=n.b-i;return function(t){return"#"+en(Math.round(e+u*t))+en(Math.round(r+a*t))+en(Math.round(i+o*t))}},$u.interpolateHsl=function(t,n){t=$u.hsl(t),n=$u.hsl(n);var e=t.h,r=t.s,i=t.l,u=n.h-e,a=n.s-r,o=n.l-i;return u>180?u-=360:-180>u&&(u+=360),function(t){return H(e+u*t,r+a*t,i+o*t)+""}},$u.interpolateLab=function(t,n){t=$u.lab(t),n=$u.lab(n);var e=t.l,r=t.a,i=t.b,u=n.l-e,a=n.a-r,o=n.b-i;return function(t){return J(e+u*t,r+a*t,i+o*t)+""}},$u.interpolateHcl=function(t,n){t=$u.hcl(t),n=$u.hcl(n);var e=t.h,r=t.c,i=t.l,u=n.h-e,a=n.c-r,o=n.l-i;return u>180?u-=360:-180>u&&(u+=360),function(t){return Z(e+u*t,r+a*t,i+o*t)+""}},$u.interpolateArray=function(t,n){var e,r=[],i=[],u=t.length,a=n.length,o=Math.min(t.length,n.length);for(e=0;o>e;++e)r.push($u.interpolate(t[e],n[e]));for(;u>e;++e)i[e]=t[e];for(;a>e;++e)i[e]=n[e];return function(t){for(e=0;o>e;++e)i[e]=r[e](t);return i}},$u.interpolateObject=function(t,n){var e,r={},i={};for(e in t)e in n?r[e]=Qe(e)(t[e],n[e]):i[e]=t[e];for(e in n)e in t||(i[e]=n[e]);return function(t){for(e in r)i[e]=r[e](t);return i}};var So=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;$u.interpolators=[$u.interpolateObject,function(t,n){return Array.isArray(n)&&$u.interpolateArray(t,n)},function(t,n){return("string"==typeof t||"string"==typeof n)&&$u.interpolateString(t+"",n+"")},function(t,n){return("string"==typeof n?Da.has(n)||/^(#|rgb\(|hsl\()/.test(n):n instanceof j)&&$u.interpolateRgb(t,n)},function(t,n){return!isNaN(t=+t)&&!isNaN(n=+n)&&$u.interpolateNumber(t,n)}],$u.layout={},$u.layout.bundle=function(){return function(t){for(var n=[],e=-1,r=t.length;r>++e;)n.push(tr(t[e]));return n}},$u.layout.chord=function(){function t(){var t,l,s,h,g,p={},d=[],m=$u.range(u),v=[];for(e=[],r=[],t=0,h=-1;u>++h;){for(l=0,g=-1;u>++g;)l+=i[h][g];d.push(l),v.push($u.range(u)),t+=l}for(a&&m.sort(function(t,n){return a(d[t],d[n])}),o&&v.forEach(function(t,n){t.sort(function(t,e){return o(i[n][t],i[n][e])})}),t=(2*_a-f*u)/t,l=0,h=-1;u>++h;){for(s=l,g=-1;u>++g;){var y=m[h],M=v[y][g],b=i[y][M],x=l,_=l+=b*t;p[y+"-"+M]={index:y,subindex:M,startAngle:x,endAngle:_,value:b}}r[y]={index:y,startAngle:s,endAngle:l,value:(l-s)/t},l+=f}for(h=-1;u>++h;)for(g=h-1;u>++g;){var w=p[h+"-"+g],S=p[g+"-"+h];(w.value||S.value)&&e.push(w.value(i-e)*o){var c=n.charge*o*o;return t.px-=u*c,t.py-=a*c,!0}if(n.point&&isFinite(o)){var c=n.pointCharge*o*o;t.px-=u*c,t.py-=a*c}}return!n.charge}}function n(t){t.px=$u.event.x,t.py=$u.event.y,o.resume()}var e,r,i,u,a,o={},c=$u.dispatch("start","tick","end"),l=[1,1],f=.9,s=Eo,h=ko,g=-30,p=.1,d=.8,m=[],v=[];return o.tick=function(){if(.005>(r*=.99))return c.end({type:"end",alpha:r=0}),!0;var n,e,o,s,h,d,y,M,b,x=m.length,_=v.length;for(e=0;_>e;++e)o=v[e],s=o.source,h=o.target,M=h.x-s.x,b=h.y-s.y,(d=M*M+b*b)&&(d=r*u[e]*((d=Math.sqrt(d))-i[e])/d,M*=d,b*=d,h.x-=M*(y=s.weight/(h.weight+s.weight)),h.y-=b*y,s.x+=M*(y=1-y),s.y+=b*y);if((y=r*p)&&(M=l[0]/2,b=l[1]/2,e=-1,y))for(;x>++e;)o=m[e],o.x+=(M-o.x)*y,o.y+=(b-o.y)*y; -if(g)for(or(n=$u.geom.quadtree(m),r,a),e=-1;x>++e;)(o=m[e]).fixed||n.visit(t(o));for(e=-1;x>++e;)o=m[e],o.fixed?(o.x=o.px,o.y=o.py):(o.x-=(o.px-(o.px=o.x))*f,o.y-=(o.py-(o.py=o.y))*f);c.tick({type:"tick",alpha:r})},o.nodes=function(t){return arguments.length?(m=t,o):m},o.links=function(t){return arguments.length?(v=t,o):v},o.size=function(t){return arguments.length?(l=t,o):l},o.linkDistance=function(t){return arguments.length?(s="function"==typeof t?t:+t,o):s},o.distance=o.linkDistance,o.linkStrength=function(t){return arguments.length?(h="function"==typeof t?t:+t,o):h},o.friction=function(t){return arguments.length?(f=+t,o):f},o.charge=function(t){return arguments.length?(g="function"==typeof t?t:+t,o):g},o.gravity=function(t){return arguments.length?(p=+t,o):p},o.theta=function(t){return arguments.length?(d=+t,o):d},o.alpha=function(t){return arguments.length?(t=+t,r?r=t>0?t:0:t>0&&(c.start({type:"start",alpha:r=t}),$u.timer(o.tick)),o):r},o.start=function(){function t(t,r){for(var i,u=n(e),a=-1,o=u.length;o>++a;)if(!isNaN(i=u[a][t]))return i;return Math.random()*r}function n(){if(!c){for(c=[],r=0;p>r;++r)c[r]=[];for(r=0;d>r;++r){var t=v[r];c[t.source.index].push(t.target),c[t.target.index].push(t.source)}}return c[e]}var e,r,c,f,p=m.length,d=v.length,y=l[0],M=l[1];for(e=0;p>e;++e)(f=m[e]).index=e,f.weight=0;for(e=0;d>e;++e)f=v[e],"number"==typeof f.source&&(f.source=m[f.source]),"number"==typeof f.target&&(f.target=m[f.target]),++f.source.weight,++f.target.weight;for(e=0;p>e;++e)f=m[e],isNaN(f.x)&&(f.x=t("x",y)),isNaN(f.y)&&(f.y=t("y",M)),isNaN(f.px)&&(f.px=f.x),isNaN(f.py)&&(f.py=f.y);if(i=[],"function"==typeof s)for(e=0;d>e;++e)i[e]=+s.call(this,v[e],e);else for(e=0;d>e;++e)i[e]=s;if(u=[],"function"==typeof h)for(e=0;d>e;++e)u[e]=+h.call(this,v[e],e);else for(e=0;d>e;++e)u[e]=h;if(a=[],"function"==typeof g)for(e=0;p>e;++e)a[e]=+g.call(this,m[e],e);else for(e=0;p>e;++e)a[e]=g;return o.resume()},o.resume=function(){return o.alpha(.1)},o.stop=function(){return o.alpha(0)},o.drag=function(){return e||(e=$u.behavior.drag().origin(gn).on("dragstart.force",rr).on("drag.force",n).on("dragend.force",ir)),arguments.length?(this.on("mouseover.force",ur).on("mouseout.force",ar).call(e),void 0):e},$u.rebind(o,c,"on")};var Eo=20,ko=1;$u.layout.hierarchy=function(){function t(n,a,o){var c=i.call(e,n,a);if(n.depth=a,o.push(n),c&&(l=c.length)){for(var l,f,s=-1,h=n.children=[],g=0,p=a+1;l>++s;)f=t(c[s],p,o),f.parent=n,h.push(f),g+=f.value;r&&h.sort(r),u&&(n.value=g)}else u&&(n.value=+u.call(e,n,a)||0);return n}function n(t,r){var i=t.children,a=0;if(i&&(o=i.length))for(var o,c=-1,l=r+1;o>++c;)a+=n(i[c],l);else u&&(a=+u.call(e,t,r)||0);return u&&(t.value=a),a}function e(n){var e=[];return t(n,0,e),e}var r=sr,i=lr,u=fr;return e.sort=function(t){return arguments.length?(r=t,e):r},e.children=function(t){return arguments.length?(i=t,e):i},e.value=function(t){return arguments.length?(u=t,e):u},e.revalue=function(t){return n(t,0),t},e},$u.layout.partition=function(){function t(n,e,r,i){var u=n.children;if(n.x=e,n.y=n.depth*i,n.dx=r,n.dy=i,u&&(a=u.length)){var a,o,c,l=-1;for(r=n.value?r/n.value:0;a>++l;)t(o=u[l],e,c=o.value*r,i),e+=c}}function n(t){var e=t.children,r=0;if(e&&(i=e.length))for(var i,u=-1;i>++u;)r=Math.max(r,n(e[u]));return 1+r}function e(e,u){var a=r.call(this,e,u);return t(a[0],0,i[0],i[1]/n(a[0])),a}var r=$u.layout.hierarchy(),i=[1,1];return e.size=function(t){return arguments.length?(i=t,e):i},cr(e,r)},$u.layout.pie=function(){function t(u){var a=u.map(function(e,r){return+n.call(t,e,r)}),o=+("function"==typeof r?r.apply(this,arguments):r),c=(("function"==typeof i?i.apply(this,arguments):i)-r)/$u.sum(a),l=$u.range(u.length);null!=e&&l.sort(e===Ao?function(t,n){return a[n]-a[t]}:function(t,n){return e(u[t],u[n])});var f=[];return l.forEach(function(t){var n;f[t]={data:u[t],value:n=a[t],startAngle:o,endAngle:o+=n*c}}),f}var n=Number,e=Ao,r=0,i=2*_a;return t.value=function(e){return arguments.length?(n=e,t):n},t.sort=function(n){return arguments.length?(e=n,t):e},t.startAngle=function(n){return arguments.length?(r=n,t):r},t.endAngle=function(n){return arguments.length?(i=n,t):i},t};var Ao={};$u.layout.stack=function(){function t(o,c){var l=o.map(function(e,r){return n.call(t,e,r)}),f=l.map(function(n){return n.map(function(n,e){return[u.call(t,n,e),a.call(t,n,e)]})}),s=e.call(t,f,c);l=$u.permute(l,s),f=$u.permute(f,s);var h,g,p,d=r.call(t,f,c),m=l.length,v=l[0].length;for(g=0;v>g;++g)for(i.call(t,l[0][g],p=d[g],f[0][g][1]),h=1;m>h;++h)i.call(t,l[h][g],p+=f[h-1][g][1],f[h][g][1]);return o}var n=gn,e=mr,r=vr,i=dr,u=gr,a=pr;return t.values=function(e){return arguments.length?(n=e,t):n},t.order=function(n){return arguments.length?(e="function"==typeof n?n:No.get(n)||mr,t):e},t.offset=function(n){return arguments.length?(r="function"==typeof n?n:qo.get(n)||vr,t):r},t.x=function(n){return arguments.length?(u=n,t):u},t.y=function(n){return arguments.length?(a=n,t):a},t.out=function(n){return arguments.length?(i=n,t):i},t};var No=$u.map({"inside-out":function(t){var n,e,r=t.length,i=t.map(yr),u=t.map(Mr),a=$u.range(r).sort(function(t,n){return i[t]-i[n]}),o=0,c=0,l=[],f=[];for(n=0;r>n;++n)e=a[n],c>o?(o+=u[e],l.push(e)):(c+=u[e],f.push(e));return f.reverse().concat(l)},reverse:function(t){return $u.range(t.length).reverse()},"default":mr}),qo=$u.map({silhouette:function(t){var n,e,r,i=t.length,u=t[0].length,a=[],o=0,c=[];for(e=0;u>e;++e){for(n=0,r=0;i>n;n++)r+=t[n][e][1];r>o&&(o=r),a.push(r)}for(e=0;u>e;++e)c[e]=(o-a[e])/2;return c},wiggle:function(t){var n,e,r,i,u,a,o,c,l,f=t.length,s=t[0],h=s.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(n=0,i=0;f>n;++n)i+=t[n][e][1];for(n=0,u=0,o=s[e][0]-s[e-1][0];f>n;++n){for(r=0,a=(t[n][e][1]-t[n][e-1][1])/(2*o);n>r;++r)a+=(t[r][e][1]-t[r][e-1][1])/o;u+=a*t[n][e][1]}g[e]=c-=i?u/i*o:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(t){var n,e,r,i=t.length,u=t[0].length,a=1/i,o=[];for(e=0;u>e;++e){for(n=0,r=0;i>n;n++)r+=t[n][e][1];if(r)for(n=0;i>n;n++)t[n][e][1]/=r;else for(n=0;i>n;n++)t[n][e][1]=a}for(e=0;u>e;++e)o[e]=0;return o},zero:vr});$u.layout.histogram=function(){function t(t,u){for(var a,o,c=[],l=t.map(e,this),f=r.call(this,l,u),s=i.call(this,f,l,u),u=-1,h=l.length,g=s.length-1,p=n?1:1/h;g>++u;)a=c[u]=[],a.dx=s[u+1]-(a.x=s[u]),a.y=0;if(g>0)for(u=-1;h>++u;)o=l[u],o>=f[0]&&f[1]>=o&&(a=c[$u.bisect(s,o,1,g)-1],a.y+=p,a.push(t[u]));return c}var n=!0,e=Number,r=wr,i=xr;return t.value=function(n){return arguments.length?(e=n,t):e},t.range=function(n){return arguments.length?(r=ln(n),t):r},t.bins=function(n){return arguments.length?(i="number"==typeof n?function(t){return _r(t,n)}:ln(n),t):i},t.frequency=function(e){return arguments.length?(n=!!e,t):n},t},$u.layout.tree=function(){function t(t,i){function u(t,n){var r=t.children,i=t._tree;if(r&&(a=r.length)){for(var a,c,l,f=r[0],s=f,h=-1;a>++h;)l=r[h],u(l,c),s=o(l,c,s),c=l;zr(t);var g=.5*(f._tree.prelim+l._tree.prelim);n?(i.prelim=n._tree.prelim+e(t,n),i.mod=i.prelim-g):i.prelim=g}else n&&(i.prelim=n._tree.prelim+e(t,n))}function a(t,n){t.x=t._tree.prelim+n;var e=t.children;if(e&&(r=e.length)){var r,i=-1;for(n+=t._tree.mod;r>++i;)a(e[i],n)}}function o(t,n,r){if(n){for(var i,u=t,a=t,o=n,c=t.parent.children[0],l=u._tree.mod,f=a._tree.mod,s=o._tree.mod,h=c._tree.mod;o=kr(o),u=Er(u),o&&u;)c=Er(c),a=kr(a),a._tree.ancestor=t,i=o._tree.prelim+s-u._tree.prelim-l+e(o,u),i>0&&(Dr(jr(o,t,r),t,i),l+=i,f+=i),s+=o._tree.mod,l+=u._tree.mod,h+=c._tree.mod,f+=a._tree.mod;o&&!kr(a)&&(a._tree.thread=o,a._tree.mod+=s-f),u&&!Er(c)&&(c._tree.thread=u,c._tree.mod+=l-h,r=t)}return r}var c=n.call(this,t,i),l=c[0];Cr(l,function(t,n){t._tree={ancestor:t,prelim:0,mod:0,change:0,shift:0,number:n?n._tree.number+1:0}}),u(l),a(l,-l._tree.prelim);var f=Ar(l,qr),s=Ar(l,Nr),h=Ar(l,Tr),g=f.x-e(f,s)/2,p=s.x+e(s,f)/2,d=h.depth||1;return Cr(l,function(t){t.x=(t.x-g)/(p-g)*r[0],t.y=t.depth/d*r[1],delete t._tree}),c}var n=$u.layout.hierarchy().sort(null).value(null),e=Sr,r=[1,1];return t.separation=function(n){return arguments.length?(e=n,t):e},t.size=function(n){return arguments.length?(r=n,t):r},cr(t,n)},$u.layout.pack=function(){function t(t,i){var u=n.call(this,t,i),a=u[0];a.x=0,a.y=0,Cr(a,function(t){t.r=Math.sqrt(t.value)}),Cr(a,Pr);var o=r[0],c=r[1],l=Math.max(2*a.r/o,2*a.r/c);if(e>0){var f=e*l/2;Cr(a,function(t){t.r+=f}),Cr(a,Pr),Cr(a,function(t){t.r-=f}),l=Math.max(2*a.r/o,2*a.r/c)}return Ur(a,o/2,c/2,1/l),u}var n=$u.layout.hierarchy().sort(Lr),e=0,r=[1,1];return t.size=function(n){return arguments.length?(r=n,t):r},t.padding=function(n){return arguments.length?(e=+n,t):e},cr(t,n)},$u.layout.cluster=function(){function t(t,i){var u,a=n.call(this,t,i),o=a[0],c=0;Cr(o,function(t){var n=t.children;n&&n.length?(t.x=Xr(n),t.y=Vr(n)):(t.x=u?c+=e(t,u):0,t.y=0,u=t)});var l=Zr(o),f=Br(o),s=l.x-e(l,f)/2,h=f.x+e(f,l)/2;return Cr(o,function(t){t.x=(t.x-s)/(h-s)*r[0],t.y=(1-(o.y?t.y/o.y:1))*r[1]}),a}var n=$u.layout.hierarchy().sort(null).value(null),e=Sr,r=[1,1];return t.separation=function(n){return arguments.length?(e=n,t):e},t.size=function(n){return arguments.length?(r=n,t):r},cr(t,n)},$u.layout.treemap=function(){function t(t,n){for(var e,r,i=-1,u=t.length;u>++i;)r=(e=t[i]).value*(0>n?0:n),e.area=isNaN(r)||0>=r?0:r}function n(e){var u=e.children;if(u&&u.length){var a,o,c,l=s(e),f=[],h=u.slice(),p=1/0,d="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?1&e.depth?l.dy:l.dx:Math.min(l.dx,l.dy);for(t(h,l.dx*l.dy/e.value),f.area=0;(c=h.length)>0;)f.push(a=h[c-1]),f.area+=a.area,"squarify"!==g||p>=(o=r(f,d))?(h.pop(),p=o):(f.area-=f.pop().area,i(f,d,l,!1),d=Math.min(l.dx,l.dy),f.length=f.area=0,p=1/0);f.length&&(i(f,d,l,!0),f.length=f.area=0),u.forEach(n)}}function e(n){var r=n.children;if(r&&r.length){var u,a=s(n),o=r.slice(),c=[];for(t(o,a.dx*a.dy/n.value),c.area=0;u=o.pop();)c.push(u),c.area+=u.area,null!=u.z&&(i(c,u.z?a.dx:a.dy,a,!o.length),c.length=c.area=0);r.forEach(e)}}function r(t,n){for(var e,r=t.area,i=0,u=1/0,a=-1,o=t.length;o>++a;)(e=t[a].area)&&(u>e&&(u=e),e>i&&(i=e));return r*=r,n*=n,r?Math.max(n*i*p/r,r/(n*u*p)):1/0}function i(t,n,e,r){var i,u=-1,a=t.length,o=e.x,l=e.y,f=n?c(t.area/n):0;if(n==e.dx){for((r||f>e.dy)&&(f=e.dy);a>++u;)i=t[u],i.x=o,i.y=l,i.dy=f,o+=i.dx=Math.min(e.x+e.dx-o,f?c(i.area/f):0);i.z=!0,i.dx+=e.x+e.dx-o,e.y+=f,e.dy-=f}else{for((r||f>e.dx)&&(f=e.dx);a>++u;)i=t[u],i.x=o,i.y=l,i.dx=f,l+=i.dy=Math.min(e.y+e.dy-l,f?c(i.area/f):0);i.z=!1,i.dy+=e.y+e.dy-l,e.x+=f,e.dx-=f}}function u(r){var i=a||o(r),u=i[0];return u.x=0,u.y=0,u.dx=l[0],u.dy=l[1],a&&o.revalue(u),t([u],u.dx*u.dy/u.value),(a?e:n)(u),h&&(a=i),i}var a,o=$u.layout.hierarchy(),c=Math.round,l=[1,1],f=null,s=$r,h=!1,g="squarify",p=.5*(1+Math.sqrt(5));return u.size=function(t){return arguments.length?(l=t,u):l},u.padding=function(t){function n(n){var e=t.call(u,n,n.depth);return null==e?$r(n):Jr(n,"number"==typeof e?[e,e,e,e]:e)}function e(n){return Jr(n,t)}if(!arguments.length)return f;var r;return s=null==(f=t)?$r:"function"==(r=typeof t)?n:"number"===r?(t=[t,t,t,t],e):e,u},u.round=function(t){return arguments.length?(c=t?Math.round:Number,u):c!=Number},u.sticky=function(t){return arguments.length?(h=t,a=null,u):h},u.ratio=function(t){return arguments.length?(p=t,u):p},u.mode=function(t){return arguments.length?(g=t+"",u):g},cr(u,o)},$u.svg={},$u.svg.line=function(){return Gr(gn)};var To=$u.map({linear:Qr,"linear-closed":ti,"step-before":ni,"step-after":ei,basis:ci,"basis-open":li,"basis-closed":fi,bundle:si,cardinal:ui,"cardinal-open":ri,"cardinal-closed":ii,monotone:vi});To.forEach(function(t,n){n.key=t,n.closed=/-closed$/.test(t)});var Co=[0,2/3,1/3,0],zo=[0,1/3,2/3,0],Do=[0,1/6,2/3,1/6];$u.layout.voronoi=function(){function t(t){var e,u,a,o=[],c=ln(r),l=ln(i),f=t.length;for(a=0;f>a;++a)o.push([+c.call(this,u=t[a],a),+l.call(this,u,a)]);for(e=$u.geom.voronoi(o),a=0;f>a;++a)e[a].data=t[a];if(n)for(a=0;f>a;++a)n(e[a]);return e}var n,e=null,r=Kr,i=Wr;return t.x=function(n){return arguments.length?(r=n,t):r},t.y=function(n){return arguments.length?(i=n,t):i},t.size=function(r){if(!arguments.length)return e;if(null==r)n=null;else{var i=+r[0],u=+r[1];n=$u.geom.polygon([[0,0],[0,u],[i,u],[i,0]]).clip}return t},t},$u.random={normal:function(t,n){var e=arguments.length;return 2>e&&(n=1),1>e&&(t=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 t+n*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=$u.random.normal.apply($u,arguments);return function(){return Math.exp(t())}},irwinHall:function(t){return function(){for(var n=0,e=0;t>e;e++)n+=Math.random();return n/t}}},$u.scale={},$u.scale.linear=function(){return Ei([0,1],[0,1],$u.interpolate,!1)},$u.scale.log=function(){return Ci($u.scale.linear().domain([0,Math.LN10]),10,zi,Di)};var jo=$u.format(".0e");$u.scale.pow=function(){return Hi($u.scale.linear(),1)},$u.scale.sqrt=function(){return $u.scale.pow().exponent(.5)},$u.scale.ordinal=function(){return Pi([],{t:"range",a:[[]]})},$u.scale.category10=function(){return $u.scale.ordinal().range(Lo)},$u.scale.category20=function(){return $u.scale.ordinal().range(Fo)},$u.scale.category20b=function(){return $u.scale.ordinal().range(Ho)},$u.scale.category20c=function(){return $u.scale.ordinal().range(Ro)};var Lo=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Fo=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],Ho=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Ro=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];$u.scale.quantile=function(){return Oi([],[])},$u.scale.quantize=function(){return Yi(0,1,[0,1])},$u.scale.threshold=function(){return Ui([.5],[0,1])},$u.scale.identity=function(){return Ii([0,1])},$u.svg.arc=function(){function t(){var t=n.apply(this,arguments),u=e.apply(this,arguments),a=r.apply(this,arguments)+Po,o=i.apply(this,arguments)+Po,c=(a>o&&(c=a,a=o,o=c),o-a),l=_a>c?"0":"1",f=Math.cos(a),s=Math.sin(a),h=Math.cos(o),g=Math.sin(o);return c>=Oo?t?"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"Z":t?"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L"+t*h+","+t*g+"A"+t+","+t+" 0 "+l+",0 "+t*f+","+t*s+"Z":"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L0,0"+"Z"}var n=Vi,e=Xi,r=Zi,i=Bi;return t.innerRadius=function(e){return arguments.length?(n=ln(e),t):n},t.outerRadius=function(n){return arguments.length?(e=ln(n),t):e},t.startAngle=function(n){return arguments.length?(r=ln(n),t):r},t.endAngle=function(n){return arguments.length?(i=ln(n),t):i},t.centroid=function(){var t=(n.apply(this,arguments)+e.apply(this,arguments))/2,u=(r.apply(this,arguments)+i.apply(this,arguments))/2+Po;return[Math.cos(u)*t,Math.sin(u)*t]},t};var Po=-_a/2,Oo=2*_a-1e-6;$u.svg.line.radial=function(){var t=Gr($i);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},ni.reverse=ei,ei.reverse=ni,$u.svg.area=function(){return Ji(gn)},$u.svg.area.radial=function(){var t=Ji($i);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},$u.svg.chord=function(){function t(t,o){var c=n(this,u,t,o),l=n(this,a,t,o);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?i(c.r,c.p1,c.r,c.p0):i(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+i(l.r,l.p1,c.r,c.p0))+"Z"}function n(t,n,e,r){var i=n.call(t,e,r),u=o.call(t,i,r),a=c.call(t,i,r)+Po,f=l.call(t,i,r)+Po;return{r:u,a0:a,a1:f,p0:[u*Math.cos(a),u*Math.sin(a)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(t,n){return t.a0==n.a0&&t.a1==n.a1}function r(t,n,e){return"A"+t+","+t+" 0 "+ +(e>_a)+",1 "+n}function i(t,n,e,r){return"Q 0,0 "+r}var u=In,a=Vn,o=Gi,c=Zi,l=Bi;return t.radius=function(n){return arguments.length?(o=ln(n),t):o},t.source=function(n){return arguments.length?(u=ln(n),t):u},t.target=function(n){return arguments.length?(a=ln(n),t):a},t.startAngle=function(n){return arguments.length?(c=ln(n),t):c},t.endAngle=function(n){return arguments.length?(l=ln(n),t):l},t},$u.svg.diagonal=function(){function t(t,i){var u=n.call(this,t,i),a=e.call(this,t,i),o=(u.y+a.y)/2,c=[u,{x:u.x,y:o},{x:a.x,y:o},a];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var n=In,e=Vn,r=Ki;return t.source=function(e){return arguments.length?(n=ln(e),t):n},t.target=function(n){return arguments.length?(e=ln(n),t):e},t.projection=function(n){return arguments.length?(r=n,t):r},t},$u.svg.diagonal.radial=function(){var t=$u.svg.diagonal(),n=Ki,e=t.projection;return t.projection=function(t){return arguments.length?e(Wi(n=t)):n},t},$u.svg.symbol=function(){function t(t,r){return(Yo.get(n.call(this,t,r))||nu)(e.call(this,t,r))}var n=tu,e=Qi;return t.type=function(e){return arguments.length?(n=ln(e),t):n},t.size=function(n){return arguments.length?(e=ln(n),t):e},t};var Yo=$u.map({circle:nu,cross:function(t){var n=Math.sqrt(t/5)/2;return"M"+-3*n+","+-n+"H"+-n+"V"+-3*n+"H"+n+"V"+-n+"H"+3*n+"V"+n+"H"+n+"V"+3*n+"H"+-n+"V"+n+"H"+-3*n+"Z"},diamond:function(t){var n=Math.sqrt(t/(2*Io)),e=n*Io;return"M0,"+-n+"L"+e+",0"+" 0,"+n+" "+-e+",0"+"Z"},square:function(t){var n=Math.sqrt(t)/2;return"M"+-n+","+-n+"L"+n+","+-n+" "+n+","+n+" "+-n+","+n+"Z"},"triangle-down":function(t){var n=Math.sqrt(t/Uo),e=n*Uo/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/Uo),e=n*Uo/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});$u.svg.symbolTypes=Yo.keys();var Uo=Math.sqrt(3),Io=Math.tan(30*Sa);ga.transition=function(){var t,n,e=Vo||++Zo,r=[],i=Object.create(Bo);i.time=Date.now();for(var u=-1,a=this.length;a>++u;){r.push(t=[]);for(var o=this[u],c=-1,l=o.length;l>++c;)(n=o[c])&&ru(n,c,e,i),t.push(n)}return eu(r,e)};var Vo,Xo=[],Zo=0,Bo={ease:Ye,delay:0,duration:250};Xo.call=ga.call,Xo.empty=ga.empty,Xo.node=ga.node,$u.transition=function(t){return arguments.length?Vo?t.transition():t:ma.transition()},$u.transition.prototype=Xo,Xo.select=function(t){var n,e,r,i=this.id,u=[];"function"!=typeof t&&(t=m(t));for(var a=-1,o=this.length;o>++a;){u.push(n=[]);for(var c=this[a],l=-1,f=c.length;f>++l;)(r=c[l])&&(e=t.call(r,r.__data__,l))?("__data__"in r&&(e.__data__=r.__data__),ru(e,l,i,r.__transition__[i]),n.push(e)):n.push(null)}return eu(u,i)},Xo.selectAll=function(t){var n,e,r,i,u,a=this.id,o=[];"function"!=typeof t&&(t=v(t));for(var c=-1,l=this.length;l>++c;)for(var f=this[c],s=-1,h=f.length;h>++s;)if(r=f[s]){u=r.__transition__[a],e=t.call(r,r.__data__,s),o.push(n=[]);for(var g=-1,p=e.length;p>++g;)ru(i=e[g],g,a,u),n.push(i)}return eu(o,a)},Xo.filter=function(t){var n,e,r,i=[];"function"!=typeof t&&(t=A(t));for(var u=0,a=this.length;a>u;u++){i.push(n=[]);for(var e=this[u],o=0,c=e.length;c>o;o++)(r=e[o])&&t.call(r,r.__data__,o)&&n.push(r)}return eu(i,this.id,this.time).ease(this.ease())},Xo.tween=function(t,n){var e=this.id;return 2>arguments.length?this.node().__transition__[e].tween.get(t):z(this,null==n?function(n){n.__transition__[e].tween.remove(t)}:function(r){r.__transition__[e].tween.set(t,n)})},Xo.attr=function(t,n){function e(){this.removeAttribute(u)}function r(){this.removeAttributeNS(u.space,u.local)}if(2>arguments.length){for(n in t)this.attr(n,t[n]);return this}var i=Qe(t),u=$u.ns.qualify(t);return iu(this,"attr."+t,n,function(t){function n(){var n,e=this.getAttribute(u);return e!==t&&(n=i(e,t),function(t){this.setAttribute(u,n(t))})}function a(){var n,e=this.getAttributeNS(u.space,u.local);return e!==t&&(n=i(e,t),function(t){this.setAttributeNS(u.space,u.local,n(t))})}return null==t?u.local?r:e:(t+="",u.local?a:n)})},Xo.attrTween=function(t,n){function e(t,e){var r=n.call(this,t,e,this.getAttribute(i));return r&&function(t){this.setAttribute(i,r(t))}}function r(t,e){var r=n.call(this,t,e,this.getAttributeNS(i.space,i.local));return r&&function(t){this.setAttributeNS(i.space,i.local,r(t))}}var i=$u.ns.qualify(t);return this.tween("attr."+t,i.local?r:e)},Xo.style=function(t,n,e){function r(){this.style.removeProperty(t)}var i=arguments.length;if(3>i){if("string"!=typeof t){2>i&&(n="");for(e in t)this.style(e,t[e],n);return this}e=""}var u=Qe(t);return iu(this,"style."+t,n,function(n){function i(){var r,i=Gu.getComputedStyle(this,null).getPropertyValue(t);return i!==n&&(r=u(i,n),function(n){this.style.setProperty(t,r(n),e)})}return null==n?r:(n+="",i)})},Xo.styleTween=function(t,n,e){return 3>arguments.length&&(e=""),this.tween("style."+t,function(r,i){var u=n.call(this,r,i,Gu.getComputedStyle(this,null).getPropertyValue(t));return u&&function(n){this.style.setProperty(t,u(n),e)}})},Xo.text=function(t){return iu(this,"text",t,uu)},Xo.remove=function(){return this.each("end.transition",function(){var t;!this.__transition__&&(t=this.parentNode)&&t.removeChild(this)})},Xo.ease=function(t){var n=this.id;return 1>arguments.length?this.node().__transition__[n].ease:("function"!=typeof t&&(t=$u.ease.apply($u,arguments)),z(this,function(e){e.__transition__[n].ease=t}))},Xo.delay=function(t){var n=this.id;return z(this,"function"==typeof t?function(e,r,i){e.__transition__[n].delay=0|t.call(e,e.__data__,r,i)}:(t|=0,function(e){e.__transition__[n].delay=t}))},Xo.duration=function(t){var n=this.id;return z(this,"function"==typeof t?function(e,r,i){e.__transition__[n].duration=Math.max(1,0|t.call(e,e.__data__,r,i))}:(t=Math.max(1,0|t),function(e){e.__transition__[n].duration=t}))},Xo.each=function(t,n){var e=this.id;if(2>arguments.length){var r=Bo,i=Vo;Vo=e,z(this,function(n,r,i){Bo=n.__transition__[e],t.call(n,n.__data__,r,i)}),Bo=r,Vo=i}else z(this,function(r){r.__transition__[e].event.on(t,n)});return this},Xo.transition=function(){for(var t,n,e,r,i=this.id,u=++Zo,a=[],o=0,c=this.length;c>o;o++){a.push(t=[]);for(var n=this[o],l=0,f=n.length;f>l;l++)(e=n[l])&&(r=Object.create(e.__transition__[i]),r.delay+=r.duration,ru(e,l,u,r)),t.push(e)}return eu(a,u)},$u.svg.axis=function(){function t(t){t.each(function(){var t,s=$u.select(this),h=null==l?e.ticks?e.ticks.apply(e,c):e.domain():l,g=null==n?e.tickFormat?e.tickFormat.apply(e,c):String:n,p=cu(e,h,f),d=s.selectAll(".tick.minor").data(p,String),m=d.enter().insert("line",".tick").attr("class","tick minor").style("opacity",1e-6),v=$u.transition(d.exit()).style("opacity",1e-6).remove(),y=$u.transition(d).style("opacity",1),M=s.selectAll(".tick.major").data(h,String),b=M.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),x=$u.transition(M.exit()).style("opacity",1e-6).remove(),_=$u.transition(M).style("opacity",1),w=Mi(e),S=s.selectAll(".domain").data([0]),E=(S.enter().append("path").attr("class","domain"),$u.transition(S)),k=e.copy(),A=this.__chart__||k;this.__chart__=k,b.append("line"),b.append("text");var N=b.select("line"),q=_.select("line"),T=M.select("text").text(g),C=b.select("text"),z=_.select("text");switch(r){case"bottom":t=au,m.attr("y2",u),y.attr("x2",0).attr("y2",u),N.attr("y2",i),C.attr("y",Math.max(i,0)+o),q.attr("x2",0).attr("y2",i),z.attr("x",0).attr("y",Math.max(i,0)+o),T.attr("dy",".71em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+a+"V0H"+w[1]+"V"+a);break;case"top":t=au,m.attr("y2",-u),y.attr("x2",0).attr("y2",-u),N.attr("y2",-i),C.attr("y",-(Math.max(i,0)+o)),q.attr("x2",0).attr("y2",-i),z.attr("x",0).attr("y",-(Math.max(i,0)+o)),T.attr("dy","0em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+-a+"V0H"+w[1]+"V"+-a);break;case"left":t=ou,m.attr("x2",-u),y.attr("x2",-u).attr("y2",0),N.attr("x2",-i),C.attr("x",-(Math.max(i,0)+o)),q.attr("x2",-i).attr("y2",0),z.attr("x",-(Math.max(i,0)+o)).attr("y",0),T.attr("dy",".32em").style("text-anchor","end"),E.attr("d","M"+-a+","+w[0]+"H0V"+w[1]+"H"+-a);break;case"right":t=ou,m.attr("x2",u),y.attr("x2",u).attr("y2",0),N.attr("x2",i),C.attr("x",Math.max(i,0)+o),q.attr("x2",i).attr("y2",0),z.attr("x",Math.max(i,0)+o).attr("y",0),T.attr("dy",".32em").style("text-anchor","start"),E.attr("d","M"+a+","+w[0]+"H0V"+w[1]+"H"+a)}if(e.ticks)b.call(t,A),_.call(t,k),x.call(t,k),m.call(t,A),y.call(t,k),v.call(t,k);else{var D=k.rangeBand()/2,j=function(t){return k(t)+D};b.call(t,j),_.call(t,j)}})}var n,e=$u.scale.linear(),r=$o,i=6,u=6,a=6,o=3,c=[10],l=null,f=0;return t.scale=function(n){return arguments.length?(e=n,t):e},t.orient=function(n){return arguments.length?(r=n in Jo?n+"":$o,t):r},t.ticks=function(){return arguments.length?(c=arguments,t):c},t.tickValues=function(n){return arguments.length?(l=n,t):l},t.tickFormat=function(e){return arguments.length?(n=e,t):n},t.tickSize=function(n,e){if(!arguments.length)return i;var r=arguments.length-1;return i=+n,u=r>1?+e:i,a=r>0?+arguments[r]:i,t},t.tickPadding=function(n){return arguments.length?(o=+n,t):o},t.tickSubdivide=function(n){return arguments.length?(f=+n,t):f},t};var $o="bottom",Jo={top:1,right:1,bottom:1,left:1};$u.svg.brush=function(){function t(u){u.each(function(){var u,a=$u.select(this),l=a.selectAll(".background").data([0]),s=a.selectAll(".extent").data([0]),h=a.selectAll(".resize").data(f,String);a.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),l.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),s.enter().append("rect").attr("class","extent").style("cursor","move"),h.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Go[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),h.style("display",t.empty()?"none":null),h.exit().remove(),o&&(u=Mi(o),l.attr("x",u[0]).attr("width",u[1]-u[0]),e(a)),c&&(u=Mi(c),l.attr("y",u[0]).attr("height",u[1]-u[0]),r(a)),n(a)})}function n(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+h[+/e$/.test(t)][0]+","+h[+/^s/.test(t)][1]+")"})}function e(t){t.select(".extent").attr("x",h[0][0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",h[1][0]-h[0][0])}function r(t){t.select(".extent").attr("y",h[0][1]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1][1]-h[0][1])}function i(){function i(){var t=$u.event.changedTouches;return t?$u.touches(y,t)[0]:$u.mouse(y)}function f(){32==$u.event.keyCode&&(E||(m=null,k[0]-=h[1][0],k[1]-=h[1][1],E=2),l())}function s(){32==$u.event.keyCode&&2==E&&(k[0]+=h[1][0],k[1]+=h[1][1],E=0,l())}function g(){var t=i(),u=!1;v&&(t[0]+=v[0],t[1]+=v[1]),E||($u.event.altKey?(m||(m=[(h[0][0]+h[1][0])/2,(h[0][1]+h[1][1])/2]),k[0]=h[+(t[0]l?(i=r,r=l):i=l),h[0][e]!==r||h[1][e]!==i?(u=null,h[0][e]=r,h[1][e]=i,!0):void 0}function d(){g(),x.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),$u.select("body").style("cursor",null),A.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),b({type:"brushend"}),l()}var m,v,y=this,M=$u.select($u.event.target),b=a.of(y,arguments),x=$u.select(y),_=M.datum(),w=!/^(n|s)$/.test(_)&&o,S=!/^(e|w)$/.test(_)&&c,E=M.classed("extent"),k=i(),A=$u.select(Gu).on("mousemove.brush",g).on("mouseup.brush",d).on("touchmove.brush",g).on("touchend.brush",d).on("keydown.brush",f).on("keyup.brush",s);if(E)k[0]=h[0][0]-k[0],k[1]=h[0][1]-k[1];else if(_){var N=+/w$/.test(_),q=+/^n/.test(_);v=[h[1-N][0]-k[0],h[1-q][1]-k[1]],k[0]=h[N][0],k[1]=h[q][1]}else $u.event.altKey&&(m=k.slice());x.style("pointer-events","none").selectAll(".resize").style("display",null),$u.select("body").style("cursor",M.style("cursor")),b({type:"brushstart"}),g(),l()}var u,a=s(t,"brushstart","brush","brushend"),o=null,c=null,f=Ko[0],h=[[0,0],[0,0]];return t.x=function(n){return arguments.length?(o=n,f=Ko[!o<<1|!c],t):o},t.y=function(n){return arguments.length?(c=n,f=Ko[!o<<1|!c],t):c},t.extent=function(n){var e,r,i,a,l;return arguments.length?(u=[[0,0],[0,0]],o&&(e=n[0],r=n[1],c&&(e=e[0],r=r[0]),u[0][0]=e,u[1][0]=r,o.invert&&(e=o(e),r=o(r)),e>r&&(l=e,e=r,r=l),h[0][0]=0|e,h[1][0]=0|r),c&&(i=n[0],a=n[1],o&&(i=i[1],a=a[1]),u[0][1]=i,u[1][1]=a,c.invert&&(i=c(i),a=c(a)),i>a&&(l=i,i=a,a=l),h[0][1]=0|i,h[1][1]=0|a),t):(n=u||h,o&&(e=n[0][0],r=n[1][0],u||(e=h[0][0],r=h[1][0],o.invert&&(e=o.invert(e),r=o.invert(r)),e>r&&(l=e,e=r,r=l))),c&&(i=n[0][1],a=n[1][1],u||(i=h[0][1],a=h[1][1],c.invert&&(i=c.invert(i),a=c.invert(a)),i>a&&(l=i,i=a,a=l))),o&&c?[[e,i],[r,a]]:o?[e,r]:c&&[i,a])},t.clear=function(){return u=null,h[0][0]=h[0][1]=h[1][0]=h[1][1]=0,t},t.empty=function(){return o&&h[0][0]===h[1][0]||c&&h[0][1]===h[1][1]},$u.rebind(t,a,"on")};var Go={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ko=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];$u.time={};var Wo=Date,Qo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];lu.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(){tc.setUTCDate.apply(this._,arguments)},setDay:function(){tc.setUTCDay.apply(this._,arguments)},setFullYear:function(){tc.setUTCFullYear.apply(this._,arguments)},setHours:function(){tc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){tc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){tc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){tc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){tc.setUTCSeconds.apply(this._,arguments)},setTime:function(){tc.setTime.apply(this._,arguments)}};var tc=Date.prototype,nc="%a %b %e %X %Y",ec="%m/%d/%Y",rc="%H:%M:%S",ic=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],uc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ac=["January","February","March","April","May","June","July","August","September","October","November","December"],oc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];$u.time.format=function(t){function n(n){for(var r,i,u,a=[],o=-1,c=0;e>++o;)37===t.charCodeAt(o)&&(a.push(t.substring(c,o)),null!=(i=pc[r=t.charAt(++o)])&&(r=t.charAt(++o)),(u=dc[r])&&(r=u(n,null==i?"e"===r?" ":"0":i)),a.push(r),c=o+1);return a.push(t.substring(c,o)),a.join("")}var e=t.length;return n.parse=function(n){var e={y:1900,m:0,d:1,H:0,M:0,S:0,L:0},r=fu(e,t,n,0);if(r!=n.length)return null;"p"in e&&(e.H=e.H%12+12*e.p);var i=new Wo;return i.setFullYear(e.y,e.m,e.d),i.setHours(e.H,e.M,e.S,e.L),i},n.toString=function(){return t},n};var cc=su(ic),lc=su(uc),fc=su(ac),sc=hu(ac),hc=su(oc),gc=hu(oc),pc={"-":"",_:" ",0:"0"},dc={a:function(t){return uc[t.getDay()]},A:function(t){return ic[t.getDay()]},b:function(t){return oc[t.getMonth()]},B:function(t){return ac[t.getMonth()]},c:$u.time.format(nc),d:function(t,n){return gu(t.getDate(),n,2)},e:function(t,n){return gu(t.getDate(),n,2)},H:function(t,n){return gu(t.getHours(),n,2) -},I:function(t,n){return gu(t.getHours()%12||12,n,2)},j:function(t,n){return gu(1+$u.time.dayOfYear(t),n,3)},L:function(t,n){return gu(t.getMilliseconds(),n,3)},m:function(t,n){return gu(t.getMonth()+1,n,2)},M:function(t,n){return gu(t.getMinutes(),n,2)},p:function(t){return t.getHours()>=12?"PM":"AM"},S:function(t,n){return gu(t.getSeconds(),n,2)},U:function(t,n){return gu($u.time.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return gu($u.time.mondayOfYear(t),n,2)},x:$u.time.format(ec),X:$u.time.format(rc),y:function(t,n){return gu(t.getFullYear()%100,n,2)},Y:function(t,n){return gu(t.getFullYear()%1e4,n,4)},Z:Cu,"%":function(){return"%"}},mc={a:pu,A:du,b:mu,B:vu,c:yu,d:Eu,e:Eu,H:ku,I:ku,L:qu,m:Su,M:Au,p:Tu,S:Nu,x:Mu,X:bu,y:_u,Y:xu},vc=/^\s*\d+/,yc=$u.map({am:0,pm:1});$u.time.format.utc=function(t){function n(t){try{Wo=lu;var n=new Wo;return n._=t,e(n)}finally{Wo=Date}}var e=$u.time.format(t);return n.parse=function(t){try{Wo=lu;var n=e.parse(t);return n&&n._}finally{Wo=Date}},n.toString=e.toString,n};var Mc=$u.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");$u.time.format.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?zu:Mc,zu.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},zu.toString=Mc.toString,$u.time.second=Du(function(t){return new Wo(1e3*Math.floor(t/1e3))},function(t,n){t.setTime(t.getTime()+1e3*Math.floor(n))},function(t){return t.getSeconds()}),$u.time.seconds=$u.time.second.range,$u.time.seconds.utc=$u.time.second.utc.range,$u.time.minute=Du(function(t){return new Wo(6e4*Math.floor(t/6e4))},function(t,n){t.setTime(t.getTime()+6e4*Math.floor(n))},function(t){return t.getMinutes()}),$u.time.minutes=$u.time.minute.range,$u.time.minutes.utc=$u.time.minute.utc.range,$u.time.hour=Du(function(t){var n=t.getTimezoneOffset()/60;return new Wo(36e5*(Math.floor(t/36e5-n)+n))},function(t,n){t.setTime(t.getTime()+36e5*Math.floor(n))},function(t){return t.getHours()}),$u.time.hours=$u.time.hour.range,$u.time.hours.utc=$u.time.hour.utc.range,$u.time.day=Du(function(t){var n=new Wo(1970,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n},function(t,n){t.setDate(t.getDate()+n)},function(t){return t.getDate()-1}),$u.time.days=$u.time.day.range,$u.time.days.utc=$u.time.day.utc.range,$u.time.dayOfYear=function(t){var n=$u.time.year(t);return Math.floor((t-n-6e4*(t.getTimezoneOffset()-n.getTimezoneOffset()))/864e5)},$u.time.year=Du(function(t){return t=$u.time.day(t),t.setMonth(0,1),t},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t){return t.getFullYear()}),$u.time.years=$u.time.year.range,$u.time.years.utc=$u.time.year.utc.range,Qo.forEach(function(t,n){t=t.toLowerCase(),n=7-n;var e=$u.time[t]=Du(function(t){return(t=$u.time.day(t)).setDate(t.getDate()-(t.getDay()+n)%7),t},function(t,n){t.setDate(t.getDate()+7*Math.floor(n))},function(t){var e=$u.time.year(t).getDay();return Math.floor(($u.time.dayOfYear(t)+(e+n)%7)/7)-(e!==n)});$u.time[t+"s"]=e.range,$u.time[t+"s"].utc=e.utc.range,$u.time[t+"OfYear"]=function(t){var e=$u.time.year(t).getDay();return Math.floor(($u.time.dayOfYear(t)+(e+n)%7)/7)}}),$u.time.week=$u.time.sunday,$u.time.weeks=$u.time.sunday.range,$u.time.weeks.utc=$u.time.sunday.utc.range,$u.time.weekOfYear=$u.time.sundayOfYear,$u.time.month=Du(function(t){return t=$u.time.day(t),t.setDate(1),t},function(t,n){t.setMonth(t.getMonth()+n)},function(t){return t.getMonth()}),$u.time.months=$u.time.month.range,$u.time.months.utc=$u.time.month.utc.range;var bc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],xc=[[$u.time.second,1],[$u.time.second,5],[$u.time.second,15],[$u.time.second,30],[$u.time.minute,1],[$u.time.minute,5],[$u.time.minute,15],[$u.time.minute,30],[$u.time.hour,1],[$u.time.hour,3],[$u.time.hour,6],[$u.time.hour,12],[$u.time.day,1],[$u.time.day,2],[$u.time.week,1],[$u.time.month,1],[$u.time.month,3],[$u.time.year,1]],_c=[[$u.time.format("%Y"),Bn],[$u.time.format("%B"),function(t){return t.getMonth()}],[$u.time.format("%b %d"),function(t){return 1!=t.getDate()}],[$u.time.format("%a %d"),function(t){return t.getDay()&&1!=t.getDate()}],[$u.time.format("%I %p"),function(t){return t.getHours()}],[$u.time.format("%I:%M"),function(t){return t.getMinutes()}],[$u.time.format(":%S"),function(t){return t.getSeconds()}],[$u.time.format(".%L"),function(t){return t.getMilliseconds()}]],wc=$u.scale.linear(),Sc=Ru(_c);xc.year=function(t,n){return wc.domain(t.map(Ou)).ticks(n).map(Pu)},$u.time.scale=function(){return Lu($u.scale.linear(),xc,Sc)};var Ec=xc.map(function(t){return[t[0].utc,t[1]]}),kc=[[$u.time.format.utc("%Y"),Bn],[$u.time.format.utc("%B"),function(t){return t.getUTCMonth()}],[$u.time.format.utc("%b %d"),function(t){return 1!=t.getUTCDate()}],[$u.time.format.utc("%a %d"),function(t){return t.getUTCDay()&&1!=t.getUTCDate()}],[$u.time.format.utc("%I %p"),function(t){return t.getUTCHours()}],[$u.time.format.utc("%I:%M"),function(t){return t.getUTCMinutes()}],[$u.time.format.utc(":%S"),function(t){return t.getUTCSeconds()}],[$u.time.format.utc(".%L"),function(t){return t.getUTCMilliseconds()}]],Ac=Ru(kc);return Ec.year=function(t,n){return wc.domain(t.map(Uu)).ticks(n).map(Yu)},$u.time.scale.utc=function(){return Lu($u.scale.linear(),Ec,Ac)},$u.xhr=function(t,n,e){function r(){var t=c.status;!t&&c.responseText||t>=200&&300>t||304===t?u.load.call(i,o.call(i,c)):u.error.call(i,c)}var i={},u=$u.dispatch("progress","load","error"),a={},o=gn,c=new(Gu.XDomainRequest&&/^(http(s)?:)?\/\//.test(t)?XDomainRequest:XMLHttpRequest);return"onload"in c?c.onload=c.onerror=r:c.onreadystatechange=function(){c.readyState>3&&r()},c.onprogress=function(t){var n=$u.event;$u.event=t;try{u.progress.call(i,c)}finally{$u.event=n}},i.header=function(t,n){return t=(t+"").toLowerCase(),2>arguments.length?a[t]:(null==n?delete a[t]:a[t]=n+"",i)},i.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",i):n},i.response=function(t){return o=t,i},["get","post"].forEach(function(t){i[t]=function(){return i.send.apply(i,[t].concat(ia(arguments)))}}),i.send=function(e,r,u){if(2===arguments.length&&"function"==typeof r&&(u=r,r=null),c.open(e,t,!0),null==n||"accept"in a||(a.accept=n+",*/*"),c.setRequestHeader)for(var o in a)c.setRequestHeader(o,a[o]);return null!=n&&c.overrideMimeType&&c.overrideMimeType(n),null!=u&&i.on("error",u).on("load",function(t){u(null,t)}),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},$u.rebind(i,u,"on"),2===arguments.length&&"function"==typeof n&&(e=n,n=null),null==e?i:i.get(Iu(e))},$u.text=function(){return $u.xhr.apply($u,arguments).response(Vu)},$u.json=function(t,n){return $u.xhr(t,"application/json",n).response(Xu)},$u.html=function(t,n){return $u.xhr(t,"text/html",n).response(Zu)},$u.xml=function(){return $u.xhr.apply($u,arguments).response(Bu)},$u}(); \ No newline at end of file +d3=function(){function t(t){return null!=t&&!isNaN(t)}function n(t){return t.length}function e(t){for(var n=1;t*n%1;)n*=10;return n}function r(t,n){try{for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}catch(r){t.prototype=n}}function i(){}function u(){}function a(t,n,e){return function(){var r=e.apply(n,arguments);return r===n?t:r}}function o(){}function c(t){function n(){for(var n,r=e,i=-1,u=r.length;++ira&&(Gu.scrollX||Gu.scrollY)){e=$u.select(Ju.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=e[0][0].getScreenCTM();ra=!(i.f||i.e),e.remove()}return ra?(r.x=n.pageX,r.y=n.pageY):(r.x=n.clientX,r.y=n.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var u=t.getBoundingClientRect();return[n.clientX-u.left-t.clientLeft,n.clientY-u.top-t.clientTop]}function g(t){for(var n=-1,e=t.length,r=[];++n0&&(t=t.substring(0,o));var l=da.get(t);return l&&(t=l,c=C),o?n?i:r:n?vn:u}function T(t,n){return function(e){var r=$u.event;$u.event=e,n[0]=this.__data__;try{t.apply(this,n)}finally{$u.event=r}}}function C(t,n){var e=T(t,n);return function(t){var n=this,r=t.relatedTarget;r&&(r===n||r.compareDocumentPosition(n)&8)||e.call(n,t)}}function z(t,n){for(var e=0,r=t.length;r>e;e++)for(var i,u=t[e],a=0,o=u.length;o>a;a++)(i=u[a])&&n(i,a,e);return t}function D(t){return aa(t,va),t}function j(){}function L(t,n,e){return new F(t,n,e)}function F(t,n,e){this.h=t,this.s=n,this.l=e}function H(t,n,e){function r(t){return t>360?t-=360:0>t&&(t+=360),60>t?u+(a-u)*t/60:180>t?a:240>t?u+(a-u)*(240-t)/60:u}function i(t){return Math.round(r(t)*255)}var u,a;return t%=360,0>t&&(t+=360),n=0>n?0:n>1?1:n,e=0>e?0:e>1?1:e,a=.5>=e?e*(1+n):e+n-e*n,u=2*e-a,tn(i(t+120),i(t),i(t-120))}function R(t){return t>0?1:0>t?-1:0}function P(t){return Math.acos(Math.max(-1,Math.min(1,t)))}function O(t){return t>1?_a/2:-1>t?-_a/2:Math.asin(t)}function Y(t){return(Math.exp(t)-Math.exp(-t))/2}function U(t){return(Math.exp(t)+Math.exp(-t))/2}function I(t){return(t=Math.sin(t/2))*t}function V(t,n,e){return new X(t,n,e)}function X(t,n,e){this.h=t,this.c=n,this.l=e}function Z(t,n,e){return B(e,Math.cos(t*=Sa)*n,Math.sin(t)*n)}function B(t,n,e){return new $(t,n,e)}function $(t,n,e){this.l=t,this.a=n,this.b=e}function J(t,n,e){var r=(t+16)/116,i=r+n/500,u=r-e/200;return i=K(i)*Na,r=K(r)*qa,u=K(u)*Ta,tn(Q(3.2404542*i-1.5371385*r-.4985314*u),Q(-.969266*i+1.8760108*r+.041556*u),Q(.0556434*i-.2040259*r+1.0572252*u))}function G(t,n,e){return V(Math.atan2(e,n)*Ea,Math.sqrt(n*n+e*e),t)}function K(t){return t>.206893034?t*t*t:(t-4/29)/7.787037}function W(t){return t>.008856?Math.pow(t,1/3):7.787037*t+4/29}function Q(t){return Math.round(255*(.00304>=t?12.92*t:1.055*Math.pow(t,1/2.4)-.055))}function tn(t,n,e){return new nn(t,n,e)}function nn(t,n,e){this.r=t,this.g=n,this.b=e}function en(t){return 16>t?"0"+Math.max(0,t).toString(16):Math.min(255,t).toString(16)}function rn(t,n,e){var r,i,u,a=0,o=0,c=0;if(r=/([a-z]+)\((.*)\)/i.exec(t))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 n(cn(i[0]),cn(i[1]),cn(i[2]))}return(u=Da.get(t))?n(u.r,u.g,u.b):(null!=t&&t.charAt(0)==="#"&&(t.length===4?(a=t.charAt(1),a+=a,o=t.charAt(2),o+=o,c=t.charAt(3),c+=c):t.length===7&&(a=t.substring(1,3),o=t.substring(3,5),c=t.substring(5,7)),a=parseInt(a,16),o=parseInt(o,16),c=parseInt(c,16)),n(a,o,c))}function un(t,n,e){var r,i,u=Math.min(t/=255,n/=255,e/=255),a=Math.max(t,n,e),o=a-u,c=(a+u)/2;return o?(i=.5>c?o/(a+u):o/(2-a-u),r=t==a?(n-e)/o+(e>n?6:0):n==a?(e-t)/o+2:(t-n)/o+4,r*=60):i=r=0,L(r,i,c)}function an(t,n,e){t=on(t),n=on(n),e=on(e);var r=W((.4124564*t+.3575761*n+.1804375*e)/Na),i=W((.2126729*t+.7151522*n+.072175*e)/qa),u=W((.0193339*t+.119192*n+.9503041*e)/Ta);return B(116*i-16,500*(r-i),200*(i-u))}function on(t){return(t/=255)<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function cn(t){var n=parseFloat(t);return t.charAt(t.length-1)==="%"?Math.round(2.55*n):n}function ln(t){return"function"==typeof t?t:function(){return t}}function fn(t,n){function e(t,e,u){arguments.length<3&&(u=e,e=null);var a=$u.xhr(t,n,u);return a.row=function(t){return arguments.length?a.response((e=t)==null?r:i(t)):e},a.row(e)}function r(t){return e.parse(t.responseText)}function i(t){return function(n){return e.parse(n.responseText,t)}}function a(n){return n.map(o).join(t)}function o(t){return c.test(t)?'"'+t.replace(/\"/g,'""')+'"':t}var c=RegExp('["'+t+"\n]"),l=t.charCodeAt(0);return e.parse=function(t,n){var r;return e.parseRows(t,function(t,e){if(r)return r(t,e-1);var i=Function("d","return {"+t.map(function(t,n){return JSON.stringify(t)+": d["+n+"]"}).join(",")+"}");r=n?function(t,e){return n(i(t),e)}:i})},e.parseRows=function(t,n){function e(){if(f>=c)return a;if(i)return i=!1,u;var n=f;if(t.charCodeAt(n)===34){for(var e=n;e++f;){var r=t.charCodeAt(f++),o=1;if(10===r)i=!0;else if(13===r)i=!0,t.charCodeAt(f)===10&&(++f,++o);else if(r!==l)continue;return t.substring(n,f-o)}return t.substring(n)}for(var r,i,u={},a={},o=[],c=t.length,f=0,s=0;(r=e())!==a;){for(var h=[];r!==u&&r!==a;)h.push(r),r=e();(!n||(h=n(h,s++)))&&o.push(h)}return o},e.format=function(n){if(Array.isArray(n[0]))return e.formatRows(n);var r=new u,i=[];return n.forEach(function(t){for(var n in t)r.has(n)||i.push(r.add(n))}),[i.map(o).join(t)].concat(n.map(function(n){return i.map(function(t){return o(n[t])}).join(t)})).join("\n")},e.formatRows=function(t){return t.map(a).join("\n")},e}function sn(){for(var t,n=Date.now(),e=Ra;e;)t=n-e.then,t>=e.delay&&(e.flush=e.callback(t)),e=e.next;var r=hn()-n;r>24?(isFinite(r)&&(clearTimeout(La),La=setTimeout(sn,r)),ja=0):(ja=1,Pa(sn))}function hn(){for(var t=null,n=Ra,e=1/0;n;)n.flush?(delete Ha[n.callback.id],n=t?t.next=n.next:Ra=n.next):(e=Math.min(e,n.then+n.delay),n=(t=n).next);return e}function gn(t){return t}function pn(t,n){var e=Math.pow(10,Math.abs(8-n)*3);return{scale:n>8?function(t){return t/e}:function(t){return t*e},symbol:t}}function dn(t,n){return n-(t?Math.ceil(Math.log(t)/Math.LN10):1)}function mn(t){return t+""}function vn(){}function yn(t,n){Ja.hasOwnProperty(t.type)&&Ja[t.type](t,n)}function Mn(t,n,e){var r,i=-1,u=t.length-e;for(n.lineStart();++it&&(r=t),t>u&&(u=t),i>n&&(i=n),n>a&&(a=n)}function e(){o.point=o.lineEnd=vn}var r,i,u,a,o={point:n,lineStart:vn,lineEnd:vn,polygonStart:function(){o.lineEnd=e},polygonEnd:function(){o.point=n}};return function(n){return a=u=-(r=i=1/0),$u.geo.stream(n,t(o)),[[r,i],[u,a]]}}function wn(t,n){if(!to){++no,t*=Sa;var e=Math.cos(n*=Sa);eo+=(e*Math.cos(t)-eo)/no,ro+=(e*Math.sin(t)-ro)/no,io+=(Math.sin(n)-io)/no}}function Sn(){var t,n;to=1,En(),to=2;var e=uo.point;uo.point=function(r,i){e(t=r,n=i)},uo.lineEnd=function(){uo.point(t,n),kn(),uo.lineEnd=kn}}function En(){function t(t,i){t*=Sa;var u=Math.cos(i*=Sa),a=u*Math.cos(t),o=u*Math.sin(t),c=Math.sin(i),l=Math.atan2(Math.sqrt((l=e*c-r*o)*l+(l=r*a-n*c)*l+(l=n*o-e*a)*l),n*a+e*o+r*c);no+=l,eo+=l*(n+(n=a)),ro+=l*(e+(e=o)),io+=l*(r+(r=c))}var n,e,r;to>1||(1>to&&(to=1,no=eo=ro=io=0),uo.point=function(i,u){i*=Sa;var a=Math.cos(u*=Sa);n=a*Math.cos(i),e=a*Math.sin(i),r=Math.sin(u),uo.point=t})}function kn(){uo.point=wn}function An(t){var n=t[0],e=t[1],r=Math.cos(e);return[r*Math.cos(n),r*Math.sin(n),Math.sin(e)]}function Nn(t,n){return t[0]*n[0]+t[1]*n[1]+t[2]*n[2]}function qn(t,n){return[t[1]*n[2]-t[2]*n[1],t[2]*n[0]-t[0]*n[2],t[0]*n[1]-t[1]*n[0]]}function Tn(t,n){t[0]+=n[0],t[1]+=n[1],t[2]+=n[2]}function Cn(t,n){return[t[0]*n,t[1]*n,t[2]*n]}function zn(t){var n=Math.sqrt(t[0]*t[0]+t[1]*t[1]+t[2]*t[2]);t[0]/=n,t[1]/=n,t[2]/=n}function Dn(t,n,e){return t?n||e?oe(Ln(t),Fn(n,e)):Ln(t):n||e?Fn(n,e):Ae}function jn(t){return function(n,e){return n+=t,[n>_a?n-2*_a:-_a>n?n+2*_a:n,e]}}function Ln(t){var n=jn(t);return n.invert=jn(-t),n}function Fn(t,n){function e(t,n){var e=Math.cos(n),o=Math.cos(t)*e,c=Math.sin(t)*e,l=Math.sin(n),f=l*r+o*i;return[Math.atan2(c*u-f*a,o*r-l*i),Math.asin(Math.max(-1,Math.min(1,f*u+c*a)))]}var r=Math.cos(t),i=Math.sin(t),u=Math.cos(n),a=Math.sin(n);return e.invert=function(t,n){var e=Math.cos(n),o=Math.cos(t)*e,c=Math.sin(t)*e,l=Math.sin(n),f=l*u-c*a;return[Math.atan2(c*u+l*a,o*r+f*i),Math.asin(Math.max(-1,Math.min(1,f*r-o*i)))]},e}function Hn(t){return[Math.atan2(t[1],t[0]),Math.asin(Math.max(-1,Math.min(1,t[2])))]}function Rn(t,n){return Math.abs(t[0]-n[0])0?u>i:i>u)&&(i+=2*a*_a)):(i=t+2*a*_a,u=t);for(var c,l=a*n,f=i;a>0?f>u:u>f;f-=l)o.point((c=Hn([e,-r*Math.cos(f),-r*Math.sin(f)]))[0],c[1])}}function On(t,n){var e=An(n);e[0]-=t,zn(e);var r=P(-e[1]);return((-e[2]<0?-r:r)+2*Math.PI-wa)%(2*Math.PI)}function Yn(t,n,e){var r=$u.range(t,n-wa,e).concat(n);return function(t){return r.map(function(n){return[t,n]})}}function Un(t,n,e){var r=$u.range(t,n-wa,e).concat(n);return function(t){return r.map(function(n){return[n,t]})}}function In(t){return t.source}function Vn(t){return t.target}function Xn(t,n,e,r){var i=Math.cos(n),u=Math.sin(n),a=Math.cos(r),o=Math.sin(r),c=i*Math.cos(t),l=i*Math.sin(t),f=a*Math.cos(e),s=a*Math.sin(e),h=2*Math.asin(Math.sqrt(I(r-n)+i*a*I(e-t))),g=1/Math.sin(h),p=h?function(t){var n=Math.sin(t*=h)*g,e=Math.sin(h-t)*g,r=e*c+n*f,i=e*l+n*s,a=e*u+n*o;return[Math.atan2(i,r)*Ea,Math.atan2(a,Math.sqrt(r*r+i*i))*Ea]}:function(){return[t*Ea,n*Ea]};return p.distance=h,p}function Zn(){function t(t,i){var u=Math.sin(i*=Sa),a=Math.cos(i),o=Math.abs((t*=Sa)-n),c=Math.cos(o);ao+=Math.atan2(Math.sqrt((o=a*Math.sin(o))*o+(o=r*u-e*a*c)*o),e*u+r*a*c),n=t,e=u,r=a}var n,e,r;oo.point=function(i,u){n=i*Sa,e=Math.sin(u*=Sa),r=Math.cos(u),oo.point=t},oo.lineEnd=function(){oo.point=oo.lineEnd=vn}}function Bn(){return!0}function $n(t,n,e,r,i){var u=[],a=[];if(t.forEach(function(t){if(!((n=t.length)<=1)){var n,e=t[0],r=t[n-1];if(Rn(e,r)){i.lineStart();for(var o=0;n>o;++o)i.point((e=t[o])[0],e[1]);return i.lineEnd(),void 0}var c={point:e,points:t,other:null,visited:!1,entry:!0,subject:!0},l={point:e,points:[e],other:c,visited:!1,entry:!1,subject:!1};c.other=l,u.push(c),a.push(l),c={point:r,points:[r],other:null,visited:!1,entry:!1,subject:!0},l={point:r,points:[r],other:c,visited:!1,entry:!0,subject:!1},c.other=l,u.push(c),a.push(l)}}),a.sort(n),Jn(u),Jn(a),u.length){if(e)for(var o=1,c=!e(a[0].point),l=a.length;l>o;++o)a[o].entry=c=!c;for(var f,s,h,g=u[0];;){for(f=g;f.visited;)if((f=f.next)===g)return;s=f.points,i.lineStart();do{if(f.visited=f.other.visited=!0,f.entry){if(f.subject)for(var o=0;o=0;)i.point((h=s[o])[0],h[1])}else r(f.point,f.prev.point,-1,i);f=f.prev}f=f.other,s=f.points}while(!f.visited);i.lineEnd()}}}function Jn(t){if(n=t.length){for(var n,e,r=0,i=t[0];++r1&&2&n&&e.push(e.pop().concat(e.shift())),s.push(e.filter(Kn))}var s,h,g,p,d,m=n(r),v={point:i,lineStart:a,lineEnd:o,polygonStart:function(){v.point=c,v.lineStart=l,v.lineEnd=f,p=!1,g=h=0,s=[],r.polygonStart()},polygonEnd:function(){v.point=i,v.lineStart=a,v.lineEnd=o,s=$u.merge(s),s.length?$n(s,te,null,e,r):(-wa>h||p&&-wa>g)&&(r.lineStart(),e(null,null,1,r),r.lineEnd()),r.polygonEnd(),s=null},sphere:function(){r.polygonStart(),r.lineStart(),e(null,null,1,r),r.lineEnd(),r.polygonEnd()}},y=Wn(),M=n(y);return v}}function Kn(t){return t.length>1}function Wn(){var t,n=[];return{lineStart:function(){n.push(t=[])},point:function(n,e){t.push([n,e])},lineEnd:vn,buffer:function(){var e=n;return n=[],t=null,e},rejoin:function(){n.length>1&&n.push(n.pop().concat(n.shift()))}}}function Qn(t,n){if(!(e=t.length))return 0;for(var e,r,i,u=0,a=0,o=t[0],c=o[0],l=o[1],f=Math.cos(l),s=Math.atan2(n*Math.sin(c)*f,Math.sin(l)),h=1-n*Math.cos(c)*f,g=s;++u2&&(a+=4*(r-s)):a+=Math.abs(h-2)0?_a:-_a,c=Math.abs(u-e);Math.abs(c-_a)0?_a/2:-_a/2),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(o,r),t.point(u,r),n=0):i!==o&&c>=_a&&(Math.abs(e-i)wa?Math.atan((Math.sin(n)*(u=Math.cos(r))*Math.sin(e)-Math.sin(r)*(i=Math.cos(n))*Math.sin(t))/(i*u*a)):(n+r)/2}function re(t,n,e,r){var i;if(null==t)i=e*_a/2,r.point(-_a,i),r.point(0,i),r.point(_a,i),r.point(_a,0),r.point(_a,-i),r.point(0,-i),r.point(-_a,-i),r.point(-_a,0),r.point(-_a,i);else if(Math.abs(t[0]-n[0])>wa){var u=(t[0]u}function e(t){var e,u,c,l,f;return{lineStart:function(){l=c=!1,f=1},point:function(s,h){var g,p=[s,h],d=n(s,h),m=a?d?0:i(s,h):d?i(s+(0>s?_a:-_a),h):0;if(!e&&(l=c=d)&&t.lineStart(),d!==c&&(g=r(e,p),(Rn(e,g)||Rn(p,g))&&(p[0]+=wa,p[1]+=wa,d=n(p[0],p[1]))),d!==c)f=0,d?(t.lineStart(),g=r(p,e),t.point(g[0],g[1])):(g=r(e,p),t.point(g[0],g[1]),t.lineEnd()),e=g;else if(o&&e&&a^d){var v;m&u||!(v=r(p,e,!0))||(f=0,a?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!d||e&&Rn(e,p)||t.point(p[0],p[1]),e=p,c=d,u=m},lineEnd:function(){c&&t.lineEnd(),e=null},clean:function(){return f|(l&&c)<<1}}}function r(t,n,e){var r=An(t),i=An(n),a=[1,0,0],o=qn(r,i),c=Nn(o,o),l=o[0],f=c-l*l;if(!f)return!e&&t;var s=u*c/f,h=-u*l/f,g=qn(a,o),p=Cn(a,s),d=Cn(o,h);Tn(p,d);var m=g,v=Nn(p,m),y=Nn(m,m),M=v*v-y*(Nn(p,p)-1);if(!(0>M)){var b=Math.sqrt(M),x=Cn(m,(-v-b)/y);if(Tn(x,p),x=Hn(x),!e)return x;var _,w=t[0],S=n[0],E=t[1],k=n[1];w>S&&(_=w,w=S,S=_);var A=S-w,N=Math.abs(A-_a)A;if(!N&&E>k&&(_=E,E=k,k=_),q?N?E+k>0^x[1]<(Math.abs(x[0]-w)_a^(w<=x[0]&&x[0]<=S)){var T=Cn(m,(-v+b)/y);return Tn(T,p),[x,Hn(T)]}}}function i(n,e){var r=a?t:_a-t,i=0;return-r>n?i|=1:n>r&&(i|=2),-r>e?i|=4:e>r&&(i|=8),i}var u=Math.cos(t),a=u>0,o=Math.abs(u)>wa,c=Pn(t,6*Sa);return Gn(n,e,c)}function ue(t,n,e,r){function i(r,i){return Math.abs(r[0]-t)0?0:3:Math.abs(r[0]-e)0?2:1:Math.abs(r[1]-n)0?1:0:i>0?3:2}function u(t,n){return a(t.point,n.point)}function a(t,n){var e=i(t,1),r=i(n,1);return e!==r?e-r:0===e?n[1]-t[1]:1===e?t[0]-n[0]:2===e?t[1]-n[1]:n[0]-t[0]}function o(i,u){var a=u[0]-i[0],o=u[1]-i[1],c=[0,1];return Math.abs(a)0&&(i[0]+=c[0]*a,i[1]+=c[0]*o),!0):!1}return function(c){function l(u){var a=i(u,-1),o=f([0===a||3===a?t:e,a>1?r:n]);return o}function f(t){for(var n=0,e=M.length,r=t[1],i=0;e>i;++i)for(var u=1,a=M[i],o=a.length,c=a[0];o>u;++u)b=a[u],c[1]<=r?b[1]>r&&s(c,b,t)>0&&++n:b[1]<=r&&s(c,b,t)<0&&--n,c=b;return 0!==n}function s(t,n,e){return(n[0]-t[0])*(e[1]-t[1])-(e[0]-t[0])*(n[1]-t[1])}function h(u,o,c,l){var f=0,s=0;if(null==u||(f=i(u,c))!==(s=i(o,c))||a(u,o)<0^c>0){do l.point(0===f||3===f?t:e,f>1?r:n);while((f=(f+c+4)%4)!==s)}else l.point(o[0],o[1])}function g(i,u){return i>=t&&e>=i&&u>=n&&r>=u}function p(t,n){g(t,n)&&c.point(t,n)}function d(){C.point=v,M&&M.push(x=[]),N=!0,A=!1,E=k=0/0}function m(){y&&(v(_,w),S&&A&&T.rejoin(),y.push(T.buffer())),C.point=p,A&&c.lineEnd()}function v(t,n){var e=g(t,n);if(M&&x.push([t,n]),N)_=t,w=n,S=e,N=!1,e&&(c.lineStart(),c.point(t,n));else if(e&&A)c.point(t,n);else{var r=[E,k],i=[t,n];o(r,i)&&(A||(c.lineStart(),c.point(r[0],r[1])),c.point(i[0],i[1]),e||c.lineEnd())}E=t,k=n,A=e}var y,M,x,_,w,S,E,k,A,N,q=c,T=Wn(),C={point:p,lineStart:d,lineEnd:m,polygonStart:function(){c=T,y=[],M=[]},polygonEnd:function(){c=q,(y=$u.merge(y)).length?(c.polygonStart(),$n(y,u,l,h,c),c.polygonEnd()):f([t,n])&&(c.polygonStart(),c.lineStart(),h(null,null,1,c),c.lineEnd(),c.polygonEnd()),y=M=x=null}};return C}}function ae(t,n,e){if(Math.abs(n)t;var r=t/n;if(n>0){if(r>e[1])return!1;r>e[0]&&(e[0]=r)}else{if(r4*r&&d--){var b=a+h,x=o+g,_=c+p,w=Math.sqrt(b*b+x*x+_*_),S=Math.asin(_/=w),E=Math.abs(Math.abs(_)-1)r||Math.abs((v*q+y*T)/M-.5)>.3)&&(e(n,i,u,a,o,c,A,N,E,b/=w,x/=w,_,d,m),m.point(A,N),e(A,N,E,b,x,_,l,f,s,h,g,p,d,m))}}var r=.5,i=16;return n.precision=function(t){return arguments.length?(i=(r=t*t)>0&&16,n):Math.sqrt(r)},n}function le(t){return fe(function(){return t})()}function fe(t){function n(t){return t=a(t[0]*Sa,t[1]*Sa),[t[0]*f+o,c-t[1]*f]}function e(t){return t=a.invert((t[0]-o)/f,(c-t[1])/f),t&&[t[0]*Ea,t[1]*Ea]}function r(){a=oe(u=Dn(d,m,v),i);var t=i(g,p);return o=s-t[0]*f,c=h+t[1]*f,n}var i,u,a,o,c,l=ce(function(t,n){return t=i(t,n),[t[0]*f+o,c-t[1]*f]}),f=150,s=480,h=250,g=0,p=0,d=0,m=0,v=0,y=co,M=gn,b=null,x=null;return n.stream=function(t){return se(u,y(l(M(t))))},n.clipAngle=function(t){return arguments.length?(y=null==t?(b=t,co):ie((b=+t)*Sa),n):b},n.clipExtent=function(t){return arguments.length?(x=t,M=null==t?gn:ue(t[0][0],t[0][1],t[1][0],t[1][1]),n):x},n.scale=function(t){return arguments.length?(f=+t,r()):f},n.translate=function(t){return arguments.length?(s=+t[0],h=+t[1],r()):[s,h]},n.center=function(t){return arguments.length?(g=t[0]%360*Sa,p=t[1]%360*Sa,r()):[g*Ea,p*Ea]},n.rotate=function(t){return arguments.length?(d=t[0]%360*Sa,m=t[1]%360*Sa,v=t.length>2?t[2]%360*Sa:0,r()):[d*Ea,m*Ea,v*Ea]},$u.rebind(n,l,"precision"),function(){return i=t.apply(this,arguments),n.invert=i.invert&&e,r()}}function se(t,n){return{point:function(e,r){r=t(e*Sa,r*Sa),e=r[0],n.point(e>_a?e-2*_a:-_a>e?e+2*_a:e,r[1])},sphere:function(){n.sphere()},lineStart:function(){n.lineStart()},lineEnd:function(){n.lineEnd()},polygonStart:function(){n.polygonStart()},polygonEnd:function(){n.polygonEnd()}}}function he(t){return"m0,"+t+"a"+t+","+t+" 0 1,1 0,"+-2*t+"a"+t+","+t+" 0 1,1 0,"+2*t+"z"}function ge(t){var n=ce(function(n,e){return t([n*Ea,e*Ea])});return function(t){return t=n(t),{point:function(n,e){t.point(n*Sa,e*Sa)},sphere:function(){t.sphere()},lineStart:function(){t.lineStart()},lineEnd:function(){t.lineEnd()},polygonStart:function(){t.polygonStart()},polygonEnd:function(){t.polygonEnd()}}}}function pe(){function t(t,n){fo+=i*t-r*n,r=t,i=n}var n,e,r,i;so.point=function(u,a){so.point=t,n=r=u,e=i=a},so.lineEnd=function(){t(n,e)}}function de(){function t(t,n){a.push("M",t,",",n,u)}function n(t,n){a.push("M",t,",",n),o.point=e}function e(t,n){a.push("L",t,",",n)}function r(){o.point=t}function i(){a.push("Z")}var u=he(4.5),a=[],o={point:t,lineStart:function(){o.point=n},lineEnd:r,polygonStart:function(){o.lineEnd=i},polygonEnd:function(){o.lineEnd=r,o.point=t},pointRadius:function(t){return u=he(t),o},result:function(){if(a.length){var t=a.join("");return a=[],t}}};return o}function me(t,n){to||(eo+=t,ro+=n,++io)}function ve(){function t(t,r){var i=t-n,u=r-e,a=Math.sqrt(i*i+u*u);eo+=a*(n+t)/2,ro+=a*(e+r)/2,io+=a,n=t,e=r}var n,e;if(1!==to){if(!(1>to))return;to=1,eo=ro=io=0}ho.point=function(r,i){ho.point=t,n=r,e=i}}function ye(){ho.point=me}function Me(){function t(t,n){var e=i*t-r*n;eo+=e*(r+t),ro+=e*(i+n),io+=3*e,r=t,i=n}var n,e,r,i;2>to&&(to=2,eo=ro=io=0),ho.point=function(u,a){ho.point=t,n=r=u,e=i=a},ho.lineEnd=function(){t(n,e)}}function be(t){function n(n,e){t.moveTo(n,e),t.arc(n,e,a,0,2*_a)}function e(n,e){t.moveTo(n,e),o.point=r}function r(n,e){t.lineTo(n,e)}function i(){o.point=n}function u(){t.closePath()}var a=4.5,o={point:n,lineStart:function(){o.point=e},lineEnd:i,polygonStart:function(){o.lineEnd=u},polygonEnd:function(){o.lineEnd=i,o.point=n},pointRadius:function(t){return a=t,o},result:vn};return o}function xe(t){var n=0,e=_a/3,r=fe(t),i=r(n,e);return i.parallels=function(t){return arguments.length?r(n=t[0]*_a/180,e=t[1]*_a/180):[180*(n/_a),180*(e/_a)]},i}function _e(t,n){function e(t,n){var e=Math.sqrt(u-2*i*Math.sin(n))/i;return[e*Math.sin(t*=i),a-e*Math.cos(t)]}var r=Math.sin(t),i=(r+Math.sin(n))/2,u=1+r*(2*i-r),a=Math.sqrt(u)/i;return e.invert=function(t,n){var e=a-n;return[Math.atan2(t,e)/i,Math.asin((u-(t*t+e*e)*i*i)/(2*i))]},e}function we(t,n){var e=t(n[0]),r=t([.5*(n[0][0]+n[1][0]),n[0][1]]),i=t([n[1][0],n[0][1]]),u=t(n[1]),a=r[1]-e[1],o=r[0]-e[0],c=i[1]-r[1],l=i[0]-r[0],f=a/o,s=c/l,h=.5*(f*s*(e[1]-i[1])+s*(e[0]+r[0])-f*(r[0]+i[0]))/(s-f),g=(.5*(e[0]+r[0])-h)/f+.5*(e[1]+r[1]),p=u[0]-h,d=u[1]-g,m=e[0]-h,v=e[1]-g,y=p*p+d*d,M=m*m+v*v,b=Math.atan2(d,p),x=Math.atan2(v,m);return function(n){var e=n[0]-h,r=n[1]-g,i=e*e+r*r,u=Math.atan2(r,e);return i>y&&M>i&&u>b&&x>u?t.invert(n):void 0}}function Se(t,n){function e(n,e){var r=Math.cos(n),i=Math.cos(e),u=t(r*i);return[u*i*Math.sin(n),u*Math.sin(e)]}return e.invert=function(t,e){var r=Math.sqrt(t*t+e*e),i=n(r),u=Math.sin(i),a=Math.cos(i);return[Math.atan2(t*u,r*a),Math.asin(r&&e*u/r)]},e}function Ee(t,n){function e(t,n){var e=Math.abs(Math.abs(n)-_a/2)0}function Ce(t,n,e){return(e[0]-n[0])*(t[1]-n[1])<(e[1]-n[1])*(t[0]-n[0])}function ze(t,n,e,r){var i=t[0],u=e[0],a=n[0]-i,o=r[0]-u,c=t[1],l=e[1],f=n[1]-c,s=r[1]-l,h=(o*(c-l)-s*(i-u))/(s*a-o*f);return[i+h*a,c+h*f]}function De(t,n){var e={list:t.map(function(t,n){return{index:n,x:t[0],y:t[1]}}).sort(function(t,n){return t.yn.y?1:t.xn.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(t,n){return{edge:t,side:n,vertex:null,l:null,r:null}},insert:function(t,n){n.l=t,n.r=t.r,t.r.l=n,t.r=n},leftBound:function(t){var n=r.leftEnd;do n=n.r;while(n!=r.rightEnd&&i.rightOf(n,t));return n=n.l},del:function(t){t.l.r=t.r,t.r.l=t.l,t.edge=null},right:function(t){return t.r},left:function(t){return t.l},leftRegion:function(t){return t.edge==null?e.bottomSite:t.edge.region[t.side]},rightRegion:function(t){return t.edge==null?e.bottomSite:t.edge.region[Mo[t.side]]}},i={bisect:function(t,n){var e={region:{l:t,r:n},ep:{l:null,r:null}},r=n.x-t.x,i=n.y-t.y,u=r>0?r:-r,a=i>0?i:-i;return e.c=t.x*r+t.y*i+.5*(r*r+i*i),u>a?(e.a=1,e.b=i/r,e.c/=r):(e.b=1,e.a=r/i,e.c/=i),e},intersect:function(t,n){var e=t.edge,r=n.edge;if(!e||!r||e.region.r==r.region.r)return null;var i=e.a*r.b-e.b*r.a;if(Math.abs(i)<1e-10)return null;var u,a,o=(e.c*r.b-r.c*e.b)/i,c=(r.c*e.a-e.c*r.a)/i,l=e.region.r,f=r.region.r;l.y=a.region.r.x;return s&&u.side==="l"||!s&&u.side==="r"?null:{x:o,y:c}},rightOf:function(t,n){var e=t.edge,r=e.region.r,i=n.x>r.x;if(i&&t.side==="l")return 1;if(!i&&t.side==="r")return 0;if(e.a===1){var u=n.y-r.y,a=n.x-r.x,o=0,c=0;if(!i&&e.b<0||i&&e.b>=0?c=o=u>=e.b*a:(c=n.x+n.y*e.b>e.c,e.b<0&&(c=!c),c||(o=1)),!o){var l=r.x-e.region.l.x;c=e.b*(a*a-u*u)h*h+g*g}return t.side==="l"?c:!c},endPoint:function(t,e,r){t.ep[e]=r,t.ep[Mo[e]]&&n(t)},distance:function(t,n){var e=t.x-n.x,r=t.y-n.y;return Math.sqrt(e*e+r*r)}},u={list:[],insert:function(t,n,e){t.vertex=n,t.ystar=n.y+e;for(var r=0,i=u.list,a=i.length;a>r;r++){var o=i[r];if(!(t.ystar>o.ystar||t.ystar==o.ystar&&n.x>o.vertex.x))break}i.splice(r,0,t)},del:function(t){for(var n=0,e=u.list,r=e.length;r>n&&e[n]!=t;++n);e.splice(n,1)},empty:function(){return u.list.length===0},nextEvent:function(t){for(var n=0,e=u.list,r=e.length;r>n;++n)if(e[n]==t)return e[n+1];return null},min:function(){var t=u.list[0];return{x:t.vertex.x,y:t.ystar}},extractMin:function(){return u.list.shift()}};r.init(),e.bottomSite=e.list.shift();for(var a,o,c,l,f,s,h,g,p,d,m,v,y,M=e.list.shift();;)if(u.empty()||(a=u.min()),M&&(u.empty()||M.yg.y&&(p=h,h=g,g=p,y="r"),v=i.bisect(h,g),s=r.createHalfEdge(v,y),r.insert(l,s),i.endPoint(v,Mo[y],m),d=i.intersect(l,s),d&&(u.del(l),u.insert(l,d,i.distance(d,h))),d=i.intersect(s,f),d&&u.insert(s,d,i.distance(d,h))}for(o=r.right(r.leftEnd);o!=r.rightEnd;o=r.right(o))n(o.edge)}function je(){return{leaf:!0,nodes:[],point:null}}function Le(t,n,e,r,i,u){if(!t(n,e,r,i,u)){var a=.5*(e+i),o=.5*(r+u),c=n.nodes;c[0]&&Le(t,c[0],e,r,a,o),c[1]&&Le(t,c[1],a,r,i,o),c[2]&&Le(t,c[2],e,o,a,u),c[3]&&Le(t,c[3],a,o,i,u)}}function Fe(t){return function(n){return 0>=n?0:n>=1?1:t(n)}}function He(t){return function(n){return 1-t(1-n)}}function Re(t){return function(n){return.5*(.5>n?t(2*n):2-t(2-2*n))}}function Pe(t){return t*t}function Oe(t){return t*t*t}function Ye(t){if(0>=t)return 0;if(t>=1)return 1;var n=t*t,e=n*t;return 4*(.5>t?e:3*(t-n)+e-.75)}function Ue(t){return function(n){return Math.pow(n,t)}}function Ie(t){return 1-Math.cos(t*_a/2)}function Ve(t){return Math.pow(2,10*(t-1)) +}function Xe(t){return 1-Math.sqrt(1-t*t)}function Ze(t,n){var e;return arguments.length<2&&(n=.45),arguments.length?e=n/(2*_a)*Math.asin(1/t):(t=1,e=n/4),function(r){return 1+t*Math.pow(2,10*-r)*Math.sin(2*(r-e)*_a/n)}}function Be(t){return t||(t=1.70158),function(n){return n*n*((t+1)*n-t)}}function $e(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}function Je(t){var n=[t.a,t.b],e=[t.c,t.d],r=Ke(n),i=Ge(n,e),u=Ke(We(e,n,-i))||0;n[0]*e[1]e;++e)(n=t[e][1])>i&&(r=e,i=n);return r}function Mr(t){return t.reduce(br,0)}function br(t,n){return t+n[1]}function xr(t,n){return _r(t,Math.ceil(Math.log(n.length)/Math.LN2+1))}function _r(t,n){for(var e=-1,r=+t[0],i=(t[1]-r)/n,u=[];++e<=n;)u[e]=i*e+r;return u}function wr(t){return[$u.min(t),$u.max(t)]}function Sr(t,n){return t.parent==n.parent?1:2}function Er(t){var n=t.children;return n&&n.length?n[0]:t._tree.thread}function kr(t){var n,e=t.children;return e&&(n=e.length)?e[n-1]:t._tree.thread}function Ar(t,n){var e=t.children;if(e&&(i=e.length))for(var r,i,u=-1;++u0&&(t=r);return t}function Nr(t,n){return t.x-n.x}function qr(t,n){return n.x-t.x}function Tr(t,n){return t.depth-n.depth}function Cr(t,n){function e(t,r){var i=t.children;if(i&&(a=i.length))for(var u,a,o=null,c=-1;++c=0;)n=i[u]._tree,n.prelim+=e,n.mod+=e,e+=n.shift+(r+=n.change)}function Dr(t,n,e){t=t._tree,n=n._tree;var r=e/(n.number-t.number);t.change+=r,n.change-=r,n.shift+=e,n.prelim+=e,n.mod+=e}function jr(t,n,e){return t._tree.ancestor.parent==n.parent?t._tree.ancestor:e}function Lr(t,n){return t.value-n.value}function Fr(t,n){var e=t._pack_next;t._pack_next=n,n._pack_prev=t,n._pack_next=e,e._pack_prev=n}function Hr(t,n){t._pack_next=n,n._pack_prev=t}function Rr(t,n){var e=n.x-t.x,r=n.y-t.y,i=t.r+n.r;return i*i-e*e-r*r>.001}function Pr(t){function n(t){f=Math.min(t.x-t.r,f),s=Math.max(t.x+t.r,s),h=Math.min(t.y-t.r,h),g=Math.max(t.y+t.r,g)}if((e=t.children)&&(l=e.length)){var e,r,i,u,a,o,c,l,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,n(r),l>1&&(i=e[1],i.x=i.r,i.y=0,n(i),l>2))for(u=e[2],Ir(r,i,u),n(u),Fr(r,u),r._pack_prev=u,Fr(u,i),i=r._pack_next,a=3;l>a;a++){Ir(r,i,u=e[a]);var p=0,d=1,m=1;for(o=i._pack_next;o!==i;o=o._pack_next,d++)if(Rr(o,u)){p=1;break}if(1==p)for(c=r._pack_prev;c!==o._pack_prev&&!Rr(c,u);c=c._pack_prev,m++);p?(m>d||d==m&&i.ra;a++)u=e[a],u.x-=v,u.y-=y,M=Math.max(M,u.r+Math.sqrt(u.x*u.x+u.y*u.y));t.r=M,e.forEach(Yr)}}function Or(t){t._pack_next=t._pack_prev=t}function Yr(t){delete t._pack_next,delete t._pack_prev}function Ur(t,n,e,r){var i=t.children;if(t.x=n+=r*t.x,t.y=e+=r*t.y,t.r*=r,i)for(var u=-1,a=i.length;++ui&&(e+=i/2,i=0),0>u&&(r+=u/2,u=0),{x:e,y:r,dx:i,dy:u}}function Gr(t){function n(n){function a(){l.push("M",u(t(f),o))}for(var c,l=[],f=[],s=-1,h=n.length,g=ln(e),p=ln(r);++s1){o=n[1],u=t[c],c++,r+="C"+(i[0]+a[0])+","+(i[1]+a[1])+","+(u[0]-o[0])+","+(u[1]-o[1])+","+u[0]+","+u[1];for(var l=2;l9&&(i=3*n/Math.sqrt(i),a[o]=i*e,a[o+1]=i*r));for(o=-1;++o<=c;)i=(t[Math.min(c,o+1)][0]-t[Math.max(0,o-1)][0])/(6*(1+a[o]*a[o])),u.push([i||0,a[o]*i||0]);return u}function vi(t){return t.length<3?Qr(t):t[0]+ai(t,mi(t))}function yi(t){var n=t[0],e=t[t.length-1];return e>n?[n,e]:[e,n]}function Mi(t){return t.rangeExtent?t.rangeExtent():yi(t.range())}function bi(t,n){return n=n-(t=+t)?1/(n-t):0,function(e){return(e-t)*n}}function xi(t,n){return n=n-(t=+t)?1/(n-t):0,function(e){return Math.max(0,Math.min(1,(e-t)*n))}}function _i(t,n,e,r){var i=e(t[0],t[1]),u=r(n[0],n[1]);return function(t){return u(i(t))}}function wi(t,n){var e,r=0,i=t.length-1,u=t[r],a=t[i];return u>a&&(e=r,r=i,i=e,e=u,u=a,a=e),(n=n(a-u))&&(t[r]=n.floor(u),t[i]=n.ceil(a)),t}function Si(t,n,e,r){var i=[],u=[],a=0,o=Math.min(t.length,n.length)-1;for(t[o]2?Si:_i,c=r?xi:bi;return a=i(t,n,c,e),o=i(n,t,c,$u.interpolate),u}function u(t){return a(t)}var a,o;return u.invert=function(t){return o(t)},u.domain=function(n){return arguments.length?(t=n.map(Number),i()):t},u.range=function(t){return arguments.length?(n=t,i()):n},u.rangeRound=function(t){return u.range(t).interpolate($u.interpolateRound)},u.clamp=function(t){return arguments.length?(r=t,i()):r},u.interpolate=function(t){return arguments.length?(e=t,i()):e},u.ticks=function(n){return qi(t,n)},u.tickFormat=function(n,e){return Ti(t,n,e)},u.nice=function(){return wi(t,Ai),i()},u.copy=function(){return Ei(t,n,e,r)},i()}function ki(t,n){return $u.rebind(t,n,"range","rangeRound","interpolate","clamp")}function Ai(t){return t=Math.pow(10,Math.round(Math.log(t)/Math.LN10)-1),t&&{floor:function(n){return Math.floor(n/t)*t},ceil:function(n){return Math.ceil(n/t)*t}}}function Ni(t,n){var e=yi(t),r=e[1]-e[0],i=Math.pow(10,Math.floor(Math.log(r/n)/Math.LN10)),u=n/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(t,n){return $u.range.apply($u,Ni(t,n))}function Ti(t,n,e){var r=-Math.floor(Math.log(Ni(t,n)[2])/Math.LN10+.01);return $u.format(e?e.replace(Va,function(t,n,e,i,u,a,o,c,l,f){return[n,e,i,u,a,o,c,l||"."+(r-2*("%"===f)),f].join("")}):",."+r+"f")}function Ci(t,n,e,r){function i(n){return t(e(n))}return i.invert=function(n){return r(t.invert(n))},i.domain=function(n){return arguments.length?(n[0]<0?(e=ji,r=Li):(e=zi,r=Di),t.domain(n.map(e)),i):t.domain().map(r)},i.base=function(t){return arguments.length?(n=+t,i):n},i.nice=function(){return t.domain(wi(t.domain(),Fi(n))),i},i.ticks=function(){var i=yi(t.domain()),u=[];if(i.every(isFinite)){var a=Math.log(n),o=Math.floor(i[0]/a),c=Math.ceil(i[1]/a),l=r(i[0]),f=r(i[1]),s=n%1?2:n;if(e===ji)for(u.push(-Math.pow(n,-o));o++0;h--)u.push(-Math.pow(n,-o)*h);else{for(;c>o;o++)for(var h=1;s>h;h++)u.push(Math.pow(n,o)*h);u.push(Math.pow(n,o))}for(o=0;u[o]f;c--);u=u.slice(o,c)}return u},i.tickFormat=function(t,u){if(arguments.length<2&&(u=jo),!arguments.length)return u;var a,o=Math.log(n),c=Math.max(.1,t/i.ticks().length),l=e===ji?(a=-1e-12,Math.floor):(a=1e-12,Math.ceil);return function(t){return t/r(o*l(e(t)/o+a))<=c?u(t):""}},i.copy=function(){return Ci(t.copy(),n,e,r)},ki(i,t)}function zi(t){return Math.log(0>t?0:t)}function Di(t){return Math.exp(t)}function ji(t){return-Math.log(t>0?0:-t)}function Li(t){return-Math.exp(-t)}function Fi(t){t=Math.log(t);var n={floor:function(n){return Math.floor(n/t)*t},ceil:function(n){return Math.ceil(n/t)*t}};return function(){return n}}function Hi(t,n){function e(n){return t(r(n))}var r=Ri(n),i=Ri(1/n);return e.invert=function(n){return i(t.invert(n))},e.domain=function(n){return arguments.length?(t.domain(n.map(r)),e):t.domain().map(i)},e.ticks=function(t){return qi(e.domain(),t)},e.tickFormat=function(t,n){return Ti(e.domain(),t,n)},e.nice=function(){return e.domain(wi(e.domain(),Ai))},e.exponent=function(t){if(!arguments.length)return n;var u=e.domain();return r=Ri(n=t),i=Ri(1/n),e.domain(u)},e.copy=function(){return Hi(t.copy(),n)},ki(e,t)}function Ri(t){return function(n){return 0>n?-Math.pow(-n,t):Math.pow(n,t)}}function Pi(t,n){function e(n){return a[((u.get(n)||u.set(n,t.push(n)))-1)%a.length]}function r(n,e){return $u.range(t.length).map(function(t){return n+e*t})}var u,a,o;return e.domain=function(r){if(!arguments.length)return t;t=[],u=new i;for(var a,o=-1,c=r.length;++oe?l():(u.active=e,h.start.call(t,f,n),a.tween.forEach(function(e,r){(r=r.call(t,f,n))&&d.push(r)}),c(r)||$u.timer(c,0,o),1)}function c(r){if(u.active!==e)return l();for(var i=(r-g)/p,a=s(i),o=d.length;o>0;)d[--o].call(t,a);return i>=1?(l(),h.end.call(t,f,n),1):void 0}function l(){return--u.count?delete u[e]:delete t.__transition__,1}var f=t.__data__,s=a.ease,h=a.event,g=a.delay,p=a.duration,d=[];return r>=g?i(r):$u.timer(i,g,o),1},0,o),a}}function iu(t,n,e,r){var i=t.id;return z(t,"function"==typeof e?function(t,u,a){t.__transition__[i].tween.set(n,r(e.call(t,t.__data__,u,a)))}:(e=r(e),function(t){t.__transition__[i].tween.set(n,e)}))}function uu(t){return null==t&&(t=""),function(){this.textContent=t}}function au(t,n){t.attr("transform",function(t){return"translate("+n(t)+",0)"})}function ou(t,n){t.attr("transform",function(t){return"translate(0,"+n(t)+")"})}function cu(t,n,e){if(r=[],e&&n.length>1){for(var r,i,u,a=yi(t.domain()),o=-1,c=n.length,l=(n[1]-n[0])/++e;++o0;)(u=+n[o]-i*l)>=a[0]&&r.push(u);for(--o,i=0;++i1?Date.UTC.apply(this,arguments):arguments[0])}function fu(t,n,e,r){for(var i,u,a=0,o=n.length,c=e.length;o>a;){if(r>=c)return-1;if(i=n.charCodeAt(a++),37===i){if(u=mc[n.charAt(a++)],!u||(r=u(t,e,r))<0)return-1}else if(i!=e.charCodeAt(r++))return-1}return r}function su(t){return RegExp("^(?:"+t.map($u.requote).join("|")+")","i")}function hu(t){for(var n=new i,e=-1,r=t.length;++er?Array(e-r+1).join(n)+t:t}function pu(t,n,e){lc.lastIndex=0;var r=lc.exec(n.substring(e));return r?e+=r[0].length:-1}function du(t,n,e){cc.lastIndex=0;var r=cc.exec(n.substring(e));return r?e+=r[0].length:-1}function mu(t,n,e){hc.lastIndex=0;var r=hc.exec(n.substring(e));return r?(t.m=gc.get(r[0].toLowerCase()),e+=r[0].length):-1}function vu(t,n,e){fc.lastIndex=0;var r=fc.exec(n.substring(e));return r?(t.m=sc.get(r[0].toLowerCase()),e+=r[0].length):-1}function yu(t,n,e){return fu(t,""+dc.c,n,e)}function Mu(t,n,e){return fu(t,""+dc.x,n,e)}function bu(t,n,e){return fu(t,""+dc.X,n,e)}function xu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+4));return r?(t.y=+r[0],e+=r[0].length):-1}function _u(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.y=wu(+r[0]),e+=r[0].length):-1}function wu(t){return t+(t>68?1900:2e3)}function Su(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.m=r[0]-1,e+=r[0].length):-1}function Eu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.d=+r[0],e+=r[0].length):-1}function ku(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.H=+r[0],e+=r[0].length):-1}function Au(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.M=+r[0],e+=r[0].length):-1}function Nu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+2));return r?(t.S=+r[0],e+=r[0].length):-1}function qu(t,n,e){vc.lastIndex=0;var r=vc.exec(n.substring(e,e+3));return r?(t.L=+r[0],e+=r[0].length):-1}function Tu(t,n,e){var r=yc.get(n.substring(e,e+=2).toLowerCase());return null==r?-1:(t.p=r,e)}function Cu(t){var n=t.getTimezoneOffset(),e=n>0?"-":"+",r=~~(Math.abs(n)/60),i=Math.abs(n)%60;return e+gu(r,"0",2)+gu(i,"0",2)}function zu(t){return t.toISOString()}function Du(t,n,e){function r(n){var e=t(n),r=u(e,1);return r-n>n-e?e:r}function i(e){return n(e=t(new Wo(e-1)),1),e}function u(t,e){return n(t=new Wo(+t),e),t}function a(t,r,u){var a=i(t),o=[];if(u>1)for(;r>a;)e(a)%u||o.push(new Date(+a)),n(a,1);else for(;r>a;)o.push(new Date(+a)),n(a,1);return o}function o(t,n,e){try{Wo=lu;var r=new lu;return r._=t,a(r,n,e)}finally{Wo=Date}}t.floor=t,t.round=r,t.ceil=i,t.offset=u,t.range=a;var c=t.utc=ju(t);return c.floor=c,c.round=ju(r),c.ceil=ju(i),c.offset=ju(u),c.range=o,t}function ju(t){return function(n,e){try{Wo=lu;var r=new lu;return r._=n,t(r,e)._}finally{Wo=Date}}}function Lu(t,n,e){function r(n){return t(n)}return r.invert=function(n){return Hu(t.invert(n))},r.domain=function(n){return arguments.length?(t.domain(n),r):t.domain().map(Hu)},r.nice=function(t){return r.domain(wi(r.domain(),function(){return t}))},r.ticks=function(e,i){var u=Fu(r.domain());if("function"!=typeof e){var a=u[1]-u[0],o=a/e,c=$u.bisect(bc,o);if(c==bc.length)return n.year(u,e);if(!c)return t.ticks(e).map(Hu);Math.log(o/bc[c-1])n?[n,e]:[e,n]}function Hu(t){return new Date(t)}function Ru(t){return function(n){for(var e=t.length-1,r=t[e];!r[1](n);)r=t[--e];return r[0](n)}}function Pu(t){var n=new Date(t,0,1);return n.setFullYear(t),n}function Ou(t){var n=t.getFullYear(),e=Pu(n),r=Pu(n+1);return n+(t-e)/(r-e)}function Yu(t){var n=new Date(Date.UTC(t,0,1));return n.setUTCFullYear(t),n}function Uu(t){var n=t.getUTCFullYear(),e=Yu(n),r=Yu(n+1);return n+(t-e)/(r-e)}function Iu(t){return t.length===1?function(n,e){t(null==n?e:null)}:t}function Vu(t){return t.responseText}function Xu(t){return JSON.parse(t.responseText)}function Zu(t){var n=Ju.createRange();return n.selectNode(Ju.body),n.createContextualFragment(t.responseText)}function Bu(t){return t.responseXML}var $u={version:"3.0.8"};Date.now||(Date.now=function(){return+new Date});var Ju=document,Gu=window;try{Ju.createElement("div").style.setProperty("opacity",0,"")}catch(Ku){var Wu=Gu.CSSStyleDeclaration.prototype,Qu=Wu.setProperty;Wu.setProperty=function(t,n,e){Qu.call(this,t,n+"",e)}}$u.ascending=function(t,n){return n>t?-1:t>n?1:t>=n?0:0/0},$u.descending=function(t,n){return t>n?-1:n>t?1:n>=t?0:0/0},$u.min=function(t,n){var e,r,i=-1,u=t.length;if(arguments.length===1){for(;++ir&&(e=r)}else{for(;++ir&&(e=r)}return e},$u.max=function(t,n){var e,r,i=-1,u=t.length;if(arguments.length===1){for(;++ie&&(e=r)}else{for(;++ie&&(e=r)}return e},$u.extent=function(t,n){var e,r,i,u=-1,a=t.length;if(arguments.length===1){for(;++ur&&(e=r),r>i&&(i=r))}else{for(;++ur&&(e=r),r>i&&(i=r))}return[e,i]},$u.sum=function(t,n){var e,r=0,i=t.length,u=-1;if(arguments.length===1)for(;++u1&&(n=n.map(e)),n=n.filter(t),n.length?$u.quantile(n.sort($u.ascending),.5):void 0},$u.bisector=function(t){return{left:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);i>r;){var u=r+i>>>1;t.call(n,n[u],u)r;){var u=r+i>>>1;er)for(;(i=t+r*++o)>n;)u.push(i/a);else for(;(i=t+r*++o)=a.length)return r?r.call(u,o):e?o.sort(e):o;for(var l,f,s,h,g=-1,p=o.length,d=a[c++],m=new i;++g=a.length)return t;var r=[],i=o[e++];return t.forEach(function(t,i){r.push({key:t,values:n(i,e)})}),i?r.sort(function(t,n){return i(t.key,n.key)}):r}var e,r,u={},a=[],o=[];return u.map=function(n,e){return t(e,n,0)},u.entries=function(e){return n(t($u.map,e,0),0)},u.key=function(t){return a.push(t),u},u.sortKeys=function(t){return o[a.length-1]=t,u},u.sortValues=function(t){return e=t,u},u.rollup=function(t){return r=t,u},u},$u.set=function(t){var n=new u;if(t)for(var e=0;e=0&&(r=t.substring(e+1),t=t.substring(0,e)),t)return arguments.length<2?this[t].on(r):this[t].on(r,n);if(arguments.length===2){if(null==n)for(t in this)this.hasOwnProperty(t)&&this[t].on(r,null);return this}},$u.event=null,$u.behavior.drag=function(){function t(){this.on("mousedown.drag",n).on("touchstart.drag",n)}function n(){function t(){var t=o.parentNode;return null!=s?$u.touches(t).filter(function(t){return t.identifier===s})[0]:$u.mouse(t)}function n(){if(!o.parentNode)return i();var n=t(),e=n[0]-h[0],r=n[1]-h[1];g|=e|r,h=n,l(),c({type:"drag",x:n[0]+a[0],y:n[1]+a[1],dx:e,dy:r})}function i(){c({type:"dragend"}),g&&(l(),$u.event.target===f&&p.on("click.drag",u,!0)),p.on(null!=s?"touchmove.drag-"+s:"mousemove.drag",null).on(null!=s?"touchend.drag-"+s:"mouseup.drag",null)}function u(){l(),p.on("click.drag",null)}var a,o=this,c=e.of(o,arguments),f=$u.event.target,s=$u.event.touches?$u.event.changedTouches[0].identifier:null,h=t(),g=0,p=$u.select(Gu).on(null!=s?"touchmove.drag-"+s:"mousemove.drag",n).on(null!=s?"touchend.drag-"+s:"mouseup.drag",i,!0);r?(a=r.apply(o,arguments),a=[a.x-h[0],a.y-h[1]]):a=[0,0],null==s&&l(),c({type:"dragstart"})}var e=s(t,"drag","dragstart","dragend"),r=null;return t.origin=function(n){return arguments.length?(r=n,t):r},$u.rebind(t,e,"on")},$u.mouse=function(t){return h(t,f())};var ra=/WebKit/.test(Gu.navigator.userAgent)?-1:0,ia=p;try{ia(Ju.documentElement.childNodes)[0].nodeType}catch(ua){ia=g}var aa=[].__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]};$u.touches=function(t,n){return arguments.length<2&&(n=f().touches),n?ia(n).map(function(n){var e=h(t,n);return e.identifier=n.identifier,e}):[]};var oa={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};$u.ns={prefix:oa,qualify:function(t){var n=t.indexOf(":"),e=t;return n>=0&&(e=t.substring(0,n),t=t.substring(n+1)),oa.hasOwnProperty(e)?{space:oa[e],local:t}:t}};var ca=function(t,n){return n.querySelector(t)},la=function(t,n){return n.querySelectorAll(t)},fa=Ju.documentElement,sa=fa.matchesSelector||fa.webkitMatchesSelector||fa.mozMatchesSelector||fa.msMatchesSelector||fa.oMatchesSelector,ha=function(t,n){return sa.call(t,n)};"function"==typeof Sizzle&&(ca=function(t,n){return Sizzle(t,n)[0]||null},la=function(t,n){return Sizzle.uniqueSort(Sizzle(t,n))},ha=Sizzle.matchesSelector);var ga=[];$u.selection=function(){return ma},$u.selection.prototype=ga,ga.select=function(t){var n,e,r,i,u=[];"function"!=typeof t&&(t=m(t));for(var a=-1,o=this.length;++ar){if("string"!=typeof t){2>r&&(n="");for(e in t)this.each(S(e,t[e],n));return this}if(2>r)return Gu.getComputedStyle(this.node(),null).getPropertyValue(t);e=""}return this.each(S(t,n,e))},ga.property=function(t,n){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(n in t)this.each(E(n,t[n]));return this}return this.each(E(t,n))},ga.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},ga.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},ga.append=function(t){function n(){return this.appendChild(Ju.createElementNS(this.namespaceURI,t))}function e(){return this.appendChild(Ju.createElementNS(t.space,t.local))}return t=$u.ns.qualify(t),this.select(t.local?e:n)},ga.insert=function(t,n){function e(e,r){return this.insertBefore(Ju.createElementNS(this.namespaceURI,t),n.call(this,e,r))}function r(e,r){return this.insertBefore(Ju.createElementNS(t.space,t.local),n.call(this,e,r))}return t=$u.ns.qualify(t),"function"!=typeof n&&(n=m(n)),this.select(t.local?r:e)},ga.remove=function(){return this.each(function(){var t=this.parentNode;t&&t.removeChild(this)})},ga.data=function(t,n){function e(t,e){var r,u,a,o=t.length,s=e.length,h=Math.min(o,s),g=Array(s),p=Array(s),d=Array(o);if(n){var m,v=new i,y=new i,M=[];for(r=-1;++rr;++r)p[r]=k(e[r]);for(;o>r;++r)d[r]=t[r]}p.update=g,p.parentNode=g.parentNode=d.parentNode=t.parentNode,c.push(p),l.push(g),f.push(d)}var r,u,a=-1,o=this.length;if(!arguments.length){for(t=Array(o=(r=this[0]).length);++au;u++){i.push(n=[]),n.parentNode=(e=this[u]).parentNode;for(var o=0,c=e.length;c>o;o++)(r=e[o])&&t.call(r,r.__data__,o)&&n.push(r)}return d(i)},ga.order=function(){for(var t=-1,n=this.length;++t=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},ga.sort=function(t){t=N.apply(this,arguments);for(var n=-1,e=this.length;++nr){if("string"!=typeof t){2>r&&(n=!1);for(e in t)this.each(q(e,t[e],n));return this}if(2>r)return(r=this.node()["__on"+t])&&r._;e=!1}return this.each(q(t,n,e))};var da=$u.map({mouseenter:"mouseover",mouseleave:"mouseout"});da.forEach(function(t){"on"+t in document&&da.remove(t)}),ga.each=function(t){return z(this,function(n,e,r){t.call(n,n.__data__,e,r)})},ga.call=function(t){var n=ia(arguments);return t.apply(n[0]=this,n),this},ga.empty=function(){return!this.node()},ga.node=function(){for(var t=0,n=this.length;n>t;t++)for(var e=this[t],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null};var ma=d([[Ju]]);ma[0].parentNode=fa,$u.select=function(t){return"string"==typeof t?ma.select(t):d([[t]])},$u.selectAll=function(t){return"string"==typeof t?ma.selectAll(t):d([ia(t)])};var va=[];$u.selection.enter=D,$u.selection.enter.prototype=va,va.append=ga.append,va.insert=ga.insert,va.empty=ga.empty,va.node=ga.node,va.select=function(t){for(var n,e,r,i,u,a=[],o=-1,c=this.length;++oe-x){var u=t[0],o=n(t[0]);r(2*w),i(u,o),a(E.of(this,arguments))}x=e}}function p(){var t=$u.touches(this),n=t[0],e=d[n.identifier];if(u=t[1]){var u,o=d[u.identifier];n=[(n[0]+u[0])/2,(n[1]+u[1])/2],e=[(e[0]+o[0])/2,(e[1]+o[1])/2],r($u.event.scale*m)}i(n,e),x=null,a(E.of(this,arguments))}var d,m,v,y,M,b,x,_=[0,0],w=1,S=Ma,E=s(t,"zoom");return t.translate=function(n){return arguments.length?(_=n.map(Number),u(),t):_},t.scale=function(n){return arguments.length?(w=+n,u(),t):w},t.scaleExtent=function(n){return arguments.length?(S=null==n?Ma:n.map(Number),t):S},t.x=function(n){return arguments.length?(y=n,v=n.copy(),_=[0,0],w=1,t):y},t.y=function(n){return arguments.length?(b=n,M=n.copy(),_=[0,0],w=1,t):b},$u.rebind(t,E,"on")};var ya,Ma=[0,1/0],ba="onwheel"in document?(ya=function(){return-$u.event.deltaY*($u.event.deltaMode?120:1)},"wheel"):"onmousewheel"in document?(ya=function(){return $u.event.wheelDelta},"mousewheel"):(ya=function(){return-$u.event.detail},"MozMousePixelScroll");j.prototype.toString=function(){return this.rgb()+""},$u.hsl=function(t,n,e){return arguments.length===1?t instanceof F?L(t.h,t.s,t.l):rn(""+t,un,L):L(+t,+n,+e)};var xa=F.prototype=new j;xa.brighter=function(t){return t=Math.pow(.7,arguments.length?t:1),L(this.h,this.s,this.l/t)},xa.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),L(this.h,this.s,t*this.l)},xa.rgb=function(){return H(this.h,this.s,this.l)};var _a=Math.PI,wa=1e-6,Sa=_a/180,Ea=180/_a;$u.hcl=function(t,n,e){return arguments.length===1?t instanceof X?V(t.h,t.c,t.l):t instanceof $?G(t.l,t.a,t.b):G((t=an((t=$u.rgb(t)).r,t.g,t.b)).l,t.a,t.b):V(+t,+n,+e)};var ka=X.prototype=new j;ka.brighter=function(t){return V(this.h,this.c,Math.min(100,this.l+Aa*(arguments.length?t:1)))},ka.darker=function(t){return V(this.h,this.c,Math.max(0,this.l-Aa*(arguments.length?t:1)))},ka.rgb=function(){return Z(this.h,this.c,this.l).rgb()},$u.lab=function(t,n,e){return arguments.length===1?t instanceof $?B(t.l,t.a,t.b):t instanceof X?Z(t.l,t.c,t.h):an((t=$u.rgb(t)).r,t.g,t.b):B(+t,+n,+e)};var Aa=18,Na=.95047,qa=1,Ta=1.08883,Ca=$.prototype=new j;Ca.brighter=function(t){return B(Math.min(100,this.l+Aa*(arguments.length?t:1)),this.a,this.b)},Ca.darker=function(t){return B(Math.max(0,this.l-Aa*(arguments.length?t:1)),this.a,this.b)},Ca.rgb=function(){return J(this.l,this.a,this.b)},$u.rgb=function(t,n,e){return arguments.length===1?t instanceof nn?tn(t.r,t.g,t.b):rn(""+t,tn,H):tn(~~t,~~n,~~e)};var za=nn.prototype=new j;za.brighter=function(t){t=Math.pow(.7,arguments.length?t:1);var n=this.r,e=this.g,r=this.b,i=30;return n||e||r?(n&&i>n&&(n=i),e&&i>e&&(e=i),r&&i>r&&(r=i),tn(Math.min(255,Math.floor(n/t)),Math.min(255,Math.floor(e/t)),Math.min(255,Math.floor(r/t)))):tn(i,i,i)},za.darker=function(t){return t=Math.pow(.7,arguments.length?t:1),tn(Math.floor(t*this.r),Math.floor(t*this.g),Math.floor(t*this.b))},za.hsl=function(){return un(this.r,this.g,this.b)},za.toString=function(){return"#"+en(this.r)+en(this.g)+en(this.b)};var Da=$u.map({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});Da.forEach(function(t,n){Da.set(t,rn(n,tn,H))}),$u.functor=ln,$u.csv=fn(",","text/csv"),$u.tsv=fn(" ","text/tab-separated-values");var ja,La,Fa=0,Ha={},Ra=null;$u.timer=function(t,n,e){if(arguments.length<3){if(arguments.length<2)n=0;else if(!isFinite(n))return;e=Date.now()}var r=Ha[t.id];r&&r.callback===t?(r.then=e,r.delay=n):Ha[t.id=++Fa]=Ra={callback:t,then:e,delay:n,next:Ra},ja||(La=clearTimeout(La),ja=1,Pa(sn))},$u.timer.flush=function(){for(var t,n=Date.now(),e=Ra;e;)t=n-e.then,e.delay||(e.flush=e.callback(t)),e=e.next;hn()};var Pa=Gu.requestAnimationFrame||Gu.webkitRequestAnimationFrame||Gu.mozRequestAnimationFrame||Gu.oRequestAnimationFrame||Gu.msRequestAnimationFrame||function(t){setTimeout(t,17)},Oa=".",Ya=",",Ua=[3,3],Ia=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"].map(pn);$u.formatPrefix=function(t,n){var e=0;return t&&(0>t&&(t*=-1),n&&(t=$u.round(t,dn(t,n))),e=1+Math.floor(1e-12+Math.log(t)/Math.LN10),e=Math.max(-24,Math.min(24,Math.floor((0>=e?e+1:e-1)/3)*3))),Ia[8+e/3]},$u.round=function(t,n){return n?Math.round(t*(n=Math.pow(10,n)))/n:Math.round(t)},$u.format=function(t){var n=Va.exec(t),e=n[1]||" ",r=n[2]||">",i=n[3]||"",u=n[4]||"",a=n[5],o=+n[6],c=n[7],l=n[8],f=n[9],s=1,h="",g=!1;switch(l&&(l=+l.substring(1)),(a||"0"===e&&"="===r)&&(a=e="0",r="=",c&&(o-=Math.floor((o-1)/4))),f){case"n":c=!0,f="g";break;case"%":s=100,h="%",f="f";break;case"p":s=100,h="%",f="r";break;case"b":case"o":case"x":case"X":u&&(u="0"+f.toLowerCase());case"c":case"d":g=!0,l=0;break;case"s":s=-1,f="r"}"#"===u&&(u=""),"r"!=f||l||(f="g"),null!=l&&("g"==f?l=Math.max(1,Math.min(21,l)):("e"==f||"f"==f)&&(l=Math.max(0,Math.min(20,l)))),f=Xa.get(f)||mn;var p=a&&c;return function(t){if(g&&t%1)return"";var n=0>t||0===t&&0>1/t?(t=-t,"-"):i;if(0>s){var d=$u.formatPrefix(t,l);t=d.scale(t),h=d.symbol}else t*=s;t=f(t,l),!a&&c&&(t=Za(t));var m=u.length+t.length+(p?0:n.length),v=o>m?Array(m=o-m+1).join(e):"";return p&&(t=Za(v+t)),Oa&&t.replace(".",Oa),n+=u,("<"===r?n+t+v:">"===r?v+n+t:"^"===r?v.substring(0,m>>=1)+n+t+v.substring(m):n+(p?t:v+t))+h}};var Va=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?(\d+)?(,)?(\.-?\d+)?([a-z%])?/i,Xa=$u.map({b:function(t){return t.toString(2)},c:function(t){return String.fromCharCode(t)},o:function(t){return t.toString(8)},x:function(t){return t.toString(16)},X:function(t){return t.toString(16).toUpperCase()},g:function(t,n){return t.toPrecision(n)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},r:function(t,n){return(t=$u.round(t,dn(t,n))).toFixed(Math.max(0,Math.min(20,dn(t*(1+1e-15),n))))}}),Za=gn;if(Ua){var Ba=Ua.length;Za=function(t){for(var n=t.lastIndexOf("."),e=n>=0?"."+t.substring(n+1):(n=t.length,""),r=[],i=0,u=Ua[0];n>0&&u>0;)r.push(t.substring(n-=u,n+u)),u=Ua[i=(i+1)%Ba];return r.reverse().join(Ya||"")+e}}$u.geo={},$u.geo.stream=function(t,n){$a.hasOwnProperty(t.type)?$a[t.type](t,n):yn(t,n)};var $a={Feature:function(t,n){yn(t.geometry,n)},FeatureCollection:function(t,n){for(var e=t.features,r=-1,i=e.length;++rt?4*_a+t:t,Qa.lineStart=Qa.lineEnd=Qa.point=vn}};$u.geo.bounds=_n(gn),$u.geo.centroid=function(t){to=no=eo=ro=io=0,$u.geo.stream(t,uo);var n;return no&&Math.abs(n=Math.sqrt(eo*eo+ro*ro+io*io))>wa?[Math.atan2(ro,eo)*Ea,Math.asin(Math.max(-1,Math.min(1,io/n)))*Ea]:void 0};var to,no,eo,ro,io,uo={sphere:function(){2>to&&(to=2,no=eo=ro=io=0)},point:wn,lineStart:En,lineEnd:kn,polygonStart:function(){2>to&&(to=2,no=eo=ro=io=0),uo.lineStart=Sn},polygonEnd:function(){uo.lineStart=En}};$u.geo.rotation=function(t){function n(n){return n=t(n[0]*Sa,n[1]*Sa),n[0]*=Ea,n[1]*=Ea,n}return t=Dn(t[0]%360*Sa,t[1]*Sa,t.length>2?t[2]*Sa:0),n.invert=function(n){return n=t.invert(n[0]*Sa,n[1]*Sa),n[0]*=Ea,n[1]*=Ea,n},n},$u.geo.circle=function(){function t(){var t="function"==typeof r?r.apply(this,arguments):r,n=Dn(-t[0]*Sa,-t[1]*Sa,0).invert,i=[];return e(null,null,1,{point:function(t,e){i.push(t=n(t,e)),t[0]*=Ea,t[1]*=Ea}}),{type:"Polygon",coordinates:[i]}}var n,e,r=[0,0],i=6;return t.origin=function(n){return arguments.length?(r=n,t):r},t.angle=function(r){return arguments.length?(e=Pn((n=+r)*Sa,i*Sa),t):n},t.precision=function(r){return arguments.length?(e=Pn(n*Sa,(i=+r)*Sa),t):i},t.angle(90)},$u.geo.distance=function(t,n){var e,r=(n[0]-t[0])*Sa,i=t[1]*Sa,u=n[1]*Sa,a=Math.sin(r),o=Math.cos(r),c=Math.sin(i),l=Math.cos(i),f=Math.sin(u),s=Math.cos(u);return Math.atan2(Math.sqrt((e=s*a)*e+(e=l*f-c*s*o)*e),c*f+l*s*o)},$u.geo.graticule=function(){function t(){return{type:"MultiLineString",coordinates:n()}}function n(){return $u.range(Math.ceil(u/m)*m,i,m).map(h).concat($u.range(Math.ceil(l/v)*v,c,v).map(g)).concat($u.range(Math.ceil(r/p)*p,e,p).filter(function(t){return Math.abs(t%m)>wa}).map(f)).concat($u.range(Math.ceil(o/d)*d,a,d).filter(function(t){return Math.abs(t%v)>wa}).map(s))}var e,r,i,u,a,o,c,l,f,s,h,g,p=10,d=p,m=90,v=360,y=2.5;return t.lines=function(){return n().map(function(t){return{type:"LineString",coordinates:t}})},t.outline=function(){return{type:"Polygon",coordinates:[h(u).concat(g(c).slice(1),h(i).reverse().slice(1),g(l).reverse().slice(1))]}},t.extent=function(n){return arguments.length?t.majorExtent(n).minorExtent(n):t.minorExtent()},t.majorExtent=function(n){return arguments.length?(u=+n[0][0],i=+n[1][0],l=+n[0][1],c=+n[1][1],u>i&&(n=u,u=i,i=n),l>c&&(n=l,l=c,c=n),t.precision(y)):[[u,l],[i,c]]},t.minorExtent=function(n){return arguments.length?(r=+n[0][0],e=+n[1][0],o=+n[0][1],a=+n[1][1],r>e&&(n=r,r=e,e=n),o>a&&(n=o,o=a,a=n),t.precision(y)):[[r,o],[e,a]]},t.step=function(n){return arguments.length?t.majorStep(n).minorStep(n):t.minorStep()},t.majorStep=function(n){return arguments.length?(m=+n[0],v=+n[1],t):[m,v]},t.minorStep=function(n){return arguments.length?(p=+n[0],d=+n[1],t):[p,d]},t.precision=function(n){return arguments.length?(y=+n,f=Yn(o,a,90),s=Un(r,e,y),h=Yn(l,c,90),g=Un(u,i,y),t):y},t.majorExtent([[-180,-90+wa],[180,90-wa]]).minorExtent([[-180,-80-wa],[180,80+wa]])},$u.geo.greatArc=function(){function t(){return{type:"LineString",coordinates:[n||r.apply(this,arguments),e||i.apply(this,arguments)]}}var n,e,r=In,i=Vn;return t.distance=function(){return $u.geo.distance(n||r.apply(this,arguments),e||i.apply(this,arguments))},t.source=function(e){return arguments.length?(r=e,n="function"==typeof e?null:e,t):r},t.target=function(n){return arguments.length?(i=n,e="function"==typeof n?null:n,t):i},t.precision=function(){return arguments.length?t:0},t},$u.geo.interpolate=function(t,n){return Xn(t[0]*Sa,t[1]*Sa,n[0]*Sa,n[1]*Sa)},$u.geo.length=function(t){return ao=0,$u.geo.stream(t,oo),ao};var ao,oo={sphere:vn,point:vn,lineStart:Zn,lineEnd:vn,polygonStart:vn,polygonEnd:vn},co=Gn(Bn,ne,re);$u.geo.projection=le,$u.geo.projectionMutator=fe,$u.geo.path=function(){function t(t){return t&&$u.geo.stream(t,r(i.pointRadius("function"==typeof u?+u.apply(this,arguments):u))),i.result()}var n,e,r,i,u=4.5;return t.area=function(t){return lo=0,$u.geo.stream(t,r(so)),lo},t.centroid=function(t){return to=eo=ro=io=0,$u.geo.stream(t,r(ho)),io?[eo/io,ro/io]:void 0},t.bounds=function(t){return _n(r)(t)},t.projection=function(e){return arguments.length?(r=(n=e)?e.stream||ge(e):gn,t):n},t.context=function(n){return arguments.length?(i=(e=n)==null?new de:new be(n),t):e},t.pointRadius=function(n){return arguments.length?(u="function"==typeof n?n:+n,t):u},t.projection($u.geo.albersUsa()).context(null)};var lo,fo,so={point:vn,lineStart:vn,lineEnd:vn,polygonStart:function(){fo=0,so.lineStart=pe},polygonEnd:function(){so.lineStart=so.lineEnd=so.point=vn,lo+=Math.abs(fo/2)}},ho={point:me,lineStart:ve,lineEnd:ye,polygonStart:function(){ho.lineStart=Me},polygonEnd:function(){ho.point=me,ho.lineStart=ve,ho.lineEnd=ye}};($u.geo.conicEqualArea=function(){return xe(_e)}).raw=_e,$u.geo.albers=function(){return $u.geo.conicEqualArea().parallels([29.5,45.5]).rotate([98,0]).center([0,38]).scale(1e3)},$u.geo.albersUsa=function(){function t(t){return n(t)(t)}function n(t){var n=t[0],e=t[1];return e>50?a:-140>n?o:21>e?c:u}var e,r,i,u=$u.geo.conicEqualArea().rotate([98,0]).center([0,38]).parallels([29.5,45.5]),a=$u.geo.conicEqualArea().rotate([160,0]).center([0,60]).parallels([55,65]),o=$u.geo.conicEqualArea().rotate([160,0]).center([0,20]).parallels([8,18]),c=$u.geo.conicEqualArea().rotate([60,0]).center([0,10]).parallels([8,18]);return t.invert=function(t){return e(t)||r(t)||i(t)||u.invert(t)},t.scale=function(n){return arguments.length?(u.scale(n),a.scale(.6*n),o.scale(n),c.scale(1.5*n),t.translate(u.translate())):u.scale()},t.translate=function(n){if(!arguments.length)return u.translate();var l=u.scale(),f=n[0],s=n[1];return u.translate(n),a.translate([f-.4*l,s+.17*l]),o.translate([f-.19*l,s+.2*l]),c.translate([f+.58*l,s+.43*l]),e=we(a,[[-180,50],[-130,72]]),r=we(o,[[-164,18],[-154,24]]),i=we(c,[[-67.5,17.5],[-65,19]]),t},t.scale(1e3)};var go=Se(function(t){return Math.sqrt(2/(1+t))},function(t){return 2*Math.asin(t/2)});($u.geo.azimuthalEqualArea=function(){return le(go)}).raw=go;var po=Se(function(t){var n=Math.acos(t);return n&&n/Math.sin(n)},gn);($u.geo.azimuthalEquidistant=function(){return le(po)}).raw=po,($u.geo.conicConformal=function(){return xe(Ee)}).raw=Ee,($u.geo.conicEquidistant=function(){return xe(ke)}).raw=ke,($u.geo.equirectangular=function(){return le(Ae)}).raw=Ae.invert=Ae;var mo=Se(function(t){return 1/t},Math.atan);($u.geo.gnomonic=function(){return le(mo)}).raw=mo,Ne.invert=function(t,n){return[t,2*Math.atan(Math.exp(n))-_a/2]},($u.geo.mercator=function(){return le(Ne)}).raw=Ne;var vo=Se(function(){return 1},Math.asin);($u.geo.orthographic=function(){return le(vo)}).raw=vo;var yo=Se(function(t){return 1/(1+t)},function(t){return 2*Math.atan(t)});($u.geo.stereographic=function(){return le(yo)}).raw=yo,qe.invert=function(t,n){return[Math.atan2(Y(t),Math.cos(n)),O(Math.sin(n)/U(t))]},($u.geo.transverseMercator=function(){return le(qe)}).raw=qe,$u.geom={},$u.geom.hull=function(t){if(t.length<3)return[];var n,e,r,i,u,a,o,c,l,f,s=t.length,h=s-1,g=[],p=[],d=0;for(n=1;s>n;++n)t[n][1]n;++n)n!==d&&(i=t[n][1]-t[d][1],r=t[n][0]-t[d][0],g.push({angle:Math.atan2(i,r),index:n}));for(g.sort(function(t,n){return t.angle-n.angle}),l=g[0].angle,c=g[0].index,o=0,n=1;h>n;++n)e=g[n].index,l==g[n].angle?(r=t[c][0]-t[d][0],i=t[c][1]-t[d][1],u=t[e][0]-t[d][0],a=t[e][1]-t[d][1],r*r+i*i>=u*u+a*a?g[n].index=-1:(g[o].index=-1,l=g[n].angle,o=n,c=e)):(l=g[n].angle,o=n,c=e);for(p.push(d),n=0,e=0;2>n;++e)g[e].index!==-1&&(p.push(g[e].index),n++);for(f=p.length;h>e;++e)if(g[e].index!==-1){for(;!Te(p[f-2],p[f-1],g[e].index,t);)--f;p[f++]=g[e].index}var m=[];for(n=0;f>n;++n)m.push(t[p[n]]);return m},$u.geom.polygon=function(t){return t.area=function(){for(var n=0,e=t.length,r=t[e-1][1]*t[0][0]-t[e-1][0]*t[0][1];++n=0?(r=t.ep.r,i=t.ep.l):(r=t.ep.l,i=t.ep.r),t.a===1?(o=r?r.y:-e,u=t.c-t.b*o,c=i?i.y:e,a=t.c-t.b*c):(u=r?r.x:-e,o=t.c-t.a*u,a=i?i.x:e,c=t.c-t.a*a);var l=[u,o],f=[a,c];n[t.region.l.index].push(l,f),n[t.region.r.index].push(l,f)}),n=n.map(function(n,e){var r=t[e][0],i=t[e][1],u=n.map(function(t){return Math.atan2(t[0]-r,t[1]-i)}),a=$u.range(n.length).sort(function(t,n){return u[t]-u[n]});return a.filter(function(t,n){return!n||u[t]-u[a[n-1]]>wa}).map(function(t){return n[t]})}),n.forEach(function(n,r){var i=n.length;if(!i)return n.push([-e,-e],[-e,e],[e,e],[e,-e]);if(!(i>2)){var u=t[r],a=n[0],o=n[1],c=u[0],l=u[1],f=a[0],s=a[1],h=o[0],g=o[1],p=Math.abs(h-f),d=g-s;if(Math.abs(d)l?-e:e;n.push([-e,m],[e,m])}else if(wa>p){var v=f>c?-e:e;n.push([v,-e],[v,e])}else{var m=(f-c)*(g-s)>(h-f)*(s-l)?e:-e,y=Math.abs(d)-p;Math.abs(y)d?m:-m,m]):(y>0&&(m*=-1),n.push([-e,m],[e,m]))}}}),n};var Mo={l:"r",r:"l"};$u.geom.delaunay=function(t){var n=t.map(function(){return[]}),e=[];return De(t,function(e){n[e.region.l.index].push(t[e.region.r.index])}),n.forEach(function(n,r){var i=t[r],u=i[0],a=i[1];n.forEach(function(t){t.angle=Math.atan2(t[0]-u,t[1]-a)}),n.sort(function(t,n){return t.angle-n.angle});for(var o=0,c=n.length-1;c>o;o++)e.push([i,n[o],n[o+1]])}),e},$u.geom.quadtree=function(t,n,e,r,i){function u(t,n,e,r,i,u){if(!isNaN(n.x)&&!isNaN(n.y))if(t.leaf){var o=t.point;o?Math.abs(o.x-n.x)+Math.abs(o.y-n.y)<.01?a(t,n,e,r,i,u):(t.point=null,a(t,o,e,r,i,u),a(t,n,e,r,i,u)):t.point=n}else a(t,n,e,r,i,u)}function a(t,n,e,r,i,a){var o=.5*(e+i),c=.5*(r+a),l=n.x>=o,f=n.y>=c,s=(f<<1)+l;t.leaf=!1,t=t.nodes[s]||(t.nodes[s]=je()),l?e=o:i=o,f?r=c:a=c,u(t,n,e,r,i,a)}var o,c=-1,l=t.length;if(arguments.length<5)if(arguments.length===3)i=e,r=n,e=n=0;else for(n=e=1/0,r=i=-1/0;++cr&&(r=o.x),o.y>i&&(i=o.y);var f=r-n,s=i-e;f>s?i=e+f:r=n+s;var h=je();return h.add=function(t){u(h,t,n,e,r,i)},h.visit=function(t){Le(t,h,n,e,r,i)},t.forEach(h.add),h};var bo=function(){return gn},xo=$u.map({linear:bo,poly:Ue,quad:function(){return Pe},cubic:function(){return Oe},sin:function(){return Ie},exp:function(){return Ve},circle:function(){return Xe},elastic:Ze,back:Be,bounce:function(){return $e}}),_o=$u.map({"in":gn,out:He,"in-out":Re,"out-in":function(t){return Re(He(t))}});$u.ease=function(t){var n=t.indexOf("-"),e=n>=0?t.substring(0,n):t,r=n>=0?t.substring(n+1):"in";return e=xo.get(e)||bo,r=_o.get(r)||gn,Fe(r(e.apply(null,Array.prototype.slice.call(arguments,1))))},$u.transform=function(t){var n=Ju.createElementNS($u.ns.prefix.svg,"g");return($u.transform=function(t){n.setAttribute("transform",t);var e=n.transform.baseVal.consolidate();return new Je(e?e.matrix:wo)})(t)},Je.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var wo={a:1,b:0,c:0,d:1,e:0,f:0};$u.interpolate=function(t,n){for(var e,r=$u.interpolators.length;--r>=0&&!(e=$u.interpolators[r](t,n)););return e},$u.interpolateNumber=function(t,n){return n-=t,function(e){return t+n*e}},$u.interpolateRound=function(t,n){return n-=t,function(e){return Math.round(t+n*e)}},$u.interpolateString=function(t,n){var e,r,i,u,a,o=0,c=0,l=[],f=[];for(So.lastIndex=0,r=0;e=So.exec(n);++r)e.index&&l.push(n.substring(o,c=e.index)),f.push({i:l.length,x:e[0]}),l.push(null),o=So.lastIndex;for(or;++r)if(a=f[r],a.x==e[0]){if(a.i)if(l[a.i+1]==null)for(l[a.i-1]+=a.x,l.splice(a.i,1),i=r+1;u>i;++i)f[i].i--;else for(l[a.i-1]+=a.x+l[a.i+1],l.splice(a.i,2),i=r+1;u>i;++i)f[i].i-=2;else if(l[a.i+1]==null)l[a.i]=a.x;else for(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1),i=r+1;u>i;++i)f[i].i--;f.splice(r,1),u--,r--}else a.x=$u.interpolateNumber(parseFloat(e[0]),parseFloat(a.x));for(;u>r;)a=f.pop(),l[a.i+1]==null?l[a.i]=a.x:(l[a.i]=a.x+l[a.i+1],l.splice(a.i+1,1)),u--;return l.length===1?l[0]==null?f[0].x:function(){return n}:function(t){for(r=0;u>r;++r)l[(a=f[r]).i]=a.x(t);return l.join("")}},$u.interpolateTransform=function(t,n){var e,r=[],i=[],u=$u.transform(t),a=$u.transform(n),o=u.translate,c=a.translate,l=u.rotate,f=a.rotate,s=u.skew,h=a.skew,g=u.scale,p=a.scale;return o[0]!=c[0]||o[1]!=c[1]?(r.push("translate(",null,",",null,")"),i.push({i:1,x:$u.interpolateNumber(o[0],c[0])},{i:3,x:$u.interpolateNumber(o[1],c[1])})):c[0]||c[1]?r.push("translate("+c+")"):r.push(""),l!=f?(l-f>180?f+=360:f-l>180&&(l+=360),i.push({i:r.push(r.pop()+"rotate(",null,")")-2,x:$u.interpolateNumber(l,f)})):f&&r.push(r.pop()+"rotate("+f+")"),s!=h?i.push({i:r.push(r.pop()+"skewX(",null,")")-2,x:$u.interpolateNumber(s,h)}):h&&r.push(r.pop()+"skewX("+h+")"),g[0]!=p[0]||g[1]!=p[1]?(e=r.push(r.pop()+"scale(",null,",",null,")"),i.push({i:e-4,x:$u.interpolateNumber(g[0],p[0])},{i:e-2,x:$u.interpolateNumber(g[1],p[1])})):(p[0]!=1||p[1]!=1)&&r.push(r.pop()+"scale("+p+")"),e=i.length,function(t){for(var n,u=-1;++u180?u-=360:-180>u&&(u+=360),function(t){return H(e+u*t,r+a*t,i+o*t)+""}},$u.interpolateLab=function(t,n){t=$u.lab(t),n=$u.lab(n);var e=t.l,r=t.a,i=t.b,u=n.l-e,a=n.a-r,o=n.b-i;return function(t){return J(e+u*t,r+a*t,i+o*t)+""}},$u.interpolateHcl=function(t,n){t=$u.hcl(t),n=$u.hcl(n);var e=t.h,r=t.c,i=t.l,u=n.h-e,a=n.c-r,o=n.l-i;return u>180?u-=360:-180>u&&(u+=360),function(t){return Z(e+u*t,r+a*t,i+o*t)+""}},$u.interpolateArray=function(t,n){var e,r=[],i=[],u=t.length,a=n.length,o=Math.min(t.length,n.length);for(e=0;o>e;++e)r.push($u.interpolate(t[e],n[e]));for(;u>e;++e)i[e]=t[e];for(;a>e;++e)i[e]=n[e];return function(t){for(e=0;o>e;++e)i[e]=r[e](t);return i}},$u.interpolateObject=function(t,n){var e,r={},i={};for(e in t)e in n?r[e]=Qe(e)(t[e],n[e]):i[e]=t[e];for(e in n)e in t||(i[e]=n[e]);return function(t){for(e in r)i[e]=r[e](t);return i}};var So=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;$u.interpolators=[$u.interpolateObject,function(t,n){return Array.isArray(n)&&$u.interpolateArray(t,n)},function(t,n){return("string"==typeof t||"string"==typeof n)&&$u.interpolateString(t+"",n+"")},function(t,n){return("string"==typeof n?Da.has(n)||/^(#|rgb\(|hsl\()/.test(n):n instanceof j)&&$u.interpolateRgb(t,n)},function(t,n){return!isNaN(t=+t)&&!isNaN(n=+n)&&$u.interpolateNumber(t,n)}],$u.layout={},$u.layout.bundle=function(){return function(t){for(var n=[],e=-1,r=t.length;++e(i-e)*o){var c=n.charge*o*o;return t.px-=u*c,t.py-=a*c,!0}if(n.point&&isFinite(o)){var c=n.pointCharge*o*o;t.px-=u*c,t.py-=a*c}}return!n.charge}}function n(t){t.px=$u.event.x,t.py=$u.event.y,o.resume()}var e,r,i,u,a,o={},c=$u.dispatch("start","tick","end"),l=[1,1],f=.9,s=Eo,h=ko,g=-30,p=.1,d=.8,m=[],v=[];return o.tick=function(){if((r*=.99)<.005)return c.end({type:"end",alpha:r=0}),!0;var n,e,o,s,h,d,y,M,b,x=m.length,_=v.length;for(e=0;_>e;++e)o=v[e],s=o.source,h=o.target,M=h.x-s.x,b=h.y-s.y,(d=M*M+b*b)&&(d=r*u[e]*((d=Math.sqrt(d))-i[e])/d,M*=d,b*=d,h.x-=M*(y=s.weight/(h.weight+s.weight)),h.y-=b*y,s.x+=M*(y=1-y),s.y+=b*y);if((y=r*p)&&(M=l[0]/2,b=l[1]/2,e=-1,y))for(;++e0?t:0:t>0&&(c.start({type:"start",alpha:r=t}),$u.timer(o.tick)),o):r},o.start=function(){function t(t,r){for(var i,u=n(e),a=-1,o=u.length;++ar;++r)c[r]=[];for(r=0;d>r;++r){var t=v[r];c[t.source.index].push(t.target),c[t.target.index].push(t.source)}}return c[e]}var e,r,c,f,p=m.length,d=v.length,y=l[0],M=l[1];for(e=0;p>e;++e)(f=m[e]).index=e,f.weight=0;for(e=0;d>e;++e)f=v[e],typeof f.source=="number"&&(f.source=m[f.source]),typeof f.target=="number"&&(f.target=m[f.target]),++f.source.weight,++f.target.weight;for(e=0;p>e;++e)f=m[e],isNaN(f.x)&&(f.x=t("x",y)),isNaN(f.y)&&(f.y=t("y",M)),isNaN(f.px)&&(f.px=f.x),isNaN(f.py)&&(f.py=f.y);if(i=[],"function"==typeof s)for(e=0;d>e;++e)i[e]=+s.call(this,v[e],e);else for(e=0;d>e;++e)i[e]=s;if(u=[],"function"==typeof h)for(e=0;d>e;++e)u[e]=+h.call(this,v[e],e);else for(e=0;d>e;++e)u[e]=h;if(a=[],"function"==typeof g)for(e=0;p>e;++e)a[e]=+g.call(this,m[e],e);else for(e=0;p>e;++e)a[e]=g;return o.resume()},o.resume=function(){return o.alpha(.1)},o.stop=function(){return o.alpha(0)},o.drag=function(){return e||(e=$u.behavior.drag().origin(gn).on("dragstart.force",rr).on("drag.force",n).on("dragend.force",ir)),arguments.length?(this.on("mouseover.force",ur).on("mouseout.force",ar).call(e),void 0):e},$u.rebind(o,c,"on")};var Eo=20,ko=1;$u.layout.hierarchy=function(){function t(n,a,o){var c=i.call(e,n,a);if(n.depth=a,o.push(n),c&&(l=c.length)){for(var l,f,s=-1,h=n.children=[],g=0,p=a+1;++sg;++g)for(i.call(t,l[0][g],p=d[g],f[0][g][1]),h=1;m>h;++h)i.call(t,l[h][g],p+=f[h-1][g][1],f[h][g][1]);return o}var n=gn,e=mr,r=vr,i=dr,u=gr,a=pr;return t.values=function(e){return arguments.length?(n=e,t):n},t.order=function(n){return arguments.length?(e="function"==typeof n?n:No.get(n)||mr,t):e},t.offset=function(n){return arguments.length?(r="function"==typeof n?n:qo.get(n)||vr,t):r},t.x=function(n){return arguments.length?(u=n,t):u},t.y=function(n){return arguments.length?(a=n,t):a},t.out=function(n){return arguments.length?(i=n,t):i},t};var No=$u.map({"inside-out":function(t){var n,e,r=t.length,i=t.map(yr),u=t.map(Mr),a=$u.range(r).sort(function(t,n){return i[t]-i[n]}),o=0,c=0,l=[],f=[];for(n=0;r>n;++n)e=a[n],c>o?(o+=u[e],l.push(e)):(c+=u[e],f.push(e));return f.reverse().concat(l)},reverse:function(t){return $u.range(t.length).reverse()},"default":mr}),qo=$u.map({silhouette:function(t){var n,e,r,i=t.length,u=t[0].length,a=[],o=0,c=[];for(e=0;u>e;++e){for(n=0,r=0;i>n;n++)r+=t[n][e][1];r>o&&(o=r),a.push(r)}for(e=0;u>e;++e)c[e]=(o-a[e])/2;return c},wiggle:function(t){var n,e,r,i,u,a,o,c,l,f=t.length,s=t[0],h=s.length,g=[];for(g[0]=c=l=0,e=1;h>e;++e){for(n=0,i=0;f>n;++n)i+=t[n][e][1];for(n=0,u=0,o=s[e][0]-s[e-1][0];f>n;++n){for(r=0,a=(t[n][e][1]-t[n][e-1][1])/(2*o);n>r;++r)a+=(t[r][e][1]-t[r][e-1][1])/o;u+=a*t[n][e][1]}g[e]=c-=i?u/i*o:0,l>c&&(l=c)}for(e=0;h>e;++e)g[e]-=l;return g},expand:function(t){var n,e,r,i=t.length,u=t[0].length,a=1/i,o=[];for(e=0;u>e;++e){for(n=0,r=0;i>n;n++)r+=t[n][e][1];if(r)for(n=0;i>n;n++)t[n][e][1]/=r;else for(n=0;i>n;n++)t[n][e][1]=a}for(e=0;u>e;++e)o[e]=0;return o},zero:vr});$u.layout.histogram=function(){function t(t,u){for(var a,o,c=[],l=t.map(e,this),f=r.call(this,l,u),s=i.call(this,f,l,u),u=-1,h=l.length,g=s.length-1,p=n?1:1/h;++u0)for(u=-1;++u=f[0]&&o<=f[1]&&(a=c[$u.bisect(s,o,1,g)-1],a.y+=p,a.push(t[u]));return c}var n=!0,e=Number,r=wr,i=xr;return t.value=function(n){return arguments.length?(e=n,t):e},t.range=function(n){return arguments.length?(r=ln(n),t):r},t.bins=function(n){return arguments.length?(i="number"==typeof n?function(t){return _r(t,n)}:ln(n),t):i},t.frequency=function(e){return arguments.length?(n=!!e,t):n},t},$u.layout.tree=function(){function t(t,i){function u(t,n){var r=t.children,i=t._tree;if(r&&(a=r.length)){for(var a,c,l,f=r[0],s=f,h=-1;++h0&&(Dr(jr(o,t,r),t,i),l+=i,f+=i),s+=o._tree.mod,l+=u._tree.mod,h+=c._tree.mod,f+=a._tree.mod;o&&!kr(a)&&(a._tree.thread=o,a._tree.mod+=s-f),u&&!Er(c)&&(c._tree.thread=u,c._tree.mod+=l-h,r=t)}return r}var c=n.call(this,t,i),l=c[0];Cr(l,function(t,n){t._tree={ancestor:t,prelim:0,mod:0,change:0,shift:0,number:n?n._tree.number+1:0}}),u(l),a(l,-l._tree.prelim);var f=Ar(l,qr),s=Ar(l,Nr),h=Ar(l,Tr),g=f.x-e(f,s)/2,p=s.x+e(s,f)/2,d=h.depth||1;return Cr(l,function(t){t.x=(t.x-g)/(p-g)*r[0],t.y=t.depth/d*r[1],delete t._tree}),c}var n=$u.layout.hierarchy().sort(null).value(null),e=Sr,r=[1,1];return t.separation=function(n){return arguments.length?(e=n,t):e},t.size=function(n){return arguments.length?(r=n,t):r},cr(t,n)},$u.layout.pack=function(){function t(t,i){var u=n.call(this,t,i),a=u[0];a.x=0,a.y=0,Cr(a,function(t){t.r=Math.sqrt(t.value)}),Cr(a,Pr);var o=r[0],c=r[1],l=Math.max(2*a.r/o,2*a.r/c);if(e>0){var f=e*l/2;Cr(a,function(t){t.r+=f}),Cr(a,Pr),Cr(a,function(t){t.r-=f}),l=Math.max(2*a.r/o,2*a.r/c)}return Ur(a,o/2,c/2,1/l),u}var n=$u.layout.hierarchy().sort(Lr),e=0,r=[1,1];return t.size=function(n){return arguments.length?(r=n,t):r},t.padding=function(n){return arguments.length?(e=+n,t):e},cr(t,n)},$u.layout.cluster=function(){function t(t,i){var u,a=n.call(this,t,i),o=a[0],c=0;Cr(o,function(t){var n=t.children;n&&n.length?(t.x=Xr(n),t.y=Vr(n)):(t.x=u?c+=e(t,u):0,t.y=0,u=t)});var l=Zr(o),f=Br(o),s=l.x-e(l,f)/2,h=f.x+e(f,l)/2;return Cr(o,function(t){t.x=(t.x-s)/(h-s)*r[0],t.y=(1-(o.y?t.y/o.y:1))*r[1]}),a}var n=$u.layout.hierarchy().sort(null).value(null),e=Sr,r=[1,1];return t.separation=function(n){return arguments.length?(e=n,t):e},t.size=function(n){return arguments.length?(r=n,t):r},cr(t,n)},$u.layout.treemap=function(){function t(t,n){for(var e,r,i=-1,u=t.length;++in?0:n),e.area=isNaN(r)||0>=r?0:r}function n(e){var u=e.children;if(u&&u.length){var a,o,c,l=s(e),f=[],h=u.slice(),p=1/0,d="slice"===g?l.dx:"dice"===g?l.dy:"slice-dice"===g?e.depth&1?l.dy:l.dx:Math.min(l.dx,l.dy);for(t(h,l.dx*l.dy/e.value),f.area=0;(c=h.length)>0;)f.push(a=h[c-1]),f.area+=a.area,"squarify"!==g||(o=r(f,d))<=p?(h.pop(),p=o):(f.area-=f.pop().area,i(f,d,l,!1),d=Math.min(l.dx,l.dy),f.length=f.area=0,p=1/0);f.length&&(i(f,d,l,!0),f.length=f.area=0),u.forEach(n)}}function e(n){var r=n.children;if(r&&r.length){var u,a=s(n),o=r.slice(),c=[];for(t(o,a.dx*a.dy/n.value),c.area=0;u=o.pop();)c.push(u),c.area+=u.area,u.z!=null&&(i(c,u.z?a.dx:a.dy,a,!o.length),c.length=c.area=0);r.forEach(e)}}function r(t,n){for(var e,r=t.area,i=0,u=1/0,a=-1,o=t.length;++ae&&(u=e),e>i&&(i=e));return r*=r,n*=n,r?Math.max(n*i*p/r,r/(n*u*p)):1/0}function i(t,n,e,r){var i,u=-1,a=t.length,o=e.x,l=e.y,f=n?c(t.area/n):0;if(n==e.dx){for((r||f>e.dy)&&(f=e.dy);++ue.dx)&&(f=e.dx);++ua;++a)o.push([+c.call(this,u=t[a],a),+l.call(this,u,a)]);for(e=$u.geom.voronoi(o),a=0;f>a;++a)e[a].data=t[a];if(n)for(a=0;f>a;++a)n(e[a]);return e}var n,e=null,r=Kr,i=Wr;return t.x=function(n){return arguments.length?(r=n,t):r},t.y=function(n){return arguments.length?(i=n,t):i},t.size=function(r){if(!arguments.length)return e;if(null==r)n=null;else{var i=+r[0],u=+r[1];n=$u.geom.polygon([[0,0],[0,u],[i,u],[i,0]]).clip}return t},t},$u.random={normal:function(t,n){var e=arguments.length;return 2>e&&(n=1),1>e&&(t=0),function(){var e,r,i;do e=Math.random()*2-1,r=Math.random()*2-1,i=e*e+r*r;while(!i||i>1);return t+n*e*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(){var t=$u.random.normal.apply($u,arguments);return function(){return Math.exp(t())}},irwinHall:function(t){return function(){for(var n=0,e=0;t>e;e++)n+=Math.random();return n/t}}},$u.scale={},$u.scale.linear=function(){return Ei([0,1],[0,1],$u.interpolate,!1)},$u.scale.log=function(){return Ci($u.scale.linear().domain([0,Math.LN10]),10,zi,Di)};var jo=$u.format(".0e");$u.scale.pow=function(){return Hi($u.scale.linear(),1)},$u.scale.sqrt=function(){return $u.scale.pow().exponent(.5)},$u.scale.ordinal=function(){return Pi([],{t:"range",a:[[]]})},$u.scale.category10=function(){return $u.scale.ordinal().range(Lo)},$u.scale.category20=function(){return $u.scale.ordinal().range(Fo)},$u.scale.category20b=function(){return $u.scale.ordinal().range(Ho)},$u.scale.category20c=function(){return $u.scale.ordinal().range(Ro)};var Lo=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Fo=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],Ho=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Ro=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];$u.scale.quantile=function(){return Oi([],[])},$u.scale.quantize=function(){return Yi(0,1,[0,1])},$u.scale.threshold=function(){return Ui([.5],[0,1])},$u.scale.identity=function(){return Ii([0,1])},$u.svg.arc=function(){function t(){var t=n.apply(this,arguments),u=e.apply(this,arguments),a=r.apply(this,arguments)+Po,o=i.apply(this,arguments)+Po,c=(a>o&&(c=a,a=o,o=c),o-a),l=_a>c?"0":"1",f=Math.cos(a),s=Math.sin(a),h=Math.cos(o),g=Math.sin(o);return c>=Oo?t?"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"M0,"+t+"A"+t+","+t+" 0 1,0 0,"+-t+"A"+t+","+t+" 0 1,0 0,"+t+"Z":"M0,"+u+"A"+u+","+u+" 0 1,1 0,"+-u+"A"+u+","+u+" 0 1,1 0,"+u+"Z":t?"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L"+t*h+","+t*g+"A"+t+","+t+" 0 "+l+",0 "+t*f+","+t*s+"Z":"M"+u*f+","+u*s+"A"+u+","+u+" 0 "+l+",1 "+u*h+","+u*g+"L0,0"+"Z"}var n=Vi,e=Xi,r=Zi,i=Bi;return t.innerRadius=function(e){return arguments.length?(n=ln(e),t):n},t.outerRadius=function(n){return arguments.length?(e=ln(n),t):e},t.startAngle=function(n){return arguments.length?(r=ln(n),t):r},t.endAngle=function(n){return arguments.length?(i=ln(n),t):i},t.centroid=function(){var t=(n.apply(this,arguments)+e.apply(this,arguments))/2,u=(r.apply(this,arguments)+i.apply(this,arguments))/2+Po;return[Math.cos(u)*t,Math.sin(u)*t]},t};var Po=-_a/2,Oo=2*_a-1e-6;$u.svg.line.radial=function(){var t=Gr($i);return t.radius=t.x,delete t.x,t.angle=t.y,delete t.y,t},ni.reverse=ei,ei.reverse=ni,$u.svg.area=function(){return Ji(gn)},$u.svg.area.radial=function(){var t=Ji($i);return t.radius=t.x,delete t.x,t.innerRadius=t.x0,delete t.x0,t.outerRadius=t.x1,delete t.x1,t.angle=t.y,delete t.y,t.startAngle=t.y0,delete t.y0,t.endAngle=t.y1,delete t.y1,t},$u.svg.chord=function(){function t(t,o){var c=n(this,u,t,o),l=n(this,a,t,o);return"M"+c.p0+r(c.r,c.p1,c.a1-c.a0)+(e(c,l)?i(c.r,c.p1,c.r,c.p0):i(c.r,c.p1,l.r,l.p0)+r(l.r,l.p1,l.a1-l.a0)+i(l.r,l.p1,c.r,c.p0))+"Z"}function n(t,n,e,r){var i=n.call(t,e,r),u=o.call(t,i,r),a=c.call(t,i,r)+Po,f=l.call(t,i,r)+Po;return{r:u,a0:a,a1:f,p0:[u*Math.cos(a),u*Math.sin(a)],p1:[u*Math.cos(f),u*Math.sin(f)]}}function e(t,n){return t.a0==n.a0&&t.a1==n.a1}function r(t,n,e){return"A"+t+","+t+" 0 "+ +(e>_a)+",1 "+n}function i(t,n,e,r){return"Q 0,0 "+r}var u=In,a=Vn,o=Gi,c=Zi,l=Bi;return t.radius=function(n){return arguments.length?(o=ln(n),t):o},t.source=function(n){return arguments.length?(u=ln(n),t):u},t.target=function(n){return arguments.length?(a=ln(n),t):a},t.startAngle=function(n){return arguments.length?(c=ln(n),t):c},t.endAngle=function(n){return arguments.length?(l=ln(n),t):l},t},$u.svg.diagonal=function(){function t(t,i){var u=n.call(this,t,i),a=e.call(this,t,i),o=(u.y+a.y)/2,c=[u,{x:u.x,y:o},{x:a.x,y:o},a];return c=c.map(r),"M"+c[0]+"C"+c[1]+" "+c[2]+" "+c[3]}var n=In,e=Vn,r=Ki;return t.source=function(e){return arguments.length?(n=ln(e),t):n},t.target=function(n){return arguments.length?(e=ln(n),t):e},t.projection=function(n){return arguments.length?(r=n,t):r},t},$u.svg.diagonal.radial=function(){var t=$u.svg.diagonal(),n=Ki,e=t.projection;return t.projection=function(t){return arguments.length?e(Wi(n=t)):n},t},$u.svg.symbol=function(){function t(t,r){return(Yo.get(n.call(this,t,r))||nu)(e.call(this,t,r))}var n=tu,e=Qi;return t.type=function(e){return arguments.length?(n=ln(e),t):n},t.size=function(n){return arguments.length?(e=ln(n),t):e},t};var Yo=$u.map({circle:nu,cross:function(t){var n=Math.sqrt(t/5)/2;return"M"+-3*n+","+-n+"H"+-n+"V"+-3*n+"H"+n+"V"+-n+"H"+3*n+"V"+n+"H"+n+"V"+3*n+"H"+-n+"V"+n+"H"+-3*n+"Z"},diamond:function(t){var n=Math.sqrt(t/(2*Io)),e=n*Io;return"M0,"+-n+"L"+e+",0"+" 0,"+n+" "+-e+",0"+"Z"},square:function(t){var n=Math.sqrt(t)/2;return"M"+-n+","+-n+"L"+n+","+-n+" "+n+","+n+" "+-n+","+n+"Z"},"triangle-down":function(t){var n=Math.sqrt(t/Uo),e=n*Uo/2;return"M0,"+e+"L"+n+","+-e+" "+-n+","+-e+"Z"},"triangle-up":function(t){var n=Math.sqrt(t/Uo),e=n*Uo/2;return"M0,"+-e+"L"+n+","+e+" "+-n+","+e+"Z"}});$u.svg.symbolTypes=Yo.keys();var Uo=Math.sqrt(3),Io=Math.tan(30*Sa);ga.transition=function(){var t,n,e=Vo||++Zo,r=[],i=Object.create(Bo);i.time=Date.now();for(var u=-1,a=this.length;++uu;u++){i.push(n=[]);for(var e=this[u],o=0,c=e.length;c>o;o++)(r=e[o])&&t.call(r,r.__data__,o)&&n.push(r)}return eu(i,this.id,this.time).ease(this.ease())},Xo.tween=function(t,n){var e=this.id;return arguments.length<2?this.node().__transition__[e].tween.get(t):z(this,null==n?function(n){n.__transition__[e].tween.remove(t)}:function(r){r.__transition__[e].tween.set(t,n)})},Xo.attr=function(t,n){function e(){this.removeAttribute(u)}function r(){this.removeAttributeNS(u.space,u.local)}if(arguments.length<2){for(n in t)this.attr(n,t[n]);return this}var i=Qe(t),u=$u.ns.qualify(t);return iu(this,"attr."+t,n,function(t){function n(){var n,e=this.getAttribute(u);return e!==t&&(n=i(e,t),function(t){this.setAttribute(u,n(t))})}function a(){var n,e=this.getAttributeNS(u.space,u.local);return e!==t&&(n=i(e,t),function(t){this.setAttributeNS(u.space,u.local,n(t))})}return null==t?u.local?r:e:(t+="",u.local?a:n)})},Xo.attrTween=function(t,n){function e(t,e){var r=n.call(this,t,e,this.getAttribute(i));return r&&function(t){this.setAttribute(i,r(t))}}function r(t,e){var r=n.call(this,t,e,this.getAttributeNS(i.space,i.local));return r&&function(t){this.setAttributeNS(i.space,i.local,r(t))}}var i=$u.ns.qualify(t);return this.tween("attr."+t,i.local?r:e)},Xo.style=function(t,n,e){function r(){this.style.removeProperty(t)}var i=arguments.length;if(3>i){if("string"!=typeof t){2>i&&(n="");for(e in t)this.style(e,t[e],n);return this}e=""}var u=Qe(t);return iu(this,"style."+t,n,function(n){function i(){var r,i=Gu.getComputedStyle(this,null).getPropertyValue(t);return i!==n&&(r=u(i,n),function(n){this.style.setProperty(t,r(n),e)})}return null==n?r:(n+="",i)})},Xo.styleTween=function(t,n,e){return arguments.length<3&&(e=""),this.tween("style."+t,function(r,i){var u=n.call(this,r,i,Gu.getComputedStyle(this,null).getPropertyValue(t));return u&&function(n){this.style.setProperty(t,u(n),e)}})},Xo.text=function(t){return iu(this,"text",t,uu)},Xo.remove=function(){return this.each("end.transition",function(){var t;!this.__transition__&&(t=this.parentNode)&&t.removeChild(this)})},Xo.ease=function(t){var n=this.id;return arguments.length<1?this.node().__transition__[n].ease:("function"!=typeof t&&(t=$u.ease.apply($u,arguments)),z(this,function(e){e.__transition__[n].ease=t}))},Xo.delay=function(t){var n=this.id;return z(this,"function"==typeof t?function(e,r,i){e.__transition__[n].delay=t.call(e,e.__data__,r,i)|0}:(t|=0,function(e){e.__transition__[n].delay=t}))},Xo.duration=function(t){var n=this.id;return z(this,"function"==typeof t?function(e,r,i){e.__transition__[n].duration=Math.max(1,t.call(e,e.__data__,r,i)|0)}:(t=Math.max(1,0|t),function(e){e.__transition__[n].duration=t}))},Xo.each=function(t,n){var e=this.id;if(arguments.length<2){var r=Bo,i=Vo;Vo=e,z(this,function(n,r,i){Bo=n.__transition__[e],t.call(n,n.__data__,r,i)}),Bo=r,Vo=i}else z(this,function(r){r.__transition__[e].event.on(t,n)});return this},Xo.transition=function(){for(var t,n,e,r,i=this.id,u=++Zo,a=[],o=0,c=this.length;c>o;o++){a.push(t=[]);for(var n=this[o],l=0,f=n.length;f>l;l++)(e=n[l])&&(r=Object.create(e.__transition__[i]),r.delay+=r.duration,ru(e,l,u,r)),t.push(e)}return eu(a,u)},$u.svg.axis=function(){function t(t){t.each(function(){var t,s=$u.select(this),h=null==l?e.ticks?e.ticks.apply(e,c):e.domain():l,g=null==n?e.tickFormat?e.tickFormat.apply(e,c):String:n,p=cu(e,h,f),d=s.selectAll(".tick.minor").data(p,String),m=d.enter().insert("line",".tick").attr("class","tick minor").style("opacity",1e-6),v=$u.transition(d.exit()).style("opacity",1e-6).remove(),y=$u.transition(d).style("opacity",1),M=s.selectAll(".tick.major").data(h,String),b=M.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),x=$u.transition(M.exit()).style("opacity",1e-6).remove(),_=$u.transition(M).style("opacity",1),w=Mi(e),S=s.selectAll(".domain").data([0]),E=(S.enter().append("path").attr("class","domain"),$u.transition(S)),k=e.copy(),A=this.__chart__||k;this.__chart__=k,b.append("line"),b.append("text");var N=b.select("line"),q=_.select("line"),T=M.select("text").text(g),C=b.select("text"),z=_.select("text");switch(r){case"bottom":t=au,m.attr("y2",u),y.attr("x2",0).attr("y2",u),N.attr("y2",i),C.attr("y",Math.max(i,0)+o),q.attr("x2",0).attr("y2",i),z.attr("x",0).attr("y",Math.max(i,0)+o),T.attr("dy",".71em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+a+"V0H"+w[1]+"V"+a);break;case"top":t=au,m.attr("y2",-u),y.attr("x2",0).attr("y2",-u),N.attr("y2",-i),C.attr("y",-(Math.max(i,0)+o)),q.attr("x2",0).attr("y2",-i),z.attr("x",0).attr("y",-(Math.max(i,0)+o)),T.attr("dy","0em").style("text-anchor","middle"),E.attr("d","M"+w[0]+","+-a+"V0H"+w[1]+"V"+-a);break;case"left":t=ou,m.attr("x2",-u),y.attr("x2",-u).attr("y2",0),N.attr("x2",-i),C.attr("x",-(Math.max(i,0)+o)),q.attr("x2",-i).attr("y2",0),z.attr("x",-(Math.max(i,0)+o)).attr("y",0),T.attr("dy",".32em").style("text-anchor","end"),E.attr("d","M"+-a+","+w[0]+"H0V"+w[1]+"H"+-a);break;case"right":t=ou,m.attr("x2",u),y.attr("x2",u).attr("y2",0),N.attr("x2",i),C.attr("x",Math.max(i,0)+o),q.attr("x2",i).attr("y2",0),z.attr("x",Math.max(i,0)+o).attr("y",0),T.attr("dy",".32em").style("text-anchor","start"),E.attr("d","M"+a+","+w[0]+"H0V"+w[1]+"H"+a)}if(e.ticks)b.call(t,A),_.call(t,k),x.call(t,k),m.call(t,A),y.call(t,k),v.call(t,k);else{var D=k.rangeBand()/2,j=function(t){return k(t)+D};b.call(t,j),_.call(t,j)}})}var n,e=$u.scale.linear(),r=$o,i=6,u=6,a=6,o=3,c=[10],l=null,f=0;return t.scale=function(n){return arguments.length?(e=n,t):e},t.orient=function(n){return arguments.length?(r=n in Jo?n+"":$o,t):r},t.ticks=function(){return arguments.length?(c=arguments,t):c},t.tickValues=function(n){return arguments.length?(l=n,t):l},t.tickFormat=function(e){return arguments.length?(n=e,t):n},t.tickSize=function(n,e){if(!arguments.length)return i;var r=arguments.length-1;return i=+n,u=r>1?+e:i,a=r>0?+arguments[r]:i,t},t.tickPadding=function(n){return arguments.length?(o=+n,t):o},t.tickSubdivide=function(n){return arguments.length?(f=+n,t):f},t};var $o="bottom",Jo={top:1,right:1,bottom:1,left:1};$u.svg.brush=function(){function t(u){u.each(function(){var u,a=$u.select(this),l=a.selectAll(".background").data([0]),s=a.selectAll(".extent").data([0]),h=a.selectAll(".resize").data(f,String);a.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),l.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),s.enter().append("rect").attr("class","extent").style("cursor","move"),h.enter().append("g").attr("class",function(t){return"resize "+t}).style("cursor",function(t){return Go[t]}).append("rect").attr("x",function(t){return/[ew]$/.test(t)?-3:null}).attr("y",function(t){return/^[ns]/.test(t)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),h.style("display",t.empty()?"none":null),h.exit().remove(),o&&(u=Mi(o),l.attr("x",u[0]).attr("width",u[1]-u[0]),e(a)),c&&(u=Mi(c),l.attr("y",u[0]).attr("height",u[1]-u[0]),r(a)),n(a)})}function n(t){t.selectAll(".resize").attr("transform",function(t){return"translate("+h[+/e$/.test(t)][0]+","+h[+/^s/.test(t)][1]+")"})}function e(t){t.select(".extent").attr("x",h[0][0]),t.selectAll(".extent,.n>rect,.s>rect").attr("width",h[1][0]-h[0][0])}function r(t){t.select(".extent").attr("y",h[0][1]),t.selectAll(".extent,.e>rect,.w>rect").attr("height",h[1][1]-h[0][1])}function i(){function i(){var t=$u.event.changedTouches;return t?$u.touches(y,t)[0]:$u.mouse(y)}function f(){$u.event.keyCode==32&&(E||(m=null,k[0]-=h[1][0],k[1]-=h[1][1],E=2),l())}function s(){$u.event.keyCode==32&&2==E&&(k[0]+=h[1][0],k[1]+=h[1][1],E=0,l())}function g(){var t=i(),u=!1;v&&(t[0]+=v[0],t[1]+=v[1]),E||($u.event.altKey?(m||(m=[(h[0][0]+h[1][0])/2,(h[0][1]+h[1][1])/2]),k[0]=h[+(t[0]l?(i=r,r=l):i=l),h[0][e]!==r||h[1][e]!==i?(u=null,h[0][e]=r,h[1][e]=i,!0):void 0}function d(){g(),x.style("pointer-events","all").selectAll(".resize").style("display",t.empty()?"none":null),$u.select("body").style("cursor",null),A.on("mousemove.brush",null).on("mouseup.brush",null).on("touchmove.brush",null).on("touchend.brush",null).on("keydown.brush",null).on("keyup.brush",null),b({type:"brushend"}),l()}var m,v,y=this,M=$u.select($u.event.target),b=a.of(y,arguments),x=$u.select(y),_=M.datum(),w=!/^(n|s)$/.test(_)&&o,S=!/^(e|w)$/.test(_)&&c,E=M.classed("extent"),k=i(),A=$u.select(Gu).on("mousemove.brush",g).on("mouseup.brush",d).on("touchmove.brush",g).on("touchend.brush",d).on("keydown.brush",f).on("keyup.brush",s);if(E)k[0]=h[0][0]-k[0],k[1]=h[0][1]-k[1];else if(_){var N=+/w$/.test(_),q=+/^n/.test(_);v=[h[1-N][0]-k[0],h[1-q][1]-k[1]],k[0]=h[N][0],k[1]=h[q][1]}else $u.event.altKey&&(m=k.slice());x.style("pointer-events","none").selectAll(".resize").style("display",null),$u.select("body").style("cursor",M.style("cursor")),b({type:"brushstart"}),g(),l()}var u,a=s(t,"brushstart","brush","brushend"),o=null,c=null,f=Ko[0],h=[[0,0],[0,0]];return t.x=function(n){return arguments.length?(o=n,f=Ko[!o<<1|!c],t):o},t.y=function(n){return arguments.length?(c=n,f=Ko[!o<<1|!c],t):c},t.extent=function(n){var e,r,i,a,l;return arguments.length?(u=[[0,0],[0,0]],o&&(e=n[0],r=n[1],c&&(e=e[0],r=r[0]),u[0][0]=e,u[1][0]=r,o.invert&&(e=o(e),r=o(r)),e>r&&(l=e,e=r,r=l),h[0][0]=0|e,h[1][0]=0|r),c&&(i=n[0],a=n[1],o&&(i=i[1],a=a[1]),u[0][1]=i,u[1][1]=a,c.invert&&(i=c(i),a=c(a)),i>a&&(l=i,i=a,a=l),h[0][1]=0|i,h[1][1]=0|a),t):(n=u||h,o&&(e=n[0][0],r=n[1][0],u||(e=h[0][0],r=h[1][0],o.invert&&(e=o.invert(e),r=o.invert(r)),e>r&&(l=e,e=r,r=l))),c&&(i=n[0][1],a=n[1][1],u||(i=h[0][1],a=h[1][1],c.invert&&(i=c.invert(i),a=c.invert(a)),i>a&&(l=i,i=a,a=l))),o&&c?[[e,i],[r,a]]:o?[e,r]:c&&[i,a])},t.clear=function(){return u=null,h[0][0]=h[0][1]=h[1][0]=h[1][1]=0,t},t.empty=function(){return o&&h[0][0]===h[1][0]||c&&h[0][1]===h[1][1]},$u.rebind(t,a,"on")};var Go={n:"ns-resize",e:"ew-resize",s:"ns-resize",w:"ew-resize",nw:"nwse-resize",ne:"nesw-resize",se:"nwse-resize",sw:"nesw-resize"},Ko=[["n","e","s","w","nw","ne","se","sw"],["e","w"],["n","s"],[]];$u.time={};var Wo=Date,Qo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];lu.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(){tc.setUTCDate.apply(this._,arguments)},setDay:function(){tc.setUTCDay.apply(this._,arguments)},setFullYear:function(){tc.setUTCFullYear.apply(this._,arguments)},setHours:function(){tc.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){tc.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){tc.setUTCMinutes.apply(this._,arguments)},setMonth:function(){tc.setUTCMonth.apply(this._,arguments)},setSeconds:function(){tc.setUTCSeconds.apply(this._,arguments)},setTime:function(){tc.setTime.apply(this._,arguments)}};var tc=Date.prototype,nc="%a %b %e %X %Y",ec="%m/%d/%Y",rc="%H:%M:%S",ic=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],uc=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],ac=["January","February","March","April","May","June","July","August","September","October","November","December"],oc=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];$u.time.format=function(t){function n(n){for(var r,i,u,a=[],o=-1,c=0;++o=12?"PM":"AM"},S:function(t,n){return gu(t.getSeconds(),n,2)},U:function(t,n){return gu($u.time.sundayOfYear(t),n,2)},w:function(t){return t.getDay()},W:function(t,n){return gu($u.time.mondayOfYear(t),n,2)},x:$u.time.format(ec),X:$u.time.format(rc),y:function(t,n){return gu(t.getFullYear()%100,n,2)},Y:function(t,n){return gu(t.getFullYear()%1e4,n,4)},Z:Cu,"%":function(){return"%"}},mc={a:pu,A:du,b:mu,B:vu,c:yu,d:Eu,e:Eu,H:ku,I:ku,L:qu,m:Su,M:Au,p:Tu,S:Nu,x:Mu,X:bu,y:_u,Y:xu},vc=/^\s*\d+/,yc=$u.map({am:0,pm:1});$u.time.format.utc=function(t){function n(t){try{Wo=lu;var n=new Wo;return n._=t,e(n)}finally{Wo=Date}}var e=$u.time.format(t);return n.parse=function(t){try{Wo=lu;var n=e.parse(t);return n&&n._}finally{Wo=Date}},n.toString=e.toString,n};var Mc=$u.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");$u.time.format.iso=Date.prototype.toISOString&&+new Date("2000-01-01T00:00:00.000Z")?zu:Mc,zu.parse=function(t){var n=new Date(t);return isNaN(n)?null:n},zu.toString=Mc.toString,$u.time.second=Du(function(t){return new Wo(Math.floor(t/1e3)*1e3)},function(t,n){t.setTime(t.getTime()+Math.floor(n)*1e3)},function(t){return t.getSeconds()}),$u.time.seconds=$u.time.second.range,$u.time.seconds.utc=$u.time.second.utc.range,$u.time.minute=Du(function(t){return new Wo(Math.floor(t/6e4)*6e4)},function(t,n){t.setTime(t.getTime()+Math.floor(n)*6e4)},function(t){return t.getMinutes()}),$u.time.minutes=$u.time.minute.range,$u.time.minutes.utc=$u.time.minute.utc.range,$u.time.hour=Du(function(t){var n=t.getTimezoneOffset()/60;return new Wo((Math.floor(t/36e5-n)+n)*36e5)},function(t,n){t.setTime(t.getTime()+Math.floor(n)*36e5)},function(t){return t.getHours()}),$u.time.hours=$u.time.hour.range,$u.time.hours.utc=$u.time.hour.utc.range,$u.time.day=Du(function(t){var n=new Wo(1970,0);return n.setFullYear(t.getFullYear(),t.getMonth(),t.getDate()),n},function(t,n){t.setDate(t.getDate()+n)},function(t){return t.getDate()-1}),$u.time.days=$u.time.day.range,$u.time.days.utc=$u.time.day.utc.range,$u.time.dayOfYear=function(t){var n=$u.time.year(t);return Math.floor((t-n-(t.getTimezoneOffset()-n.getTimezoneOffset())*6e4)/864e5)},$u.time.year=Du(function(t){return t=$u.time.day(t),t.setMonth(0,1),t},function(t,n){t.setFullYear(t.getFullYear()+n)},function(t){return t.getFullYear()}),$u.time.years=$u.time.year.range,$u.time.years.utc=$u.time.year.utc.range,Qo.forEach(function(t,n){t=t.toLowerCase(),n=7-n;var e=$u.time[t]=Du(function(t){return(t=$u.time.day(t)).setDate(t.getDate()-(t.getDay()+n)%7),t},function(t,n){t.setDate(t.getDate()+Math.floor(n)*7)},function(t){var e=$u.time.year(t).getDay();return Math.floor(($u.time.dayOfYear(t)+(e+n)%7)/7)-(e!==n)});$u.time[t+"s"]=e.range,$u.time[t+"s"].utc=e.utc.range,$u.time[t+"OfYear"]=function(t){var e=$u.time.year(t).getDay();return Math.floor(($u.time.dayOfYear(t)+(e+n)%7)/7)}}),$u.time.week=$u.time.sunday,$u.time.weeks=$u.time.sunday.range,$u.time.weeks.utc=$u.time.sunday.utc.range,$u.time.weekOfYear=$u.time.sundayOfYear,$u.time.month=Du(function(t){return t=$u.time.day(t),t.setDate(1),t},function(t,n){t.setMonth(t.getMonth()+n)},function(t){return t.getMonth()}),$u.time.months=$u.time.month.range,$u.time.months.utc=$u.time.month.utc.range;var bc=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],xc=[[$u.time.second,1],[$u.time.second,5],[$u.time.second,15],[$u.time.second,30],[$u.time.minute,1],[$u.time.minute,5],[$u.time.minute,15],[$u.time.minute,30],[$u.time.hour,1],[$u.time.hour,3],[$u.time.hour,6],[$u.time.hour,12],[$u.time.day,1],[$u.time.day,2],[$u.time.week,1],[$u.time.month,1],[$u.time.month,3],[$u.time.year,1]],_c=[[$u.time.format("%Y"),Bn],[$u.time.format("%B"),function(t){return t.getMonth()}],[$u.time.format("%b %d"),function(t){return t.getDate()!=1}],[$u.time.format("%a %d"),function(t){return t.getDay()&&t.getDate()!=1}],[$u.time.format("%I %p"),function(t){return t.getHours()}],[$u.time.format("%I:%M"),function(t){return t.getMinutes()}],[$u.time.format(":%S"),function(t){return t.getSeconds()}],[$u.time.format(".%L"),function(t){return t.getMilliseconds()}]],wc=$u.scale.linear(),Sc=Ru(_c);xc.year=function(t,n){return wc.domain(t.map(Ou)).ticks(n).map(Pu)},$u.time.scale=function(){return Lu($u.scale.linear(),xc,Sc)};var Ec=xc.map(function(t){return[t[0].utc,t[1]]}),kc=[[$u.time.format.utc("%Y"),Bn],[$u.time.format.utc("%B"),function(t){return t.getUTCMonth()}],[$u.time.format.utc("%b %d"),function(t){return t.getUTCDate()!=1}],[$u.time.format.utc("%a %d"),function(t){return t.getUTCDay()&&t.getUTCDate()!=1}],[$u.time.format.utc("%I %p"),function(t){return t.getUTCHours()}],[$u.time.format.utc("%I:%M"),function(t){return t.getUTCMinutes()}],[$u.time.format.utc(":%S"),function(t){return t.getUTCSeconds()}],[$u.time.format.utc(".%L"),function(t){return t.getUTCMilliseconds()}]],Ac=Ru(kc);return Ec.year=function(t,n){return wc.domain(t.map(Uu)).ticks(n).map(Yu)},$u.time.scale.utc=function(){return Lu($u.scale.linear(),Ec,Ac)},$u.xhr=function(t,n,e){function r(){var t=c.status;!t&&c.responseText||t>=200&&300>t||304===t?u.load.call(i,o.call(i,c)):u.error.call(i,c)}var i={},u=$u.dispatch("progress","load","error"),a={},o=gn,c=new(Gu.XDomainRequest&&/^(http(s)?:)?\/\//.test(t)?XDomainRequest:XMLHttpRequest);return"onload"in c?c.onload=c.onerror=r:c.onreadystatechange=function(){c.readyState>3&&r()},c.onprogress=function(t){var n=$u.event;$u.event=t;try{u.progress.call(i,c)}finally{$u.event=n}},i.header=function(t,n){return t=(t+"").toLowerCase(),arguments.length<2?a[t]:(null==n?delete a[t]:a[t]=n+"",i)},i.mimeType=function(t){return arguments.length?(n=null==t?null:t+"",i):n},i.response=function(t){return o=t,i},["get","post"].forEach(function(t){i[t]=function(){return i.send.apply(i,[t].concat(ia(arguments)))}}),i.send=function(e,r,u){if(arguments.length===2&&"function"==typeof r&&(u=r,r=null),c.open(e,t,!0),null==n||"accept"in a||(a.accept=n+",*/*"),c.setRequestHeader)for(var o in a)c.setRequestHeader(o,a[o]);return null!=n&&c.overrideMimeType&&c.overrideMimeType(n),null!=u&&i.on("error",u).on("load",function(t){u(null,t)}),c.send(null==r?null:r),i},i.abort=function(){return c.abort(),i},$u.rebind(i,u,"on"),arguments.length===2&&"function"==typeof n&&(e=n,n=null),null==e?i:i.get(Iu(e))},$u.text=function(){return $u.xhr.apply($u,arguments).response(Vu)},$u.json=function(t,n){return $u.xhr(t,"application/json",n).response(Xu)},$u.html=function(t,n){return $u.xhr(t,"text/html",n).response(Zu)},$u.xml=function(){return $u.xhr.apply($u,arguments).response(Bu)},$u}(); \ No newline at end of file diff --git a/src/geo/circle.js b/src/geo/circle.js index 7eb8c720..5846a079 100644 --- a/src/geo/circle.js +++ b/src/geo/circle.js @@ -48,17 +48,17 @@ d3.geo.circle = function() { // Interpolates along a circle centered at [0°, 0°], with a given radius and // precision. -function d3_geo_circleInterpolate(radians, precision) { - var cr = Math.cos(radians), - sr = Math.sin(radians); +function d3_geo_circleInterpolate(radius, precision) { + var cr = Math.cos(radius), + sr = Math.sin(radius); return function(from, to, direction, listener) { if (from != null) { from = d3_geo_circleAngle(cr, from); to = d3_geo_circleAngle(cr, to); if (direction > 0 ? from < to: from > to) from += direction * 2 * π; } else { - from = radians + direction * 2 * π; - to = radians; + from = radius + direction * 2 * π; + to = radius; } var point; for (var step = direction * precision, t = from; direction > 0 ? t > to : t < to; t -= step) { diff --git a/src/geo/clip-circle.js b/src/geo/clip-circle.js index f7f9d257..67b2605f 100644 --- a/src/geo/clip-circle.js +++ b/src/geo/clip-circle.js @@ -4,11 +4,12 @@ import "clip"; import "circle"; import "spherical"; -// Clip features against a circle centered at [0°, 0°], with a given radius. -function d3_geo_clipCircle(degrees) { - var radians = degrees * d3_radians, - cr = Math.cos(radians), - interpolate = d3_geo_circleInterpolate(radians, 6 * d3_radians); +// Clip features against a small circle centered at [0°, 0°]. +function d3_geo_clipCircle(radius) { + var cr = Math.cos(radius), + smallRadius = cr > 0, + notHemisphere = Math.abs(cr) > ε, // TODO optimise for this common case + interpolate = d3_geo_circleInterpolate(radius, 6 * d3_radians); return d3_geo_clip(visible, clipLine, interpolate); @@ -16,7 +17,6 @@ function d3_geo_clipCircle(degrees) { return Math.cos(λ) * Math.cos(φ) > cr; } - // TODO handle two invisible endpoints with visible intermediate segment. // Takes a line and cuts into visible segments. Return values used for // polygon clipping: // 0: there were intersections or the line was empty. @@ -24,9 +24,10 @@ function d3_geo_clipCircle(degrees) { // 2: there were intersections, and the first and last segments should be // rejoined. function clipLine(listener) { - var point0, - v0, - v00, + 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() { @@ -36,9 +37,13 @@ function d3_geo_clipCircle(degrees) { point: function(λ, φ) { var point1 = [λ, φ], point2, - v = visible(λ, φ); + v = visible(λ, φ), + c = smallRadius + ? v ? 0 : code(λ, φ) + : v ? code(λ + (λ < 0 ? π : -π), φ) : 0; if (!point0 && (v00 = v0 = v)) listener.lineStart(); - // handle degeneracies + // 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)) { @@ -49,7 +54,7 @@ function d3_geo_clipCircle(degrees) { } if (v !== v0) { clean = 0; - if (v0 = v) { + if (v) { // outside going in listener.lineStart(); point2 = intersect(point1, point0); @@ -61,9 +66,29 @@ function d3_geo_clipCircle(degrees) { 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; + 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(); @@ -76,18 +101,20 @@ function d3_geo_clipCircle(degrees) { } // Intersects the great circle between a and b with the clip circle. - function intersect(a, b) { + 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 x n2). + // 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 a; + if (!determinant) return !two && a; var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, @@ -95,13 +122,55 @@ function d3_geo_clipCircle(degrees) { A = d3_geo_cartesianScale(n1, c1), B = d3_geo_cartesianScale(n2, c2); d3_geo_cartesianAdd(A, B); - // Now solve |p(t)|^2 = 1. + + // Solve |p(t)|^2 = 1. var u = n1xn2, w = d3_geo_cartesianDot(A, u), uu = d3_geo_cartesianDot(u, u), - t = Math.sqrt(w * w - uu * (d3_geo_cartesianDot(A, A) - 1)), + 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); - return d3_geo_spherical(q); + 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 = Math.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] < (Math.abs(q[0] - λ0) < ε ? φ0 : φ1) + : φ0 <= q[1] && q[1] <= φ1 + : δλ > π ^ (λ0 <= q[0] && q[0] <= λ1)) { + var q1 = d3_geo_cartesianScale(u, (-w + t) / uu); + d3_geo_cartesianAdd(q1, A); + return [q, d3_geo_spherical(q1)]; + } + } + + // 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/projection.js b/src/geo/projection.js index e88d6872..842db2f8 100644 --- a/src/geo/projection.js +++ b/src/geo/projection.js @@ -48,7 +48,7 @@ function d3_geo_projectionMutator(projectAt) { projection.clipAngle = function(_) { if (!arguments.length) return clipAngle; - preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle(clipAngle = +_); + preclip = _ == null ? (clipAngle = _, d3_geo_clipAntimeridian) : d3_geo_clipCircle((clipAngle = +_) * d3_radians); return projection; }; diff --git a/test/geo/path-test.js b/test/geo/path-test.js index d51544f6..841bc880 100644 --- a/test/geo/path-test.js +++ b/test/geo/path-test.js @@ -589,6 +589,42 @@ suite.addBatch({ } } }, + "clipAngle(30)": { + topic: function() { + return d3.geo.path() + .context(testContext) + .projection(d3.geo.equirectangular() + .scale(900 / Math.PI) + .precision(0) + .clipAngle(30)); + }, + "clips lines with two invisible endpoints and visible middle": function(path) { + path({type: "LineString", coordinates: [[-45, 0], [45, 0]]}); + assert.deepEqual(testContext.buffer(), [ + {type: "moveTo", x: 330, y: 250}, + {type: "lineTo", x: 630, y: 250} + ]); + } + }, + "clipAngle(150)": { + topic: function() { + return d3.geo.path() + .context(testContext) + .projection(d3.geo.equirectangular() + .scale(900 / Math.PI) + .precision(0) + .clipAngle(150)); + }, + "clips lines with two visible endpoints and invisible middle": function(path) { + path({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} + ]); + } + }, "antimeridian cutting": { "rotate([98, 0])": {