From d7a660dd14517e631c016fff35367fa42eaff997 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Thu, 13 Feb 2014 11:14:16 +0900 Subject: [PATCH] Fix unload when stacked bar chart --- c3.js | 4 +- c3.min.js | 164 +++++++++++++++++++++++++++--------------------------- 2 files changed, 84 insertions(+), 84 deletions(-) diff --git a/c3.js b/c3.js index 67a691d..896ee0d 100644 --- a/c3.js +++ b/c3.js @@ -458,8 +458,8 @@ if (! isBarType(__data_groups[j][k])) { continue; } if (isUndefined(ys[__data_groups[j][k]])) { continue; } ys[__data_groups[j][k]].forEach(function (v, i) { - if (getAxisId(__data_groups[j][k]) === getAxisId(__data_groups[j][0])) { - ys[__data_groups[j][0]][i] += v * 1; + if (getAxisId(__data_groups[j][k]) === getAxisId(__data_groups[j][0]) && ys[__data_groups[j][0]]) { + ys[__data_groups[j][0]][i] += +v; } }); } diff --git a/c3.min.js b/c3.min.js index 06d8013..44820f2 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,83 +1,83 @@ -(function(M){function id(){function p(d,e){d.attr("transform",function(d){return"translate("+(e(d)+ea)+", 0)"})}function u(d,e){d.attr("transform",function(d){return"translate(0,"+e(d)+")"})}function M(d){var e=d[0];d=d[d.length-1];return ea?0:a}function qc(a){return qa&&a===qa||ba&&Dd(ba,a)}function Ed(a){return!qc(a)}function nb(a){var b= -Oa[a.id];a.name=p(b)?b:a.id;return a}function rc(a){var b=a[0],c={},f=[],m,d;for(m=1;my[c].indexOf(m.id)))for(f=0;fb?a-b:0};return function(a){var d=b?Y(a.id):x(a.id);return c(d(a.value))}}function Ta(a,b){var c=u(a)?ob():a;"string"===typeof c&&(c=[c]);for(var f=0;f=e;e+=s)h+=f(a[d-1],a[d],e,n)}return h}function Mb(a){var b,c;pb=d.select(wa);if(pb.empty())M.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{pb.html(""); -h.data.x={};h.data.targets=Pa(a);ua();Xb();l.domain(d.extent(lb(h.data.targets)));z.domain(jb("y"));$.domain(jb("y2"));T.domain(l.domain());eb.domain(z.domain());fb.domain($.domain());H.ticks(10>a.length?a.length:10);oa.ticks(Sd).outerTickSize(0).tickFormat(Td);gb.ticks(Ud).outerTickSize(0).tickFormat(Vd);U=l.domain();I.x(T);ra&&E.x(l);q=d.select(wa).append("svg").attr("width",r+G+fa).attr("height",s+t+L).on("mouseenter",Wd).on("mouseleave",Xd);qb=q.append("defs");qb.append("clipPath").attr("id", -Nb).append("rect").attr("y",t).attr("width",r).attr("height",s-t);qb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-G).attr("y",-20).attr("width",X).attr("height",W);qb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-G+1).attr("y",t-1).attr("width",la).attr("height",tb);k=q.append("g").attr("transform",J.main);A=za?q.append("g").attr("transform",J.context):null;Aa=Ba?q.append("g").attr("transform",J.legend):null;V=d.select(wa).style("position","relative").append("div").style("position", -"absolute").style("z-index","10").style("display","none");k.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",J.x).call(g?oa:H).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text(Yd);k.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?H:oa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Zd);dc&& -k.append("g").attr("class","y2 axis").attr("transform",J.y2).call(gb);b=k.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",g?"":"rotate(-90)").attr("dx",g? -0:-t).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",g?0:-10).attr("x2",g?r:-10).attr("y1",g?-10:t).attr("y2",g?-10:s);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"]});k.append("g").attr("clip-path",Va).attr("class","regions");k.append("g").attr("clip-path", -Va).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ra?"ew-resize":null);ba?ae(b):be(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");k.select(".chart").append("g").attr("class","chart-arcs").attr("transform",J.arc);if(ra)k.insert("rect",ce?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",s).style("opacity",0).style("cursor","ew-resize").call(E).on("dblclick.zoom", -null);null!==rb&&I.extent("function"!==typeof rb?rb:rb(lb()));za&&(A.append("g").attr("clip-path",Va).attr("class","chart"),A.select(".chart").append("g").attr("class","chart-bars"),A.select(".chart").append("g").attr("class","chart-lines"),A.append("g").attr("clip-path",Va).attr("class","x brush").call(I).selectAll("rect").attr("height",na),A.append("g").attr("class","x axis").attr("transform",J.subx).call(Ia));Ba&&sb(h.data.targets);Xc(h.data.targets);F({withTransition:!1,withUpdateXDomain:!0}); -if(de){if(B&&"string"===typeof Ca){Ca=pa(Ca);for(a=0;aEb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;C(h.data.targets)||(a=d.mouse(this),c=Cc(h.data.targets, -a),100>Eb(c,a)&&k.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(E).on("dblclick.zoom",null)}function Zc(a,b,c){var f=d.select(a),e=f.classed(ka),h=!1,g;"circle"===a.nodeName?(h=Nc(a,1.5*Ua),g=Qc):"rect"===a.nodeName&&(h=Oc(a),g=Sc);if(sa||h)ia&&ja(b)&&(f.classed(ka,!e),g(!e,f,b,c)),ge(b,f)} -function $c(a){var b,c,f,e,g,l,n;C(h.data.targets)||!ia||ra&&!E.altDomain||(b=Tb[0],c=Tb[1],f=a[0],a=a[1],e=Math.min(b,f),g=Math.max(b,f),l=sa?t:Math.min(c,a),n=sa?s:Math.max(c,a),k.select(".dragarea").attr("x",e).attr("y",l).attr("width",g-e).attr("height",n-l),k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ja(a)}).each(function(a,b){var c=d.select(this),f=c.classed(ka),h=c.classed(Ub),k,p,r,q;k=!1;"circle"===this.nodeName?(k=1*c.attr("cx"),p=1*c.attr("cy"),q=Qc,k=e",c,d,e;for(c=0;c"+e+""+d+"";return b+""}),de=e(["tooltip","init","show"],!1),Ca=e(["tooltip","init","x"],0),Yc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Nb=wa.replace("#","")+"-clip",Va="url(#"+Nb+")",B="timeseries"===hd,aa="categorized"===hd,Db=!B&&(qa||ba),Tb=null,Wa=!1,Sb=!1,ma=Ba?40:0,P=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]}}(ne,oe),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,s,na,ub,va,db,xb,hb,lc,mc,Ab,jc,kc,yb,zb,l,z,$,T,eb,fb,H,oa,gb,Ia,ld=g?"left":"bottom",md=g?wb?"top":"bottom":wb?"right":"left",nd=g?vb?"bottom":"top":vb?"left":"right",od="bottom",J={main:function(){return"translate("+G+","+t+")"},context:function(){return"translate("+n+","+Da+")"},legend:function(){return"translate("+Zb+","+Yb+")"}, -y2:function(){return"translate("+(g?0:r)+","+(g?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+na+")"},arc:function(){return"translate("+r/2+","+s/2+")"}};Ab=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var ie=function(){var a=d.svg.line().x(g?function(a){return x(a.id)(a.value)}:ya).y(g?ya:function(a){return x(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,l,x(b.id),gd[b.id]):a(c);d=l(c[0].x);b=x(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),je=function(){var a;a=g?d.svg.area().x0(function(a){return x(a.id)(0)}).x1(function(a){return x(a.id)(a.value)}).y(ya):d.svg.area().x(ya).y0(function(a){return x(a.id)(0)}).y1(function(a){return x(a.id)(a.value)});return function(b){var c=Ib(b.values),d;if(Na([b],"area")||Na([b],"area-spline"))return Kc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d= -l(c[0].x);b=x(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),ke=function(){var a=d.svg.line().x(function(a){return T(a.x)}).y(function(a){return Y(a.id)(a.value)});return function(b){var c=Ib(b.values);return Fb(b)?a(c):"M "+T(c[0].x)+" "+Y(b.id)(c[0].value)}}(),I=d.svg.brush().on("brush",function(){F({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),E=d.behavior.zoom().on("zoomstart",function(){E.altDomain=d.event.sourceEvent.altKey?l.orgDomain():null}).on("zoom",ra? -le:null);I.update=function(){A&&A.select(".x.brush").call(this);return this};E.orgScaleExtent=function(){var a=fd?fd:[1,10];return[a[0],Math.max(Qa()/a[1],a[1])]};E.updateScaleExtent=function(){var a=l.orgDomain(),a=(a[1]-a[0])/(U[1]-U[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,qb,k,A,Aa,V,pb,U;h.focus=function(a){var b=q.selectAll(Za(a)),c=b.filter(Vb),b=b.filter(Wb);h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity", -1);C(h.data.targets)&&Ga(a,!0)};h.defocus=function(a){var b=q.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);C(h.data.targets)&&Ha(a)};h.revert=function(a){var b=q.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);C(h.data.targets)&&Ha(a)};h.show=function(a){q.selectAll(Za(a)).transition().style("opacity", -1)};h.hide=function(a){q.selectAll(Za(a)).transition().style("opacity",0)};h.unzoom=function(){I.clear().update();F({withUpdateXDomain:!0})};h.load=function(a){u(a.done)&&(a.done=function(){});"categories"in a&&aa&&(Ja=a.categories,H.categories(Ja));if("cacheIds"in a&&Bd(a.cacheIds))Xa(Cd(a.cacheIds),a.done);else if("data"in a)Xa(Pa(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Xa(Pa(c),a.done)});else if("rows"in a)Xa(Pa(rc(a.rows)),a.done);else if("columns"in a)Xa(Pa(sc(a.columns)), -a.done);else throw Error("url or rows or columns is required.");};h.unload=function(a){h.data.targets=h.data.targets.filter(function(b){return b.id!==a});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(q.selectAll(".legend-item-"+a).remove(),sb(h.data.targets));0b.classes.indexOf(a)})});return Q};h.data.get=function(a){a=h.data.getAsTarget(a);return p(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=kb(function(b){return b.id===a});return 0a?0:a}function pc(a){return pa&&a===pa||aa&&Cd(aa,a)}function Dd(a){return!pc(a)} +function mb(a){var b=Na[a.id];a.name=p(b)?b:a.id;return a}function qc(a){var b=a[0],c={},f=[],m,d;for(m=1;ms[c].indexOf(m.id)))for(f=0;fb?a-b:0};return function(a){var d=b?X(a.id):x(a.id);return c(d(a.value))}}function Sa(a,b){var c=v(a)?nb():a;"string"===typeof c&&(c=[c]);for(var f=0;f=e;e+=t)h+=f(a[d-1],a[d],e,n)}return h}function Lb(a){var b,c;ob=d.select(va);if(ob.empty())L.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); +else{ob.html("");h.data.x={};h.data.targets=Oa(a);ta();Wb();l.domain(d.extent(kb(h.data.targets)));y.domain(ib("y"));Z.domain(ib("y2"));S.domain(l.domain());db.domain(y.domain());eb.domain(Z.domain());G.ticks(10>a.length?a.length:10);na.ticks(Rd).outerTickSize(0).tickFormat(Sd);fb.ticks(Td).outerTickSize(0).tickFormat(Ud);T=l.domain();H.x(S);qa&&D.x(l);q=d.select(va).append("svg").attr("width",r+F+ea).attr("height",t+u+K).on("mouseenter",Vd).on("mouseleave",Wd);pb=q.append("defs");pb.append("clipPath").attr("id", +Mb).append("rect").attr("y",u).attr("width",r).attr("height",t-u);pb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-F).attr("y",-20).attr("width",W).attr("height",V);pb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-F+1).attr("y",u-1).attr("width",ka).attr("height",sb);k=q.append("g").attr("transform",I.main);z=ya?q.append("g").attr("transform",I.context):null;za=Aa?q.append("g").attr("transform",I.legend):null;U=d.select(va).style("position","relative").append("div").style("position", +"absolute").style("z-index","10").style("display","none");k.append("g").attr("class","x axis").attr("clip-path",g?"":"url(#xaxis-clip)").attr("transform",I.x).call(g?na:G).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text(Xd);k.append("g").attr("class","y axis").attr("clip-path",g?"url(#yaxis-clip)":"").call(g?G:na).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(Yd);cc&& +k.append("g").attr("class","y2 axis").attr("transform",I.y2).call(fb);b=k.append("g").attr("clip-path",Ua).attr("class","grid");Uc&&b.append("g").attr("class","xgrids");Nb&&(c=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Nb).enter().append("g").attr("class","xgrid-line"),c.append("line").attr("class",function(a){return""+a["class"]}),c.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g? +0:-u).attr("dy",-6).text(function(a){return a.text}));Zd&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?r:-10).attr("y1",g?-10:u).attr("y2",g?-10:t);Vc&&b.append("g").attr("class","ygrids");Ob&&b.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Ob).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Ua).attr("class","regions");k.append("g").attr("clip-path", +Ua).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",qa?"ew-resize":null);aa?$d(b):ae(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");k.select(".chart").append("g").attr("class","chart-arcs").attr("transform",I.arc);if(qa)k.insert("rect",be?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(D).on("dblclick.zoom", +null);null!==qb&&H.extent("function"!==typeof qb?qb:qb(kb()));ya&&(z.append("g").attr("clip-path",Ua).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",Ua).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&&rb(h.data.targets);Wc(h.data.targets);E({withTransition:!1,withUpdateXDomain:!0}); +if(ce){if(A&&"string"===typeof Ba){Ba=oa(Ba);for(a=0;aDb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;B(h.data.targets)||(a=d.mouse(this),c=Bc(h.data.targets, +a),100>Db(c,a)&&k.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){Yc(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){Zc(d.mouse(this))}).on("dragstart",function(){$c(d.mouse(this))}).on("dragend",function(){ad()})).call(D).on("dblclick.zoom",null)}function Yc(a,b,c){var f=d.select(a),e=f.classed(ja),h=!1,g;"circle"===a.nodeName?(h=Mc(a,1.5*Ta),g=Pc):"rect"===a.nodeName&&(h=Nc(a),g=Rc);if(ra||h)ha&&ia(b)&&(f.classed(ja,!e),g(!e,f,b,c)),fe(b,f)} +function Zc(a){var b,c,f,e,g,l,n;B(h.data.targets)||!ha||qa&&!D.altDomain||(b=Sb[0],c=Sb[1],f=a[0],a=a[1],e=Math.min(b,f),g=Math.max(b,f),l=ra?u:Math.min(c,a),n=ra?t:Math.max(c,a),k.select(".dragarea").attr("x",e).attr("y",l).attr("width",g-e).attr("height",n-l),k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ia(a)}).each(function(a,b){var c=d.select(this),f=c.classed(ja),h=c.classed(Tb),k,p,r,q;k=!1;"circle"===this.nodeName?(k=1*c.attr("cx"),p=1*c.attr("cy"),q=Pc,k=e",c,d,e;for(c=0;c"+e+""+d+"";return b+""}),ce=e(["tooltip","init","show"],!1),Ba=e(["tooltip","init","x"],0),Xc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Mb=va.replace("#","")+"-clip",Ua="url(#"+Mb+")",A="timeseries"===gd,$="categorized"===gd,Cb=!A&&(pa||aa),Sb=null,Va=!1,Rb=!1,la=Aa?40:0,O=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),pd=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)}}(),Zb,fc,ac,bb,ec,gc,r,t,ma,tb,ua,cb,wb,gb,kc,lc,zb,ic,jc,xb,yb,l,y,Z,S,db,eb,G,na,fb,Ha,kd=g?"left":"bottom",ld=g?vb?"top":"bottom":vb?"right":"left",md=g?ub?"bottom":"top":ub?"left":"right",nd="bottom",I={main:function(){return"translate("+F+","+u+")"},context:function(){return"translate("+n+","+Ca+")"},legend:function(){return"translate("+Yb+","+Xb+")"}, +y2:function(){return"translate("+(g?0:r)+","+(g?10:0)+")"},x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+ma+")"},arc:function(){return"translate("+r/2+","+t/2+")"}};zb=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(g?function(a){return x(a.id)(a.value)}:xa).y(g?xa:function(a){return x(a.id)(a.value)});return function(b){var c=Hb(b.values),d;if(Eb(b))return Jc(b)?a.interpolate("cardinal"): +a.interpolate("linear"),fd[b.id]?Qd(c,l,x(b.id),fd[b.id]):a(c);d=l(c[0].x);b=x(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),ie=function(){var a;a=g?d.svg.area().x0(function(a){return x(a.id)(0)}).x1(function(a){return x(a.id)(a.value)}).y(xa):d.svg.area().x(xa).y0(function(a){return x(a.id)(0)}).y1(function(a){return x(a.id)(a.value)});return function(b){var c=Hb(b.values),d;if(Ma([b],"area")||Ma([b],"area-spline"))return Jc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d= +l(c[0].x);b=x(b.id)(c[0].value);return g?"M "+b+" "+d:"M "+d+" "+b}}(),je=function(){var a=d.svg.line().x(function(a){return S(a.x)}).y(function(a){return X(a.id)(a.value)});return function(b){var c=Hb(b.values);return Eb(b)?a(c):"M "+S(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?l.orgDomain():null}).on("zoom",qa? +ke:null);H.update=function(){z&&z.select(".x.brush").call(this);return this};D.orgScaleExtent=function(){var a=ed?ed:[1,10];return[a[0],Math.max(Pa()/a[1],a[1])]};D.updateScaleExtent=function(){var a=l.orgDomain(),a=(a[1]-a[0])/(T[1]-T[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,pb,k,z,za,U,ob,T;h.focus=function(a){var b=q.selectAll(Ya(a)),c=b.filter(Ub),b=b.filter(Vb);h.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity", +1);B(h.data.targets)&&Fa(a,!0)};h.defocus=function(a){var b=q.selectAll(Ya(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);B(h.data.targets)&&Ga(a)};h.revert=function(a){var b=q.selectAll(Ya(a)),c=b.filter(Ub),b=b.filter(Vb);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);B(h.data.targets)&&Ga(a)};h.show=function(a){q.selectAll(Ya(a)).transition().style("opacity", +1)};h.hide=function(a){q.selectAll(Ya(a)).transition().style("opacity",0)};h.unzoom=function(){H.clear().update();E({withUpdateXDomain:!0})};h.load=function(a){v(a.done)&&(a.done=function(){});"categories"in a&&$&&(Ia=a.categories,G.categories(Ia));if("cacheIds"in a&&Ad(a.cacheIds))Wa(Bd(a.cacheIds),a.done);else if("data"in a)Wa(Oa(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Wa(Oa(c),a.done)});else if("rows"in a)Wa(Oa(qc(a.rows)),a.done);else if("columns"in a)Wa(Oa(rc(a.columns)), +a.done);else throw Error("url or rows or columns is required.");};h.unload=function(a){h.data.targets=h.data.targets.filter(function(b){return b.id!==a});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Aa&&(q.selectAll(".legend-item-"+a).remove(),rb(h.data.targets));0b.classes.indexOf(a)})});return P};h.data.get=function(a){a=h.data.getAsTarget(a);return p(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=jb(function(b){return b.id===a});return 0