From 054929689fc056d6054bd4b174b809e2400d752f Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Tue, 18 Feb 2014 15:03:28 +0900 Subject: [PATCH] Fix y grid lines --- c3.js | 19 ++++--- c3.min.js | 164 +++++++++++++++++++++++++++--------------------------- 2 files changed, 94 insertions(+), 89 deletions(-) diff --git a/c3.js b/c3.js index edabf35..2785e35 100644 --- a/c3.js +++ b/c3.js @@ -1873,7 +1873,7 @@ } function redraw(options) { - var xgrid, xgridData, xgridLine, ygrid; + var xgrid, xgridData, xgridLines, ygrid, ygridLines; var mainCircle, mainBar, mainRegion, contextBar, eventRectUpdate; var barIndices = getBarIndices(), barTargetsNum = barIndices.__max__ + 1, maxDataCountTarget; var rectX, rectW; @@ -1950,13 +1950,14 @@ xgrid.exit().remove(); } if (__grid_x_lines) { - xgridLine = main.selectAll(".xgrid-lines"); - xgridLine.selectAll('line') + xgridLines = main.selectAll(".xgrid-lines"); + xgridLines.selectAll('line') + .transition().duration(duration) .attr("x1", __axis_rotated ? 0 : xv) .attr("x2", __axis_rotated ? width : xv) .attr("y1", __axis_rotated ? xv : margin.top) .attr("y2", __axis_rotated ? xv : height); - xgridLine.selectAll('text') + xgridLines.selectAll('text') .attr("x", __axis_rotated ? width : 0) .attr("y", xv); } @@ -1973,9 +1974,13 @@ ygrid.exit().remove(); } if (withY && __grid_y_lines) { - main.select('.ygrid-lines').selectAll('.ygrid-line') - .attr("y1", yv) - .attr("y2", yv); + ygridLines = main.select('.ygrid-lines'); + ygridLines.selectAll('line') + .transition().duration(duration) + .attr("x1", __axis_rotated ? yv : 0) + .attr("x2", __axis_rotated ? yv : width) + .attr("y1", __axis_rotated ? 0 : yv) + .attr("y2", __axis_rotated ? height : yv); } // bars diff --git a/c3.min.js b/c3.min.js index a09d073..df51d83 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,85 +1,85 @@ (function(P){function jd(){function r(d,f){d.attr("transform",function(d){return"translate("+(f(d)+ba)+", 0)"})}function x(d,f){d.attr("transform",function(d){return"translate(0,"+f(d)+")"})}function P(d){var f=d[0];d=d[d.length-1];return fa?a:0}),c=1;c -+a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function lb(a){var b=mb(function(b){return y(b.id)===a}),c="y2"===a?vd:wd,e="y2"===a?xd:yd,c=c?c:sd(b),e=e?e:td(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?zd:Ad;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ga&&(d=Ga.top?Ga.top:k,f=Ga.bottom?Ga.bottom:k);"y2"===a&&Ha&&(d=Ha.top?Ha.top:k,f=Ha.bottom?Ha.bottom:k);Ia(b,"bar")&&!qc(b)&&(f=c);return[c-f,e+d]}function jc(a){var b;a?(a=m.domain(),b=K.extent()): +typeof d}var yb=P.c3={},d=P.d3;yb.generate=function(aa){var $b,ac,Da,Ea,n,u,da,O,I;function f(a,b){for(var c=aa,e=0;ea?a:0}),c=1;c ++a||(b[e][c]+=+a)});return d.max(Object.keys(b).map(function(a){return d.max(b[a])}))}function lb(a){var b=mb(function(b){return y(b.id)===a}),c="y2"===a?vd:wd,e="y2"===a?xd:yd,c=c?c:sd(b),e=e?e:td(b),k=0.1*Math.abs(e-c),d=k,f=k,g="y2"===a?zd:Ad;g&&(c=Math.max(Math.abs(c),Math.abs(e)),e=c-g,c=g-c);"y"===a&&Ga&&(d=Ga.top?Ga.top:k,f=Ga.bottom?Ga.bottom:k);"y2"===a&&Ha&&(d=Ha.top?Ha.top:k,f=Ha.bottom?Ha.bottom:k);Ia(b,"bar")&&!rc(b)&&(f=c);return[c-f,e+d]}function kc(a){var b;a?(a=m.domain(),b=K.extent()): (a=V,b=m.domain());return(a[1]-a[0])/(b[1]-b[0])}function Bd(a){return d.min(a,function(a){return d.min(a.values,function(a){return a.x})})}function Cd(a){return d.max(a,function(a){return d.max(a.values,function(a){return a.x})})}function nb(a){var b=[Bd(a),Cd(a)];a=b[0];var b=b[1],c=ea?0:0.01*Math.abs(a-b);a=B?new Date(a.getTime()-c):a-c;b=B?new Date(b.getTime()+c):b+c;return[a,b]}function Dd(a){for(var b=0;ba?0:a}function tc(a){return qa&&a===qa||Z&&Fd(Z,a)}function Gd(a){return!tc(a)}function Hd(a){Object.keys(a).forEach(function(b){Z[b]=a[b]})}function pb(a){var b;a&&(b=Ja[a.id],a.name=b?b:a.id);return a}function uc(a){var b=a[0],c={},e=[],k,d;for(k=1;kb&&(c=a,b=a.values.length)}):c=a?g.data.targets[0]:null;return c}function qb(a){a=x(a)?g.data.targets:a;return a.map(function(a){return a.id})}function xc(a){var b= -qb(),c;for(c=0;ca})}function ud(a){return yc(a,function(a){return 0k&&(d-=c+30));c=b[1]+ -15+es[c].indexOf(k.id)))for(e=0;e=f;f+=t)g+=e(a[d-1],a[d],f,ya)}return g}function Ob(a){var b;sb=d.select(wa);if(sb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); -else{sb.html("");g.data.x={};g.data.targets=Ka(a);ta();R();m.domain(d.extent(nb(g.data.targets)));z.domain(lb("y"));Y.domain(lb("y2"));U.domain(m.domain());gb.domain(z.domain());hb.domain(Y.domain());J.ticks(10>a.length?a.length:10);oa.ticks(Zd).outerTickSize(0).tickFormat($d);ib.ticks(ae).outerTickSize(0).tickFormat(be);V=m.domain();K.x(U);ra&&F.x(m);p=d.select(wa).append("svg").attr("width",q+I+da).attr("height",t+u+O).on("mouseenter",ce).on("mouseleave",de);tb=p.append("defs");tb.append("clipPath").attr("id", -Pb).append("rect").attr("y",u).attr("width",q).attr("height",t-u);tb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-I).attr("y",-20).attr("width",N).attr("height",ca);tb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-I+1).attr("y",u-1).attr("width",ka).attr("height",xb);h=p.append("g").attr("transform",M.main);A=za?p.append("g").attr("transform",M.context):null;Aa=Ba?p.append("g").attr("transform",M.legend):null;W=d.select(wa).style("position","relative").append("div").style("position", -"absolute").style("z-index","10").style("display","none");h.append("g").attr("class","x axis").attr("clip-path",l?"":"url(#xaxis-clip)").attr("transform",M.x).call(l?oa:J).append("text").attr("class","-axis-x-label").attr("x",q).attr("dy","-.5em").style("text-anchor","end").text(ee);h.append("g").attr("class","y axis").attr("clip-path",l?"url(#yaxis-clip)":"").call(l?J:oa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(fe);zb&& -h.append("g").attr("class","y2 axis").attr("transform",M.y2).call(ib);a=h.append("g").attr("clip-path",Pa).attr("class","grid");Wc&&a.append("g").attr("class","xgrids");Qb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Qb).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",l?"":"rotate(-90)").attr("dx",l? -0:-u).attr("dy",-6).text(function(a){return a.text}));ge&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",l?0:-10).attr("x2",l?q:-10).attr("y1",l?-10:u).attr("y2",l?-10:t);Xc&&a.append("g").attr("class","ygrids");Rb&&a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Rb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});h.append("g").attr("clip-path",Pa).attr("class","regions");h.append("g").attr("clip-path", -Pa).attr("class","chart");h.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ra?"ew-resize":null);h.select(".chart").append("g").attr("class","chart-bars");h.select(".chart").append("g").attr("class","chart-lines");h.select(".chart").append("g").attr("class","chart-arcs").attr("transform",M.arc);if(ra)h.insert("rect",he?null:"g.grid").attr("class","zoom-rect").attr("width",q).attr("height",t).style("opacity",0).style("cursor","ew-resize").call(F).on("dblclick.zoom", -null);null!==ub&&K.extent("function"!==typeof ub?ub:ub(nb()));za&&(A.append("g").attr("clip-path",Pa).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",Pa).attr("class","x brush").call(K).selectAll("rect").attr("height",va),A.append("g").attr("class","x axis").attr("transform",M.subx).call(fb));Ba&&vb(g.data.targets);Yc(g.data.targets);G({withTransition:!1,withUpdateXDomain:!0}); -if(ie){if(B&&"string"===typeof Ca){Ca=pa(Ca);for(a=0;aGb(c,a)?p.select(".event-rect").style("cursor","pointer"):p.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;C(g.data.targets)||(a=d.mouse(this),c=Hc(g.data.targets,a),100>Gb(c,a)&&h.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){$c(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){ad(d.mouse(this))}).on("dragstart", -function(){bd(d.mouse(this))}).on("dragend",function(){cd()})).call(F).on("dblclick.zoom",null)}function $c(a,b,c){var e=d.select(a),f=e.classed(ja),g=!1,l;"circle"===a.nodeName?(g=Pc(a,1.5*Oa),l=Sc):"rect"===a.nodeName&&(g=Qc(a),l=Uc);if(sa||g)ha&&ia(b)&&(e.classed(ja,!f),l(!f,e,b,c)),ne(b,e)}function ad(a){var b,c,e,f,l,m,q;C(g.data.targets)||!ha||ra&&!F.altDomain||(b=Vb[0],c=Vb[1],e=a[0],a=a[1],f=Math.min(b,e),l=Math.max(b,e),m=sa?u:Math.min(c,a),q=sa?t:Math.max(c,a),h.select(".dragarea").attr("x", -f).attr("y",m).attr("width",l-f).attr("height",q-m),h.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ia(a)}).each(function(a,b){var c=d.select(this),e=c.classed(ja),g=c.classed(Wb),h,n,p,r;h=!1;"circle"===this.nodeName?(h=1*c.attr("cx"),n=1*c.attr("cy"),r=Sc,h=f",c,e,d;for(c=0;c"+d+""+e+"");return b+""}),ie=f(["tooltip","init","show"],!1),Ca=f(["tooltip","init","x"],0),Zc=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Pb=wa.replace("#","")+"-clip",Pa="url(#"+Pb+")",B="timeseries"===id,ea="categorized"===id,Fb=!B&&(qa||Z),Vb=null,Qa=!1,Ub=!1,na=Ba?40:0,L=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]}}(ue,ve),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)}}(),cc,gc,ec,ab,fc,hc,q,t,va,yb,ua,db,Ab,jb,mc,nc,Db,kc,lc,Bb,Cb,m,z,Y,U,gb,hb,J,oa,ib,fb,ld=l?"left":"bottom",md=l?cb?"top":"bottom":cb?"right":"left",nd=l?$a?"bottom":"top":$a?"left":"right",od="bottom",M={main:function(){return"translate("+I+","+u+")"},context:function(){return"translate("+n+","+Da+")"},legend:function(){return"translate("+ -$b+","+Zb+")"},y2:function(){return"translate("+(l?0:q)+","+(l?10:0)+")"},x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+va+")"},arc:function(){return"translate("+q/2+","+t/2+")"}};Db=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var pe=function(){var a=d.svg.line().x(l?function(a){return v(a.id)(a.value)}:xa).y(l?xa:function(a){return v(a.id)(a.value)});return function(b){var c=Kb(b.values),d;if(Hb(b))return Mc(b)?a.interpolate("cardinal"): -a.interpolate("linear"),hd[b.id]?Yd(c,m,v(b.id),hd[b.id]):a(c);d=m(c[0].x);b=v(b.id)(c[0].value);return l?"M "+b+" "+d:"M "+d+" "+b}}(),qe=function(){var a;a=l?d.svg.area().x0(function(a){return v(a.id)(0)}).x1(function(a){return v(a.id)(a.value)}).y(xa):d.svg.area().x(xa).y0(function(a){return v(a.id)(0)}).y1(function(a){return v(a.id)(a.value)});return function(b){var c=Kb(b.values),d;if(Ia([b],"area")||Ia([b],"area-spline"))return Mc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d= -m(c[0].x);b=v(b.id)(c[0].value);return l?"M "+b+" "+d:"M "+d+" "+b}}(),re=function(){var a=d.svg.line().x(function(a){return U(a.x)}).y(function(a){return H(a.id)(a.value)});return function(b){var c=Kb(b.values);return Hb(b)?a(c):"M "+U(c[0].x)+" "+H(b.id)(c[0].value)}}(),K=d.svg.brush().on("brush",function(){G({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}),F=d.behavior.zoom().on("zoomstart",function(){F.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",ra? -se:null);K.update=function(){A&&A.select(".x.brush").call(this);return this};F.orgScaleExtent=function(){var a=gd?gd:[1,10];return[a[0],Math.max(eb()/a[1],a[1])]};F.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(V[1]-V[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var p,tb,h,A,Aa,W,sb,V;g.focus=function(a){var b=p.selectAll(Ta(a)),c=b.filter(Xb),b=b.filter(Yb);g.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity", -1);C(g.data.targets)&&Xa(a,!0)};g.defocus=function(a){var b=p.selectAll(Ta(a)),c=b.filter(Xb),b=b.filter(Yb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);C(g.data.targets)&&wb(a)};g.revert=function(a){var b=p.selectAll(Ta(a)),c=b.filter(Xb),b=b.filter(Yb);c.classed("focused",!1).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);C(g.data.targets)&&wb(a)};g.show=function(a){p.selectAll(Ta(a)).transition().style("opacity", -1)};g.hide=function(a){p.selectAll(Ta(a)).transition().style("opacity",0)};g.unzoom=function(){K.clear().update();G({withUpdateXDomain:!0})};g.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Hd(a.xs);"categories"in a&&ea&&(Fa=a.categories,J.categories(Fa));if("cacheIds"in a&&Dd(a.cacheIds))Ra(Ed(a.cacheIds),a.done);else if("data"in a)Ra(Ka(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Ra(Ka(c),a.done)});else if("rows"in a)Ra(Ka(uc(a.rows)),a.done);else if("columns"in -a)Ra(Ka(vc(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});p.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(p.selectAll(".legend-item-"+a).remove(),vb(g.data.targets));0b.classes.indexOf(a)})});return Q};g.data.get=function(a){a=g.data.getAsTarget(a);return r(a)?a.values.map(function(a){return a.value}):void 0};g.data.getAsTarget=function(a){var b=mb(function(b){return b.id===a});return 0a?0:a}function uc(a){return qa&&a===qa||Z&&Fd(Z,a)}function Gd(a){return!uc(a)}function Hd(a){Object.keys(a).forEach(function(b){Z[b]=a[b]})}function pb(a){var b;a&&(b=Ja[a.id],a.name=b?b:a.id);return a}function vc(a){var b=a[0],c={},e=[],k,d;for(k=1;kb&&(c=a,b=a.values.length)}):c=a?g.data.targets[0]:null;return c}function qb(a){a=x(a)?g.data.targets:a;return a.map(function(a){return a.id})}function yc(a){var b= +qb(),c;for(c=0;ca})}function ud(a){return zc(a,function(a){return 0k&&(d-=c+30));c=b[1]+ +15+et[c].indexOf(k.id)))for(e=0;e=f;f+=s)g+=e(a[d-1],a[d],f,ya)}return g}function Pb(a){var b;tb=d.select(wa);if(tb.empty())P.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); +else{tb.html("");g.data.x={};g.data.targets=Ka(a);ta();R();m.domain(d.extent(nb(g.data.targets)));z.domain(lb("y"));Y.domain(lb("y2"));U.domain(m.domain());gb.domain(z.domain());hb.domain(Y.domain());J.ticks(10>a.length?a.length:10);oa.ticks(Zd).outerTickSize(0).tickFormat($d);ib.ticks(ae).outerTickSize(0).tickFormat(be);V=m.domain();K.x(U);ra&&F.x(m);q=d.select(wa).append("svg").attr("width",p+I+da).attr("height",s+u+O).on("mouseenter",ce).on("mouseleave",de);ub=q.append("defs");ub.append("clipPath").attr("id", +Qb).append("rect").attr("y",u).attr("width",p).attr("height",s-u);ub.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-I).attr("y",-20).attr("width",N).attr("height",ca);ub.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-I+1).attr("y",u-1).attr("width",ka).attr("height",yb);l=q.append("g").attr("transform",M.main);A=za?q.append("g").attr("transform",M.context):null;Aa=Ba?q.append("g").attr("transform",M.legend):null;W=d.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",M.x).call(h?oa:J).append("text").attr("class","-axis-x-label").attr("x",p).attr("dy","-.5em").style("text-anchor","end").text(ee);l.append("g").attr("class","y axis").attr("clip-path",h?"url(#yaxis-clip)":"").call(h?J:oa).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(fe);Ab&& +l.append("g").attr("class","y2 axis").attr("transform",M.y2).call(ib);a=l.append("g").attr("clip-path",Pa).attr("class","grid");Wc&&a.append("g").attr("class","xgrids");Rb&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(Rb).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:-u).attr("dy",-6).text(function(a){return a.text}));ge&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",h?0:-10).attr("x2",h?p:-10).attr("y1",h?-10:u).attr("y2",h?-10:s);Xc&&a.append("g").attr("class","ygrids");Sb&&a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Sb).enter().append("line").attr("class",function(a){return"ygrid-line "+a["class"]});l.append("g").attr("clip-path",Pa).attr("class","regions");l.append("g").attr("clip-path", +Pa).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ra?"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",M.arc);if(ra)l.insert("rect",he?null:"g.grid").attr("class","zoom-rect").attr("width",p).attr("height",s).style("opacity",0).style("cursor","ew-resize").call(F).on("dblclick.zoom", +null);null!==vb&&K.extent("function"!==typeof vb?vb:vb(nb()));za&&(A.append("g").attr("clip-path",Pa).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",Pa).attr("class","x brush").call(K).selectAll("rect").attr("height",va),A.append("g").attr("class","x axis").attr("transform",M.subx).call(fb));Ba&&wb(g.data.targets);Yc(g.data.targets);G({withTransition:!1,withUpdateXDomain:!0}); +if(ie){if(B&&"string"===typeof Ca){Ca=pa(Ca);for(a=0;aHb(c,a)?q.select(".event-rect").style("cursor","pointer"):q.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;C(g.data.targets)||(a=d.mouse(this),c=Hc(g.data.targets,a),100>Hb(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){$c(this,c,c.index)}))}).call(d.behavior.drag().origin(Object).on("drag",function(){ad(d.mouse(this))}).on("dragstart", +function(){bd(d.mouse(this))}).on("dragend",function(){cd()})).call(F).on("dblclick.zoom",null)}function $c(a,b,c){var e=d.select(a),f=e.classed(ja),g=!1,h;"circle"===a.nodeName?(g=Pc(a,1.5*Oa),h=Sc):"rect"===a.nodeName&&(g=Qc(a),h=Uc);if(sa||g)ha&&ia(b)&&(e.classed(ja,!f),h(!f,e,b,c)),ne(b,e)}function ad(a){var b,c,e,f,h,m,p;C(g.data.targets)||!ha||ra&&!F.altDomain||(b=Wb[0],c=Wb[1],e=a[0],a=a[1],f=Math.min(b,e),h=Math.max(b,e),m=sa?u:Math.min(c,a),p=sa?s:Math.max(c,a),l.select(".dragarea").attr("x", +f).attr("y",m).attr("width",h-f).attr("height",p-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),g=c.classed(Xb),l,n,q,r;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),r=Sc,l=f",c,d,f;for(c=0;c"+f+""+d+"");return b+""}),ie=f(["tooltip","init","show"],!1),Ca=f(["tooltip","init","x"],0),Zc=f(["tooltip","init","position"],{top:"0px",left:"50px"}),Qb=wa.replace("#","")+"-clip",Pa="url(#"+Qb+")",B="timeseries"===id,ea="categorized"===id,Gb=!B&&(qa||Z),Wb=null,Qa=!1,Vb=!1,na=Ba?40:0,L=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]}}(ue,ve),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)}}(),dc,hc,fc,ab,gc,ic,p,s,va,zb,ua,db,Bb,jb,nc,oc,Eb,lc,mc,Cb,Db,m,z,Y,U,gb,hb,J,oa,ib,fb,ld=h?"left":"bottom",md=h?cb?"top":"bottom":cb?"right":"left",nd=h?$a?"bottom":"top":$a?"left":"right",od="bottom", +M={main:function(){return"translate("+I+","+u+")"},context:function(){return"translate("+n+","+Da+")"},legend:function(){return"translate("+ac+","+$b+")"},y2:function(){return"translate("+(h?0:p)+","+(h?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+va+")"},arc:function(){return"translate("+p/2+","+s/2+")"}};Eb=d.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var pe=function(){var a=d.svg.line().x(h?function(a){return w(a.id)(a.value)}: +xa).y(h?xa:function(a){return w(a.id)(a.value)});return function(b){var c=Lb(b.values),d;if(Ib(b))return Mc(b)?a.interpolate("cardinal"):a.interpolate("linear"),hd[b.id]?Yd(c,m,w(b.id),hd[b.id]):a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),qe=function(){var a;a=h?d.svg.area().x0(function(a){return w(a.id)(0)}).x1(function(a){return w(a.id)(a.value)}).y(xa):d.svg.area().x(xa).y0(function(a){return w(a.id)(0)}).y1(function(a){return w(a.id)(a.value)});return function(b){var c= +Lb(b.values),d;if(Ia([b],"area")||Ia([b],"area-spline"))return Mc(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=w(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),re=function(){var a=d.svg.line().x(function(a){return U(a.x)}).y(function(a){return H(a.id)(a.value)});return function(b){var c=Lb(b.values);return Ib(b)?a(c):"M "+U(c[0].x)+" "+H(b.id)(c[0].value)}}(),K=d.svg.brush().on("brush",function(){G({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}), +F=d.behavior.zoom().on("zoomstart",function(){F.altDomain=d.event.sourceEvent.altKey?m.orgDomain():null}).on("zoom",ra?se:null);K.update=function(){A&&A.select(".x.brush").call(this);return this};F.orgScaleExtent=function(){var a=gd?gd:[1,10];return[a[0],Math.max(eb()/a[1],a[1])]};F.updateScaleExtent=function(){var a=m.orgDomain(),a=(a[1]-a[0])/(V[1]-V[0]),b=this.orgScaleExtent();this.scaleExtent([b[0]*a,b[1]*a]);return this};var q,ub,l,A,Aa,W,tb,V;g.focus=function(a){var b=q.selectAll(Ta(a)),c=b.filter(Yb), +b=b.filter(Zb);g.defocus();c.classed("focused",!0).transition().duration(100).style("opacity",1);b.transition().duration(100).style("opacity",1);C(g.data.targets)&&Xa(a,!0)};g.defocus=function(a){var b=q.selectAll(Ta(a)),c=b.filter(Yb),b=b.filter(Zb);c.classed("focused",!1).transition().duration(100).style("opacity",0.3);b.transition().duration(100).style("opacity",0.3);C(g.data.targets)&&xb(a)};g.revert=function(a){var b=q.selectAll(Ta(a)),c=b.filter(Yb),b=b.filter(Zb);c.classed("focused",!1).transition().duration(100).style("opacity", +1);b.transition().duration(100).style("opacity",1);C(g.data.targets)&&xb(a)};g.show=function(a){q.selectAll(Ta(a)).transition().style("opacity",1)};g.hide=function(a){q.selectAll(Ta(a)).transition().style("opacity",0)};g.unzoom=function(){K.clear().update();G({withUpdateXDomain:!0})};g.load=function(a){"function"!==typeof a.done&&(a.done=function(){});a.xs&&Hd(a.xs);"categories"in a&&ea&&(Fa=a.categories,J.categories(Fa));if("cacheIds"in a&&Dd(a.cacheIds))Ra(Ed(a.cacheIds),a.done);else if("data"in +a)Ra(Ka(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Ra(Ka(c),a.done)});else if("rows"in a)Ra(Ka(vc(a.rows)),a.done);else if("columns"in a)Ra(Ka(wc(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});q.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(q.selectAll(".legend-item-"+a).remove(),wb(g.data.targets));0b.classes.indexOf(a)})});return Q};g.data.get=function(a){a=g.data.getAsTarget(a);return r(a)?a.values.map(function(a){return a.value}):void 0};g.data.getAsTarget= +function(a){var b=mb(function(b){return b.id===a});return 0