@mui/x-charts 7.11.0 → 7.12.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 +0 -2
- package/BarChart/BarElement.d.ts +22 -21
- package/BarChart/BarElement.js +3 -3
- package/BarChart/BarLabel/BarLabel.d.ts +20 -20
- package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
- package/BarChart/BarLabel/BarLabelItem.js +2 -2
- 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 +3 -3
- package/CHANGELOG.md +194 -4
- package/ChartContainer/ChartContainer.d.ts +3 -3
- package/ChartContainer/ChartContainer.js +3 -5
- package/ChartContainer/useChartContainerProps.d.ts +50 -52
- package/ChartContainer/useChartContainerProps.js +2 -2
- package/ChartContainer/useDefaultizeAxis.d.ts +24 -25
- package/ChartContainer/usePluginsMerge.d.ts +1 -1
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsLegend/ChartsLegend.js +6 -6
- package/ChartsLegend/DefaultChartsLegend.d.ts +1 -1
- package/ChartsLegend/LegendPerItem.js +2 -2
- package/ChartsLegend/utils.d.ts +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 +9 -5
- package/ChartsTooltip/ChartsItemTooltipContent.js +6 -6
- package/ChartsTooltip/ChartsTooltip.d.ts +1 -1
- package/ChartsTooltip/ChartsTooltip.js +10 -10
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -3
- package/ChartsXAxis/ChartsXAxis.js +5 -5
- package/ChartsYAxis/ChartsYAxis.js +6 -6
- package/Gauge/GaugeReferenceArc.js +1 -1
- package/Gauge/GaugeValueArc.js +1 -1
- package/LineChart/AnimatedArea.d.ts +20 -20
- package/LineChart/AnimatedArea.js +1 -1
- package/LineChart/AnimatedLine.d.ts +20 -20
- package/LineChart/AnimatedLine.js +1 -1
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaElement.js +2 -2
- package/LineChart/AreaPlot.js +11 -7
- package/LineChart/LineChart.js +4 -3
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineElement.js +2 -2
- package/LineChart/LineHighlightPlot.d.ts +2 -1
- package/LineChart/LineHighlightPlot.js +9 -5
- package/LineChart/LinePlot.js +11 -7
- package/LineChart/MarkElement.js +1 -1
- package/LineChart/MarkPlot.js +9 -5
- package/LineChart/extremums.js +4 -1
- package/LineChart/formatter.js +3 -3
- package/PieChart/PieArc.js +2 -1
- package/PieChart/PieArcLabel.js +1 -1
- package/PieChart/PieChart.js +0 -2
- package/PieChart/formatter.js +1 -1
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
- package/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +2 -2
- package/ScatterChart/ScatterChart.js +4 -3
- package/ScatterChart/ScatterPlot.js +6 -3
- package/ScatterChart/extremums.js +8 -2
- package/SparkLineChart/SparkLineChart.js +0 -2
- package/context/CartesianProvider/CartesianContext.d.ts +1 -1
- package/context/CartesianProvider/computeValue.d.ts +1 -1
- package/context/CartesianProvider/computeValue.js +1 -1
- package/context/CartesianProvider/defaultizeAxis.d.ts +24 -25
- package/context/CartesianProvider/getAxisExtremum.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.d.ts → SeriesProvider/Series.types.d.ts} +4 -8
- package/context/SeriesProvider/Series.types.js +5 -0
- package/context/SeriesProvider/SeriesContext.d.ts +4 -0
- package/context/SeriesProvider/SeriesContext.js +16 -0
- package/context/SeriesProvider/SeriesProvider.d.ts +5 -0
- package/context/SeriesProvider/SeriesProvider.js +37 -0
- package/context/SeriesProvider/index.d.ts +12 -0
- package/context/SeriesProvider/index.js +49 -0
- package/context/SeriesProvider/processSeries.d.ts +17 -0
- package/context/SeriesProvider/processSeries.js +55 -0
- package/context/ZAxisContextProvider.d.ts +1 -1
- package/context/ZAxisContextProvider.js +1 -1
- package/esm/BarChart/BarChart.js +0 -2
- package/esm/BarChart/BarElement.js +2 -2
- package/esm/BarChart/BarLabel/BarLabelItem.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 +3 -3
- package/esm/ChartContainer/ChartContainer.js +3 -5
- package/esm/ChartContainer/useChartContainerProps.js +2 -2
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsLegend/LegendPerItem.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 +8 -4
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +5 -5
- package/esm/ChartsTooltip/ChartsTooltip.js +3 -3
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -3
- package/esm/ChartsXAxis/ChartsXAxis.js +2 -2
- package/esm/ChartsYAxis/ChartsYAxis.js +2 -2
- package/esm/Gauge/GaugeReferenceArc.js +1 -1
- package/esm/Gauge/GaugeValueArc.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaElement.js +1 -1
- package/esm/LineChart/AreaPlot.js +11 -7
- package/esm/LineChart/LineChart.js +4 -3
- package/esm/LineChart/LineElement.js +1 -1
- package/esm/LineChart/LineHighlightPlot.js +9 -5
- package/esm/LineChart/LinePlot.js +11 -7
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +9 -5
- package/esm/LineChart/extremums.js +4 -1
- package/esm/LineChart/formatter.js +3 -3
- package/esm/PieChart/PieArc.js +2 -1
- package/esm/PieChart/PieArcLabel.js +1 -1
- package/esm/PieChart/PieChart.js +0 -2
- package/esm/PieChart/formatter.js +1 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
- package/esm/ScatterChart/ScatterChart.js +4 -3
- package/esm/ScatterChart/ScatterPlot.js +6 -3
- package/esm/ScatterChart/extremums.js +8 -2
- package/esm/SparkLineChart/SparkLineChart.js +0 -2
- package/esm/context/CartesianProvider/computeValue.js +1 -1
- package/esm/context/CartesianProvider/normalizeAxis.js +1 -1
- package/esm/context/DrawingProvider.js +7 -1
- package/esm/context/SeriesProvider/Series.types.js +1 -0
- package/esm/context/SeriesProvider/SeriesContext.js +8 -0
- package/esm/context/SeriesProvider/SeriesProvider.js +30 -0
- package/esm/context/SeriesProvider/index.js +8 -0
- package/esm/context/{SeriesContextProvider.js → SeriesProvider/processSeries.js} +10 -35
- package/esm/context/ZAxisContextProvider.js +1 -1
- package/esm/hooks/useAxisEvents.js +12 -8
- package/esm/hooks/useReducedMotion.js +2 -2
- package/esm/hooks/useSeries.js +1 -1
- package/esm/internals/SlotComponentPropsFromProps.js +1 -0
- package/esm/internals/colorScale.js +1 -1
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +1 -1
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/getCurve.js +1 -1
- package/esm/internals/getPercentageValue.js +1 -1
- package/esm/internals/getScale.js +1 -1
- package/esm/internals/index.js +1 -1
- package/esm/internals/stackSeries.js +1 -1
- package/esm/internals/useAnimatedPath.js +1 -1
- package/esm/internals/warning.js +19 -11
- package/hooks/useAxisEvents.js +12 -8
- package/hooks/useReducedMotion.js +2 -2
- package/hooks/useSeries.d.ts +1 -1
- package/hooks/useSeries.js +2 -2
- package/hooks/useTicks.d.ts +1 -1
- package/index.js +1 -1
- package/internals/SlotComponentPropsFromProps.d.ts +1 -0
- package/internals/SlotComponentPropsFromProps.js +5 -0
- package/internals/colorScale.d.ts +3 -3
- package/internals/colorScale.js +1 -1
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +1 -1
- package/internals/defaultizeColor.d.ts +8 -1
- package/internals/geometry.js +1 -1
- package/internals/getCurve.d.ts +1 -1
- package/internals/getCurve.js +1 -1
- package/internals/getPercentageValue.js +1 -1
- package/internals/getScale.js +1 -1
- package/internals/index.d.ts +1 -1
- package/internals/index.js +4 -4
- package/internals/isBandScale.d.ts +1 -1
- package/internals/stackSeries.d.ts +1 -1
- package/internals/stackSeries.js +1 -1
- package/internals/useAnimatedPath.js +1 -1
- package/internals/warning.d.ts +2 -1
- package/internals/warning.js +21 -12
- package/models/axis.d.ts +2 -2
- package/models/seriesType/common.d.ts +10 -0
- package/models/seriesType/pie.d.ts +1 -1
- package/models/seriesType/scatter.d.ts +5 -0
- package/models/z-axis.d.ts +1 -1
- package/modern/BarChart/BarChart.js +0 -2
- package/modern/BarChart/BarElement.js +2 -2
- package/modern/BarChart/BarLabel/BarLabelItem.js +1 -1
- 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 +3 -3
- package/modern/ChartContainer/ChartContainer.js +3 -5
- package/modern/ChartContainer/useChartContainerProps.js +2 -2
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsLegend/ChartsLegend.js +2 -2
- package/modern/ChartsLegend/LegendPerItem.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 +8 -4
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +5 -5
- package/modern/ChartsTooltip/ChartsTooltip.js +3 -3
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +5 -3
- package/modern/ChartsXAxis/ChartsXAxis.js +2 -2
- package/modern/ChartsYAxis/ChartsYAxis.js +2 -2
- package/modern/Gauge/GaugeReferenceArc.js +1 -1
- package/modern/Gauge/GaugeValueArc.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaElement.js +1 -1
- package/modern/LineChart/AreaPlot.js +11 -7
- package/modern/LineChart/LineChart.js +4 -3
- package/modern/LineChart/LineElement.js +1 -1
- package/modern/LineChart/LineHighlightPlot.js +9 -5
- package/modern/LineChart/LinePlot.js +11 -7
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +9 -5
- package/modern/LineChart/extremums.js +4 -1
- package/modern/LineChart/formatter.js +3 -3
- package/modern/PieChart/PieArc.js +2 -1
- package/modern/PieChart/PieArcLabel.js +1 -1
- package/modern/PieChart/PieChart.js +0 -2
- package/modern/PieChart/formatter.js +1 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +0 -2
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +2 -2
- package/modern/ScatterChart/ScatterChart.js +4 -3
- package/modern/ScatterChart/ScatterPlot.js +6 -3
- package/modern/ScatterChart/extremums.js +8 -2
- package/modern/SparkLineChart/SparkLineChart.js +0 -2
- package/modern/context/CartesianProvider/computeValue.js +1 -1
- package/modern/context/CartesianProvider/normalizeAxis.js +1 -1
- package/modern/context/DrawingProvider.js +7 -1
- package/modern/context/SeriesProvider/Series.types.js +1 -0
- package/modern/context/SeriesProvider/SeriesContext.js +8 -0
- package/modern/context/SeriesProvider/SeriesProvider.js +30 -0
- package/modern/context/SeriesProvider/index.js +8 -0
- package/modern/context/{SeriesContextProvider.js → SeriesProvider/processSeries.js} +10 -35
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/hooks/useAxisEvents.js +12 -8
- package/modern/hooks/useReducedMotion.js +2 -2
- package/modern/hooks/useSeries.js +1 -1
- package/modern/index.js +1 -1
- package/modern/internals/SlotComponentPropsFromProps.js +1 -0
- package/modern/internals/colorScale.js +1 -1
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +1 -1
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/getCurve.js +1 -1
- package/modern/internals/getPercentageValue.js +1 -1
- package/modern/internals/getScale.js +1 -1
- package/modern/internals/index.js +1 -1
- package/modern/internals/stackSeries.js +1 -1
- package/modern/internals/useAnimatedPath.js +1 -1
- package/modern/internals/warning.js +19 -11
- package/package.json +8 -25
- package/context/SeriesContextProvider.js +0 -81
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
-
import { stack as d3Stack } from 'd3-shape';
|
|
2
|
+
import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
|
|
3
3
|
import { getStackingGroups } from '../internals/stackSeries';
|
|
4
4
|
import { defaultizeValueFormatter } from '../internals/defaultizeValueFormatter';
|
|
5
5
|
let warnOnce = false;
|
|
@@ -25,7 +25,7 @@ const formatter = (params, dataset) => {
|
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
27
|
} else if (dataset === undefined) {
|
|
28
|
-
throw new Error([`MUI X
|
|
28
|
+
throw new Error([`MUI X: bar series with id='${id}' has no data.`, 'Either provide a data property to the series or use the dataset prop.'].join('\n'));
|
|
29
29
|
}
|
|
30
30
|
});
|
|
31
31
|
const completedSeries = {};
|
|
@@ -52,7 +52,7 @@ const formatter = (params, dataset) => {
|
|
|
52
52
|
if (typeof value !== 'number') {
|
|
53
53
|
if (process.env.NODE_ENV !== 'production' && !warnOnce && value !== null) {
|
|
54
54
|
warnOnce = true;
|
|
55
|
-
console.error([`MUI X charts: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.']);
|
|
55
|
+
console.error([`MUI X charts: your dataset key "${dataKey}" is used for plotting bars, but contains nonnumerical elements.`, 'Bar plots only support numbers and null values.'].join('\n'));
|
|
56
56
|
}
|
|
57
57
|
return 0;
|
|
58
58
|
}
|
|
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { DrawingProvider } from '../context/DrawingProvider';
|
|
5
|
-
import {
|
|
5
|
+
import { SeriesProvider } from '../context/SeriesProvider';
|
|
6
6
|
import { InteractionProvider } from '../context/InteractionProvider';
|
|
7
7
|
import { ColorProvider } from '../context/ColorProvider';
|
|
8
8
|
import { ChartsSurface } from '../ChartsSurface';
|
|
@@ -16,7 +16,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
16
16
|
children,
|
|
17
17
|
drawingProviderProps,
|
|
18
18
|
colorProviderProps,
|
|
19
|
-
|
|
19
|
+
seriesProviderProps,
|
|
20
20
|
cartesianContextProps,
|
|
21
21
|
zAxisContextProps,
|
|
22
22
|
highlightedProviderProps,
|
|
@@ -24,7 +24,7 @@ const ChartContainer = /*#__PURE__*/React.forwardRef(function ChartContainer(pro
|
|
|
24
24
|
} = useChartContainerProps(props, ref);
|
|
25
25
|
return /*#__PURE__*/_jsx(DrawingProvider, _extends({}, drawingProviderProps, {
|
|
26
26
|
children: /*#__PURE__*/_jsx(ColorProvider, _extends({}, colorProviderProps, {
|
|
27
|
-
children: /*#__PURE__*/_jsx(
|
|
27
|
+
children: /*#__PURE__*/_jsx(SeriesProvider, _extends({}, seriesProviderProps, {
|
|
28
28
|
children: /*#__PURE__*/_jsx(CartesianContextProvider, _extends({}, cartesianContextProps, {
|
|
29
29
|
children: /*#__PURE__*/_jsx(ZAxisContextProvider, _extends({}, zAxisContextProps, {
|
|
30
30
|
children: /*#__PURE__*/_jsx(InteractionProvider, {
|
|
@@ -121,7 +121,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
121
121
|
* An array of [[AxisConfig]] objects.
|
|
122
122
|
*/
|
|
123
123
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
124
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
125
124
|
classes: PropTypes.object,
|
|
126
125
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
127
126
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
@@ -174,7 +173,6 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
174
173
|
* An array of [[AxisConfig]] objects.
|
|
175
174
|
*/
|
|
176
175
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
177
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
178
176
|
classes: PropTypes.object,
|
|
179
177
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
180
178
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
@@ -42,7 +42,7 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
42
42
|
const colorProviderProps = {
|
|
43
43
|
colorProcessors
|
|
44
44
|
};
|
|
45
|
-
const
|
|
45
|
+
const seriesProviderProps = {
|
|
46
46
|
series,
|
|
47
47
|
colors,
|
|
48
48
|
dataset,
|
|
@@ -76,7 +76,7 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
76
76
|
children,
|
|
77
77
|
drawingProviderProps,
|
|
78
78
|
colorProviderProps,
|
|
79
|
-
|
|
79
|
+
seriesProviderProps,
|
|
80
80
|
cartesianContextProps,
|
|
81
81
|
zAxisContextProps,
|
|
82
82
|
highlightedProviderProps,
|
|
@@ -57,16 +57,16 @@ function ChartsAxis(props) {
|
|
|
57
57
|
const topId = getAxisId(topAxis, xAxisIds[0]);
|
|
58
58
|
const rightId = getAxisId(rightAxis, yAxisIds[0]);
|
|
59
59
|
if (topId !== null && !xAxis[topId]) {
|
|
60
|
-
throw Error([`MUI X
|
|
60
|
+
throw Error([`MUI X: id used for top axis "${topId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
61
61
|
}
|
|
62
62
|
if (leftId !== null && !yAxis[leftId]) {
|
|
63
|
-
throw Error([`MUI X
|
|
63
|
+
throw Error([`MUI X: id used for left axis "${leftId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
64
64
|
}
|
|
65
65
|
if (rightId !== null && !yAxis[rightId]) {
|
|
66
|
-
throw Error([`MUI X
|
|
66
|
+
throw Error([`MUI X: id used for right axis "${rightId}" is not defined.`, `Available ids are: ${yAxisIds.join(', ')}.`].join('\n'));
|
|
67
67
|
}
|
|
68
68
|
if (bottomId !== null && !xAxis[bottomId]) {
|
|
69
|
-
throw Error([`MUI X
|
|
69
|
+
throw Error([`MUI X: id used for bottom axis "${bottomId}" is not defined.`, `Available ids are: ${xAxisIds.join(', ')}.`].join('\n'));
|
|
70
70
|
}
|
|
71
71
|
const topAxisProps = mergeProps(topAxis, slots, slotProps);
|
|
72
72
|
const bottomAxisProps = mergeProps(bottomAxis, slots, slotProps);
|
|
@@ -74,7 +74,7 @@ function ChartsAxisHighlight(props) {
|
|
|
74
74
|
const isXError = isBandScaleX && xScale(axisX.value) === undefined;
|
|
75
75
|
const isYError = isBandScaleY && yScale(axisY.value) === undefined;
|
|
76
76
|
if (isXError || isYError) {
|
|
77
|
-
console.error([`MUI X
|
|
77
|
+
console.error([`MUI X: The position value provided for the axis is not valid for the current scale.`, `This probably means something is wrong with the data passed to the chart.`, `The ChartsAxisHighlight component will not be displayed.`].join('\n'));
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import
|
|
5
|
-
import
|
|
4
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
5
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
6
6
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
7
7
|
import { getSeriesToDisplay } from './utils';
|
|
8
8
|
import { getLegendUtilityClass } from './chartsLegendClasses';
|
|
@@ -2,7 +2,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
2
2
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
3
3
|
const _excluded = ["rotate", "dominantBaseline"];
|
|
4
4
|
import * as React from 'react';
|
|
5
|
-
import
|
|
5
|
+
import NoSsr from '@mui/material/NoSsr';
|
|
6
6
|
import { useTheme, styled } from '@mui/material/styles';
|
|
7
7
|
import { ChartsText } from '../ChartsText';
|
|
8
8
|
import { getWordsByLines } from '../internals/getWordsByLines';
|
|
@@ -37,7 +37,9 @@ function ChartsOnAxisClickHandler(props) {
|
|
|
37
37
|
Object.keys(series).filter(seriesType => ['bar', 'line'].includes(seriesType)).forEach(seriesType => {
|
|
38
38
|
series[seriesType]?.seriesOrder.forEach(seriesId => {
|
|
39
39
|
const seriesItem = series[seriesType].series[seriesId];
|
|
40
|
-
const
|
|
40
|
+
const providedXAxisId = seriesItem.xAxisId ?? seriesItem.xAxisKey;
|
|
41
|
+
const providedYAxisId = seriesItem.yAxisId ?? seriesItem.yAxisKey;
|
|
42
|
+
const axisKey = isXaxis ? providedXAxisId : providedYAxisId;
|
|
41
43
|
if (axisKey === undefined || axisKey === USED_AXIS_ID) {
|
|
42
44
|
seriesValues[seriesId] = seriesItem.data[dataIndex];
|
|
43
45
|
}
|
|
@@ -10,10 +10,10 @@ function ChartsReferenceLine(props) {
|
|
|
10
10
|
y
|
|
11
11
|
} = props;
|
|
12
12
|
if (x !== undefined && y !== undefined) {
|
|
13
|
-
throw new Error('MUI X
|
|
13
|
+
throw new Error('MUI X: The ChartsReferenceLine cannot have both `x` and `y` props set.');
|
|
14
14
|
}
|
|
15
15
|
if (x === undefined && y === undefined) {
|
|
16
|
-
throw new Error('MUI X
|
|
16
|
+
throw new Error('MUI X: The ChartsReferenceLine should have a value in `x` or `y` prop.');
|
|
17
17
|
}
|
|
18
18
|
if (x !== undefined) {
|
|
19
19
|
return /*#__PURE__*/_jsx(ChartsXReferenceLine, _extends({}, props));
|
|
@@ -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
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
4
4
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
5
5
|
import { DefaultChartsAxisTooltipContent } from './DefaultChartsAxisTooltipContent';
|
|
6
6
|
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
@@ -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
|
}));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import
|
|
3
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
4
4
|
import { DefaultChartsItemTooltipContent } from './DefaultChartsItemTooltipContent';
|
|
5
5
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
6
6
|
import { ZAxisContext } from '../context/ZAxisContextProvider';
|
|
@@ -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,
|
|
@@ -3,9 +3,9 @@ import * as React from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import composeClasses from '@mui/utils/composeClasses';
|
|
5
5
|
import { styled, useThemeProps } from '@mui/material/styles';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
6
|
+
import Popper from '@mui/material/Popper';
|
|
7
|
+
import NoSsr from '@mui/material/NoSsr';
|
|
8
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
9
9
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
10
10
|
import { generateVirtualElement, useMouseTracker, getTooltipHasData } from './utils';
|
|
11
11
|
import { ChartsItemTooltipContent } from './ChartsItemTooltipContent';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import { Delaunay } from 'd3-delaunay';
|
|
3
|
+
import { Delaunay } from '@mui/x-charts-vendor/d3-delaunay';
|
|
4
4
|
import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
|
|
5
5
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
6
6
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
@@ -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(({
|
|
@@ -3,8 +3,8 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["scale", "tickNumber", "reverse"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
9
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
10
10
|
import { useTicks } from '../hooks/useTicks';
|
|
@@ -3,8 +3,8 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["scale", "tickNumber"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
6
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
8
|
import { useThemeProps, useTheme } from '@mui/material/styles';
|
|
9
9
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
10
10
|
import { useTicks } from '../hooks/useTicks';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { arc as d3Arc } from 'd3-shape';
|
|
3
|
+
import { arc as d3Arc } from '@mui/x-charts-vendor/d3-shape';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { useGaugeState } from './GaugeProvider';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import * as React from 'react';
|
|
3
|
-
import { arc as d3Arc } from 'd3-shape';
|
|
3
|
+
import { arc as d3Arc } from '@mui/x-charts-vendor/d3-shape';
|
|
4
4
|
import { styled } from '@mui/material/styles';
|
|
5
5
|
import { useGaugeState } from './GaugeProvider';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -4,8 +4,8 @@ const _excluded = ["d", "skipAnimation", "ownerState"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { styled } from '@mui/material/styles';
|
|
7
|
-
import { color as d3Color } from 'd3-color';
|
|
8
7
|
import { animated, useSpring } from '@react-spring/web';
|
|
8
|
+
import { color as d3Color } from '@mui/x-charts-vendor/d3-color';
|
|
9
9
|
import { useAnimatedPath } from '../internals/useAnimatedPath';
|
|
10
10
|
import { cleanId } from '../internals/cleanId';
|
|
11
11
|
import { useChartId, useDrawingArea } from '../hooks';
|
|
@@ -4,7 +4,7 @@ const _excluded = ["d", "skipAnimation", "ownerState"];
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import { animated, useSpring } from '@react-spring/web';
|
|
7
|
-
import { color as d3Color } from 'd3-color';
|
|
7
|
+
import { color as d3Color } from '@mui/x-charts-vendor/d3-color';
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import { useAnimatedPath } from '../internals/useAnimatedPath';
|
|
10
10
|
import { cleanId } from '../internals/cleanId';
|
|
@@ -4,7 +4,7 @@ const _excluded = ["id", "classes", "color", "gradientId", "slots", "slotProps",
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
-
import
|
|
7
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
8
8
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
9
9
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
10
10
|
import { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["slots", "slotProps", "onItemClick", "skipAnimation"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { area as d3Area } from 'd3-shape';
|
|
6
|
+
import { area as d3Area } from '@mui/x-charts-vendor/d3-shape';
|
|
7
7
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
8
8
|
import { AreaElement } from './AreaElement';
|
|
9
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
@@ -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 = {
|
|
@@ -237,7 +240,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
237
240
|
* An array of [[AxisConfig]] objects.
|
|
238
241
|
*/
|
|
239
242
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
240
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
241
243
|
classes: PropTypes.object,
|
|
242
244
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
243
245
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
@@ -290,7 +292,6 @@ process.env.NODE_ENV !== "production" ? LineChart.propTypes = {
|
|
|
290
292
|
* An array of [[AxisConfig]] objects.
|
|
291
293
|
*/
|
|
292
294
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
293
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
294
295
|
classes: PropTypes.object,
|
|
295
296
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
296
297
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
@@ -4,7 +4,7 @@ const _excluded = ["id", "classes", "color", "gradientId", "slots", "slotProps",
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
7
|
-
import
|
|
7
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
8
8
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
9
9
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
10
10
|
import { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
@@ -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),
|
|
@@ -3,7 +3,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
3
3
|
const _excluded = ["slots", "slotProps", "skipAnimation", "onItemClick"];
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { line as d3Line } from 'd3-shape';
|
|
6
|
+
import { line as d3Line } from '@mui/x-charts-vendor/d3-shape';
|
|
7
7
|
import { useCartesianContext } from '../context/CartesianProvider';
|
|
8
8
|
import { LineElement } from './LineElement';
|
|
9
9
|
import { getValueToPositionMapper } from '../hooks/useScale';
|
|
@@ -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]));
|
|
@@ -7,7 +7,7 @@ import composeClasses from '@mui/utils/composeClasses';
|
|
|
7
7
|
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
8
8
|
import { styled } from '@mui/material/styles';
|
|
9
9
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
10
|
-
import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from 'd3-shape';
|
|
10
|
+
import { symbol as d3Symbol, symbolsFill as d3SymbolsFill } from '@mui/x-charts-vendor/d3-shape';
|
|
11
11
|
import { animated, to, useSpring } from '@react-spring/web';
|
|
12
12
|
import { getSymbol } from '../internals/getSymbol';
|
|
13
13
|
import { InteractionContext } from '../context/InteractionProvider';
|
|
@@ -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
|