@thewhitehaven04/chartjs-plugin-zoom 2.2.22 → 2.2.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chartjs-plugin-zoom.esm.js +3 -3
- package/dist/chartjs-plugin-zoom.js +3 -3
- package/dist/chartjs-plugin-zoom.min.js +3 -3
- package/dist/src/core.d.ts +24 -0
- package/dist/src/defaults.d.ts +3 -0
- package/dist/src/hammer.d.ts +6 -0
- package/dist/src/handlers.d.ts +24 -0
- package/dist/src/index.d.ts +31 -0
- package/dist/src/index.umd.d.ts +3 -0
- package/dist/src/options.d.ts +196 -0
- package/dist/src/plugin.d.ts +25 -0
- package/dist/src/scale.types.d.ts +12 -0
- package/dist/src/scale.types.test.d.ts +2 -0
- package/dist/src/state.d.ts +53 -0
- package/dist/src/types.d.ts +11 -0
- package/dist/src/utils.d.ts +14 -0
- package/dist/src/utils.test.d.ts +2 -0
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @thewhitehaven04/chartjs-plugin-zoom v2.2.
|
|
3
|
-
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.
|
|
2
|
+
* @thewhitehaven04/chartjs-plugin-zoom v2.2.22
|
|
3
|
+
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.22/
|
|
4
4
|
* (c) 2016-2026 chartjs-plugin-zoom Contributors
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
@@ -1043,7 +1043,7 @@ function hammerOptionsChanged(oldOptions, newOptions) {
|
|
|
1043
1043
|
return false;
|
|
1044
1044
|
}
|
|
1045
1045
|
|
|
1046
|
-
var version = "2.2.
|
|
1046
|
+
var version = "2.2.22";
|
|
1047
1047
|
|
|
1048
1048
|
const defaults = {
|
|
1049
1049
|
pan: {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @thewhitehaven04/chartjs-plugin-zoom v2.2.
|
|
3
|
-
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.
|
|
2
|
+
* @thewhitehaven04/chartjs-plugin-zoom v2.2.22
|
|
3
|
+
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.22/
|
|
4
4
|
* (c) 2016-2026 chartjs-plugin-zoom Contributors
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
@@ -1046,7 +1046,7 @@ function hammerOptionsChanged(oldOptions, newOptions) {
|
|
|
1046
1046
|
return false;
|
|
1047
1047
|
}
|
|
1048
1048
|
|
|
1049
|
-
var version = "2.2.
|
|
1049
|
+
var version = "2.2.22";
|
|
1050
1050
|
|
|
1051
1051
|
const defaults = {
|
|
1052
1052
|
pan: {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* @thewhitehaven04/chartjs-plugin-zoom v2.2.
|
|
3
|
-
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.
|
|
2
|
+
* @thewhitehaven04/chartjs-plugin-zoom v2.2.22
|
|
3
|
+
* https://www.chartjs.org/chartjs-plugin-zoom/2.2.22/
|
|
4
4
|
* (c) 2016-2026 chartjs-plugin-zoom Contributors
|
|
5
5
|
* Released under the MIT License
|
|
6
6
|
*/
|
|
7
|
-
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("chart.js"),require("hammerjs"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["chart.js","hammerjs","chart.js/helpers"],n):(t="undefined"!=typeof globalThis?globalThis:t||self).ChartZoom=n(t.Chart,t.Hammer,t.Chart.helpers)}(this,(function(t,n,e){"use strict";const o=t=>`${t}Key`,i=t=>t?.enabled&&t.modifierKey?t.modifierKey:void 0,a=(t,n)=>t&&n[o(t)],r=(t,n)=>t&&!n[o(t)];function s(t,n,e){return void 0===t||("string"==typeof t?-1!==t.indexOf(n):"function"==typeof t&&-1!==t({chart:e}).indexOf(n))}function c(t,n){return"function"==typeof t&&(t=t({chart:n})),"string"==typeof t?{x:-1!==t.indexOf("x"),y:-1!==t.indexOf("y")}:{x:!1,y:!1}}function l(t,n,e){const{mode:o="xy",scaleMode:i,overScaleMode:a}=t||{},r=function({x:t,y:n},e){const o=e.scales,i=Object.keys(o);for(let e=0;e<i.length;e++){const a=o[i[e]];if(n>=a.top&&n<=a.bottom&&t>=a.left&&t<=a.right)return a}return null}(n,e),s=c(o,e),l=c(i,e);return((t,n,e,o)=>{if(!n)return;const i=c(n,t);for(const t of["x","y"])i[t]&&(e[t]=o[t],o[t]=!1)})(e,a,l,s),r&&l[r.axis]?[r]:((t,n)=>{const e=[];for(const o of Object.values(t.scales))n[o.axis]&&e.push(o);return e||Object.values(t.scales)})(e,s)}const m=new WeakMap;function u(t){let n=m.get(t);return n||(n={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},options:{},targets:{},panDelta:{},dragging:!1,panning:!1},m.set(t,n)),n}const d=t=>void 0===t||isNaN(t);function f(t,n,o,i){const a=o&&e.isNumber(t)&&e.isNumber(n)?Math.max(0,Math.min(1,(t-n)/o)):0;return{min:i*a,max:i*(1-a)}}function p(t,n){const e=t.isHorizontal()?n.x:n.y;return t.getValueForPixel(e)}function h(t,n,e){const o=t.max-t.min,i=o*(n-1);return f(p(t,e),t.min,o,i)}function g(t,n,o,i,a){let r=o[i];if("original"===r){const o=t.originalScaleLimits[n.id][i];if(e.isNumber(o.options))return o.options;if(!e.isNullOrUndef(o.options)){const t=n.parse(o.options);if(e.isNumber(t))return t}r=o.scale}return e.valueOrDefault(r,a)}function x(t,{min:n,max:o},i,a=!1,r=!1){const s=u(t.chart),{options:c}=t,l=function(t,n){return n?.[t.id]||n?.[t.axis]||{}}(t,i),{minRange:m=0}=l,d=g(s,t,l,"min",-1/0),f=g(s,t,l,"max",1/0);if(r&&(n<d||o>f))return!0;const p=t.max-t.min,h=a?Math.max(o-n,m):p;if(a&&h===m&&p<=m)return!0;const x=function(t,{min:n,max:o,minLimit:i,maxLimit:a},r,s){const c=(t-o+n)/2;n-=c,o+=c;const l={min:"original",max:"original"},m=g(r,s,l,"min",-1/0),u=g(r,s,l,"max",1/0),d=t/1e6;return e.almostEquals(n,m,d)&&(n=m),e.almostEquals(o,u,d)&&(o=u),n<i?(n=i,o=Math.min(i+t,a)):o>a&&(o=a,n=Math.max(a-t,i)),{min:n,max:o}}(h,{min:n,max:o,minLimit:d,maxLimit:f},s,t);return c.min=x.min,c.max=x.max,s.updatedScaleLimits[t.id]=x,t.parse(x.min)!==t.min||t.parse(x.max)!==t.max}const y=t=>0===t||isNaN(t)?0:t<0?Math.min(Math.round(t),-1):Math.max(Math.round(t),1);const b={millisecond:0,second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function v(t,n,e,o=!1){const{min:i,max:a}=t;let r=0;if((t=>"time"===t.type)(t)){const n=t.options.time?.round;r=n?b[n]:0}const s=t.getValueForPixel(t.getPixelForValue(i+r)-n),c=t.getValueForPixel(t.getPixelForValue(a+r)-n);return!(!d(s)&&!d(c))||x(t,{min:s,max:c},e,o,!0)}function w(t,n,e){return v(t,n,e,!0)}const M={category:function(t,n,e,o){const i=h(t,n,e);return t.min===t.max&&n<1&&function(t){const n=t.getLabels().length-1;t.min>0&&(t.min-=1),t.max<n&&(t.max+=1)}(t),x(t,{min:t.min+y(i.min),max:t.max-y(i.max)},o,!0)},default:function(t,n,e,o){const i=h(t,n,e);return x(t,{min:t.min+i.min,max:t.max-i.max},o,!0)},logarithmic:function(t,n,e,o){const i=function(t,n,e){const o=p(t,e);if(void 0===o)return{min:t.min,max:t.max};const i=Math.log10(t.min),a=Math.log10(t.max),r=a-i,s=f(Math.log10(o),i,r,r*(n-1));return{min:Math.pow(10,i+s.min),max:Math.pow(10,a-s.max)}}(t,n,e);return x(t,i,o,!0)}},z={default:function(t,n,e,o){return x(t,function(t,n,e){const o=t.getValueForPixel(n)??t.min,i=t.getValueForPixel(e)??t.max;return{min:Math.min(o,i),max:Math.max(o,i)}}(t,n,e),o,!0)}},S={category:function(t,n,e){const o=t.getLabels().length-1;let{min:i,max:a}=t;const r=Math.max(a-i,1),s=Math.round(function(t){return t.isHorizontal()?t.width:t.height}(t)/Math.max(r,10)),c=Math.round(Math.abs(n/s));let l;return n<-s?(a=Math.min(a+c,o),i=1===r?a:a-r,l=a===o):n>s&&(i=Math.max(0,i-c),a=1===r?i:i+r,l=0===i),x(t,{min:i,max:a},e)||Boolean(l)},default:v,logarithmic:w,timeseries:w};function P(t,n,e){const{id:o,options:{min:i,max:a}}=t;if(!n[o]||!e[o])return!0;const r=e[o];return r.min!==i||r.max!==a}function j(t,n){for(const e of Object.keys(t))n[e]||delete t[e]}function O(t,n){const{scales:e}=t,{originalScaleLimits:o,updatedScaleLimits:i}=n;for(const t of Object.values(e))P(t,o,i)&&(o[t.id]={min:{scale:t.min,options:t.options.min},max:{scale:t.max,options:t.options.max}});return j(o,e),j(i,e),o}function k(t,n,e,o){const i=M[t.type]||M.default;i?.(t,n,e,o)}function C(t,n,e,o){const i=z[t.type]||z.default;i?.(t,n,e,o)}function Z(t){const n=t.chartArea;return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}}function D(t,n,e="none",o="api"){const{x:i=1,y:a=1,focalPoint:r=Z(t)}="number"==typeof n?{x:n,y:n}:n,s=u(t),{options:{limits:c={},zoom:m}}=s;O(t,s);const d=1!==i,f=1!==a,p=l(m,r,t);for(const t of p)t.isHorizontal()&&d?k(t,i,r,c):!t.isHorizontal()&&f&&k(t,a,r,c);t.update(e),m?.onZoom?.({chart:t,trigger:o,amount:{x:i,y:a,focalPoint:r}})}function R(t,n,e,o="none",i="api"){const a=u(t),{options:{limits:r={},zoom:c={}}}=a,{mode:l="xy"}=c;O(t,a);const m=s(l,"x",t),d=s(l,"y",t);for(const o of Object.values(t.scales))o.isHorizontal()&&m?C(o,n.x,e.x,r):!o.isHorizontal()&&d&&C(o,n.y,e.y,r);t.update(o),c.onZoom?.({chart:t,trigger:i})}function L(t,n){const o=t.originalScaleLimits[n];if(!o)return;const{min:i,max:a}=o;return e.isNumber(a.options)&&e.isNumber(i.options)?a.options-i.options:e.isNumber(a.scale)&&e.isNumber(i.scale)?a.scale-i.scale:void 0}function N(t,n,o,i){const{panDelta:a}=i,r=a[t.id]||0;e.sign(r)===e.sign(n)&&(n+=r);const s=S[t.type]||S.default;s?.(t,n,o)?a[t.id]=0:a[t.id]=n}function E(t,n,e,o="none",i="other"){const{x:a=0,y:r=0}="number"==typeof n?{x:n,y:n}:n,s=u(t),{options:{pan:c,limits:l={}}}=s,{onPan:m}=c||{};O(t,s);const d=0!==a,f=0!==r,p=e||Object.values(t.scales);for(const t of p)t.isHorizontal()&&d?N(t,a,l,s):!t.isHorizontal()&&f&&N(t,r,l,s);t.update(o),m?.({chart:t,trigger:i,delta:{x:a,y:r}})}function F(t){const n=u(t);O(t,n);const e={};for(const o of Object.keys(t.scales)){const{min:t,max:i}=n.originalScaleLimits[o]||{min:{},max:{}};e[o]={min:t.scale,max:i.scale}}return e}function A(t){return t.panning||t.dragging}const H=(t,n,e)=>Math.min(e,Math.max(n,t));function T(t,n){const{handlers:e,targets:o}=u(t),i=e[n],a=o[n];i&&a&&(a.removeEventListener(n,i),delete e[n])}function Y(t,n,e,o){const{handlers:i,options:a,targets:r}=u(t);if(i[e]&&r[e]===n)return;T(t,e);const s=i[e]=n=>o(t,n,a);r[e]=n;const c="wheel"!==e&&void 0;n.addEventListener(e,s,{passive:c})}function B(t,n){const e=u(t);e.dragStart&&(e.dragging=!0,e.dragEnd=n,t.draw())}function q(t,n){const e=u(t);e.dragStart&&"Escape"===n.key&&(T(t,"keydown"),e.dragging=!1,e.dragStart=e.dragEnd=void 0,t.draw())}function V(t,n){if(t.target!==n.canvas){const e=n.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}return e.getRelativePosition(t,n)}function X(t,n,e){const{onZoomStart:o,onZoomRejected:i}=e;if(o){const e=V(n,t);if(!1===o?.({chart:t,event:n,point:e}))return i?.({chart:t,event:n}),!1}}function K(t,n){if(t.legend){const o=e.getRelativePosition(n,t);if(e._isPointInArea(o,t.legend))return}const o=u(t),{pan:s,zoom:c={}}=o.options;if(0!==n.button||a(i(s),n)||r(i(c.drag),n))return c.onZoomRejected?.({chart:t,event:n});!1!==X(t,n,c)&&(o.dragStart=n,Y(t,t.canvas.ownerDocument,"mousemove",B),Y(t,window.document,"keydown",q))}function W(t,n,e,{min:o,max:i,prop:a}){t[o]=H(Math.min(e.begin[a],e.end[a]),n[o],n[i]),t[i]=H(Math.max(e.begin[a],e.end[a]),n[o],n[i])}function I(t,n,e){const o={begin:V(n.dragStart,t),end:V(n.dragEnd,t)};if(e){!function({begin:t,end:n},e){let o=n.x-t.x,i=n.y-t.y;const a=Math.abs(o/i);a>e?o=Math.sign(o)*Math.abs(i*e):a<e&&(i=Math.sign(i)*Math.abs(o/e)),n.x=t.x+o,n.y=t.y+i}(o,t.chartArea.width/t.chartArea.height)}return o}function U(t,n,e,o){const i=s(n,"x",t),a=s(n,"y",t),{top:r,left:c,right:l,bottom:m,width:u,height:d}=t.chartArea,f={top:r,left:c,right:l,bottom:m},p=I(t,e,o&&i&&a);i&&W(f,t.chartArea,p,{min:"left",max:"right",prop:"x"}),a&&W(f,t.chartArea,p,{min:"top",max:"bottom",prop:"y"});const h=f.right-f.left,g=f.bottom-f.top;return{...f,width:h,height:g,zoomX:i&&h?1+(u-h)/u:1,zoomY:a&&g?1+(d-g)/d:1}}function $(t,n){const e=u(t);if(!e.dragStart)return;T(t,"mousemove");const{mode:o,onZoomComplete:i,drag:a}=e.options.zoom??{},{threshold:r=0,maintainAspectRatio:c}=a??{},l=U(t,o,{dragStart:e.dragStart,dragEnd:n},c),m=s(o,"x",t)?l.width:0,d=s(o,"y",t)?l.height:0,f=Math.sqrt(m*m+d*d);if(e.dragStart=e.dragEnd=void 0,f<=r)return e.dragging=!1,void t.draw();R(t,{x:l.left,y:l.top},{x:l.right,y:l.bottom},"zoom","drag"),e.dragging=!1,e.filterNextClick=!0,i?.({chart:t})}function _(t,n){const{handlers:{onZoomComplete:e},options:{zoom:o={}}}=u(t);if(!function(t,n,e){if(r(i(e.wheel),n))e.onZoomRejected?.({chart:t,event:n});else if(!1!==X(t,n,e)&&(n.cancelable&&n.preventDefault(),void 0!==n.deltaY))return!0}(t,n,o))return;const a=n.target?.getBoundingClientRect(),s=o?.wheel?.speed??.1,c=n.deltaY>=0?2-1/(1-s):1+s;D(t,{x:c,y:c,focalPoint:{x:n.clientX-a.left,y:n.clientY-a.top}},"zoom","wheel"),e?.(n)}function G(t,n,e,o){e&&(u(t).handlers[n]=function(t,n){let e;return function(){return clearTimeout(e),e=setTimeout(t,n),n}}((()=>e?.({chart:t})),o))}function J(t,n){return function(e,o){const{pan:s,zoom:c={}}=n.options;if(!s||!s.enabled)return!1;const l=o&&o.srcEvent;return!l||(!(!n.panning&&"mouse"===o.pointerType&&(r(i(s),l)||a(i(c.drag),l)))||(s.onPanRejected?.({chart:t,event:o}),!1))}}function Q(t,n,e){if(n.scale){const{center:o,pointers:i}=e,a=1/n.scale*e.scale,r=e.target.getBoundingClientRect(),c=function(t,n){const e=Math.abs(t.clientX-n.clientX),o=Math.abs(t.clientY-n.clientY),i=e/o;let a,r;return i>.3&&i<1.7?a=r=!0:e>o?a=!0:r=!0,{x:a,y:r}}(i[0],i[1]),l=n.options.zoom?.mode;D(t,{x:c.x&&s(l,"x",t)?a:1,y:c.y&&s(l,"y",t)?a:1,focalPoint:{x:o.x-r.left,y:o.y-r.top}},"zoom","pinch"),n.scale=e.scale}}function tt(t,n,e){const o=n.delta;o&&(n.panning=!0,E(t,{x:e.deltaX-o.x,y:e.deltaY-o.y},n.panScales&&n.panScales.map((n=>t.scales[n])).filter(Boolean)),n.delta={x:e.deltaX,y:e.deltaY})}const nt=new WeakMap;function et(t,o){const i=u(t),a=t.canvas,{pan:r,zoom:s}=o,c=new n.Manager(a);s?.pinch?.enabled&&(c.add(new n.Pinch),c.on("pinchstart",(n=>function(t,n,o){if(n.options.zoom?.pinch?.enabled){const i=e.getRelativePosition(o.srcEvent,t);!1===n.options.zoom?.onZoomStart?.({chart:t,event:o.srcEvent,point:i})?(n.scale=null,n.options.zoom?.onZoomRejected?.({chart:t,event:o.srcEvent})):n.scale=1}}(t,i,n))),c.on("pinch",(n=>Q(t,i,n))),c.on("pinchend",(n=>function(t,n,e){n.scale&&(Q(t,n,e),n.scale=null,n.options.zoom?.onZoomComplete?.({chart:t}))}(t,i,n)))),r&&r.enabled&&(c.add(new n.Pan({threshold:r.threshold,enable:J(t,i)})),c.on("panstart",(n=>function(t,n,e){const{enabled:o,onPanStart:i,onPanRejected:a}=n.options.pan??{};if(!o)return;const r=e.target.getBoundingClientRect(),s={x:e.center.x-r.left,y:e.center.y-r.top};if(!1===i?.({chart:t,event:e,point:s}))return a?.({chart:t,event:e});n.panScales=l(n.options.pan,s,t).map((t=>t.id)),n.delta={x:0,y:0},tt(t,n,e)}(t,i,n))),c.on("panmove",(n=>tt(t,i,n))),c.on("panend",(()=>function(t,n){n.delta=null,n.panning&&(n.panning=!1,n.filterNextClick=!0,n.options.pan?.onPanComplete?.({chart:t}))}(t,i)))),nt.set(t,c)}function ot(t){const n=nt.get(t);n&&(n.remove("pinchstart"),n.remove("pinch"),n.remove("pinchend"),n.remove("panstart"),n.remove("pan"),n.remove("panend"),n.destroy(),nt.delete(t))}function it(t,n,e){const o=e.zoom?.drag,{dragStart:i,dragEnd:a}=u(t);if(o?.drawTime!==n||!i||!a)return;const{left:r,top:s,width:c,height:l}=U(t,e.zoom?.mode,{dragStart:i,dragEnd:a},o.maintainAspectRatio),m=t.ctx;m.save(),m.beginPath(),m.fillStyle=o.backgroundColor||"rgba(225,225,225,0.3)",m.fillRect(r,s,c,l),o.borderWidth&&(m.lineWidth=o.borderWidth,m.strokeStyle=o.borderColor||"rgba(225,225,225)",m.strokeRect(r,s,c,l)),m.restore()}const at=t=>{t.pan=(n,e,o)=>E(t,n,e,o,"api"),t.zoom=(n,e)=>D(t,n,e),t.zoomRect=(n,e,o)=>R(t,n,e,o),t.zoomScale=(n,e,o)=>function(t,n,e,o="none",i="api"){const a=u(t);O(t,a),x(t.scales[n],e,void 0,!0),t.update(o),a.options.zoom?.onZoom?.({chart:t,trigger:i})}(t,n,e,o),t.resetZoom=n=>function(t,n="default"){const e=u(t),o=O(t,e);for(const n of Object.values(t.scales)){const t=n.options;o[n.id]?(t.min=o[n.id].min.options,t.max=o[n.id].max.options):(delete t.min,delete t.max),delete e.updatedScaleLimits[n.id]}t.update(n),e.options.zoom?.onZoomComplete?.({chart:t})}(t,n),t.getZoomLevel=()=>function(t){const n=u(t);let e=1,o=1;for(const i of Object.values(t.scales)){const t=L(n,i.id);if(t){const n=Math.round(t/(i.max-i.min)*100)/100;e=Math.min(e,n),o=Math.max(o,n)}}return e<1?e:o}(t),t.getInitialScaleBounds=()=>F(t),t.getZoomedScaleBounds=()=>function(t){const n=u(t),e={};for(const o of Object.keys(t.scales))e[o]=n.updatedScaleLimits[o];return e}(t),t.isZoomedOrPanned=()=>function(t){const n=F(t);for(const e of Object.keys(t.scales)){const{min:o,max:i}=n[e];if(void 0!==o&&t.scales[e].min!==o)return!0;if(void 0!==i&&t.scales[e].max!==i)return!0}return!1}(t),t.isZoomingOrPanning=()=>function(t){const n=u(t);return!(!A(n)&&!n.filterNextClick)}(t)};var rt={id:"zoom",version:"2.2.21",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(t,e,o){u(t).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)."),n&&et(t,o),at(t)},beforeEvent(t,{event:n}){const e=u(t);return!A(e)&&("click"!==n.type&&"mouseup"!==n.type||!e.filterNextClick?void 0:(e.filterNextClick=!1,!1))},beforeUpdate(t,n,e){const o=u(t),i=o.options;o.options=e,function(t,n){const{pan:e,zoom:o}=t,{pan:i,zoom:a}=n;return o?.pinch?.enabled!==a?.pinch?.enabled||e?.enabled!==i?.enabled||e?.threshold!==i?.threshold}(i,e)&&(ot(t),et(t,e)),function(t,n){const e=t.canvas,{wheel:o,drag:i,onZoomComplete:a}=n.zoom??{};o?.enabled?(Y(t,e,"wheel",_),G(t,"onZoomComplete",a,250)):T(t,"wheel"),i?.enabled?(Y(t,e,"mousedown",K),Y(t,e.ownerDocument,"mouseup",$)):(T(t,"mousedown"),T(t,"mousemove"),T(t,"mouseup"),T(t,"keydown"))}(t,e)},beforeDatasetsDraw(t,n,e){it(t,"beforeDatasetsDraw",e)},afterDatasetsDraw(t,n,e){it(t,"afterDatasetsDraw",e)},beforeDraw(t,n,e){it(t,"beforeDraw",e)},afterDraw(t,n,e){it(t,"afterDraw",e)},stop(t){!function(t){T(t,"mousedown"),T(t,"mousemove"),T(t,"mouseup"),T(t,"wheel"),T(t,"click"),T(t,"keydown")}(t),n&&ot(t),function(t){m.delete(t)}(t)},panFunctions:S,zoomFunctions:M,zoomRectFunctions:z};return t.Chart.register(rt),rt}));
|
|
7
|
+
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n(require("chart.js"),require("hammerjs"),require("chart.js/helpers")):"function"==typeof define&&define.amd?define(["chart.js","hammerjs","chart.js/helpers"],n):(t="undefined"!=typeof globalThis?globalThis:t||self).ChartZoom=n(t.Chart,t.Hammer,t.Chart.helpers)}(this,(function(t,n,e){"use strict";const o=t=>`${t}Key`,i=t=>t?.enabled&&t.modifierKey?t.modifierKey:void 0,a=(t,n)=>t&&n[o(t)],r=(t,n)=>t&&!n[o(t)];function s(t,n,e){return void 0===t||("string"==typeof t?-1!==t.indexOf(n):"function"==typeof t&&-1!==t({chart:e}).indexOf(n))}function c(t,n){return"function"==typeof t&&(t=t({chart:n})),"string"==typeof t?{x:-1!==t.indexOf("x"),y:-1!==t.indexOf("y")}:{x:!1,y:!1}}function l(t,n,e){const{mode:o="xy",scaleMode:i,overScaleMode:a}=t||{},r=function({x:t,y:n},e){const o=e.scales,i=Object.keys(o);for(let e=0;e<i.length;e++){const a=o[i[e]];if(n>=a.top&&n<=a.bottom&&t>=a.left&&t<=a.right)return a}return null}(n,e),s=c(o,e),l=c(i,e);return((t,n,e,o)=>{if(!n)return;const i=c(n,t);for(const t of["x","y"])i[t]&&(e[t]=o[t],o[t]=!1)})(e,a,l,s),r&&l[r.axis]?[r]:((t,n)=>{const e=[];for(const o of Object.values(t.scales))n[o.axis]&&e.push(o);return e||Object.values(t.scales)})(e,s)}const m=new WeakMap;function u(t){let n=m.get(t);return n||(n={originalScaleLimits:{},updatedScaleLimits:{},handlers:{},options:{},targets:{},panDelta:{},dragging:!1,panning:!1},m.set(t,n)),n}const d=t=>void 0===t||isNaN(t);function f(t,n,o,i){const a=o&&e.isNumber(t)&&e.isNumber(n)?Math.max(0,Math.min(1,(t-n)/o)):0;return{min:i*a,max:i*(1-a)}}function p(t,n){const e=t.isHorizontal()?n.x:n.y;return t.getValueForPixel(e)}function h(t,n,e){const o=t.max-t.min,i=o*(n-1);return f(p(t,e),t.min,o,i)}function g(t,n,o,i,a){let r=o[i];if("original"===r){const o=t.originalScaleLimits[n.id][i];if(e.isNumber(o.options))return o.options;if(!e.isNullOrUndef(o.options)){const t=n.parse(o.options);if(e.isNumber(t))return t}r=o.scale}return e.valueOrDefault(r,a)}function x(t,{min:n,max:o},i,a=!1,r=!1){const s=u(t.chart),{options:c}=t,l=function(t,n){return n?.[t.id]||n?.[t.axis]||{}}(t,i),{minRange:m=0}=l,d=g(s,t,l,"min",-1/0),f=g(s,t,l,"max",1/0);if(r&&(n<d||o>f))return!0;const p=t.max-t.min,h=a?Math.max(o-n,m):p;if(a&&h===m&&p<=m)return!0;const x=function(t,{min:n,max:o,minLimit:i,maxLimit:a},r,s){const c=(t-o+n)/2;n-=c,o+=c;const l={min:"original",max:"original"},m=g(r,s,l,"min",-1/0),u=g(r,s,l,"max",1/0),d=t/1e6;return e.almostEquals(n,m,d)&&(n=m),e.almostEquals(o,u,d)&&(o=u),n<i?(n=i,o=Math.min(i+t,a)):o>a&&(o=a,n=Math.max(a-t,i)),{min:n,max:o}}(h,{min:n,max:o,minLimit:d,maxLimit:f},s,t);return c.min=x.min,c.max=x.max,s.updatedScaleLimits[t.id]=x,t.parse(x.min)!==t.min||t.parse(x.max)!==t.max}const y=t=>0===t||isNaN(t)?0:t<0?Math.min(Math.round(t),-1):Math.max(Math.round(t),1);const b={millisecond:0,second:500,minute:3e4,hour:18e5,day:432e5,week:3024e5,month:1296e6,quarter:5184e6,year:157248e5};function v(t,n,e,o=!1){const{min:i,max:a}=t;let r=0;if((t=>"time"===t.type)(t)){const n=t.options.time?.round;r=n?b[n]:0}const s=t.getValueForPixel(t.getPixelForValue(i+r)-n),c=t.getValueForPixel(t.getPixelForValue(a+r)-n);return!(!d(s)&&!d(c))||x(t,{min:s,max:c},e,o,!0)}function w(t,n,e){return v(t,n,e,!0)}const M={category:function(t,n,e,o){const i=h(t,n,e);return t.min===t.max&&n<1&&function(t){const n=t.getLabels().length-1;t.min>0&&(t.min-=1),t.max<n&&(t.max+=1)}(t),x(t,{min:t.min+y(i.min),max:t.max-y(i.max)},o,!0)},default:function(t,n,e,o){const i=h(t,n,e);return x(t,{min:t.min+i.min,max:t.max-i.max},o,!0)},logarithmic:function(t,n,e,o){const i=function(t,n,e){const o=p(t,e);if(void 0===o)return{min:t.min,max:t.max};const i=Math.log10(t.min),a=Math.log10(t.max),r=a-i,s=f(Math.log10(o),i,r,r*(n-1));return{min:Math.pow(10,i+s.min),max:Math.pow(10,a-s.max)}}(t,n,e);return x(t,i,o,!0)}},z={default:function(t,n,e,o){return x(t,function(t,n,e){const o=t.getValueForPixel(n)??t.min,i=t.getValueForPixel(e)??t.max;return{min:Math.min(o,i),max:Math.max(o,i)}}(t,n,e),o,!0)}},S={category:function(t,n,e){const o=t.getLabels().length-1;let{min:i,max:a}=t;const r=Math.max(a-i,1),s=Math.round(function(t){return t.isHorizontal()?t.width:t.height}(t)/Math.max(r,10)),c=Math.round(Math.abs(n/s));let l;return n<-s?(a=Math.min(a+c,o),i=1===r?a:a-r,l=a===o):n>s&&(i=Math.max(0,i-c),a=1===r?i:i+r,l=0===i),x(t,{min:i,max:a},e)||Boolean(l)},default:v,logarithmic:w,timeseries:w};function P(t,n,e){const{id:o,options:{min:i,max:a}}=t;if(!n[o]||!e[o])return!0;const r=e[o];return r.min!==i||r.max!==a}function j(t,n){for(const e of Object.keys(t))n[e]||delete t[e]}function O(t,n){const{scales:e}=t,{originalScaleLimits:o,updatedScaleLimits:i}=n;for(const t of Object.values(e))P(t,o,i)&&(o[t.id]={min:{scale:t.min,options:t.options.min},max:{scale:t.max,options:t.options.max}});return j(o,e),j(i,e),o}function k(t,n,e,o){const i=M[t.type]||M.default;i?.(t,n,e,o)}function C(t,n,e,o){const i=z[t.type]||z.default;i?.(t,n,e,o)}function Z(t){const n=t.chartArea;return{x:(n.left+n.right)/2,y:(n.top+n.bottom)/2}}function D(t,n,e="none",o="api"){const{x:i=1,y:a=1,focalPoint:r=Z(t)}="number"==typeof n?{x:n,y:n}:n,s=u(t),{options:{limits:c={},zoom:m}}=s;O(t,s);const d=1!==i,f=1!==a,p=l(m,r,t);for(const t of p)t.isHorizontal()&&d?k(t,i,r,c):!t.isHorizontal()&&f&&k(t,a,r,c);t.update(e),m?.onZoom?.({chart:t,trigger:o,amount:{x:i,y:a,focalPoint:r}})}function R(t,n,e,o="none",i="api"){const a=u(t),{options:{limits:r={},zoom:c={}}}=a,{mode:l="xy"}=c;O(t,a);const m=s(l,"x",t),d=s(l,"y",t);for(const o of Object.values(t.scales))o.isHorizontal()&&m?C(o,n.x,e.x,r):!o.isHorizontal()&&d&&C(o,n.y,e.y,r);t.update(o),c.onZoom?.({chart:t,trigger:i})}function L(t,n){const o=t.originalScaleLimits[n];if(!o)return;const{min:i,max:a}=o;return e.isNumber(a.options)&&e.isNumber(i.options)?a.options-i.options:e.isNumber(a.scale)&&e.isNumber(i.scale)?a.scale-i.scale:void 0}function N(t,n,o,i){const{panDelta:a}=i,r=a[t.id]||0;e.sign(r)===e.sign(n)&&(n+=r);const s=S[t.type]||S.default;s?.(t,n,o)?a[t.id]=0:a[t.id]=n}function E(t,n,e,o="none",i="other"){const{x:a=0,y:r=0}="number"==typeof n?{x:n,y:n}:n,s=u(t),{options:{pan:c,limits:l={}}}=s,{onPan:m}=c||{};O(t,s);const d=0!==a,f=0!==r,p=e||Object.values(t.scales);for(const t of p)t.isHorizontal()&&d?N(t,a,l,s):!t.isHorizontal()&&f&&N(t,r,l,s);t.update(o),m?.({chart:t,trigger:i,delta:{x:a,y:r}})}function F(t){const n=u(t);O(t,n);const e={};for(const o of Object.keys(t.scales)){const{min:t,max:i}=n.originalScaleLimits[o]||{min:{},max:{}};e[o]={min:t.scale,max:i.scale}}return e}function A(t){return t.panning||t.dragging}const H=(t,n,e)=>Math.min(e,Math.max(n,t));function T(t,n){const{handlers:e,targets:o}=u(t),i=e[n],a=o[n];i&&a&&(a.removeEventListener(n,i),delete e[n])}function Y(t,n,e,o){const{handlers:i,options:a,targets:r}=u(t);if(i[e]&&r[e]===n)return;T(t,e);const s=i[e]=n=>o(t,n,a);r[e]=n;const c="wheel"!==e&&void 0;n.addEventListener(e,s,{passive:c})}function B(t,n){const e=u(t);e.dragStart&&(e.dragging=!0,e.dragEnd=n,t.draw())}function q(t,n){const e=u(t);e.dragStart&&"Escape"===n.key&&(T(t,"keydown"),e.dragging=!1,e.dragStart=e.dragEnd=void 0,t.draw())}function V(t,n){if(t.target!==n.canvas){const e=n.canvas.getBoundingClientRect();return{x:t.clientX-e.left,y:t.clientY-e.top}}return e.getRelativePosition(t,n)}function X(t,n,e){const{onZoomStart:o,onZoomRejected:i}=e;if(o){const e=V(n,t);if(!1===o?.({chart:t,event:n,point:e}))return i?.({chart:t,event:n}),!1}}function K(t,n){if(t.legend){const o=e.getRelativePosition(n,t);if(e._isPointInArea(o,t.legend))return}const o=u(t),{pan:s,zoom:c={}}=o.options;if(0!==n.button||a(i(s),n)||r(i(c.drag),n))return c.onZoomRejected?.({chart:t,event:n});!1!==X(t,n,c)&&(o.dragStart=n,Y(t,t.canvas.ownerDocument,"mousemove",B),Y(t,window.document,"keydown",q))}function W(t,n,e,{min:o,max:i,prop:a}){t[o]=H(Math.min(e.begin[a],e.end[a]),n[o],n[i]),t[i]=H(Math.max(e.begin[a],e.end[a]),n[o],n[i])}function I(t,n,e){const o={begin:V(n.dragStart,t),end:V(n.dragEnd,t)};if(e){!function({begin:t,end:n},e){let o=n.x-t.x,i=n.y-t.y;const a=Math.abs(o/i);a>e?o=Math.sign(o)*Math.abs(i*e):a<e&&(i=Math.sign(i)*Math.abs(o/e)),n.x=t.x+o,n.y=t.y+i}(o,t.chartArea.width/t.chartArea.height)}return o}function U(t,n,e,o){const i=s(n,"x",t),a=s(n,"y",t),{top:r,left:c,right:l,bottom:m,width:u,height:d}=t.chartArea,f={top:r,left:c,right:l,bottom:m},p=I(t,e,o&&i&&a);i&&W(f,t.chartArea,p,{min:"left",max:"right",prop:"x"}),a&&W(f,t.chartArea,p,{min:"top",max:"bottom",prop:"y"});const h=f.right-f.left,g=f.bottom-f.top;return{...f,width:h,height:g,zoomX:i&&h?1+(u-h)/u:1,zoomY:a&&g?1+(d-g)/d:1}}function $(t,n){const e=u(t);if(!e.dragStart)return;T(t,"mousemove");const{mode:o,onZoomComplete:i,drag:a}=e.options.zoom??{},{threshold:r=0,maintainAspectRatio:c}=a??{},l=U(t,o,{dragStart:e.dragStart,dragEnd:n},c),m=s(o,"x",t)?l.width:0,d=s(o,"y",t)?l.height:0,f=Math.sqrt(m*m+d*d);if(e.dragStart=e.dragEnd=void 0,f<=r)return e.dragging=!1,void t.draw();R(t,{x:l.left,y:l.top},{x:l.right,y:l.bottom},"zoom","drag"),e.dragging=!1,e.filterNextClick=!0,i?.({chart:t})}function _(t,n){const{handlers:{onZoomComplete:e},options:{zoom:o={}}}=u(t);if(!function(t,n,e){if(r(i(e.wheel),n))e.onZoomRejected?.({chart:t,event:n});else if(!1!==X(t,n,e)&&(n.cancelable&&n.preventDefault(),void 0!==n.deltaY))return!0}(t,n,o))return;const a=n.target?.getBoundingClientRect(),s=o?.wheel?.speed??.1,c=n.deltaY>=0?2-1/(1-s):1+s;D(t,{x:c,y:c,focalPoint:{x:n.clientX-a.left,y:n.clientY-a.top}},"zoom","wheel"),e?.(n)}function G(t,n,e,o){e&&(u(t).handlers[n]=function(t,n){let e;return function(){return clearTimeout(e),e=setTimeout(t,n),n}}((()=>e?.({chart:t})),o))}function J(t,n){return function(e,o){const{pan:s,zoom:c={}}=n.options;if(!s||!s.enabled)return!1;const l=o&&o.srcEvent;return!l||(!(!n.panning&&"mouse"===o.pointerType&&(r(i(s),l)||a(i(c.drag),l)))||(s.onPanRejected?.({chart:t,event:o}),!1))}}function Q(t,n,e){if(n.scale){const{center:o,pointers:i}=e,a=1/n.scale*e.scale,r=e.target.getBoundingClientRect(),c=function(t,n){const e=Math.abs(t.clientX-n.clientX),o=Math.abs(t.clientY-n.clientY),i=e/o;let a,r;return i>.3&&i<1.7?a=r=!0:e>o?a=!0:r=!0,{x:a,y:r}}(i[0],i[1]),l=n.options.zoom?.mode;D(t,{x:c.x&&s(l,"x",t)?a:1,y:c.y&&s(l,"y",t)?a:1,focalPoint:{x:o.x-r.left,y:o.y-r.top}},"zoom","pinch"),n.scale=e.scale}}function tt(t,n,e){const o=n.delta;o&&(n.panning=!0,E(t,{x:e.deltaX-o.x,y:e.deltaY-o.y},n.panScales&&n.panScales.map((n=>t.scales[n])).filter(Boolean)),n.delta={x:e.deltaX,y:e.deltaY})}const nt=new WeakMap;function et(t,o){const i=u(t),a=t.canvas,{pan:r,zoom:s}=o,c=new n.Manager(a);s?.pinch?.enabled&&(c.add(new n.Pinch),c.on("pinchstart",(n=>function(t,n,o){if(n.options.zoom?.pinch?.enabled){const i=e.getRelativePosition(o.srcEvent,t);!1===n.options.zoom?.onZoomStart?.({chart:t,event:o.srcEvent,point:i})?(n.scale=null,n.options.zoom?.onZoomRejected?.({chart:t,event:o.srcEvent})):n.scale=1}}(t,i,n))),c.on("pinch",(n=>Q(t,i,n))),c.on("pinchend",(n=>function(t,n,e){n.scale&&(Q(t,n,e),n.scale=null,n.options.zoom?.onZoomComplete?.({chart:t}))}(t,i,n)))),r&&r.enabled&&(c.add(new n.Pan({threshold:r.threshold,enable:J(t,i)})),c.on("panstart",(n=>function(t,n,e){const{enabled:o,onPanStart:i,onPanRejected:a}=n.options.pan??{};if(!o)return;const r=e.target.getBoundingClientRect(),s={x:e.center.x-r.left,y:e.center.y-r.top};if(!1===i?.({chart:t,event:e,point:s}))return a?.({chart:t,event:e});n.panScales=l(n.options.pan,s,t).map((t=>t.id)),n.delta={x:0,y:0},tt(t,n,e)}(t,i,n))),c.on("panmove",(n=>tt(t,i,n))),c.on("panend",(()=>function(t,n){n.delta=null,n.panning&&(n.panning=!1,n.filterNextClick=!0,n.options.pan?.onPanComplete?.({chart:t}))}(t,i)))),nt.set(t,c)}function ot(t){const n=nt.get(t);n&&(n.remove("pinchstart"),n.remove("pinch"),n.remove("pinchend"),n.remove("panstart"),n.remove("pan"),n.remove("panend"),n.destroy(),nt.delete(t))}function it(t,n,e){const o=e.zoom?.drag,{dragStart:i,dragEnd:a}=u(t);if(o?.drawTime!==n||!i||!a)return;const{left:r,top:s,width:c,height:l}=U(t,e.zoom?.mode,{dragStart:i,dragEnd:a},o.maintainAspectRatio),m=t.ctx;m.save(),m.beginPath(),m.fillStyle=o.backgroundColor||"rgba(225,225,225,0.3)",m.fillRect(r,s,c,l),o.borderWidth&&(m.lineWidth=o.borderWidth,m.strokeStyle=o.borderColor||"rgba(225,225,225)",m.strokeRect(r,s,c,l)),m.restore()}const at=t=>{t.pan=(n,e,o)=>E(t,n,e,o,"api"),t.zoom=(n,e)=>D(t,n,e),t.zoomRect=(n,e,o)=>R(t,n,e,o),t.zoomScale=(n,e,o)=>function(t,n,e,o="none",i="api"){const a=u(t);O(t,a),x(t.scales[n],e,void 0,!0),t.update(o),a.options.zoom?.onZoom?.({chart:t,trigger:i})}(t,n,e,o),t.resetZoom=n=>function(t,n="default"){const e=u(t),o=O(t,e);for(const n of Object.values(t.scales)){const t=n.options;o[n.id]?(t.min=o[n.id].min.options,t.max=o[n.id].max.options):(delete t.min,delete t.max),delete e.updatedScaleLimits[n.id]}t.update(n),e.options.zoom?.onZoomComplete?.({chart:t})}(t,n),t.getZoomLevel=()=>function(t){const n=u(t);let e=1,o=1;for(const i of Object.values(t.scales)){const t=L(n,i.id);if(t){const n=Math.round(t/(i.max-i.min)*100)/100;e=Math.min(e,n),o=Math.max(o,n)}}return e<1?e:o}(t),t.getInitialScaleBounds=()=>F(t),t.getZoomedScaleBounds=()=>function(t){const n=u(t),e={};for(const o of Object.keys(t.scales))e[o]=n.updatedScaleLimits[o];return e}(t),t.isZoomedOrPanned=()=>function(t){const n=F(t);for(const e of Object.keys(t.scales)){const{min:o,max:i}=n[e];if(void 0!==o&&t.scales[e].min!==o)return!0;if(void 0!==i&&t.scales[e].max!==i)return!0}return!1}(t),t.isZoomingOrPanning=()=>function(t){const n=u(t);return!(!A(n)&&!n.filterNextClick)}(t)};var rt={id:"zoom",version:"2.2.22",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(t,e,o){u(t).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)."),n&&et(t,o),at(t)},beforeEvent(t,{event:n}){const e=u(t);return!A(e)&&("click"!==n.type&&"mouseup"!==n.type||!e.filterNextClick?void 0:(e.filterNextClick=!1,!1))},beforeUpdate(t,n,e){const o=u(t),i=o.options;o.options=e,function(t,n){const{pan:e,zoom:o}=t,{pan:i,zoom:a}=n;return o?.pinch?.enabled!==a?.pinch?.enabled||e?.enabled!==i?.enabled||e?.threshold!==i?.threshold}(i,e)&&(ot(t),et(t,e)),function(t,n){const e=t.canvas,{wheel:o,drag:i,onZoomComplete:a}=n.zoom??{};o?.enabled?(Y(t,e,"wheel",_),G(t,"onZoomComplete",a,250)):T(t,"wheel"),i?.enabled?(Y(t,e,"mousedown",K),Y(t,e.ownerDocument,"mouseup",$)):(T(t,"mousedown"),T(t,"mousemove"),T(t,"mouseup"),T(t,"keydown"))}(t,e)},beforeDatasetsDraw(t,n,e){it(t,"beforeDatasetsDraw",e)},afterDatasetsDraw(t,n,e){it(t,"afterDatasetsDraw",e)},beforeDraw(t,n,e){it(t,"beforeDraw",e)},afterDraw(t,n,e){it(t,"afterDraw",e)},stop(t){!function(t){T(t,"mousedown"),T(t,"mousemove"),T(t,"mouseup"),T(t,"wheel"),T(t,"click"),T(t,"keydown")}(t),n&&ot(t),function(t){m.delete(t)}(t)},panFunctions:S,zoomFunctions:M,zoomRectFunctions:z};return t.Chart.register(rt),rt}));
|
|
8
8
|
//# sourceMappingURL=chartjs-plugin-zoom.min.js.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { type ScaleRange, type State } from './state.js';
|
|
2
|
+
import type { Chart, Point, Scale, UpdateMode } from 'chart.js';
|
|
3
|
+
import type { PanTrigger, ZoomTrigger } from './options.js';
|
|
4
|
+
import type { ZoomAmount } from './types.js';
|
|
5
|
+
export declare function zoom(chart: Chart, amount: ZoomAmount, transition?: UpdateMode, trigger?: ZoomTrigger): void;
|
|
6
|
+
export declare function zoomRect(chart: Chart, p0: Point, p1: Point, transition?: UpdateMode, trigger?: ZoomTrigger): void;
|
|
7
|
+
export declare function zoomScale(chart: Chart, scaleId: string, range: ScaleRange, transition?: UpdateMode, trigger?: ZoomTrigger): void;
|
|
8
|
+
export declare function resetZoom(chart: Chart, transition?: UpdateMode): void;
|
|
9
|
+
export declare function getZoomLevel(chart: Chart): number;
|
|
10
|
+
type PanAmount = number | Partial<Point>;
|
|
11
|
+
export declare function pan(chart: Chart, delta: PanAmount, enabledScales?: Scale[], transition?: UpdateMode, trigger?: PanTrigger): void;
|
|
12
|
+
export declare function getInitialScaleBounds(chart: Chart): Record<string, {
|
|
13
|
+
min?: number | undefined;
|
|
14
|
+
max?: number | undefined;
|
|
15
|
+
}>;
|
|
16
|
+
export declare function getZoomedScaleBounds(chart: Chart): Record<string, {
|
|
17
|
+
min?: number | undefined;
|
|
18
|
+
max?: number | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare function isZoomedOrPanned(chart: Chart): boolean;
|
|
21
|
+
export declare function isZoomingOrPanningState(state: State): boolean;
|
|
22
|
+
export declare function isZoomingOrPanning(chart: Chart): boolean;
|
|
23
|
+
export {};
|
|
24
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { Chart } from 'chart.js';
|
|
2
|
+
import type { ZoomPluginOptions } from './options';
|
|
3
|
+
export declare function startHammer(chart: Chart, options: ZoomPluginOptions): void;
|
|
4
|
+
export declare function stopHammer(chart: Chart): void;
|
|
5
|
+
export declare function hammerOptionsChanged(oldOptions: ZoomPluginOptions, newOptions: ZoomPluginOptions): boolean;
|
|
6
|
+
//# sourceMappingURL=hammer.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Chart } from 'chart.js';
|
|
2
|
+
import type { ModeOption, ZoomPluginOptions } from './options';
|
|
3
|
+
export declare function mouseMove(chart: Chart, event: MouseEvent): void;
|
|
4
|
+
export declare function mouseDown(chart: Chart, event: MouseEvent): void;
|
|
5
|
+
export declare function computeDragRect(chart: Chart, mode: ModeOption | undefined, pointEvents: {
|
|
6
|
+
dragStart: MouseEvent;
|
|
7
|
+
dragEnd: MouseEvent;
|
|
8
|
+
}, maintainAspectRatio: boolean | undefined): {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
zoomX: number;
|
|
12
|
+
zoomY: number;
|
|
13
|
+
top: number;
|
|
14
|
+
left: number;
|
|
15
|
+
right: number;
|
|
16
|
+
bottom: number;
|
|
17
|
+
};
|
|
18
|
+
export declare function mouseUp(chart: Chart, event: MouseEvent): void;
|
|
19
|
+
export declare function wheel(chart: Chart, event: WheelEvent & {
|
|
20
|
+
target?: HTMLCanvasElement;
|
|
21
|
+
}): void;
|
|
22
|
+
export declare function addListeners(chart: Chart, options: ZoomPluginOptions): void;
|
|
23
|
+
export declare function removeListeners(chart: Chart): void;
|
|
24
|
+
//# sourceMappingURL=handlers.d.ts.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import plugin from './plugin';
|
|
2
|
+
import type { ZoomPluginOptions } from './options';
|
|
3
|
+
import type { ScaleRange } from './state';
|
|
4
|
+
import type { DistributiveArray, PanAmount, ZoomAmount } from './types.js';
|
|
5
|
+
import type { ChartType, ChartTypeRegistry, Point, Scale, UpdateMode } from 'chart.js';
|
|
6
|
+
declare module 'chart.js' {
|
|
7
|
+
interface PluginOptionsByType<TType extends ChartType> {
|
|
8
|
+
zoom: ZoomPluginOptions;
|
|
9
|
+
}
|
|
10
|
+
enum UpdateModeEnum {
|
|
11
|
+
zoom = "zoom"
|
|
12
|
+
}
|
|
13
|
+
interface Chart<TType extends ChartType = keyof ChartTypeRegistry, TData = DistributiveArray<ChartTypeRegistry[TType]['defaultDataPoint']>, TLabel = unknown> {
|
|
14
|
+
pan(pan: PanAmount, scales?: Scale[], mode?: UpdateMode): void;
|
|
15
|
+
zoom(zoom: ZoomAmount, mode?: UpdateMode): void;
|
|
16
|
+
zoomRect(p0: Point, p1: Point, mode?: UpdateMode): void;
|
|
17
|
+
zoomScale(id: string, range: ScaleRange, mode?: UpdateMode): void;
|
|
18
|
+
resetZoom(mode?: UpdateMode): void;
|
|
19
|
+
getZoomLevel(): number;
|
|
20
|
+
getInitialScaleBounds(): Record<string, {
|
|
21
|
+
min?: number;
|
|
22
|
+
max?: number;
|
|
23
|
+
}>;
|
|
24
|
+
getZoomedScaleBounds(): Record<string, Partial<ScaleRange>>;
|
|
25
|
+
isZoomedOrPanned(): boolean;
|
|
26
|
+
isZoomingOrPanning(): boolean;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
export default plugin;
|
|
30
|
+
export { pan, zoom, zoomRect, zoomScale, resetZoom } from './core';
|
|
31
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/// <reference types="hammerjs" />
|
|
2
|
+
import type { Chart, Color, Point } from 'chart.js';
|
|
3
|
+
export type Mode = 'x' | 'y' | 'xy';
|
|
4
|
+
export type ModeFn = (context: {
|
|
5
|
+
chart: Chart;
|
|
6
|
+
}) => Mode;
|
|
7
|
+
export type ModeOption = Mode | ModeFn;
|
|
8
|
+
export type ModifierKey = 'ctrl' | 'alt' | 'shift' | 'meta';
|
|
9
|
+
export type DrawTime = 'afterDraw' | 'afterDatasetsDraw' | 'beforeDraw' | 'beforeDatasetsDraw';
|
|
10
|
+
export type ZoomTrigger = 'api' | 'drag' | 'wheel' | 'pinch';
|
|
11
|
+
export type PanTrigger = 'api' | 'drag' | 'wheel' | 'other';
|
|
12
|
+
type RejectableStartEvent<T = Event | HammerInput> = (context: {
|
|
13
|
+
chart: Chart;
|
|
14
|
+
event: T;
|
|
15
|
+
point: Point;
|
|
16
|
+
}) => boolean | undefined;
|
|
17
|
+
type RejectEvent<T = Event | HammerInput> = (context: {
|
|
18
|
+
chart: Chart;
|
|
19
|
+
event: T;
|
|
20
|
+
}) => void;
|
|
21
|
+
type GenericEvent = (context: {
|
|
22
|
+
chart: Chart;
|
|
23
|
+
}) => void;
|
|
24
|
+
export interface WheelOptions {
|
|
25
|
+
/**
|
|
26
|
+
* Enable the zoom via mouse wheel
|
|
27
|
+
*/
|
|
28
|
+
enabled?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Speed of zoom via mouse wheel
|
|
31
|
+
* (percentage of zoom on a wheel event)
|
|
32
|
+
*/
|
|
33
|
+
speed?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Modifier key required for zooming with mouse
|
|
36
|
+
*/
|
|
37
|
+
modifierKey?: ModifierKey | null;
|
|
38
|
+
}
|
|
39
|
+
export interface DragOptions {
|
|
40
|
+
/**
|
|
41
|
+
* Enable the zoom via drag
|
|
42
|
+
*/
|
|
43
|
+
enabled?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Minimal zoom distance required before actually applying zoom
|
|
46
|
+
*/
|
|
47
|
+
threshold?: number;
|
|
48
|
+
/**
|
|
49
|
+
* Border color of the drag area
|
|
50
|
+
*/
|
|
51
|
+
borderColor?: Color;
|
|
52
|
+
/**
|
|
53
|
+
* Border width of the drag area
|
|
54
|
+
*/
|
|
55
|
+
borderWidth?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Background color of the drag area
|
|
58
|
+
*/
|
|
59
|
+
backgroundColor?: Color;
|
|
60
|
+
/**
|
|
61
|
+
* Modifier key required for drag-to-zoom
|
|
62
|
+
*/
|
|
63
|
+
modifierKey?: ModifierKey | null;
|
|
64
|
+
/**
|
|
65
|
+
* Draw time required for drag-to-zoom
|
|
66
|
+
*/
|
|
67
|
+
drawTime?: DrawTime;
|
|
68
|
+
/**
|
|
69
|
+
* Maintain aspect ratio of the drag rectangle
|
|
70
|
+
*/
|
|
71
|
+
maintainAspectRatio?: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface PinchOptions {
|
|
74
|
+
/**
|
|
75
|
+
* Enable the zoom via pinch
|
|
76
|
+
*/
|
|
77
|
+
enabled?: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Container for zoom options
|
|
81
|
+
*/
|
|
82
|
+
export interface ZoomOptions {
|
|
83
|
+
/**
|
|
84
|
+
* Zooming directions. Remove the appropriate direction to disable
|
|
85
|
+
* E.g. 'y' would only allow zooming in the y direction
|
|
86
|
+
* A function that is called as the user is zooming and returns the
|
|
87
|
+
* available directions can also be used:
|
|
88
|
+
* mode: function({ chart }) {
|
|
89
|
+
* return 'xy';
|
|
90
|
+
* },
|
|
91
|
+
*/
|
|
92
|
+
mode?: ModeOption;
|
|
93
|
+
/**
|
|
94
|
+
* Options of the mouse wheel mode
|
|
95
|
+
*/
|
|
96
|
+
wheel?: WheelOptions;
|
|
97
|
+
/**
|
|
98
|
+
* Options of the drag-to-zoom mode
|
|
99
|
+
*/
|
|
100
|
+
drag?: DragOptions;
|
|
101
|
+
/**
|
|
102
|
+
* Options of the pinch mode
|
|
103
|
+
*/
|
|
104
|
+
pinch?: PinchOptions;
|
|
105
|
+
scaleMode?: ModeOption;
|
|
106
|
+
/** @deprecated Use scaleMode instead */
|
|
107
|
+
overScaleMode?: ModeOption;
|
|
108
|
+
/**
|
|
109
|
+
* Function called while the user is zooming
|
|
110
|
+
*/
|
|
111
|
+
onZoom?: (context: {
|
|
112
|
+
chart: Chart;
|
|
113
|
+
trigger: ZoomTrigger;
|
|
114
|
+
amount?: {
|
|
115
|
+
x: number;
|
|
116
|
+
y: number;
|
|
117
|
+
} & {
|
|
118
|
+
focalPoint: Point;
|
|
119
|
+
};
|
|
120
|
+
}) => void;
|
|
121
|
+
/**
|
|
122
|
+
* Function called once zooming is completed
|
|
123
|
+
*/
|
|
124
|
+
onZoomComplete?: GenericEvent;
|
|
125
|
+
/**
|
|
126
|
+
* Function called when wheel input occurs without modifier key
|
|
127
|
+
*/
|
|
128
|
+
onZoomRejected?: RejectEvent<Event>;
|
|
129
|
+
onZoomStart?: RejectableStartEvent<Event>;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Container for pan options
|
|
133
|
+
*/
|
|
134
|
+
export interface PanOptions {
|
|
135
|
+
/**
|
|
136
|
+
* Boolean to enable panning
|
|
137
|
+
*/
|
|
138
|
+
enabled?: boolean;
|
|
139
|
+
/**
|
|
140
|
+
* Panning directions. Remove the appropriate direction to disable
|
|
141
|
+
* E.g. 'y' would only allow panning in the y direction
|
|
142
|
+
* A function that is called as the user is panning and returns the
|
|
143
|
+
* available directions can also be used:
|
|
144
|
+
* mode: function({ chart }) {
|
|
145
|
+
* return 'xy';
|
|
146
|
+
* },
|
|
147
|
+
*/
|
|
148
|
+
mode?: ModeOption;
|
|
149
|
+
/**
|
|
150
|
+
* Modifier key required for panning with mouse
|
|
151
|
+
*/
|
|
152
|
+
modifierKey?: ModifierKey | null;
|
|
153
|
+
scaleMode?: ModeOption;
|
|
154
|
+
/** @deprecated Use scaleMode instead */
|
|
155
|
+
overScaleMode?: ModeOption;
|
|
156
|
+
/**
|
|
157
|
+
* Minimal pan distance required before actually applying pan
|
|
158
|
+
*/
|
|
159
|
+
threshold?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Function called while the user is panning
|
|
162
|
+
*/
|
|
163
|
+
onPan?: (context: {
|
|
164
|
+
chart: Chart;
|
|
165
|
+
trigger: PanTrigger;
|
|
166
|
+
delta: {
|
|
167
|
+
x: number;
|
|
168
|
+
y: number;
|
|
169
|
+
};
|
|
170
|
+
}) => void;
|
|
171
|
+
/**
|
|
172
|
+
* Function called once panning is completed
|
|
173
|
+
*/
|
|
174
|
+
onPanComplete?: GenericEvent;
|
|
175
|
+
/**
|
|
176
|
+
* Function called when pan fails because modifier key was not detected.
|
|
177
|
+
* event is the Hammer event that failed - see https://hammerjs.github.io/api#event-object
|
|
178
|
+
*/
|
|
179
|
+
onPanRejected?: RejectEvent<HammerInput>;
|
|
180
|
+
onPanStart?: RejectableStartEvent<HammerInput>;
|
|
181
|
+
}
|
|
182
|
+
export interface ScaleLimits {
|
|
183
|
+
min?: number | 'original';
|
|
184
|
+
max?: number | 'original';
|
|
185
|
+
minRange?: number;
|
|
186
|
+
}
|
|
187
|
+
export interface LimitOptions {
|
|
188
|
+
[axisId: string]: ScaleLimits;
|
|
189
|
+
}
|
|
190
|
+
export interface ZoomPluginOptions {
|
|
191
|
+
pan?: PanOptions;
|
|
192
|
+
limits?: LimitOptions;
|
|
193
|
+
zoom?: ZoomOptions;
|
|
194
|
+
}
|
|
195
|
+
export {};
|
|
196
|
+
//# sourceMappingURL=options.d.ts.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { Chart, ChartEvent } from 'chart.js';
|
|
2
|
+
import type { ZoomPluginOptions } from './options';
|
|
3
|
+
declare const _default: {
|
|
4
|
+
id: string;
|
|
5
|
+
version: string;
|
|
6
|
+
defaults: ZoomPluginOptions;
|
|
7
|
+
start(chart: Chart, _args: unknown, options: ZoomPluginOptions): void;
|
|
8
|
+
beforeEvent(chart: Chart, { event }: {
|
|
9
|
+
event: ChartEvent;
|
|
10
|
+
replay: boolean;
|
|
11
|
+
cancelable: true;
|
|
12
|
+
inChartArea: boolean;
|
|
13
|
+
}): boolean | void;
|
|
14
|
+
beforeUpdate(chart: Chart, _args: unknown, options: ZoomPluginOptions): void;
|
|
15
|
+
beforeDatasetsDraw(chart: Chart, _args: unknown, options: ZoomPluginOptions): void;
|
|
16
|
+
afterDatasetsDraw(chart: Chart, _args: unknown, options: ZoomPluginOptions): void;
|
|
17
|
+
beforeDraw(chart: Chart, _args: unknown, options: ZoomPluginOptions): void;
|
|
18
|
+
afterDraw(chart: Chart, _args: unknown, options: ZoomPluginOptions): void;
|
|
19
|
+
stop(chart: Chart): void;
|
|
20
|
+
panFunctions: Record<string, import("./scale.types").PanFunction>;
|
|
21
|
+
zoomFunctions: Record<string, import("./scale.types").ZoomFunction>;
|
|
22
|
+
zoomRectFunctions: Record<string, import("./scale.types").ZoomRectFunction>;
|
|
23
|
+
};
|
|
24
|
+
export default _default;
|
|
25
|
+
//# sourceMappingURL=plugin.d.ts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type ScaleRange } from './state';
|
|
2
|
+
import type { Point, Scale } from 'chart.js';
|
|
3
|
+
import type { LimitOptions } from './options';
|
|
4
|
+
export type ZoomFunction = (scale: Scale, zoom: number, center: Point, limits: LimitOptions) => boolean;
|
|
5
|
+
export type ZoomRectFunction = (scale: Scale, from: number, to: number, limits: LimitOptions) => boolean;
|
|
6
|
+
export type PanFunction = (scale: Scale, delta: number, limits: LimitOptions) => boolean;
|
|
7
|
+
export declare function zoomDelta(val: number | undefined, min: number | undefined, range: number, newRange: number): ScaleRange;
|
|
8
|
+
export declare function updateRange(scale: Scale, { min, max }: ScaleRange, limits?: LimitOptions, zoom?: boolean, pan?: boolean): boolean;
|
|
9
|
+
export declare const zoomFunctions: Record<string, ZoomFunction>;
|
|
10
|
+
export declare const zoomRectFunctions: Record<string, ZoomRectFunction>;
|
|
11
|
+
export declare const panFunctions: Record<string, PanFunction>;
|
|
12
|
+
//# sourceMappingURL=scale.types.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Chart, type Point } from 'chart.js';
|
|
2
|
+
import type { ZoomPluginOptions } from './options';
|
|
3
|
+
export type ScaleRange = {
|
|
4
|
+
min: number;
|
|
5
|
+
max: number;
|
|
6
|
+
};
|
|
7
|
+
export type OriginalLimits = {
|
|
8
|
+
min: {
|
|
9
|
+
scale?: number;
|
|
10
|
+
options?: unknown;
|
|
11
|
+
};
|
|
12
|
+
max: {
|
|
13
|
+
scale?: number;
|
|
14
|
+
options?: unknown;
|
|
15
|
+
};
|
|
16
|
+
};
|
|
17
|
+
export type OriginalScaleLimits = Record<string, OriginalLimits>;
|
|
18
|
+
export type UpdatedScaleLimits = Record<string, ScaleRange>;
|
|
19
|
+
export type HandlerFunctions = {
|
|
20
|
+
click: (chart: Chart, event: MouseEvent, options: ZoomPluginOptions) => void;
|
|
21
|
+
keydown: (chart: Chart, event: KeyboardEvent) => void;
|
|
22
|
+
mousedown: (chart: Chart, event: MouseEvent, options: ZoomPluginOptions) => void;
|
|
23
|
+
mousemove: (chart: Chart, event: MouseEvent, options: ZoomPluginOptions) => void;
|
|
24
|
+
mouseup: (chart: Chart, event: MouseEvent, options: ZoomPluginOptions) => void;
|
|
25
|
+
onZoomComplete: ({ chart }: {
|
|
26
|
+
chart: Chart;
|
|
27
|
+
}) => void;
|
|
28
|
+
wheel: (chart: Chart, event: WheelEvent) => void;
|
|
29
|
+
};
|
|
30
|
+
export type HandlerName = keyof HandlerFunctions;
|
|
31
|
+
export type HandlerFunction = HandlerFunctions[HandlerName];
|
|
32
|
+
export type Handler = EventListener;
|
|
33
|
+
export type Handlers = Partial<Record<HandlerName, Handler>>;
|
|
34
|
+
export type HandlerTarget = Partial<Record<HandlerName, HTMLCanvasElement | Document>>;
|
|
35
|
+
export interface State {
|
|
36
|
+
originalScaleLimits: OriginalScaleLimits;
|
|
37
|
+
updatedScaleLimits: UpdatedScaleLimits;
|
|
38
|
+
handlers: Handlers;
|
|
39
|
+
targets: HandlerTarget;
|
|
40
|
+
panDelta: Record<string, number>;
|
|
41
|
+
dragging: boolean;
|
|
42
|
+
panning: boolean;
|
|
43
|
+
options: ZoomPluginOptions;
|
|
44
|
+
dragStart?: MouseEvent;
|
|
45
|
+
dragEnd?: MouseEvent;
|
|
46
|
+
filterNextClick?: boolean;
|
|
47
|
+
scale?: number | null;
|
|
48
|
+
delta?: Point | null;
|
|
49
|
+
panScales?: string[];
|
|
50
|
+
}
|
|
51
|
+
export declare function getState(chart: Chart): State;
|
|
52
|
+
export declare function removeState(chart: Chart): void;
|
|
53
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Point } from 'chart.js';
|
|
2
|
+
export type ZoomAmount = number | (Partial<Point> & {
|
|
3
|
+
focalPoint?: Point;
|
|
4
|
+
});
|
|
5
|
+
export type PanAmount = number | Partial<Point>;
|
|
6
|
+
export type ScaleRange = {
|
|
7
|
+
min: number;
|
|
8
|
+
max: number;
|
|
9
|
+
};
|
|
10
|
+
export type DistributiveArray<T> = [T] extends [unknown] ? Array<T> : never;
|
|
11
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Chart, Point, Scale } from 'chart.js';
|
|
2
|
+
import type { DragOptions, ModeOption, ModifierKey, PanOptions } from './options';
|
|
3
|
+
export declare const getModifierKey: (opts?: DragOptions | PanOptions) => ModifierKey | undefined;
|
|
4
|
+
export declare const keyPressed: (key: ModifierKey | undefined, event: TouchEvent | MouseEvent | PointerEvent) => boolean | undefined;
|
|
5
|
+
export declare const keyNotPressed: (key: ModifierKey | undefined, event: TouchEvent | MouseEvent | PointerEvent) => boolean | undefined;
|
|
6
|
+
export declare function directionEnabled(mode: ModeOption | undefined, dir: 'x' | 'y', chart: Chart): boolean;
|
|
7
|
+
export declare function debounce(fn: () => void, delay: number | undefined): () => number | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* Evaluate the chart's mode, scaleMode, and overScaleMode properties to
|
|
10
|
+
* determine which axes are eligible for scaling.
|
|
11
|
+
* options.overScaleMode can be a function if user want zoom only one scale of many for example.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getEnabledScalesByPoint(options: PanOptions | undefined, point: Point, chart: Chart): Scale[];
|
|
14
|
+
//# sourceMappingURL=utils.d.ts.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thewhitehaven04/chartjs-plugin-zoom",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.25",
|
|
4
4
|
"description": "A fork of the ChartJS Zoom plugin that enables zoom and pan functionality in Chart.js charts",
|
|
5
5
|
"homepage": "https://www.chartjs.org/chartjs-plugin-zoom/",
|
|
6
6
|
"repository": {
|
|
@@ -13,17 +13,17 @@
|
|
|
13
13
|
"unpkg": "dist/chartjs-plugin-zoom.min.js",
|
|
14
14
|
"main": "dist/chartjs-plugin-zoom.js",
|
|
15
15
|
"module": "dist/chartjs-plugin-zoom.esm.js",
|
|
16
|
-
"types": "dist/
|
|
16
|
+
"types": "dist/src/index.d.ts",
|
|
17
17
|
"exports": {
|
|
18
18
|
".": {
|
|
19
|
-
"types": "./dist/
|
|
19
|
+
"types": "./dist/index.d.ts",
|
|
20
20
|
"import": "./dist/chartjs-plugin-zoom-esm.js",
|
|
21
21
|
"require": "./dist/chartjs-plugin-zoom.js"
|
|
22
22
|
}
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
25
25
|
"dist/*.js",
|
|
26
|
-
"dist/*.d.ts",
|
|
26
|
+
"dist/src/*.d.ts",
|
|
27
27
|
"dist/*.map"
|
|
28
28
|
],
|
|
29
29
|
"scripts": {
|