d3/d3.min.js

2 строки
49 KiB
JavaScript
Исходник Обычный вид История

2011-09-14 22:15:50 +04:00
(function(){function dq(a,b,c){function i(a,b){var c=a.__domain||(a.__domain=a.domain()),d=a.range().map(function(a){return(a-b)/h});a.domain(c).domain(d.map(a.invert))}var d=Math.pow(2,(dc[2]=a)-c[2]),e=dc[0]=b[0]-d*c[0],f=dc[1]=b[1]-d*c[1],g=d3.event,h=Math.pow(2,a);d3.event={scale:h,translate:[e,f],transform:function(a,b){a&&i(a,e),b&&i(b,f)}};try{dd.apply(de,df)}finally{d3.event=g}g.preventDefault()}function dp(){dh&&(d3.event.stopPropagation(),d3.event.preventDefault(),dh=!1)}function dn(){c$&&(dg&&(dh=!0),dm(),c$=null)}function dm(){c_=null,c$&&(dg=!0,dq(dc[2],d3.svg.mouse(de),c$))}function dl(){var a=d3.svg.touches(de);switch(a.length){case 1:var b=a[0];dq(dc[2],b,da[b.identifier]);break;case 2:var c=a[0],d=a[1],e=[(c[0]+d[0])/2,(c[1]+d[1])/2],f=da[c.identifier],g=da[d.identifier],h=[(f[0]+g[0])/2,(f[1]+g[1])/2,f[2]];dq(Math.log(d3.event.scale)/Math.LN2+f[2],e,h)}}function dk(){var a=d3.svg.touches(de),b=-1,c=a.length,d;while(++b<c)da[(d=a[b]).identifier]=di(d);return a}function dj(){cZ||(cZ=d3.select("body").append("div").style("visibility","hidden").style("top",0).style("height",0).style("width",0).style("overflow-y","scroll").append("div").style("height","2000px").node().parentNode);var a=d3.event,b;try{cZ.scrollTop=1e3,cZ.dispatchEvent(a),b=1e3-cZ.scrollTop}catch(c){b=a.wheelDelta||-a.detail*5}return b*.005}function di(a){return[a[0]-dc[0],a[1]-dc[1],dc[2]]}function cY(){d3.event.stopPropagation(),d3.event.preventDefault()}function cX(){cS&&(cY(),cS=!1)}function cW(){!cO||(cT("dragend"),cO=null,cR&&(cS=!0,cY()))}function cV(){if(!!cO){var a=cO.parentNode;if(!a)return cW();cT("drag"),cY()}}function cU(a){return d3.event.touches?d3.svg.touches(a)[0]:d3.svg.mouse(a)}function cT(a){var b=d3.event,c=cO.parentNode,d=0,e=0;c&&(c=cU(c),d=c[0]-cQ[0],e=c[1]-cQ[1],cQ=c,cR|=d|e);try{d3.event={dx:d,dy:e},cN[a].dispatch.apply(cO,cP)}finally{d3.event=b}b.preventDefault()}function cM(a,b,c){e=[];if(c&&b.length>1){var d=bq(a.domain()),e,f=-1,g=b.length,h=(b[1]-b[0])/++c,i,j;while(++f<g)for(i=c;--i>0;)(j=+b[f]-i*h)>=d[0]&&e.push(j);for(--f,i=0;++i<c&&(j=+b[f]+i*h)<d[1];)e.push(j)}return e}function cL(a,b){a.attr("transform",function(a){return"translate(0,"+b(a)+")"})}function cK(a,b){a.attr("transform",function(a){return"translate("+b(a)+",0)"})}function cG(){return"circle"}function cF(){return 64}function cE(a,b){var c=(a.ownerSVGElement||a).createSVGPoint();if(cD<0&&(window.scrollX||window.scrollY)){var d=d3.select(document.body).append("svg:svg").style("position","absolute").style("top",0).style("left",0),e=d[0][0].getScreenCTM();cD=!e.f&&!e.e,d.remove()}cD?(c.x=b.pageX,c.y=b.pageY):(c.x=b.clientX,c.y=b.clientY),c=c.matrixTransform(a.getScreenCTM().inverse());return[c.x,c.y]}function cC(a){return function(){var b=a.apply(this,arguments),c=b[0],d=b[1]+bO;return[c*Math.cos(d),c*Math.sin(d)]}}function cB(a){return[a.x,a.y]}function cA(a){return a.endAngle}function cz(a){return a.startAngle}function cy(a){return a.radius}function cx(a){return a.target}function cw(a){return a.source}function cv(a){return function(b,c){return a[c][1]}}function cu(a){return function(b,c){return a[c][0]}}function ct(a){function i(f){if(f.length<1)return null;var i=bV(this,f,b,d),j=bV(this,f,b===c?cu(i):c,d===e?cv(i):e);return"M"+g(a(j),h)+"L"+g(a(i.reverse()),h)+"Z"}var b=bW,c=bW,d=0,e=bX,f="linear",g=bY[f],h=.7;i.x=function(a){if(!arguments.length)return c;b=c=a;return i},i.x0=function(a){if(!arguments.length)return b;b=a;return i},i.x1=function(a){if(!arguments.length)return c;c=a;return i},i.y=function(a){if(!arguments.length)return e;d=e=a;return i},i.y0=function(a){if(!arguments.length)return d;d=a;return i},i.y1=function(a){if(!arguments.length)return e;e=a;return i},i.interpolate=function(a){if(!arguments.length)return f;g=bY[f=a];return i},i.tension=function(a){if(!arguments.length)return h;h=a;return i};return i}function cs(a){var b,c=-1,d=a.length,e,f;while(++c<d)b=a[c],e=b[0],f=b[1]+bO,b[0]=e*Math.cos(f),b[1]=e*Math.sin(f);return a}function cr(a){return a.length<3?bZ(a):a[0]+cd(a,cq(a))}function cq(a){var b=[],c,d,e,f,g=cp(a),h=-1,i=a.le
;return c.test(e.baseVal!=null?e.baseVal:e)}return this.each(typeof b=="function"?i:b?f:g)},W.style=function(a,b,c){function f(){var d=b.apply(this,arguments);d==null?this.style.removeProperty(a):this.style.setProperty(a,d,c)}function e(){this.style.setProperty(a,b,c)}function d(){this.style.removeProperty(a)}arguments.length<3&&(c="");return arguments.length<2?window.getComputedStyle(this.node(),null).getPropertyValue(a):this.each(b==null?d:typeof b=="function"?f:e)},W.property=function(a,b){function e(){var c=b.apply(this,arguments);c==null?delete this[a]:this[a]=c}function d(){this[a]=b}function c(){delete this[a]}return arguments.length<2?this.node()[a]:this.each(b==null?c:typeof b=="function"?e:d)},W.text=function(a){return arguments.length<1?this.node().textContent:this.each(typeof a=="function"?function(){this.textContent=a.apply(this,arguments)}:function(){this.textContent=a})},W.html=function(a){return arguments.length<1?this.node().innerHTML:this.each(typeof a=="function"?function(){this.innerHTML=a.apply(this,arguments)}:function(){this.innerHTML=a})},W.append=function(a){function c(){return this.appendChild(document.createElementNS(a.space,a.local))}function b(){return this.appendChild(document.createElement(a))}a=d3.ns.qualify(a);return this.select(a.local?c:b)},W.insert=function(a,b){function d(){return this.insertBefore(document.createElementNS(a.space,a.local),U(b,this))}function c(){return this.insertBefore(document.createElement(a),U(b,this))}a=d3.ns.qualify(a);return this.select(a.local?d:c)},W.remove=function(){return this.each(function(){var a=this.parentNode;a&&a.removeChild(this)})},W.data=function(a,b){function f(a,f){var g,h=a.length,i=f.length,j=Math.min(h,i),k=Math.max(h,i),l=[],m=[],n=[],o,p;if(b){var q={},r=[],s,t=f.length;for(g=-1;++g<h;)s=b.call(o=a[g],o.__data__,g),s in q?n[t++]=o:q[s]=o,r.push(s);for(g=-1;++g<i;)o=q[s=b.call(f,p=f[g],g)],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Z(p),l[g]=n[g]=null),delete q[s];for(g=-1;++g<h;)r[g]in q&&(n[g]=a[g])}else{for(g=-1;++g<j;)o=a[g],p=f[g],o?(o.__data__=p,l[g]=o,m[g]=n[g]=null):(m[g]=Z(p),l[g]=n[g]=null);for(;g<i;++g)m[g]=Z(f[g]),l[g]=n[g]=null;for(;g<k;++g)n[g]=a[g],m[g]=l[g]=null}m.update=l,m.parentNode=l.parentNode=n.parentNode=a.parentNode,c.push(m),d.push(l),e.push(n)}var c=[],d=[],e=[],g=-1,h=this.length,i;if(typeof a=="function")while(++g<h)f(i=this[g],a.call(i,i.parentNode.__data__,g));else while(++g<h)f(i=this[g],a);var j=T(d);j.enter=function(){return $(c)},j.exit=function(){return T(e)};return j};var _=[];_.append=W.append,_.insert=W.insert,_.empty=W.empty,_.select=function(a){var b=[],c,d,e,f,g;for(var h=-1,i=this.length;++h<i;){e=(f=this[h]).update,b.push(c=[]),c.parentNode=f.parentNode;for(var j=-1,k=f.length;++j<k;)(g=f[j])?(c.push(e[j]=d=a.call(f.parentNode,g.__data__,j)),d.__data__=g.__data__):c.push(null)}return T(b)},W.filter=function(a){var b=[],c,d,e;for(var f=0,g=this.length;f<g;f++){b.push(c=[]),c.parentNode=(d=this[f]).parentNode;for(var h=0,i=d.length;h<i;h++)(e=d[h])&&a.call(e,e.__data__,h)&&c.push(e)}return T(b)},W.map=function(a){return this.each(function(){this.__data__=a.apply(this,arguments)})},W.sort=function(a){a=ba.apply(this,arguments);for(var b=0,c=this.length;b<c;b++)for(var d=this[b].sort(a),e=1,f=d.length,g=d[0];e<f;e++){var h=d[e];h&&(g&&g.parentNode.insertBefore(h,g.nextSibling),g=h)}return this},W.on=function(a,b,c){arguments.length<3&&(c=!1);var d="__on"+a,e=a.indexOf(".");e>0&&(a=a.substring(0,e));return arguments.length<2?(e=this.node()[d])&&e._:this.each(function(e,f){function h(a){var c=d3.event;d3.event=a;try{b.call(g,g.__data__,f)}finally{d3.event=c}}var g=this;g[d]&&g.removeEventListener(a,g[d],c),b&&g.addEventListener(a,g[d]=h,c),h._=b})},W.each=function(a){for(var b=-1,c=this.length;++b<c;)for(var d=this[b],e=-1,f=d.length;++e<f;){var g=d[e];g&&a.call(g,g.__data__,e,b)}return this},W.call=function(a){a.apply(this,(arguments[0]=this,arguments));return this},W.empty=function(){return!this.node()},W.node=function(a){for(var b=0,c=this.length;b<c;b++)for(var d=this[b],e=0,f=d.length;e<f;e++){va