UNPKG

klinecharts

Version:

Lightweight k-line chart built with html5 canvas

7 lines 233 kB
/** * @license * KLineChart v10.0.1 * Copyright (c) 2019 lihu. * Licensed under Apache License 2.0 https://www.apache.org/licenses/LICENSE-2.0 */ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).klinecharts={})}(this,(function(t){"use strict";var e=function(t,i){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i])},e(t,i)};function i(t,i){if("function"!=typeof i&&null!==i)throw new TypeError("Class extends value "+String(i)+" is not a constructor or null");function r(){this.constructor=t}e(t,i),t.prototype=null===i?Object.create(i):(r.prototype=i.prototype,new r)}var r=function(){return r=Object.assign||function(t){for(var e,i=1,r=arguments.length;i<r;i++)for(var n in e=arguments[i])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},r.apply(this,arguments)};function n(t,e){var i={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(i[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var n=0;for(r=Object.getOwnPropertySymbols(t);n<r.length;n++)e.indexOf(r[n])<0&&Object.prototype.propertyIsEnumerable.call(t,r[n])&&(i[r[n]]=t[r[n]])}return i}function o(t,e,i,r){return new(i||(i=Promise))((function(n,o){function a(t){try{l(r.next(t))}catch(t){o(t)}}function s(t){try{l(r.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(a,s)}l((r=r.apply(t,e||[])).next())}))}function a(t,e){var i,r,n,o={label:0,sent:function(){if(1&n[0])throw n[1];return n[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=s(0),a.throw=s(1),a.return=s(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function s(s){return function(l){return function(s){if(i)throw new TypeError("Generator is already executing.");for(;a&&(a=0,s[0]&&(o=0)),o;)try{if(i=1,r&&(n=2&s[0]?r.return:s[0]?r.throw||((n=r.return)&&n.call(r),0):r.next)&&!(n=n.call(r,s[1])).done)return n;switch(r=0,n&&(s=[2&s[0],n.value]),s[0]){case 0:case 1:n=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!(n=o.trys,(n=n.length>0&&n[n.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!n||s[1]>n[0]&&s[1]<n[3])){o.label=s[1];break}if(6===s[0]&&o.label<n[1]){o.label=n[1],n=s;break}if(n&&o.label<n[2]){o.label=n[2],o.ops.push(s);break}n[2]&&o.ops.pop(),o.trys.pop();continue}s=e.call(t,o)}catch(t){s=[6,t],r=0}finally{i=n=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,l])}}}function s(t){var e="function"==typeof Symbol&&Symbol.iterator,i=e&&t[e],r=0;if(i)return i.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function l(t,e){var i="function"==typeof Symbol&&t[Symbol.iterator];if(!i)return t;var r,n,o=i.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){n={error:t}}finally{try{r&&!r.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return a}function u(t,e,i){if(i||2===arguments.length)for(var r,n=0,o=e.length;n<o;n++)!r&&n in e||(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}function c(t,e){if(g(t)||g(e))for(var i in e)if(Object.prototype.hasOwnProperty.call(e,i)){var r=t[i],n=e[i];g(n)&&g(r)?c(r,n):t[i]=h(n)}}function h(t){if(!g(t))return t;var e=null;for(var i in e=d(t)?[]:{},t)if(Object.prototype.hasOwnProperty.call(t,i)){var r=t[i];g(r)?e[i]=h(r):e[i]=r}return e}function d(t){return"[object Array]"===Object.prototype.toString.call(t)}function p(t){return"function"==typeof t}function g(t){return"object"==typeof t&&f(t)}function v(t){return"number"==typeof t&&Number.isFinite(t)}function f(t){return null!=t}function y(t){return"boolean"==typeof t}function m(t){return"string"==typeof t}"function"==typeof SuppressedError&&SuppressedError;var _=-1;function x(t){return p(window.requestAnimationFrame)?window.requestAnimationFrame(t):window.setTimeout(t,20)}function b(t){p(window.cancelAnimationFrame)?window.cancelAnimationFrame(t):window.clearTimeout(t)}var w=function(){function t(t){this._options={duration:500,iterationCount:1},this._currentIterationCount=0,this._running=!1,this._requestAnimationId=_,this._time=0,c(this._options,t)}return t.prototype._loop=function(){var t=this;this._running=!0,this._time=performance.now();var e=function(i){var r;if(t._requestAnimationId=_,t._running){var n="number"==typeof i?i:performance.now(),o=Math.max(0,n-t._time);o<t._options.duration?(null===(r=t._doFrameCallback)||void 0===r||r.call(t,o),t._running&&t._requestAnimationId===_&&(t._requestAnimationId=x(e))):(t.stop(),t._currentIterationCount++,t._currentIterationCount<t._options.iterationCount&&t._loop())}};this._requestAnimationId=x(e)},t.prototype.doFrame=function(t){return this._doFrameCallback=t,this},t.prototype.setDuration=function(t){return this._options.duration=t,this},t.prototype.setIterationCount=function(t){return this._options.iterationCount=t,this},t.prototype.start=function(){this._running||(this._currentIterationCount=0,this._loop())},t.prototype.stop=function(){var t;this._running&&(this.cancel(),null===(t=this._doFrameCallback)||void 0===t||t.call(this,this._options.duration)),this._running=!1},t.prototype.cancel=function(){this._requestAnimationId!==_&&(b(this._requestAnimationId),this._requestAnimationId=_),this._running=!1},t}();function C(t){var e={width:0,height:0,left:0,right:0,top:0,bottom:0};return f(t)&&c(e,t),e}var E=null;function T(t){var e,i;return null!==(i=null===(e=t.ownerDocument.defaultView)||void 0===e?void 0:e.devicePixelRatio)&&void 0!==i?i:1}function I(t,e,i){return"".concat(null!=e?e:"normal"," ").concat(null!=t?t:12,"px ").concat(null!=i?i:"Helvetica Neue")}function S(t,e,i,r){if(!f(E)){var n=document.createElement("canvas"),o=T(n);(E=n.getContext("2d")).scale(o,o)}return E.font=I(e,i,r),Math.round(E.measureText(t).width)}function A(t,e){var i,r=document.createElement(t),n=null!=e?e:{};for(var o in n)r.style[o]=null!==(i=n[o])&&void 0!==i?i:"";return r}var M=1,P=Date.now();function D(t){var e=Date.now();return e===P?++M:M=1,P=e,"".concat(null!=t?t:"").concat(e,"_").concat(M)}function k(t,e,i){var r=0,n=0;for(n=t.length-1;r!==n;){var o=Math.floor((n+r)/2),a=n-r,s=t[o][e];if(i===t[r][e])return r;if(i===t[n][e])return n;if(i===s)return o;if(i>s?r=o:n=o,a<=2)break}return r}function B(t,e){e=Math.max(0,null!=e?e:0);var i=Math.pow(10,e);return Math.round(t*i)/i}function F(t,e,i){for(var r,n,o=[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],a=t.length,s=0;s<a;){var l=t[s];o[0]=Math.max(null!==(r=l[e])&&void 0!==r?r:Number.MIN_SAFE_INTEGER,o[0]),o[1]=Math.min(null!==(n=l[i])&&void 0!==n?n:Number.MAX_SAFE_INTEGER,o[1]),++s}return o}function R(t){return 0===t?0:Math.log10(t)}function L(t){return Math.pow(10,t)}var O=2,Y=0,W=/\\(\\)?/g,z=new RegExp("[^.[\\]]+|\\[(?:([^\"'][^[]*)|([\"'])((?:(?!\\2)[^\\\\]|\\\\.)*?)\\2)\\]|(?=(?:\\.|\\[\\])(?:\\.|\\[\\]|$))","g");function V(t,e,i){if(f(t)){var r=[];e.replace(z,(function(t){for(var e=[],i=1;i<arguments.length;i++)e[i-1]=arguments[i];var n=t;return f(e[1])?n=e[2].replace(W,"$1"):f(e[0])&&(n=e[0].trim()),r.push(n),""}));for(var n=t,o=0,a=r.length;f(n)&&o<a;)n=null==n?void 0:n[r[o++]];return f(n)?n:null!=i?i:"--"}return null!=i?i:"--"}function N(t,e,i){var r=function(t,e){var i={};return t.formatToParts(new Date(e)).forEach((function(t){var e=t.type,r=t.value;switch(e){case"year":i.YYYY=r;break;case"month":i.MM=r;break;case"day":i.DD=r;break;case"hour":i.HH="24"===r?"00":r;break;case"minute":i.mm=r;break;case"second":i.ss=r}})),i}(t,e);return i.replace(/YYYY|MM|DD|HH|mm|ss/g,(function(t){return r[t]}))}function H(t,e){var i=+t;return v(i)?i.toFixed(null!=e?e:2):"".concat(t)}function X(t){var e=+t;if(v(e)){if(e>1e9)return"".concat(+(e/1e9).toFixed(3),"B");if(e>1e6)return"".concat(+(e/1e6).toFixed(3),"M");if(e>1e3)return"".concat(+(e/1e3).toFixed(3),"K")}return"".concat(t)}function U(t,e){var i="".concat(t);if(0===e.length)return i;if(i.includes(".")){var r=i.split(".");return"".concat(r[0].replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)})),".").concat(r[1])}return i.replace(/(\d)(?=(\d{3})+$)/g,(function(t){return"".concat(t).concat(e)}))}function G(t,e){var i="".concat(t);if(new RegExp("\\.0{"+e+",}[1-9][0-9]*$").test(i)){var r=i.split("."),n=r.length-1,o=r[n],a=/0*/.exec(o);if(f(a)){var s=a[0].length;return r[n]=o.replace(/0*/,"0{".concat(s,"}")),r.join(".")}}return i}function Z(t,e){return t.replace(/\{(\w+)\}/g,(function(t,i){var r=e[i];return f(r)?r:"{".concat(i,"}")}))}var q="candle_pane",j="indicator_pane_",K="x_axis_pane";var Q=function(){function t(t){this.scrollZoomEnabled=!0,this._range={from:0,to:0,range:0,realFrom:0,realTo:0,realRange:0,displayFrom:0,displayTo:0,displayRange:0},this._prevRange={from:0,to:0,range:0,realFrom:0,realTo:0,realRange:0,displayFrom:0,displayTo:0,displayRange:0},this._ticks=[],this._autoCalcTickFlag=!0,this._parent=t}return t.prototype.getParent=function(){return this._parent},t.prototype.buildTicks=function(t){return this._autoCalcTickFlag&&(this._range=this.createRangeImp()),!(this._prevRange.from===this._range.from&&this._prevRange.to===this._range.to&&!t)&&(this._prevRange=this._range,this._ticks=this.createTicksImp(),!0)},t.prototype.getTicks=function(){return this._ticks},t.prototype.setRange=function(t){this._autoCalcTickFlag=!1,this._range=t},t.prototype.getRange=function(){return this._range},t.prototype.setAutoCalcTickFlag=function(t){this._autoCalcTickFlag=t},t.prototype.getAutoCalcTickFlag=function(){return this._autoCalcTickFlag},t}(),$="yAxis_",J=function(t){function e(e,i){var r=t.call(this,e)||this;r.id="",r.paneId="",r.reverse=!1,r.inside=!1,r.position="right",r.gap={top:.2,bottom:.1},r.createRange=function(t){return t.defaultRange},r.minSpan=function(t){return L(-t)},r.valueToRealValue=function(t){return t},r.realValueToDisplayValue=function(t){return t},r.displayValueToRealValue=function(t){return t},r.realValueToValue=function(t){return t},r.displayValueToText=function(t,e){return H(t,e)};var o=i.minSpan,a=i.valueToRealValue,s=i.realValueToDisplayValue,l=i.displayValueToRealValue,u=i.realValueToValue,c=i.displayValueToText,h=n(i,["minSpan","valueToRealValue","realValueToDisplayValue","displayValueToRealValue","realValueToValue","displayValueToText"]);return p(o)&&(r.minSpan=o),p(a)&&(r.valueToRealValue=a),p(s)&&(r.realValueToDisplayValue=s),p(l)&&(r.displayValueToRealValue=l),p(u)&&(r.realValueToValue=u),p(c)&&(r.displayValueToText=c),r.override(h),r}return i(e,t),e.prototype.override=function(t){var e=t.id,i=t.name,r=t.gap,o=n(t,["id","name","gap"]);f(e)&&0===this.id.length&&(this.id=e),!m(this.name)&&m(i)&&(this.name=i),c(this.gap,r),c(this,o)},e.prototype._getIndicatorsByYAxisIds=function(){var t=this.getParent(),e=new Set([this.id]);if(t.isManualYAxis(this.id)){var i=t.getDefaultYAxisId();f(i)&&e.add(i)}return t.getChart().getChartStore().getIndicatorsByPaneId(t.getId()).filter((function(t){return e.has(t.yAxisId)}))},e.prototype._shouldUseCandleData=function(){var t=this.getParent();return this.isInCandle()&&(t.isDefaultYAxis(this.id)||t.isManualYAxis(this.id))},e.prototype.createRangeImp=function(){var t,e,i=this.getParent(),r=i.getChart(),n=r.getChartStore(),o=i.getId(),a=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,l=!1,u=Number.MAX_SAFE_INTEGER,c=Number.MIN_SAFE_INTEGER,h=Number.MAX_SAFE_INTEGER,d=this._getIndicatorsByYAxisIds();d.forEach((function(t){l||(l=t.shouldOhlc),h=Math.min(h,t.precision),v(t.minValue)&&(u=Math.min(u,t.minValue)),v(t.maxValue)&&(c=Math.max(c,t.maxValue))}));var p=4,g=this.isInCandle();if(g){var y=null!==(e=null===(t=n.getSymbol())||void 0===t?void 0:t.pricePrecision)&&void 0!==e?e:O;p=h!==Number.MAX_SAFE_INTEGER?Math.min(h,y):y}else h!==Number.MAX_SAFE_INTEGER&&(p=h);var m=n.getVisibleRangeDataList(),_=r.getStyles().candle,x="area"===_.type,b=_.area.value,w=this._shouldUseCandleData(),C=w&&!x||!g&&l;m.forEach((function(t){var e=t.dataIndex,i=t.data.current;if(f(i)&&(C&&(a=Math.min(a,i.low),s=Math.max(s,i.high)),w&&x)){var r=i[b];v(r)&&(a=Math.min(a,r),s=Math.max(s,r))}d.forEach((function(t){var i,r=t.result,n=t.figures,o=null!==(i=r[e])&&void 0!==i?i:{};n.forEach((function(t){var e=o[t.key];v(e)&&(a=Math.min(a,e),s=Math.max(s,e))}))}))})),a!==Number.MAX_SAFE_INTEGER&&s!==Number.MIN_SAFE_INTEGER?(a=Math.min(u,a),s=Math.max(c,s)):(a=0,s=10);var E=s-a,T={from:a,to:s,range:E,realFrom:a,realTo:s,realRange:E,displayFrom:a,displayTo:s,displayRange:E},I=this.createRange({chart:r,paneId:o,defaultRange:T}),S=I.realFrom,A=I.realTo,M=I.realRange,P=this.minSpan(p);if(S===A||M<P){var D=u===S,k=c===A;S=D?S:k?S-8*P:S-4*P,A=k?A:D?A+8*P:A+4*P}var B=this.getBounding().height,F=this.gap,R=F.top;R>=1&&(R/=B);var L=F.bottom;L>=1&&(L/=B),S-=(M=A-S)*L,A+=M*R;var Y=this.realValueToValue(S,{range:I}),W=this.realValueToValue(A,{range:I}),z=this.realValueToDisplayValue(S,{range:I}),V=this.realValueToDisplayValue(A,{range:I});return{from:Y,to:W,range:W-Y,realFrom:S,realTo:A,realRange:A-S,displayFrom:z,displayTo:V,displayRange:V-z}},e.prototype.isInCandle=function(){return this.getParent().getId()===q},e.prototype.isFromZero=function(){return"left"===this.position&&this.inside||"right"===this.position&&!this.inside},e.prototype.createTicksImp=function(){var t,e,i=this,r=this.getRange(),n=r.displayFrom,o=r.displayTo,a=r.displayRange,s=[];if(a>=0){var l=function(t){var e=Math.floor(R(t)),i=L(e),r=t/i;return+(t=(r<1.5?1:r<2.5?2:r<3.5?3:r<4.5?4:r<5.5?5:r<6.5?6:8)*i).toFixed(Math.abs(e))}(a/8),u=function(t){var e=t.toString(),i=e.indexOf("e");if(i>0){var r=+e.slice(i+1);return r<0?-r:0}var n=e.indexOf(".");return n<0?0:e.length-1-n}(l),c=B(Math.ceil(n/l)*l,u),h=B(Math.floor(o/l)*l,u),d=0,g=c;if(0!==l)for(;g<=h;){var f=g.toFixed(u);s[d]={text:f,coord:0,value:f},++d,g+=l}}var y=this.getParent(),m=this.getBounding().height,_=y.getChart().getChartStore(),x=[],b=this._getIndicatorsByYAxisIds(),w=_.getStyles(),C=0,E=!1;this._shouldUseCandleData()?C=null!==(e=null===(t=_.getSymbol())||void 0===t?void 0:t.pricePrecision)&&void 0!==e?e:O:b.forEach((function(t){C=Math.max(C,t.precision),E||(E=t.shouldFormatBigNumber)}));var T=_.getInnerFormatter(),I=_.getThousandsSeparator(),S=_.getDecimalFold(),A=w.xAxis.tickText.size,M=NaN;return s.forEach((function(t){var e=t.value,n=i.displayValueToText(+e,C),o=i.convertToPixel(i.realValueToValue(i.displayValueToRealValue(+e,{range:r}),{range:r}));E&&(n=T.formatBigNumber(e)),n=S.format(I.format(n));var a=v(M);o>A&&o<m-A&&(a&&Math.abs(M-o)>2*A||!a)&&(x.push({text:n,coord:o,value:e}),M=o)})),p(this.createTicks)?this.createTicks({range:this.getRange(),bounding:this.getBounding(),defaultTicks:x}):x},e.prototype.getAutoSize=function(){var t,e,i=this.getParent().getChart().getChartStore(),r=i.getStyles(),n=r.yAxis,o=n.size;if("auto"!==o)return o;var a=0;if(n.show&&(n.axisLine.show&&(a+=n.axisLine.size),n.tickLine.show&&(a+=n.tickLine.length),n.tickText.show)){var s=0;this.getTicks().forEach((function(t){s=Math.max(s,S(t.text,n.tickText.size,n.tickText.weight,n.tickText.family))})),a+=n.tickText.marginStart+n.tickText.marginEnd+s}var l=r.candle.priceMark,u=l.show&&l.last.show&&l.last.text.show,c=0,h=r.crosshair,d=h.show&&h.horizontal.show&&h.horizontal.text.show,p=0;if(u||d){var g=null!==(e=null===(t=i.getSymbol())||void 0===t?void 0:t.pricePrecision)&&void 0!==e?e:O,v=this.getRange().displayTo;if(u){var y=i.getDataList(),m=y[y.length-1];if(f(m)){var _=l.last.text,x=_.paddingLeft,b=_.paddingRight,w=_.size,C=_.family,E=_.weight;c=x+S(H(m.close,g),w,E,C)+b;var T=i.getInnerFormatter().formatExtendText;l.last.extendTexts.forEach((function(t,e){var i=T({type:"last_price",data:m,index:e});i.length>0&&t.show&&(c=Math.max(c,t.paddingLeft+S(i,t.size,t.weight,t.family)+t.paddingRight))}))}}if(d){var I=this._getIndicatorsByYAxisIds(),A=0,M=!1;I.forEach((function(t){A=Math.max(t.precision,A),M||(M=t.shouldFormatBigNumber)}));var P=2;if(this._shouldUseCandleData()){var D=r.indicator.lastValueMark;P=D.show&&D.text.show?Math.max(A,g):g}else P=A;var k=H(v,P);M&&(k=i.getInnerFormatter().formatBigNumber(k)),k=i.getDecimalFold().format(k),p+=h.horizontal.text.paddingLeft+h.horizontal.text.paddingRight+2*h.horizontal.text.borderSize+S(k,h.horizontal.text.size,h.horizontal.text.weight,h.horizontal.text.family)}}return Math.max(a,c,p)},e.prototype.getBounding=function(){var t,e;return null!==(e=null===(t=this.getParent().getYAxisWidgetById(this.id))||void 0===t?void 0:t.getBounding())&&void 0!==e?e:this.getParent().getMainWidget().getBounding()},e.prototype.convertFromPixel=function(t){var e=this.getBounding().height,i=this.getRange(),r=i.realFrom,n=i.realRange,o=(this.reverse?t/e:1-t/e)*n+r;return this.realValueToValue(o,{range:i})},e.prototype.convertToPixel=function(t){var e=this.getRange(),i=this.valueToRealValue(t,{range:e}),r=this.getBounding().height,n=(i-e.realFrom)/e.realRange;return this.reverse?Math.round(n*r):Math.round((1-n)*r)},e.prototype.convertToNicePixel=function(t){var e=this.getBounding().height,i=this.convertToPixel(t);return Math.round(Math.max(.05*e,Math.min(i,.98*e)))},e.extend=function(t){var r=function(e){function r(i){return e.call(this,i,t)||this}return i(r,e),r}(e);return r},e}(Q);function tt(){return"undefined"!=typeof window&&window.navigator.userAgent.toLowerCase().includes("firefox")}function et(){return"undefined"!=typeof window&&/iPhone|iPad|iPod|iOS/.test(window.navigator.userAgent)}var it,rt=500,nt=500,ot=500,at=5,st=5,lt=5,ut=30,ct=0,ht=1,dt=2,pt=function(){function t(t,e,i){var r=this;this._clickCount=0,this._clickTimeoutId=null,this._clickCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._tapCount=0,this._tapTimeoutId=null,this._tapCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY},this._longTapTimeoutId=null,this._longTapActive=!1,this._mouseMoveStartCoordinate=null,this._touchMoveStartCoordinate=null,this._touchMoveExceededManhattanDistance=!1,this._cancelClick=!1,this._cancelTap=!1,this._unsubscribeOutsideMouseEvents=null,this._unsubscribeOutsideTouchEvents=null,this._unsubscribeMobileSafariEvents=null,this._unsubscribeMousemove=null,this._unsubscribeMouseWheel=null,this._unsubscribeContextMenu=null,this._unsubscribeRootMouseEvents=null,this._unsubscribeRootTouchEvents=null,this._startPinchMiddleCoordinate=null,this._startPinchDistance=0,this._pinchPrevented=!1,this._preventTouchDragProcess=!1,this._mousePressed=!1,this._lastTouchEventTimeStamp=0,this._activeTouchId=null,this._acceptMouseLeave=!et(),this._onFirefoxOutsideMouseUp=function(t){r._mouseUpHandler(t)},this._onMobileSafariDoubleClick=function(t){r._firesTouchEvents(t)?(++r._tapCount,null!==r._tapTimeoutId&&r._tapCount>1&&(r._mouseTouchMoveWithDownInfo(r._getCoordinate(t),r._tapCoordinate).manhattanDistance<ut&&!r._cancelTap&&r._processEvent(r._makeCompatEvent(t),r._handler.doubleTapEvent),r._resetTapTimeout())):(++r._clickCount,null!==r._clickTimeoutId&&r._clickCount>1&&(r._mouseTouchMoveWithDownInfo(r._getCoordinate(t),r._clickCoordinate).manhattanDistance<lt&&!r._cancelClick&&r._processEvent(r._makeCompatEvent(t),r._handler.mouseDoubleClickEvent),r._resetClickTimeout()))},this._target=t,this._handler=e,this._options=i,this._init()}return t.prototype.destroy=function(){null!==this._unsubscribeOutsideMouseEvents&&(this._unsubscribeOutsideMouseEvents(),this._unsubscribeOutsideMouseEvents=null),null!==this._unsubscribeOutsideTouchEvents&&(this._unsubscribeOutsideTouchEvents(),this._unsubscribeOutsideTouchEvents=null),null!==this._unsubscribeMousemove&&(this._unsubscribeMousemove(),this._unsubscribeMousemove=null),null!==this._unsubscribeMouseWheel&&(this._unsubscribeMouseWheel(),this._unsubscribeMouseWheel=null),null!==this._unsubscribeContextMenu&&(this._unsubscribeContextMenu(),this._unsubscribeContextMenu=null),null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null),null!==this._unsubscribeMobileSafariEvents&&(this._unsubscribeMobileSafariEvents(),this._unsubscribeMobileSafariEvents=null),this._clearLongTapTimeout(),this._resetClickTimeout()},t.prototype._mouseEnterHandler=function(t){var e,i,r,n=this;null===(e=this._unsubscribeMousemove)||void 0===e||e.call(this),null===(i=this._unsubscribeMouseWheel)||void 0===i||i.call(this),null===(r=this._unsubscribeContextMenu)||void 0===r||r.call(this);var o=this._mouseMoveHandler.bind(this);this._unsubscribeMousemove=function(){n._target.removeEventListener("mousemove",o)},this._target.addEventListener("mousemove",o);var a=this._mouseWheelHandler.bind(this);this._unsubscribeMouseWheel=function(){n._target.removeEventListener("wheel",a)},this._target.addEventListener("wheel",a,{passive:!1});var s=this._contextMenuHandler.bind(this);this._unsubscribeContextMenu=function(){n._target.removeEventListener("contextmenu",s)},this._target.addEventListener("contextmenu",s,{passive:!1}),this._firesTouchEvents(t)||(this._processEvent(this._makeCompatEvent(t),this._handler.mouseEnterEvent),this._acceptMouseLeave=!0)},t.prototype._resetClickTimeout=function(){null!==this._clickTimeoutId&&clearTimeout(this._clickTimeoutId),this._clickCount=0,this._clickTimeoutId=null,this._clickCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}},t.prototype._resetTapTimeout=function(){null!==this._tapTimeoutId&&clearTimeout(this._tapTimeoutId),this._tapCount=0,this._tapTimeoutId=null,this._tapCoordinate={x:Number.NEGATIVE_INFINITY,y:Number.POSITIVE_INFINITY}},t.prototype._mouseMoveHandler=function(t){this._mousePressed||null!==this._touchMoveStartCoordinate||this._firesTouchEvents(t)||(this._processEvent(this._makeCompatEvent(t),this._handler.mouseMoveEvent),this._acceptMouseLeave=!0)},t.prototype._mouseWheelHandler=function(t){if(Math.abs(t.deltaX)>Math.abs(t.deltaY)){if(!f(this._handler.mouseWheelHortEvent))return;if(this._preventDefault(t),0===Math.abs(t.deltaX))return;this._handler.mouseWheelHortEvent(this._makeCompatEvent(t),-t.deltaX)}else{if(!f(this._handler.mouseWheelVertEvent))return;var e=-t.deltaY/100;if(0===e)return;switch(this._preventDefault(t),t.deltaMode){case t.DOM_DELTA_PAGE:e*=120;break;case t.DOM_DELTA_LINE:e*=32}if(0!==e){var i=Math.sign(e)*Math.min(1,Math.abs(e));this._handler.mouseWheelVertEvent(this._makeCompatEvent(t),i)}}},t.prototype._contextMenuHandler=function(t){this._preventDefault(t)},t.prototype._touchMoveHandler=function(t){var e=this._touchWithId(t.changedTouches,this._activeTouchId);if(null!==e&&(this._lastTouchEventTimeStamp=this._eventTimeStamp(t),null===this._startPinchMiddleCoordinate&&!this._preventTouchDragProcess)){this._pinchPrevented=!0;var i=this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._touchMoveStartCoordinate),r=i.xOffset,n=i.yOffset,o=i.manhattanDistance;if(this._touchMoveExceededManhattanDistance||!(o<st)){if(!this._touchMoveExceededManhattanDistance){var a=.5*r,s=n>=a&&!this._options.treatVertDragAsPageScroll(),l=a>n&&!this._options.treatHorzDragAsPageScroll();s||l||(this._preventTouchDragProcess=!0),this._touchMoveExceededManhattanDistance=!0,this._cancelTap=!0,this._clearLongTapTimeout(),this._resetTapTimeout()}this._preventTouchDragProcess||(this._processEvent(this._makeCompatEvent(t,e),this._handler.touchMoveEvent),this._preventDefault(t))}}},t.prototype._mouseMoveWithDownHandler=function(t){t.button===ct&&(this._mouseTouchMoveWithDownInfo(this._getCoordinate(t),this._mouseMoveStartCoordinate).manhattanDistance>=at&&(this._cancelClick=!0,this._resetClickTimeout()),this._cancelClick&&this._processEvent(this._makeCompatEvent(t),this._handler.pressedMouseMoveEvent))},t.prototype._mouseTouchMoveWithDownInfo=function(t,e){var i=Math.abs(e.x-t.x),r=Math.abs(e.y-t.y);return{xOffset:i,yOffset:r,manhattanDistance:i+r}},t.prototype._touchEndHandler=function(t){var e=this._touchWithId(t.changedTouches,this._activeTouchId);if(null===e&&0===t.touches.length&&(e=t.changedTouches[0]),null!==e){this._activeTouchId=null,this._lastTouchEventTimeStamp=this._eventTimeStamp(t),this._clearLongTapTimeout(),this._touchMoveStartCoordinate=null,null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);var i=this._makeCompatEvent(t,e);if(this._processEvent(i,this._handler.touchEndEvent),++this._tapCount,null!==this._tapTimeoutId&&this._tapCount>1)this._mouseTouchMoveWithDownInfo(this._getCoordinate(e),this._tapCoordinate).manhattanDistance<ut&&!this._cancelTap&&this._processEvent(i,this._handler.doubleTapEvent),this._resetTapTimeout();else this._cancelTap||(this._processEvent(i,this._handler.tapEvent),f(this._handler.tapEvent)&&this._preventDefault(t));0===this._tapCount&&this._preventDefault(t),0===t.touches.length&&this._longTapActive&&(this._longTapActive=!1,this._preventDefault(t))}},t.prototype._mouseUpHandler=function(t){if(t.button===ct){var e=this._makeCompatEvent(t);if(this._mouseMoveStartCoordinate=null,this._mousePressed=!1,null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null),tt())this._target.ownerDocument.documentElement.removeEventListener("mouseleave",this._onFirefoxOutsideMouseUp);if(!this._firesTouchEvents(t))if(this._processEvent(e,this._handler.mouseUpEvent),++this._clickCount,null!==this._clickTimeoutId&&this._clickCount>1)this._mouseTouchMoveWithDownInfo(this._getCoordinate(t),this._clickCoordinate).manhattanDistance<lt&&!this._cancelClick&&this._processEvent(e,this._handler.mouseDoubleClickEvent),this._resetClickTimeout();else this._cancelClick||this._processEvent(e,this._handler.mouseClickEvent)}},t.prototype._clearLongTapTimeout=function(){null!==this._longTapTimeoutId&&(clearTimeout(this._longTapTimeoutId),this._longTapTimeoutId=null)},t.prototype._touchStartHandler=function(t){if(null===this._activeTouchId){var e=t.changedTouches[0];this._activeTouchId=e.identifier,this._lastTouchEventTimeStamp=this._eventTimeStamp(t);var i=this._target.ownerDocument.documentElement;this._cancelTap=!1,this._touchMoveExceededManhattanDistance=!1,this._preventTouchDragProcess=!1,this._touchMoveStartCoordinate=this._getCoordinate(e),null!==this._unsubscribeRootTouchEvents&&(this._unsubscribeRootTouchEvents(),this._unsubscribeRootTouchEvents=null);var r=this._touchMoveHandler.bind(this),n=this._touchEndHandler.bind(this);this._unsubscribeRootTouchEvents=function(){i.removeEventListener("touchmove",r),i.removeEventListener("touchend",n)},i.addEventListener("touchmove",r,{passive:!1}),i.addEventListener("touchend",n,{passive:!1}),this._clearLongTapTimeout(),this._longTapTimeoutId=setTimeout(this._longTapHandler.bind(this,t),nt),this._processEvent(this._makeCompatEvent(t,e),this._handler.touchStartEvent),null===this._tapTimeoutId&&(this._tapCount=0,this._tapTimeoutId=setTimeout(this._resetTapTimeout.bind(this),rt),this._tapCoordinate=this._getCoordinate(e))}},t.prototype._mouseDownHandler=function(t){if(t.button===dt)return this._preventDefault(t),void this._processEvent(this._makeCompatEvent(t),this._handler.mouseRightClickEvent);if(t.button===ct){var e=this._target.ownerDocument.documentElement;tt()&&e.addEventListener("mouseleave",this._onFirefoxOutsideMouseUp),this._cancelClick=!1,this._mouseMoveStartCoordinate=this._getCoordinate(t),null!==this._unsubscribeRootMouseEvents&&(this._unsubscribeRootMouseEvents(),this._unsubscribeRootMouseEvents=null);var i=this._mouseMoveWithDownHandler.bind(this),r=this._mouseUpHandler.bind(this);this._unsubscribeRootMouseEvents=function(){e.removeEventListener("mousemove",i),e.removeEventListener("mouseup",r)},e.addEventListener("mousemove",i),e.addEventListener("mouseup",r),this._mousePressed=!0,this._firesTouchEvents(t)||(this._processEvent(this._makeCompatEvent(t),this._handler.mouseDownEvent),null===this._clickTimeoutId&&(this._clickCount=0,this._clickTimeoutId=setTimeout(this._resetClickTimeout.bind(this),rt),this._clickCoordinate=this._getCoordinate(t)))}},t.prototype._init=function(){var t=this;this._target.addEventListener("mouseenter",this._mouseEnterHandler.bind(this)),this._target.addEventListener("touchcancel",this._clearLongTapTimeout.bind(this));var e=this._target.ownerDocument,i=function(e){null!=t._handler.mouseDownOutsideEvent&&(e.composed&&t._target.contains(e.composedPath()[0])||null!==e.target&&t._target.contains(e.target)||t._handler.mouseDownOutsideEvent({x:0,y:0,pageX:0,pageY:0}))};this._unsubscribeOutsideTouchEvents=function(){e.removeEventListener("touchstart",i)},this._unsubscribeOutsideMouseEvents=function(){e.removeEventListener("mousedown",i)},e.addEventListener("mousedown",i),e.addEventListener("touchstart",i,{passive:!0}),et()&&(this._unsubscribeMobileSafariEvents=function(){t._target.removeEventListener("dblclick",t._onMobileSafariDoubleClick)},this._target.addEventListener("dblclick",this._onMobileSafariDoubleClick)),this._target.addEventListener("mouseleave",this._mouseLeaveHandler.bind(this)),this._target.addEventListener("touchstart",this._touchStartHandler.bind(this),{passive:!0}),this._target.addEventListener("mousedown",(function(t){if(t.button===ht)return t.preventDefault(),!1})),this._target.addEventListener("mousedown",this._mouseDownHandler.bind(this)),this._initPinch(),this._target.addEventListener("touchmove",(function(){}),{passive:!1})},t.prototype._initPinch=function(){var t=this;(f(this._handler.pinchStartEvent)||f(this._handler.pinchEvent)||f(this._handler.pinchEndEvent))&&(this._target.addEventListener("touchstart",(function(e){t._checkPinchState(e.touches)}),{passive:!0}),this._target.addEventListener("touchmove",(function(e){if(2===e.touches.length&&null!==t._startPinchMiddleCoordinate&&f(t._handler.pinchEvent)){var i=t._getTouchDistance(e.touches[0],e.touches[1])/t._startPinchDistance;t._handler.pinchEvent(r(r({},t._startPinchMiddleCoordinate),{pageX:0,pageY:0}),i),t._preventDefault(e)}}),{passive:!1}),this._target.addEventListener("touchend",(function(e){t._checkPinchState(e.touches)})))},t.prototype._checkPinchState=function(t){1===t.length&&(this._pinchPrevented=!1),2!==t.length||this._pinchPrevented||this._longTapActive?this._stopPinch():this._startPinch(t)},t.prototype._startPinch=function(t){var e=this._target.getBoundingClientRect();this._startPinchMiddleCoordinate={x:(t[0].clientX-e.left+(t[1].clientX-e.left))/2,y:(t[0].clientY-e.top+(t[1].clientY-e.top))/2},this._startPinchDistance=this._getTouchDistance(t[0],t[1]),f(this._handler.pinchStartEvent)&&this._handler.pinchStartEvent({x:0,y:0,pageX:0,pageY:0}),this._clearLongTapTimeout()},t.prototype._stopPinch=function(){null!==this._startPinchMiddleCoordinate&&(this._startPinchMiddleCoordinate=null,f(this._handler.pinchEndEvent)&&this._handler.pinchEndEvent({x:0,y:0,pageX:0,pageY:0}))},t.prototype._mouseLeaveHandler=function(t){var e,i,r;null===(e=this._unsubscribeMousemove)||void 0===e||e.call(this),null===(i=this._unsubscribeMouseWheel)||void 0===i||i.call(this),null===(r=this._unsubscribeContextMenu)||void 0===r||r.call(this),this._firesTouchEvents(t)||this._acceptMouseLeave&&(this._processEvent(this._makeCompatEvent(t),this._handler.mouseLeaveEvent),this._acceptMouseLeave=!et())},t.prototype._longTapHandler=function(t){var e=this._touchWithId(t.touches,this._activeTouchId);null!==e&&(this._processEvent(this._makeCompatEvent(t,e),this._handler.longTapEvent),this._cancelTap=!0,this._longTapActive=!0)},t.prototype._firesTouchEvents=function(t){var e;return f(null===(e=t.sourceCapabilities)||void 0===e?void 0:e.firesTouchEvents)?t.sourceCapabilities.firesTouchEvents:this._eventTimeStamp(t)<this._lastTouchEventTimeStamp+ot},t.prototype._processEvent=function(t,e){null==e||e.call(this._handler,t)},t.prototype._makeCompatEvent=function(t,e){var i=this,r=null!=e?e:t,n=this._target.getBoundingClientRect();return{x:r.clientX-n.left,y:r.clientY-n.top,pageX:r.pageX,pageY:r.pageY,isTouch:!t.type.startsWith("mouse")&&"contextmenu"!==t.type&&"click"!==t.type&&"wheel"!==t.type,preventDefault:function(){"touchstart"!==t.type&&i._preventDefault(t)}}},t.prototype._getTouchDistance=function(t,e){var i=t.clientX-e.clientX,r=t.clientY-e.clientY;return Math.sqrt(i*i+r*r)},t.prototype._preventDefault=function(t){t.cancelable&&t.preventDefault()},t.prototype._getCoordinate=function(t){return{x:t.pageX,y:t.pageY}},t.prototype._eventTimeStamp=function(t){var e;return null!==(e=t.timeStamp)&&void 0!==e?e:performance.now()},t.prototype._touchWithId=function(t,e){for(var i=0;i<t.length;++i)if(t[i].identifier===e)return t[i];return null},t}(),gt={name:"scrollLeft",keys:"Shift+ArrowLeft",action:function(t){var e=t.chart;e.scrollByDistance(-3*e.getBarSpace().bar)}},vt={name:"scrollRight",keys:"Shift+ArrowRight",action:function(t){var e=t.chart;e.scrollByDistance(3*e.getBarSpace().bar)}},ft={name:"zoomIn",keys:["Shift+Equal","Shift+NumpadAdd"],action:function(t){t.chart.zoomAtCoordinate(1.05)}},yt={name:"zoomOut",keys:["Shift+Minus","Shift+NumpadSubtract"],action:function(t){t.chart.zoomAtCoordinate(.95)}},mt=((it={})[gt.name]=gt,it[vt.name]=vt,it[ft.name]=ft,it[yt.name]=yt,it);function _t(t){var e;return null!==(e=mt[t])&&void 0!==e?e:null}function xt(){return Object.keys(mt)}var bt="main",wt="xAxis",Ct="yAxis",Et="separator",Tt=.975,It=1e3/60,St={command:"meta",cmd:"meta",control:"ctrl",option:"alt",mod:/Mac|iPhone|iPad|iPod|iOS/.test(window.navigator.userAgent)?"meta":"ctrl"},At={"+":"equal",plus:"equal",add:"equal",numpadadd:"equal","-":"minus",subtract:"minus",numpadsubtract:"minus",esc:"escape",del:"delete",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown"},Mt=["ctrl","alt","shift","meta"],Pt=function(){function t(t,e){var i=this;this._flingStartTime=performance.now(),this._flingScrollAnimation=null,this._startScrollCoordinate=null,this._touchCoordinate=null,this._touchCancelCrosshair=!1,this._touchZoomed=!1,this._pinchScale=1,this._mouseDownWidget=null,this._prevYAxisRanges=new Map,this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0,this._mouseMoveTriggerWidgetInfo={pane:null,widget:null},this._boundKeyBoardDownEvent=function(t){var e,r,n,o=t.target,a=null==o?void 0:o.tagName.toLowerCase();if("input"!==a&&"textarea"!==a&&!0!==(null==o?void 0:o.isContentEditable)){var s=i._chart.getHotKey(),c=s.enabled,h=s.exclude;if(c){var g=[];t.ctrlKey&&g.push("ctrl"),t.altKey&&g.push("alt"),t.shiftKey&&g.push("shift"),t.metaKey&&g.push("meta");var v=t.code.trim().toLowerCase();/^key[a-z]$/.test(v)?g.push(v.slice(3)):/^digit[0-9]$/.test(v)?g.push(v.slice(5)):g.push(null!==(e=At[v])&&void 0!==e?e:v);for(var y=g.join("+"),m=xt(),_=m.length-1;_>=0;_--){var x=m[_],b=_t(x);if(!h.includes(x)&&f(b)){var w=(d(b.keys)?b.keys:[b.keys]).some((function(t){var e=[],i="";return t.replace(/\+\+$/,"+Plus").replace(/\+=$/,"+Equal").split("+").forEach((function(t){var r,n,o=(null!==(r=St[t.trim().toLowerCase()])&&void 0!==r?r:t).trim().toLowerCase(),a="";a=/^key[a-z]$/.test(o)?o.slice(3):/^digit[0-9]$/.test(o)?o.slice(5):null!==(n=At[o])&&void 0!==n?n:o,Mt.includes(a)?e.includes(a)||e.push(a):a.length>0&&(i=a)})),e.sort((function(t,e){return Mt.indexOf(t)-Mt.indexOf(e)})),u(u([],l(e),!1),[i],!1).filter((function(t){return t.length>0})).join("+")===y}));if(w){var C={chart:i._chart,event:t,key:y,hotkey:b};if(!p(b.check)||b.check(C))return(null===(r=b.preventDefault)||void 0===r||r)&&t.preventDefault(),null!==(n=b.stopPropagation)&&void 0!==n&&n&&t.stopPropagation(),void b.action(C)}}}}}},this._chart=e,this._event=new pt(t,this,{treatVertDragAsPageScroll:function(){return!1},treatHorzDragAsPageScroll:function(){return!1}}),document.addEventListener("keydown",this._boundKeyBoardDownEvent)}return t.prototype._getYAxisByWidget=function(t){return t.getName()===Ct?t.getAxisComponent():t.getPane().getYAxisComponentById()},t.prototype._getYAxisScaleTargetByWidget=function(t){var e=this._getYAxisByWidget(t),i=t.getPane();return i.isManualYAxis(e.id)?i.getYAxisComponentById():e},t.prototype._syncYAxisValueRange=function(t,e){var i=t.getRange(),r=e.from,n=e.to,o=t.valueToRealValue(r,{range:i}),a=t.valueToRealValue(n,{range:i}),s=t.realValueToDisplayValue(o,{range:i}),l=t.realValueToDisplayValue(a,{range:i});t.setRange({from:r,to:n,range:n-r,realFrom:o,realTo:a,realRange:a-o,displayFrom:s,displayTo:l,displayRange:l-s})},t.prototype._syncManualYAxesValueRange=function(t,e){var i=this,r=e.getRange();t.getPane().getYAxisComponents().forEach((function(n){var o=n;o!==e&&t.getPane().isManualYAxis(o.id)&&i._syncYAxisValueRange(o,r)}))},t.prototype._resetYAxisAndManualYAxes=function(t,e){e.setAutoCalcTickFlag(!0),t.getPane().getYAxisComponents().forEach((function(e){var i=e;t.getPane().isManualYAxis(i.id)&&i.setAutoCalcTickFlag(!0)})),this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0})},t.prototype.pinchStartEvent=function(){return this._touchZoomed=!0,this._pinchScale=1,!0},t.prototype.pinchEvent=function(t,e){void 0===e&&(e=1);var i=this._findWidgetByEvent(t),r=i.pane,n=i.widget;if((null==r?void 0:r.getId())!==K&&(null==n?void 0:n.getName())===bt){var o=this._makeWidgetEvent(t,n),a=5*(e-this._pinchScale);return this._pinchScale=e,this._chart.getChartStore().zoom(a,{x:o.x,y:o.y},"main"),!0}return!1},t.prototype.mouseWheelHortEvent=function(t,e){void 0===e&&(e=0);var i=this._chart.getChartStore();return i.startScroll(),i.scroll(e),!0},t.prototype.mouseWheelVertEvent=function(t,e){void 0===e&&(e=0);var i=this._findWidgetByEvent(t).widget,r=this._makeWidgetEvent(t,i),n=null==i?void 0:i.getName();if(n===bt)return this._chart.getChartStore().zoom(e,{x:r.x,y:r.y},"main"),!0;if(n===Ct){var o=i;if(this._getYAxisByWidget(o).scrollZoomEnabled){var a=1+.05*e,s=this._getYAxisScaleTargetByWidget(o);return this._zoomYAxis(s,a),this._syncManualYAxesValueRange(o,s),!0}}return!1},t.prototype.mouseDownEvent=function(t){var e,i,n=this._findWidgetByEvent(t),o=n.pane,a=n.widget;if(this._mouseDownWidget=a,null!==a){var l=this._makeWidgetEvent(t,a);switch(a.getName()){case Et:return a.dispatchEvent("mouseDownEvent",l);case bt:var u=a.dispatchEvent("mouseDownEvent",l);if(!u){var c=o.getYAxisComponents();try{for(var h=s(c),d=h.next();!d.done;d=h.next()){var p=d.value;if(!p.getAutoCalcTickFlag()){var g=p.getRange();this._prevYAxisRanges.set(p,r({},g))}}}catch(t){e={error:t}}finally{try{d&&!d.done&&(i=h.return)&&i.call(h)}finally{if(e)throw e.error}}this._startScrollCoordinate={x:l.x,y:l.y},this._chart.getChartStore().startScroll()}return u;case wt:return this._processXAxisScrollStartEvent(a,l);case Ct:return this._processYAxisScaleStartEvent(a,l)}}return!1},t.prototype.mouseMoveEvent=function(t){var e,i,r,n=this._findWidgetByEvent(t),o=n.pane,a=n.widget,s=this._makeWidgetEvent(t,a);if((null===(e=this._mouseMoveTriggerWidgetInfo.pane)||void 0===e?void 0:e.getId())===(null==o?void 0:o.getId())&&(null===(i=this._mouseMoveTriggerWidgetInfo.widget)||void 0===i?void 0:i.getName())===(null==a?void 0:a.getName())||(null==a||a.dispatchEvent("mouseEnterEvent",s),null===(r=this._mouseMoveTriggerWidgetInfo.widget)||void 0===r||r.dispatchEvent("mouseLeaveEvent",s),this._mouseMoveTriggerWidgetInfo={pane:o,widget:a}),null!==a)switch(a.getName()){case bt:var l=a.dispatchEvent("mouseMoveEvent",s),u={x:s.x,y:s.y,paneId:null==o?void 0:o.getId()};return l?("pointer"!==a.getForceCursor()&&(u=void 0),a.setCursor("pointer")):a.setCursor("crosshair"),this._chart.getChartStore().setCrosshair(u),l;case Et:case wt:case Ct:l=a.dispatchEvent("mouseMoveEvent",s);return this._chart.getChartStore().setCrosshair(),l}return!1},t.prototype.pressedMouseMoveEvent=function(t){var e,i;if(null!==this._mouseDownWidget&&this._mouseDownWidget.getName()===Et)return this._mouseDownWidget.dispatchEvent("pressedMouseMoveEvent",t);var r=this._findWidgetByEvent(t),n=r.pane,o=r.widget;if(null!==o&&(null===(e=this._mouseDownWidget)||void 0===e?void 0:e.getPane().getId())===(null==n?void 0:n.getId())&&(null===(i=this._mouseDownWidget)||void 0===i?void 0:i.getName())===o.getName()){var a=this._makeWidgetEvent(t,o);switch(o.getName()){case bt:var s=void 0,l=o.dispatchEvent("pressedMouseMoveEvent",a);return l?this._chart.updatePane(1):this._processMainScrollingEvent(o,a),l&&"pointer"!==o.getForceCursor()||(s={x:a.x,y:a.y,paneId:null==n?void 0:n.getId()}),this._chart.getChartStore().setCrosshair(s,{forceInvalidate:!0}),l;case wt:return this._processXAxisScrollingEvent(o,a);case Ct:return this._processYAxisScalingEvent(o,a)}}return!1},t.prototype.mouseUpEvent=function(t){var e=this._findWidgetByEvent(t).widget,i=!1;if(null!==e){var r=this._makeWidgetEvent(t,e);switch(e.getName()){case bt:case Et:case wt:case Ct:i=e.dispatchEvent("mouseUpEvent",r)}i&&this._chart.updatePane(1)}return this._mouseDownWidget=null,this._startScrollCoordinate=null,this._prevYAxisRanges.clear(),this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0,i},t.prototype.mouseClickEvent=function(t){var e=this._findWidgetByEvent(t).widget;if(null!==e){var i=this._makeWidgetEvent(t,e);return e.dispatchEvent("mouseClickEvent",i)}return!1},t.prototype.mouseRightClickEvent=function(t){var e=this._findWidgetByEvent(t).widget,i=!1;if(null!==e){var r=this._makeWidgetEvent(t,e);switch(e.getName()){case bt:case wt:case Ct:i=e.dispatchEvent("mouseRightClickEvent",r)}i&&this._chart.updatePane(1)}return!1},t.prototype.mouseDoubleClickEvent=function(t){var e=this._findWidgetByEvent(t).widget;if(null!==e)switch(e.getName()){case bt:var i=this._makeWidgetEvent(t,e);return e.dispatchEvent("mouseDoubleClickEvent",i);case Ct:var r=e,n=this._getYAxisByWidget(r),o=this._getYAxisScaleTargetByWidget(r);if(!o.getAutoCalcTickFlag()||!n.getAutoCalcTickFlag())return this._resetYAxisAndManualYAxes(r,o),!0}return!1},t.prototype.mouseLeaveEvent=function(){return this._chart.getChartStore().setCrosshair(),!0},t.prototype.touchStartEvent=function(t){var e,i,n,o=this._findWidgetByEvent(t),a=o.pane,l=o.widget;if(null!==l){var u=this._makeWidgetEvent(t,l);switch(null===(n=u.preventDefault)||void 0===n||n.call(u),l.getName()){case bt:var c=this._chart.getChartStore();if(l.dispatchEvent("mouseDownEvent",u))return this._touchCancelCrosshair=!0,this._touchCoordinate=null,c.setCrosshair(void 0,{notInvalidate:!0}),this._chart.updatePane(1),!0;null!==this._flingScrollAnimation&&(this._flingScrollAnimation.cancel(),this._flingScrollAnimation=null),this._flingStartTime=performance.now();var h=a.getYAxisComponents();try{for(var d=s(h),p=d.next();!p.done;p=d.next()){var g=p.value;if(!g.getAutoCalcTickFlag()){var v=g.getRange();this._prevYAxisRanges.set(g,r({},v))}}}catch(t){e={error:t}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}if(this._startScrollCoordinate={x:u.x,y:u.y},c.startScroll(),this._touchZoomed=!1,null!==this._touchCoordinate){var f=u.x-this._touchCoordinate.x,y=u.y-this._touchCoordinate.y;Math.sqrt(f*f+y*y)<10?(this._touchCoordinate={x:u.x,y:u.y},c.setCrosshair({x:u.x,y:u.y,paneId:null==a?void 0:a.getId()})):(this._touchCoordinate=null,this._touchCancelCrosshair=!0,c.setCrosshair())}return!0;case wt:return this._processXAxisScrollStartEvent(l,u);case Ct:return this._processYAxisScaleStartEvent(l,u)}}return!1},t.prototype.touchMoveEvent=function(t){var e,i,r,n=this._findWidgetByEvent(t),o=n.pane,a=n.widget;if(null!==a){var s=this._makeWidgetEvent(t,a),l=a.getName(),u=this._chart.getChartStore();switch(l){case bt:return a.dispatchEvent("pressedMouseMoveEvent",s)?(null===(e=s.preventDefault)||void 0===e||e.call(s),u.setCrosshair(void 0,{notInvalidate:!0}),this._chart.updatePane(1),!0):(null!==this._touchCoordinate?(null===(i=s.preventDefault)||void 0===i||i.call(s),u.setCrosshair({x:s.x,y:s.y,paneId:null==o?void 0:o.getId()})):this._processMainScrollingEvent(a,s),!0);case wt:return null===(r=s.preventDefault)||void 0===r||r.call(s),this._processXAxisScrollingEvent(a,s);case Ct:return this._processYAxisScalingEvent(a,s)}}return!1},t.prototype.touchEndEvent=function(t){var e=this,i=this._findWidgetByEvent(t).widget;if(null!==i){var r=this._makeWidgetEvent(t,i);switch(i.getName()){case bt:if(i.dispatchEvent("mouseUpEvent",r),null!==this._startScrollCoordinate){var n=performance.now()-this._flingStartTime,o=(r.x-this._startScrollCoordinate.x)/(n>0?n:1)*20;if(n<200&&Math.abs(o)>1){var a=this._chart.getChartStore(),s=Math.log(1/Math.abs(o))/Math.log(Tt)*It,l=new w({duration:s}).doFrame((function(t){var i=t/It,r=o*(1-Math.pow(Tt,i))/(1-Tt);a.scroll(r),t>=s&&e._flingScrollAnimation===l&&(e._flingScrollAnimation=null)}));a.startScroll(),this._flingScrollAnimation=l,l.start()}}return!0;case wt:case Ct:i.dispatchEvent("mouseUpEvent",r)&&this._chart.updatePane(1)}this._startScrollCoordinate=null,this._prevYAxisRanges.clear(),this._xAxisStartScaleCoordinate=null,this._xAxisStartScaleDistance=0,this._xAxisScale=1,this._yAxisStartScaleDistance=0}return!1},t.prototype.tapEvent=function(t){var e=this._findWidgetByEvent(t),i=e.pane,r=e.widget,n=!1;if(null!==r){var o=this._makeWidgetEvent(t,r),a=r.dispatchEvent("mouseClickEvent",o);if(r.getName()===bt){var s=this._makeWidgetEvent(t,r),l=this._chart.getChartStore();a?(this._touchCancelCrosshair=!0,this._touchCoordinate=null,l.setCrosshair(void 0,{notInvalidate:!0}),n=!0):(this._touchCancelCrosshair||this._touchZoomed||(this._touchCoordinate={x:s.x,y:s.y},l.setCrosshair({x:s.x,y:s.y,paneId:null==i?void 0:i.getId()},{notInvalidate:!0}),n=!0),this._touchCancelCrosshair=!1)}(n||a)&&this._chart.updatePane(1)}return n},t.prototype.doubleTapEvent=function(t){return this.mouseDoubleClickEvent(t)},t.prototype.longTapEvent=function(t){var e=this._findWidgetByEvent(t),i=e.pane,r=e.widget;if(null!==r&&r.getName()===bt){var n=this._makeWidgetEvent(t,r);return this._touchCoordinate={x:n.x,y:n.y},this._chart.getChartStore().setCrosshair({x:n.x,y:n.y,paneId:null==i?void 0:i.getId()}),!0}return!1},t.prototype._processMainScrollingEvent=function(t,e){var i,r,n;if(null!==this._startScrollCoordinate){var o=t.getPane().getYAxisComponents();try{for(var a=s(o),l=a.next();!l.done;l=a.next()){var u=l.value,c=this._prevYAxisRanges.get(u);if(f(c)&&!u.getAutoCalcTickFlag()&&u.scrollZoomEnabled){null===(n=e.preventDefault)||void 0===n||n.call(e);var h=c.from,d=c.to,p=c.range,g=p*((u.reverse?this._startScrollCoordinate.y-e.y:e.y-this._startScrollCoordinate.y)/t.getBounding().height),v=h+g,y=d+g,m=u.valueToRealValue(v,{range:c}),_=u.valueToRealValue(y,{range:c}),x=u.realValueToDisplayValue(m,{range:c}),b=u.realValueToDisplayValue(_,{range:c});u.setRange({from:v,to:y,range:y-v,realFrom:m,realTo:_,realRange:_-m,displayFrom:x,displayTo:b,displayRange:b-x})}}}catch(t){i={error:t}}finally{try{l&&!l.done&&(r=a.return)&&r.call(a)}finally{if(i)throw i.error}}var w=e.x-this._startScrollCoordinate.x;this._chart.getChartStore().scroll(w)}},t.prototype._processXAxisScrollStartEvent=function(t,e){var i=t.dispatchEvent("mouseDownEvent",e);return i&&this._chart.updatePane(1),this._xAxisStartScaleCoordinate={x:e.x,y:e.y},this._xAxisStartScaleDistance=e.pageX,i},t.prototype._processXAxisScrollingEvent=function(t,e){var i=t.dispatchEvent("pressedMouseMoveEvent",e);if(i)this._chart.updatePane(1);else if(t.getPane().getXAxisComponent().scrollZoomEnabled&&0!==this._xAxisStartScaleDistance){var r=this._xAxisStartScaleDistance/e.pageX;if(Number.isFinite(r)){var n=10*(r-this._xAxisScale);this._xAxisScale=r,this._chart.getChartStore().zoom(n,this._xAxisStartScaleCoordinate,"xAxis")}}return i},t.prototype._processYAxisScaleStartEvent=function(t,e){var i=t.dispatchEvent("mouseDownEvent",e);i&&this._chart.updatePane(1);var n=this._getYAxisScaleTargetByWidget(t),o=n.getRange();return this._prevYAxisRanges.set(n,r({},o)),this._yAxisStartScaleDistance=e.pageY,i},t.prototype._processYAxisScalingEvent=function(t,e){var i,r=t.dispatchEvent("pressedMouseMoveEvent",e);if(r)this._chart.updatePane(1);else{var n=this._getYAxisByWidget(t),o=this._getYAxisScaleTargetByWidget(t),a=this._prevYAxisRanges.get(o);if(f(a)&&n.scrollZoomEnabled&&0!==this._yAxisStartScaleDistance){null===(i=e.preventDefault)||void 0===i||i.call(e);var s=e.pageY/this._yAxisStartScaleDistance;this._zoomYAxis(o,s,a),this._syncManualYAxesValueRange(t,o)}}return r},t.prototype._zoomYAxis=function(t,e,i){var r=null!=i?i:t.getRange(),n=r.from,o=r.to,a=r.range,s=a*e,l=(s-a)/2,u=n-l,c=o+l,h=t.valueToRealValue(u,{range:r}),d=t.valueToRealValue(c,{range:r}),p=t.realValueToDisplayValue(h,{range:r}),g=t.realValueToDisplayValue(d,{range:r});t.setRange({from:u,to:c,range:s,realFrom:h,realTo:d,realRange:d-h,displayFrom:p,displayTo:g,displayRange:g-p}),this._chart.layout({measureWidth:!0,update:!0,buildYAxisTick:!0})},t.prototype._findWidgetByEvent=function(t){var e,i,r,n,o,a,l=t.x,u=t.y,c=this._chart.getSeparatorPanes(),h=this._chart.getStyles().separator.size;try{for(var d=s(c),p=d.next();!p.done;p=d.next()){var g=p.value[1],v=(b=g.getBounding()).top-Math.round((7-h)/2);if(l>=b.left&&l<=b.left+b.width&&u>=v&&u<=v+7)return{pane:g,widget:g.getWidget()}}}catch(t){e={error:t}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(e)throw e.error}}var y=this._chart.getDrawPanes(),m=null;try{for(var _=s(y),x=_.next();!x.done;x=_.next()){var b,w=x.value;if(l>=(b=w.getBounding()).left&&l<=b.left+b.width&&u>=b.top&&u<=b.top+b.height){m=w;break}}}catch(t){r={error:t}}finally{try{x&&!x.done&&(n=_.return)&&n.call(_)}finally{if(r)throw r.error}}var C=null;if(null!==m){if(!f(C)){var E=m.getMainWidget(),T=E.getBounding();l>=T.left&&l<=T.left+T.width&&u>=T.top&&u<=T.top+T