From 3af91c35e4d639999dfeda01bb92f0a446376d3e Mon Sep 17 00:00:00 2001 From: Mike Bostock Date: Tue, 16 Oct 2012 16:40:46 -0700 Subject: [PATCH] Greedy evaluation of transition.{style,attr,text}. Rather than computing the ending value when the transition starts, the ending value is computed when the transition is scheduled. This gives more predictable behavior and makes it easier to debug evaluation errors since they occur immediately (during user code) rather than inside a d3_timer callback. The behavior of attrTween and styleTween are unchanged, since the interpolator can only be constructed once the starting value is known. This commit also removes d3.tween; I may add this back in a future commit, but I think there is probably a better way to specify an interpolator for transitions. --- Makefile | 1 - d3.js | 92 +++++++++++++++++++++++++----------- d3.min.js | 8 ++-- src/core/selection-style.js | 4 +- src/core/transition-attr.js | 43 +++++++++++++---- src/core/transition-style.js | 32 ++++++++++--- src/core/transition-text.js | 14 ++++-- src/core/tween.js | 27 ----------- test/core/tween-test.js | 27 ----------- test/env.js | 1 + 10 files changed, 141 insertions(+), 108 deletions(-) delete mode 100644 src/core/tween.js delete mode 100644 test/core/tween-test.js diff --git a/Makefile b/Makefile index c37e6b50..2a0e4ff5 100644 --- a/Makefile +++ b/Makefile @@ -123,7 +123,6 @@ d3.core.js: \ src/core/transition-each.js \ src/core/transition-transition.js \ src/core/transition-tween.js \ - src/core/tween.js \ src/core/timer.js \ src/core/mouse.js \ src/core/touches.js \ diff --git a/d3.js b/d3.js index 997741d6..d5d50466 100644 --- a/d3.js +++ b/d3.js @@ -591,11 +591,47 @@ return transition; } } - function d3_tweenNull(d, i, a) { - return a != "" && d3_tweenRemove; + function d3_transition_attr(name, b) { + function attrNull() { + this.removeAttribute(name); + } + function attrNullNS() { + this.removeAttributeNS(name.space, name.local); + } + function attrString() { + var a = this.getAttribute(name), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.setAttribute(name, i(t)); + }); + } + function attrStringNS() { + var a = this.getAttributeNS(name.space, name.local), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.setAttributeNS(name.space, name.local, i(t)); + }); + } + var interpolate; + name = d3.ns.qualify(name); + return b == null ? name.local ? attrNullNS : attrNull : (b += "", interpolate = d3_interpolateByName(name), name.local ? attrStringNS : attrString); } - function d3_tweenByName(b, name) { - return d3.tween(b, d3_interpolateByName(name)); + function d3_transition_style(name, b, priority) { + function styleNull() { + this.style.removeProperty(name); + } + function styleString() { + var a = getComputedStyle(this, null).getPropertyValue(name), i; + return a !== b && (i = interpolate(a, b), function(t) { + this.style.setProperty(name, i(t), priority); + }); + } + var interpolate; + return b == null ? styleNull : (b += "", interpolate = d3_interpolateByName(name), styleString); + } + function d3_transition_text(value) { + if (value == null) value = ""; + return function() { + this.textContent = value; + }; } function d3_timer_step() { var elapsed, now = Date.now(), t1 = d3_timer_queue; @@ -4052,7 +4088,7 @@ for (priority in name) this.each(d3_selection_style(priority, name[priority], value)); return this; } - if (n < 2) return window.getComputedStyle(this.node(), null).getPropertyValue(name); + if (n < 2) return getComputedStyle(this.node(), null).getPropertyValue(name); priority = ""; } return this.each(d3_selection_style(name, value, priority)); @@ -4371,21 +4407,26 @@ }; d3_transitionPrototype.attr = function(name, value) { if (arguments.length < 2) { - for (value in name) this.attrTween(value, d3_tweenByName(name[value], value)); + for (value in name) this.attr(value, name[value]); return this; } - return this.attrTween(name, d3_tweenByName(value, name)); + var id = this.id; + return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { + node.__transition__[id].tween.set("attr." + name, d3_transition_attr(name, value.call(node, node.__data__, i, j))); + } : (value = d3_transition_attr(name, value), function(node) { + node.__transition__[id].tween.set("attr." + name, value); + })); }; d3_transitionPrototype.attrTween = function(nameNS, tween) { function attrTween(d, i) { var f = tween.call(this, d, i, this.getAttribute(name)); - return f === d3_tweenRemove ? (this.removeAttribute(name), null) : f && function(t) { + return f && function(t) { this.setAttribute(name, f(t)); }; } function attrTweenNS(d, i) { var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); - return f === d3_tweenRemove ? (this.removeAttributeNS(name.space, name.local), null) : f && function(t) { + return f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); }; } @@ -4397,26 +4438,34 @@ if (n < 3) { if (typeof name !== "string") { if (n < 2) value = ""; - for (priority in name) this.styleTween(priority, d3_tweenByName(name[priority], priority), value); + for (priority in name) this.style(priority, name[priority], value); return this; } priority = ""; } - return this.styleTween(name, d3_tweenByName(value, name), priority); + var id = this.id; + return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { + node.__transition__[id].tween.set("style." + name, d3_transition_style(name, value.call(node, node.__data__, i, j), priority)); + } : (value = d3_transition_style(name, value, priority), function(node) { + node.__transition__[id].tween.set("style." + name, value); + })); }; d3_transitionPrototype.styleTween = function(name, tween, priority) { if (arguments.length < 3) priority = ""; return this.tween("style." + name, function(d, i) { - var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name)); - return f === d3_tweenRemove ? (this.style.removeProperty(name), null) : f && function(t) { + var f = tween.call(this, d, i, getComputedStyle(this, null).getPropertyValue(name)); + return f && function(t) { this.style.setProperty(name, f(t), priority); }; }); }; d3_transitionPrototype.text = function(value) { - return this.tween("text", function(d, i) { - this.textContent = typeof value === "function" ? value.call(this, d, i) : value; - }); + var id = this.id; + return d3_selection_each(this, typeof value === "function" ? function(node, i, j) { + node.__transition__[id].tween.set("text", d3_transition_text(value.call(node, node.__data__, i, j))); + } : (value = d3_transition_text(value), function(node) { + node.__transition__[id].tween.set("text", value); + })); }; d3_transitionPrototype.remove = function() { return this.each("end.transition", function() { @@ -4490,17 +4539,6 @@ node.__transition__[id].tween.set(name, tween); }); }; - d3.tween = function(b, interpolate) { - function tweenFunction(d, i, a) { - var v = b.call(this, d, i); - return v == null ? a != "" && d3_tweenRemove : a != v && interpolate(a, v + ""); - } - function tweenString(d, i, a) { - return a != b && interpolate(a, b); - } - return typeof b === "function" ? tweenFunction : b == null ? d3_tweenNull : (b += "", tweenString); - }; - var d3_tweenRemove = {}; var d3_timer_id = 0, d3_timer_byId = {}, d3_timer_queue = null, d3_timer_interval, d3_timer_timeout; d3.timer = function(callback, delay, then) { if (arguments.length < 3) { diff --git a/d3.min.js b/d3.min.js index 3e77fa75..037ad522 100644 --- a/d3.min.js +++ b/d3.min.js @@ -1,4 +1,4 @@ -(function(){function e(e,t){try{for(var n in t)Object.defineProperty(e.prototype,n,{value:t[n],enumerable:!1})}catch(r){e.prototype=t}}function t(e){var t=-1,n=e.length,r=[];while(++t=0?e.substring(t):(t=e.length,""),r=[];while(t>0)r.push(e.substring(t-=3,t+3));return r.reverse().join(",")+n}function S(e,t){var n=Math.pow(10,Math.abs(8-t)*3);return{scale:t>8?function(e){return e/n}:function(e){return e*n},symbol:e}}function T(e){return function(t){return t<=0?0:t>=1?1:e(t)}}function N(e){return function(t){return 1-e(1-t)}}function C(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}}function k(e){return e*e}function L(e){return e*e*e}function A(e){if(e<=0)return 0;if(e>=1)return 1;var t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function O(e){return function(t){return Math.pow(t,e)}}function M(e){return 1-Math.cos(e*ys/2)}function _(e){return Math.pow(2,10*(e-1))}function D(e){return 1-Math.sqrt(1-e*e)}function P(e,t){var n;return arguments.length<2&&(t=.45),arguments.length<1?(e=1,n=t/4):n=t/(2*ys)*Math.asin(1/e),function(r){return 1+e*Math.pow(2,10*-r)*Math.sin((r-n)*2*ys/t)}}function H(e){return e||(e=1.70158),function(t){return t*t*((e+1)*t-e)}}function B(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}function j(){d3.event.stopPropagation(),d3.event.preventDefault()}function F(){var e=d3.event,t;while(t=e.sourceEvent)e=t;return e}function I(e){var t=new g,n=0,r=arguments.length;while(++n360?e-=360:e<0&&(e+=360),e<60?s+(o-s)*e/60:e<180?o:e<240?s+(o-s)*(240-e)/60:s}function i(e){return Math.round(r(e)*255)}var s,o;return e%=360,e<0&&(e+=360),t=t<0?0:t>1?1:t,n=n<0?0:n>1?1:n,o=n<=.5?n*(1+t):n+t-n*t,s=2*n-o,J(i(e+120),i(e),i(e-120))}function st(e,t,n){return new ot(e,t,n)}function ot(e,t,n){this.h=e,this.c=t,this.l=n}function ut(e,t,n){return at(n,Math.cos(e*=ws)*t,Math.sin(e)*t)}function at(e,t,n){return new ft(e,t,n)}function ft(e,t,n){this.l=e,this.a=t,this.b=n}function lt(e,t,n){var r=(e+16)/116,i=r+t/500,s=r-n/200;return i=ht(i)*Ws,r=ht(r)*Xs,s=ht(s)*Vs,J(dt(3.2404542*i-1.5371385*r-.4985314*s),dt(-0.969266*i+1.8760108*r+.041556*s),dt(.0556434*i-.2040259*r+1.0572252*s))}function ct(e,t,n){return st(Math.atan2(n,t)/ys*180,Math.sqrt(t*t+n*n),e)}function ht(e){return e>.206893034?e*e*e:(e-4/29)/7.787037}function pt(e){return e>.008856?Math.pow(e,1/3):7.787037*e+4/29}function dt(e){return Math.round(255*(e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055))}function vt(e){return Ns(e,Zs),e}function mt(e){return function(){return Js(e,this)}}function gt(e){return function(){return Ks(e,this)}}function yt(e,t){function n(){this.removeAttribute(e)}function r(){this.removeAttributeNS(e.space,e.local)}function i(){this.setAttribute(e,t)}function s(){this.setAttributeNS(e.space,e.local,t)}function o(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}function u(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}return e=d3.ns.qualify(e),t==null?e.local?r:n:typeof t=="function"?e.local?u:o:e.local?s:i}function bt(e){return new RegExp("(?:^|\\s+)"+d3.requote(e)+"(?:\\s+|$)","g")}function wt(e,t){function n(){var n=-1;while(++n0&&(e=e.substring(0,o)),t?i:r}function Lt(e,t){for(var n=0,r=e.length;nn?a():(s.active=n,c.start.call(e,f,t),o.tween.forEach(function(n,r){(r=r.call(e,f,t))&&v.push(r)}),u(r)||d3.timer(u,0,h),1)}function u(r){if(s.active!==n)return a();var i=(r-p)/d,o=l(i),u=v.length;while(u>0)v[--u].call(e,o);if(i>=1)return a(),c.end.call(e,f,t),1}function a(){return--s.count?delete s[n]:delete e.__transition__,1}var f=e.__data__,l=o.ease,c=o.event,h=o.time,p=o.delay,d=o.duration,v=[];return p<=r?i(r):d3.timer(i,p,h),1}),o}function _t(e,t,n){return n!=""&&oo}function Dt(e,t){return d3.tween(e,W(t))}function Pt(){var e,t=Date.now(),n=fo;while(n)e=t-n.then,e>=n.delay&&(n.flush=n.callback(e)),n=n.next;var r=Ht()-t;r>24?(isFinite(r)&&(clearTimeout(co),co=setTimeout(Pt,r)),lo=0):(lo=1,ho(Pt))}function Ht(){var e=null,t=fo,n=Infinity;while(t)t.flush?(delete ao[t.callback.id],t=e?e.next=t.next:fo=t.next):(n=Math.min(n,t.then+t.delay),t=(e=t).next);return n}function Bt(e,t){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();if(po<0&&(window.scrollX||window.scrollY)){n=d3.select(document.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=n[0][0].getScreenCTM();po=!i.f&&!i.e,n.remove()}return po?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}function jt(){}function Ft(e){var t=e[0],n=e[e.length-1];return t2?Kt:Jt,a=r?V:X;return o=i(e,t,a,n),u=i(t,e,a,d3.interpolate),s}function s(e){return o(e)}var o,u;return s.invert=function(e){return u(e)},s.domain=function(t){return arguments.length?(e=t.map(Number),i()):e},s.range=function(e){return arguments.length?(t=e,i()):t},s.rangeRound=function(e){return s.range(e).interpolate(d3.interpolateRound)},s.clamp=function(e){return arguments.length?(r=e,i()):r},s.interpolate=function(e){return arguments.length?(n=e,i()):n},s.ticks=function(t){return Vt(e,t)},s.tickFormat=function(t){return $t(e,t)},s.nice=function(){return qt(e,Wt),i()},s.copy=function(){return Ut(e,t,n,r)},i()}function zt(e,t){return d3.rebind(e,t,"range","rangeRound","interpolate","clamp")}function Wt(e){return e=Math.pow(10,Math.round(Math.log(e)/Math.LN10)-1),e&&{floor:function(t){return Math.floor(t/e)*e},ceil:function(t){return Math.ceil(t/e)*e}}}function Xt(e,t){var n=Ft(e),r=n[1]-n[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),s=t/r*i;return s<=.15?i*=10:s<=.35?i*=5:s<=.75&&(i*=2),n[0]=Math.ceil(n[0]/i)*i,n[1]=Math.floor(n[1]/i)*i+i*.5,n[2]=i,n}function Vt(e,t){return d3.range.apply(d3,Xt(e,t))}function $t(e,t){return d3.format(",."+Math.max(0,-Math.floor(Math.log(Xt(e,t)[2])/Math.LN10+.01))+"f")}function Jt(e,t,n,r){var i=n(e[0],e[1]),s=r(t[0],t[1]);return function(e){return s(i(e))}}function Kt(e,t,n,r){var i=[],s=[],o=0,u=Math.min(e.length,t.length)-1;e[u]0;f--)i.push(r(s)*f)}else{for(;sa;o--);i=i.slice(s,o)}return i},n.tickFormat=function(e,i){arguments.length<2&&(i=vo);if(arguments.length<1)return i;var s=Math.max(.1,e/n.ticks().length),o=t===Yt?(u=-1e-12,Math.floor):(u=1e-12,Math.ceil),u;return function(e){return e/r(o(t(e)+u))<=s?i(e):""}},n.copy=function(){return Qt(e.copy(),t)},zt(n,e)}function Gt(e){return Math.log(e<0?0:e)/Math.LN10}function Yt(e){return-Math.log(e>0?0:-e)/Math.LN10}function Zt(e,t){function n(t){return e(r(t))}var r=en(t),i=en(1/t);return n.invert=function(t){return i(e.invert(t))},n.domain=function(t){return arguments.length?(e.domain(t.map(r)),n):e.domain().map(i)},n.ticks=function(e){return Vt(n.domain(),e)},n.tickFormat=function(e){return $t(n.domain(),e)},n.nice=function(){return n.domain(qt(n.domain(),Wt))},n.exponent=function(e){if(!arguments.length)return t;var s=n.domain();return r=en(t=e),i=en(1/t),n.domain(s)},n.copy=function(){return Zt(e.copy(),t)},zt(n,e)}function en(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function tn(e,t){function n(t){return o[((s.get(t)||s.set(t,e.push(t)))-1)%o.length]}function i(t,n){return d3.range(e.length).map(function(e){return t+n*e})}var s,o,u;return n.domain=function(i){if(!arguments.length)return e;e=[],s=new r;var o=-1,u=i.length,a;while(++o1){u=t[1],s=e[a],a++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(s[0]-u[0])+","+(s[1]-u[1])+","+s[0]+","+s[1];for(var f=2;f9&&(s=n*3/Math.sqrt(s),o[u]=s*r,o[u+1]=s*i));u=-1;while(++u<=a)s=(e[Math.min(a,u+1)][0]-e[Math.max(0,u-1)][0])/(6*(1+o[u]*o[u])),t.push([s||0,o[u]*s||0]);return t}function _n(e){return e.length<3?dn(e):e[0]+En(e,Mn(e))}function Dn(e){var t,n=-1,r=e.length,i,s;while(++n1){var r=Ft(e.domain()),i,s=-1,o=t.length,u=(t[1]-t[0])/++n,a,f;while(++s0;)(f=+t[s]-a*u)>=r[0]&&i.push(f);for(--s,a=0;++ar&&(n=t,r=i);return n}function cr(e){return e.reduce(hr,0)}function hr(e,t){return e+t[1]}function pr(e,t){return dr(e,Math.ceil(Math.log(t.length)/Math.LN2+1))}function dr(e,t){var n=-1,r=+e[0],i=(e[1]-r)/t,s=[];while(++n<=t)s[n]=i*n+r;return s}function vr(e){return[d3.min(e),d3.max(e)]}function mr(e,t){return d3.rebind(e,t,"sort","children","value"),e.links=wr,e.nodes=function(t){return Bo=!0,(e.nodes=e)(t)},e}function gr(e){return e.children}function yr(e){return e.value}function br(e,t){return t.value-e.value}function wr(e){return d3.merge(e.map(function(e){return(e.children||[]).map(function(t){return{source:e,target:t}})}))}function Er(e,t){return e.value-t.value}function Sr(e,t){var n=e._pack_next;e._pack_next=t,t._pack_prev=e,t._pack_next=n,n._pack_prev=t}function xr(e,t){e._pack_next=t,t._pack_prev=e}function Tr(e,t){var n=t.x-e.x,r=t.y-e.y,i=e.r+t.r;return i*i-n*n-r*r>.001}function Nr(e){function t(e){r=Math.min(e.x-e.r,r),i=Math.max(e.x+e.r,i),s=Math.min(e.y-e.r,s),o=Math.max(e.y+e.r,o)}if(!(n=e.children)||!(p=n.length))return;var n,r=Infinity,i=-Infinity,s=Infinity,o=-Infinity,u,a,f,l,c,h,p;n.forEach(Cr),u=n[0],u.x=-u.r,u.y=0,t(u);if(p>1){a=n[1],a.x=a.r,a.y=0,t(a);if(p>2){f=n[2],Ar(u,a,f),t(f),Sr(u,f),u._pack_prev=f,Sr(f,a),a=u._pack_next;for(l=3;l0&&(e=r)}return e}function Fr(e,t){return e.x-t.x}function Ir(e,t){return t.x-e.x}function qr(e,t){return e.depth-t.depth}function Rr(e,t){function n(e,r){var i=e.children;if(i&&(a=i.length)){var s,o=null,u=-1,a;while(++u=0)s=r[i]._tree,s.prelim+=t,s.mod+=t,t+=s.shift+(n+=s.change)}function zr(e,t,n){e=e._tree,t=t._tree;var r=n/(t.number-e.number);e.change+=r,t.change-=r,t.shift+=n,t.prelim+=n,t.mod+=n}function Wr(e,t,n){return e._tree.ancestor.parent==t.parent?e._tree.ancestor:n}function Xr(e){return{x:e.x,y:e.y,dx:e.dx,dy:e.dy}}function Vr(e,t){var n=e.x+t[3],r=e.y+t[0],i=e.dx-t[1]-t[3],s=e.dy-t[0]-t[2];return i<0&&(n+=i/2,i=0),s<0&&(r+=s/2,s=0),{x:n,y:r,dx:i,dy:s}}function $r(e,t){function n(e,n){return d3.xhr(e,t,n).response(r)}function r(e){return n.parse(e.responseText)}function i(t){return t.map(s).join(e)}function s(e){return u.test(e)?'"'+e.replace(/\"/g,'""')+'"':e}var o=new RegExp("\r\n|["+e+"\r\n]","g"),u=new RegExp('["'+e+"\n]"),a=e.charCodeAt(0);return n.parse=function(e){var t;return n.parseRows(e,function(e,n){if(n){var r={},i=-1,s=t.length;while(++i=e.length)return i;if(l)return l=!1,r;var t=o.lastIndex;if(e.charCodeAt(t)===34){var n=t;while(n++l}function r(e,r,s){if(!(f=e.length))return;var o=t(e[0]),u=n(o),a=u&&s!=null,f;u&&r.moveTo(o[0],o[1]);for(var l=1;lt;m-=v){var g=Math.cos(m),y=Math.sin(m),b=ei([h[0]+c*(g*i+y*l),h[1]+c*(g*s+y*p),h[2]+c*(g*o+y*d)]);n.lineTo(b[0],b[1])}}var o=e*ws,u=6*ws,a=[1,0,0],f=[0,-1,0],l=Math.cos(o),c=Math.sin(o),h=ii(a,l),p=Yr(h);return{point:function(e,r){n(e=t(e))&&r.moveTo(e[0],e[1])},line:function(e,t){r(e,t)},polygon:function(e,t){Gr(e,t,r,s,p)}}}function Gr(e,t,n,r,i){var s=0,o=[],u=[],a=oi(n),f=0;e.forEach(function(e){var n=a(e,t),r=n[1];f+=n[0];var i=r.length;if(i>1){var s=r[0],o=r[i-1],l=s[0],c=o[o.length-1];l[0]===c[0]&&l[1]===c[1]&&(r.shift(),r.pop(),r.push(o.concat(s)))}u=u.concat(r)});if(f>0){f=[],u.push(f=[]),x={lineTo:function(e,t){f.push([e,t])}};for(var l=0;l<4;l++)r({angle:-l*ys/2},{angle:-(l+1)*ys/2},x);f.push(f[0])}u.forEach(function(e){var n=e[0],r=e[e.length-1];if(n[0]!==r[0]||n[1]!==r[1]){var u={point:r,angle:i(r),points:[],other:null},a={point:n,angle:i(n),points:e,other:u};o.push(a,u),s++}else{var f=e[0],l=e.length-1,c=0;t.moveTo(f[0],f[1]);while(++c0&&(e[0]-t[0])*e[1]+e[0]*(t[1]-e[1])>0)return 1}else if(t[1]<=0&&(e[0]-t[0])*e[1]+e[0]*(t[1]-e[1])<0)return-1;return 0}function ai(e,t){function n(n,r){var i=e(n,r);return t(i[0],i[1])}return e===fi?t:t===fi?e:(e.invert&&t.invert&&(n.invert=function(n,r){var i=t.invert(n,r);return e.invert(i[0],i[1])}),n)}function fi(e,t){return[e,t]}function li(e,t){var n=d3.range(e,t-bs,Jo).concat(t);return function(e){return n.map(function(t){return[e,t]})}}function ci(e,t){var n=d3.range(e,t-bs,Jo).concat(t);return function(e){return n.map(function(t){return[t,e]})}}function hi(e){return e.source}function pi(e){return e.target}function di(){function e(e){var t=Math.sin(e*=p)*d,n=Math.sin(p-e)*d,r=n*s+t*c,u=n*o+t*h,a=n*i+t*l;return[Math.atan2(u,r)/ws,Math.atan2(a,Math.sqrt(r*r+u*u))/ws]}var t,n,r,i,s,o,u,a,f,l,c,h,p,d;return e.distance=function(){return p==null&&(d=1/Math.sin(p=Math.acos(Math.max(-1,Math.min(1,i*l+r*f*Math.cos(u-t)))))),p},e.source=function(u){var a=Math.cos(t=u[0]*ws),f=Math.sin(t);return r=Math.cos(n=u[1]*ws),i=Math.sin(n),s=r*a,o=r*f,p=null,e},e.target=function(t){var n=Math.cos(u=t[0]*ws),r=Math.sin(u);return f=Math.cos(a=t[1]*ws),l=Math.sin(a),c=f*n,h=f*r,p=null,e},e}function vi(e,t){var n=di().source(e).target -(t);return n.distance(),n}function mi(e,t){return[e/(2*ys),Math.max(-0.5,Math.min(.5,Math.log(Math.tan(ys/4+t/2))/(2*ys)))]}function gi(e){return"m0,"+e+"a"+e+","+e+" 0 1,1 0,"+ -2*e+"a"+e+","+e+" 0 1,1 0,"+2*e+"z"}function yi(e){return bi(function(){return e})()}function bi(e){function t(e){return e=f(e[0]*ws,e[1]*ws),[e[0]*l+y,b-e[1]*l]}function n(e){return e=f.invert((e[0]-y)/l,(b-e[1])/l),[e[0]*Es,e[1]*Es]}function r(e){function t(t,n){var r=s(o=a=t,u=f=n);e.moveTo(l=r[0],c=r[1])}function n(t,n){var i=s(t,n);r(l,c,a,f,l=i[0],c=i[1],a=t,f=n,h),e.lineTo(l,c)}function r(t,n,i,o,u,a,f,l,c){var h=u-t,p=a-n,d=h*h+p*p;if(d>4*w&&c--){var v=Math.sin(o),m=Math.cos(o),g=Math.sin(l),y=Math.cos(l),b=v*g+m*y*Math.cos(f-i),E=1/(Math.SQRT2*Math.sqrt(1+b)),S=E*(m*Math.cos(i)+y*Math.cos(f)),x=E*(m*Math.sin(i)+y*Math.sin(f)),T=E*(v+g),N=Math.asin(Math.max(-1,Math.min(1,T))),C=Math.abs(S)d-bs?r(t,n,i,o,u,a,C,N,c):_*_/d>w&&(r(t,n,i,o,L,A,C,N,c),e.lineTo(L,A),r(L,A,C,N,u,a,f,l,c))}}function i(){var t=s(o,u);r(l,c,a,f,t[0],t[1],o,u,h),e.closePath()}var o,u,a,f,l,c,h=w>0&&16;return{moveTo:t,lineTo:n,closePath:i}}function i(e){return a(e[0]*ws,e[1]*ws)}function s(e,t){var n=u(e,t);return[n[0]*l+y,b-n[1]*l]}function o(){f=ai(a=Ti(v,m,g),u);var e=u(p,d);return y=c-e[0]*l,b=h+e[1]*l,t}var u,a,f,l=150,c=480,h=250,p=0,d=0,v=0,m=0,g=0,y=c,b=h,w=.5,E=Ei(i),S=null;return t.point=function(e,t){E.point(e,r(t))},t.line=function(e,t){E.line(e,r(t))},t.polygon=function(e,t){E.polygon(e,r(t))},t.clipAngle=function(e){return arguments.length?(E=e==null?(S=e,Ei(i)):Qr(S=+e,i),t):S},t.scale=function(e){return arguments.length?(l=+e,o()):l},t.translate=function(e){return arguments.length?(c=+e[0],h=+e[1],o()):[c,h]},t.center=function(e){return arguments.length?(p=e[0]%360*ws,d=e[1]%360*ws,o()):[p*Es,d*Es]},t.rotate=function(e){return arguments.length?(v=e[0]%360*ws,m=e[1]%360*ws,g=e.length>2?e[2]%360*ws:0,o()):[v*Es,m*Es,g*Es]},t.precision=function(e){return arguments.length?(w=e*e,t):Math.sqrt(w)},function(){return u=e.apply(this,arguments),t.invert=u.invert&&n,o()}}function wi(e,t,n,r){var i,s,o=Math.sin(e-n);return Math.abs(o)>bs?Math.atan((Math.sin(t)*(s=Math.cos(r))*Math.sin(n)-Math.sin(r)*(i=Math.cos(t))*Math.sin(e))/(i*s*o)):(t+r)/2}function Ei(e){var t={point:function(t,n){var r=e(t);n.point(r[0],r[1])},line:function(t,n){if(!(c=t.length))return;var r=e(t[0]),i=r[0],s=r[1],o,u,a=i>0?ys:-ys,f,l=0,c;n.moveTo(i,s);while(++l0?ys:-ys,a!==f&&Math.abs(o-i)>=ys?(s=wi(i,s,o,u),Math.abs(i-a)>bs&&n.lineTo(a,s),Math.abs(o-f)>bs?(n.moveTo(f,s),n.lineTo(i=o,s=u)):n.moveTo(i=o,s=u)):n.lineTo(i=o,s=u),a=f},polygon:function(e,n){Gr(e,n,t.line,xi,Si)}};return t}function Si(e){return-(e[0]<0?e[1]-ys/2:ys/2-e[1])}function xi(e,t,n){e=e.point,t=t.point;if(Math.abs(e[0]-t[0])>bs){var r=e[0]ys?t-2*ys:t<-ys?t+2*ys:t,n]}}function Ci(e){var t=Ni(e);return t.invert=Ni(-e),t}function ki(e,t){function n(e,t){var n=Math.cos(t),u=Math.cos(e)*n,a=Math.sin(e)*n,f=Math.sin(t),l=f*r+u*i;return[Math.atan2(a*s-l*o,u*r-f*i),Math.asin(Math.max(-1,Math.min(1,l*s+a*o)))]}var r=Math.cos(e),i=Math.sin(e),s=Math.cos(t),o=Math.sin(t);return n.invert=function(e,t){var n=Math.cos(t),u=Math.cos(e)*n,a=Math.sin(e)*n,f=Math.sin(t),l=f*s-a*o;return[Math.atan2(a*s+f*o,u*r+l*i),Math.asin(Math.max(-1,Math.min(1,l*r-u*i)))]},n}function Li(e,t){function n(t,n){var r=Math.cos(t),i=Math.cos(n),s=e(r*i);return[s*i*Math.sin(t),s*Math.sin(n)]}return n.invert=function(e,n){var r=Math.sqrt(e*e+n*n),i=t(r),s=Math.sin(i),o=Math.cos(i);return[Math.atan2(e*s,r*o),Math.asin(r&&n*s/r)]},n}function Ai(e,t,n,r){var i,s,o,u,a,f,l;return i=r[e],s=i[0],o=i[1],i=r[t],u=i[0],a=i[1],i=r[n],f=i[0],l=i[1],(l-o)*(u-s)-(a-o)*(f-s)>0}function Oi(e,t,n){return(n[0]-t[0])*(e[1]-t[1])<(n[1]-t[1])*(e[0]-t[0])}function Mi(e,t,n,r){var i=e[0],s=t[0],o=n[0],u=r[0],a=e[1],f=t[1],l=n[1],c=r[1],h=i-o,p=s-i,d=u-o,v=a-l,m=f-a,g=c-l,y=(d*v-g*h)/(g*p-d*m);return[i+y*p,a+y*m]}function _i(e,t){var n={list:e.map(function(e,t){return{index:t,x:e[0],y:e[1]}}).sort(function(e,t){return e.yt.y?1:e.xt.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(e,t){return{edge:e,side:t,vertex:null,l:null,r:null}},insert:function(e,t){t.l=e,t.r=e.r,e.r.l=t,e.r=t},leftBound:function(e){var t=r.leftEnd;do t=t.r;while(t!=r.rightEnd&&i.rightOf(t,e));return t=t.l,t},del:function(e){e.l.r=e.r,e.r.l=e.l,e.edge=null},right:function(e){return e.r},left:function(e){return e.l},leftRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[e.side]},rightRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[Go[e.side]]}},i={bisect:function(e,t){var n={region:{l:e,r:t},ep:{l:null,r:null}},r=t.x-e.x,i=t.y-e.y,s=r>0?r:-r,o=i>0?i:-i;return n.c=e.x*r+e.y*i+(r*r+i*i)*.5,s>o?(n.a=1,n.b=i/r,n.c/=r):(n.b=1,n.a=r/i,n.c/=i),n},intersect:function(e,t){var n=e.edge,r=t.edge;if(!n||!r||n.region.r==r.region.r)return null;var i=n.a*r.b-n.b*r.a;if(Math.abs(i)<1e-10)return null;var s=(n.c*r.b-r.c*n.b)/i,o=(r.c*n.a-n.c*r.a)/i,u=n.region.r,a=r.region.r,f,l;u.y=l.region.r.x;return c&&f.side==="l"||!c&&f.side==="r"?null:{x:s,y:o}},rightOf:function(e,t){var n=e.edge,r=n.region.r,i=t.x>r.x;if(i&&e.side==="l")return 1;if(!i&&e.side==="r")return 0;if(n.a===1){var s=t.y-r.y,o=t.x-r.x,u=0,a=0;!i&&n.b<0||i&&n.b>=0?a=u=s>=n.b*o:(a=t.x+t.y*n.b>n.c,n.b<0&&(a=!a),a||(u=1));if(!u){var f=r.x-n.region.l.x;a=n.b*(o*o-s*s)h*h+p*p}return e.side==="l"?a:!a},endPoint:function(e,n,r){e.ep[n]=r;if(!e.ep[Go[n]])return;t(e)},distance:function(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}},s={list:[],insert:function(e,t,n){e.vertex=t,e.ystar=t.y+n;for(var r=0,i=s.list,o=i.length;ru.ystar||e.ystar==u.ystar&&t.x>u.vertex.x)continue;break}i.splice(r,0,e)},del:function(e){for(var t=0,n=s.list,r=n.length;td.y&&(v=p,p=d,d=v,b="r"),y=i.bisect(p,d),h=r.createHalfEdge(y,b),r.insert(l,h),i.endPoint(y,Go[b],g),m=i.intersect(l,h),m&&(s.del(l),s.insert(l,m,i.distance(m,p))),m=i.intersect(h,c),m&&s.insert(h,m,i.distance(m,p))}}for(a=r.right(r.leftEnd);a!=r.rightEnd;a=r.right(a))t(a.edge)}function Di(){return{leaf:!0,nodes:[],point:null}}function Pi(e,t,n,r,i,s){if(!e(t,n,r,i,s)){var o=(n+i)*.5,u=(r+s)*.5,a=t.nodes;a[0]&&Pi(e,a[0],n,r,o,u),a[1]&&Pi(e,a[1],o,r,i,u),a[2]&&Pi(e,a[2],n,u,o,s),a[3]&&Pi(e,a[3],o,u,i,s)}}function Hi(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function Bi(e){return e.substring(0,3)}function ji(e,t,n,r){var i,s,o=0,u=t.length,a=n.length;while(o=a)return-1;i=t.charCodeAt(o++);if(i==37){s=bu[t.charAt(o++)];if(!s||(r=s(e,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}function Fi(e){return new RegExp("^(?:"+e.map(d3.requote).join("|")+")","i")}function Ii(e){var t=new r,n=-1,i=e.length;while(++n68?1900:2e3)}function Qi(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.m=r[0]-1,n+=r[0].length):-1}function Gi(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.d=+r[0],n+=r[0].length):-1}function Yi(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.H=+r[0],n+=r[0].length):-1}function Zi(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.M=+r[0],n+=r[0].length):-1}function es(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.S=+r[0],n+=r[0].length):-1}function ts(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+3));return r?(e.L=+r[0],n+=r[0].length):-1}function ns(e,t,n){var r=Eu.get(t.substring(n,n+=2).toLowerCase());return r==null?-1:(e.p=r,n)}function rs(e){var t=e.getTimezoneOffset(),n=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return n+au(r)+au(i)}function is(e){return e.toISOString()}function ss(e,t,n){function r(t){var n=e(t),r=s(n,1);return t-n1)while(ot?1:e>=t?0:NaN},d3.descending=function(e,t){return te?1:t>=e?0:NaN},d3.mean=function(e,t){var n=e.length,r,i=0,s=-1,o=0;if(arguments.length===1)while(++s1&&(e=e.map(t)),e=e.filter(f),e.length?d3.quantile(e.sort(d3.ascending),.5):undefined},d3.min=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++ns&&(i=s)}else{while(++ns&&(i=s)}return i},d3.max=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++ni&&(i=s)}else{while(++ni&&(i=s)}return i},d3.extent=function(e,t){var n=-1,r=e.length,i,s,o;if(arguments.length===1){while(++ns&&(i=s),os&&(i=s),o1);return e+t*n*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(e,t){var n=arguments.length;n<2&&(t=1),n<1&&(e=0);var r=d3.random.normal();return function(){return Math.exp(e+t*r())}},irwinHall:function(e){return function(){for(var t=0,n=0;n>>1;e.call(t,t[s],s)>>1;n=i.length)return u?u.call(n,t):o?t.sort(o):t;var a=-1,f=t.length,l=i[s++],c,h,p=new r,d,v={};while(++a=i.length)return e;var r=[],o=s[n++],u;for(u in e)r.push({key:u,values:t(e[u],n)});return o&&r.sort(function(e,t){return o(e.key,t.key)}),r}var n={},i=[],s=[],o,u;return n.map=function(t){return e(t,0)},n.entries=function(n){return t(e(n,0),0)},n.key=function(e){return i.push(e),n},n.sortKeys=function(e){return s[i.length-1]=e,n},n.sortValues=function(e){return o=e,n},n.rollup=function(e){return u=e,n},n},d3.keys=function(e){var t=[];for(var n in e)t.push(n);return t},d3.values=function(e){var t=[];for(var n in e)t.push(e[n]);return t},d3.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},d3.permute=function(e,t){var n=[],r=-1,i=t.length;while(++rt)r.push(o/i);else while((o=e+n*++s)=200&&e<300||e===304?s.load.call(r,u.call(r,a)):s.error.call(r,a)}},a.onprogress=function(e){var t=d3.event;d3.event=e;try{s.progress.call(r,a)}finally{d3.event=t}},r.header=function(e,t){return e=(e+"").toLowerCase(),arguments.length<2?o[e]:(t==null?delete o[e]:o[e]=t+"",r)},r.mimeType=function(e){return arguments.length?(t=e==null?null:e+"",r):t},r.response=function(e){return u=e,r},["get","post"].forEach(function(e){r[e]=function(){return r.send.apply(r,[e].concat(xs(arguments)))}}),r.send=function(n,i,s){arguments.length===2&&typeof i=="function"&&(s=i,i=null),a.open(n,e,!0),t!=null&&!("accept"in o)&&(o.accept=t+",*/*");for(var u in o)a.setRequestHeader(u,o[u]);return t!=null&&a.overrideMimeType&&a.overrideMimeType(t),s!=null&&r.on("error",s).on("load",function(e){s(null,e)}),a.send(i==null?null:i),r},r.abort=function(){return a.abort(),r},d3.rebind(r,s,"on"),arguments.length===2&&typeof t=="function"&&(n=t,t=null),n==null?r:r.get(n)},d3.text=function(){return d3.xhr.apply(d3,arguments).response(p)},d3.json=function(e,t){return d3.xhr(e,"application/json",t).response(d)},d3.html=function(e,t){return d3.xhr(e,"text/html",t).response(v)},d3.xml=function(){return d3.xhr.apply(d3,arguments).response(m)};var Os={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};d3.ns={prefix:Os,qualify:function(e){var t=e.indexOf(":"),n=e;return t>=0&&(n=e.substring(0,t),e=e.substring(t+1)),Os.hasOwnProperty(n)?{space:Os[n],local:e}:e}},d3.dispatch=function(){var e=new g,t=-1,n=arguments.length;while(++t0&&(r=e.substring(n+1),e=e.substring(0,n)),arguments.length<2?this[e].on(r):this[e].on(r,t)},d3.format=function(e){var t=Ms.exec(e),n=t[1]||" ",r=t[3]||"",i=t[5],s=+t[6],o=t[7],u=t[8],a=t[9],f=1,l="",c=!1;u&&(u=+u.substring(1)),i&&(n="0",o&&(s-=Math.floor((s-1)/4)));switch(a){case"n":o=!0,a="g";break;case"%":f=100,l="%",a="f";break;case"p":f=100,l="%",a="r";break;case"d":c=!0,u=0;break;case"s":f=-1,a="r"}return a=="r"&&!u&&(a="g"),a=_s.get(a)||w,function(e){if(c&&e%1)return"";var t=e<0&&(e=-e)?"-":r;if(f<0){var h=d3.formatPrefix(e,u);e=h.scale(e),l=h.symbol}else e*=f;e=a(e,u);if(i){var p=e.length+t.length;p=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,_s=d3.map({g:function(e,t){return e.toPrecision(t)},e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},r:function(e,t){return d3.round(e,t=b(e,t)).toFixed(Math.max(0,Math.min(20,t)))}}),Ds=["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(S);d3.formatPrefix=function(e,t){var n=0;return e&&(e<0&&(e*=-1),t&&(e=d3.round(e,b(e,t))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,Math.floor((n<=0?n+1:n-1)/3)*3))),Ds[8+n/3]};var Ps=function(){return i},Hs=d3.map({linear:Ps,poly:O,quad:function(){return k},cubic:function(){return L},sin:function(){return M},exp:function(){return _},circle:function(){return D},elastic:P,back:H,bounce:function(){return B}}),Bs=d3.map({"in":i,out:N,"in-out":C,"out-in":function(e){return C(N(e))}});d3.ease=function(e){var t=e.indexOf("-"),n=t>=0?e.substring(0,t):e,r=t>=0?e.substring(t+1):"in";return n=Hs.get(n)||Ps,r=Bs.get(r)||i,T(r(n.apply(null,Array.prototype.slice.call(arguments,1))))},d3.event=null,d3.transform=function(e){var t=document.createElementNS(d3.ns.prefix.svg,"g");return(d3.transform=function(e){t.setAttribute("transform",e);var n=t.transform.baseVal.consolidate();return new q(n?n.matrix:js)})(e)},q.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var js={a:1,b:0,c:0,d:1,e:0,f:0};d3.interpolate=function(e,t){var n=d3.interpolators.length,r;while(--n>=0&&!(r=d3.interpolators[n](e,t)));return r},d3.interpolateNumber=function(e,t){return t-=e,function(n){return e+t*n}},d3.interpolateRound=function(e,t){return t-=e,function(n){return Math.round(e+t*n)}},d3.interpolateString=function(e,t){var n,r,i,s=0,o=0,u=[],a=[],f,l;Fs.lastIndex=0;for(r=0;n=Fs.exec(t);++r)n.index&&u.push(t.substring(s,o=n.index)),a.push({i:u.length,x:n[0]}),u.push(null),s=Fs.lastIndex;s180?l+=360:l-f>180&&(f+=360),r.push({i:n.push(n.pop()+"rotate(",null,")")-2,x:d3.interpolateNumber(f,l)})):l&&n.push(n.pop()+"rotate("+l+")"),c!=h?r.push({i:n.push(n.pop()+"skewX(",null,")")-2,x:d3.interpolateNumber(c,h)}):h&&n.push(n.pop()+"skewX("+h+")"),p[0]!=d[0]||p[1]!=d[1]?(i=n.push(n.pop()+"scale(",null,",",null,")"),r.push({i:i-4,x:d3.interpolateNumber(p[0],d[0])},{i:i-2,x:d3.interpolateNumber(p[1],d[1])})):(d[0]!=1||d[1]!=1)&&n.push(n.pop()+"scale("+d+")"),i=r.length,function(e){var t=-1,s;while(++t180?s-=360:s<-180&&(s+=360),function(e){return it(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateLab=function(e,t){e=d3.lab(e),t=d3.lab(t);var n=e.l,r=e.a,i=e.b,s=t.l-n,o=t.a-r,u=t.b-i;return function(e){return lt(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateHcl=function(e,t){e=d3.hcl(e),t=d3.hcl(t);var n=e.h,r=e.c,i=e.l,s=t.h-n,o=t.c-r,u=t.l-i;return s>180?s-=360:s<-180&&(s+=360),function(e){return ut(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateArray=function(e,t){var n=[],r=[],i=e.length,s=t.length,o=Math.min(e.length,t.length),u;for(u=0;u=0;)if(s=n[r])i&&i!==s.nextSibling&&i.parentNode.insertBefore(s,i),i=s;return this},Zs.sort=function(e){e=Ct.apply(this,arguments);for(var t=-1,n=this.length;++t=Eo?e?"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"M0,"+e+"A"+e+","+e+" 0 1,0 0,"+ -e+"A"+e+","+e+" 0 1,0 0,"+e+"Z":"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"Z":e?"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L"+e*h+","+e*p+"A"+e+","+e+" 0 "+f+",0 "+e*l+","+e*c+"Z":"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L0,0"+"Z"}var t=un,n=an,r=fn,i=ln;return e.innerRadius=function(n){return arguments.length?(t=u(n),e):t},e.outerRadius=function(t){return arguments.length?(n=u(t),e):n},e.startAngle=function(t){return arguments.length?(r=u(t),e):r},e.endAngle=function(t){return arguments.length?(i=u(t),e):i},e.centroid=function(){var e=(t.apply(this,arguments)+n.apply(this,arguments))/2,s=(r.apply(this,arguments)+i.apply(this,arguments))/2+wo;return[Math.cos(s)*e,Math.sin(s)*e]},e};var wo=-ys/2,Eo=2*ys-1e-6;d3.svg.line=function(){return cn(i)};var So=d3.map({linear:dn,"linear-closed":vn,"step-before":mn,"step-after":gn,basis:xn,"basis-open":Tn,"basis-closed":Nn,bundle:Cn,cardinal:wn,"cardinal-open":yn,"cardinal-closed":bn,monotone:_n});So.forEach(function(e,t){t.key=e,t.closed=/-closed$/.test(e)});var xo=[0,2/3,1/3,0],To=[0,1/3,2/3,0],No=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var e=cn(Dn);return e.radius=e.x,delete e.x,e.angle=e.y,delete e.y,e},mn.reverse=gn,gn.reverse=mn,d3.svg.area=function(){return Pn(i)},d3.svg.area.radial=function(){var e=Pn(Dn);return e.radius=e.x,delete e.x,e.innerRadius=e.x0,delete e.x0,e.outerRadius=e.x1,delete e.x1,e.angle=e.y,delete e.y,e.startAngle=e.y0,delete e.y0,e.endAngle=e.y1,delete e.y1,e},d3.svg.chord=function(){function e(e,u){var a=t(this,s,e,u),f=t(this,o,e,u);return"M"+a.p0+r(a.r,a.p1,a.a1-a.a0)+(n(a,f)?i(a.r,a.p1,a.r,a.p0):i(a.r,a.p1,f.r,f.p0)+r(f.r,f.p1,f.a1-f.a0)+i(f.r,f.p1,a.r,a.p0))+"Z"}function t(e,t,n,r){var i=t.call(e,n,r),s=a.call(e,i,r),o=f.call(e,i,r)+wo,u=l.call(e,i,r)+wo;return{r:s,a0:o,a1:u,p0:[s*Math.cos(o),s*Math.sin(o)],p1:[s*Math.cos(u),s*Math.sin(u)]}}function n(e,t){return e.a0==t.a0&&e.a1==t.a1}function r(e,t,n){return"A"+e+","+e+" 0 "+ +(n>ys)+",1 "+t}function i(e,t,n,r){return"Q 0,0 "+r}var s=Hn,o=Bn,a=jn,f=fn,l=ln;return e.radius=function(t){return arguments.length?(a=u(t),e):a},e.source=function(t){return arguments.length?(s=u(t),e):s},e.target=function(t){return arguments.length?(o=u(t),e):o},e.startAngle=function(t){return arguments.length?(f=u(t),e):f},e.endAngle=function(t){return arguments.length?(l=u(t),e):l},e},d3.svg.diagonal=function(){function e(e,i){var s=t.call(this,e,i),o=n.call(this,e,i),u=(s.y+o.y)/2,a=[s,{x:s.x,y:u},{x:o.x,y:u},o];return a=a.map(r),"M"+a[0]+"C"+a[1]+" "+a[2]+" "+a[3]}var t=Hn,n=Bn,r=qn;return e.source=function(n){return arguments.length?(t=u(n),e):t},e.target=function(t){return arguments.length?(n=u(t),e):n},e.projection=function(t){return arguments.length?(r=t,e):r},e},d3.svg.diagonal.radial=function(){var e=d3.svg.diagonal(),t=qn,n=e.projection;return e.projection=function(e){return arguments.length?n(Rn(t=e)):t},e},d3.svg.symbol=function(){function e(e,r){return(Co.get(t.call(this,e,r))||Wn)(n.call(this,e,r))}var t=zn,n=Un;return e.type=function(n){return arguments.length?(t=u(n),e):t},e.size=function(t){return arguments.length?(n=u(t),e):n},e};var Co=d3.map({circle:Wn,cross:function(e){var t=Math.sqrt(e/5)/2;return"M"+ -3*t+","+ -t+"H"+ -t+"V"+ -3*t+"H"+t+"V"+ -t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+ -t+"V"+t+"H"+ -3*t+"Z"},diamond:function(e){var t=Math.sqrt(e/(2*Lo)),n=t*Lo;return"M0,"+ -t+"L"+n+",0"+" 0,"+t+" "+ -n+",0"+"Z"},square:function(e){var t=Math.sqrt(e)/2;return"M"+ -t+","+ -t+"L"+t+","+ -t+" "+t+","+t+" "+ -t+","+t+"Z"},"triangle-down":function(e){var t=Math.sqrt(e/ko),n=t*ko/2;return"M0,"+n+"L"+t+","+ -n+" "+ -t+","+ -n+"Z"},"triangle-up":function(e){var t=Math.sqrt(e/ko),n=t*ko/2;return"M0,"+ -n+"L"+t+","+n+" "+ -t+","+n+"Z"}});d3.svg.symbolTypes=Co.keys();var ko=Math.sqrt(3),Lo=Math.tan(30*ws);d3.svg.axis=function(){function e(e){e.each(function(){var e=d3.select(this),c=a==null?t.ticks?t.ticks.apply(t,u):t.domain():a,h=f==null?t.tickFormat?t.tickFormat.apply(t,u):String:f,p=$n(t,c,l),d=e.selectAll(".minor").data(p,String),v=d.enter().insert("line","g").attr("class","tick minor").style("opacity",1e-6),m=d3.transition(d.exit()).style("opacity",1e-6).remove(),g=d3.transition(d).style("opacity",1),y=e.selectAll("g").data(c,String),b=y.enter().insert("g","path").style("opacity",1e-6),w=d3.transition(y.exit()).style("opacity",1e-6).remove(),E=d3.transition(y).style("opacity",1),S,x=It(t),T=e.selectAll(".domain").data([0]),N=T.enter().append("path").attr("class","domain"),C=d3.transition(T),k=t.copy(),L=this.__chart__||k;this.__chart__=k,b.append("line").attr("class","tick"),b.append("text");var A=b.select("line"),O=E.select("line"),M=y.select("text").text(h),_=b.select("text"),D=E.select("text");switch(n){case"bottom":S=Xn,v.attr("y2",i),g.attr("x2",0).attr("y2",i),A.attr("y2",r),_.attr("y",Math.max(r,0)+o),O.attr("x2",0).attr("y2",r),D.attr("x",0).attr("y",Math.max(r,0)+o),M.attr("dy",".71em").style("text-anchor","middle"),C.attr("d","M"+x[0]+","+s+"V0H"+x[1]+"V"+s);break;case"top":S=Xn,v.attr("y2",-i),g.attr("x2",0).attr("y2",-i),A.attr("y2",-r),_.attr("y",-(Math.max(r,0)+o)),O.attr("x2",0).attr("y2",-r),D.attr("x",0).attr("y",-(Math.max(r,0)+o)),M.attr("dy","0em").style("text-anchor","middle"),C.attr("d","M"+x[0]+","+ -s+"V0H"+x[1]+"V"+ -s);break;case"left":S=Vn,v.attr("x2",-i),g.attr("x2",-i).attr("y2",0),A.attr("x2",-r),_.attr("x",-(Math.max(r,0)+o)),O.attr("x2",-r).attr("y2",0),D.attr("x",-(Math.max(r,0)+o)).attr("y",0),M.attr("dy",".32em").style("text-anchor","end"),C.attr("d","M"+ -s+","+x[0]+"H0V"+x[1]+"H"+ -s);break;case"right":S=Vn,v.attr("x2",i),g.attr("x2",i).attr("y2",0),A.attr("x2",r),_.attr("x",Math.max(r,0)+o),O.attr("x2",r).attr("y2",0),D.attr("x",Math.max(r,0)+o).attr("y",0),M.attr("dy",".32em").style("text-anchor","start"),C.attr("d","M"+s+","+x[0]+"H0V"+x[1]+"H"+s)}if(t.ticks)b.call(S,L),E.call(S,k),w.call(S,k),v.call(S,L),g.call(S,k),m.call(S,k);else{var P=k.rangeBand()/2,H=function(e){return k(e)+P};b.call(S,H),E.call(S,H)}})}var t=d3.scale.linear(),n="bottom",r=6,i=6,s=6,o=3,u=[10],a=null,f,l=0;return e.scale=function(n){return arguments.length?(t=n,e):t},e.orient=function(t){return arguments.length?(n=t,e):n},e.ticks=function(){return arguments.length?(u=arguments,e):u},e.tickValues=function(t){return arguments.length?(a=t,e):a},e.tickFormat=function(t){return arguments.length?(f=t,e):f},e.tickSize=function(t,n,o){if(!arguments.length)return r;var u=arguments.length-1;return r=+t,i=u>1?+n:r,s=u>0?+arguments[u]:r,e},e.tickPadding=function(t){return arguments.length?(o=+t,e):o},e.tickSubdivide=function(t){return arguments.length?(l=+t,e):l},e},d3.svg.brush=function(){function e(s){s.each(function(){var s=d3.select(this),f=s.selectAll(".background").data([0]),l=s.selectAll(".extent").data([0]),c=s.selectAll(".resize").data(a,String),h;s.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),f.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),l.enter().append("rect").attr("class","extent").style("cursor","move"),c.enter().append("g").attr("class",function(e){return"resize "+e}).style("cursor",function(e){return Ao[e]}).append("rect").attr("x",function(e){return/[ew]$/.test(e)?-3:null}).attr("y",function(e){return/^[ns]/.test(e)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),c.style("display",e.empty()?"none":null),c.exit().remove(),o&&(h=It(o),f.attr("x",h[0]).attr("width",h[1]-h[0]),n(s)),u&&(h=It(u),f.attr("y",h[0]).attr("height",h[1]-h[0]),r(s)),t(s)})}function t(e){e.selectAll(".resize").attr("transform",function(e){return"translate("+f[+/e$/.test(e)][0]+","+f[+/^s/.test(e)][1]+")"})}function n(e){e.select(".extent").attr("x",f[0][0]),e.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1][0]-f[0][0])}function r(e){e.select(".extent").attr("y",f[0][1]),e.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1][1]-f[0][1])}function i(){function i(){var e=d3.event.changedTouches;return e?d3.touches(v,e)[0]:d3.mouse(v)}function a(){d3.event.keyCode==32&&(S||(T=null,N[0]-=f[1][0],N[1]-=f[1][1],S=2),j())}function c(){d3.event.keyCode==32&&S==2&&(N[0]+=f[1][0],N[1]+=f[1][1],S=0,j())}function h(){var e=i(),s=!1;C&&(e[0]+=C[0],e[1]+=C[1]),S||(d3.event.altKey?(T||(T=[(f[0][0]+f[1][0])/2,(f[0][1]+f[1][1])/2]),N[0]=f[+(e[0]0?a=e:a=0:e>0&&(r.start({type:"start",alpha:a=e}),d3.timer(n.tick)),n):a},n.start=function(){function e(e,n){var i=t(r),s=-1,o=i.length,u;while(++si&&(i=u),r.push(u)}for(o=0;o0){s=-1;while(++s=a[0]&&d<=a[1]&&(l=o[d3.bisect(f,d,1,h)-1],l.y+=p,l.push(e[s]))}return o}var t=!0,n=Number,r=vr,i=pr;return e.value=function(t){return arguments.length?(n=t,e):n},e.range=function(t){return arguments.length?(r=u(t),e):r},e.bins=function(t){return arguments.length?(i=typeof t=="number"?function(e){return dr(e,t)}:u(t),e):i},e.frequency=function(n){return arguments.length?(t=!!n,e):t},e},d3.layout.hierarchy=function(){function e(t,o,u){var a=i.call(n,t,o),f=Bo?t:{data:t};f.depth=o,u.push(f);if(a&&(c=a.length)){var l=-1,c,h=f.children=[],p=0,d=o+1,v;while(++l0){var l=n*f/2;Rr(o,function(e){e.r+=l}),Rr(o,Nr),Rr(o,function(e){e.r-=l}),f=Math.max(2*o.r/u,2*o.r/a)}return Lr(o,u/2,a/2,1/f),s}var t=d3.layout.hierarchy().sort(Er),n=0,r=[1,1];return e.size=function(t){return arguments.length?(r=t,e):r},e.padding=function(t){return arguments.length?(n=+t,e):n},mr(e,t)},d3.layout.cluster=function(){function e(e,i){var s=t.call(this,e,i),o=s[0],u,a=0,f,l;Rr(o,function(e){var t=e.children;t&&t.length?(e.x=Mr(t),e.y=Or(t)):(e.x=u?a+=n(e,u):0,e.y=0,u=e)});var c=_r(o),h=Dr(o),p=c.x-n(c,h)/2,d=h.x+n(h,c)/2;return Rr(o,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=(1-(o.y?e.y/o.y:1))*r[1]}),s}var t=d3.layout.hierarchy().sort(null).value(null),n=Pr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},mr(e,t)},d3.layout.tree=function(){function e(e,i){function s(e,t){var r=e.children,i=e._tree;if(r&&(o=r.length)){var o,a=r[0],f,l=a,c,h=-1;while(++h0&&(zr(Wr(o,e,r),e,h),a+=h,f+=h),l+=o._tree.mod,a+=i._tree.mod,c+=u._tree.mod,f+=s._tree.mod;o&&!Br(s)&&(s._tree.thread=o,s._tree.mod+=l-f),i&&!Hr(u)&&(u._tree.thread=i,u._tree.mod+=a-c,r=e)}return r}var a=t.call(this,e,i),f=a[0];Rr(f,function(e,t){e._tree={ancestor:e,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),s(f),o(f,-f._tree.prelim);var l=jr(f,Ir),c=jr(f,Fr),h=jr(f,qr),p=l.x-n(l,c)/2,d=c.x+n(c,l)/2,v=h.depth||1;return Rr(f,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=e.depth/v*r[1],delete e._tree}),a}var t=d3.layout.hierarchy().sort(null).value(null),n=Pr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},mr(e,t)},d3.layout.treemap=function(){function e(e,t){var n=-1,r=e.length,i,s;while(++n0)u.push(f=a[d-1]),u.area+=f.area,(h=r(u,p))<=c?(a.pop(),c=h):(u.area-=u.pop().area,i(u,p,o,!1),p=Math.min(o.dx,o.dy),u.length=u.area=0,c=Infinity);u.length&&(i(u,p,o,!0),u.length=u.area=0),s.forEach(t)}}function n(t){var r=t.children;if(r&&r.length){var s=l(t),o=r.slice(),u,a=[];e(o,s.dx*s.dy/t.value),a.area=0;while(u=o.pop())a.push(u),a.area+=u.area,u.z!=null&&(i(a,u.z?s.dx:s.dy,s,!o.length),a.length=a.area=0);r.forEach(n)}}function r(e,t){var n=e.area,r,i=0,s=Infinity,o=-1,u=e.length;while(++oi&&(i=r)}return n*=n,t*=t,n?Math.max(t*i*p/n,n/(t*s*p)):Infinity}function i(e,t,n,r){var i=-1,s=e.length,o=n.x,a=n.y,f=t?u(e.area/t):0,l;if(t==n.dx){if(r||f>n.dy)f=n.dy;while(++in.dx)f=n.dx;while(++i50?r:t<-140?i:o<21?s:n}var n=d3.geo.albers(),r=d3.geo.albers().rotate([160,0]).center([0,60]).parallels([55,65]),i=d3.geo.albers().rotate([160,0]).center([0,20]).parallels([8,18]),s=d3.geo.albers().rotate([60,0]).center([0,10]).parallels([8,18]);return e.point=function(e,n){return t(e).point(e,n)},e.line=function(e,n){return t(e[0]).line(e,n)},e.polygon=function(e,n){return t(e[0][0]).polygon(e,n)},e.scale=function(t){return arguments.length?(n.scale(t),r.scale(t*.6),i.scale(t),s.scale(t*1.5),e.translate(n.translate())):n.scale()},e.translate=function(t){if(!arguments.length)return n.translate();var o=n.scale(),u=t[0],a=t[1];return n.translate(t),r.translate([u-.4*o,a+.17*o]),i.translate([u-.19*o,a+.2*o]),s.translate([u+.58*o,a+.43*o]),e},e.scale(n.scale())},(d3.geo.albers=function(){var e=29.5*ws,t=45.5*ws,n=bi(Kr),r=n(e,t);return r.parallels=function(r){return arguments.length?n(e=r[0]*ws,t=r[1]*ws):[e*Es,t*Es]},r.rotate([98,0]).center([0,38]).scale(1e3)}).raw=Kr;var qo=Li(function(e){return Math.sqrt(2/(1+e))},function(e){return 2*Math.asin(e/2)});(d3.geo.azimuthalEqualArea=function(){return yi(qo)}).raw=qo;var Ro=Li(function(e){var t=Math.acos(e);return t&&t/Math.sin(t)},i);(d3.geo.azimuthalEquidistant=function(){return yi(Ro)}).raw=Ro,d3.geo.bounds=function(e){return Xo=Wo=-(Uo=zo=Infinity),Vo.object(e),[[Uo,zo],[Wo,Xo]]};var Uo,zo,Wo,Xo,Vo=Jr({point:function(e){var t=e[0],n=e[1];tWo&&(Wo=t),nXo&&(Xo=n)},polygon:function(e){this.line(e[0])}});d3.geo.circle=function(){function e(){}function t(e){var t=null;return{moveTo:function(n,r){var i=u.invert(n,r);i[0]*=Es,i[1]*=Es,e.push(t=[i])},lineTo:function(e,n){var r=u.invert(e,n);r[0]*=Es,r[1]*=Es,t.push(r)},closePath:function(){t.length&&t.push(t[0])}}}var n=[0,0],r=90,s,o,u;e.clip=function(e){var t=typeof n=="function"?n.apply(this,arguments):n;return u=Ti(-t[0]*ws,-t[1]*ws,0),s=Qr(r,function(e){return u(e[0]*ws,e[1]*ws)}),a.object(e)||null};var a=Jr({FeatureCollection:function(e){var t=e.features.map(a.Feature,a).filter(i);return t&&(e=Object.create(e),e.features=t,e)},Feature:function(e){var t=a.geometry(e.geometry);return t&&(e=Object.create(e),e.geometry=t,e)},Point:function(e){var n=[];return s.point(e.coordinates,t(n)),n.length&&e},MultiPoint:function(e){var n=[],r=t(n);return e.coordinates.forEach(function(e){s.point(e,r)}),n.length&&(e=Object.create(e),e.coordinates=n.map(function(e){return e[0]}),e)},LineString:function(e){var n=[],r=t(n);return s.line(e.coordinates,r),n.length&&(e=Object.create(e),e.type="MultiLineString",e.coordinates=n,e)},MultiLineString:function(e){var n=[],r=t(n);return e.coordinates.forEach(function(e){s.line(e,r)}),n.length&&(e=Object.create(e),e.coordinates=n,e)},Polygon:function(e){var n=[];s.polygon(e.coordinates,t(n));var r=n.map(function(e){return[e]});return r.length&&(e=Object.create(e),e.type="MultiPolygon",e.coordinates=r,e)},MultiPolygon:function(e){var n=[],r=t(n);e.coordinates.forEach(function(e){s.polygon(e,r)});var i=n.map(function(e){return[e]});return i.length&&(e=Object.create(e),e.coordinates=i,e)},GeometryCollection:function(e){var t=e.geometries.map(a.geometry,a).filter(i);return t.length&&(e=Object.create(e),e.geometries=t,e)}});return e.origin=function(t){return arguments.length?(n=t,e):n},e.angle=function(t){return arguments.length?(r=+t,e):r},e.precision=function(t){return arguments.length?(o=+t,e):o},e},(d3.geo.equirectangular=function(){return yi(fi).scale(250/ys)}).raw=fi.invert=fi;var $o=Li(function(e){return 1/e},Math.atan);(d3.geo.gnomonic=function(){return yi($o)}).raw=$o,d3.geo.graticule=function(){function e(){return{type:"GeometryCollection",geometries:e.lines()}}var t,n,r,i,s=22.5,o=s,u,a;return e.lines=function(){return d3.range(Math.ceil(n/s)*s,t,s).map(u).concat(d3.range(Math.ceil(i/o)*o,r,o).map(a)).map(function(e){return{type:"LineString",coordinates:e}})},e.outline=function(){return{type:"Polygon",coordinates:[u(n).concat(a(r).slice(1),u(t).reverse().slice(1),a(i).reverse().slice(1))]}},e.extent=function(s){return arguments.length?(n=+s[0][0],t=+s[1][0],i=+s[0][1],r=+s[1][1],n>t&&(s=n,n=t,t=s),i>r&&(s=i,i=r,r=s),u=li(i,r),a=ci(n,t),e):[[n,i],[t,r]]},e.step=function(t){return arguments.length?(s=+t[0],o=+t[1],e):[s,o]},e.extent([[-180+bs,-90+bs],[180-bs,90-bs]])};var Jo=3;d3.geo.greatArc=function(){function e(){var t=e.distance.apply(this,arguments),r=0,u=s/t,a=[n];while((r+=u)<1)a.push(o(r));return a.push(i),{type:"LineString",coordinates:a}}var t=hi,n,r=pi,i,s=6*ws,o=di();return e.distance=function(){return typeof t=="function"&&o.source(n=t.apply(this,arguments)),typeof r=="function"&&o.target(i=r.apply(this,arguments)),o.distance()},e.source=function(r){return arguments.length?(t=r,typeof t!="function"&&o.source(n=t),e):t},e.target=function(t){return arguments.length?(r=t,typeof r!="function"&&o.target(i=r),e):r},e.precision=function(t){return arguments.length?(s=t*ws,e):s/ws},e},mi.invert=function(e,t){return[2*ys*e,2*Math.atan(Math.exp(2*ys*t))-ys/2]},(d3.geo.mercator=function(){return yi(mi).scale(500)}).raw=mi;var Ko=Li(function(){return 1},Math.asin);(d3.geo.orthographic=function(){return yi(Ko)}).raw=Ko,d3.geo.path=function(){function e(e){var t=null;return e!=t&&(typeof f=="function"&&(l=gi(f.apply(this,arguments))),v.object(e),h.length&&(t=h.join(""),h=[])),t}function t(e){return Math.abs(d3.geom.polygon(e.map(c)).area())}function n(e){return t(e[0])-d3.sum(e.slice(1),t)}function r(e){switch(e.type){case"Point":case"MultiPoint":return 0;case"LineString":case"MultiLineString":return 1;case"Polygon":case"MultiPolygon":return 2}}function i(e){return function(t){var n=e(t.coordinates);return n?[n[0]/n[2],n[1]/n[2]]:null}}function s(e){return function(t){var n=t.coordinates,r,i=0,s=0,o=0,u=-1,a=n.length;while(++u=l*l+c*c?r[s].index=-1:(r[h].index=-1,d=r[s].angle,h=s,p=o)):(d=r[s].angle,h=s,p=o);i.push(u);for(s=0,o=0;s<2;++o)r[o].index!==-1&&(i.push(r[o].index),s++);v=i.length;for(;o=0?(r=e.ep.r,i=e.ep.l):(r=e.ep.l,i=e.ep.r),e.a===1?(u=r?r.y:-n,s=e.c-e.b*u,a=i?i.y:n,o=e.c-e.b*a):(s=r?r.x:-n,u=e.c-e.a*s,o=i?i.x:n,a=e.c-e.a*o);var f=[s,u],l=[o,a];t[e.region.l.index].push(f,l),t[e.region.r.index].push(f,l)}),t=t.map(function(t,n){var r=e[n][0],i=e[n][1],s=t.map(function(e){return Math.atan2(e[0]-r,e[1]-i)});return d3.range(t.length).sort(function(e,t){return s[e]-s[t]}).filter(function(e,t,n){return!t||s[e]-s[n[t-1]]>bs}).map(function(e){return t[e]})}),t.forEach(function(t,r){var i=t.length;if(!i)return t.push([-n,-n],[-n,n],[n,n],[n,-n]);if(i>2)return;var s=e[r],o=t[0],u=t[1],a=s[0],f=s[1],l=o[0],c=o[1],h=u[0],p=u[1],d=h-l,v=p-c;if(Math.abs(v)=u,l=t.y>=a,c=(l<<1)+f;e.leaf=!1,e=e.nodes[c]||(e.nodes[c]=Di()),f?n=u:i=u,l?r=a:o=a,s(e,t,n,r,i,o)}var u,a=-1,f=e.length;if(arguments.length<5)if(arguments.length===3)i=n,r=t,n=t=0;else{t=n=Infinity,r=i=-Infinity;while(++ar&&(r=u.x),u.y>i&&(i=u.y)}var l=r-t,c=i-n;l>c?i=n+l:r=t+c;var h=Di();return h.add=function(e){s(h,e,t,n,r,i)},h.visit=function(e){Pi(e,h,t,n,r,i)},e.forEach(h.add),h},d3.time={};var Yo=Date,Zo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Hi.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(){eu.setUTCDate.apply(this._,arguments)},setDay:function(){eu.setUTCDay.apply(this._,arguments)},setFullYear:function(){eu.setUTCFullYear.apply(this._,arguments)},setHours:function(){eu.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){eu.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){eu.setUTCMinutes.apply(this._,arguments)},setMonth:function(){eu.setUTCMonth.apply(this._,arguments)},setSeconds:function(){eu.setUTCSeconds.apply(this._,arguments)},setTime:function(){eu.setTime.apply(this._,arguments)}};var eu=Date.prototype,tu="%a %b %e %H:%M:%S %Y",nu="%m/%d/%y",ru="%H:%M:%S",iu=Zo,su=iu.map(Bi),ou=["January","February","March","April","May","June","July","August","September","October","November","December"],uu=ou.map(Bi);d3.time.format=function(e){function t(t){var r=[],i=-1,s=0,o,u;while(++i=12?"PM":"AM"},S:function(e){return au(e.getSeconds())},U:function(e){return au(d3.time.sundayOfYear(e))},w:function(e){return e.getDay()},W:function(e){return au(d3.time.mondayOfYear(e))},x:d3.time.format(nu),X:d3.time.format(ru),y:function(e){return au(e.getFullYear()%100)},Y:function(e){return lu(e.getFullYear()%1e4)},Z:rs,"%":function(e){return"%"}},bu={a:qi,A:Ri,b:Ui,B:zi,c:Wi,d:Gi,e:Gi,H:Yi,I:Yi,L:ts,m:Qi,M:Zi,p:ns,S:es,x:Xi,X:Vi,y:Ji,Y:$i},wu=/^\s*\d+/,Eu=d3.map({am:0,pm:1});d3.time.format.utc=function(e){function t(e){try{Yo=Hi;var t=new Yo;return t._=e,n(t)}finally{Yo=Date}}var n=d3.time.format(e);return t.parse=function(e){try{Yo=Hi;var t=n.parse(e);return t&&t._}finally{Yo=Date}},t.toString=n.toString,t};var Su=d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");d3.time.format.iso=Date.prototype.toISOString?is:Su,is.parse=function(e){var t=new Date(e);return isNaN(t)?null:t},is.toString=Su.toString,d3.time.second=ss(function(e){return new Yo(Math.floor(e/1e3)*1e3)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*1e3)},function(e){return e.getSeconds()}),d3.time.seconds=d3.time.second.range,d3.time.seconds.utc=d3.time.second.utc.range,d3.time.minute=ss(function(e){return new Yo(Math.floor(e/6e4)*6e4)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*6e4)},function(e){return e.getMinutes()}),d3.time.minutes=d3.time.minute.range,d3.time.minutes.utc=d3.time.minute.utc.range,d3.time.hour=ss(function(e){var t=e.getTimezoneOffset()/60;return new Yo((Math.floor(e/36e5-t)+t)*36e5)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*36e5)},function(e){return e.getHours()}),d3.time.hours=d3.time.hour.range,d3.time.hours.utc=d3.time.hour.utc.range,d3.time.day=ss(function(e){var t=new Yo(1970,0);return t.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t},function(e,t){e.setDate(e.getDate()+t)},function(e){return e.getDate()-1}),d3.time.days=d3.time.day.range,d3.time.days.utc=d3.time.day.utc.range,d3.time.dayOfYear=function(e){var t=d3.time.year(e);return Math.floor((e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5)},Zo.forEach(function(e,t){e=e.toLowerCase(),t=7-t;var n=d3.time[e]=ss(function(e){return(e=d3.time.day(e)).setDate(e.getDate()-(e.getDay()+t)%7),e},function(e,t){e.setDate(e.getDate()+Math.floor(t)*7)},function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%7)/7)-(n!==t)});d3.time[e+"s"]=n.range,d3.time[e+"s"].utc=n.utc.range,d3.time[e+"OfYear"]=function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%7)/7)}}),d3.time.week=d3.time.sunday,d3.time.weeks=d3.time.sunday.range,d3.time.weeks.utc=d3.time.sunday.utc.range,d3.time.weekOfYear=d3.time.sundayOfYear,d3.time.month=ss(function(e){return e=d3.time.day(e),e.setDate(1),e},function(e,t){e.setMonth(e.getMonth()+t)},function(e){return e.getMonth()}),d3.time.months=d3.time.month.range,d3.time.months.utc=d3.time.month.utc.range,d3.time.year=ss(function(e){return e=d3.time.day(e),e.setMonth(0,1),e},function(e,t){e.setFullYear(e.getFullYear()+t)},function(e){return e.getFullYear()}),d3.time.years=d3.time.year.range,d3.time.years.utc=d3.time.year.utc.range;var xu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Tu=[[d3.time.second,1],[d3.time.second,5],[d3.time.second,15],[d3.time.second,30],[d3.time.minute,1],[d3.time.minute,5],[d3.time.minute,15],[d3.time.minute,30],[d3.time.hour,1],[d3.time.hour,3],[d3.time.hour,6],[d3.time.hour,12],[d3.time.day,1],[d3.time.day,2],[d3.time.week,1],[d3.time.month,1],[d3.time.month,3],[d3.time.year,1]],Nu=[[d3.time.format("%Y"),function(e){return!0}],[d3.time.format("%B"),function(e){return e.getMonth()}],[d3.time.format("%b %d"),function(e){return e.getDate()!=1}],[d3.time.format("%a %d"),function(e){return e.getDay()&&e.getDate()!=1}],[d3.time.format("%I %p"),function(e){return e.getHours()}],[d3.time.format("%I:%M"),function(e){return e.getMinutes()}],[d3.time.format(":%S"),function(e){return e.getSeconds()}],[d3.time.format(".%L"),function(e){return e.getMilliseconds()}]],Cu=d3.scale.linear(),ku=ls(Nu);Tu.year=function(e,t){return Cu.domain(e.map(hs)).ticks(t).map(cs)},d3.time.scale=function(){return us(d3.scale.linear(),Tu,ku)};var Lu=Tu.map(function(e){return[e[0].utc,e[1]]}),Au=[[d3.time.format.utc("%Y"),function(e){return!0}],[d3.time.format.utc("%B"),function(e){return e.getUTCMonth()}],[d3.time.format.utc("%b %d"),function(e){return e.getUTCDate()!=1}],[d3.time.format.utc("%a %d"),function(e){return e.getUTCDay()&&e.getUTCDate()!=1}],[d3.time.format.utc("%I %p"),function(e){return e.getUTCHours()}],[d3.time.format.utc("%I:%M"),function(e){return e.getUTCMinutes()}],[d3.time.format.utc(":%S"),function(e){return e.getUTCSeconds()}],[d3.time.format.utc(".%L"),function(e){return e.getUTCMilliseconds()}]],Ou=ls(Au);Lu.year=function(e,t){return Cu.domain(e.map(ds)).ticks(t).map(ps)},d3.time.scale.utc=function(){return us(d3.scale.linear(),Lu,Ou)}})(); \ No newline at end of file +(function(){function e(e,t){try{for(var n in t)Object.defineProperty(e.prototype,n,{value:t[n],enumerable:!1})}catch(r){e.prototype=t}}function t(e){var t=-1,n=e.length,r=[];while(++t=0?e.substring(t):(t=e.length,""),r=[];while(t>0)r.push(e.substring(t-=3,t+3));return r.reverse().join(",")+n}function S(e,t){var n=Math.pow(10,Math.abs(8-t)*3);return{scale:t>8?function(e){return e/n}:function(e){return e*n},symbol:e}}function T(e){return function(t){return t<=0?0:t>=1?1:e(t)}}function N(e){return function(t){return 1-e(1-t)}}function C(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}}function k(e){return e*e}function L(e){return e*e*e}function A(e){if(e<=0)return 0;if(e>=1)return 1;var t=e*e,n=t*e;return 4*(e<.5?n:3*(e-t)+n-.75)}function O(e){return function(t){return Math.pow(t,e)}}function M(e){return 1-Math.cos(e*bs/2)}function _(e){return Math.pow(2,10*(e-1))}function D(e){return 1-Math.sqrt(1-e*e)}function P(e,t){var n;return arguments.length<2&&(t=.45),arguments.length<1?(e=1,n=t/4):n=t/(2*bs)*Math.asin(1/e),function(r){return 1+e*Math.pow(2,10*-r)*Math.sin((r-n)*2*bs/t)}}function H(e){return e||(e=1.70158),function(t){return t*t*((e+1)*t-e)}}function B(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}function j(){d3.event.stopPropagation(),d3.event.preventDefault()}function F(){var e=d3.event,t;while(t=e.sourceEvent)e=t;return e}function I(e){var t=new g,n=0,r=arguments.length;while(++n360?e-=360:e<0&&(e+=360),e<60?s+(o-s)*e/60:e<180?o:e<240?s+(o-s)*(240-e)/60:s}function i(e){return Math.round(r(e)*255)}var s,o;return e%=360,e<0&&(e+=360),t=t<0?0:t>1?1:t,n=n<0?0:n>1?1:n,o=n<=.5?n*(1+t):n+t-n*t,s=2*n-o,J(i(e+120),i(e),i(e-120))}function st(e,t,n){return new ot(e,t,n)}function ot(e,t,n){this.h=e,this.c=t,this.l=n}function ut(e,t,n){return at(n,Math.cos(e*=Es)*t,Math.sin(e)*t)}function at(e,t,n){return new ft(e,t,n)}function ft(e,t,n){this.l=e,this.a=t,this.b=n}function lt(e,t,n){var r=(e+16)/116,i=r+t/500,s=r-n/200;return i=ht(i)*Xs,r=ht(r)*Vs,s=ht(s)*$s,J(dt(3.2404542*i-1.5371385*r-.4985314*s),dt(-0.969266*i+1.8760108*r+.041556*s),dt(.0556434*i-.2040259*r+1.0572252*s))}function ct(e,t,n){return st(Math.atan2(n,t)/bs*180,Math.sqrt(t*t+n*n),e)}function ht(e){return e>.206893034?e*e*e:(e-4/29)/7.787037}function pt(e){return e>.008856?Math.pow(e,1/3):7.787037*e+4/29}function dt(e){return Math.round(255*(e<=.00304?12.92*e:1.055*Math.pow(e,1/2.4)-.055))}function vt(e){return Cs(e,eo),e}function mt(e){return function(){return Ks(e,this)}}function gt(e){return function(){return Qs(e,this)}}function yt(e,t){function n(){this.removeAttribute(e)}function r(){this.removeAttributeNS(e.space,e.local)}function i(){this.setAttribute(e,t)}function s(){this.setAttributeNS(e.space,e.local,t)}function o(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}function u(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}return e=d3.ns.qualify(e),t==null?e.local?r:n:typeof t=="function"?e.local?u:o:e.local?s:i}function bt(e){return new RegExp("(?:^|\\s+)"+d3.requote(e)+"(?:\\s+|$)","g")}function wt(e,t){function n(){var n=-1;while(++n0&&(e=e.substring(0,o)),t?i:r}function Lt(e,t){for(var n=0,r=e.length;nn?a():(s.active=n,c.start.call(e,f,t),o.tween.forEach(function(n,r){(r=r.call(e,f,t))&&v.push(r)}),u(r)||d3.timer(u,0,h),1)}function u(r){if(s.active!==n)return a();var i=(r-p)/d,o=l(i),u=v.length;while(u>0)v[--u].call(e,o);if(i>=1)return a(),c.end.call(e,f,t),1}function a(){return--s.count?delete s[n]:delete e.__transition__,1}var f=e.__data__,l=o.ease,c=o.event,h=o.time,p=o.delay,d=o.duration,v=[];return p<=r?i(r):d3.timer(i,p,h),1}),o}function _t(e,t){function n(){this.removeAttribute(e)}function r(){this.removeAttributeNS(e.space,e.local)}function i(){var n=this.getAttribute(e),r;return n!==t&&(r=o(n,t),function(t){this.setAttribute(e,r(t))})}function s(){var n=this.getAttributeNS(e.space,e.local),r;return n!==t&&(r=o(n,t),function(t){this.setAttributeNS(e.space,e.local,r(t))})}var o;return e=d3.ns.qualify(e),t==null?e.local?r:n:(t+="",o=W(e),e.local?s:i)}function Dt(e,t,n){function r(){this.style.removeProperty(e)}function i(){var r=getComputedStyle(this,null).getPropertyValue(e),i;return r!==t&&(i=s(r,t),function(t){this.style.setProperty(e,i(t),n)})}var s;return t==null?r:(t+="",s=W(e),i)}function Pt(e){return e==null&&(e=""),function(){this.textContent=e}}function Ht(){var e,t=Date.now(),n=fo;while(n)e=t-n.then,e>=n.delay&&(n.flush=n.callback(e)),n=n.next;var r=Bt()-t;r>24?(isFinite(r)&&(clearTimeout(co),co=setTimeout(Ht,r)),lo=0):(lo=1,ho(Ht))}function Bt(){var e=null,t=fo,n=Infinity;while(t)t.flush?(delete ao[t.callback.id],t=e?e.next=t.next:fo=t.next):(n=Math.min(n,t.then+t.delay),t=(e=t).next);return n}function jt(e,t){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var r=n.createSVGPoint();if(po<0&&(window.scrollX||window.scrollY)){n=d3.select(document.body).append("svg").style("position","absolute").style("top",0).style("left",0);var i=n[0][0].getScreenCTM();po=!i.f&&!i.e,n.remove()}return po?(r.x=t.pageX,r.y=t.pageY):(r.x=t.clientX,r.y=t.clientY),r=r.matrixTransform(e.getScreenCTM().inverse()),[r.x,r.y]}var s=e.getBoundingClientRect();return[t.clientX-s.left-e.clientLeft,t.clientY-s.top-e.clientTop]}function Ft(){}function It(e){var t=e[0],n=e[e.length-1];return t2?Qt:Kt,a=r?V:X;return o=i(e,t,a,n),u=i(t,e,a,d3.interpolate),s}function s(e){return o(e)}var o,u;return s.invert=function(e){return u(e)},s.domain=function(t){return arguments.length?(e=t.map(Number),i()):e},s.range=function(e){return arguments.length?(t=e,i()):t},s.rangeRound=function(e){return s.range(e).interpolate(d3.interpolateRound)},s.clamp=function(e){return arguments.length?(r=e,i()):r},s.interpolate=function(e){return arguments.length?(n=e,i()):n},s.ticks=function(t){return $t(e,t)},s.tickFormat=function(t){return Jt(e,t)},s.nice=function(){return Rt(e,Xt),i()},s.copy=function(){return zt(e,t,n,r)},i()}function Wt(e,t){return d3.rebind(e,t,"range","rangeRound","interpolate","clamp")}function Xt(e){return e=Math.pow(10,Math.round(Math.log(e)/Math.LN10)-1),e&&{floor:function(t){return Math.floor(t/e)*e},ceil:function(t){return Math.ceil(t/e)*e}}}function Vt(e,t){var n=It(e),r=n[1]-n[0],i=Math.pow(10,Math.floor(Math.log(r/t)/Math.LN10)),s=t/r*i;return s<=.15?i*=10:s<=.35?i*=5:s<=.75&&(i*=2),n[0]=Math.ceil(n[0]/i)*i,n[1]=Math.floor(n[1]/i)*i+i*.5,n[2]=i,n}function $t(e,t){return d3.range.apply(d3,Vt(e,t))}function Jt(e,t){return d3.format(",."+Math.max(0,-Math.floor(Math.log(Vt(e,t)[2])/Math.LN10+.01))+"f")}function Kt(e,t,n,r){var i=n(e[0],e[1]),s=r(t[0],t[1]);return function(e){return s(i(e))}}function Qt(e,t,n,r){var i=[],s=[],o=0,u=Math.min(e.length,t.length)-1;e[u]0;f--)i.push(r(s)*f)}else{for(;sa;o--);i=i.slice(s,o)}return i},n.tickFormat=function(e,i){arguments.length<2&&(i=vo);if(arguments.length<1)return i;var s=Math.max(.1,e/n.ticks().length),o=t===Zt?(u=-1e-12,Math.floor):(u=1e-12,Math.ceil),u;return function(e){return e/r(o(t(e)+u))<=s?i(e):""}},n.copy=function(){return Gt(e.copy(),t)},Wt(n,e)}function Yt(e){return Math.log(e<0?0:e)/Math.LN10}function Zt(e){return-Math.log(e>0?0:-e)/Math.LN10}function en(e,t){function n(t){return e(r(t))}var r=tn(t),i=tn(1/t);return n.invert=function(t){return i(e.invert(t))},n.domain=function(t){return arguments.length?(e.domain(t.map(r)),n):e.domain().map(i)},n.ticks=function(e){return $t(n.domain(),e)},n.tickFormat=function(e){return Jt(n.domain(),e)},n.nice=function(){return n.domain(Rt(n.domain(),Xt))},n.exponent=function(e){if(!arguments.length)return t;var s=n.domain();return r=tn(t=e),i=tn(1/t),n.domain(s)},n.copy=function(){return en(e.copy(),t)},Wt(n,e)}function tn(e){return function(t){return t<0?-Math.pow(-t,e):Math.pow(t,e)}}function nn(e,t){function n(t){return o[((s.get(t)||s.set(t,e.push(t)))-1)%o.length]}function i(t,n){return d3.range(e.length).map(function(e){return t+n*e})}var s,o,u;return n.domain=function(i){if(!arguments.length)return e;e=[],s=new r;var o=-1,u=i.length,a;while(++o1){u=t[1],s=e[a],a++,r+="C"+(i[0]+o[0])+","+(i[1]+o[1])+","+(s[0]-u[0])+","+(s[1]-u[1])+","+s[0]+","+s[1];for(var f=2;f9&&(s=n*3/Math.sqrt(s),o[u]=s*r,o[u+1]=s*i));u=-1;while(++u<=a)s=(e[Math.min(a,u+1)][0]-e[Math.max(0,u-1)][0])/(6*(1+o[u]*o[u])),t.push([s||0,o[u]*s||0]);return t}function Dn(e){return e.length<3?vn(e):e[0]+Sn(e,_n(e))}function Pn(e){var t,n=-1,r=e.length,i,s;while(++n1){var r=It(e.domain()),i,s=-1,o=t.length,u=(t[1]-t[0])/++n,a,f;while(++s0;)(f=+t[s]-a*u)>=r[0]&&i.push(f);for(--s,a=0;++ar&&(n=t,r=i);return n}function hr(e){return e.reduce(pr,0)}function pr(e,t){return e+t[1]}function dr(e,t){return vr(e,Math.ceil(Math.log(t.length)/Math.LN2+1))}function vr(e,t){var n=-1,r=+e[0],i=(e[1]-r)/t,s=[];while(++n<=t)s[n]=i*n+r;return s}function mr(e){return[d3.min(e),d3.max(e)]}function gr(e,t){return d3.rebind(e,t,"sort","children","value"),e.links=Er,e.nodes=function(t){return Bo=!0,(e.nodes=e)(t)},e}function yr(e){return e.children}function br(e){return e.value}function wr(e,t){return t.value-e.value}function Er(e){return d3.merge(e.map(function(e){return(e.children||[]).map(function(t){return{source:e,target:t}})}))}function Sr(e,t){return e.value-t.value}function xr(e,t){var n=e._pack_next;e._pack_next=t,t._pack_prev=e,t._pack_next=n,n._pack_prev=t}function Tr(e,t){e._pack_next=t,t._pack_prev=e}function Nr(e,t){var n=t.x-e.x,r=t.y-e.y,i=e.r+t.r;return i*i-n*n-r*r>.001}function Cr(e){function t(e){r=Math.min(e.x-e.r,r),i=Math.max(e.x+e.r,i),s=Math.min(e.y-e.r,s),o=Math.max(e.y+e.r,o)}if(!(n=e.children)||!(p=n.length))return;var n,r=Infinity,i=-Infinity,s=Infinity,o=-Infinity,u,a,f,l,c,h,p;n.forEach(kr),u=n[0],u.x=-u.r,u.y=0,t(u);if(p>1){a=n[1],a.x=a.r,a.y=0,t(a);if(p>2){f=n[2],Or(u,a,f),t(f),xr(u,f),u._pack_prev=f,xr(f,a),a=u._pack_next;for(l=3;l0&&(e=r)}return e}function Ir(e,t){return e.x-t.x}function qr(e,t){return t.x-e.x}function Rr(e,t){return e.depth-t.depth}function Ur(e,t){function n(e,r){var i=e.children;if(i&&(a=i.length)){var s,o=null,u=-1,a;while(++u=0)s=r[i]._tree,s.prelim+=t,s.mod+=t,t+=s.shift+(n+=s.change)}function Wr(e,t,n){e=e._tree,t=t._tree;var r=n/(t.number-e.number);e.change+=r,t.change-=r,t.shift+=n,t.prelim+=n,t.mod+=n}function Xr(e,t,n){return e._tree.ancestor.parent==t.parent?e._tree.ancestor:n}function Vr(e){return{x:e.x,y:e.y,dx:e.dx,dy:e.dy}}function $r(e,t){var n=e.x+t[3],r=e.y+t[0],i=e.dx-t[1]-t[3],s=e.dy-t[0]-t[2];return i<0&&(n+=i/2,i=0),s<0&&(r+=s/2,s=0),{x:n,y:r,dx:i,dy:s}}function Jr(e,t){function n(e,n){return d3.xhr(e,t,n).response(r)}function r(e){return n.parse(e.responseText)}function i(t){return t.map(s).join(e)}function s(e){return u.test(e)?'"'+e.replace(/\"/g,'""')+'"':e}var o=new RegExp("\r\n|["+e+"\r\n]","g"),u=new RegExp('["'+e+"\n]"),a=e.charCodeAt(0);return n.parse=function(e){var t;return n.parseRows(e,function(e,n){if(n){var r={},i=-1,s=t.length;while(++i=e.length)return i;if(l)return l=!1,r;var t=o.lastIndex;if(e.charCodeAt(t)===34){var n=t;while(n++l}function r(e,r,s){if(!(f=e.length))return;var o=t(e[0]),u=n(o),a=u&&s!=null,f;u&&r.moveTo(o[0],o[1]);for(var l=1;lt;m-=v){var g=Math.cos(m),y=Math.sin(m),b=ti([h[0]+c*(g*i+y*l),h[1]+c*(g*s+y*p),h[2]+c*(g*o+y*d)]);n.lineTo(b[0],b[1])}}var o=e*Es,u=6*Es,a=[1,0,0],f=[0,-1,0],l=Math.cos(o),c=Math.sin(o),h=si(a,l),p=Zr(h);return{point:function(e,r){n(e=t(e))&&r.moveTo(e[0],e[1])},line:function(e,t){r(e,t)},polygon:function(e,t){Yr(e,t,r,s,p)}}}function Yr(e,t,n,r,i){var s=0,o=[],u=[],a=ui(n),f=0;e.forEach(function(e){var n=a(e,t),r=n[1];f+=n[0];var i=r.length;if(i>1){var s=r[0],o=r[i-1],l=s[0],c=o[o.length-1];l[0]===c[0]&&l[1]===c[1]&&(r.shift(),r.pop(),r.push(o.concat(s)))}u=u.concat(r)});if(f>0){f=[],u.push(f=[]),x={lineTo:function(e,t){f.push([e,t])}};for(var l=0;l<4;l++)r({angle:-l*bs/2},{angle:-(l+1)*bs/2},x);f.push(f[0])}u.forEach(function(e){var n=e[0],r=e[e.length-1];if(n[0]!==r[0]||n[1]!==r[1]){var u={point:r,angle:i(r),points:[],other:null},a={point:n,angle:i(n),points:e,other:u};o.push(a,u),s++}else{var f=e[0],l=e.length-1,c=0;t.moveTo(f[0],f[1]);while(++c0&&(e[0]-t[0])*e[1]+e[0]*(t[1]-e[1])>0)return 1}else if(t[1]<=0&&(e[0]-t[0])*e[1]+e[0]*(t[1]-e[1])<0)return-1;return 0}function fi(e,t){function n(n,r){var i=e(n,r);return t(i[0],i[1])}return e===li?t:t===li?e:(e.invert&&t.invert&&(n.invert=function(n,r){var i=t.invert(n,r);return e.invert(i[0],i[1])}),n)}function li(e,t){return[e,t]}function ci(e,t){var n=d3.range(e,t-ws,Jo).concat(t);return function(e){return n.map(function(t){return[e,t]})}}function hi(e,t){var n=d3.range(e,t-ws,Jo).concat(t);return function(e){return n.map(function(t){return[t,e]})}}function pi( +e){return e.source}function di(e){return e.target}function vi(){function e(e){var t=Math.sin(e*=p)*d,n=Math.sin(p-e)*d,r=n*s+t*c,u=n*o+t*h,a=n*i+t*l;return[Math.atan2(u,r)/Es,Math.atan2(a,Math.sqrt(r*r+u*u))/Es]}var t,n,r,i,s,o,u,a,f,l,c,h,p,d;return e.distance=function(){return p==null&&(d=1/Math.sin(p=Math.acos(Math.max(-1,Math.min(1,i*l+r*f*Math.cos(u-t)))))),p},e.source=function(u){var a=Math.cos(t=u[0]*Es),f=Math.sin(t);return r=Math.cos(n=u[1]*Es),i=Math.sin(n),s=r*a,o=r*f,p=null,e},e.target=function(t){var n=Math.cos(u=t[0]*Es),r=Math.sin(u);return f=Math.cos(a=t[1]*Es),l=Math.sin(a),c=f*n,h=f*r,p=null,e},e}function mi(e,t){var n=vi().source(e).target(t);return n.distance(),n}function gi(e,t){return[e/(2*bs),Math.max(-0.5,Math.min(.5,Math.log(Math.tan(bs/4+t/2))/(2*bs)))]}function yi(e){return"m0,"+e+"a"+e+","+e+" 0 1,1 0,"+ -2*e+"a"+e+","+e+" 0 1,1 0,"+2*e+"z"}function bi(e){return wi(function(){return e})()}function wi(e){function t(e){return e=f(e[0]*Es,e[1]*Es),[e[0]*l+y,b-e[1]*l]}function n(e){return e=f.invert((e[0]-y)/l,(b-e[1])/l),[e[0]*Ss,e[1]*Ss]}function r(e){function t(t,n){var r=s(o=a=t,u=f=n);e.moveTo(l=r[0],c=r[1])}function n(t,n){var i=s(t,n);r(l,c,a,f,l=i[0],c=i[1],a=t,f=n,h),e.lineTo(l,c)}function r(t,n,i,o,u,a,f,l,c){var h=u-t,p=a-n,d=h*h+p*p;if(d>4*w&&c--){var v=Math.sin(o),m=Math.cos(o),g=Math.sin(l),y=Math.cos(l),b=v*g+m*y*Math.cos(f-i),E=1/(Math.SQRT2*Math.sqrt(1+b)),S=E*(m*Math.cos(i)+y*Math.cos(f)),x=E*(m*Math.sin(i)+y*Math.sin(f)),T=E*(v+g),N=Math.asin(Math.max(-1,Math.min(1,T))),C=Math.abs(S)d-ws?r(t,n,i,o,u,a,C,N,c):_*_/d>w&&(r(t,n,i,o,L,A,C,N,c),e.lineTo(L,A),r(L,A,C,N,u,a,f,l,c))}}function i(){var t=s(o,u);r(l,c,a,f,t[0],t[1],o,u,h),e.closePath()}var o,u,a,f,l,c,h=w>0&&16;return{moveTo:t,lineTo:n,closePath:i}}function i(e){return a(e[0]*Es,e[1]*Es)}function s(e,t){var n=u(e,t);return[n[0]*l+y,b-n[1]*l]}function o(){f=fi(a=Ni(v,m,g),u);var e=u(p,d);return y=c-e[0]*l,b=h+e[1]*l,t}var u,a,f,l=150,c=480,h=250,p=0,d=0,v=0,m=0,g=0,y=c,b=h,w=.5,E=Si(i),S=null;return t.point=function(e,t){E.point(e,r(t))},t.line=function(e,t){E.line(e,r(t))},t.polygon=function(e,t){E.polygon(e,r(t))},t.clipAngle=function(e){return arguments.length?(E=e==null?(S=e,Si(i)):Gr(S=+e,i),t):S},t.scale=function(e){return arguments.length?(l=+e,o()):l},t.translate=function(e){return arguments.length?(c=+e[0],h=+e[1],o()):[c,h]},t.center=function(e){return arguments.length?(p=e[0]%360*Es,d=e[1]%360*Es,o()):[p*Ss,d*Ss]},t.rotate=function(e){return arguments.length?(v=e[0]%360*Es,m=e[1]%360*Es,g=e.length>2?e[2]%360*Es:0,o()):[v*Ss,m*Ss,g*Ss]},t.precision=function(e){return arguments.length?(w=e*e,t):Math.sqrt(w)},function(){return u=e.apply(this,arguments),t.invert=u.invert&&n,o()}}function Ei(e,t,n,r){var i,s,o=Math.sin(e-n);return Math.abs(o)>ws?Math.atan((Math.sin(t)*(s=Math.cos(r))*Math.sin(n)-Math.sin(r)*(i=Math.cos(t))*Math.sin(e))/(i*s*o)):(t+r)/2}function Si(e){var t={point:function(t,n){var r=e(t);n.point(r[0],r[1])},line:function(t,n){if(!(c=t.length))return;var r=e(t[0]),i=r[0],s=r[1],o,u,a=i>0?bs:-bs,f,l=0,c;n.moveTo(i,s);while(++l0?bs:-bs,a!==f&&Math.abs(o-i)>=bs?(s=Ei(i,s,o,u),Math.abs(i-a)>ws&&n.lineTo(a,s),Math.abs(o-f)>ws?(n.moveTo(f,s),n.lineTo(i=o,s=u)):n.moveTo(i=o,s=u)):n.lineTo(i=o,s=u),a=f},polygon:function(e,n){Yr(e,n,t.line,Ti,xi)}};return t}function xi(e){return-(e[0]<0?e[1]-bs/2:bs/2-e[1])}function Ti(e,t,n){e=e.point,t=t.point;if(Math.abs(e[0]-t[0])>ws){var r=e[0]bs?t-2*bs:t<-bs?t+2*bs:t,n]}}function ki(e){var t=Ci(e);return t.invert=Ci(-e),t}function Li(e,t){function n(e,t){var n=Math.cos(t),u=Math.cos(e)*n,a=Math.sin(e)*n,f=Math.sin(t),l=f*r+u*i;return[Math.atan2(a*s-l*o,u*r-f*i),Math.asin(Math.max(-1,Math.min(1,l*s+a*o)))]}var r=Math.cos(e),i=Math.sin(e),s=Math.cos(t),o=Math.sin(t);return n.invert=function(e,t){var n=Math.cos(t),u=Math.cos(e)*n,a=Math.sin(e)*n,f=Math.sin(t),l=f*s-a*o;return[Math.atan2(a*s+f*o,u*r+l*i),Math.asin(Math.max(-1,Math.min(1,l*r-u*i)))]},n}function Ai(e,t){function n(t,n){var r=Math.cos(t),i=Math.cos(n),s=e(r*i);return[s*i*Math.sin(t),s*Math.sin(n)]}return n.invert=function(e,n){var r=Math.sqrt(e*e+n*n),i=t(r),s=Math.sin(i),o=Math.cos(i);return[Math.atan2(e*s,r*o),Math.asin(r&&n*s/r)]},n}function Oi(e,t,n,r){var i,s,o,u,a,f,l;return i=r[e],s=i[0],o=i[1],i=r[t],u=i[0],a=i[1],i=r[n],f=i[0],l=i[1],(l-o)*(u-s)-(a-o)*(f-s)>0}function Mi(e,t,n){return(n[0]-t[0])*(e[1]-t[1])<(n[1]-t[1])*(e[0]-t[0])}function _i(e,t,n,r){var i=e[0],s=t[0],o=n[0],u=r[0],a=e[1],f=t[1],l=n[1],c=r[1],h=i-o,p=s-i,d=u-o,v=a-l,m=f-a,g=c-l,y=(d*v-g*h)/(g*p-d*m);return[i+y*p,a+y*m]}function Di(e,t){var n={list:e.map(function(e,t){return{index:t,x:e[0],y:e[1]}}).sort(function(e,t){return e.yt.y?1:e.xt.x?1:0}),bottomSite:null},r={list:[],leftEnd:null,rightEnd:null,init:function(){r.leftEnd=r.createHalfEdge(null,"l"),r.rightEnd=r.createHalfEdge(null,"l"),r.leftEnd.r=r.rightEnd,r.rightEnd.l=r.leftEnd,r.list.unshift(r.leftEnd,r.rightEnd)},createHalfEdge:function(e,t){return{edge:e,side:t,vertex:null,l:null,r:null}},insert:function(e,t){t.l=e,t.r=e.r,e.r.l=t,e.r=t},leftBound:function(e){var t=r.leftEnd;do t=t.r;while(t!=r.rightEnd&&i.rightOf(t,e));return t=t.l,t},del:function(e){e.l.r=e.r,e.r.l=e.l,e.edge=null},right:function(e){return e.r},left:function(e){return e.l},leftRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[e.side]},rightRegion:function(e){return e.edge==null?n.bottomSite:e.edge.region[Go[e.side]]}},i={bisect:function(e,t){var n={region:{l:e,r:t},ep:{l:null,r:null}},r=t.x-e.x,i=t.y-e.y,s=r>0?r:-r,o=i>0?i:-i;return n.c=e.x*r+e.y*i+(r*r+i*i)*.5,s>o?(n.a=1,n.b=i/r,n.c/=r):(n.b=1,n.a=r/i,n.c/=i),n},intersect:function(e,t){var n=e.edge,r=t.edge;if(!n||!r||n.region.r==r.region.r)return null;var i=n.a*r.b-n.b*r.a;if(Math.abs(i)<1e-10)return null;var s=(n.c*r.b-r.c*n.b)/i,o=(r.c*n.a-n.c*r.a)/i,u=n.region.r,a=r.region.r,f,l;u.y=l.region.r.x;return c&&f.side==="l"||!c&&f.side==="r"?null:{x:s,y:o}},rightOf:function(e,t){var n=e.edge,r=n.region.r,i=t.x>r.x;if(i&&e.side==="l")return 1;if(!i&&e.side==="r")return 0;if(n.a===1){var s=t.y-r.y,o=t.x-r.x,u=0,a=0;!i&&n.b<0||i&&n.b>=0?a=u=s>=n.b*o:(a=t.x+t.y*n.b>n.c,n.b<0&&(a=!a),a||(u=1));if(!u){var f=r.x-n.region.l.x;a=n.b*(o*o-s*s)h*h+p*p}return e.side==="l"?a:!a},endPoint:function(e,n,r){e.ep[n]=r;if(!e.ep[Go[n]])return;t(e)},distance:function(e,t){var n=e.x-t.x,r=e.y-t.y;return Math.sqrt(n*n+r*r)}},s={list:[],insert:function(e,t,n){e.vertex=t,e.ystar=t.y+n;for(var r=0,i=s.list,o=i.length;ru.ystar||e.ystar==u.ystar&&t.x>u.vertex.x)continue;break}i.splice(r,0,e)},del:function(e){for(var t=0,n=s.list,r=n.length;td.y&&(v=p,p=d,d=v,b="r"),y=i.bisect(p,d),h=r.createHalfEdge(y,b),r.insert(l,h),i.endPoint(y,Go[b],g),m=i.intersect(l,h),m&&(s.del(l),s.insert(l,m,i.distance(m,p))),m=i.intersect(h,c),m&&s.insert(h,m,i.distance(m,p))}}for(a=r.right(r.leftEnd);a!=r.rightEnd;a=r.right(a))t(a.edge)}function Pi(){return{leaf:!0,nodes:[],point:null}}function Hi(e,t,n,r,i,s){if(!e(t,n,r,i,s)){var o=(n+i)*.5,u=(r+s)*.5,a=t.nodes;a[0]&&Hi(e,a[0],n,r,o,u),a[1]&&Hi(e,a[1],o,r,i,u),a[2]&&Hi(e,a[2],n,u,o,s),a[3]&&Hi(e,a[3],o,u,i,s)}}function Bi(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function ji(e){return e.substring(0,3)}function Fi(e,t,n,r){var i,s,o=0,u=t.length,a=n.length;while(o=a)return-1;i=t.charCodeAt(o++);if(i==37){s=bu[t.charAt(o++)];if(!s||(r=s(e,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}function Ii(e){return new RegExp("^(?:"+e.map(d3.requote).join("|")+")","i")}function qi(e){var t=new r,n=-1,i=e.length;while(++n68?1900:2e3)}function Gi(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.m=r[0]-1,n+=r[0].length):-1}function Yi(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.d=+r[0],n+=r[0].length):-1}function Zi(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.H=+r[0],n+=r[0].length):-1}function es(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.M=+r[0],n+=r[0].length):-1}function ts(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+2));return r?(e.S=+r[0],n+=r[0].length):-1}function ns(e,t,n){wu.lastIndex=0;var r=wu.exec(t.substring(n,n+3));return r?(e.L=+r[0],n+=r[0].length):-1}function rs(e,t,n){var r=Eu.get(t.substring(n,n+=2).toLowerCase());return r==null?-1:(e.p=r,n)}function is(e){var t=e.getTimezoneOffset(),n=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return n+au(r)+au(i)}function ss(e){return e.toISOString()}function os(e,t,n){function r(t){var n=e(t),r=s(n,1);return t-n1)while(ot?1:e>=t?0:NaN},d3.descending=function(e,t){return te?1:t>=e?0:NaN},d3.mean=function(e,t){var n=e.length,r,i=0,s=-1,o=0;if(arguments.length===1)while(++s1&&(e=e.map(t)),e=e.filter(f),e.length?d3.quantile(e.sort(d3.ascending),.5):undefined},d3.min=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++ns&&(i=s)}else{while(++ns&&(i=s)}return i},d3.max=function(e,t){var n=-1,r=e.length,i,s;if(arguments.length===1){while(++ni&&(i=s)}else{while(++ni&&(i=s)}return i},d3.extent=function(e,t){var n=-1,r=e.length,i,s,o;if(arguments.length===1){while(++ns&&(i=s),os&&(i=s),o1);return e+t*n*Math.sqrt(-2*Math.log(i)/i)}},logNormal:function(e,t){var n=arguments.length;n<2&&(t=1),n<1&&(e=0);var r=d3.random.normal();return function(){return Math.exp(e+t*r())}},irwinHall:function(e){return function(){for(var t=0,n=0;n>>1;e.call(t,t[s],s)>>1;n=i.length)return u?u.call(n,t):o?t.sort(o):t;var a=-1,f=t.length,l=i[s++],c,h,p=new r,d,v={};while(++a=i.length)return e;var r=[],o=s[n++],u;for(u in e)r.push({key:u,values:t(e[u],n)});return o&&r.sort(function(e,t){return o(e.key,t.key)}),r}var n={},i=[],s=[],o,u;return n.map=function(t){return e(t,0)},n.entries=function(n){return t(e(n,0),0)},n.key=function(e){return i.push(e),n},n.sortKeys=function(e){return s[i.length-1]=e,n},n.sortValues=function(e){return o=e,n},n.rollup=function(e){return u=e,n},n},d3.keys=function(e){var t=[];for(var n in e)t.push(n);return t},d3.values=function(e){var t=[];for(var n in e)t.push(e[n]);return t},d3.entries=function(e){var t=[];for(var n in e)t.push({key:n,value:e[n]});return t},d3.permute=function(e,t){var n=[],r=-1,i=t.length;while(++rt)r.push(o/i);else while((o=e+n*++s)=200&&e<300||e===304?s.load.call(r,u.call(r,a)):s.error.call(r,a)}},a.onprogress=function(e){var t=d3.event;d3.event=e;try{s.progress.call(r,a)}finally{d3.event=t}},r.header=function(e,t){return e=(e+"").toLowerCase(),arguments.length<2?o[e]:(t==null?delete o[e]:o[e]=t+"",r)},r.mimeType=function(e){return arguments.length?(t=e==null?null:e+"",r):t},r.response=function(e){return u=e,r},["get","post"].forEach(function(e){r[e]=function(){return r.send.apply(r,[e].concat(Ts(arguments)))}}),r.send=function(n,i,s){arguments.length===2&&typeof i=="function"&&(s=i,i=null),a.open(n,e,!0),t!=null&&!("accept"in o)&&(o.accept=t+",*/*");for(var u in o)a.setRequestHeader(u,o[u]);return t!=null&&a.overrideMimeType&&a.overrideMimeType(t),s!=null&&r.on("error",s).on("load",function(e){s(null,e)}),a.send(i==null?null:i),r},r.abort=function(){return a.abort(),r},d3.rebind(r,s,"on"),arguments.length===2&&typeof t=="function"&&(n=t,t=null),n==null?r:r.get(n)},d3.text=function(){return d3.xhr.apply(d3,arguments).response(p)},d3.json=function(e,t){return d3.xhr(e,"application/json",t).response(d)},d3.html=function(e,t){return d3.xhr(e,"text/html",t).response(v)},d3.xml=function(){return d3.xhr.apply(d3,arguments).response(m)};var Ms={svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};d3.ns={prefix:Ms,qualify:function(e){var t=e.indexOf(":"),n=e;return t>=0&&(n=e.substring(0,t),e=e.substring(t+1)),Ms.hasOwnProperty(n)?{space:Ms[n],local:e}:e}},d3.dispatch=function(){var e=new g,t=-1,n=arguments.length;while(++t0&&(r=e.substring(n+1),e=e.substring(0,n)),arguments.length<2?this[e].on(r):this[e].on(r,t)},d3.format=function(e){var t=_s.exec(e),n=t[1]||" ",r=t[3]||"",i=t[5],s=+t[6],o=t[7],u=t[8],a=t[9],f=1,l="",c=!1;u&&(u=+u.substring(1)),i&&(n="0",o&&(s-=Math.floor((s-1)/4)));switch(a){case"n":o=!0,a="g";break;case"%":f=100,l="%",a="f";break;case"p":f=100,l="%",a="r";break;case"d":c=!0,u=0;break;case"s":f=-1,a="r"}return a=="r"&&!u&&(a="g"),a=Ds.get(a)||w,function(e){if(c&&e%1)return"";var t=e<0&&(e=-e)?"-":r;if(f<0){var h=d3.formatPrefix(e,u);e=h.scale(e),l=h.symbol}else e*=f;e=a(e,u);if(i){var p=e.length+t.length;p=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,Ds=d3.map({g:function(e,t){return e.toPrecision(t)},e:function(e,t){return e.toExponential(t)},f:function(e,t){return e.toFixed(t)},r:function(e,t){return d3.round(e,t=b(e,t)).toFixed(Math.max(0,Math.min(20,t)))}}),Ps=["y","z","a","f","p","n","μ","m","","k","M","G","T","P","E","Z","Y"].map(S);d3.formatPrefix=function(e,t){var n=0;return e&&(e<0&&(e*=-1),t&&(e=d3.round(e,b(e,t))),n=1+Math.floor(1e-12+Math.log(e)/Math.LN10),n=Math.max(-24,Math.min(24,Math.floor((n<=0?n+1:n-1)/3)*3))),Ps[8+n/3]};var Hs=function(){return i},Bs=d3.map({linear:Hs,poly:O,quad:function(){return k},cubic:function(){return L},sin:function(){return M},exp:function(){return _},circle:function(){return D},elastic:P,back:H,bounce:function(){return B}}),js=d3.map({"in":i,out:N,"in-out":C,"out-in":function(e){return C(N(e))}});d3.ease=function(e){var t=e.indexOf("-"),n=t>=0?e.substring(0,t):e,r=t>=0?e.substring(t+1):"in";return n=Bs.get(n)||Hs,r=js.get(r)||i,T(r(n.apply(null,Array.prototype.slice.call(arguments,1))))},d3.event=null,d3.transform=function(e){var t=document.createElementNS(d3.ns.prefix.svg,"g");return(d3.transform=function(e){t.setAttribute("transform",e);var n=t.transform.baseVal.consolidate();return new q(n?n.matrix:Fs)})(e)},q.prototype.toString=function(){return"translate("+this.translate+")rotate("+this.rotate+")skewX("+this.skew+")scale("+this.scale+")"};var Fs={a:1,b:0,c:0,d:1,e:0,f:0};d3.interpolate=function(e,t){var n=d3.interpolators.length,r;while(--n>=0&&!(r=d3.interpolators[n](e,t)));return r},d3.interpolateNumber=function(e,t){return t-=e,function(n){return e+t*n}},d3.interpolateRound=function(e,t){return t-=e,function(n){return Math.round(e+t*n)}},d3.interpolateString=function(e,t){var n,r,i,s=0,o=0,u=[],a=[],f,l;Is.lastIndex=0;for(r=0;n=Is.exec(t);++r)n.index&&u.push(t.substring(s,o=n.index)),a.push({i:u.length,x:n[0]}),u.push(null),s=Is.lastIndex;s180?l+=360:l-f>180&&(f+=360),r.push({i:n.push(n.pop()+"rotate(",null,")")-2,x:d3.interpolateNumber(f,l)})):l&&n.push(n.pop()+"rotate("+l+")"),c!=h?r.push({i:n.push(n.pop()+"skewX(",null,")")-2,x:d3.interpolateNumber(c,h)}):h&&n.push(n.pop()+"skewX("+h+")"),p[0]!=d[0]||p[1]!=d[1]?(i=n.push(n.pop()+"scale(",null,",",null,")"),r.push({i:i-4,x:d3.interpolateNumber(p[0],d[0])},{i:i-2,x:d3.interpolateNumber(p[1],d[1])})):(d[0]!=1||d[1]!=1)&&n.push(n.pop()+"scale("+d+")"),i=r.length,function(e){var t=-1,s;while(++t180?s-=360:s<-180&&(s+=360),function(e){return it(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateLab=function(e,t){e=d3.lab(e),t=d3.lab(t);var n=e.l,r=e.a,i=e.b,s=t.l-n,o=t.a-r,u=t.b-i;return function(e){return lt(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateHcl=function(e,t){e=d3.hcl(e),t=d3.hcl(t);var n=e.h,r=e.c,i=e.l,s=t.h-n,o=t.c-r,u=t.l-i;return s>180?s-=360:s<-180&&(s+=360),function(e){return ut(n+s*e,r+o*e,i+u*e)+""}},d3.interpolateArray=function(e,t){var n=[],r=[],i=e.length,s=t.length,o=Math.min(e.length,t.length),u;for(u=0;u=0;)if(s=n[r])i&&i!==s.nextSibling&&i.parentNode.insertBefore(s,i),i=s;return this},eo.sort=function(e){e=Ct.apply(this,arguments);for(var t=-1,n=this.length;++t=Eo?e?"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"M0,"+e+"A"+e+","+e+" 0 1,0 0,"+ -e+"A"+e+","+e+" 0 1,0 0,"+e+"Z":"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"Z":e?"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L"+e*h+","+e*p+"A"+e+","+e+" 0 "+f+",0 "+e*l+","+e*c+"Z":"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L0,0"+"Z"}var t=an,n=fn,r=ln,i=cn;return e.innerRadius=function(n){return arguments.length?(t=u(n),e):t},e.outerRadius=function(t){return arguments.length?(n=u(t),e):n},e.startAngle=function(t){return arguments.length?(r=u(t),e):r},e.endAngle=function(t){return arguments.length?(i=u(t),e):i},e.centroid=function(){var e=(t.apply(this,arguments)+n.apply(this,arguments))/2,s=(r.apply(this,arguments)+i.apply(this,arguments))/2+wo;return[Math.cos(s)*e,Math.sin(s)*e]},e};var wo=-bs/2,Eo=2*bs-1e-6;d3.svg.line=function(){return hn(i)};var So=d3.map({linear:vn,"linear-closed":mn,"step-before":gn,"step-after":yn,basis:Tn,"basis-open":Nn,"basis-closed":Cn,bundle:kn,cardinal:En,"cardinal-open":bn,"cardinal-closed":wn,monotone:Dn});So.forEach(function(e,t){t.key=e,t.closed=/-closed$/.test(e)});var xo=[0,2/3,1/3,0],To=[0,1/3,2/3,0],No=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var e=hn(Pn);return e.radius=e.x,delete e.x,e.angle=e.y,delete e.y,e},gn.reverse=yn,yn.reverse=gn,d3.svg.area=function(){return Hn(i)},d3.svg.area.radial=function(){var e=Hn(Pn);return e.radius=e.x,delete e.x,e.innerRadius=e.x0,delete e.x0,e.outerRadius=e.x1,delete e.x1,e.angle=e.y,delete e.y,e.startAngle=e.y0,delete e.y0,e.endAngle=e.y1,delete e.y1,e},d3.svg.chord=function(){function e(e,u){var a=t(this,s,e,u),f=t(this,o,e,u);return"M"+a.p0+r(a.r,a.p1,a.a1-a.a0)+(n(a,f)?i(a.r,a.p1,a.r,a.p0):i(a.r,a.p1,f.r,f.p0)+r(f.r,f.p1,f.a1-f.a0)+i(f.r,f.p1,a.r,a.p0))+"Z"}function t(e,t,n,r){var i=t.call(e,n,r),s=a.call(e,i,r),o=f.call(e,i,r)+wo,u=l.call(e,i,r)+wo;return{r:s,a0:o,a1:u,p0:[s*Math.cos(o),s*Math.sin(o)],p1:[s*Math.cos(u),s*Math.sin(u)]}}function n(e,t){return e.a0==t.a0&&e.a1==t.a1}function r(e,t,n){return"A"+e+","+e+" 0 "+ +(n>bs)+",1 "+t}function i(e,t,n,r){return"Q 0,0 "+r}var s=Bn,o=jn,a=Fn,f=ln,l=cn;return e.radius=function(t){return arguments.length?(a=u(t),e):a},e.source=function(t){return arguments.length?(s=u(t),e):s},e.target=function(t){return arguments.length?(o=u(t),e):o},e.startAngle=function(t){return arguments.length?(f=u(t),e):f},e.endAngle=function(t){return arguments.length?(l=u(t),e):l},e},d3.svg.diagonal=function(){function e(e,i){var s=t.call(this,e,i),o=n.call(this,e,i),u=(s.y+o.y)/2,a=[s,{x:s.x,y:u},{x:o.x,y:u},o];return a=a.map(r),"M"+a[0]+"C"+a[1]+" "+a[2]+" "+a[3]}var t=Bn,n=jn,r=Rn;return e.source=function(n){return arguments.length?(t=u(n),e):t},e.target=function(t){return arguments.length?(n=u(t),e):n},e.projection=function(t){return arguments.length?(r=t,e):r},e},d3.svg.diagonal.radial=function(){var e=d3.svg.diagonal(),t=Rn,n=e.projection;return e.projection=function(e){return arguments.length?n(Un(t=e)):t},e},d3.svg.symbol=function(){function e(e,r){return(Co.get(t.call(this,e,r))||Xn)(n.call(this,e,r))}var t=Wn,n=zn;return e.type=function(n){return arguments.length?(t=u(n),e):t},e.size=function(t){return arguments.length?(n=u(t),e):n},e};var Co=d3.map({circle:Xn,cross:function(e){var t=Math.sqrt(e/5)/2;return"M"+ -3*t+","+ -t+"H"+ -t+"V"+ -3*t+"H"+t+"V"+ -t+"H"+3*t+"V"+t+"H"+t+"V"+3*t+"H"+ -t+"V"+t+"H"+ -3*t+"Z"},diamond:function(e){var t=Math.sqrt(e/(2*Lo)),n=t*Lo;return"M0,"+ -t+"L"+n+",0"+" 0,"+t+" "+ -n+",0"+"Z"},square:function(e){var t=Math.sqrt(e)/2;return"M"+ -t+","+ -t+"L"+t+","+ -t+" "+t+","+t+" "+ -t+","+t+"Z"},"triangle-down":function(e){var t=Math.sqrt(e/ko),n=t*ko/2;return"M0,"+n+"L"+t+","+ -n+" "+ -t+","+ -n+"Z"},"triangle-up":function(e){var t=Math.sqrt(e/ko),n=t*ko/2;return"M0,"+ -n+"L"+t+","+n+" "+ -t+","+n+"Z"}});d3.svg.symbolTypes=Co.keys();var ko=Math.sqrt(3),Lo=Math.tan(30*Es);d3.svg.axis=function(){function e(e){e.each(function(){var e=d3.select(this),c=a==null?t.ticks?t.ticks.apply(t,u):t.domain():a,h=f==null?t.tickFormat?t.tickFormat.apply(t,u):String:f,p=Jn(t,c,l),d=e.selectAll(".minor").data(p,String),v=d.enter().insert("line","g").attr("class","tick minor").style("opacity",1e-6),m=d3.transition(d.exit()).style("opacity",1e-6).remove(),g=d3.transition(d).style("opacity",1),y=e.selectAll("g").data(c,String),b=y.enter().insert("g","path").style("opacity",1e-6),w=d3.transition(y.exit()).style("opacity",1e-6).remove(),E=d3.transition(y).style("opacity",1),S,x=qt(t),T=e.selectAll(".domain").data([0]),N=T.enter().append("path").attr("class","domain"),C=d3.transition(T),k=t.copy(),L=this.__chart__||k;this.__chart__=k,b.append("line").attr("class","tick"),b.append("text");var A=b.select("line"),O=E.select("line"),M=y.select("text").text(h),_=b.select("text"),D=E.select("text");switch(n){case"bottom":S=Vn,v.attr("y2",i),g.attr("x2",0).attr("y2",i),A.attr("y2",r),_.attr("y",Math.max(r,0)+o),O.attr("x2",0).attr("y2",r),D.attr("x",0).attr("y",Math.max(r,0)+o),M.attr("dy",".71em").style("text-anchor","middle"),C.attr("d","M"+x[0]+","+s+"V0H"+x[1]+"V"+s);break;case"top":S=Vn,v.attr("y2",-i),g.attr("x2",0).attr("y2",-i),A.attr("y2",-r),_.attr("y",-(Math.max(r,0)+o)),O.attr("x2",0).attr("y2",-r),D.attr("x",0).attr("y",-(Math.max(r,0)+o)),M.attr("dy","0em").style("text-anchor","middle"),C.attr("d","M"+x[0]+","+ -s+"V0H"+x[1]+"V"+ -s);break;case"left":S=$n,v.attr("x2",-i),g.attr("x2",-i).attr("y2",0),A.attr("x2",-r),_.attr("x",-(Math.max(r,0)+o)),O.attr("x2",-r).attr("y2",0),D.attr("x",-(Math.max(r,0)+o)).attr("y",0),M.attr("dy",".32em").style("text-anchor","end"),C.attr("d","M"+ -s+","+x[0]+"H0V"+x[1]+"H"+ -s);break;case"right":S=$n,v.attr("x2",i),g.attr("x2",i).attr("y2",0),A.attr("x2",r),_.attr("x",Math.max(r,0)+o),O.attr("x2",r).attr("y2",0),D.attr("x",Math.max(r,0)+o).attr("y",0),M.attr("dy",".32em").style("text-anchor","start"),C.attr("d","M"+s+","+x[0]+"H0V"+x[1]+"H"+s)}if(t.ticks)b.call(S,L),E.call(S,k),w.call(S,k),v.call(S,L),g.call(S,k),m.call(S,k);else{var P=k.rangeBand()/2,H=function(e){return k(e)+P};b.call(S,H),E.call(S,H)}})}var t=d3.scale.linear(),n="bottom",r=6,i=6,s=6,o=3,u=[10],a=null,f,l=0;return e.scale=function(n){return arguments.length?(t=n,e):t},e.orient=function(t){return arguments.length?(n=t,e):n},e.ticks=function(){return arguments.length?(u=arguments,e):u},e.tickValues=function(t){return arguments.length?(a=t,e):a},e.tickFormat=function(t){return arguments.length?(f=t,e):f},e.tickSize=function(t,n,o){if(!arguments.length)return r;var u=arguments.length-1;return r=+t,i=u>1?+n:r,s=u>0?+arguments[u]:r,e},e.tickPadding=function(t){return arguments.length?(o=+t,e):o},e.tickSubdivide=function(t){return arguments.length?(l=+t,e):l},e},d3.svg.brush=function(){function e(s){s.each(function(){var s=d3.select(this),f=s.selectAll(".background").data([0]),l=s.selectAll(".extent").data([0]),c=s.selectAll(".resize").data(a,String),h;s.style("pointer-events","all").on("mousedown.brush",i).on("touchstart.brush",i),f.enter().append("rect").attr("class","background").style("visibility","hidden").style("cursor","crosshair"),l.enter().append("rect").attr("class","extent").style("cursor","move"),c.enter().append("g").attr("class",function(e){return"resize "+e}).style("cursor",function(e){return Ao[e]}).append("rect").attr("x",function(e){return/[ew]$/.test(e)?-3:null}).attr("y",function(e){return/^[ns]/.test(e)?-3:null}).attr("width",6).attr("height",6).style("visibility","hidden"),c.style("display",e.empty()?"none":null),c.exit().remove(),o&&(h=qt(o),f.attr("x",h[0]).attr("width",h[1]-h[0]),n(s)),u&&(h=qt(u),f.attr("y",h[0]).attr("height",h[1]-h[0]),r(s)),t(s)})}function t(e){e.selectAll(".resize").attr("transform",function(e){return"translate("+f[+/e$/.test(e)][0]+","+f[+/^s/.test(e)][1]+")"})}function n(e){e.select(".extent").attr("x",f[0][0]),e.selectAll(".extent,.n>rect,.s>rect").attr("width",f[1][0]-f[0][0])}function r(e){e.select(".extent").attr("y",f[0][1]),e.selectAll(".extent,.e>rect,.w>rect").attr("height",f[1][1]-f[0][1])}function i(){function i(){var e=d3.event.changedTouches;return e?d3.touches(v,e)[0]:d3.mouse(v)}function a(){d3.event.keyCode==32&&(S||(T=null,N[0]-=f[1][0],N[1]-=f[1][1],S=2),j())}function c(){d3.event.keyCode==32&&S==2&&(N[0]+=f[1][0],N[1]+=f[1][1],S=0,j())}function h(){var e=i(),s=!1;C&&(e[0]+=C[0],e[1]+=C[1]),S||(d3.event.altKey?(T||(T=[(f[0][0]+f[1][0])/2,(f[0][1]+f[1][1])/2]),N[0]=f[+(e[0]0?a=e:a=0:e>0&&(r.start({type:"start",alpha:a=e}),d3.timer(n.tick)),n):a},n.start=function(){function e(e,n){var i=t(r),s=-1,o=i.length,u;while(++si&&(i=u),r.push(u)}for(o=0;o0){s=-1;while(++s=a[0]&&d<=a[1]&&(l=o[d3.bisect(f,d,1,h)-1],l.y+=p,l.push(e[s]))}return o}var t=!0,n=Number,r=mr,i=dr;return e.value=function(t){return arguments.length?(n=t,e):n},e.range=function(t){return arguments.length?(r=u(t),e):r},e.bins=function(t){return arguments.length?(i=typeof t=="number"?function(e){return vr(e,t)}:u(t),e):i},e.frequency=function(n){return arguments.length?(t=!!n,e):t},e},d3.layout.hierarchy=function(){function e(t,o,u){var a=i.call(n,t,o),f=Bo?t:{data:t};f.depth=o,u.push(f);if(a&&(c=a.length)){var l=-1,c,h=f.children=[],p=0,d=o+1,v;while(++l0){var l=n*f/2;Ur(o,function(e){e.r+=l}),Ur(o,Cr),Ur(o,function(e){e.r-=l}),f=Math.max(2*o.r/u,2*o.r/a)}return Ar(o,u/2,a/2,1/f),s}var t=d3.layout.hierarchy().sort(Sr),n=0,r=[1,1];return e.size=function(t){return arguments.length?(r=t,e):r},e.padding=function(t){return arguments.length?(n=+t,e):n},gr(e,t)},d3.layout.cluster=function(){function e(e,i){var s=t.call(this,e,i),o=s[0],u,a=0,f,l;Ur(o,function(e){var t=e.children;t&&t.length?(e.x=_r(t),e.y=Mr(t)):(e.x=u?a+=n(e,u):0,e.y=0,u=e)});var c=Dr(o),h=Pr(o),p=c.x-n(c,h)/2,d=h.x+n(h,c)/2;return Ur(o,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=(1-(o.y?e.y/o.y:1))*r[1]}),s}var t=d3.layout.hierarchy().sort(null).value(null),n=Hr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},gr(e,t)},d3.layout.tree=function(){function e(e,i){function s(e,t){var r=e.children,i=e._tree;if(r&&(o=r.length)){var o,a=r[0],f,l=a,c,h=-1;while(++h0&&(Wr(Xr(o,e,r),e,h),a+=h,f+=h),l+=o._tree.mod,a+=i._tree.mod,c+=u._tree.mod,f+=s._tree.mod;o&&!jr(s)&&(s._tree.thread=o,s._tree.mod+=l-f),i&&!Br(u)&&(u._tree.thread=i,u._tree.mod+=a-c,r=e)}return r}var a=t.call(this,e,i),f=a[0];Ur(f,function(e,t){e._tree={ancestor:e,prelim:0,mod:0,change:0,shift:0,number:t?t._tree.number+1:0}}),s(f),o(f,-f._tree.prelim);var l=Fr(f,qr),c=Fr(f,Ir),h=Fr(f,Rr),p=l.x-n(l,c)/2,d=c.x+n(c,l)/2,v=h.depth||1;return Ur(f,function(e){e.x=(e.x-p)/(d-p)*r[0],e.y=e.depth/v*r[1],delete e._tree}),a}var t=d3.layout.hierarchy().sort(null).value(null),n=Hr,r=[1,1];return e.separation=function(t){return arguments.length?(n=t,e):n},e.size=function(t){return arguments.length?(r=t,e):r},gr(e,t)},d3.layout.treemap=function(){function e(e,t){var n=-1,r=e.length,i,s;while(++n0)u.push(f=a[d-1]),u.area+=f.area,(h=r(u,p))<=c?(a.pop(),c=h):(u.area-=u.pop().area,i(u,p,o,!1),p=Math.min(o.dx,o.dy),u.length=u.area=0,c=Infinity);u.length&&(i(u,p,o,!0),u.length=u.area=0),s.forEach(t)}}function n(t){var r=t.children;if(r&&r.length){var s=l(t),o=r.slice(),u,a=[];e(o,s.dx*s.dy/t.value),a.area=0;while(u=o.pop())a.push(u),a.area+=u.area,u.z!=null&&(i(a,u.z?s.dx:s.dy,s,!o.length),a.length=a.area=0);r.forEach(n)}}function r(e,t){var n=e.area,r,i=0,s=Infinity,o=-1,u=e.length;while(++oi&&(i=r)}return n*=n,t*=t,n?Math.max(t*i*p/n,n/(t*s*p)):Infinity}function i(e,t,n,r){var i=-1,s=e.length,o=n.x,a=n.y,f=t?u(e.area/t):0,l;if(t==n.dx){if(r||f>n.dy)f=n.dy;while(++in.dx)f=n.dx;while(++i50?r:t<-140?i:o<21?s:n}var n=d3.geo.albers(),r=d3.geo.albers().rotate([160,0]).center([0,60]).parallels([55,65]),i=d3.geo.albers().rotate([160,0]).center([0,20]).parallels([8,18]),s=d3.geo.albers().rotate([60,0]).center([0,10]).parallels([8,18]);return e.point=function(e,n){return t(e).point(e,n)},e.line=function(e,n){return t(e[0]).line(e,n)},e.polygon=function(e,n){return t(e[0][0]).polygon(e,n)},e.scale=function(t){return arguments.length?(n.scale(t),r.scale(t*.6),i.scale(t),s.scale(t*1.5),e.translate(n.translate())):n.scale()},e.translate=function(t){if(!arguments.length)return n.translate();var o=n.scale(),u=t[0],a=t[1];return n.translate(t),r.translate([u-.4*o,a+.17*o]),i.translate([u-.19*o,a+.2*o]),s.translate([u+.58*o,a+.43*o]),e},e.scale(n.scale())},(d3.geo.albers=function(){var e=29.5*Es,t=45.5*Es,n=wi(Qr),r=n(e,t);return r.parallels=function(r){return arguments.length?n(e=r[0]*Es,t=r[1]*Es):[e*Ss,t*Ss]},r.rotate([98,0]).center([0,38]).scale(1e3)}).raw=Qr;var qo=Ai(function(e){return Math.sqrt(2/(1+e))},function(e){return 2*Math.asin(e/2)});(d3.geo.azimuthalEqualArea=function(){return bi(qo)}).raw=qo;var Ro=Ai(function(e){var t=Math.acos(e);return t&&t/Math.sin(t)},i);(d3.geo.azimuthalEquidistant=function(){return bi(Ro)}).raw=Ro,d3.geo.bounds=function(e){return Xo=Wo=-(Uo=zo=Infinity),Vo.object(e),[[Uo,zo],[Wo,Xo]]};var Uo,zo,Wo,Xo,Vo=Kr({point:function(e){var t=e[0],n=e[1];tWo&&(Wo=t),nXo&&(Xo=n)},polygon:function(e){this.line(e[0])}});d3.geo.circle=function(){function e(){}function t(e){var t=null;return{moveTo:function(n,r){var i=u.invert(n,r);i[0]*=Ss,i[1]*=Ss,e.push(t=[i])},lineTo:function(e,n){var r=u.invert(e,n);r[0]*=Ss,r[1]*=Ss,t.push(r)},closePath:function(){t.length&&t.push(t[0])}}}var n=[0,0],r=90,s,o,u;e.clip=function(e){var t=typeof n=="function"?n.apply(this,arguments):n;return u=Ni(-t[0]*Es,-t[1]*Es,0),s=Gr(r,function(e){return u(e[0]*Es,e[1]*Es)}),a.object(e)||null};var a=Kr({FeatureCollection:function(e){var t=e.features.map(a.Feature,a).filter(i);return t&&(e=Object.create(e),e.features=t,e)},Feature:function(e){var t=a.geometry(e.geometry);return t&&(e=Object.create(e),e.geometry=t,e)},Point:function(e){var n=[];return s.point(e.coordinates,t(n)),n.length&&e},MultiPoint:function(e){var n=[],r=t(n);return e.coordinates.forEach(function(e){s.point(e,r)}),n.length&&(e=Object.create(e),e.coordinates=n.map(function(e){return e[0]}),e)},LineString:function(e){var n=[],r=t(n);return s.line(e.coordinates,r),n.length&&(e=Object.create(e),e.type="MultiLineString",e.coordinates=n,e)},MultiLineString:function(e){var n=[],r=t(n);return e.coordinates.forEach(function(e){s.line(e,r)}),n.length&&(e=Object.create(e),e.coordinates=n,e)},Polygon:function(e){var n=[];s.polygon(e.coordinates,t(n));var r=n.map(function(e){return[e]});return r.length&&(e=Object.create(e),e.type="MultiPolygon",e.coordinates=r,e)},MultiPolygon:function(e){var n=[],r=t(n);e.coordinates.forEach(function(e){s.polygon(e,r)});var i=n.map(function(e){return[e]});return i.length&&(e=Object.create(e),e.coordinates=i,e)},GeometryCollection:function(e){var t=e.geometries.map(a.geometry,a).filter(i);return t.length&&(e=Object.create(e),e.geometries=t,e)}});return e.origin=function(t){return arguments.length?(n=t,e):n},e.angle=function(t){return arguments.length?(r=+t,e):r},e.precision=function(t){return arguments.length?(o=+t,e):o},e},(d3.geo.equirectangular=function(){return bi(li).scale(250/bs)}).raw=li.invert=li;var $o=Ai(function(e){return 1/e},Math.atan);(d3.geo.gnomonic=function(){return bi($o)}).raw=$o,d3.geo.graticule=function(){function e(){return{type:"GeometryCollection",geometries:e.lines()}}var t,n,r,i,s=22.5,o=s,u,a;return e.lines=function(){return d3.range(Math.ceil(n/s)*s,t,s).map(u).concat(d3.range(Math.ceil(i/o)*o,r,o).map(a)).map(function(e){return{type:"LineString",coordinates:e}})},e.outline=function(){return{type:"Polygon",coordinates:[u(n).concat(a(r).slice(1),u(t).reverse().slice(1),a(i).reverse().slice(1))]}},e.extent=function(s){return arguments.length?(n=+s[0][0],t=+s[1][0],i=+s[0][1],r=+s[1][1],n>t&&(s=n,n=t,t=s),i>r&&(s=i,i=r,r=s),u=ci(i,r),a=hi(n,t),e):[[n,i],[t,r]]},e.step=function(t){return arguments.length?(s=+t[0],o=+t[1],e):[s,o]},e.extent([[-180+ws,-90+ws],[180-ws,90-ws]])};var Jo=3;d3.geo.greatArc=function(){function e(){var t=e.distance.apply(this,arguments),r=0,u=s/t,a=[n];while((r+=u)<1)a.push(o(r));return a.push(i),{type:"LineString",coordinates:a}}var t=pi,n,r=di,i,s=6*Es,o=vi();return e.distance=function(){return typeof t=="function"&&o.source(n=t.apply(this,arguments)),typeof r=="function"&&o.target(i=r.apply(this,arguments)),o.distance()},e.source=function(r){return arguments.length?(t=r,typeof t!="function"&&o.source(n=t),e):t},e.target=function(t){return arguments.length?(r=t,typeof r!="function"&&o.target(i=r),e):r},e.precision=function(t){return arguments.length?(s=t*Es,e):s/Es},e},gi.invert=function(e,t){return[2*bs*e,2*Math.atan(Math.exp(2*bs*t))-bs/2]},(d3.geo.mercator=function(){return bi(gi).scale(500)}).raw=gi;var Ko=Ai(function(){return 1},Math.asin);(d3.geo.orthographic=function(){return bi(Ko)}).raw=Ko,d3.geo.path=function(){function e(e){var t=null;return e!=t&&(typeof f=="function"&&(l=yi(f.apply(this,arguments))),v.object(e),h.length&&(t=h.join(""),h=[])),t}function t(e){return Math.abs(d3.geom.polygon(e.map(c)).area())}function n(e){return t(e[0])-d3.sum(e.slice(1),t)}function r(e){switch(e.type){case"Point":case"MultiPoint":return 0;case"LineString":case"MultiLineString":return 1;case"Polygon":case"MultiPolygon":return 2}}function i(e){return function(t){var n=e(t.coordinates);return n?[n[0]/n[2],n[1]/n[2]]:null}}function s(e){return function(t){var n=t.coordinates,r,i=0,s=0,o=0,u=-1,a=n.length;while(++u=l*l+c*c?r[s].index=-1:(r[h].index=-1,d=r[s].angle,h=s,p=o)):(d=r[s].angle,h=s,p=o);i.push(u);for(s=0,o=0;s<2;++o)r[o].index!==-1&&(i.push(r[o].index),s++);v=i.length;for(;o=0?(r=e.ep.r,i=e.ep.l):(r=e.ep.l,i=e.ep.r),e.a===1?(u=r?r.y:-n,s=e.c-e.b*u,a=i?i.y:n,o=e.c-e.b*a):(s=r?r.x:-n,u=e.c-e.a*s,o=i?i.x:n,a=e.c-e.a*o);var f=[s,u],l=[o,a];t[e.region.l.index].push(f,l),t[e.region.r.index].push(f,l)}),t=t.map(function(t,n){var r=e[n][0],i=e[n][1],s=t.map(function(e){return Math.atan2(e[0]-r,e[1]-i)});return d3.range(t.length).sort(function(e,t){return s[e]-s[t]}).filter(function(e,t,n){return!t||s[e]-s[n[t-1]]>ws}).map(function(e){return t[e]})}),t.forEach(function(t,r){var i=t.length;if(!i)return t.push([-n,-n],[-n,n],[n,n],[n,-n]);if(i>2)return;var s=e[r],o=t[0],u=t[1],a=s[0],f=s[1],l=o[0],c=o[1],h=u[0],p=u[1],d=h-l,v=p-c;if(Math.abs(v)=u,l=t.y>=a,c=(l<<1)+f;e.leaf=!1,e=e.nodes[c]||(e.nodes[c]=Pi()),f?n=u:i=u,l?r=a:o=a,s(e,t,n,r,i,o)}var u,a=-1,f=e.length;if(arguments.length<5)if(arguments.length===3)i=n,r=t,n=t=0;else{t=n=Infinity,r=i=-Infinity;while(++ar&&(r=u.x),u.y>i&&(i=u.y)}var l=r-t,c=i-n;l>c?i=n+l:r=t+c;var h=Pi();return h.add=function(e){s(h,e,t,n,r,i)},h.visit=function(e){Hi(e,h,t,n,r,i)},e.forEach(h.add),h},d3.time={};var Yo=Date,Zo=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];Bi.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(){eu.setUTCDate.apply(this._,arguments)},setDay:function(){eu.setUTCDay.apply(this._,arguments)},setFullYear:function(){eu.setUTCFullYear.apply(this._,arguments)},setHours:function(){eu.setUTCHours.apply(this._,arguments)},setMilliseconds:function(){eu.setUTCMilliseconds.apply(this._,arguments)},setMinutes:function(){eu.setUTCMinutes.apply(this._,arguments)},setMonth:function(){eu.setUTCMonth.apply(this._,arguments)},setSeconds:function(){eu.setUTCSeconds.apply(this._,arguments)},setTime:function(){eu.setTime.apply(this._,arguments)}};var eu=Date.prototype,tu="%a %b %e %H:%M:%S %Y",nu="%m/%d/%y",ru="%H:%M:%S",iu=Zo,su=iu.map(ji),ou=["January","February","March","April","May","June","July","August","September","October","November","December"],uu=ou.map(ji);d3.time.format=function(e){function t(t){var r=[],i=-1,s=0,o,u;while(++i=12?"PM":"AM"},S:function(e){return au(e.getSeconds())},U:function(e){return au(d3.time.sundayOfYear(e))},w:function(e){return e.getDay()},W:function(e){return au(d3.time.mondayOfYear(e))},x:d3.time.format(nu),X:d3.time.format(ru),y:function(e){return au(e.getFullYear()%100)},Y:function(e){return lu(e.getFullYear()%1e4)},Z:is,"%":function(e){return"%"}},bu={a:Ri,A:Ui,b:zi,B:Wi,c:Xi,d:Yi,e:Yi,H:Zi,I:Zi,L:ns,m:Gi,M:es,p:rs,S:ts,x:Vi,X:$i,y:Ki,Y:Ji},wu=/^\s*\d+/,Eu=d3.map({am:0,pm:1});d3.time.format.utc=function(e){function t(e){try{Yo=Bi;var t=new Yo;return t._=e,n(t)}finally{Yo=Date}}var n=d3.time.format(e);return t.parse=function(e){try{Yo=Bi;var t=n.parse(e);return t&&t._}finally{Yo=Date}},t.toString=n.toString,t};var Su=d3.time.format.utc("%Y-%m-%dT%H:%M:%S.%LZ");d3.time.format.iso=Date.prototype.toISOString?ss:Su,ss.parse=function(e){var t=new Date(e);return isNaN(t)?null:t},ss.toString=Su.toString,d3.time.second=os(function(e){return new Yo(Math.floor(e/1e3)*1e3)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*1e3)},function(e){return e.getSeconds()}),d3.time.seconds=d3.time.second.range,d3.time.seconds.utc=d3.time.second.utc.range,d3.time.minute=os(function(e){return new Yo(Math.floor(e/6e4)*6e4)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*6e4)},function(e){return e.getMinutes()}),d3.time.minutes=d3.time.minute.range,d3.time.minutes.utc=d3.time.minute.utc.range,d3.time.hour=os(function(e){var t=e.getTimezoneOffset()/60;return new Yo((Math.floor(e/36e5-t)+t)*36e5)},function(e,t){e.setTime(e.getTime()+Math.floor(t)*36e5)},function(e){return e.getHours()}),d3.time.hours=d3.time.hour.range,d3.time.hours.utc=d3.time.hour.utc.range,d3.time.day=os(function(e){var t=new Yo(1970,0);return t.setFullYear(e.getFullYear(),e.getMonth(),e.getDate()),t},function(e,t){e.setDate(e.getDate()+t)},function(e){return e.getDate()-1}),d3.time.days=d3.time.day.range,d3.time.days.utc=d3.time.day.utc.range,d3.time.dayOfYear=function(e){var t=d3.time.year(e);return Math.floor((e-t-(e.getTimezoneOffset()-t.getTimezoneOffset())*6e4)/864e5)},Zo.forEach(function(e,t){e=e.toLowerCase(),t=7-t;var n=d3.time[e]=os(function(e){return(e=d3.time.day(e)).setDate(e.getDate()-(e.getDay()+t)%7),e},function(e,t){e.setDate(e.getDate()+Math.floor(t)*7)},function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%7)/7)-(n!==t)});d3.time[e+"s"]=n.range,d3.time[e+"s"].utc=n.utc.range,d3.time[e+"OfYear"]=function(e){var n=d3.time.year(e).getDay();return Math.floor((d3.time.dayOfYear(e)+(n+t)%7)/7)}}),d3.time.week=d3.time.sunday,d3.time.weeks=d3.time.sunday.range,d3.time.weeks.utc=d3.time.sunday.utc.range,d3.time.weekOfYear=d3.time.sundayOfYear,d3.time.month=os(function(e){return e=d3.time.day(e),e.setDate(1),e},function(e,t){e.setMonth(e.getMonth()+t)},function(e){return e.getMonth()}),d3.time.months=d3.time.month.range,d3.time.months.utc=d3.time.month.utc.range,d3.time.year=os(function(e){return e=d3.time.day(e),e.setMonth(0,1),e},function(e,t){e.setFullYear(e.getFullYear()+t)},function(e){return e.getFullYear()}),d3.time.years=d3.time.year.range,d3.time.years.utc=d3.time.year.utc.range;var xu=[1e3,5e3,15e3,3e4,6e4,3e5,9e5,18e5,36e5,108e5,216e5,432e5,864e5,1728e5,6048e5,2592e6,7776e6,31536e6],Tu=[[d3.time.second,1],[d3.time.second,5],[d3.time.second,15],[d3.time.second,30],[d3.time.minute,1],[d3.time.minute,5],[d3.time.minute,15],[d3.time.minute,30],[d3.time.hour,1],[d3.time.hour,3],[d3.time.hour,6],[d3.time.hour,12],[d3.time.day,1],[d3.time.day,2],[d3.time.week,1],[d3.time.month,1],[d3.time.month,3],[d3.time.year,1]],Nu=[[d3.time.format("%Y"),function(e){return!0}],[d3.time.format("%B"),function(e){return e.getMonth()}],[d3.time.format("%b %d"),function(e){return e.getDate()!=1}],[d3.time.format("%a %d"),function(e){return e.getDay()&&e.getDate()!=1}],[d3.time.format("%I %p"),function(e){return e.getHours()}],[d3.time.format("%I:%M"),function(e){return e.getMinutes()}],[d3.time.format(":%S"),function(e){return e.getSeconds()}],[d3.time.format(".%L"),function(e){return e.getMilliseconds()}]],Cu=d3.scale.linear(),ku=cs(Nu);Tu.year=function(e,t){return Cu.domain(e.map(ps)).ticks(t).map(hs)},d3.time.scale=function(){return as(d3.scale.linear(),Tu,ku)};var Lu=Tu.map(function(e){return[e[0].utc,e[1]]}),Au=[[d3.time.format.utc("%Y"),function(e){return!0}],[d3.time.format.utc("%B"),function(e){return e.getUTCMonth()}],[d3.time.format.utc("%b %d"),function(e){return e.getUTCDate()!=1}],[d3.time.format.utc("%a %d"),function(e){return e.getUTCDay()&&e.getUTCDate()!=1}],[d3.time.format.utc("%I %p"),function(e){return e.getUTCHours()}],[d3.time.format.utc("%I:%M"),function(e){return e.getUTCMinutes()}],[d3.time.format.utc(":%S"),function(e){return e.getUTCSeconds()}],[d3.time.format.utc(".%L"),function(e){return e.getUTCMilliseconds()}]],Ou=cs(Au);Lu.year=function(e,t){return Cu.domain(e.map(vs)).ticks(t).map(ds)},d3.time.scale.utc=function(){return as(d3.scale.linear(),Lu,Ou)}})(); \ No newline at end of file diff --git a/src/core/selection-style.js b/src/core/selection-style.js index 13223ed1..88b8dc15 100644 --- a/src/core/selection-style.js +++ b/src/core/selection-style.js @@ -13,9 +13,7 @@ d3_selectionPrototype.style = function(name, value, priority) { } // For style(string), return the computed style value for the first node. - if (n < 2) return window - .getComputedStyle(this.node(), null) - .getPropertyValue(name); + if (n < 2) return getComputedStyle(this.node(), null).getPropertyValue(name); // For style(string, string) or style(string, function), use the default // priority. The priority is ignored for style(string, null). diff --git a/src/core/transition-attr.js b/src/core/transition-attr.js index 78dad88b..5f063cc0 100644 --- a/src/core/transition-attr.js +++ b/src/core/transition-attr.js @@ -4,11 +4,14 @@ d3_transitionPrototype.attr = function(name, value) { // For attr(object), the object specifies the names and values of the // attributes to transition. The values may be functions that are // evaluated for each element. - for (value in name) this.attrTween(value, d3_tweenByName(name[value], value)); + for (value in name) this.attr(value, name[value]); return this; } - return this.attrTween(name, d3_tweenByName(value, name)); + var id = this.id; + return d3_selection_each(this, typeof value === "function" + ? function(node, i, j) { node.__transition__[id].tween.set("attr." + name, d3_transition_attr(name, value.call(node, node.__data__, i, j))); } + : (value = d3_transition_attr(name, value), function(node) { node.__transition__[id].tween.set("attr." + name, value); })); }; d3_transitionPrototype.attrTween = function(nameNS, tween) { @@ -16,17 +19,41 @@ d3_transitionPrototype.attrTween = function(nameNS, tween) { function attrTween(d, i) { var f = tween.call(this, d, i, this.getAttribute(name)); - return f === d3_tweenRemove - ? (this.removeAttribute(name), null) - : f && function(t) { this.setAttribute(name, f(t)); }; + return f && function(t) { this.setAttribute(name, f(t)); }; } function attrTweenNS(d, i) { var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local)); - return f === d3_tweenRemove - ? (this.removeAttributeNS(name.space, name.local), null) - : f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); }; + return f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); }; } return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween); }; + +function d3_transition_attr(name, b) { + var interpolate; + + name = d3.ns.qualify(name); + + // For attr(string, null), remove the attribute with the specified name. + function attrNull() { + this.removeAttribute(name); + } + function attrNullNS() { + this.removeAttributeNS(name.space, name.local); + } + + // For attr(string, string), set the attribute with the specified name. + function attrString() { + var a = this.getAttribute(name), i; + return a !== b && (i = interpolate(a, b), function(t) { this.setAttribute(name, i(t)); }); + } + function attrStringNS() { + var a = this.getAttributeNS(name.space, name.local), i; + return a !== b && (i = interpolate(a, b), function(t) { this.setAttributeNS(name.space, name.local, i(t)); }); + } + + return b == null + ? (name.local ? attrNullNS : attrNull) + : (b += "", interpolate = d3_interpolateByName(name), name.local ? attrStringNS : attrString); +} diff --git a/src/core/transition-style.js b/src/core/transition-style.js index ef54c222..b7fd61c5 100644 --- a/src/core/transition-style.js +++ b/src/core/transition-style.js @@ -8,7 +8,7 @@ d3_transitionPrototype.style = function(name, value, priority) { // specifies the priority. if (typeof name !== "string") { if (n < 2) value = ""; - for (priority in name) this.styleTween(priority, d3_tweenByName(name[priority], priority), value); + for (priority in name) this.style(priority, name[priority], value); return this; } @@ -18,15 +18,35 @@ d3_transitionPrototype.style = function(name, value, priority) { } // Otherwise, a name, value and priority are specified, and handled as below. - return this.styleTween(name, d3_tweenByName(value, name), priority); + var id = this.id; + return d3_selection_each(this, typeof value === "function" + ? function(node, i, j) { node.__transition__[id].tween.set("style." + name, d3_transition_style(name, value.call(node, node.__data__, i, j), priority)); } + : (value = d3_transition_style(name, value, priority), function(node) { node.__transition__[id].tween.set("style." + name, value); })); }; d3_transitionPrototype.styleTween = function(name, tween, priority) { if (arguments.length < 3) priority = ""; return this.tween("style." + name, function(d, i) { - var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name)); - return f === d3_tweenRemove - ? (this.style.removeProperty(name), null) - : f && function(t) { this.style.setProperty(name, f(t), priority); }; + var f = tween.call(this, d, i, getComputedStyle(this, null).getPropertyValue(name)); + return f && function(t) { this.style.setProperty(name, f(t), priority); }; }); }; + +function d3_transition_style(name, b, priority) { + var interpolate; + + // For style(name, null) or style(name, null, priority), remove the style + // property with the specified name. The priority is ignored. + function styleNull() { + this.style.removeProperty(name); + } + + // For style(name, string) or style(name, string, priority), set the style + // property with the specified name, using the specified priority. + function styleString() { + var a = getComputedStyle(this, null).getPropertyValue(name), i; + return a !== b && (i = interpolate(a, b), function(t) { this.style.setProperty(name, i(t), priority); }); + } + + return b == null ? styleNull : (b += "", interpolate = d3_interpolateByName(name), styleString); +} diff --git a/src/core/transition-text.js b/src/core/transition-text.js index 365dc34b..5b2a906d 100644 --- a/src/core/transition-text.js +++ b/src/core/transition-text.js @@ -1,7 +1,11 @@ d3_transitionPrototype.text = function(value) { - return this.tween("text", function(d, i) { - this.textContent = typeof value === "function" - ? value.call(this, d, i) - : value; - }); + var id = this.id; + return d3_selection_each(this, typeof value === "function" + ? function(node, i, j) { node.__transition__[id].tween.set("text", d3_transition_text(value.call(node, node.__data__, i, j))); } + : (value = d3_transition_text(value), function(node) { node.__transition__[id].tween.set("text", value); })); }; + +function d3_transition_text(value) { + if (value == null) value = ""; + return function() { this.textContent = value; }; +} diff --git a/src/core/tween.js b/src/core/tween.js deleted file mode 100644 index 6a36f181..00000000 --- a/src/core/tween.js +++ /dev/null @@ -1,27 +0,0 @@ -d3.tween = function(b, interpolate) { - - function tweenFunction(d, i, a) { - var v = b.call(this, d, i); - return v == null - ? a != "" && d3_tweenRemove - : a != v && interpolate(a, v + ""); - } - - function tweenString(d, i, a) { - return a != b && interpolate(a, b); - } - - return typeof b === "function" ? tweenFunction - : b == null ? d3_tweenNull - : (b += "", tweenString); -}; - -var d3_tweenRemove = {}; - -function d3_tweenNull(d, i, a) { - return a != "" && d3_tweenRemove; -} - -function d3_tweenByName(b, name) { - return d3.tween(b, d3_interpolateByName(name)); -} diff --git a/test/core/tween-test.js b/test/core/tween-test.js deleted file mode 100644 index 8a3e1678..00000000 --- a/test/core/tween-test.js +++ /dev/null @@ -1,27 +0,0 @@ -require("../env"); - -var vows = require("vows"), - assert = require("assert"); - -var suite = vows.describe("d3.tween"); - -suite.addBatch({ - "tween": { - "coerces constants to strings before interpolating": function() { - var t = d3.tween({toString: function() { return "#fff"; }}, d3.interpolate), - i = t(null, 0, "red"); - assert.strictEqual(i(0), "#ff0000"); - assert.strictEqual(i(.5), "#ff8080"); - assert.strictEqual(i(1), "#ffffff"); - }, - "coerces function return values to strings before interpolating": function() { - var t = d3.tween(function(d) { return {toString: function() { return d; }}; }, d3.interpolate), - i = t("#fff", 0, "red"); - assert.strictEqual(i(0), "#ff0000"); - assert.strictEqual(i(.5), "#ff8080"); - assert.strictEqual(i(1), "#ffffff"); - } - } -}); - -suite.export(module); diff --git a/test/env.js b/test/env.js index 7336f98d..2125cf00 100644 --- a/test/env.js +++ b/test/env.js @@ -5,6 +5,7 @@ CSSStyleDeclaration = window.CSSStyleDeclaration; require("../lib/sizzle/sizzle"); Sizzle = window.Sizzle; +getComputedStyle = window.getComputedStyle; process.env.TZ = "America/Los_Angeles";