telegram-crawler/data/tsf.telegram.org/js/tchart.min.js

1 line
84 KiB
JavaScript
Raw Normal View History

2021-04-24 14:28:52 +02:00
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;a<t.length;){if(!(i=o[(s=t[a]).prop])){if(s.end==s.state[s.prop]){s.cbEnd&&s.cbEnd(s.state),a++;continue}i={lastStart:1},o[s.prop]=i,this.queueSize++}e=h-i.lastStart,s.duration*=this.state.speed,s.delay*=this.state.speed,i.cbEnd=s.cbEnd,i.state=s.state,i.lastStart=h,i.start=s.state[s.prop],i.end=s.end,i.startDt=h+(s.delay||0),i.endDt=i.startDt+(s.duration||0)-(s.fixed?0:Math.max(s.duration-e,0)),i.tween=s.tween||"easeInOutQuad",i.speed=s.speed,i.group=s.group,a++}this.animFrame||(this.animFrame=requestAnimationFrame(this.step))},get:function(t){return this.queue[t]},step:function(){var i,s,e,a,h,o,n,r,d,l=[],p=+new Date,c={top:!1,bottom:!1};for(i in this.queue)e=p,a=(s=this.queue[i]).endDt-s.startDt,o=s.state[i],d=e<s.startDt,e<s.startDt?e=s.startDt:e>s.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;r<l.length;)this.queue[l[r]].cbEnd&&this.queue[l[r]].cbEnd(this.queue[l[r]].state),delete this.queue[l[r]],r++;this.queueSize-=l.length,this.composer.render(c),this.queueSize?this.animFrame=requestAnimationFrame(this.step):delete this.animFrame}},window.Graph.units.TAnimator=i}(),function(){var t=window.Graph.units,i=function(t){this.opts=t,t.additional.mini&&(this.$canvas=document.createElement("canvas"),this.ctx=this.$canvas.getContext("2d",{alpha:!0}))};i.prototype={onResize:function(){if(this.opts.additional.mini){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=this.opts,c=p.data.ys,m=p.state,g=p.additional.mini,u=g?m.xg1:m.x1,x=g?m.xg2:m.x2,v=p.settings,f=v["PADD"+(g?"_MINI_AREA":"")][0],y=v["PADD"+(g?"_MINI_AREA":"")][1],M=v["PADD"+(g?"_MINI_AREA":"")][2],T=v["PADD"+(g?"_MINI_AREA":"")][3],b=p.data.x,_=p.settings.dpi,w=g?this.ctx:this.opts.ctx,D=[],S=[],I=g?m.dims.mini:m.dims.graph,$=null==m.zoomMorph?0:m.zoomMorph,L=$,A=(m.zoomMode,c.length);if(g){var E=[I.w,I.h,m.xg1,m.xg2,this.isDarkMode,m.zoomMode,$];for(i=0;i<A;i++)E.push(m["om_"+i]),E.push(m["f_"+i]);if((E=E.join(","))==this.cached)return void this.opts.ctx.drawImage(this.$canvas,I.l*_,I.t*_);this.cached=E}h=(I.w-y-T)/(x-u),d=Math.floor(t.TUtils.getXIndex(b,u-T/h)),l=Math.ceil(t.TUtils.getXIndex(b,x+y/h)),h*=_,n=(T+(g?0:I.l))*_-u*h,hBottom=(I.h-M+(g?0:I.t))*_;var P=[],R=[],k=0,C=0,z=0,F=!1;for(i=0;i<A;i++)a=g?m["om_"+i]:m["o_"+i],F=F||m["f_"+i]<1,a<1&&a>0&&(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;i<Y;i++)S[s]+=(U[P[i]].y[s]||0)*R[i];0==S[s]&&(N=!0)}if((N||F)&&(w.fillStyle=this.isDarkMode?"#242f3e":"#fff",w.fillRect(0,0,I.w*_,I.h*_)),$>0&&!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;i<