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