From f7c94e7fc3e6d5d4d7b4618fda3cb29cf4eaf717 Mon Sep 17 00:00:00 2001 From: Masayuki Tanaka Date: Tue, 18 Feb 2014 21:48:55 +0900 Subject: [PATCH] Fix grid.y.lines --- c3.css | 5 +- c3.js | 28 +++++++--- c3.min.js | 159 +++++++++++++++++++++++++++--------------------------- 3 files changed, 104 insertions(+), 88 deletions(-) diff --git a/c3.css b/c3.css index b31c23b..226122c 100644 --- a/c3.css +++ b/c3.css @@ -27,7 +27,10 @@ text { /*-- Grid --*/ .grid line { - stroke: #ccc; + stroke: #aaa; +} +.grid text { + fill: #aaa; } .xgrid, .ygrid { stroke-dasharray: 3 3; diff --git a/c3.js b/c3.js index 2785e35..ee7cbf8 100644 --- a/c3.js +++ b/c3.js @@ -1330,7 +1330,7 @@ var orgXDomain; function init(data) { - var eventRect, grid, xgridLine; + var eventRect, grid, xgridLines, ygridLines; var i; selectChart = d3.select(__bindto); @@ -1458,20 +1458,20 @@ grid.append("g").attr("class", "xgrids"); } if (__grid_x_lines) { - xgridLine = grid.append('g') + xgridLines = grid.append('g') .attr("class", "xgrid-lines") .selectAll('.xgrid-line') .data(__grid_x_lines) .enter().append('g') .attr("class", "xgrid-line"); - xgridLine.append('line') + xgridLines.append('line') .attr("class", function (d) { return "" + d['class']; }); - xgridLine.append('text') + xgridLines.append('text') .attr("class", function (d) { return "" + d['class']; }) .attr("text-anchor", "end") .attr("transform", __axis_rotated ? "" : "rotate(-90)") .attr('dx', __axis_rotated ? 0 : -margin.top) - .attr('dy', -6) + .attr('dy', -5) .text(function (d) { return d.text; }); } if (__point_focus_line_enabled) { @@ -1490,12 +1490,21 @@ grid.append('g').attr('class', 'ygrids'); } if (__grid_y_lines) { - grid.append('g') + ygridLines = grid.append('g') .attr('class', 'ygrid-lines') .selectAll('ygrid-line') .data(__grid_y_lines) - .enter().append('line') - .attr("class", function (d) { return "ygrid-line " + d['class']; }); + .enter().append('g') + .attr("class", "ygrid-line"); + ygridLines.append('line') + .attr("class", function (d) { return "" + d['class']; }); + ygridLines.append('text') + .attr("class", function (d) { return "" + d['class']; }) + .attr("text-anchor", "end") + .attr("transform", __axis_rotated ? "rotate(-90)" : "") + .attr('dx', __axis_rotated ? 0 : -margin.top) + .attr('dy', -5) + .text(function (d) { return d.text; }); } // Area @@ -1981,6 +1990,9 @@ .attr("x2", __axis_rotated ? yv : width) .attr("y1", __axis_rotated ? 0 : yv) .attr("y2", __axis_rotated ? height : yv); + ygridLines.selectAll('text') + .attr("x", __axis_rotated ? 0 : width) + .attr("y", yv); } // bars diff --git a/c3.min.js b/c3.min.js index df51d83..7466c51 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,85 +1,86 @@ -(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")&&!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 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;ka?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 qb(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 0b&&(c=a,b=a.values.length)}):c=a?g.data.targets[0]:null;return c}function rb(a){a=x(a)?g.data.targets:a;return a.map(function(a){return a.id})}function yc(a){var b= +rb(),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;ek&&(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=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(ob(g.data.targets)));z.domain(mb("y"));Y.domain(mb("y2"));U.domain(m.domain());hb.domain(z.domain());ib.domain(Y.domain());J.ticks(10>a.length?a.length:10);oa.ticks(Zd).outerTickSize(0).tickFormat($d);jb.ticks(ae).outerTickSize(0).tickFormat(be);V=m.domain();K.x(U);ra&&F.x(m);n=d.select(wa).append("svg").attr("width",q+I+da).attr("height",s+u+O).on("mouseenter",ce).on("mouseleave",de);ub=n.append("defs");ub.append("clipPath").attr("id", +Qb).append("rect").attr("y",u).attr("width",q).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=n.append("g").attr("transform",M.main);A=za?n.append("g").attr("transform",M.context):null;Aa=Ba?n.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",q).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(jb);a=l.append("g").attr("clip-path",Qa).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",-5).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?q:-10).attr("y1",h?-10:u).attr("y2",h?-10:s);Xc&&a.append("g").attr("class","ygrids");Sb&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(Sb).enter().append("g").attr("class","ygrid-line"),a.append("line").attr("class",function(a){return""+a["class"]}),a.append("text").attr("class",function(a){return""+ +a["class"]}).attr("text-anchor","end").attr("transform",h?"rotate(-90)":"").attr("dx",h?0:-u).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Qa).attr("class","regions");l.append("g").attr("clip-path",Qa).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",q).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(ob()));za&&(A.append("g").attr("clip-path",Qa).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",Qa).attr("class","x brush").call(K).selectAll("rect").attr("height", +va),A.append("g").attr("class","x axis").attr("transform",M.subx).call(gb));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)?n.select(".event-rect").style("cursor","pointer"):n.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*Pa),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,n;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),n=sa?s: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),g=c.classed(Xb),l,p,q,r;l=!1; +"circle"===this.nodeName?(l=1*c.attr("cx"),p=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",Qa="url(#"+Qb+")",B="timeseries"===id,ea="categorized"===id,Gb=!B&&(qa||Z),Wb=null,Ra=!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,bb,gc,ic,q,s,va,zb,ua,eb,Bb,kb,nc,oc,Eb,lc,mc,Cb,Db,m,z,Y,U,hb,ib,J,oa,jb,gb,ld=h?"left":"bottom",md=h?db?"top":"bottom":db?"right":"left",nd=h?ab?"bottom":"top":ab?"left":"right",od="bottom",M={main:function(){return"translate("+I+","+u+")"},context:function(){return"translate("+p+","+Da+")"},legend:function(){return"translate("+ac+","+$b+")"}, +y2:function(){return"translate("+(h?0:q)+","+(h?10:0)+")"},x:function(){return"translate(0,"+s+")"},subx:function(){return"translate(0,"+va+")"},arc:function(){return"translate("+q/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(fb()/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 n,ub,l,A,Aa,W,tb,V;g.focus=function(a){var b=n.selectAll(Ua(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)&&Ya(a,!0)};g.defocus=function(a){var b=n.selectAll(Ua(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=n.selectAll(Ua(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){n.selectAll(Ua(a)).transition().style("opacity", +1)};g.hide=function(a){n.selectAll(Ua(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))Sa(Ed(a.cacheIds),a.done);else if("data"in a)Sa(Ka(a.data),a.done);else if("url"in a)d.csv(a.url,function(b,c){Sa(Ka(c),a.done)});else if("rows"in a)Sa(Ka(vc(a.rows)),a.done);else if("columns"in +a)Sa(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});n.selectAll(".target-"+a).transition().style("opacity",0).remove();Ba&&(n.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=nb(function(b){return b.id===a});return 0