@mui/x-charts-pro 7.0.0-alpha.1 → 7.0.0-alpha.2
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/CHANGELOG.md +82 -2
- package/ChartContainerPro/ChartContainerPro.js +2 -0
- package/Heatmap/Heatmap.js +2 -0
- package/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +2 -0
- package/ScatterChartPro/ScatterChartPro.js +2 -0
- package/context/CartesianProviderPro/CartesianProviderPro.js +44 -8
- package/context/CartesianProviderPro/createAxisFilterMapper.d.ts +12 -0
- package/context/CartesianProviderPro/createAxisFilterMapper.js +61 -0
- package/context/ZoomProvider/Zoom.types.d.ts +10 -0
- package/context/ZoomProvider/defaultizeZoom.js +2 -1
- package/index.js +1 -1
- package/internals/utils/releaseInfo.js +1 -1
- package/modern/ChartContainerPro/ChartContainerPro.js +2 -0
- package/modern/Heatmap/Heatmap.js +2 -0
- package/modern/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +2 -0
- package/modern/ScatterChartPro/ScatterChartPro.js +2 -0
- package/modern/context/CartesianProviderPro/CartesianProviderPro.js +44 -8
- package/modern/context/CartesianProviderPro/createAxisFilterMapper.js +61 -0
- package/modern/context/ZoomProvider/defaultizeZoom.js +2 -1
- package/modern/index.js +1 -1
- package/modern/internals/utils/releaseInfo.js +1 -1
- package/node/ChartContainerPro/ChartContainerPro.js +2 -0
- package/node/Heatmap/Heatmap.js +2 -0
- package/node/ResponsiveChartContainerPro/ResponsiveChartContainerPro.js +2 -0
- package/node/ScatterChartPro/ScatterChartPro.js +2 -0
- package/node/context/CartesianProviderPro/CartesianProviderPro.js +45 -8
- package/node/context/CartesianProviderPro/createAxisFilterMapper.js +69 -0
- package/node/context/ZoomProvider/defaultizeZoom.js +2 -1
- package/node/index.js +1 -1
- package/node/internals/utils/releaseInfo.js +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,86 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## 7.14.0
|
|
7
|
+
|
|
8
|
+
_Aug 23, 2024_
|
|
9
|
+
|
|
10
|
+
We'd like to offer a big thanks to the 14 contributors who made this release possible. Here are some highlights ✨:
|
|
11
|
+
|
|
12
|
+
- 💫 Allow [filtering the axis on zoom](https://mui.com/x/react-charts/zoom-and-pan/#zoom-filtering), making the axis adapt by removing values outside the view.
|
|
13
|
+
|
|
14
|
+
<img width="600" src="https://github.com/user-attachments/assets/e65bbd00-d2a8-4136-81cd-3598f1373c16" alt="filtering the axis on zoom" />
|
|
15
|
+
|
|
16
|
+
- 📊 Improve bar chart performances
|
|
17
|
+
- 🌍 Improve Czech (cs-CZ) and Hebrew (he-IL) locales on the Data Grid
|
|
18
|
+
- 🌍 Improve Chinese (zh-HK), Hebrew (he-IL), and Vietnamese (vi-VN) locales on the Date and Time Pickers
|
|
19
|
+
- 🐞 Bugfixes
|
|
20
|
+
|
|
21
|
+
<!--/ HIGHLIGHT_ABOVE_SEPARATOR /-->
|
|
22
|
+
|
|
23
|
+
### Data Grid
|
|
24
|
+
|
|
25
|
+
#### `@mui/x-data-grid@7.14.0`
|
|
26
|
+
|
|
27
|
+
- [DataGrid] Use readonly array result for `getTreeDataPath` (#11743) @pcorpet
|
|
28
|
+
- [DataGrid] Use `event.key` for `Tab` and `Escape` keys (#14170) @k-rajat19
|
|
29
|
+
- [DataGrid] Introduce selectors with arguments (#14236) @MBilalShafi
|
|
30
|
+
- [DataGrid] include `api` in `gridCellParams` interface (#14201) @k-rajat19
|
|
31
|
+
- [l10n] Improve Czech (cs-CZ) locale (#14135) @chirimiri22
|
|
32
|
+
- [l10n] Improve Hebrew (he-IL) locale (#14287) @rotembarsela
|
|
33
|
+
|
|
34
|
+
#### `@mui/x-data-grid-pro@7.14.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
35
|
+
|
|
36
|
+
Same changes as in `@mui/x-data-grid@7.14.0`.
|
|
37
|
+
|
|
38
|
+
#### `@mui/x-data-grid-premium@7.14.0` [](https://mui.com/r/x-premium-svg-link 'Premium plan')
|
|
39
|
+
|
|
40
|
+
Same changes as in `@mui/x-data-grid-pro@7.14.0`, plus:
|
|
41
|
+
|
|
42
|
+
- [DataGridPremium] Fix clipboard paste not working for a single cell on non-first page (#14261) @arminmeh
|
|
43
|
+
- [DataGridPremium] Fix `onCellSelectionModelChange` not triggered when additional cell range is selected (#14199) @arminmeh
|
|
44
|
+
|
|
45
|
+
### Date and Time Pickers
|
|
46
|
+
|
|
47
|
+
#### `@mui/x-date-pickers@7.14.0`
|
|
48
|
+
|
|
49
|
+
- [l10n] Improve Chinese (zh-HK) locale (#13289) @yeeharn
|
|
50
|
+
- [l10n] Improve Hebrew (he-IL) locale (#14287) @rotembarsela
|
|
51
|
+
- [l10n] Improve Vietnamese (vi-VN) locale (#14238) @locnbk2002
|
|
52
|
+
- [TimePicker] Handle `Space` and `Enter` on the `TimeClock` component @arthurbalduini
|
|
53
|
+
|
|
54
|
+
#### `@mui/x-date-pickers-pro@7.14.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
55
|
+
|
|
56
|
+
Same changes as in `@mui/x-date-pickers@7.14.0`.
|
|
57
|
+
|
|
58
|
+
### Charts
|
|
59
|
+
|
|
60
|
+
#### `@mui/x-charts@7.14.0`
|
|
61
|
+
|
|
62
|
+
- [charts] Fix grid overflow with zooming (#14280) @alexfauquette
|
|
63
|
+
- [charts] Improve bar chart performances (#14278) @alexfauquette
|
|
64
|
+
- [charts] Test pointer events (#14042) @alexfauquette
|
|
65
|
+
- [charts] Use `isPointInside` function for both graphs and axis (#14222) @JCQuintas
|
|
66
|
+
|
|
67
|
+
#### `@mui/x-charts-pro@7.0.0-alpha.2` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
68
|
+
|
|
69
|
+
Same changes as in `@mui/x-charts@7.14.0`, plus:
|
|
70
|
+
|
|
71
|
+
- [charts-pro] Zoom axis filtering (#14121) @JCQuintas
|
|
72
|
+
|
|
73
|
+
### Docs
|
|
74
|
+
|
|
75
|
+
- [docs] Consistent use of UTC and timezones (#14250) @oliviertassinari
|
|
76
|
+
- [docs] Fix missing leading slashes in URLs (#14249) @oliviertassinari
|
|
77
|
+
- [docs] Dash usage revision on pickers pages (#14260) @arthurbalduini
|
|
78
|
+
|
|
79
|
+
### Core
|
|
80
|
+
|
|
81
|
+
- [core] Follow JSDocs convention @oliviertassinari
|
|
82
|
+
- [core] Prepare for material v6 (#14143) @LukasTy
|
|
83
|
+
- [code-infra] Set up `eslint-plugin-testing-library` (#14232) @LukasTy
|
|
84
|
+
- [infra] Updated mui-x roadmap links with new project URL (#14271) @michelengelen
|
|
85
|
+
|
|
6
86
|
## 7.13.0
|
|
7
87
|
|
|
8
88
|
_Aug 16, 2024_
|
|
@@ -58,7 +138,7 @@ Same changes as in `@mui/x-date-pickers@7.13.0`.
|
|
|
58
138
|
- [charts] Rename `CartesianContextProvider` to `CartesianProvider` (#14102) @JCQuintas
|
|
59
139
|
- [charts] Support axis with the same value for all data points (#14191) @alexfauquette
|
|
60
140
|
|
|
61
|
-
#### `@mui/x-
|
|
141
|
+
#### `@mui/x-charts-pro@7.0.0-alpha.1` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
62
142
|
|
|
63
143
|
Same changes as in `@mui/x-charts@7.13.0`.
|
|
64
144
|
|
|
@@ -132,7 +212,7 @@ Same changes as in `@mui/x-date-pickers@7.12.1`.
|
|
|
132
212
|
- [charts] Fix charts vendor publish config (#14073) @JCQuintas
|
|
133
213
|
- [charts] Move `plugins` to `PluginProvider` (#14056) @JCQuintas
|
|
134
214
|
|
|
135
|
-
#### `@mui/x-
|
|
215
|
+
#### `@mui/x-charts-pro@7.0.0-alpha.0` [](https://mui.com/r/x-pro-svg-link 'Pro plan')
|
|
136
216
|
|
|
137
217
|
Same changes as in `@mui/x-charts@7.12.1`, plus:
|
|
138
218
|
|
|
@@ -178,6 +178,7 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
178
178
|
tickSize: PropTypes.number,
|
|
179
179
|
valueFormatter: PropTypes.func,
|
|
180
180
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
181
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
181
182
|
maxEnd: PropTypes.number,
|
|
182
183
|
maxSpan: PropTypes.number,
|
|
183
184
|
minSpan: PropTypes.number,
|
|
@@ -239,6 +240,7 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
239
240
|
tickSize: PropTypes.number,
|
|
240
241
|
valueFormatter: PropTypes.func,
|
|
241
242
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
243
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
242
244
|
maxEnd: PropTypes.number,
|
|
243
245
|
maxSpan: PropTypes.number,
|
|
244
246
|
minSpan: PropTypes.number,
|
package/Heatmap/Heatmap.js
CHANGED
|
@@ -289,6 +289,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
289
289
|
tickSize: PropTypes.number,
|
|
290
290
|
valueFormatter: PropTypes.func,
|
|
291
291
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
292
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
292
293
|
maxEnd: PropTypes.number,
|
|
293
294
|
maxSpan: PropTypes.number,
|
|
294
295
|
minSpan: PropTypes.number,
|
|
@@ -352,6 +353,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
352
353
|
tickSize: PropTypes.number,
|
|
353
354
|
valueFormatter: PropTypes.func,
|
|
354
355
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
356
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
355
357
|
maxEnd: PropTypes.number,
|
|
356
358
|
maxSpan: PropTypes.number,
|
|
357
359
|
minSpan: PropTypes.number,
|
|
@@ -155,6 +155,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainerPro.propTypes =
|
|
|
155
155
|
tickSize: PropTypes.number,
|
|
156
156
|
valueFormatter: PropTypes.func,
|
|
157
157
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
158
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
158
159
|
maxEnd: PropTypes.number,
|
|
159
160
|
maxSpan: PropTypes.number,
|
|
160
161
|
minSpan: PropTypes.number,
|
|
@@ -216,6 +217,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainerPro.propTypes =
|
|
|
216
217
|
tickSize: PropTypes.number,
|
|
217
218
|
valueFormatter: PropTypes.func,
|
|
218
219
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
220
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
219
221
|
maxEnd: PropTypes.number,
|
|
220
222
|
maxSpan: PropTypes.number,
|
|
221
223
|
minSpan: PropTypes.number,
|
|
@@ -284,6 +284,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
284
284
|
tickSize: PropTypes.number,
|
|
285
285
|
valueFormatter: PropTypes.func,
|
|
286
286
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
287
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
287
288
|
maxEnd: PropTypes.number,
|
|
288
289
|
maxSpan: PropTypes.number,
|
|
289
290
|
minSpan: PropTypes.number,
|
|
@@ -345,6 +346,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
345
346
|
tickSize: PropTypes.number,
|
|
346
347
|
valueFormatter: PropTypes.func,
|
|
347
348
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
349
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
348
350
|
maxEnd: PropTypes.number,
|
|
349
351
|
maxSpan: PropTypes.number,
|
|
350
352
|
minSpan: PropTypes.number,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useDrawingArea, useSeries, CartesianContext, cartesianProviderUtils, useXExtremumGetter, useYExtremumGetter } from '@mui/x-charts/internals';
|
|
3
4
|
import { useZoom } from '../ZoomProvider/useZoom';
|
|
5
|
+
import { createAxisFilterMapper, createGetAxisFilters } from './createAxisFilterMapper';
|
|
4
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
7
|
const {
|
|
6
8
|
computeValue
|
|
@@ -9,34 +11,68 @@ function CartesianProviderPro(props) {
|
|
|
9
11
|
const {
|
|
10
12
|
xAxis,
|
|
11
13
|
yAxis,
|
|
12
|
-
dataset,
|
|
13
14
|
children
|
|
14
15
|
} = props;
|
|
15
16
|
const formattedSeries = useSeries();
|
|
16
17
|
const drawingArea = useDrawingArea();
|
|
17
18
|
const {
|
|
18
|
-
zoomData
|
|
19
|
+
zoomData,
|
|
20
|
+
options
|
|
19
21
|
} = useZoom();
|
|
20
22
|
const xExtremumGetters = useXExtremumGetter();
|
|
21
23
|
const yExtremumGetters = useYExtremumGetter();
|
|
24
|
+
const getFilters = React.useMemo(() => {
|
|
25
|
+
const xMapper = createAxisFilterMapper({
|
|
26
|
+
zoomData,
|
|
27
|
+
extremumGetter: xExtremumGetters,
|
|
28
|
+
formattedSeries,
|
|
29
|
+
direction: 'x'
|
|
30
|
+
});
|
|
31
|
+
const yMapper = createAxisFilterMapper({
|
|
32
|
+
zoomData,
|
|
33
|
+
extremumGetter: yExtremumGetters,
|
|
34
|
+
formattedSeries,
|
|
35
|
+
direction: 'y'
|
|
36
|
+
});
|
|
37
|
+
const xFilters = xAxis.reduce((acc, axis, index) => {
|
|
38
|
+
const filter = xMapper(axis, index);
|
|
39
|
+
if (filter !== null) {
|
|
40
|
+
acc[axis.id] = filter;
|
|
41
|
+
}
|
|
42
|
+
return acc;
|
|
43
|
+
}, {});
|
|
44
|
+
const yFilters = yAxis.reduce((acc, axis, index) => {
|
|
45
|
+
const filter = yMapper(axis, index);
|
|
46
|
+
if (filter !== null) {
|
|
47
|
+
acc[axis.id] = filter;
|
|
48
|
+
}
|
|
49
|
+
return acc;
|
|
50
|
+
}, {});
|
|
51
|
+
if (Object.keys(xFilters).length === 0 && Object.keys(yFilters).length === 0) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return createGetAxisFilters(_extends({}, xFilters, yFilters));
|
|
55
|
+
}, [formattedSeries, xAxis, xExtremumGetters, yAxis, yExtremumGetters, zoomData]);
|
|
22
56
|
const xValues = React.useMemo(() => computeValue({
|
|
23
57
|
drawingArea,
|
|
24
58
|
formattedSeries,
|
|
25
59
|
axis: xAxis,
|
|
26
60
|
extremumGetters: xExtremumGetters,
|
|
27
|
-
dataset,
|
|
28
61
|
axisDirection: 'x',
|
|
29
|
-
zoomData
|
|
30
|
-
|
|
62
|
+
zoomData,
|
|
63
|
+
zoomOptions: options,
|
|
64
|
+
getFilters
|
|
65
|
+
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters, zoomData, options, getFilters]);
|
|
31
66
|
const yValues = React.useMemo(() => computeValue({
|
|
32
67
|
drawingArea,
|
|
33
68
|
formattedSeries,
|
|
34
69
|
axis: yAxis,
|
|
35
70
|
extremumGetters: yExtremumGetters,
|
|
36
|
-
dataset,
|
|
37
71
|
axisDirection: 'y',
|
|
38
|
-
zoomData
|
|
39
|
-
|
|
72
|
+
zoomData,
|
|
73
|
+
zoomOptions: options,
|
|
74
|
+
getFilters
|
|
75
|
+
}), [drawingArea, formattedSeries, yAxis, yExtremumGetters, zoomData, options, getFilters]);
|
|
40
76
|
const value = React.useMemo(() => ({
|
|
41
77
|
isInitialized: true,
|
|
42
78
|
data: {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { FormattedSeries, ExtremumGettersConfig, ExtremumFilter, ZoomAxisFilters, GetZoomAxisFilters } from '@mui/x-charts/internals';
|
|
2
|
+
import { ChartsAxisProps, ScaleName, AxisConfig } from '@mui/x-charts';
|
|
3
|
+
import { ZoomData } from '../ZoomProvider';
|
|
4
|
+
type CreateAxisFilterMapperParams = {
|
|
5
|
+
zoomData: ZoomData[];
|
|
6
|
+
extremumGetter: ExtremumGettersConfig;
|
|
7
|
+
formattedSeries: FormattedSeries;
|
|
8
|
+
direction: 'x' | 'y';
|
|
9
|
+
};
|
|
10
|
+
export declare const createAxisFilterMapper: ({ zoomData, extremumGetter, formattedSeries, direction }: CreateAxisFilterMapperParams) => (axis: AxisConfig<ScaleName, any, ChartsAxisProps>, axisIndex: number) => ExtremumFilter | null;
|
|
11
|
+
export declare const createGetAxisFilters: (filters: ZoomAxisFilters) => GetZoomAxisFilters;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getAxisExtremum, isDefined } from '@mui/x-charts/internals';
|
|
2
|
+
import { getScale } from '../../../../x-charts/src/internals/getScale';
|
|
3
|
+
export const createAxisFilterMapper = ({
|
|
4
|
+
zoomData,
|
|
5
|
+
extremumGetter,
|
|
6
|
+
formattedSeries,
|
|
7
|
+
direction
|
|
8
|
+
}) => (axis, axisIndex) => {
|
|
9
|
+
if (typeof axis.zoom !== 'object' || axis.zoom.filterMode !== 'discard') {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const zoom = zoomData?.find(({
|
|
13
|
+
axisId
|
|
14
|
+
}) => axisId === axis.id);
|
|
15
|
+
if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
|
|
16
|
+
// No zoom, or zoom with all data visible
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
let extremums = [];
|
|
20
|
+
const scaleType = axis.scaleType;
|
|
21
|
+
if (scaleType === 'point' || scaleType === 'band') {
|
|
22
|
+
extremums = [0, (axis.data?.length ?? 1) - 1];
|
|
23
|
+
} else {
|
|
24
|
+
extremums = getAxisExtremum(axis, extremumGetter, axisIndex === 0, formattedSeries);
|
|
25
|
+
}
|
|
26
|
+
let min;
|
|
27
|
+
let max;
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error The function defaults to linear scale if the scaleType is not recognized.
|
|
30
|
+
[min, max] = getScale(scaleType, extremums, [0, 100]).nice().domain();
|
|
31
|
+
min = min instanceof Date ? min.getTime() : min;
|
|
32
|
+
max = max instanceof Date ? max.getTime() : max;
|
|
33
|
+
const minVal = min + zoom.start * (max - min) / 100;
|
|
34
|
+
const maxVal = min + zoom.end * (max - min) / 100;
|
|
35
|
+
return (value, dataIndex) => {
|
|
36
|
+
const val = value[direction] ?? axis.data?.[dataIndex];
|
|
37
|
+
if (val == null) {
|
|
38
|
+
// If the value does not exist because of missing data point, or out of range index, we just ignore.
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (axis.scaleType === 'point' || axis.scaleType === 'band' || typeof val === 'string') {
|
|
42
|
+
return dataIndex >= minVal && dataIndex <= maxVal;
|
|
43
|
+
}
|
|
44
|
+
return val >= minVal && val <= maxVal;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export const createGetAxisFilters = filters => ({
|
|
48
|
+
currentAxisId,
|
|
49
|
+
seriesXAxisId,
|
|
50
|
+
seriesYAxisId,
|
|
51
|
+
isDefaultAxis
|
|
52
|
+
}) => {
|
|
53
|
+
return (value, dataIndex) => {
|
|
54
|
+
const axisId = currentAxisId === seriesXAxisId ? seriesYAxisId : seriesXAxisId;
|
|
55
|
+
if (!axisId || isDefaultAxis) {
|
|
56
|
+
return Object.values(filters ?? {})[0]?.(value, dataIndex) ?? true;
|
|
57
|
+
}
|
|
58
|
+
const data = [seriesYAxisId, seriesXAxisId].filter(id => id !== currentAxisId).map(id => filters[id ?? '']).filter(isDefined);
|
|
59
|
+
return data.every(f => f(value, dataIndex));
|
|
60
|
+
};
|
|
61
|
+
};
|
|
@@ -93,6 +93,16 @@ export type ZoomOptions = {
|
|
|
93
93
|
* @default true
|
|
94
94
|
*/
|
|
95
95
|
panning?: boolean;
|
|
96
|
+
/**
|
|
97
|
+
* Defines how to filter the axis data when it is outside of the zoomed range of this axis.
|
|
98
|
+
*
|
|
99
|
+
* - `keep`: The data outside the zoomed range is kept. And the other axes will stay the same.
|
|
100
|
+
* - `discard`: The data outside the zoomed range is discarded for the other axes.
|
|
101
|
+
* The other axes will be adjusted to fit the zoomed range.
|
|
102
|
+
*
|
|
103
|
+
* @default 'keep'
|
|
104
|
+
*/
|
|
105
|
+
filterMode?: 'discard' | 'keep';
|
|
96
106
|
};
|
|
97
107
|
export type ZoomData = {
|
|
98
108
|
/**
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTcyNDM2MDQwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -178,6 +178,7 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
178
178
|
tickSize: PropTypes.number,
|
|
179
179
|
valueFormatter: PropTypes.func,
|
|
180
180
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
181
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
181
182
|
maxEnd: PropTypes.number,
|
|
182
183
|
maxSpan: PropTypes.number,
|
|
183
184
|
minSpan: PropTypes.number,
|
|
@@ -239,6 +240,7 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
239
240
|
tickSize: PropTypes.number,
|
|
240
241
|
valueFormatter: PropTypes.func,
|
|
241
242
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
243
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
242
244
|
maxEnd: PropTypes.number,
|
|
243
245
|
maxSpan: PropTypes.number,
|
|
244
246
|
minSpan: PropTypes.number,
|
|
@@ -289,6 +289,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
289
289
|
tickSize: PropTypes.number,
|
|
290
290
|
valueFormatter: PropTypes.func,
|
|
291
291
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
292
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
292
293
|
maxEnd: PropTypes.number,
|
|
293
294
|
maxSpan: PropTypes.number,
|
|
294
295
|
minSpan: PropTypes.number,
|
|
@@ -352,6 +353,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
352
353
|
tickSize: PropTypes.number,
|
|
353
354
|
valueFormatter: PropTypes.func,
|
|
354
355
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
356
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
355
357
|
maxEnd: PropTypes.number,
|
|
356
358
|
maxSpan: PropTypes.number,
|
|
357
359
|
minSpan: PropTypes.number,
|
|
@@ -155,6 +155,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainerPro.propTypes =
|
|
|
155
155
|
tickSize: PropTypes.number,
|
|
156
156
|
valueFormatter: PropTypes.func,
|
|
157
157
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
158
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
158
159
|
maxEnd: PropTypes.number,
|
|
159
160
|
maxSpan: PropTypes.number,
|
|
160
161
|
minSpan: PropTypes.number,
|
|
@@ -216,6 +217,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainerPro.propTypes =
|
|
|
216
217
|
tickSize: PropTypes.number,
|
|
217
218
|
valueFormatter: PropTypes.func,
|
|
218
219
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
220
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
219
221
|
maxEnd: PropTypes.number,
|
|
220
222
|
maxSpan: PropTypes.number,
|
|
221
223
|
minSpan: PropTypes.number,
|
|
@@ -284,6 +284,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
284
284
|
tickSize: PropTypes.number,
|
|
285
285
|
valueFormatter: PropTypes.func,
|
|
286
286
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
287
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
287
288
|
maxEnd: PropTypes.number,
|
|
288
289
|
maxSpan: PropTypes.number,
|
|
289
290
|
minSpan: PropTypes.number,
|
|
@@ -345,6 +346,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
345
346
|
tickSize: PropTypes.number,
|
|
346
347
|
valueFormatter: PropTypes.func,
|
|
347
348
|
zoom: PropTypes.oneOfType([PropTypes.shape({
|
|
349
|
+
filterMode: PropTypes.oneOf(['discard', 'keep']),
|
|
348
350
|
maxEnd: PropTypes.number,
|
|
349
351
|
maxSpan: PropTypes.number,
|
|
350
352
|
minSpan: PropTypes.number,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
1
2
|
import * as React from 'react';
|
|
2
3
|
import { useDrawingArea, useSeries, CartesianContext, cartesianProviderUtils, useXExtremumGetter, useYExtremumGetter } from '@mui/x-charts/internals';
|
|
3
4
|
import { useZoom } from '../ZoomProvider/useZoom';
|
|
5
|
+
import { createAxisFilterMapper, createGetAxisFilters } from './createAxisFilterMapper';
|
|
4
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
7
|
const {
|
|
6
8
|
computeValue
|
|
@@ -9,34 +11,68 @@ function CartesianProviderPro(props) {
|
|
|
9
11
|
const {
|
|
10
12
|
xAxis,
|
|
11
13
|
yAxis,
|
|
12
|
-
dataset,
|
|
13
14
|
children
|
|
14
15
|
} = props;
|
|
15
16
|
const formattedSeries = useSeries();
|
|
16
17
|
const drawingArea = useDrawingArea();
|
|
17
18
|
const {
|
|
18
|
-
zoomData
|
|
19
|
+
zoomData,
|
|
20
|
+
options
|
|
19
21
|
} = useZoom();
|
|
20
22
|
const xExtremumGetters = useXExtremumGetter();
|
|
21
23
|
const yExtremumGetters = useYExtremumGetter();
|
|
24
|
+
const getFilters = React.useMemo(() => {
|
|
25
|
+
const xMapper = createAxisFilterMapper({
|
|
26
|
+
zoomData,
|
|
27
|
+
extremumGetter: xExtremumGetters,
|
|
28
|
+
formattedSeries,
|
|
29
|
+
direction: 'x'
|
|
30
|
+
});
|
|
31
|
+
const yMapper = createAxisFilterMapper({
|
|
32
|
+
zoomData,
|
|
33
|
+
extremumGetter: yExtremumGetters,
|
|
34
|
+
formattedSeries,
|
|
35
|
+
direction: 'y'
|
|
36
|
+
});
|
|
37
|
+
const xFilters = xAxis.reduce((acc, axis, index) => {
|
|
38
|
+
const filter = xMapper(axis, index);
|
|
39
|
+
if (filter !== null) {
|
|
40
|
+
acc[axis.id] = filter;
|
|
41
|
+
}
|
|
42
|
+
return acc;
|
|
43
|
+
}, {});
|
|
44
|
+
const yFilters = yAxis.reduce((acc, axis, index) => {
|
|
45
|
+
const filter = yMapper(axis, index);
|
|
46
|
+
if (filter !== null) {
|
|
47
|
+
acc[axis.id] = filter;
|
|
48
|
+
}
|
|
49
|
+
return acc;
|
|
50
|
+
}, {});
|
|
51
|
+
if (Object.keys(xFilters).length === 0 && Object.keys(yFilters).length === 0) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return createGetAxisFilters(_extends({}, xFilters, yFilters));
|
|
55
|
+
}, [formattedSeries, xAxis, xExtremumGetters, yAxis, yExtremumGetters, zoomData]);
|
|
22
56
|
const xValues = React.useMemo(() => computeValue({
|
|
23
57
|
drawingArea,
|
|
24
58
|
formattedSeries,
|
|
25
59
|
axis: xAxis,
|
|
26
60
|
extremumGetters: xExtremumGetters,
|
|
27
|
-
dataset,
|
|
28
61
|
axisDirection: 'x',
|
|
29
|
-
zoomData
|
|
30
|
-
|
|
62
|
+
zoomData,
|
|
63
|
+
zoomOptions: options,
|
|
64
|
+
getFilters
|
|
65
|
+
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters, zoomData, options, getFilters]);
|
|
31
66
|
const yValues = React.useMemo(() => computeValue({
|
|
32
67
|
drawingArea,
|
|
33
68
|
formattedSeries,
|
|
34
69
|
axis: yAxis,
|
|
35
70
|
extremumGetters: yExtremumGetters,
|
|
36
|
-
dataset,
|
|
37
71
|
axisDirection: 'y',
|
|
38
|
-
zoomData
|
|
39
|
-
|
|
72
|
+
zoomData,
|
|
73
|
+
zoomOptions: options,
|
|
74
|
+
getFilters
|
|
75
|
+
}), [drawingArea, formattedSeries, yAxis, yExtremumGetters, zoomData, options, getFilters]);
|
|
40
76
|
const value = React.useMemo(() => ({
|
|
41
77
|
isInitialized: true,
|
|
42
78
|
data: {
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getAxisExtremum, isDefined } from '@mui/x-charts/internals';
|
|
2
|
+
import { getScale } from '../../../../x-charts/src/internals/getScale';
|
|
3
|
+
export const createAxisFilterMapper = ({
|
|
4
|
+
zoomData,
|
|
5
|
+
extremumGetter,
|
|
6
|
+
formattedSeries,
|
|
7
|
+
direction
|
|
8
|
+
}) => (axis, axisIndex) => {
|
|
9
|
+
if (typeof axis.zoom !== 'object' || axis.zoom.filterMode !== 'discard') {
|
|
10
|
+
return null;
|
|
11
|
+
}
|
|
12
|
+
const zoom = zoomData?.find(({
|
|
13
|
+
axisId
|
|
14
|
+
}) => axisId === axis.id);
|
|
15
|
+
if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
|
|
16
|
+
// No zoom, or zoom with all data visible
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
let extremums = [];
|
|
20
|
+
const scaleType = axis.scaleType;
|
|
21
|
+
if (scaleType === 'point' || scaleType === 'band') {
|
|
22
|
+
extremums = [0, (axis.data?.length ?? 1) - 1];
|
|
23
|
+
} else {
|
|
24
|
+
extremums = getAxisExtremum(axis, extremumGetter, axisIndex === 0, formattedSeries);
|
|
25
|
+
}
|
|
26
|
+
let min;
|
|
27
|
+
let max;
|
|
28
|
+
|
|
29
|
+
// @ts-expect-error The function defaults to linear scale if the scaleType is not recognized.
|
|
30
|
+
[min, max] = getScale(scaleType, extremums, [0, 100]).nice().domain();
|
|
31
|
+
min = min instanceof Date ? min.getTime() : min;
|
|
32
|
+
max = max instanceof Date ? max.getTime() : max;
|
|
33
|
+
const minVal = min + zoom.start * (max - min) / 100;
|
|
34
|
+
const maxVal = min + zoom.end * (max - min) / 100;
|
|
35
|
+
return (value, dataIndex) => {
|
|
36
|
+
const val = value[direction] ?? axis.data?.[dataIndex];
|
|
37
|
+
if (val == null) {
|
|
38
|
+
// If the value does not exist because of missing data point, or out of range index, we just ignore.
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
if (axis.scaleType === 'point' || axis.scaleType === 'band' || typeof val === 'string') {
|
|
42
|
+
return dataIndex >= minVal && dataIndex <= maxVal;
|
|
43
|
+
}
|
|
44
|
+
return val >= minVal && val <= maxVal;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export const createGetAxisFilters = filters => ({
|
|
48
|
+
currentAxisId,
|
|
49
|
+
seriesXAxisId,
|
|
50
|
+
seriesYAxisId,
|
|
51
|
+
isDefaultAxis
|
|
52
|
+
}) => {
|
|
53
|
+
return (value, dataIndex) => {
|
|
54
|
+
const axisId = currentAxisId === seriesXAxisId ? seriesYAxisId : seriesXAxisId;
|
|
55
|
+
if (!axisId || isDefaultAxis) {
|
|
56
|
+
return Object.values(filters ?? {})[0]?.(value, dataIndex) ?? true;
|
|
57
|
+
}
|
|
58
|
+
const data = [seriesYAxisId, seriesXAxisId].filter(id => id !== currentAxisId).map(id => filters[id ?? '']).filter(isDefined);
|
|
59
|
+
return data.every(f => f(value, dataIndex));
|
|
60
|
+
};
|
|
61
|
+
};
|
package/modern/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ponyfillGlobal } from '@mui/utils';
|
|
2
2
|
export const getReleaseInfo = () => {
|
|
3
|
-
const releaseInfo = "
|
|
3
|
+
const releaseInfo = "MTcyNDM2MDQwMDAwMA==";
|
|
4
4
|
if (process.env.NODE_ENV !== 'production') {
|
|
5
5
|
// A simple hack to set the value in the test environment (has no build step).
|
|
6
6
|
// eslint-disable-next-line no-useless-concat
|
|
@@ -187,6 +187,7 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
187
187
|
tickSize: _propTypes.default.number,
|
|
188
188
|
valueFormatter: _propTypes.default.func,
|
|
189
189
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
190
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
190
191
|
maxEnd: _propTypes.default.number,
|
|
191
192
|
maxSpan: _propTypes.default.number,
|
|
192
193
|
minSpan: _propTypes.default.number,
|
|
@@ -248,6 +249,7 @@ process.env.NODE_ENV !== "production" ? ChartContainerPro.propTypes = {
|
|
|
248
249
|
tickSize: _propTypes.default.number,
|
|
249
250
|
valueFormatter: _propTypes.default.func,
|
|
250
251
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
252
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
251
253
|
maxEnd: _propTypes.default.number,
|
|
252
254
|
maxSpan: _propTypes.default.number,
|
|
253
255
|
minSpan: _propTypes.default.number,
|
package/node/Heatmap/Heatmap.js
CHANGED
|
@@ -298,6 +298,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
298
298
|
tickSize: _propTypes.default.number,
|
|
299
299
|
valueFormatter: _propTypes.default.func,
|
|
300
300
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
301
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
301
302
|
maxEnd: _propTypes.default.number,
|
|
302
303
|
maxSpan: _propTypes.default.number,
|
|
303
304
|
minSpan: _propTypes.default.number,
|
|
@@ -361,6 +362,7 @@ process.env.NODE_ENV !== "production" ? Heatmap.propTypes = {
|
|
|
361
362
|
tickSize: _propTypes.default.number,
|
|
362
363
|
valueFormatter: _propTypes.default.func,
|
|
363
364
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
365
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
364
366
|
maxEnd: _propTypes.default.number,
|
|
365
367
|
maxSpan: _propTypes.default.number,
|
|
366
368
|
minSpan: _propTypes.default.number,
|
|
@@ -164,6 +164,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainerPro.propTypes =
|
|
|
164
164
|
tickSize: _propTypes.default.number,
|
|
165
165
|
valueFormatter: _propTypes.default.func,
|
|
166
166
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
167
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
167
168
|
maxEnd: _propTypes.default.number,
|
|
168
169
|
maxSpan: _propTypes.default.number,
|
|
169
170
|
minSpan: _propTypes.default.number,
|
|
@@ -225,6 +226,7 @@ process.env.NODE_ENV !== "production" ? ResponsiveChartContainerPro.propTypes =
|
|
|
225
226
|
tickSize: _propTypes.default.number,
|
|
226
227
|
valueFormatter: _propTypes.default.func,
|
|
227
228
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
229
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
228
230
|
maxEnd: _propTypes.default.number,
|
|
229
231
|
maxSpan: _propTypes.default.number,
|
|
230
232
|
minSpan: _propTypes.default.number,
|
|
@@ -293,6 +293,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
293
293
|
tickSize: _propTypes.default.number,
|
|
294
294
|
valueFormatter: _propTypes.default.func,
|
|
295
295
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
296
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
296
297
|
maxEnd: _propTypes.default.number,
|
|
297
298
|
maxSpan: _propTypes.default.number,
|
|
298
299
|
minSpan: _propTypes.default.number,
|
|
@@ -354,6 +355,7 @@ process.env.NODE_ENV !== "production" ? ScatterChartPro.propTypes = {
|
|
|
354
355
|
tickSize: _propTypes.default.number,
|
|
355
356
|
valueFormatter: _propTypes.default.func,
|
|
356
357
|
zoom: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
358
|
+
filterMode: _propTypes.default.oneOf(['discard', 'keep']),
|
|
357
359
|
maxEnd: _propTypes.default.number,
|
|
358
360
|
maxSpan: _propTypes.default.number,
|
|
359
361
|
minSpan: _propTypes.default.number,
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.CartesianProviderPro = CartesianProviderPro;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
9
|
var React = _interopRequireWildcard(require("react"));
|
|
8
10
|
var _internals = require("@mui/x-charts/internals");
|
|
9
11
|
var _useZoom = require("../ZoomProvider/useZoom");
|
|
12
|
+
var _createAxisFilterMapper = require("./createAxisFilterMapper");
|
|
10
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
11
14
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
12
15
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
@@ -17,34 +20,68 @@ function CartesianProviderPro(props) {
|
|
|
17
20
|
const {
|
|
18
21
|
xAxis,
|
|
19
22
|
yAxis,
|
|
20
|
-
dataset,
|
|
21
23
|
children
|
|
22
24
|
} = props;
|
|
23
25
|
const formattedSeries = (0, _internals.useSeries)();
|
|
24
26
|
const drawingArea = (0, _internals.useDrawingArea)();
|
|
25
27
|
const {
|
|
26
|
-
zoomData
|
|
28
|
+
zoomData,
|
|
29
|
+
options
|
|
27
30
|
} = (0, _useZoom.useZoom)();
|
|
28
31
|
const xExtremumGetters = (0, _internals.useXExtremumGetter)();
|
|
29
32
|
const yExtremumGetters = (0, _internals.useYExtremumGetter)();
|
|
33
|
+
const getFilters = React.useMemo(() => {
|
|
34
|
+
const xMapper = (0, _createAxisFilterMapper.createAxisFilterMapper)({
|
|
35
|
+
zoomData,
|
|
36
|
+
extremumGetter: xExtremumGetters,
|
|
37
|
+
formattedSeries,
|
|
38
|
+
direction: 'x'
|
|
39
|
+
});
|
|
40
|
+
const yMapper = (0, _createAxisFilterMapper.createAxisFilterMapper)({
|
|
41
|
+
zoomData,
|
|
42
|
+
extremumGetter: yExtremumGetters,
|
|
43
|
+
formattedSeries,
|
|
44
|
+
direction: 'y'
|
|
45
|
+
});
|
|
46
|
+
const xFilters = xAxis.reduce((acc, axis, index) => {
|
|
47
|
+
const filter = xMapper(axis, index);
|
|
48
|
+
if (filter !== null) {
|
|
49
|
+
acc[axis.id] = filter;
|
|
50
|
+
}
|
|
51
|
+
return acc;
|
|
52
|
+
}, {});
|
|
53
|
+
const yFilters = yAxis.reduce((acc, axis, index) => {
|
|
54
|
+
const filter = yMapper(axis, index);
|
|
55
|
+
if (filter !== null) {
|
|
56
|
+
acc[axis.id] = filter;
|
|
57
|
+
}
|
|
58
|
+
return acc;
|
|
59
|
+
}, {});
|
|
60
|
+
if (Object.keys(xFilters).length === 0 && Object.keys(yFilters).length === 0) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
return (0, _createAxisFilterMapper.createGetAxisFilters)((0, _extends2.default)({}, xFilters, yFilters));
|
|
64
|
+
}, [formattedSeries, xAxis, xExtremumGetters, yAxis, yExtremumGetters, zoomData]);
|
|
30
65
|
const xValues = React.useMemo(() => computeValue({
|
|
31
66
|
drawingArea,
|
|
32
67
|
formattedSeries,
|
|
33
68
|
axis: xAxis,
|
|
34
69
|
extremumGetters: xExtremumGetters,
|
|
35
|
-
dataset,
|
|
36
70
|
axisDirection: 'x',
|
|
37
|
-
zoomData
|
|
38
|
-
|
|
71
|
+
zoomData,
|
|
72
|
+
zoomOptions: options,
|
|
73
|
+
getFilters
|
|
74
|
+
}), [drawingArea, formattedSeries, xAxis, xExtremumGetters, zoomData, options, getFilters]);
|
|
39
75
|
const yValues = React.useMemo(() => computeValue({
|
|
40
76
|
drawingArea,
|
|
41
77
|
formattedSeries,
|
|
42
78
|
axis: yAxis,
|
|
43
79
|
extremumGetters: yExtremumGetters,
|
|
44
|
-
dataset,
|
|
45
80
|
axisDirection: 'y',
|
|
46
|
-
zoomData
|
|
47
|
-
|
|
81
|
+
zoomData,
|
|
82
|
+
zoomOptions: options,
|
|
83
|
+
getFilters
|
|
84
|
+
}), [drawingArea, formattedSeries, yAxis, yExtremumGetters, zoomData, options, getFilters]);
|
|
48
85
|
const value = React.useMemo(() => ({
|
|
49
86
|
isInitialized: true,
|
|
50
87
|
data: {
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.createGetAxisFilters = exports.createAxisFilterMapper = void 0;
|
|
7
|
+
var _internals = require("@mui/x-charts/internals");
|
|
8
|
+
var _getScale = require("../../../../x-charts/src/internals/getScale");
|
|
9
|
+
const createAxisFilterMapper = ({
|
|
10
|
+
zoomData,
|
|
11
|
+
extremumGetter,
|
|
12
|
+
formattedSeries,
|
|
13
|
+
direction
|
|
14
|
+
}) => (axis, axisIndex) => {
|
|
15
|
+
if (typeof axis.zoom !== 'object' || axis.zoom.filterMode !== 'discard') {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
const zoom = zoomData?.find(({
|
|
19
|
+
axisId
|
|
20
|
+
}) => axisId === axis.id);
|
|
21
|
+
if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
|
|
22
|
+
// No zoom, or zoom with all data visible
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
let extremums = [];
|
|
26
|
+
const scaleType = axis.scaleType;
|
|
27
|
+
if (scaleType === 'point' || scaleType === 'band') {
|
|
28
|
+
extremums = [0, (axis.data?.length ?? 1) - 1];
|
|
29
|
+
} else {
|
|
30
|
+
extremums = (0, _internals.getAxisExtremum)(axis, extremumGetter, axisIndex === 0, formattedSeries);
|
|
31
|
+
}
|
|
32
|
+
let min;
|
|
33
|
+
let max;
|
|
34
|
+
|
|
35
|
+
// @ts-expect-error The function defaults to linear scale if the scaleType is not recognized.
|
|
36
|
+
[min, max] = (0, _getScale.getScale)(scaleType, extremums, [0, 100]).nice().domain();
|
|
37
|
+
min = min instanceof Date ? min.getTime() : min;
|
|
38
|
+
max = max instanceof Date ? max.getTime() : max;
|
|
39
|
+
const minVal = min + zoom.start * (max - min) / 100;
|
|
40
|
+
const maxVal = min + zoom.end * (max - min) / 100;
|
|
41
|
+
return (value, dataIndex) => {
|
|
42
|
+
const val = value[direction] ?? axis.data?.[dataIndex];
|
|
43
|
+
if (val == null) {
|
|
44
|
+
// If the value does not exist because of missing data point, or out of range index, we just ignore.
|
|
45
|
+
return true;
|
|
46
|
+
}
|
|
47
|
+
if (axis.scaleType === 'point' || axis.scaleType === 'band' || typeof val === 'string') {
|
|
48
|
+
return dataIndex >= minVal && dataIndex <= maxVal;
|
|
49
|
+
}
|
|
50
|
+
return val >= minVal && val <= maxVal;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
exports.createAxisFilterMapper = createAxisFilterMapper;
|
|
54
|
+
const createGetAxisFilters = filters => ({
|
|
55
|
+
currentAxisId,
|
|
56
|
+
seriesXAxisId,
|
|
57
|
+
seriesYAxisId,
|
|
58
|
+
isDefaultAxis
|
|
59
|
+
}) => {
|
|
60
|
+
return (value, dataIndex) => {
|
|
61
|
+
const axisId = currentAxisId === seriesXAxisId ? seriesYAxisId : seriesXAxisId;
|
|
62
|
+
if (!axisId || isDefaultAxis) {
|
|
63
|
+
return Object.values(filters ?? {})[0]?.(value, dataIndex) ?? true;
|
|
64
|
+
}
|
|
65
|
+
const data = [seriesYAxisId, seriesXAxisId].filter(id => id !== currentAxisId).map(id => filters[id ?? '']).filter(_internals.isDefined);
|
|
66
|
+
return data.every(f => f(value, dataIndex));
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
exports.createGetAxisFilters = createGetAxisFilters;
|
package/node/index.js
CHANGED
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getReleaseInfo = void 0;
|
|
7
7
|
var _utils = require("@mui/utils");
|
|
8
8
|
const getReleaseInfo = () => {
|
|
9
|
-
const releaseInfo = "
|
|
9
|
+
const releaseInfo = "MTcyNDM2MDQwMDAwMA==";
|
|
10
10
|
if (process.env.NODE_ENV !== 'production') {
|
|
11
11
|
// A simple hack to set the value in the test environment (has no build step).
|
|
12
12
|
// eslint-disable-next-line no-useless-concat
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts-pro",
|
|
3
|
-
"version": "7.0.0-alpha.
|
|
3
|
+
"version": "7.0.0-alpha.2",
|
|
4
4
|
"description": "The Pro plan edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./node/index.js",
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/runtime": "^7.25.0",
|
|
33
|
-
"@mui/system": "^5.16.
|
|
34
|
-
"@mui/utils": "^5.16.
|
|
33
|
+
"@mui/system": "^5.16.7",
|
|
34
|
+
"@mui/utils": "^5.16.6",
|
|
35
35
|
"@react-spring/rafz": "^9.7.4",
|
|
36
36
|
"@react-spring/web": "^9.7.4",
|
|
37
37
|
"clsx": "^2.1.1",
|
|
38
38
|
"prop-types": "^15.8.1",
|
|
39
|
-
"@mui/x-charts": "7.
|
|
40
|
-
"@mui/x-
|
|
41
|
-
"@mui/x-
|
|
39
|
+
"@mui/x-charts": "7.14.0",
|
|
40
|
+
"@mui/x-license": "7.14.0",
|
|
41
|
+
"@mui/x-charts-vendor": "7.14.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@emotion/react": "^11.9.0",
|