@mui/x-charts-pro 9.3.0 → 9.5.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 +33 -3
- package/BarChartPro/BarChartPro.mjs +34 -4
- package/CHANGELOG.md +296 -0
- package/ChartsDataProviderPro/ChartsDataProviderPro.js +2 -2
- package/ChartsDataProviderPro/ChartsDataProviderPro.mjs +2 -2
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.js +1 -0
- package/ChartsToolbarPro/ChartsToolbarImageExportTrigger.mjs +1 -0
- package/ChartsToolbarPro/ChartsToolbarPro.d.mts +1 -1
- package/ChartsToolbarPro/ChartsToolbarPro.d.ts +1 -1
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.d.mts +1 -1
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.d.ts +1 -1
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.js +35 -38
- package/ChartsToolbarPro/ChartsToolbarRangeButtonTrigger.mjs +37 -40
- package/ChartsToolbarPro/Toolbar.types.d.mts +3 -2
- package/ChartsToolbarPro/Toolbar.types.d.ts +3 -2
- package/ChartsToolbarPro/rangeButtonValueToZoom.d.mts +18 -2
- package/ChartsToolbarPro/rangeButtonValueToZoom.d.ts +18 -2
- package/ChartsToolbarPro/rangeButtonValueToZoom.js +73 -10
- package/ChartsToolbarPro/rangeButtonValueToZoom.mjs +72 -10
- package/ChartsZoomSlider/internals/chartsAxisZoomSliderThumbClasses.js +9 -2
- package/ChartsZoomSlider/internals/chartsAxisZoomSliderThumbClasses.mjs +9 -2
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.js +2 -1
- package/ChartsZoomSlider/internals/previews/ScatterPreviewPlot.mjs +2 -1
- package/FunnelChart/funnel.types.d.mts +1 -1
- package/FunnelChart/funnel.types.d.ts +1 -1
- package/FunnelChart/funnelPlotSlots.types.d.mts +5 -4
- package/FunnelChart/funnelPlotSlots.types.d.ts +5 -4
- package/Heatmap/Heatmap.d.mts +3 -2
- package/Heatmap/Heatmap.d.ts +3 -2
- package/Heatmap/Heatmap.js +32 -2
- package/Heatmap/Heatmap.mjs +32 -2
- package/Heatmap/HeatmapItem.d.mts +3 -2
- package/Heatmap/HeatmapItem.d.ts +3 -2
- package/Heatmap/HeatmapItem.js +2 -0
- package/Heatmap/HeatmapItem.mjs +2 -0
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.mts +3 -2
- package/Heatmap/HeatmapTooltip/HeatmapTooltip.types.d.ts +3 -2
- package/LineChartPro/LineChartPro.js +33 -3
- package/LineChartPro/LineChartPro.mjs +34 -4
- package/PieChartPro/PieChartPro.js +1 -1
- package/PieChartPro/PieChartPro.mjs +2 -2
- package/RadarChartPro/RadarChartPro.js +1 -1
- package/RadarChartPro/RadarChartPro.mjs +2 -2
- package/ScatterChartPro/ScatterChartPro.d.mts +2 -1
- package/ScatterChartPro/ScatterChartPro.d.ts +2 -1
- package/ScatterChartPro/ScatterChartPro.js +40 -6
- package/ScatterChartPro/ScatterChartPro.mjs +41 -7
- package/ScatterChartPro/ScatterChartPro.plugins.d.mts +2 -2
- package/ScatterChartPro/ScatterChartPro.plugins.d.ts +2 -2
- package/ScatterChartPro/ScatterChartPro.plugins.js +1 -1
- package/ScatterChartPro/ScatterChartPro.plugins.mjs +2 -2
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internals/plugins/allPlugins.d.mts +5 -5
- package/internals/plugins/allPlugins.d.ts +5 -5
- package/internals/plugins/allPlugins.js +2 -2
- package/internals/plugins/allPlugins.mjs +3 -3
- package/internals/plugins/useChartProExport/exportImage.js +8 -2
- package/internals/plugins/useChartProExport/exportImage.mjs +8 -2
- package/internals/plugins/useChartProExport/print.js +1 -0
- package/internals/plugins/useChartProExport/print.mjs +1 -0
- package/internals/plugins/useChartProExport/useChartProExport.types.d.mts +6 -0
- package/internals/plugins/useChartProExport/useChartProExport.types.d.ts +6 -0
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.mts +36 -4
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.d.ts +36 -4
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.js +2 -4
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.selectors.mjs +1 -3
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.mts +11 -11
- package/internals/plugins/useChartProZoom/ZoomInteractionConfig.types.d.ts +11 -11
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.js +9 -65
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnDrag.mjs +9 -64
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.js +9 -69
- package/internals/plugins/useChartProZoom/gestureHooks/usePanOnPressAndDrag.mjs +9 -68
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.js +9 -39
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnPinch.mjs +10 -39
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.mts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.d.ts +0 -1
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.js +9 -58
- package/internals/plugins/useChartProZoom/gestureHooks/useZoomOnWheel.mjs +10 -58
- package/internals/plugins/useChartProZoom/useChartProZoom.js +77 -14
- package/internals/plugins/useChartProZoom/useChartProZoom.mjs +79 -15
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.mts +0 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.d.ts +0 -3
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.js +1 -2
- package/internals/plugins/useChartProZoom/useChartProZoom.selectors.mjs +0 -1
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.mts +28 -11
- package/internals/plugins/useChartProZoom/useChartProZoom.types.d.ts +28 -11
- package/internals/plugins/zoomGestures/index.d.mts +5 -0
- package/internals/plugins/zoomGestures/index.d.ts +5 -0
- package/internals/plugins/zoomGestures/index.js +33 -0
- package/internals/plugins/zoomGestures/index.mjs +4 -0
- package/internals/plugins/zoomGestures/useDragGesture.d.mts +30 -0
- package/internals/plugins/zoomGestures/useDragGesture.d.ts +30 -0
- package/internals/plugins/zoomGestures/useDragGesture.js +105 -0
- package/internals/plugins/zoomGestures/useDragGesture.mjs +99 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.d.mts +30 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.d.ts +30 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.js +105 -0
- package/internals/plugins/zoomGestures/useDragOnPressGesture.mjs +99 -0
- package/internals/plugins/zoomGestures/usePinchGesture.d.mts +22 -0
- package/internals/plugins/zoomGestures/usePinchGesture.d.ts +22 -0
- package/internals/plugins/zoomGestures/usePinchGesture.js +77 -0
- package/internals/plugins/zoomGestures/usePinchGesture.mjs +71 -0
- package/internals/plugins/zoomGestures/useWheelGesture.d.mts +21 -0
- package/internals/plugins/zoomGestures/useWheelGesture.d.ts +21 -0
- package/internals/plugins/zoomGestures/useWheelGesture.js +78 -0
- package/internals/plugins/zoomGestures/useWheelGesture.mjs +72 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.d.mts +29 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.d.ts +29 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.js +5 -0
- package/internals/plugins/zoomGestures/zoomGestures.types.mjs +1 -0
- package/internals/slots/chartsBaseSlots.d.mts +6 -5
- package/internals/slots/chartsBaseSlots.d.ts +6 -5
- package/internals/slots/chartsIconSlots.d.mts +4 -3
- package/internals/slots/chartsIconSlots.d.ts +4 -3
- package/models/chartsSlotsComponentsPropsPro.d.mts +11 -0
- package/models/chartsSlotsComponentsPropsPro.d.ts +11 -0
- package/models/chartsSlotsComponentsPropsPro.js +5 -0
- package/models/chartsSlotsComponentsPropsPro.mjs +1 -0
- package/models/index.d.mts +1 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +12 -0
- package/models/index.mjs +1 -0
- package/models/seriesType/heatmap.d.mts +1 -1
- package/models/seriesType/heatmap.d.ts +1 -1
- package/package.json +5 -5
|
@@ -1,67 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.useZoomOnWheel = void 0;
|
|
9
|
-
var React = _interopRequireWildcard(require("react"));
|
|
10
8
|
var _internals = require("@mui/x-charts/internals");
|
|
11
|
-
var _rafThrottle = require("@mui/x-internals/rafThrottle");
|
|
12
9
|
var _useZoom = require("./useZoom.utils");
|
|
13
10
|
var _ZoomInteractionConfig = require("../ZoomInteractionConfig.selectors");
|
|
11
|
+
var _useWheelGesture = require("../../zoomGestures/useWheelGesture");
|
|
14
12
|
const useZoomOnWheel = ({
|
|
15
13
|
store,
|
|
16
14
|
instance
|
|
17
15
|
}, setZoomDataCallback) => {
|
|
18
|
-
const {
|
|
19
|
-
chartsLayerContainerRef
|
|
20
|
-
} = instance;
|
|
21
16
|
const drawingArea = store.use(_internals.selectorChartDrawingArea);
|
|
22
17
|
const optionsLookup = store.use(_internals.selectorChartZoomOptionsLookup);
|
|
23
|
-
const startedOutsideRef = React.useRef(false);
|
|
24
|
-
const startedOutsideTimeoutRef = React.useRef(null);
|
|
25
18
|
const config = store.use(_ZoomInteractionConfig.selectorZoomInteractionConfig, 'wheel');
|
|
26
19
|
const isZoomOnWheelEnabled = Object.keys(optionsLookup).length > 0 && Boolean(config);
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
requiredKeys: config.requiredKeys
|
|
33
|
-
});
|
|
34
|
-
}, [config, isZoomOnWheelEnabled, instance]);
|
|
35
|
-
|
|
36
|
-
// Add event for chart zoom in/out
|
|
37
|
-
React.useEffect(() => {
|
|
38
|
-
const element = chartsLayerContainerRef.current;
|
|
39
|
-
if (element === null || !isZoomOnWheelEnabled) {
|
|
40
|
-
return () => {};
|
|
41
|
-
}
|
|
42
|
-
const rafThrottledSetZoomData = (0, _rafThrottle.rafThrottle)(setZoomDataCallback);
|
|
43
|
-
const zoomOnWheelHandler = instance.addInteractionListener('zoomTurnWheel', event => {
|
|
44
|
-
const point = (0, _internals.getChartPoint)(element, {
|
|
45
|
-
clientX: event.detail.centroid.x,
|
|
46
|
-
clientY: event.detail.centroid.y
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
// This prevents a zoom event from being triggered when the mouse is outside the chart area.
|
|
50
|
-
// The timeout is used to prevent a weird behavior where if the mouse is outside but enters due to
|
|
51
|
-
// scrolling, then the zoom event is triggered.
|
|
52
|
-
if (startedOutsideRef.current || !instance.isPointInside(point.x, point.y)) {
|
|
53
|
-
startedOutsideRef.current = true;
|
|
54
|
-
if (startedOutsideTimeoutRef.current) {
|
|
55
|
-
clearTimeout(startedOutsideTimeoutRef.current);
|
|
56
|
-
}
|
|
57
|
-
startedOutsideTimeoutRef.current = setTimeout(() => {
|
|
58
|
-
startedOutsideRef.current = false;
|
|
59
|
-
startedOutsideTimeoutRef.current = null;
|
|
60
|
-
}, 100);
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
event.detail.srcEvent.preventDefault();
|
|
64
|
-
rafThrottledSetZoomData(prev => {
|
|
20
|
+
(0, _useWheelGesture.useWheelGesture)(instance, {
|
|
21
|
+
enabled: isZoomOnWheelEnabled,
|
|
22
|
+
requiredKeys: config?.requiredKeys,
|
|
23
|
+
onWheel: (point, wheelEvent) => {
|
|
24
|
+
setZoomDataCallback(prev => {
|
|
65
25
|
return prev.map(zoom => {
|
|
66
26
|
const option = optionsLookup[zoom.axisId];
|
|
67
27
|
if (!option) {
|
|
@@ -71,7 +31,7 @@ const useZoomOnWheel = ({
|
|
|
71
31
|
const {
|
|
72
32
|
scaleRatio,
|
|
73
33
|
isZoomIn
|
|
74
|
-
} = (0, _useZoom.getWheelScaleRatio)(
|
|
34
|
+
} = (0, _useZoom.getWheelScaleRatio)(wheelEvent, option.step);
|
|
75
35
|
const [newMinRange, newMaxRange] = (0, _useZoom.zoomAtPoint)(centerRatio, scaleRatio, zoom, option);
|
|
76
36
|
if (!(0, _useZoom.isSpanValid)(newMinRange, newMaxRange, isZoomIn, option)) {
|
|
77
37
|
return zoom;
|
|
@@ -83,16 +43,7 @@ const useZoomOnWheel = ({
|
|
|
83
43
|
};
|
|
84
44
|
});
|
|
85
45
|
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
zoomOnWheelHandler.cleanup();
|
|
89
|
-
if (startedOutsideTimeoutRef.current) {
|
|
90
|
-
clearTimeout(startedOutsideTimeoutRef.current);
|
|
91
|
-
startedOutsideTimeoutRef.current = null;
|
|
92
|
-
}
|
|
93
|
-
startedOutsideRef.current = false;
|
|
94
|
-
rafThrottledSetZoomData.clear();
|
|
95
|
-
};
|
|
96
|
-
}, [chartsLayerContainerRef, drawingArea, isZoomOnWheelEnabled, optionsLookup, instance, setZoomDataCallback, store]);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
97
48
|
};
|
|
98
49
|
exports.useZoomOnWheel = useZoomOnWheel;
|
|
@@ -1,61 +1,22 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import { getChartPoint, selectorChartDrawingArea, selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
5
|
-
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
3
|
+
import { selectorChartDrawingArea, selectorChartZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
6
4
|
import { getHorizontalCenterRatio, getVerticalCenterRatio, getWheelScaleRatio, isSpanValid, zoomAtPoint } from "./useZoom.utils.mjs";
|
|
7
5
|
import { selectorZoomInteractionConfig } from "../ZoomInteractionConfig.selectors.mjs";
|
|
6
|
+
import { useWheelGesture } from "../../zoomGestures/useWheelGesture.mjs";
|
|
8
7
|
export const useZoomOnWheel = ({
|
|
9
8
|
store,
|
|
10
9
|
instance
|
|
11
10
|
}, setZoomDataCallback) => {
|
|
12
|
-
const {
|
|
13
|
-
chartsLayerContainerRef
|
|
14
|
-
} = instance;
|
|
15
11
|
const drawingArea = store.use(selectorChartDrawingArea);
|
|
16
12
|
const optionsLookup = store.use(selectorChartZoomOptionsLookup);
|
|
17
|
-
const startedOutsideRef = React.useRef(false);
|
|
18
|
-
const startedOutsideTimeoutRef = React.useRef(null);
|
|
19
13
|
const config = store.use(selectorZoomInteractionConfig, 'wheel');
|
|
20
14
|
const isZoomOnWheelEnabled = Object.keys(optionsLookup).length > 0 && Boolean(config);
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
requiredKeys: config.requiredKeys
|
|
27
|
-
});
|
|
28
|
-
}, [config, isZoomOnWheelEnabled, instance]);
|
|
29
|
-
|
|
30
|
-
// Add event for chart zoom in/out
|
|
31
|
-
React.useEffect(() => {
|
|
32
|
-
const element = chartsLayerContainerRef.current;
|
|
33
|
-
if (element === null || !isZoomOnWheelEnabled) {
|
|
34
|
-
return () => {};
|
|
35
|
-
}
|
|
36
|
-
const rafThrottledSetZoomData = rafThrottle(setZoomDataCallback);
|
|
37
|
-
const zoomOnWheelHandler = instance.addInteractionListener('zoomTurnWheel', event => {
|
|
38
|
-
const point = getChartPoint(element, {
|
|
39
|
-
clientX: event.detail.centroid.x,
|
|
40
|
-
clientY: event.detail.centroid.y
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// This prevents a zoom event from being triggered when the mouse is outside the chart area.
|
|
44
|
-
// The timeout is used to prevent a weird behavior where if the mouse is outside but enters due to
|
|
45
|
-
// scrolling, then the zoom event is triggered.
|
|
46
|
-
if (startedOutsideRef.current || !instance.isPointInside(point.x, point.y)) {
|
|
47
|
-
startedOutsideRef.current = true;
|
|
48
|
-
if (startedOutsideTimeoutRef.current) {
|
|
49
|
-
clearTimeout(startedOutsideTimeoutRef.current);
|
|
50
|
-
}
|
|
51
|
-
startedOutsideTimeoutRef.current = setTimeout(() => {
|
|
52
|
-
startedOutsideRef.current = false;
|
|
53
|
-
startedOutsideTimeoutRef.current = null;
|
|
54
|
-
}, 100);
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
event.detail.srcEvent.preventDefault();
|
|
58
|
-
rafThrottledSetZoomData(prev => {
|
|
15
|
+
useWheelGesture(instance, {
|
|
16
|
+
enabled: isZoomOnWheelEnabled,
|
|
17
|
+
requiredKeys: config?.requiredKeys,
|
|
18
|
+
onWheel: (point, wheelEvent) => {
|
|
19
|
+
setZoomDataCallback(prev => {
|
|
59
20
|
return prev.map(zoom => {
|
|
60
21
|
const option = optionsLookup[zoom.axisId];
|
|
61
22
|
if (!option) {
|
|
@@ -65,7 +26,7 @@ export const useZoomOnWheel = ({
|
|
|
65
26
|
const {
|
|
66
27
|
scaleRatio,
|
|
67
28
|
isZoomIn
|
|
68
|
-
} = getWheelScaleRatio(
|
|
29
|
+
} = getWheelScaleRatio(wheelEvent, option.step);
|
|
69
30
|
const [newMinRange, newMaxRange] = zoomAtPoint(centerRatio, scaleRatio, zoom, option);
|
|
70
31
|
if (!isSpanValid(newMinRange, newMaxRange, isZoomIn, option)) {
|
|
71
32
|
return zoom;
|
|
@@ -77,15 +38,6 @@ export const useZoomOnWheel = ({
|
|
|
77
38
|
};
|
|
78
39
|
});
|
|
79
40
|
});
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
zoomOnWheelHandler.cleanup();
|
|
83
|
-
if (startedOutsideTimeoutRef.current) {
|
|
84
|
-
clearTimeout(startedOutsideTimeoutRef.current);
|
|
85
|
-
startedOutsideTimeoutRef.current = null;
|
|
86
|
-
}
|
|
87
|
-
startedOutsideRef.current = false;
|
|
88
|
-
rafThrottledSetZoomData.clear();
|
|
89
|
-
};
|
|
90
|
-
}, [chartsLayerContainerRef, drawingArea, isZoomOnWheelEnabled, optionsLookup, instance, setZoomDataCallback, store]);
|
|
41
|
+
}
|
|
42
|
+
});
|
|
91
43
|
};
|
|
@@ -11,9 +11,11 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _internals = require("@mui/x-charts/internals");
|
|
13
13
|
var _debounce = _interopRequireDefault(require("@mui/utils/debounce"));
|
|
14
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
15
|
var _useEffectAfterFirstRender = require("@mui/x-internals/useEffectAfterFirstRender");
|
|
15
16
|
var _utils = require("@mui/material/utils");
|
|
16
17
|
var _isDeepEqual = require("@mui/x-internals/isDeepEqual");
|
|
18
|
+
var _rangeButtonValueToZoom = require("../../../ChartsToolbarPro/rangeButtonValueToZoom");
|
|
17
19
|
var _calculateZoom = require("./calculateZoom");
|
|
18
20
|
var _useZoomOnWheel = require("./gestureHooks/useZoomOnWheel");
|
|
19
21
|
var _useZoomOnPinch = require("./gestureHooks/useZoomOnPinch");
|
|
@@ -25,6 +27,12 @@ var _useZoomOnBrush = require("./gestureHooks/useZoomOnBrush");
|
|
|
25
27
|
var _useZoomOnDoubleTapReset = require("./gestureHooks/useZoomOnDoubleTapReset");
|
|
26
28
|
var _initializeZoomInteractionConfig = require("./initializeZoomInteractionConfig");
|
|
27
29
|
var _initializeZoomData = require("./initializeZoomData");
|
|
30
|
+
/**
|
|
31
|
+
* Type guard for `initialZoom` entries provided as a range value.
|
|
32
|
+
*/
|
|
33
|
+
function isInitialZoomRange(entry) {
|
|
34
|
+
return 'value' in entry;
|
|
35
|
+
}
|
|
28
36
|
const useChartProZoom = pluginData => {
|
|
29
37
|
const {
|
|
30
38
|
store,
|
|
@@ -62,6 +70,68 @@ const useChartProZoom = pluginData => {
|
|
|
62
70
|
}));
|
|
63
71
|
removeIsInteracting();
|
|
64
72
|
}, [store, paramsZoomData, removeIsInteracting]);
|
|
73
|
+
|
|
74
|
+
// Resolve `initialZoom` entries provided as range values (e.g. `{ axisId, value: { unit: 'month' } }`).
|
|
75
|
+
// These depend on the computed axis domains, which are only available after the first render
|
|
76
|
+
// (unless the user provides explicit `width`/`height`), so they are resolved once on mount.
|
|
77
|
+
// A layout effect avoids a visible unzoomed frame.
|
|
78
|
+
const hasResolvedInitialZoomRanges = React.useRef(false);
|
|
79
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
80
|
+
if (hasResolvedInitialZoomRanges.current) {
|
|
81
|
+
// `initialZoom` is only read on mount, like the rest of the initial zoom state.
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
hasResolvedInitialZoomRanges.current = true;
|
|
85
|
+
if (paramsZoomData !== undefined) {
|
|
86
|
+
// The zoom is controlled, `initialZoom` is ignored.
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const rangeEntries = (params.initialZoom ?? []).filter(isInitialZoomRange);
|
|
90
|
+
if (rangeEntries.length === 0) {
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const {
|
|
94
|
+
axes: xAxes,
|
|
95
|
+
domains: xDomains
|
|
96
|
+
} = (0, _internals.selectorChartXAxisWithDomains)(store.state);
|
|
97
|
+
const {
|
|
98
|
+
axes: yAxes,
|
|
99
|
+
domains: yDomains
|
|
100
|
+
} = (0, _internals.selectorChartYAxisWithDomains)(store.state);
|
|
101
|
+
const resolvedZoom = new Map();
|
|
102
|
+
rangeEntries.forEach(entry => {
|
|
103
|
+
const xAxis = xAxes?.find(axis => axis.id === entry.axisId);
|
|
104
|
+
const axis = xAxis ?? yAxes?.find(candidate => candidate.id === entry.axisId);
|
|
105
|
+
if (!axis) {
|
|
106
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
107
|
+
console.error(`MUI X Charts: \`initialZoom\` references the axis with id "${entry.axisId}", which does not exist.\n` + 'The range cannot be resolved. Provide an `axisId` that matches a chart axis.');
|
|
108
|
+
}
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
const domain = (xAxis ? xDomains : yDomains)[entry.axisId]?.domain;
|
|
112
|
+
const domainParams = (0, _rangeButtonValueToZoom.getRangeButtonDomainParams)(axis, domain);
|
|
113
|
+
if (!domainParams) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
const {
|
|
117
|
+
start,
|
|
118
|
+
end
|
|
119
|
+
} = (0, _rangeButtonValueToZoom.rangeButtonValueToZoom)(entry.value, domainParams);
|
|
120
|
+
resolvedZoom.set(entry.axisId, {
|
|
121
|
+
axisId: entry.axisId,
|
|
122
|
+
start,
|
|
123
|
+
end
|
|
124
|
+
});
|
|
125
|
+
});
|
|
126
|
+
if (resolvedZoom.size === 0) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
store.set('zoom', (0, _extends2.default)({}, store.state.zoom, {
|
|
130
|
+
isInteracting: true,
|
|
131
|
+
zoomData: store.state.zoom.zoomData.map(zoom => resolvedZoom.get(zoom.axisId) ?? zoom)
|
|
132
|
+
}));
|
|
133
|
+
removeIsInteracting();
|
|
134
|
+
}, [store, paramsZoomData, params.initialZoom, removeIsInteracting]);
|
|
65
135
|
const setZoomDataCallback = React.useCallback(zoomData => {
|
|
66
136
|
const newZoomData = typeof zoomData === 'function' ? zoomData([...store.state.zoom.zoomData]) : zoomData;
|
|
67
137
|
if ((0, _isDeepEqual.isDeepEqual)(store.state.zoom.zoomData, newZoomData)) {
|
|
@@ -70,14 +140,12 @@ const useChartProZoom = pluginData => {
|
|
|
70
140
|
onZoomChange(newZoomData);
|
|
71
141
|
if (store.state.zoom.isControlled) {
|
|
72
142
|
store.set('zoom', (0, _extends2.default)({}, store.state.zoom, {
|
|
73
|
-
isInteracting: true
|
|
74
|
-
activeRangeButtonKey: null
|
|
143
|
+
isInteracting: true
|
|
75
144
|
}));
|
|
76
145
|
} else {
|
|
77
146
|
store.set('zoom', (0, _extends2.default)({}, store.state.zoom, {
|
|
78
147
|
isInteracting: true,
|
|
79
|
-
zoomData: newZoomData
|
|
80
|
-
activeRangeButtonKey: null
|
|
148
|
+
zoomData: newZoomData
|
|
81
149
|
}));
|
|
82
150
|
removeIsInteracting();
|
|
83
151
|
}
|
|
@@ -141,11 +209,6 @@ const useChartProZoom = pluginData => {
|
|
|
141
209
|
}, [setZoomDataCallback, store]);
|
|
142
210
|
const zoomIn = React.useCallback(() => zoom(0.1), [zoom]);
|
|
143
211
|
const zoomOut = React.useCallback(() => zoom(-0.1), [zoom]);
|
|
144
|
-
const setActiveRangeButtonKey = React.useCallback(key => {
|
|
145
|
-
store.set('zoom', (0, _extends2.default)({}, store.state.zoom, {
|
|
146
|
-
activeRangeButtonKey: key
|
|
147
|
-
}));
|
|
148
|
-
}, [store]);
|
|
149
212
|
return {
|
|
150
213
|
publicAPI: {
|
|
151
214
|
setZoomData: setZoomDataCallback,
|
|
@@ -158,8 +221,7 @@ const useChartProZoom = pluginData => {
|
|
|
158
221
|
setAxisZoomData,
|
|
159
222
|
moveZoomRange,
|
|
160
223
|
zoomIn,
|
|
161
|
-
zoomOut
|
|
162
|
-
setActiveRangeButtonKey
|
|
224
|
+
zoomOut
|
|
163
225
|
}
|
|
164
226
|
};
|
|
165
227
|
};
|
|
@@ -178,16 +240,17 @@ useChartProZoom.getInitialState = params => {
|
|
|
178
240
|
defaultizedYAxis
|
|
179
241
|
} = params;
|
|
180
242
|
const optionsLookup = (0, _extends2.default)({}, (0, _internals.createZoomLookup)('x')(defaultizedXAxis), (0, _internals.createZoomLookup)('y')(defaultizedYAxis));
|
|
243
|
+
// Range-value entries of `initialZoom` are resolved after the first render, once the axis
|
|
244
|
+
// domains are computed. Only the explicit `ZoomData` entries are applied to the initial state.
|
|
181
245
|
const userZoomData =
|
|
182
246
|
// eslint-disable-next-line no-nested-ternary
|
|
183
|
-
zoomData !== undefined ? zoomData : initialZoom !== undefined ? initialZoom : undefined;
|
|
247
|
+
zoomData !== undefined ? zoomData : initialZoom !== undefined ? initialZoom.filter(entry => !isInitialZoomRange(entry)) : undefined;
|
|
184
248
|
return {
|
|
185
249
|
zoom: {
|
|
186
250
|
zoomData: (0, _initializeZoomData.initializeZoomData)(optionsLookup, userZoomData),
|
|
187
251
|
isInteracting: false,
|
|
188
252
|
isControlled: zoomData !== undefined,
|
|
189
|
-
zoomInteractionConfig: (0, _initializeZoomInteractionConfig.initializeZoomInteractionConfig)(params.zoomInteractionConfig, optionsLookup)
|
|
190
|
-
activeRangeButtonKey: null
|
|
253
|
+
zoomInteractionConfig: (0, _initializeZoomInteractionConfig.initializeZoomInteractionConfig)(params.zoomInteractionConfig, optionsLookup)
|
|
191
254
|
}
|
|
192
255
|
};
|
|
193
256
|
};
|
|
@@ -2,11 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import { selectorChartZoomOptionsLookup, createZoomLookup, selectorChartAxisZoomOptionsLookup } from '@mui/x-charts/internals';
|
|
5
|
+
import { selectorChartZoomOptionsLookup, createZoomLookup, selectorChartAxisZoomOptionsLookup, selectorChartXAxisWithDomains, selectorChartYAxisWithDomains } from '@mui/x-charts/internals';
|
|
6
6
|
import debounce from '@mui/utils/debounce';
|
|
7
|
+
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
7
8
|
import { useEffectAfterFirstRender } from '@mui/x-internals/useEffectAfterFirstRender';
|
|
8
9
|
import { useEventCallback } from '@mui/material/utils';
|
|
9
10
|
import { isDeepEqual } from '@mui/x-internals/isDeepEqual';
|
|
11
|
+
import { getRangeButtonDomainParams, rangeButtonValueToZoom } from "../../../ChartsToolbarPro/rangeButtonValueToZoom.mjs";
|
|
10
12
|
import { calculateZoom } from "./calculateZoom.mjs";
|
|
11
13
|
import { useZoomOnWheel } from "./gestureHooks/useZoomOnWheel.mjs";
|
|
12
14
|
import { useZoomOnPinch } from "./gestureHooks/useZoomOnPinch.mjs";
|
|
@@ -18,6 +20,13 @@ import { useZoomOnBrush } from "./gestureHooks/useZoomOnBrush.mjs";
|
|
|
18
20
|
import { useZoomOnDoubleTapReset } from "./gestureHooks/useZoomOnDoubleTapReset.mjs";
|
|
19
21
|
import { initializeZoomInteractionConfig } from "./initializeZoomInteractionConfig.mjs";
|
|
20
22
|
import { initializeZoomData } from "./initializeZoomData.mjs";
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Type guard for `initialZoom` entries provided as a range value.
|
|
26
|
+
*/
|
|
27
|
+
function isInitialZoomRange(entry) {
|
|
28
|
+
return 'value' in entry;
|
|
29
|
+
}
|
|
21
30
|
export const useChartProZoom = pluginData => {
|
|
22
31
|
const {
|
|
23
32
|
store,
|
|
@@ -55,6 +64,68 @@ export const useChartProZoom = pluginData => {
|
|
|
55
64
|
}));
|
|
56
65
|
removeIsInteracting();
|
|
57
66
|
}, [store, paramsZoomData, removeIsInteracting]);
|
|
67
|
+
|
|
68
|
+
// Resolve `initialZoom` entries provided as range values (e.g. `{ axisId, value: { unit: 'month' } }`).
|
|
69
|
+
// These depend on the computed axis domains, which are only available after the first render
|
|
70
|
+
// (unless the user provides explicit `width`/`height`), so they are resolved once on mount.
|
|
71
|
+
// A layout effect avoids a visible unzoomed frame.
|
|
72
|
+
const hasResolvedInitialZoomRanges = React.useRef(false);
|
|
73
|
+
useEnhancedEffect(() => {
|
|
74
|
+
if (hasResolvedInitialZoomRanges.current) {
|
|
75
|
+
// `initialZoom` is only read on mount, like the rest of the initial zoom state.
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
hasResolvedInitialZoomRanges.current = true;
|
|
79
|
+
if (paramsZoomData !== undefined) {
|
|
80
|
+
// The zoom is controlled, `initialZoom` is ignored.
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
const rangeEntries = (params.initialZoom ?? []).filter(isInitialZoomRange);
|
|
84
|
+
if (rangeEntries.length === 0) {
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const {
|
|
88
|
+
axes: xAxes,
|
|
89
|
+
domains: xDomains
|
|
90
|
+
} = selectorChartXAxisWithDomains(store.state);
|
|
91
|
+
const {
|
|
92
|
+
axes: yAxes,
|
|
93
|
+
domains: yDomains
|
|
94
|
+
} = selectorChartYAxisWithDomains(store.state);
|
|
95
|
+
const resolvedZoom = new Map();
|
|
96
|
+
rangeEntries.forEach(entry => {
|
|
97
|
+
const xAxis = xAxes?.find(axis => axis.id === entry.axisId);
|
|
98
|
+
const axis = xAxis ?? yAxes?.find(candidate => candidate.id === entry.axisId);
|
|
99
|
+
if (!axis) {
|
|
100
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
101
|
+
console.error(`MUI X Charts: \`initialZoom\` references the axis with id "${entry.axisId}", which does not exist.\n` + 'The range cannot be resolved. Provide an `axisId` that matches a chart axis.');
|
|
102
|
+
}
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
const domain = (xAxis ? xDomains : yDomains)[entry.axisId]?.domain;
|
|
106
|
+
const domainParams = getRangeButtonDomainParams(axis, domain);
|
|
107
|
+
if (!domainParams) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
const {
|
|
111
|
+
start,
|
|
112
|
+
end
|
|
113
|
+
} = rangeButtonValueToZoom(entry.value, domainParams);
|
|
114
|
+
resolvedZoom.set(entry.axisId, {
|
|
115
|
+
axisId: entry.axisId,
|
|
116
|
+
start,
|
|
117
|
+
end
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
if (resolvedZoom.size === 0) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
store.set('zoom', _extends({}, store.state.zoom, {
|
|
124
|
+
isInteracting: true,
|
|
125
|
+
zoomData: store.state.zoom.zoomData.map(zoom => resolvedZoom.get(zoom.axisId) ?? zoom)
|
|
126
|
+
}));
|
|
127
|
+
removeIsInteracting();
|
|
128
|
+
}, [store, paramsZoomData, params.initialZoom, removeIsInteracting]);
|
|
58
129
|
const setZoomDataCallback = React.useCallback(zoomData => {
|
|
59
130
|
const newZoomData = typeof zoomData === 'function' ? zoomData([...store.state.zoom.zoomData]) : zoomData;
|
|
60
131
|
if (isDeepEqual(store.state.zoom.zoomData, newZoomData)) {
|
|
@@ -63,14 +134,12 @@ export const useChartProZoom = pluginData => {
|
|
|
63
134
|
onZoomChange(newZoomData);
|
|
64
135
|
if (store.state.zoom.isControlled) {
|
|
65
136
|
store.set('zoom', _extends({}, store.state.zoom, {
|
|
66
|
-
isInteracting: true
|
|
67
|
-
activeRangeButtonKey: null
|
|
137
|
+
isInteracting: true
|
|
68
138
|
}));
|
|
69
139
|
} else {
|
|
70
140
|
store.set('zoom', _extends({}, store.state.zoom, {
|
|
71
141
|
isInteracting: true,
|
|
72
|
-
zoomData: newZoomData
|
|
73
|
-
activeRangeButtonKey: null
|
|
142
|
+
zoomData: newZoomData
|
|
74
143
|
}));
|
|
75
144
|
removeIsInteracting();
|
|
76
145
|
}
|
|
@@ -134,11 +203,6 @@ export const useChartProZoom = pluginData => {
|
|
|
134
203
|
}, [setZoomDataCallback, store]);
|
|
135
204
|
const zoomIn = React.useCallback(() => zoom(0.1), [zoom]);
|
|
136
205
|
const zoomOut = React.useCallback(() => zoom(-0.1), [zoom]);
|
|
137
|
-
const setActiveRangeButtonKey = React.useCallback(key => {
|
|
138
|
-
store.set('zoom', _extends({}, store.state.zoom, {
|
|
139
|
-
activeRangeButtonKey: key
|
|
140
|
-
}));
|
|
141
|
-
}, [store]);
|
|
142
206
|
return {
|
|
143
207
|
publicAPI: {
|
|
144
208
|
setZoomData: setZoomDataCallback,
|
|
@@ -151,8 +215,7 @@ export const useChartProZoom = pluginData => {
|
|
|
151
215
|
setAxisZoomData,
|
|
152
216
|
moveZoomRange,
|
|
153
217
|
zoomIn,
|
|
154
|
-
zoomOut
|
|
155
|
-
setActiveRangeButtonKey
|
|
218
|
+
zoomOut
|
|
156
219
|
}
|
|
157
220
|
};
|
|
158
221
|
};
|
|
@@ -170,16 +233,17 @@ useChartProZoom.getInitialState = params => {
|
|
|
170
233
|
defaultizedYAxis
|
|
171
234
|
} = params;
|
|
172
235
|
const optionsLookup = _extends({}, createZoomLookup('x')(defaultizedXAxis), createZoomLookup('y')(defaultizedYAxis));
|
|
236
|
+
// Range-value entries of `initialZoom` are resolved after the first render, once the axis
|
|
237
|
+
// domains are computed. Only the explicit `ZoomData` entries are applied to the initial state.
|
|
173
238
|
const userZoomData =
|
|
174
239
|
// eslint-disable-next-line no-nested-ternary
|
|
175
|
-
zoomData !== undefined ? zoomData : initialZoom !== undefined ? initialZoom : undefined;
|
|
240
|
+
zoomData !== undefined ? zoomData : initialZoom !== undefined ? initialZoom.filter(entry => !isInitialZoomRange(entry)) : undefined;
|
|
176
241
|
return {
|
|
177
242
|
zoom: {
|
|
178
243
|
zoomData: initializeZoomData(optionsLookup, userZoomData),
|
|
179
244
|
isInteracting: false,
|
|
180
245
|
isControlled: zoomData !== undefined,
|
|
181
|
-
zoomInteractionConfig: initializeZoomInteractionConfig(params.zoomInteractionConfig, optionsLookup)
|
|
182
|
-
activeRangeButtonKey: null
|
|
246
|
+
zoomInteractionConfig: initializeZoomInteractionConfig(params.zoomInteractionConfig, optionsLookup)
|
|
183
247
|
}
|
|
184
248
|
};
|
|
185
249
|
};
|
|
@@ -13,9 +13,6 @@ export declare const selectorChartAxisZoomData: (args_0: import("@mui/x-charts/i
|
|
|
13
13
|
export declare const selectorChartCanZoomOut: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.mjs").UseChartProZoomState & Partial<{}> & {
|
|
14
14
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
15
15
|
}) => boolean;
|
|
16
|
-
export declare const selectorChartActiveRangeButtonKey: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.mjs").UseChartProZoomState & Partial<{}> & {
|
|
17
|
-
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
18
|
-
}) => string | null;
|
|
19
16
|
export declare const selectorChartCanZoomIn: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.mjs").UseChartProZoomState & Partial<{}> & {
|
|
20
17
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
21
18
|
}) => boolean;
|
|
@@ -13,9 +13,6 @@ export declare const selectorChartAxisZoomData: (args_0: import("@mui/x-charts/i
|
|
|
13
13
|
export declare const selectorChartCanZoomOut: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.js").UseChartProZoomState & Partial<{}> & {
|
|
14
14
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
15
15
|
}) => boolean;
|
|
16
|
-
export declare const selectorChartActiveRangeButtonKey: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.js").UseChartProZoomState & Partial<{}> & {
|
|
17
|
-
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
18
|
-
}) => string | null;
|
|
19
16
|
export declare const selectorChartCanZoomIn: (args_0: import("@mui/x-charts/internals/plugins/corePlugins/useChartId/useChartId.types").UseChartIdState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types").UseChartSeriesConfigState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types").UseChartExperimentalFeaturesState & import("@mui/x-charts/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.types").UseChartDimensionsState & import("@mui/x-charts/internals/plugins/corePlugins/useChartSeries/useChartSeries.types").UseChartSeriesState<keyof import("@mui/x-charts/internals").ChartsSeriesConfig> & import("@mui/x-charts/internals/plugins/corePlugins/useChartAnimation/useChartAnimation.types").UseChartAnimationState & import("@mui/x-charts/internals").UseChartInteractionListenerState & import("./useChartProZoom.types.js").UseChartProZoomState & Partial<{}> & {
|
|
20
17
|
cacheKey: import("@mui/x-charts/internals").ChartStateCacheKey;
|
|
21
18
|
}) => boolean;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorChartZoomState = exports.selectorChartZoomIsInteracting = exports.selectorChartZoomIsEnabled = exports.selectorChartCanZoomOut = exports.selectorChartCanZoomIn = exports.selectorChartAxisZoomData =
|
|
6
|
+
exports.selectorChartZoomState = exports.selectorChartZoomIsInteracting = exports.selectorChartZoomIsEnabled = exports.selectorChartCanZoomOut = exports.selectorChartCanZoomIn = exports.selectorChartAxisZoomData = void 0;
|
|
7
7
|
var _store = require("@mui/x-internals/store");
|
|
8
8
|
var _internals = require("@mui/x-charts/internals");
|
|
9
9
|
const selectorChartZoomState = state => state.zoom;
|
|
@@ -18,7 +18,6 @@ const selectorChartCanZoomOut = exports.selectorChartCanZoomOut = (0, _store.cre
|
|
|
18
18
|
return zoomData.start === options.minStart && zoomData.end === options.maxEnd || span === options.maxSpan;
|
|
19
19
|
});
|
|
20
20
|
});
|
|
21
|
-
const selectorChartActiveRangeButtonKey = exports.selectorChartActiveRangeButtonKey = (0, _store.createSelector)(selectorChartZoomState, zoom => zoom.activeRangeButtonKey);
|
|
22
21
|
const selectorChartCanZoomIn = exports.selectorChartCanZoomIn = (0, _store.createSelector)(selectorChartZoomState, _internals.selectorChartZoomOptionsLookup, (zoomState, zoomOptions) => {
|
|
23
22
|
return !zoomState.zoomData.every(zoomData => {
|
|
24
23
|
const span = zoomData.end - zoomData.start;
|
|
@@ -11,7 +11,6 @@ export const selectorChartCanZoomOut = createSelector(selectorChartZoomState, se
|
|
|
11
11
|
return zoomData.start === options.minStart && zoomData.end === options.maxEnd || span === options.maxSpan;
|
|
12
12
|
});
|
|
13
13
|
});
|
|
14
|
-
export const selectorChartActiveRangeButtonKey = createSelector(selectorChartZoomState, zoom => zoom.activeRangeButtonKey);
|
|
15
14
|
export const selectorChartCanZoomIn = createSelector(selectorChartZoomState, selectorChartZoomOptionsLookup, (zoomState, zoomOptions) => {
|
|
16
15
|
return !zoomState.zoomData.every(zoomData => {
|
|
17
16
|
const span = zoomData.end - zoomData.start;
|
|
@@ -1,11 +1,38 @@
|
|
|
1
1
|
import { type UseChartSeriesSignature, type ChartPluginSignature, type UseChartCartesianAxisSignature, type UseChartCartesianAxisDefaultizedParameters, type ZoomData, type AxisId, type UseChartBrushSignature } from '@mui/x-charts/internals';
|
|
2
2
|
import { type ZoomInteractionConfig, type DefaultizedZoomInteractionConfig } from "./ZoomInteractionConfig.types.mjs";
|
|
3
|
+
import { type RangeButtonValue } from "../../../ChartsToolbarPro/rangeButtonValueToZoom.mjs";
|
|
4
|
+
/**
|
|
5
|
+
* Initializes the zoom of an axis with a range value instead of zoom percentages.
|
|
6
|
+
*/
|
|
7
|
+
export interface InitialZoomRange {
|
|
8
|
+
/**
|
|
9
|
+
* The id of the axis to apply the zoom to.
|
|
10
|
+
*/
|
|
11
|
+
axisId: AxisId;
|
|
12
|
+
/**
|
|
13
|
+
* The range to zoom to. Accepts the same values as a range button:
|
|
14
|
+
*
|
|
15
|
+
* - `{ unit, step }` — A calendar interval from the end of the data.
|
|
16
|
+
* - `[start, end]` — An absolute date range, or a range between two ordinal axis values.
|
|
17
|
+
* - `(params) => { start, end }` — A function returning zoom percentages (0-100).
|
|
18
|
+
* - `null` — Shows all data.
|
|
19
|
+
*/
|
|
20
|
+
value: RangeButtonValue;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* An entry of the `initialZoom` prop. Either explicit zoom percentages ({@link ZoomData})
|
|
24
|
+
* or a range value resolved against the axis ({@link InitialZoomRange}).
|
|
25
|
+
*/
|
|
26
|
+
export type InitialZoom = ZoomData | InitialZoomRange;
|
|
3
27
|
export interface UseChartProZoomParameters {
|
|
4
28
|
/**
|
|
5
29
|
* The list of zoom data related to each axis.
|
|
6
30
|
* Used to initialize the zoom in a specific configuration without controlling it.
|
|
31
|
+
*
|
|
32
|
+
* Each entry is either explicit zoom percentages (`{ axisId, start, end }`) or a
|
|
33
|
+
* range value (`{ axisId, value }`) resolved against the axis domain.
|
|
7
34
|
*/
|
|
8
|
-
initialZoom?: readonly
|
|
35
|
+
initialZoom?: readonly InitialZoom[];
|
|
9
36
|
/**
|
|
10
37
|
* Callback fired when the zoom has changed.
|
|
11
38
|
*
|
|
@@ -41,11 +68,6 @@ export interface UseChartProZoomState {
|
|
|
41
68
|
* Configuration for zoom interactions.
|
|
42
69
|
*/
|
|
43
70
|
zoomInteractionConfig: DefaultizedZoomInteractionConfig;
|
|
44
|
-
/**
|
|
45
|
-
* The key of the currently active range button, or `null` if no range button is active.
|
|
46
|
-
* Cleared when the user manually zooms or pans the chart.
|
|
47
|
-
*/
|
|
48
|
-
activeRangeButtonKey: string | null;
|
|
49
71
|
};
|
|
50
72
|
}
|
|
51
73
|
export interface UseChartProZoomPublicApi {
|
|
@@ -78,11 +100,6 @@ export interface UseChartProZoomInstance extends UseChartProZoomPublicApi {
|
|
|
78
100
|
* Zoom out the chart.
|
|
79
101
|
*/
|
|
80
102
|
zoomOut: () => void;
|
|
81
|
-
/**
|
|
82
|
-
* Set the active range button key. Pass `null` to clear.
|
|
83
|
-
* @param {string | null} key The key of the active range button.
|
|
84
|
-
*/
|
|
85
|
-
setActiveRangeButtonKey: (key: string | null) => void;
|
|
86
103
|
}
|
|
87
104
|
export type UseChartProZoomSignature = ChartPluginSignature<{
|
|
88
105
|
params: UseChartProZoomParameters;
|