Quite good looking graph derived from d3.js http://c3js.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

91 lines
45 KiB

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