diff --git a/c3.js b/c3.js index 1fb7f27..3133da6 100644 --- a/c3.js +++ b/c3.js @@ -398,8 +398,10 @@ if (isCategorized) { axis.categories(__axis_x_categories).tickCentered(__axis_x_tick_centered); } else { - // TODO: fix - axis.tickOffset = function () { return 0; }; + axis.tickOffset = function () { + var base = __axis_rotated ? height : width; + return ((base * getXDomainRatio()) / getMaxDataCount()) / 2; + }; } return axis; @@ -594,10 +596,21 @@ function getXDomainMax(targets) { return d3.max(targets, function (t) { return d3.max(t.values, function (v) { return v.x; }); }); } + function getXDomainPadding(targets, domain) { + var firstX = domain[0], lastX = domain[1], diff = Math.abs(firstX - lastX), padding; + if (isCategorized) { + padding = 0; + } else if (hasBarType(targets)) { + padding = (diff / (getMaxDataCount() - 1)) / 2; + } else { + padding = diff * 0.01; + } + return padding; + } function getXDomain(targets) { var xDomain = [getXDomainMin(targets), getXDomainMax(targets)], firstX = xDomain[0], lastX = xDomain[1], - padding = isCategorized ? 0 : Math.abs(firstX - lastX) * 0.01, + padding = getXDomainPadding(targets, xDomain), min = isTimeSeries ? new Date(firstX.getTime() - padding) : firstX - padding, max = isTimeSeries ? new Date(lastX.getTime() + padding) : lastX + padding; return [min, max]; @@ -1050,14 +1063,8 @@ return offset; }; } - function getBarW(axis, barTargetsNum, isSub) { - var barW; - if (isCategorized) { - barW = barTargetsNum ? (axis.tickOffset() * 2 * 0.6) / barTargetsNum : 0; - } else { - barW = (((__axis_rotated ? height : width) * getXDomainRatio(isSub)) / (getMaxDataCount() - 1)) * 0.6; - } - return barW; + function getBarW(axis, barTargetsNum) { + return barTargetsNum ? (axis.tickOffset() * 2 * 0.6) / barTargetsNum : 0; } //-- Type --// @@ -1321,7 +1328,7 @@ var drawBar = function (barIndices, isSub_) { var barTargetsNum = barIndices.__max__ + 1, isSub = arguments.length > 1 ? isSub_ : true, - barW = getBarW(xAxis, barTargetsNum, !!isSub), + barW = getBarW(xAxis, barTargetsNum), x = getBarX(barW, barTargetsNum, barIndices, !!isSub), y = getBarY(!!isSub), barOffset = getBarOffset(barIndices, !!isSub), diff --git a/c3.min.js b/c3.min.js index 0358825..54daef5 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,90 +1,90 @@ -(function(K){function xd(){function R(e,g){e.attr("transform",function(e){return"translate("+(g(e)+pa)+", 0)"})}function x(e,g){e.attr("transform",function(e){return"translate(0,"+g(e)+")"})}function y(e){var g=e[0];e=e[e.length-1];return ga?a:10}function ra(a){var b=!1;Pb(k.data.targets).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function yb(){var a=e.svg.arc().outerRadius(Ja).innerRadius(Fb),b=function(b,d){var f;return d?a(b):(f=ra(b))?a(f):"M 0 0"};b.centroid= -a.centroid;return b}function uc(a){var b=e.svg.arc().outerRadius(Eb*(a?a:1)).innerRadius(Fb);return function(a){return(a=ra(a))?b(a):"M 0 0"}}function Jd(a){a=ra(a);var b,c;b="";a&&(b=jb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*Ja+","+0.8*(b/c)*Ja+")");return b}function Kd(a){return Ld(a,(a.endAngle-a.startAngle)/(2*Math.PI))}function Ac(a,b){var c=n.selectAll(".chart-arc"+la(a)),d=n.selectAll(".-arc").filter(function(b){return b.data.id!==a});c.selectAll("path").transition().duration(50).attr("d", -xc).transition().duration(100).attr("d",yc).each(function(a){Qb(a.data)});b||d.style("opacity",0.3)}function Rb(a){n.selectAll(".chart-arc"+la(a)).selectAll("path").transition().duration(50).attr("d",jb);n.selectAll(".-arc").style("opacity",1)}function Md(a){var b=Bc(a),c,d,f,H;if(0a?a:0}),c=1;c+a||(b[d][c]+=+a)});return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))}function lb(a){var b=mb(function(b){return U(b.id)===a}),c="y2"===a?Pd:Qd,d="y2"===a?Rd:Sd,c=c?c:Md(b),d=d?d:Nd(b), -f=0.1*Math.abs(d-c),e=f,g=f,h="y2"===a?Td:Ud;h&&(c=Math.max(Math.abs(c),Math.abs(d)),d=c-h,c=h-c);"y"===a&&Na&&(e=z(Na.top)?Na.top:f,g=z(Na.bottom)?Na.bottom:f);"y2"===a&&Oa&&(e=z(Oa.top)?Oa.top:f,g=z(Oa.bottom)?Oa.bottom:f);ja(b,"bar")&&!Cc(b)&&(g=c);return[c-g,d+e]}function Vd(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.x})})}function Wd(a){return e.max(a,function(a){return e.max(a.values,function(a){return a.x})})}function nb(a){var b=[Vd(a),Wd(a)];a=b[0];var b=b[1], -c=ka?0:0.01*Math.abs(a-b);a=E?new Date(a.getTime()-c):a-c;b=E?new Date(b.getTime()+c):b+c;return[a,b]}function Aa(a){return a[1]-a[0]}function Xd(a){for(var b=0;ba?0:a}function Fc(a){return ua&&a===ua||ba&&Zd(ba,a)}function $d(a){return!Fc(a)} -function ae(a){Object.keys(a).forEach(function(b){ba[b]=a[b]})}function pb(a){var b;a&&(b=Pa[a.id],a.name=b?b:a.id);return a}function Gc(a){var b=a[0],c={},d=[],f,e;for(f=1;fb&&(c=a,b=a.values.length)}):c=a?k.data.targets[0]:null;return c}function Ra(a){a=x(a)?k.data.targets:a;return a.map(function(a){return a.id})}function Kc(a){var b=Ra(),c;for(c=0;ca})}function Od(a){return Lc(a,function(a){return 0f&&(e-=c+30)),c=b[1]+15+dv[c].indexOf(f.id)))for(d=0;d=e;e+=p)g+=d(a[f-1],a[f],e,m)}return g}function cc(a){var b;rb=e.select(za);if(rb.empty())K.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".'); -else{rb.html("");k.data.x={};k.data.targets=Qa(a);xa();sc();m.domain(e.extent(nb(k.data.targets)));A.domain(lb("y"));aa.domain(lb("y2"));W.domain(m.domain());hb.domain(A.domain());ib.domain(aa.domain());$=m.domain();I.scale(W);ea&&C.scale(m);n=e.select(za).append("svg").attr("width",r+D+Z).attr("height",t+q+M).on("mouseenter",te).on("mouseleave",ue);sb=n.append("defs");sb.append("clipPath").attr("id",dc).append("rect").attr("y",q).attr("width",r).attr("height",t-q);sb.append("clipPath").attr("id", -"xaxis-clip").append("rect").attr("x",-1-D).attr("y",-20).attr("width",fa).attr("height",zb);sb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-D+1).attr("y",q-1).attr("width",yd).attr("height",Y);l=n.append("g").attr("transform",J.main);G=Ea?n.append("g").attr("transform",J.context):null;Fa=Ga?n.append("g").attr("transform",J.legend):null;X=e.select(za).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("+document.URL+"#xaxis-clip)").attr("transform",J.x).call(h?La:N).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text(ve);l.append("g").attr("class","y axis").attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").call(h?N:La).append("text").attr("transform","rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(we);Cb&&l.append("g").attr("class","y2 axis").attr("transform", -J.y2).call(Ob);a=l.append("g").attr("clip-path",Xa).attr("class","grid");kd&&a.append("g").attr("class","xgrids");ec&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(ec).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:-q).attr("dy",-5).text(function(a){return a.text})); -xe&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",h?0:-10).attr("x2",h?r:-10).attr("y1",h?-10:q).attr("y2",h?-10:t);ld&&a.append("g").attr("class","ygrids");fc&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(fc).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:-q).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Xa).attr("class","regions");l.append("g").attr("clip-path",Xa).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",ea?h?"ns-resize":"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", -J.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(ye);if(ea)l.insert("rect",ze?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",t).style("opacity",0).style("cursor",h?"ns-resize":"ew-resize").call(C).on("dblclick.zoom",null);null!==tb&&I.extent("function"!==typeof tb?tb:tb(nb()));Ea&&(G.append("g").attr("clip-path",Xa).attr("class","chart"),G.select(".chart").append("g").attr("class","chart-bars"),G.select(".chart").append("g").attr("class", -"chart-lines"),G.append("g").attr("clip-path",Xa).attr("class","x brush").call(I).selectAll("rect").attr(h?"width":"height",h?Db:fb),G.append("g").attr("class","x axis").attr("transform",J.subx).attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").call(gb));Ga&&ub(k.data.targets);md(k.data.targets);w({withTransform:!0,withUpdateXDomain:!0});if(Ae){if(E&&"string"===typeof Ha){Ha=ta(Ha);for(a=0;aUb(c,a)?n.select(".event-rect").style("cursor","pointer"):n.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;F(k.data.targets)||(a=e.mouse(this),c=Vc(k.data.targets,a),100>Ub(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){pd(this,c,c.index)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){qd(e.mouse(this))}).on("dragstart",function(){rd(e.mouse(this))}).on("dragend",function(){sd()})).call(C).on("dblclick.zoom", -null)}function pd(a,b,c){var d=e.select(a),f=d.classed(oa),g=!1,h;"circle"===a.nodeName?(g=dd(a,1.5*Wa),h=gd):"rect"===a.nodeName&&(g=ed(a),h=id);if(wa||g)ma&&na(b)&&(d.classed(oa,!f),h(!f,d,b,c)),Ee(b,d)}function qd(a){var b,c,d,f,g,h,m;F(k.data.targets)||!ma||ea&&!C.altDomain||(b=jc[0],c=jc[1],d=a[0],a=a[1],f=Math.min(b,d),g=Math.max(b,d),h=wa?q:Math.min(c,a),m=wa?t:Math.max(c,a),l.select(".dragarea").attr("x",f).attr("y",h).attr("width",g-f).attr("height",m-h),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return na(a)}).each(function(a, -b){var c=e.select(this),d=c.classed(oa),k=c.classed(kc),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=gd,l=f"+d+""),h=a[e].name,g=b(a[e].value),d+=""+h+""+g+"");return d+""}),Ae=g(["tooltip", -"init","show"],!1),Ha=g(["tooltip","init","x"],0),nd=g(["tooltip","init","position"],{top:"0px",left:"50px"}),dc=za.replace("#","")+"-clip",Xa="url("+document.URL+"#"+dc+")",E="timeseries"===wd,ka="categorized"===wd,Tb=!E&&(ua||ba),jc=null,Ya=!1,ic=!1,sa=Ga?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]}}(Ne, -Oe),Hd=function(){var a=[[e.time.format("%Y/%-m/%-d"),function(){return!0}],[e.time.format("%-m/%-d"),function(a){return a.getMonth()}],[e.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[e.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[e.time.format("%I %p"),function(a){return a.getHours()}],[e.time.format("%I:%M"),function(a){return a.getMinutes()}],[e.time.format(":%S"),function(a){return a.getSeconds()}],[e.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)}}(),r,Db,t,fb,Ab,ya,Ja,Eb,Fb,jb,xc,yc,Pb,Hb,Ib,Jb,Kb,Lb,Mb,m,A,aa,W,hb,ib,N,La,Ob,gb,zd=h?"left":"bottom",Bd=h?cb?"top":"bottom":cb?"right":"left",Dd=h?eb?"bottom":"top":eb?"left":"right",Ad=h?"left":"bottom",J={main:function(){return"translate("+D+","+q+")"},context:function(){return"translate("+rc+","+xb+")"},legend:function(){return"translate("+qc+","+pc+")"},y2:function(){return"translate("+(h?0:r)+","+(h?10:0)+")"}, -x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+(h?0:fb)+")"},arc:function(){return"translate("+r/2+","+t/2+")"}},wc=40,vc=20;Pb=e.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var He=function(){var a=e.svg.line().x(h?function(a){return s(a.id)(a.value)}:Ba).y(h?Ba:function(a){return s(a.id)(a.value)});return function(b){var c=Zb(b.values),d;if(Wb(b))return ad(b)?a.interpolate("cardinal"):a.interpolate("linear"),vd[b.id]?se(c, -m,s(b.id),vd[b.id]):a(c);d=m(c[0].x);b=s(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),Ie=function(){var a;a=h?e.svg.area().x0(function(a){return s(a.id)(0)}).x1(function(a){return s(a.id)(a.value)}).y(Ba):e.svg.area().x(Ba).y0(function(a){return s(a.id)(0)}).y1(function(a){return s(a.id)(a.value)});return function(b){var c=Zb(b.values),d;if(ja([b],"area")||ja([b],"area-spline"))return ad(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=s(b.id)(c[0].value);return h? -"M "+b+" "+d:"M "+d+" "+b}}(),vb=function(a,b){var c=a.__max__+1,d=1b.classes.indexOf(a)})});return Q};k.data.get=function(a){a=k.data.getAsTarget(a); -return y(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=mb(function(b){return b.id===a});return 0a?a:10}function qa(a){var b=!1;Pb(k.data.targets).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)});return b?a:null}function yb(){var a=e.svg.arc().outerRadius(Ka).innerRadius(Fb),b=function(b,d){var f;return d?a(b): +(f=qa(b))?a(f):"M 0 0"};b.centroid=a.centroid;return b}function uc(a){var b=e.svg.arc().outerRadius(Eb*(a?a:1)).innerRadius(Fb);return function(a){return(a=qa(a))?b(a):"M 0 0"}}function Jd(a){a=qa(a);var b,c;b="";a&&(b=jb.centroid(a),a=b[0],b=b[1],c=Math.sqrt(a*a+b*b),b="translate("+0.8*(a/c)*Ka+","+0.8*(b/c)*Ka+")");return b}function Kd(a){return Ld(a,(a.endAngle-a.startAngle)/(2*Math.PI))}function Ac(a,b){var c=n.selectAll(".chart-arc"+ka(a)),d=n.selectAll(".-arc").filter(function(b){return b.data.id!== +a});c.selectAll("path").transition().duration(50).attr("d",xc).transition().duration(100).attr("d",yc).each(function(a){Qb(a.data)});b||d.style("opacity",0.3)}function Rb(a){n.selectAll(".chart-arc"+ka(a)).selectAll("path").transition().duration(50).attr("d",jb);n.selectAll(".-arc").style("opacity",1)}function Md(a){var b=Bc(a),c,d,f,H;if(0a?a:0}),c=1;c+a||(b[d][c]+=+a)});return e.max(Object.keys(b).map(function(a){return e.max(b[a])}))}function lb(a){var b=mb(function(b){return U(b.id)===a}),c="y2"=== +a?Pd:Qd,d="y2"===a?Rd:Sd,c=c?c:Md(b),d=d?d:Nd(b),f=0.1*Math.abs(d-c),e=f,g=f,h="y2"===a?Td:Ud;h&&(c=Math.max(Math.abs(c),Math.abs(d)),d=c-h,c=h-c);"y"===a&&Na&&(e=z(Na.top)?Na.top:f,g=z(Na.bottom)?Na.bottom:f);"y2"===a&&Oa&&(e=z(Oa.top)?Oa.top:f,g=z(Oa.bottom)?Oa.bottom:f);$(b,"bar")&&!Cc(b)&&(g=c);return[c-g,d+e]}function Vd(a){return e.min(a,function(a){return e.min(a.values,function(a){return a.x})})}function Wd(a){return e.max(a,function(a){return e.max(a.values,function(a){return a.x})})}function nb(a){var b= +[Vd(a),Wd(a)],c=b[0],d=b[1],b=Math.abs(b[0]-b[1]);a=sa?0:$(a,"bar")?b/(Ba()-1)/2:0.01*b;c=E?new Date(c.getTime()-a):c-a;d=E?new Date(d.getTime()+a):d+a;return[c,d]}function Aa(a){return a[1]-a[0]}function Xd(a){for(var b=0;ba?0:a} +function Fc(a){return ua&&a===ua||ca&&Zd(ca,a)}function $d(a){return!Fc(a)}function ae(a){Object.keys(a).forEach(function(b){ca[b]=a[b]})}function pb(a){var b;a&&(b=Pa[a.id],a.name=b?b:a.id);return a}function Gc(a){var b=a[0],c={},d=[],f,e;for(f=1;fb&&(c=a,b=a.values.length)}):c=a?k.data.targets[0]:null;return c}function Ra(a){a=x(a)?k.data.targets:a;return a.map(function(a){return a.id})}function Kc(a){var b=Ra(),c;for(c=0;ca})}function Od(a){return Lc(a,function(a){return 0f&&(e-=c+30)),c=b[1]+15+ +dv[c].indexOf(f.id)))for(d=0;d=e;e+=p)g+=d(a[f-1],a[f],e,m)}return g}function cc(a){var b; +rb=e.select(za);if(rb.empty())K.alert('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".');else{rb.html("");k.data.x={};k.data.targets=Qa(a);xa();sc();m.domain(e.extent(nb(k.data.targets)));A.domain(lb("y"));ba.domain(lb("y2"));W.domain(m.domain());hb.domain(A.domain());ib.domain(ba.domain());aa=m.domain();I.scale(W);fa&&C.scale(m);n=e.select(za).append("svg").attr("width",r+D+Z).attr("height",t+q+M).on("mouseenter",te).on("mouseleave", +ue);sb=n.append("defs");sb.append("clipPath").attr("id",dc).append("rect").attr("y",q).attr("width",r).attr("height",t-q);sb.append("clipPath").attr("id","xaxis-clip").append("rect").attr("x",-1-D).attr("y",-20).attr("width",ga).attr("height",zb);sb.append("clipPath").attr("id","yaxis-clip").append("rect").attr("x",-D+1).attr("y",q-1).attr("width",yd).attr("height",Y);l=n.append("g").attr("transform",J.main);G=Fa?n.append("g").attr("transform",J.context):null;Ga=Ha?n.append("g").attr("transform", +J.legend):null;X=e.select(za).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("+document.URL+"#xaxis-clip)").attr("transform",J.x).call(h?La:N).append("text").attr("class","-axis-x-label").attr("x",r).attr("dy","-.5em").style("text-anchor","end").text(ve);l.append("g").attr("class","y axis").attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").call(h?N:La).append("text").attr("transform", +"rotate(-90)").attr("dy","1.2em").attr("dx","-.5em").style("text-anchor","end").text(we);Cb&&l.append("g").attr("class","y2 axis").attr("transform",J.y2).call(Ob);a=l.append("g").attr("clip-path",Xa).attr("class","grid");kd&&a.append("g").attr("class","xgrids");ec&&(b=a.append("g").attr("class","xgrid-lines").selectAll(".xgrid-line").data(ec).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:-q).attr("dy",-5).text(function(a){return a.text}));xe&&a.append("g").attr("class","xgrid-focus").append("line").attr("class","xgrid-focus").attr("x1",h?0:-10).attr("x2",h?r:-10).attr("y1",h?-10:q).attr("y2",h?-10:t);ld&&a.append("g").attr("class","ygrids");fc&&(a=a.append("g").attr("class","ygrid-lines").selectAll("ygrid-line").data(fc).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:-q).attr("dy",-5).text(function(a){return a.text}));l.append("g").attr("clip-path",Xa).attr("class","regions");l.append("g").attr("clip-path",Xa).attr("class","chart");l.select(".chart").append("g").attr("class","event-rects").style("fill-opacity",0).style("cursor",fa?h?"ns-resize":"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",J.arc).append("text").attr("class","chart-arcs-title").style("text-anchor","middle").text(ye);if(fa)l.insert("rect",ze?null:"g.grid").attr("class","zoom-rect").attr("width",r).attr("height",t).style("opacity",0).style("cursor",h?"ns-resize":"ew-resize").call(C).on("dblclick.zoom",null);null!==tb&&I.extent("function"!==typeof tb?tb:tb(nb()));Fa&&(G.append("g").attr("clip-path", +Xa).attr("class","chart"),G.select(".chart").append("g").attr("class","chart-bars"),G.select(".chart").append("g").attr("class","chart-lines"),G.append("g").attr("clip-path",Xa).attr("class","x brush").call(I).selectAll("rect").attr(h?"width":"height",h?Db:fb),G.append("g").attr("class","x axis").attr("transform",J.subx).attr("clip-path",h?"url("+document.URL+"#yaxis-clip)":"").call(gb));Ha&&ub(k.data.targets);md(k.data.targets);w({withTransform:!0,withUpdateXDomain:!0});if(Ae){if(E&&"string"===typeof Ia){Ia= +ta(Ia);for(a=0;aUb(c,a)?n.select(".event-rect").style("cursor","pointer"):n.select(".event-rect").style("cursor",null))}).on("click",function(){var a,c;F(k.data.targets)||(a=e.mouse(this),c=Vc(k.data.targets,a),100>Ub(c,a)&&l.select(".-circles-"+c.id).select(".-circle-"+c.index).each(function(){pd(this, +c,c.index)}))}).call(e.behavior.drag().origin(Object).on("drag",function(){qd(e.mouse(this))}).on("dragstart",function(){rd(e.mouse(this))}).on("dragend",function(){sd()})).call(C).on("dblclick.zoom",null)}function pd(a,b,c){var d=e.select(a),f=d.classed(na),g=!1,h;"circle"===a.nodeName?(g=dd(a,1.5*Wa),h=gd):"rect"===a.nodeName&&(g=ed(a),h=id);if(wa||g)la&&ma(b)&&(d.classed(na,!f),h(!f,d,b,c)),Ee(b,d)}function qd(a){var b,c,d,f,g,h,m;F(k.data.targets)||!la||fa&&!C.altDomain||(b=jc[0],c=jc[1],d=a[0], +a=a[1],f=Math.min(b,d),g=Math.max(b,d),h=wa?q:Math.min(c,a),m=wa?t:Math.max(c,a),l.select(".dragarea").attr("x",f).attr("y",h).attr("width",g-f).attr("height",m-h),l.selectAll(".-shapes").selectAll(".-shape").filter(function(a){return ma(a)}).each(function(a,b){var c=e.select(this),d=c.classed(na),k=c.classed(kc),l,n,p,q;l=!1;"circle"===this.nodeName?(l=1*c.attr("cx"),n=1*c.attr("cy"),q=gd,l=f"+d+""),h=a[e].name,g=b(a[e].value),d+=""+h+""+g+"");return d+""}),Ae=g(["tooltip","init","show"],!1),Ia=g(["tooltip","init","x"],0),nd=g(["tooltip","init","position"],{top:"0px",left:"50px"}),dc=za.replace("#", +"")+"-clip",Xa="url("+document.URL+"#"+dc+")",E="timeseries"===wd,sa="categorized"===wd,Tb=!E&&(ua||ca),jc=null,Ya=!1,ic=!1,ra=Ha?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]}}(Ne,Oe),Hd=function(){var a=[[e.time.format("%Y/%-m/%-d"),function(){return!0}],[e.time.format("%-m/%-d"),function(a){return a.getMonth()}], +[e.time.format("%-m/%-d"),function(a){return 1!==a.getDate()}],[e.time.format("%-m/%-d"),function(a){return a.getDay()&&1!==a.getDate()}],[e.time.format("%I %p"),function(a){return a.getHours()}],[e.time.format("%I:%M"),function(a){return a.getMinutes()}],[e.time.format(":%S"),function(a){return a.getSeconds()}],[e.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)}}(),r,Db,t,fb,Ab,ya,Ka,Eb,Fb,jb,xc,yc,Pb,Hb, +Ib,Jb,Kb,Lb,Mb,m,A,ba,W,hb,ib,N,La,Ob,gb,zd=h?"left":"bottom",Bd=h?cb?"top":"bottom":cb?"right":"left",Dd=h?eb?"bottom":"top":eb?"left":"right",Ad=h?"left":"bottom",J={main:function(){return"translate("+D+","+q+")"},context:function(){return"translate("+rc+","+xb+")"},legend:function(){return"translate("+qc+","+pc+")"},y2:function(){return"translate("+(h?0:r)+","+(h?10:0)+")"},x:function(){return"translate(0,"+t+")"},subx:function(){return"translate(0,"+(h?0:fb)+")"},arc:function(){return"translate("+ +r/2+","+t/2+")"}},wc=40,vc=20;Pb=e.layout.pie().value(function(a){return a.values.reduce(function(a,c){return a+c.value},0)});var He=function(){var a=e.svg.line().x(h?function(a){return s(a.id)(a.value)}:Ca).y(h?Ca:function(a){return s(a.id)(a.value)});return function(b){var c=Zb(b.values),d;if(Wb(b))return ad(b)?a.interpolate("cardinal"):a.interpolate("linear"),vd[b.id]?se(c,m,s(b.id),vd[b.id]):a(c);d=m(c[0].x);b=s(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),Ie=function(){var a;a=h? +e.svg.area().x0(function(a){return s(a.id)(0)}).x1(function(a){return s(a.id)(a.value)}).y(Ca):e.svg.area().x(Ca).y0(function(a){return s(a.id)(0)}).y1(function(a){return s(a.id)(a.value)});return function(b){var c=Zb(b.values),d;if($([b],"area")||$([b],"area-spline"))return ad(b)?a.interpolate("cardinal"):a.interpolate("linear"),a(c);d=m(c[0].x);b=s(b.id)(c[0].value);return h?"M "+b+" "+d:"M "+d+" "+b}}(),vb=function(a,b){var c=a.__max__+1,d=1b.classes.indexOf(a)})});return Q};k.data.get=function(a){a=k.data.getAsTarget(a);return y(a)?a.values.map(function(a){return a.value}):void 0};k.data.getAsTarget=function(a){var b=mb(function(b){return b.id=== +a});return 0