Browse Source

Add interface to update categories

pull/4/head
Masayuki Tanaka 11 years ago
parent
commit
f1268f48c2
  1. 5
      c3.js
  2. 126
      c3.min.js

5
c3.js

@ -1789,6 +1789,11 @@
if (isUndefined(args.done)) {
args.done = function () {};
}
// update categories if exists
if ('categories' in args && isCategorized) {
__axis_x_categories = args.categories;
xAxis.categories(__axis_x_categories);
}
// use cache if exists
if ('cacheIds' in args && hasCaches(args.cacheIds)) {
load(getCaches(args.cacheIds), args.done);

126
c3.min.js vendored

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

Loading…
Cancel
Save