@thewhitehaven04/chartjs-plugin-zoom 2.2.31 → 2.2.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thewhitehaven04/chartjs-plugin-zoom",
3
- "version": "2.2.31",
3
+ "version": "2.2.33",
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": {
@@ -11,19 +11,20 @@
11
11
  "type": "module",
12
12
  "jsdelivr": "dist/chartjs-plugin-zoom.min.js",
13
13
  "unpkg": "dist/chartjs-plugin-zoom.min.js",
14
- "main": "dist/chartjs-plugin-zoom.js",
15
- "module": "dist/chartjs-plugin-zoom.esm.js",
16
- "types": "dist/index.d.ts",
14
+ "main": "./dist/chartjs-plugin-zoom.js",
15
+ "module": "./dist/chartjs-plugin-zoom.esm.js",
16
+ "types": "types/index.d.ts",
17
17
  "exports": {
18
18
  ".": {
19
- "types": "./dist/index.d.ts",
19
+ "types": "./dist/**/*.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/*.d.ts",
27
+ "types"
27
28
  ],
28
29
  "scripts": {
29
30
  "autobuild": "rollup -c -w",
@@ -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