highcharts
Version:
JavaScript charting framework
13 lines • 3.77 kB
JavaScript
/**
* Highcharts JS v12.5.0 (2026-01-12)
* @module highcharts/modules/mouse-wheel-zoom
* @requires highcharts
*
* Non-cartesian series zoom module
*
* (c) 2024-2026 Highsoft AS
* Author: Hubert Kozik
*
* A commercial license may be required depending on use.
* See 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:a}=i(),{addEvent:s,pushUnique:r}=i();function n(t){let e=this,{trigger:o,selection:i,reset:a,from:s={},to:r={}}=t;"xy"===e.zooming.type&&("mousewheel"===o||"pan"===o||i||a)&&e.series.forEach(i=>{if(!i.isCartesian&&!1!==i.options.zoomEnabled){i.isDirty=!0,e.isDirtyBox=!0,t.hasZoomed=!0;let{plotWidth:a=0,plotHeight:n=0}=e;if("pan"===o&&i.zooming)i.zooming.panX-=(r.x||0)/a,i.zooming.panY-=(r.y||0)/n;else if(Object.keys(s).length){let{width:t=1,height:o=1}=r,l=Math.abs(i.group?.scaleX||1),{x:h=0,y:p=0,width:c=1,height:m=1}=s,g=h,d=p,f=i.zooming?.scale||i.group?.scaleX||1,z=(i.zooming?.width||1)*a,u=(i.zooming?.height||1)*n;if(Object.keys(r).length)z=c/t*z,u=c/o*u,h-=e.plotLeft,p-=e.plotTop,g=h-z/2,d=p-u/2,f=Math.min(a/z,n/u);else{c/=l,m/=l,f=Math.min(a/c,n/m);let t=0,o=0;i.zooming&&(t=i.zooming.x*a,o=i.zooming.y*n);let s=(h-e.plotLeft)/(a-c*l||1),r=(p-e.plotTop)/(n-m*l||1);z=c,u=m,h-=e.plotLeft,p-=e.plotTop,h/=l,p/=l,h+=t+c*s,p+=o+m*r,g-=e.plotLeft,d-=e.plotTop,g/=l,d/=l,g+=t,d+=o}i.zooming={x:g/a,y:d/n,zoomX:h/a,zoomY:p/n,width:z/a,height:u/n,scale:f,panX:0,panY:0},f<1&&delete i.zooming}else delete i.zooming}})}function l(t){let{chart:e,group:o,zooming:i}=this,{plotSizeX:a=0,plotSizeY:s=0}=e,{scale:r,translateX:n,translateY:l,name:h}=t,p=0,c=0,m=n,g=l;e.inverted&&([a,s]=[s,a]),o&&i&&(r=i.scale,p=i.zoomX*a*(r-Math.abs(o.scaleX||1)),c=i.zoomY*s*(r-Math.abs(o.scaleY||1)),"series"===h&&(i.x=Math.max(0,Math.min(1-i.width,i.x+i.panX/r)),p+=i.panX*a,i.panX=0,i.y=Math.max(0,Math.min(1-i.height,i.y+i.panY/r)),c+=i.panY*s,i.panY=0),n=(o.translateX||m)-p,(l=(o.translateY||g)-c)>g?l=g:(o.translateY||g)-c<s*(1-r)+g&&(l=s*(1-r)+g),n>m?n=m:n<a*(1-r)+m&&(n=a*(1-r)+m),t.scale=r,t.translateX=n,t.translateY=l)}function h(){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.series.forEach(e=>{e.dataLabelsParentGroups?.forEach(e=>{e.clip(t)})})}function p(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,a=t.point.series.group.translateY||0;t.ret[0]=t.ret[0]*o+i-e.plotLeft,t.ret[1]=t.ret[1]*o+a-e.plotTop}}function c(t){t.skipAxes&&this.series.forEach(t=>{t.group&&t.zooming&&t.group.attr({translateX:0,translateY:0,scaleX:1,scaleY:1})})}function m({index:t,zIndex:e}){var o;this.hasDataLabels?.()&&(this.dataLabelsParentGroups||(this.dataLabelsParentGroups=[]),(o=this.dataLabelsParentGroups)[t]||(o[t]=this.chart.renderer.g().attr({zIndex:e}).add()))}let g=class{static compose(t,e,o){r(a,"NonCartesianSeriesZoom")&&(s(t,"afterDrawChartBox",h),s(t,"transform",n),s(t,"afterSetChartSize",c),s(e,"getPlotBox",l),s(e,"initDataLabelsGroup",m),s(o,"getAnchor",p))}},d=i();d.NonCartesianSeriesZoom=d.NonCartesianSeriesZoom||g,d.NonCartesianSeriesZoom.compose(d.Chart,d.Series,d.Tooltip);let f=i();export{f as default};