d3-jsnext
Version:
d3, but futuristic
1 lines • 20.7 kB
JavaScript
!function(){"use strict";function t(t){for(var n=1;t*n%1;)n*=10;return n}function n(t){return"function"==typeof t?t:function(){return t}}function e(t,n,e){return(t.x-e.x)*(n.y-t.y)-(t.x-n.x)*(e.y-t.y)}function r(t,n){return n.angle-t.angle}function i(t){this.site=t,this.edges=[]}function u(t){t.U=t.C=t.L=t.R=t.P=t.N=null}function o(){u(this),this.x=this.y=this.arc=this.site=this.cy=null}function a(t){var n=t.P,e=t.N;if(n&&e){var r=n.site,i=t.site,u=e.site;if(r!==u){var a=i.x,s=i.y,f=r.x-a,l=r.y-s,c=u.x-a,h=u.y-s,p=2*(f*h-l*c);if(!(p>=-zt)){var v=f*f+l*l,g=c*c+h*h,y=(h*v-l*g)/p,d=(f*g-c*v)/p,h=d+s,_=Et.pop()||new o;_.arc=t,_.site=i,_.x=y+a,_.y=h+Math.sqrt(y*y+d*d),_.cy=h,t.circle=_;for(var m=null,x=Ut._;x;)if(_.y<x.y||_.y===x.y&&_.x<=x.x){if(!x.L){m=x.P;break}x=x.L}else{if(!x.R){m=x;break}x=x.R}Ut.insert(m,_),m||(Pt=_)}}}}function s(t){var n=t.circle;n&&(n.P||(Pt=n.N),Ut.remove(n),Et.push(n),u(n),t.circle=null)}function f(t,n){this.l=t,this.r=n,this.a=this.b=null}function l(t,n,e){var r=new f(t,null);return r.a=n,r.b=e,Nt.push(r),r}function c(t,n,e){var r=t.a,i=t.b;this.edge=t,this.site=n,this.angle=e?Math.atan2(e.y-n.y,e.x-n.x):t.l===n?Math.atan2(i.x-r.x,r.y-i.y):Math.atan2(r.x-i.x,i.y-r.y)}function h(t){for(var n,e,r,i,u,o,a,s,f,h,p=t[0][0],v=t[1][0],g=t[0][1],y=t[1][1],d=Rt,_=d.length;_--;)if(u=d[_],u&&u.prepare())for(a=u.edges,s=a.length,o=0;s>o;)h=a[o].end(),r=h.x,i=h.y,f=a[++o%s].start(),n=f.x,e=f.y,(Ct(r-n)>Mt||Ct(i-e)>Mt)&&(a.splice(o,0,new c(l(u.site,h,Ct(r-p)<Mt&&y-i>Mt?{x:p,y:Ct(n-p)<Mt?e:y}:Ct(i-y)<Mt&&v-r>Mt?{x:Ct(e-y)<Mt?n:v,y:y}:Ct(r-v)<Mt&&i-g>Mt?{x:v,y:Ct(n-v)<Mt?e:g}:Ct(i-g)<Mt&&r-p>Mt?{x:Ct(e-g)<Mt?n:p,y:g}:null),u.site,null)),++s)}function p(t,n){var e=t.b;if(e)return!0;var r,i,u=t.a,o=n[0][0],a=n[1][0],s=n[0][1],f=n[1][1],l=t.l,c=t.r,h=l.x,p=l.y,v=c.x,g=c.y,y=(h+v)/2,d=(p+g)/2;if(g===p){if(o>y||y>=a)return;if(h>v){if(u){if(u.y>=f)return}else u={x:y,y:s};e={x:y,y:f}}else{if(u){if(u.y<s)return}else u={x:y,y:f};e={x:y,y:s}}}else if(r=(h-v)/(g-p),i=d-r*y,-1>r||r>1)if(h>v){if(u){if(u.y>=f)return}else u={x:(s-i)/r,y:s};e={x:(f-i)/r,y:f}}else{if(u){if(u.y<s)return}else u={x:(f-i)/r,y:f};e={x:(s-i)/r,y:s}}else if(g>p){if(u){if(u.x>=a)return}else u={x:o,y:r*o+i};e={x:a,y:r*a+i}}else{if(u){if(u.x<o)return}else u={x:a,y:r*a+i};e={x:o,y:r*o+i}}return t.a=u,t.b=e,!0}function v(t,n,e,r){return function(i){var u,o=i.a,a=i.b,s=o.x,f=o.y,l=a.x,c=a.y,h=0,p=1,v=l-s,g=c-f;if(u=t-s,v||!(u>0)){if(u/=v,0>v){if(h>u)return;p>u&&(p=u)}else if(v>0){if(u>p)return;u>h&&(h=u)}if(u=e-s,v||!(0>u)){if(u/=v,0>v){if(u>p)return;u>h&&(h=u)}else if(v>0){if(h>u)return;p>u&&(p=u)}if(u=n-f,g||!(u>0)){if(u/=g,0>g){if(h>u)return;p>u&&(p=u)}else if(g>0){if(u>p)return;u>h&&(h=u)}if(u=r-f,g||!(0>u)){if(u/=g,0>g){if(u>p)return;u>h&&(h=u)}else if(g>0){if(h>u)return;p>u&&(p=u)}return h>0&&(i.a={x:s+h*v,y:f+h*g}),1>p&&(i.b={x:s+p*v,y:f+p*g}),i}}}}}}function g(t){for(var n,e=Nt,r=v(t[0][0],t[0][1],t[1][0],t[1][1]),i=e.length;i--;)n=e[i],(!p(n,t)||!r(n)||Ct(n.a.x-n.b.x)<Mt&&Ct(n.a.y-n.b.y)<Mt)&&(n.a=n.b=null,e.splice(i,1))}function y(t,n,e,r){t.a||t.b?t.l===e?t.b=r:t.a=r:(t.a=r,t.l=n,t.r=e)}function d(t,n,e,r){var i=new f(t,n);return Nt.push(i),e&&y(i,t,n,e),r&&y(i,n,t,r),Rt[t.i].edges.push(new c(i,t,n)),Rt[n.i].edges.push(new c(i,n,t)),i}function _(t){s(t),At.remove(t),St.push(t),u(t)}function m(t){var n=t.circle,e=n.x,r=n.cy,i={x:e,y:r},u=t.P,o=t.N,f=[t];_(t);for(var l=u;l.circle&&Ct(e-l.circle.x)<Mt&&Ct(r-l.circle.cy)<Mt;)u=l.P,f.unshift(l),_(l),l=u;f.unshift(l),s(l);for(var c=o;c.circle&&Ct(e-c.circle.x)<Mt&&Ct(r-c.circle.cy)<Mt;)o=c.N,f.push(c),_(c),c=o;f.push(c),s(c);var h,p=f.length;for(h=1;p>h;++h)c=f[h],l=f[h-1],y(c.edge,l.site,c.site,i);l=f[0],c=f[p-1],c.edge=d(l.site,c.site,null,i),a(l),a(c)}function x(){u(this),this.edge=this.site=this.circle=null}function w(t){var n=St.pop()||new x;return n.site=t,n}function C(t,n){var e=t.site,r=e.x,i=e.y,u=i-n;if(!u)return r;var o=t.P;if(!o)return-(1/0);e=o.site;var a=e.x,s=e.y,f=s-n;if(!f)return a;var l=a-r,c=1/u-1/f,h=l/f;return c?(-h+Math.sqrt(h*h-2*c*(l*l/(-2*f)-s+f/2+i-u/2)))/c+r:(r+a)/2}function L(t,n){var e=t.N;if(e)return C(e,n);var r=t.site;return r.y===n?r.x:1/0}function b(t){for(var n,e,r,i,u=t.x,o=t.y,f=At._;f;)if(r=C(f,o)-u,r>Mt)f=f.L;else{if(i=u-L(f,o),!(i>Mt)){r>-Mt?(n=f.P,e=f):i>-Mt?(n=f,e=f.N):n=e=f;break}if(!f.R){n=f;break}f=f.R}var l=w(t);if(At.insert(n,l),n||e){if(n===e)return s(n),e=w(n.site),At.insert(l,e),l.edge=e.edge=d(n.site,l.site),a(n),void a(e);if(!e)return void(l.edge=d(n.site,l.site));s(n),s(e);var c=n.site,h=c.x,p=c.y,v=t.x-h,g=t.y-p,_=e.site,m=_.x-h,x=_.y-p,b=2*(v*x-g*m),N=v*v+g*g,R=m*m+x*x,A={x:(x*N-g*R)/b+h,y:(v*R-m*N)/b+p};y(e.edge,c,_,A),l.edge=d(c,t,null,A),e.edge=d(t,_,null,A),a(n),a(e)}}function N(){this._=null}function R(t,n){var e=n,r=n.L,i=e.U;i?i.L===e?i.L=r:i.R=r:t._=r,r.U=i,e.U=r,e.L=r.R,e.L&&(e.L.U=e),r.R=e}function A(t,n){var e=n,r=n.R,i=e.U;i?i.L===e?i.L=r:i.R=r:t._=r,r.U=i,e.U=r,e.R=r.L,e.R&&(e.R.U=e),r.L=e}function P(t){for(;t.L;)t=t.L;return t}function U(t,n){return n.y-t.y||n.x-t.x}function S(t,n){var e,r,u,o=t.sort(U).pop();for(Nt=[],Rt=new Array(t.length),At=new N,Ut=new N;;)if(u=Pt,o&&(!u||o.y<u.y||o.y===u.y&&o.x<u.x))(o.x!==e||o.y!==r)&&(Rt[o.i]=new i(o),b(o),e=o.x,r=o.y),o=t.pop();else{if(!u)break;m(u.arc)}n&&(g(n),h(n));var a={cells:Rt,edges:Nt};return At=Ut=Nt=Rt=null,a}function E(t){return t[1]}function M(t){return t[0]}function z(){for(var t,n=window.d3_event;t=n.sourceEvent;)n=t;return n}function k(t,n){if(n in t)return n;n=n.charAt(0).toUpperCase()+n.slice(1);for(var e=0,r=Vt.length;r>e;++e){var i=Vt[e]+n;if(i in t)return i}}function T(t){return"function"==typeof t?t:function(){return Xt(t,this)}}function q(t){return"function"==typeof t?t:function(){return Ht(t,this)}}function $(t,n){function e(){this.removeAttribute(t)}function r(){this.removeAttributeNS(t.space,t.local)}function i(){this.setAttribute(t,n)}function u(){this.setAttributeNS(t.space,t.local,n)}function o(){var e=n.apply(this,arguments);null==e?this.removeAttribute(t):this.setAttribute(t,e)}function a(){var e=n.apply(this,arguments);null==e?this.removeAttributeNS(t.space,t.local):this.setAttributeNS(t.space,t.local,e)}return t=Gt.qualify(t),null==n?t.local?r:e:"function"==typeof n?t.local?a:o:t.local?u:i}function D(t){return t.trim().replace(/\s+/g," ")}function O(t){return new RegExp("(?:^|\\s+)"+Kt(t)+"(?:\\s+|$)","g")}function V(t){var n=O(t);return function(e,r){if(i=e.classList)return r?i.add(t):i.remove(t);var i=e.getAttribute("class")||"";r?(n.lastIndex=0,n.test(i)||e.setAttribute("class",D(i+" "+t))):e.setAttribute("class",D(i.replace(n," ")))}}function X(t){return(t+"").trim().split(/^|\s+/)}function H(t,n){function e(){for(var e=-1;++e<i;)t[e](this,n)}function r(){for(var e=-1,r=n.apply(this,arguments);++e<i;)t[e](this,r)}t=X(t).map(V);var i=t.length;return"function"==typeof n?r:e}function Y(t,n,e){function r(){this.style.removeProperty(t)}function i(){this.style.setProperty(t,n,e)}function u(){var r=n.apply(this,arguments);null==r?this.style.removeProperty(t):this.style.setProperty(t,r,e)}return null==n?r:"function"==typeof n?u:i}function j(t){return t&&(t.ownerDocument&&t.ownerDocument.defaultView||t.document&&t||t.defaultView)}function B(t,n){function e(){delete this[t]}function r(){this[t]=n}function i(){var e=n.apply(this,arguments);null==e?delete this[t]:this[t]=e}return null==n?e:"function"==typeof n?i:r}function G(t){function n(){var n=this.ownerDocument,e=this.namespaceURI;return e?n.createElementNS(e,t):n.createElement(t)}function e(){return this.ownerDocument.createElementNS(t.space,t.local)}return"function"==typeof t?t:(t=Gt.qualify(t)).local?e:n}function I(){var t=this.parentNode;t&&t.removeChild(this)}function K(t){var n,e;return function(r,i,u){var o,a=t[u].update,s=a.length;for(u!=e&&(e=u,n=0),i>=n&&(n=i+1);!(o=a[n])&&++n<s;);return o}}function W(t){return Ft(t,Zt),t}function Z(t){return{__data__:t}}function F(){this._=Object.create(null)}function J(t){return(t+="")[0]===Qt?t.slice(1):t}function Q(){for(var t in this._)return!1;return!0}function tt(){var t=0;for(var n in this._)++t;return t}function nt(){var t=[];for(var n in this._)t.push(J(n));return t}function et(t){return(t+="")===Jt||t[0]===Qt?Qt+t:t}function rt(t){return(t=et(t))in this._&&delete this._[t]}function it(t){return et(t)in this._}function ut(t,n){for(var e in n)Object.defineProperty(t.prototype,e,{value:n[e],enumerable:!1})}function ot(t){return function(){return Yt(this,t)}}function at(t,n){return n>t?-1:t>n?1:t>=n?0:0/0}function st(t){return arguments.length||(t=at),function(n,e){return n&&e?t(n.__data__,e.__data__):!n-!e}}function ft(){}function lt(t,n){return function(e){var r=window.d3_event;window.d3_event=e,n[0]=this.__data__;try{t.apply(this,n)}finally{window.d3_event=r}}}function ct(t,n){var e=lt(t,n);return function(t){var n=this,r=t.relatedTarget;r&&(r===n||8&r.compareDocumentPosition(n))||e.call(n,t)}}function ht(t,n,e){function r(){var n=this[o];n&&(this.removeEventListener(t,n,n.$),delete this[o])}function i(){var i=s(n,Bt(arguments));r.call(this),this.addEventListener(t,this[o]=i,i.$=e),i._=n}function u(){var n,e=new RegExp("^__on([^.]+)"+Kt(t)+"$");for(var r in this)if(n=r.match(e)){var i=this[r];this.removeEventListener(n[1],i,i.$),delete this[r]}}var o="__on"+t,a=t.indexOf("."),s=lt;a>0&&(t=t.slice(0,a));var f=nn.get(t);return f&&(t=f,s=ct),a?n?i:r:n?ft:u}function pt(t,n){for(var e=0,r=t.length;r>e;e++)for(var i,u=t[e],o=0,a=u.length;a>o;o++)(i=u[o])&&n(i,o,e);return t}function vt(t){return Ft(t,Ot),t}function gt(t){return t&&(t.ownerDocument||t.document||t).documentElement}function yt(t,n){n.changedTouches&&(n=n.changedTouches[0]);var e=t.ownerSVGElement||t;if(e.createSVGPoint){var r=e.createSVGPoint();if(0>$t){var i=j(t);if(i.scrollX||i.scrollY){e=Tt("body").append("svg").style({position:"absolute",top:0,left:0,margin:0,padding:0,border:"none"},"important");var u=e[0][0].getScreenCTM();$t=!(u.f||u.e),e.remove()}}return $t?(r.x=n.pageX,r.y=n.pageY):(r.x=n.clientX,r.y=n.clientY),r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}var o=t.getBoundingClientRect();return[n.clientX-o.left-t.clientLeft,n.clientY-o.top-t.clientTop]}function dt(){on=on.data(rn(en),_t),on.exit().remove(),on.enter().append("path").attr("class",function(t,n){return"q"+n%9+"-9"}).attr("d",_t),on.order()}function _t(t){return"M"+t.join("L")+"Z"}var mt,xt=960,wt=500,Ct=Math.abs;mt=function(n,e,r){if(arguments.length<3&&(r=1,arguments.length<2&&(e=n,n=0)),(e-n)/r===1/0)throw new Error("infinite range");var i,u=[],o=t(Ct(r)),a=-1;if(n*=o,e*=o,r*=o,0>r)for(;(i=n+r*++a)>e;)u.push(i/o);else for(;(i=n+r*++a)<e;)u.push(i/o);return u};var Lt,bt=[[-1e6,-1e6],[1e6,1e6]];i.prototype.prepare=function(){for(var t,n=this.edges,e=n.length;e--;)t=n[e].edge,t.b&&t.a||n.splice(e,1);return n.sort(r),n.length};{var Nt,Rt,At,Pt,Ut,St=[],Et=[],Mt=1e-6,zt=Mt*Mt;Math.PI}c.prototype={start:function(){return this.edge.l===this.site?this.edge.a:this.edge.b},end:function(){return this.edge.l===this.site?this.edge.b:this.edge.a}},N.prototype={insert:function(t,n){var e,r,i;if(t){if(n.P=t,n.N=t.N,t.N&&(t.N.P=n),t.N=n,t.R){for(t=t.R;t.L;)t=t.L;t.L=n}else t.R=n;e=t}else this._?(t=P(this._),n.P=null,n.N=t,t.P=t.L=n,e=t):(n.P=n.N=null,this._=n,e=null);for(n.L=n.R=null,n.U=e,n.C=!0,t=n;e&&e.C;)r=e.U,e===r.L?(i=r.R,i&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.R&&(A(this,e),t=e,e=t.U),e.C=!1,r.C=!0,R(this,r))):(i=r.L,i&&i.C?(e.C=i.C=!1,r.C=!0,t=r):(t===e.L&&(R(this,e),t=e,e=t.U),e.C=!1,r.C=!0,A(this,r))),e=t.U;this._.C=!1},remove:function(t){t.N&&(t.N.P=t.P),t.P&&(t.P.N=t.N),t.N=t.P=null;var n,e,r,i=t.U,u=t.L,o=t.R;if(e=u?o?P(o):u:o,i?i.L===t?i.L=e:i.R=e:this._=e,u&&o?(r=e.C,e.C=t.C,e.L=u,u.U=e,e!==o?(i=e.U,e.U=t.U,t=e.R,i.L=t,e.R=o,o.U=e):(e.U=i,i=e,t=e.R)):(r=t.C,t=e),t&&(t.U=i),!r){if(t&&t.C)return void(t.C=!1);do{if(t===this._)break;if(t===i.L){if(n=i.R,n.C&&(n.C=!1,i.C=!0,A(this,i),n=i.R),n.L&&n.L.C||n.R&&n.R.C){n.R&&n.R.C||(n.L.C=!1,n.C=!0,R(this,n),n=i.R),n.C=i.C,i.C=n.R.C=!1,A(this,i),t=this._;break}}else if(n=i.L,n.C&&(n.C=!1,i.C=!0,R(this,i),n=i.L),n.L&&n.L.C||n.R&&n.R.C){n.L&&n.L.C||(n.R.C=!1,n.C=!0,A(this,n),n=i.L),n.C=i.C,i.C=n.L.C=!1,R(this,i),t=this._;break}n.C=!0,t=i,i=i.U}while(!t.C);t&&(t.C=!1)}}},Lt=function(t){function i(t){var n=new Array(t.length),e=l[0][0],r=l[0][1],i=l[1][0],o=l[1][1];return S(u(t),l).cells.forEach(function(u,a){var s=u.edges,f=u.site,l=n[a]=s.length?s.map(function(t){var n=t.start();return[n.x,n.y]}):f.x>=e&&f.x<=i&&f.y>=r&&f.y<=o?[[e,o],[i,o],[i,r],[e,r]]:[];l.point=t[a]}),n}function u(t){return t.map(function(t,n){return{x:Math.round(s(t,n)/Mt)*Mt,y:Math.round(f(t,n)/Mt)*Mt,i:n}})}var o=M,a=E,s=o,f=a,l=bt;return t?i(t):(i.links=function(t){return S(u(t)).edges.filter(function(t){return t.l&&t.r}).map(function(n){return{source:t[n.l.i],target:t[n.r.i]}})},i.triangles=function(t){var n=[];return S(u(t)).cells.forEach(function(i,u){for(var o,a,s=i.site,f=i.edges.sort(r),l=-1,c=f.length,h=f[c-1].edge,p=h.l===s?h.r:h.l;++l<c;)o=h,a=p,h=f[l].edge,p=h.l===s?h.r:h.l,u<a.i&&u<p.i&&e(s,a,p)<0&&n.push([t[u],t[a.i],t[p.i]])}),n},i.x=function(t){return arguments.length?(s=n(o=t),i):o},i.y=function(t){return arguments.length?(f=n(a=t),i):a},i.clipExtent=function(t){return arguments.length?(l=null==t?bt:t,i):l===bt?null:l},i.size=function(t){return arguments.length?i.clipExtent(t&&[[0,0],t]):l===bt?null:l&&l[1]},i)};var kt,Tt,qt,$t=window.navigator&&/WebKit/.test(window.navigator.userAgent)?-1:0,Dt=window.document;qt=function(){return Tt(Dt.documentElement)};var Ot=qt.prototype=[],Vt=["webkit","ms","moz","Moz","o","O"],Xt=function(t,n){return n.querySelector(t)},Ht=function(t,n){return n.querySelectorAll(t)},Yt=function(t,n){var e=t.matches||t[k(t,"matchesSelector")];return(Yt=function(t,n){return e.call(t,n)})(t,n)};"function"==typeof Sizzle&&(Xt=function(t,n){return Sizzle(t,n)[0]||null},Ht=Sizzle,Yt=Sizzle.matchesSelector),Ot.select=function(t){var n,e,r,i,u=[];t=T(t);for(var o=-1,a=this.length;++o<a;){u.push(n=[]),n.parentNode=(r=this[o]).parentNode;for(var s=-1,f=r.length;++s<f;)(i=r[s])?(n.push(e=t.call(i,i.__data__,s,o)),e&&"__data__"in i&&(e.__data__=i.__data__)):n.push(null)}return vt(u)};var jt=[].slice,Bt=function(t){return jt.call(t)};Ot.selectAll=function(t){var n,e,r=[];t=q(t);for(var i=-1,u=this.length;++i<u;)for(var o=this[i],a=-1,s=o.length;++a<s;)(e=o[a])&&(r.push(n=Bt(t.call(e,e.__data__,a,i))),n.parentNode=e);return vt(r)};var Gt,It={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/"};Gt={prefix:It,qualify:function(t){var n=t.indexOf(":"),e=t;return n>=0&&(e=t.slice(0,n),t=t.slice(n+1)),It.hasOwnProperty(e)?{space:It[e],local:t}:t}},Ot.attr=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node();return t=Gt.qualify(t),t.local?e.getAttributeNS(t.space,t.local):e.getAttribute(t)}for(n in t)this.each($(n,t[n]));return this}return this.each($(t,n))};var Kt,Wt=/[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;Kt=function(t){return t.replace(Wt,"\\$&")},Ot.classed=function(t,n){if(arguments.length<2){if("string"==typeof t){var e=this.node(),r=(t=X(t)).length,i=-1;if(n=e.classList){for(;++i<r;)if(!n.contains(t[i]))return!1}else for(n=e.getAttribute("class");++i<r;)if(!O(t[i]).test(n))return!1;return!0}for(n in t)this.each(H(n,t[n]));return this}return this.each(H(t,n))},Ot.style=function(t,n,e){var r=arguments.length;if(3>r){if("string"!=typeof t){2>r&&(n="");for(e in t)this.each(Y(e,t[e],n));return this}if(2>r){var i=this.node();return j(i).getComputedStyle(i,null).getPropertyValue(t)}e=""}return this.each(Y(t,n,e))},Ot.property=function(t,n){if(arguments.length<2){if("string"==typeof t)return this.node()[t];for(n in t)this.each(B(n,t[n]));return this}return this.each(B(t,n))},Ot.text=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments);this.textContent=null==n?"":n}:null==t?function(){this.textContent=""}:function(){this.textContent=t}):this.node().textContent},Ot.html=function(t){return arguments.length?this.each("function"==typeof t?function(){var n=t.apply(this,arguments);this.innerHTML=null==n?"":n}:null==t?function(){this.innerHTML=""}:function(){this.innerHTML=t}):this.node().innerHTML},Ot.append=function(t){return t=G(t),this.select(function(){return this.appendChild(t.apply(this,arguments))})},Ot.insert=function(t,n){return t=G(t),n=T(n),this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})},Ot.remove=function(){return this.each(I)};var Zt=[];Zt.append=Ot.append,Zt.empty=Ot.empty,Zt.node=Ot.node,Zt.call=Ot.call,Zt.size=Ot.size,Zt.select=function(t){for(var n,e,r,i,u,o=[],a=-1,s=this.length;++a<s;){r=(i=this[a]).update,o.push(n=[]),n.parentNode=i.parentNode;for(var f=-1,l=i.length;++f<l;)(u=i[f])?(n.push(r[f]=e=t.call(i.parentNode,u.__data__,f,a)),e.__data__=u.__data__):n.push(null)}return vt(o)},Zt.insert=function(t,n){return arguments.length<2&&(n=K(this)),Ot.insert.call(this,t,n)};var Ft={}.__proto__?function(t,n){t.__proto__=n}:function(t,n){for(var e in n)t[e]=n[e]},Jt="__proto__",Qt="\x00";ut(F,{has:it,get:function(t){return this._[et(t)]},set:function(t,n){return this._[et(t)]=n},remove:rt,keys:nt,values:function(){var t=[];for(var n in this._)t.push(this._[n]);return t},entries:function(){var t=[];for(var n in this._)t.push({key:J(n),value:this._[n]});return t},size:tt,empty:Q,forEach:function(t){for(var n in this._)t.call(this,J(n),this._[n])}}),Ot.data=function(t,n){function e(t,e){var r,i,u,o=t.length,l=e.length,c=Math.min(o,l),h=new Array(l),p=new Array(l),v=new Array(o);if(n){var g,y=new F,d=new Array(o);for(r=-1;++r<o;)y.has(g=n.call(i=t[r],i.__data__,r))?v[r]=i:y.set(g,i),d[r]=g;for(r=-1;++r<l;)(i=y.get(g=n.call(e,u=e[r],r)))?i!==!0&&(h[r]=i,i.__data__=u):p[r]=Z(u),y.set(g,!0);for(r=-1;++r<o;)y.get(d[r])!==!0&&(v[r]=t[r])}else{for(r=-1;++r<c;)i=t[r],u=e[r],i?(i.__data__=u,h[r]=i):p[r]=Z(u);for(;l>r;++r)p[r]=Z(e[r]);for(;o>r;++r)v[r]=t[r]}p.update=h,p.parentNode=h.parentNode=v.parentNode=t.parentNode,a.push(p),s.push(h),f.push(v)}var r,i,u=-1,o=this.length;if(!arguments.length){for(t=new Array(o=(r=this[0]).length);++u<o;)(i=r[u])&&(t[u]=i.__data__);return t}var a=W([]),s=vt([]),f=vt([]);if("function"==typeof t)for(;++u<o;)e(r=this[u],t.call(r,r.parentNode.__data__,u));else for(;++u<o;)e(r=this[u],t);return s.enter=function(){return a},s.exit=function(){return f},s},Ot.datum=function(t){return arguments.length?this.property("__data__",t):this.property("__data__")},Ot.filter=function(t){var n,e,r,i=[];"function"!=typeof t&&(t=ot(t));for(var u=0,o=this.length;o>u;u++){i.push(n=[]),n.parentNode=(e=this[u]).parentNode;for(var a=0,s=e.length;s>a;a++)(r=e[a])&&t.call(r,r.__data__,a,u)&&n.push(r)}return vt(i)},Ot.order=function(){for(var t=-1,n=this.length;++t<n;)for(var e,r=this[t],i=r.length-1,u=r[i];--i>=0;)(e=r[i])&&(u&&u!==e.nextSibling&&u.parentNode.insertBefore(e,u),u=e);return this},Ot.sort=function(t){t=st.apply(this,arguments);for(var n=-1,e=this.length;++n<e;)this[n].sort(t);return this.order()};var tn;tn=function(t,n){var e=new F;if(t instanceof F)t.forEach(function(t,n){e.set(t,n)});else if(Array.isArray(t)){var r,i=-1,u=t.length;if(1===arguments.length)for(;++i<u;)e.set(i,t[i]);else for(;++i<u;)e.set(n.call(t,r=t[i],i),r)}else for(var o in t)e.set(o,t[o]);return e};var nn=tn({mouseenter:"mouseover",mouseleave:"mouseout"});Ot.on=function(t,n,e){var r=arguments.length;if(3>r){if("string"!=typeof t){2>r&&(n=!1);for(e in t)this.each(ht(e,t[e],n));return this}if(2>r)return(r=this.node()["__on"+t])&&r._;e=!1}return this.each(ht(t,n,e))},Ot.each=function(t){return pt(this,function(n,e,r){t.call(n,n.__data__,e,r)})},Ot.call=function(t){var n=Bt(arguments);return t.apply(n[0]=this,n),this},Ot.empty=function(){return!this.node()},Ot.node=function(){for(var t=0,n=this.length;n>t;t++)for(var e=this[t],r=0,i=e.length;i>r;r++){var u=e[r];if(u)return u}return null},Ot.size=function(){var t=0;return pt(this,function(){++t}),t},Tt=function(t){var n;return"string"==typeof t?(n=[Xt(t,Dt)],n.parentNode=Dt.documentElement):(n=[t],n.parentNode=gt(t)),vt([n])},kt=function(t){return yt(t,z())};var en=mt(100).map(function(){return[Math.random()*xt,Math.random()*wt]}),rn=Lt().clipExtent([[0,0],[xt,wt]]),un=Tt("body").append("svg").attr("width",xt).attr("height",wt).on("mousemove",function(){en[0]=kt(this),dt()}),on=un.append("g").selectAll("path");un.selectAll("circle").data(en.slice(1)).enter().append("circle").attr("transform",function(t){return"translate("+t+")"}).attr("r",1.5),dt()}();