mirror of https://github.com/masayuki0812/c3.git
Masayuki Tanaka
11 years ago
2 changed files with 487 additions and 317 deletions
@ -1,69 +1,72 @@
|
||||
(function(O){function xc(){function n(e,c){e.attr("transform",function(e){return"translate("+(c(e)+Z)+", 0)"})}function r(e,c){e.attr("transform",function(e){return"translate(0,"+c(e)+")"})}function O(e){var c=e[0];e=e[e.length-1];return c<e?[c,e]:[e,c]}function Aa(e){for(var c=[],n=Math.ceil(e[0]);n<e[1];n++)c.push(n);0<c.length&&0<c[0]&&c.unshift(c[0]-(c[1]-c[0]));return c}function Ba(e){e=e<P.length?P[e]:e;return Q?Q(e):e}function m(m){m.each(function(){var m=e.select(this),ja=Aa(s.domain()),I= |
||||
m.selectAll(".tick.major").data(ja,String),D=I.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),E=e.transition(I.exit()).style("opacity",1E-6).remove(),R=e.transition(I).style("opacity",1),M,N=s.rangeExtent?s.rangeExtent():O(s.range()),m=m.selectAll(".domain").data([0]);m.enter().append("path").attr("class","domain");var m=e.transition(m),J=s.copy(),Q=this.__chart__||J;this.__chart__=J;D.append("line");D.append("text");var P=D.select("line"),ka=R.select("line"),$=I.select("text"), |
||||
Sa=D.select("text"),Ta=R.select("text");Z=(J(1)-J(0))/2;I=sa?0:Z;switch(aa){case "bottom":M=n;P.attr("y2",F);Sa.attr("y",Math.max(F,0)+c);ka.attr("x1",I).attr("x2",I).attr("y2",F);Ta.attr("x",0).attr("y",Math.max(F,0)+c);$.attr("dy",".71em").style("text-anchor","middle");$.text(function(e){return ja.length<S||0===e%Math.ceil(ja.length/S)?Ba(e):""});m.attr("d","M"+N[0]+","+A+"V0H"+N[1]+"V"+A);break;case "left":M=r,P.attr("x2",-F),Sa.attr("x",-(Math.max(F,0)+c)),ka.attr("x2",-F).attr("y2",0),Ta.attr("x", |
||||
-(Math.max(F,0)+c)).attr("y",Z),$.attr("dy",".32em").style("text-anchor","end"),$.text(function(e){return ja.length<S||0===e%Math.ceil(ja.length/S)?Ba(e):""}),m.attr("d","M"+-A+","+N[0]+"H0V"+N[1]+"H"+-A)}if(s.ticks)D.call(M,Q),R.call(M,J),E.call(M,J);else{var Ca=J.rangeBand()/2,E=function(e){return J(e)+Ca};D.call(M,E);R.call(M,E)}})}var s=e.scale.linear(),aa="bottom",F=6,A=6,c=3,sa=!1,S=10,Z=0,Q=null,P=[];m.scale=function(e){if(!arguments.length)return s;s=e;return m};m.orient=function(e){if(!arguments.length)return aa; |
||||
aa=e in{top:1,right:1,bottom:1,left:1}?e+"":"bottom";return m};m.categories=function(e){if(!arguments.length)return P;P=e;return m};m.tickCentered=function(e){if(!arguments.length)return sa;sa=e;return m};m.tickTextNum=function(e){if(!arguments.length)return S;S=e;return m};m.tickFormat=function(e){if(!arguments.length)return Q;Q=e;return m};m.tickOffset=function(){return Z};m.ticks=function(){};return m}function r(e){return"undefined"===typeof e}function n(e){return"undefined"!==typeof e}var hb= |
||||
O.c3={},e=O.d3;hb.generate=function(Y){var Fb,Gb,Aa,Ba,m,s,aa,F,A;function c(a,b){for(var d=Y,k=0;k<a.length;k++){if(!(a[k]in d))return b;d=d[a[k]]}return d}function sa(){ib=null===Ua?Z():Ua;ta=S();Ib=20+Jb+la;Kb=Lb?Lb:Mb?jb||f?1:40:20;Va=Nb?Nb:kb?1:40;Ob=ta-Jb-la;Pb=20+la;Qb=ta-la;s=0;aa=Kb;F=Ib;A=Va;Aa=Ob;Ba=Pb;m=Va;Fb=Qb;Gb=Va;p=ib-A-aa;t=ta-s-F;ma=ta-Aa-Ba}function S(){var a=null===Rb?+e.select(ua).style("height").replace("px",""):Rb;return 0<a?a:320}function Z(){return+e.select(ua).style("width").replace("px", |
||||
"")}function Q(){return p+2+A+aa}function P(){return 40}function ja(){return A+20}function hb(){return t-s+42}function Eb(){Sb=f?10:0;Tb=f?t:p;lb=f?0:t;mb=f?p:1;l=I(Sb,Tb,n(l)?l.domain():void 0,function(){return B.tickOffset()});y=D(lb,mb,n(y)?y.domain():void 0);T=D(lb,mb,n(T)?T.domain():void 0);ba=I(0,p,n(U)?U:void 0,function(a){return 0===a%1?Da.tickOffset():0});Wa=D(ma,10);Xa=D(ma,10);B=M(l,Ac);na=e.svg.axis().scale(y).orient(Bc);Ya=e.svg.axis().scale(T).orient(Cc);Da=M(ba,Dc)}function I(a,b,d, |
||||
k){var q=(z?e.time.scale():e.scale.linear()).range([a,b]);q.orgDomain=function(){return q.domain()};n(d)&&q.domain(d);r(k)&&(k=function(){return 0});if(ca){var c=q,f,q=function(a){return c(a)+k(a)};for(f in c)q[f]=c[f];q.orgDomain=function(){return c.domain()};q.domain=function(a){if(!arguments.length)return a=c.domain(),[a[0],a[1]+1];c.domain(a);return q}}return q}function D(a,b){return e.scale.linear().range([a,b])}function E(a){return"y2"===N(a)?T:y}function R(a){return"y2"===N(a)?Xa:Wa}function M(a, |
||||
b){var d=(ca?xc():e.svg.axis()).scale(a).orient(b);d.tickFormat(J());ca?d.categories(Ea).tickCentered(Ec):d.tickOffset=function(){return 0};return d}function N(a){return a in Ub?Ub[a]:"y"}function J(){var a=z?Fc:ca?Gc:function(a){return a};Za&&(a="function"===typeof Za?Za:z?function(a){return e.time.format(Za)(a)}:a);return a}function yc(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.value})})}function zc(a){var b={},d,k;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})}); |
||||
for(d=0;d<w.length;d++)for(k=1;k<w[d].length;k++)Fa(w[d][k])&&(r(b[w[d][k]])||b[w[d][k]].forEach(function(a,e){N(w[d][k])===N(w[d][0])&&(b[w[d][0]][e]+=1*a)}));return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))}function ka(a){var b=$a(function(b){return N(b.id)===a}),d="y2"===a?Hc:Ic,k="y2"===a?Jc:Kc,d=null!==d?d:yc(b),k=null!==k?k:zc(b),q=0.1*Math.abs(k-d),e=q,c=q,f="y2"===a?Lc:Mc;null!==f&&(d=Math.max(Math.abs(d),Math.abs(k)),k=d-f,d=f-d);"y"===a&&null!==Ga&&(e=n(Ga.top)?Ga.top:q, |
||||
c=n(Ga.bottom)?Ga.bottom:q);"y2"===a&&null!==Ha&&(e=n(Ha.top)?Ha.top:q,c=n(Ha.bottom)?Ha.bottom:q);return[Nc(b,"bar")?0:d-c,k+e]}function $(a){var b;a?(a=l.domain(),b=G.extent()):(a=U,b=l.domain());return(a[1]-a[0])/(b[1]-b[0])}function Sa(a){for(var b=0;b<a.length;b++)if(!(a[b]in ab))return!1;return!0}function Ta(a){for(var b=[],d=0;d<a.length;d++)a[d]in ab&&b.push(Vb(ab[a[d]]));return b}function Ca(a){return"start"in a?l(z?oa(a.start):a.start):0}function Hb(a){var b=Ca(a);a=("end"in a?l(z?oa(a.end): |
||||
a.end):p)-b;return 0>a?0:a}function nb(a){var b=Ia[a.id];a.name=n(b)?b:a.id;return a}function Wb(a){var b=a[0],d={},k=[],e,c;for(e=1;e<a.length;e++){d={};for(c=0;c<a[e].length;c++)d[b[c]]=a[e][c];k.push(d)}return k}function Xb(a){var b=[],d,k,e;for(d=0;d<a.length;d++)for(e=a[d][0],k=1;k<a[d].length;k++)r(b[k-1])&&(b[k-1]={}),b[k-1][e]=a[d][k];return b}function Ja(a){var b=e.keys(a[0]).filter(function(a){return a!==V}),d,k;if(z&&!V)return O.alert('data.x must be specified when axis.x.type == "timeseries"'), |
||||
[];ob&&r(g.data.x)&&(g.data.x=a.map(function(a){return a[V]}));d=0;a.forEach(function(a){if(z){if(!(V in a))throw Error("'"+V+"' must be included in data");k=oa(a[V]);if(null===k)throw Error("Failed to parse timeseries date in data");a.x=k}else a.x=ob?n(a[V])?a[V]:g.data.x[d]:d;null===bb&&(bb=new Date(a.x));pb=new Date(a.x);d++});b=b.map(function(b){var d=Oc(b);return{id:d,id_org:b,values:a.map(function(a){return{x:a.x,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d}})}});b.forEach(function(a){ab[a.id_org]= |
||||
Vb(a)});return b}function Vb(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function va(){return e.max(g.data.targets,function(a){return a.values.length})}function qb(a){a=r(a)?g.data.targets:a;return a.map(function(a){return a.id})}function rb(a){var b=qb(),d;for(d=0;d<b.length;d++)if(b[d]===a)return!0;return!1}function $a(a){return n(a)?g.data.targets.filter(a):g.data.targets}function Gc(a){return a<Ea.length?Ea[a]:a}function sb(a){return"-shapes -shapes-"+ |
||||
a.id}function Yb(a){return sb(a)+" -line -line-"+a.id}function Pc(a){return sb(a)+" -circles -circles-"+a.id}function Zb(a){return sb(a)+" -bars -bars-"+a.id}function Qc(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function $b(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function Rc(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function cb(a){return l(a.x)}function Ka(a){return l(z?oa(a.value):a.value)}function ac(a){return y(a.value)}function da(a){return l(a.x)} |
||||
function ea(a){return E(a.id)(a.value)}function Sc(){var a={},b=0,d,k;$a(Fa).forEach(function(e){for(d=0;d<w.length;d++)if(!(0>w[d].indexOf(e.id)))for(k=0;k<w[d].length;k++)if(w[d][k]in a){a[e.id]=a[w[d][k]];break}r(a[e.id])&&(a[e.id]=b++)});a.__max__=b-1;return a}function bc(a,b,d,k){var e=k?ba:l;return function(k){var c=k.id in d?d[k.id]:0;return e(k.x)-a*(b/2-c)}}function cc(a,b,d,k){var e=Object.keys(b);return function(c,f){var g=0,h=k?R(c.id):E(c.id);$a(Fa).forEach(function(d){d.id!==c.id&&b[d.id]=== |
||||
b[c.id]&&e.indexOf(d.id)<e.indexOf(c.id)&&(g+=a(d.values[f]))});return d?g:h(c.value)-g}}function dc(a,b){var d=null===a?function(a){return a}:function(b){return a-b};return function(a){var e=b?R(a.id):E(a.id);return d(e(a.value))}}function tb(a,b){var d=r(a)?qb():a;"string"===typeof d&&(d=[d]);for(var e=0;e<d.length;e++)fa[d[e]]=b}function Nc(a,b){var d=!1;a.forEach(function(a){fa[a.id]===b&&(d=!0);a.id in fa||"line"!==b||(d=!0)});return d}function ub(a){a="string"===typeof a?a:a.id;return!(a in |
||||
fa)||"line"===fa[a]||"spline"===fa[a]}function Fa(a){return"bar"===fa["string"===typeof a?a:a.id]}function Tc(a){return ub(a)?a.values:[]}function ec(a){return Fa(a)?a.values:[]}function fc(a,b){var d=e.mouse(a),k=e.select(a),c=1*k.attr("cx"),k=1*k.attr("cy");return Math.sqrt(Math.pow(c-d[0],2)+Math.pow(k-d[1],2))<b}function gc(a){var b=e.mouse(a),d=e.select(a);a=1*d.attr("x");var k=1*d.attr("y"),d=1*d.attr("width");return a-10<b[0]&&b[0]<a+d+10&&k-10<b[1]}function Uc(a,b){var d;for(d=0;d<b.length;d++)if(b[d].start< |
||||
a&&a<=b[d].end)return!0;return!1}function hc(a,b,d){Vc(a,b);h.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+d}).attr("cx",f?ea:da).attr("cy",f?da:ea).attr("stroke",function(){return W(b.id)}).attr("r",1.4*La).transition().duration(100).attr("r",La)}function vb(a,b,d){Wc(a,b);h.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).transition().duration(100).attr("r", |
||||
0).remove()}function ic(a,b,d,e){a?hc(b,d,e):vb(b,d,e)}function Xc(){}function jc(){}function kc(a,b,d,e){}function lc(a){return a.filter(function(a){return null!==a.value})}function Yc(a,b,d,e){var c,g,u="M",h,l,v,mc,m,p=[];if(n(e))for(c=0;c<e.length;c++)p[c]={},r(e[c].start)?p[c].start=a[0].x:p[c].start=z?oa(e[c].start):e[c].start,r(e[c].end)?p[c].end=a[a.length-1].x:p[c].end=z?oa(e[c].end):e[c].end;mc=f?function(a){return d(a.value)}:function(a){return b(a.x)};m=f?function(a){return b(a.x)}:function(a){return d(a.value)}; |
||||
e=z?function(a,e,c,k){var f=a.x.getTime();a=e.x-a.x;e=new Date(f+a*(c+k));return"M"+b(new Date(f+a*c))+" "+d(l(c))+" "+b(e)+" "+d(l(c+k))}:function(a,e,c,k){return"M"+b(h(c))+" "+d(l(c))+" "+b(h(c+k))+" "+d(l(c+k))};for(c=0;c<a.length;c++)if(r(p)||!Uc(a[c].x,p))u+=" "+mc(a[c])+" "+m(a[c]);else{h=I(a[c-1].x,a[c].x);l=D(a[c-1].value,a[c].value);g=b(a[c].x)-b(a[c-1].x);v=d(a[c].value)-d(a[c-1].value);g=Math.sqrt(Math.pow(g,2)+Math.pow(v,2));v=2/g;var s=2*v;for(g=v;1>=g;g+=s)u+=e(a[c-1],a[c],g,v)}return u} |
||||
function wb(a){var b,d;db=e.select(ua);if(db.empty())O.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{db.html("");g.data.x=void 0;g.data.targets=Ja(a);sa();Eb();l.domain(e.extent(a.map(function(a){return a.x})));y.domain(ka("y"));T.domain(ka("y2"));ba.domain(l.domain());Wa.domain(y.domain());Xa.domain(T.domain());B.ticks(10>a.length?a.length:10);na.ticks(Zc).outerTickSize(0).tickFormat($c);Ya.ticks(ad).outerTickSize(0).tickFormat(bd); |
||||
U=l.domain();G.x(ba);pa&&H.x(l);Ma=e.select(ua).append("svg").attr("width",p+A+aa).attr("height",t+s+F).on("mouseenter",cd).on("mouseleave",dd);eb=Ma.append("defs");eb.append("clipPath").attr("id",xb).append("rect").attr("y",s).attr("width",p).attr("height",t-s);eb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",Q).attr("height",P);eb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-A+1).attr("y",s-1).attr("width",ja).attr("height", |
||||
hb);h=Ma.append("g").attr("transform",K.main);x=wa?Ma.append("g").attr("transform",K.context):null;xa=ya?Ma.append("g").attr("transform",K.legend):null;X=e.select(ua).style("position","relative").append("div").style("position","absolute").style("z-index","10").style("display","none");h.append("g").attr("class","x axis").attr("clip-path",f?"":"url(#xaxis-clip)").attr("transform",K.x).call(f?na:B).append("text").attr("class","-axis-x-label").attr("x",p).attr("dy","-.5em").style("text-anchor","end").text(ed); |
||||
h.append("g").attr("class","y axis").attr("clip-path",f?"url(#yaxis-clip)":"").call(f?B:na).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(fd);Mb&&h.append("g").attr("class","y2 axis").attr("transform",K.y2).call(Ya);b=h.append("g").attr("clip-path",Na).attr("class","grid");nc&&b.append("g").attr("class","xgrids");yb&&(d=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(yb).enter().append("g").attr("class", |
||||
"xgrid-line"),d.append("line").attr("class",function(a){return""+a["class"]}),d.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",f?"":"rotate(-90)").attr("dx",f?0:-s).attr("dy",-6).text(function(a){return a.text}));gd&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",f?0:-10).attr("x2",f?p:-10).attr("y1",f?-10:s).attr("y2",f?-10:t);oc&&b.append("g").attr("class","ygrids");zb&&b.append("g").attr("class", |
||||
"ygrid-lines").selectAll("ygrid-line").data(zb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Na).attr("class","regions");h.append("g").attr("clip-path",Na).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",pa?"ew-resize":null).selectAll(".event-rects").data(a).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",ga&& |
||||
qa?"pointer":null).on("mouseover",function(a,b){if(!fb){var d=g.data.targets.map(function(a){return nb(a.values[b])}),e,c;if(0<Object.keys(Ia).length){c=[];for(var l in Ia)for(e=0;e<d.length;e++)if(d[e].id===l){c.push(d[e]);d.shift(e);break}d=c.concat(d)}pc&&h.selectAll(".-circle-"+b).classed(ha,!0).attr("r",qc);h.selectAll(".-bar-"+b).classed(ha,!0);h.selectAll("line.xgrid-focus").style("visibility","visible").data([d[0]]).attr(f?"y1":"x1",cb).attr(f?"y2":"x2",cb)}}).on("mouseout",function(a,b){h.select("line.xgrid-focus").style("visibility", |
||||
"hidden");X.style("display","none");h.selectAll(".-circle-"+b).filter(function(){return e.select(this).classed(ha)}).classed(ha,!1).attr("r",Ab);h.selectAll(".-bar-"+b).classed(ha,!1)}).on("mousemove",function(a,b){var d=g.data.targets.map(function(a){return nb(a.values[b])});X.html(rc(d)).style("visibility","hidden").style("display","block");var c=X.property("offsetWidth"),n=X.property("offsetHeight");X.style("top",(e.mouse(this)[1]+15+n<S()?e.mouse(this)[1]+15:e.mouse(this)[1]-n)+"px").style("left", |
||||
f?e.mouse(this)[0]:l(d[0].x)+60+c<(null===Ua?Z():Ua)?l(d[0].x)+60+"px":l(d[0].x)-c+30+"px").style("visibility","visible");ga&&!fb&&(qa||h.selectAll(".-shape-"+b).filter(function(a){return ra(a)}).each(function(){var a=e.select(this).classed(ha,!0);"circle"===this.nodeName&&a.attr("r",qc);e.select(".event-rect-"+b).style("cursor",null)}).filter(function(){var a=e.select(this);if("circle"===this.nodeName)return fc(this,La);if("rect"===this.nodeName)return gc(this,a.attr("x"),a.attr("y"))}).each(function(){var a= |
||||
e.select(this);a.classed(ha)||(a.classed(ha,!0),"circle"===this.nodeName&&a.attr("r",La));e.select(".event-rect-"+b).style("cursor","pointer")}))}).on("click",function(a,b){Bb?Bb=!1:h.selectAll(".-shape-"+b).each(function(a){var d=e.select(this),c=d.classed(ia),k=!1,f;"circle"===this.nodeName?(k=fc(this,1.5*La),f=ic):"rect"===this.nodeName&&(k=gc(this),f=kc);if(qa||k)ga&&ra(a)&&(d.classed(ia,!c),f(!c,d,a,b)),hd(a,d)})}).call(e.behavior.drag().origin(Object).on("drag",function(){if(ga&&(!pa||H.altDomain)){var a= |
||||
Cb[0],b=Cb[1],d=e.mouse(this),c=d[0],d=d[1],f=Math.min(a,c),g=Math.max(a,c),l=qa?s:Math.min(b,d),n=qa?t:Math.max(b,d);h.select(".dragarea").attr("x",f).attr("y",l).attr("width",g-f).attr("height",n-l);h.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ra(a)}).each(function(a,b){var d=e.select(this),c=d.classed(ia),k=d.classed(Db),h,q,u,p;h=!1;"circle"===this.nodeName?(h=1*d.attr("cx"),q=1*d.attr("cy"),p=ic,h=f<h&&h<g&&l<q&&q<n):"rect"===this.nodeName&&(h=1*d.attr("x"),q=1*d.attr("y"), |
||||
u=1*d.attr("width"),p=kc,h=f<h+u&&h<g&&q<n);h^k&&(d.classed(Db,!k),d.classed(ia,!c),p(!c,d,a,b))})}}).on("dragstart",function(){ga&&(Cb=e.mouse(this),h.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),fb=!0)}).on("dragend",function(){ga&&(h.select(".dragarea").transition().duration(100).style("opacity",0).remove(),h.selectAll(".-shape").classed(Db,!1),fb=!1)})).call(H).on("dblclick.zoom",null);h.select(".chart").append("g").attr("class","chart-bars");h.select(".chart").append("g").attr("class", |
||||
"chart-lines");if(pa)h.insert("rect",id?null:"g.grid").attr("class","zoom-rect").attr("width",p).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(H).on("dblclick.zoom",null);null!==Oa&&G.extent("function"!==typeof Oa?Oa:z?Oa(bb,pb):Oa(0,va()-1));wa&&(x.append("g").attr("clip-path",Na).attr("class","chart"),x.select(".chart").append("g").attr("class","chart-bars"),x.select(".chart").append("g").attr("class","chart-lines"),x.append("g").attr("clip-path",Na).attr("class","x brush").call(G).selectAll("rect").attr("height", |
||||
ma),x.append("g").attr("class","x axis").attr("transform",K.subx).call(Da));ya&&gb(g.data.targets);sc(g.data.targets);C({withTransition:!1,withUpdateXDomain:!0});if(jd){if(z&&"string"===typeof za){za=oa(za);for(a=0;a<g.data.targets[0].values.length&&0!==g.data.targets[0].values[a].x-za;a++);za=a}X.html(rc(g.data.targets.map(function(a){return nb(a.values[za])})));X.style("top",tc.top).style("left",tc.left).style("display","block")}null==O.onresize&&(O.onresize=kd)}}function C(a){var b,d,c=Sc(),q= |
||||
c.__max__+1,m,u,r,w,v;a=n(a)?a:{};b=n(a.withY)?a.withY:!0;w=n(a.withSubchart)?a.withSubchart:!0;v=n(a.withTransition)?a.withTransition:!0;a=n(a.withUpdateXDomain)?a.withUpdateXDomain:!1;v=v?250:0;a&&(l.domain(G.empty()?U:G.extent()),pa&&H.x(l).updateScaleExtent());y.domain(ka("y"));T.domain(ka("y2"));h.select(".x.axis").transition().duration(f?v:0).call(f?na:B);h.select(".y.axis").transition().duration(f?0:v).call(f?B:na);h.select(".y2.axis").transition().call(Ya);h.select(".x.axis .-axis-x-label").attr("x", |
||||
p);Wa.domain(y.domain());Xa.domain(T.domain());X.style("display","none");h.select("line.xgrid-focus").style("visibility","hidden").attr("y2",t);if(nc){if("year"===ld)for(a=[],u=bb.getFullYear(),m=pb.getFullYear();u<=m;u++)a.push(new Date(u+"-01-01 00:00:00"));else a=l.ticks(10);a=h.select(".xgrids").selectAll(".xgrid").data(a);a.enter().append("line").attr("class","xgrid");a.attr("x1",f?0:function(a){return l(a)-B.tickOffset()}).attr("x2",f?p:function(a){return l(a)-B.tickOffset()}).attr("y1",f?function(a){return l(a)- |
||||
B.tickOffset()}:s).attr("y2",f?function(a){return l(a)-B.tickOffset()}:t).style("opacity",function(){return+e.select(this).attr(f?"y1":"x1")===(f?t:0)?0:1});a.exit().remove()}yb&&(a=h.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",f?0:Ka).attr("x2",f?p:Ka).attr("y1",f?Ka:s).attr("y2",f?Ka:t),a.selectAll("text").attr("x",f?p:0).attr("y",Ka));b&&oc&&(a=h.select(".ygrids").selectAll(".ygrid").data(y.ticks(10)),a.enter().append("line").attr("class","ygrid"),a.attr("x1",f?y:0).attr("x2",f?y:p).attr("y1", |
||||
f?0:y).attr("y2",f?t:y),a.exit().remove());b&&zb&&h.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",ac).attr("y2",ac);m=ca?1.2*B.tickOffset()/q:0.6*((f?t:p)*$(!1)/(va()-1));u=dc(f?null:t);b=bc(m,q,c);a=cc(u,c,f);d=h.selectAll(".-bars").selectAll(".-bar").data(ec);d.transition().duration(v).attr("x",f?a:b).attr("y",f?b:a).attr("width",f?u:m).attr("height",f?m:u);d.enter().append("rect").attr("class",$b).attr("x",f?a:b).attr("y",f?b:a).attr("width",f?u:m).attr("height",f?m:u).style("opacity", |
||||
0).transition().duration(v).style("opacity",1);d.exit().transition().duration(v).style("opacity",0).remove();h.selectAll(".-line").transition().duration(v).attr("d",md);b=h.selectAll(".-circles").selectAll(".-circle").data(Tc);b.transition().duration(v).style("opacity",function(a){return null===a.value?0:1}).attr("cx",f?ea:da).attr("cy",f?da:ea);b.enter().append("circle").style("opacity",function(a){return null===a.value?0:1}).attr("class",Qc).attr("cx",f?ea:da).attr("cy",f?da:ea).attr("r",Ab);b.exit().remove(); |
||||
wa&&(null!==e.event&&"zoom"===e.event.type&&G.extent(l.orgDomain()).update(),w&&(x.select(".x.axis").transition().duration(f?v:0).call(f?na:Da),G.empty()||G.extent(l.orgDomain()).update(),m=ca?1.2*Da.tickOffset()/q:0.6*((f?t:p)*$(!0)/(va()-1)),u=dc(ma,!0),b=bc(m,q,c,!0),a=cc(u,c,!1,!0),c=x.selectAll(".-bars").selectAll(".-bar").data(ec),c.transition().duration(v).attr("x",b).attr("y",a).attr("width",m).attr("height",u),c.enter().append("rect").attr("class",$b).attr("x",b).attr("y",a).attr("width", |
||||
m).attr("height",u).style("opacity",0).transition().style("opacity",1),c.exit().transition().style("opacity",0).remove(),x.selectAll(".-line").transition().duration(v).attr("d",nd)));h.selectAll(".selected-circles").filter(function(a){return Fa(a)}).selectAll("circle").remove();h.selectAll(".selected-circle").transition().duration(v).attr("cx",f?ea:da).attr("cy",f?da:ea);ob?(r=function(a,b){var d=0<b?g.data.targets[0].values[b-1].x:void 0,c=b<va()-1?g.data.targets[0].values[b+1].x:void 0;return(l(c? |
||||
c:a.x+50)-l(d?d:a.x-50))/2},c=function(a,b){var d=0<b?g.data.targets[0].values[b-1].x:void 0;return(l(a.x)+l(d?d:a.x-50))/2}):(r=(f?t:p)*$()/(va()-1),c=function(a){return l(a.x)-r/2});h.selectAll(".event-rect").attr("x",f?0:c).attr("y",f?c:0).attr("width",f?p:r).attr("height",f?r:t);c=h.select(".regions").selectAll("rect.region").data(L);c.enter().append("rect");c.attr("class",Rc).attr("x",f?0:Ca).attr("y",f?Ca:s).attr("width",f?p:Hb).attr("height",f?Hb:t).style("fill-opacity",function(a){return n(a.opacity)? |
||||
a.opacity:0.1});c.exit().transition().duration(v).style("fill-opacity",0).remove()}function od(){"mousemove"===e.event.sourceEvent.type&&H.altDomain?(l.domain(H.altDomain),H.x(l).updateScaleExtent()):(ca&&l.orgDomain()[0]===U[0]&&l.domain([U[0]-1E-10,l.orgDomain()[1]]),C({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===e.event.sourceEvent.type&&(Bb=!0))}function kd(){sa();Eb();G.x(ba);pa&&H.x(l);e.select("svg").attr("width",ib).attr("height",ta);e.select("#"+xb).select("rect").attr("width", |
||||
p).attr("height",t);e.select("#xaxis-clip").select("rect").attr("width",Q);e.select(".zoom-rect").attr("width",p).attr("height",t);h.select(".x.axis").attr("transform",K.x);h.select(".y2.axis").attr("transform",K.y2);wa&&(x.select(".x.brush").selectAll("rect").attr("height",ma),x.attr("transform",K.context),x.select(".x.axis").attr("transform",K.subx));ya&&(xa.attr("transform",K.legend),gb(g.data.targets,{withTransition:!1}));C({withTransition:!1,withUpdateXDomain:!0})}function sc(a){var b;h.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class", |
||||
function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity",0).append("g").attr("class",Zb).style("fill",function(a){return W(a.id)}).style("stroke",function(a){return W(a.id)}).style("stroke-width",0).style("cursor",function(a){return ra(a)?"pointer":null});b=h.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class", |
||||
Yb).style("stroke",function(a){return W(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+a.id});b.append("g").attr("class",Pc).style("fill",function(a){return W(a.id)}).style("cursor",function(a){return ra(a)?"pointer":null});a.forEach(function(a){h.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});wa&&(b=x.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class", |
||||
function(a){return"chart-bar target target-"+a.id}).style("opacity",0),b.append("g").attr("class",Zb).style("fill",function(a){return W(a.id)}),b=x.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity",0),b.append("path").attr("class",Yb).style("stroke",function(a){return W(a.id)}));ya&&gb(a);e.selectAll(".target").transition().style("opacity",1)}function Pa(a,b){g.data.targets.forEach(function(b){for(var c= |
||||
0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values;a.splice(c,1);break}});g.data.targets=g.data.targets.concat(a);sc(g.data.targets);C();b()}function gb(a,b){var d=qb(a),c,f=p/2-Qa*Object.keys(a).length/2,h;b=r(b)?{}:b;h=n(b.withTransition)?b.withTransition:!0;c=xa.selectAll(".legend-item").data(d).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){pd(a)}).on("mouseover",function(a){e.selectAll(".legend-item").filter(function(b){return b!== |
||||
a}).transition().duration(100).style("opacity",0.3);g.focus(a)}).on("mouseout",function(){e.selectAll(".legend-item").transition().duration(100).style("opacity",1);g.revert()});c.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return la/2-16}).attr("width",Qa).attr("height",24);c.append("rect").attr("class","legend-item-tile").style("fill",function(a){return W(a)}).attr("x",-200).attr("y",function(){return la/2-9}).attr("width",10).attr("height", |
||||
10);c.append("text").text(function(a){return n(Ia[a])?Ia[a]:a}).attr("x",-200).attr("y",function(){return la/2});xa.selectAll("rect.legend-item-event").data(d).transition().duration(h?250:0).attr("x",function(a,b){return f+Qa*b});xa.selectAll("rect.legend-item-tile").data(d).transition().duration(h?250:0).attr("x",function(a,b){return f+Qa*b});xa.selectAll("text").data(d).transition().duration(h?250:0).attr("x",function(a,b){return f+Qa*b+14})}function Ra(a){return n(a)?".target-"+a:".target"}var g= |
||||
{data:{}},ab={},ha="_expanded_",ia="_selected_",Db="_included_",ua=c(["bindto"],"#chart"),Ua=c(["size","width"],null),Rb=c(["size","height"],null),Nb=c(["padding","left"],null),Lb=c(["padding","right"],null),pa=c(["zoom","enabled"],!1),uc=c(["zoom","extent"],null),id=c(["zoom","privileged"],!1),cd=c(["onenter"],function(){}),dd=c(["onleave"],function(){});if(!("data"in Y))throw Error("data is required in config");var V=c(["data","x"],void 0),qd=c(["data","x_format"],"%Y-%m-%d"),Oc=c(["data","id_converter"], |
||||
function(a){return a}),Ia=c(["data","names"],{}),w=c(["data","groups"],[]),Ub=c(["data","axes"],{}),fa=c(["data","types"],{}),vc=c(["data","regions"],{}),rd=c(["data","colors"],{}),ga=c(["data","selection","enabled"],!1),qa=c(["data","selection","grouped"],!1),ra=c(["data","selection","isselectable"],function(){return!0}),wa=c(["subchart","show"],!1),Jb=wa?c(["subchart","size","height"],60):0,sd=c(["color","pattern"],null),ya=c(["legend","show"],!0),Qa=c(["legend","item","width"],80),pd=c(["legend", |
||||
"item","onclick"],function(){}),wc=c(["axis","x","type"],"indexed"),Ea=c(["axis","x","categories"],[]),Ec=c(["axis","x","tick","centered"],!1),Za=c(["axis","x","tick","format"],null),Oa=c(["axis","x","default"],null),ed=c(["axis","x","label"],null),Kc=c(["axis","y","max"],null),Ic=c(["axis","y","min"],null),Mc=c(["axis","y","center"],null),fd=c(["axis","y","label"],null),kb=c(["axis","y","inner"],!1),$c=c(["axis","y","format"],function(a){return a}),Ga=c(["axis","y","padding"],null),Zc=c(["axis", |
||||
"y","ticks"],10),Mb=c(["axis","y2","show"],!1),Jc=c(["axis","y2","max"],null),Hc=c(["axis","y2","min"],null),Lc=c(["axis","y2","center"],null),jb=c(["axis","y2","inner"],!1),bd=c(["axis","y2","format"],function(a){return a}),Ha=c(["axis","y2","padding"],null),ad=c(["axis","y2","ticks"],10),f=c(["axis","rotated"],!1),nc=c(["grid","x","show"],!1),ld=c(["grid","x","type"],"tick"),yb=c(["grid","x","lines"],null),oc=c(["grid","y","show"],!1),zb=c(["grid","y","lines"],null),Ab=c(["point","show"],!0)?c(["point", |
||||
"r"],2.5):0,gd=c(["point","focus","line","enabled"],!0),pc=c(["point","focus","expand","enabled"],!0),qc=c(["point","focus","expand","r"],pc?4:Ab),La=c(["point","focus","select","r"],8),hd=c(["point","onclick"],function(){}),Vc=c(["point","onselected"],function(){}),Wc=c(["point","onunselected"],function(){}),L=c(["regions"],[]),rc=c(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+J()(a[0].x)+"</th></tr>",d,c,e;for(d=0;d<a.length;d++)n(a[d])?(c=n(a[d].value)? |
||||
(Math.round(100*a[d].value)/100).toFixed(2):"-",e=a[d].name):e=c="-",b+="<tr class='-tooltip-name-"+a[d].id+"'><td class='name'><span style='background-color:"+W(a[d].id)+"'></span>"+e+"</td><td class='value'>"+c+"</td></tr>";return b+"</table>"}),jd=c(["tooltip","init","show"],!1),za=c(["tooltip","init","x"],0),tc=c(["tooltip","init","position"],{top:"0px",left:"50px"}),xb=ua.replace("#","")+"-clip",Na="url(#"+xb+")",z="timeseries"===wc,ca="categorized"===wc,ob=!z&&V,Cb=null,fb=!1,Bb=!1,la=ya?40: |
||||
0,oa=e.time.format(qd).parse,W=function(a,b){var d=[],c=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in a)return a[b];-1===d.indexOf(b)&&d.push(b);return c[d.indexOf(b)%c.length]}}(rd,sd),Fc=function(){var a=[[e.time.format("%Y/%-m/%-d"),function(){return!0}],[e.time.format("%-m/%-d"),function(a){return a.getMonth()}],[e.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[e.time.format("%-m/%-d"),function(a){return a.getDay()&& |
||||
1!==a.getDate()}],[e.time.format("%I %p"),function(a){return a.getHours()}],[e.time.format("%I:%M"),function(a){return a.getMinutes()}],[e.time.format(":%S"),function(a){return a.getSeconds()}],[e.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var d=a.length-1,c=a[d];!c[1](b);)c=a[--d];return c[0](b)}}(),Ib,Pb,Kb,Va,Ob,Qb,p,t,ma,ib,ta,Sb,Tb,lb,mb,l,y,T,ba,Wa,Xa,B,na,Ya,Da,Ac=f?"left":"bottom",Bc=f?kb?"top":"bottom":kb?"right":"left",Cc=f?jb?"bottom":"top":jb?"left": |
||||
"right",Dc="bottom",K={main:function(){return"translate("+A+","+s+")"},context:function(){return"translate("+m+","+Aa+")"},legend:function(){return"translate("+Gb+","+Fb+")"},y2:function(){return"translate("+(f?0:p)+","+(f?10:0)+")"},x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+ma+")"}},md=function(){var a=e.svg.line().x(f?function(a){return E(a.id)(a.value)}:cb).y(f?cb:function(a){return E(a.id)(a.value)});return function(b){var d=lc(b.values),c;if(ub(b))return"spline"=== |
||||
fa["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),vc[b.id]?Yc(d,l,E(b.id),vc[b.id]):a(d);c=l(d[0].x);b=E(b.id)(d[0].value);return f?"M "+b+" "+c:"M "+c+" "+b}}(),nd=function(){var a=e.svg.line().x(function(a){return ba(a.x)}).y(function(a){return R(a.id)(a.value)});return function(b){var d=lc(b.values);return ub(b)?a(d):"M "+ba(d[0].x)+" "+R(b.id)(d[0].value)}}(),G=e.svg.brush().on("brush",function(){C({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}), |
||||
H=e.behavior.zoom().on("zoomstart",function(){H.altDomain=e.event.sourceEvent.altKey?l.orgDomain():null}).on("zoom",pa?od:null);G.update=function(){x&&x.select(".x.brush").call(this);return this};H.orgScaleExtent=function(){var a=uc?uc:[1,10];return[a[0],Math.max(va()/a[1],a[1])]};H.updateScaleExtent=function(){var a=l.orgDomain(),a=(a[1]-a[0])/(U[1]-U[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var Ma,eb,h,x,xa,X,db,bb=null,pb=null,U;g.focus=function(a){g.defocus(); |
||||
e.selectAll(Ra(a)).filter(function(a){return rb(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};g.defocus=function(a){e.selectAll(Ra(a)).filter(function(a){return rb(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};g.revert=function(a){e.selectAll(Ra(a)).filter(function(a){return rb(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};g.show=function(a){e.selectAll(Ra(a)).transition().style("opacity",1)};g.hide=function(a){e.selectAll(Ra(a)).transition().style("opacity", |
||||
0)};g.unzoom=function(){G.clear().update();C({withUpdateXDomain:!0})};g.load=function(a){r(a.done)&&(a.done=function(){});"categories"in a&&ca&&(Ea=a.categories,B.categories(Ea));if("cacheIds"in a&&Sa(a.cacheIds))Pa(Ta(a.cacheIds),a.done);else if("data"in a)Pa(Ja(a.data),a.done);else if("url"in a)e.csv(a.url,function(b,d){Pa(Ja(d),a.done)});else if("rows"in a)Pa(Ja(Wb(a.rows)),a.done);else if("columns"in a)Pa(Ja(Xb(a.columns)),a.done);else throw Error("url or rows or columns is required.");};g.unload= |
||||
function(a){g.data.targets=g.data.targets.filter(function(b){return b.id!==a});e.selectAll(".target-"+a).transition().style("opacity",0).remove();ya&&(e.selectAll(".legend-item-"+a).remove(),gb(g.data.targets));0<g.data.targets.length&&C()};g.selected=function(a){a=n(a)?"-"+a:"";return e.merge(h.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return e.select(this).classed(ia)}).map(function(a){return a.map(function(a){return a.__data__})}))};g.select=function(a,b,c){ga&&h.selectAll(".-shapes").selectAll(".-shape").each(function(f, |
||||
g){var h="circle"===this.nodeName?hc:Xc,l="circle"===this.nodeName?vb:jc;0<=b.indexOf(g)?ra(f)&&(qa||r(a)||0<=a.indexOf(f.id))&&h(e.select(this).classed(ia,!0),f,g):n(c)&&c&&l(e.select(this).classed(ia,!1),f,g)})};g.unselect=function(a,b){ga&&h.selectAll(".-shapes").selectAll(".-shape").each(function(c,f){var g="circle"===this.nodeName?vb:jc;(r(b)||0<=b.indexOf(f))&&ra(c)&&(qa||r(a)||0<=a.indexOf(c.id))&&g(e.select(this).classed(ia,!1),c,f)})};g.toLine=function(a){tb(a,"line");C()};g.toSpline=function(a){tb(a, |
||||
"spline");C()};g.toBar=function(a){tb(a,"bar");C()};g.groups=function(a){if(r(a))return w;w=a;C();return w};g.regions=function(a){if(r(a))return L;L=a;C();return L};g.regions.add=function(a){if(r(a))return L;L=L.concat(a);C();return L};g.regions.remove=function(a,b){var c=[].concat(a);b=n(b)?b:{};c.forEach(function(a){var c=e.selectAll("."+a);n(b.duration)&&(c=c.transition().duration(b.duration).style("fill-opacity",0));c.remove();L=L.filter(function(b){return 0>b.classes.indexOf(a)})});return L}; |
||||
g.data.get=function(a){a=g.data.getAsTarget(a);return n(a)?a.values.map(function(a){return a.value}):void 0};g.data.getAsTarget=function(a){var b=$a(function(b){return b.id===a});return 0<b.length?b[0]:void 0};g.destroy=function(){g.data.targets=void 0;g.data.x=void 0;db.html("");O.onresize=null};if("url"in Y.data)e.csv(Y.data.url,function(a,b){wb(b)});else if("rows"in Y.data)wb(Wb(Y.data.rows));else if("columns"in Y.data)wb(Xb(Y.data.columns));else throw Error("url or rows or columns is required."); |
||||
return g}})(window); |
||||
(function(Q){function Kc(){function n(c,e){c.attr("transform",function(c){return"translate("+(e(c)+aa)+", 0)"})}function s(c,e){c.attr("transform",function(c){return"translate(0,"+e(c)+")"})}function Q(c){var e=c[0];c=c[c.length-1];return e<c?[e,c]:[c,e]}function Ca(c){for(var e=[],n=Math.ceil(c[0]);n<c[1];n++)e.push(n);0<e.length&&0<e[0]&&e.unshift(e[0]-(e[1]-e[0]));return e}function Da(c){c=c<R.length?R[c]:c;return S?S(c):c}function l(l){l.each(function(){var l=c.select(this),ka=Ca(r.domain()), |
||||
H=l.selectAll(".tick.major").data(ka,String),D=H.enter().insert("g","path").attr("class","tick major").style("opacity",1E-6),E=c.transition(H.exit()).style("opacity",1E-6).remove(),T=c.transition(H).style("opacity",1),M,N=r.rangeExtent?r.rangeExtent():Q(r.range()),l=l.selectAll(".domain").data([0]);l.enter().append("path").attr("class","domain");var l=c.transition(l),I=r.copy(),S=this.__chart__||I;this.__chart__=I;D.append("line");D.append("text");var R=D.select("line"),la=T.select("line"),ba=H.select("text"), |
||||
Va=D.select("text"),Wa=T.select("text");aa=(I(1)-I(0))/2;H=ua?0:aa;switch(ca){case "bottom":M=n;R.attr("y2",F);Va.attr("y",Math.max(F,0)+e);la.attr("x1",H).attr("x2",H).attr("y2",F);Wa.attr("x",0).attr("y",Math.max(F,0)+e);ba.attr("dy",".71em").style("text-anchor","middle");ba.text(function(c){return ka.length<U||0===c%Math.ceil(ka.length/U)?Da(c):""});l.attr("d","M"+N[0]+","+y+"V0H"+N[1]+"V"+y);break;case "left":M=s,R.attr("x2",-F),Va.attr("x",-(Math.max(F,0)+e)),la.attr("x2",-F).attr("y2",0),Wa.attr("x", |
||||
-(Math.max(F,0)+e)).attr("y",aa),ba.attr("dy",".32em").style("text-anchor","end"),ba.text(function(c){return ka.length<U||0===c%Math.ceil(ka.length/U)?Da(c):""}),l.attr("d","M"+-y+","+N[0]+"H0V"+N[1]+"H"+-y)}if(r.ticks)D.call(M,S),T.call(M,I),E.call(M,I);else{var Ea=I.rangeBand()/2,E=function(c){return I(c)+Ea};D.call(M,E);T.call(M,E)}})}var r=c.scale.linear(),ca="bottom",F=6,y=6,e=3,ua=!1,U=10,aa=0,S=null,R=[];l.scale=function(c){if(!arguments.length)return r;r=c;return l};l.orient=function(c){if(!arguments.length)return ca; |
||||
ca=c in{top:1,right:1,bottom:1,left:1}?c+"":"bottom";return l};l.categories=function(c){if(!arguments.length)return R;R=c;return l};l.tickCentered=function(c){if(!arguments.length)return ua;ua=c;return l};l.tickTextNum=function(c){if(!arguments.length)return U;U=c;return l};l.tickFormat=function(c){if(!arguments.length)return S;S=c;return l};l.tickOffset=function(){return aa};l.ticks=function(){};return l}function s(c){return"undefined"===typeof c}function n(c){return"undefined"!==typeof c}var mb= |
||||
Q.c3={},c=Q.d3;mb.generate=function($){var Kb,Lb,Ca,Da,l,r,ca,F,y;function e(a,b){for(var d=$,f=0;f<a.length;f++){if(!(a[f]in d))return b;d=d[a[f]]}return d}function ua(){nb=null===Xa?aa():Xa;va=U();Nb=20+Ob+ma;Pb=Qb?Qb:Rb?ob||g?1:40:20;Ya=Sb?Sb:pb?1:40;Tb=va-Ob-ma;Ub=20+ma;Vb=va-ma;r=0;ca=Pb;F=Nb;y=Ya;Ca=Tb;Da=Ub;l=Ya;Kb=Vb;Lb=Ya;q=nb-y-ca;p=va-r-F;na=va-Ca-Da}function U(){var a=null===Wb?+c.select(wa).style("height").replace("px",""):Wb;return 0<a?a:320}function aa(){return+c.select(wa).style("width").replace("px", |
||||
"")}function S(){return q+2+y+ca}function R(){return 40}function ka(){return y+20}function mb(){return p-r+42}function Jb(){Xb=g?10:0;Yb=g?p:q;qb=g?0:p;rb=g?q:1;m=H(Xb,Yb,n(m)?m.domain():void 0,function(){return z.tickOffset()});u=D(qb,rb,n(u)?u.domain():void 0);V=D(qb,rb,n(V)?V.domain():void 0);da=H(0,q,n(W)?W:void 0,function(a){return 0===a%1?Fa.tickOffset():0});Za=D(na,10);$a=D(na,10);z=M(m,Nc);oa=c.svg.axis().scale(u).orient(Oc);ab=c.svg.axis().scale(V).orient(Pc);Fa=M(da,Qc)}function H(a,b,d, |
||||
f){var O=(A?c.time.scale():c.scale.linear()).range([a,b]);O.orgDomain=function(){return O.domain()};n(d)&&O.domain(d);s(f)&&(f=function(){return 0});if(ea){var P=O,e,O=function(a){return P(a)+f(a)};for(e in P)O[e]=P[e];O.orgDomain=function(){return P.domain()};O.domain=function(a){if(!arguments.length)return a=P.domain(),[a[0],a[1]+1];P.domain(a);return O}}return O}function D(a,b){return c.scale.linear().range([a,b])}function E(a){return"y2"===N(a)?V:u}function T(a){return"y2"===N(a)?$a:Za}function M(a, |
||||
b){var d=(ea?Kc():c.svg.axis()).scale(a).orient(b);d.tickFormat(I());ea?d.categories(Ga).tickCentered(Rc):d.tickOffset=function(){return 0};return d}function N(a){return a in Zb?Zb[a]:"y"}function I(){var a=A?Sc:ea?Tc:function(a){return a};bb&&(a="function"===typeof bb?bb:A?function(a){return c.time.format(bb)(a)}:a);return a}function Lc(a){return c.min(a,function(a){return c.min(a.values,function(a){return a.value})})}function Mc(a){var b={},d,f;a.forEach(function(a){b[a.id]=[];a.values.forEach(function(d){b[a.id].push(d.value)})}); |
||||
for(d=0;d<t.length;d++)for(f=1;f<t[d].length;f++)Ha(t[d][f])&&(s(b[t[d][f]])||b[t[d][f]].forEach(function(a,c){N(t[d][f])===N(t[d][0])&&(b[t[d][0]][c]+=1*a)}));return c.max(Object.keys(b).map(function(a){return c.max(b[a])}))}function la(a){var b=cb(function(b){return N(b.id)===a}),d="y2"===a?Uc:Vc,f="y2"===a?Wc:Xc,d=null!==d?d:Lc(b),f=null!==f?f:Mc(b),c=0.1*Math.abs(f-d),P=c,e=c,g="y2"===a?Yc:Zc;null!==g&&(d=Math.max(Math.abs(d),Math.abs(f)),f=d-g,d=g-d);"y"===a&&null!==Ia&&(P=n(Ia.top)?Ia.top:c, |
||||
e=n(Ia.bottom)?Ia.bottom:c);"y2"===a&&null!==Ja&&(P=n(Ja.top)?Ja.top:c,e=n(Ja.bottom)?Ja.bottom:c);return[$c(b,"bar")?0:d-e,f+P]}function ba(a){var b;a?(a=m.domain(),b=G.extent()):(a=W,b=m.domain());return(a[1]-a[0])/(b[1]-b[0])}function Va(a){for(var b=0;b<a.length;b++)if(!(a[b]in db))return!1;return!0}function Wa(a){for(var b=[],d=0;d<a.length;d++)a[d]in db&&b.push($b(db[a[d]]));return b}function Ea(a){return"start"in a?m(A?pa(a.start):a.start):0}function Mb(a){var b=Ea(a);a=("end"in a?m(A?pa(a.end): |
||||
a.end):q)-b;return 0>a?0:a}function ac(a){return qa&&a===qa||X&&ad(X,a)}function bd(a){return!ac(a)}function eb(a){var b=Ka[a.id];a.name=n(b)?b:a.id;return a}function bc(a){var b=a[0],d={},f=[],c,e;for(c=1;c<a.length;c++){d={};for(e=0;e<a[c].length;e++)d[b[e]]=a[c][e];f.push(d)}return f}function cc(a){var b=[],d,f,c;for(d=0;d<a.length;d++)for(c=a[d][0],f=1;f<a[d].length;f++)s(b[f-1])&&(b[f-1]={}),b[f-1][c]=a[d][f];return b}function La(a){var b=c.keys(a[0]).filter(bd),d=c.keys(a[0]).filter(ac);if(A&& |
||||
0===d.length)return Q.alert('data.x or data.xs must be specified when axis.x.type == "timeseries"'),[];sb&&b.forEach(function(b){var c=qa?qa:X?X[b]:null;0<=d.indexOf(c)&&(h.data.x[b]=a.map(function(a){return a[c]}))});b=b.map(function(b){var d=cd(b);return{id:d,id_org:b,values:a.map(function(a,c){var e;e=qa?qa:X?X[b]:null;e=A?pa(a[e]):sb?a[e]?a[e]:h.data.x[b][c]:c;if(e<xa||null===xa)xa=e;Ma<e&&(Ma=e);a.x=e;return{x:e,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d,index:c}})}});b.forEach(function(a){db[a.id_org]= |
||||
$b(a)});return b}function $b(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function Na(){return c.max(h.data.targets,function(a){return a.values.length})}function tb(a){a=s(a)?h.data.targets:a;return a.map(function(a){return a.id})}function ub(a){var b=tb(),d;for(d=0;d<b.length;d++)if(b[d]===a)return!0;return!1}function cb(a){return n(a)?h.data.targets.filter(a):h.data.targets}function Tc(a){return a<Ga.length?Ga[a]:a}function vb(a){return"-shapes -shapes-"+ |
||||
a.id}function dc(a){return vb(a)+" -line -line-"+a.id}function dd(a){return vb(a)+" -circles -circles-"+a.id}function ec(a){return vb(a)+" -bars -bars-"+a.id}function ed(a,b){return"-shape -shape-"+b+" -circle -circle-"+b}function fc(a,b){return"-shape -shape-"+b+" -bar -bar-"+b}function fd(a,b){return"region region-"+b+" "+("classes"in a?[].concat(a.classes).join(" "):"")}function fb(a){return m(a.x)}function Oa(a){return m(A?pa(a.value):a.value)}function gc(a){return u(a.value)}function hc(a,b, |
||||
d,f){d=d?d:0;f=f?f:a.length-1;var c=Math.floor((f-d)/2)+d;0<m(a[c].x)-b[0]?f=c:d=c;if(1===f-d){if(!a[d].x)return a[f];if(!a[f].x)return a[d];c=Math.pow(b[0]-m(a[d].x),2)+Math.pow(b[1]-u(a[d].value),2);b=Math.pow(b[0]-m(a[f].x),2)+Math.pow(b[1]-u(a[f].value),2);return c<b?a[d]:a[f]}return hc(a,b,d,f)}function ic(a,b){var d,f;a.map(function(a){return hc(a.values,b)}).forEach(function(a){var c=Math.pow(m(a.x)-b[0],2)+Math.pow(u(a.value)-b[1],2);if(c<f||!f)f=c,d=a});return d}function jc(a,b){Y.html(kc(a)).style("visibility", |
||||
"hidden").style("display","block");var d=Y.property("offsetWidth"),f=Y.property("offsetHeight");Y.style("top",(b[1]+15+f<U()?b[1]+15:b[1]-f)+"px").style("left",g?b[0]:m(a[0].x)+60+d<(null===Xa?aa():Xa)?m(a[0].x)+60+"px":m(a[0].x)-d+30+"px").style("visibility","visible")}function lc(a){k.selectAll("line.xgrid-focus").style("visibility","visible").data([a]).attr(g?"y1":"x1",fb).attr(g?"y2":"x2",fb)}function fa(a){return a.x||0===a.x?m(a.x):null}function ga(a){return E(a.id)(a.value)}function gd(){var a= |
||||
{},b=0,d,f;cb(Ha).forEach(function(c){for(d=0;d<t.length;d++)if(!(0>t[d].indexOf(c.id)))for(f=0;f<t[d].length;f++)if(t[d][f]in a){a[c.id]=a[t[d][f]];break}s(a[c.id])&&(a[c.id]=b++)});a.__max__=b-1;return a}function mc(a,b,d,f){var c=f?da:m;return function(f){var e=f.id in d?d[f.id]:0;return c(f.x)-a*(b/2-e)}}function nc(a,b,d,f){var c=Object.keys(b);return function(e,g){var h=0,k=f?T(e.id):E(e.id);cb(Ha).forEach(function(d){d.id!==e.id&&b[d.id]===b[e.id]&&c.indexOf(d.id)<c.indexOf(e.id)&&(h+=a(d.values[g]))}); |
||||
return d?h:k(e.value)-h}}function oc(a,b){var d=null===a?function(a){return a}:function(b){return a-b};return function(a){var c=b?T(a.id):E(a.id);return d(c(a.value))}}function wb(a,b){var d=s(a)?tb():a;"string"===typeof d&&(d=[d]);for(var f=0;f<d.length;f++)ha[d[f]]=b}function $c(a,b){var d=!1;a.forEach(function(a){ha[a.id]===b&&(d=!0);a.id in ha||"line"!==b||(d=!0)});return d}function xb(a){a="string"===typeof a?a:a.id;return!(a in ha)||"line"===ha[a]||"spline"===ha[a]}function Ha(a){return"bar"=== |
||||
ha["string"===typeof a?a:a.id]}function hd(a){return xb(a)?a.values:[]}function pc(a){return Ha(a)?a.values:[]}function pa(a){var b;if(!a)throw Error(a+" can not be parsed as d3.time with format "+yb+". Maybe 'x' of this data is not defined. See data.x or data.xs option.");b=c.time.format(yb).parse(a);if(!b)throw Error("Failed to parse '"+a+"' with format "+yb);return b}function qc(a,b){var d=c.mouse(a),f=c.select(a),e=1*f.attr("cx"),f=1*f.attr("cy");return Math.sqrt(Math.pow(e-d[0],2)+Math.pow(f- |
||||
d[1],2))<b}function rc(a){var b=c.mouse(a),d=c.select(a);a=1*d.attr("x");var f=1*d.attr("y"),d=1*d.attr("width");return a-10<b[0]&&b[0]<a+d+10&&f-10<b[1]}function id(a,b){var d;for(d=0;d<b.length;d++)if(b[d].start<a&&a<=b[d].end)return!0;return!1}function ad(a,b){var d=!1;Object.keys(a).forEach(function(f){a[f]===b&&(d=!0)});return d}function sc(a,b){return Math.pow(m(a.x)-b[0],2)+Math.pow(u(a.value)-b[1],2)}function tc(a,b,d){jd(a,b);k.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+ |
||||
d).data([b]).enter().append("circle").attr("class",function(){return"selected-circle selected-circle-"+d}).attr("cx",g?ga:fa).attr("cy",g?fa:ga).attr("stroke",function(){return Z(b.id)}).attr("r",1.4*Pa).transition().duration(100).attr("r",Pa)}function zb(a,b,d){kd(a,b);k.select(".selected-circles-"+b.id).selectAll(".selected-circle-"+d).transition().duration(100).attr("r",0).remove()}function uc(a,b,d,f){a?tc(b,d,f):zb(b,d,f)}function ld(){}function vc(){}function wc(a,b,d,f){}function xc(a){return a.filter(function(a){return null!== |
||||
a.value})}function md(a,b,d,f){var c,e,h="M",k,m,l,yc,q,p=[];if(n(f))for(c=0;c<f.length;c++)p[c]={},s(f[c].start)?p[c].start=a[0].x:p[c].start=A?pa(f[c].start):f[c].start,s(f[c].end)?p[c].end=a[a.length-1].x:p[c].end=A?pa(f[c].end):f[c].end;yc=g?function(a){return d(a.value)}:function(a){return b(a.x)};q=g?function(a){return b(a.x)}:function(a){return d(a.value)};f=A?function(a,c,f,e){var g=a.x.getTime();a=c.x-a.x;c=new Date(g+a*(f+e));return"M"+b(new Date(g+a*f))+" "+d(m(f))+" "+b(c)+" "+d(m(f+e))}: |
||||
function(a,c,f,e){return"M"+b(k(f))+" "+d(m(f))+" "+b(k(f+e))+" "+d(m(f+e))};for(c=0;c<a.length;c++)if(s(p)||!id(a[c].x,p))h+=" "+yc(a[c])+" "+q(a[c]);else{k=H(a[c-1].x,a[c].x);m=D(a[c-1].value,a[c].value);e=b(a[c].x)-b(a[c-1].x);l=d(a[c].value)-d(a[c-1].value);e=Math.sqrt(Math.pow(e,2)+Math.pow(l,2));l=2/e;var r=2*l;for(e=l;1>=e;e+=r)h+=f(a[c-1],a[c],e,l)}return h}function Ab(a){var b,d;gb=c.select(wa);if(gb.empty())Q.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); |
||||
else{gb.html("");h.data.x={};h.data.targets=La(a);ua();Jb();m.domain(c.extent([xa,Ma]));u.domain(la("y"));V.domain(la("y2"));da.domain(m.domain());Za.domain(u.domain());$a.domain(V.domain());z.ticks(10>a.length?a.length:10);oa.ticks(nd).outerTickSize(0).tickFormat(od);ab.ticks(pd).outerTickSize(0).tickFormat(qd);W=m.domain();G.x(da);ra&&B.x(m);Qa=c.select(wa).append("svg").attr("width",q+y+ca).attr("height",p+r+F).on("mouseenter",rd).on("mouseleave",sd);hb=Qa.append("defs");hb.append("clipPath").attr("id", |
||||
Bb).append("rect").attr("y",r).attr("width",q).attr("height",p-r);hb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-y).attr("y",-20).attr("width",S).attr("height",R);hb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-y+1).attr("y",r-1).attr("width",ka).attr("height",mb);k=Qa.append("g").attr("transform",J.main);v=ya?Qa.append("g").attr("transform",J.context):null;za=Aa?Qa.append("g").attr("transform",J.legend):null;Y=c.select(wa).style("position","relative").append("div").style("position", |
||||
"absolute").style("z-index","10").style("display","none");k.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",J.x).call(g?oa:z).append("text").attr("class","-axis-x-label").attr("x",q).attr("dy","-.5em").style("text-anchor","end").text(td);k.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?z:oa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(ud);Rb&& |
||||
k.append("g").attr("class","y2 axis").attr("transform",J.y2).call(ab);b=k.append("g").attr("clip-path",Ra).attr("class","grid");zc&&b.append("g").attr("class","xgrids");Cb&&(d=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Cb).enter().append("g").attr("class","xgrid-line"),d.append("line").attr("class",function(a){return""+a["class"]}),d.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g? |
||||
0:-r).attr("dy",-6).text(function(a){return a.text}));vd&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?q:-10).attr("y1",g?-10:r).attr("y2",g?-10:p);Ac&&b.append("g").attr("class","ygrids");Db&&b.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Db).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Ra).attr("class","regions");k.append("g").attr("clip-path", |
||||
Ra).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ra?"ew-resize":null);X?wd(b):xd(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");if(ra)k.insert("rect",yd?null:"g.grid").attr("class","zoom-rect").attr("width",q).attr("height",p).style("opacity",0).style("cursor","ew-resize").call(B).on("dblclick.zoom",null);null!==ib&&G.extent("function"!==typeof ib? |
||||
ib:ib(xa,Ma));ya&&(v.append("g").attr("clip-path",Ra).attr("class","chart"),v.select(".chart").append("g").attr("class","chart-bars"),v.select(".chart").append("g").attr("class","chart-lines"),v.append("g").attr("clip-path",Ra).attr("class","x brush").call(G).selectAll("rect").attr("height",na),v.append("g").attr("class","x axis").attr("transform",J.subx).call(Fa));Aa&&jb(h.data.targets);Bc(h.data.targets);C({withTransition:!1,withUpdateXDomain:!0});if(zd){if(A&&"string"===typeof Ba){Ba=pa(Ba);for(a= |
||||
0;a<h.data.targets[0].values.length&&0!==h.data.targets[0].values[a].x-Ba;a++);Ba=a}Y.html(kc(h.data.targets.map(function(a){return eb(a.values[Ba])})));Y.style("top",Cc.top).style("left",Cc.left).style("display","block")}null==Q.onresize&&(Q.onresize=Ad)}}function xd(a,b){a.selectAll(".event-rects").data(b).enter().append("rect").attr("class",function(a,b){return"event-rect event-rect-"+b}).style("cursor",ia&&sa?"pointer":null).on("mouseover",function(a,b){if(!kb){var c=h.data.targets.map(function(a){return eb(a.values[b])}), |
||||
e,g;if(0<Object.keys(Ka).length){g=[];for(var m in Ka)for(e=0;e<c.length;e++)if(c[e].id===m){g.push(c[e]);c.shift(e);break}c=g.concat(c)}Eb&&k.selectAll(".-circle-"+b).classed(K,!0).attr("r",Fb);k.selectAll(".-bar-"+b).classed(K,!0);lc(c[0])}}).on("mouseout",function(a,b){k.select("line.xgrid-focus").style("visibility","hidden");Y.style("display","none");k.selectAll(".-circle-"+b).filter(function(){return c.select(this).classed(K)}).classed(K,!1).attr("r",lb);k.selectAll(".-bar-"+b).classed(K,!1)}).on("mousemove", |
||||
function(a,b){var e;kb||(e=h.data.targets.map(function(a){return eb(a.values[b])}),jc(e,c.mouse(this)),ia&&(sa||k.selectAll(".-shape-"+b).filter(function(a){return ta(a)}).each(function(){var a=c.select(this).classed(K,!0);"circle"===this.nodeName&&a.attr("r",Fb);c.select(".event-rect-"+b).style("cursor",null)}).filter(function(){var a=c.select(this);if("circle"===this.nodeName)return qc(this,Pa);if("rect"===this.nodeName)return rc(this,a.attr("x"),a.attr("y"))}).each(function(){var a=c.select(this); |
||||
a.classed(K)||(a.classed(K,!0),"circle"===this.nodeName&&a.attr("r",Pa));c.select(".event-rect-"+b).style("cursor","pointer")})))}).on("click",function(a,b){Gb?Gb=!1:k.selectAll(".-shape-"+b).each(function(a){Dc(this,a,b)})}).call(c.behavior.drag().origin(Object).on("drag",function(){Ec(c.mouse(this))}).on("dragstart",function(){Fc(c.mouse(this))}).on("dragend",function(){Gc()})).call(B).on("dblclick.zoom",null)}function wd(a){a.append("rect").attr("x",0).attr("y",0).attr("width",q).attr("height", |
||||
p).attr("class","event-rect").on("mousemove",function(){var a=c.mouse(this),d=ic(h.data.targets,a),f=[eb(d)];jc(f,a);Eb&&(k.selectAll(".-circle").filter(function(){return c.select(this).classed(K)}).classed(K,!1).attr("r",lb),k.select(".-circles-"+d.id).select(".-circle-"+d.index).classed(K,!0).attr("r",Fb));lc(f[0]);100>sc(d,a)?c.select(".event-rect").style("cursor","pointer"):c.select(".event-rect").style("cursor",null)}).on("click",function(){var a=c.mouse(this),d=ic(h.data.targets,a);100>sc(d, |
||||
a)&&k.select(".-circles-"+d.id).select(".-circle-"+d.index).each(function(){Dc(this,d,d.index)})}).call(c.behavior.drag().origin(Object).on("drag",function(){Ec(c.mouse(this))}).on("dragstart",function(){Fc(c.mouse(this))}).on("dragend",function(){Gc()})).call(B).on("dblclick.zoom",null)}function Dc(a,b,d){var f=c.select(a),e=f.classed(ja),g=!1,h;"circle"===a.nodeName?(g=qc(a,1.5*Pa),h=uc):"rect"===a.nodeName&&(g=rc(a),h=wc);if(sa||g)ia&&ta(b)&&(f.classed(ja,!e),h(!e,f,b,d)),Bd(b,f)}function Ec(a){if(ia&& |
||||
(!ra||B.altDomain)){var b=Hb[0],d=Hb[1],f=a[0];a=a[1];var e=Math.min(b,f),g=Math.max(b,f),h=sa?r:Math.min(d,a),m=sa?p:Math.max(d,a);k.select(".dragarea").attr("x",e).attr("y",h).attr("width",g-e).attr("height",m-h);k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ta(a)}).each(function(a,b){var d=c.select(this),f=d.classed(ja),k=d.classed(Ib),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*d.attr("cx"),n=1*d.attr("cy"),q=uc,l=e<l&&l<g&&h<n&&n<m):"rect"===this.nodeName&&(l=1*d.attr("x"), |
||||
n=1*d.attr("y"),p=1*d.attr("width"),q=wc,l=e<l+p&&l<g&&n<m);l^k&&(d.classed(Ib,!k),d.classed(ja,!f),q(!f,d,a,b))})}}function Fc(a){ia&&(Hb=a,k.select(".chart").append("rect").attr("class","dragarea").style("opacity",0.1),kb=!0)}function Gc(){ia&&(k.select(".dragarea").transition().duration(100).style("opacity",0).remove(),k.selectAll(".-shape").classed(Ib,!1),kb=!1)}function C(a){var b,d,f=gd(),e=f.__max__+1,l,x,s,t,w;a=n(a)?a:{};b=n(a.withY)?a.withY:!0;t=n(a.withSubchart)?a.withSubchart:!0;w=n(a.withTransition)? |
||||
a.withTransition:!0;a=n(a.withUpdateXDomain)?a.withUpdateXDomain:!1;w=w?250:0;a&&(m.domain(G.empty()?W:G.extent()),ra&&B.x(m).updateScaleExtent());u.domain(la("y"));V.domain(la("y2"));k.select(".x.axis").transition().duration(g?w:0).call(g?oa:z);k.select(".y.axis").transition().duration(g?0:w).call(g?z:oa);k.select(".y2.axis").transition().call(ab);k.select(".x.axis .-axis-x-label").attr("x",q);Za.domain(u.domain());$a.domain(V.domain());Y.style("display","none");k.select("line.xgrid-focus").style("visibility", |
||||
"hidden").attr("y2",p);if(zc){if("year"===Cd)for(a=[],x=xa.getFullYear(),l=Ma.getFullYear();x<=l;x++)a.push(new Date(x+"-01-01 00:00:00"));else a=m.ticks(10);a=k.select(".xgrids").selectAll(".xgrid").data(a);a.enter().append("line").attr("class","xgrid");a.attr("x1",g?0:function(a){return m(a)-z.tickOffset()}).attr("x2",g?q:function(a){return m(a)-z.tickOffset()}).attr("y1",g?function(a){return m(a)-z.tickOffset()}:r).attr("y2",g?function(a){return m(a)-z.tickOffset()}:p).style("opacity",function(){return+c.select(this).attr(g? |
||||
"y1":"x1")===(g?p:0)?0:1});a.exit().remove()}Cb&&(a=k.selectAll(".xgrid-lines"),a.selectAll("line").attr("x1",g?0:Oa).attr("x2",g?q:Oa).attr("y1",g?Oa:r).attr("y2",g?Oa:p),a.selectAll("text").attr("x",g?q:0).attr("y",Oa));b&&Ac&&(a=k.select(".ygrids").selectAll(".ygrid").data(u.ticks(10)),a.enter().append("line").attr("class","ygrid"),a.attr("x1",g?u:0).attr("x2",g?u:q).attr("y1",g?0:u).attr("y2",g?p:u),a.exit().remove());b&&Db&&k.select(".ygrid-lines").selectAll(".ygrid-line").attr("y1",gc).attr("y2", |
||||
gc);l=ea?1.2*z.tickOffset()/e:0.6*((g?p:q)*ba(!1)/(Na()-1));x=oc(g?null:p);b=mc(l,e,f);a=nc(x,f,g);d=k.selectAll(".-bars").selectAll(".-bar").data(pc);d.transition().duration(w).attr("x",g?a:b).attr("y",g?b:a).attr("width",g?x:l).attr("height",g?l:x);d.enter().append("rect").attr("class",fc).attr("x",g?a:b).attr("y",g?b:a).attr("width",g?x:l).attr("height",g?l:x).style("opacity",0).transition().duration(w).style("opacity",1);d.exit().transition().duration(w).style("opacity",0).remove();k.selectAll(".-line").transition().duration(w).attr("d", |
||||
Dd);b=k.selectAll(".-circles").selectAll(".-circle").data(hd);b.transition().duration(w).style("opacity",function(a){return null===a.value?0:1}).attr("cx",g?ga:fa).attr("cy",g?fa:ga);b.enter().append("circle").style("opacity",function(a){return null===a.value?0:1}).attr("class",ed).attr("cx",g?ga:fa).attr("cy",g?fa:ga).attr("r",lb);b.exit().remove();ya&&(null!==c.event&&"zoom"===c.event.type&&G.extent(m.orgDomain()).update(),t&&(v.select(".x.axis").transition().duration(g?w:0).call(g?oa:Fa),G.empty()|| |
||||
G.extent(m.orgDomain()).update(),l=ea?1.2*Fa.tickOffset()/e:0.6*((g?p:q)*ba(!0)/(Na()-1)),x=oc(na,!0),b=mc(l,e,f,!0),a=nc(x,f,!1,!0),f=v.selectAll(".-bars").selectAll(".-bar").data(pc),f.transition().duration(w).attr("x",b).attr("y",a).attr("width",l).attr("height",x),f.enter().append("rect").attr("class",fc).attr("x",b).attr("y",a).attr("width",l).attr("height",x).style("opacity",0).transition().style("opacity",1),f.exit().transition().style("opacity",0).remove(),v.selectAll(".-line").transition().duration(w).attr("d", |
||||
Ed)));k.selectAll(".selected-circles").filter(function(a){return Ha(a)}).selectAll("circle").remove();k.selectAll(".selected-circle").transition().duration(w).attr("cx",g?ga:fa).attr("cy",g?fa:ga);X||(sb?(s=function(a,b){var d=0<b?h.data.targets[0].values[b-1].x:void 0,c=b<Na()-1?h.data.targets[0].values[b+1].x:void 0;return(m(c?c:a.x+50)-m(d?d:a.x-50))/2},f=function(a,b){var d=0<b?h.data.targets[0].values[b-1].x:void 0;return(m(a.x)+m(d?d:a.x-50))/2}):(s=(g?p:q)*ba()/(Na()-1),f=function(a){return m(a.x)- |
||||
s/2}),k.selectAll(".event-rect").attr("x",g?0:f).attr("y",g?f:0).attr("width",g?q:s).attr("height",g?s:p));f=k.select(".regions").selectAll("rect.region").data(L);f.enter().append("rect");f.attr("class",fd).attr("x",g?0:Ea).attr("y",g?Ea:r).attr("width",g?q:Mb).attr("height",g?Mb:p).style("fill-opacity",function(a){return n(a.opacity)?a.opacity:0.1});f.exit().transition().duration(w).style("fill-opacity",0).remove()}function Fd(){"mousemove"===c.event.sourceEvent.type&&B.altDomain?(m.domain(B.altDomain), |
||||
B.x(m).updateScaleExtent()):(ea&&m.orgDomain()[0]===W[0]&&m.domain([W[0]-1E-10,m.orgDomain()[1]]),C({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===c.event.sourceEvent.type&&(Gb=!0))}function Ad(){ua();Jb();G.x(da);ra&&B.x(m);c.select("svg").attr("width",nb).attr("height",va);c.select("#"+Bb).select("rect").attr("width",q).attr("height",p);c.select("#xaxis-clip").select("rect").attr("width",S);c.select(".zoom-rect").attr("width",q).attr("height",p);k.select(".x.axis").attr("transform", |
||||
J.x);k.select(".y2.axis").attr("transform",J.y2);ya&&(v.select(".x.brush").selectAll("rect").attr("height",na),v.attr("transform",J.context),v.select(".x.axis").attr("transform",J.subx));Aa&&(za.attr("transform",J.legend),jb(h.data.targets,{withTransition:!1}));C({withTransition:!1,withUpdateXDomain:!0})}function Bc(a){var b;k.select(".chart-bars").selectAll(".chart-bar").data(a).enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("pointer-events","none").style("opacity", |
||||
0).append("g").attr("class",ec).style("fill",function(a){return Z(a.id)}).style("stroke",function(a){return Z(a.id)}).style("stroke-width",0).style("cursor",function(a){return ta(a)?"pointer":null});b=k.select(".chart-lines").selectAll(".chart-line").data(a).enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("pointer-events","none").style("opacity",0);b.append("path").attr("class",dc).style("stroke",function(a){return Z(a.id)});b.append("g").attr("class",function(a){return"selected-circles selected-circles-"+ |
||||
a.id});b.append("g").attr("class",dd).style("fill",function(a){return Z(a.id)}).style("cursor",function(a){return ta(a)?"pointer":null});a.forEach(function(a){k.selectAll(".selected-circles-"+a.id).selectAll(".selected-circle").each(function(b){b.value=a.values[b.x].value})});ya&&(b=v.select(".chart-bars").selectAll(".chart-bar").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-bar target target-"+a.id}).style("opacity",0),b.append("g").attr("class",ec).style("fill",function(a){return Z(a.id)}), |
||||
b=v.select(".chart-lines").selectAll(".chart-line").data(a),b=b.enter().append("g").attr("class",function(a){return"chart-line target target-"+a.id}).style("opacity",0),b.append("path").attr("class",dc).style("stroke",function(a){return Z(a.id)}));Aa&&jb(a);c.selectAll(".target").transition().style("opacity",1)}function Sa(a,b){h.data.targets.forEach(function(b){for(var c=0;c<a.length;c++)if(b.id===a[c].id){b.values=a[c].values;a.splice(c,1);break}});h.data.targets=h.data.targets.concat(a);Bc(h.data.targets); |
||||
C();b()}function jb(a,b){var d=tb(a),f,e=q/2-Ta*Object.keys(a).length/2,g;b=s(b)?{}:b;g=n(b.withTransition)?b.withTransition:!0;f=za.selectAll(".legend-item").data(d).enter().append("g").attr("class",function(a){return"legend-item legend-item-"+a}).style("cursor","pointer").on("click",function(a){Gd(a)}).on("mouseover",function(a){c.selectAll(".legend-item").filter(function(b){return b!==a}).transition().duration(100).style("opacity",0.3);h.focus(a)}).on("mouseout",function(){c.selectAll(".legend-item").transition().duration(100).style("opacity", |
||||
1);h.revert()});f.append("rect").attr("class","legend-item-event").style("fill-opacity",0).attr("x",-200).attr("y",function(){return ma/2-16}).attr("width",Ta).attr("height",24);f.append("rect").attr("class","legend-item-tile").style("fill",function(a){return Z(a)}).attr("x",-200).attr("y",function(){return ma/2-9}).attr("width",10).attr("height",10);f.append("text").text(function(a){return n(Ka[a])?Ka[a]:a}).attr("x",-200).attr("y",function(){return ma/2});za.selectAll("rect.legend-item-event").data(d).transition().duration(g? |
||||
250:0).attr("x",function(a,b){return e+Ta*b});za.selectAll("rect.legend-item-tile").data(d).transition().duration(g?250:0).attr("x",function(a,b){return e+Ta*b});za.selectAll("text").data(d).transition().duration(g?250:0).attr("x",function(a,b){return e+Ta*b+14})}function Ua(a){return n(a)?".target-"+a:".target"}var h={data:{}},db={},K="_expanded_",ja="_selected_",Ib="_included_",wa=e(["bindto"],"#chart"),Xa=e(["size","width"],null),Wb=e(["size","height"],null),Sb=e(["padding","left"],null),Qb=e(["padding", |
||||
"right"],null),ra=e(["zoom","enabled"],!1),Hc=e(["zoom","extent"],null),yd=e(["zoom","privileged"],!1),rd=e(["onenter"],function(){}),sd=e(["onleave"],function(){});if(!("data"in $))throw Error("data is required in config");var qa=e(["data","x"],null),X=e(["data","xs"],null),yb=e(["data","x_format"],"%Y-%m-%d"),cd=e(["data","id_converter"],function(a){return a}),Ka=e(["data","names"],{}),t=e(["data","groups"],[]),Zb=e(["data","axes"],{}),ha=e(["data","types"],{}),Ic=e(["data","regions"],{}),Hd=e(["data", |
||||
"colors"],{}),ia=e(["data","selection","enabled"],!1),sa=e(["data","selection","grouped"],!1),ta=e(["data","selection","isselectable"],function(){return!0}),ya=e(["subchart","show"],!1),Ob=ya?e(["subchart","size","height"],60):0,Id=e(["color","pattern"],null),Aa=e(["legend","show"],!0),Ta=e(["legend","item","width"],80),Gd=e(["legend","item","onclick"],function(){}),Jc=e(["axis","x","type"],"indexed"),Ga=e(["axis","x","categories"],[]),Rc=e(["axis","x","tick","centered"],!1),bb=e(["axis","x","tick", |
||||
"format"],null),ib=e(["axis","x","default"],null),td=e(["axis","x","label"],null),Xc=e(["axis","y","max"],null),Vc=e(["axis","y","min"],null),Zc=e(["axis","y","center"],null),ud=e(["axis","y","label"],null),pb=e(["axis","y","inner"],!1),od=e(["axis","y","format"],function(a){return a}),Ia=e(["axis","y","padding"],null),nd=e(["axis","y","ticks"],10),Rb=e(["axis","y2","show"],!1),Wc=e(["axis","y2","max"],null),Uc=e(["axis","y2","min"],null),Yc=e(["axis","y2","center"],null),ob=e(["axis","y2","inner"], |
||||
!1),qd=e(["axis","y2","format"],function(a){return a}),Ja=e(["axis","y2","padding"],null),pd=e(["axis","y2","ticks"],10),g=e(["axis","rotated"],!1),zc=e(["grid","x","show"],!1),Cd=e(["grid","x","type"],"tick"),Cb=e(["grid","x","lines"],null),Ac=e(["grid","y","show"],!1),Db=e(["grid","y","lines"],null),lb=e(["point","show"],!0)?e(["point","r"],2.5):0,vd=e(["point","focus","line","enabled"],!0),Eb=e(["point","focus","expand","enabled"],!0),Fb=e(["point","focus","expand","r"],Eb?4:lb),Pa=e(["point", |
||||
"focus","select","r"],8),Bd=e(["point","onclick"],function(){}),jd=e(["point","onselected"],function(){}),kd=e(["point","onunselected"],function(){}),L=e(["regions"],[]),kc=e(["tooltip","contents"],function(a){var b="<table class='-tooltip'><tr><th colspan='2'>"+I()(a[0].x)+"</th></tr>",c,e,g;for(c=0;c<a.length;c++)n(a[c])?(e=n(a[c].value)?(Math.round(100*a[c].value)/100).toFixed(2):"-",g=a[c].name):g=e="-",b+="<tr class='-tooltip-name-"+a[c].id+"'><td class='name'><span style='background-color:"+ |
||||
Z(a[c].id)+"'></span>"+g+"</td><td class='value'>"+e+"</td></tr>";return b+"</table>"}),zd=e(["tooltip","init","show"],!1),Ba=e(["tooltip","init","x"],0),Cc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Bb=wa.replace("#","")+"-clip",Ra="url(#"+Bb+")",A="timeseries"===Jc,ea="categorized"===Jc,sb=!A&&(qa||X),Hb=null,kb=!1,Gb=!1,ma=Aa?40:0,Z=function(a,b){var c=[],e=null!==b?b:"#1f77b4 #ff7f0e #2ca02c #d62728 #9467bd #8c564b #e377c2 #7f7f7f #bcbd22 #17becf".split(" ");return function(b){if(b in |
||||
a)return a[b];-1===c.indexOf(b)&&c.push(b);return e[c.indexOf(b)%e.length]}}(Hd,Id),Sc=function(){var a=[[c.time.format("%Y/%-m/%-d"),function(){return!0}],[c.time.format("%-m/%-d"),function(a){return a.getMonth()}],[c.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[c.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[c.time.format("%I %p"),function(a){return a.getHours()}],[c.time.format("%I:%M"),function(a){return a.getMinutes()}],[c.time.format(":%S"),function(a){return a.getSeconds()}], |
||||
[c.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}(),Nb,Ub,Pb,Ya,Tb,Vb,q,p,na,nb,va,Xb,Yb,qb,rb,m,u,V,da,Za,$a,z,oa,ab,Fa,Nc=g?"left":"bottom",Oc=g?pb?"top":"bottom":pb?"right":"left",Pc=g?ob?"bottom":"top":ob?"left":"right",Qc="bottom",J={main:function(){return"translate("+y+","+r+")"},context:function(){return"translate("+l+","+Ca+")"},legend:function(){return"translate("+Lb+","+Kb+")"},y2:function(){return"translate("+ |
||||
(g?0:q)+","+(g?10:0)+")"},x:function(){return"translate(0,"+p+")"},subx:function(){return"translate(0,"+na+")"}},Dd=function(){var a=c.svg.line().x(g?function(a){return E(a.id)(a.value)}:fb).y(g?fb:function(a){return E(a.id)(a.value)});return function(b){var c=xc(b.values),e;if(xb(b))return"spline"===ha["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),Ic[b.id]?md(c,m,E(b.id),Ic[b.id]):a(c);e=m(c[0].x);b=E(b.id)(c[0].value);return g?"M "+b+" "+e:"M "+e+" "+b}}(),Ed=function(){var a= |
||||
c.svg.line().x(function(a){return da(a.x)}).y(function(a){return T(a.id)(a.value)});return function(b){var c=xc(b.values);return xb(b)?a(c):"M "+da(c[0].x)+" "+T(b.id)(c[0].value)}}(),G=c.svg.brush().on("brush",function(){C({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),B=c.behavior.zoom().on("zoomstart",function(){B.altDomain=c.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",ra?Fd:null);G.update=function(){v&&v.select(".x.brush").call(this);return this};B.orgScaleExtent= |
||||
function(){var a=Hc?Hc:[1,10];return[a[0],Math.max(Na()/a[1],a[1])]};B.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(W[1]-W[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var Qa,hb,k,v,za,Y,gb,xa=null,Ma=null,W;h.focus=function(a){h.defocus();c.selectAll(Ua(a)).filter(function(a){return ub(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};h.defocus=function(a){c.selectAll(Ua(a)).filter(function(a){return ub(a.id)}).classed("focused", |
||||
!1).transition().duration(100).style("opacity",0.3)};h.revert=function(a){c.selectAll(Ua(a)).filter(function(a){return ub(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};h.show=function(a){c.selectAll(Ua(a)).transition().style("opacity",1)};h.hide=function(a){c.selectAll(Ua(a)).transition().style("opacity",0)};h.unzoom=function(){G.clear().update();C({withUpdateXDomain:!0})};h.load=function(a){s(a.done)&&(a.done=function(){});"categories"in a&&ea&&(Ga=a.categories,z.categories(Ga)); |
||||
if("cacheIds"in a&&Va(a.cacheIds))Sa(Wa(a.cacheIds),a.done);else if("data"in a)Sa(La(a.data),a.done);else if("url"in a)c.csv(a.url,function(b,c){Sa(La(c),a.done)});else if("rows"in a)Sa(La(bc(a.rows)),a.done);else if("columns"in a)Sa(La(cc(a.columns)),a.done);else throw Error("url or rows or columns is required.");};h.unload=function(a){h.data.targets=h.data.targets.filter(function(b){return b.id!==a});c.selectAll(".target-"+a).transition().style("opacity",0).remove();Aa&&(c.selectAll(".legend-item-"+ |
||||
a).remove(),jb(h.data.targets));0<h.data.targets.length&&C()};h.selected=function(a){a=n(a)?"-"+a:"";return c.merge(k.selectAll(".-shapes"+a).selectAll(".-shape").filter(function(){return c.select(this).classed(ja)}).map(function(a){return a.map(function(a){return a.__data__})}))};h.select=function(a,b,d){ia&&k.selectAll(".-shapes").selectAll(".-shape").each(function(e,g){var h="circle"===this.nodeName?tc:ld,k="circle"===this.nodeName?zb:vc;0<=b.indexOf(g)?ta(e)&&(sa||s(a)||0<=a.indexOf(e.id))&&h(c.select(this).classed(ja, |
||||
!0),e,g):n(d)&&d&&k(c.select(this).classed(ja,!1),e,g)})};h.unselect=function(a,b){ia&&k.selectAll(".-shapes").selectAll(".-shape").each(function(d,e){var g="circle"===this.nodeName?zb:vc;(s(b)||0<=b.indexOf(e))&&ta(d)&&(sa||s(a)||0<=a.indexOf(d.id))&&g(c.select(this).classed(ja,!1),d,e)})};h.toLine=function(a){wb(a,"line");C()};h.toSpline=function(a){wb(a,"spline");C()};h.toBar=function(a){wb(a,"bar");C()};h.groups=function(a){if(s(a))return t;t=a;C();return t};h.regions=function(a){if(s(a))return L; |
||||
L=a;C();return L};h.regions.add=function(a){if(s(a))return L;L=L.concat(a);C();return L};h.regions.remove=function(a,b){var d=[].concat(a);b=n(b)?b:{};d.forEach(function(a){var d=c.selectAll("."+a);n(b.duration)&&(d=d.transition().duration(b.duration).style("fill-opacity",0));d.remove();L=L.filter(function(b){return 0>b.classes.indexOf(a)})});return L};h.data.get=function(a){a=h.data.getAsTarget(a);return n(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b= |
||||
cb(function(b){return b.id===a});return 0<b.length?b[0]:void 0};h.destroy=function(){h.data.targets=void 0;h.data.x={};gb.html("");Q.onresize=null};if("url"in $.data)c.csv($.data.url,function(a,b){Ab(b)});else if("rows"in $.data)Ab(bc($.data.rows));else if("columns"in $.data)Ab(cc($.data.columns));else throw Error("url or rows or columns is required.");return h}})(window); |
||||
|
Loading…
Reference in new issue