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