mirror of https://github.com/masayuki0812/c3.git
Quite good looking graph derived from d3.js
http://c3js.org
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
68 KiB
1 lines
68 KiB
(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",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;i<e.length;i++){if(typeof r==="object"&&!(e[i]in r)){return n}s=i===e.length-1;o=r[e[i]];if(!s&&typeof o!=="object"||s&&typeof n!=="object"&&typeof o==="object"&&o!==null){return n}r=o}return r}function br(e){return"url("+document.URL.split("#")[0]+"#"+e+")"}function wr(){na.attr("transform",dr.main);na.select("."+n.axisX).attr("transform",dr.x);na.select("."+n.axisY).attr("transform",dr.y);na.select("."+n.axisY2).attr("transform",dr.y2);na.select("."+n.chartArcs).attr("transform",dr.arc)}function Er(){if(V){ra.attr("transform",dr.context);ra.select("."+n.axisX).attr("transform",dr.subx)}}function Sr(e){var t=e!==false?250:0;if(Q){ia.transition().duration(t).attr("transform",dr.legend)}}function xr(e){wr(e);Er(e);Sr(e)}function kr(){Hn=Or();Bn=Mr();jn=ti();Fn=ei();Ln={top:et?Hr("y2"):Cr,right:Dr(),bottom:Hr(et?"y":"x")+(et?0:$)+(vr?0:jn),left:(et?$+Nr:0)+_r()};Mn=Hn-Ln.left-Ln.right;Dn=Bn-Ln.top-Ln.bottom;if(Mn<0){Mn=0}if(Dn<0){Dn=0}An={top:et?Ln.top:Bn-$-(vr?0:jn),right:NaN,bottom:20+(vr?0:jn),left:et?Tr:Ln.left};_n=et?Ln.left-Tr-Nr:Mn;Pn=et?Dn:Bn-An.top-An.bottom;if(_n<0){_n=0}if(Pn<0){Pn=0}On={top:vr?0:Bn-jn,right:NaN,bottom:0,left:vr?Hn-Fn:0};Lr();if(vr&&iu(u.data.targets)){On.left=Mn/2+qn}}function Lr(){qn=Dn/2;In=qn*.95;Rn=ru(u.data.targets)?In*.6:0}function Ar(){var e=et?n.axisX:n.axisY,t=o.select("."+e).node(),r=t?t.getBoundingClientRect():{right:0},i=o.select(c).node().getBoundingClientRect(),s=r.right-i.left-_r();return s>0?s:0}function Or(){return h?h:Br()}function Mr(){var e=p?p:jr();return e>0?e:320}function _r(){if(iu(u.data.targets)){return 0}else if(d){return d}else{return et||!pt||yt?1:Pr("y")}}function Dr(){var e=1;if(iu(u.data.targets)){return 0}else if(v){return v}else if(vr){return Fn+(St&&!et?Pr("y2"):e)}else if(St){return kt||et?e:Pr("y2")}else{return e}}function Pr(e){var t=bi(e);return t.isInner?20+Fi(e):40+Fi(e)}function Hr(e){if(e==="y"&&!pt){return Q&&!vr?10:1}if(e==="y2"&&!St){return Cr}return(bi(e).isInner?30:40)+(e==="y2"?-10:0)}function Br(){return+o.select(c).style("width").replace("px","")}function jr(){return+o.select(c).style("height").replace("px","")}function Fr(e){return e?-(1+4):-(Ln.left-1)}function Ir(e){return e?-20:-1}function qr(){return Fr(!et)}function Rr(){return Ir(!et)}function Ur(){return Fr(et)}function zr(){return Ir(et)}function Wr(e){return e?Mn+2+4:Ln.left+20}function Xr(e){return e?80:Dn+2}function Vr(){return Wr(!et)}function $r(){return Xr(!et)}function Jr(){return Wr(et)}function Kr(){return Xr(et)}function Qr(){var e=et?Dn:Mn,t=_s(),n=os()*(eu(u.data.targets)?(t-(bn?.25:1))/t:.98);return t>1?e*n/(t-1):e}function Gr(e){mr=e}function Yr(e){gr=e}function Zr(e){yr=e}function ei(){return Q?vr?gr*(mr+1):Hn:0}function ti(){return Q?vr?Bn:yr*(mr+1):0}function ni(){var e,t=!er;Vn=et?1:0;$n=et?Dn:Mn;Jn=et?0:Dn;Kn=et?Mn:1;Qn=Vn;Gn=$n;Yn=et?0:Pn;Zn=et?_n:1;er=ii(Vn,$n,t?undefined:er.domain(),function(){return or.tickOffset()});tr=si(Jn,Kn);nr=si(Jn,Kn);rr=ii(Vn,$n,ua,function(e){return e%1?0:fr.tickOffset()});ir=si(Yn,Zn);sr=si(Yn,Zn);e=ci();or=ai(er,lr,e);fr=ai(rr,pr,e);ur=fi(tr,cr,bt,Et);ar=fi(nr,hr,Lt,Ot);if(!t){Yu.scale(rr);if(m){Zu.scale(er)}}ri()}function ri(){Un=Ui();zn=zi();Wn=zi(.98)}function ii(e,t,n,r){var u=(yn?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(bn){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 oi(e){return li(e)==="y2"?nr:tr}function ui(e){return li(e)==="y2"?sr:ir}function ai(e,t,n){var r=(bn?qi():o.svg.axis()).scale(e).orient(t);r.tickFormat(n);if(bn){r.tickCentered(rt)}else{r.tickOffset=function(){var e=et?Dn:Mn;return e*os()/_s()/2}}if(bn){r.categories(nt)}return r}function fi(e,t,n,r){return o.svg.axis().scale(e).orient(t).tickFormat(n).ticks(r).outerTickSize(0)}function li(e){return e in L?L[e]:"y"}function ci(){var e=yn?Cn:bn?$s:function(e){return e<0?e.toFixed(0):e};if(it){if(typeof it==="function"){e=it}else if(yn){e=function(e){return o.time.format(it)(e)}}}return e}function hi(e){var t;if(e==="y"){t=gt}else if(e==="y2"){t=Ct}else if(e==="x"){t=ht}return t}function pi(e){var t=hi(e);return typeof t==="string"?t:t?t.text:null}function di(e,t){var n=hi(e);if(typeof n==="string"){if(e==="y"){gt=t}else if(e==="y2"){Ct=t}else if(e==="x"){ht=t}}else if(n){n.text=t}}function vi(e,t){var n=hi(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 mi(){return vi("x",et?"inner-top":"inner-right")}function gi(){return vi("y",et?"inner-right":"inner-top")}function yi(){return vi("y2",et?"inner-right":"inner-top")}function bi(e){return e==="y2"?yi():e==="y"?gi():mi()}function wi(){return pi("x")}function Ei(){return pi("y")}function Si(){return pi("y2")}function xi(e,t){if(e){return t.isLeft?0:t.isCenter?Mn/2:Mn}else{return t.isBottom?-Dn:t.isMiddle?-Dn/2:0}}function Ti(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 Ni(e,t){if(e){return t.isLeft?"start":t.isCenter?"middle":"end"}else{return t.isBottom?"start":t.isMiddle?"middle":"end"}}function Ci(){return xi(!et,mi())}function ki(){return xi(et,gi())}function Li(){return xi(et,yi())}function Ai(){return Ti(!et,mi())}function Oi(){return Ti(et,gi())}function Mi(){return Ti(et,yi())}function _i(){var e=mi();if(et){return e.isInner?"1.2em":-30-Fi("x")}else{return e.isInner?"-0.5em":"3em"}}function Di(){var e=gi();if(et){return e.isInner?"-0.5em":"3em"}else{return e.isInner?"1.2em":-20-Fi("y")}}function Pi(){var e=yi();if(et){return e.isInner?"1.2em":"-2.2em"}else{return e.isInner?"-0.5em":30+Fi("y2")}}function Hi(){return Ni(!et,mi())}function Bi(){return Ni(et,gi())}function ji(){return Ni(et,yi())}function Fi(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(t<e.width){t=e.width}});return t<20?20:t}function Ii(){na.select("."+n.axisX+" ."+n.axisXLabel).attr("x",Ci).text(wi);na.select("."+n.axisY+" ."+n.axisYLabel).attr("x",ki).attr("dy",Di).text(Ei);na.select("."+n.axisY2+" ."+n.axisY2Label).attr("x",Li).attr("dy",Pi).text(Si)}function qi(){function h(e,t){e.attr("transform",function(e){return"translate("+(t(e)+a)+", 0)"})}function p(e,t){e.attr("transform",function(e){return"translate(0,"+t(e)+")"})}function d(e){var t=e[0],n=e[e.length-1];return t<n?[t,n]:[n,t]}function v(e){var t=[];for(var n=Math.ceil(e[0]);n<e[1];n++){t.push(n)}if(t.length>0&&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 e<c.length?c[e]:e}function y(e){var t=g(e);return f?f(t):t}function b(u){u.each(function(){var u=o.select(this);var f=v(e.domain());var l=u.selectAll(".tick.major").data(f,String),c=l.enter().insert("g","path").attr("class","tick major").style("opacity",1e-6),g=o.transition(l.exit()).style("opacity",1e-6).remove(),b=o.transition(l).style("opacity",1),w,E;var S=e.rangeExtent?e.rangeExtent():d(e.range()),x=u.selectAll(".domain").data([0]);x.enter().append("path").attr("class","domain");var T=o.transition(x);var N=e.copy(),C=this.__chart__||N;this.__chart__=N;c.append("line");c.append("text");var k=c.select("line"),L=b.select("line"),A=l.select("text"),O=c.select("text"),M=b.select("text");a=(N(1)-N(0))/2;E=s?0:a;switch(t){case"bottom":{w=h;k.attr("y2",n);O.attr("y",Math.max(n,0)+i);L.attr("x1",E).attr("x2",E).attr("y2",n);M.attr("x",0).attr("y",Math.max(n,0)+i);A.attr("dy",".71em").style("text-anchor","middle");A.text(function(e){return m(f,e)?y(e):""});T.attr("d","M"+S[0]+","+r+"V0H"+S[1]+"V"+r);break};case"left":{w=p;k.attr("x2",-n);O.attr("x",-(Math.max(n,0)+i));L.attr("x2",-n).attr("y2",0);M.attr("x",-(Math.max(n,0)+i)).attr("y",a);A.attr("dy",".32em").style("text-anchor","end");A.text(function(e){return m(f,e)?y(e):""});T.attr("d","M"+ -r+","+S[0]+"H0V"+S[1]+"H"+ -r);break}}if(e.ticks){c.call(w,C);b.call(w,N);g.call(w,N)}else{var _=N.rangeBand()/2,D=function(e){return N(e)+_};c.call(w,D);b.call(w,D)}})}var e=o.scale.linear(),t="bottom";var n=6,r=6,i=3,s=false,u=10,a=0,f=null,l=true;var c=[];b.scale=function(t){if(!arguments.length){return e}e=t;return b};b.orient=function(e){if(!arguments.length){return t}t=e in{top:1,right:1,bottom:1,left:1}?e+"":"bottom";return b};b.categories=function(e){if(!arguments.length){return c}c=e;return b};b.tickCentered=function(e){if(!arguments.length){return s}s=e;return b};b.tickFormat=function(e){if(!arguments.length){return f}f=e;return b};b.tickOffset=function(){return a};b.ticks=function(e){if(!arguments.length){return u}u=e;return b};b.tickCulling=function(e){if(!arguments.length){return l}l=e;return b};b.tickValues=function(){};return b}function Ri(e){var t=false;Xn(Fs(u.data.targets)).forEach(function(n){if(!t&&n.data.id===e.data.id){t=true;e=n;return}});return t?e:null}function Ui(){var e=o.svg.arc().outerRadius(In).innerRadius(Rn),t=function(t,n){var r;if(n){return e(t)}r=Ri(t);return r?e(r):"M 0 0"};t.centroid=e.centroid;return t}function zi(e){var t=o.svg.arc().outerRadius(qn*(e?e:1)).innerRadius(Rn);return function(e){var n=Ri(e);return n?t(n):"M 0 0"}}function Wi(e,t){return pu(e.data)?Un(e,t):"M 0 0"}function Xi(e){var t=Ri(e),n,r,i,s,o="";if(t){n=Un.centroid(t);r=n[0],i=n[1],s=Math.sqrt(r*r+i*i);o="translate("+r/s*In*.8+","+i/s*In*.8+")"}return o}function Vi(e){return e?(e.endAngle-e.startAngle)/(Math.PI*2):null}function $i(e){return Ss({id:e.data.id,value:e.value,ratio:Vi(e)})}function Ji(e){var t,n,r,i;if(!Gi()){return""}t=Ri(e);n=t?t.value:null;r=Vi(t);i=Yi();return i?i(n,r):bo(n,r)}function Ki(e,t){var r=ea.selectAll("."+n.chartArc+lo(e)),i=ea.selectAll("."+n.arc).filter(function(t){return t.data.id!==e});r.selectAll("path").transition().duration(50).attr("d",zn).transition().duration(100).attr("d",Wn).each(function(e){if(hu(e.data)){}});if(!t){i.style("opacity",.3)}}function Qi(e){var t=ea.selectAll("."+n.chartArc+lo(e));t.selectAll("path").transition().duration(50).attr("d",Un);ea.selectAll("."+n.arc).style("opacity",K?K:1)}function Gi(){return ru(u.data.targets)?Gt:Vt}function Yi(){return ru(u.data.targets)?Yt:$t}function Zi(){return ru(u.data.targets)?Zt:""}function es(){var e=ru(u.data.targets)?en:Jt;return typeof e==="function"?e:function(){}}function ts(){var e=ru(u.data.targets)?tn:Kt;return typeof e==="function"?e:function(){}}function ns(){var e=ru(u.data.targets)?nn:Qt;return typeof e==="function"?e:function(){}}function rs(e){var t=Ps(e),n=zs(e),r,i,s,u,a,f;if(k.length>0){f=Xs(e);for(r=0;r<k.length;r++){u=k[r].filter(function(e){return t.indexOf(e)>=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;i<u.length;i++){a=u[i];if(!n[a]){continue}n[a].forEach(function(e,t){if(li(a)===li(s)&&n[s]&&!(f&&+e>0)){n[s][t]+=+e}})}}}return o.min(Object.keys(n).map(function(e){return o.min(n[e])}))}function is(e){var t=Ps(e),n=zs(e),r,i,s,u,a,f;if(k.length>0){f=Vs(e);for(r=0;r<k.length;r++){u=k[r].filter(function(e){return t.indexOf(e)>=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;i<u.length;i++){a=u[i];if(!n[a]){continue}n[a].forEach(function(e,t){if(li(a)===li(s)&&n[s]&&!(f&&+e<0)){n[s][t]+=+e}})}}}return o.max(Object.keys(n).map(function(e){return o.max(n[e])}))}function ss(e,t){var n=e.filter(function(e){return li(e.id)===t}),i=t==="y2"?Tt:vt,s=t==="y2"?xt:dt,o=r(i)?i:rs(n),u=r(s)?s:is(n),a,f,l,c,h=t==="y2"?Nt:mt,p,d,v,m,g=mo()&&et;if(n.length===0){return t==="y2"?nr.domain():tr.domain()}if(o===u){o<0?u=0:o=0}a=Math.abs(u-o);f=l=c=g?0:a*.1;if(h){p=Math.max(Math.abs(o),Math.abs(u));u=p-h;o=h-p}if(t==="y"&&wt){l=r(wt.top)?wt.top:f;c=r(wt.bottom)?wt.bottom:f}if(t==="y2"&&At){l=r(At.top)?At.top:f;c=r(At.bottom)?At.bottom:f}if(g){d=go(o,u);v=cs(tr.range());m=[d[0]/v,d[1]/v];l+=a*(m[1]/(1-m[0]-m[1]));c+=a*(m[0]/(1-m[0]-m[1]))}if(eu(n)&&!Xs(n)){c=o}if(Mt){c=o}return[o-c,u+l]}function os(e){var t=cs(ua),n=cs(er.domain());return e||n===0?1:t/n}function us(e){return lt?lt:o.min(e,function(e){return o.min(e.values,function(e){return e.x})})}function as(e){return ft?ft:o.max(e,function(e){return o.max(e.values,function(e){return e.x})})}function fs(e,t){var n=t[0],r=t[1],i=Math.abs(n-r),s,o;if(bn){o=0}else if(eu(e)){s=_s();o=s>1?i/(s-1)/2:.5}else if(Mt){o=i*.001}else{o=i*.01}return o}function ls(e){var t=[us(e),as(e)],n=t[0],r=t[1],i=fs(e,t),s=yn?new Date(n.getTime()-i):n-i,o=yn?new Date(r.getTime()+i):r+i;return[s,o]}function cs(e){return e[1]-e[0]}function hs(e){for(var t=0;t<e.length;t++){if(!(e[t]in a)){return false}}return true}function ps(e,t){a[e]=As(t)}function ds(e){var t=[];for(var n=0;n<e.length;n++){if(e[n]in a){t.push(As(a[e[n]]))}}return t}function vs(e){return"start"in e?er(yn?yu(e.start):e.start):0}function ms(e){var t=vs(e),n="end"in e?er(yn?yu(e.end):e.end):Mn,r=n-t;return r<0?0:r}function gs(e){return S&&e===S||Su(x)&&xu(x,e)}function ys(e){return!gs(e)}function bs(e){return S?S:Su(x)?x[e]:null}function ws(e,t){return e in u.data.x&&u.data.x[e]&&u.data.x[e][t]?u.data.x[e][t]:t}function Es(e){Object.keys(e).forEach(function(t){x[t]=e[t]})}function Ss(e){var t;if(e){t=C[e.id];e.name=t?t:e.id}return e}function xs(e,t){e.forEach(function(e){e.values.forEach(function(n,r){n.x=Ns(t[r],e.id,r)});u.data.x[e.id]=t})}function Ts(e,t){e.forEach(function(e){if(t[e.id]){xs([e],t[e.id])}})}function Ns(e,t,n){var r;if(yn){r=e?e instanceof Date?e:yu(e):yu(ws(t,n))}else if(wn&&!bn){r=e?+e:ws(t,n)}else{r=n}return r}function Cs(e){var t=e[0],n={},r=[],i,s;for(i=1;i<e.length;i++){n={};for(s=0;s<e[i].length;s++){n[t[s]]=e[i][s]}r.push(n)}return r}function ks(e){var t=[],n,r,s;for(n=0;n<e.length;n++){s=e[n][0];for(r=1;r<e[n].length;r++){if(i(t[r-1])){t[r-1]={}}t[r-1][s]=e[n][r]}}return t}function Ls(e){var t=o.keys(e[0]).filter(ys),n=o.keys(e[0]).filter(gs),r;t.forEach(function(t){var r=bs(t);if(wn||yn){if(n.indexOf(r)>=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=Ns(o,t,i);if(wn&&bn&&n===0&&o){if(i===0){nt=[]}nt.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){Yo(Ps(r).filter(function(e){return!(e in O)}),A)}r.forEach(function(e){ps(e.id_org,e)});return r}function As(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 Os(e){return e>0&&u.data.targets[0].values[e-1]?u.data.targets[0].values[e-1].x:undefined}function Ms(e){return e<_s()-1?u.data.targets[0].values[e+1].x:undefined}function _s(){return o.max(u.data.targets,function(e){return e.values.length})}function Ds(){var e=u.data.targets.length,t=0,n;if(e>1){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 Ps(e){e=i(e)?u.data.targets:e;return e.map(function(e){return e.id})}function Hs(e){var t=Ps(),n;for(n=0;n<t.length;n++){if(t[n]===e){return true}}return false}function Bs(e){return s(e)?u.data.targets.filter(e):u.data.targets}function js(e){return kn.indexOf(e)<0}function Fs(e){return e.filter(function(e){return js(e.id)})}function Is(e){var t=o.set(o.merge(e.map(function(e){return e.values.map(function(e){return e.x})}))).values();return yn?t.map(function(e){return new Date(e)}):t.map(function(e){return+e})}function qs(e){var t=e,n,r,i,s,o,u,a;if(!at&&ut){n=typeof ut==="function"?ut():ut;if(n===1){t=[e[0]]}else if(n===2){t=[e[0],e[e.length-1]]}else if(n>2){s=n-2;r=e[0];i=e[e.length-1];o=(i-r)/(s+1);t=[r];for(u=0;u<s;u++){a=+r+o*(u+1);t.push(yn?new Date(a):a)}t.push(i)}}return t}function Rs(e){kn=kn.concat(e)}function Us(e){kn=kn.filter(function(t){return e.indexOf(t)<0})}function zs(e){var t={};e.forEach(function(e){t[e.id]=[];e.values.forEach(function(n){t[e.id].push(n.value)})});return t}function Ws(e,t){var n=Object.keys(e),r,i,s;for(r=0;r<n.length;r++){s=e[n[r]].values;for(i=0;i<s.length;i++){if(t(s[i].value)){return true}}}return false}function Xs(e){return Ws(e,function(e){return e<0})}function Vs(e){return Ws(e,function(e){return e>0})}function $s(e){return e<nt.length?nt[e]:e}function Js(e,t){return" "+e+" "+e+fo(t)}function Ks(e){return Js(n.text,e.id)}function Qs(e){return Js(n.texts,e.id)}function Gs(e,t){return Js(n.shape,t)}function Ys(e){return Js(n.shapes,e.id)}function Zs(e){return Ys(e)+Js(n.line,e.id)}function eo(e,t){return Gs(e,t)+Js(n.circle,t)}function to(e){return Ys(e)+Js(n.circles,e.id)}function no(e,t){return Gs(e,t)+Js(n.bar,t)}function ro(e){return Ys(e)+Js(n.bars,e.id)}function io(e){return Ys(e.data)+Js(n.arc,e.data.id)}function so(e){return Ys(e)+Js(n.area,e.id)}function oo(e,t){return Js(n.region,t)+" "+("class"in e?e.class:"")}function uo(e,t){return Js(n.eventRect,t)}function ao(e){return Ys(e)+Js(n.step,e.id)}function fo(e){return e||e===0?"-"+(e.replace?e.replace(/([^a-zA-Z0-9-_])/g,"-"):e):""}function lo(e){return"."+n.target+fo(e)}function co(e){return e.value!==null&&fa[e.id]?1:0}function ho(e){var t=vo(e);return co(e)*t}function po(e){return r(e.value)?lu(e)?.5:1:0}function vo(){return mo()?1:0}function mo(){if(typeof M==="boolean"&&M){return true}else if(typeof M==="object"&&Su(M)){return true}return false}function go(e,t){var n=[],r=1.3;o.select("svg").selectAll(".dummy").data([e,t]).enter().append("text").text(function(e){return e}).each(function(e,t){var i=this.getBBox();n[t]=i.width*r}).remove();return n}function yo(e){var t=bt?bt:function(e){return r(e)?+e:""};return t(e)}function bo(e,t){return(t*100).toFixed(1)+"%"}function wo(e){var t=function(e){return r(e)?+e:""},n=li(e),i=t;if(typeof M.format==="function"){i=M.format}else if(typeof M.format==="object"){if(typeof M.format[n]==="function"){i=M.format[n]}}return i}function Eo(e){return e?er(e.x):null}function So(e){return er(yn?yu(e.value):e.value)}function xo(e){return tr(e.value)}function To(e){return rr(e.x)}function No(e,t){var n,r=e[t].x,i=[];for(n=t-1;n>=0;n--){if(r!==e[n].x){break}i.push(e[n])}for(n=t;n<e.length;n++){if(r!==e[n].x){break}i.push(e[n])}return i}function Co(e,t,n,r){var i=n?n:0,s=r?r:e.length-1,o=Math.floor((s-i)/2)+i,u=e[o],a=er(u.x)-t[0],f;a>0?s=o:i=o;if(s-i===1||i===0&&s===0){f=[];if(e[i].x){f=f.concat(No(e,i))}if(e[s].x){f=f.concat(No(e,s))}return Lo(f,t)}return Co(e,t,i,s)}function ko(e,t){var n;n=e.map(function(e){return Co(e.values,t)});return Lo(n,t)}function Lo(e,t){var n,r;e.forEach(function(e){var i=Tu(e,t);if(i<n||!n){n=i;r=e}});return r}function Ao(e){var t=e.getBoundingClientRect(),n=[e.pathSegList.getItem(0),e.pathSegList.getItem(1)],r=n[0].x,i=Math.min(n[0].y,n[1].y);return{x:r,y:i,width:t.width,height:t.height}}function Oo(){return _&&_.toLowerCase()==="desc"}function Mo(){return _&&_.toLowerCase()==="asc"}function _o(e){var t=Mo(),n=Oo();if(t||n){e.sort(function(e,n){var r=function(e,t){return e+Math.abs(t.value)};var i=e.values.reduce(r,0),s=n.values.reduce(r,0);return t?s-i:i-s})}else if(typeof _==="function"){e.sort(_)}return e}function Do(e,t){var n,i;var s,o,a,f,l;var c=iu(u.data.targets);var h=c?bo:yo;var p=e.filter(function(e){return e&&r(e.value)});if(!sn){return}if(p.length===0){return}sa.html(an(e,ci(),h,Nn)).style("display","block");n=sa.property("offsetWidth");i=sa.property("offsetHeight");if(c){o=Mn/2+t[0];f=Dn/2+t[1]+20}else{if(et){s=Ar();o=s+t[0]+100;a=o+n;l=Or()-Dr();f=er(p[0].x)+20}else{s=Ar();o=s+_r()+er(p[0].x)+20;a=o+n;l=s+Or()-Dr();f=t[1]+15}if(a>l){o-=n+60}if(f+i>Mr()){f-=i+30}}sa.style("top",f+"px").style("left",o+"px")}function Po(){sa.style("display","none")}function Ho(e){var t=e.filter(function(e){return e&&r(e.value)});if(!sn){return}if(tu(u.data.targets)||iu(u.data.targets)){return}na.selectAll("line."+n.xgridFocus).style("visibility","visible").data([t[0]]).attr(et?"y1":"x1",Eo).attr(et?"y2":"x2",Eo)}function Bo(){na.select("line."+n.xgridFocus).style("visibility","hidden")}function jo(e){return e.x||e.x===0?er(e.x):null}function Fo(e,t){var n=Jo(),r=Ku(n);if(k.length>0){var i=r(e,t);return i[0][1]}return oi(e.id)(e.value)}function Io(){var e={},t=0,n,r;Fs(Bs(fu)).forEach(function(s){for(n=0;n<k.length;n++){if(k[n].indexOf(s.id)<0){continue}for(r=0;r<k[n].length;r++){if(k[n][r]in e){e[s.id]=e[k[n][r]];break}}}if(i(e[s.id])){e[s.id]=t++}});e.__max__=t-1;return e}function qo(e,t,n,r){var i=r?rr:er;return function(r){var s=r.id in n?n[r.id]:0;return r.x||r.x===0?i(r.x)-e*(t/2-s):0}}function Ro(e){return function(t){var n=e?ui(t.id):oi(t.id);return n(t.value)}}function Uo(e,t){var n=_o(Fs(Bs(fu))),r=n.map(function(e){return e.id});return function(i,s){var o=t?ui(i.id):oi(i.id),u=o(0),a=u;n.forEach(function(t){if(t.id===i.id||e[t.id]!==e[i.id]){return}if(r.indexOf(t.id)<r.indexOf(i.id)&&t.values[s].value*i.value>0){a+=o(t.values[s].value)-u}});return a}}function zo(e,t){return Wt?Wt:t?e.tickOffset()*2*Xt/t:0}function Wo(){var e={},t=0,n,r;Fs(Bs(au)).forEach(function(s){for(n=0;n<k.length;n++){if(k[n].indexOf(s.id)<0){continue}for(r=0;r<k[n].length;r++){if(k[n][r]in e){e[s.id]=e[k[n][r]];break}}}if(i(e[s.id])){e[s.id]=t++}});e.__max__=t-1;return e}function Xo(e,t,n){var r=n?rr:er;return function(n){var i=n.id in t?t[n.id]:0;return n.x||n.x===0?r(n.x)-0*(e/2-i):0}}function Vo(e){return function(t){var n=e?ui(t.id):oi(t.id);return n(t.value)}}function $o(e,t){var n=_o(Fs(Bs(au))),r=n.map(function(e){return e.id});return function(i,s){var o=t?ui(i.id):oi(i.id),u=o(0),a=u;n.forEach(function(t){if(t.id===i.id||e[t.id]!==e[i.id]){return}if(r.indexOf(t.id)<r.indexOf(i.id)&&t.values[s].value>0){a+=o(t.values[s].value)-u}});return a}}function Jo(){var e={},t=0,n,r;Fs(Bs(su)).forEach(function(s){for(n=0;n<k.length;n++){if(k[n].indexOf(s.id)<0){continue}for(r=0;r<k[n].length;r++){if(k[n][r]in e){e[s.id]=e[k[n][r]];break}}}if(i(e[s.id])){e[s.id]=t++}});e.__max__=t-1;return e}function Ko(e,t,n){var r=n?rr:er;return function(n){var i=n.id in t?t[n.id]:0;return n.x||n.x===0?r(n.x)-0*(e/2-i):0}}function Qo(e){return function(t){var n=e?ui(t.id):oi(t.id);return n(t.value)}}function Go(e,t){var n=_o(Fs(Bs(su))),r=n.map(function(e){return e.id});return function(i,s){var o=t?ui(i.id):oi(i.id),u=o(0),a=u;n.forEach(function(t){if(t.id===i.id||e[t.id]!==e[i.id]){return}if(r.indexOf(t.id)<r.indexOf(i.id)&&t.values[s].value>0){a+=o(t.values[s].value)-u}});return a}}function Yo(e,t){var n=i(e)?Ps():e;if(typeof n==="string"){n=[n]}for(var r=0;r<n.length;r++){fa[n[r]]=t===O[n[r]];O[n[r]]=t}}function Zo(e,t){var n=false;e.forEach(function(e){if(O[e.id]===t){n=true}if(!(e.id in O)&&t==="line"){n=true}});return n}function eu(e){return Zo(e,"bar")}function tu(e){return Zo(e,"scatter")}function nu(e){return Zo(e,"pie")}function ru(e){return Zo(e,"donut")}function iu(e){return nu(e)||ru(e)}function su(e){var t=typeof e==="string"?e:e.id;return!(t in O)||O[t]==="line"||O[t]==="spline"||O[t]==="area"||O[t]==="area-spline"}function ou(e){var t=typeof e==="string"?e:e.id;return!(t in O)||O[t]==="step"||O[t]==="area-step"}function uu(e){var t=typeof e==="string"?e:e.id;return O[t]==="spline"||O[t]==="area-spline"}function au(e){var t=typeof e==="string"?e:e.id;return O[t]==="area"}function fu(e){var t=typeof e==="string"?e:e.id;return O[t]==="bar"}function lu(e){var t=typeof e==="string"?e:e.id;return O[t]==="scatter"}function cu(e){var t=typeof e==="string"?e:e.id;return O[t]==="pie"}function hu(e){var t=typeof e==="string"?e:e.id;return O[t]==="donut"}function pu(e){return cu(e)||hu(e)}function du(e){return fu(e)?e.values:[]}function vu(e){return su(e)||lu(e)?e.values:[]}function mu(e){return fu(e)||su(e)?e.values:[]}function gu(e,t){var n=[],r=e,i=Su(t)?t:["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"];return function(t){if(t in r){return e[t]}if(n.indexOf(t)===-1){n.push(t)}return i[n.indexOf(t)%i.length]}}function yu(t){var n;if(!t){throw Error(t+" can not be parsed as d3.time with format "+T+". Maybe 'x' of this data is not defined. See data.x or data.xs option.")}try{n=T?o.time.format(T).parse(t):new Date(t)}catch(r){n=undefined}if(!n){e.console.error("Failed to parse x '"+t+"' to Date with format "+T)}return n}function bu(e,t){var n=o.mouse(e),r=o.select(e);var i=r.attr("cx")*1,s=r.attr("cy")*1;return Math.sqrt(Math.pow(i-n[0],2)+Math.pow(s-n[1],2))<t}function wu(e){var t=o.mouse(e),n=e.getBBox();var r=n.x,i=n.y,s=n.width,u=n.height,a=2;var f=r-a,l=r+s+a,c=i+u+a,h=i-a;return f<t[0]&&t[0]<l&&h<t[1]&&t[1]<c}function Eu(e,t){var n;for(n=0;n<t.length;n++){if(t[n].start<e&&e<=t[n].end){return true}}return false}function Su(e){return Object.keys(e).length>0}function xu(e,t){var n=false;Object.keys(e).forEach(function(r){if(e[r]===t){n=true}});return n}function Tu(e,t){return Math.pow(er(e.x)-t[0],2)+Math.pow(tr(e.value)-t[1],2)}function Nu(e,t){var n=0;e.each(function(){++n}).each("end",function(){if(!--n){t.apply(this,arguments)}})}function Cu(e,t,r){U(t,e.node());na.select("."+n.selectedCircles+fo(t.id)).selectAll("."+n.selectedCircle+"-"+r).data([t]).enter().append("circle").attr("class",function(){return Js(n.selectedCircle,r)}).attr("cx",et?Fo:jo).attr("cy",et?jo:Fo).attr("stroke",function(){return Nn(t.id)}).attr("r",zt*1.4).transition().duration(100).attr("r",zt)}function ku(e,t,r){z(t,e.node());na.select("."+n.selectedCircles+fo(t.id)).selectAll("."+n.selectedCircle+"-"+r).transition().duration(100).attr("r",0).remove()}function Lu(e,t,n,r){e?Cu(t,n,r):ku(t,n,r)}function Au(e,t){U(t,e.node());e.transition().duration(100).style("fill",function(){return o.rgb(Nn(t.id)).darker(1)})}function Ou(e,t){z(t,e.node());e.transition().duration(100).style("fill",function(){return Nn(t.id)})}function Mu(e,t,n,r){e?Au(t,n,r):Ou(t,n,r)}function _u(e){return e.filter(function(e){return r(e.value)})}function Du(e,t){return(t?na.selectAll("."+n.circles+fo(t)):na).selectAll("."+n.circle+(r(e)?"-"+e:""))}function Pu(e,t){Du(e,t).classed(n.EXPANDED,true).attr("r",Ut)}function Hu(e){Du(e).filter(function(){return o.select(this).classed(n.EXPANDED)}).classed(n.EXPANDED,false).attr("r",It)}function Bu(e){return na.selectAll("."+n.bar+(r(e)?"-"+e:""))}function ju(e){Bu(e).classed(n.EXPANDED,true)}function Fu(e){Bu(e).classed(n.EXPANDED,false)}function Ru(e,t){var n,r=$u(e,t);if(et){n=o.svg.area().x0(function(e,t){return oi(e.id)(0)}).x1(function(e,t){return oi(e.id)(e.value)}).y(Eo)}else{n=o.svg.area().x(Eo).y0(function(e,t){if(k.length>0){var n=r(e,t);return n[0][1]}return oi(e.id)(0)}).y1(function(e,t){if(k.length>0){var n=r(e,t);return n[1][1]}return oi(e.id)(e.value)})}return function(e,t){var r=_u(e.values),i,s;if(Zo([e],"area")||Zo([e],"area-spline")){uu(e)?n.interpolate("cardinal"):n.interpolate("linear");return n(r)}else if(Zo([e],"area-step")){ou(e)?n.interpolate("step-after"):n.interpolate("linear");return n(r)}else{i=er(r[0].x);s=oi(e.id)(r[0].value);return et?"M "+s+" "+i:"M "+i+" "+s}}}function Uu(e,t){var n=Ju(e,t);return function(e,t){var r=n(e,t);var i=et?1:0;var s=et?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 zu(e,t){var n=Ku(e,t),r=o.svg.line().x(et?function(e,t){if(k.length>0){var r=n(e,t);return r[0][1]}return oi(e.id)(e.value)}:Eo).y(et?Eo:function(e,t){if(k.length>0){var r=n(e,t);return r[0][1]}return oi(e.id)(e.value)});return function(e){var t=_u(e.values),n,i;if(su(e)){uu(e)?r.interpolate("cardinal"):r.interpolate("linear");return D[e.id]?Gu(t,er,oi(e.id),D[e.id]):r(t)}else if(ou(e)){r.interpolate("step-after");return D[e.id]?Gu(t,er,oi(e.id),D[e.id]):r(t)}else{n=er(t[0].x);i=oi(e.id)(t[0].value);return et?"M "+i+" "+n:"M "+n+" "+i}}}function Wu(e,t){var n=Ju(e,false),r=t?Xu:Vu;return function(e,t){return r(n(e,t),e,this)}}function Xu(e,t){var n;if(et){n=fu(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 Vu(e,t,n){var r=n.getBBox();if(et){return(e[0][0]+e[2][0]+r.height*.6)/2}else{return e[2][1]+(t.value<0?r.height:fu(t)?-3:-6)}}function $u(e,t){var n=e.__max__+1,r=Xo(n,e,!!t),i=Vo(!!t),s=$o(e,!!t),o=t?ui:oi;return function(e,t){var n=o(e.id)(0),u=s(e,t)||n,a=r(e),f=i(e);if(et){if(e.value>0&&f<u||e.value<0&&f>u){f=u}}return[[a,u],[a,f-(n-u)]]}}function Ju(e,t){var n=e.__max__+1,r=zo(or,n),i=qo(r,n,e,!!t),s=Ro(!!t),o=Uo(e,!!t),u=t?ui:oi;return function(e,t){var n=u(e.id)(0),a=o(e,t)||n,f=i(e),l=s(e);if(et){if(e.value>0&&l<a||e.value<0&&l>a){l=a}}return[[f,a],[f,l-(n-a)],[f+r,l-(n-a)],[f+r,a]]}}function Ku(e,t){var n=e.__max__+1,r=Ko(n,e,!!t),i=Qo(!!t),s=Go(e,!!t),o=t?ui:oi;return function(e,t){var n=o(e.id)(0),u=s(e,t)||n,a=r(e),f=i(e);if(et){if(e.value>0&&f<u||e.value<0&&f>u){f=u}}return[[a,f-(n-u)]]}}function Gu(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;u<r.length;u++){b[u]={};if(i(r[u].start)){b[u].start=e[0].x}else{b[u].start=yn?yu(r[u].start):r[u].start}if(i(r[u].end)){b[u].end=e[e.length-1].x}else{b[u].end=yn?yu(r[u].end):r[u].end}}}g=et?function(e){return n(e.value)}:function(e){return t(e.x)};y=et?function(e){return t(e.x)}:function(e){return n(e.value)};if(yn){l=function(e,r,i,s){var o=e.x.getTime(),u=r.x-e.x,a=new Date(o+u*i),f=new Date(o+u*(i+s));return"M"+t(a)+" "+n(h(i))+" "+t(f)+" "+n(h(i+s))}}else{l=function(e,r,i,s){return"M"+t(c(i))+" "+n(h(i))+" "+t(c(i+s))+" "+n(h(i+s))}}for(u=0;u<e.length;u++){if(i(b)||!Eu(e[u].x,b)){f+=" "+g(e[u])+" "+y(e[u])}else{c=ii(e[u-1].x,e[u].x);h=si(e[u-1].value,e[u].value);p=t(e[u].x)-t(e[u-1].x);d=n(e[u].value)-n(e[u-1].value);v=Math.sqrt(Math.pow(p,2)+Math.pow(d,2));m=2/v;var w=m*2;for(a=m;a<=1;a+=w){f+=l(e[u-1],e[u],a,m)}}o=e[u].x}return f}function la(t){var r,i;var s;oa=o.select(c);if(oa.empty()){throw new Error('No bind element found. Check the selector specified by "bindto" and existance of that element. Default "bindto" is "#chart".')}else{oa.html("")}oa.classed("c3",true);u.data.x={};u.data.targets=Ls(t);kr();ni();er.domain(o.extent(ls(u.data.targets)));tr.domain(ss(u.data.targets,"y"));nr.domain(ss(u.data.targets,"y2"));rr.domain(er.domain());ir.domain(tr.domain());sr.domain(nr.domain());ua=er.domain();Yu.scale(rr);if(m){Zu.scale(er)}ea=oa.append("svg").attr("width",Mn+Ln.left+Ln.right).attr("height",Dn+Ln.top+Ln.bottom).on("mouseenter",b).on("mouseleave",w);ta=ea.append("defs");ta.append("clipPath").attr("id",hn).append("rect").attr("width",Mn).attr("height",Dn);ta.append("clipPath").attr("id",pn).append("rect").attr("x",qr).attr("y",Rr).attr("width",Vr).attr("height",$r);ta.append("clipPath").attr("id",dn).append("rect").attr("x",Ur).attr("y",zr).attr("width",Jr).attr("height",Kr);na=ea.append("g").attr("transform",dr.main);ra=V?ea.append("g").attr("transform",dr.context):null;ia=Q?ea.append("g").attr("transform",dr.legend):null;sa=o.select(c).style("position","relative").append("div").style("position","absolute").style("pointer-events","none").style("z-index","10").style("display","none");na.append("g").attr("class",n.axisX).attr("clip-path",et?"":mn).attr("transform",dr.x).append("text").attr("class",n.axisXLabel).attr("transform",et?"rotate(-90)":"").attr("dx",Ai).attr("dy",_i).style("text-anchor",Hi);if(pt){na.append("g").attr("class",n.axisY).attr("clip-path",et?gn:"").append("text").attr("class",n.axisYLabel).attr("transform",et?"":"rotate(-90)").attr("dx",Oi).attr("dy",Di).style("text-anchor",Bi)}if(St){na.append("g").attr("class",n.axisY2).attr("transform",dr.y2).append("text").attr("class",n.axisY2Label).attr("transform",et?"":"rotate(-90)").attr("dx",Mi).style("text-anchor",ji)}i=na.append("g").attr("clip-path",vn).attr("class",n.grid);if(_t){i.append("g").attr("class",n.xgrids)}if(Su(Pt)){i.append("g").attr("class",n.xgridLines)}if(qt){i.append("g").attr("class",n.xgridFocus).append("line").attr("class",n.xgridFocus).attr("x1",et?0:-10).attr("x2",et?Mn:-10).attr("y1",et?-10:Ln.top).attr("y2",et?-10:Dn)}if(Ht){i.append("g").attr("class",n.ygrids)}if(Su(Bt)){i.append("g").attr("class",n.ygridLines)}na.append("g").attr("clip-path",vn).attr("class",n.regions);na.append("g").attr("clip-path",vn).attr("class",n.chart);r=na.select("."+n.chart).append("g").attr("class",n.eventRects).style("fill-opacity",0).style("cursor",m?et?"ns-resize":"ew-resize":null);na.select("."+n.chart).append("g").attr("class",n.chartBars);na.select("."+n.chart).append("g").attr("class",n.chartLines);na.select("."+n.chart).append("g").attr("class",n.chartArcs).attr("transform",dr.arc).append("text").attr("class",n.chartArcsTitle).style("text-anchor","middle").text(Zi());na.select("."+n.chart).append("g").attr("class",n.chartTexts);if(m){na.insert("rect",y?null:"g."+n.grid).attr("class",n.zoomRect).attr("width",Mn).attr("height",Dn).style("opacity",0).style("cursor",et?"ns-resize":"ew-resize").call(Zu).on("dblclick.zoom",null)}if(ct){Yu.extent(typeof ct!=="function"?ct:ct(ls()))}if(V){ra.append("g").attr("clip-path",vn).attr("class",n.chart);ra.select("."+n.chart).append("g").attr("class",n.chartBars);ra.select("."+n.chart).append("g").attr("class",n.chartLines);ra.append("g").attr("clip-path",vn).attr("class",n.brush).call(Yu).selectAll("rect").attr(et?"width":"height",et?_n:Pn);ra.append("g").attr("class",n.axisX).attr("transform",dr.subx).attr("clip-path",et?"":mn)}xa(u.data.targets);if(et){na.select("."+n.axisX).style("opacity",0).call(or)}else{na.select("."+n.axisY).style("opacity",0).call(ur);na.select("."+n.axisY2).style("opacity",0).call(ar)}Sa({withTransform:true,withLegend:true,durationForAxis:0});if(fn){if(yn&&typeof ln==="string"){ln=yu(ln);for(s=0;s<u.data.targets[0].values.length;s++){if(u.data.targets[0].values[s].x-ln===0){break}}ln=s}sa.html(an(u.data.targets.map(function(e){return Ss(e.values[ln])}),ci(),yo,Nn));sa.style("top",cn.top).style("left",cn.left).style("display","block")}if(e.onresize==null){e.onresize=wa()}if(e.onresize.add){e.onresize.add(function(){Sa({withTransition:false,withLegend:true})})}}function ca(e){e.append("rect").attr("class",uo).style("cursor",H&&B?"pointer":null).on("mouseover",function(e,t){if(Sn){return}if(iu(u.data.targets)){return}var r=u.data.targets.map(function(e){return Ss(e.values[t])});var i,s;if(Object.keys(C).length>0){s=[];for(var o in C){for(i=0;i<r.length;i++){if(r[i].id===o){s.push(r[i]);r.shift(i);break}}}r=s.concat(r)}if(Rt){Pu(t)}ju(t);na.selectAll("."+n.shape+"-"+t).each(function(e){q(e)})}).on("mouseout",function(e,t){if(iu(u.data.targets)){return}Bo();Po();Hu(t);Fu();na.selectAll("."+n.shape+"-"+t).each(function(e){R(e)})}).on("mousemove",function(e,t){var r;if(Sn){return}if(iu(u.data.targets)){return}r=Fs(u.data.targets).map(function(e){return Ss(e.values[t])});Do(r,o.mouse(this));Ho(r);if(!H){return}if(B){return}na.selectAll("."+n.shape+"-"+t).filter(function(e){return j(e)}).each(function(){var e=o.select(this).classed(n.EXPANDED,true);if(this.nodeName==="circle"){e.attr("r",Ut)}ea.select("."+n.eventRect+"-"+t).style("cursor",null)}).filter(function(){if(this.nodeName==="circle"){return bu(this,zt)}else if(this.nodeName==="path"){return wu(this)}}).each(function(){var e=o.select(this);if(!e.classed(n.EXPANDED)){e.classed(n.EXPANDED,true);if(this.nodeName==="circle"){e.attr("r",zt)}}ea.select("."+n.eventRect+"-"+t).style("cursor","pointer")})}).on("click",function(e,t){if(iu(u.data.targets)){return}if(xn){xn=false;return}na.selectAll("."+n.shape+"-"+t).each(function(e){pa(this,e,t)})}).call(o.behavior.drag().origin(Object).on("drag",function(){da(o.mouse(this))}).on("dragstart",function(){va(o.mouse(this))}).on("dragend",function(){ma()})).call(Zu).on("dblclick.zoom",null)}function ha(e){e.append("rect").attr("x",0).attr("y",0).attr("width",Mn).attr("height",Dn).attr("class",n.eventRect).on("mouseout",function(){if(iu(u.data.targets)){return}Bo();Po();Hu()}).on("mousemove",function(){var e,t,r;if(Sn){return}if(iu(u.data.targets)){return}e=o.mouse(this);t=ko(u.data.targets,e);r=[Ss(t)];Do(r,e);if(Rt){Hu();Pu(t.index,t.id)}Ho(r);if(Tu(t,e)<100){ea.select("."+n.eventRect).style("cursor","pointer");if(!Tn){q(t);Tn=true}}else{ea.select("."+n.eventRect).style("cursor",null);R(t);Tn=false}}).on("click",function(){var e,t;if(iu(u.data.targets)){return}e=o.mouse(this);t=ko(u.data.targets,e);if(Tu(t,e)<100){na.select("."+n.circles+"-"+fo(t.id)).select("."+n.circle+"-"+t.index).each(function(){pa(this,t,t.index)})}}).call(o.behavior.drag().origin(Object).on("drag",function(){da(o.mouse(this))}).on("dragstart",function(){va(o.mouse(this))}).on("dragend",function(){ma()})).call(Zu).on("dblclick.zoom",null)}function pa(e,t,r){var i=o.select(e),s=i.classed(n.SELECTED);var u=false,a;if(e.nodeName==="circle"){u=bu(e,zt*1.5);a=Lu}else if(e.nodeName==="path"){u=wu(e);a=Mu}if(B||u){if(H&&j(t)){if(!F){na.selectAll("."+n.shapes+(B?fo(t.id):"")).selectAll("."+n.shape).each(function(e,t){var r=o.select(this);if(r.classed(n.SELECTED)){a(false,r.classed(n.SELECTED,false),e,t)}})}i.classed(n.SELECTED,!s);a(!s,i,t,r)}I(t,e)}}function da(e){var t,r,i,s,a,f,l,c;if(iu(u.data.targets)){return}if(!H){return}if(m&&!Zu.altDomain){return}if(!F){return}t=En[0];r=En[1];i=e[0];s=e[1];a=Math.min(t,i);f=Math.max(t,i);l=B?Ln.top:Math.min(r,s);c=B?Dn:Math.max(r,s);na.select("."+n.dragarea).attr("x",a).attr("y",l).attr("width",f-a).attr("height",c-l);na.selectAll("."+n.shapes).selectAll("."+n.shape).filter(function(e){return j(e)}).each(function(e,t){var r=o.select(this),i=r.classed(n.SELECTED),s=r.classed(n.INCLUDED),u,h,p,d,v,m=false,g;if(this.nodeName==="circle"){u=r.attr("cx")*1;h=r.attr("cy")*1;v=Lu;m=a<u&&u<f&&l<h&&h<c}else if(this.nodeName==="path"){g=Ao(this);u=g.x;h=g.y;p=g.width;d=g.height;v=Mu;m=!(f<u||u+p<a)&&!(c<h||h+d<l)}if(m^s){r.classed(n.INCLUDED,!s);r.classed(n.SELECTED,!i);v(!i,r,e,t)}})}function va(e){if(iu(u.data.targets)){return}if(!H){return}En=e;na.select("."+n.chart).append("rect").attr("class",n.dragarea).style("opacity",.1);Sn=true;W()}function ma(){if(iu(u.data.targets)){return}if(!H){return}na.select("."+n.dragarea).transition().duration(100).style("opacity",0).remove();na.selectAll("."+n.shape).classed(n.INCLUDED,false);Sn=false;X()}function ga(e){var t,i,a,f,l,c,h;var p,d,v,g,y,b;var w=Wo(),S=Io(),T=Jo(),N;var C,k;var L,A,O,M,_,D,P;var H=iu(u.data.targets);var B,j,F,I,q,R;var U,z,W;var X=Fs(u.data.targets),$,J,G;if(X.length===0){return}e=s(e)?e:{};L=s(e.withY)?e.withY:true;A=s(e.withSubchart)?e.withSubchart:true;O=s(e.withTransition)?e.withTransition:true;M=s(e.withTransform)?e.withTransform:false;_=s(e.withUpdateXDomain)?e.withUpdateXDomain:false;D=s(e.withUpdateOrgXDomain)?e.withUpdateOrgXDomain:false;P=s(e.withLegend)?e.withLegend:false;U=O?E:0;z=s(e.durationForExit)?e.durationForExit:U;W=s(e.durationForAxis)?e.durationForAxis:U;if(P&&Q){Ma(u.data.targets,e)}if(D){er.domain(o.extent(ls(X)));ua=er.domain();if(m){Zu.scale(er).updateScaleExtent()}rr.domain(er.domain());Yu.scale(rr)}if(_){er.domain(Yu.empty()?ua:Yu.extent());if(m){Zu.scale(er).updateScaleExtent()}if(!tu(X)){$=qs(Is(X));or.tickValues($);fr.tickValues($)}}tr.domain(ss(X,"y"));nr.domain(ss(X,"y2"));na.select("."+n.axisX).style("opacity",H?0:1).transition().duration(W).call(or);na.select("."+n.axisY).style("opacity",H?0:1).transition().duration(W).call(ur);na.select("."+n.axisY2).style("opacity",H?0:1).transition().duration(W).call(ar);if(_&&st&&$){for(J=1;J<$.length;J++){if($.length/J<ot){G=J;break}}o.selectAll("."+n.axisX+" .tick text").each(function(e,t){o.select(this).style("display",t%G?"none":"block")})}B=Ru(w);j=Uu(S);I=zu(T);q=Wu(S,true);R=Wu(S,false);Ii();ir.domain(tr.domain());sr.domain(nr.domain());sa.style("display","none");na.select("line."+n.xgridFocus).style("visibility","hidden");if(_t){if(Dt==="year"){i=[];var Y=ls();var Z=Y[0].getFullYear();var tt=Y[1].getFullYear();for(var nt=Z;nt<=tt;nt++){i.push(new Date(nt+"-01-01 00:00:00"))}}else{i=er.ticks(10)}t=na.select("."+n.xgrids).selectAll("."+n.xgrid).data(i);t.enter().append("line").attr("class",n.xgrid);t.attr("x1",et?0:function(e){return er(e)-or.tickOffset()}).attr("x2",et?Mn:function(e){return er(e)-or.tickOffset()}).attr("y1",et?function(e){return er(e)-or.tickOffset()}:Ln.top).attr("y2",et?function(e){return er(e)-or.tickOffset()}:Dn).style("opacity",function(){return+o.select(this).attr(et?"y1":"x1")===(et?Dn:0)?0:1});t.exit().remove()}if(Su(Pt)){a=na.select("."+n.xgridLines).selectAll("."+n.xgridLine).data(Pt);f=a.enter().append("g").attr("class",function(e){return n.xgridLine+(e.class?e.class:"")});f.append("line").style("opacity",0);f.append("text").attr("text-anchor","end").attr("transform",et?"":"rotate(-90)").attr("dx",et?0:-Ln.top).attr("dy",-5).style("opacity",0);a.select("line").transition().duration(U).attr("x1",et?0:So).attr("x2",et?Mn:So).attr("y1",et?So:Ln.top).attr("y2",et?So:Dn).style("opacity",1);a.select("text").transition().duration(U).attr("x",et?Mn:0).attr("y",So).text(function(e){return e.text}).style("opacity",1);a.exit().transition().duration(U).style("opacity",0).remove()}if(L&&Ht){l=na.select("."+n.ygrids).selectAll("."+n.ygrid).data(tr.ticks(jt));l.enter().append("line").attr("class",n.ygrid);l.attr("x1",et?tr:0).attr("x2",et?tr:Mn).attr("y1",et?0:tr).attr("y2",et?Dn:tr);l.exit().remove()}if(L&&Su(Bt)){c=na.select("."+n.ygridLines).selectAll("."+n.ygridLine).data(Bt);h=c.enter().append("g").attr("class",function(e){return n.ygridLine+(e.class?e.class:"")});h.append("line").style("opacity",0);h.append("text").attr("text-anchor","end").attr("transform",et?"rotate(-90)":"").attr("dx",et?0:-Ln.top).attr("dy",-5).style("opacity",0);c.select("line").transition().duration(U).attr("x1",et?xo:0).attr("x2",et?xo:Mn).attr("y1",et?0:xo).attr("y2",et?Dn:xo).style("opacity",1);c.select("text").transition().duration(U).attr("x",et?0:Mn).attr("y",xo).text(function(e){return e.text}).style("opacity",1);c.exit().transition().duration(U).style("opacity",0).remove()}d=na.selectAll("."+n.bars).selectAll("."+n.bar).data(du);d.enter().append("path").attr("d",j).style("stroke",function(e){return Nn(e.id)}).style("stroke-width",2).style("opacity",0).style("fill",function(e){return Nn(e.id)}).style("fill-opacity",function(){if(K){return K}return co}).attr("class",no);d.style("opacity",co).transition().duration(U).attr("d",j).style("opacity",1);d.exit().transition().duration(z).style("opacity",0).remove();g=na.selectAll("."+n.texts).selectAll("."+n.text).data(mu);g.enter().append("text").attr("class",Ks).attr("text-anchor",function(e){return et?e.value<0?"end":"start":"middle"}).style("stroke","none").style("fill-opacity",0);g.text(function(e){return wo(e.id)(e.value)}).style("fill-opacity",ho).transition().duration(U).attr("x",q).attr("y",R).style("fill-opacity",vo);g.exit().transition().duration(z).style("fill-opacity",0).remove();na.selectAll("."+n.line).style("opacity",co).transition().duration(U).attr("d",I).style("opacity",1);na.selectAll("."+n.step).style("opacity",co).transition().duration(U).attr("d",I).style("opacity",1);na.selectAll("."+n.area).style("opacity",0).transition().duration(U).attr("d",B).style("opacity",aa);p=na.selectAll("."+n.circles).selectAll("."+n.circle).data(vu);p.enter().append("circle").attr("class",eo).style("opacity",0).attr("r",It);p.style("opacity",co).transition().duration(U).style("opacity",po).attr("cx",et?Fo:jo).attr("cy",et?jo:Fo);p.exit().remove();na.selectAll("."+n.chartArc).select("."+n.arc).attr("transform",M?"scale(0)":"").style("opacity",function(e){return e===this._current?0:1}).transition().duration(U).attrTween("d",function(e){var t=Ri(e),n;if(!t){return function(){return"M 0 0"}}n=o.interpolate(this._current,t);this._current=n(0);return function(e){return Wi(n(e),true)}}).attr("transform",M?"scale(1)":"").style("opacity",K?K:1);na.selectAll("."+n.chartArc).select("text").attr("transform",Xi).style("opacity",0).transition().duration(U).text(Ji).style("opacity",function(e){return js(e.data.id)&&pu(e.data)?1:0});na.select("."+n.chartArcsTitle).style("opacity",ru(u.data.targets)?1:0);if(V){if(o.event!==null&&o.event.type==="zoom"){Yu.extent(er.orgDomain()).update()}if(A){ra.select("."+n.axisX).style("opacity",H?0:1).transition().duration(U).call(fr);if(!Yu.empty()){Yu.extent(er.orgDomain()).update()}F=Uu(S,true);y=ra.selectAll("."+n.bars).selectAll("."+n.bar).data(du);y.enter().append("path").attr("d",F).style("stroke","none").style("fill",function(e){return Nn(e.id)}).attr("class",no);y.style("opacity",co).transition().duration(U).attr("d",F).style("opacity",1);y.exit().transition().duration(U).style("opacity",0).remove();ra.selectAll("."+n.line).style("opacity",co).transition().duration(U).attr("d",Qu).style("opacity",1);ra.selectAll("."+n.step).style("opacity",co).transition().duration(U).attr("d",Qu).style("opacity",1)}}na.selectAll("."+n.selectedCircles).filter(function(e){return fu(e)}).selectAll("circle").remove();na.selectAll("."+n.selectedCircle).transition().duration(U).attr("cx",et?Fo:jo).attr("cy",et?jo:Fo);if(Su(x)){b=na.select("."+n.eventRects).selectAll("."+n.eventRect).data([0]);ha(b.enter());b.attr("x",0).attr("y",0).attr("width",Mn).attr("height",Dn)}else{if(wn&&!bn){k=function(e,t){var n=Os(t),r=Ms(t),i=u.data.x[e.id][t];return(er(r?r:i+50)-er(n?n:i-50))/2};C=function(e,t){var n=Os(t),r=u.data.x[e.id][t];return(er(r)+er(n?n:r-50))/2}}else{k=Qr();C=function(e){return er(e.x)-k/2}}N=Ds();na.select("."+n.eventRects).datum(N?N.values:[]);b=na.select("."+n.eventRects).selectAll("."+n.eventRect).data(function(e){return e});ca(b.enter());b.attr("class",uo).attr("x",et?0:C).attr("y",et?C:0).attr("width",et?Mn:k).attr("height",et?k:Dn);b.exit().remove()}v=na.select("."+n.regions).selectAll("rect."+n.region).data(rn);v.enter().append("rect").style("fill-opacity",0);v.attr("class",oo).attr("x",et?0:vs).attr("y",et?vs:Ln.top).attr("width",et?Mn:ms).attr("height",et?ms:Dn).transition().duration(U).style("fill-opacity",function(e){return r(e.opacity)?e.opacity:.1});v.exit().transition().duration(U).style("fill-opacity",0).remove();Ps().forEach(function(e){fa[e]=true})}function ya(){ga({withTransition:false,withY:false,withSubchart:false,withUpdateXDomain:true})}function ba(){if(o.event.sourceEvent.type==="mousemove"&&Zu.altDomain){er.domain(Zu.altDomain);Zu.scale(er).updateScaleExtent();return}if(bn&&er.orgDomain()[0]===ua[0]){er.domain([ua[0]-1e-10,er.orgDomain()[1]])}ga({withTransition:false,withY:false,withSubchart:false});if(o.event.sourceEvent.type==="mousemove"){xn=true}}function wa(){function t(){e.forEach(function(e){e()})}var e=[];t.add=function(t){e.push(t)};return t}function Ea(){ea.attr("width",Hn).attr("height",Bn);ea.select("#"+hn).select("rect").attr("width",Mn).attr("height",Dn);ea.select("#"+pn).select("rect").attr("width",Vr);ea.select("#"+dn).select("rect").attr("width",Jr);ea.select("."+n.zoomRect).attr("width",Mn).attr("height",Dn)}function Sa(e){e=s(e)?e:{};e.withTransition=s(e.withTransition)?e.withTransition:true;e.withTransform=s(e.withTransform)?e.withTransform:false;e.withLegend=s(e.withLegend)?e.withLegend:false;e.withUpdateXDomain=true;e.withUpdateOrgXDomain=true;e.durationForExit=0;kr();ni();Ea();xr(e.withTransition);ga(e)}function xa(e){var t,r,i,s,u,a,f,l;var c,h,p,d;f=na.select("."+n.chartTexts).selectAll("."+n.chartText).data(e);l=f.enter().append("g").attr("class",function(e){return n.chartText+Js(n.target,e.id)}).style("pointer-events","none");l.append("g").attr("class",Qs).style("fill",function(e){return Nn(e.id)});s=na.select("."+n.chartBars).selectAll("."+n.chartBar).data(e);i=s.enter().append("g").attr("class",function(e){return n.chartBar+Js(n.target,e.id)}).style("pointer-events","none");i.append("g").attr("class",ro).style("fill",function(e){return Nn(e.id)}).style("stroke","none").style("cursor",function(e){return j(e)?"pointer":null});r=na.select("."+n.chartLines).selectAll("."+n.chartLine).data(e);t=r.enter().append("g").attr("class",function(e){return n.chartLine+Js(n.target,e.id)}).style("pointer-events","none");t.append("path").attr("class",Zs).style("opacity",0).style("stroke",function(e){return Nn(e.id)});t.append("path").attr("class",ao).style("opacity",0).style("stroke",function(e){return Nn(e.id)});t.append("path").attr("class",so).style("opacity",function(){aa=K?K:1;return 0}).style("fill",function(e){return Nn(e.id)});t.append("g").attr("class",function(e){return Js(n.selectedCircles,e.id)});t.append("g").attr("class",to).style("fill",function(e){return Nn(e.id)}).style("cursor",function(e){return j(e)?"pointer":null});e.forEach(function(e){na.selectAll("."+n.selectedCircles+fo(e.id)).selectAll("."+n.selectedCircle).each(function(t,n){t.value=e.values[n].value})});a=na.select("."+n.chartArcs).selectAll("."+n.chartArc).data(Xn(e));u=a.enter().append("g").attr("class",function(e){return n.chartArc+Js(n.target,e.data.id)});u.append("path").attr("class",io).style("opacity",0).style("fill",function(e){return Nn(e.data.id)}).style("cursor",function(e){return j(e)?"pointer":null}).each(function(e){this._current=e}).on("mouseover",function(e,t){var n=Ri(e),r=$i(n),i=ts();Ki(n.data.id);La(n.data.id);i(r,t)}).on("mousemove",function(e){var t=Ri(e),n=[$i(t)];Do(n,o.mouse(this))}).on("mouseout",function(e,t){var n=Ri(e),r=$i(n),i=ns();Qi(n.data.id);Oa();Po();i(r,t)}).on("click",function(e,t){var n=Ri(e),r=$i(n),i=es();i(r,t)});u.append("text").attr("dy",".35em").style("opacity",0).style("text-anchor","middle").style("pointer-events","none");if(V){d=ra.select("."+n.chartBars).selectAll("."+n.chartBar).data(e);p=d.enter().append("g").attr("class",function(e){return n.chartBar+Js(n.target,e.id)});p.append("g").attr("class",ro).style("fill",function(e){return Nn(e.id)});h=ra.select("."+n.chartLines).selectAll("."+n.chartLine).data(e);c=h.enter().append("g").attr("class",function(e){return n.chartLine+Js(n.target,e.id)});c.append("path").attr("class",Zs).style("opacity",0).style("stroke",function(e){return Nn(e.id)})}ea.selectAll("."+n.target).filter(function(e){return js(e.id)}).transition().style("opacity",1)}function Ta(e,t){u.data.targets.forEach(function(t){for(var n=0;n<e.length;n++){if(t.id===e[n].id){t.values=e[n].values;e.splice(n,1);break}}});u.data.targets=u.data.targets.concat(e);xa(u.data.targets);ga({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:true});if(typeof t==="function"){t()}}function Na(e){if("data"in e){Ta(Ls(e.data),e.done)}else if("url"in e){o.csv(e.url,function(t,n){Ta(Ls(n),e.done)})}else if("rows"in e){Ta(Ls(Cs(e.rows)),e.done)}else if("columns"in e){Ta(Ls(ks(e.columns)),e.done)}else{throw Error("url or rows or columns is required.")}}function Ca(e,t){if(typeof t!=="function"){t=function(){}}e=e.filter(function(e){return Hs(e)});if(!e||e.length===0){t();return}ea.selectAll(e.map(function(e){return lo(e)})).transition().style("opacity",0).remove().call(Nu,t);e.forEach(function(e){fa[e]=false;if(Q){ia.selectAll("."+n.legendItem+fo(e)).remove()}u.data.targets=u.data.targets.filter(function(t){return t.id!==e})})}function ka(e,t){var r,i,s;if(!Q){return}r=ia.selectAll("."+n.legendItem);i=function(t){return!e||t===e};s=function(e){return!i(e)};r.filter(s).transition().duration(100).style("opacity",t?.3:1);r.filter(i).transition().duration(100).style("opacity",t?1:.3)}function La(e){ka(e,true)}function Aa(e){ka(e,false)}function Oa(){if(!Q){return}ia.selectAll("."+n.legendItem).transition().duration(100).style("opacity",1)}function Ma(e,t){function L(e,t,n){function c(e,t){if(!t){f=(a-b-u)/2;if(f<y){f=(a-u)/2;b=0;N++}}T[e]=N;x[N]=f;w[e]=b;b+=u}var i=e.getBBox(),s=Math.ceil((i.width+v)/10)*10,o=Math.ceil((i.height+d)/10)*10,u=vr?o:s,a=vr?jn:Fn,f,l;if(n){b=0;N=0;m=0;g=0}E[t]=s;S[t]=o;if(!m||s>=m){m=s}if(!g||o>=g){g=o}l=vr?g:m;if(Z){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<y){b=0;N=0;r.forEach(function(e){c(e)})}else{c(t,true)}}else{c(t)}}var r=Ps(e),o;var a,f,l,c,h,p;var d=4,v=26,m=0,g=0,y=10;var b=0,w={},E={},S={},x={},T={},N=0;var k;t=i(t)?{}:t;k=s(t.withTransition)?t.withTransition:true;if(vr){a=function(e){return m*(.2+T[e])};c=function(e){return x[T[e]]+w[e]}}else{a=function(e){return x[T[e]]+w[e]};c=function(e){return g*(.2+T[e])}}f=function(e,t){return a(e,t)+14};h=function(e,t){return c(e,t)+9};l=function(e,t){return a(e,t)-4};p=function(e,t){return c(e,t)-7};o=ia.selectAll("."+n.legendItem).data(r).enter().append("g").attr("class",function(e){return Js(n.legendItem,e)}).style("cursor","pointer").on("click",function(e){typeof Y==="function"?Y(e):u.toggle(e)}).on("mouseover",function(e){u.focus(e)}).on("mouseout",function(){u.revert()});o.append("text").text(function(e){return s(C[e])?C[e]:e}).each(function(e,t){L(this,e,t===0)}).style("pointer-events","none").attr("x",vr?f:-200).attr("y",vr?-200:h);o.append("rect").attr("class",n.legendItemEvent).style("fill-opacity",0).attr("x",vr?l:-200).attr("y",vr?-200:p).attr("width",function(e){return E[e]}).attr("height",function(e){return S[e]});o.append("rect").attr("class",n.legendItemTile).style("pointer-events","none").style("fill",function(e){return Nn(e)}).attr("x",vr?f:-200).attr("y",vr?-200:c).attr("width",10).attr("height",10);ia.selectAll("text").data(r).text(function(e){return s(C[e])?C[e]:e}).each(function(e,t){L(this,e,t===0)}).transition().duration(k?250:0).attr("x",f).attr("y",h);ia.selectAll("rect."+n.legendItemEvent).data(r).transition().duration(k?250:0).attr("x",l).attr("y",p);ia.selectAll("rect."+n.legendItemTile).data(r).transition().duration(k?250:0).attr("x",a).attr("y",c);Yr(m);Zr(g);Gr(N);kr();ni();Ea();xr(false)}function _a(e){return Hs(e.id)}function Da(e){return"data"in e&&Hs(e.data.id)}function Pa(e){var t=e&&e.value?e.value:null,n=e&&e["class"]?e["class"]:null;return t?function(e){return e.value!==t}:n?function(e){return e["class"]!==n}:function(){return true}}var o=e.d3?e.d3:e.require?e.require("d3"):undefined;var u={data:{},axis:{}},a={};var c=l(["bindto"],"#chart");var h=l(["size","width"]),p=l(["size","height"]);var d=l(["padding","left"]),v=l(["padding","right"]);var m=l(["zoom","enabled"],false),g=l(["zoom","extent"]),y=l(["zoom","privileged"],false);var b=l(["onenter"],function(){}),w=l(["onleave"],function(){});var E=l(["transition","duration"],350);f("data","data is required in config");var S=l(["data","x"]),x=l(["data","xs"],{}),T=l(["data","x_format"]),N=l(["data","id_converter"],function(e){return e}),C=l(["data","names"],{}),k=l(["data","groups"],[]),L=l(["data","axes"],{}),A=l(["data","type"]),O=l(["data","types"],{}),M=l(["data","labels"],{}),_=l(["data","order"]),D=l(["data","regions"],{}),P=l(["data","colors"],{}),H=l(["data","selection","enabled"],false),B=l(["data","selection","grouped"],false),j=l(["data","selection","isselectable"],function(){return true}),F=l(["data","selection","multiple"],true),I=l(["data","onclick"],function(){}),q=l(["data","onenter"],function(){}),R=l(["data","onleave"],function(){}),U=l(["data","onselected"],function(){}),z=l(["data","onunselected"],function(){}),W=l(["data","ondragstart"],function(){}),X=l(["data","ondragend"],function(){});var V=l(["subchart","show"],false),$=V?l(["subchart","size","height"],60):0;var J=l(["color","pattern"],[]),K=l(["color","opacity"],null);var Q=l(["legend","show"],true),G=l(["legend","position"],"bottom"),Y=l(["legend","item","onclick"]),Z=l(["legend","equally"],false);var et=l(["axis","rotated"],false),tt=l(["axis","x","type"],"indexed"),nt=l(["axis","x","categories"],[]),rt=l(["axis","x","tick","centered"],false),it=l(["axis","x","tick","format"]),st=l(["axis","x","tick","culling"],{}),ot=l(["axis","x","tick","culling","max"],tt==="categorized"?Infinity:10),ut=l(["axis","x","tick","count"]),at=l(["axis","x","tick","fit"],false),ft=l(["axis","x","max"]),lt=l(["axis","x","min"]),ct=l(["axis","x","default"]),ht=l(["axis","x","label"],{}),pt=l(["axis","y","show"],true),dt=l(["axis","y","max"]),vt=l(["axis","y","min"]),mt=l(["axis","y","center"]),gt=l(["axis","y","label"],{}),yt=l(["axis","y","inner"],false),bt=l(["axis","y","tick","format"]),wt=l(["axis","y","padding"]),Et=l(["axis","y","ticks"],10),St=l(["axis","y2","show"],false),xt=l(["axis","y2","max"]),Tt=l(["axis","y2","min"]),Nt=l(["axis","y2","center"]),Ct=l(["axis","y2","label"],{}),kt=l(["axis","y2","inner"],false),Lt=l(["axis","y2","tick","format"]),At=l(["axis","y2","padding"]),Ot=l(["axis","y2","ticks"],10);var Mt=l(["zeropadding"],false);var _t=l(["grid","x","show"],false),Dt=l(["grid","x","type"],"tick"),Pt=l(["grid","x","lines"],[]),Ht=l(["grid","y","show"],false),Bt=l(["grid","y","lines"],[]),jt=l(["grid","y","ticks"],10);var Ft=l(["point","show"],true),It=Ft?l(["point","r"],2.5):0,qt=l(["point","focus","line","enabled"],true),Rt=l(["point","focus","expand","enabled"],true),Ut=l(["point","focus","expand","r"],Rt?4:It),zt=l(["point","focus","select","r"],8);var Wt=l(["bar","width"]),Xt=l(["bar","width","ratio"],.6);var Vt=l(["pie","label","show"],true),$t=l(["pie","label","format"]),Jt=l(["pie","onclick"],function(){}),Kt=l(["pie","onmouseover"],function(){}),Qt=l(["pie","onmouseout"],function(){});var Gt=l(["donut","label","show"],true),Yt=l(["donut","label","format"]),Zt=l(["donut","title"],""),en=l(["donut","onclick"],function(){}),tn=l(["donut","onmouseover"],function(){}),nn=l(["donut","onmouseout"],function(){});var rn=l(["regions"],[]);var sn=l(["tooltip","show"],true),on=l(["tooltip","format","title"]),un=l(["tooltip","format","value"]),an=l(["tooltip","contents"],function(e,t,r,i){var s=on?on:t,o=un?un:r,u,a,f,l,c;for(a=0;a<e.length;a++){if(!(e[a]&&(e[a].value||e[a].value===0))){continue}if(!u){f=s?s(e[a].x):e[a].x;u="<table class='"+n.tooltip+"'>"+(f||f===0?"<tr><th colspan='2'>"+f+"</th></tr>":"")}c=e[a].name;l=o(e[a].value,e[a].ratio);u+="<tr class='"+n.tooltipName+"-"+e[a].id+"'>";u+="<td class='name'><span style='background-color:"+i(e[a].id)+"'></span>"+c+"</td>";u+="<td class='value'>"+l+"</td>";u+="</tr>"}return u+"</table>"}),fn=l(["tooltip","init","show"],false),ln=l(["tooltip","init","x"],0),cn=l(["tooltip","init","position"],{top:"0px",left:"50px"});var hn=(typeof c==="string"?c.replace("#",""):c.id)+"-clip",pn=hn+"-xaxis",dn=hn+"-yaxis",vn=br(hn),mn=br(mn),gn=br(gn);var yn=tt==="timeseries",bn=tt==="categorized",wn=!yn&&(S||Su(x));var En=null,Sn=false,xn=false,Tn=false;var Nn=gu(P,J);var Cn=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 kn=[];var Ln,An,On,Mn,_n,Dn,Pn,Hn,Bn,jn,Fn;var In,qn,Rn,Un,zn,Wn,Xn;var Vn,$n,Jn,Kn,Qn,Gn,Yn,Zn;var er,tr,nr,rr,ir,sr,or,ur,ar,fr;var lr=et?"left":"bottom",cr=et?yt?"top":"bottom":yt?"right":"left",hr=et?kt?"bottom":"top":kt?"left":"right",pr=et?"left":"bottom";var dr={main:function(){return"translate("+Ln.left+","+Ln.top+")"},context:function(){return"translate("+An.left+","+An.top+")"},legend:function(){return"translate("+On.left+","+On.top+")"},x:function(){return"translate(0,"+(et?0:Dn)+")"},y:function(){return"translate(0,"+(et?Dn:0)+")"},y2:function(){return"translate("+(et?0:Mn)+","+(et?1:0)+")"},subx:function(){return"translate(0,"+(et?0:Pn)+")"},arc:function(){return"translate("+Mn/2+","+Dn/2+")"}};var vr=G==="right";var mr=0,gr=0,yr=0;var Tr=30,Nr=30,Cr=5;Xn=o.layout.pie().value(function(e){return e.values.reduce(function(e,t){return e+t.value},0)});var Iu=function(){var e=o.svg.line().x(et?function(e){return oi(e.id)(e.value)}:Eo).y(et?Eo:function(e){return oi(e.id)(e.value)});return function(t){var n=_u(t.values),r,i;if(su(t)){uu(t)?e.interpolate("cardinal"):e.interpolate("linear");return D[t.id]?Gu(n,er,oi(t.id),D[t.id]):e(n)}else if(ou(t)){e.interpolate("step-after");return D[t.id]?Gu(n,er,oi(t.id),D[t.id]):e(n)}else{r=er(n[0].x);i=oi(t.id)(n[0].value);return et?"M "+i+" "+r:"M "+r+" "+i}}}();var qu=function(){var e;if(et){e=o.svg.area().x0(function(e){return oi(e.id)(0)}).x1(function(e){return oi(e.id)(e.value)}).y(Eo)}else{e=o.svg.area().x(Eo).y0(function(e){return oi(e.id)(0)}).y1(function(e){return oi(e.id)(e.value)})}return function(t){var n=_u(t.values),r,i;if(Zo([t],"area")||Zo([t],"area-spline")){uu(t)?e.interpolate("cardinal"):e.interpolate("linear");return e(n)}else if(Zo([t],"area-step")){ou(t)?e.interpolate("step-after"):"";return e(n)}else{r=er(n[0].x);i=oi(t.id)(n[0].value);return et?"M "+i+" "+r:"M "+r+" "+i}}}();var Qu=function(){var e=o.svg.line().x(et?function(e){return ui(e.id)(e.value)}:To).y(et?To:function(e){return ui(e.id)(e.value)});return function(t){var n=_u(t.values);return su(t)?e(n):"M "+rr(n[0].x)+" "+ui(t.id)(n[0].value)}}();var Yu,Zu=function(){};Yu=o.svg.brush().on("brush",ya);Yu.update=function(){if(ra){ra.select("."+n.brush).call(this)}return this};Yu.scale=function(e){return et?this.y(e):this.x(e)};if(m){Zu=o.behavior.zoom().on("zoomstart",function(){Zu.altDomain=o.event.sourceEvent.altKey?er.orgDomain():null}).on("zoom",m?ba:null);Zu.scale=function(e){return et?this.y(e):this.x(e)};Zu.orgScaleExtent=function(){var e=g?g:[1,10];return[e[0],Math.max(_s()/e[1],e[1])]};Zu.updateScaleExtent=function(){var e=cs(er.orgDomain())/cs(ua),t=this.orgScaleExtent();this.scaleExtent([t[0]*e,t[1]*e]);return this}}var ea,ta,na,ra,ia,sa,oa;var ua;var aa,fa={};u.focus=function(e){function s(e){Fs(e).transition().duration(100).style("opacity",1)}var t=ea.selectAll(lo(e)),r=t.filter(_a),i=t.filter(Da);u.revert();u.defocus();s(r.classed(n.focused,true));s(i);if(iu(u.data.targets)){Ki(e,true)}La(e)};u.defocus=function(e){function s(e){Fs(e).transition().duration(100).style("opacity",.3)}var t=ea.selectAll(lo(e)),r=t.filter(_a),i=t.filter(Da);u.revert();s(r.classed(n.focused,false));s(i);if(iu(u.data.targets)){Qi(e)}Aa(e)};u.revert=function(e){function s(e){Fs(e).transition().duration(100).style("opacity",1)}var t=ea.selectAll(lo(e)),r=t.filter(_a),i=t.filter(Da);s(r.classed(n.focused,false));s(i);if(iu(u.data.targets)){Qi(e)}Oa()};u.show=function(e){Us(e);ea.selectAll(lo(e)).transition().style("opacity",1);ga({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:false})};u.hide=function(e){Rs(e);ea.selectAll(lo(e)).transition().style("opacity",0);ga({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:false})};u.toggle=function(e){js(e)?u.hide(e):u.show(e)};u.unzoom=function(){Yu.clear().update();ga({withUpdateXDomain:true})};u.load=function(e){if(e.xs){Es(e.xs)}if("categories"in e&&bn){nt=e.categories;or.categories(nt)}if("cacheIds"in e&&hs(e.cacheIds)){Ta(ds(e.cacheIds),e.done);return}if("unload"in e){Ca(typeof e.unload==="string"?[e.unload]:typeof e.unload==="boolean"&&e.unload?Ps():e.unload,function(){Na(e)})}else{Na(e)}};u.unload=function(e){Ca(e?typeof e==="string"?[e]:e:Ps(),function(){ga({withUpdateOrgXDomain:true,withUpdateXDomain:true,withLegend:true})})};u.selected=function(e){return o.merge(na.selectAll("."+n.shapes+fo(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}na.selectAll("."+n.shapes).selectAll("."+n.shape).each(function(i,u){var a=o.select(this),f=this.nodeName==="circle"?Cu:Au,l=this.nodeName==="circle"?ku:Ou,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}na.selectAll("."+n.shapes).selectAll("."+n.shape).each(function(r,i){var s=o.select(this),u=this.nodeName==="circle"?ku:Ou,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){Yo(e,"line");Sa()};u.toSpline=function(e){Yo(e,"spline");Sa()};u.toBar=function(e){Yo(e,"bar");Sa()};u.toScatter=function(e){Yo(e,"scatter");Sa()};u.toArea=function(e){Yo(e,"area");Sa()};u.toAreaSpline=function(e){Yo(e,"area-spline");Sa()};u.toPie=function(e){Yo(e,"pie");Sa({withTransform:true})};u.toDonut=function(e){Yo(e,"donut");Sa({withTransform:true})};u.groups=function(e){if(i(e)){return k}k=e;ga();return k};u.xgrids=function(e){if(!e){return Pt}Pt=e;ga();return Pt};u.xgrids.add=function(e){if(!e){return}return u.xgrids(Pt.concat(e))};u.xgrids.remove=function(e){var t=Pa(e);return u.xgrids(Pt.filter(t))};u.ygrids=function(e){if(!e){return Bt}Bt=e;ga();return Bt};u.ygrids.add=function(e){if(!e){return}return u.ygrids(Bt.concat(e))};u.ygrids.remove=function(e){var t=Pa(e);return u.ygrids(Bt.filter(t))};u.regions=function(e){if(i(e)){return rn}rn=e;ga();return rn};u.regions.add=function(e){if(i(e)){return rn}rn=rn.concat(e);ga();return rn};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();rn=rn.filter(function(t){return t.classes.indexOf(e)<0})});return rn};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=Bs(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]});Ma(u.data.targets,{withTransition:true});return C};u.x=function(e){if(arguments.length){xs(u.data.targets,e);ga({withUpdateOrgXDomain:true,withUpdateXDomain:true})}return u.data.x};u.xs=function(e){if(arguments.length){Ts(u.data.targets,e);ga({withUpdateOrgXDomain:true,withUpdateXDomain:true})}return u.data.x};u.axis.labels=function(e){if(arguments.length){Object.keys(e).forEach(function(t){di(t,e[t])});Ii()}};u.axis.max=function(e){if(arguments.length){if(typeof e==="object"){if(r(e.y)){dt=+e.y}if(r(e.y2)){xt=+e.y2}}else{dt=xt=+e}ga()}};u.axis.min=function(e){if(arguments.length){if(typeof e==="object"){if(r(e.y)){vt=+e.y}if(r(e.y2)){Tt=+e.y2}}else{vt=Tt=+e}ga()}};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;Sa({withLegend:true,withTransition:false})};u.destroy=function(){u.data.targets=undefined;u.data.x={};oa.html("");e.onresize=null};if("url"in t.data){o.csv(t.data.url,function(e,t){la(t)})}else if("rows"in t.data){la(Cs(t.data.rows))}else if("columns"in t.data){la(ks(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) |