1 line
3.9 KiB
JavaScript
1 line
3.9 KiB
JavaScript
!function(T,B){"use strict";var E="ht",z=E+".graph.",c=T[E],P=c.graph,Z=c.Default,t=c.Color,H=null,h="px",X=Z.getInternal(),s=X.getPinchDist,b=Z.preventDefault,W=Z.getTouchCount,q=Z.startDragging;X.addMethod(Z,{overviewBackground:t.widgetBackground,overviewMaskBackground:t.transparent,overviewContentBorderColor:t.widgetBorder,overviewContentBackground:t.background},!0),P.Overview=function(F){var x=this,q=x._view=X.createView(1,x);x._canvas=X.createCanvas(q),q.style.background=Z.overviewBackground,q.appendChild(x._mask=X.createDiv()),x.setGraphView(F),x.addListeners()},Z.def(z+"Overview",B,{ms_v:1,ms_fire:1,ms_listener:1,ms_ac:["maskBackground","contentBorderColor","contentBackground","autoUpdate","fixToRect"],_autoUpdate:!0,_fixToRect:!1,_rate:1,_scrollRect:{x:0,y:0,width:0,height:0},_maskBackground:Z.overviewMaskBackground,_contentBorderColor:Z.overviewContentBorderColor,_contentBackground:Z.overviewContentBackground,getGraphView:function(){return this.gv},setGraphView:function(j){var C=this;if(C.gv!==j){var g=C.gv;C.gv=j,g&&(g.removeViewListener(C.handleGraphViewChanged,C),g.ump(C.handleGraphViewPropertyChanged,C)),j&&(j.addViewListener(C.handleGraphViewChanged,C),j.mp(C.handleGraphViewPropertyChanged,C)),C.fp("graphView",g,j),C.redraw()}},getCanvas:function(){return this._canvas},getMask:function(){return this._mask},dispose:function(){this.setGraphView(null)},onPropertyChanged:function(){this.redraw()},handleGraphViewChanged:function(j){this._autoUpdate&&"validate"===j.kind&&this.redraw()},handleGraphViewPropertyChanged:function(l){("canvasBackground"===l.property||this.getFixToRect()&&("zoom"===l.property||"translateX"===l.property||"translateY"===l.property))&&this.redraw()},redraw:function(){var Z=this;Z._redraw||(Z._redraw=1,Z.iv(50))},validateImpl:function(){var t=this,K=t.gv,V=t._canvas,w=t.getWidth(),R=t.getHeight(),e=t._redraw,G=Z.devicePixelRatio;if(K){var M=t._mask,_=M.style,n=K.getViewRect(),v=this.getFixToRect(),B=v?"boolean"==typeof v?K.getContentRect():v:K.getScrollRect(),N=B.x,m=B.y,u=B.width,a=B.height,I=t._rate=Math.max(u/w,a/R),c=t._x=(w-u/I)/2,b=t._y=(R-a/I)/2;if(0!==n.width&&0!==n.height||t.hasRetry||(Z.callLater(t.iv,t,H),t.hasRetry=!0),(w!==V.clientWidth||R!==V.clientHeight)&&(X.setCanvas(V,w,R),e=1),X.isSameRect(B,t._scrollRect)||(t._scrollRect=B,e=1),e){var L=X.initContext(V),P=K.getDataModel(),S=P.getBackground()||t._contentBackground,D=t._contentBorderColor;L.clearRect(0,0,w*G,R*G);var l=P.getBackground()&&P.a("width")>0&&P.a("height")>0;S&&!l&&X.fillRect(L,c*G,b*G,u/I*G,a/I*G,S),X.translateAndScale(L,-N/I+c,-m/I+b,1/I),K._42(L),L.restore(),D&&X.drawBorder(L,D,c*G,b*G,u/I*G,a/I*G)}_.background=t._maskBackground,_.left=c+(n.x-N)/I+h,_.top=b+(n.y-m)/I+h,_.width=n.width/I+h,_.height=n.height/I+h,t._redraw=null}else if(e){var L=X.initContext(V);L.clearRect(0,0,w*G,R*G),L.restore(),t._redraw=null}},center:function(s){var U=this,L=U.gv;if(L){var $=L._zoom,t=L._29I,h=U._rate,w=U._scrollRect,_=Z.getLogicalPoint(s,U._canvas),j=w.x+(_.x-U._x)*h,f=w.y+(_.y-U._y)*h;L.setTranslate((t.width/2-j)*$,(t.height/2-f)*$)}},handle_mousedown:function(B){this.handle_touchstart(B)},handleWindowMouseUp:function(c){this.handleWindowTouchEnd(c)},handleWindowMouseMove:function(L){this.handleWindowTouchMove(L)},handle_mousewheel:function(L){this.handleScroll(L,L.wheelDelta)},handle_DOMMouseScroll:function(B){2===B.axis&&this.handleScroll(B,-B.detail)},handleScroll:function(e,n){if(b(e),this.gv){var x=this.gv;n>0?x.scrollZoomIn():0>n&&x.scrollZoomOut()}},handle_touchstart:function(m){if(b(m),this.gv&&Z.isLeftButton(m)){var N=this,A=N.gv,d=W(m);1===d?Z.isDoubleClick(m)&&A.isResettable()?A.reset():(N.center(m),q(N,m)):2===d&&(N._dist=s(m),q(N,m))}},handleWindowTouchEnd:function(){delete this._dist},handleWindowTouchMove:function(B){if(this.gv){var V=this,l=V._dist,g=W(B);1===g?V.center(B):2===g&&l!=H&&V.gv.handlePinch(H,s(B),l)}}})}("undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:(0,eval)("this"),Object); |