@mui/x-charts-pro 8.0.0 → 8.1.0
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/BarChartPro/BarChartPro.js +5 -0
- package/BarChartPro/BarChartPro.plugins.d.ts +2 -1
- package/BarChartPro/BarChartPro.plugins.js +2 -1
- package/CHANGELOG.md +106 -0
- package/ChartContainerPro/ChartContainerPro.d.ts +1 -0
- package/ChartDataProviderPro/ChartDataProviderPro.js +11 -2
- package/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -0
- package/ChartDataProviderPro/useChartDataProviderProProps.js +2 -0
- package/FunnelChart/FunnelChart.js +5 -0
- package/Heatmap/Heatmap.js +4 -0
- package/Heatmap/HeatmapItem.js +1 -1
- package/LineChartPro/LineChartPro.js +5 -0
- package/LineChartPro/LineChartPro.plugins.d.ts +2 -1
- package/LineChartPro/LineChartPro.plugins.js +2 -1
- package/ScatterChartPro/ScatterChartPro.js +5 -0
- package/ScatterChartPro/ScatterChartPro.plugins.d.ts +2 -1
- package/ScatterChartPro/ScatterChartPro.plugins.js +2 -1
- package/esm/BarChartPro/BarChartPro.js +5 -0
- package/esm/BarChartPro/BarChartPro.plugins.d.ts +2 -1
- package/esm/BarChartPro/BarChartPro.plugins.js +2 -1
- package/esm/ChartContainerPro/ChartContainerPro.d.ts +1 -0
- package/esm/ChartDataProviderPro/ChartDataProviderPro.js +11 -2
- package/esm/ChartDataProviderPro/useChartDataProviderProProps.d.ts +1 -0
- package/esm/ChartDataProviderPro/useChartDataProviderProProps.js +2 -0
- package/esm/FunnelChart/FunnelChart.js +5 -0
- package/esm/Heatmap/Heatmap.js +4 -0
- package/esm/Heatmap/HeatmapItem.js +1 -1
- package/esm/LineChartPro/LineChartPro.js +5 -0
- package/esm/LineChartPro/LineChartPro.plugins.d.ts +2 -1
- package/esm/LineChartPro/LineChartPro.plugins.js +2 -1
- package/esm/ScatterChartPro/ScatterChartPro.js +5 -0
- package/esm/ScatterChartPro/ScatterChartPro.plugins.d.ts +2 -1
- package/esm/ScatterChartPro/ScatterChartPro.plugins.js +2 -1
- package/esm/index.d.ts +1 -0
- package/esm/index.js +2 -1
- package/esm/internals/plugins/allPlugins.d.ts +5 -4
- package/esm/internals/plugins/allPlugins.js +3 -2
- package/esm/internals/plugins/useChartProExport/index.d.ts +2 -0
- package/esm/internals/plugins/useChartProExport/index.js +2 -0
- package/esm/internals/plugins/useChartProExport/print.d.ts +4 -0
- package/esm/internals/plugins/useChartProExport/print.js +72 -0
- package/esm/internals/plugins/useChartProExport/useChartProExport.d.ts +3 -0
- package/esm/internals/plugins/useChartProExport/useChartProExport.js +45 -0
- package/esm/internals/plugins/useChartProExport/useChartProExport.types.d.ts +35 -0
- package/esm/internals/plugins/useChartProExport/useChartProExport.types.js +1 -0
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.d.ts +2 -1
- package/esm/internals/plugins/useChartProZoom/useChartProZoom.js +53 -29
- package/esm/locales/index.d.ts +1 -0
- package/esm/locales/index.js +1 -0
- package/index.d.ts +1 -0
- package/index.js +12 -1
- package/internals/plugins/allPlugins.d.ts +5 -4
- package/internals/plugins/allPlugins.js +3 -2
- package/internals/plugins/useChartProExport/index.d.ts +2 -0
- package/internals/plugins/useChartProExport/index.js +27 -0
- package/internals/plugins/useChartProExport/print.d.ts +4 -0
- package/internals/plugins/useChartProExport/print.js +79 -0
- package/internals/plugins/useChartProExport/useChartProExport.d.ts +3 -0
- package/internals/plugins/useChartProExport/useChartProExport.js +53 -0
- package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +35 -0
- package/internals/plugins/useChartProExport/useChartProExport.types.js +5 -0
- package/internals/plugins/useChartProZoom/useChartProZoom.d.ts +2 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.js +53 -29
- package/locales/index.d.ts +1 -0
- package/locales/index.js +16 -0
- package/package.json +3 -3
|
@@ -6,6 +6,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
value: true
|
|
8
8
|
});
|
|
9
|
+
exports.initializeZoomData = initializeZoomData;
|
|
9
10
|
exports.useChartProZoom = void 0;
|
|
10
11
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
12
|
var React = _interopRequireWildcard(require("react"));
|
|
@@ -15,16 +16,28 @@ var _rafThrottle = require("@mui/x-internals/rafThrottle");
|
|
|
15
16
|
var _debounce = _interopRequireDefault(require("@mui/utils/debounce"));
|
|
16
17
|
var _useChartProZoom = require("./useChartProZoom.utils");
|
|
17
18
|
// It is helpful to avoid the need to provide the possibly auto-generated id for each axis.
|
|
18
|
-
function initializeZoomData(options) {
|
|
19
|
+
function initializeZoomData(options, zoomData) {
|
|
20
|
+
const zoomDataMap = new Map();
|
|
21
|
+
zoomData?.forEach(zoom => {
|
|
22
|
+
const option = options[zoom.axisId];
|
|
23
|
+
if (option) {
|
|
24
|
+
zoomDataMap.set(zoom.axisId, zoom);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
19
27
|
return Object.values(options).map(({
|
|
20
28
|
axisId,
|
|
21
29
|
minStart: start,
|
|
22
30
|
maxEnd: end
|
|
23
|
-
}) =>
|
|
24
|
-
axisId
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
}) => {
|
|
32
|
+
if (zoomDataMap.has(axisId)) {
|
|
33
|
+
return zoomDataMap.get(axisId);
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
axisId,
|
|
37
|
+
start,
|
|
38
|
+
end
|
|
39
|
+
};
|
|
40
|
+
});
|
|
28
41
|
}
|
|
29
42
|
const useChartProZoom = ({
|
|
30
43
|
store,
|
|
@@ -79,10 +92,7 @@ const useChartProZoom = ({
|
|
|
79
92
|
})
|
|
80
93
|
});
|
|
81
94
|
}), 166), [store]);
|
|
82
|
-
|
|
83
|
-
// This is throttled. We want to run it at most once per frame.
|
|
84
|
-
// By joining the two, we ensure that interacting and zooming are in sync.
|
|
85
|
-
const setZoomDataCallback = React.useMemo(() => (0, _rafThrottle.rafThrottle)(zoomData => {
|
|
95
|
+
const setZoomDataCallback = React.useCallback(zoomData => {
|
|
86
96
|
store.update(prevState => {
|
|
87
97
|
const newZoomData = typeof zoomData === 'function' ? zoomData([...prevState.zoom.zoomData]) : zoomData;
|
|
88
98
|
onZoomChange?.(newZoomData);
|
|
@@ -97,10 +107,9 @@ const useChartProZoom = ({
|
|
|
97
107
|
})
|
|
98
108
|
});
|
|
99
109
|
});
|
|
100
|
-
}
|
|
110
|
+
}, [onZoomChange, store, removeIsInteracting]);
|
|
101
111
|
React.useEffect(() => {
|
|
102
112
|
return () => {
|
|
103
|
-
setZoomDataCallback.clear();
|
|
104
113
|
removeIsInteracting.clear();
|
|
105
114
|
};
|
|
106
115
|
}, [setZoomDataCallback, removeIsInteracting]);
|
|
@@ -119,17 +128,10 @@ const useChartProZoom = ({
|
|
|
119
128
|
if (element === null || !isPanEnabled) {
|
|
120
129
|
return () => {};
|
|
121
130
|
}
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
if (touchStartRef.current == null) {
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
const point = (0, _internals.getSVGPoint)(element, event);
|
|
130
|
-
const movementX = point.x - touchStartRef.current.x;
|
|
131
|
-
const movementY = (point.y - touchStartRef.current.y) * -1;
|
|
132
|
-
const newZoomData = touchStartRef.current.zoomData.map(zoom => {
|
|
131
|
+
const throttledHandlePan = (0, _rafThrottle.rafThrottle)((touchStart, point) => {
|
|
132
|
+
const movementX = point.x - touchStart.x;
|
|
133
|
+
const movementY = (point.y - touchStart.y) * -1;
|
|
134
|
+
const newZoomData = touchStart.zoomData.map(zoom => {
|
|
133
135
|
const options = optionsLookup[zoom.axisId];
|
|
134
136
|
if (!options || !options.panning) {
|
|
135
137
|
return zoom;
|
|
@@ -160,6 +162,17 @@ const useChartProZoom = ({
|
|
|
160
162
|
});
|
|
161
163
|
});
|
|
162
164
|
setZoomDataCallback(newZoomData);
|
|
165
|
+
});
|
|
166
|
+
const handlePan = event => {
|
|
167
|
+
if (element === null || !isDraggingRef.current || panningEventCacheRef.current.length > 1) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (touchStartRef.current == null) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
const touchStart = touchStartRef.current;
|
|
174
|
+
const point = (0, _internals.getSVGPoint)(element, event);
|
|
175
|
+
throttledHandlePan(touchStart, point);
|
|
163
176
|
};
|
|
164
177
|
const handleDown = event => {
|
|
165
178
|
panningEventCacheRef.current.push(event);
|
|
@@ -194,6 +207,7 @@ const useChartProZoom = ({
|
|
|
194
207
|
document.removeEventListener('pointerup', handleUp);
|
|
195
208
|
document.removeEventListener('pointercancel', handleUp);
|
|
196
209
|
document.removeEventListener('pointerleave', handleUp);
|
|
210
|
+
throttledHandlePan.clear();
|
|
197
211
|
};
|
|
198
212
|
}, [instance, svgRef, isDraggingRef, isPanEnabled, optionsLookup, drawingArea.width, drawingArea.height, setZoomDataCallback, store]);
|
|
199
213
|
|
|
@@ -203,6 +217,7 @@ const useChartProZoom = ({
|
|
|
203
217
|
if (element === null || !isZoomEnabled) {
|
|
204
218
|
return () => {};
|
|
205
219
|
}
|
|
220
|
+
const rafThrottledSetZoomData = (0, _rafThrottle.rafThrottle)(setZoomDataCallback);
|
|
206
221
|
const wheelHandler = event => {
|
|
207
222
|
if (element === null) {
|
|
208
223
|
return;
|
|
@@ -212,7 +227,13 @@ const useChartProZoom = ({
|
|
|
212
227
|
return;
|
|
213
228
|
}
|
|
214
229
|
event.preventDefault();
|
|
215
|
-
|
|
230
|
+
|
|
231
|
+
/*
|
|
232
|
+
* Need to throttle `setZoomDataCallback` instead of `wheelHandler` because we're calling `event.preventDefault()`.
|
|
233
|
+
* If we throttle the event, then some events' default behavior won't be prevented and the page will scroll while
|
|
234
|
+
* the user is trying to zoom in.
|
|
235
|
+
*/
|
|
236
|
+
rafThrottledSetZoomData(prevZoomData => {
|
|
216
237
|
return prevZoomData.map(zoom => {
|
|
217
238
|
const option = optionsLookup[zoom.axisId];
|
|
218
239
|
if (!option) {
|
|
@@ -238,7 +259,7 @@ const useChartProZoom = ({
|
|
|
238
259
|
function pointerDownHandler(event) {
|
|
239
260
|
zoomEventCacheRef.current.push(event);
|
|
240
261
|
}
|
|
241
|
-
function pointerMoveHandler(event) {
|
|
262
|
+
const pointerMoveHandler = (0, _rafThrottle.rafThrottle)(function pointerMoveHandler(event) {
|
|
242
263
|
if (element === null) {
|
|
243
264
|
return;
|
|
244
265
|
}
|
|
@@ -281,7 +302,7 @@ const useChartProZoom = ({
|
|
|
281
302
|
eventPrevDiff.current = curDiff;
|
|
282
303
|
return newZoomData;
|
|
283
304
|
});
|
|
284
|
-
}
|
|
305
|
+
});
|
|
285
306
|
function pointerUpHandler(event) {
|
|
286
307
|
zoomEventCacheRef.current.splice(zoomEventCacheRef.current.findIndex(cachedEvent => cachedEvent.pointerId === event.pointerId), 1);
|
|
287
308
|
if (zoomEventCacheRef.current.length < 2) {
|
|
@@ -309,6 +330,8 @@ const useChartProZoom = ({
|
|
|
309
330
|
element.removeEventListener('pointerleave', pointerUpHandler);
|
|
310
331
|
element.removeEventListener('touchstart', _useChartProZoom.preventDefault);
|
|
311
332
|
element.removeEventListener('touchmove', _useChartProZoom.preventDefault);
|
|
333
|
+
pointerMoveHandler.clear();
|
|
334
|
+
rafThrottledSetZoomData.clear();
|
|
312
335
|
};
|
|
313
336
|
}, [svgRef, drawingArea, isZoomEnabled, optionsLookup, instance, setZoomDataCallback]);
|
|
314
337
|
return {
|
|
@@ -339,11 +362,12 @@ useChartProZoom.getInitialState = params => {
|
|
|
339
362
|
defaultizedYAxis
|
|
340
363
|
} = params;
|
|
341
364
|
const optionsLookup = (0, _extends2.default)({}, (0, _internals.createZoomLookup)('x')(defaultizedXAxis), (0, _internals.createZoomLookup)('y')(defaultizedYAxis));
|
|
365
|
+
const userZoomData =
|
|
366
|
+
// eslint-disable-next-line no-nested-ternary
|
|
367
|
+
zoomData !== undefined ? zoomData : initialZoom !== undefined ? initialZoom : undefined;
|
|
342
368
|
return {
|
|
343
369
|
zoom: {
|
|
344
|
-
zoomData:
|
|
345
|
-
// eslint-disable-next-line no-nested-ternary
|
|
346
|
-
zoomData !== undefined ? zoomData : initialZoom !== undefined ? initialZoom : initializeZoomData(optionsLookup),
|
|
370
|
+
zoomData: initializeZoomData(optionsLookup, userZoomData),
|
|
347
371
|
isInteracting: false,
|
|
348
372
|
isControlled: zoomData !== undefined
|
|
349
373
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@mui/x-charts/locales';
|
package/locales/index.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _locales = require("@mui/x-charts/locales");
|
|
7
|
+
Object.keys(_locales).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _locales[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _locales[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts-pro",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.1.0",
|
|
4
4
|
"description": "The Pro plan edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"clsx": "^2.1.1",
|
|
35
35
|
"prop-types": "^15.8.1",
|
|
36
36
|
"@mui/x-charts-vendor": "8.0.0",
|
|
37
|
+
"@mui/x-internals": "8.0.0",
|
|
37
38
|
"@mui/x-license": "8.0.0",
|
|
38
|
-
"@mui/x-charts": "8.
|
|
39
|
-
"@mui/x-internals": "8.0.0"
|
|
39
|
+
"@mui/x-charts": "8.1.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@emotion/react": "^11.9.0",
|