@mui/x-charts 7.11.0 → 7.11.1
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/BarElement.d.ts +2 -1
- package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
- package/BarChart/BarPlot.js +8 -8
- package/BarChart/checkScaleErrors.d.ts +4 -4
- package/BarChart/checkScaleErrors.js +11 -11
- package/BarChart/extremums.js +4 -1
- package/BarChart/formatter.js +2 -2
- package/CHANGELOG.md +84 -0
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -2
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaPlot.js +10 -6
- package/LineChart/LineChart.js +4 -1
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineHighlightPlot.d.ts +2 -1
- package/LineChart/LineHighlightPlot.js +9 -5
- package/LineChart/LinePlot.js +10 -6
- package/LineChart/MarkPlot.js +9 -5
- package/LineChart/extremums.js +4 -1
- package/LineChart/formatter.js +2 -2
- package/PieChart/PieArc.js +1 -0
- package/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
- package/ScatterChart/ScatterChart.js +4 -1
- package/ScatterChart/ScatterPlot.js +6 -3
- package/ScatterChart/extremums.js +8 -2
- package/context/CartesianProvider/CartesianContext.d.ts +1 -1
- package/context/CartesianProvider/normalizeAxis.js +1 -1
- package/context/DrawingProvider.d.ts +2 -1
- package/context/DrawingProvider.js +7 -1
- package/context/SeriesContextProvider.js +1 -1
- package/context/ZAxisContextProvider.d.ts +1 -1
- package/context/ZAxisContextProvider.js +1 -1
- package/esm/BarChart/BarPlot.js +8 -8
- package/esm/BarChart/checkScaleErrors.js +11 -11
- package/esm/BarChart/extremums.js +4 -1
- package/esm/BarChart/formatter.js +2 -2
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/esm/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
- package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -2
- package/esm/LineChart/AreaPlot.js +10 -6
- package/esm/LineChart/LineChart.js +4 -1
- package/esm/LineChart/LineHighlightPlot.js +9 -5
- package/esm/LineChart/LinePlot.js +10 -6
- package/esm/LineChart/MarkPlot.js +9 -5
- package/esm/LineChart/extremums.js +4 -1
- package/esm/LineChart/formatter.js +2 -2
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
- package/esm/ScatterChart/ScatterChart.js +4 -1
- package/esm/ScatterChart/ScatterPlot.js +6 -3
- package/esm/ScatterChart/extremums.js +8 -2
- package/esm/context/CartesianProvider/normalizeAxis.js +1 -1
- package/esm/context/DrawingProvider.js +7 -1
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/context/ZAxisContextProvider.js +1 -1
- package/esm/hooks/useAxisEvents.js +12 -8
- package/esm/internals/SlotComponentPropsFromProps.js +1 -0
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/getPercentageValue.js +1 -1
- package/esm/internals/warning.js +19 -11
- package/hooks/useAxisEvents.js +12 -8
- package/index.js +1 -1
- package/internals/SlotComponentPropsFromProps.d.ts +1 -0
- package/internals/SlotComponentPropsFromProps.js +5 -0
- package/internals/defaultizeColor.d.ts +7 -0
- package/internals/geometry.js +1 -1
- package/internals/getPercentageValue.js +1 -1
- package/internals/warning.d.ts +2 -1
- package/internals/warning.js +21 -12
- package/models/seriesType/common.d.ts +10 -0
- package/models/seriesType/scatter.d.ts +5 -0
- package/modern/BarChart/BarPlot.js +8 -8
- package/modern/BarChart/checkScaleErrors.js +11 -11
- package/modern/BarChart/extremums.js +4 -1
- package/modern/BarChart/formatter.js +2 -2
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/modern/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/modern/ChartsReferenceLine/ChartsXReferenceLine.js +2 -3
- package/modern/ChartsReferenceLine/ChartsYReferenceLine.js +2 -3
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +4 -2
- package/modern/LineChart/AreaPlot.js +10 -6
- package/modern/LineChart/LineChart.js +4 -1
- package/modern/LineChart/LineHighlightPlot.js +9 -5
- package/modern/LineChart/LinePlot.js +10 -6
- package/modern/LineChart/MarkPlot.js +9 -5
- package/modern/LineChart/extremums.js +4 -1
- package/modern/LineChart/formatter.js +2 -2
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
- package/modern/ScatterChart/ScatterChart.js +4 -1
- package/modern/ScatterChart/ScatterPlot.js +6 -3
- package/modern/ScatterChart/extremums.js +8 -2
- package/modern/context/CartesianProvider/normalizeAxis.js +1 -1
- package/modern/context/DrawingProvider.js +7 -1
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/hooks/useAxisEvents.js +12 -8
- package/modern/index.js +1 -1
- package/modern/internals/SlotComponentPropsFromProps.js +1 -0
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/getPercentageValue.js +1 -1
- package/modern/internals/warning.js +19 -11
- package/package.json +3 -3
|
@@ -5,7 +5,7 @@ import { useDrawingArea, useXScale } from '../hooks';
|
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
6
|
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
-
import {
|
|
8
|
+
import { warnOnce } from '../internals/warning';
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const getTextParams = ({
|
|
11
11
|
top,
|
|
@@ -47,7 +47,6 @@ export function getXReferenceLineClasses(classes) {
|
|
|
47
47
|
label: ['label']
|
|
48
48
|
}, getReferenceLineUtilityClass, classes);
|
|
49
49
|
}
|
|
50
|
-
const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of x axis with id ${id}.`, 'error');
|
|
51
50
|
function ChartsXReferenceLine(props) {
|
|
52
51
|
const {
|
|
53
52
|
x,
|
|
@@ -67,7 +66,7 @@ function ChartsXReferenceLine(props) {
|
|
|
67
66
|
const xPosition = xAxisScale(x);
|
|
68
67
|
if (xPosition === undefined) {
|
|
69
68
|
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
-
|
|
69
|
+
warnOnce(`MUI X: the value ${x} does not exist in the data of x axis with id ${axisId}.`, 'error');
|
|
71
70
|
}
|
|
72
71
|
return null;
|
|
73
72
|
}
|
|
@@ -5,7 +5,7 @@ import { useDrawingArea, useYScale } from '../hooks';
|
|
|
5
5
|
import { ReferenceLineRoot } from './common';
|
|
6
6
|
import { ChartsText } from '../ChartsText';
|
|
7
7
|
import { getReferenceLineUtilityClass } from './chartsReferenceLineClasses';
|
|
8
|
-
import {
|
|
8
|
+
import { warnOnce } from '../internals/warning';
|
|
9
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
10
|
const getTextParams = ({
|
|
11
11
|
left,
|
|
@@ -47,7 +47,6 @@ export function getYReferenceLineClasses(classes) {
|
|
|
47
47
|
label: ['label']
|
|
48
48
|
}, getReferenceLineUtilityClass, classes);
|
|
49
49
|
}
|
|
50
|
-
const valueError = buildWarning((value, id) => `MUI X Charts: the value ${value} does not exist in the data of y axis with id ${id}.`, 'error');
|
|
51
50
|
function ChartsYReferenceLine(props) {
|
|
52
51
|
const {
|
|
53
52
|
y,
|
|
@@ -67,7 +66,7 @@ function ChartsYReferenceLine(props) {
|
|
|
67
66
|
const yPosition = yAxisScale(y);
|
|
68
67
|
if (yPosition === undefined) {
|
|
69
68
|
if (process.env.NODE_ENV !== 'production') {
|
|
70
|
-
|
|
69
|
+
warnOnce(`MUI X: the value ${y} does not exist in the data of y axis with id ${axisId}.`, 'error');
|
|
71
70
|
}
|
|
72
71
|
return null;
|
|
73
72
|
}
|
|
@@ -40,11 +40,15 @@ function ChartsAxisTooltipContent(props) {
|
|
|
40
40
|
Object.keys(series).filter(isCartesianSeriesType).forEach(seriesType => {
|
|
41
41
|
series[seriesType].seriesOrder.forEach(seriesId => {
|
|
42
42
|
const item = series[seriesType].series[seriesId];
|
|
43
|
-
const
|
|
43
|
+
const providedXAxisId = item.xAxisId ?? item.xAxisKey;
|
|
44
|
+
const providedYAxisId = item.yAxisId ?? item.yAxisKey;
|
|
45
|
+
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
44
46
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
45
47
|
const seriesToAdd = series[seriesType].series[seriesId];
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
+
const xAxisId = providedXAxisId ?? xAxisIds[0];
|
|
49
|
+
const yAxisId = providedYAxisId ?? yAxisIds[0];
|
|
50
|
+
const zAxisId = seriesToAdd.zAxisId ?? seriesToAdd.zAxisKey ?? zAxisIds[0];
|
|
51
|
+
const getColor = colorProcessors[seriesType]?.(seriesToAdd, xAxis[xAxisId], yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
48
52
|
rep.push(_extends({}, seriesToAdd, {
|
|
49
53
|
getColor
|
|
50
54
|
}));
|
|
@@ -30,10 +30,10 @@ function ChartsItemTooltipContent(props) {
|
|
|
30
30
|
zAxisIds
|
|
31
31
|
} = React.useContext(ZAxisContext);
|
|
32
32
|
const colorProcessors = useColorProcessor();
|
|
33
|
-
const
|
|
34
|
-
const
|
|
35
|
-
const
|
|
36
|
-
const getColor = colorProcessors[series.type]?.(series,
|
|
33
|
+
const xAxisId = series.xAxisId ?? series.xAxisKey ?? xAxisIds[0];
|
|
34
|
+
const yAxisId = series.yAxisId ?? series.yAxisKey ?? yAxisIds[0];
|
|
35
|
+
const zAxisId = series.zAxisId ?? series.zAxisKey ?? zAxisIds[0];
|
|
36
|
+
const getColor = colorProcessors[series.type]?.(series, xAxisId && xAxis[xAxisId], yAxisId && yAxis[yAxisId], zAxisId && zAxis[zAxisId]) ?? (() => '');
|
|
37
37
|
const Content = content ?? DefaultChartsItemTooltipContent;
|
|
38
38
|
const chartTooltipContentProps = useSlotProps({
|
|
39
39
|
elementType: Content,
|
|
@@ -63,11 +63,13 @@ function ChartsVoronoiHandler(props) {
|
|
|
63
63
|
seriesOrder.forEach(seriesId => {
|
|
64
64
|
const {
|
|
65
65
|
data,
|
|
66
|
+
xAxisId,
|
|
67
|
+
yAxisId,
|
|
66
68
|
xAxisKey,
|
|
67
69
|
yAxisKey
|
|
68
70
|
} = series[seriesId];
|
|
69
|
-
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
70
|
-
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
71
|
+
const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
|
|
72
|
+
const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
|
|
71
73
|
const getXPosition = getValueToPositionMapper(xScale);
|
|
72
74
|
const getYPosition = getValueToPositionMapper(yScale);
|
|
73
75
|
const seriesPoints = data.flatMap(({
|
|
@@ -36,22 +36,26 @@ const useAggregatedData = () => {
|
|
|
36
36
|
return [...groupIds].reverse() // Revert stacked area for a more pleasant animation
|
|
37
37
|
.map(seriesId => {
|
|
38
38
|
const {
|
|
39
|
+
xAxisId: xAxisIdProp,
|
|
40
|
+
yAxisId: yAxisIdProp,
|
|
39
41
|
xAxisKey = defaultXAxisId,
|
|
40
42
|
yAxisKey = defaultYAxisId,
|
|
41
43
|
stackedData,
|
|
42
44
|
data,
|
|
43
45
|
connectNulls
|
|
44
46
|
} = series[seriesId];
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
47
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
48
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
49
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
50
|
+
const yScale = yAxis[yAxisId].scale;
|
|
51
|
+
const xData = xAxis[xAxisId].data;
|
|
52
|
+
const gradientUsed = yAxis[yAxisId].colorScale && [yAxisId, 'y'] || xAxis[xAxisId].colorScale && [xAxisId, 'x'] || undefined;
|
|
49
53
|
if (process.env.NODE_ENV !== 'production') {
|
|
50
54
|
if (xData === undefined) {
|
|
51
|
-
throw new Error(`MUI X
|
|
55
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
52
56
|
}
|
|
53
57
|
if (xData.length < stackedData.length) {
|
|
54
|
-
throw new Error(`MUI X
|
|
58
|
+
throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
55
59
|
}
|
|
56
60
|
}
|
|
57
61
|
const areaPath = d3Area().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y0(d => {
|
|
@@ -49,7 +49,10 @@ const LineChart = /*#__PURE__*/React.forwardRef(function LineChart(props, ref) {
|
|
|
49
49
|
}, chartContainerProps, {
|
|
50
50
|
children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
51
51
|
children: [/*#__PURE__*/_jsx(AreaPlot, _extends({}, areaPlotProps)), /*#__PURE__*/_jsx(LinePlot, _extends({}, linePlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
52
|
-
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(
|
|
52
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx("g", {
|
|
53
|
+
"data-drawing-container": true,
|
|
54
|
+
children: /*#__PURE__*/_jsx(MarkPlot, _extends({}, markPlotProps))
|
|
55
|
+
}), /*#__PURE__*/_jsx(LineHighlightPlot, _extends({}, lineHighlightPlotProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
53
56
|
}));
|
|
54
57
|
});
|
|
55
58
|
process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
@@ -60,20 +60,24 @@ function LineHighlightPlot(props) {
|
|
|
60
60
|
}) => {
|
|
61
61
|
return groupIds.flatMap(seriesId => {
|
|
62
62
|
const {
|
|
63
|
+
xAxisId: xAxisIdProp,
|
|
64
|
+
yAxisId: yAxisIdProp,
|
|
63
65
|
xAxisKey = defaultXAxisId,
|
|
64
66
|
yAxisKey = defaultYAxisId,
|
|
65
67
|
stackedData,
|
|
66
68
|
data,
|
|
67
69
|
disableHighlight
|
|
68
70
|
} = series[seriesId];
|
|
71
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
72
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
69
73
|
if (disableHighlight || data[highlightedIndex] == null) {
|
|
70
74
|
return null;
|
|
71
75
|
}
|
|
72
|
-
const xScale = getValueToPositionMapper(xAxis[
|
|
73
|
-
const yScale = yAxis[
|
|
74
|
-
const xData = xAxis[
|
|
76
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
77
|
+
const yScale = yAxis[yAxisId].scale;
|
|
78
|
+
const xData = xAxis[xAxisId].data;
|
|
75
79
|
if (xData === undefined) {
|
|
76
|
-
throw new Error(`MUI X
|
|
80
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
77
81
|
}
|
|
78
82
|
const x = xScale(xData[highlightedIndex]);
|
|
79
83
|
const y = yScale(stackedData[highlightedIndex][1]); // This should not be undefined since y should not be a band scale
|
|
@@ -84,7 +88,7 @@ function LineHighlightPlot(props) {
|
|
|
84
88
|
})) {
|
|
85
89
|
return null;
|
|
86
90
|
}
|
|
87
|
-
const colorGetter = getColor(series[seriesId], xAxis[
|
|
91
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
|
|
88
92
|
return /*#__PURE__*/_jsx(Element, _extends({
|
|
89
93
|
id: seriesId,
|
|
90
94
|
color: colorGetter(highlightedIndex),
|
|
@@ -35,22 +35,26 @@ const useAggregatedData = () => {
|
|
|
35
35
|
}) => {
|
|
36
36
|
return groupIds.flatMap(seriesId => {
|
|
37
37
|
const {
|
|
38
|
+
xAxisId: xAxisIdProp,
|
|
39
|
+
yAxisId: yAxisIdProp,
|
|
38
40
|
xAxisKey = defaultXAxisId,
|
|
39
41
|
yAxisKey = defaultYAxisId,
|
|
40
42
|
stackedData,
|
|
41
43
|
data,
|
|
42
44
|
connectNulls
|
|
43
45
|
} = series[seriesId];
|
|
44
|
-
const
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
46
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
47
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
48
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
49
|
+
const yScale = yAxis[yAxisId].scale;
|
|
50
|
+
const xData = xAxis[xAxisId].data;
|
|
51
|
+
const gradientUsed = yAxis[yAxisId].colorScale && [yAxisId, 'y'] || xAxis[xAxisId].colorScale && [xAxisId, 'x'] || undefined;
|
|
48
52
|
if (process.env.NODE_ENV !== 'production') {
|
|
49
53
|
if (xData === undefined) {
|
|
50
|
-
throw new Error(`MUI X
|
|
54
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
51
55
|
}
|
|
52
56
|
if (xData.length < stackedData.length) {
|
|
53
|
-
throw new Error(`MUI X
|
|
57
|
+
throw new Error(`MUI X: The data length of the x axis (${xData.length} items) is lower than the length of series (${stackedData.length} items).`);
|
|
54
58
|
}
|
|
55
59
|
}
|
|
56
60
|
const linePath = d3Line().x(d => xScale(d.x)).defined((_, i) => connectNulls || data[i] != null).y(d => yScale(d.y[1]));
|
|
@@ -57,6 +57,8 @@ function MarkPlot(props) {
|
|
|
57
57
|
}) => {
|
|
58
58
|
return groupIds.map(seriesId => {
|
|
59
59
|
const {
|
|
60
|
+
xAxisId: xAxisIdProp,
|
|
61
|
+
yAxisId: yAxisIdProp,
|
|
60
62
|
xAxisKey = defaultXAxisId,
|
|
61
63
|
yAxisKey = defaultYAxisId,
|
|
62
64
|
stackedData,
|
|
@@ -66,15 +68,17 @@ function MarkPlot(props) {
|
|
|
66
68
|
if (showMark === false) {
|
|
67
69
|
return null;
|
|
68
70
|
}
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const
|
|
71
|
+
const xAxisId = xAxisIdProp ?? xAxisKey;
|
|
72
|
+
const yAxisId = yAxisIdProp ?? yAxisKey;
|
|
73
|
+
const xScale = getValueToPositionMapper(xAxis[xAxisId].scale);
|
|
74
|
+
const yScale = yAxis[yAxisId].scale;
|
|
75
|
+
const xData = xAxis[xAxisId].data;
|
|
72
76
|
if (xData === undefined) {
|
|
73
|
-
throw new Error(`MUI X
|
|
77
|
+
throw new Error(`MUI X: ${xAxisId === DEFAULT_X_AXIS_KEY ? 'The first `xAxis`' : `The x-axis with id "${xAxisId}"`} should have data property to be able to display a line plot.`);
|
|
74
78
|
}
|
|
75
79
|
const clipId = cleanId(`${chartId}-${seriesId}-line-clip`); // We assume that if displaying line mark, the line will also be rendered
|
|
76
80
|
|
|
77
|
-
const colorGetter = getColor(series[seriesId], xAxis[
|
|
81
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
|
|
78
82
|
return /*#__PURE__*/_jsx("g", {
|
|
79
83
|
clipPath: `url(#${clipId})`,
|
|
80
84
|
children: xData?.map((x, index) => {
|
|
@@ -24,7 +24,10 @@ export const getExtremumY = params => {
|
|
|
24
24
|
axis,
|
|
25
25
|
isDefaultAxis
|
|
26
26
|
} = params;
|
|
27
|
-
return Object.keys(series).filter(seriesId =>
|
|
27
|
+
return Object.keys(series).filter(seriesId => {
|
|
28
|
+
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
|
|
29
|
+
return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
|
|
30
|
+
}).reduce((acc, seriesId) => {
|
|
28
31
|
const {
|
|
29
32
|
area,
|
|
30
33
|
stackedData
|
|
@@ -31,7 +31,7 @@ const formatter = (params, dataset) => {
|
|
|
31
31
|
}
|
|
32
32
|
});
|
|
33
33
|
} else if (dataset === undefined && process.env.NODE_ENV !== 'production') {
|
|
34
|
-
throw new Error([`MUI X
|
|
34
|
+
throw new Error([`MUI X: line series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
35
35
|
}
|
|
36
36
|
});
|
|
37
37
|
const completedSeries = {};
|
|
@@ -56,7 +56,7 @@ const formatter = (params, dataset) => {
|
|
|
56
56
|
if (typeof value !== 'number') {
|
|
57
57
|
if (process.env.NODE_ENV !== 'production' && !warnedOnce && value !== null) {
|
|
58
58
|
warnedOnce = true;
|
|
59
|
-
console.error([`MUI X
|
|
59
|
+
console.error([`MUI X: Your dataset key "${dataKey}" is used for plotting line, but contains nonnumerical elements.`, 'Line plots only support numbers and null values.']);
|
|
60
60
|
}
|
|
61
61
|
return null;
|
|
62
62
|
}
|
|
@@ -54,11 +54,11 @@ export const useChartContainerDimensions = (inWidth, inHeight) => {
|
|
|
54
54
|
}, [computeSize, inHeight, inWidth]);
|
|
55
55
|
if (process.env.NODE_ENV !== 'production') {
|
|
56
56
|
if (displayError.current && inWidth === undefined && width === 0) {
|
|
57
|
-
console.error(`MUI X
|
|
57
|
+
console.error(`MUI X: ChartContainer does not have \`width\` prop, and its container has no \`width\` defined.`);
|
|
58
58
|
displayError.current = false;
|
|
59
59
|
}
|
|
60
60
|
if (displayError.current && inHeight === undefined && height === 0) {
|
|
61
|
-
console.error(`MUI X
|
|
61
|
+
console.error(`MUI X: ChartContainer does not have \`height\` prop, and its container has no \`height\` defined.`);
|
|
62
62
|
displayError.current = false;
|
|
63
63
|
}
|
|
64
64
|
}
|
|
@@ -41,7 +41,10 @@ const ScatterChart = /*#__PURE__*/React.forwardRef(function ScatterChart(props,
|
|
|
41
41
|
ref: ref
|
|
42
42
|
}, chartContainerProps, {
|
|
43
43
|
children: /*#__PURE__*/_jsxs(ZAxisContextProvider, _extends({}, zAxisProps, {
|
|
44
|
-
children: [!props.disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, _extends({}, voronoiHandlerProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx(
|
|
44
|
+
children: [!props.disableVoronoi && /*#__PURE__*/_jsx(ChartsVoronoiHandler, _extends({}, voronoiHandlerProps)), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsx("g", {
|
|
45
|
+
"data-drawing-container": true,
|
|
46
|
+
children: /*#__PURE__*/_jsx(ScatterPlot, _extends({}, scatterPlotProps))
|
|
47
|
+
}), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), children]
|
|
45
48
|
}))
|
|
46
49
|
}));
|
|
47
50
|
});
|
|
@@ -53,12 +53,15 @@ function ScatterPlot(props) {
|
|
|
53
53
|
xAxisKey,
|
|
54
54
|
yAxisKey,
|
|
55
55
|
zAxisKey,
|
|
56
|
+
xAxisId,
|
|
57
|
+
yAxisId,
|
|
58
|
+
zAxisId,
|
|
56
59
|
markerSize,
|
|
57
60
|
color
|
|
58
61
|
} = series[seriesId];
|
|
59
|
-
const colorGetter = getColor(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
|
|
60
|
-
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
61
|
-
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
62
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId], yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId], zAxis[zAxisId ?? zAxisKey ?? defaultZAxisId]);
|
|
63
|
+
const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
|
|
64
|
+
const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
|
|
62
65
|
return /*#__PURE__*/_jsx(ScatterItems, _extends({
|
|
63
66
|
xScale: xScale,
|
|
64
67
|
yScale: yScale,
|
|
@@ -13,7 +13,10 @@ export const getExtremumX = params => {
|
|
|
13
13
|
axis,
|
|
14
14
|
isDefaultAxis
|
|
15
15
|
} = params;
|
|
16
|
-
return Object.keys(series).filter(seriesId =>
|
|
16
|
+
return Object.keys(series).filter(seriesId => {
|
|
17
|
+
const axisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey;
|
|
18
|
+
return axisId === axis.id || axisId === undefined && isDefaultAxis;
|
|
19
|
+
}).reduce((acc, seriesId) => {
|
|
17
20
|
const seriesMinMax = series[seriesId].data.reduce((accSeries, {
|
|
18
21
|
x
|
|
19
22
|
}) => {
|
|
@@ -29,7 +32,10 @@ export const getExtremumY = params => {
|
|
|
29
32
|
axis,
|
|
30
33
|
isDefaultAxis
|
|
31
34
|
} = params;
|
|
32
|
-
return Object.keys(series).filter(seriesId =>
|
|
35
|
+
return Object.keys(series).filter(seriesId => {
|
|
36
|
+
const axisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
|
|
37
|
+
return axisId === axis.id || axisId === undefined && isDefaultAxis;
|
|
38
|
+
}).reduce((acc, seriesId) => {
|
|
33
39
|
const seriesMinMax = series[seriesId].data.reduce((accSeries, {
|
|
34
40
|
y
|
|
35
41
|
}) => {
|
|
@@ -6,7 +6,7 @@ export const normalizeAxis = (axis, dataset, axisName) => {
|
|
|
6
6
|
return axisConfig;
|
|
7
7
|
}
|
|
8
8
|
if (dataset === undefined) {
|
|
9
|
-
throw Error(`MUI X
|
|
9
|
+
throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
10
10
|
}
|
|
11
11
|
return _extends({}, axisConfig, {
|
|
12
12
|
data: dataset.map(d => d[dataKey])
|
|
@@ -42,7 +42,13 @@ export function DrawingProvider(props) {
|
|
|
42
42
|
const isPointInside = React.useCallback(({
|
|
43
43
|
x,
|
|
44
44
|
y
|
|
45
|
-
}) =>
|
|
45
|
+
}, targetElement) => {
|
|
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]')) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height;
|
|
51
|
+
}, [drawingArea]);
|
|
46
52
|
const value = React.useMemo(() => _extends({
|
|
47
53
|
chartId: chartId ?? ''
|
|
48
54
|
}, drawingArea, {
|
|
@@ -34,7 +34,7 @@ const preprocessSeries = (series, colors, seriesFormatters, dataset) => {
|
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
if (seriesGroups[type]?.series[id] !== undefined) {
|
|
37
|
-
throw new Error(`MUI X
|
|
37
|
+
throw new Error(`MUI X: series' id "${id}" is not unique.`);
|
|
38
38
|
}
|
|
39
39
|
seriesGroups[type].series[id] = _extends({
|
|
40
40
|
id
|
|
@@ -22,7 +22,7 @@ function ZAxisContextProvider(props) {
|
|
|
22
22
|
return axisConfig;
|
|
23
23
|
}
|
|
24
24
|
if (dataset === undefined) {
|
|
25
|
-
throw Error('MUI X
|
|
25
|
+
throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
26
26
|
}
|
|
27
27
|
return _extends({}, axisConfig, {
|
|
28
28
|
data: dataset.map(d => d[dataKey])
|
|
@@ -25,6 +25,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
25
25
|
|
|
26
26
|
// Use a ref to avoid rerendering on every mousemove event.
|
|
27
27
|
const mousePosition = React.useRef({
|
|
28
|
+
isInChart: false,
|
|
28
29
|
x: -1,
|
|
29
30
|
y: -1
|
|
30
31
|
});
|
|
@@ -84,6 +85,7 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
84
85
|
}
|
|
85
86
|
const handleOut = () => {
|
|
86
87
|
mousePosition.current = {
|
|
88
|
+
isInChart: false,
|
|
87
89
|
x: -1,
|
|
88
90
|
y: -1
|
|
89
91
|
};
|
|
@@ -94,16 +96,18 @@ export const useAxisEvents = disableAxisListener => {
|
|
|
94
96
|
const handleMove = event => {
|
|
95
97
|
const target = 'targetTouches' in event ? event.targetTouches[0] : event;
|
|
96
98
|
const svgPoint = getSVGPoint(element, target);
|
|
97
|
-
mousePosition.current =
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
mousePosition.current.x = svgPoint.x;
|
|
100
|
+
mousePosition.current.y = svgPoint.y;
|
|
101
|
+
if (!drawingArea.isPointInside(svgPoint, event.target)) {
|
|
102
|
+
if (mousePosition.current.isInChart) {
|
|
103
|
+
dispatch({
|
|
104
|
+
type: 'exitChart'
|
|
105
|
+
});
|
|
106
|
+
mousePosition.current.isInChart = false;
|
|
107
|
+
}
|
|
105
108
|
return;
|
|
106
109
|
}
|
|
110
|
+
mousePosition.current.isInChart = true;
|
|
107
111
|
const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
|
|
108
112
|
const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
|
|
109
113
|
dispatch({
|
package/modern/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -14,7 +14,7 @@ export function getMinXTranslation(width, height, angle = 0) {
|
|
|
14
14
|
if (process.env.NODE_ENV !== 'production') {
|
|
15
15
|
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
16
16
|
warnedOnce = true;
|
|
17
|
-
console.warn([`MUI X
|
|
17
|
+
console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
@@ -24,5 +24,5 @@ export function getPercentageValue(value, refValue) {
|
|
|
24
24
|
return val;
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
throw Error(`MUI X
|
|
27
|
+
throw Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
|
|
28
28
|
}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
const warnedOnceCache = new Set();
|
|
2
|
+
|
|
3
|
+
// TODO move to @mui/x-internals
|
|
4
|
+
// TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
|
|
5
|
+
export function warnOnce(message, gravity = 'warning') {
|
|
6
|
+
if (process.env.NODE_ENV === 'production') {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
|
|
10
|
+
if (!warnedOnceCache.has(cleanMessage)) {
|
|
11
|
+
warnedOnceCache.add(cleanMessage);
|
|
12
|
+
if (gravity === 'error') {
|
|
13
|
+
console.error(cleanMessage);
|
|
14
|
+
} else {
|
|
15
|
+
console.warn(cleanMessage);
|
|
11
16
|
}
|
|
12
|
-
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export function clearWarningsCache() {
|
|
20
|
+
warnedOnceCache.clear();
|
|
13
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "7.11.
|
|
3
|
+
"version": "7.11.1",
|
|
4
4
|
"description": "The community edition of the Charts components (MUI X).",
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"main": "./index.js",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@babel/runtime": "^7.24.8",
|
|
33
33
|
"@mui/base": "^5.0.0-beta.40",
|
|
34
|
-
"@mui/system": "^5.16.
|
|
35
|
-
"@mui/utils": "^5.16.
|
|
34
|
+
"@mui/system": "^5.16.5",
|
|
35
|
+
"@mui/utils": "^5.16.5",
|
|
36
36
|
"@react-spring/rafz": "^9.7.3",
|
|
37
37
|
"@react-spring/web": "^9.7.3",
|
|
38
38
|
"clsx": "^2.1.1",
|