@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
|
@@ -50,7 +50,10 @@ const ScatterChart = exports.ScatterChart = /*#__PURE__*/React.forwardRef(functi
|
|
|
50
50
|
ref: ref
|
|
51
51
|
}, chartContainerProps, {
|
|
52
52
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_ZAxisContextProvider.ZAxisContextProvider, (0, _extends2.default)({}, zAxisProps, {
|
|
53
|
-
children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
53
|
+
children: [!props.disableVoronoi && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsVoronoiHandler.ChartsVoronoiHandler, (0, _extends2.default)({}, voronoiHandlerProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxis.ChartsAxis, (0, _extends2.default)({}, chartsAxisProps)), props.grid && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsGrid.ChartsGrid, (0, _extends2.default)({}, gridProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)("g", {
|
|
54
|
+
"data-drawing-container": true,
|
|
55
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_ScatterPlot.ScatterPlot, (0, _extends2.default)({}, scatterPlotProps))
|
|
56
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsOverlay.ChartsOverlay, (0, _extends2.default)({}, overlayProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsLegend.ChartsLegend, (0, _extends2.default)({}, legendProps)), /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsAxisHighlight.ChartsAxisHighlight, (0, _extends2.default)({}, axisHighlightProps)), !props.loading && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ChartsTooltip.ChartsTooltip, (0, _extends2.default)({}, tooltipProps)), children]
|
|
54
57
|
}))
|
|
55
58
|
}));
|
|
56
59
|
});
|
|
@@ -227,7 +230,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
227
230
|
* An array of [[AxisConfig]] objects.
|
|
228
231
|
*/
|
|
229
232
|
xAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
230
|
-
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
231
233
|
classes: _propTypes.default.object,
|
|
232
234
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
233
235
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
@@ -280,7 +282,6 @@ process.env.NODE_ENV !== "production" ? ScatterChart.propTypes = {
|
|
|
280
282
|
* An array of [[AxisConfig]] objects.
|
|
281
283
|
*/
|
|
282
284
|
yAxis: _propTypes.default.arrayOf(_propTypes.default.shape({
|
|
283
|
-
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
284
285
|
classes: _propTypes.default.object,
|
|
285
286
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
286
287
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
@@ -62,12 +62,15 @@ function ScatterPlot(props) {
|
|
|
62
62
|
xAxisKey,
|
|
63
63
|
yAxisKey,
|
|
64
64
|
zAxisKey,
|
|
65
|
+
xAxisId,
|
|
66
|
+
yAxisId,
|
|
67
|
+
zAxisId,
|
|
65
68
|
markerSize,
|
|
66
69
|
color
|
|
67
70
|
} = series[seriesId];
|
|
68
|
-
const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisKey ?? defaultXAxisId], yAxis[yAxisKey ?? defaultYAxisId], zAxis[zAxisKey ?? defaultZAxisId]);
|
|
69
|
-
const xScale = xAxis[xAxisKey ?? defaultXAxisId].scale;
|
|
70
|
-
const yScale = yAxis[yAxisKey ?? defaultYAxisId].scale;
|
|
71
|
+
const colorGetter = (0, _getColor.default)(series[seriesId], xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId], yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId], zAxis[zAxisId ?? zAxisKey ?? defaultZAxisId]);
|
|
72
|
+
const xScale = xAxis[xAxisId ?? xAxisKey ?? defaultXAxisId].scale;
|
|
73
|
+
const yScale = yAxis[yAxisId ?? yAxisKey ?? defaultYAxisId].scale;
|
|
71
74
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(ScatterItems, (0, _extends2.default)({
|
|
72
75
|
xScale: xScale,
|
|
73
76
|
yScale: yScale,
|
|
@@ -19,7 +19,10 @@ const getExtremumX = params => {
|
|
|
19
19
|
axis,
|
|
20
20
|
isDefaultAxis
|
|
21
21
|
} = params;
|
|
22
|
-
return Object.keys(series).filter(seriesId =>
|
|
22
|
+
return Object.keys(series).filter(seriesId => {
|
|
23
|
+
const axisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey;
|
|
24
|
+
return axisId === axis.id || axisId === undefined && isDefaultAxis;
|
|
25
|
+
}).reduce((acc, seriesId) => {
|
|
23
26
|
const seriesMinMax = series[seriesId].data.reduce((accSeries, {
|
|
24
27
|
x
|
|
25
28
|
}) => {
|
|
@@ -36,7 +39,10 @@ const getExtremumY = params => {
|
|
|
36
39
|
axis,
|
|
37
40
|
isDefaultAxis
|
|
38
41
|
} = params;
|
|
39
|
-
return Object.keys(series).filter(seriesId =>
|
|
42
|
+
return Object.keys(series).filter(seriesId => {
|
|
43
|
+
const axisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
|
|
44
|
+
return axisId === axis.id || axisId === undefined && isDefaultAxis;
|
|
45
|
+
}).reduce((acc, seriesId) => {
|
|
40
46
|
const seriesMinMax = series[seriesId].data.reduce((accSeries, {
|
|
41
47
|
y
|
|
42
48
|
}) => {
|
|
@@ -254,7 +254,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
254
254
|
* Notice it is a single [[AxisConfig]] object, not an array of configuration.
|
|
255
255
|
*/
|
|
256
256
|
xAxis: _propTypes.default.shape({
|
|
257
|
-
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
258
257
|
classes: _propTypes.default.object,
|
|
259
258
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
260
259
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
@@ -306,7 +305,6 @@ process.env.NODE_ENV !== "production" ? SparkLineChart.propTypes = {
|
|
|
306
305
|
* Notice it is a single [[AxisConfig]] object, not an array of configuration.
|
|
307
306
|
*/
|
|
308
307
|
yAxis: _propTypes.default.shape({
|
|
309
|
-
axisId: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.string]),
|
|
310
308
|
classes: _propTypes.default.object,
|
|
311
309
|
colorMap: _propTypes.default.oneOfType([_propTypes.default.shape({
|
|
312
310
|
colors: _propTypes.default.arrayOf(_propTypes.default.string).isRequired,
|
|
@@ -2,7 +2,7 @@ import * as React from 'react';
|
|
|
2
2
|
import { Initializable } from '../context.types';
|
|
3
3
|
import { AxisDefaultized, ScaleName, ChartsXAxisProps, ChartsYAxisProps, AxisId } from '../../models/axis';
|
|
4
4
|
export type DefaultizedAxisConfig<AxisProps> = {
|
|
5
|
-
[
|
|
5
|
+
[axisId: AxisId]: AxisDefaultized<ScaleName, any, AxisProps>;
|
|
6
6
|
};
|
|
7
7
|
export type CartesianContextState = {
|
|
8
8
|
/**
|
|
@@ -3,7 +3,7 @@ import { ChartsXAxisProps, ChartsAxisProps, ChartsYAxisProps, AxisId } from '../
|
|
|
3
3
|
import { CartesianChartSeriesType, DatasetType, ExtremumGetter } from '../../models/seriesType/config';
|
|
4
4
|
import { DefaultizedAxisConfig } from './CartesianContext';
|
|
5
5
|
import { DrawingArea } from '../DrawingProvider';
|
|
6
|
-
import { FormattedSeries } from '../
|
|
6
|
+
import { FormattedSeries } from '../SeriesProvider';
|
|
7
7
|
export declare function computeValue(options: {
|
|
8
8
|
drawingArea: DrawingArea;
|
|
9
9
|
formattedSeries: FormattedSeries;
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports.computeValue = computeValue;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
-
var _d3Scale = require("d3-scale");
|
|
9
|
+
var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
|
|
10
10
|
var _axis = require("../../models/axis");
|
|
11
11
|
var _colorScale = require("../../internals/colorScale");
|
|
12
12
|
var _useTicks = require("../../hooks/useTicks");
|
|
@@ -2,35 +2,34 @@ import { MakeOptional } from '../../models/helpers';
|
|
|
2
2
|
import { AxisConfig, ScaleName } from '../../models';
|
|
3
3
|
import { ChartsAxisProps } from '../../models/axis';
|
|
4
4
|
export declare const defaultizeAxis: (inAxis: MakeOptional<AxisConfig<ScaleName, any, ChartsAxisProps>, "id">[] | undefined, axisName: "x" | "y") => {
|
|
5
|
-
reverse?: boolean;
|
|
6
|
-
fill?: string;
|
|
7
|
-
stroke?: string;
|
|
5
|
+
reverse?: boolean | undefined;
|
|
6
|
+
fill?: string | undefined;
|
|
7
|
+
stroke?: string | undefined;
|
|
8
8
|
data?: any[] | undefined;
|
|
9
|
-
label?: string;
|
|
10
|
-
max?: number | Date;
|
|
11
|
-
min?: number | Date;
|
|
12
|
-
classes?: Partial<import("../..").ChartsAxisClasses
|
|
13
|
-
slots?: Partial<import("../../models/axis").ChartsAxisSlots
|
|
14
|
-
slotProps?: Partial<import("../../models/axis").ChartsAxisSlotProps
|
|
15
|
-
dataKey?: string;
|
|
9
|
+
label?: string | undefined;
|
|
10
|
+
max?: (number | Date) | undefined;
|
|
11
|
+
min?: (number | Date) | undefined;
|
|
12
|
+
classes?: Partial<import("../..").ChartsAxisClasses> | undefined;
|
|
13
|
+
slots?: Partial<import("../../models/axis").ChartsAxisSlots> | undefined;
|
|
14
|
+
slotProps?: Partial<import("../../models/axis").ChartsAxisSlotProps> | undefined;
|
|
15
|
+
dataKey?: string | undefined;
|
|
16
16
|
valueFormatter?: ((value: any, context: import("../../models/axis").AxisValueFormatterContext) => string) | undefined;
|
|
17
17
|
colorMap?: import("../../models/colorMapping").ContinuousColorConfig<number | Date> | import("../../models/colorMapping").PiecewiseColorConfig<number | Date> | import("../../models/colorMapping").OrdinalColorConfig<string | number | Date> | undefined;
|
|
18
|
-
tickMaxStep?: number;
|
|
19
|
-
tickMinStep?: number;
|
|
20
|
-
tickNumber?: number;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
axisId?: import("../../models/axis").AxisId;
|
|
25
|
-
disableLine?: boolean;
|
|
26
|
-
disableTicks?: boolean;
|
|
27
|
-
tickFontSize?: number;
|
|
18
|
+
tickMaxStep?: number | undefined;
|
|
19
|
+
tickMinStep?: number | undefined;
|
|
20
|
+
tickNumber?: number | undefined;
|
|
21
|
+
disableLine?: boolean | undefined;
|
|
22
|
+
disableTicks?: boolean | undefined;
|
|
23
|
+
tickFontSize?: number | undefined;
|
|
28
24
|
tickLabelStyle?: import("../..").ChartsTextProps["style"];
|
|
29
25
|
labelStyle?: import("../..").ChartsTextProps["style"];
|
|
30
|
-
tickLabelInterval?: "auto" | ((value: any, index: number) => boolean);
|
|
31
|
-
labelFontSize?: number;
|
|
32
|
-
tickSize?: number;
|
|
33
|
-
tickInterval?: "auto" | ((value: any, index: number) => boolean) | any[];
|
|
34
|
-
|
|
26
|
+
tickLabelInterval?: ("auto" | ((value: any, index: number) => boolean)) | undefined;
|
|
27
|
+
labelFontSize?: number | undefined;
|
|
28
|
+
tickSize?: number | undefined;
|
|
29
|
+
tickInterval?: ("auto" | ((value: any, index: number) => boolean) | any[]) | undefined;
|
|
30
|
+
tickPlacement?: ("start" | "end" | "middle" | "extremities") | undefined;
|
|
31
|
+
tickLabelPlacement?: ("middle" | "tick") | undefined;
|
|
32
|
+
scaleType?: "linear" | "time" | "log" | "band" | "point" | "pow" | "sqrt" | "utc" | undefined;
|
|
33
|
+
hideTooltip?: boolean | undefined;
|
|
35
34
|
id: import("../../models/axis").AxisId;
|
|
36
35
|
}[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { AxisConfig, ExtremumGettersConfig } from '../../models';
|
|
2
2
|
import { ExtremumGetterResult } from '../../models/seriesType/config';
|
|
3
|
-
import { FormattedSeries } from '../
|
|
3
|
+
import { FormattedSeries } from '../SeriesProvider';
|
|
4
4
|
export declare const getAxisExtremum: (axis: AxisConfig, getters: ExtremumGettersConfig, isDefaultAxis: boolean, formattedSeries: FormattedSeries) => ExtremumGetterResult;
|
|
@@ -13,7 +13,7 @@ const normalizeAxis = (axis, dataset, axisName) => {
|
|
|
13
13
|
return axisConfig;
|
|
14
14
|
}
|
|
15
15
|
if (dataset === undefined) {
|
|
16
|
-
throw Error(`MUI X
|
|
16
|
+
throw Error(`MUI X: ${axisName}-axis uses \`dataKey\` but no \`dataset\` is provided.`);
|
|
17
17
|
}
|
|
18
18
|
return (0, _extends2.default)({}, axisConfig, {
|
|
19
19
|
data: dataset.map(d => d[dataKey])
|
|
@@ -38,12 +38,13 @@ export type DrawingArea = {
|
|
|
38
38
|
* @param {Object} point The point to check.
|
|
39
39
|
* @param {number} point.x The x coordinate of the point.
|
|
40
40
|
* @param {number} point.y The y coordinate of the point.
|
|
41
|
+
* @param {Element} targetElement The target element if relevant.
|
|
41
42
|
* @returns {boolean} `true` if the point is inside the drawing area, `false` otherwise.
|
|
42
43
|
*/
|
|
43
44
|
isPointInside: (point: {
|
|
44
45
|
x: number;
|
|
45
46
|
y: number;
|
|
46
|
-
}) => boolean;
|
|
47
|
+
}, targetElement?: Element) => boolean;
|
|
47
48
|
};
|
|
48
49
|
export declare const DrawingContext: React.Context<DrawingArea & {
|
|
49
50
|
/**
|
|
@@ -53,7 +53,13 @@ function DrawingProvider(props) {
|
|
|
53
53
|
const isPointInside = React.useCallback(({
|
|
54
54
|
x,
|
|
55
55
|
y
|
|
56
|
-
}) =>
|
|
56
|
+
}, targetElement) => {
|
|
57
|
+
// For element allowed to overflow, wrapping them in <g data-drawing-container /> make them fully part of the drawing area.
|
|
58
|
+
if (targetElement && targetElement.closest('[data-drawing-container]')) {
|
|
59
|
+
return true;
|
|
60
|
+
}
|
|
61
|
+
return x >= drawingArea.left && x <= drawingArea.left + drawingArea.width && y >= drawingArea.top && y <= drawingArea.top + drawingArea.height;
|
|
62
|
+
}, [drawingArea]);
|
|
57
63
|
const value = React.useMemo(() => (0, _extends2.default)({
|
|
58
64
|
chartId: chartId ?? ''
|
|
59
65
|
}, drawingArea, {
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { AllSeriesType } from '
|
|
3
|
-
import { ChartSeriesType, DatasetType, FormatterParams, FormatterResult } from '
|
|
4
|
-
import { ChartsColorPalette } from '
|
|
5
|
-
import { Initializable } from './context.types';
|
|
2
|
+
import { AllSeriesType } from '../../models/seriesType';
|
|
3
|
+
import { ChartSeriesType, DatasetType, FormatterParams, FormatterResult } from '../../models/seriesType/config';
|
|
4
|
+
import { ChartsColorPalette } from '../../colorPalettes';
|
|
6
5
|
export type SeriesFormatterType<T extends ChartSeriesType> = (series: AllSeriesType<T>[], colors: string[], dataset?: DatasetType) => {
|
|
7
6
|
[type in T]?: FormatterResult<type>;
|
|
8
7
|
};
|
|
9
|
-
export type
|
|
8
|
+
export type SeriesProviderProps<T extends ChartSeriesType = ChartSeriesType> = {
|
|
10
9
|
dataset?: DatasetType;
|
|
11
10
|
/**
|
|
12
11
|
* The array of series to display.
|
|
@@ -28,9 +27,6 @@ export type SeriesContextProviderProps<T extends ChartSeriesType = ChartSeriesTy
|
|
|
28
27
|
export type FormattedSeries = {
|
|
29
28
|
[type in ChartSeriesType]?: FormatterResult<type>;
|
|
30
29
|
};
|
|
31
|
-
export declare const SeriesContext: React.Context<Initializable<FormattedSeries>>;
|
|
32
30
|
export type SeriesFormatterConfig<T extends ChartSeriesType = ChartSeriesType> = {
|
|
33
31
|
[K in T]?: (series: FormatterParams<K>, dataset?: DatasetType) => any;
|
|
34
32
|
};
|
|
35
|
-
declare function SeriesContextProvider<T extends ChartSeriesType>(props: SeriesContextProviderProps<T>): React.JSX.Element;
|
|
36
|
-
export { SeriesContextProvider };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SeriesContext = void 0;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
9
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
|
+
const SeriesContext = exports.SeriesContext = /*#__PURE__*/React.createContext({
|
|
11
|
+
isInitialized: false,
|
|
12
|
+
data: {}
|
|
13
|
+
});
|
|
14
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
15
|
+
SeriesContext.displayName = 'SeriesContext';
|
|
16
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { ChartSeriesType } from '../../models/seriesType/config';
|
|
3
|
+
import { SeriesProviderProps } from './Series.types';
|
|
4
|
+
declare function SeriesProvider<T extends ChartSeriesType>(props: SeriesProviderProps<T>): React.JSX.Element;
|
|
5
|
+
export { SeriesProvider };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SeriesProvider = SeriesProvider;
|
|
7
|
+
var React = _interopRequireWildcard(require("react"));
|
|
8
|
+
var _styles = require("@mui/material/styles");
|
|
9
|
+
var _colorPalettes = require("../../colorPalettes");
|
|
10
|
+
var _SeriesContext = require("./SeriesContext");
|
|
11
|
+
var _processSeries = require("./processSeries");
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
14
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
15
|
+
function SeriesProvider(props) {
|
|
16
|
+
const {
|
|
17
|
+
series,
|
|
18
|
+
dataset,
|
|
19
|
+
colors = _colorPalettes.blueberryTwilightPalette,
|
|
20
|
+
seriesFormatters,
|
|
21
|
+
children
|
|
22
|
+
} = props;
|
|
23
|
+
const theme = (0, _styles.useTheme)();
|
|
24
|
+
const formattedSeries = React.useMemo(() => ({
|
|
25
|
+
isInitialized: true,
|
|
26
|
+
data: (0, _processSeries.preprocessSeries)({
|
|
27
|
+
series,
|
|
28
|
+
colors: typeof colors === 'function' ? colors(theme.palette.mode) : colors,
|
|
29
|
+
seriesFormatters,
|
|
30
|
+
dataset: dataset
|
|
31
|
+
})
|
|
32
|
+
}), [series, colors, theme.palette.mode, seriesFormatters, dataset]);
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_SeriesContext.SeriesContext.Provider, {
|
|
34
|
+
value: formattedSeries,
|
|
35
|
+
children: children
|
|
36
|
+
});
|
|
37
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from './SeriesProvider';
|
|
2
|
+
export * from './SeriesContext';
|
|
3
|
+
export * from './Series.types';
|
|
4
|
+
declare const seriesProviderUtils: {
|
|
5
|
+
preprocessSeries: <T extends import("../../internals").ChartSeriesType>({ series, colors, seriesFormatters, dataset, }: {
|
|
6
|
+
series: import("../..").AllSeriesType<T>[];
|
|
7
|
+
colors: string[];
|
|
8
|
+
seriesFormatters: import("./Series.types").SeriesFormatterConfig<T>;
|
|
9
|
+
dataset?: import("../../internals").DatasetType;
|
|
10
|
+
}) => import("./Series.types").FormattedSeries;
|
|
11
|
+
};
|
|
12
|
+
export { seriesProviderUtils };
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
seriesProviderUtils: true
|
|
8
|
+
};
|
|
9
|
+
exports.seriesProviderUtils = void 0;
|
|
10
|
+
var _processSeries = require("./processSeries");
|
|
11
|
+
var _SeriesProvider = require("./SeriesProvider");
|
|
12
|
+
Object.keys(_SeriesProvider).forEach(function (key) {
|
|
13
|
+
if (key === "default" || key === "__esModule") return;
|
|
14
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
15
|
+
if (key in exports && exports[key] === _SeriesProvider[key]) return;
|
|
16
|
+
Object.defineProperty(exports, key, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () {
|
|
19
|
+
return _SeriesProvider[key];
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
var _SeriesContext = require("./SeriesContext");
|
|
24
|
+
Object.keys(_SeriesContext).forEach(function (key) {
|
|
25
|
+
if (key === "default" || key === "__esModule") return;
|
|
26
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
27
|
+
if (key in exports && exports[key] === _SeriesContext[key]) return;
|
|
28
|
+
Object.defineProperty(exports, key, {
|
|
29
|
+
enumerable: true,
|
|
30
|
+
get: function () {
|
|
31
|
+
return _SeriesContext[key];
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
var _Series = require("./Series.types");
|
|
36
|
+
Object.keys(_Series).forEach(function (key) {
|
|
37
|
+
if (key === "default" || key === "__esModule") return;
|
|
38
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
39
|
+
if (key in exports && exports[key] === _Series[key]) return;
|
|
40
|
+
Object.defineProperty(exports, key, {
|
|
41
|
+
enumerable: true,
|
|
42
|
+
get: function () {
|
|
43
|
+
return _Series[key];
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
const seriesProviderUtils = exports.seriesProviderUtils = {
|
|
48
|
+
preprocessSeries: _processSeries.preprocessSeries
|
|
49
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AllSeriesType } from '../../models/seriesType';
|
|
2
|
+
import { ChartSeriesType, DatasetType } from '../../models/seriesType/config';
|
|
3
|
+
import { FormattedSeries, SeriesFormatterConfig } from './Series.types';
|
|
4
|
+
/**
|
|
5
|
+
* This methods is the interface between what the developer is providing and what components receives
|
|
6
|
+
* To simplify the components behaviors, it groups series by type, such that LinePlots props are not updated if some line data are modified
|
|
7
|
+
* It also add defaultized values such as the ids, colors
|
|
8
|
+
* @param series The array of series provided by the developer
|
|
9
|
+
* @param colors The color palette used to defaultize series colors
|
|
10
|
+
* @returns An object structuring all the series by type.
|
|
11
|
+
*/
|
|
12
|
+
export declare const preprocessSeries: <T extends ChartSeriesType>({ series, colors, seriesFormatters, dataset, }: {
|
|
13
|
+
series: AllSeriesType<T>[];
|
|
14
|
+
colors: string[];
|
|
15
|
+
seriesFormatters: SeriesFormatterConfig<T>;
|
|
16
|
+
dataset?: DatasetType;
|
|
17
|
+
}) => FormattedSeries;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.preprocessSeries = void 0;
|
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
|
+
var _defaultizeColor = require("../../internals/defaultizeColor");
|
|
10
|
+
/**
|
|
11
|
+
* This methods is the interface between what the developer is providing and what components receives
|
|
12
|
+
* To simplify the components behaviors, it groups series by type, such that LinePlots props are not updated if some line data are modified
|
|
13
|
+
* It also add defaultized values such as the ids, colors
|
|
14
|
+
* @param series The array of series provided by the developer
|
|
15
|
+
* @param colors The color palette used to defaultize series colors
|
|
16
|
+
* @returns An object structuring all the series by type.
|
|
17
|
+
*/
|
|
18
|
+
const preprocessSeries = ({
|
|
19
|
+
series,
|
|
20
|
+
colors,
|
|
21
|
+
seriesFormatters,
|
|
22
|
+
dataset
|
|
23
|
+
}) => {
|
|
24
|
+
// Group series by type
|
|
25
|
+
const seriesGroups = {};
|
|
26
|
+
series.forEach((seriesData, seriesIndex) => {
|
|
27
|
+
const {
|
|
28
|
+
id = `auto-generated-id-${seriesIndex}`,
|
|
29
|
+
type
|
|
30
|
+
} = seriesData;
|
|
31
|
+
if (seriesGroups[type] === undefined) {
|
|
32
|
+
seriesGroups[type] = {
|
|
33
|
+
series: {},
|
|
34
|
+
seriesOrder: []
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
if (seriesGroups[type]?.series[id] !== undefined) {
|
|
38
|
+
throw new Error(`MUI X: series' id "${id}" is not unique.`);
|
|
39
|
+
}
|
|
40
|
+
seriesGroups[type].series[id] = (0, _extends2.default)({
|
|
41
|
+
id
|
|
42
|
+
}, (0, _defaultizeColor.defaultizeColor)(seriesData, seriesIndex, colors));
|
|
43
|
+
seriesGroups[type].seriesOrder.push(id);
|
|
44
|
+
});
|
|
45
|
+
const formattedSeries = {};
|
|
46
|
+
// Apply formatter on a type group
|
|
47
|
+
Object.keys(seriesFormatters).forEach(type => {
|
|
48
|
+
const group = seriesGroups[type];
|
|
49
|
+
if (group !== undefined) {
|
|
50
|
+
formattedSeries[type] = seriesFormatters[type]?.(group, dataset) ?? seriesGroups[type];
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
return formattedSeries;
|
|
54
|
+
};
|
|
55
|
+
exports.preprocessSeries = preprocessSeries;
|
|
@@ -32,7 +32,7 @@ function ZAxisContextProvider(props) {
|
|
|
32
32
|
return axisConfig;
|
|
33
33
|
}
|
|
34
34
|
if (dataset === undefined) {
|
|
35
|
-
throw Error('MUI X
|
|
35
|
+
throw Error('MUI X: z-axis uses `dataKey` but no `dataset` is provided.');
|
|
36
36
|
}
|
|
37
37
|
return (0, _extends2.default)({}, axisConfig, {
|
|
38
38
|
data: dataset.map(d => d[dataKey])
|
package/esm/BarChart/BarChart.js
CHANGED
|
@@ -239,7 +239,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
239
239
|
* An array of [[AxisConfig]] objects.
|
|
240
240
|
*/
|
|
241
241
|
xAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
242
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
243
242
|
classes: PropTypes.object,
|
|
244
243
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
245
244
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
@@ -292,7 +291,6 @@ process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
|
292
291
|
* An array of [[AxisConfig]] objects.
|
|
293
292
|
*/
|
|
294
293
|
yAxis: PropTypes.arrayOf(PropTypes.shape({
|
|
295
|
-
axisId: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
|
|
296
294
|
classes: PropTypes.object,
|
|
297
295
|
colorMap: PropTypes.oneOfType([PropTypes.shape({
|
|
298
296
|
colors: PropTypes.arrayOf(PropTypes.string).isRequired,
|
|
@@ -4,11 +4,11 @@ const _excluded = ["id", "dataIndex", "classes", "color", "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 { styled } from '@mui/material/styles';
|
|
10
|
-
import { color as d3Color } from 'd3-color';
|
|
11
10
|
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
11
|
+
import { color as d3Color } from '@mui/x-charts-vendor/d3-color';
|
|
12
12
|
import { animated } from '@react-spring/web';
|
|
13
13
|
import { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
14
14
|
import { useItemHighlighted } from '../context';
|
|
@@ -3,7 +3,7 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
3
3
|
const _excluded = ["seriesId", "classes", "color", "style", "dataIndex", "barLabel", "slots", "slotProps", "height", "width", "value"],
|
|
4
4
|
_excluded2 = ["ownerState"];
|
|
5
5
|
import * as React from 'react';
|
|
6
|
-
import
|
|
6
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useUtilityClasses } from './barLabelClasses';
|
|
9
9
|
import { getBarLabel } from './getBarLabel';
|
package/esm/BarChart/BarPlot.js
CHANGED
|
@@ -66,16 +66,16 @@ const useAggregatedData = () => {
|
|
|
66
66
|
ids: groupIds
|
|
67
67
|
}, groupIndex) => {
|
|
68
68
|
return groupIds.flatMap(seriesId => {
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const xAxisConfig = xAxis[
|
|
72
|
-
const yAxisConfig = yAxis[
|
|
69
|
+
const xAxisId = series[seriesId].xAxisId ?? series[seriesId].xAxisKey ?? defaultXAxisId;
|
|
70
|
+
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey ?? defaultYAxisId;
|
|
71
|
+
const xAxisConfig = xAxis[xAxisId];
|
|
72
|
+
const yAxisConfig = yAxis[yAxisId];
|
|
73
73
|
const verticalLayout = series[seriesId].layout === 'vertical';
|
|
74
|
-
checkScaleErrors(verticalLayout, seriesId,
|
|
74
|
+
checkScaleErrors(verticalLayout, seriesId, xAxisId, xAxis, yAxisId, yAxis);
|
|
75
75
|
const baseScaleConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
76
76
|
const xScale = xAxisConfig.scale;
|
|
77
77
|
const yScale = yAxisConfig.scale;
|
|
78
|
-
const colorGetter = getColor(series[seriesId], xAxis[
|
|
78
|
+
const colorGetter = getColor(series[seriesId], xAxis[xAxisId], yAxis[yAxisId]);
|
|
79
79
|
const bandWidth = baseScaleConfig.scale.bandwidth();
|
|
80
80
|
const {
|
|
81
81
|
barWidth,
|
|
@@ -98,8 +98,8 @@ const useAggregatedData = () => {
|
|
|
98
98
|
seriesId,
|
|
99
99
|
dataIndex,
|
|
100
100
|
layout: series[seriesId].layout,
|
|
101
|
-
x: verticalLayout ? xScale(xAxis[
|
|
102
|
-
y: verticalLayout ? minValueCoord : yScale(yAxis[
|
|
101
|
+
x: verticalLayout ? xScale(xAxis[xAxisId].data?.[dataIndex]) + barOffset : minValueCoord,
|
|
102
|
+
y: verticalLayout ? minValueCoord : yScale(yAxis[yAxisId].data?.[dataIndex]) + barOffset,
|
|
103
103
|
xOrigin: xScale(0),
|
|
104
104
|
yOrigin: yScale(0),
|
|
105
105
|
height: verticalLayout ? maxValueCoord - minValueCoord : barWidth,
|
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
2
2
|
import { isBandScaleConfig, isPointScaleConfig } from '../models/axis';
|
|
3
|
-
const getAxisMessage = (axisDirection,
|
|
3
|
+
const getAxisMessage = (axisDirection, axisId) => {
|
|
4
4
|
const axisName = `${axisDirection}-axis`;
|
|
5
|
-
const
|
|
5
|
+
const axisIdName = `${axisDirection}Axis`;
|
|
6
6
|
const axisDefaultKey = axisDirection === 'x' ? DEFAULT_X_AXIS_KEY : DEFAULT_Y_AXIS_KEY;
|
|
7
|
-
return
|
|
7
|
+
return axisId === axisDefaultKey ? `The first \`${axisIdName}\`` : `The ${axisName} with id "${axisId}"`;
|
|
8
8
|
};
|
|
9
|
-
export function checkScaleErrors(verticalLayout, seriesId,
|
|
10
|
-
const xAxisConfig = xAxis[
|
|
11
|
-
const yAxisConfig = yAxis[
|
|
9
|
+
export function checkScaleErrors(verticalLayout, seriesId, xAxisId, xAxis, yAxisId, yAxis) {
|
|
10
|
+
const xAxisConfig = xAxis[xAxisId];
|
|
11
|
+
const yAxisConfig = yAxis[yAxisId];
|
|
12
12
|
const discreteAxisConfig = verticalLayout ? xAxisConfig : yAxisConfig;
|
|
13
13
|
const continuousAxisConfig = verticalLayout ? yAxisConfig : xAxisConfig;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
14
|
+
const discreteAxisId = verticalLayout ? xAxisId : yAxisId;
|
|
15
|
+
const continuousAxisId = verticalLayout ? yAxisId : xAxisId;
|
|
16
16
|
const discreteAxisDirection = verticalLayout ? 'x' : 'y';
|
|
17
17
|
const continuousAxisDirection = verticalLayout ? 'y' : 'x';
|
|
18
18
|
if (!isBandScaleConfig(discreteAxisConfig)) {
|
|
19
|
-
throw new Error(`MUI X
|
|
19
|
+
throw new Error(`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should be of type "band" to display the bar series of id "${seriesId}".`);
|
|
20
20
|
}
|
|
21
21
|
if (discreteAxisConfig.data === undefined) {
|
|
22
|
-
throw new Error(`MUI X
|
|
22
|
+
throw new Error(`MUI X: ${getAxisMessage(discreteAxisDirection, discreteAxisId)} should have data property.`);
|
|
23
23
|
}
|
|
24
24
|
if (isBandScaleConfig(continuousAxisConfig) || isPointScaleConfig(continuousAxisConfig)) {
|
|
25
|
-
throw new Error(`MUI X
|
|
25
|
+
throw new Error(`MUI X: ${getAxisMessage(continuousAxisDirection, continuousAxisId)} should be a continuous type to display the bar series of id "${seriesId}".`);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -12,7 +12,10 @@ const getValueExtremum = params => {
|
|
|
12
12
|
axis,
|
|
13
13
|
isDefaultAxis
|
|
14
14
|
} = params;
|
|
15
|
-
return Object.keys(series).filter(seriesId =>
|
|
15
|
+
return Object.keys(series).filter(seriesId => {
|
|
16
|
+
const yAxisId = series[seriesId].yAxisId ?? series[seriesId].yAxisKey;
|
|
17
|
+
return yAxisId === axis.id || isDefaultAxis && yAxisId === undefined;
|
|
18
|
+
}).reduce((acc, seriesId) => {
|
|
16
19
|
const [seriesMin, seriesMax] = series[seriesId].stackedData?.reduce((seriesAcc, values) => [Math.min(...values, ...(seriesAcc[0] === null ? [] : [seriesAcc[0]])), Math.max(...values, ...(seriesAcc[1] === null ? [] : [seriesAcc[1]]))], series[seriesId].stackedData[0]) ?? [null, null];
|
|
17
20
|
return [acc[0] === null ? seriesMin : Math.min(seriesMin, acc[0]), acc[1] === null ? seriesMax : Math.max(seriesMax, acc[1])];
|
|
18
21
|
}, [null, null]);
|