highcharts
Version:
JavaScript charting framework
11 lines • 3.4 kB
JavaScript
/**
* Highcharts JS v12.3.0 (2025-06-21)
* @module highcharts/modules/mouse-wheel-zoom
* @requires highcharts
*
* Non-cartesian series zoom module
*
* (c) 2024 Hubert Kozik
*
* License: www.highcharts.com/license
*/import*as t from"../highcharts.js";var e={};e.n=t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return e.d(o,{a:o}),o},e.d=(t,o)=>{for(var i in o)e.o(o,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:o[i]})},e.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);let o=t.default;var i=e.n(o);let{composed:s}=i(),{addEvent:a,pushUnique:n}=i();function r(t){let e=this,{trigger:o,selection:i,reset:s,from:a={},to:n={}}=t;"xy"===e.zooming.type&&("mousewheel"===o||"pan"===o||i||s)&&e.series.forEach(i=>{if(!i.isCartesian&&!1!==i.options.zoomEnabled){i.isDirty=!0,e.isDirtyBox=!0,t.hasZoomed=!0;let{plotSizeX:s=0,plotSizeY:r=0}=e;if("pan"===o&&i.zooming)i.zooming.panX-=(n.x||0)/s,i.zooming.panY-=(n.y||0)/r;else if(Object.keys(a).length){let{width:t=1,height:o=1}=n,l=Math.abs(i.group?.scaleX||1),{x:p=0,y:h=0,width:m=1,height:c=1}=a,g=p,f=h,z=i.zooming?.scale||i.group?.scaleX||1,d=(i.zooming?.width||1)*s,u=(i.zooming?.height||1)*r;if(Object.keys(n).length)d=m/t*d,u=m/o*u,p-=e.plotLeft,h-=e.plotTop,g=p-d/2,f=h-u/2,z=Math.min(s/d,r/u);else{m/=l,c/=l,z=Math.min(s/m,r/c);let t=0,o=0;i.zooming&&(t=i.zooming.x*s,o=i.zooming.y*r);let a=(p-e.plotLeft)/(s-m*l||1),n=(h-e.plotTop)/(r-c*l||1);d=m,u=c,p-=e.plotLeft,h-=e.plotTop,p/=l,h/=l,p+=t+m*a,h+=o+c*n,g-=e.plotLeft,f-=e.plotTop,g/=l,f/=l,g+=t,f+=o}i.zooming={x:g/s,y:f/r,zoomX:p/s,zoomY:h/r,width:d/s,height:u/r,scale:z,panX:0,panY:0},z<1&&delete i.zooming}else delete i.zooming}})}function l(t){let{chart:e,group:o,zooming:i}=this,{plotSizeX:s=0,plotSizeY:a=0}=e,{scale:n,translateX:r,translateY:l,name:p}=t,h=0,m=0,c=r,g=l;e.inverted&&([s,a]=[a,s]),o&&i&&(n=i.scale,h=i.zoomX*s*(n-Math.abs(o.scaleX||1)),m=i.zoomY*a*(n-Math.abs(o.scaleY||1)),"series"===p&&(i.x=Math.max(0,Math.min(1-i.width,i.x+i.panX/n)),h+=i.panX*s,i.panX=0,i.y=Math.max(0,Math.min(1-i.height,i.y+i.panY/n)),m+=i.panY*a,i.panY=0),r=(o.translateX||c)-h,(l=(o.translateY||g)-m)>g?l=g:(o.translateY||g)-m<a*(1-n)+g&&(l=a*(1-n)+g),r>c?r=c:r<s*(1-n)+c&&(r=s*(1-n)+c),t.scale=n,t.translateX=r,t.translateY=l)}function p(){let t;this.series.find(t=>!!t.zooming)&&(this.zoomClipRect||(this.zoomClipRect=this.renderer.clipRect()),this.zoomClipRect.attr({x:this.plotLeft,y:this.plotTop,width:this.inverted?this.clipBox.height:this.clipBox.width,height:this.inverted?this.clipBox.width:this.clipBox.height}),t=this.zoomClipRect),this.seriesGroup?.clip(t),this.dataLabelsGroup?.clip(t)}function h(t){if(t.point.series&&!t.point.series.isCartesian&&t.point.series.group&&t.point.series.zooming){let e=t.point.series.chart,o=t.point.series.zooming.scale,i=t.point.series.group.translateX||0,s=t.point.series.group.translateY||0;t.ret[0]=t.ret[0]*o+i-e.plotLeft,t.ret[1]=t.ret[1]*o+s-e.plotTop}}function m(t){t.skipAxes&&this.series.forEach(t=>{t.group&&t.zooming&&t.group.attr({translateX:0,translateY:0,scaleX:1,scaleY:1})})}let c=class{static compose(t,e,o){n(s,"NonCartesianSeriesZoom")&&(a(t,"afterDrawChartBox",p),a(t,"transform",r),a(t,"afterSetChartSize",m),a(e,"getPlotBox",l),a(o,"getAnchor",h))}},g=i();g.NonCartesianSeriesZoom=g.NonCartesianSeriesZoom||c,g.NonCartesianSeriesZoom.compose(g.Chart,g.Series,g.Tooltip);let f=i();export{f as default};