@mui/x-charts 7.10.0 → 7.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/BarChart/BarChart.js +2 -2
- package/BarChart/BarElement.d.ts +2 -1
- package/BarChart/BarLabel/BarLabelItem.d.ts +2 -1
- package/BarChart/BarPlot.js +8 -8
- package/BarChart/checkScaleErrors.d.ts +4 -4
- package/BarChart/checkScaleErrors.js +11 -11
- package/BarChart/extremums.js +4 -1
- package/BarChart/formatter.js +2 -2
- package/BarChart/useBarChartProps.js +38 -33
- package/CHANGELOG.md +169 -0
- package/ChartContainer/ChartContainer.d.ts +28 -2
- package/ChartContainer/ChartContainer.js +25 -66
- package/ChartContainer/useChartContainerHooks.d.ts +1 -1
- package/ChartContainer/useChartContainerHooks.js +2 -2
- package/ChartContainer/useChartContainerProps.d.ts +86 -0
- package/ChartContainer/useChartContainerProps.js +95 -0
- package/ChartContainer/useDefaultizeAxis.d.ts +36 -0
- package/ChartContainer/useDefaultizeAxis.js +29 -0
- package/ChartsAxis/ChartsAxis.js +4 -4
- package/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/ChartsLegend/ChartsLegend.d.ts +3 -12
- package/ChartsLegend/ContinuousColorLegend.d.ts +65 -0
- package/ChartsLegend/ContinuousColorLegend.js +398 -0
- package/ChartsLegend/DefaultChartsLegend.d.ts +7 -50
- package/ChartsLegend/DefaultChartsLegend.js +13 -198
- package/ChartsLegend/LegendPerItem.d.ts +61 -0
- package/ChartsLegend/LegendPerItem.js +151 -0
- package/ChartsLegend/PiecewiseColorLegend.d.ts +26 -0
- package/ChartsLegend/PiecewiseColorLegend.js +169 -0
- package/ChartsLegend/chartsLegend.types.d.ts +31 -0
- package/ChartsLegend/chartsLegend.types.js +5 -0
- package/ChartsLegend/index.d.ts +2 -0
- package/ChartsLegend/index.js +22 -0
- package/ChartsLegend/legend.types.d.ts +62 -0
- package/ChartsLegend/legend.types.js +5 -0
- package/ChartsLegend/legendItemsPlacement.d.ts +3 -0
- package/ChartsLegend/legendItemsPlacement.js +79 -0
- package/ChartsLegend/useAxis.d.ts +7 -0
- package/ChartsLegend/useAxis.js +47 -0
- package/ChartsLegend/utils.d.ts +1 -8
- package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +3 -1
- package/ChartsOverlay/ChartsOverlay.d.ts +3 -2
- package/ChartsReferenceLine/ChartsReferenceLine.d.ts +1 -1
- package/ChartsReferenceLine/ChartsReferenceLine.js +2 -2
- package/ChartsReferenceLine/ChartsXReferenceLine.js +1 -2
- package/ChartsReferenceLine/ChartsYReferenceLine.js +1 -2
- package/ChartsSurface.js +3 -1
- package/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/ChartsXAxis/ChartsXAxis.js +1 -1
- package/ChartsYAxis/ChartsYAxis.js +15 -3
- package/Gauge/Gauge.d.ts +1 -4
- package/Gauge/Gauge.js +9 -6
- package/Gauge/GaugeContainer.js +8 -4
- package/Gauge/GaugeProvider.js +9 -9
- package/LineChart/AnimatedArea.js +2 -2
- package/LineChart/AnimatedLine.js +2 -2
- package/LineChart/AreaElement.d.ts +2 -1
- package/LineChart/AreaPlot.js +10 -6
- package/LineChart/LineChart.js +5 -2
- package/LineChart/LineElement.d.ts +2 -1
- package/LineChart/LineHighlightPlot.d.ts +2 -1
- package/LineChart/LineHighlightPlot.js +17 -5
- package/LineChart/LinePlot.js +10 -6
- package/LineChart/MarkElement.js +2 -2
- package/LineChart/MarkPlot.js +13 -25
- package/LineChart/extremums.js +4 -1
- package/LineChart/formatter.js +2 -2
- package/LineChart/useLineChartProps.js +38 -33
- package/PieChart/PieArc.js +1 -0
- package/PieChart/PieChart.d.ts +1 -4
- package/PieChart/PieChart.js +40 -34
- package/PieChart/PiePlot.js +6 -6
- package/PieChart/getPieCoordinates.js +3 -3
- package/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/ResponsiveChartContainer/useChartContainerDimensions.d.ts +5 -1
- package/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.d.ts +20 -0
- package/ResponsiveChartContainer/useResponsiveChartContainerProps.js +73 -0
- package/ScatterChart/Scatter.js +6 -9
- package/ScatterChart/ScatterChart.js +4 -1
- package/ScatterChart/ScatterPlot.js +6 -3
- package/ScatterChart/extremums.js +8 -2
- package/ScatterChart/useScatterChartProps.js +35 -30
- package/SparkLineChart/SparkLineChart.js +27 -22
- package/context/CartesianProvider/CartesianContext.d.ts +1 -1
- package/context/CartesianProvider/CartesianProvider.d.ts +2 -3
- package/context/CartesianProvider/CartesianProvider.js +18 -7
- package/context/CartesianProvider/computeValue.d.ts +32 -9
- package/context/CartesianProvider/computeValue.js +20 -16
- package/context/CartesianProvider/defaultizeAxis.d.ts +36 -0
- package/context/CartesianProvider/defaultizeAxis.js +21 -0
- package/context/CartesianProvider/index.d.ts +0 -1
- package/context/CartesianProvider/index.js +1 -3
- package/context/CartesianProvider/normalizeAxis.d.ts +1 -1
- package/context/CartesianProvider/normalizeAxis.js +2 -2
- package/context/DrawingProvider.d.ts +12 -0
- package/context/DrawingProvider.js +15 -2
- package/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/context/SeriesContextProvider.js +1 -1
- package/context/ZAxisContextProvider.d.ts +1 -1
- package/context/ZAxisContextProvider.js +1 -1
- package/esm/BarChart/BarChart.js +2 -2
- package/esm/BarChart/BarPlot.js +8 -8
- package/esm/BarChart/checkScaleErrors.js +11 -11
- package/esm/BarChart/extremums.js +4 -1
- package/esm/BarChart/formatter.js +2 -2
- package/esm/BarChart/useBarChartProps.js +38 -33
- package/esm/ChartContainer/ChartContainer.js +25 -66
- package/esm/ChartContainer/useChartContainerHooks.js +2 -2
- package/esm/ChartContainer/useChartContainerProps.js +87 -0
- package/esm/ChartContainer/useDefaultizeAxis.js +19 -0
- package/esm/ChartsAxis/ChartsAxis.js +4 -4
- package/esm/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/esm/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/esm/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/esm/ChartsLegend/LegendPerItem.js +141 -0
- package/esm/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/esm/ChartsLegend/chartsLegend.types.js +1 -0
- package/esm/ChartsLegend/index.js +2 -0
- package/esm/ChartsLegend/legend.types.js +1 -0
- package/esm/ChartsLegend/legendItemsPlacement.js +72 -0
- package/esm/ChartsLegend/useAxis.js +39 -0
- 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/ChartsSurface.js +3 -1
- package/esm/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/esm/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/esm/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/esm/ChartsXAxis/ChartsXAxis.js +1 -1
- package/esm/ChartsYAxis/ChartsYAxis.js +15 -3
- package/esm/Gauge/Gauge.js +8 -5
- package/esm/Gauge/GaugeContainer.js +8 -4
- package/esm/Gauge/GaugeProvider.js +1 -1
- package/esm/LineChart/AnimatedArea.js +1 -1
- package/esm/LineChart/AnimatedLine.js +1 -1
- package/esm/LineChart/AreaPlot.js +10 -6
- package/esm/LineChart/LineChart.js +5 -2
- package/esm/LineChart/LineHighlightPlot.js +17 -5
- package/esm/LineChart/LinePlot.js +10 -6
- package/esm/LineChart/MarkElement.js +1 -1
- package/esm/LineChart/MarkPlot.js +12 -24
- package/esm/LineChart/extremums.js +4 -1
- package/esm/LineChart/formatter.js +2 -2
- package/esm/LineChart/useLineChartProps.js +38 -33
- package/esm/PieChart/PieArc.js +1 -0
- package/esm/PieChart/PieChart.js +39 -33
- package/esm/PieChart/PiePlot.js +1 -1
- package/esm/PieChart/getPieCoordinates.js +1 -1
- package/esm/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/esm/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/esm/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/esm/ScatterChart/Scatter.js +6 -9
- package/esm/ScatterChart/ScatterChart.js +4 -1
- package/esm/ScatterChart/ScatterPlot.js +6 -3
- package/esm/ScatterChart/extremums.js +8 -2
- package/esm/ScatterChart/useScatterChartProps.js +35 -30
- package/esm/SparkLineChart/SparkLineChart.js +27 -22
- package/esm/context/CartesianProvider/CartesianProvider.js +18 -7
- package/esm/context/CartesianProvider/computeValue.js +20 -16
- package/esm/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/esm/context/CartesianProvider/index.js +1 -3
- package/esm/context/CartesianProvider/normalizeAxis.js +2 -2
- package/esm/context/DrawingProvider.js +15 -2
- package/esm/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/esm/context/SeriesContextProvider.js +1 -1
- package/esm/context/ZAxisContextProvider.js +1 -1
- package/esm/hooks/useAxisEvents.js +14 -17
- package/esm/hooks/useDrawingArea.js +5 -3
- package/esm/hooks/useReducedMotion.js +4 -2
- package/esm/internals/SlotComponentPropsFromProps.js +1 -0
- package/esm/internals/cleanId.js +6 -0
- package/esm/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/esm/internals/geometry.js +1 -1
- package/esm/internals/{utils.js → getPercentageValue.js} +1 -13
- package/esm/internals/getSymbol.js +5 -0
- package/esm/internals/index.js +3 -1
- package/esm/internals/isDefined.js +3 -0
- package/esm/internals/notNull.js +3 -0
- package/esm/internals/ts-generic.js +1 -0
- package/esm/internals/warning.js +19 -11
- package/hooks/useAxisEvents.js +14 -17
- package/hooks/useDrawingArea.js +5 -3
- package/hooks/useReducedMotion.js +4 -2
- package/index.js +1 -1
- package/internals/SlotComponentPropsFromProps.d.ts +1 -0
- package/internals/SlotComponentPropsFromProps.js +5 -0
- package/internals/cleanId.d.ts +4 -0
- package/internals/cleanId.js +12 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.d.ts +6 -0
- package/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/internals/defaultizeColor.d.ts +7 -0
- package/internals/geometry.js +1 -1
- package/internals/getPercentageValue.d.ts +7 -0
- package/internals/{utils.js → getPercentageValue.js} +1 -15
- package/internals/getSymbol.d.ts +2 -0
- package/internals/getSymbol.js +11 -0
- package/internals/index.d.ts +3 -1
- package/internals/index.js +25 -5
- package/internals/isDefined.d.ts +1 -0
- package/internals/isDefined.js +9 -0
- package/internals/notNull.d.ts +1 -0
- package/internals/notNull.js +9 -0
- package/internals/ts-generic.d.ts +5 -0
- package/internals/ts-generic.js +5 -0
- package/internals/warning.d.ts +2 -1
- package/internals/warning.js +21 -12
- package/models/axis.d.ts +5 -2
- package/models/helpers.d.ts +1 -0
- package/models/seriesType/common.d.ts +10 -0
- package/models/seriesType/config.d.ts +2 -16
- package/models/seriesType/scatter.d.ts +5 -0
- package/modern/BarChart/BarChart.js +2 -2
- package/modern/BarChart/BarPlot.js +8 -8
- package/modern/BarChart/checkScaleErrors.js +11 -11
- package/modern/BarChart/extremums.js +4 -1
- package/modern/BarChart/formatter.js +2 -2
- package/modern/BarChart/useBarChartProps.js +38 -33
- package/modern/ChartContainer/ChartContainer.js +25 -66
- package/modern/ChartContainer/useChartContainerHooks.js +2 -2
- package/modern/ChartContainer/useChartContainerProps.js +87 -0
- package/modern/ChartContainer/useDefaultizeAxis.js +19 -0
- package/modern/ChartsAxis/ChartsAxis.js +4 -4
- package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +1 -1
- package/modern/ChartsLegend/ContinuousColorLegend.js +390 -0
- package/modern/ChartsLegend/DefaultChartsLegend.js +14 -198
- package/modern/ChartsLegend/LegendPerItem.js +141 -0
- package/modern/ChartsLegend/PiecewiseColorLegend.js +161 -0
- package/modern/ChartsLegend/chartsLegend.types.js +1 -0
- package/modern/ChartsLegend/index.js +2 -0
- package/modern/ChartsLegend/legend.types.js +1 -0
- package/modern/ChartsLegend/legendItemsPlacement.js +72 -0
- package/modern/ChartsLegend/useAxis.js +39 -0
- 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/ChartsSurface.js +3 -1
- package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +7 -3
- package/modern/ChartsTooltip/ChartsItemTooltipContent.js +4 -4
- package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +30 -20
- package/modern/ChartsXAxis/ChartsXAxis.js +1 -1
- package/modern/ChartsYAxis/ChartsYAxis.js +15 -3
- package/modern/Gauge/Gauge.js +8 -5
- package/modern/Gauge/GaugeContainer.js +8 -4
- package/modern/Gauge/GaugeProvider.js +1 -1
- package/modern/LineChart/AnimatedArea.js +1 -1
- package/modern/LineChart/AnimatedLine.js +1 -1
- package/modern/LineChart/AreaPlot.js +10 -6
- package/modern/LineChart/LineChart.js +5 -2
- package/modern/LineChart/LineHighlightPlot.js +17 -5
- package/modern/LineChart/LinePlot.js +10 -6
- package/modern/LineChart/MarkElement.js +1 -1
- package/modern/LineChart/MarkPlot.js +12 -24
- package/modern/LineChart/extremums.js +4 -1
- package/modern/LineChart/formatter.js +2 -2
- package/modern/LineChart/useLineChartProps.js +38 -33
- package/modern/PieChart/PieArc.js +1 -0
- package/modern/PieChart/PieChart.js +39 -33
- package/modern/PieChart/PiePlot.js +1 -1
- package/modern/PieChart/getPieCoordinates.js +1 -1
- package/modern/ResponsiveChartContainer/ResponsiveChartContainer.js +8 -20
- package/modern/ResponsiveChartContainer/useChartContainerDimensions.js +8 -4
- package/modern/ResponsiveChartContainer/useResponsiveChartContainerProps.js +65 -0
- package/modern/ScatterChart/Scatter.js +6 -9
- package/modern/ScatterChart/ScatterChart.js +4 -1
- package/modern/ScatterChart/ScatterPlot.js +6 -3
- package/modern/ScatterChart/extremums.js +8 -2
- package/modern/ScatterChart/useScatterChartProps.js +35 -30
- package/modern/SparkLineChart/SparkLineChart.js +27 -22
- package/modern/context/CartesianProvider/CartesianProvider.js +18 -7
- package/modern/context/CartesianProvider/computeValue.js +20 -16
- package/modern/context/CartesianProvider/defaultizeAxis.js +13 -0
- package/modern/context/CartesianProvider/index.js +1 -3
- package/modern/context/CartesianProvider/normalizeAxis.js +2 -2
- package/modern/context/DrawingProvider.js +15 -2
- package/modern/context/HighlightedProvider/HighlightedProvider.js +2 -2
- package/modern/context/SeriesContextProvider.js +1 -1
- package/modern/context/ZAxisContextProvider.js +1 -1
- package/modern/hooks/useAxisEvents.js +14 -17
- package/modern/hooks/useDrawingArea.js +5 -3
- package/modern/hooks/useReducedMotion.js +4 -2
- package/modern/index.js +1 -1
- package/modern/internals/SlotComponentPropsFromProps.js +1 -0
- package/modern/internals/cleanId.js +6 -0
- package/modern/internals/components/ChartsAxesGradients/ChartsContinuousGradient.js +3 -2
- package/modern/internals/geometry.js +1 -1
- package/modern/internals/{utils.js → getPercentageValue.js} +1 -13
- package/modern/internals/getSymbol.js +5 -0
- package/modern/internals/index.js +3 -1
- package/modern/internals/isDefined.js +3 -0
- package/modern/internals/notNull.js +3 -0
- package/modern/internals/ts-generic.js +1 -0
- package/modern/internals/warning.js +19 -11
- package/package.json +4 -4
- package/internals/utils.d.ts +0 -18
|
@@ -56,6 +56,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
56
56
|
highlightScope?: Partial<import("..").HighlightScope>;
|
|
57
57
|
xAxisKey?: string;
|
|
58
58
|
yAxisKey?: string;
|
|
59
|
+
xAxisId?: string;
|
|
60
|
+
yAxisId?: string;
|
|
59
61
|
stack?: string;
|
|
60
62
|
stackOrder?: import("..").StackOrderType;
|
|
61
63
|
} | {
|
|
@@ -76,6 +78,8 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
76
78
|
highlightScope?: Partial<import("..").HighlightScope>;
|
|
77
79
|
xAxisKey?: string;
|
|
78
80
|
yAxisKey?: string;
|
|
81
|
+
xAxisId?: string;
|
|
82
|
+
yAxisId?: string;
|
|
79
83
|
stackOrder?: import("..").StackOrderType;
|
|
80
84
|
} | {
|
|
81
85
|
type: "scatter";
|
|
@@ -84,10 +88,13 @@ export declare function defaultizeColor(series: AllSeriesType, seriesIndex: numb
|
|
|
84
88
|
label?: string | ((location: "tooltip" | "legend") => string);
|
|
85
89
|
disableHover?: boolean;
|
|
86
90
|
zAxisKey?: string;
|
|
91
|
+
zAxisId?: string;
|
|
87
92
|
id?: import(".").SeriesId;
|
|
88
93
|
color: string;
|
|
89
94
|
valueFormatter?: import(".").SeriesValueFormatter<import("../models/seriesType").ScatterValueType> | undefined;
|
|
90
95
|
highlightScope?: Partial<import("..").HighlightScope>;
|
|
91
96
|
xAxisKey?: string;
|
|
92
97
|
yAxisKey?: string;
|
|
98
|
+
xAxisId?: string;
|
|
99
|
+
yAxisId?: string;
|
|
93
100
|
};
|
package/internals/geometry.js
CHANGED
|
@@ -20,7 +20,7 @@ function getMinXTranslation(width, height, angle = 0) {
|
|
|
20
20
|
if (process.env.NODE_ENV !== 'production') {
|
|
21
21
|
if (!warnedOnce && angle > 90 && angle < -90) {
|
|
22
22
|
warnedOnce = true;
|
|
23
|
-
console.warn([`MUI X
|
|
23
|
+
console.warn([`MUI X: It seems you applied an angle larger than 90° or smaller than -90° to an axis text.`, `This could cause some text overlapping.`, `If you encounter a use case where it's needed, please open an issue.`].join('\n'));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
const standardAngle = Math.min(Math.abs(angle) % 180, Math.abs(Math.abs(angle) % 180 - 180) % 180); // Map from R to [0, 90]
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper that converts values and percentages into values.
|
|
3
|
+
* @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
|
|
4
|
+
* @param refValue The numerical value associated to 100%.
|
|
5
|
+
* @returns The numerical value associated to the provided value.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPercentageValue(value: number | string, refValue: number): number;
|
|
@@ -3,14 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.cleanId = cleanId;
|
|
7
6
|
exports.getPercentageValue = getPercentageValue;
|
|
8
|
-
exports.getSymbol = getSymbol;
|
|
9
|
-
// Returns the index of a defined shape
|
|
10
|
-
function getSymbol(shape) {
|
|
11
|
-
const symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
|
|
12
|
-
return symbolNames.indexOf(shape) || 0;
|
|
13
|
-
}
|
|
14
7
|
/**
|
|
15
8
|
* Helper that converts values and percentages into values.
|
|
16
9
|
* @param value The value provided by the developer. Can either be a number or a string with '%' or 'px'.
|
|
@@ -37,12 +30,5 @@ function getPercentageValue(value, refValue) {
|
|
|
37
30
|
return val;
|
|
38
31
|
}
|
|
39
32
|
}
|
|
40
|
-
throw Error(`MUI
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Remove spaces to have viable ids
|
|
45
|
-
*/
|
|
46
|
-
function cleanId(id) {
|
|
47
|
-
return id.replace(' ', '_');
|
|
33
|
+
throw Error(`MUI X: Received an unknown value "${value}". It should be a number, or a string with a percentage value.`);
|
|
48
34
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getSymbol = getSymbol;
|
|
7
|
+
// Returns the index of a defined shape
|
|
8
|
+
function getSymbol(shape) {
|
|
9
|
+
const symbolNames = 'circle cross diamond square star triangle wye'.split(/ /);
|
|
10
|
+
return symbolNames.indexOf(shape) || 0;
|
|
11
|
+
}
|
package/internals/index.d.ts
CHANGED
|
@@ -5,14 +5,16 @@ export { useReducedMotion } from '../hooks/useReducedMotion';
|
|
|
5
5
|
export { useSeries } from '../hooks/useSeries';
|
|
6
6
|
export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
|
|
7
7
|
export { useDrawingArea } from '../hooks/useDrawingArea';
|
|
8
|
-
export { useChartContainerHooks } from '../ChartContainer/useChartContainerHooks';
|
|
9
8
|
export { useScatterChartProps } from '../ScatterChart/useScatterChartProps';
|
|
10
9
|
export { useLineChartProps } from '../LineChart/useLineChartProps';
|
|
11
10
|
export { useBarChartProps } from '../BarChart/useBarChartProps';
|
|
11
|
+
export { useResponsiveChartContainerProps } from '../ResponsiveChartContainer/useResponsiveChartContainerProps';
|
|
12
|
+
export { useChartContainerProps } from '../ChartContainer/useChartContainerProps';
|
|
12
13
|
export * from './defaultizeValueFormatter';
|
|
13
14
|
export * from './configInit';
|
|
14
15
|
export * from './getLabel';
|
|
15
16
|
export * from './getSVGPoint';
|
|
17
|
+
export * from './isDefined';
|
|
16
18
|
export * from '../context/CartesianProvider';
|
|
17
19
|
export * from '../context/DrawingProvider';
|
|
18
20
|
export * from '../context/ColorProvider';
|
package/internals/index.js
CHANGED
|
@@ -8,10 +8,11 @@ var _exportNames = {
|
|
|
8
8
|
useSeries: true,
|
|
9
9
|
useInteractionItemProps: true,
|
|
10
10
|
useDrawingArea: true,
|
|
11
|
-
useChartContainerHooks: true,
|
|
12
11
|
useScatterChartProps: true,
|
|
13
12
|
useLineChartProps: true,
|
|
14
|
-
useBarChartProps: true
|
|
13
|
+
useBarChartProps: true,
|
|
14
|
+
useResponsiveChartContainerProps: true,
|
|
15
|
+
useChartContainerProps: true
|
|
15
16
|
};
|
|
16
17
|
Object.defineProperty(exports, "useBarChartProps", {
|
|
17
18
|
enumerable: true,
|
|
@@ -19,10 +20,10 @@ Object.defineProperty(exports, "useBarChartProps", {
|
|
|
19
20
|
return _useBarChartProps.useBarChartProps;
|
|
20
21
|
}
|
|
21
22
|
});
|
|
22
|
-
Object.defineProperty(exports, "
|
|
23
|
+
Object.defineProperty(exports, "useChartContainerProps", {
|
|
23
24
|
enumerable: true,
|
|
24
25
|
get: function () {
|
|
25
|
-
return
|
|
26
|
+
return _useChartContainerProps.useChartContainerProps;
|
|
26
27
|
}
|
|
27
28
|
});
|
|
28
29
|
Object.defineProperty(exports, "useDrawingArea", {
|
|
@@ -49,6 +50,12 @@ Object.defineProperty(exports, "useReducedMotion", {
|
|
|
49
50
|
return _useReducedMotion.useReducedMotion;
|
|
50
51
|
}
|
|
51
52
|
});
|
|
53
|
+
Object.defineProperty(exports, "useResponsiveChartContainerProps", {
|
|
54
|
+
enumerable: true,
|
|
55
|
+
get: function () {
|
|
56
|
+
return _useResponsiveChartContainerProps.useResponsiveChartContainerProps;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
52
59
|
Object.defineProperty(exports, "useScatterChartProps", {
|
|
53
60
|
enumerable: true,
|
|
54
61
|
get: function () {
|
|
@@ -101,10 +108,11 @@ var _useReducedMotion = require("../hooks/useReducedMotion");
|
|
|
101
108
|
var _useSeries = require("../hooks/useSeries");
|
|
102
109
|
var _useInteractionItemProps = require("../hooks/useInteractionItemProps");
|
|
103
110
|
var _useDrawingArea = require("../hooks/useDrawingArea");
|
|
104
|
-
var _useChartContainerHooks = require("../ChartContainer/useChartContainerHooks");
|
|
105
111
|
var _useScatterChartProps = require("../ScatterChart/useScatterChartProps");
|
|
106
112
|
var _useLineChartProps = require("../LineChart/useLineChartProps");
|
|
107
113
|
var _useBarChartProps = require("../BarChart/useBarChartProps");
|
|
114
|
+
var _useResponsiveChartContainerProps = require("../ResponsiveChartContainer/useResponsiveChartContainerProps");
|
|
115
|
+
var _useChartContainerProps = require("../ChartContainer/useChartContainerProps");
|
|
108
116
|
var _defaultizeValueFormatter = require("./defaultizeValueFormatter");
|
|
109
117
|
Object.keys(_defaultizeValueFormatter).forEach(function (key) {
|
|
110
118
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -153,6 +161,18 @@ Object.keys(_getSVGPoint).forEach(function (key) {
|
|
|
153
161
|
}
|
|
154
162
|
});
|
|
155
163
|
});
|
|
164
|
+
var _isDefined = require("./isDefined");
|
|
165
|
+
Object.keys(_isDefined).forEach(function (key) {
|
|
166
|
+
if (key === "default" || key === "__esModule") return;
|
|
167
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
168
|
+
if (key in exports && exports[key] === _isDefined[key]) return;
|
|
169
|
+
Object.defineProperty(exports, key, {
|
|
170
|
+
enumerable: true,
|
|
171
|
+
get: function () {
|
|
172
|
+
return _isDefined[key];
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
});
|
|
156
176
|
var _CartesianProvider = require("../context/CartesianProvider");
|
|
157
177
|
Object.keys(_CartesianProvider).forEach(function (key) {
|
|
158
178
|
if (key === "default" || key === "__esModule") return;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function isDefined<T>(value: T | null | undefined): value is NonNullable<T>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function notNull<T>(value: T): value is NonNullable<T>;
|
package/internals/warning.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function warnOnce(message: string | string[], gravity?: 'warning' | 'error'): void;
|
|
2
|
+
export declare function clearWarningsCache(): void;
|
package/internals/warning.js
CHANGED
|
@@ -3,17 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
6
|
+
exports.clearWarningsCache = clearWarningsCache;
|
|
7
|
+
exports.warnOnce = warnOnce;
|
|
8
|
+
const warnedOnceCache = new Set();
|
|
9
|
+
|
|
10
|
+
// TODO move to @mui/x-internals
|
|
11
|
+
// TODO eventually move to @base_ui/internals. Base UI, etc. too need this helper.
|
|
12
|
+
function warnOnce(message, gravity = 'warning') {
|
|
13
|
+
if (process.env.NODE_ENV === 'production') {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const cleanMessage = Array.isArray(message) ? message.join('\n') : message;
|
|
17
|
+
if (!warnedOnceCache.has(cleanMessage)) {
|
|
18
|
+
warnedOnceCache.add(cleanMessage);
|
|
19
|
+
if (gravity === 'error') {
|
|
20
|
+
console.error(cleanMessage);
|
|
21
|
+
} else {
|
|
22
|
+
console.warn(cleanMessage);
|
|
17
23
|
}
|
|
18
|
-
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function clearWarningsCache() {
|
|
27
|
+
warnedOnceCache.clear();
|
|
19
28
|
}
|
package/models/axis.d.ts
CHANGED
|
@@ -212,8 +212,9 @@ export type AxisValueFormatterContext = {
|
|
|
212
212
|
* Location indicates where the value will be displayed.
|
|
213
213
|
* - `'tick'` The value is displayed on the axis ticks.
|
|
214
214
|
* - `'tooltip'` The value is displayed in the tooltip when hovering the chart.
|
|
215
|
+
* - `'legend'` The value is displayed in the legend when using color legend.
|
|
215
216
|
*/
|
|
216
|
-
location: 'tick' | 'tooltip';
|
|
217
|
+
location: 'tick' | 'tooltip' | 'legend';
|
|
217
218
|
};
|
|
218
219
|
export type AxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps = ChartsXAxisProps | ChartsYAxisProps> = {
|
|
219
220
|
/**
|
|
@@ -253,7 +254,9 @@ export type AxisConfig<S extends ScaleName = ScaleName, V = any, AxisProps = Cha
|
|
|
253
254
|
* If `true`, Reverse the axis scaleBand.
|
|
254
255
|
*/
|
|
255
256
|
reverse?: boolean;
|
|
256
|
-
} & Partial<AxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams;
|
|
257
|
+
} & Partial<AxisProps> & Partial<Omit<AxisScaleConfig[S], 'scale'>> & TickParams & AxisConfigExtension;
|
|
258
|
+
export interface AxisConfigExtension {
|
|
259
|
+
}
|
|
257
260
|
export type AxisDefaultized<S extends ScaleName = ScaleName, V = any, AxisProps = ChartsXAxisProps | ChartsYAxisProps> = Omit<AxisConfig<S, V, AxisProps>, 'scaleType'> & AxisScaleConfig[S] & AxisScaleComputedConfig[S] & {
|
|
258
261
|
/**
|
|
259
262
|
* An indication of the expected number of ticks.
|
package/models/helpers.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
2
|
+
export type MakeRequired<T, K extends keyof T> = Omit<T, K> & Required<Pick<T, K>>;
|
|
2
3
|
export type DefaultizedProps<P extends {}, RequiredProps extends keyof P, AdditionalProps extends {} = {}> = Omit<P, RequiredProps | keyof AdditionalProps> & Required<Pick<P, RequiredProps>> & AdditionalProps;
|
|
@@ -27,12 +27,22 @@ export type CommonDefaultizedProps = 'id' | 'valueFormatter' | 'data';
|
|
|
27
27
|
export type CartesianSeriesType = {
|
|
28
28
|
/**
|
|
29
29
|
* The id of the x-axis used to render the series.
|
|
30
|
+
* @deprecated Use `xAxisId` instead
|
|
30
31
|
*/
|
|
31
32
|
xAxisKey?: string;
|
|
32
33
|
/**
|
|
33
34
|
* The id of the y-axis used to render the series.
|
|
35
|
+
* @deprecated Use `xAxisId` instead
|
|
34
36
|
*/
|
|
35
37
|
yAxisKey?: string;
|
|
38
|
+
/**
|
|
39
|
+
* The id of the x-axis used to render the series.
|
|
40
|
+
*/
|
|
41
|
+
xAxisId?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The id of the y-axis used to render the series.
|
|
44
|
+
*/
|
|
45
|
+
yAxisId?: string;
|
|
36
46
|
};
|
|
37
47
|
export type StackableSeriesType = {
|
|
38
48
|
/**
|
|
@@ -6,6 +6,7 @@ import { AxisConfig } from '../axis';
|
|
|
6
6
|
import { DefaultizedProps, MakeOptional } from '../helpers';
|
|
7
7
|
import { StackingGroupsType } from '../../internals/stackSeries';
|
|
8
8
|
import { SeriesId } from './common';
|
|
9
|
+
import { LegendItemParams } from '../../ChartsLegend/chartsLegend.types';
|
|
9
10
|
export interface ChartsSeriesConfig {
|
|
10
11
|
bar: {
|
|
11
12
|
/**
|
|
@@ -102,20 +103,5 @@ export type DatasetElementType<T> = {
|
|
|
102
103
|
};
|
|
103
104
|
export type DatasetType<T = number | string | Date | null | undefined> = DatasetElementType<T>[];
|
|
104
105
|
export type Formatter<T extends ChartSeriesType> = (params: FormatterParams<T>, dataset?: DatasetType) => FormatterResult<T>;
|
|
105
|
-
export type
|
|
106
|
-
/**
|
|
107
|
-
* The color used in the legend
|
|
108
|
-
*/
|
|
109
|
-
color: string;
|
|
110
|
-
/**
|
|
111
|
-
* The label displayed in the legend
|
|
112
|
-
*/
|
|
113
|
-
label: string;
|
|
114
|
-
/**
|
|
115
|
-
* The identifier of the legend element.
|
|
116
|
-
* Used for internal purpose such as `key` props
|
|
117
|
-
*/
|
|
118
|
-
id: SeriesId;
|
|
119
|
-
};
|
|
120
|
-
export type LegendGetter<T extends ChartSeriesType> = (series: FormatterResult<T>) => LegendParams[];
|
|
106
|
+
export type LegendGetter<T extends ChartSeriesType> = (series: FormatterResult<T>) => LegendItemParams[];
|
|
121
107
|
export {};
|
|
@@ -24,8 +24,13 @@ export interface ScatterSeriesType extends CommonSeriesType<ScatterValueType>, C
|
|
|
24
24
|
disableHover?: boolean;
|
|
25
25
|
/**
|
|
26
26
|
* The id of the z-axis used to render the series.
|
|
27
|
+
* @deprecated Use `zAxisId` instead.
|
|
27
28
|
*/
|
|
28
29
|
zAxisKey?: string;
|
|
30
|
+
/**
|
|
31
|
+
* The id of the z-axis used to render the series.
|
|
32
|
+
*/
|
|
33
|
+
zAxisId?: string;
|
|
29
34
|
}
|
|
30
35
|
/**
|
|
31
36
|
* An object that allows to identify a single scatter item.
|
|
@@ -43,8 +43,8 @@ const BarChart = /*#__PURE__*/React.forwardRef(function BarChart(props, ref) {
|
|
|
43
43
|
ref: ref
|
|
44
44
|
}, chartContainerProps, {
|
|
45
45
|
children: [props.onAxisClick && /*#__PURE__*/_jsx(ChartsOnAxisClickHandler, _extends({}, axisClickHandlerProps)), props.grid && /*#__PURE__*/_jsx(ChartsGrid, _extends({}, gridProps)), /*#__PURE__*/_jsxs("g", _extends({}, clipPathGroupProps, {
|
|
46
|
-
children: [/*#__PURE__*/_jsx(BarPlot, _extends({}, barPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps))]
|
|
47
|
-
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)),
|
|
46
|
+
children: [/*#__PURE__*/_jsx(BarPlot, _extends({}, barPlotProps)), /*#__PURE__*/_jsx(ChartsOverlay, _extends({}, overlayProps)), /*#__PURE__*/_jsx(ChartsAxisHighlight, _extends({}, axisHighlightProps))]
|
|
47
|
+
})), /*#__PURE__*/_jsx(ChartsAxis, _extends({}, chartsAxisProps)), /*#__PURE__*/_jsx(ChartsLegend, _extends({}, legendProps)), !props.loading && /*#__PURE__*/_jsx(ChartsTooltip, _extends({}, tooltipProps)), /*#__PURE__*/_jsx(ChartsClipPath, _extends({}, clipPathProps)), children]
|
|
48
48
|
}));
|
|
49
49
|
});
|
|
50
50
|
process.env.NODE_ENV !== "production" ? BarChart.propTypes = {
|
|
@@ -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]);
|
|
@@ -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
|
|
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
|
}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "tooltip", "onAxisClick", "axisHighlight", "legend", "grid", "topAxis", "leftAxis", "rightAxis", "bottomAxis", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className"];
|
|
2
4
|
import useId from '@mui/utils/useId';
|
|
3
5
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
4
6
|
/**
|
|
@@ -10,36 +12,38 @@ import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from '../constants';
|
|
|
10
12
|
*/
|
|
11
13
|
export const useBarChartProps = props => {
|
|
12
14
|
const {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
15
|
+
xAxis,
|
|
16
|
+
yAxis,
|
|
17
|
+
series,
|
|
18
|
+
width,
|
|
19
|
+
height,
|
|
20
|
+
margin,
|
|
21
|
+
colors,
|
|
22
|
+
dataset,
|
|
23
|
+
sx,
|
|
24
|
+
tooltip,
|
|
25
|
+
onAxisClick,
|
|
26
|
+
axisHighlight,
|
|
27
|
+
legend,
|
|
28
|
+
grid,
|
|
29
|
+
topAxis,
|
|
30
|
+
leftAxis,
|
|
31
|
+
rightAxis,
|
|
32
|
+
bottomAxis,
|
|
33
|
+
children,
|
|
34
|
+
slots,
|
|
35
|
+
slotProps,
|
|
36
|
+
skipAnimation,
|
|
37
|
+
loading,
|
|
38
|
+
layout,
|
|
39
|
+
onItemClick,
|
|
40
|
+
highlightedItem,
|
|
41
|
+
onHighlightChange,
|
|
42
|
+
borderRadius,
|
|
43
|
+
barLabel,
|
|
44
|
+
className
|
|
45
|
+
} = props,
|
|
46
|
+
rest = _objectWithoutPropertiesLoose(props, _excluded);
|
|
43
47
|
const id = useId();
|
|
44
48
|
const clipPathId = `${id}-clip-path`;
|
|
45
49
|
const hasHorizontalSeries = layout === 'horizontal' || layout === undefined && series.some(item => item.layout === 'horizontal');
|
|
@@ -49,7 +53,7 @@ export const useBarChartProps = props => {
|
|
|
49
53
|
length: Math.max(...series.map(s => (s.data ?? dataset ?? []).length))
|
|
50
54
|
}, (_, index) => index)
|
|
51
55
|
};
|
|
52
|
-
const chartContainerProps = {
|
|
56
|
+
const chartContainerProps = _extends({}, rest, {
|
|
53
57
|
series: series.map(s => _extends({
|
|
54
58
|
type: 'bar'
|
|
55
59
|
}, s, {
|
|
@@ -69,8 +73,9 @@ export const useBarChartProps = props => {
|
|
|
69
73
|
sx,
|
|
70
74
|
highlightedItem,
|
|
71
75
|
onHighlightChange,
|
|
72
|
-
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick
|
|
73
|
-
|
|
76
|
+
disableAxisListener: tooltip?.trigger !== 'axis' && axisHighlight?.x === 'none' && axisHighlight?.y === 'none' && !onAxisClick,
|
|
77
|
+
className
|
|
78
|
+
});
|
|
74
79
|
const barPlotProps = {
|
|
75
80
|
onItemClick,
|
|
76
81
|
slots,
|