mirror of
https://github.com/MarshalX/telegram-crawler.git
synced 2024-12-05 06:24:56 +01:00
1 line
84 KiB
JavaScript
1 line
84 KiB
JavaScript
|
window.Graph={render:function(t,C){var b=document.createElement("div");b.className="tchart--wrapper";t.appendChild(b);return new this.units.TChart({container:b,data:C})},units:{}};(function(){var t=function(b,a,c,e){return{linear:function(d,f,g,h){return g*d/h+f},easeInOutQuad:function(d,f,g,h){d/=.5*h;if(1>d)return.5*g*d*d+f;d--;return-g/2*(d*(d-2)-1)+f}}[e](c,b,a-b,1)},C=function(b){this.composer=b.composer;this.state=b.state;this.queue={};this.queueSize=0;this.step=this.step.bind(this)};C.prototype={add:function(b){for(var a=0,c=+new Date,e,d,f,g=this.queue;a<b.length;){d=b[a];e=g[d.prop];if(!e){if(d.end==d.state[d.prop]){d.cbEnd&&d.cbEnd(d.state);a++;continue}e={lastStart:1};g[d.prop]=e;this.queueSize++}f=c-e.lastStart;d.duration*=this.state.speed;d.delay*=this.state.speed;e.cbEnd=d.cbEnd;e.state=d.state;e.lastStart=c;e.start=d.state[d.prop];e.end=d.end;e.startDt=c+(d.delay||0);e.endDt=e.startDt+(d.duration||0)-(d.fixed?0:Math.max(d.duration-f,0));e.tween=d.tween||"easeInOutQuad";e.speed=d.speed;e.group=d.group;a++}this.animFrame||(this.animFrame=requestAnimationFrame(this.step))},get:function(b){return this.queue[b]},step:function(){var b=[],a=+new Date,c,e={top:!1,bottom:!1};for(c in this.queue){var d=this.queue[c];var f=a;var g=d.endDt-d.startDt;var h=d.state[c];var k=f<d.startDt;f<d.startDt?f=d.startDt:f>d.endDt&&(f=d.endDt);f=g?(f-d.startDt)/g:k?0:1;f=1>f?"exp"==d.tween?h+(d.end-h)*d.speed:t(d.start,d.end,f,d.tween):d.end;f!=h?(d.state[c]=f,e.top=e.top||d.group.top,e.bottom=e.bottom||d.group.bottom):f==d.end&&b.push(c)}for(a=0;a<b.length;)this.queue[b[a]].cbEnd&&this.queue[b[a]].cbEnd(this.queue[b[a]].state),delete this.queue[b[a]],a++;this.queueSize-=b.length;this.composer.render(e);this.queueSize?this.animFrame=requestAnimationFrame(this.step):delete this.animFrame}};window.Graph.units.TAnimator=C})();(function(){var t=window.Graph.units,C=function(b){this.opts=b;b.additional.mini&&(this.$canvas=document.createElement("canvas"),this.ctx=this.$canvas.getContext("2d",{alpha:!0}))};C.prototype={onResize:function(){if(this.opts.additional.mini){var b=this.opts.settings.dpi,a=this.opts.additional.mini?this.opts.state.dims.mini:this.opts.state.dims.graph;this.$canvas.width=a.w*b;this.$canvas.height=a.h*b;this.cached=""}},setDarkMode:function(b){this.isDarkMode=b},render:function(){var b,a,c=this.opts,e=c.data.ys,d=c.state,f=c.additional.mini,g=f?d.xg1:d.x1,h=f?d.xg2:d.x2,k=c.settings,m=k["PADD"+(f?"_MINI_AREA":"")][0],w=k["PADD"+(f?"_MINI_AREA":"")][1],r=k["PADD"+(f?"_MINI_AREA":"")][2],q=k["PADD"+(f?"_MINI_AREA":"")][3],n=c.data.x,p=c.settings.dpi,l=f?this.ctx:this.opts.ctx,u=[],B=[],D=f?d.dims.mini:d.dims.graph,E=void 0==d.zoomMorph?0:d.zoomMorph,F=E,G=e.length;if(f){var I=[D.w,D.h,d.xg1,d.xg2,this.isDarkMode,d.zoomMode,E];for(b=0;b<G;b++)I.push(d["om_"+b]),I.push(d["f_"+b]);I=I.join(",");if(I==this.cached){this.opts.ctx.drawImage(this.$canvas,D.l*p,D.t*p);return}this.cached=I}var z=(D.w-w-q)/(h-g);var x=Math.floor(t.TUtils.getXIndex(n,g-q/z));var y=Math.ceil(t.TUtils.getXIndex(n,h+w/z));z*=p;var A=(q+(f?0:D.l))*p-g*z;hBottom=(D.h-r+(f?0:D.t))*p;var Q=[],R=[],P=0,N=0,S=0,O=!1;for(b=0;b<G;b++){var H=f?d["om_"+b]:d["o_"+b];O=O||1>d["f_"+b];1>H&&0<H&&(P=H);0<H&&(Q.push(b),R.push(H),1==H&&d["e_"+b]&&(N++,S=Q.length-1))}var W=Q.length;P=1==N?P:1;var Z=t.TUtils.simplifyData("line",n,e,z,A,Q,x,y,D.w-w-q);x=Z.xInd1;y=Z.xInd2;var J=Z.x,ka=Z.ys,la=!1;for(a=x;a<=y;a++){u[a]=0;for(b=B[a]=0;b<W;b++)B[a]+=(ka[Q[b]].y[a]||0)*R[b];0==B[a]&&(la=!0)}if(la||O)l.fillStyle=this.isDarkMode?"#242f3e":"#fff",l.fillRect(0,0,D.w*p,D.h*p);if(0<E&&!f){1==F&&(this.savedX1=g,this.savedX2=h);if(1>F){var Qa=this.opts.animator.get("x1"),Ra=this.opts.animator.get("x2");x1End=Qa?Qa.end:this.opts.state.x1;x2End=Ra?Ra.end:this.opts.state.x2;var Aa=t.TUtils.getXIndex(n,-1==this.opts.state.zoomDir?this.savedX1:x1End,!0),ua=t.TUtils.getXIndex(n,-1==this.opts.state.zoomDir?this.savedX2:x2End,!0)}else Aa=t.TUtils.getXIndex(n,g,!0),ua=t.TUtils.getXIndex(n,h,!0);ua--;var eb=Math.floor(Aa),Sa=Math.ceil(Aa),Ta=Math.floor(ua),fb=Math.ceil(ua),Ba=0,aa=[];for(b
|