@mui/x-charts 7.12.1 → 7.14.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/BarChart/BarChart.js +2 -0
- package/BarChart/BarPlot.js +4 -3
- package/BarChart/extremums.js +46 -9
- package/CHANGELOG.md +162 -1
- package/ChartContainer/ChartContainer.d.ts +3 -3
- package/ChartContainer/ChartContainer.js +4 -2
- package/ChartContainer/useChartContainerProps.d.ts +4 -2
- package/ChartContainer/useChartContainerProps.js +3 -3
- package/ChartContainer/useDefaultizeAxis.d.ts +3 -1
- package/ChartContainer/useDefaultizeAxis.js +16 -5
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +23 -9
- package/ChartsGrid/ChartsGrid.js +6 -4
- package/ChartsTooltip/utils.js +4 -2
- package/ChartsXAxis/ChartsXAxis.js +25 -8
- package/ChartsYAxis/ChartsYAxis.js +19 -7
- package/LineChart/AreaPlot.js +11 -1
- package/LineChart/LineChart.js +2 -0
- package/LineChart/extremums.js +23 -18
- package/PieChart/PieChart.js +2 -0
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -0
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +1 -1
- package/ScatterChart/ScatterChart.js +2 -0
- package/ScatterChart/extremums.js +30 -22
- package/SparkLineChart/SparkLineChart.js +2 -0
- package/context/CartesianProvider/Cartesian.types.d.ts +59 -0
- package/context/CartesianProvider/Cartesian.types.js +5 -0
- package/context/CartesianProvider/CartesianContext.d.ts +1 -22
- package/context/CartesianProvider/CartesianProvider.d.ts +3 -23
- package/context/CartesianProvider/CartesianProvider.js +4 -7
- package/context/CartesianProvider/computeValue.d.ts +18 -31
- package/context/CartesianProvider/computeValue.js +20 -23
- package/context/CartesianProvider/defaultizeAxis.d.ts +1 -0
- package/context/CartesianProvider/getAxisExtremum.d.ts +3 -2
- package/context/CartesianProvider/getAxisExtremum.js +10 -11
- package/context/CartesianProvider/index.d.ts +1 -0
- package/context/CartesianProvider/index.js +12 -0
- package/context/CartesianProvider/useCartesianContext.d.ts +1 -1
- package/context/CartesianProvider/zoom.d.ts +10 -0
- package/context/CartesianProvider/zoom.js +26 -0
- package/context/DrawingProvider.d.ts +7 -2
- package/context/DrawingProvider.js +11 -3
- package/context/PluginProvider/ExtremumGetter.types.d.ts +12 -2
- package/esm/BarChart/BarChart.js +2 -0
- package/esm/BarChart/BarPlot.js +4 -3
- package/esm/BarChart/extremums.js +46 -9
- package/esm/ChartContainer/ChartContainer.js +5 -3
- package/esm/ChartContainer/useChartContainerProps.js +3 -3
- package/esm/ChartContainer/useDefaultizeAxis.js +16 -5
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +23 -9
- package/esm/ChartsGrid/ChartsGrid.js +6 -4
- package/esm/ChartsTooltip/utils.js +4 -2
- package/esm/ChartsXAxis/ChartsXAxis.js +25 -8
- package/esm/ChartsYAxis/ChartsYAxis.js +19 -7
- package/esm/LineChart/AreaPlot.js +11 -1
- package/esm/LineChart/LineChart.js +2 -0
- package/esm/LineChart/extremums.js +23 -18
- package/esm/PieChart/PieChart.js +2 -0
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -0
- package/esm/ScatterChart/ScatterChart.js +2 -0
- package/esm/ScatterChart/extremums.js +30 -22
- package/esm/SparkLineChart/SparkLineChart.js +2 -0
- package/esm/context/CartesianProvider/Cartesian.types.js +1 -0
- package/esm/context/CartesianProvider/CartesianProvider.js +4 -7
- package/esm/context/CartesianProvider/computeValue.js +20 -23
- package/esm/context/CartesianProvider/getAxisExtremum.js +10 -11
- package/esm/context/CartesianProvider/index.js +1 -0
- package/esm/context/CartesianProvider/zoom.js +19 -0
- package/esm/context/DrawingProvider.js +11 -3
- package/esm/hooks/useAxisEvents.js +3 -1
- package/esm/hooks/useTicks.js +5 -2
- package/esm/internals/domUtils.js +16 -3
- package/esm/internals/index.js +3 -0
- package/esm/internals/isInfinity.js +3 -0
- package/esm/models/axis.js +5 -0
- package/esm/tests/firePointerEvent.js +35 -0
- package/hooks/useAxisEvents.js +3 -1
- package/hooks/useTicks.js +5 -2
- package/index.js +1 -1
- package/internals/defaultizeColor.d.ts +1 -0
- package/internals/domUtils.d.ts +2 -0
- package/internals/domUtils.js +19 -5
- package/internals/index.d.ts +2 -0
- package/internals/index.js +17 -1
- package/internals/isInfinity.d.ts +1 -0
- package/internals/isInfinity.js +9 -0
- package/models/axis.d.ts +6 -0
- package/models/axis.js +5 -0
- package/models/seriesType/line.d.ts +10 -0
- package/modern/BarChart/BarChart.js +2 -0
- package/modern/BarChart/BarPlot.js +4 -3
- package/modern/BarChart/extremums.js +46 -9
- package/modern/ChartContainer/ChartContainer.js +5 -3
- package/modern/ChartContainer/useChartContainerProps.js +3 -3
- package/modern/ChartContainer/useDefaultizeAxis.js +16 -5
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +23 -9
- package/modern/ChartsGrid/ChartsGrid.js +6 -4
- package/modern/ChartsTooltip/utils.js +4 -2
- package/modern/ChartsXAxis/ChartsXAxis.js +25 -8
- package/modern/ChartsYAxis/ChartsYAxis.js +19 -7
- package/modern/LineChart/AreaPlot.js +11 -1
- package/modern/LineChart/LineChart.js +2 -0
- package/modern/LineChart/extremums.js +23 -18
- package/modern/PieChart/PieChart.js +2 -0
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +2 -0
- package/modern/ScatterChart/ScatterChart.js +2 -0
- package/modern/ScatterChart/extremums.js +30 -22
- package/modern/SparkLineChart/SparkLineChart.js +2 -0
- package/modern/context/CartesianProvider/Cartesian.types.js +1 -0
- package/modern/context/CartesianProvider/CartesianProvider.js +4 -7
- package/modern/context/CartesianProvider/computeValue.js +20 -23
- package/modern/context/CartesianProvider/getAxisExtremum.js +10 -11
- package/modern/context/CartesianProvider/index.js +1 -0
- package/modern/context/CartesianProvider/zoom.js +19 -0
- package/modern/context/DrawingProvider.js +11 -3
- package/modern/hooks/useAxisEvents.js +3 -1
- package/modern/hooks/useTicks.js +5 -2
- package/modern/index.js +1 -1
- package/modern/internals/domUtils.js +16 -3
- package/modern/internals/index.js +3 -0
- package/modern/internals/isInfinity.js +3 -0
- package/modern/models/axis.js +5 -0
- package/modern/tests/firePointerEvent.js +35 -0
- package/package.json +4 -4
- package/tests/firePointerEvent.js +42 -0
- package/context/CartesianProvider/normalizeAxis.d.ts +0 -5
- package/context/CartesianProvider/normalizeAxis.js +0 -23
- package/esm/context/CartesianProvider/normalizeAxis.js +0 -15
- package/modern/context/CartesianProvider/normalizeAxis.js +0 -15
|
@@ -1,21 +1,20 @@
|
|
|
1
|
-
const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis, formattedSeries) => {
|
|
1
|
+
const axisExtremumCallback = (acc, chartType, axis, getters, isDefaultAxis, formattedSeries, getFilters) => {
|
|
2
2
|
const getter = getters[chartType];
|
|
3
3
|
const series = formattedSeries[chartType]?.series ?? {};
|
|
4
4
|
const [minChartTypeData, maxChartTypeData] = getter?.({
|
|
5
5
|
series,
|
|
6
6
|
axis,
|
|
7
|
-
isDefaultAxis
|
|
8
|
-
|
|
7
|
+
isDefaultAxis,
|
|
8
|
+
getFilters
|
|
9
|
+
}) ?? [Infinity, -Infinity];
|
|
9
10
|
const [minData, maxData] = acc;
|
|
10
|
-
if (minData === null || maxData === null) {
|
|
11
|
-
return [minChartTypeData, maxChartTypeData];
|
|
12
|
-
}
|
|
13
|
-
if (minChartTypeData === null || maxChartTypeData === null) {
|
|
14
|
-
return [minData, maxData];
|
|
15
|
-
}
|
|
16
11
|
return [Math.min(minChartTypeData, minData), Math.max(maxChartTypeData, maxData)];
|
|
17
12
|
};
|
|
18
|
-
export const getAxisExtremum = (axis, getters, isDefaultAxis, formattedSeries) => {
|
|
13
|
+
export const getAxisExtremum = (axis, getters, isDefaultAxis, formattedSeries, getFilters) => {
|
|
19
14
|
const charTypes = Object.keys(getters);
|
|
20
|
-
|
|
15
|
+
const extremums = charTypes.reduce((acc, charType) => axisExtremumCallback(acc, charType, axis, getters, isDefaultAxis, formattedSeries, getFilters), [Infinity, -Infinity]);
|
|
16
|
+
if (Number.isNaN(extremums[0]) || Number.isNaN(extremums[1])) {
|
|
17
|
+
return [Infinity, -Infinity];
|
|
18
|
+
}
|
|
19
|
+
return extremums;
|
|
21
20
|
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies the zoom into the scale range.
|
|
3
|
+
* It changes the screen coordinates that the scale covers.
|
|
4
|
+
* Not the data that is displayed.
|
|
5
|
+
*
|
|
6
|
+
* @param scaleRange the original range in real screen coordinates.
|
|
7
|
+
* @param zoomRange the zoom range in percentage.
|
|
8
|
+
* @returns zoomed range in real screen coordinates.
|
|
9
|
+
*/
|
|
10
|
+
export const zoomScaleRange = (scaleRange, zoomRange) => {
|
|
11
|
+
const rangeGap = scaleRange[1] - scaleRange[0];
|
|
12
|
+
const zoomGap = zoomRange[1] - zoomRange[0];
|
|
13
|
+
|
|
14
|
+
// If current zoom show the scale between p1 and p2 percents
|
|
15
|
+
// The range should be extended by adding [0, p1] and [p2, 100] segments
|
|
16
|
+
const min = scaleRange[0] - zoomRange[0] * rangeGap / zoomGap;
|
|
17
|
+
const max = scaleRange[1] + (100 - zoomRange[1]) * rangeGap / zoomGap;
|
|
18
|
+
return [min, max];
|
|
19
|
+
};
|
|
@@ -42,12 +42,20 @@ export function DrawingProvider(props) {
|
|
|
42
42
|
const isPointInside = React.useCallback(({
|
|
43
43
|
x,
|
|
44
44
|
y
|
|
45
|
-
},
|
|
45
|
+
}, options) => {
|
|
46
46
|
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
47
|
-
if (targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
47
|
+
if (options?.targetElement && options?.targetElement.closest('[data-drawing-container]')) {
|
|
48
48
|
return true;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
const isInsideX = x >= drawingArea.left - 1 && x <= drawingArea.left + drawingArea.width;
|
|
51
|
+
const isInsideY = y >= drawingArea.top - 1 && y <= drawingArea.top + drawingArea.height;
|
|
52
|
+
if (options?.direction === 'x') {
|
|
53
|
+
return isInsideX;
|
|
54
|
+
}
|
|
55
|
+
if (options?.direction === 'y') {
|
|
56
|
+
return isInsideY;
|
|
57
|
+
}
|
|
58
|
+
return isInsideX && isInsideY;
|
|
51
59
|
}, [drawingArea]);
|
|
52
60
|
const value = React.useMemo(() => _extends({
|
|
53
61
|
chartId: chartId ?? ''
|
|
@@ -98,7 +98,9 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
98
98
|
const svgPoint = getSVGPoint(element, target);
|
|
99
99
|
mousePosition.current.x = svgPoint.x;
|
|
100
100
|
mousePosition.current.y = svgPoint.y;
|
|
101
|
-
if (!drawingArea.isPointInside(svgPoint,
|
|
101
|
+
if (!drawingArea.isPointInside(svgPoint, {
|
|
102
|
+
targetElement: event.target
|
|
103
|
+
})) {
|
|
102
104
|
if (mousePosition.current.isInChart) {
|
|
103
105
|
dispatch({
|
|
104
106
|
type: 'exitChart'
|
package/modern/hooks/useTicks.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { isBandScale } from '../internals/isBandScale';
|
|
3
|
+
import { isInfinity } from '../internals/isInfinity';
|
|
3
4
|
export function getTickNumber(params) {
|
|
4
5
|
const {
|
|
5
6
|
tickMaxStep,
|
|
@@ -60,8 +61,10 @@ export function useTicks(options) {
|
|
|
60
61
|
labelOffset: 0
|
|
61
62
|
}));
|
|
62
63
|
}
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
const domain = scale.domain();
|
|
65
|
+
// Skip axis rendering if no data is available
|
|
66
|
+
// - The domains contains Infinity for continuous scales.
|
|
67
|
+
if (domain.some(isInfinity)) {
|
|
65
68
|
return [];
|
|
66
69
|
}
|
|
67
70
|
const ticks = typeof tickInterval === 'object' ? tickInterval : scale.ticks(tickNumber);
|
package/modern/index.js
CHANGED
|
@@ -20,7 +20,7 @@ const SPAN_STYLE = {
|
|
|
20
20
|
whiteSpace: 'pre'
|
|
21
21
|
};
|
|
22
22
|
const STYLE_LIST = ['minWidth', 'maxWidth', 'width', 'minHeight', 'maxHeight', 'height', 'top', 'left', 'fontSize', 'padding', 'margin', 'paddingLeft', 'paddingRight', 'paddingTop', 'paddingBottom', 'marginLeft', 'marginRight', 'marginTop', 'marginBottom'];
|
|
23
|
-
const MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
23
|
+
export const MEASUREMENT_SPAN_ID = 'mui_measurement_span';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
*
|
|
@@ -57,7 +57,7 @@ function camelToMiddleLine(text) {
|
|
|
57
57
|
* @returns CSS styling string
|
|
58
58
|
*/
|
|
59
59
|
export const getStyleString = style => Object.keys(style).sort().reduce((result, s) => `${result}${camelToMiddleLine(s)}:${autoCompleteStyle(s, style[s])};`, '');
|
|
60
|
-
|
|
60
|
+
let domCleanTimeout;
|
|
61
61
|
/**
|
|
62
62
|
*
|
|
63
63
|
* @param text The string to estimate
|
|
@@ -105,6 +105,13 @@ export const getStringSize = (text, style = {}) => {
|
|
|
105
105
|
} else {
|
|
106
106
|
stringCache.cacheCount += 1;
|
|
107
107
|
}
|
|
108
|
+
if (domCleanTimeout) {
|
|
109
|
+
clearTimeout(domCleanTimeout);
|
|
110
|
+
}
|
|
111
|
+
domCleanTimeout = setTimeout(() => {
|
|
112
|
+
// Limit node cleaning to once per render cycle
|
|
113
|
+
measurementSpan.textContent = '';
|
|
114
|
+
}, 0);
|
|
108
115
|
return result;
|
|
109
116
|
} catch (e) {
|
|
110
117
|
return {
|
|
@@ -112,4 +119,10 @@ export const getStringSize = (text, style = {}) => {
|
|
|
112
119
|
height: 0
|
|
113
120
|
};
|
|
114
121
|
}
|
|
115
|
-
};
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
125
|
+
export function unstable_cleanupDOM() {
|
|
126
|
+
// const measurementSpan = document.getElementById(MEASUREMENT_SPAN_ID);
|
|
127
|
+
// measurementSpan?.remove();
|
|
128
|
+
}
|
|
@@ -20,6 +20,7 @@ export * from './configInit';
|
|
|
20
20
|
export * from './getLabel';
|
|
21
21
|
export * from './getSVGPoint';
|
|
22
22
|
export * from './isDefined';
|
|
23
|
+
export { unstable_cleanupDOM } from './domUtils';
|
|
23
24
|
|
|
24
25
|
// contexts
|
|
25
26
|
|
|
@@ -29,6 +30,8 @@ export * from '../context/InteractionProvider';
|
|
|
29
30
|
export * from '../context/SeriesProvider';
|
|
30
31
|
export * from '../context/ZAxisContextProvider';
|
|
31
32
|
export * from '../context/PluginProvider';
|
|
33
|
+
export { getAxisExtremum } from '../context/CartesianProvider/getAxisExtremum';
|
|
34
|
+
|
|
32
35
|
// series configuration
|
|
33
36
|
export * from '../models/seriesType/config';
|
|
34
37
|
export * from '../models/seriesType/common';
|
package/modern/models/axis.js
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { fireEvent } from '@mui/internal-test-utils';
|
|
3
|
+
export function firePointerEvent(target, type, options) {
|
|
4
|
+
const originalGetBoundingClientRect = target.getBoundingClientRect;
|
|
5
|
+
target.getBoundingClientRect = () => ({
|
|
6
|
+
x: 0,
|
|
7
|
+
y: 0,
|
|
8
|
+
bottom: 0,
|
|
9
|
+
height: 0,
|
|
10
|
+
left: 0,
|
|
11
|
+
right: 0,
|
|
12
|
+
top: 0,
|
|
13
|
+
width: 0,
|
|
14
|
+
toJSON() {
|
|
15
|
+
return {
|
|
16
|
+
x: 0,
|
|
17
|
+
y: 0,
|
|
18
|
+
bottom: 0,
|
|
19
|
+
height: 0,
|
|
20
|
+
left: 0,
|
|
21
|
+
right: 0,
|
|
22
|
+
top: 0,
|
|
23
|
+
width: 0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
const event = new window.PointerEvent(type, _extends({
|
|
28
|
+
bubbles: true,
|
|
29
|
+
cancelable: true,
|
|
30
|
+
composed: true,
|
|
31
|
+
isPrimary: true
|
|
32
|
+
}, options));
|
|
33
|
+
fireEvent(target, event);
|
|
34
|
+
target.getBoundingClientRect = originalGetBoundingClientRect;
|
|
35
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.14.0",
|
|
4
4
|
"description": "The community edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -30,13 +30,13 @@
|
|
|
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-vendor": "7.
|
|
39
|
+
"@mui/x-charts-vendor": "7.14.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@emotion/react": "^11.9.0",
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.firePointerEvent = firePointerEvent;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _internalTestUtils = require("@mui/internal-test-utils");
|
|
10
|
+
function firePointerEvent(target, type, options) {
|
|
11
|
+
const originalGetBoundingClientRect = target.getBoundingClientRect;
|
|
12
|
+
target.getBoundingClientRect = () => ({
|
|
13
|
+
x: 0,
|
|
14
|
+
y: 0,
|
|
15
|
+
bottom: 0,
|
|
16
|
+
height: 0,
|
|
17
|
+
left: 0,
|
|
18
|
+
right: 0,
|
|
19
|
+
top: 0,
|
|
20
|
+
width: 0,
|
|
21
|
+
toJSON() {
|
|
22
|
+
return {
|
|
23
|
+
x: 0,
|
|
24
|
+
y: 0,
|
|
25
|
+
bottom: 0,
|
|
26
|
+
height: 0,
|
|
27
|
+
left: 0,
|
|
28
|
+
right: 0,
|
|
29
|
+
top: 0,
|
|
30
|
+
width: 0
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
const event = new window.PointerEvent(type, (0, _extends2.default)({
|
|
35
|
+
bubbles: true,
|
|
36
|
+
cancelable: true,
|
|
37
|
+
composed: true,
|
|
38
|
+
isPrimary: true
|
|
39
|
+
}, options));
|
|
40
|
+
(0, _internalTestUtils.fireEvent)(target, event);
|
|
41
|
+
target.getBoundingClientRect = originalGetBoundingClientRect;
|
|
42
|
+
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { AxisConfig, ScaleName } from '../../models';
|
|
2
|
-
import { ChartsAxisProps } from '../../models/axis';
|
|
3
|
-
import { MakeOptional } from '../../models/helpers';
|
|
4
|
-
import { DatasetType } from '../../models/seriesType/config';
|
|
5
|
-
export declare const normalizeAxis: <T extends ChartsAxisProps, R extends MakeOptional<AxisConfig<ScaleName, any, T>, "id">>(axis: R[] | undefined, dataset: DatasetType | undefined, axisName: "x" | "y") => R[];
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
Object.defineProperty(exports, "__esModule", {
|
|
5
|
-
value: true
|
|
6
|
-
});
|
|
7
|
-
exports.normalizeAxis = void 0;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
const normalizeAxis = (axis, dataset, axisName) => {
|
|
10
|
-
return axis?.map(axisConfig => {
|
|
11
|
-
const dataKey = axisConfig.dataKey;
|
|
12
|
-
if (dataKey === undefined || axisConfig.data !== undefined) {
|
|
13
|
-
return axisConfig;
|
|
14
|
-
}
|
|
15
|
-
if (dataset === undefined) {
|
|
16
|
-
throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
17
|
-
}
|
|
18
|
-
return (0, _extends2.default)({}, axisConfig, {
|
|
19
|
-
data: dataset.map(d => d[dataKey])
|
|
20
|
-
});
|
|
21
|
-
}) ?? [];
|
|
22
|
-
};
|
|
23
|
-
exports.normalizeAxis = normalizeAxis;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
export const normalizeAxis = (axis, dataset, axisName) => {
|
|
3
|
-
return axis?.map(axisConfig => {
|
|
4
|
-
const dataKey = axisConfig.dataKey;
|
|
5
|
-
if (dataKey === undefined || axisConfig.data !== undefined) {
|
|
6
|
-
return axisConfig;
|
|
7
|
-
}
|
|
8
|
-
if (dataset === undefined) {
|
|
9
|
-
throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
10
|
-
}
|
|
11
|
-
return _extends({}, axisConfig, {
|
|
12
|
-
data: dataset.map(d => d[dataKey])
|
|
13
|
-
});
|
|
14
|
-
}) ?? [];
|
|
15
|
-
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
export const normalizeAxis = (axis, dataset, axisName) => {
|
|
3
|
-
return axis?.map(axisConfig => {
|
|
4
|
-
const dataKey = axisConfig.dataKey;
|
|
5
|
-
if (dataKey === undefined || axisConfig.data !== undefined) {
|
|
6
|
-
return axisConfig;
|
|
7
|
-
}
|
|
8
|
-
if (dataset === undefined) {
|
|
9
|
-
throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
10
|
-
}
|
|
11
|
-
return _extends({}, axisConfig, {
|
|
12
|
-
data: dataset.map(d => d[dataKey])
|
|
13
|
-
});
|
|
14
|
-
}) ?? [];
|
|
15
|
-
};
|