diff --git a/c3.js b/c3.js index 8239718..1618838 100644 --- a/c3.js +++ b/c3.js @@ -419,6 +419,10 @@ } return (domain[1] - domain[0]) / (extent[1] - extent[0]); } + function getDefaultXDomain() { + var padding = isCategorized ? 0 : Math.abs(lastX - firstX) * 0.01; + return [firstX - padding, lastX + padding]; + } function diffDomain(d) { return d[1] - d[0]; } @@ -540,11 +544,27 @@ d.x = x; // used by event-rect - return {x: x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId, index: i}; + return {x: x, value: d[id] !== null && !isNaN(d[id]) ? +d[id] : null, id: convertedId}; }) }; }); + // finish targets + targets.forEach(function (t) { + var i; + // sort values by its x + t.values = t.values.sort(function (v1, v2) { + var x1 = v1.x || v1.x === 0 ? v1.x : Infinity, + x2 = v2.x || v2.x === 0 ? v2.x : Infinity; + return x1 - x2; + }); + // indexing each value + i = 0; + t.values.forEach(function (v) { + v.index = i++; + }); + }); + // cache as original id keyed targets.forEach(function (d) { addCache(d.id_org, d); @@ -678,6 +698,8 @@ } function showXGridFocus(data) { + // Show when line chart exists + if (! hasLineType(c3.data.targets)) { return; } main.selectAll('line.xgrid-focus') .style("visibility", "visible") .data([data]) @@ -771,14 +793,17 @@ }); return has; } - /* not used function hasLineType(targets) { return hasType(targets, 'line'); } - */ function hasBarType(targets) { return hasType(targets, 'bar'); } + /* not used + function hasScatterType(targets) { + return hasType(targets, 'scatter'); + } + */ function isLineType(d) { var id = (typeof d === 'string') ? d : d.id; return !(id in __data_types) || __data_types[id] === 'line' || __data_types[id] === 'spline'; @@ -791,12 +816,24 @@ var id = (typeof d === 'string') ? d : d.id; return __data_types[id] === 'bar'; } + function isScatterType(d) { + var id = (typeof d === 'string') ? d : d.id; + return __data_types[id] === 'scatter'; + } + /* not used function lineData(d) { return isLineType(d) ? d.values : []; } + function scatterData(d) { + return isScatterType(d) ? d.values : []; + } + */ function barData(d) { return isBarType(d) ? d.values : []; } + function lineOrScatterData(d) { + return isLineType(d) || isScatterType(d) ? d.values : []; + } //-- Color --// @@ -1073,7 +1110,7 @@ updateScales(); // Set domains for each scale - x.domain(d3.extent([firstX, lastX])); + x.domain(d3.extent(getDefaultXDomain())); y.domain(getYDomain('y')); y2.domain(getYDomain('y2')); subX.domain(x.domain()); @@ -1698,7 +1735,7 @@ .transition().duration(duration) .attr("d", lineOnMain); mainCircle = main.selectAll('.-circles').selectAll('.-circle') - .data(lineData); + .data(lineOrScatterData); mainCircle.transition().duration(duration) .style('opacity', function (d) { return d.value === null ? 0 : 1; }) .attr("cx", __axis_rotated ? circleY : circleX) @@ -2186,6 +2223,11 @@ redraw(); }; + c3.toScatter = function (targets) { + setTargetType(targets, 'scatter'); + redraw(); + }; + c3.groups = function (groups) { if (isUndefined(groups)) { return __data_groups; } __data_groups = groups; diff --git a/c3.min.js b/c3.min.js index 33889af..e15fe2e 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,73 +1,73 @@ -(function(Q){function Oc(){function n(c,e){c.attr("transform",function(c){return"translate("+(e(c)+aa)+", 0)"})}function s(c,e){c.attr("transform",function(c){return"translate(0,"+e(c)+")"})}function Q(c){var e=c[0];c=c[c.length-1];return ea?0:a}function cc(a){return qa&&a===qa||X&&ed(X,a)}function fd(a){return!cc(a)}function fb(a){var b=Ka[a.id];a.name=n(b)?b:a.id;return a}function dc(a){var b=a[0],d={},f=[],c,e;for(c=1;ct[d].indexOf(c.id)))for(f=0;fb?a-b:0};return function(a){var c=b?T(a.id):E(a.id);return d(c(a.value))}}function vb(a,b){var d=s(a)?sb():a;"string"===typeof d&&(d=[d]);for(var f=0;f=e;e+=r)h+=f(a[c-1],a[c],e,l)}return h}function Cb(a){var b,d;hb=c.select(wa);if(hb.empty())Q.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{hb.html("");h.data.x={};h.data.targets=La(a);ua();Lb();m.domain(c.extent([xa, -Ma]));u.domain(la("y"));V.domain(la("y2"));da.domain(m.domain());$a.domain(u.domain());ab.domain(V.domain());z.ticks(10>a.length?a.length:10);oa.ticks(rd).outerTickSize(0).tickFormat(sd);bb.ticks(td).outerTickSize(0).tickFormat(ud);W=m.domain();G.x(da);ra&&B.x(m);Qa=c.select(wa).append("svg").attr("width",q+y+ca).attr("height",p+r+F).on("mouseenter",vd).on("mouseleave",wd);ib=Qa.append("defs");ib.append("clipPath").attr("id",Db).append("rect").attr("y",r).attr("width",q).attr("height",p-r);ib.append("clipPath").attr("id", -"xaxis-clip").append("rect").attr("x",-1-y).attr("y",-20).attr("width",S).attr("height",R);ib.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-y+1).attr("y",r-1).attr("width",ka).attr("height",lb);k=Qa.append("g").attr("transform",J.main);v=ya?Qa.append("g").attr("transform",J.context):null;za=Aa?Qa.append("g").attr("transform",J.legend):null;P=c.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:z).append("text").attr("class","-axis-x-label").attr("x",q).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?z:oa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(yd);Tb&&k.append("g").attr("class","y2 axis").attr("transform",J.y2).call(bb);b=k.append("g").attr("clip-path", -Ra).attr("class","grid");Dc&&b.append("g").attr("class","xgrids");Eb&&(d=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Eb).enter().append("g").attr("class","xgrid-line"),d.append("line").attr("class",function(a){return""+a["class"]}),d.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-r).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?q:-10).attr("y1",g?-10:r).attr("y2",g?-10:p);Ec&&b.append("g").attr("class","ygrids");Fb&&b.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Fb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Ra).attr("class","regions");k.append("g").attr("clip-path",Ra).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor", -ra?"ew-resize":null);X?Ad(b):Bd(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");if(ra)k.insert("rect",Cd?null:"g.grid").attr("class","zoom-rect").attr("width",q).attr("height",p).style("opacity",0).style("cursor","ew-resize").call(B).on("dblclick.zoom",null);null!==jb&&G.extent("function"!==typeof jb?jb:jb(xa,Ma));ya&&(v.append("g").attr("clip-path",Ra).attr("class","chart"),v.select(".chart").append("g").attr("class","chart-bars"), -v.select(".chart").append("g").attr("class","chart-lines"),v.append("g").attr("clip-path",Ra).attr("class","x brush").call(G).selectAll("rect").attr("height",na),v.append("g").attr("class","x axis").attr("transform",J.subx).call(Fa));Aa&&kb(h.data.targets);Fc(h.data.targets);C({withTransition:!1,withUpdateXDomain:!0});if(Dd){if(A&&"string"===typeof Ba){Ba=pa(Ba);for(a=0;avc(d,a)?c.select(".event-rect").style("cursor","pointer"):c.select(".event-rect").style("cursor", -null))}).on("click",function(){var a=c.mouse(this),d=kc(h.data.targets,a);100>vc(d,a)&&k.select(".-circles-"+d.id).select(".-circle-"+d.index).each(function(){Hc(this,d,d.index)})}).call(c.behavior.drag().origin(Object).on("drag",function(){Ic(c.mouse(this))}).on("dragstart",function(){Jc(c.mouse(this))}).on("dragend",function(){Kc()})).call(B).on("dblclick.zoom",null)}function Hc(a,b,d){var f=c.select(a),e=f.classed(ja),g=!1,h;"circle"===a.nodeName?(g=tc(a,1.5*Pa),h=xc):"rect"===a.nodeName&&(g=uc(a), -h=zc);if(sa||g)ia&&ta(b)&&(f.classed(ja,!e),h(!e,f,b,d)),Fd(b,f)}function Ic(a){if(ia&&(!ra||B.altDomain)){var b=Jb[0],d=Jb[1],f=a[0];a=a[1];var e=Math.min(b,f),g=Math.max(b,f),h=sa?r:Math.min(d,a),m=sa?p:Math.max(d,a);k.select(".dragarea").attr("x",e).attr("y",h).attr("width",g-e).attr("height",m-h);k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ta(a)}).each(function(a,b){var d=c.select(this),f=d.classed(ja),k=d.classed(Kb),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*d.attr("cx"), -n=1*d.attr("cy"),q=xc,l=e",c,e,g;for(c= -0;c"+g+""+e+"";return b+""}),Dd=e(["tooltip","init","show"],!1),Ba=e(["tooltip","init","x"],0),Gc=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Db=wa.replace("#","")+"-clip",Ra="url(#"+Db+")",A="timeseries"===Nc,ea="categorized"=== -Nc,rb=!A&&(qa||X),Jb=null,Sa=!1,Ib=!1,ma=Aa?40:0,Y=function(a,b){var c=[],e=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 e[c.indexOf(b)%e.length]}}(Ld,Md),Wc=function(){var a=[[c.time.format("%Y/%-m/%-d"),function(){return!0}],[c.time.format("%-m/%-d"),function(a){return a.getMonth()}],[c.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[c.time.format("%-m/%-d"), -function(a){return a.getDay()&&1!==a.getDate()}],[c.time.format("%I %p"),function(a){return a.getHours()}],[c.time.format("%I:%M"),function(a){return a.getMinutes()}],[c.time.format(":%S"),function(a){return a.getSeconds()}],[c.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}(),Pb,Wb,Rb,Za,Vb,Xb,q,p,na,mb,va,Zb,$b,pb,qb,m,u,V,da,$a,ab,z,oa,bb,Fa,Rc=g?"left":"bottom",Sc=g?ob?"top":"bottom":ob?"right":"left", -Tc=g?nb?"bottom":"top":nb?"left":"right",Uc="bottom",J={main:function(){return"translate("+y+","+r+")"},context:function(){return"translate("+l+","+Ca+")"},legend:function(){return"translate("+Nb+","+Mb+")"},y2:function(){return"translate("+(g?0:q)+","+(g?10:0)+")"},x:function(){return"translate(0,"+p+")"},subx:function(){return"translate(0,"+na+")"}},Hd=function(){var a=c.svg.line().x(g?function(a){return E(a.id)(a.value)}:gb).y(g?gb:function(a){return E(a.id)(a.value)});return function(b){var c= -Ac(b.values),e;if(wb(b))return"spline"===ha["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),Mc[b.id]?qd(c,m,E(b.id),Mc[b.id]):a(c);e=m(c[0].x);b=E(b.id)(c[0].value);return g?"M "+b+" "+e:"M "+e+" "+b}}(),Id=function(){var a=c.svg.line().x(function(a){return da(a.x)}).y(function(a){return T(a.id)(a.value)});return function(b){var c=Ac(b.values);return wb(b)?a(c):"M "+da(c[0].x)+" "+T(b.id)(c[0].value)}}(),G=c.svg.brush().on("brush",function(){C({withTransition:!1,withY:!1, -withSubchart:!1,withUpdateXDomain:!0})}),B=c.behavior.zoom().on("zoomstart",function(){B.altDomain=c.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",ra?Jd:null);G.update=function(){v&&v.select(".x.brush").call(this);return this};B.orgScaleExtent=function(){var a=Lc?Lc:[1,10];return[a[0],Math.max(Na()/a[1],a[1])]};B.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(W[1]-W[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var Qa,ib,k,v,za,P,hb,xa=null, -Ma=null,W;h.focus=function(a){h.defocus();c.selectAll(Va(a)).filter(function(a){return tb(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};h.defocus=function(a){c.selectAll(Va(a)).filter(function(a){return tb(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",0.3)};h.revert=function(a){c.selectAll(Va(a)).filter(function(a){return tb(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};h.show=function(a){c.selectAll(Va(a)).transition().style("opacity", -1)};h.hide=function(a){c.selectAll(Va(a)).transition().style("opacity",0)};h.unzoom=function(){G.clear().update();C({withUpdateXDomain:!0})};h.load=function(a){s(a.done)&&(a.done=function(){});"categories"in a&&ea&&(Ga=a.categories,z.categories(Ga));if("cacheIds"in a&&Wa(a.cacheIds))Ta(Xa(a.cacheIds),a.done);else if("data"in a)Ta(La(a.data),a.done);else if("url"in a)c.csv(a.url,function(b,c){Ta(La(c),a.done)});else if("rows"in a)Ta(La(dc(a.rows)),a.done);else if("columns"in a)Ta(La(ec(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});c.selectAll(".target-"+a).transition().style("opacity",0).remove();Aa&&(c.selectAll(".legend-item-"+a).remove(),kb(h.data.targets));0b.classes.indexOf(a)})});return K};h.data.get=function(a){a=h.data.getAsTarget(a);return n(a)?a.values.map(function(a){return a.value}):void 0};h.data.getAsTarget=function(a){var b=db(function(b){return b.id===a});return 0a?0:a}function ec(a){return ra&&a===ra||Y&&fd(Y,a)}function gd(a){return!ec(a)}function eb(a){var b=Ka[a.id];a.name=n(b)?b:a.id;return a}function fc(a){var b=a[0],d={},f=[],c,H;for(c=1;ct[d].indexOf(c.id)))for(f=0;fb?a-b:0};return function(a){var c=b?T(a.id):F(a.id);return d(c(a.value))}} +function gb(a,b){var d=s(a)?ub():a;"string"===typeof d&&(d=[d]);for(var f=0;f=e;e+= +r)h+=f(a[c-1],a[c],e,l)}return h}function Db(a){var b,d;hb=c.select(xa);if(hb.empty())Q.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{hb.html("");h.data.x={};h.data.targets=La(a);va();Mb();m.domain(c.extent(Va()));u.domain(la("y"));V.domain(la("y2"));fa.domain(m.domain());Za.domain(u.domain());$a.domain(V.domain());B.ticks(10>a.length?a.length:10);oa.ticks(sd).outerTickSize(0).tickFormat(td);ab.ticks(ud).outerTickSize(0).tickFormat(vd); +W=m.domain();I.x(fa);sa&&D.x(m);Pa=c.select(xa).append("svg").attr("width",q+A+ea).attr("height",p+r+G).on("mouseenter",wd).on("mouseleave",xd);ib=Pa.append("defs");ib.append("clipPath").attr("id",Eb).append("rect").attr("y",r).attr("width",q).attr("height",p-r);ib.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-A).attr("y",-20).attr("width",S).attr("height",R);ib.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-A+1).attr("y",r-1).attr("width",ka).attr("height", +nb);k=Pa.append("g").attr("transform",L.main);w=za?Pa.append("g").attr("transform",L.context):null;Aa=Ba?Pa.append("g").attr("transform",L.legend):null;P=c.select(xa).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",L.x).call(g?oa:B).append("text").attr("class","-axis-x-label").attr("x",q).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?B:oa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(zd);Tb&&k.append("g").attr("class","y2 axis").attr("transform",L.y2).call(ab);b=k.append("g").attr("clip-path",Qa).attr("class","grid");Fc&&b.append("g").attr("class","xgrids");Fb&&(d=b.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Fb).enter().append("g").attr("class", +"xgrid-line"),d.append("line").attr("class",function(a){return""+a["class"]}),d.append("text").attr("class",function(a){return""+a["class"]}).attr("text-anchor","end").attr("transform",g?"":"rotate(-90)").attr("dx",g?0:-r).attr("dy",-6).text(function(a){return a.text}));Ad&&b.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",g?0:-10).attr("x2",g?q:-10).attr("y1",g?-10:r).attr("y2",g?-10:p);Gc&&b.append("g").attr("class","ygrids");Gb&&b.append("g").attr("class", +"ygrid-lines").selectAll("ygrid-line").data(Gb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});k.append("g").attr("clip-path",Qa).attr("class","regions");k.append("g").attr("clip-path",Qa).attr("class","chart");b=k.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",sa?"ew-resize":null);Y?Bd(b):Cd(b,a);k.select(".chart").append("g").attr("class","chart-bars");k.select(".chart").append("g").attr("class","chart-lines");if(sa)k.insert("rect", +Dd?null:"g.grid").attr("class","zoom-rect").attr("width",q).attr("height",p).style("opacity",0).style("cursor","ew-resize").call(D).on("dblclick.zoom",null);null!==jb&&I.extent("function"!==typeof jb?jb:jb(pa,ya));za&&(w.append("g").attr("clip-path",Qa).attr("class","chart"),w.select(".chart").append("g").attr("class","chart-bars"),w.select(".chart").append("g").attr("class","chart-lines"),w.append("g").attr("clip-path",Qa).attr("class","x brush").call(I).selectAll("rect").attr("height",na),w.append("g").attr("class", +"x axis").attr("transform",L.subx).call(Fa));Ba&&kb(h.data.targets);Hc(h.data.targets);z({withTransition:!1,withUpdateXDomain:!0});if(Ed){if(C&&"string"===typeof Ca){Ca=qa(Ca);for(a=0;axc(d,a)?c.select(".event-rect").style("cursor","pointer"):c.select(".event-rect").style("cursor",null))}).on("click",function(){var a=c.mouse(this),d=mc(h.data.targets,a);100>xc(d,a)&&k.select(".-circles-"+d.id).select(".-circle-"+d.index).each(function(){Jc(this, +d,d.index)})}).call(c.behavior.drag().origin(Object).on("drag",function(){Kc(c.mouse(this))}).on("dragstart",function(){Lc(c.mouse(this))}).on("dragend",function(){Mc()})).call(D).on("dblclick.zoom",null)}function Jc(a,b,d){var f=c.select(a),e=f.classed(ja),g=!1,h;"circle"===a.nodeName?(g=vc(a,1.5*Oa),h=zc):"rect"===a.nodeName&&(g=wc(a),h=Bc);if(ta||g)ia&&ua(b)&&(f.classed(ja,!e),h(!e,f,b,d)),Gd(b,f)}function Kc(a){if(ia&&(!sa||D.altDomain)){var b=Kb[0],d=Kb[1],f=a[0];a=a[1];var e=Math.min(b,f),g= +Math.max(b,f),h=ta?r:Math.min(d,a),m=ta?p:Math.max(d,a);k.select(".dragarea").attr("x",e).attr("y",h).attr("width",g-e).attr("height",m-h);k.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ua(a)}).each(function(a,b){var d=c.select(this),f=d.classed(ja),k=d.classed(Lb),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*d.attr("cx"),n=1*d.attr("cy"),q=zc,l=e",d,c,e;for(d=0;d"+e+""+c+"";return b+""}),Ed=e(["tooltip","init","show"],!1),Ca=e(["tooltip","init","x"],0),Ic=e(["tooltip","init","position"],{top:"0px",left:"50px"}),Eb=xa.replace("#","")+"-clip",Qa="url(#"+Eb+")",C="timeseries"===Pc,X="categorized"===Pc,tb=!C&&(ra||Y),Kb=null,Ra=!1,Jb=!1,ma=Ba?40:0,$=function(a,b){var c=[],e=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 e[c.indexOf(b)%e.length]}}(Md,Nd),Yc=function(){var a=[[c.time.format("%Y/%-m/%-d"),function(){return!0}],[c.time.format("%-m/%-d"),function(a){return a.getMonth()}],[c.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[c.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[c.time.format("%I %p"),function(a){return a.getHours()}],[c.time.format("%I:%M"),function(a){return a.getMinutes()}],[c.time.format(":%S"),function(a){return a.getSeconds()}], +[c.time.format(".%L"),function(a){return a.getMilliseconds()}]];return function(b){for(var c=a.length-1,e=a[c];!e[1](b);)e=a[--c];return e[0](b)}}(),Pb,Wb,Rb,Ya,Vb,Xb,q,p,na,ob,wa,Zb,$b,rb,sb,m,u,V,fa,Za,$a,B,oa,ab,Fa,Tc=g?"left":"bottom",Uc=g?qb?"top":"bottom":qb?"right":"left",Vc=g?pb?"bottom":"top":pb?"left":"right",Wc="bottom",L={main:function(){return"translate("+A+","+r+")"},context:function(){return"translate("+l+","+Da+")"},legend:function(){return"translate("+Ob+","+Nb+")"},y2:function(){return"translate("+ +(g?0:q)+","+(g?10:0)+")"},x:function(){return"translate(0,"+p+")"},subx:function(){return"translate(0,"+na+")"}},Id=function(){var a=c.svg.line().x(g?function(a){return F(a.id)(a.value)}:fb).y(g?fb:function(a){return F(a.id)(a.value)});return function(b){var c=Cc(b.values),e;if(xb(b))return"spline"===Z["string"===typeof b?b:b.id]?a.interpolate("cardinal"):a.interpolate("linear"),Oc[b.id]?rd(c,m,F(b.id),Oc[b.id]):a(c);e=m(c[0].x);b=F(b.id)(c[0].value);return g?"M "+b+" "+e:"M "+e+" "+b}}(),Jd=function(){var a= +c.svg.line().x(function(a){return fa(a.x)}).y(function(a){return T(a.id)(a.value)});return function(b){var c=Cc(b.values);return xb(b)?a(c):"M "+fa(c[0].x)+" "+T(b.id)(c[0].value)}}(),I=c.svg.brush().on("brush",function(){z({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),D=c.behavior.zoom().on("zoomstart",function(){D.altDomain=c.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",sa?Kd:null);I.update=function(){w&&w.select(".x.brush").call(this);return this};D.orgScaleExtent= +function(){var a=Nc?Nc:[1,10];return[a[0],Math.max(Ma()/a[1],a[1])]};D.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(W[1]-W[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var Pa,ib,k,w,Aa,P,hb,pa=null,ya=null,W;h.focus=function(a){h.defocus();c.selectAll(Ua(a)).filter(function(a){return vb(a.id)}).classed("focused",!0).transition().duration(100).style("opacity",1)};h.defocus=function(a){c.selectAll(Ua(a)).filter(function(a){return vb(a.id)}).classed("focused", +!1).transition().duration(100).style("opacity",0.3)};h.revert=function(a){c.selectAll(Ua(a)).filter(function(a){return vb(a.id)}).classed("focused",!1).transition().duration(100).style("opacity",1)};h.show=function(a){c.selectAll(Ua(a)).transition().style("opacity",1)};h.hide=function(a){c.selectAll(Ua(a)).transition().style("opacity",0)};h.unzoom=function(){I.clear().update();z({withUpdateXDomain:!0})};h.load=function(a){s(a.done)&&(a.done=function(){});"categories"in a&&X&&(Ga=a.categories,B.categories(Ga)); +if("cacheIds"in a&&Wa(a.cacheIds))Sa(mb(a.cacheIds),a.done);else if("data"in a)Sa(La(a.data),a.done);else if("url"in a)c.csv(a.url,function(b,c){Sa(La(c),a.done)});else if("rows"in a)Sa(La(fc(a.rows)),a.done);else if("columns"in a)Sa(La(gc(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});c.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(c.selectAll(".legend-item-"+ +a).remove(),kb(h.data.targets));0b.classes.indexOf(a)})});return M};h.data.get=function(a){a=h.data.getAsTarget(a);return n(a)?a.values.map(function(a){return a.value}): +void 0};h.data.getAsTarget=function(a){var b=cb(function(b){return b.id===a});return 0