diff --git a/c3.js b/c3.js index b088697..8f3a4cb 100644 --- a/c3.js +++ b/c3.js @@ -1217,7 +1217,7 @@ yDomainMax = isValue(yMax) ? yMax : getYDomainMax(yTargets), domainLength, padding, padding_top, padding_bottom, center = axisId === 'y2' ? __axis_y2_center : __axis_y_center, - yDomainAbs, widths, diff, ratio, + yDomainAbs, lengths, diff, ratio, showHorizontalDataLabel = hasDataLabel() && __axis_rotated; if (yTargets.length === 0) { // use current domain if target of axisId is none return axisId === 'y2' ? y2.domain() : y.domain(); @@ -1234,11 +1234,15 @@ } // add padding for data label if (showHorizontalDataLabel) { - widths = getDataLabelWidth(yDomainMin, yDomainMax, axisId); + lengths = getDataLabelLength(yDomainMin, yDomainMax, axisId, 'width'); diff = diffDomain(y.range()); - ratio = [widths[0] / diff, widths[1] / diff]; + ratio = [lengths[0] / diff, lengths[1] / diff]; padding_top += domainLength * (ratio[1] / (1 - ratio[0] - ratio[1])); padding_bottom += domainLength * (ratio[0] / (1 - ratio[0] - ratio[1])); + } else { + lengths = getDataLabelLength(yDomainMin, yDomainMax, axisId, 'height'); + padding_top += lengths[1]; + padding_bottom += lengths[0]; } if (axisId === 'y' && __axis_y_padding) { padding_top = getAxisPadding(__axis_y_padding, 'top', padding, domainLength); @@ -1806,17 +1810,17 @@ } return false; } - function getDataLabelWidth(min, max, axisId) { - var widths = [], paddingCoef = 1.3; + function getDataLabelLength(min, max, axisId, key) { + var lengths = [0, 0], paddingCoef = 1.3; selectChart.select('svg').selectAll('.dummy') .data([min, max]) .enter().append('text') .text(function (d) { return formatByAxisId(axisId)(d); }) .each(function (d, i) { - widths[i] = this.getBoundingClientRect().width * paddingCoef; + lengths[i] = this.getBoundingClientRect()[key] * paddingCoef; }) .remove(); - return widths; + return lengths; } function getYFormat(forArc) { var formatForY = forArc && !hasGaugeType(c3.data.targets) ? defaultArcValueFormat : yFormat, diff --git a/c3.min.js b/c3.min.js index 957712e..24dab31 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1,3 +1,3 @@ -!function(a){"use strict";function b(a){return a||0===a}function c(a){return"undefined"==typeof a}function d(a){return"undefined"!=typeof a}function e(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,k);for(c=a.domain(),b=Math.ceil(c[0]);b0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=m.copy();return b&&(a=m.domain(),c.domain([a[0],a[1]-1])),c}function h(a){return j?j(a):a}function i(i){i.each(function(){function i(a){var b=m(a)+s;return B[0]=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"}function k(a){return Math.ceil(a)+.5}function l(a,b){var c,d,e;b&&b.axisX?c=b.axisX:(c=nk.select("."+g.axisX),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=nk.select("."+g.axisY),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=nk.select("."+g.axisY2),a&&(e=e.transition())),nk.attr("transform",ak.main),c.attr("transform",ak.x),d.attr("transform",ak.y),e.attr("transform",ak.y2),nk.select("."+g.chartArcs).attr("transform",ak.arc)}function m(a,b){var c;b&&b.axisSubX?c=b.axisSubX:(c=ok.select("."+g.axisX),a&&(c=c.transition())),ok.attr("transform",ak.context),c.attr("transform",ak.subx)}function n(a){(a?pk.transition():pk).attr("transform",ak.legend)}function o(a,b){l(a,b),Oh&&m(a,b),n(a)}function p(){var a=V(),b=U(),c=bk?0:a,d=we(lg.data.targets),e=Yh||d?0:A("x"),f=Oh&&!d?Ph+e:0;Kg=t(),Lg=u(),Yh?(Dg={top:A("y2")+v(),right:d?0:y(),bottom:A("y")+c+w(),left:f+(d?0:x())},Eg={top:Dg.top,right:0/0,bottom:20+c,left:gk}):(Dg={top:4+v(),right:d?0:y(),bottom:e+f+c+w(),left:d?0:x()},Eg={top:Lg-f-c,right:0/0,bottom:e+c,left:Dg.left}),Fg={top:bk?0:Lg-a,right:0/0,bottom:0,left:bk?Kg-b:0},Gg=Kg-Dg.left-Dg.right,Ig=Lg-Dg.top-Dg.bottom,0>Gg&&(Gg=0),0>Ig&&(Ig=0),Hg=Yh?Dg.left-gk-hk:Gg,Jg=Yh?Ig:Lg-Eg.top-Eg.bottom,0>Hg&&(Hg=0),0>Jg&&(Jg=0),Pg=Gg-(bk?b+10:0),Qg=Ig-(bk?0:10),r(),bk&&d&&(Fg.left=Pg/2+1.1*Ng)}function q(){nk.select("line."+g.xgridFocus).attr("x1",Yh?0:-10).attr("x2",Yh?Gg:-10).attr("y1",Yh?-10:Dg.top).attr("y2",Yh?-10:Ig)}function r(){var a;Ng=Math.min(Pg,Qg)/2,Mg=.95*Ng,a=kj?(Mg-kj)/Mg:.6,Og=ve(lg.data.targets)||ue(lg.data.targets)?Mg*a:0}function s(){var a=Yh?g.axisX:g.axisY,b=nk.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=rk.node().getBoundingClientRect(),e=we(lg.data.targets),f=c.right-d.left-(e?0:x());return f>0?f:0}function t(){return og?og:C()}function u(){var a=pg?pg:D();return a>0?a:320}function v(){return sg?sg:0}function w(){return tg?tg:0}function x(){return qg?qg:Yh?Zh?Math.max($e(z("x")),40):1:!pi||ui?1:$e(z("y"))}function y(){var a=10,b=bk?U()+20:0;return rg?rg:Yh?a+b:(!yi||Di?a:$e(z("y2")))+b}function z(a){var b=pb(a);return b.isInner?20+Ib(a):40+Ib(a)}function A(a){return"x"!==a||Zh?"x"===a&&mi?mi:"y"!==a||pi?"y2"!==a||yi?(pb(a).isInner?30:40)+("y2"===a?-10:0):ik:Sh&&!bk?10:1:0}function B(a){for(var b,c=rk.node();c&&"BODY"!==c.tagName&&!(b=c.getBoundingClientRect()[a]);)c=c.parentNode;return b}function C(){return B("width")}function D(){var a=rk.style("height");return a.indexOf("px")>0?+a.replace("px",""):0}function E(a){return a?-31:-(Dg.left-1)}function F(a){return a?-20:-4}function G(){return E(!Yh)}function H(){return F(!Yh)}function I(){return E(Yh)}function J(){return F(Yh)}function K(a){return a?Gg+2+30+30:Dg.left+20}function L(a){return a?(mi?mi:0)+80:Ig+8}function M(){return K(!Yh)}function N(){return L(!Yh)}function O(){return K(Yh)}function P(){return L(Yh)}function Q(){var a,b,c,d,e,f,g=Oc(lg.data.targets);return g?(a=g.values[0],b=g.values[g.values.length-1],c=bh(b.x)-bh(a.x),0===c?Yh?Ig:Gg:(d=Nc(),e=re(lg.data.targets)?(d-(Jj?.25:1))/d:1,f=d>1?c*e/(d-1):c,1>f?1:f)):0}function R(a){ck=a}function S(a){dk=a}function T(a){ek=a}function U(){return Sh?bk?dk*(ck+1):Kg:0}function V(){return Sh?bk?Lg:Math.max(20,ek)*(ck+1):0}function W(){var a,b,c=!bh;Vg=Yh?1:0,Wg=Yh?Ig:Gg,Xg=Yh?0:Ig,Yg=Yh?Gg:1,Zg=Vg,$g=Wg,_g=Yh?0:Jg,ah=Yh?Hg:1,bh=Z(Vg,Wg,c?void 0:bh.domain(),function(){return hh.tickOffset()}),ch=$(Xg,Yg,c?void 0:ch.domain()),dh=$(Xg,Yg,c?void 0:dh.domain()),eh=Z(Vg,Wg,sk,function(a){return a%1?0:kh.tickOffset()}),fh=$(_g,ah,c?void 0:fh.domain()),gh=$(_g,ah,c?void 0:gh.domain()),a=eb(),b=hi?hi:c?void 0:hh.tickValues(),hh=bb(bh,Yj,a,b),kh=bb(eh,_j,a,b),ih=cb(ch,Zj,vi,xi),jh=cb(dh,$j,Ei,Gi),c||(jk.scale(eh),ug&&kk.scale(bh)),X()}function X(){Rg=Lb(),Sg=Mb(),Tg=Mb(.98)}function Y(a,b,c){return(c?kg.time.scale():kg.scale.linear()).range([a,b])}function Z(a,b,c,d){var e,f=Y(a,b,Ij),g=c?f.domain(c):f;Jj?(d=d||function(){return 0},f=function(a,b){var c=g(a)+d(a);return b?c:Math.ceil(c)}):f=function(a,b){var c=g(a);return b?c:Math.ceil(c)};for(e in g)f[e]=g[e];return f.orgDomain=function(){var a=g.domain();return sk&&sk[0]===a[0]&&sk[1]a?a.toFixed(0):a};return ci&&("function"==typeof ci?a=ci:Ij&&(a=function(a){return a?Tj(ci)(a):""})),a}function fb(a){var b;return"y"===a?b=ti:"y2"===a?b=Ci:"x"===a&&(b=oi),b}function gb(a){var b=fb(a);return"string"==typeof b?b:b?b.text:null}function hb(a,b){var c=fb(a);"string"==typeof c?"y"===a?ti=b:"y2"===a?Ci=b:"x"===a&&(oi=b):c&&(c.text=b)}function ib(a){return 10*Math.sin(Math.PI*(a/180))}function jb(a){return 11.5-2.5*(a/15)}function kb(a,b,c){a.selectAll(".tick text").style("text-anchor","start"),b.selectAll(".tick text").attr("y",jb(c)).attr("x",ib(c)).attr("transform","rotate("+c+")")}function lb(a,b){var c=fb(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}}function mb(){return lb("x",Yh?"inner-top":"inner-right")}function nb(){return lb("y",Yh?"inner-right":"inner-top")}function ob(){return lb("y2",Yh?"inner-right":"inner-top")}function pb(a){return"y2"===a?ob():"y"===a?nb():mb()}function qb(){return gb("x")}function rb(){return gb("y")}function sb(){return gb("y2")}function tb(a,b){return a?b.isLeft?0:b.isCenter?Gg/2:Gg:b.isBottom?-Ig:b.isMiddle?-Ig/2:0}function ub(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function vb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function wb(){return tb(!Yh,mb())}function xb(){return tb(Yh,nb())}function yb(){return tb(Yh,ob())}function zb(){return ub(!Yh,mb())}function Ab(){return ub(Yh,nb())}function Bb(){return ub(Yh,ob())}function Cb(){var a=mb();return Yh?a.isInner?"1.2em":-25-Ib("x"):a.isInner?"-0.5em":mi?mi-10:"3em"}function Db(){var a=nb();return Yh?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-Ib("y")}function Eb(){var a=ob();return Yh?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+Ib("y2")}function Fb(){return vb(!Yh,mb())}function Gb(){return vb(Yh,nb())}function Hb(){return vb(Yh,ob())}function Ib(a){var b=0,c="x"===a?g.axisX:"y"===a?g.axisY:g.axisY2;return kg.selectAll("."+c+" .tick text").each(function(){var a=this.getBoundingClientRect();bb?0:b}function Jb(a){var b=nk.select("."+g.axisX+" ."+g.axisXLabel),c=nk.select("."+g.axisY+" ."+g.axisYLabel),d=nk.select("."+g.axisY2+" ."+g.axisY2Label);(a?b.transition():b).attr("x",wb).attr("dx",zb).attr("dy",Cb).text(qb),(a?c.transition():c).attr("x",xb).attr("dx",Ab).attr("dy",Db).attr("dy",Db).text(rb),(a?d.transition():d).attr("x",yb).attr("dx",Bb).attr("dy",Eb).text(sb)}function Kb(a){var b=!1;if(Ug(Vc(lg.data.targets)).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)}),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),Ee(a.data)){var c=ej,d=fj,e=Math.abs(c)+d,f=Math.PI/e;a.startAngle=-1*(Math.PI/2)+f*Math.abs(c),a.endAngle=a.startAngle+f*(a.value>d?d:a.value)}return b?a:null}function Lb(){var a=kg.svg.arc().outerRadius(Mg).innerRadius(Og),b=function(b,c){var d;return c?a(b):(d=Kb(b),d?a(d):"M 0 0")};return b.centroid=a.centroid,b}function Mb(a){var b=kg.svg.arc().outerRadius(Ng*(a?a:1)).innerRadius(Og);return function(a){var c=Kb(a);return c?b(c):"M 0 0"}}function Nb(a,b,c){return c||Ge(a.data)?Rg(a,b):"M 0 0"}function Ob(a){var b,c,d,e,f,g=Kb(a),h="";return g&&!ue(lg.data.targets)&&(b=Rg.centroid(g),c=isNaN(b[0])?0:b[0],d=isNaN(b[1])?0:b[1],e=Math.sqrt(c*c+d*d),f=Mg&&e?(36/Mg>.375?1.175-36/Mg:.8)*Mg/e:0,h="translate("+c*f+","+d*f+")"),h}function Pb(a){var b=ue(lg.data.targets)?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/b:null}function Qb(a){return Ac({id:a.data.id,value:a.value,ratio:Pb(a)})}function Rb(a){var b,c,d,e;return Ub()?(b=Kb(a),c=b?b.value:null,d=Pb(b),Vb(d)?(e=Wb(),e?e(c,d):Qd(c,d)):""):""}function Sb(a,b){var c=lk.selectAll("."+g.chartArc+Cd(a)),d=lk.selectAll("."+g.arc).filter(function(b){return b.data.id!==a});Me(a)&&c.selectAll("path").transition().duration(50).attr("d",Sg).transition().duration(100).attr("d",Tg).each(function(a){Fe(a.data)}),b||d.style("opacity",.3)}function Tb(a){var b=lk.selectAll("."+g.chartArc+Cd(a));b.selectAll("path."+g.arc).transition().duration(50).attr("d",Rg),lk.selectAll("."+g.arc).style("opacity",1)}function Ub(){var a=!0;return ve(lg.data.targets)?a=lj:te(lg.data.targets)&&(a=Wi),a}function Vb(a){var b=ve(lg.data.targets)?nj:Yi;return a>=b}function Wb(){var a=Xi;return ue(lg.data.targets)?a=cj:ve(lg.data.targets)&&(a=mj),a}function Xb(){return ve(lg.data.targets)?pj:""}function Yb(){var a=$i;return ue(lg.data.targets)?a=gj:ve(lg.data.targets)&&(a=qj),"function"==typeof a?a:function(){}}function Zb(){var a=_i;return ue(lg.data.targets)?a=hj:ve(lg.data.targets)&&(a=rj),"function"==typeof a?a:function(){}}function $b(){var a=aj;return ue(lg.data.targets)?a=ij:ve(lg.data.targets)&&(a=sj),"function"==typeof a?a:function(){}}function _b(a,c,d,e){var f="ratio"===a.unit?e:1;return b(a[c])?a[c]*f:d}function ac(a){var b,c,d,e,f,g,h=Qc(a),i=ad(a);if(rh.length>0)for(g=cd(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=0>a?a:0}),c=1;c0||(i[d][b]+=+a)});return kg.min(Object.keys(i).map(function(a){return kg.min(i[a])}))}function bc(a){var b,c,d,e,f,g,h=Qc(a),i=ad(a);if(rh.length>0)for(g=dd(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=a>0?a:0}),c=1;c+a||(i[d][b]+=+a)});return kg.max(Object.keys(i).map(function(a){return kg.max(i[a])}))}function cc(a,c){var d,e,f,g,h,i,j,k,l=a.filter(function(a){return db(a.id)===c}),m="y2"===c?Ai:ri,n="y2"===c?zi:qi,o=b(m)?m:ac(l),p=b(n)?n:bc(l),q="y2"===c?Bi:si,r=Kd()&&Yh;return 0===l.length?"y2"===c?dh.domain():ch.domain():(o===p&&(0>o?p=0:o=0),d=Math.abs(p-o),e=f=g=r?0:.1*d,q&&(h=Math.max(Math.abs(o),Math.abs(p)),p=h-q,o=q-h),r&&(i=Ld(o,p,c),j=ic(ch.range()),k=[i[0]/j,i[1]/j],f+=d*(k[1]/(1-k[0]-k[1])),g+=d*(k[0]/(1-k[0]-k[1]))),"y"===c&&wi&&(f=_b(wi,"top",e,d),g=_b(wi,"bottom",e,d)),"y2"===c&&Fi&&(f=_b(Fi,"top",e,d),g=_b(Fi,"bottom",e,d)),re(l)&&!cd(l)&&(g=o),[o-g,p+f])}function dc(a){return ki?Ij?Pe(ki):ki:kg.min(a,function(a){return kg.min(a.values,function(a){return a.x})})}function ec(a){return ji?Ij?Pe(ji):ji:kg.max(a,function(a){return kg.max(a.values,function(a){return a.x})})}function fc(a){var c,d,e,f,g=Pc(a),h=g[1]-g[0];return Jj?d=0:re(a)?(c=Nc(),d=c>1?h/(c-1)/2:.5):d=.01*h,"object"==typeof li&&Ue(li)?(e=b(li.left)?li.left:d,f=b(li.right)?li.right:d):e=f="number"==typeof li?li:d,{left:e,right:f}}function gc(a){var b=[dc(a),ec(a)],c=b[0],d=b[1],e=fc(a),f=0,g=0;return c-d!==0||Jj||(c=Ij?new Date(.5*c.getTime()):-.5,d=Ij?new Date(1.5*d.getTime()):.5),(c||0===c)&&(f=Ij?new Date(c.getTime()-e.left):c-e.left),(d||0===d)&&(g=Ij?new Date(d.getTime()+e.right):d+e.right),[f,g]}function hc(a,b,c,d){c&&(bh.domain(d?d:kg.extent(gc(a))),sk=bh.domain(),ug&&kk.scale(bh).updateScaleExtent(),eh.domain(bh.domain()),jk.scale(eh)),b&&(bh.domain(d?d:jk.empty()?sk:jk.extent()),ug&&kk.scale(bh).updateScaleExtent())}function ic(a){return a[1]-a[0]}function jc(a){for(var b=0;bb?0:b-c}function pc(a){var b,c=nc(a),d="y"===a.axis?ch:dh;return b="y"===a.axis||"y2"===a.axis?Yh?Ig:"start"in a?d(a.start):Ig:Yh?"end"in a?bh(Ij?Pe(a.end):a.end):Ig:Ig,c>b?0:b-c}function qc(a){return!a.axis||"x"===a.axis}function rc(a){return lh&&a===lh||Ue(mh)&&Ve(mh,a)}function sc(a){return!rc(a)}function tc(a){return lh?lh:Ue(mh)?mh[a]:null}function uc(a,b){var c,d=b&&Ue(b)?Qc(b):[];return d.forEach(function(b){tc(b)===a&&(c=lg.data.xs[b])}),c}function vc(a,b){return a in lg.data.xs&&lg.data.xs[a]&&lg.data.xs[a][b]?lg.data.xs[a][b]:b}function wc(){var a=Object.keys(lg.data.xs);return a.length?lg.data.xs[a[0]]:null}function xc(a){var b=wc();return b&&a=0?lg.data.xs[d]=(c&&lg.data.xs[d]?lg.data.xs[d]:[]).concat(a.map(function(a){return a[e]}).filter(b).map(function(a,b){return Ec(a,d,b)})):lh?lg.data.xs[d]=wc():Ue(mh)&&(lg.data.xs[d]=uc(e,lg.data.targets)):lg.data.xs[d]=a.map(function(a,b){return b})}),e.forEach(function(a){if(!lg.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),d=e.map(function(b,c){var d=oh(b);return{id:d,id_org:b,values:a.map(function(a,e){var f=tc(b),g=a[f],h=Ec(g,b,e);return Kj()&&Jj&&0===c&&g&&(0===e&&(ai=[]),ai.push(g)),("undefined"==typeof a[b]||lg.data.xs[b].length<=e)&&(h=void 0),{x:h,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d}}).filter(function(a){return"undefined"!=typeof a.x})}}),d.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),th&&pe(Qc(d).filter(function(a){return!(a in uh)}),th),d.forEach(function(a){kc(a.id_org,a)}),d}function Kc(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function Lc(a){var b=Bc(lg.data.targets[0].values,a-1);return b?b.x:null}function Mc(a){var b=Bc(lg.data.targets[0].values,a+1);return b?b.x:null}function Nc(){return kg.max(lg.data.targets,function(a){return a.values.length})}function Oc(a){var b,c=a.length,d=0;return c>1?a.forEach(function(a){a.values.length>d&&(b=a,d=a.values.length)}):b=c?a[0]:null,b}function Pc(a){var b,c,d=Oc(a);return d?(b=d.values[0],c=d.values[d.values.length-1],[b.x,c.x]):[0,0]}function Qc(a){return a.map(function(a){return a.id})}function Rc(a){return a?"string"==typeof a?[a]:a:Qc(lg.data.targets)}function Sc(a,b){var c,d=Qc(a);for(c=0;c2){for(f=c-2,d=a[0],e=a[a.length-1],g=(e-d)/(f+1),j=[d],h=0;f>h;h++)i=+d+g*(h+1),j.push(Ij?new Date(i):i);j.push(e)}return Ij||(j=j.sort(function(a,b){return a-b})),j}function Yc(a){Vj=Vj.concat(a)}function Zc(a){Vj=Vj.filter(function(b){return a.indexOf(b)<0})}function $c(a){Wj=Wj.concat(a)}function _c(a){Wj=Wj.filter(function(b){return a.indexOf(b)<0})}function ad(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function bd(a,b){var c,d,e,f=Object.keys(a);for(c=0;ca})}function dd(a){return bd(a,function(a){return a>0})}function ed(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1||0===f&&0===g?(e=[],(a[f].x||0===a[f].x)&&(e=e.concat(Wd(a,f))),(a[g].x||0===a[g].x)&&(e=e.concat(Wd(a,g))),Zd(e,b)):Xd(a,b,f,g)}function Yd(a,b){var c;return c=a.map(function(a){return Xd(a.values,b)}),Zd(c,b)}function Zd(a,b){var c,d;return a.forEach(function(a){var e=We(a,b);(c>e||!c)&&(c=e,d=a)}),d}function $d(a,b){return kg.merge(a.map(function(a){return a.values})).filter(function(a){return a.x-b===0})}function _d(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}}function ae(){return wh&&"desc"===wh.toLowerCase()}function be(){return wh&&"asc"===wh.toLowerCase()}function ce(a){var b=be(),c=ae();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof wh&&a.sort(wh),a}function de(a,c){var d,e,f,g,h,i,j,k=we(lg.data.targets),l=a.filter(function(a){return a&&b(a.value)});0!==l.length&&uj&&(qk.html(yj(a,eb(),Md(k),Rj)).style("display","block"),d=qk.property("offsetWidth"),e=qk.property("offsetHeight"),k?(g=Gg/2+c[0],i=Ig/2+c[1]+20):(Yh?(f=s(),g=f+c[0]+100,h=g+d,j=t()-y(),i=bh(l[0].x)+20):(f=s(),g=f+x()+bh(l[0].x)+20,h=g+d,j=f+t()-y(),i=c[1]+15),h>j&&(g-=h-j),i+e>u()&&(i-=e+30)),qk.style("top",i+"px").style("left",g+"px"))}function ee(){qk.style("display","none")}function fe(a){var c=a.filter(function(a){return a&&b(a.value)});if(uj&&!se(lg.data.targets)&&!we(lg.data.targets)){var d=nk.selectAll("line."+g.xgridFocus);d.style("visibility","visible").data([c[0]]).attr(Yh?"y1":"x1",Sd).attr(Yh?"y2":"x2",Sd),Nf(d,"grid")}}function ge(){nk.select("line."+g.xgridFocus).style("visibility","hidden")}function he(a,b){var c,d,e,f,h=[],i=nk.select("."+g.axisX).selectAll(".tick").size();if("year"===a)for(c=gc(),d=c[0].getFullYear(),e=c[1].getFullYear(),f=d;e>=f;f++)h.push(new Date(f+"-01-01 00:00:00"));else h=b.ticks(10),h.length>i&&(h=h.filter(function(a){return(""+a).indexOf(".")<0}));return h}function ie(a){var b,d,e={},f=0;return Vc(lg.data.targets.filter(a)).forEach(function(a){for(b=0;b0&&(i+=g(c.values[f].value)-h)}),i}}function me(a){return a.x||0===a.x?bh(a.x):null}function ne(a,b){var c=ie(xe),d=Df(c);return rh.length>0?d(a,b)[0][1]:_(a.id)(a.value)}function oe(a,b){return"number"==typeof Ui?Ui:b?2*a.tickOffset()*Vi/b:0}function pe(a,b){Rc(a).forEach(function(a){uk[a]=b===uh[a],uh[a]=b}),a||(th=b)}function qe(a,b){var c=!1;return a.forEach(function(a){uh[a.id]===b&&(c=!0),a.id in uh||"line"!==b||(c=!0)}),c}function re(a){return qe(a,"bar")}function se(a){return qe(a,"scatter")}function te(a){return"pie"===th||qe(a,"pie")}function ue(a){return qe(a,"gauge")}function ve(a){return"donut"===th||qe(a,"donut")}function we(a){return te(a)||ve(a)||ue(a)}function xe(a){var b="string"==typeof a?a:a.id;return!uh[b]||["line","spline","area","area-spline","step","area-step"].indexOf(uh[b])>=0}function ye(a){var b="string"==typeof a?a:a.id;return["step","area-step"].indexOf(uh[b])>=0}function ze(a){var b="string"==typeof a?a:a.id;return["spline","area-spline"].indexOf(uh[b])>=0}function Ae(a){var b="string"==typeof a?a:a.id;return["area","area-spline","area-step"].indexOf(uh[b])>=0}function Be(a){var b="string"==typeof a?a:a.id;return"bar"===uh[b]}function Ce(a){var b="string"==typeof a?a:a.id;return"scatter"===uh[b]}function De(a){var b="string"==typeof a?a:a.id;return"pie"===uh[b]}function Ee(a){var b="string"==typeof a?a:a.id;return"gauge"===uh[b]}function Fe(a){var b="string"==typeof a?a:a.id;return"donut"===uh[b]}function Ge(a){return De(a)||Fe(a)||Ee(a)}function He(a){return xe(a)?[a]:[]}function Ie(a){return Ge(a.data)?[a]:[]}function Je(a){return Be(a)?a.values:[]}function Ke(a){return xe(a)||Ce(a)?a.values:[]}function Le(a){return Be(a)||xe(a)?a.values:[]}function Me(a){return Fe(a)&&oj||Ee(a)&&dj||De(a)&&Zi}function Ne(a,b,c){var d=[];return function(e){var f,g=e.id||e;return a[g]instanceof Function?f=a[g](e):a[g]?f=a[g]:(d.indexOf(g)<0&&d.push(g),f=b[d.indexOf(g)%b.length]),c instanceof Function?c(f,e):f}}function Oe(a,b){var c="value"===b.unit,d=b.values&&b.values.length?b.values:[],e=b.max||100;return function(b){var f,g,h=a[a.length-1];for(f=0;f0}function Ve(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function We(a,b){var c="y"===db(a.id)?ch:dh,d=Yh?1:0,e=Yh?0:1;return Math.pow(bh(a.x)-b[d],2)+Math.pow(c(a.value)-b[e],2)}function Xe(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function Ye(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0; +!function(a){"use strict";function b(a){return a||0===a}function c(a){return"undefined"==typeof a}function d(a){return"undefined"!=typeof a}function e(a,b){function c(a,b){a.attr("transform",function(a){return"translate("+Math.ceil(b(a)+s)+", 0)"})}function d(a,b){a.attr("transform",function(a){return"translate(0,"+Math.ceil(b(a))+")"})}function e(a){var b=a[0],c=a[a.length-1];return c>b?[b,c]:[c,b]}function f(a){var b,c,d=[];if(a.ticks)return a.ticks.apply(a,k);for(c=a.domain(),b=Math.ceil(c[0]);b0&&d[0]>0&&d.unshift(d[0]-(d[1]-d[0])),d}function g(){var a,c=m.copy();return b&&(a=m.domain(),c.domain([a[0],a[1]-1])),c}function h(a){return j?j(a):a}function i(i){i.each(function(){function i(a){var b=m(a)+s;return B[0]=0;return"url("+(c?"":document.URL.split("#")[0])+"#"+b+")"}function k(a){return Math.ceil(a)+.5}function l(a,b){var c,d,e;b&&b.axisX?c=b.axisX:(c=nk.select("."+g.axisX),a&&(c=c.transition())),b&&b.axisY?d=b.axisY:(d=nk.select("."+g.axisY),a&&(d=d.transition())),b&&b.axisY2?e=b.axisY2:(e=nk.select("."+g.axisY2),a&&(e=e.transition())),nk.attr("transform",ak.main),c.attr("transform",ak.x),d.attr("transform",ak.y),e.attr("transform",ak.y2),nk.select("."+g.chartArcs).attr("transform",ak.arc)}function m(a,b){var c;b&&b.axisSubX?c=b.axisSubX:(c=ok.select("."+g.axisX),a&&(c=c.transition())),ok.attr("transform",ak.context),c.attr("transform",ak.subx)}function n(a){(a?pk.transition():pk).attr("transform",ak.legend)}function o(a,b){l(a,b),Oh&&m(a,b),n(a)}function p(){var a=V(),b=U(),c=bk?0:a,d=we(lg.data.targets),e=Yh||d?0:A("x"),f=Oh&&!d?Ph+e:0;Kg=t(),Lg=u(),Yh?(Dg={top:A("y2")+v(),right:d?0:y(),bottom:A("y")+c+w(),left:f+(d?0:x())},Eg={top:Dg.top,right:0/0,bottom:20+c,left:gk}):(Dg={top:4+v(),right:d?0:y(),bottom:e+f+c+w(),left:d?0:x()},Eg={top:Lg-f-c,right:0/0,bottom:e+c,left:Dg.left}),Fg={top:bk?0:Lg-a,right:0/0,bottom:0,left:bk?Kg-b:0},Gg=Kg-Dg.left-Dg.right,Ig=Lg-Dg.top-Dg.bottom,0>Gg&&(Gg=0),0>Ig&&(Ig=0),Hg=Yh?Dg.left-gk-hk:Gg,Jg=Yh?Ig:Lg-Eg.top-Eg.bottom,0>Hg&&(Hg=0),0>Jg&&(Jg=0),Pg=Gg-(bk?b+10:0),Qg=Ig-(bk?0:10),r(),bk&&d&&(Fg.left=Pg/2+1.1*Ng)}function q(){nk.select("line."+g.xgridFocus).attr("x1",Yh?0:-10).attr("x2",Yh?Gg:-10).attr("y1",Yh?-10:Dg.top).attr("y2",Yh?-10:Ig)}function r(){var a;Ng=Math.min(Pg,Qg)/2,Mg=.95*Ng,a=kj?(Mg-kj)/Mg:.6,Og=ve(lg.data.targets)||ue(lg.data.targets)?Mg*a:0}function s(){var a=Yh?g.axisX:g.axisY,b=nk.select("."+a).node(),c=b?b.getBoundingClientRect():{right:0},d=rk.node().getBoundingClientRect(),e=we(lg.data.targets),f=c.right-d.left-(e?0:x());return f>0?f:0}function t(){return og?og:C()}function u(){var a=pg?pg:D();return a>0?a:320}function v(){return sg?sg:0}function w(){return tg?tg:0}function x(){return qg?qg:Yh?Zh?Math.max($e(z("x")),40):1:!pi||ui?1:$e(z("y"))}function y(){var a=10,b=bk?U()+20:0;return rg?rg:Yh?a+b:(!yi||Di?a:$e(z("y2")))+b}function z(a){var b=pb(a);return b.isInner?20+Ib(a):40+Ib(a)}function A(a){return"x"!==a||Zh?"x"===a&&mi?mi:"y"!==a||pi?"y2"!==a||yi?(pb(a).isInner?30:40)+("y2"===a?-10:0):ik:Sh&&!bk?10:1:0}function B(a){for(var b,c=rk.node();c&&"BODY"!==c.tagName&&!(b=c.getBoundingClientRect()[a]);)c=c.parentNode;return b}function C(){return B("width")}function D(){var a=rk.style("height");return a.indexOf("px")>0?+a.replace("px",""):0}function E(a){return a?-31:-(Dg.left-1)}function F(a){return a?-20:-4}function G(){return E(!Yh)}function H(){return F(!Yh)}function I(){return E(Yh)}function J(){return F(Yh)}function K(a){return a?Gg+2+30+30:Dg.left+20}function L(a){return a?(mi?mi:0)+80:Ig+8}function M(){return K(!Yh)}function N(){return L(!Yh)}function O(){return K(Yh)}function P(){return L(Yh)}function Q(){var a,b,c,d,e,f,g=Oc(lg.data.targets);return g?(a=g.values[0],b=g.values[g.values.length-1],c=bh(b.x)-bh(a.x),0===c?Yh?Ig:Gg:(d=Nc(),e=re(lg.data.targets)?(d-(Jj?.25:1))/d:1,f=d>1?c*e/(d-1):c,1>f?1:f)):0}function R(a){ck=a}function S(a){dk=a}function T(a){ek=a}function U(){return Sh?bk?dk*(ck+1):Kg:0}function V(){return Sh?bk?Lg:Math.max(20,ek)*(ck+1):0}function W(){var a,b,c=!bh;Vg=Yh?1:0,Wg=Yh?Ig:Gg,Xg=Yh?0:Ig,Yg=Yh?Gg:1,Zg=Vg,$g=Wg,_g=Yh?0:Jg,ah=Yh?Hg:1,bh=Z(Vg,Wg,c?void 0:bh.domain(),function(){return hh.tickOffset()}),ch=$(Xg,Yg,c?void 0:ch.domain()),dh=$(Xg,Yg,c?void 0:dh.domain()),eh=Z(Vg,Wg,sk,function(a){return a%1?0:kh.tickOffset()}),fh=$(_g,ah,c?void 0:fh.domain()),gh=$(_g,ah,c?void 0:gh.domain()),a=eb(),b=hi?hi:c?void 0:hh.tickValues(),hh=bb(bh,Yj,a,b),kh=bb(eh,_j,a,b),ih=cb(ch,Zj,vi,xi),jh=cb(dh,$j,Ei,Gi),c||(jk.scale(eh),ug&&kk.scale(bh)),X()}function X(){Rg=Lb(),Sg=Mb(),Tg=Mb(.98)}function Y(a,b,c){return(c?kg.time.scale():kg.scale.linear()).range([a,b])}function Z(a,b,c,d){var e,f=Y(a,b,Ij),g=c?f.domain(c):f;Jj?(d=d||function(){return 0},f=function(a,b){var c=g(a)+d(a);return b?c:Math.ceil(c)}):f=function(a,b){var c=g(a);return b?c:Math.ceil(c)};for(e in g)f[e]=g[e];return f.orgDomain=function(){var a=g.domain();return sk&&sk[0]===a[0]&&sk[1]a?a.toFixed(0):a};return ci&&("function"==typeof ci?a=ci:Ij&&(a=function(a){return a?Tj(ci)(a):""})),a}function fb(a){var b;return"y"===a?b=ti:"y2"===a?b=Ci:"x"===a&&(b=oi),b}function gb(a){var b=fb(a);return"string"==typeof b?b:b?b.text:null}function hb(a,b){var c=fb(a);"string"==typeof c?"y"===a?ti=b:"y2"===a?Ci=b:"x"===a&&(oi=b):c&&(c.text=b)}function ib(a){return 10*Math.sin(Math.PI*(a/180))}function jb(a){return 11.5-2.5*(a/15)}function kb(a,b,c){a.selectAll(".tick text").style("text-anchor","start"),b.selectAll(".tick text").attr("y",jb(c)).attr("x",ib(c)).attr("transform","rotate("+c+")")}function lb(a,b){var c=fb(a),d=c&&"object"==typeof c&&c.position?c.position:b;return{isInner:d.indexOf("inner")>=0,isOuter:d.indexOf("outer")>=0,isLeft:d.indexOf("left")>=0,isCenter:d.indexOf("center")>=0,isRight:d.indexOf("right")>=0,isTop:d.indexOf("top")>=0,isMiddle:d.indexOf("middle")>=0,isBottom:d.indexOf("bottom")>=0}}function mb(){return lb("x",Yh?"inner-top":"inner-right")}function nb(){return lb("y",Yh?"inner-right":"inner-top")}function ob(){return lb("y2",Yh?"inner-right":"inner-top")}function pb(a){return"y2"===a?ob():"y"===a?nb():mb()}function qb(){return gb("x")}function rb(){return gb("y")}function sb(){return gb("y2")}function tb(a,b){return a?b.isLeft?0:b.isCenter?Gg/2:Gg:b.isBottom?-Ig:b.isMiddle?-Ig/2:0}function ub(a,b){return a?b.isLeft?"0.5em":b.isRight?"-0.5em":"0":b.isTop?"-0.5em":b.isBottom?"0.5em":"0"}function vb(a,b){return a?b.isLeft?"start":b.isCenter?"middle":"end":b.isBottom?"start":b.isMiddle?"middle":"end"}function wb(){return tb(!Yh,mb())}function xb(){return tb(Yh,nb())}function yb(){return tb(Yh,ob())}function zb(){return ub(!Yh,mb())}function Ab(){return ub(Yh,nb())}function Bb(){return ub(Yh,ob())}function Cb(){var a=mb();return Yh?a.isInner?"1.2em":-25-Ib("x"):a.isInner?"-0.5em":mi?mi-10:"3em"}function Db(){var a=nb();return Yh?a.isInner?"-0.5em":"3em":a.isInner?"1.2em":-20-Ib("y")}function Eb(){var a=ob();return Yh?a.isInner?"1.2em":"-2.2em":a.isInner?"-0.5em":30+Ib("y2")}function Fb(){return vb(!Yh,mb())}function Gb(){return vb(Yh,nb())}function Hb(){return vb(Yh,ob())}function Ib(a){var b=0,c="x"===a?g.axisX:"y"===a?g.axisY:g.axisY2;return kg.selectAll("."+c+" .tick text").each(function(){var a=this.getBoundingClientRect();bb?0:b}function Jb(a){var b=nk.select("."+g.axisX+" ."+g.axisXLabel),c=nk.select("."+g.axisY+" ."+g.axisYLabel),d=nk.select("."+g.axisY2+" ."+g.axisY2Label);(a?b.transition():b).attr("x",wb).attr("dx",zb).attr("dy",Cb).text(qb),(a?c.transition():c).attr("x",xb).attr("dx",Ab).attr("dy",Db).attr("dy",Db).text(rb),(a?d.transition():d).attr("x",yb).attr("dx",Bb).attr("dy",Eb).text(sb)}function Kb(a){var b=!1;if(Ug(Vc(lg.data.targets)).forEach(function(c){b||c.data.id!==a.data.id||(b=!0,a=c)}),isNaN(a.endAngle)&&(a.endAngle=a.startAngle),Ee(a.data)){var c=ej,d=fj,e=Math.abs(c)+d,f=Math.PI/e;a.startAngle=-1*(Math.PI/2)+f*Math.abs(c),a.endAngle=a.startAngle+f*(a.value>d?d:a.value)}return b?a:null}function Lb(){var a=kg.svg.arc().outerRadius(Mg).innerRadius(Og),b=function(b,c){var d;return c?a(b):(d=Kb(b),d?a(d):"M 0 0")};return b.centroid=a.centroid,b}function Mb(a){var b=kg.svg.arc().outerRadius(Ng*(a?a:1)).innerRadius(Og);return function(a){var c=Kb(a);return c?b(c):"M 0 0"}}function Nb(a,b,c){return c||Ge(a.data)?Rg(a,b):"M 0 0"}function Ob(a){var b,c,d,e,f,g=Kb(a),h="";return g&&!ue(lg.data.targets)&&(b=Rg.centroid(g),c=isNaN(b[0])?0:b[0],d=isNaN(b[1])?0:b[1],e=Math.sqrt(c*c+d*d),f=Mg&&e?(36/Mg>.375?1.175-36/Mg:.8)*Mg/e:0,h="translate("+c*f+","+d*f+")"),h}function Pb(a){var b=ue(lg.data.targets)?Math.PI:2*Math.PI;return a?(a.endAngle-a.startAngle)/b:null}function Qb(a){return Ac({id:a.data.id,value:a.value,ratio:Pb(a)})}function Rb(a){var b,c,d,e;return Ub()?(b=Kb(a),c=b?b.value:null,d=Pb(b),Vb(d)?(e=Wb(),e?e(c,d):Qd(c,d)):""):""}function Sb(a,b){var c=lk.selectAll("."+g.chartArc+Cd(a)),d=lk.selectAll("."+g.arc).filter(function(b){return b.data.id!==a});Me(a)&&c.selectAll("path").transition().duration(50).attr("d",Sg).transition().duration(100).attr("d",Tg).each(function(a){Fe(a.data)}),b||d.style("opacity",.3)}function Tb(a){var b=lk.selectAll("."+g.chartArc+Cd(a));b.selectAll("path."+g.arc).transition().duration(50).attr("d",Rg),lk.selectAll("."+g.arc).style("opacity",1)}function Ub(){var a=!0;return ve(lg.data.targets)?a=lj:te(lg.data.targets)&&(a=Wi),a}function Vb(a){var b=ve(lg.data.targets)?nj:Yi;return a>=b}function Wb(){var a=Xi;return ue(lg.data.targets)?a=cj:ve(lg.data.targets)&&(a=mj),a}function Xb(){return ve(lg.data.targets)?pj:""}function Yb(){var a=$i;return ue(lg.data.targets)?a=gj:ve(lg.data.targets)&&(a=qj),"function"==typeof a?a:function(){}}function Zb(){var a=_i;return ue(lg.data.targets)?a=hj:ve(lg.data.targets)&&(a=rj),"function"==typeof a?a:function(){}}function $b(){var a=aj;return ue(lg.data.targets)?a=ij:ve(lg.data.targets)&&(a=sj),"function"==typeof a?a:function(){}}function _b(a,c,d,e){var f="ratio"===a.unit?e:1;return b(a[c])?a[c]*f:d}function ac(a){var b,c,d,e,f,g,h=Qc(a),i=ad(a);if(rh.length>0)for(g=cd(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=0>a?a:0}),c=1;c0||(i[d][b]+=+a)});return kg.min(Object.keys(i).map(function(a){return kg.min(i[a])}))}function bc(a){var b,c,d,e,f,g,h=Qc(a),i=ad(a);if(rh.length>0)for(g=dd(a),b=0;b=0}),0!==e.length)for(d=e[0],g&&i[d]&&i[d].forEach(function(a,b){i[d][b]=a>0?a:0}),c=1;c+a||(i[d][b]+=+a)});return kg.max(Object.keys(i).map(function(a){return kg.max(i[a])}))}function cc(a,c){var d,e,f,g,h,i,j,k,l=a.filter(function(a){return db(a.id)===c}),m="y2"===c?Ai:ri,n="y2"===c?zi:qi,o=b(m)?m:ac(l),p=b(n)?n:bc(l),q="y2"===c?Bi:si,r=Kd()&&Yh;return 0===l.length?"y2"===c?dh.domain():ch.domain():(o===p&&(0>o?p=0:o=0),d=Math.abs(p-o),e=f=g=r?0:.1*d,q&&(h=Math.max(Math.abs(o),Math.abs(p)),p=h-q,o=q-h),r?(i=Ld(o,p,c,"width"),j=ic(ch.range()),k=[i[0]/j,i[1]/j],f+=d*(k[1]/(1-k[0]-k[1])),g+=d*(k[0]/(1-k[0]-k[1]))):(i=Ld(o,p,c,"height"),f+=i[1],g+=i[0]),"y"===c&&wi&&(f=_b(wi,"top",e,d),g=_b(wi,"bottom",e,d)),"y2"===c&&Fi&&(f=_b(Fi,"top",e,d),g=_b(Fi,"bottom",e,d)),re(l)&&!cd(l)&&(g=o),[o-g,p+f])}function dc(a){return ki?Ij?Pe(ki):ki:kg.min(a,function(a){return kg.min(a.values,function(a){return a.x})})}function ec(a){return ji?Ij?Pe(ji):ji:kg.max(a,function(a){return kg.max(a.values,function(a){return a.x})})}function fc(a){var c,d,e,f,g=Pc(a),h=g[1]-g[0];return Jj?d=0:re(a)?(c=Nc(),d=c>1?h/(c-1)/2:.5):d=.01*h,"object"==typeof li&&Ue(li)?(e=b(li.left)?li.left:d,f=b(li.right)?li.right:d):e=f="number"==typeof li?li:d,{left:e,right:f}}function gc(a){var b=[dc(a),ec(a)],c=b[0],d=b[1],e=fc(a),f=0,g=0;return c-d!==0||Jj||(c=Ij?new Date(.5*c.getTime()):-.5,d=Ij?new Date(1.5*d.getTime()):.5),(c||0===c)&&(f=Ij?new Date(c.getTime()-e.left):c-e.left),(d||0===d)&&(g=Ij?new Date(d.getTime()+e.right):d+e.right),[f,g]}function hc(a,b,c,d){c&&(bh.domain(d?d:kg.extent(gc(a))),sk=bh.domain(),ug&&kk.scale(bh).updateScaleExtent(),eh.domain(bh.domain()),jk.scale(eh)),b&&(bh.domain(d?d:jk.empty()?sk:jk.extent()),ug&&kk.scale(bh).updateScaleExtent())}function ic(a){return a[1]-a[0]}function jc(a){for(var b=0;bb?0:b-c}function pc(a){var b,c=nc(a),d="y"===a.axis?ch:dh;return b="y"===a.axis||"y2"===a.axis?Yh?Ig:"start"in a?d(a.start):Ig:Yh?"end"in a?bh(Ij?Pe(a.end):a.end):Ig:Ig,c>b?0:b-c}function qc(a){return!a.axis||"x"===a.axis}function rc(a){return lh&&a===lh||Ue(mh)&&Ve(mh,a)}function sc(a){return!rc(a)}function tc(a){return lh?lh:Ue(mh)?mh[a]:null}function uc(a,b){var c,d=b&&Ue(b)?Qc(b):[];return d.forEach(function(b){tc(b)===a&&(c=lg.data.xs[b])}),c}function vc(a,b){return a in lg.data.xs&&lg.data.xs[a]&&lg.data.xs[a][b]?lg.data.xs[a][b]:b}function wc(){var a=Object.keys(lg.data.xs);return a.length?lg.data.xs[a[0]]:null}function xc(a){var b=wc();return b&&a=0?lg.data.xs[d]=(c&&lg.data.xs[d]?lg.data.xs[d]:[]).concat(a.map(function(a){return a[e]}).filter(b).map(function(a,b){return Ec(a,d,b)})):lh?lg.data.xs[d]=wc():Ue(mh)&&(lg.data.xs[d]=uc(e,lg.data.targets)):lg.data.xs[d]=a.map(function(a,b){return b})}),e.forEach(function(a){if(!lg.data.xs[a])throw new Error('x is not defined for id = "'+a+'".')}),d=e.map(function(b,c){var d=oh(b);return{id:d,id_org:b,values:a.map(function(a,e){var f=tc(b),g=a[f],h=Ec(g,b,e);return Kj()&&Jj&&0===c&&g&&(0===e&&(ai=[]),ai.push(g)),("undefined"==typeof a[b]||lg.data.xs[b].length<=e)&&(h=void 0),{x:h,value:null===a[b]||isNaN(a[b])?null:+a[b],id:d}}).filter(function(a){return"undefined"!=typeof a.x})}}),d.forEach(function(a){var b;a.values=a.values.sort(function(a,b){var c=a.x||0===a.x?a.x:1/0,d=b.x||0===b.x?b.x:1/0;return c-d}),b=0,a.values.forEach(function(a){a.index=b++})}),th&&pe(Qc(d).filter(function(a){return!(a in uh)}),th),d.forEach(function(a){kc(a.id_org,a)}),d}function Kc(a){return{id:a.id,id_org:a.id_org,values:a.values.map(function(a){return{x:a.x,value:a.value,id:a.id}})}}function Lc(a){var b=Bc(lg.data.targets[0].values,a-1);return b?b.x:null}function Mc(a){var b=Bc(lg.data.targets[0].values,a+1);return b?b.x:null}function Nc(){return kg.max(lg.data.targets,function(a){return a.values.length})}function Oc(a){var b,c=a.length,d=0;return c>1?a.forEach(function(a){a.values.length>d&&(b=a,d=a.values.length)}):b=c?a[0]:null,b}function Pc(a){var b,c,d=Oc(a);return d?(b=d.values[0],c=d.values[d.values.length-1],[b.x,c.x]):[0,0]}function Qc(a){return a.map(function(a){return a.id})}function Rc(a){return a?"string"==typeof a?[a]:a:Qc(lg.data.targets)}function Sc(a,b){var c,d=Qc(a);for(c=0;c2){for(f=c-2,d=a[0],e=a[a.length-1],g=(e-d)/(f+1),j=[d],h=0;f>h;h++)i=+d+g*(h+1),j.push(Ij?new Date(i):i);j.push(e)}return Ij||(j=j.sort(function(a,b){return a-b})),j}function Yc(a){Vj=Vj.concat(a)}function Zc(a){Vj=Vj.filter(function(b){return a.indexOf(b)<0})}function $c(a){Wj=Wj.concat(a)}function _c(a){Wj=Wj.filter(function(b){return a.indexOf(b)<0})}function ad(a){var b={};return a.forEach(function(a){b[a.id]=[],a.values.forEach(function(c){b[a.id].push(c.value)})}),b}function bd(a,b){var c,d,e,f=Object.keys(a);for(c=0;ca})}function dd(a){return bd(a,function(a){return a>0})}function ed(a){return a=0&&d===a[c].x;c--)e.push(a[c]);for(c=b;c0?g=h:f=h,g-f===1||0===f&&0===g?(e=[],(a[f].x||0===a[f].x)&&(e=e.concat(Wd(a,f))),(a[g].x||0===a[g].x)&&(e=e.concat(Wd(a,g))),Zd(e,b)):Xd(a,b,f,g)}function Yd(a,b){var c;return c=a.map(function(a){return Xd(a.values,b)}),Zd(c,b)}function Zd(a,b){var c,d;return a.forEach(function(a){var e=We(a,b);(c>e||!c)&&(c=e,d=a)}),d}function $d(a,b){return kg.merge(a.map(function(a){return a.values})).filter(function(a){return a.x-b===0})}function _d(a){var b=a.getBoundingClientRect(),c=[a.pathSegList.getItem(0),a.pathSegList.getItem(1)],d=c[0].x,e=Math.min(c[0].y,c[1].y);return{x:d,y:e,width:b.width,height:b.height}}function ae(){return wh&&"desc"===wh.toLowerCase()}function be(){return wh&&"asc"===wh.toLowerCase()}function ce(a){var b=be(),c=ae();return b||c?a.sort(function(a,c){var d=function(a,b){return a+Math.abs(b.value)},e=a.values.reduce(d,0),f=c.values.reduce(d,0);return b?f-e:e-f}):"function"==typeof wh&&a.sort(wh),a}function de(a,c){var d,e,f,g,h,i,j,k=we(lg.data.targets),l=a.filter(function(a){return a&&b(a.value)});0!==l.length&&uj&&(qk.html(yj(a,eb(),Md(k),Rj)).style("display","block"),d=qk.property("offsetWidth"),e=qk.property("offsetHeight"),k?(g=Gg/2+c[0],i=Ig/2+c[1]+20):(Yh?(f=s(),g=f+c[0]+100,h=g+d,j=t()-y(),i=bh(l[0].x)+20):(f=s(),g=f+x()+bh(l[0].x)+20,h=g+d,j=f+t()-y(),i=c[1]+15),h>j&&(g-=h-j),i+e>u()&&(i-=e+30)),qk.style("top",i+"px").style("left",g+"px"))}function ee(){qk.style("display","none")}function fe(a){var c=a.filter(function(a){return a&&b(a.value)});if(uj&&!se(lg.data.targets)&&!we(lg.data.targets)){var d=nk.selectAll("line."+g.xgridFocus);d.style("visibility","visible").data([c[0]]).attr(Yh?"y1":"x1",Sd).attr(Yh?"y2":"x2",Sd),Nf(d,"grid")}}function ge(){nk.select("line."+g.xgridFocus).style("visibility","hidden")}function he(a,b){var c,d,e,f,h=[],i=nk.select("."+g.axisX).selectAll(".tick").size();if("year"===a)for(c=gc(),d=c[0].getFullYear(),e=c[1].getFullYear(),f=d;e>=f;f++)h.push(new Date(f+"-01-01 00:00:00"));else h=b.ticks(10),h.length>i&&(h=h.filter(function(a){return(""+a).indexOf(".")<0}));return h}function ie(a){var b,d,e={},f=0;return Vc(lg.data.targets.filter(a)).forEach(function(a){for(b=0;b0&&(i+=g(c.values[f].value)-h)}),i}}function me(a){return a.x||0===a.x?bh(a.x):null}function ne(a,b){var c=ie(xe),d=Df(c);return rh.length>0?d(a,b)[0][1]:_(a.id)(a.value)}function oe(a,b){return"number"==typeof Ui?Ui:b?2*a.tickOffset()*Vi/b:0}function pe(a,b){Rc(a).forEach(function(a){uk[a]=b===uh[a],uh[a]=b}),a||(th=b)}function qe(a,b){var c=!1;return a.forEach(function(a){uh[a.id]===b&&(c=!0),a.id in uh||"line"!==b||(c=!0)}),c}function re(a){return qe(a,"bar")}function se(a){return qe(a,"scatter")}function te(a){return"pie"===th||qe(a,"pie")}function ue(a){return qe(a,"gauge")}function ve(a){return"donut"===th||qe(a,"donut")}function we(a){return te(a)||ve(a)||ue(a)}function xe(a){var b="string"==typeof a?a:a.id;return!uh[b]||["line","spline","area","area-spline","step","area-step"].indexOf(uh[b])>=0}function ye(a){var b="string"==typeof a?a:a.id;return["step","area-step"].indexOf(uh[b])>=0}function ze(a){var b="string"==typeof a?a:a.id;return["spline","area-spline"].indexOf(uh[b])>=0}function Ae(a){var b="string"==typeof a?a:a.id;return["area","area-spline","area-step"].indexOf(uh[b])>=0}function Be(a){var b="string"==typeof a?a:a.id;return"bar"===uh[b]}function Ce(a){var b="string"==typeof a?a:a.id;return"scatter"===uh[b]}function De(a){var b="string"==typeof a?a:a.id;return"pie"===uh[b]}function Ee(a){var b="string"==typeof a?a:a.id;return"gauge"===uh[b]}function Fe(a){var b="string"==typeof a?a:a.id;return"donut"===uh[b]}function Ge(a){return De(a)||Fe(a)||Ee(a)}function He(a){return xe(a)?[a]:[]}function Ie(a){return Ge(a.data)?[a]:[]}function Je(a){return Be(a)?a.values:[]}function Ke(a){return xe(a)||Ce(a)?a.values:[]}function Le(a){return Be(a)||xe(a)?a.values:[]}function Me(a){return Fe(a)&&oj||Ee(a)&&dj||De(a)&&Zi}function Ne(a,b,c){var d=[];return function(e){var f,g=e.id||e;return a[g]instanceof Function?f=a[g](e):a[g]?f=a[g]:(d.indexOf(g)<0&&d.push(g),f=b[d.indexOf(g)%b.length]),c instanceof Function?c(f,e):f}}function Oe(a,b){var c="value"===b.unit,d=b.values&&b.values.length?b.values:[],e=b.max||100;return function(b){var f,g,h=a[a.length-1];for(f=0;f0}function Ve(a,b){var c=!1;return Object.keys(a).forEach(function(d){a[d]===b&&(c=!0)}),c}function We(a,b){var c="y"===db(a.id)?ch:dh,d=Yh?1:0,e=Yh?0:1;return Math.pow(bh(a.x)-b[d],2)+Math.pow(c(a.value)-b[e],2)}function Xe(a,b){var c=0;a.each(function(){++c}).each("end",function(){--c||b.apply(this,arguments)})}function Ye(){var a=[],b=function(b,c){var d=setInterval(function(){var b=0; a.forEach(function(a){if(a.empty())return void(b+=1);try{a.transition()}catch(c){b+=1}}),b===a.length&&(clearInterval(d),c&&c())},10)};return b.add=function(b){a.push(b)},b}function Ze(a,b,c){return d(a[b])?a[b]:c}function $e(a){return 10*Math.ceil(a/10)}function _e(a,b){var c;return kg.select("body").selectAll(".dummy").data([a]).enter().append("text").classed(b?b:"",!0).text(a).each(function(){c=this.getBoundingClientRect()}).remove(),c}function af(a){return ze(a)?"cardinal":ye(a)?"step-after":"linear"}function bf(){return kg.selectAll([])}function cf(a,b,c){Jh(b,a.node()),nk.select("."+g.selectedCircles+Bd(b.id)).selectAll("."+g.selectedCircle+"-"+c).data([b]).enter().append("circle").attr("class",function(){return fd(g.selectedCircle,c)}).attr("cx",Yh?ne:me).attr("cy",Yh?me:ne).attr("stroke",function(){return Rj(b)}).attr("r",1.4*of(b)).transition().duration(100).attr("r",of)}function df(a,b,c){Kh(b,a.node()),nk.select("."+g.selectedCircles+Bd(b.id)).selectAll("."+g.selectedCircle+"-"+c).transition().duration(100).attr("r",0).remove()}function ef(a,b,c,d){a?cf(b,c,d):df(b,c,d)}function ff(a,b){Jh(b,a.node()),a.transition().duration(100).style("fill",function(){return kg.rgb(Rj(b)).brighter(.75)})}function gf(a,b){Kh(b,a.node()),a.transition().duration(100).style("fill",function(){return Rj(b)})}function hf(a,b,c,d){a?ff(b,c,d):gf(b,c,d)}function jf(a,b,c,d){hf(a,b,c.data,d)}function kf(a){return"circle"===a.nodeName?ef:kg.select(a).classed(g.bar)?hf:jf}function lf(a){return a.filter(function(a){return b(a.value)})}function mf(a){return Ni&&!ye(a)?"function"==typeof Oi?Oi(a):Oi:0}function nf(a){return Qi?Ri?Ri:1.75*mf(a):mf(a)}function of(a){return Si?Si:4*mf(a)}function pf(a,c){return(c?nk.selectAll("."+g.circles+Bd(c)):nk).selectAll("."+g.circle+(b(a)?"-"+a:""))}function qf(a,b){pf(a,b).classed(g.EXPANDED,!0).attr("r",nf)}function rf(a){pf(a).filter(function(){return kg.select(this).classed(g.EXPANDED)}).classed(g.EXPANDED,!1).attr("r",mf)}function sf(a){return nk.selectAll("."+g.bar+(b(a)?"-"+a:""))}function tf(a){sf(a).classed(g.EXPANDED,!0)}function uf(a){sf(a).classed(g.EXPANDED,!1)}function vf(a,b){var c=kg.svg.area(),d=Bf(a,b),e=b?ab:_,f=function(a,b){return rh.length>0?d(a,b)[0][1]:e(a.id)(0)},g=function(a,b){return rh.length>0?d(a,b)[1][1]:e(a.id)(a.value)};return c=Yh?c.x0(f).x1(g).y(Sd):c.x(Sd).y0(f).y1(g),function(a){var b,d=lf(a.values),e=0,f=0;return Ae(a)?b=c.interpolate(af(a))(d):(d[0]&&(e=bh(d[0].x),f=_(a.id)(d[0].value)),b=Yh?"M "+f+" "+e:"M "+e+" "+f),b?b:"M 0 0"}}function wf(a,b){var c=kg.svg.line(),d=Df(a,b),e=b?ab:_,f=b?Vd:Sd,g=function(a,b){return rh.length>0?d(a,b)[0][1]:e(a.id)(a.value)};return c=Yh?c.x(g).y(f):c.x(f).y(g),Ti||(c=c.defined(function(a){return null!=a.value})),function(a){var d,f=Ti?lf(a.values):a.values,g=b?g:eh,h=e(a.id),i=0,j=0;return xe(a)?d=xh[a.id]?Ef(f,g,h,xh[a.id]):c.interpolate(af(a))(f):(f[0]&&(i=g(f[0].x),j=h(f[0].value)),d=Yh?"M "+j+" "+i:"M "+i+" "+j),d?d:"M 0 0"}}function xf(a,b){var c=Cf(a,b);return function(a,b){var d=c(a,b),e=Yh?1:0,f=Yh?0:1,g="M "+d[0][e]+","+d[0][f]+" L"+d[1][e]+","+d[1][f]+" L"+d[2][e]+","+d[2][f]+" L"+d[3][e]+","+d[3][f]+" z";return g}}function yf(a,b){var c=Cf(a,!1),d=b?zf:Af;return function(a,b){return d(c(a,b),a,this)}}function zf(a,b){var c;return Yh?(c=Be(b)?4:6,a[2][1]+c*(b.value<0?-1:1)):a[0][0]+(a[2][0]-a[0][0])/2}function Af(a,b,c){var d=c.getBoundingClientRect();return Yh?(a[0][0]+a[2][0]+.6*d.height)/2:a[2][1]+(b.value<0?d.height:Be(b)?-3:-6)}function Bf(a,b){var c=a.__max__+1,d=je(0,c,a,!!b),e=ke(!!b),f=le(Ae,a,!!b),g=b?ab:_;return function(a,b){var c=g(a.id)(0),h=f(a,b)||c,i=d(a),j=e(a);return Yh&&(0j||a.value<0&&j>c)&&(j=c),[[i,h],[i,j-(c-h)]]}}function Cf(a,b){var c=a.__max__+1,d=oe(hh,c),e=je(d,c,a,!!b),f=ke(!!b),g=le(Be,a,!!b),h=b?ab:_;return function(a,b){var c=h(a.id)(0),i=g(a,b)||c,j=e(a),k=f(a);return Yh&&(0k||a.value<0&&k>c)&&(k=c),[[j,i],[j,k-(c-i)],[j+d,k-(c-i)],[j+d,i]]}}function Df(a,b){var c=a.__max__+1,d=je(0,c,a,!!b),e=ke(!!b),f=le(xe,a,!!b),g=b?ab:_;return function(a,b){var c=g(a.id)(0),h=f(a,b)||c,i=d(a),j=e(a);return Yh&&(0j||a.value<0&&j>c)&&(j=c),[[i,j-(c-h)]]}}function Ef(a,b,e,f){var g,h,i,j,k,l,m,n,o,p,q,r,s=-1,t="M",u=[];if(d(f))for(g=0;g=h;h+=p)t+=i(a[g-1],a[g],h,o);s=a[g].x}return t}function Ff(b){var c=new MutationObserver(function(d){d.forEach(function(d){if("childList"===d.type&&d.previousSibling){c.disconnect();var e=a.setInterval(function(){b.node().parentNode&&(a.clearInterval(e),Of({withUpdateTranslate:!0,withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransition:!1,withTransitionForTransform:!1,withLegend:!0}),b.transition().style("opacity",1))},10)}})});c.observe(b.node(),{attributes:!0,childList:!0,characterData:!0})}function Gf(b){var c,d,e,f,h=!0;if(rk=kg.select(ng),rk.empty()&&(rk=kg.select(document.createElement("div")).style("opacity",0),Ff(rk),h=!1),rk.html("").classed("c3",!0),lg.data.xs={},lg.data.targets=Jc(b),Bh&&(lg.data.targets=lg.data.targets.filter(Bh)),Ah&&Yc(Ah===!0?Qc(lg.data.targets):Ah),ue(lg.data.targets)&&(Sh=!1),p(),W(),bh.domain(kg.extent(gc(lg.data.targets))),ch.domain(cc(lg.data.targets,"y")),dh.domain(cc(lg.data.targets,"y2")),eh.domain(bh.domain()),fh.domain(ch.domain()),gh.domain(dh.domain()),sk=bh.domain(),jk.scale(eh),ug&&kk.scale(bh),lk=rk.append("svg").style("overflow","hidden").on("mouseenter",yg).on("mouseleave",zg),mk=lk.append("defs"),mk.append("clipPath").attr("id",Cj).append("rect"),mk.append("clipPath").attr("id",Dj).append("rect"),mk.append("clipPath").attr("id",Ej).append("rect"),Sf(),nk=lk.append("g").attr("transform",ak.main),ok=lk.append("g").attr("transform",ak.context),pk=lk.append("g").attr("transform",ak.legend),Oh||ok.style("visibility","hidden"),Sh||(pk.style("visibility","hidden"),Wj=Qc(lg.data.targets)),qk=rk.style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none"),dg(Qc(lg.data.targets),{withTransform:!1,withTransitionForTransform:!1}),nk.append("text").attr("class",g.text+" "+g.empty).attr("text-anchor","middle").attr("dominant-baseline","middle"),e=nk.append("g").attr("clip-path",Fj).attr("class",g.grid),Hi&&e.append("g").attr("class",g.xgrids),Pi&&e.append("g").attr("class",g.xgridFocus).append("line").attr("class",g.xgridFocus),e.append("g").attr("class",g.xgridLines),Ki&&e.append("g").attr("class",g.ygrids),e.append("g").attr("class",g.ygridLines),nk.append("g").attr("clip-path",Fj).attr("class",g.regions),nk.append("g").attr("clip-path",Fj).attr("class",g.chart),d=nk.select("."+g.chart).append("g").attr("class",g.eventRects).style("fill-opacity",0).style("cursor",ug?Yh?"ns-resize":"ew-resize":null),nk.select("."+g.chart).append("g").attr("class",g.chartBars),nk.select("."+g.chart).append("g").attr("class",g.chartLines),c=nk.select("."+g.chart).append("g").attr("class",g.chartArcs).attr("transform",ak.arc),c.append("text").attr("class",g.chartArcsTitle).style("text-anchor","middle").text(Xb()),ue(lg.data.targets)&&(c.append("path").attr("class",g.chartArcsBackground).attr("d",function(){var a={data:[{value:fj}],startAngle:-1*(Math.PI/2),endAngle:Math.PI/2};return Nb(a,!0,!0)}),c.append("text").attr("dy",".75em").attr("class",g.chartArcsGaugeUnit).style("text-anchor","middle").style("pointer-events","none").text(bj?jj:""),c.append("text").attr("dx",-1*(Og+(Mg-Og)/2)+"px").attr("dy","1.2em").attr("class",g.chartArcsGaugeMin).style("text-anchor","middle").style("pointer-events","none").text(bj?ej:""),c.append("text").attr("dx",Og+(Mg-Og)/2+"px").attr("dy","1.2em").attr("class",g.chartArcsGaugeMax).style("text-anchor","middle").style("pointer-events","none").text(bj?fj:"")),nk.select("."+g.chart).append("g").attr("class",g.chartTexts),ug&&nk.insert("rect",wg?null:"g."+g.grid).attr("class",g.zoomRect).attr("width",Gg).attr("height",Ig).style("opacity",0).style("cursor",Yh?"ns-resize":"ew-resize").call(kk).on("dblclick.zoom",null),ni&&jk.extent("function"!=typeof ni?ni:ni(gc())),Xj.x=nk.append("g").attr("class",g.axis+" "+g.axisX).attr("clip-path",Gj).attr("transform",ak.x).style("visibility",Zh?"visible":"hidden"),Xj.x.append("text").attr("class",g.axisXLabel).attr("transform",Yh?"rotate(-90)":"").style("text-anchor",Fb),Xj.y=nk.append("g").attr("class",g.axis+" "+g.axisY).attr("clip-path",Hj).attr("transform",ak.y).style("visibility",pi?"visible":"hidden"),Xj.y.append("text").attr("class",g.axisYLabel).attr("transform",Yh?"":"rotate(-90)").style("text-anchor",Gb),Xj.y2=nk.append("g").attr("class",g.axis+" "+g.axisY2).attr("transform",ak.y2).style("visibility",yi?"visible":"hidden"),Xj.y2.append("text").attr("class",g.axisY2Label).attr("transform",Yh?"":"rotate(-90)").style("text-anchor",Hb),ok.append("g").attr("clip-path",Fj).attr("class",g.chart),ok.select("."+g.chart).append("g").attr("class",g.chartBars),ok.select("."+g.chart).append("g").attr("class",g.chartLines),ok.append("g").attr("clip-path",Fj).attr("class",g.brush).call(jk).selectAll("rect").attr(Yh?"width":"height",Yh?Hg:Jg),Xj.subx=ok.append("g").attr("class",g.axisX).attr("transform",ak.subx).attr("clip-path",Yh?"":Gj),Vf(lg.data.targets),h&&Of({withUpdateTranslate:!0,withTransform:!0,withUpdateXDomain:!0,withUpdateOrgXDomain:!0,withTransitionForAxis:!1}),zj){if(Ij&&"string"==typeof Aj){for(Aj=Pe(Aj),f=0;ff&&h>c&&d>i&&j>d;else{if(!n.classed(g.bar))return;m=_d(this),c=m.x,d=m.y,e=m.width,k=m.height,l=hf,q=!(c>h||f>c+e||d>j||i>d+k)}q^p&&(n.classed(g.INCLUDED,!p),n.classed(g.SELECTED,!o),l(!o,n,a,b))}))}function Lf(a){we(lg.data.targets)||Ch&&(Lj=a,nk.select("."+g.chart).append("rect").attr("class",g.dragarea).style("opacity",.1),Mj=!0,Lh())}function Mf(){we(lg.data.targets)||Ch&&(nk.select("."+g.dragarea).transition().duration(100).style("opacity",0).remove(),nk.selectAll("."+g.shape).classed(g.INCLUDED,!1),Mj=!1,Mh())}function Nf(a,b){"grid"===b&&a.each(function(){var a=kg.select(this),b=a.attr("x1"),c=a.attr("x2"),d=a.attr("y1"),e=a.attr("y2");a.attr({x1:Math.ceil(b),x2:Math.ceil(c),y1:Math.ceil(d),y2:Math.ceil(e)})})}function Of(a,c){var d,e,f,h,i,j,k,l,m,n,r,s,t,u,v,w,x,y,z,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,R,S,T,U,V,X,Y,Z,$,_,ab,bb,cb,eb,fb=ie(Ae),gb=ie(Be),hb=ie(xe),ib=we(lg.data.targets),jb=Ye(),lb=Vc(lg.data.targets);if(d=h=s=w=bf(),a=a||{},G=Ze(a,"withY",!0),H=Ze(a,"withSubchart",!0),I=Ze(a,"withTransition",!0),L=Ze(a,"withTransform",!1),M=Ze(a,"withUpdateXDomain",!1),N=Ze(a,"withUpdateOrgXDomain",!1),P=Ze(a,"withUpdateTranslate",!1),O=Ze(a,"withLegend",!1),J=Ze(a,"withTransitionForExit",I),K=Ze(a,"withTransitionForAxis",I),$=I?Cg:0,_=J?$:0,ab=K?$:0,c=c||Tf(ab),P&&(Yh?(Xj.x.call(hh),Xj.subx.call(kh)):(Xj.y.call(ih),Xj.y2.call(jh)),p(),W(),Sf(),o(!1)),O&&Sh&&dg(Qc(lg.data.targets),a,c),Jj&&0===lb.length&&bh.domain([0,Xj.x.selectAll(".tick").size()]),lb.length?(hc(lb,M,N),hi||!gi&&!fi||(bb=Xc(Wc(lb),fi),hh.tickValues(bb),kh.tickValues(bb))):(hh.tickValues([]),kh.tickValues([])),ch.domain(cc(lb,"y")),dh.domain(cc(lb,"y2")),Xj.x.style("opacity",ib?0:1),Xj.y.style("opacity",ib?0:1),Xj.y2.style("opacity",ib?0:1),Xj.subx.style("opacity",ib?0:1),c.axisX.call(hh),c.axisY.call(ih),c.axisY2.call(jh),c.axisSubX.call(kh),Jb(I),M&&lb.length)if(di&&bb){for(cb=1;cb=0&&kg.select(this).style("display",b%eb?"none":"block")})}else lk.selectAll("."+g.axisX+" .tick text").style("display","block");!Yh&&ii&&kb(Xj.x,c.axisX,ii),R=vf(fb,!1),T=xf(gb),V=wf(hb,!1),Y=yf(gb,!0),Z=yf(gb,!1),fh.domain(ch.domain()),gh.domain(dh.domain()),qk.style("display","none"),q(),nk.select("text."+g.text+"."+g.empty).attr("x",Gg/2).attr("y",Ig/2).text(Nh).transition().style("opacity",lb.length?0:1),nk.select("line."+g.xgridFocus).style("visibility","hidden"),Hi&&(e=Yh?{x1:0,x2:Gg,y1:function(a){return bh(a)-D},y2:function(a){return bh(a)-D}}:{x1:function(a){return bh(a)+D},x2:function(a){return bh(a)+D},y1:Dg.top,y2:Ig},(m=function(a){f=he(Ii,bh),D=Jj?hh.tickOffset():0,d=nk.select("."+g.xgrids).selectAll("."+g.xgrid).data(f),d.enter().append("line").attr("class",g.xgrid),a||d.attr(e).style("opacity",function(){return+kg.select(this).attr(Yh?"y1":"x1")===(Yh?Ig:0)?0:1}),d.exit().remove()})()),h=nk.select("."+g.xgridLines).selectAll("."+g.xgridLine).data(Ji),i=h.enter().append("g").attr("class",function(a){return g.xgridLine+(a["class"]?" "+a["class"]:"")}),i.append("line").style("opacity",0),i.append("text").attr("text-anchor","end").attr("transform",Yh?"":"rotate(-90)").attr("dx",Yh?0:-Dg.top).attr("dy",-5).style("opacity",0),h.exit().transition().duration($).style("opacity",0).remove(),G&&Ki&&(j=nk.select("."+g.ygrids).selectAll("."+g.ygrid).data(ch.ticks(Mi)),j.enter().append("line").attr("class",g.ygrid),j.attr("x1",Yh?ch:0).attr("x2",Yh?ch:Gg).attr("y1",Yh?0:ch).attr("y2",Yh?Ig:ch),j.exit().remove(),Nf(j,"grid")),G&&(k=nk.select("."+g.ygridLines).selectAll("."+g.ygridLine).data(Li),l=k.enter().append("g").attr("class",function(a){return g.ygridLine+(a.class?a.class:"")}),l.append("line").style("opacity",0),l.append("text").attr("text-anchor","end").attr("transform",Yh?"rotate(-90)":"").attr("dx",Yh?0:-Dg.top).attr("dy",-5).style("opacity",0),k.select("line").transition().duration($).attr("x1",Yh?Ud:0).attr("x2",Yh?Ud:Gg).attr("y1",Yh?0:Ud).attr("y2",Yh?Ig:Ud).style("opacity",1),k.select("text").transition().duration($).attr("x",Yh?0:Gg).attr("y",Ud).text(function(a){return a.text}).style("opacity",1),k.exit().transition().duration($).style("opacity",0).remove()),v=nk.select("."+g.regions).selectAll("."+g.region).data(tj),v.enter().append("g").attr("class",ud).append("rect").style("fill-opacity",0),v.exit().transition().duration($).style("opacity",0).remove(),t=nk.selectAll("."+g.bars).selectAll("."+g.bar).data(Je),t.enter().append("path").attr("class",od).style("stroke",function(a){return Rj(a.id)}).style("fill",function(a){return Rj(a.id)}),t.style("opacity",Gd),t.exit().transition().duration(_).style("opacity",0).remove(),n=nk.selectAll("."+g.lines).selectAll("."+g.line).data(He),n.enter().append("path").attr("class",kd).style("stroke",Rj),n.style("opacity",Gd).attr("transform",null),n.exit().transition().duration(_).style("opacity",0).remove(),r=nk.selectAll("."+g.areas).selectAll("."+g.area).data(He),r.enter().append("path").attr("class",sd).style("fill",Rj).style("opacity",function(){return tk=+kg.select(this).style("opacity"),0}),r.style("opacity",tk),r.exit().transition().duration(_).style("opacity",0).remove(),Ni&&(s=nk.selectAll("."+g.circles).selectAll("."+g.circle).data(Ke),s.enter().append("circle").attr("class",md).attr("r",mf).style("fill",Rj),s.style("opacity",Gd),s.exit().remove()),Kd()&&(w=nk.selectAll("."+g.texts).selectAll("."+g.text).data(Le),w.enter().append("text").attr("class",gd).attr("text-anchor",function(a){return Yh?a.value<0?"end":"start":"middle"}).style("stroke","none").style("fill",Rj).style("fill-opacity",0),w.text(function(a){return Rd(db(a.id))(a.value,a.id)}).style("fill-opacity",Hd),w.exit().transition().duration(_).style("fill-opacity",0).remove()),u=nk.selectAll("."+g.arcs).selectAll("."+g.arc).data(Ie),u.enter().append("path").attr("class",qd).style("fill",function(a){return Rj(a.data)}).style("cursor",function(a){return Eh(a)?"pointer":null}).style("opacity",0).each(function(a){Ee(a.data)&&(a.startAngle=a.endAngle=-1*(Math.PI/2)),this._current=a}).on("mouseover",function(a,b){var c,d,e;Pj||(c=Kb(a),d=Qb(c),e=Zb(),Sb(c.data.id),_f(c.data.id,!0),e(d,b))}).on("mousemove",function(a){var b=Kb(a),c=Qb(b),d=[c];de(d,kg.mouse(this))}).on("mouseout",function(a,b){var c,d,e;Pj||(c=Kb(a),d=Qb(c),e=$b(),Tb(c.data.id),ag(),ee(),e(d,b))}).on("click",function(a,b){var c=Kb(a),d=Qb(c),e=Yb();Jf(this,a,b),e(d,b)}),u.attr("transform",function(a){return!Ee(a.data)&&L?"scale(0)":""}).style("opacity",function(a){return a===this._current?0:1}).each(function(){Pj=!0}).transition().duration($).attrTween("d",function(a){var b,c=Kb(a);return c?(isNaN(this._current.endAngle)&&(this._current.endAngle=this._current.startAngle),b=kg.interpolate(this._current,c),this._current=b(0),function(a){return Nb(b(a),!0)}):function(){return"M 0 0"}}).attr("transform",L?"scale(1)":"").style("fill",function(a){return Sj?Sj(a.data.values[0].value):Rj(a.data.id)}).style("opacity",1).call(Xe,function(){Pj=!1}),u.exit().transition().duration(_).style("opacity",0).remove(),nk.selectAll("."+g.chartArc).select("text").style("opacity",0).attr("class",function(a){return Ee(a.data)?g.gaugeValue:""}).text(Rb).attr("transform",Ob).transition().duration($).style("opacity",function(a){return Tc(a.data.id)&&Ge(a.data)?1:0}),nk.select("."+g.chartArcsTitle).style("opacity",ve(lg.data.targets)||ue(lg.data.targets)?1:0),Oh&&(kg.event&&"zoom"===kg.event.type&&jk.extent(bh.orgDomain()).update(),H&&(!Yh&&ii&&kb(Xj.subx,c.axisSubX,ii),jk.empty()||jk.extent(bh.orgDomain()).update(),S=vf(fb,!0),U=xf(gb,!0),X=wf(hb,!0),z=ok.selectAll("."+g.bars).selectAll("."+g.bar).data(Je),z.enter().append("path").attr("class",od).style("stroke","none").style("fill",Rj),z.style("opacity",Gd).transition().duration($).attr("d",U).style("opacity",1),z.exit().transition().duration($).style("opacity",0).remove(),x=ok.selectAll("."+g.lines).selectAll("."+g.line).data(He),x.enter().append("path").attr("class",kd).style("stroke",Rj),x.style("opacity",Gd).transition().duration($).attr("d",X).style("opacity",1),x.exit().transition().duration($).style("opacity",0).remove(),y=ok.selectAll("."+g.areas).selectAll("."+g.area).data(He),y.enter().append("path").attr("class",sd).style("fill",Rj).style("opacity",function(){return tk=+kg.select(this).style("opacity"),0}),y.style("opacity",0).transition().duration($).attr("d",S).style("fill",Rj).style("opacity",tk),y.exit().transition().duration(_).style("opacity",0).remove())),nk.selectAll("."+g.selectedCircles).filter(function(a){return Be(a)}).selectAll("circle").remove(),xg&&(A=nk.select("."+g.eventRects),Ue(mh)&&!zc(mh)?(A.classed(g.eventRectsMultiple)||A.classed(g.eventRectsMultiple,!0).classed(g.eventRectsSingle,!1).selectAll("."+g.eventRect).remove(),B=nk.select("."+g.eventRects).selectAll("."+g.eventRect).data([0]),If(B.enter()),B.attr("x",0).attr("y",0).attr("width",Gg).attr("height",Ig)):(A.classed(g.eventRectsSingle)||A.classed(g.eventRectsMultiple,!1).classed(g.eventRectsSingle,!0).selectAll("."+g.eventRect).remove(),!Kj()&&!Ij||Jj?(F=Q(),E=function(a){return bh(a.x)-F/2}):(F=function(a){var b=Lc(a.index),c=Mc(a.index),d=lg.data.xs[a.id][a.index];return(bh(c?c:d)-bh(b?b:d))/2},E=function(a){var b=Lc(a.index),c=lg.data.xs[a.id][a.index];return(bh(c)+bh(b?b:c))/2}),C=Oc(lg.data.targets),nk.select("."+g.eventRects).datum(C?C.values:[]),B=nk.select("."+g.eventRects).selectAll("."+g.eventRect).data(function(a){return a}),Hf(B.enter()),B.attr("class",vd).attr("x",Yh?0:E).attr("y",Yh?E:0).attr("width",Yh?Gg:F).attr("height",Yh?F:Ig),B.exit().remove())),kg.transition().duration($).each(function(){jb.add(t.transition().attr("d",T).style("fill",Rj).style("opacity",1)),jb.add(n.transition().attr("d",V).style("stroke",Rj).style("opacity",1)),jb.add(r.transition().attr("d",R).style("fill",Rj).style("opacity",tk)),jb.add(s.transition().style("opacity",Id).style("fill",Rj).attr("cx",Yh?ne:me).attr("cy",Yh?me:ne)),jb.add(nk.selectAll("."+g.selectedCircle).transition().attr("cx",Yh?ne:me).attr("cy",Yh?me:ne)),jb.add(w.transition().attr("x",Y).attr("y",Z).style("fill",Rj).style("fill-opacity",Jd)),jb.add(v.selectAll("rect").transition().attr("x",mc).attr("y",nc).attr("width",oc).attr("height",pc).style("fill-opacity",function(a){return b(a.opacity)?a.opacity:.1})),jb.add(h.select("line").transition().attr("x1",Yh?0:Td).attr("x2",Yh?Gg:Td).attr("y1",Yh?Td:Dg.top).attr("y2",Yh?Td:Ig).style("opacity",1)),jb.add(h.select("text").transition().attr("x",Yh?Gg:0).attr("y",Td).text(function(a){return a.text}).style("opacity",1))}).call(jb,a.flow?function(){var b,c,f=1,i=a.flow.index,j=a.flow.length,k=Bc(lg.data.targets[0].values,i),l=Bc(lg.data.targets[0].values,i+j),o=bh.domain(),p=a.flow.duration||$,q=a.flow.onend||function(){},u=Ye();lg.data.targets.forEach(function(a){a.values.splice(0,j)}),hc(lb,!0,!0),m&&m(!0),a.flow.orgDataCount?b=1===a.flow.orgDataCount||k.x===l.x?bh(o[0])-bh(l.x):(bh(k.x)-bh(l.x))*(Ij?.9:1):Ij||1!==lg.data.targets[0].values.length?(k=Bc(lg.data.targets[0].values,0),l=Bc(lg.data.targets[0].values,lg.data.targets[0].values.length-1),b=bh(k.x)-bh(l.x)):b=bh(-.5)-bh(0),f=ic(o)/ic(bh.domain()),c="translate("+b+",0) scale("+f+",1)",kg.transition().ease("linear").duration(p).each(function(){u.add(Xj.x.transition().call(hh)),u.add(t.transition().attr("transform",c)),u.add(n.transition().attr("transform",c)),u.add(r.transition().attr("transform",c)),u.add(s.transition().attr("transform",c)),u.add(w.transition().attr("transform",c)),u.add(v.filter(qc).transition().attr("transform",c)),u.add(d.transition().attr("transform",c)),u.add(h.transition().attr("transform",c))}).call(u,function(){var a,b=[],c=[],f=[];if(j){for(a=0;j>a;a++)b.push("."+g.shape+"-"+(i+a)),c.push("."+g.text+"-"+(i+a)),f.push("."+g.eventRect+"-"+(i+a));lk.selectAll("."+g.shapes).selectAll(b).remove(),lk.selectAll("."+g.texts).selectAll(c).remove(),lk.selectAll("."+g.eventRects).selectAll(f).remove(),lk.select("."+g.xgrid).remove()}d.attr("transform",null).attr(e),h.attr("transform",null),h.select("line").attr("x1",Yh?0:Td).attr("x2",Yh?Gg:Td),h.select("text").attr("x",Yh?Gg:0).attr("y",Td),t.attr("transform",null).attr("d",T),n.attr("transform",null).attr("d",V),r.attr("transform",null).attr("d",R),s.attr("transform",null).attr("cx",Yh?ne:me).attr("cy",Yh?me:ne),w.attr("transform",null).attr("x",Y).attr("y",Z),v.attr("transform",null),v.select("rect").filter(qc).attr("x",mc).attr("width",oc),B.attr("x",Yh?0:E).attr("y",Yh?E:0).attr("width",Yh?Gg:F).attr("height",Yh?F:Ig),q()})}:null),Qc(lg.data.targets).forEach(function(a){uk[a]=!0})}function Pf(){Of({withTransition:!1,withY:!1,withSubchart:!1,withUpdateXDomain:!0})}function Qf(){if(0!==Vc(lg.data.targets).length){if("mousemove"===kg.event.sourceEvent.type&&kk.altDomain)return bh.domain(kk.altDomain),void kk.scale(bh).updateScaleExtent();Jj&&bh.orgDomain()[0]===sk[0]&&bh.domain([sk[0]-1e-10,bh.orgDomain()[1]]),Of({withTransition:!1,withY:!1,withSubchart:!1}),"mousemove"===kg.event.sourceEvent.type&&(Nj=!0)}}function Rf(){function a(){b.forEach(function(a){a()})}var b=[];return a.add=function(a){b.push(a)},a}function Sf(){lk.attr("width",Kg).attr("height",Lg),lk.select("#"+Cj).select("rect").attr("width",Gg).attr("height",Ig),lk.select("#"+Dj).select("rect").attr("x",G).attr("y",H).attr("width",M).attr("height",N),lk.select("#"+Ej).select("rect").attr("x",I).attr("y",J).attr("width",O).attr("height",P),lk.select("."+g.zoomRect).attr("width",Gg).attr("height",Ig),rk.style("max-height",Lg+"px")}function Tf(a){return{axisX:a?Xj.x.transition().duration(a):Xj.x,axisY:a?Xj.y.transition().duration(a):Xj.y,axisY2:a?Xj.y2.transition().duration(a):Xj.y2,axisSubX:a?Xj.subx.transition().duration(a):Xj.subx}}function Uf(a){var b;a=a||{},a.withTransition=Ze(a,"withTransition",!0),a.withTransform=Ze(a,"withTransform",!1),a.withLegend=Ze(a,"withLegend",!1),a.withUpdateXDomain=!0,a.withUpdateOrgXDomain=!0,a.withTransitionForExit=!1,p(),a.withLegend&&Sh||(b=Tf(a.withTransitionForAxis?Cg:0),W(),Sf(),o(a.withTransition,b)),Of(a,b)}function Vf(a){var b,c,d,e,f,h,i,j,k,l,m,n;i=nk.select("."+g.chartTexts).selectAll("."+g.chartText).data(a).attr("class",xd),j=i.enter().append("g").attr("class",xd).style("opacity",0).style("pointer-events","none"),j.append("g").attr("class",hd),e=nk.select("."+g.chartBars).selectAll("."+g.chartBar).data(a).attr("class",zd),d=e.enter().append("g").attr("class",zd).style("opacity",0).style("pointer-events","none"),d.append("g").attr("class",pd).style("cursor",function(a){return Eh(a)?"pointer":null}),c=nk.select("."+g.chartLines).selectAll("."+g.chartLine).data(a).attr("class",yd),b=c.enter().append("g").attr("class",yd).style("opacity",0).style("pointer-events","none"),b.append("g").attr("class",ld),b.append("g").attr("class",td),b.append("g").attr("class",function(a){return fd(g.selectedCircles,a.id)}),b.append("g").attr("class",nd).style("cursor",function(a){return Eh(a)?"pointer":null}),a.forEach(function(a){nk.selectAll("."+g.selectedCircles+Bd(a.id)).selectAll("."+g.selectedCircle).each(function(b){b.value=a.values[b.index].value})}),h=nk.select("."+g.chartArcs).selectAll("."+g.chartArc).data(Ug(a)).attr("class",Ad),f=h.enter().append("g").attr("class",Ad),f.append("g").attr("class",rd),f.append("text").attr("dy",ue(lg.data.targets)?"-0.35em":".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none"),Oh&&(n=ok.select("."+g.chartBars).selectAll("."+g.chartBar).data(a).attr("class",zd),m=n.enter().append("g").style("opacity",0).attr("class",zd),m.append("g").attr("class",pd),l=ok.select("."+g.chartLines).selectAll("."+g.chartLine).data(a).attr("class",yd),k=l.enter().append("g").style("opacity",0).attr("class",yd),k.append("g").attr("class",ld),k.append("g").attr("class",td)),lk.selectAll("."+g.target).filter(function(a){return Tc(a.id)}).transition().duration(Cg).style("opacity",1)}function Wf(a,b){b.filter&&(a=a.filter(b.filter)),(b.type||b.types)&&a.forEach(function(a){b.types?pe(a.id,b.types[a.id]):pe(a.id,b.type)}),lg.data.targets.forEach(function(b){for(var c=0;cf&&(f=(m-l)/2,z=0,F++)),E[a]=F,D[F]=f,A[a]=z,z+=l}var f,h,i=_e(b.textContent,g.legendItem),j=10*Math.ceil((i.width+v)/10),k=10*Math.ceil((i.height+u)/10),l=bk?k:j,m=bk?V():U(); return d&&(z=0,F=0,w=0,x=0),Sh&&!Uc(c)?void(B[c]=C[c]=E[c]=A[c]=0):(B[c]=j,C[c]=k,(!w||j>=w)&&(w=j),(!x||k>=x)&&(x=k),h=bk?x:w,void(Xh?(Object.keys(B).forEach(function(a){B[a]=w}),Object.keys(C).forEach(function(a){C[a]=x}),f=(m-h*a.length)/2,y>f?(z=0,F=0,a.forEach(function(a){e(a)})):e(c,!0)):e(c)))}var f,h,i,j,k,l,m,n,q,r,s,t,u=4,v=36,w=0,x=0,y=10,z=0,A={},B={},C={},D=[0],E={},F=0,G=pk.selectAll("."+g.legendItemFocused).size();b=b||{},n=Ze(b,"withTransition",!0),q=Ze(b,"withTransitionForTransform",!0),bk?(f=function(a){return w*E[a]},j=function(a){return D[E[a]]+A[a]}):(f=function(a){return D[E[a]]+A[a]},j=function(a){return x*E[a]}),h=function(a,b){return f(a,b)+14},k=function(a,b){return j(a,b)+9},i=function(a,b){return f(a,b)-4},l=function(a,b){return j(a,b)-7},m=pk.selectAll("."+g.legendItem).data(a).enter().append("g").attr("class",function(a){return fd(g.legendItem,a)}).style("visibility",function(a){return Uc(a)?"visible":"hidden"}).style("cursor","pointer").on("click",function(a){"function"==typeof Uh?Uh(a):lg.toggle(a)}).on("mouseover",function(a){kg.select(this).classed(g.legendItemFocused,!0),Pj||lg.focus(a),"function"==typeof Vh&&Vh(a)}).on("mouseout",function(a){kg.select(this).classed(g.legendItemFocused,!1),Pj||lg.revert(),"function"==typeof Wh&&Wh(a)}),m.append("text").text(function(a){return d(ph[a])?ph[a]:a}).each(function(a,b){e(this,a,0===b)}).style("pointer-events","none").attr("x",bk?h:-200).attr("y",bk?-200:k),m.append("rect").attr("class",g.legendItemEvent).style("fill-opacity",0).attr("x",bk?i:-200).attr("y",bk?-200:l),m.append("rect").attr("class",g.legendItemTile).style("pointer-events","none").style("fill",Rj).attr("x",bk?h:-200).attr("y",bk?-200:j).attr("width",10).attr("height",10),r=pk.selectAll("text").data(a).text(function(a){return d(ph[a])?ph[a]:a}).each(function(a,b){e(this,a,0===b)}),(n?r.transition():r).attr("x",h).attr("y",k),s=pk.selectAll("rect."+g.legendItemEvent).data(a),(n?s.transition():s).attr("width",function(a){return B[a]}).attr("height",function(a){return C[a]}).attr("x",i).attr("y",l),t=pk.selectAll("rect."+g.legendItemTile).data(a),(n?t.transition():t).style("fill",Rj).attr("x",f).attr("y",j),pk.selectAll("."+g.legendItem).classed(g.legendItemHidden,function(a){return!Tc(a)}).transition().style("opacity",function(a){var b=kg.select(this);return Tc(a)?!G||b.classed(g.legendItemFocused)?Zf(b):$f(b):fk}),S(w),T(x),R(F),p(),W(),Sf(),o(q,c)}function eg(a){return Sc(lg.data.targets,a.id)}function fg(a){return"data"in a&&Sc(lg.data.targets,a.data.id)}function gg(a){return a=a||{},function(b){return!("value"in a&&b.value===a.value||"class"in a&&b.class===a.class)}}function hg(a,b){var c=gg(a),d=function(a){return!c(a)},e=b?g.xgridLines:g.ygridLines,f=b?g.xgridLine:g.ygridLine;nk.select("."+e).selectAll("."+f).filter(d).transition().duration(Cg).style("opacity",0).remove(),b?Ji=Ji.filter(c):Li=Li.filter(c)}function ig(a,b,c){var d=!we(lg.data.targets);Pj=!1,pe(a,b),Uf(c||{withTransitionForAxis:d})}function jg(a){var b=a.mimeType?a.mimeType:"csv";kg.xhr(a.url,function(c,d){var e;e="json"===b?Gc(JSON.parse(d.response),a.keys):Fc(d.response),Gf(e)})}var kg=a.d3?a.d3:"undefined"!=typeof require?require("d3"):void 0,lg={data:{},axis:{},legend:{}},mg={},ng=i(["bindto"],"#chart"),og=i(["size","width"]),pg=i(["size","height"]),qg=i(["padding","left"]),rg=i(["padding","right"]),sg=i(["padding","top"]),tg=i(["padding","bottom"]),ug=i(["zoom","enabled"],!1),vg=i(["zoom","extent"]),wg=i(["zoom","privileged"],!1),xg=i(["interaction","enabled"],!0),yg=i(["onenter"],function(){}),zg=i(["onleave"],function(){}),Ag=i(["onresize"],function(){}),Bg=i(["onresized"],function(){}),Cg=i(["transition","duration"],350);h("data","data is required in config");var Dg,Eg,Fg,Gg,Hg,Ig,Jg,Kg,Lg,Mg,Ng,Og,Pg,Qg,Rg,Sg,Tg,Ug,Vg,Wg,Xg,Yg,Zg,$g,_g,ah,bh,ch,dh,eh,fh,gh,hh,ih,jh,kh,lh=i(["data","x"]),mh=i(["data","xs"],{}),nh=i(["data","x_format"],"%Y-%m-%d"),oh=i(["data","id_converter"],function(a){return a}),ph=i(["data","names"],{}),qh=i(["data","classes"],{}),rh=i(["data","groups"],[]),sh=i(["data","axes"],{}),th=i(["data","type"]),uh=i(["data","types"],{}),vh=i(["data","labels"],{}),wh=i(["data","order"]),xh=i(["data","regions"],{}),yh=i(["data","color"]),zh=i(["data","colors"],{}),Ah=i(["data","hide"],!1),Bh=i(["data","filter"]),Ch=i(["data","selection","enabled"],!1),Dh=i(["data","selection","grouped"],!1),Eh=i(["data","selection","isselectable"],function(){return!0}),Fh=i(["data","selection","multiple"],!0),Gh=i(["data","onclick"],function(){}),Hh=i(["data","onenter"],function(){}),Ih=i(["data","onleave"],function(){}),Jh=i(["data","onselected"],function(){}),Kh=i(["data","onunselected"],function(){}),Lh=i(["data","ondragstart"],function(){}),Mh=i(["data","ondragend"],function(){}),Nh=i(["data","empty","label","text"],""),Oh=i(["subchart","show"],!1),Ph=i(["subchart","size","height"],60),Qh=i(["color","pattern"],[]),Rh=i(["color","threshold"],{}),Sh=i(["legend","show"],!0),Th=i(["legend","position"],"bottom"),Uh=i(["legend","item","onclick"]),Vh=i(["legend","item","onmouseover"]),Wh=i(["legend","item","onmouseout"]),Xh=i(["legend","equally"],!1),Yh=i(["axis","rotated"],!1),Zh=i(["axis","x","show"],!0),$h=i(["axis","x","type"],"indexed"),_h=i(["axis","x","localtime"],!0),ai=i(["axis","x","categories"],[]),bi=i(["axis","x","tick","centered"],!1),ci=i(["axis","x","tick","format"]),di=i(["axis","x","tick","culling"],{}),ei=i(["axis","x","tick","culling","max"],10),fi=i(["axis","x","tick","count"]),gi=i(["axis","x","tick","fit"],!0),hi=i(["axis","x","tick","values"],null),ii=i(["axis","x","tick","rotate"]),ji=i(["axis","x","max"],null),ki=i(["axis","x","min"],null),li=i(["axis","x","padding"],{}),mi=i(["axis","x","height"]),ni=i(["axis","x","default"]),oi=i(["axis","x","label"],{}),pi=i(["axis","y","show"],!0),qi=i(["axis","y","max"]),ri=i(["axis","y","min"]),si=i(["axis","y","center"]),ti=i(["axis","y","label"],{}),ui=i(["axis","y","inner"],!1),vi=i(["axis","y","tick","format"]),wi=i(["axis","y","padding"]),xi=i(["axis","y","ticks"],10),yi=i(["axis","y2","show"],!1),zi=i(["axis","y2","max"]),Ai=i(["axis","y2","min"]),Bi=i(["axis","y2","center"]),Ci=i(["axis","y2","label"],{}),Di=i(["axis","y2","inner"],!1),Ei=i(["axis","y2","tick","format"]),Fi=i(["axis","y2","padding"]),Gi=i(["axis","y2","ticks"],10),Hi=i(["grid","x","show"],!1),Ii=i(["grid","x","type"],"tick"),Ji=i(["grid","x","lines"],[]),Ki=i(["grid","y","show"],!1),Li=i(["grid","y","lines"],[]),Mi=i(["grid","y","ticks"],10),Ni=i(["point","show"],!0),Oi=i(["point","r"],2.5),Pi=i(["point","focus","line","enabled"],!0),Qi=i(["point","focus","expand","enabled"],!0),Ri=i(["point","focus","expand","r"]),Si=i(["point","focus","select","r"]),Ti=i(["line","connect_null"],!1),Ui=i(["bar","width"]),Vi=i(["bar","width","ratio"],.6),Wi=i(["pie","label","show"],!0),Xi=i(["pie","label","format"]),Yi=i(["pie","label","threshold"],.05),Zi=i(["pie","expand"],!0),$i=i(["pie","onclick"],function(){}),_i=i(["pie","onmouseover"],function(){}),aj=i(["pie","onmouseout"],function(){}),bj=i(["gauge","label","show"],!0),cj=i(["gauge","label","format"]),dj=i(["gauge","expand"],!0),ej=i(["gauge","min"],0),fj=i(["gauge","max"],100),gj=i(["gauge","onclick"],function(){}),hj=i(["gauge","onmouseover"],function(){}),ij=i(["gauge","onmouseout"],function(){}),jj=i(["gauge","units"]),kj=i(["gauge","width"]),lj=i(["donut","label","show"],!0),mj=i(["donut","label","format"]),nj=i(["donut","label","threshold"],.05),oj=i(["donut","expand"],!0),pj=i(["donut","title"],""),qj=i(["donut","onclick"],function(){}),rj=i(["donut","onmouseover"],function(){}),sj=i(["donut","onmouseout"],function(){}),tj=i(["regions"],[]),uj=i(["tooltip","show"],!0),vj=i(["tooltip","format","title"]),wj=i(["tooltip","format","name"]),xj=i(["tooltip","format","value"]),yj=i(["tooltip","contents"],function(a,b,c,d){var e,f,h,i,j,k,l=vj?vj:b,m=wj?wj:function(a){return a},n=xj?xj:c;for(f=0;f"+(h||0===h?""+h+"":"")),j=m(a[f].name),i=n(a[f].value,a[f].ratio,a[f].id,a[f].index),k=Sj?Sj(a[f].value):d(a[f].id),e+="",e+=""+j+"",e+=""+i+"",e+="");return e+""}),zj=i(["tooltip","init","show"],!1),Aj=i(["tooltip","init","x"],0),Bj=i(["tooltip","init","position"],{top:"0px",left:"50px"}),Cj="c3-"+ +new Date+"-clip",Dj=Cj+"-xaxis",Ej=Cj+"-yaxis",Fj=j(Cj),Gj=j(Dj),Hj=j(Ej),Ij="timeseries"===$h,Jj=$h.indexOf("categor")>=0,Kj=function(){return!Ij&&(lh||Ue(mh))},Lj=null,Mj=!1,Nj=!1,Oj=!1,Pj=!1,Qj=kg.scale.category10().range(),Rj=Ne(zh,Ue(Qh)?Qh:Qj,yh),Sj=Ue(Rh)?Oe(Qh,Rh):null,Tj=_h?kg.time.format:kg.time.format.utc,Uj=Tj.multi([[".%L",function(a){return a.getMilliseconds()}],[":%S",function(a){return a.getSeconds()}],["%I:%M",function(a){return a.getMinutes()}],["%I %p",function(a){return a.getHours()}],["%-m/%-d",function(a){return a.getDay()&&1!==a.getDate()}],["%-m/%-d",function(a){return 1!==a.getDate()}],["%-m/%-d",function(a){return a.getMonth()}],["%Y/%-m/%-d",function(){return!0}]]),Vj=[],Wj=[],Xj={},Yj=Yh?"left":"bottom",Zj=Yh?ui?"top":"bottom":ui?"right":"left",$j=Yh?Di?"bottom":"top":Di?"left":"right",_j=Yh?"left":"bottom",ak={main:function(){return"translate("+k(Dg.left)+","+k(Dg.top)+")"},context:function(){return"translate("+k(Eg.left)+","+k(Eg.top)+")"},legend:function(){return"translate("+Fg.left+","+Fg.top+")"},x:function(){return"translate(0,"+(Yh?0:Ig)+")"},y:function(){return"translate(0,"+(Yh?Ig:0)+")"},y2:function(){return"translate("+(Yh?0:Gg)+","+(Yh?1:0)+")"},subx:function(){return"translate(0,"+(Yh?0:Jg)+")"},arc:function(){return"translate("+Pg/2+","+Qg/2+")"}},bk="right"===Th,ck=0,dk=0,ek=0,fk=.15,gk=30,hk=Yh&&!Zh?0:30,ik=5;Ug=kg.layout.pie().value(function(a){return a.values.reduce(function(a,b){return a+b.value},0)});var jk,kk=function(){};jk=kg.svg.brush().on("brush",Pf),jk.update=function(){return ok&&ok.select("."+g.brush).call(this),this},jk.scale=function(a){return Yh?this.y(a):this.x(a)},ug&&(kk=kg.behavior.zoom().on("zoomstart",function(){kk.altDomain=kg.event.sourceEvent.altKey?bh.orgDomain():null}).on("zoom",ug?Qf:null),kk.scale=function(a){return Yh?this.y(a):this.x(a)},kk.orgScaleExtent=function(){var a=vg?vg:[1,10];return[a[0],Math.max(Nc()/a[1],a[1])]},kk.updateScaleExtent=function(){var a=ic(bh.orgDomain())/ic(sk),b=this.orgScaleExtent();return this.scaleExtent([b[0]*a,b[1]*a]),this});var lk,mk,nk,ok,pk,qk,rk,sk,tk,uk={};if(lg.focus=function(a){function b(a){Vc(a).transition().duration(100).style("opacity",1)}var c=lk.selectAll(Cd(a)),d=c.filter(eg),e=c.filter(fg);lg.revert(),lg.defocus(),b(d.classed(g.focused,!0)),b(e),we(lg.data.targets)&&Sb(a,!0),_f(a,!0)},lg.defocus=function(a){function b(a){Vc(a).transition().duration(100).style("opacity",.3)}var c=lk.selectAll(Cd(a)),d=c.filter(eg),e=c.filter(fg);lg.revert(),b(d.classed(g.focused,!1)),b(e),we(lg.data.targets)&&Tb(a),_f(a,!1)},lg.revert=function(a){function b(a){Vc(a).transition().duration(100).style("opacity",1)}var c=lk.selectAll(Cd(a)),d=c.filter(eg),e=c.filter(fg);b(d.classed(g.focused,!1)),b(e),we(lg.data.targets)&&Tb(a),ag()},lg.show=function(a,b){a=Rc(a),b=b||{},Zc(a),lk.selectAll(Dd(a)).transition().style("opacity",1),b.withLegend&&bg(a),Of({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},lg.hide=function(a,b){a=Rc(a),b=b||{},Yc(a),lk.selectAll(Dd(a)).transition().style("opacity",0),b.withLegend&&cg(a),Of({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0})},lg.toggle=function(a){Tc(a)?lg.hide(a):lg.show(a)},lg.unzoom=function(){jk.clear().update(),Of({withUpdateXDomain:!0})},lg.load=function(a){return a.xs&&yc(a.xs),"classes"in a&&Object.keys(a.classes).forEach(function(b){qh[b]=a.classes[b]}),"categories"in a&&Jj&&(ai=a.categories),"cacheIds"in a&&jc(a.cacheIds)?void Wf(lc(a.cacheIds),a.done):void("unload"in a?Yf(Rc("boolean"==typeof a.unload&&a.unload?null:a.unload),function(){Xf(a)}):Xf(a))},lg.unload=function(a,b){Yf(Rc(a),function(){Of({withUpdateOrgXDomain:!0,withUpdateXDomain:!0,withLegend:!0}),"function"==typeof b&&b()})},lg.flow=function(a){var c,e,f,g,h,i,j=Jc(Ic(a.columns),!0),k=[],l=Nc(),m=0,n=0;lg.data.targets.forEach(function(a){var b,c,d=!1;for(b=0;bc;c++)j[b].values[c].index=n+c,Ij||(j[b].values[c].x=n+c);a.values=a.values.concat(j[b].values),j.splice(b,1);break}d||k.push(a.id)}),lg.data.targets.forEach(function(a){var b,c;for(b=0;bc;c++)a.values.push({id:a.id,index:n+c,x:Ij?xc(n+c):n+c,value:null})}),lg.data.targets.length&&j.forEach(function(a){var b,c=[];for(b=lg.data.targets[0].values[0].index;n>b;b++)c.push({id:a.id,index:b,x:Ij?xc(b):b,value:null});a.values.forEach(function(a){a.index+=n,Ij||(a.x+=n)}),a.values=c.concat(a.values)}),lg.data.targets=lg.data.targets.concat(j),c=Nc(),f=lg.data.targets[0],g=f.values[0],d(a.to)?(m=0,i=Ij?Pe(a.to):a.to,f.values.forEach(function(a){a.x1?f.values[f.values.length-1].x-g.x:g.x-gc(lg.data.targets)[0]:1,e=[g.x-h,g.x],hc(null,!0,!0,e)),Vf(lg.data.targets),Of({flow:{index:g.index,length:m,duration:b(a.duration)?a.duration:Cg,onend:a.onend,orgDataCount:l},withLegend:!0,withTransition:l>1})},lg.selected=function(a){return kg.merge(nk.selectAll("."+g.shapes+Bd(a)).selectAll("."+g.shape).filter(function(){return kg.select(this).classed(g.SELECTED)}).map(function(a){return a.map(function(a){var b=a.__data__;return b.data?b.data:b})}))},lg.select=function(a,b,c){Ch&&nk.selectAll("."+g.shapes).selectAll("."+g.shape).each(function(e,f){var h=kg.select(this),i=e.data?e.data.id:e.id,j=kf(this),k=Dh||!a||a.indexOf(i)>=0,l=!b||b.indexOf(f)>=0,m=h.classed(g.SELECTED);h.classed(g.line)||h.classed(g.area)||(k&&l?Eh(e)&&!m&&j(!0,h.classed(g.SELECTED,!0),e,f):d(c)&&c&&m&&j(!1,h.classed(g.SELECTED,!1),e,f))})},lg.unselect=function(a,b){Ch&&nk.selectAll("."+g.shapes).selectAll("."+g.shape).each(function(c,d){var e=kg.select(this),f=c.data?c.data.id:c.id,h=kf(this),i=Dh||!a||a.indexOf(f)>=0,j=!b||b.indexOf(d)>=0,k=e.classed(g.SELECTED);e.classed(g.line)||e.classed(g.area)||i&&j&&Eh(c)&&k&&h(!1,e.classed(g.SELECTED,!1),c,d)})},lg.transform=function(a,b){var c=["pie","donut"].indexOf(a)>=0?{withTransform:!0}:null;ig(b,a,c)},lg.groups=function(a){return c(a)?rh:(rh=a,Of(),rh)},lg.xgrids=function(a){return a?(Ji=a,Of(),Ji):Ji},lg.xgrids.add=function(a){return a?lg.xgrids(Ji.concat(a)):void 0},lg.xgrids.remove=function(a){hg(a,!0)},lg.ygrids=function(a){return a?(Li=a,Of(),Li):Li},lg.ygrids.add=function(a){return a?lg.ygrids(Li.concat(a)):void 0},lg.ygrids.remove=function(a){hg(a,!1)},lg.regions=function(a){return a?(tj=a,Of(),tj):tj},lg.regions.add=function(a){return a?(tj=tj.concat(a),Of(),tj):tj},lg.regions.remove=function(a){var b,c,d;return a=a||{},b=Ze(a,"duration",Cg),c=Ze(a,"classes",[g.region]),d=nk.select("."+g.regions).selectAll(c.map(function(a){return"."+a})),(b?d.transition().duration(b):d).style("opacity",0).remove(),tj=tj.filter(function(a){var b=!1;return a.class?(a.class.split(" ").forEach(function(a){c.indexOf(a)>=0&&(b=!0)}),!b):!0})},lg.data.get=function(a){var b=lg.data.getAsTarget(a);return d(b)?b.values.map(function(a){return a.value}):void 0},lg.data.getAsTarget=function(a){var b=lg.data.targets.filter(function(b){return b.id===a});return b.length>0?b[0]:void 0},lg.data.names=function(a){return arguments.length?(Object.keys(a).forEach(function(b){ph[b]=a[b]}),Of({withLegend:!0}),ph):ph},lg.data.colors=function(a){return arguments.length?(Object.keys(a).forEach(function(b){zh[b]=a[b]}),Of({withLegend:!0}),zh):zh},lg.color=Rj,lg.x=function(a){return arguments.length&&(Cc(lg.data.targets,a),Of({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),lg.data.xs},lg.xs=function(a){return arguments.length&&(Dc(lg.data.targets,a),Of({withUpdateOrgXDomain:!0,withUpdateXDomain:!0})),lg.data.xs},lg.axis.labels=function(a){arguments.length&&(Object.keys(a).forEach(function(b){hb(b,a[b])}),Jb())},lg.axis.max=function(a){arguments.length&&("object"==typeof a?(b(a.x)&&(ji=a.x),b(a.y)&&(qi=a.y),b(a.y2)&&(zi=a.y2)):qi=zi=a,Of({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},lg.axis.min=function(a){arguments.length&&("object"==typeof a?(b(a.x)&&(ki=a.x),b(a.y)&&(ri=a.y),b(a.y2)&&(Ai=a.y2)):ri=Ai=a,Of({withUpdateOrgXDomain:!0,withUpdateXDomain:!0}))},lg.axis.range=function(a){arguments.length&&("undefined"!=typeof a.max&&lg.axis.max(a.max),"undefined"!=typeof a.min&&lg.axis.min(a.min))},lg.legend.show=function(a){bg(Rc(a)),Of({withLegend:!0})},lg.legend.hide=function(a){cg(Rc(a)),Of({withLegend:!0})},lg.resize=function(a){og=a?a.width:null,pg=a?a.height:null,lg.flush()},lg.flush=function(){Uf({withLegend:!0,withTransition:!1,withTransitionForTransform:!1})},lg.destroy=function(){lg.data.targets=void 0,lg.data.xs={},rk.classed("c3",!1).html(""),a.onresize=null},f.data.url)jg(f.data);else if(f.data.json)Gf(Gc(f.data.json,f.data.keys));else if(f.data.rows)Gf(Hc(f.data.rows));else{if(!f.data.columns)throw Error("url or json or rows or columns is required.");Gf(Ic(f.data.columns))}return lg},"function"==typeof define&&define.amd?define("c3",["d3"],f):"undefined"!=typeof exports&&"undefined"!=typeof module?module.exports=f:a.c3=f}(window); \ No newline at end of file diff --git a/htdocs/samples/data_label.html b/htdocs/samples/data_label.html new file mode 100644 index 0000000..7c278ce --- /dev/null +++ b/htdocs/samples/data_label.html @@ -0,0 +1,57 @@ + + + + + +
+
+ + + + + +