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.

84 lines
41 KiB

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