window.Graph={render:function(t,i){var s=document.createElement("div");return s.className="tchart--wrapper",t.appendChild(s),new this.units.TChart({container:s,data:i})},units:{}},function(){var t=function(t,i,s,e){return{linear:function(t,i,s,e){return s*t/e+i},easeInOutQuad:function(t,i,s,e){return(t/=.5*e)<1?.5*s*t*t+i:-s/2*(--t*(t-2)-1)+i}}[e](s,t,i-t,1)},i=function(t){this.composer=t.composer,this.state=t.state,this.queue={},this.queueSize=0,this.step=this.step.bind(this)};i.prototype={add:function(t){for(var i,s,e,a=0,h=+new Date,o=this.queue;as.endDt&&(e=s.endDt),(n=(h=a?(e-s.startDt)/a:d?0:1)<1?"exp"==s.tween?o+(s.end-o)*s.speed:t(s.start,s.end,h,s.tween):s.end)!=o?(s.state[i]=n,c.top=c.top||s.group.top,c.bottom=c.bottom||s.group.bottom):n==s.end&&l.push(i);for(r=0;r0&&(k=a),a>0&&(P.push(i),R.push(a),1==a&&m["e_"+i]&&(C++,z=P.length-1));var Y=P.length;k=1==C?k:1,g?m.y1m:m.y1,g?m.y2m:m.y2;var X=t.TUtils.simplifyData("line",b,c,h,n,P,d,l,I.w-y-T);d=X.xInd1,l=X.xInd2;var H=X.x,U=X.ys,N=!1;for(s=d;s<=l;s++){for(D[s]=0,S[s]=0,i=0;i0&&!g){if(1==L&&(this.savedX1=u,this.savedX2=x),L<1){var B=this.opts.animator.get("x1"),G=this.opts.animator.get("x2");x1End=B?B.end:this.opts.state.x1,x2End=G?G.end:this.opts.state.x2;var O=t.TUtils.getXIndex(b,-1==this.opts.state.zoomDir?this.savedX1:x1End,!0),W=t.TUtils.getXIndex(b,-1==this.opts.state.zoomDir?this.savedX2:x2End,!0)}else O=t.TUtils.getXIndex(b,u,!0),W=t.TUtils.getXIndex(b,x,!0);W--;var j=Math.floor(O),V=Math.ceil(O),Z=Math.floor(W),q=Math.ceil(W),J=0,K=[];for(i=0;i0){e=U[i].y;var xt=a*o;if(w.fillStyle=this.isDarkMode?c[i].colors_n[0]:c[i].colors_d[0],w.globalAlpha=.9*m["f_"+i]+.1,w.beginPath(),0!=$&&g){var vt=this.opts.data.mainPeriodLen*h;if(w.moveTo(H[l]*h+vt+n,hBottom-D[l]),i>0)for(w.lineTo(H[l]*h+n,hBottom-D[l]),s=l;s>=d+1;s--)w.lineTo(H[s]*h+n,hBottom-(D[s]+L*(D[s-1]-D[s]))+0),w.lineTo(H[s-1]*h+n,hBottom-D[s-1]+0);else w.lineTo(H[d]*h+n,hBottom);if(ut0)for(w.moveTo(H[l]*h+n<<0,hBottom-D[l]+0<<0),s=l-1;s>=d;s--)w.lineTo(H[s]*h+n<<0,hBottom-D[s]+0<<0);else w.moveTo(H[l]*h+n<<0,hBottom<<0),w.lineTo(H[d]*h+n<<0,hBottom<<0);if(uto&&(Gt=o),w.lineTo(H[s]*h+n<<0,hBottom-Gt<<0),D[s]+=bt}else w.lineTo(H[d]*h+n<<0,hBottom-o<<0),w.lineTo(H[l]*h+n<<0,hBottom-o<<0)}else{var _t,wt,Dt,St=function(t,i,s,e){var a=0,h=0;At&&C>1&&(a=Math.cos(at[ut].mid)*At*8*_,h=-Math.sin(at[ut].mid)*At*8*_),e>ht&&(e=ht);var o=Math.atan2(nt-i,t-ot);o=o<0?2*Math.PI+o:o;var n=Math.pow((nt-i)*(nt-i)+(t-ot)*(t-ot),.5);Math.abs(s-o)>Math.PI*(1==Y?1.5:1)&&(s-=2*Math.PI),s<2*-Math.PI&&(s-=2*-Math.PI);var r=o+L*(s-o),d=n+L*(e-n);return[ot+Math.cos(r)*d+a,nt-Math.sin(r)*d+h]},It=$<1?4:at[ut].additionalPoints,$t=!1,Lt=!1,At=m["pieInd_"+P[ut]]||0;if(0==at[ut].percentage&&(w.globalAlpha=0),_t=St(H[l]*h+n,hBottom-D[l],at[0].st,ht),w.moveTo(_t[0],_t[1]),ut>0)for(s=l-1;s>=d;s--){if((Dt=H[s]*h+n)==ot&&($t=!0),Dt>=ot)wt=(Dt-ot)/(I.w*_/2),0==L&&(wt=0),_t=St(Dt,hBottom-D[s]+0,at[0].st,ht*wt);else{if(!$t){$t=!0;var Et=(ot-Dt)/(H[s+1]*h+n-Dt),Pt=hBottom-D[s]+0,Rt=hBottom-D[s+1]+0;_t=St(ot,Pt+Et*(Rt-Pt),at[ut].st,0),w.lineTo(_t[0],_t[1])}wt=(ot-Dt)/(I.w*_/2),_t=St(Dt,hBottom-D[s]+0,at[ut].st,ht*wt)}w.lineTo(_t[0],_t[1])}else _t=St(H[d]*h+n,hBottom,at[0].st,ht),w.lineTo(_t[0],_t[1]);if(ut0&&at[ut].percentageText){var zt=Math.pow(L,1==this.opts.state.zoomDir?4:20)*a*(.9*m["f_"+i]+.1),Ft=Math.max(Math.min(2*at[ut].percentage,26),10),Yt=v.PIE_RADIUS,Xt=2*Yt/3,Ht=Math.cos(at[ut].mid),Ut=Math.sin(at[ut].mid),Nt=at[ut].percentage1&&(Bt=Ht*At*8*_,Gt=-Ut*At*8*_),w.fillStyle="white",w.textAlign="center",w.globalAlpha=zt,at[ut].percentageT?this.prevXStep/T:T/this.prevXStep:1,$=1/Math.pow(I,5);p&&1==c&&($/=2),this.prevXStep=T;var L,A=Math.max(A-Math.ceil((n+.5*x)/_),0),E=Math.min(E+Math.ceil((o+.5*x)/_),a.length-1);if(p){var P=this.opts.animator.get("x1"),R=this.opts.animator.get("x2");m=P?P.end:this.opts.state.x1,g=R?R.end:this.opts.state.x2,m=Math.floor(t.TUtils.getXIndex(a,m)),g=Math.floor(t.TUtils.getXIndex(a,g))}if(p)var k=Math.max(a[this.opts.state.detailInd1],this.opts.state.xMainMin),C=Math.min(a[this.opts.state.detailInd2],this.opts.state.xMainMax),z=Math.round((C-k)/this.opts.data.mainPeriodLen)+(u?0:1);for(var F=A;F<=E;F++){var Y=F%w==0,X="m";p&&(F0){var N=(U.xi-h.x1+y/2)*S+n;if(this.ctx.globalAlpha=U.state["ox_"+H]*i,N+x/2>=d.l&&N-x/2<=d.l+d.w){var B=(N+d.l)*e;this.ctx.fillText(s.data.datesShort[F],B,(d.t+9)*e)}}}for(F in this.items){1==(U=this.items[F]).tp&&(U.xih.x2+o/S)&&this.hideItem(F,$)}this.ctx.globalAlpha=1,p&&1==c&&g--,gr?s[t]/r:r/s[t],g=s[i]>d?s[i]/d:d/s[i],u=d-r,x=(this.opts.state.dims.axisYLines.h-e-a)/c,v=(this.opts.state.dims.axisYLines.h-e-a)/u;return(m>1.05||g>1.05||this.forceUpdate)&&(h=!0),{needAnimation:h=this.items[0]&&h&&!this.noAnimation&&!this.animationInProgress,y1:r,y2:d,yRealStep:l,yRealStart:p,yScaleCur:x,yScaleEnd:v}},updateAxisState:function(i,s,e,a,h,o){var n,r=this.opts,d=(r.settings,r.settings.dpi,r.state),l=(r.settings.PADD[0],r.settings.PADD[2]),p=(r.settings.PADD[3],r.settings.PADD[1],r.animator),c=Math.floor(r.settings.Y_AXIS_RANGE),m=!1,g=this.opts.state.dims.axisYLines;a.needAnimation&&(this.animationInProgress=!0);for(var u=0;u<=c;u++){var x=a.yRealStart+Math.round(a.yRealStep*u),v=h.yRealStart+Math.round(h.yRealStep*u),f=o.yRealStart+Math.round(o.yRealStep*u),y=t.TUtils.getFormatter("yTickFormatter",r.data,d.zoomMorph),M=y(v,h.yRealStep),T=y(Math.max(f,0),h.yRealStep,!0);if(a.needAnimation){var b=g.t+g.h-l-(x-a.y1)*a.yScaleEnd,_=g.t+g.h-l-(this.items[u][e]-a.y1)*a.yScaleEnd,w=g.t+g.h-l-(x-d[i])*a.yScaleCur,D=g.t+g.h-l-(x-a.y1)*a.yScaleEnd;Math.abs(_-D)<1?this.items[u]={numLeft:v,strLeft:M,numRight:f,strRight:T,y:D}:(m=!0,this.uuid++,(n={animated:!0,strLeft:this.items[u].strLeft,strRight:this.items[u].strRight,oProp:"oyt_"+this.uuid,yProp:"yyt_"+this.uuid,state:{id:"t_"+this.uuid}}).state[n.oProp]=1,n.state[n.yProp]=b,this.items[n.state.id]=n,p.add([{prop:n.oProp,state:n.state,end:0,duration:this.noAnimation?0:200,tween:"linear",group:{top:!0}},{prop:n.yProp,state:n.state,end:_,duration:this.noAnimation?0:this.forceUpdate?333:500,fixed:!this.forceUpdate,tween:this.forceUpdate?null:"exp",speed:.18,group:{top:!0},cbEnd:this.deleteItem}]),delete this.items[u],this.uuid++,(n={animated:!0,strLeft:M,strRight:T,oProp:"oy_"+u,yProp:"yy_"+u,state:{id:u,numLeft:v,strLeft:M,numRight:f,strRight:T}}).state[n.oProp]=0,n.state[n.yProp]=w,this.items[n.state.id]=n,p.add([{prop:n.oProp,state:n.state,end:1,duration:this.noAnimation?0:200,tween:"linear",group:{top:!0}},{prop:n.yProp,state:n.state,end:D,duration:this.noAnimation?0:this.forceUpdate?333:500,fixed:!this.forceUpdate,tween:this.forceUpdate?null:"exp",speed:.18,group:{top:!0},cbEnd:function(t){this.items[t.id]={numLeft:t.numLeft,strLeft:t.strLeft,numRight:t.numRight,strRight:t.strRight,y:t["yy_"+t.id]},clearTimeout(this.animationEndTimeout),this.animationEndTimeout=setTimeout(function(){this.animationInProgress=!1}.bind(this),30)}.bind(this)}]))}else this.items[u]&&this.items[u].animated?(this.items[u].numLeft=v,this.items[u].strLeft=M,this.items[u].numRight=f,this.items[u].strRight=T,this.items[u].state.numLeft=v,this.items[u].state.strLeft=M,this.items[u].state.numRight=f,this.items[u].state.strRight=T):this.items[u]={numLeft:v,strLeft:M,numRight:f,strRight:T,y:g.t+g.h-l-(x-a.y1)*a.yScaleEnd}}a.needAnimation&&!m&&(this.animationInProgress=!1),this.forceUpdate=!1},renderState:function(t){var i,s,e,a,h=this.opts.settings.dpi,o=this.opts.state.dims.axisYLeft,n=this.opts.state.dims.axisYRight,r=this.opts.state.dims.axisYLines,d=this.opts.data.ys;for(i in this.ctx.font=11*h+"px "+this.opts.settings.FONTS,this.ctx.strokeStyle=this.isDarkMode?"rgba(255, 255, 255, 0.1)":"rgba(24, 45, 59, 0.1)",this.ctx.lineWidth=1*h,this.ctx.lineCap="square",this.ctx.lineJoin="square",this.items)(a=this.items[i]).animated?(e=a.state[a.yProp],s=a.state[a.oProp]):(e=a.y,s=1),e-6>=0&&e-16<=o.h&&(this.ctx.globalAlpha=s*(this.opts.pairY?this.opts.state.o_0:1)*t,this.ctx.textAlign="left",this.opts.pairY?this.ctx.fillStyle=this.isDarkMode?d[0].colors_n[1]:d[0].colors_d[1]:this.ctx.fillStyle=this.isDarkMode?this.opts.data.axis_n.y:this.opts.data.axis_d.y,this.ctx.fillText(a.strLeft,o.l*h,(e-7)*h),this.opts.pairY&&(this.ctx.globalAlpha=s*this.opts.state.o_1*t,this.ctx.textAlign="right",this.ctx.fillStyle=this.isDarkMode?d[1].colors_n[1]:d[1].colors_d[1],this.ctx.fillText(a.strRight,(n.l+n.w)*h,(e-7)*h))),(e=(e<<0)-.5)>=0&&e<=o.h&&(this.ctx.beginPath(),this.ctx.globalAlpha=s*t,this.ctx.moveTo(r.l*h,e*h),this.ctx.lineTo((r.l+r.w)*h,e*h),this.ctx.stroke());this.ctx.globalAlpha=1}},t.TAxisY=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,this.filteredX1=[],this.filteredX2=[],this.filteredJ=[],this.prevY=[],this.$canvas=document.createElement("canvas"),this.ctx=this.$canvas.getContext("2d",{alpha:!1})};i.prototype={onResize:function(){var t=this.opts.settings.dpi,i=this.opts.additional.mini?this.opts.state.dims.mini:this.opts.state.dims.graph;this.$canvas.width=i.w*t,this.$canvas.height=i.h*t,this.cached=""},setDarkMode:function(t){this.isDarkMode=t},render:function(){var i,s,e,a,h,o,n,r,d,l,p,c,m,g,u=this.opts,x=u.data.ys,v=u.state,f=u.additional.mini,y=f?v.xg1:v.x1,M=f?v.xg2:v.x2,T=u.settings,b=(this.w,this.h,T["PADD"+(f?"_MINI_BAR":"")][0]),_=T["PADD"+(f?"_MINI_BAR":"")][1],w=T["PADD"+(f?"_MINI_BAR":"")][2],D=T["PADD"+(f?"_MINI_BAR":"")][3],S=u.data.x,I=u.settings.dpi,$=this.ctx,L=f?v.dims.mini:v.dims.graph,A=v.zoomMode,E=v.detailInd1,P=v.detailInd2,R=null==v.zoomMorph?0:v.zoomMorph,k=this.filteredX1,C=this.filteredX2,z=this.filteredJ,F=this.prevY,Y=x.length,X=[L.w,L.h,f?v.xg1:v.x1,f?v.xg2:v.x2,this.isDarkMode,A];for(f||(X.push(v.y1),X.push(v.y2)),i=0;ithis.opts.state.xg2Ind&&(g=this.opts.state.xg2Ind-1)),d=D*I-y*(n*=I),p=(L.h-w)*I;var H=this.opts.data.mainPeriodLen*n,U=this.opts.data.detailPeriodLen*n;if(X!=this.cached){var N;$.fillStyle=this.isDarkMode?"#242f3e":"#fff",$.fillRect(0,0,L.w*I,L.h*I);var B=0;for(s=m;s<=g;s++){N=A&&s>=E&&s<=P?U:H;var G=Math.round(S[s]*n+d),O=Math.round(S[s]*n+d+N);O-G>0&&(k[B]=G,C[B]=O,z[B]=s,F[B]=0,B++)}for(i=0;i0){e=x[i].y,c=x[i].yFrom,h=f?v.y1m:v.y1,o=f?v.y2m:v.y2,r=I*(L.h-b-w)/(o-h),l=(L.h-w)*I+h*r;var W,j=a*r;if($.fillStyle=this.isDarkMode?x[i].colors_n[0]:x[i].colors_d[0],$.globalAlpha=.9*v["f_"+i]+.1,$.beginPath(),$.moveTo(Math.round(S[g]*n+d+(1==R?U:H)),Math.round(p)),i>0)for(s=B-1;s>=0;s--){var V=p-F[s];$.lineTo(C[s],Math.round(V)),$.lineTo(k[s],Math.round(V))}else $.lineTo(Math.round(S[m]*n+d),Math.round(p));for(s=0;s=E&&Z<=P?c[Z]+R*(e[Z]-c[Z]):e[Z]+R*(e[E]-e[Z]):e[Z])||0)*j);F[s]+=q,$.lineTo(k[s],Math.round(p-F[s])),$.lineTo(C[s],Math.round(p-F[s]))}$.closePath(),$.fill()}$.globalAlpha=1,this.opts.ctx.drawImage(this.$canvas,L.l*I,L.t*I)}if(v.barInd>-1&&!f){this.opts.ctx.fillStyle=this.isDarkMode?"rgba(36, 47, 62, 0.5)":"rgba(255, 255, 255, 0.5)",this.opts.ctx.globalAlpha=v.barO,this.opts.ctx.fillRect(0,0,L.w*I,L.h*I);var J=0;for(i=0;i0){e=x[i].y,c=x[i].yFrom,h=v.y1,o=v.y2,r=I*(L.h-b-w)/(o-h),l=(L.h-w)*I+h*r;j=a*r;this.opts.ctx.fillStyle=this.isDarkMode?x[i].colors_n[0]:x[i].colors_d[0],this.opts.ctx.globalAlpha=.9*v["f_"+i]+.1,A?v.barInd>=E&&v.barInd<=P?(W=c[v.barInd]+R*(e[v.barInd]-c[v.barInd]),N=U):(N=H,W=e[v.barInd]+R*(e[E]-e[v.barInd])):(W=e[v.barInd],N=H);var K=p-(l-(W=W||0)*j)+J;this.opts.ctx.fillRect(Math.round(S[v.barInd]*n+d),Math.round(p-J+L.t*I),Math.max(Math.round(N),1),Math.round(J)-Math.round(K)),J=K}$.globalAlpha=1}this.cached=X}}},t.TBars=i}(),function(){var t=window.Graph.units,s=function(i){this.state={},this.state.masterVisibility=1,this.state.slaveVisibility=0,this.specialZoomTransition=void 0,this.darkMode=!!document.documentElement.classList.contains("dark");var s=(!!window.ActiveXObject&&+/msie\s(\d+)/i.exec(navigator.userAgent)[1]||NaN)<11,e=-1!=navigator.userAgent.indexOf("Trident/")&&(-1!=navigator.userAgent.indexOf("rv:")||-1!=navigator.appName.indexOf("Netscape"));this.settings={isIE:s||e,isEdge:/Edge\/\d./i.test(navigator.userAgent),dpi:Math.min(window.devicePixelRatio||1,2),Y_AXIS_RANGE:5.3,PADD:[20,16,20,16],PADD_MINI:[2,0,2,0],PADD_MINI_BAR:[0,0,0,0],PADD_MINI_AREA:[0,0,0,0],Y_LABELS_WIDTH:50,X_LABELS_HEIGHT:12,DATES_HEIGHT:18,DATES_WIDTH:300,MINI_GRAPH_HEIGHT:40,MINI_GRAPH_TOP:14,MINI_GRAPH_BOTTOM:2,FADE_HEIGHT:16,PIE_RADIUS:130,FONTS:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif'},this.data={caption:i.data.title,detailsFunc:i.data.x_on_zoom,hasDetail:!!i.data.x_on_zoom,slave:i.slave,yTickFormatter:i.data.yTickFormatter,yTooltipFormatter:i.data.yTooltipFormatter,xTickFormatter:i.data.xTickFormatter,xTooltipFormatter:i.data.xTooltipFormatter,xRangeFormatter:i.data.xRangeFormatter,strokeWidth:i.data.strokeWidth||"auto",hidden:i.data.hidden||[],tooltipOnHover:!!i.data.tooltipOnHover,sideLegend:i.data.sideLegend||!1,pieZoomRange:i.data.pieZoomRange||6048e5,pieLabelsPercentages:{outboard:i.data.pieLabelsPercentages&&null!=i.data.pieLabelsPercentages.outboard?i.data.pieLabelsPercentages.outboard:5,hoverOnly:i.data.pieLabelsPercentages&&null!=i.data.pieLabelsPercentages.hoverOnly?i.data.pieLabelsPercentages.hoverOnly:2},subchart:{show:!i.data.subchart||null==i.data.subchart.show||i.data.subchart.show,defaultZoom:i.data.subchart&&i.data.subchart.defaultZoom}},i.data.y_scaled&&(this.pairY=!0),this.graphStyle="line";var a=this.settings;i.data.columns.forEach(function(s,e){var a=s.shift(),h=i.data.types[a];if("x"===h){this.data.x=s,this.state.xCount=s.length,this.state.x1=s[.75*s.length<<0],this.state.x2=s[s.length-1],this.state.xg1=s[0],this.state.xg2=s[s.length-1],this.state.xg1Ind=0,this.state.xg2Ind=s.length-1,this.state.xMainMin=s[0],this.state.xMainMax=s[this.state.xg2Ind],this.state.xgMin=s[0],this.state.xgMax=s[this.state.xg2Ind];var o=this.getDefaultZoom({x1:this.state.x1,x2:this.state.x2,xg1:this.state.xg1,xg2:this.state.xg2,default:this.data.subchart.defaultZoom});this.state.x1=o.x1,this.state.x2=o.x2,this.data.mainPeriodLen=this.data.x[1]-this.data.x[0],this.data.detailPeriodLen=this.data.mainPeriodLen,this.data.dates=[],this.data.datesShort=[],this.data.datesRange=[];var n=t.TUtils.getFormatter("xTooltipFormatter",this.data,0),r=t.TUtils.getFormatter("xTickFormatter",this.data,0),d=t.TUtils.getFormatter("xRangeFormatter",this.data,0),l=0;s.forEach(function(t,i){this.data.dates[i]=n(t,!1),this.data.datesShort[i]=r(t,!1),this.data.datesRange[i]=d(t,!1),this.data.datesShort[i].length>l&&(l=this.data.datesShort[i].length)}.bind(this)),this.data.maxXTickLength=l}if("x"!==h){this.data.ys=this.data.ys||[],this.data.yIds=this.data.yIds||{};var p=i.data.colors[a];this.data.ys.push({colors_d:[p,p,p],colors_n:[p,p,p],label:i.data.names[a],y:s,tp:h,id:a}),"line"==h||"step"==h?(this.data.axis_d={x:"#8E8E93",y:"#8E8E93"},this.data.axis_n={x:"rgba(163,177,194,0.6)",y:"rgba(163,177,194,0.6)"}):(this.data.axis_d={x:"rgba(37,37,41,0.5)",y:"rgba(37,37,41,0.5)"},this.data.axis_n={x:"rgba(163,177,194,0.6)",y:"rgba(236,242,248,0.5)"});var c=this.data.ys.length-1,m=-1==this.data.hidden.indexOf(a);this.data.yIds[a]=c,this.state["e_"+c]=m,this.state["o_"+c]=m?1:0,this.state["om_"+c]=m?1:0,this.state["pieInd_"+c]=0,this.state["f_"+c]=1,this.graphStyle=h}}.bind(this)),this.state.activeColumnsCount=this.data.ys.length,this.updateSpeed(),"area"==this.graphStyle&&(a.Y_AXIS_RANGE=4.06,this.data.hasDetail=!0);var h=this.reduceGlobalRange({});h.isReduced&&(this.state.x1=h.x1,this.state.x2=h.x2,this.state.xg1=h.xg1,this.state.xg2=h.xg2,this.state.xg1Ind=h.xg1Ind,this.state.xg2Ind=h.xg2Ind),this.onResize=this.onResize.bind(this),this.onSwitcherChange=this.onSwitcherChange.bind(this),this.onSwitcherEnter=this.onSwitcherEnter.bind(this),this.onSwitcherLeave=this.onSwitcherLeave.bind(this),this.onHandleMove=this.onHandleMove.bind(this),this.toggleZoom=this.toggleZoom.bind(this),this.createDOM(i.container),window.addEventListener("resize",this.onResize),document.addEventListener("darkmode",function(t){this.setDarkMode(!this.darkMode)}.bind(this),!1),document.addEventListener("chart-hide-tips",function(t){t.detail.except!=this&&this.tip.toggle(!1)}.bind(this),!1),this.opts=i,this.onResize(),this.darkMode&&this.setDarkMode(this.darkMode),window.matchMedia("(-webkit-min-device-pixel-ratio: 1), (min-resolution: 96dpi)").addListener(this.onResize),window.matchMedia("(-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi)").addListener(this.onResize),window.matchMedia("(-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi)").addListener(this.onResize),window.matchMedia("(-webkit-min-device-pixel-ratio: 3), (min-resolution: 288dpi)").addListener(this.onResize)};s.prototype={reduceGlobalRange:function(s){var e=null==s.x1?this.state.x1:s.x1,a=null==s.x2?this.state.x2:s.x2,h=null==s.xg1?this.state.xg1:s.xg1,o=null==s.xg2?this.state.xg2:s.xg2,n=s.useSaved?this.data.saved.x:this.data.x,r=Math.floor(t.TUtils.getXIndex(n,this.state.xgMin)),d=Math.ceil(t.TUtils.getXIndex(n,this.state.xgMax)),l=d,p=r,c=this.state.zoomMode?"bar"==this.graphStyle||"step"==this.graphStyle?1:2:0;if("area"==this.graphStyle&&(c=0),this.data.ys.forEach(function(t,e){var a=s.useSaved?this.data.saved.y[e]:t.y;if(this.state["e_"+e])for(i=r;i<=d-c;i++)v=a[i],null!=v&&(l=Math.min(l,i),p=Math.max(p,i))}.bind(this)),p+c==d&&(p=d-Math.max(c-1,0)),l>=p)return{isReduced:!1};var m=n[l],g=n[p];return h==m&&o==g?{isReduced:!1}:(a>g?(e=g-(a-e),a=g,eg&&(a=g)),{isReduced:!0,x1:e,x2:a,xg1:m,xg2:g,xg1Ind:l,xg2Ind:p})},getDefaultZoom:function(t){if(!t.default)return{x1:t.x1,x2:t.x2};var i={};return i.x1=t.default[0],i.x2=t.default[1],i.x1=Math.max(i.x1,t.xg1),i.x2=Math.min(i.x2,t.xg2),i.x1>=i.x2&&(i.x1=t.xg1,i.x2=t.xg2),i},updateSpeed:function(t){var i=this.state.activeColumnsCount*this.state.xCount*Math.pow((this.state.x2-this.state.x1)/(this.state.xMainMax-this.state.xMainMin),.5),s=this.state.deviceSpeed*i/16.66<<0,e=Math.max(1-.25*s,0);return e=Math.pow(e,.85),null==this.state.deviceSpeed&&(t=1),t=1,this.state.speed=null==t?e:t,this.state.speed},getYMinMax:function(i,s,e,a,h){if("area"==this.graphStyle)return{min:0,max:102};var o,n,r,d,l,p,c=this.state.dims?this.state.dims.graph.w:this.getGraphWidth(this.data.sideLegend).width,m=Number.MAX_VALUE,g=-Number.MAX_VALUE,u=(s-i)/c,x=t.TUtils.getXIndex(h?this.data.saved.x:this.data.x,i-u*this.settings.PADD[3]),v=t.TUtils.getXIndex(h?this.data.saved.x:this.data.x,s+u*this.settings.PADD[1]),f=[],y=[],M=this.settings,T=this.state;!h&&this.state.zoomMode?(x=Math.max(x,this.state.detailInd1),v=Math.min(v,this.state.detailInd2)):(x=Math.max(x,0),v=Math.min(v,this.data.x.length-1));var b=Math.floor(x),_=Math.ceil(x),w=Math.floor(v),D=Math.ceil(v);if("line"!=this.graphStyle&&"step"!=this.graphStyle||this.data.ys.forEach(function(t,i){var s=h?this.data.saved.y[i]:t.y,e="step"==this.graphStyle?b:_,a="step"==this.graphStyle?D:w;if(T["e_"+i]||0==i&&this.pairY){for(o=e;o<=a;o++)void 0!==(n=s[o])&&(ng&&(g=n));"line"==this.graphStyle&&(void 0!==s[b]&&void 0!==s[_]&&((r=s[b]+(x-b)*(s[_]-s[b]))g&&(g=r)),void 0!==s[w]&&void 0!==s[D]&&((d=s[w]+(v-w)*(s[D]-s[w]))g&&(g=d)))}if(this.pairY){var l=L(m,g,i,p);f[i]=l.min,y[i]=l.max,m=Number.MAX_VALUE,g=-Number.MAX_VALUE,p=l.range}}.bind(this)),"bar"==this.graphStyle){var S=[];for(l=0;lg&&(g=yCur)}m=0}if(this.pairY)return isNaN(f[0])&&(f[0]=f[1]),isNaN(f[1])&&(f[1]=f[0]),isNaN(y[0])&&(y[0]=y[1]),isNaN(y[1])&&(y[1]=y[0]),{min:f,max:y};var $=L(m,g);return{min:$.min,max:$.max};function L(i,s,h,o){if(i==Number.MAX_VALUE)e?null==h?(i=T.y1m,s=T.y2m):(i=T["y1m_"+h],s=T["y2m_"+h]):null==h?(i=T.y1,s=T.y2):(i=T["y1_"+h],s=T["y2_"+h]);else if("bar"==this.graphStyle&&(i=0),i=Math.floor(i),s=Math.ceil(s),a){var n=t.TUtils.roundRange(i,s,M.Y_AXIS_RANGE,o);i=n.yMin,s=n.yMax}return{min:i,max:s,range:n}}},setDarkMode:function(t){this.darkMode=t,this.graph.setDarkMode(t),this.axisY.setDarkMode(t),this.fade.setDarkMode(t),this.axisX.setDarkMode(t),this.mini.setDarkMode(t),this.handle.setDarkMode(t),this.tip.setDarkMode(t),this.switchers.setDarkMode(t),this.composer.setDarkMode(t)},getGraphWidth:function(t){var i=this.$el.getBoundingClientRect();if(t){var s=this.$switchers.getBoundingClientRect();return i.width-s.width>=500?{hasSpaceForLegend:!0,width:Math.max(i.width-s.width,1)}:{hasSpaceForLegend:!1,width:i.width}}return{width:i.width}},onResize:function(){var t=Math.min(window.devicePixelRatio||1,2);if(this.ww!=window.innerWidth||t!=this.settings.dpi){if(this.settings.dpi=t,this.ww=window.innerWidth,this.data.sideLegend){this.$switchers.classList.remove("tchart--switchers__no-space");var i=this.getGraphWidth(!0);i.hasSpaceForLegend?this.$graph.style.width=i.width+"px":(this.$switchers.classList.add("tchart--switchers__no-space"),this.$graph.style.width=i.width+"px")}var s=this.$graph.getBoundingClientRect(),e=this.settings,a=s.height-e.DATES_HEIGHT-e.MINI_GRAPH_HEIGHT-e.MINI_GRAPH_TOP-e.MINI_GRAPH_BOTTOM;this.state.dims={composer:{w:s.width,h:s.height,l:0,t:0},graph:{w:s.width,h:a,l:0,t:e.DATES_HEIGHT},axisYLeft:{w:e.Y_LABELS_WIDTH,h:a,l:e.PADD[3],t:e.DATES_HEIGHT},axisYRight:{w:e.Y_LABELS_WIDTH,h:a,l:s.width-e.PADD[1]-e.Y_LABELS_WIDTH,t:e.DATES_HEIGHT},axisYLines:{w:s.width-e.PADD[1]-e.PADD[3],h:a,l:e.PADD[3],t:e.DATES_HEIGHT},fadeTop:{w:s.width,h:e.FADE_HEIGHT,l:0,t:e.DATES_HEIGHT},fadeBottom:{w:s.width,h:e.FADE_HEIGHT,l:0,t:e.DATES_HEIGHT+a-e.FADE_HEIGHT},axisX:{w:s.width,h:e.X_LABELS_HEIGHT,l:0,t:e.DATES_HEIGHT+a-e.X_LABELS_HEIGHT},dates:{w:e.DATES_WIDTH,h:e.DATES_HEIGHT,l:s.width-e.DATES_WIDTH-e.PADD[1],t:0},mini:{w:s.width-e.PADD[1]-e.PADD[3],h:e.MINI_GRAPH_HEIGHT,l:e.PADD[3],t:e.DATES_HEIGHT+a+e.MINI_GRAPH_TOP},handle:{w:s.width-e.PADD[1]-e.PADD[3],h:e.MINI_GRAPH_HEIGHT+2,l:e.PADD[3],t:e.DATES_HEIGHT+a+e.MINI_GRAPH_TOP-1},tip:{w:s.width,h:a,l:0,t:e.DATES_HEIGHT}},this.graph.onResize(),this.axisY.onResize(),this.fade.onResize(),this.axisX.onResize(),this.mini.onResize(),this.handle.onResize(),this.tip.onResize(),this.composer.onResize()}},createDOM:function(i){var s,e,a,h=this.settings;this.$el=document.createElement("div"),this.$el.className="tchart",this.data.subchart.show||this.$el.classList.add("tchart__no-subchart"),this.data.slave&&this.$el.classList.add("tchart__slave"),this.$h1=document.createElement("h1"),this.$h1.className="tchart--header",this.$h1.textContent=this.data.caption,this.$el.appendChild(this.$h1),this.$zoom=document.createElement("div"),this.$zoom.className="tchart--zoom",this.$el.appendChild(this.$zoom);var o=document.createElement("div");this.$zoom.appendChild(o);var n=document.createElement("span");if(n.textContent="Zoom Out",this.$zoom.appendChild(n),this.$zoom.addEventListener("click",function(){this.toggleZoom(!1)}.bind(this)),this.$graph=document.createElement("div"),this.$graph.className="tchart--graph",this.$el.appendChild(this.$graph),this.$switchers=document.createElement("div"),this.$switchers.className="tchart--switchers",this.data.sideLegend&&this.$switchers.classList.add("tchart--switchers__side-legend"),this.$el.appendChild(this.$switchers),i.appendChild(this.$el),s=this.getYMinMax(this.state.x1,this.state.x2,!1,!0),e=this.getYMinMax(this.state.xg1,this.state.xg2,!0),this.pairY)for(a=0;ag&&(g=this.data.datesShort[n].length);this.data.maxXTickLength=g,this.data.subchart=e.subchart,this.data.hidden=e.hidden;var u=this.getDefaultZoom({x1:d,x2:l,xg1:d,xg2:l,default:this.data.subchart.defaultZoom});this.state.x1=u.x1,this.state.x2=u.x2,this.state.xCount=this.data.x.length,this.state.xg1=d,this.state.xg2=l,this.state.xg1Ind=0,this.state.xg2Ind=this.data.x.length-1,this.state.xMainMin=d,this.state.xMainMax=l,this.state.xgMin=d,this.state.xgMax=l;var x=this.reduceGlobalRange({});x.isReduced&&(this.state.x1=x.x1,this.state.x2=x.x2,this.state.xg1=x.xg1,this.state.xg2=x.xg2,this.state.xg1Ind=x.xg1Ind,this.state.xg2Ind=x.xg2Ind);var v=this.getYMinMax(this.state.x1,this.state.x2,!1,!0),f=this.getYMinMax(d,l,!0);this.state.y1=v.min,this.state.y2=v.max,this.state.y1m=f.min,this.state.y2m=f.max}else this.switchers.switchers.forEach(function(t,i){t.classList.remove("tchart--switcher__visible")});setTimeout(function(){i||(this.state.zoomModeSlave=!1)}.bind(this),470),this.state.slaveVisibility=i?0:1,h.push({prop:"slaveVisibility",state:this.state,end:i?1:0,duration:450,group:{top:!0,bottom:!0}}),this.animator.add(h)}},toggleZoomSpecial:function(t,i,s){var e=[];if(this.state.zoomModeSpecial!=t){var a=this.updateSpeed();if(t){var h=(this.state.x2-this.state.x1)/(this.state.dims.graph.w-this.settings.PADD[3]-this.settings.PADD[1]),o=this.settings.PADD[3]*h,n=this.settings.PADD[1]*h;this.state.zoomSpecialOrigin=(i-this.state.x1+o)/(this.state.x2-this.state.x1+o+n),this.state.zoomModeSpecial=!0,this.$h1.classList.add("tchart--header__hidden"),this.$zoom.classList.add("tchart--zoom__visible"),this.switchers.switchers.forEach(function(t,i){t.classList.remove("tchart--switcher__visible")}),this.slaveChart.toggleSlave(!0,this.state.zoomSpecialOrigin,s,a)}else this.$h1.classList.remove("tchart--header__hidden"),this.$zoom.classList.remove("tchart--zoom__visible"),this.switchers.switchers.forEach(function(t,i){t.classList.add("tchart--switcher__visible")}),this.slaveChart.toggleSlave(!1,this.state.zoomSpecialOrigin,null,a);document.body.style.pointerEvents="none",setTimeout(function(){t||(this.state.zoomModeSpecial=!1),document.body.style.pointerEvents=""}.bind(this),470),this.state.masterVisibility=t?1:0,e.push({prop:"masterVisibility",state:this.state,end:t?0:1,duration:450,group:{top:!0,bottom:!0}}),this.animator.add(e)}},toggleZoom:function(i,s,e){if(e&&null==this.specialZoomTransition&&(e.columns.length!=this.data.ys.length+1&&(this.specialZoomTransition=!0),this.specialZoomTransition||e.columns.forEach(function(t,i){var s=t[0],a=e.types[s],h=e.names[s];if(null!=(i=this.data.yIds[s])){var o=this.data.ys[i].tp,n=this.data.ys[i].label;o==a&&n==h||(this.specialZoomTransition=!0)}else"x"!==s&&(this.specialZoomTransition=!0)}.bind(this)),null==this.specialZoomTransition&&(this.specialZoomTransition=!1)),this.specialZoomTransition&&(this.data.master=!0,this.$el.classList.add("tchart__master"),!this.slaveChart)){var a=JSON.parse(JSON.stringify(e));a.yTickFormatter=e.yTickFormatter,a.yTooltipFormatter=e.yTooltipFormatter,a.xTickFormatter=e.xTickFormatter,a.xTooltipFormatter=e.xTooltipFormatter,a.xRangeFormatter=e.xRangeFormatter,a.sideLegend=this.data.sideLegend,this.slaveChart=new t.TChart({container:this.opts.container,slave:!0,data:a}),this.slaveChart.setDarkMode(this.darkMode)}if(e&&!e.details&&(e.details={y:[],names:[]},e.columns.forEach(function(t,i){var s=t.shift(),a=e.types[s],h=e.names[s];"x"===a?e.details.x=t:this.specialZoomTransition?(e.details.y.push(t),e.details.names.push(h)):e.details.y[this.data.yIds[s]]=t}.bind(this))),e&&(e.subchart={show:!e.subchart||null==e.subchart.show||e.subchart.show,defaultZoom:e.subchart&&e.subchart.defaultZoom},e.details.subchart=e.subchart,e.details.hidden=e.hidden||[]),this.specialZoomTransition)this.toggleZoomSpecial(i,s,e&&e.details);else{var h,o,n,r=e&&e.details,d=[];if(this.state.zoomMode!=i){if(i){if(this.state.zoomMode=!0,this.state.zoomDir=1,this.$h1.classList.add("tchart--header__hidden"),this.$zoom.classList.add("tchart--zoom__visible"),this.zoomEnterSpeed=this.updateSpeed(),e&&(this.data.details={yTickFormatter:e.yTickFormatter,yTooltipFormatter:e.yTooltipFormatter,xTickFormatter:e.xTickFormatter,xTooltipFormatter:e.xTooltipFormatter,xRangeFormatter:e.xRangeFormatter,subchart:e.subchart,hidden:e.hidden||[]}),!this.hasSavedData){for(this.data.saved={},this.data.saved.x=this.data.x.slice(),this.data.saved.dates=this.data.dates.slice(),this.data.saved.datesShort=this.data.datesShort.slice(),this.data.saved.datesRange=this.data.datesRange.slice(),this.data.saved.y=[],j=0;jthis.data.x[this.data.x.length-1]&&(p=this.data.x[this.data.x.length-1]+c):p>this.data.x[this.data.x.length-1]&&(l=(p=this.data.x[this.data.x.length-1]+c)-x)this.data.x[h]&&h++;var n,r,d,l,p,c,m=a,g=h-("bar"==this.graphStyle||"step"==this.graphStyle?1:0),u=this.data.x.length-1,x=[],v=[],f=[],y=[],M=[],T=[];for(n=0;n$&&($=f[r].length);var L=t.TUtils.getXIndex(this.data.x,x[r]);b[n]=L,_[n]=Math.floor(L),w[n]=Math.ceil(L)}for(this.data.details.maxXTickLength=$,j=0;j0?"visible":"hidden"),i.top){if(a.clearRect(s.dates.l*h,s.dates.t*h,s.dates.w*h,s.dates.h*h),("line"==this.opts.graphStyle||"step"==this.opts.graphStyle||"area"==this.opts.graphStyle&&r>0||this.opts.data.slave&&e.slaveVisibility<1||this.opts.data.master&&e.masterVisibility<1)&&(l?a.clearRect(s.graph.l*h,(s.graph.t-18)*h,s.graph.w*h,(s.graph.h+30)*h):a.clearRect(s.graph.l*h,s.graph.t*h,s.graph.w*h,s.graph.h*h)),("area"==this.opts.graphStyle&&0==r||"bar"==this.opts.graphStyle)&&(a.clearRect(s.graph.l*h,s.graph.t*h,s.graph.w*h,(o.PADD[0]+4)*h),a.clearRect(s.graph.l*h,(s.graph.t+n[0])*h,n[3]*h,(s.graph.h-n[0]-n[2])*h),a.clearRect(s.graph.l*h,(s.graph.t+s.graph.h-n[2])*h,s.graph.w*h,n[2]*h),a.clearRect((s.graph.l+s.graph.w-n[1]-1)*h,(s.graph.t+n[0])*h,(n[1]+1)*h,(s.graph.h-n[0]-n[2])*h)),d||l||(a.save(),a.beginPath(),a.rect(s.graph.l*h,s.graph.t*h,s.graph.w*h,s.graph.h*h),a.clip()),this.opts.data.master&&e.masterVisibility<1){a.save();var p=5*(1-e.masterVisibility)+1;a.translate(s.graph.w*e.zoomSpecialOrigin*(1-p),0),a.scale(p,1)}if(this.opts.data.slave&&e.slaveVisibility<1){a.save();p=e.slaveVisibility;a.translate(s.graph.w*e.zoomSpecialOrigin*(1-p),0),a.scale(p,1)}var c=1;if("area"==this.opts.graphStyle&&e.zoomMode&&(c=1-r),d){a.save();var m=o.PIE_RADIUS,g=s.graph.w+r*(2*m-s.graph.w),u=s.graph.h-42+r*(2*m-s.graph.h+42);t.TUtils.drawRoundedRect2(a,h,g,u,(s.graph.w-g)/2+s.graph.l,(s.graph.h-42-u)/2+s.graph.t+23,r*m),a.clip()}this.opts.chart.graph.render(),d&&a.restore(),this.opts.data.master&&e.masterVisibility<1&&a.restore(),this.opts.data.slave&&e.slaveVisibility<1&&a.restore(),this.opts.chart.axisY.render(c),this.opts.chart.fade.render(),d||l||a.restore(),this.opts.chart.axisX.render(c)}if(i.bottom){a.clearRect(s.graph.l*h,(s.handle.t-1)*h,s.graph.w*h,(s.handle.h+2)*h);var x=this.opts.data.subchart.show,v=!this.opts.data.master&&!this.opts.data.slave&&this.opts.data.details&&this.opts.data.subchart.show!=this.opts.data.details.subchart.show;v&&(x=x?r<1:r>0),x&&(a.save(),t.TUtils.drawRoundedRect(a,h,s.mini.w,s.mini.h,s.mini.l,s.mini.t,7),a.clip(),this.opts.chart.mini.render(),a.restore(),this.opts.chart.handle.render()),v&&r>0&&r<1&&(a.fillStyle=this.isDarkMode?"#242f3e":"#fff",a.globalAlpha=this.opts.data.subchart.show?r:1-r,a.fillRect(s.graph.l*h,(s.handle.t-1)*h,s.graph.w*h,(s.handle.h+2)*h),a.globalAlpha=1)}}},t.TComposer=i}(),function(){var t=window.Graph.units,i=function(i){this.opts=i,this.onDragStart=this.onDragStart.bind(this),this.onDragMove=this.onDragMove.bind(this),this.onDragEnd=this.onDragEnd.bind(this),this.isTouch=t.TUtils.isTouchDevice(),this.skipMoveEnd=!0;var s=i.useElForMove?i.$el:window;i.$el.addEventListener(this.isTouch?"touchstart":"mousedown",this.onDragStart,{passive:!1}),s.addEventListener(this.isTouch?"touchmove":"mousemove",this.onDragMove,{passive:!1}),s.addEventListener(this.isTouch?"touchend":"mouseup",this.onDragEnd,{passive:!1})};i.prototype={onDragStart:function(t){(this.skipMoveEnd=!0,clearTimeout(this.pointerTimeout),this.isTouch&&t.touches.length>1)||(this.scroll=void 0,this.x=this.isTouch?t.touches[0].pageX:t.pageX,this.y=this.isTouch?t.touches[0].pageY:t.pageY,this.dX=0,this.dY=0,this.pageX=this.x,this.pageY=this.y,delete this.prevDx,delete this.prevDy,this.opts.onDragStart({pageX:this.x,pageY:this.y,isTouch:this.isTouch})||(this.skipMoveEnd=!1))},onDragMove:function(t){if(!this.skipMoveEnd&&"v"!=this.scroll){var i=this.isTouch?t.touches[0].pageX:t.pageX,s=this.isTouch?t.touches[0].pageY:t.pageY;this.dX=i-this.x,this.dY=s-this.y,this.pageX=i,this.pageY=s,this.isTouch&&("h"==this.scroll?!this.opts.noPrevent&&t.preventDefault():(Math.abs(this.dX)>5||Math.abs(this.dY)>5)&&(this.scroll=Math.abs(this.dX)>Math.abs(this.dY)?"h":"v")),this.prevDx==this.dX&&this.prevDy==this.dY||(this.opts.onDragMove&&this.opts.onDragMove({canceled:"v"==this.scroll,d:this.dX,pageX:this.pageX,pageY:this.pageY,isTouch:this.isTouch}),this.prevDx=this.dX,this.prevDy=this.dY)}},onDragEnd:function(t){this.skipMoveEnd||(this.skipMoveEnd=!0,this.opts.onDragEnd&&this.opts.onDragEnd({isTouch:this.isTouch,e:t}))}},t.TDrag=i}(),function(){var t=function(t){this.opts=t,this.ctx=t.ctx,"area"!=this.opts.graphStyle&&(this.$fadeTop=document.createElement("canvas"),this.ctxFadeTop=this.$fadeTop.getContext("2d"),"bar"!=this.opts.graphStyle&&(this.$fadeBottom=document.createElement("canvas"),this.ctxFadeBottom=this.$fadeBottom.getContext("2d")))};t.prototype={onResize:function(){var t=this.opts.settings.dpi,i=this.opts.state.dims.fadeTop,s=this.opts.state.dims.fadeBottom;if("area"!=this.opts.graphStyle){var e=this.ctxFadeTop.createLinearGradient(0,0,0,i.h*t);if(this.isDarkMode?(e.addColorStop(0,"rgba(36,47,62,1)"),e.addColorStop(1,"rgba(36,47,62,0)")):(e.addColorStop(0,"rgba(255,255,255,1)"),e.addColorStop(1,"rgba(255,255,255,0)")),this.$fadeTop.width=i.w*t,this.$fadeTop.height=i.h*t,this.ctxFadeTop.fillStyle=e,this.ctxFadeTop.fillRect(0,0,i.w*t,i.h*t),"bar"!=this.opts.graphStyle){var a=this.ctxFadeBottom.createLinearGradient(0,0,0,s.h*t);this.isDarkMode?(a.addColorStop(0,"rgba(36,47,62,0)"),a.addColorStop(1,"rgba(36,47,62,1)")):(a.addColorStop(0,"rgba(255,255,255,0)"),a.addColorStop(1,"rgba(255,255,255,1)")),this.$fadeBottom.width=s.w*t,this.$fadeBottom.height=s.h*t,this.ctxFadeBottom.fillStyle=a,this.ctxFadeBottom.fillRect(0,0,s.w*t,s.h*t)}}},setDarkMode:function(t){this.isDarkMode=t,this.onResize()},render:function(){var t=this.opts.settings.dpi,i=this.opts.state.dims.fadeTop,s=this.opts.state.dims.fadeBottom;this.$fadeTop&&this.ctx.drawImage(this.$fadeTop,i.l*t,i.t*t),this.$fadeBottom&&this.ctx.drawImage(this.$fadeBottom,s.l*t,s.t*t)}},window.Graph.units.TFade=t}(),function(){var t=window.Graph.units,i=function(i){this.opts=i,this.ctx=i.ctx,this.isTouch=t.TUtils.isTouchDevice(),this.$canvas=i.$canvas,this.drag=new t.TDrag({$el:this.$canvas,onDragStart:function(s){this.canvasPos=t.TUtils.getElemPagePos(this.$canvas);var e=s.pageX-this.canvasPos.x,a=s.pageY-this.canvasPos.y;return this._x1=i.state.x1,this._x2=i.state.x2,this.constrainHandleSize(!1),this.tp=this.getTp(e-i.settings.PADD[3],a-(this.opts.state.dims.composer.h-i.settings.MINI_GRAPH_HEIGHT-i.settings.MINI_GRAPH_BOTTOM),s.isTouch),this.firstMove=!0,!this.tp}.bind(this),onDragMove:function(t){this.onDragMove(t.d),this.firstMove=!1}.bind(this),onDragEnd:function(t){}.bind(this)}),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.trackMouse(!0)};i.prototype={getTp:function(t,i,s){var e=this.opts.state.dims.handle,a=this.opts.state,h=this.opts.state.zoomMode;if(i<0||i>e.h)return"";var o=s?.3*e.w:10;s&&o<14&&(o=14),s&&o>30&&(o=30);var n=this.prevX1+(s?a.x1==a.xg1?-5:-15:0),r=n+o,d=this.prevX2+(s?a.x2==a.xg2?5:15:0),l=d-o;return Math.abs(a.x2-a.x1-(h?this.opts.data.mainPeriodLen:this.minRange))<.01&&(a.x2==a.xg2&&(l=d+1),a.x1==a.xg1&&(r=n-1)),t>r&&t=n&&t<=r?"start":t>=l&&t<=d?"end":""},trackMouse:function(t){this.isTouch||(this.$canvas.addEventListener("mousemove",this.onMouseMove),this.$canvas.addEventListener("mouseleave",this.onMouseLeave))},onMouseLeave:function(){this.$canvas.classList.remove("tchart--graph-canvas__handle-pointer"),this.$canvas.classList.remove("tchart--graph-canvas__handle-grab"),this.$canvas.classList.remove("tchart--graph-canvas__handle-col-resize"),delete this.canvasPos},onMouseMove:function(i){this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas);var s=i.pageX-this.canvasPos.x,e=i.pageY-this.canvasPos.y,a=this.getTp(s-this.opts.settings.PADD[3],e-(this.opts.state.dims.composer.h-this.opts.settings.MINI_GRAPH_HEIGHT-this.opts.settings.MINI_GRAPH_BOTTOM),!1),h={"":"",both:this.opts.settings.isIE?"pointer":"grab",start:"col-resize",end:"col-resize"};this.onMouseLeave(),h[a]&&this.$canvas.classList.add("tchart--graph-canvas__handle-"+h[a])},onResize:function(t){this.constrainHandleSize(!0)},setDarkMode:function(t){this.isDarkMode=t},constrainHandleSize:function(t){var i=32/(this.opts.state.dims.handle.w/(this.opts.state.xg2-this.opts.state.xg1)),s=this.opts.state.x1,e=this.opts.state.x2,a=(this.opts.state.xg1,this.opts.state.xg2);this.minRange=i,e-sa&&(s=(e=a)-i),t&&this.opts.additional.cb(s,e,"constraint"))},onDragMove:function(t){var i,s,e=this.opts.state.dims.handle,a=this.tp,h=this.opts.state,o=t/e.w*(h.xg2-h.xg1),n=this._x1,r=this._x2;"both"==a&&(s=r+o,(i=n+o)h.xg2&&(i=h.xg2-(r-n),s=h.xg2)),"start"==a&&(s=h.x2,i=Math.min(Math.max(n+o,h.xg1),s-this.minRange)),"end"==a&&(i=h.x1,s=Math.max(Math.min(r+o,h.xg2),i+this.minRange)),h.x1==i&&h.x2==s||this.opts.additional.cb(i,s,a,this.firstMove)},render:function(){var i=this.opts.state.dims.handle,s=this.opts.settings.dpi,e=this.opts.state,a=1/(e.xg2-e.xg1),h=Math.round((e.x1-e.xg1)*a*i.w),o=Math.round((e.x2-e.xg1)*a*i.w),n=this.ctx;n.fillStyle=this.isDarkMode?"rgba(48, 66, 89, 0.6)":"rgba(226, 238, 249, 0.6)",t.TUtils.drawRoundedRect(n,s,h+4,i.h-2,i.l,i.t+1,[7,0,0,7]),n.fill(),t.TUtils.drawRoundedRect(n,s,i.w-o+4,i.h-2,i.l+o-4,i.t+1,[0,7,7,0]),n.fill(),this.isDarkMode||"line"==this.opts.graphStyle||"step"==this.opts.graphStyle||(n.fillStyle="#fff",t.TUtils.drawRoundedRect(n,s,12,i.h+2,i.l+h-1,i.t-1,[8,0,0,8]),n.fill(),t.TUtils.drawRoundedRect(n,s,12,i.h+2,i.l+o-11,i.t-1,[0,8,8,0]),n.fill()),n.fillStyle=this.isDarkMode?"#56626D":"#C0D1E1",t.TUtils.drawRoundedRect(n,s,10,i.h,i.l+h,i.t,[7,0,0,7]),n.fill(),t.TUtils.drawRoundedRect(n,s,10,i.h,i.l+o-10,i.t,[0,7,7,0]),n.fill(),n.fillRect((i.l+h+10)*s,i.t*s,(o-h-20)*s,s),n.fillRect((i.l+h+10)*s,(i.t+i.h-1)*s,(o-h-20)*s,s),n.strokeStyle="#fff",this.ctx.lineCap="round",this.ctx.lineJoin="round",this.ctx.lineWidth=2*s,n.beginPath(),n.moveTo((i.l+h+5)*s,(i.t+17)*s),n.lineTo((i.l+h+5)*s,(i.t+25)*s),n.moveTo((i.l+o-5)*s,(i.t+17)*s),n.lineTo((i.l+o-5)*s,(i.t+25)*s),n.stroke(),this.prevX1=h,this.prevX2=o}},t.THandle=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,this.$canvas=document.createElement("canvas"),this.ctx=this.$canvas.getContext("2d",{alpha:!0})};i.prototype={onResize:function(){var t=this.opts.settings.dpi,i=this.opts.additional.mini?this.opts.state.dims.mini:this.opts.state.dims.graph;this.$canvas.width=i.w*t,this.$canvas.height=i.h*t,this.cached="",this.ctx.fillStyle=this.isDarkMode?"#242f3e":"#fff",this.ctx.fillRect(0,0,i.w*t,i.h*t)},setDarkMode:function(t){this.isDarkMode=t},render:function(){var i,s,e,a,h,o,n,r,d,l,p,c,m,g,u,x=this.opts,v=x.data.ys,f=x.state,y=x.additional.mini,M=y||x.data.master&&f.masterVisibility<1&&f.masterVisibility>0||x.data.slave&&f.slaveVisibility<1&&f.slaveVisibility>0,T=y?f.xg1:f.x1,b=y?f.xg2:f.x2,_=x.settings,w=_["PADD"+(y?"_MINI":"")][0],D=_["PADD"+(y?"_MINI":"")][1],S=_["PADD"+(y?"_MINI":"")][2],I=_["PADD"+(y?"_MINI":"")][3],$=x.data.x,L=x.settings.dpi,A=M?this.ctx:this.opts.ctx,E=y?f.dims.mini:f.dims.graph,P=f.zoomMode,R=f.detailInd1,k=f.detailInd2,C=null==f.zoomMorph?0:f.zoomMorph,z=v.length,F="step"==x.graphStyle;n=(E.w-D-I)/(b-T+(F?this.opts.data.mainPeriodLen*(1-C):0)),m=Math.floor(t.TUtils.getXIndex($,T-I/n)),g=Math.ceil(t.TUtils.getXIndex($,b+D/n)),n*=L,d=(I+(M?0:E.l))*L-T*n,F&&P&&1==C&&(mthis.opts.state.xg2Ind&&(g=this.opts.state.xg2Ind-1));var Y=this.opts.data.mainPeriodLen*n,X=this.opts.data.detailPeriodLen*n;if(M){var H=[E.w,E.h,y?f.xg1:f.x1,y?f.xg2:f.x2,this.isDarkMode,P];for(y||(H.push(f.y1),H.push(f.y2)),i=0;i5?1:2:x.data.strokeWidth)*L,N=U%2==0?0:.5;for(A.lineWidth=U,A.lineCap=x.additional.mini?"square":"round",A.lineJoin=x.additional.mini?"square":"round",i=0;i0){var B,G;e=v[i].y,c=v[i].yFrom,x.pairY?(h=y?f["y1m_"+i]:f["y1_"+i],o=y?f["y2m_"+i]:f["y2_"+i]):y?p&&a<1?(h=f.y1m_show,o=f.y2m_show):!p&&a<1?(h=f.y1m_hidd,o=f.y2m_hidd):(h=f.y1m,o=f.y2m):(h=f.y1,o=f.y2),r=L*(E.h-w-S)/(o-h),l=(E.h-S+(M?0:E.t))*L+h*r,A.beginPath(),A.strokeStyle=this.isDarkMode?v[i].colors_n[0]:v[i].colors_d[0],A.globalAlpha=a*(.9*f["f_"+i]+.1);var O,W=Number.MAX_VALUE,j=-Number.MAX_VALUE,V=-Number.MAX_VALUE,Z=!1,q=!0;for(s=m;s<=g;s++)P?s>=R&&s<=k?(B=c[s]+C*(e[s]-c[s]),u=X):(B=e[s]+C*(e[R]-e[s]),u=Y):(B=e[s],u=Y),isNaN(B)?q=!0:(G=$[s]*n+d<<0,yc=l-B*r<<0,G>V||F&&s==k+1?(Z&&(O==W?(A.moveTo(V+N,j-N),A.lineTo(V+N,W-N)):(A.moveTo(V+N,W-N),A.lineTo(V+N,j-N),O!=j&&A.moveTo(V+N,O-N)),Z=!1),q&&(A.moveTo(G+N,yc-N),q=!1),W=yc,j=yc,A.lineTo(G+N,yc-N),F&&A.lineTo(($[s]*n+u+d<<0)+N,yc-N)):(W=Math.min(W,yc),j=Math.max(j,yc),Z=!0),V=G,O=yc);Z&&(A.moveTo(V+N,W-N),A.lineTo(V+N,j-N)),A.stroke()}A.globalAlpha=1,M&&this.opts.ctx.drawImage(this.$canvas,E.l*L,E.t*L)}},t.TLines=i}(),function(){var t=window.Graph.units,i=function(i){var s,e;this.opts=i,this.isTouch=t.TUtils.isTouchDevice(),this.enabled=i.data.ys.length,1==this.enabled&&(i.$parent.style.display="none"),this.switchers=i.data.ys.map(function(a,h){var o=document.createElement("div");o.className="tchart--switcher",i.state["e_"+h]?o.classList.toggle("tchart--switcher__active"):this.enabled--,o.setAttribute("data-label",a.label),i.$parent.appendChild(o);var n,r,d,l=document.createElement("span");return l.textContent=a.label,o.appendChild(l),this.isTouch||(o.addEventListener("mouseenter",function(t){i.state["e_"+h]&&i.additional.onEnter(h)}),o.addEventListener("mouseleave",function(t){i.state["e_"+h]&&i.additional.onLeave(h)})),o.addEventListener("click",function(t){if(e)e=!1;else{var a=o.classList.contains("tchart--switcher__active");if(a&&1==this.enabled)return o.classList.add("tchart--switcher__denied"),clearTimeout(s),void(s=setTimeout(function(){o.classList.remove("tchart--switcher__denied")},500));this.isTouch||(a?i.additional.onLeave(h):i.additional.onEnter(h)),i.additional.onClick(!a,h)}}.bind(this)),this.drag=new t.TDrag({$el:o,noPrevent:!0,useElForMove:!0,onDragStart:function(t){n=t.pageX,r=t.pageY,d=setTimeout(function(){e=!0,this.isTouch||i.additional.onEnter(h),i.additional.onLongTap(h)}.bind(this),500)}.bind(this),onDragMove:function(t){(Math.abs(n-t.pageX)>5||Math.abs(r-t.pageY)>5)&&clearTimeout(d)}.bind(this),onDragEnd:function(t){clearTimeout(d)}.bind(this)}),o}.bind(this)),this.updateColors()};i.prototype={onResize:function(){},updateColors:function(){for(var t=this.opts.data.ys,i=0;i1&&(this.allLabel=this.addLabel({label:"All",outside:!0})),"area"==i.graphStyle&&(this.pieLabel=this.addLabel({label:"pie",outside:!0})),this.tooltipOnHover=!this.isTouch&&i.data.tooltipOnHover,"bar"!=i.graphStyle?(this.$line=document.createElement("div"),this.$line.className="tchart--line",i.$parent.appendChild(this.$line),this.$lineFill=document.createElement("div"),this.$line.appendChild(this.$lineFill),"area"!=i.graphStyle&&(this.points=i.data.ys.map(function(t,i){var s=document.createElement("span");return this.$line.appendChild(s),s}.bind(this)))):(i.state.barInd=-1,i.state.barO=0),this.onMouseMove=this.onMouseMove.bind(this),this.onMouseLeave=this.onMouseLeave.bind(this),this.onBodyClick=this.onBodyClick.bind(this),this.onTipClick=this.onTipClick.bind(this),this.tooltipOnHover?(this.$canvas.addEventListener("mousemove",function(i){this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas),this.dx=i.pageX-this.canvasPos.x,this.dy=i.pageY-this.canvasPos.y;var s=this.opts.state.dims.tip;this.tp=this.getTp(this.dx,this.dy-s.t,this.isTouch),this.tp?this.shown?this.render({isMove:!0}):(delete this.prevXInd,this.toggle(!0),this.render({})):this.toggle(!1)}.bind(this)),this.$canvas.addEventListener("mouseleave",function(){delete this.canvasPos,this.toggle(!1)}.bind(this)),this.$canvas.addEventListener("click",function(t){this.shown&&this.onTipClick(t)}.bind(this)),this.$tip.style.pointerEvents="none"):(this.drag=new t.TDrag({$el:this.$canvas,onDragStart:function(i){this.canvasPos=t.TUtils.getElemPagePos(this.$canvas),this.dx=i.pageX-this.canvasPos.x,this.dy=i.pageY-this.canvasPos.y;var s=this.opts.state.dims.tip;return this.tp=this.getTp(this.dx,this.dy-s.t,i.isTouch),delete this.prevXInd,clearTimeout(this.showTimeout),this.showTimeout=setTimeout(function(){this.toggle(!!this.tp),this.tp&&this.render()}.bind(this),this.isTouch?100:30),document.body.removeEventListener("click",this.onBodyClick),!this.tp}.bind(this),onDragMove:function(i){if(i.canceled)return clearTimeout(this.showTimeout),void this.toggle(!1);this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas),this.dx=i.pageX-this.canvasPos.x,this.dy=i.pageY-this.canvasPos.y,this.render({isMove:!0})}.bind(this),onDragEnd:function(t){delete this.canvasPos,this.bodyTimeout=setTimeout(function(){document.body.addEventListener("click",this.onBodyClick)}.bind(this),140)}.bind(this)}),this.$tip.addEventListener("click",this.onTipClick)),this.trackMouse(!0),this.updateColors()};i.prototype={onResize:function(t){var i=this.opts.state.dims.tip;if(this.$line){var s="area"==this.opts.graphStyle?25:16;this.$line.style.top=i.t+"px",this.$line.style.height=i.h+"px",this.$lineFill.style.top=s+"px",this.$lineFill.style.bottom=this.opts.settings.PADD[2]+1+"px"}this.render()},abortDetailCallbacks:function(){this.detailCallbacks&&(this.detailCallbacks.forEach(function(t,i){t.cancelled=!0}),delete this.detailCallbacks)},onTipClick:function(t){if(null!=this.prevXInd&&this.opts.additional.onClick&&this.opts.data.hasDetail&&!this.opts.state.zoomMode&&!this.opts.state.zoomModeSpecial&&(t.stopPropagation(),!this.$tip.classList.contains("tchart--tip__loading"))){var i=this.opts.data.x[this.prevXInd];if(!this.opts.data.detailsFunc)return this.toggle(!1,!0),void this.opts.additional.onClick(!0,i);if(this.$tip.classList.remove("tchart--tip__error"),this.$tip.classList.add("tchart--tip__loading"),this.cache[i])return this.toggle(!1,!0),this.opts.additional.onClick(!0,i,this.cache[i]),void this.$tip.classList.remove("tchart--tip__loading");this.abortDetailCallbacks();var s=this.opts.data.detailsFunc(i),e=this;this.detailCallbacks=this.detailCallbacks||[];var a=function(t){a.cancelled||(e.$tip.classList.remove("tchart--tip__loading"),t&&t.columns?(e.toggle(!1,!0),e.opts.additional.onClick(!0,i,t),e.cache[i]=t):e.$tip.classList.add("tchart--tip__error"))},h=function(t){h.cancelled||(console.log("error:",t),e.$tip.classList.remove("tchart--tip__loading"),e.$tip.classList.add("tchart--tip__error"))};this.detailCallbacks.push(a),this.detailCallbacks.push(h),s.then(a).catch(h)}},updateColors:function(){var t=this.opts.data.ys;this.labels.forEach(function(i,s){this.points&&(this.points[s].style.borderColor=this.isDarkMode?t[s].colors_n[0]:t[s].colors_d[0]),i.$value.style.color=this.isDarkMode?t[s].colors_n[2]:t[s].colors_d[2]}.bind(this)),this.allLabel&&(this.allLabel.$value.style.color=this.isDarkMode?"#fff":"#000"),this.$lineFill&&(this.$lineFill.style.backgroundColor=this.isDarkMode?"rgba(255, 255, 255, 0.1)":"rgba(24, 45, 59, 0.1)")},setDarkMode:function(t){this.isDarkMode=t,this.updateColors()},addLabel:function(t){var i=document.createElement("div");i.className="tchart--tip-row",t.outside?(this.$tip.appendChild(i),i.classList.add("tchart--tip-row__outside")):this.$tipScroller.appendChild(i);var s=document.createElement("span");i.appendChild(s);var e,a=document.createTextNode("");if(a.nodeValue=t.label,s.appendChild(a),"area"==this.opts.graphStyle){var h=document.createElement("p");i.appendChild(h),e=document.createTextNode(""),h.appendChild(e)}var o=document.createElement("div");i.appendChild(o);var n=document.createTextNode("");return o.appendChild(n),{$row:i,$value:o,$valueText:n,$label:s,$labelText:a,$per:h,$perText:e}},getTp:function(t,i,s){if("area"==this.opts.graphStyle&&this.opts.state.zoomMode){var e=(h=this.opts.state.dims.graph).w/2,a=h.h/2;return Math.pow((a-i)*(a-i)+(t-e)*(t-e),.5)<=this.opts.settings.PIE_RADIUS?"graph":""}var h=this.opts.state.dims.tip;return i<0||i>h.h?"":"graph"},trackMouse:function(t,i){this.isTouch||(this.$canvas.addEventListener("mousemove",this.onMouseMove),this.$canvas.addEventListener("mouseleave",this.onMouseLeave))},onMouseLeave:function(){this.$canvas.classList.remove("tchart--graph-canvas__tip-pointer"),delete this.canvasPos},onMouseMove:function(i){this.canvasPos=this.canvasPos||t.TUtils.getElemPagePos(this.$canvas);var s=i.pageX-this.canvasPos.x,e=i.pageY-this.canvasPos.y,a=this.opts.state.dims.tip,h=this.getTp(s,e-a.t,!1);this.onMouseLeave(),h&&this.$canvas.classList.add("tchart--graph-canvas__tip-pointer")},toggle:function(i,s){var e=this.opts,a=e.state;if(i&&!this.shown&&(this.$tip.classList.add("tchart--tip__visible"),!this.opts.data.hasDetail||this.opts.state.zoomMode||this.opts.state.zoomModeSpecial?this.$tip.classList.remove("tchart--tip__has-zoom"):this.$tip.classList.add("tchart--tip__has-zoom"),this.$tip.classList.remove("tchart--tip__shiftHide"),this.$line&&this.$line.classList.add("tchart--line__visible"),t.TUtils.triggerEvent("chart-hide-tips",{except:this.opts.chart})),!i&&this.shown){if(delete this.lastCurPieItemInd,"area"==e.graphStyle&&a.zoomMode){for(var h=[],o=0;o=f.ed&&(s=f),u-2*Math.PI<=f.st&&u-2*Math.PI>=f.ed&&(s=f)}if(this.lastCurPieItemInd!=s.ind){var v=[];for(x=0;xm.w-1&&M--;else(this.opts.state.zoomMode||this.opts.state.zoomModeSpecial)&&(Mh.state.detailInd2&&M--);if("bar"==h.graphStyle&&h.animator.add([{prop:"barInd",state:h.state,end:M,duration:0,tween:"linear",group:{top:!0}},{prop:"barO",state:this.opts.state,end:1,duration:150,tween:"exp",speed:.3,group:{top:!0}}]),this.prevXInd!=M||!i.isMove){this.$tip.classList.remove("tchart--tip__piemode"),this.$line&&this.$line.classList.remove("tchart--line__piemode"),this.labels.forEach(function(t,i){var s=h.state["e_"+i]&&!isNaN(h.data.ys[i].y[M])?"block":"none";t.$row.style.display=s,this.points&&(this.points[i].style.display=s),c+="block"==s?1:0}.bind(this)),this.itemsVisible=c,this.allLabel&&(this.allLabel.$row.style.display=c>1?"block":"none"),this.itemsVisible?(this.$tip.classList.remove("tchart--tip__has_no_items"),this.$line&&this.$line.classList.remove("tchart--line__has_no_items")):(this.$tip.classList.add("tchart--tip__has_no_items"),this.$line&&this.$line.classList.add("tchart--line__has_no_items"));var T=0;"step"==h.graphStyle&&(T=this.opts.state.zoomMode?h.data.detailPeriodLen:h.data.mainPeriodLen);var b=(h.data.x[M]-o.x1+T/2)/(o.x2-o.x1+x)*(m.w-p-d)+p<<0;this.$line&&(this.$line.style.transform="translateX("+b+"px)"),this.$line&&(this.$line.style.webkitTransform="translateX("+b+"px)"),this.$tipDtText.nodeValue=h.data.dates[M];var _=0;if(h.data.ys.forEach(function(t,i){if(h.state["e_"+i]&&!isNaN(t.y[M])&&(this.labels[i].$valueText.nodeValue=g(t.y[M]),_+=t.y[M]||0,this.points)){s=this.points[i],h.pairY?(e=o["y1_"+i],a=o["y2_"+i]):(e=o.y1,a=o.y2);var n=(t.y[M]-e)/(a-e);s.style.transform="translateY("+(m.h-n*(m.h-r-l)-l<<0)+"px)",s.style.webkitTransform="translateY("+(m.h-n*(m.h-r-l)-l<<0)+"px)"}}.bind(this)),this.allLabel&&(this.allLabel.$valueText.nodeValue=g(_)),!i.isMove){this.maxLabelWidth=0,this.maxValueWidth=0,this.maxPercentageWidth=0,this.maxDateWidth=0;var w=window.getComputedStyle(this.$tip);this.rowPaddings=parseInt(w.getPropertyValue("padding-left"),10)+parseInt(w.getPropertyValue("padding-right"),10)}"area"==h.graphStyle&&this.fillPercentages(M,_),this.labels.forEach(function(t,i){if(h.state["e_"+i]&&!isNaN(h.data.ys[i].y[M])){var s=t.$label.offsetWidth;s>this.maxLabelWidth&&(this.maxLabelWidth=s);var e=t.$value.offsetWidth;e>this.maxValueWidth&&(this.maxValueWidth=e)}}.bind(this));var D=this.rowPaddings+this.maxLabelWidth+20+this.maxValueWidth;D+="area"==h.graphStyle?this.maxPercentageWidth:0;var S=this.rowPaddings+this.$tipDt.offsetWidth+20;S>this.maxDateWidth&&(this.maxDateWidth=S),D=Math.max(D,this.maxDateWidth),this.$tip.style.width=D+"px",this.tipH=this.$tip.offsetHeight,this.tipW=this.$tip.offsetWidth}var I=this.itemsVisible<=2?"center":"side";if("center"==I){var $=this.dx-this.tipW/2;(L=Math.min(this.dy-20-this.tipH,m.t+m.h-this.tipH-l))m.w/2)$=this.dx-this.tipW-20;else $=this.dx+20;var L=Math.min(Math.max(this.dy-this.tipH/2,m.t+r),m.t+m.h-this.tipH-l)}$=Math.min(Math.max($,p/2),m.w-this.tipW-d/2),this.$tip.style.transform="translate("+($<<0)+"px,"+(L<<0)+"px)",this.$tip.style.webkitTransform="translate("+($<<0)+"px,"+(L<<0)+"px)",this.lastTipLeft=$<<0,this.lastTipTop=L<<0,this.prevXInd=M,this.updateTipScrollClasses()}}},updateTipScrollClasses:function(){this.$tipScroller.scrollHeight>this.$tipScroller.offsetHeight?this.$tip.classList.add("tchart--tip__scroll"):this.$tip.classList.remove("tchart--tip__scroll"),this.$tipScroller.scrollTop<=0?this.$tip.classList.remove("tchart--tip__has_less"):this.$tip.classList.add("tchart--tip__has_less"),this.$tipScroller.scrollTop>=this.$tipScroller.scrollHeight-this.$tipScroller.offsetHeight?this.$tip.classList.remove("tchart--tip__has_more"):this.$tip.classList.add("tchart--tip__has_more")},fillPercentages:function(t,i){var s=this.opts,e=[],a=2;s.data.ys.forEach(function(h,o){s.state["e_"+o]&&(e[o]=Math.max(Math.round(100*h.y[t]/i),1),isNaN(h.y[t])&&(e[o]=0),100==e[o]&&(a=3))}.bind(this)),s.data.ys.forEach(function(t,i){if(s.state["e_"+i]){var h=8*a+17;this.labels[i].$label.style.transform="translateX("+h+"px)",this.labels[i].$label.style.webkitTransform="translateX("+h+"px)",this.labels[i].$perText.nodeValue=e[i]+"%",this.labels[i].$per.style.width=h-7+"px",h>this.maxPercentageWidth&&(this.maxPercentageWidth=h)}}.bind(this))}},t.TTip=i}(),function(){Math.log2=Math.log2||function(t){return Math.log(t)*Math.LOG2E},Math.log10=Math.log10||function(t){return Math.log(t)*Math.LOG10E};var t=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],i=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],s=["January","February","March","April","May","June","July","August","September","October","November","December"],e={simplifyData:function(t,i,s,e,a,h,o,n,r){var d=(n-o)/r,l=[],p=[];if(d<=1)return{xInd1:o,xInd2:n,x:i,ys:s};for(var c,m=0,g=-999999999,u=h.length,x=o;x<=n;x++){var v=i[x]*e+a<<0,f=v>g;for(f?(l[m]=i[x],m++):c++,j=0;j1&&(f&&(p[y].y[m-2]/=c),x==n&&(p[y].y[m-1]/=c))}f&&(c=1),g=v}return o=0,n=m-1,{isOptimized:d>1,xInd1:0,xInd2:m-1,x:l,ys:p}},getElemPagePos:function(t){var i=t.getBoundingClientRect();return{x:i.left+(window.pageXOffset||document.documentElement.scrollLeft),y:i.top+(window.pageYOffset||document.documentElement.scrollTop)}},getXIndex:function(t,i,s){var e=0,a=t.length-1;for(s||(it[a]&&(i=t[a]));Math.abs(e-a)>1;){var h=Math.round((e+a)/2);i>=t[e]&&i<=t[h]?a=h:e=h}return e+(i-t[e])/(t[a]-t[e])},triggerEvent:function(t,i){"function"==typeof window.CustomEvent&&document.dispatchEvent(new CustomEvent(t,{detail:i||null}))},isTouchDevice:function(){var t=" -webkit- -moz- -o- -ms- ".split(" ");return!!("ontouchstart"in window||window.DocumentTouch&&document instanceof DocumentTouch)||function(t){return window.matchMedia(t).matches}(["(",t.join("touch-enabled),("),"heartz",")"].join(""))},drawRoundedRect:function(t,i,s,e,a,h,o){s*=i,e*=i,a*=i,h*=i,"number"==typeof o&&(o=[o,o,o,o]),o[0]*=i,o[1]*=i,o[2]*=i,o[3]*=i,t.beginPath(),t.moveTo(a+o[0],h),t.lineTo(a+s-o[1],h),t.quadraticCurveTo(a+s,h,a+s,h+o[1]),t.lineTo(a+s,h+e-o[2]),t.quadraticCurveTo(a+s,h+e,a+s-o[2],h+e),t.lineTo(a+o[3],h+e),t.quadraticCurveTo(a,h+e,a,h+e-o[3]),t.lineTo(a,h+o[0]),t.quadraticCurveTo(a,h,a+o[0],h),t.closePath()},drawRoundedRect2:function(t,i,s,e,a,h,o){a*=i,h*=i,(s*=i)<2*(o*=i)&&(o=s/2),(e*=i)<2*o&&(o=e/2),t.beginPath(),t.moveTo(a+o,h),t.arcTo(a+s,h,a+s,h+e,o),t.arcTo(a+s,h+e,a,h+e,o),t.arcTo(a,h+e,a,h,o),t.arcTo(a,h,a+s,h,o),t.closePath()},getFormatter:function(t,i,s){var a;return s>.5&&i.details&&(a=i.details[t]),a||i[t]||e[t]},xTooltipFormatter:function(s,e){var a=new Date(s),h=[a.getUTCFullYear(),a.getUTCMonth(),a.getUTCDate(),a.getUTCDay(),a.getUTCHours(),a.getUTCMinutes()];return e?(h[4]<10?"0":"")+h[4]+":"+(h[5]<10?"0":"")+h[5]:i[h[3]]+", "+h[2]+" "+t[h[1]]+" "+h[0]},xTickFormatter:function(i,s){var e=new Date(i),a=[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate(),e.getUTCDay(),e.getUTCHours(),e.getUTCMinutes()];return s?(a[4]<10?"0":"")+a[4]+":"+(a[5]<10?"0":"")+a[5]:a[2]+" "+t[a[1]]},xRangeFormatter:function(t,i){var e=new Date(t),a=[e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate()];return a[2]+" "+s[a[1]]+" "+a[0]},yTickFormatter:function(t,i,s){return 0==t?0:i<1e3?Math.floor(t):i>=1e3&&i<1e6?s?Math.floor(10*t/1e3)/10+"K":Math.round(t/1e3)+"K":s?Math.floor(10*t/1e6)/10+"M":Math.round(t/1e6)+"M"},yTooltipFormatter:function(t){return"number"!=typeof t?"string"==typeof t?t:"?":e.statsFormatKMBT(t)},statsFormatKMBT:function(t,i,s){if(0==t)return"0";null==i&&(i=e.statsChooseNumKMBT(t));var a=e.statsFormatFixedKMBT(t,i);return null==s&&(s=e.statsChoosePrecision(a)),a.toFixed(s)+i},statsFormatFixedKMBT:function(t,i){switch(i){case"K":return t/1e3;case"M":return t/1e6;case"B":return t/1e9;case"T":return t/1e12}return t},statsChoosePrecision:function(t){var i=Math.abs(t);return i>10?0:i>=1?Math.abs(i-Math.floor(i))<.001?0:1:2},statsChooseNumKMBT:function(t){var i=Math.abs(t);return i>=1e12?"T":i>=1e9?"B":i>=1e6?"M":i>=2e3?"K":""},roundRange:function(t,i,s,e){if(Math.abs(i-t)<1&&(t-=t/10,i+=i/10),e){var a=(e.yMinOrig-e.yMin)/(e.yMaxOrig-e.yMinOrig),h=(e.yMax-e.yMaxOrig)/(e.yMaxOrig-e.yMinOrig);return{yMin:t-(i-t)*a,yMax:i+(i-t)*h,yMinOrig:t,yMaxOrig:i}}for(var o,n=function(e){var a=l*e,h=Math.floor(t/a)*a,o=h+s*Math.ceil((i-h)*r/a)*a;return{good:o<=c&&h>=p,yMin:Math.round(h),yMax:Math.round(o),yMinOrig:t,yMaxOrig:i}},r=1/s,d=(i-t)*r,l=Math.max(Math.pow(10,Math.floor(Math.log10(d))),1),p=t-.5*d,c=i+.5*d,m=1;!(o=n(5)).good&&!(o=n(2)).good&&!(o=n(1)).good;)if(l*=.1,++m>10)return{yMinOrig:t,yMaxOrig:i,yMin:t,yMax:i};return o}};window.Graph.units.TUtils=e}();