UNPKG

highcharts

Version:
14 lines 6.5 kB
!/** * Highstock JS v12.6.0 (2026-04-13) * @module highcharts/modules/drag-panes * @requires highcharts * @requires highcharts/modules/stock * * Drag-panes module * * (c) 2010-2026 Highsoft AS * Author: Kacper Madej * * A commercial license may be required depending on use. * See www.highcharts.com/license */function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(t._Highcharts):"function"==typeof define&&define.amd?define("highcharts/modules/drag-panes",["highcharts/highcharts"],function(t){return e(t)}):"object"==typeof exports?exports["highcharts/modules/drag-panes"]=e(t._Highcharts):t.Highcharts=e(t.Highcharts)}("u"<typeof window?this:window,t=>(()=>{"use strict";var e={944:e=>{e.exports=t}},o={};function i(t){var s=o[t];if(void 0!==s)return s.exports;var r=o[t]={exports:{}};return e[t](r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var o in e)i.o(e,o)&&!i.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:e[o]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var s={};i.d(s,{default:()=>j});var r=i(944),n=i.n(r);let{doc:a,win:h}=n();function c(t,e,o,i={}){let s="function"==typeof t&&t.prototype||t;Object.hasOwnProperty.call(s,"hcEvents")||(s.hcEvents={});let r=s.hcEvents;n().Point&&t instanceof n().Point&&t.series&&t.series.chart&&(t.series.chart.runTrackerClick=!0);let a=t.addEventListener;a&&a.call(t,e,o,!!n().supportsPassiveEvents&&{passive:void 0===i.passive?-1!==e.indexOf("touch"):i.passive,capture:!1}),r[e]||(r[e]=[]);let h={fn:o,order:"number"==typeof i.order?i.order:1/0};return r[e].push(h),r[e].sort((t,e)=>t.order-e.order),function(){!function(t,e,o){function i(e,o){let i=t.removeEventListener;i&&i.call(t,e,o,!1)}function s(o){let s,r;t.nodeName&&(e?(s={})[e]=!0:s=o,d(s,function(t,e){if(o[e])for(r=o[e].length;r--;)i(e,o[e][r].fn)}))}let r="function"==typeof t&&t.prototype||t;if(Object.hasOwnProperty.call(r,"hcEvents")){let t=r.hcEvents;if(e){let r=t[e]||[];o?(t[e]=r.filter(function(t){return o!==t.fn}),i(e,o)):(s(t),t[e]=[])}else s(t),delete r.hcEvents}}(t,e,o)}}function l(t,e,o){return t>e?t<o?t:o:e}function p(t){return u(t)&&"number"==typeof t.nodeType}function u(t,e){let o;return!!t&&"object"==typeof t&&(!e||"[object Array]"!==(o=Object.prototype.toString.call(t))&&"[object Array Iterator]"!==o)}function d(t,e,o){for(let i in t)Object.hasOwnProperty.call(t,i)&&e.call(o||t[i],t[i],i,t)}function f(t,e,o){return/%$/.test(t)?e*parseFloat(t)/100+(o||0):parseFloat(t)}function y(t,e,o){let i=t[e];t[e]=function(){let t=arguments,e=this;return o.apply(this,[function(){return i.apply(e,arguments.length?arguments:t)}].concat([].slice.call(arguments)))}}Array.prototype.find;let x=class{constructor(t){this.init(t)}init(t,e){this.axis=t,this.options=t.options.resize||{},this.render(),e||this.addMouseEvents()}render(){let t=this.axis,e=t.chart,o=this.options,i=o.x||0,s=o.y,r=l(t.top+t.height+s,e.plotTop,e.plotTop+e.plotHeight),n={};e.styledMode||(n={cursor:o.cursor,stroke:o.lineColor,"stroke-width":o.lineWidth,dashstyle:o.lineDashStyle}),this.lastPos=r-s,this.controlLine||(this.controlLine=e.renderer.path().addClass("highcharts-axis-resizer")),this.controlLine.add(t.axisGroup);let a=e.styledMode?this.controlLine.strokeWidth():o.lineWidth;n.d=e.renderer.crispLine([["M",t.left+i,r],["L",t.left+t.width+i,r]],a),this.controlLine.attr(n)}addMouseEvents(){let t,e,o,i=this,s=i.controlLine.element,r=i.axis.chart.container,n=[];i.mouseMoveHandler=t=t=>i.onMouseMove(t),i.mouseUpHandler=e=t=>i.onMouseUp(t),i.mouseDownHandler=o=()=>i.onMouseDown(),n.push(c(r,"mousemove",t),c(r.ownerDocument,"mouseup",e),c(s,"mousedown",o),c(r,"touchmove",t),c(r.ownerDocument,"touchend",e),c(s,"touchstart",o)),i.eventsToUnbind=n}onMouseMove(t){if(!t.touches||0!==t.touches[0].pageX){let e=this.axis.chart.pointer;this.grabbed&&e&&(this.hasDragged=!0,this.updateAxes(e.normalize(t).chartY-(this.options.y||0)))}}onMouseUp(t){let e=this.axis.chart.pointer;this.hasDragged&&e&&this.updateAxes(e.normalize(t).chartY-(this.options.y||0)),this.grabbed=this.hasDragged=this.axis.chart.activeResizer=void 0}onMouseDown(){this.axis.chart.pointer?.reset(!1,0),this.grabbed=this.axis.chart.activeResizer=!0}updateAxes(t){let e=this.axis.chart,o=this.options.controlledAxis,i=0===o.next.length?[e.yAxis.indexOf(this.axis)+1]:o.next,s=[this.axis].concat(o.prev),r=[],n=e.plotTop,a=e.plotHeight,h=n+a,c=t=>100*t/a+"%",p=(t,e,o)=>Math.round(l(t,e,o));t=l(t,n,h);let u=!1,d=t-this.lastPos;if(d*d<1)return;let y=!0;for(let o of[s,i])for(let s of o){let l,x,v="number"==typeof s&&!isNaN(s)&&s<1/0&&s>-1/0?e.yAxis[s]:y?s:e.get(s),g=v&&v.options,m={};if(!g||g.isInternal){y=!1;continue}x=v.top;let b=Math.round(f(g.minLength||NaN,a)),w=Math.round(f(g.maxLength||NaN,a));if(y||o!==i)(l=p(t-x,b,w))===w&&(u=!0),t=x+l,r.push({axis:v,options:{height:c(l)}});else{if(d=t-this.lastPos,l=p(v.len-d,b,w),(x=v.top+d)+l>h){let e=h-l-x;t+=e,x+=e}x<n&&(x=n)+l>h&&(l=a),l===b&&(u=!0),r.push({axis:v,options:{top:c(x-n),height:c(l)}})}y=!1,m.height=l}if(!u){for(let t of r)t.axis.update(t.options,!1);e.redraw(!1)}}destroy(){let t=this.axis;for(let e of(delete t.resizer,this.eventsToUnbind&&this.eventsToUnbind.forEach(t=>t()),this.controlLine.destroy(),Object.keys(this)))this[e]=null}},v={minLength:"10%",maxLength:"100%",resize:{controlledAxis:{next:[],prev:[]},enabled:!1,cursor:"ns-resize",lineColor:"#cccccc",lineDashStyle:"Solid",lineWidth:4,x:0,y:0}},{defaultOptions:g}=n();function m(){let t=this.resizer,e=this.options.resize;if(e){let o=!1!==e.enabled;t?o?t.init(this,!0):t.destroy():o&&(this.resizer=new x(this))}}function b(t){!t.keepEvents&&this.resizer&&this.resizer.destroy()}function w(t){this.chart.activeResizer||t.apply(this,[].slice.call(arguments,1))}function z(t){this.chart.activeResizer||t.apply(this,[].slice.call(arguments,1))}let M=n();({compose:function(t,e){t.keepProps.includes("resizer")||(!function(t,...e){let o,i=[t,...e],s={},r=function(t,e){return"object"!=typeof t&&(t={}),d(e,function(o,i){if("__proto__"!==i&&"constructor"!==i){let s;!u(o,!0)||(s=o?.constructor,u(o,!0)&&!p(o)&&s?.name&&"Object"!==s.name)||p(o)?t[i]=e[i]:t[i]=r(t[i]||{},o)}}),t};!0===t&&(s=i[1],i=Array.prototype.slice.call(i,2));let n=i.length;for(o=0;o<n;o++)s=r(s,i[o])}(!0,g.yAxis,v),t.keepProps.push("resizer"),c(t,"afterRender",m),c(t,"destroy",b),y(e.prototype,"runPointActions",z),y(e.prototype,"drag",w))}}).compose(M.Axis,M.Pointer);let j=n();return s.default})());