diff --git a/package-lock.json b/package-lock.json index c64d89450..decdc6817 100644 --- a/package-lock.json +++ b/package-lock.json @@ -20,7 +20,7 @@ "chart.js": "4.4.6", "chartjs-adapter-moment": "1.0.1", "chartjs-plugin-deferred": "2.0.0", - "chartjs-plugin-zoom": "2.0.1", + "chartjs-plugin-zoom": "2.1.0", "datatables.net-bs": "1.10.21", "datatables.net-buttons-bs": "1.7.1", "datatables.net-select-bs": "1.3.1", @@ -344,6 +344,11 @@ "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", "dev": true }, + "node_modules/@types/hammerjs": { + "version": "2.0.46", + "resolved": "https://registry.npmjs.org/@types/hammerjs/-/hammerjs-2.0.46.tgz", + "integrity": "sha512-ynRvcq6wvqexJ9brDMS4BnBLzmr0e14d6ZJTEShTBWKymQiHwlAyGu0ZPEFI2Fh1U53F7tN9ufClWM5KvqkKOw==" + }, "node_modules/@types/json-schema": { "version": "7.0.15", "resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz", @@ -1695,10 +1700,11 @@ } }, "node_modules/chartjs-plugin-zoom": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/chartjs-plugin-zoom/-/chartjs-plugin-zoom-2.0.1.tgz", - "integrity": "sha512-ogOmLu6e+Q7E1XWOCOz9YwybMslz9qNfGV2a+qjfmqJYpsw5ZMoRHZBUyW+NGhkpQ5PwwPA/+rikHpBZb7PZuA==", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/chartjs-plugin-zoom/-/chartjs-plugin-zoom-2.1.0.tgz", + "integrity": "sha512-7lMimfQCUaIJLhPJaWSAA4gw+1m8lyR3Wn+M3MxjHbM/XxRUnOxN7cM5RR9jUmxmyW0h7L2hZ8KhvUsqrFxy/Q==", "dependencies": { + "@types/hammerjs": "^2.0.45", "hammerjs": "^2.0.8" }, "peerDependencies": { diff --git a/package.json b/package.json index 7ddf666a8..d93e41426 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "chart.js": "4.4.6", "chartjs-adapter-moment": "1.0.1", "chartjs-plugin-deferred": "2.0.0", - "chartjs-plugin-zoom": "2.0.1", + "chartjs-plugin-zoom": "2.1.0", "datatables.net-bs": "1.10.21", "datatables.net-buttons-bs": "1.7.1", "datatables.net-select-bs": "1.3.1", diff --git a/vendor/chartjs-plugin-zoom/chartjs-plugin-zoom.min.js b/vendor/chartjs-plugin-zoom/chartjs-plugin-zoom.min.js index a6c55771b..0de1c4fab 100644 --- a/vendor/chartjs-plugin-zoom/chartjs-plugin-zoom.min.js +++ b/vendor/chartjs-plugin-zoom/chartjs-plugin-zoom.min.js @@ -1,7 +1,7 @@ /*! -* chartjs-plugin-zoom v2.0.1 -* undefined - * (c) 2016-2023 chartjs-plugin-zoom Contributors +* chartjs-plugin-zoom v2.1.0 +* https://www.chartjs.org/chartjs-plugin-zoom/2.1.0/ + * (c) 2016-2024 chartjs-plugin-zoom Contributors * Released under the MIT License */ -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("chart.js"),require("hammerjs"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["chart.js","hammerjs","chart.js/helpers"],t):(e="undefined"!=typeof globalThis?globalThis:e||self).ChartZoom=t(e.Chart,e.Hammer,e.Chart.helpers)}(this,(function(e,t,n){"use strict";function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var a=o(t);const i=e=>e&&e.enabled&&e.modifierKey,c=(e,t)=>e&&t[e+"Key"],r=(e,t)=>e&&!t[e+"Key"];function s(e,t,n){return void 0===e||("string"==typeof e?-1!==e.indexOf(t):"function"==typeof e&&-1!==e({chart:n}).indexOf(t))}function l(e,t){return"function"==typeof e&&(e=e({chart:t})),"string"==typeof e?{x:-1!==e.indexOf("x"),y:-1!==e.indexOf("y")}:{x:!1,y:!1}}function u(e,t,o){const{mode:a="xy",scaleMode:i,overScaleMode:c}=e||{},r=function({x:e,y:t},n){const o=n.scales,a=Object.keys(o);for(let n=0;n=i.top&&t<=i.bottom&&e>=i.left&&e<=i.right)return i}return null}(t,o),s=l(a,o),u=l(i,o);if(c){const e=l(c,o);for(const t of["x","y"])e[t]&&(u[t]=s[t],s[t]=!1)}if(r&&u[r.axis])return[r];const m=[];return n.each(o.scales,(function(e){s[e.axis]&&m.push(e)})),m}const m=new WeakMap;function d(e){let t=m.get(e);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{}},m.set(e,t)),t}function f(e,t,n){const o=e.max-e.min,a=o*(t-1),i=e.isHorizontal()?n.x:n.y,c=Math.max(0,Math.min(1,(e.getValueForPixel(i)-e.min)/o||0));return{min:a*c,max:a*(1-c)}}function p(e,t,o,a,i){let c=o[a];if("original"===c){const o=e.originalScaleLimits[t.id][a];c=n.valueOrDefault(o.options,o.scale)}return n.valueOrDefault(c,i)}function h(e,{min:t,max:n},o,a=!1){const i=d(e.chart),{id:c,axis:r,options:s}=e,l=o&&(o[c]||o[r])||{},{minRange:u=0}=l,m=p(i,e,l,"min",-1/0),f=p(i,e,l,"max",1/0),h=a?Math.max(n-t,u):e.max-e.min,x=(h-n+t)/2;return n+=x,(t-=x)f&&(n=f,t=Math.max(f-h,m)),s.min=t,s.max=n,i.updatedScaleLimits[e.id]={min:t,max:n},e.parse(t)!==e.min||e.parse(n)!==e.max}const x=e=>0===e||isNaN(e)?0:e<0?Math.min(Math.round(e),-1):Math.max(Math.round(e),1);const g={second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function y(e,t,n,o=!1){const{min:a,max:i,options:c}=e,r=c.time&&c.time.round,s=g[r]||0,l=e.getValueForPixel(e.getPixelForValue(a+s)-t),u=e.getValueForPixel(e.getPixelForValue(i+s)-t),{min:m=-1/0,max:d=1/0}=o&&n&&n[e.axis]||{};return!!(isNaN(l)||isNaN(u)||ld)||h(e,{min:l,max:u},n,o)}function b(e,t,n){return y(e,t,n,!0)}const v={category:function(e,t,n,o){const a=f(e,t,n);return e.min===e.max&&t<1&&function(e){const t=e.getLabels().length-1;e.min>0&&(e.min-=1),e.maxr&&(a=Math.max(0,a-s),i=1===c?a:a+c,l=0===a),h(e,{min:a,max:i},n)||l},default:y,logarithmic:b,timeseries:b};function M(e,t){n.each(e,((n,o)=>{t[o]||delete e[o]}))}function k(e,t){const{scales:o}=e,{originalScaleLimits:a,updatedScaleLimits:i}=t;return n.each(o,(function(e){(function(e,t,n){const{id:o,options:{min:a,max:i}}=e;if(!t[o]||!n[o])return!0;const c=n[o];return c.min!==a||c.max!==i})(e,a,i)&&(a[e.id]={min:{scale:e.min,options:e.options.min},max:{scale:e.max,options:e.options.max}})})),M(a,o),M(i,o),a}function S(e,t,o,a){const i=v[e.type]||v.default;n.callback(i,[e,t,o,a])}function P(e,t,o,a,i){const c=w[e.type]||w.default;n.callback(c,[e,t,o,a,i])}function D(e){const t=e.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function j(e,t,o="none"){const{x:a=1,y:i=1,focalPoint:c=D(e)}="number"==typeof t?{x:t,y:t}:t,r=d(e),{options:{limits:s,zoom:l}}=r;k(e,r);const m=1!==a,f=1!==i,p=u(l,c,e);n.each(p||e.scales,(function(e){e.isHorizontal()&&m?S(e,a,c,s):!e.isHorizontal()&&f&&S(e,i,c,s)})),e.update(o),n.callback(l.onZoom,[{chart:e}])}function O(e,t,o,a="none"){const i=d(e),{options:{limits:c,zoom:r}}=i,{mode:l="xy"}=r;k(e,i);const u=s(l,"x",e),m=s(l,"y",e);n.each(e.scales,(function(e){e.isHorizontal()&&u?P(e,t.x,o.x,c):!e.isHorizontal()&&m&&P(e,t.y,o.y,c)})),e.update(a),n.callback(r.onZoom,[{chart:e}])}function C(e){const t=d(e);let o=1,a=1;return n.each(e.scales,(function(e){const i=function(e,t){const o=e.originalScaleLimits[t];if(!o)return;const{min:a,max:i}=o;return n.valueOrDefault(i.options,i.scale)-n.valueOrDefault(a.options,a.scale)}(t,e.id);if(i){const t=Math.round(i/(e.max-e.min)*100)/100;o=Math.min(o,t),a=Math.max(a,t)}})),o<1?o:a}function R(e,t,o,a){const{panDelta:i}=a,c=i[e.id]||0;n.sign(c)===n.sign(t)&&(t+=c);const r=z[e.type]||z.default;n.callback(r,[e,t,o])?i[e.id]=0:i[e.id]=t}function Z(e,t,o,a="none"){const{x:i=0,y:c=0}="number"==typeof t?{x:t,y:t}:t,r=d(e),{options:{pan:s,limits:l}}=r,{onPan:u}=s||{};k(e,r);const m=0!==i,f=0!==c;n.each(o||e.scales,(function(e){e.isHorizontal()&&m?R(e,i,l,r):!e.isHorizontal()&&f&&R(e,c,l,r)})),e.update(a),n.callback(u,[{chart:e}])}function T(e){const t=d(e);k(e,t);const n={};for(const o of Object.keys(e.scales)){const{min:e,max:a}=t.originalScaleLimits[o]||{min:{},max:{}};n[o]={min:e.scale,max:a.scale}}return n}function L(e,t){const{handlers:n}=d(e),o=n[t];o&&o.target&&(o.target.removeEventListener(t,o),delete n[t])}function E(e,t,n,o){const{handlers:a,options:i}=d(e),c=a[n];c&&c.target===t||(L(e,n),a[n]=t=>o(e,t,i),a[n].target=t,t.addEventListener(n,a[n]))}function F(e,t){const n=d(e);n.dragStart&&(n.dragging=!0,n.dragEnd=t,e.update("none"))}function H(e,t){const n=d(e);n.dragStart&&"Escape"===t.key&&(L(e,"keydown"),n.dragging=!1,n.dragStart=n.dragEnd=null,e.update("none"))}function Y(e,t,o){const{onZoomStart:a,onZoomRejected:i}=o;if(a){const o=n.getRelativePosition(t,e);if(!1===n.callback(a,[{chart:e,event:t,point:o}]))return n.callback(i,[{chart:e,event:t}]),!1}}function V(e,t){const o=d(e),{pan:a,zoom:s={}}=o.options;if(0!==t.button||c(i(a),t)||r(i(s.drag),t))return n.callback(s.onZoomRejected,[{chart:e,event:t}]);!1!==Y(e,t,s)&&(o.dragStart=t,E(e,e.canvas,"mousemove",F),E(e,window.document,"keydown",H))}function K(e,t,o,a){const i=s(t,"x",e),c=s(t,"y",e);let{top:r,left:l,right:u,bottom:m,width:d,height:f}=e.chartArea;const p=n.getRelativePosition(o,e),h=n.getRelativePosition(a,e);i&&(l=Math.min(p.x,h.x),u=Math.max(p.x,h.x)),c&&(r=Math.min(p.y,h.y),m=Math.max(p.y,h.y));const x=u-l,g=m-r;return{left:l,top:r,right:u,bottom:m,width:x,height:g,zoomX:i&&x?1+(d-x)/d:1,zoomY:c&&g?1+(f-g)/f:1}}function N(e,t){const o=d(e);if(!o.dragStart)return;L(e,"mousemove");const{mode:a,onZoomComplete:i,drag:{threshold:c=0}}=o.options.zoom,r=K(e,a,o.dragStart,t),l=s(a,"x",e)?r.width:0,u=s(a,"y",e)?r.height:0,m=Math.sqrt(l*l+u*u);if(o.dragStart=o.dragEnd=null,m<=c)return o.dragging=!1,void e.update("none");O(e,{x:r.left,y:r.top},{x:r.right,y:r.bottom},"zoom"),setTimeout((()=>o.dragging=!1),500),n.callback(i,[{chart:e}])}function X(e,t){const{handlers:{onZoomComplete:o},options:{zoom:a}}=d(e);if(!function(e,t,o){if(r(i(o.wheel),t))n.callback(o.onZoomRejected,[{chart:e,event:t}]);else if(!1!==Y(e,t,o)&&(t.cancelable&&t.preventDefault(),void 0!==t.deltaY))return!0}(e,t,a))return;const c=t.target.getBoundingClientRect(),s=1+(t.deltaY>=0?-a.wheel.speed:a.wheel.speed);j(e,{x:s,y:s,focalPoint:{x:t.clientX-c.left,y:t.clientY-c.top}}),o&&o()}function q(e,t,o,a){o&&(d(e).handlers[t]=function(e,t){let n;return function(){return clearTimeout(n),n=setTimeout(e,t),t}}((()=>n.callback(o,[{chart:e}])),a))}function W(e,t){return function(o,a){const{pan:s,zoom:l={}}=t.options;if(!s||!s.enabled)return!1;const u=a&&a.srcEvent;return!u||(!(!t.panning&&"mouse"===a.pointerType&&(r(i(s),u)||c(i(l.drag),u)))||(n.callback(s.onPanRejected,[{chart:e,event:a}]),!1))}}function B(e,t,n){if(t.scale){const{center:o,pointers:a}=n,i=1/t.scale*n.scale,c=n.target.getBoundingClientRect(),r=function(e,t){const n=Math.abs(e.clientX-t.clientX),o=Math.abs(e.clientY-t.clientY),a=n/o;let i,c;return a>.3&&a<1.7?i=c=!0:n>o?i=!0:c=!0,{x:i,y:c}}(a[0],a[1]),l=t.options.zoom.mode;j(e,{x:r.x&&s(l,"x",e)?i:1,y:r.y&&s(l,"y",e)?i:1,focalPoint:{x:o.x-c.left,y:o.y-c.top}}),t.scale=n.scale}}function A(e,t,n){const o=t.delta;o&&(t.panning=!0,Z(e,{x:n.deltaX-o.x,y:n.deltaY-o.y},t.panScales),t.delta={x:n.deltaX,y:n.deltaY})}const I=new WeakMap;function U(e,t){const o=d(e),i=e.canvas,{pan:c,zoom:r}=t,s=new a.default.Manager(i);r&&r.pinch.enabled&&(s.add(new a.default.Pinch),s.on("pinchstart",(()=>function(e,t){t.options.zoom.pinch.enabled&&(t.scale=1)}(0,o))),s.on("pinch",(t=>B(e,o,t))),s.on("pinchend",(t=>function(e,t,o){t.scale&&(B(e,t,o),t.scale=null,n.callback(t.options.zoom.onZoomComplete,[{chart:e}]))}(e,o,t)))),c&&c.enabled&&(s.add(new a.default.Pan({threshold:c.threshold,enable:W(e,o)})),s.on("panstart",(t=>function(e,t,o){const{enabled:a,onPanStart:i,onPanRejected:c}=t.options.pan;if(!a)return;const r=o.target.getBoundingClientRect(),s={x:o.center.x-r.left,y:o.center.y-r.top};if(!1===n.callback(i,[{chart:e,event:o,point:s}]))return n.callback(c,[{chart:e,event:o}]);t.panScales=u(t.options.pan,s,e),t.delta={x:0,y:0},clearTimeout(t.panEndTimeout),A(e,t,o)}(e,o,t))),s.on("panmove",(t=>A(e,o,t))),s.on("panend",(()=>function(e,t){t.delta=null,t.panning&&(t.panEndTimeout=setTimeout((()=>t.panning=!1),500),n.callback(t.options.pan.onPanComplete,[{chart:e}]))}(e,o)))),I.set(e,s)}function G(e,t,n){const o=n.zoom.drag,{dragStart:a,dragEnd:i}=d(e);if(o.drawTime!==t||!i)return;const{left:c,top:r,width:s,height:l}=K(e,n.zoom.mode,a,i),u=e.ctx;u.save(),u.beginPath(),u.fillStyle=o.backgroundColor||"rgba(225,225,225,0.3)",u.fillRect(c,r,s,l),o.borderWidth>0&&(u.lineWidth=o.borderWidth,u.strokeStyle=o.borderColor||"rgba(225,225,225)",u.strokeRect(c,r,s,l)),u.restore()}var J={id:"zoom",version:"2.0.1",defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(e,t,o){d(e).options=o,Object.prototype.hasOwnProperty.call(o.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(o.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(o.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),a.default&&U(e,o),e.pan=(t,n,o)=>Z(e,t,n,o),e.zoom=(t,n)=>j(e,t,n),e.zoomRect=(t,n,o)=>O(e,t,n,o),e.zoomScale=(t,n,o)=>function(e,t,n,o="none"){k(e,d(e)),h(e.scales[t],n,void 0,!0),e.update(o)}(e,t,n,o),e.resetZoom=t=>function(e,t="default"){const o=d(e),a=k(e,o);n.each(e.scales,(function(e){const t=e.options;a[e.id]?(t.min=a[e.id].min.options,t.max=a[e.id].max.options):(delete t.min,delete t.max)})),e.update(t),n.callback(o.options.zoom.onZoomComplete,[{chart:e}])}(e,t),e.getZoomLevel=()=>C(e),e.getInitialScaleBounds=()=>T(e),e.isZoomedOrPanned=()=>function(e){const t=T(e);for(const n of Object.keys(e.scales)){const{min:o,max:a}=t[n];if(void 0!==o&&e.scales[n].min!==o)return!0;if(void 0!==a&&e.scales[n].max!==a)return!0}return!1}(e)},beforeEvent(e){const t=d(e);if(t.panning||t.dragging)return!1},beforeUpdate:function(e,t,n){d(e).options=n,function(e,t){const n=e.canvas,{wheel:o,drag:a,onZoomComplete:i}=t.zoom;o.enabled?(E(e,n,"wheel",X),q(e,"onZoomComplete",i,250)):L(e,"wheel"),a.enabled?(E(e,n,"mousedown",V),E(e,n.ownerDocument,"mouseup",N)):(L(e,"mousedown"),L(e,"mousemove"),L(e,"mouseup"),L(e,"keydown"))}(e,n)},beforeDatasetsDraw(e,t,n){G(e,"beforeDatasetsDraw",n)},afterDatasetsDraw(e,t,n){G(e,"afterDatasetsDraw",n)},beforeDraw(e,t,n){G(e,"beforeDraw",n)},afterDraw(e,t,n){G(e,"afterDraw",n)},stop:function(e){!function(e){L(e,"mousedown"),L(e,"mousemove"),L(e,"mouseup"),L(e,"wheel"),L(e,"click"),L(e,"keydown")}(e),a.default&&function(e){const t=I.get(e);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),I.delete(e))}(e),function(e){m.delete(e)}(e)},panFunctions:z,zoomFunctions:v,zoomRectFunctions:w};return e.Chart.register(J),J})); +!function(n,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("chart.js"),require("hammerjs"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["chart.js","hammerjs","chart.js/helpers"],t):(n="undefined"!=typeof globalThis?globalThis:n||self).ChartZoom=t(n.Chart,n.Hammer,n.Chart.helpers)}(this,(function(n,t,e){"use strict";const o=n=>n&&n.enabled&&n.modifierKey,a=(n,t)=>n&&t[n+"Key"],i=(n,t)=>n&&!t[n+"Key"];function c(n,t,e){return void 0===n||("string"==typeof n?-1!==n.indexOf(t):"function"==typeof n&&-1!==n({chart:e}).indexOf(t))}function r(n,t){return"function"==typeof n&&(n=n({chart:t})),"string"==typeof n?{x:-1!==n.indexOf("x"),y:-1!==n.indexOf("y")}:{x:!1,y:!1}}function s(n,t,o){const{mode:a="xy",scaleMode:i,overScaleMode:c}=n||{},s=function({x:n,y:t},e){const o=e.scales,a=Object.keys(o);for(let e=0;e=i.top&&t<=i.bottom&&n>=i.left&&n<=i.right)return i}return null}(t,o),l=r(a,o),m=r(i,o);if(c){const n=r(c,o);for(const t of["x","y"])n[t]&&(m[t]=l[t],l[t]=!1)}if(s&&m[s.axis])return[s];const u=[];return e.each(o.scales,(function(n){l[n.axis]&&u.push(n)})),u}const l=new WeakMap;function m(n){let t=l.get(n);return t||(t={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},panDelta:{},dragging:!1,panning:!1},l.set(n,t)),t}function u(n,t,e,o){const a=Math.max(0,Math.min(1,(n-t)/e||0));return{min:o*a,max:o*(1-a)}}function d(n,t){const e=n.isHorizontal()?t.x:t.y;return n.getValueForPixel(e)}function f(n,t,e){const o=n.max-n.min,a=o*(t-1);return u(d(n,e),n.min,o,a)}function p(n,t,o,a,i){let c=o[a];if("original"===c){const o=n.originalScaleLimits[t.id][a];c=e.valueOrDefault(o.options,o.scale)}return e.valueOrDefault(c,i)}function h(n,{min:t,max:o},a,i=!1){const c=m(n.chart),{options:r}=n,s=function(n,t){return t&&(t[n.id]||t[n.axis])||{}}(n,a),{minRange:l=0}=s,u=p(c,n,s,"min",-1/0),d=p(c,n,s,"max",1/0);if("pan"===i&&(td))return!0;const f=n.max-n.min,h=i?Math.max(o-t,l):f;if(i&&h===l&&f<=l)return!0;const g=function(n,{min:t,max:o,minLimit:a,maxLimit:i},c){const r=(n-o+t)/2;t-=r,o+=r;const s=c.min.options??c.min.scale,l=c.max.options??c.max.scale,m=n/1e6;return e.almostEquals(t,s,m)&&(t=s),e.almostEquals(o,l,m)&&(o=l),ti&&(o=i,t=Math.max(i-n,a)),{min:t,max:o}}(h,{min:t,max:o,minLimit:u,maxLimit:d},c.originalScaleLimits[n.id]);return r.min=g.min,r.max=g.max,c.updatedScaleLimits[n.id]=g,n.parse(g.min)!==n.min||n.parse(g.max)!==n.max}const g=n=>0===n||isNaN(n)?0:n<0?Math.min(Math.round(n),-1):Math.max(Math.round(n),1);const x={second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function b(n,t,e,o=!1){const{min:a,max:i,options:c}=n,r=c.time&&c.time.round,s=x[r]||0,l=n.getValueForPixel(n.getPixelForValue(a+s)-t),m=n.getValueForPixel(n.getPixelForValue(i+s)-t);return!(!isNaN(l)&&!isNaN(m))||h(n,{min:l,max:m},e,!!o&&"pan")}function y(n,t,e){return b(n,t,e,!0)}const v={category:function(n,t,e,o){const a=f(n,t,e);return n.min===n.max&&t<1&&function(n){const t=n.getLabels().length-1;n.min>0&&(n.min-=1),n.maxr&&(a=Math.max(0,a-s),i=1===c?a:a+c,l=0===a),h(n,{min:a,max:i},e)||l},default:b,logarithmic:y,timeseries:y};function z(n,t){e.each(n,((e,o)=>{t[o]||delete n[o]}))}function k(n,t){const{scales:o}=n,{originalScaleLimits:a,updatedScaleLimits:i}=t;return e.each(o,(function(n){(function(n,t,e){const{id:o,options:{min:a,max:i}}=n;if(!t[o]||!e[o])return!0;const c=e[o];return c.min!==a||c.max!==i})(n,a,i)&&(a[n.id]={min:{scale:n.min,options:n.options.min},max:{scale:n.max,options:n.options.max}})})),z(a,o),z(i,o),a}function S(n,t,o,a){const i=v[n.type]||v.default;e.callback(i,[n,t,o,a])}function P(n,t,o,a){const i=w[n.type]||w.default;e.callback(i,[n,t,o,a])}function D(n){const t=n.chartArea;return{x:(t.left+t.right)/2,y:(t.top+t.bottom)/2}}function C(n,t,o="none"){const{x:a=1,y:i=1,focalPoint:c=D(n)}="number"==typeof t?{x:t,y:t}:t,r=m(n),{options:{limits:l,zoom:u}}=r;k(n,r);const d=1!==a,f=1!==i,p=s(u,c,n);e.each(p||n.scales,(function(n){n.isHorizontal()&&d?S(n,a,c,l):!n.isHorizontal()&&f&&S(n,i,c,l)})),n.update(o),e.callback(u.onZoom,[{chart:n}])}function L(n,t,o,a="none"){const i=m(n),{options:{limits:r,zoom:s}}=i,{mode:l="xy"}=s;k(n,i);const u=c(l,"x",n),d=c(l,"y",n);e.each(n.scales,(function(n){n.isHorizontal()&&u?P(n,t.x,o.x,r):!n.isHorizontal()&&d&&P(n,t.y,o.y,r)})),n.update(a),e.callback(s.onZoom,[{chart:n}])}function O(n){const t=m(n);let o=1,a=1;return e.each(n.scales,(function(n){const i=function(n,t){const o=n.originalScaleLimits[t];if(!o)return;const{min:a,max:i}=o;return e.valueOrDefault(i.options,i.scale)-e.valueOrDefault(a.options,a.scale)}(t,n.id);if(i){const t=Math.round(i/(n.max-n.min)*100)/100;o=Math.min(o,t),a=Math.max(a,t)}})),o<1?o:a}function Z(n,t,o,a){const{panDelta:i}=a,c=i[n.id]||0;e.sign(c)===e.sign(t)&&(t+=c);const r=M[n.type]||M.default;e.callback(r,[n,t,o])?i[n.id]=0:i[n.id]=t}function j(n,t,o,a="none"){const{x:i=0,y:c=0}="number"==typeof t?{x:t,y:t}:t,r=m(n),{options:{pan:s,limits:l}}=r,{onPan:u}=s||{};k(n,r);const d=0!==i,f=0!==c;e.each(o||n.scales,(function(n){n.isHorizontal()&&d?Z(n,i,l,r):!n.isHorizontal()&&f&&Z(n,c,l,r)})),n.update(a),e.callback(u,[{chart:n}])}function R(n){const t=m(n);k(n,t);const e={};for(const o of Object.keys(n.scales)){const{min:n,max:a}=t.originalScaleLimits[o]||{min:{},max:{}};e[o]={min:n.scale,max:a.scale}}return e}function E(n){const t=m(n);return t.panning||t.dragging}function F(n,t){const{handlers:e}=m(n),o=e[t];o&&o.target&&(o.target.removeEventListener(t,o),delete e[t])}function N(n,t,e,o){const{handlers:a,options:i}=m(n),c=a[e];if(c&&c.target===t)return;F(n,e),a[e]=t=>o(n,t,i),a[e].target=t;const r="wheel"!==e&&void 0;t.addEventListener(e,a[e],{passive:r})}function H(n,t){const e=m(n);e.dragStart&&(e.dragging=!0,e.dragEnd=t,n.update("none"))}function T(n,t){const e=m(n);e.dragStart&&"Escape"===t.key&&(F(n,"keydown"),e.dragging=!1,e.dragStart=e.dragEnd=null,n.update("none"))}function Y(n,t){const o=e.getRelativePosition(n,t),a=t.canvas.getBoundingClientRect();return e._isPointInArea(n,a)||(o.x=n.clientX-a.left,o.y=n.clientY-a.top),o}function A(n,t,o){const{onZoomStart:a,onZoomRejected:i}=o;if(a){const o=Y(t,n);if(!1===e.callback(a,[{chart:n,event:t,point:o}]))return e.callback(i,[{chart:n,event:t}]),!1}}function q(n,t){if(n.legend){const o=e.getRelativePosition(t,n);if(e._isPointInArea(o,n.legend))return}const c=m(n),{pan:r,zoom:s={}}=c.options;if(0!==t.button||a(o(r),t)||i(o(s.drag),t))return e.callback(s.onZoomRejected,[{chart:n,event:t}]);!1!==A(n,t,s)&&(c.dragStart=t,N(n,n.canvas.ownerDocument,"mousemove",H),N(n,window.document,"keydown",T))}function V(n,t,e,{min:o,max:a,prop:i}){n[o]=Math.max(0,Math.min(t[i],e[i])),n[a]=Math.max(t[i],e[i])}function X(n,t,e){const o=Y(t.dragStart,n),a=Y(t.dragEnd,n);if(e){!function(n,t,e){let o=n.x-t.x,a=n.y-t.y;const i=Math.abs(o/a);i>e?o=Math.sign(o)*Math.abs(a*e):i=0?2-1/(1-s):1+s;C(n,{x:l,y:l,focalPoint:{x:t.clientX-r.left,y:t.clientY-r.top}}),e.callback(a,[{chart:n}])}function I(n,t,o,a){o&&(m(n).handlers[t]=function(n,t){let e;return function(){return clearTimeout(e),e=setTimeout(n,t),t}}((()=>e.callback(o,[{chart:n}])),a))}function _(n,t){return function(c,r){const{pan:s,zoom:l={}}=t.options;if(!s||!s.enabled)return!1;const m=r&&r.srcEvent;return!m||(!(!t.panning&&"mouse"===r.pointerType&&(i(o(s),m)||a(o(l.drag),m)))||(e.callback(s.onPanRejected,[{chart:n,event:r}]),!1))}}function U(n,t,e){if(t.scale){const{center:o,pointers:a}=e,i=1/t.scale*e.scale,r=e.target.getBoundingClientRect(),s=function(n,t){const e=Math.abs(n.clientX-t.clientX),o=Math.abs(n.clientY-t.clientY),a=e/o;let i,c;return a>.3&&a<1.7?i=c=!0:e>o?i=!0:c=!0,{x:i,y:c}}(a[0],a[1]),l=t.options.zoom.mode;C(n,{x:s.x&&c(l,"x",n)?i:1,y:s.y&&c(l,"y",n)?i:1,focalPoint:{x:o.x-r.left,y:o.y-r.top}}),t.scale=e.scale}}function G(n,t,e){const o=t.delta;o&&(t.panning=!0,j(n,{x:e.deltaX-o.x,y:e.deltaY-o.y},t.panScales),t.delta={x:e.deltaX,y:e.deltaY})}const J=new WeakMap;function Q(n,o){const a=m(n),i=n.canvas,{pan:c,zoom:r}=o,l=new t.Manager(i);r&&r.pinch.enabled&&(l.add(new t.Pinch),l.on("pinchstart",(t=>function(n,t,o){if(t.options.zoom.pinch.enabled){const a=e.getRelativePosition(o,n);e.callback(t.options.zoom.onZoomStart,[{chart:n,event:o,point:a}]),t.scale=1}}(n,a,t))),l.on("pinch",(t=>U(n,a,t))),l.on("pinchend",(t=>function(n,t,o){t.scale&&(U(n,t,o),t.scale=null,e.callback(t.options.zoom.onZoomComplete,[{chart:n}]))}(n,a,t)))),c&&c.enabled&&(l.add(new t.Pan({threshold:c.threshold,enable:_(n,a)})),l.on("panstart",(t=>function(n,t,o){const{enabled:a,onPanStart:i,onPanRejected:c}=t.options.pan;if(!a)return;const r=o.target.getBoundingClientRect(),l={x:o.center.x-r.left,y:o.center.y-r.top};if(!1===e.callback(i,[{chart:n,event:o,point:l}]))return e.callback(c,[{chart:n,event:o}]);t.panScales=s(t.options.pan,l,n),t.delta={x:0,y:0},G(n,t,o)}(n,a,t))),l.on("panmove",(t=>G(n,a,t))),l.on("panend",(()=>function(n,t){t.delta=null,t.panning&&(t.panning=!1,t.filterNextClick=!0,e.callback(t.options.pan.onPanComplete,[{chart:n}]))}(n,a)))),J.set(n,l)}function $(n){const t=J.get(n);t&&(t.remove("pinchstart"),t.remove("pinch"),t.remove("pinchend"),t.remove("panstart"),t.remove("pan"),t.remove("panend"),t.destroy(),J.delete(n))}function nn(n,t,e){const o=e.zoom.drag,{dragStart:a,dragEnd:i}=m(n);if(o.drawTime!==t||!i)return;const{left:c,top:r,width:s,height:l}=B(n,e.zoom.mode,{dragStart:a,dragEnd:i},o.maintainAspectRatio),u=n.ctx;u.save(),u.beginPath(),u.fillStyle=o.backgroundColor||"rgba(225,225,225,0.3)",u.fillRect(c,r,s,l),o.borderWidth>0&&(u.lineWidth=o.borderWidth,u.strokeStyle=o.borderColor||"rgba(225,225,225)",u.strokeRect(c,r,s,l)),u.restore()}var tn={id:"zoom",version:"2.1.0",defaults:{pan:{enabled:!1,mode:"xy",threshold:10,modifierKey:null},zoom:{wheel:{enabled:!1,speed:.1,modifierKey:null},drag:{enabled:!1,drawTime:"beforeDatasetsDraw",modifierKey:null},pinch:{enabled:!1},mode:"xy"}},start:function(n,o,a){m(n).options=a,Object.prototype.hasOwnProperty.call(a.zoom,"enabled")&&console.warn("The option `zoom.enabled` is no longer supported. Please use `zoom.wheel.enabled`, `zoom.drag.enabled`, or `zoom.pinch.enabled`."),(Object.prototype.hasOwnProperty.call(a.zoom,"overScaleMode")||Object.prototype.hasOwnProperty.call(a.pan,"overScaleMode"))&&console.warn("The option `overScaleMode` is deprecated. Please use `scaleMode` instead (and update `mode` as desired)."),t&&Q(n,a),n.pan=(t,e,o)=>j(n,t,e,o),n.zoom=(t,e)=>C(n,t,e),n.zoomRect=(t,e,o)=>L(n,t,e,o),n.zoomScale=(t,o,a)=>function(n,t,o,a="none"){const i=m(n);k(n,i),h(n.scales[t],o,void 0,!0),n.update(a),e.callback(i.options.zoom?.onZoom,[{chart:n}])}(n,t,o,a),n.resetZoom=t=>function(n,t="default"){const o=m(n),a=k(n,o);e.each(n.scales,(function(n){const t=n.options;a[n.id]?(t.min=a[n.id].min.options,t.max=a[n.id].max.options):(delete t.min,delete t.max),delete o.updatedScaleLimits[n.id]})),n.update(t),e.callback(o.options.zoom.onZoomComplete,[{chart:n}])}(n,t),n.getZoomLevel=()=>O(n),n.getInitialScaleBounds=()=>R(n),n.getZoomedScaleBounds=()=>function(n){const t=m(n),e={};for(const o of Object.keys(n.scales))e[o]=t.updatedScaleLimits[o];return e}(n),n.isZoomedOrPanned=()=>function(n){const t=R(n);for(const e of Object.keys(n.scales)){const{min:o,max:a}=t[e];if(void 0!==o&&n.scales[e].min!==o)return!0;if(void 0!==a&&n.scales[e].max!==a)return!0}return!1}(n),n.isZoomingOrPanning=()=>E(n)},beforeEvent(n,{event:t}){if(E(n))return!1;if("click"===t.type||"mouseup"===t.type){const t=m(n);if(t.filterNextClick)return t.filterNextClick=!1,!1}},beforeUpdate:function(n,t,e){const o=m(n),a=o.options;o.options=e,function(n,t){const{pan:e,zoom:o}=n,{pan:a,zoom:i}=t;return o?.zoom?.pinch?.enabled!==i?.zoom?.pinch?.enabled||e?.enabled!==a?.enabled||e?.threshold!==a?.threshold}(a,e)&&($(n),Q(n,e)),function(n,t){const e=n.canvas,{wheel:o,drag:a,onZoomComplete:i}=t.zoom;o.enabled?(N(n,e,"wheel",W),I(n,"onZoomComplete",i,250)):F(n,"wheel"),a.enabled?(N(n,e,"mousedown",q),N(n,e.ownerDocument,"mouseup",K)):(F(n,"mousedown"),F(n,"mousemove"),F(n,"mouseup"),F(n,"keydown"))}(n,e)},beforeDatasetsDraw(n,t,e){nn(n,"beforeDatasetsDraw",e)},afterDatasetsDraw(n,t,e){nn(n,"afterDatasetsDraw",e)},beforeDraw(n,t,e){nn(n,"beforeDraw",e)},afterDraw(n,t,e){nn(n,"afterDraw",e)},stop:function(n){!function(n){F(n,"mousedown"),F(n,"mousemove"),F(n,"mouseup"),F(n,"wheel"),F(n,"click"),F(n,"keydown")}(n),t&&$(n),function(n){l.delete(n)}(n)},panFunctions:M,zoomFunctions:v,zoomRectFunctions:w};return n.Chart.register(tn),tn}));