From e75290a002eccfabab19791b6e2fb091aec070dd Mon Sep 17 00:00:00 2001 From: Brandon Bernal Date: Mon, 12 May 2014 14:38:02 -0400 Subject: [PATCH] Fixed pie chart color. --- c3.js | 6 +++--- c3.min.js | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/c3.js b/c3.js index 5d870fd..8407b92 100644 --- a/c3.js +++ b/c3.js @@ -273,7 +273,7 @@ name = d[i].name; value = valueFormat(d[i].value, d[i].ratio); - bgcolor = (__color_values) ? levelColor(d[i].value) : color(d[i].id); + bgcolor = (__gauge_style === 'arc' && __color_values) ? levelColor(d[i].value) : color(d[i].id); text += ""; text += "" + name + ""; @@ -3489,7 +3489,7 @@ return function (t) { return getArc(interpolate(t), true); }; }) .attr("transform", withTransform ? "scale(1)" : "") - .style("fill", function (d) { return (__color_values) ? levelColor(d.data.values[0].value) : color(d.data.id); }) // Where gauge reading color would receive customization. + .style("fill", function (d) { return (__gauge_style === 'arc' && __color_values) ? levelColor(d.data.values[0].value) : color(d.data.id); }) // Where gauge reading color would receive customization. .style("opacity", (__color_opacity) ? __color_opacity : 1); main.selectAll('.' + CLASS.chartArc).select('text') .attr("transform", transformForArcLabel) @@ -3812,7 +3812,7 @@ mainPieEnter.append("path") .attr("class", classArc) .style("opacity", 0) - .style("fill", function (d) { return (__color_values) ? levelColor(d.data.values[0].value) : color(d.data.id); }) // Where gauge reading color would receive customization. + .style("fill", function (d) { return (__gauge_style === 'arc' && __color_values) ? levelColor(d.data.values[0].value) : color(d.data.id); }) // Where gauge reading color would receive customization. .style("cursor", function (d) { return __data_selection_isselectable(d) ? "pointer" : null; }) .each(function (d) { this._current = d; }) .on('mouseover', function (d, i) { diff --git a/c3.min.js b/c3.min.js index da4b243..f9ab2eb 100644 --- a/c3.min.js +++ b/c3.min.js @@ -1 +1 @@ -(function(e){"use strict";function r(e){return e||e===0}function i(e){return typeof e==="undefined"}function s(e){return typeof e!=="undefined"}var t={version:"0.1.27"};var n={target:"c3-target",chart:"c3-chart",chartLine:"c3-chart-line",chartLines:"c3-chart-lines",chartBar:"c3-chart-bar",chartBars:"c3-chart-bars",chartText:"c3-chart-text",chartTexts:"c3-chart-texts",chartArc:"c3-chart-arc",chartArcs:"c3-chart-arcs",chartArcsTitle:"c3-chart-arcs-title",gaugeArc:"c3-gauge-arc",gaugeArcs:"c3-gauge-arcs",gaugeArcsTitle:"c3-gauge-arcs-title",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",step:"c3-step",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",area:"c3-area",text:"c3-text",texts:"c3-texts",grid:"c3-grid",xgrid:"c3-xgrid",xgrids:"c3-xgrids",xgridLine:"c3-xgrid-line",xgridLines:"c3-xgrid-lines",xgridFocus:"c3-xgrid-focus",ygrid:"c3-ygrid",ygrids:"c3-ygrids",ygridLine:"c3-ygrid-line",ygridLines:"c3-ygrid-lines",axisX:"c3-axis-x",axisXLabel:"c3-axis-x-label",axisY:"c3-axis-y",axisYLabel:"c3-axis-y-label",axisY2:"c3-axis-y2",axisY2Label:"c3-axis-y2-label",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};t.generate=function(t){function f(e,n){if(!(e in t)){throw Error(n)}}function l(e,n){var r=t,i,s,o;for(i=0;i0?s:0}function $r(){return h?h:Zr()}function Jr(){var e=p?p:ei();return e>0?e:320}function Kr(){if(Su(u.data.targets)){return 0}else if(d){return d}else{return st||!yt||xt?1:Gr("y")}}function Qr(){var e=1;if(Su(u.data.targets)){return 0}else if(v){return v}else if(_r){return tr+(kt&&!st?Gr("y2"):e)}else if(kt){return _t||st?e:Gr("y2")}else{return e}}function Gr(e){var t=Bi(e);return t.isInner?20+ts(e):40+ts(e)}function Yr(e){if(e==="y"&&!yt){return tt&&!_r?10:1}if(e==="y2"&&!kt){return zr}return(Bi(e).isInner?30:40)+(e==="y2"?-10:0)}function Zr(){return+o.select(c).style("width").replace("px","")}function ei(){return+o.select(c).style("height").replace("px","")}function ti(e){return e?-(1+4):-(Xn.left-1)}function ni(e){return e?-20:-1}function ri(){return ti(!st)}function ii(){return ni(!st)}function si(){return ti(st)}function oi(){return ni(st)}function ui(e){return e?Jn+2+4:Xn.left+20}function ai(e){return e?80:Qn+2}function fi(){return ui(!st)}function li(){return ai(!st)}function ci(){return ui(st)}function hi(){return ai(st)}function pi(){var e=st?Qn:Jn,t=Ks(),n=xs()*(gu(u.data.targets)?(t-(Hn?.25:1))/t:.98);return t>1?e*n/(t-1):e}function di(e){Dr=e}function vi(e){Pr=e}function mi(e){Hr=e}function gi(){return tt?_r?Pr*(Dr+1):Yn:0}function yi(){return tt?_r?Zn:Hr*(Dr+1):0}function bi(){var e,t=!gr;fr=st?1:0;lr=st?Qn:Jn;cr=st?0:Qn;hr=st?Jn:1;pr=fr;dr=lr;vr=st?0:Gn;mr=st?Kn:1;gr=Ei(fr,lr,t?undefined:gr.domain(),function(){return xr.tickOffset()});yr=Si(cr,hr);br=Si(cr,hr);wr=Ei(fr,lr,La,function(e){return e%1?0:Cr.tickOffset()});Er=Si(vr,mr);Sr=Si(vr,mr);e=Li();xr=Ni(gr,kr,e);Cr=Ni(wr,Or,e);Tr=Ci(yr,Lr,Tt,Ct);Nr=Ci(br,Ar,Dt,Ht);if(!t){ba.scale(wr);if(m){wa.scale(gr)}}wi()}function wi(){sr=ss();or=os();ur=os(.98)}function Ei(e,t,n,r){var u=(Pn?o.time.scale():o.scale.linear()).range([e,t]);u.orgDomain=function(){return u.domain()};if(s(n)){u.domain(n)}if(i(r)){r=function(){return 0}}if(Hn){var a=u,f;u=function(e){return a(e)+r(e)};for(f in a){u[f]=a[f]}u.orgDomain=function(){return a.domain()};u.domain=function(e){if(!arguments.length){e=a.domain();return[e[0],e[1]+1]}a.domain(e);return u}}return u}function Si(e,t){return o.scale.linear().range([e,t])}function xi(e){return ki(e)==="y2"?br:yr}function Ti(e){return ki(e)==="y2"?Sr:Er}function Ni(e,t,n){var r=(Hn?rs():o.svg.axis()).scale(e).orient(t);r.tickFormat(n);if(Hn){r.tickCentered(at)}else{r.tickOffset=function(){var e=st?Qn:Jn;return e*xs()/Ks()/2}}if(Hn){r.categories(ut)}return r}function Ci(e,t,n,r){return o.svg.axis().scale(e).orient(t).tickFormat(n).ticks(r).outerTickSize(0)}function ki(e){return e in L?L[e]:"y"}function Li(){var e=Pn?zn:Hn?lo:function(e){return e<0?e.toFixed(0):e};if(ft){if(typeof ft==="function"){e=ft}else if(Pn){e=function(e){return o.time.format(ft)(e)}}}return e}function Ai(e){var t;if(e==="y"){t=St}else if(e==="y2"){t=Mt}else if(e==="x"){t=gt}return t}function Oi(e){var t=Ai(e);return typeof t==="string"?t:t?t.text:null}function Mi(e,t){var n=Ai(e);if(typeof n==="string"){if(e==="y"){St=t}else if(e==="y2"){Mt=t}else if(e==="x"){gt=t}}else if(n){n.text=t}}function _i(e,t){var n=Ai(e),r=n&&typeof n==="object"&&n.position?n.position:t;return{isInner:r.indexOf("inner")>=0,isOuter:r.indexOf("outer")>=0,isLeft:r.indexOf("left")>=0,isCenter:r.indexOf("center")>=0,isRight:r.indexOf("right")>=0,isTop:r.indexOf("top")>=0,isMiddle:r.indexOf("middle")>=0,isBottom:r.indexOf("bottom")>=0}}function Di(){return _i("x",st?"inner-top":"inner-right")}function Pi(){return _i("y",st?"inner-right":"inner-top")}function Hi(){return _i("y2",st?"inner-right":"inner-top")}function Bi(e){return e==="y2"?Hi():e==="y"?Pi():Di()}function ji(){return Oi("x")}function Fi(){return Oi("y")}function Ii(){return Oi("y2")}function qi(e,t){if(e){return t.isLeft?0:t.isCenter?Jn/2:Jn}else{return t.isBottom?-Qn:t.isMiddle?-Qn/2:0}}function Ri(e,t){if(e){return t.isLeft?"0.5em":t.isRight?"-0.5em":"0"}else{return t.isTop?"-0.5em":t.isBottom?"0.5em":"0"}}function Ui(e,t){if(e){return t.isLeft?"start":t.isCenter?"middle":"end"}else{return t.isBottom?"start":t.isMiddle?"middle":"end"}}function zi(){return qi(!st,Di())}function Wi(){return qi(st,Pi())}function Xi(){return qi(st,Hi())}function Vi(){return Ri(!st,Di())}function $i(){return Ri(st,Pi())}function Ji(){return Ri(st,Hi())}function Ki(){var e=Di();if(st){return e.isInner?"1.2em":-30-ts("x")}else{return e.isInner?"-0.5em":"3em"}}function Qi(){var e=Pi();if(st){return e.isInner?"-0.5em":"3em"}else{return e.isInner?"1.2em":-20-ts("y")}}function Gi(){var e=Hi();if(st){return e.isInner?"1.2em":"-2.2em"}else{return e.isInner?"-0.5em":30+ts("y2")}}function Yi(){return Ui(!st,Di())}function Zi(){return Ui(st,Pi())}function es(){return Ui(st,Hi())}function ts(e){var t=0,r=e==="x"?n.axisX:e==="y"?n.axisY:n.axisY2;o.selectAll("."+r+" .tick text").each(function(){var e=this.getBBox();if(t0&&t[0]>0){t.unshift(t[0]-(t[1]-t[0]))}return t}function m(e,t){var n=e.length-1;return n<=u||t%Math.ceil(n/u)===0}function g(e){return e0){f=ao(e);for(r=0;r=0});if(u.length===0){continue}s=u[0];if(f&&n[s]){n[s].forEach(function(e,t){n[s][t]=e<0?e:0})}for(i=1;i0)){n[s][t]+=+e}})}}}return o.min(Object.keys(n).map(function(e){return o.min(n[e])}))}function Es(e){var t=Gs(e),n=oo(e),r,i,s,u,a,f;if(k.length>0){f=fo(e);for(r=0;r=0});if(u.length===0){continue}s=u[0];if(f&&n[s]){n[s].forEach(function(e,t){n[s][t]=e>0?e:0})}for(i=1;i1?i/(s-1)/2:.5}else if(Bt){o=i*.001}else{o=i*.01}return o}function ks(e){var t=[Ts(e),Ns(e)],n=t[0],r=t[1],i=Cs(e,t),s=n==undefined?i:Pn?new Date(n.getTime()-i):n-i,o=r==undefined?i:Pn?new Date(r.getTime()+i):r+i;return[s,o]}function Ls(e){return e[1]-e[0]}function As(e){for(var t=0;t=0){u.data.x[t]=e.map(function(e){return e[r]})}}else{u.data.x[t]=e.map(function(e,t){return t})}});t.forEach(function(e){if(!u.data.x[e]){throw new Error('x is not defined for id = "'+e+'".')}});r=t.map(function(t,n){var r=N(t);return{id:r,id_org:t,values:e.map(function(e,i){var s=Bs(t),o=e[s],u=Us(o,t,i);if(Bn&&Hn&&n===0&&o){if(i===0){ut=[]}ut.push(o)}if(typeof e[t]==="undefined"){u=undefined}return{x:u,value:e[t]!==null&&!isNaN(e[t])?+e[t]:null,id:r}}).filter(function(e){return typeof e.x!=="undefined"})}});r.forEach(function(e){var t;e.values=e.values.sort(function(e,t){var n=e.x||e.x===0?e.x:Infinity,r=t.x||t.x===0?t.x:Infinity;return n-r});t=0;e.values.forEach(function(e){e.index=t++})});if(A){vu(Gs(r).filter(function(e){return!(e in O)}),A)}r.forEach(function(e){Os(e.id_org,e)});return r}function Vs(e){return{id:e.id,id_org:e.id_org,values:e.values.map(function(e){return{x:e.x,value:e.value,id:e.id}})}}function $s(e){return e>0&&u.data.targets[0].values[e-1]?u.data.targets[0].values[e-1].x:undefined}function Js(e){return e1){u.data.targets.forEach(function(e){if(e.values.length>t){n=e;t=e.values.length}})}else{n=e?u.data.targets[0]:null}return n}function Gs(e){e=i(e)?u.data.targets:e;return e.map(function(e){return e.id})}function Ys(e){var t=Gs(),n;for(n=0;n2){s=n-2;r=e[0];i=e[e.length-1];o=(i-r)/(s+1);t=[r];for(u=0;u0})}function lo(e){return e=0;n--){if(r!==e[n].x){break}i.push(e[n])}for(n=t;n0?s=o:i=o;if(s-i===1||i===0&&s===0){f=[];if(e[i].x){f=f.concat(Uo(e,i))}if(e[s].x){f=f.concat(Uo(e,s))}return Xo(f,t)}return zo(e,t,i,s)}function Wo(e,t){var n;n=e.map(function(e){return zo(e.values,t)});return Xo(n,t)}function Xo(e,t){var n,r;e.forEach(function(e){var i=Wu(e,t);if(il){o-=n+60}if(f+i>Jr()){f-=i+30}}Ca.style("top",f+"px").style("left",o+"px")}function Go(){Ca.style("display","none")}function Yo(e){var t=e.filter(function(e){return e&&r(e.value)});if(!En){return}if(yu(u.data.targets)||Su(u.data.targets)){return}xa.selectAll("line."+n.xgridFocus).style("visibility","visible").data([t[0]]).attr(st?"y1":"x1",Fo).attr(st?"y2":"x2",Fo)}function Zo(){xa.select("line."+n.xgridFocus).style("visibility","hidden")}function eu(e){return e.x||e.x===0?gr(e.x):null}function tu(e,t){var n=cu(),r=va(n);if(k.length>0){var i=r(e,t);return i[0][1]}return xi(e.id)(e.value)}function nu(){var e={},t=0,n,r;to(Zs(ku)).forEach(function(s){for(n=0;n0){a+=o(t.values[s].value)-u}});return a}}function ou(e,t){return Kt?Kt:t?e.tickOffset()*2*Qt/t:0}function uu(){var e={},t=0,n,r;to(Zs(Cu)).forEach(function(s){for(n=0;n0){a+=o(t.values[s].value)-u}});return a}}function cu(){var e={},t=0,n,r;to(Zs(xu)).forEach(function(s){for(n=0;n0){a+=o(t.values[s].value)-u}});return a}}function vu(e,t){var n=i(e)?Gs():e;if(typeof n==="string"){n=[n]}for(var r=0;r0}function zu(e,t){var n=false;Object.keys(e).forEach(function(r){if(e[r]===t){n=true}});return n}function Wu(e,t){return Math.pow(gr(e.x)-t[0],2)+Math.pow(yr(e.value)-t[1],2)}function Xu(e,t){var n=0;e.each(function(){++n}).each("end",function(){if(!--n){t.apply(this,arguments)}})}function Vu(e,t,r){U(t,e.node());xa.select("."+n.selectedCircles+ko(t.id)).selectAll("."+n.selectedCircle+"-"+r).data([t]).enter().append("circle").attr("class",function(){return co(n.selectedCircle,r)}).attr("cx",st?tu:eu).attr("cy",st?eu:tu).attr("stroke",function(){return Rn(t.id)}).attr("r",Jt*1.4).transition().duration(100).attr("r",Jt)}function $u(e,t,r){z(t,e.node());xa.select("."+n.selectedCircles+ko(t.id)).selectAll("."+n.selectedCircle+"-"+r).transition().duration(100).attr("r",0).remove()}function Ju(e,t,n,r){e?Vu(t,n,r):$u(t,n,r)}function Ku(e,t){U(t,e.node());e.transition().duration(100).style("fill",function(){return o.rgb(Rn(t.id)).darker(1)})}function Qu(e,t){z(t,e.node());e.transition().duration(100).style("fill",function(){return Rn(t.id)})}function Gu(e,t,n,r){e?Ku(t,n,r):Qu(t,n,r)}function Yu(e){return e.filter(function(e){return r(e.value)})}function Zu(e,t){return(t?xa.selectAll("."+n.circles+ko(t)):xa).selectAll("."+n.circle+(r(e)?"-"+e:""))}function ea(e,t){Zu(e,t).classed(n.EXPANDED,true).attr("r",$t)}function ta(e){Zu(e).filter(function(){return o.select(this).classed(n.EXPANDED)}).classed(n.EXPANDED,false).attr("r",Wt)}function na(e){return xa.selectAll("."+n.bar+(r(e)?"-"+e:""))}function ra(e){na(e).classed(n.EXPANDED,true)}function ia(e){na(e).classed(n.EXPANDED,false)}function ua(e,t){var n,r=pa(e,t);if(st){n=o.svg.area().x0(function(e,t){return xi(e.id)(0)}).x1(function(e,t){return xi(e.id)(e.value)}).y(Fo)}else{n=o.svg.area().x(Fo).y0(function(e,t){if(k.length>0){var n=r(e,t);return n[0][1]}return xi(e.id)(0)}).y1(function(e,t){if(k.length>0){var n=r(e,t);return n[1][1]}return xi(e.id)(e.value)})}return function(e,t){var r=Yu(e.values),i,s;if(mu([e],"area")||mu([e],"area-spline")){Nu(e)?n.interpolate("cardinal"):n.interpolate("linear");return n(r)}else if(mu([e],"area-step")){Tu(e)?n.interpolate("step-after"):n.interpolate("linear");return n(r)}else{i=gr(r[0].x);s=xi(e.id)(r[0].value);return st?"M "+s+" "+i:"M "+i+" "+s}}}function aa(e,t){var n=da(e,t);return function(e,t){var r=n(e,t);var i=st?1:0;var s=st?0:1;var o="M "+r[0][i]+","+r[0][s]+" "+"L"+r[1][i]+","+r[1][s]+" "+"L"+r[2][i]+","+r[2][s]+" "+"L"+r[3][i]+","+r[3][s]+" "+"z";return o}}function fa(e,t){var n=va(e,t),r=o.svg.line().x(st?function(e,t){if(k.length>0){var r=n(e,t);return r[0][1]}return xi(e.id)(e.value)}:Fo).y(st?Fo:function(e,t){if(k.length>0){var r=n(e,t);return r[0][1]}return xi(e.id)(e.value)});return function(e){var t=Yu(e.values),n,i;if(xu(e)){Nu(e)?r.interpolate("cardinal"):r.interpolate("linear");return D[e.id]?ya(t,gr,xi(e.id),D[e.id]):r(t)}else if(Tu(e)){r.interpolate("step-after");return D[e.id]?ya(t,gr,xi(e.id),D[e.id]):r(t)}else{n=gr(t[0].x);i=xi(e.id)(t[0].value);return st?"M "+i+" "+n:"M "+n+" "+i}}}function la(e,t){var n=da(e,false),r=t?ca:ha;return function(e,t){return r(n(e,t),e,this)}}function ca(e,t){var n;if(st){n=ku(t)?4:6;return e[2][1]+n*(t.value<0?-1:1)}else{return e[0][0]+(e[2][0]-e[0][0])/2}}function ha(e,t,n){var r=n.getBBox();if(st){return(e[0][0]+e[2][0]+r.height*.6)/2}else{return e[2][1]+(t.value<0?r.height:ku(t)?-3:-6)}}function pa(e,t){var n=e.__max__+1,r=au(n,e,!!t),i=fu(!!t),s=lu(e,!!t),o=t?Ti:xi;return function(e,t){var n=o(e.id)(0),u=s(e,t)||n,a=r(e),f=i(e);if(st){if(e.value>0&&fu){f=u}}return[[a,u],[a,f-(n-u)]]}}function da(e,t){var n=e.__max__+1,r=ou(xr,n),i=ru(r,n,e,!!t),s=iu(!!t),o=su(e,!!t),u=t?Ti:xi;return function(e,t){var n=u(e.id)(0),a=o(e,t)||n,f=i(e),l=s(e);if(st){if(e.value>0&&la){l=a}}return[[f,a],[f,l-(n-a)],[f+r,l-(n-a)],[f+r,a]]}}function va(e,t){var n=e.__max__+1,r=hu(n,e,!!t),i=pu(!!t),s=du(e,!!t),o=t?Ti:xi;return function(e,t){var n=o(e.id)(0),u=s(e,t)||n,a=r(e),f=i(e);if(st){if(e.value>0&&fu){f=u}}return[[a,f-(n-u)]]}}function ya(e,t,n,r){var o=-1,u,a;var f="M",l;var c,h,p,d,v,m;var g,y;var b=[];if(s(r)){for(u=0;u0){s=[];for(var o in C){for(i=0;i=m){m=s}if(!g||o>=g){g=o}l=_r?g:m;if(it){Object.keys(E).forEach(function(e){E[e]=m});Object.keys(S).forEach(function(e){S[e]=g});f=(a-l*r.length)/2;if(f"+(f||f===0?""+f+"":"")}c=e[a].name;l=o(e[a].value,e[a].ratio);h=et?Un(e[a].value):i(e[a].id);u+="";u+=""+c+"";u+=""+l+"";u+=""}return u+""}),Nn=l(["tooltip","init","show"],false),Cn=l(["tooltip","init","x"],0),kn=l(["tooltip","init","position"],{top:"0px",left:"50px"});var Ln=(typeof c==="string"?c.replace("#",""):c.id)+"-clip",An=Ln+"-xaxis",On=Ln+"-yaxis",Mn=Br(Ln),_n=Br(_n),Dn=Br(Dn);var Pn=ot==="timeseries",Hn=ot==="categorized",Bn=!Pn&&(S||Uu(x));var jn=null,Fn=false,In=false,qn=false;var Rn=Bu(P,Y);var Un=ju(Y,et);var zn=function(){var e=[[o.time.format("%Y/%-m/%-d"),function(){return true}],[o.time.format("%-m/%-d"),function(e){return e.getMonth()}],[o.time.format("%-m/%-d"),function(e){return e.getDate()!==1}],[o.time.format("%-m/%-d"),function(e){return e.getDay()&&e.getDate()!==1}],[o.time.format("%I %p"),function(e){return e.getHours()}],[o.time.format("%I:%M"),function(e){return e.getMinutes()}],[o.time.format(":%S"),function(e){return e.getSeconds()}],[o.time.format(".%L"),function(e){return e.getMilliseconds()}]];return function(t){var n=e.length-1,r=e[n];while(!r[1](t)){r=e[--n]}return r[0](t)}}();var Wn=[];var Xn,Vn,$n,Jn,Kn,Qn,Gn,Yn,Zn,er,tr;var nr,rr,ir,sr,or,ur,ar;var fr,lr,cr,hr,pr,dr,vr,mr;var gr,yr,br,wr,Er,Sr,xr,Tr,Nr,Cr;var kr=st?"left":"bottom",Lr=st?xt?"top":"bottom":xt?"right":"left",Ar=st?_t?"bottom":"top":_t?"left":"right",Or=st?"left":"bottom";var Mr={main:function(){return"translate("+Xn.left+","+Xn.top+")"},context:function(){return"translate("+Vn.left+","+Vn.top+")"},legend:function(){return"translate("+$n.left+","+$n.top+")"},x:function(){return"translate(0,"+(st?0:Qn)+")"},y:function(){return"translate(0,"+(st?Qn:0)+")"},y2:function(){return"translate("+(st?0:Jn)+","+(st?1:0)+")"},subx:function(){return"translate(0,"+(st?0:Gn)+")"},arc:function(){return"translate("+Jn/2+","+Qn/2+")"}};var _r=nt==="right";var Dr=0,Pr=0,Hr=0;var Rr=30,Ur=30,zr=5;ar=o.layout.pie().value(function(e){return e.values.reduce(function(e,t){return e+t.value},0)});var sa=function(){var e=o.svg.line().x(st?function(e){return xi(e.id)(e.value)}:Fo).y(st?Fo:function(e){return xi(e.id)(e.value)});return function(t){var n=Yu(t.values),r,i;if(xu(t)){Nu(t)?e.interpolate("cardinal"):e.interpolate("linear");return D[t.id]?ya(n,gr,xi(t.id),D[t.id]):e(n)}else if(Tu(t)){e.interpolate("step-after");return D[t.id]?ya(n,gr,xi(t.id),D[t.id]):e(n)}else{r=gr(n[0].x);i=xi(t.id)(n[0].value);return st?"M "+i+" "+r:"M "+r+" "+i}}}();var oa=function(){var e;if(st){e=o.svg.area().x0(function(e){return xi(e.id)(0)}).x1(function(e){return xi(e.id)(e.value)}).y(Fo)}else{e=o.svg.area().x(Fo).y0(function(e){return xi(e.id)(0)}).y1(function(e){return xi(e.id)(e.value)})}return function(t){var n=Yu(t.values),r,i;if(mu([t],"area")||mu([t],"area-spline")){Nu(t)?e.interpolate("cardinal"):e.interpolate("linear");return e(n)}else if(mu([t],"area-step")){Tu(t)?e.interpolate("step-after"):e.interpolate("linear");return e(n)}else{r=gr(n[0].x);i=xi(t.id)(n[0].value);return st?"M "+i+" "+r:"M "+r+" "+i}}}();var ma=function(){var e=o.svg.line().x(st?function(e){return Ti(e.id)(e.value)}:Ro).y(st?Ro:function(e){return Ti(e.id)(e.value)});return function(t){var n=Yu(t.values);if(xu(t)){return e(n)}else if(Tu(t)){e.interpolate("step-after");return e(n)}else{return"M "+wr(n[0].x)+" "+Ti(t.id)(n[0].value)}}}();var ga=function(){var e=o.svg.area().x(Fo).y0(function(e){return Ti(e.id)(Xn.bottom-G)}).y1(function(e){return Ti(e.id)(e.value)});return function(t){var n=Yu(t.values),r,i;if(mu([t],"area")||mu([t],"area-spline")){Nu(t)?e.interpolate("cardinal"):e.interpolate("linear");return e(n)}else if(mu([t],"area-step")){Tu(t)?e.interpolate("step-after"):e.interpolate("linear");return e(n)}else{r=wr(n[0].x);i=Ti(t.id)(n[0].value);return st?"M "+i+" "+r:"M "+r+" "+i}}}();var ba,wa=function(){};ba=o.svg.brush().on("brush",Ia);ba.update=function(){if(Ta){Ta.select("."+n.brush).call(this)}return this};ba.scale=function(e){return st?this.y(e):this.x(e)};if(m){wa=o.behavior.zoom().on("zoomstart",function(){wa.altDomain=o.event.sourceEvent.altKey?gr.orgDomain():null}).on("zoom",m?qa:null);wa.scale=function(e){return st?this.y(e):this.x(e)};wa.orgScaleExtent=function(){var e=g?g:[1,10];return[e[0],Math.max(Ks()/e[1],e[1])]};wa.updateScaleExtent=function(){var e=Ls(gr.orgDomain())/Ls(La),t=this.orgScaleExtent();this.scaleExtent([t[0]*e,t[1]*e]);return this}}var Ea,Sa,xa,Ta,Na,Ca,ka;var La;var Aa,Oa={};u.focus=function(e){function s(e){to(e).transition().duration(100).style("opacity",1)}var t=Ea.selectAll(Lo(e)),r=t.filter(Za),i=t.filter(ef);u.revert();u.defocus();s(r.classed(n.focused,true));s(i);if(Su(u.data.targets)){hs(e,true)}Ka(e)};u.defocus=function(e){function s(e){to(e).transition().duration(100).style("opacity",.3)}var t=Ea.selectAll(Lo(e)),r=t.filter(Za),i=t.filter(ef);u.revert();s(r.classed(n.focused,false));s(i);if(Su(u.data.targets)){ps(e)}Qa(e)};u.revert=function(e){function s(e){to(e).transition().duration(100).style("opacity",1)}var t=Ea.selectAll(Lo(e)),r=t.filter(Za),i=t.filter(ef);s(r.classed(n.focused,false));s(i);if(Su(u.data.targets)){ps(e)}Ga()};u.show=function(e){so(e);Ea.selectAll(Lo(e)).transition().style("opacity",1);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:false})};u.hide=function(e){io(e);Ea.selectAll(Lo(e)).transition().style("opacity",0);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:false})};u.toggle=function(e){eo(e)?u.hide(e):u.show(e)};u.unzoom=function(){ba.clear().update();Fa({withUpdateXDomain:true})};u.load=function(e){if(e.xs){Fs(e.xs)}if("categories"in e&&Hn){ut=e.categories;xr.categories(ut)}if("cacheIds"in e&&As(e.cacheIds)){Xa(Ms(e.cacheIds),e.done);return}if("unload"in e){$a(typeof e.unload==="string"?[e.unload]:typeof e.unload==="boolean"&&e.unload?Gs():e.unload,function(){Va(e)})}else{Va(e)}};u.unload=function(e){$a(e?typeof e==="string"?[e]:e:Gs(),function(){Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:true})})};u.selected=function(e){return o.merge(xa.selectAll("."+n.shapes+ko(e)).selectAll("."+n.shape).filter(function(){return o.select(this).classed(n.SELECTED)}).map(function(e){return e.map(function(e){return e.__data__})}))};u.select=function(e,t,r){if(!H){return}xa.selectAll("."+n.shapes).selectAll("."+n.shape).each(function(i,u){var a=o.select(this),f=this.nodeName==="circle"?Vu:Ku,l=this.nodeName==="circle"?$u:Qu,c=B||!e||e.indexOf(i.id)>=0,h=!t||t.indexOf(u)>=0,p=a.classed(n.SELECTED);if(c&&h){if(j(i)&&!p){f(a.classed(n.SELECTED,true),i,u)}}else if(s(r)&&r){if(p){l(a.classed(n.SELECTED,false),i,u)}}})};u.unselect=function(e,t){if(!H){return}xa.selectAll("."+n.shapes).selectAll("."+n.shape).each(function(r,i){var s=o.select(this),u=this.nodeName==="circle"?$u:Qu,a=B||!e||e.indexOf(r.id)>=0,f=!t||t.indexOf(i)>=0,l=s.classed(n.SELECTED);if(a&&f){if(j(r)){if(l){u(s.classed(n.SELECTED,false),r,i)}}}})};u.toLine=function(e){vu(e,"line");za()};u.toSpline=function(e){vu(e,"spline");za()};u.toBar=function(e){vu(e,"bar");za()};u.toScatter=function(e){vu(e,"scatter");za()};u.toArea=function(e){vu(e,"area");za()};u.toAreaSpline=function(e){vu(e,"area-spline");za()};u.toPie=function(e){vu(e,"pie");za({withTransform:true})};u.toDonut=function(e){vu(e,"donut");za({withTransform:true})};u.groups=function(e){if(i(e)){return k}k=e;Fa();return k};u.xgrids=function(e){if(!e){return It}It=e;Fa();return It};u.xgrids.add=function(e){if(!e){return}return u.xgrids(It.concat(e))};u.xgrids.remove=function(e){var t=tf(e);return u.xgrids(It.filter(t))};u.ygrids=function(e){if(!e){return Rt}Rt=e;Fa();return Rt};u.ygrids.add=function(e){if(!e){return}return u.ygrids(Rt.concat(e))};u.ygrids.remove=function(e){var t=tf(e);return u.ygrids(Rt.filter(t))};u.regions=function(e){if(i(e)){return wn}wn=e;Fa();return wn};u.regions.add=function(e){if(i(e)){return wn}wn=wn.concat(e);Fa();return wn};u.regions.remove=function(e,t){var n=[].concat(e);t=s(t)?t:{};n.forEach(function(e){var n=r(t.duration)?t.duration:0;Ea.selectAll("."+e).transition().duration(n).style("fill-opacity",0).remove();wn=wn.filter(function(t){return t.classes.indexOf(e)<0})});return wn};u.data.get=function(e){var t=u.data.getAsTarget(e);return s(t)?t.values.map(function(e){return e.value}):undefined};u.data.getAsTarget=function(e){var t=Zs(function(t){return t.id===e});return t.length>0?t[0]:undefined};u.data.names=function(e){if(!arguments.length){return C}Object.keys(e).forEach(function(t){C[t]=e[t]});Ya(u.data.targets,{withTransition:true});return C};u.x=function(e){if(arguments.length){qs(u.data.targets,e);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true})}return u.data.x};u.xs=function(e){if(arguments.length){Rs(u.data.targets,e);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true})}return u.data.x};u.axis.labels=function(e){if(arguments.length){Object.keys(e).forEach(function(t){Mi(t,e[t])});ns()}};u.axis.max=function(e){if(arguments.length){if(typeof e==="object"){if(r(e.y)){bt=+e.y}if(r(e.y2)){Lt=+e.y2}}else{bt=Lt=+e}Fa()}};u.axis.min=function(e){if(arguments.length){if(typeof e==="object"){if(r(e.y)){wt=+e.y}if(r(e.y2)){At=+e.y2}}else{wt=At=+e}Fa()}};u.axis.range=function(e){if(arguments.length){if(typeof e.max!=="undefined"){u.axis.max(e.max)}if(typeof e.min!=="undefined"){u.axis.min(e.min)}}};u.resize=function(e){h=e?e.width:null;p=e?e.height:null;za({withLegend:true,withTransition:false})};u.destroy=function(){u.data.targets=undefined;u.data.x={};ka.html("");e.onresize=null};if("url"in t.data){o.csv(t.data.url,function(e,t){Ma(t)})}else if("rows"in t.data){Ma(zs(t.data.rows))}else if("columns"in t.data){Ma(Ws(t.data.columns))}else{throw Error("url or rows or columns is required.")}return u};if(typeof e.define==="function"&&e.define.amd){e.define("c3",["d3"],t)}else{e.c3=t}})(window) +(function(e){"use strict";function r(e){return e||e===0}function i(e){return typeof e==="undefined"}function s(e){return typeof e!=="undefined"}var t={version:"0.1.27"};var n={target:"c3-target",chart:"c3-chart",chartLine:"c3-chart-line",chartLines:"c3-chart-lines",chartBar:"c3-chart-bar",chartBars:"c3-chart-bars",chartText:"c3-chart-text",chartTexts:"c3-chart-texts",chartArc:"c3-chart-arc",chartArcs:"c3-chart-arcs",chartArcsTitle:"c3-chart-arcs-title",gaugeArc:"c3-gauge-arc",gaugeArcs:"c3-gauge-arcs",gaugeArcsTitle:"c3-gauge-arcs-title",selectedCircle:"c3-selected-circle",selectedCircles:"c3-selected-circles",eventRect:"c3-event-rect",eventRects:"c3-event-rects",zoomRect:"c3-zoom-rect",brush:"c3-brush",focused:"c3-focused",region:"c3-region",regions:"c3-regions",tooltip:"c3-tooltip",tooltipName:"c3-tooltip-name",shape:"c3-shape",shapes:"c3-shapes",line:"c3-line",step:"c3-step",bar:"c3-bar",bars:"c3-bars",circle:"c3-circle",circles:"c3-circles",arc:"c3-arc",area:"c3-area",text:"c3-text",texts:"c3-texts",grid:"c3-grid",xgrid:"c3-xgrid",xgrids:"c3-xgrids",xgridLine:"c3-xgrid-line",xgridLines:"c3-xgrid-lines",xgridFocus:"c3-xgrid-focus",ygrid:"c3-ygrid",ygrids:"c3-ygrids",ygridLine:"c3-ygrid-line",ygridLines:"c3-ygrid-lines",axisX:"c3-axis-x",axisXLabel:"c3-axis-x-label",axisY:"c3-axis-y",axisYLabel:"c3-axis-y-label",axisY2:"c3-axis-y2",axisY2Label:"c3-axis-y2-label",legendItem:"c3-legend-item",legendItemEvent:"c3-legend-item-event",legendItemTile:"c3-legend-item-tile",dragarea:"c3-dragarea",EXPANDED:"_expanded_",SELECTED:"_selected_",INCLUDED:"_included_"};t.generate=function(t){function f(e,n){if(!(e in t)){throw Error(n)}}function l(e,n){var r=t,i,s,o;for(i=0;i0?s:0}function $r(){return h?h:Zr()}function Jr(){var e=p?p:ei();return e>0?e:320}function Kr(){if(Su(u.data.targets)){return 0}else if(d){return d}else{return st||!yt||xt?1:Gr("y")}}function Qr(){var e=1;if(Su(u.data.targets)){return 0}else if(v){return v}else if(_r){return tr+(kt&&!st?Gr("y2"):e)}else if(kt){return _t||st?e:Gr("y2")}else{return e}}function Gr(e){var t=Bi(e);return t.isInner?20+ts(e):40+ts(e)}function Yr(e){if(e==="y"&&!yt){return tt&&!_r?10:1}if(e==="y2"&&!kt){return zr}return(Bi(e).isInner?30:40)+(e==="y2"?-10:0)}function Zr(){return+o.select(c).style("width").replace("px","")}function ei(){return+o.select(c).style("height").replace("px","")}function ti(e){return e?-(1+4):-(Xn.left-1)}function ni(e){return e?-20:-1}function ri(){return ti(!st)}function ii(){return ni(!st)}function si(){return ti(st)}function oi(){return ni(st)}function ui(e){return e?Jn+2+4:Xn.left+20}function ai(e){return e?80:Qn+2}function fi(){return ui(!st)}function li(){return ai(!st)}function ci(){return ui(st)}function hi(){return ai(st)}function pi(){var e=st?Qn:Jn,t=Ks(),n=xs()*(gu(u.data.targets)?(t-(Hn?.25:1))/t:.98);return t>1?e*n/(t-1):e}function di(e){Dr=e}function vi(e){Pr=e}function mi(e){Hr=e}function gi(){return tt?_r?Pr*(Dr+1):Yn:0}function yi(){return tt?_r?Zn:Hr*(Dr+1):0}function bi(){var e,t=!gr;fr=st?1:0;lr=st?Qn:Jn;cr=st?0:Qn;hr=st?Jn:1;pr=fr;dr=lr;vr=st?0:Gn;mr=st?Kn:1;gr=Ei(fr,lr,t?undefined:gr.domain(),function(){return xr.tickOffset()});yr=Si(cr,hr);br=Si(cr,hr);wr=Ei(fr,lr,La,function(e){return e%1?0:Cr.tickOffset()});Er=Si(vr,mr);Sr=Si(vr,mr);e=Li();xr=Ni(gr,kr,e);Cr=Ni(wr,Or,e);Tr=Ci(yr,Lr,Tt,Ct);Nr=Ci(br,Ar,Dt,Ht);if(!t){ba.scale(wr);if(m){wa.scale(gr)}}wi()}function wi(){sr=ss();or=os();ur=os(.98)}function Ei(e,t,n,r){var u=(Pn?o.time.scale():o.scale.linear()).range([e,t]);u.orgDomain=function(){return u.domain()};if(s(n)){u.domain(n)}if(i(r)){r=function(){return 0}}if(Hn){var a=u,f;u=function(e){return a(e)+r(e)};for(f in a){u[f]=a[f]}u.orgDomain=function(){return a.domain()};u.domain=function(e){if(!arguments.length){e=a.domain();return[e[0],e[1]+1]}a.domain(e);return u}}return u}function Si(e,t){return o.scale.linear().range([e,t])}function xi(e){return ki(e)==="y2"?br:yr}function Ti(e){return ki(e)==="y2"?Sr:Er}function Ni(e,t,n){var r=(Hn?rs():o.svg.axis()).scale(e).orient(t);r.tickFormat(n);if(Hn){r.tickCentered(at)}else{r.tickOffset=function(){var e=st?Qn:Jn;return e*xs()/Ks()/2}}if(Hn){r.categories(ut)}return r}function Ci(e,t,n,r){return o.svg.axis().scale(e).orient(t).tickFormat(n).ticks(r).outerTickSize(0)}function ki(e){return e in L?L[e]:"y"}function Li(){var e=Pn?zn:Hn?lo:function(e){return e<0?e.toFixed(0):e};if(ft){if(typeof ft==="function"){e=ft}else if(Pn){e=function(e){return o.time.format(ft)(e)}}}return e}function Ai(e){var t;if(e==="y"){t=St}else if(e==="y2"){t=Mt}else if(e==="x"){t=gt}return t}function Oi(e){var t=Ai(e);return typeof t==="string"?t:t?t.text:null}function Mi(e,t){var n=Ai(e);if(typeof n==="string"){if(e==="y"){St=t}else if(e==="y2"){Mt=t}else if(e==="x"){gt=t}}else if(n){n.text=t}}function _i(e,t){var n=Ai(e),r=n&&typeof n==="object"&&n.position?n.position:t;return{isInner:r.indexOf("inner")>=0,isOuter:r.indexOf("outer")>=0,isLeft:r.indexOf("left")>=0,isCenter:r.indexOf("center")>=0,isRight:r.indexOf("right")>=0,isTop:r.indexOf("top")>=0,isMiddle:r.indexOf("middle")>=0,isBottom:r.indexOf("bottom")>=0}}function Di(){return _i("x",st?"inner-top":"inner-right")}function Pi(){return _i("y",st?"inner-right":"inner-top")}function Hi(){return _i("y2",st?"inner-right":"inner-top")}function Bi(e){return e==="y2"?Hi():e==="y"?Pi():Di()}function ji(){return Oi("x")}function Fi(){return Oi("y")}function Ii(){return Oi("y2")}function qi(e,t){if(e){return t.isLeft?0:t.isCenter?Jn/2:Jn}else{return t.isBottom?-Qn:t.isMiddle?-Qn/2:0}}function Ri(e,t){if(e){return t.isLeft?"0.5em":t.isRight?"-0.5em":"0"}else{return t.isTop?"-0.5em":t.isBottom?"0.5em":"0"}}function Ui(e,t){if(e){return t.isLeft?"start":t.isCenter?"middle":"end"}else{return t.isBottom?"start":t.isMiddle?"middle":"end"}}function zi(){return qi(!st,Di())}function Wi(){return qi(st,Pi())}function Xi(){return qi(st,Hi())}function Vi(){return Ri(!st,Di())}function $i(){return Ri(st,Pi())}function Ji(){return Ri(st,Hi())}function Ki(){var e=Di();if(st){return e.isInner?"1.2em":-30-ts("x")}else{return e.isInner?"-0.5em":"3em"}}function Qi(){var e=Pi();if(st){return e.isInner?"-0.5em":"3em"}else{return e.isInner?"1.2em":-20-ts("y")}}function Gi(){var e=Hi();if(st){return e.isInner?"1.2em":"-2.2em"}else{return e.isInner?"-0.5em":30+ts("y2")}}function Yi(){return Ui(!st,Di())}function Zi(){return Ui(st,Pi())}function es(){return Ui(st,Hi())}function ts(e){var t=0,r=e==="x"?n.axisX:e==="y"?n.axisY:n.axisY2;o.selectAll("."+r+" .tick text").each(function(){var e=this.getBBox();if(t0&&t[0]>0){t.unshift(t[0]-(t[1]-t[0]))}return t}function m(e,t){var n=e.length-1;return n<=u||t%Math.ceil(n/u)===0}function g(e){return e0){f=ao(e);for(r=0;r=0});if(u.length===0){continue}s=u[0];if(f&&n[s]){n[s].forEach(function(e,t){n[s][t]=e<0?e:0})}for(i=1;i0)){n[s][t]+=+e}})}}}return o.min(Object.keys(n).map(function(e){return o.min(n[e])}))}function Es(e){var t=Gs(e),n=oo(e),r,i,s,u,a,f;if(k.length>0){f=fo(e);for(r=0;r=0});if(u.length===0){continue}s=u[0];if(f&&n[s]){n[s].forEach(function(e,t){n[s][t]=e>0?e:0})}for(i=1;i1?i/(s-1)/2:.5}else if(Bt){o=i*.001}else{o=i*.01}return o}function ks(e){var t=[Ts(e),Ns(e)],n=t[0],r=t[1],i=Cs(e,t),s=n==undefined?i:Pn?new Date(n.getTime()-i):n-i,o=r==undefined?i:Pn?new Date(r.getTime()+i):r+i;return[s,o]}function Ls(e){return e[1]-e[0]}function As(e){for(var t=0;t=0){u.data.x[t]=e.map(function(e){return e[r]})}}else{u.data.x[t]=e.map(function(e,t){return t})}});t.forEach(function(e){if(!u.data.x[e]){throw new Error('x is not defined for id = "'+e+'".')}});r=t.map(function(t,n){var r=N(t);return{id:r,id_org:t,values:e.map(function(e,i){var s=Bs(t),o=e[s],u=Us(o,t,i);if(Bn&&Hn&&n===0&&o){if(i===0){ut=[]}ut.push(o)}if(typeof e[t]==="undefined"){u=undefined}return{x:u,value:e[t]!==null&&!isNaN(e[t])?+e[t]:null,id:r}}).filter(function(e){return typeof e.x!=="undefined"})}});r.forEach(function(e){var t;e.values=e.values.sort(function(e,t){var n=e.x||e.x===0?e.x:Infinity,r=t.x||t.x===0?t.x:Infinity;return n-r});t=0;e.values.forEach(function(e){e.index=t++})});if(A){vu(Gs(r).filter(function(e){return!(e in O)}),A)}r.forEach(function(e){Os(e.id_org,e)});return r}function Vs(e){return{id:e.id,id_org:e.id_org,values:e.values.map(function(e){return{x:e.x,value:e.value,id:e.id}})}}function $s(e){return e>0&&u.data.targets[0].values[e-1]?u.data.targets[0].values[e-1].x:undefined}function Js(e){return e1){u.data.targets.forEach(function(e){if(e.values.length>t){n=e;t=e.values.length}})}else{n=e?u.data.targets[0]:null}return n}function Gs(e){e=i(e)?u.data.targets:e;return e.map(function(e){return e.id})}function Ys(e){var t=Gs(),n;for(n=0;n2){s=n-2;r=e[0];i=e[e.length-1];o=(i-r)/(s+1);t=[r];for(u=0;u0})}function lo(e){return e=0;n--){if(r!==e[n].x){break}i.push(e[n])}for(n=t;n0?s=o:i=o;if(s-i===1||i===0&&s===0){f=[];if(e[i].x){f=f.concat(Uo(e,i))}if(e[s].x){f=f.concat(Uo(e,s))}return Xo(f,t)}return zo(e,t,i,s)}function Wo(e,t){var n;n=e.map(function(e){return zo(e.values,t)});return Xo(n,t)}function Xo(e,t){var n,r;e.forEach(function(e){var i=Wu(e,t);if(il){o-=n+60}if(f+i>Jr()){f-=i+30}}Ca.style("top",f+"px").style("left",o+"px")}function Go(){Ca.style("display","none")}function Yo(e){var t=e.filter(function(e){return e&&r(e.value)});if(!En){return}if(yu(u.data.targets)||Su(u.data.targets)){return}xa.selectAll("line."+n.xgridFocus).style("visibility","visible").data([t[0]]).attr(st?"y1":"x1",Fo).attr(st?"y2":"x2",Fo)}function Zo(){xa.select("line."+n.xgridFocus).style("visibility","hidden")}function eu(e){return e.x||e.x===0?gr(e.x):null}function tu(e,t){var n=cu(),r=va(n);if(k.length>0){var i=r(e,t);return i[0][1]}return xi(e.id)(e.value)}function nu(){var e={},t=0,n,r;to(Zs(ku)).forEach(function(s){for(n=0;n0){a+=o(t.values[s].value)-u}});return a}}function ou(e,t){return Kt?Kt:t?e.tickOffset()*2*Qt/t:0}function uu(){var e={},t=0,n,r;to(Zs(Cu)).forEach(function(s){for(n=0;n0){a+=o(t.values[s].value)-u}});return a}}function cu(){var e={},t=0,n,r;to(Zs(xu)).forEach(function(s){for(n=0;n0){a+=o(t.values[s].value)-u}});return a}}function vu(e,t){var n=i(e)?Gs():e;if(typeof n==="string"){n=[n]}for(var r=0;r0}function zu(e,t){var n=false;Object.keys(e).forEach(function(r){if(e[r]===t){n=true}});return n}function Wu(e,t){return Math.pow(gr(e.x)-t[0],2)+Math.pow(yr(e.value)-t[1],2)}function Xu(e,t){var n=0;e.each(function(){++n}).each("end",function(){if(!--n){t.apply(this,arguments)}})}function Vu(e,t,r){U(t,e.node());xa.select("."+n.selectedCircles+ko(t.id)).selectAll("."+n.selectedCircle+"-"+r).data([t]).enter().append("circle").attr("class",function(){return co(n.selectedCircle,r)}).attr("cx",st?tu:eu).attr("cy",st?eu:tu).attr("stroke",function(){return Rn(t.id)}).attr("r",Jt*1.4).transition().duration(100).attr("r",Jt)}function $u(e,t,r){z(t,e.node());xa.select("."+n.selectedCircles+ko(t.id)).selectAll("."+n.selectedCircle+"-"+r).transition().duration(100).attr("r",0).remove()}function Ju(e,t,n,r){e?Vu(t,n,r):$u(t,n,r)}function Ku(e,t){U(t,e.node());e.transition().duration(100).style("fill",function(){return o.rgb(Rn(t.id)).darker(1)})}function Qu(e,t){z(t,e.node());e.transition().duration(100).style("fill",function(){return Rn(t.id)})}function Gu(e,t,n,r){e?Ku(t,n,r):Qu(t,n,r)}function Yu(e){return e.filter(function(e){return r(e.value)})}function Zu(e,t){return(t?xa.selectAll("."+n.circles+ko(t)):xa).selectAll("."+n.circle+(r(e)?"-"+e:""))}function ea(e,t){Zu(e,t).classed(n.EXPANDED,true).attr("r",$t)}function ta(e){Zu(e).filter(function(){return o.select(this).classed(n.EXPANDED)}).classed(n.EXPANDED,false).attr("r",Wt)}function na(e){return xa.selectAll("."+n.bar+(r(e)?"-"+e:""))}function ra(e){na(e).classed(n.EXPANDED,true)}function ia(e){na(e).classed(n.EXPANDED,false)}function ua(e,t){var n,r=pa(e,t);if(st){n=o.svg.area().x0(function(e,t){return xi(e.id)(0)}).x1(function(e,t){return xi(e.id)(e.value)}).y(Fo)}else{n=o.svg.area().x(Fo).y0(function(e,t){if(k.length>0){var n=r(e,t);return n[0][1]}return xi(e.id)(0)}).y1(function(e,t){if(k.length>0){var n=r(e,t);return n[1][1]}return xi(e.id)(e.value)})}return function(e,t){var r=Yu(e.values),i,s;if(mu([e],"area")||mu([e],"area-spline")){Nu(e)?n.interpolate("cardinal"):n.interpolate("linear");return n(r)}else if(mu([e],"area-step")){Tu(e)?n.interpolate("step-after"):n.interpolate("linear");return n(r)}else{i=gr(r[0].x);s=xi(e.id)(r[0].value);return st?"M "+s+" "+i:"M "+i+" "+s}}}function aa(e,t){var n=da(e,t);return function(e,t){var r=n(e,t);var i=st?1:0;var s=st?0:1;var o="M "+r[0][i]+","+r[0][s]+" "+"L"+r[1][i]+","+r[1][s]+" "+"L"+r[2][i]+","+r[2][s]+" "+"L"+r[3][i]+","+r[3][s]+" "+"z";return o}}function fa(e,t){var n=va(e,t),r=o.svg.line().x(st?function(e,t){if(k.length>0){var r=n(e,t);return r[0][1]}return xi(e.id)(e.value)}:Fo).y(st?Fo:function(e,t){if(k.length>0){var r=n(e,t);return r[0][1]}return xi(e.id)(e.value)});return function(e){var t=Yu(e.values),n,i;if(xu(e)){Nu(e)?r.interpolate("cardinal"):r.interpolate("linear");return D[e.id]?ya(t,gr,xi(e.id),D[e.id]):r(t)}else if(Tu(e)){r.interpolate("step-after");return D[e.id]?ya(t,gr,xi(e.id),D[e.id]):r(t)}else{n=gr(t[0].x);i=xi(e.id)(t[0].value);return st?"M "+i+" "+n:"M "+n+" "+i}}}function la(e,t){var n=da(e,false),r=t?ca:ha;return function(e,t){return r(n(e,t),e,this)}}function ca(e,t){var n;if(st){n=ku(t)?4:6;return e[2][1]+n*(t.value<0?-1:1)}else{return e[0][0]+(e[2][0]-e[0][0])/2}}function ha(e,t,n){var r=n.getBBox();if(st){return(e[0][0]+e[2][0]+r.height*.6)/2}else{return e[2][1]+(t.value<0?r.height:ku(t)?-3:-6)}}function pa(e,t){var n=e.__max__+1,r=au(n,e,!!t),i=fu(!!t),s=lu(e,!!t),o=t?Ti:xi;return function(e,t){var n=o(e.id)(0),u=s(e,t)||n,a=r(e),f=i(e);if(st){if(e.value>0&&fu){f=u}}return[[a,u],[a,f-(n-u)]]}}function da(e,t){var n=e.__max__+1,r=ou(xr,n),i=ru(r,n,e,!!t),s=iu(!!t),o=su(e,!!t),u=t?Ti:xi;return function(e,t){var n=u(e.id)(0),a=o(e,t)||n,f=i(e),l=s(e);if(st){if(e.value>0&&la){l=a}}return[[f,a],[f,l-(n-a)],[f+r,l-(n-a)],[f+r,a]]}}function va(e,t){var n=e.__max__+1,r=hu(n,e,!!t),i=pu(!!t),s=du(e,!!t),o=t?Ti:xi;return function(e,t){var n=o(e.id)(0),u=s(e,t)||n,a=r(e),f=i(e);if(st){if(e.value>0&&fu){f=u}}return[[a,f-(n-u)]]}}function ya(e,t,n,r){var o=-1,u,a;var f="M",l;var c,h,p,d,v,m;var g,y;var b=[];if(s(r)){for(u=0;u0){s=[];for(var o in C){for(i=0;i=m){m=s}if(!g||o>=g){g=o}l=_r?g:m;if(it){Object.keys(E).forEach(function(e){E[e]=m});Object.keys(S).forEach(function(e){S[e]=g});f=(a-l*r.length)/2;if(f"+(f||f===0?""+f+"":"")}c=e[a].name;l=o(e[a].value,e[a].ratio);h=cn==="arc"&&et?Un(e[a].value):i(e[a].id);u+="";u+=""+c+"";u+=""+l+"";u+=""}return u+""}),Nn=l(["tooltip","init","show"],false),Cn=l(["tooltip","init","x"],0),kn=l(["tooltip","init","position"],{top:"0px",left:"50px"});var Ln=(typeof c==="string"?c.replace("#",""):c.id)+"-clip",An=Ln+"-xaxis",On=Ln+"-yaxis",Mn=Br(Ln),_n=Br(_n),Dn=Br(Dn);var Pn=ot==="timeseries",Hn=ot==="categorized",Bn=!Pn&&(S||Uu(x));var jn=null,Fn=false,In=false,qn=false;var Rn=Bu(P,Y);var Un=ju(Y,et);var zn=function(){var e=[[o.time.format("%Y/%-m/%-d"),function(){return true}],[o.time.format("%-m/%-d"),function(e){return e.getMonth()}],[o.time.format("%-m/%-d"),function(e){return e.getDate()!==1}],[o.time.format("%-m/%-d"),function(e){return e.getDay()&&e.getDate()!==1}],[o.time.format("%I %p"),function(e){return e.getHours()}],[o.time.format("%I:%M"),function(e){return e.getMinutes()}],[o.time.format(":%S"),function(e){return e.getSeconds()}],[o.time.format(".%L"),function(e){return e.getMilliseconds()}]];return function(t){var n=e.length-1,r=e[n];while(!r[1](t)){r=e[--n]}return r[0](t)}}();var Wn=[];var Xn,Vn,$n,Jn,Kn,Qn,Gn,Yn,Zn,er,tr;var nr,rr,ir,sr,or,ur,ar;var fr,lr,cr,hr,pr,dr,vr,mr;var gr,yr,br,wr,Er,Sr,xr,Tr,Nr,Cr;var kr=st?"left":"bottom",Lr=st?xt?"top":"bottom":xt?"right":"left",Ar=st?_t?"bottom":"top":_t?"left":"right",Or=st?"left":"bottom";var Mr={main:function(){return"translate("+Xn.left+","+Xn.top+")"},context:function(){return"translate("+Vn.left+","+Vn.top+")"},legend:function(){return"translate("+$n.left+","+$n.top+")"},x:function(){return"translate(0,"+(st?0:Qn)+")"},y:function(){return"translate(0,"+(st?Qn:0)+")"},y2:function(){return"translate("+(st?0:Jn)+","+(st?1:0)+")"},subx:function(){return"translate(0,"+(st?0:Gn)+")"},arc:function(){return"translate("+Jn/2+","+Qn/2+")"}};var _r=nt==="right";var Dr=0,Pr=0,Hr=0;var Rr=30,Ur=30,zr=5;ar=o.layout.pie().value(function(e){return e.values.reduce(function(e,t){return e+t.value},0)});var sa=function(){var e=o.svg.line().x(st?function(e){return xi(e.id)(e.value)}:Fo).y(st?Fo:function(e){return xi(e.id)(e.value)});return function(t){var n=Yu(t.values),r,i;if(xu(t)){Nu(t)?e.interpolate("cardinal"):e.interpolate("linear");return D[t.id]?ya(n,gr,xi(t.id),D[t.id]):e(n)}else if(Tu(t)){e.interpolate("step-after");return D[t.id]?ya(n,gr,xi(t.id),D[t.id]):e(n)}else{r=gr(n[0].x);i=xi(t.id)(n[0].value);return st?"M "+i+" "+r:"M "+r+" "+i}}}();var oa=function(){var e;if(st){e=o.svg.area().x0(function(e){return xi(e.id)(0)}).x1(function(e){return xi(e.id)(e.value)}).y(Fo)}else{e=o.svg.area().x(Fo).y0(function(e){return xi(e.id)(0)}).y1(function(e){return xi(e.id)(e.value)})}return function(t){var n=Yu(t.values),r,i;if(mu([t],"area")||mu([t],"area-spline")){Nu(t)?e.interpolate("cardinal"):e.interpolate("linear");return e(n)}else if(mu([t],"area-step")){Tu(t)?e.interpolate("step-after"):e.interpolate("linear");return e(n)}else{r=gr(n[0].x);i=xi(t.id)(n[0].value);return st?"M "+i+" "+r:"M "+r+" "+i}}}();var ma=function(){var e=o.svg.line().x(st?function(e){return Ti(e.id)(e.value)}:Ro).y(st?Ro:function(e){return Ti(e.id)(e.value)});return function(t){var n=Yu(t.values);if(xu(t)){return e(n)}else if(Tu(t)){e.interpolate("step-after");return e(n)}else{return"M "+wr(n[0].x)+" "+Ti(t.id)(n[0].value)}}}();var ga=function(){var e=o.svg.area().x(Fo).y0(function(e){return Ti(e.id)(Xn.bottom-G)}).y1(function(e){return Ti(e.id)(e.value)});return function(t){var n=Yu(t.values),r,i;if(mu([t],"area")||mu([t],"area-spline")){Nu(t)?e.interpolate("cardinal"):e.interpolate("linear");return e(n)}else if(mu([t],"area-step")){Tu(t)?e.interpolate("step-after"):e.interpolate("linear");return e(n)}else{r=wr(n[0].x);i=Ti(t.id)(n[0].value);return st?"M "+i+" "+r:"M "+r+" "+i}}}();var ba,wa=function(){};ba=o.svg.brush().on("brush",Ia);ba.update=function(){if(Ta){Ta.select("."+n.brush).call(this)}return this};ba.scale=function(e){return st?this.y(e):this.x(e)};if(m){wa=o.behavior.zoom().on("zoomstart",function(){wa.altDomain=o.event.sourceEvent.altKey?gr.orgDomain():null}).on("zoom",m?qa:null);wa.scale=function(e){return st?this.y(e):this.x(e)};wa.orgScaleExtent=function(){var e=g?g:[1,10];return[e[0],Math.max(Ks()/e[1],e[1])]};wa.updateScaleExtent=function(){var e=Ls(gr.orgDomain())/Ls(La),t=this.orgScaleExtent();this.scaleExtent([t[0]*e,t[1]*e]);return this}}var Ea,Sa,xa,Ta,Na,Ca,ka;var La;var Aa,Oa={};u.focus=function(e){function s(e){to(e).transition().duration(100).style("opacity",1)}var t=Ea.selectAll(Lo(e)),r=t.filter(Za),i=t.filter(ef);u.revert();u.defocus();s(r.classed(n.focused,true));s(i);if(Su(u.data.targets)){hs(e,true)}Ka(e)};u.defocus=function(e){function s(e){to(e).transition().duration(100).style("opacity",.3)}var t=Ea.selectAll(Lo(e)),r=t.filter(Za),i=t.filter(ef);u.revert();s(r.classed(n.focused,false));s(i);if(Su(u.data.targets)){ps(e)}Qa(e)};u.revert=function(e){function s(e){to(e).transition().duration(100).style("opacity",1)}var t=Ea.selectAll(Lo(e)),r=t.filter(Za),i=t.filter(ef);s(r.classed(n.focused,false));s(i);if(Su(u.data.targets)){ps(e)}Ga()};u.show=function(e){so(e);Ea.selectAll(Lo(e)).transition().style("opacity",1);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:false})};u.hide=function(e){io(e);Ea.selectAll(Lo(e)).transition().style("opacity",0);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:false})};u.toggle=function(e){eo(e)?u.hide(e):u.show(e)};u.unzoom=function(){ba.clear().update();Fa({withUpdateXDomain:true})};u.load=function(e){if(e.xs){Fs(e.xs)}if("categories"in e&&Hn){ut=e.categories;xr.categories(ut)}if("cacheIds"in e&&As(e.cacheIds)){Xa(Ms(e.cacheIds),e.done);return}if("unload"in e){$a(typeof e.unload==="string"?[e.unload]:typeof e.unload==="boolean"&&e.unload?Gs():e.unload,function(){Va(e)})}else{Va(e)}};u.unload=function(e){$a(e?typeof e==="string"?[e]:e:Gs(),function(){Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:true})})};u.selected=function(e){return o.merge(xa.selectAll("."+n.shapes+ko(e)).selectAll("."+n.shape).filter(function(){return o.select(this).classed(n.SELECTED)}).map(function(e){return e.map(function(e){return e.__data__})}))};u.select=function(e,t,r){if(!H){return}xa.selectAll("."+n.shapes).selectAll("."+n.shape).each(function(i,u){var a=o.select(this),f=this.nodeName==="circle"?Vu:Ku,l=this.nodeName==="circle"?$u:Qu,c=B||!e||e.indexOf(i.id)>=0,h=!t||t.indexOf(u)>=0,p=a.classed(n.SELECTED);if(c&&h){if(j(i)&&!p){f(a.classed(n.SELECTED,true),i,u)}}else if(s(r)&&r){if(p){l(a.classed(n.SELECTED,false),i,u)}}})};u.unselect=function(e,t){if(!H){return}xa.selectAll("."+n.shapes).selectAll("."+n.shape).each(function(r,i){var s=o.select(this),u=this.nodeName==="circle"?$u:Qu,a=B||!e||e.indexOf(r.id)>=0,f=!t||t.indexOf(i)>=0,l=s.classed(n.SELECTED);if(a&&f){if(j(r)){if(l){u(s.classed(n.SELECTED,false),r,i)}}}})};u.toLine=function(e){vu(e,"line");za()};u.toSpline=function(e){vu(e,"spline");za()};u.toBar=function(e){vu(e,"bar");za()};u.toScatter=function(e){vu(e,"scatter");za()};u.toArea=function(e){vu(e,"area");za()};u.toAreaSpline=function(e){vu(e,"area-spline");za()};u.toPie=function(e){vu(e,"pie");za({withTransform:true})};u.toDonut=function(e){vu(e,"donut");za({withTransform:true})};u.groups=function(e){if(i(e)){return k}k=e;Fa();return k};u.xgrids=function(e){if(!e){return It}It=e;Fa();return It};u.xgrids.add=function(e){if(!e){return}return u.xgrids(It.concat(e))};u.xgrids.remove=function(e){var t=tf(e);return u.xgrids(It.filter(t))};u.ygrids=function(e){if(!e){return Rt}Rt=e;Fa();return Rt};u.ygrids.add=function(e){if(!e){return}return u.ygrids(Rt.concat(e))};u.ygrids.remove=function(e){var t=tf(e);return u.ygrids(Rt.filter(t))};u.regions=function(e){if(i(e)){return wn}wn=e;Fa();return wn};u.regions.add=function(e){if(i(e)){return wn}wn=wn.concat(e);Fa();return wn};u.regions.remove=function(e,t){var n=[].concat(e);t=s(t)?t:{};n.forEach(function(e){var n=r(t.duration)?t.duration:0;Ea.selectAll("."+e).transition().duration(n).style("fill-opacity",0).remove();wn=wn.filter(function(t){return t.classes.indexOf(e)<0})});return wn};u.data.get=function(e){var t=u.data.getAsTarget(e);return s(t)?t.values.map(function(e){return e.value}):undefined};u.data.getAsTarget=function(e){var t=Zs(function(t){return t.id===e});return t.length>0?t[0]:undefined};u.data.names=function(e){if(!arguments.length){return C}Object.keys(e).forEach(function(t){C[t]=e[t]});Ya(u.data.targets,{withTransition:true});return C};u.x=function(e){if(arguments.length){qs(u.data.targets,e);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true})}return u.data.x};u.xs=function(e){if(arguments.length){Rs(u.data.targets,e);Fa({withUpdateOrgXDomain:true,withUpdateXDomain:true})}return u.data.x};u.axis.labels=function(e){if(arguments.length){Object.keys(e).forEach(function(t){Mi(t,e[t])});ns()}};u.axis.max=function(e){if(arguments.length){if(typeof e==="object"){if(r(e.y)){bt=+e.y}if(r(e.y2)){Lt=+e.y2}}else{bt=Lt=+e}Fa()}};u.axis.min=function(e){if(arguments.length){if(typeof e==="object"){if(r(e.y)){wt=+e.y}if(r(e.y2)){At=+e.y2}}else{wt=At=+e}Fa()}};u.axis.range=function(e){if(arguments.length){if(typeof e.max!=="undefined"){u.axis.max(e.max)}if(typeof e.min!=="undefined"){u.axis.min(e.min)}}};u.resize=function(e){h=e?e.width:null;p=e?e.height:null;za({withLegend:true,withTransition:false})};u.destroy=function(){u.data.targets=undefined;u.data.x={};ka.html("");e.onresize=null};if("url"in t.data){o.csv(t.data.url,function(e,t){Ma(t)})}else if("rows"in t.data){Ma(zs(t.data.rows))}else if("columns"in t.data){Ma(Ws(t.data.columns))}else{throw Error("url or rows or columns is required.")}return u};if(typeof e.define==="function"&&e.define.amd){e.define("c3",["d3"],t)}else{e.c3=t}})(window)