@mui/x-charts 8.23.0 → 8.24.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 +39 -0
- package/BarChart/BarChart.plugins.d.ts +2 -1
- package/BarChart/BarChart.plugins.js +2 -1
- package/BarChart/BarLabel/BarLabel.d.ts +2 -0
- package/BarChart/BarLabel/BarLabel.js +8 -3
- package/BarChart/BarLabel/BarLabelItem.d.ts +2 -0
- package/BarChart/BarLabel/BarLabelItem.js +4 -2
- package/BarChart/BarPlot.d.ts +12 -2
- package/BarChart/BarPlot.js +29 -86
- package/BarChart/BatchBarPlot/BarGroup.d.ts +15 -0
- package/BarChart/BatchBarPlot/BarGroup.js +142 -0
- package/BarChart/BatchBarPlot/BatchBarPlot.d.ts +12 -0
- package/BarChart/BatchBarPlot/BatchBarPlot.js +140 -0
- package/BarChart/BatchBarPlot/index.d.ts +1 -0
- package/BarChart/BatchBarPlot/index.js +12 -0
- package/BarChart/BatchBarPlot/useCreateBarPaths.d.ts +8 -0
- package/BarChart/BatchBarPlot/useCreateBarPaths.js +53 -0
- package/BarChart/FocusedBar.js +5 -1
- package/BarChart/IndividualBarPlot.d.ts +21 -0
- package/BarChart/IndividualBarPlot.js +106 -0
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +1 -1
- package/BarChart/seriesConfig/bar/legend.js +1 -0
- package/BarChart/seriesConfig/index.js +3 -1
- package/BarChart/types.d.ts +2 -0
- package/BarChart/useBarChartProps.d.ts +6 -2
- package/BarChart/useBarChartProps.js +4 -2
- package/BarChart/useBarPlotData.d.ts +1 -1
- package/BarChart/useBarPlotData.js +23 -4
- package/BarChart/useRegisterItemClickHandlers.d.ts +6 -0
- package/BarChart/useRegisterItemClickHandlers.js +72 -0
- package/CHANGELOG.md +111 -1
- package/ChartContainer/ChartContainer.js +34 -0
- package/ChartContainer/useChartContainerProps.js +6 -2
- package/ChartsLegend/ChartsLegend.js +2 -2
- package/ChartsLegend/legendContext.types.d.ts +12 -0
- package/ChartsLegend/onClickContextBuilder.js +2 -1
- package/ChartsOverlay/ChartsLoadingOverlay.js +4 -1
- package/ChartsOverlay/ChartsNoDataOverlay.js +4 -1
- package/ChartsReferenceLine/common.d.ts +1 -1
- package/ChartsReferenceLine/common.js +4 -1
- package/ChartsTooltip/ChartsTooltipContainer.js +25 -21
- package/Gauge/GaugeContainer.js +4 -1
- package/LineChart/AnimatedLine.js +7 -3
- package/LineChart/AppearingMask.js +4 -1
- package/LineChart/CircleMarkElement.d.ts +5 -0
- package/LineChart/CircleMarkElement.js +13 -5
- package/LineChart/FocusedLineMark.js +5 -1
- package/LineChart/LineChart.js +30 -0
- package/LineChart/LineChart.plugins.d.ts +2 -1
- package/LineChart/LineChart.plugins.js +2 -1
- package/LineChart/LineElement.d.ts +4 -0
- package/LineChart/LineElement.js +7 -3
- package/LineChart/MarkElement.d.ts +5 -0
- package/LineChart/MarkElement.js +17 -10
- package/LineChart/markElementClasses.d.ts +0 -1
- package/LineChart/seriesConfig/index.js +3 -1
- package/LineChart/seriesConfig/legend.js +1 -0
- package/PieChart/FocusedPieArc.js +5 -2
- package/PieChart/PieArcLabel.d.ts +2 -0
- package/PieChart/PieArcLabel.js +5 -2
- package/PieChart/PieChart.js +35 -5
- package/PieChart/PieChart.plugins.d.ts +2 -1
- package/PieChart/PieChart.plugins.js +2 -1
- package/PieChart/seriesConfig/index.js +3 -1
- package/PieChart/seriesConfig/legend.js +6 -3
- package/RadarChart/RadarChart.js +30 -0
- package/RadarChart/RadarChart.plugins.d.ts +3 -2
- package/RadarChart/RadarChart.plugins.js +2 -1
- package/RadarChart/seriesConfig/index.js +3 -1
- package/RadarChart/seriesConfig/legend.js +1 -0
- package/ScatterChart/BatchScatter.js +8 -14
- package/ScatterChart/ScatterChart.js +30 -0
- package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/ScatterChart/ScatterChart.plugins.js +2 -1
- package/ScatterChart/seriesConfig/index.js +3 -1
- package/ScatterChart/seriesConfig/legend.js +1 -0
- package/SparkLineChart/SparkLineChart.js +46 -0
- package/esm/BarChart/BarChart.js +39 -0
- package/esm/BarChart/BarChart.plugins.d.ts +2 -1
- package/esm/BarChart/BarChart.plugins.js +2 -1
- package/esm/BarChart/BarLabel/BarLabel.d.ts +2 -0
- package/esm/BarChart/BarLabel/BarLabel.js +8 -3
- package/esm/BarChart/BarLabel/BarLabelItem.d.ts +2 -0
- package/esm/BarChart/BarLabel/BarLabelItem.js +4 -2
- package/esm/BarChart/BarPlot.d.ts +12 -2
- package/esm/BarChart/BarPlot.js +29 -86
- package/esm/BarChart/BatchBarPlot/BarGroup.d.ts +15 -0
- package/esm/BarChart/BatchBarPlot/BarGroup.js +134 -0
- package/esm/BarChart/BatchBarPlot/BatchBarPlot.d.ts +12 -0
- package/esm/BarChart/BatchBarPlot/BatchBarPlot.js +133 -0
- package/esm/BarChart/BatchBarPlot/index.d.ts +1 -0
- package/esm/BarChart/BatchBarPlot/index.js +1 -0
- package/esm/BarChart/BatchBarPlot/useCreateBarPaths.d.ts +8 -0
- package/esm/BarChart/BatchBarPlot/useCreateBarPaths.js +46 -0
- package/esm/BarChart/FocusedBar.js +5 -1
- package/esm/BarChart/IndividualBarPlot.d.ts +21 -0
- package/esm/BarChart/IndividualBarPlot.js +98 -0
- package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +1 -1
- package/esm/BarChart/seriesConfig/bar/legend.js +1 -0
- package/esm/BarChart/seriesConfig/index.js +3 -1
- package/esm/BarChart/types.d.ts +2 -0
- package/esm/BarChart/useBarChartProps.d.ts +6 -2
- package/esm/BarChart/useBarChartProps.js +4 -3
- package/esm/BarChart/useBarPlotData.d.ts +1 -1
- package/esm/BarChart/useBarPlotData.js +20 -1
- package/esm/BarChart/useRegisterItemClickHandlers.d.ts +6 -0
- package/esm/BarChart/useRegisterItemClickHandlers.js +67 -0
- package/esm/ChartContainer/ChartContainer.js +34 -0
- package/esm/ChartContainer/useChartContainerProps.js +6 -2
- package/esm/ChartsLegend/ChartsLegend.js +2 -2
- package/esm/ChartsLegend/legendContext.types.d.ts +12 -0
- package/esm/ChartsLegend/onClickContextBuilder.js +2 -1
- package/esm/ChartsOverlay/ChartsLoadingOverlay.js +4 -1
- package/esm/ChartsOverlay/ChartsNoDataOverlay.js +4 -1
- package/esm/ChartsReferenceLine/common.d.ts +1 -1
- package/esm/ChartsReferenceLine/common.js +4 -1
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +26 -22
- package/esm/Gauge/GaugeContainer.js +4 -1
- package/esm/LineChart/AnimatedLine.js +7 -3
- package/esm/LineChart/AppearingMask.js +4 -1
- package/esm/LineChart/CircleMarkElement.d.ts +5 -0
- package/esm/LineChart/CircleMarkElement.js +13 -5
- package/esm/LineChart/FocusedLineMark.js +5 -1
- package/esm/LineChart/LineChart.js +30 -0
- package/esm/LineChart/LineChart.plugins.d.ts +2 -1
- package/esm/LineChart/LineChart.plugins.js +2 -1
- package/esm/LineChart/LineElement.d.ts +4 -0
- package/esm/LineChart/LineElement.js +7 -3
- package/esm/LineChart/MarkElement.d.ts +5 -0
- package/esm/LineChart/MarkElement.js +17 -10
- package/esm/LineChart/markElementClasses.d.ts +0 -1
- package/esm/LineChart/seriesConfig/index.js +3 -1
- package/esm/LineChart/seriesConfig/legend.js +1 -0
- package/esm/PieChart/FocusedPieArc.js +4 -1
- package/esm/PieChart/PieArcLabel.d.ts +2 -0
- package/esm/PieChart/PieArcLabel.js +5 -2
- package/esm/PieChart/PieChart.js +35 -5
- package/esm/PieChart/PieChart.plugins.d.ts +2 -1
- package/esm/PieChart/PieChart.plugins.js +2 -1
- package/esm/PieChart/seriesConfig/index.js +3 -1
- package/esm/PieChart/seriesConfig/legend.js +6 -3
- package/esm/RadarChart/RadarChart.js +30 -0
- package/esm/RadarChart/RadarChart.plugins.d.ts +3 -2
- package/esm/RadarChart/RadarChart.plugins.js +2 -1
- package/esm/RadarChart/seriesConfig/index.js +3 -1
- package/esm/RadarChart/seriesConfig/legend.js +1 -0
- package/esm/ScatterChart/BatchScatter.js +5 -11
- package/esm/ScatterChart/ScatterChart.js +30 -0
- package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
- package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
- package/esm/ScatterChart/seriesConfig/index.js +3 -1
- package/esm/ScatterChart/seriesConfig/legend.js +1 -0
- package/esm/SparkLineChart/SparkLineChart.js +46 -0
- package/esm/index.js +1 -1
- package/esm/internals/appendAtKey.d.ts +8 -0
- package/esm/internals/appendAtKey.js +17 -0
- package/esm/internals/commonNextFocusItem.js +12 -8
- package/esm/internals/getBarDimensions.d.ts +1 -2
- package/esm/internals/identifierSerializer.d.ts +9 -0
- package/esm/internals/identifierSerializer.js +6 -0
- package/esm/internals/index.d.ts +6 -2
- package/esm/internals/index.js +6 -2
- package/esm/internals/invertScale.d.ts +6 -2
- package/esm/internals/invertScale.js +9 -1
- package/esm/internals/plugins/allPlugins.d.ts +4 -3
- package/esm/internals/plugins/allPlugins.js +2 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.d.ts +14 -0
- package/esm/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.js +18 -0
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +8 -1
- package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +12 -1
- package/esm/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +11 -0
- package/esm/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +74 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +20 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -3
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +4 -0
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +83 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +6 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +7 -34
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.d.ts +7 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +9 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +10 -32
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/index.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/index.js +3 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.d.ts +4 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.js +5 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.d.ts +3 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.js +78 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.d.ts +16 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.js +19 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.d.ts +90 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.js +1 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.d.ts +4 -0
- package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.js +11 -0
- package/esm/internals/plugins/models/seriesConfig/identifierSerializer.types.d.ts +2 -0
- package/esm/internals/plugins/models/seriesConfig/identifierSerializer.types.js +1 -0
- package/esm/internals/plugins/models/seriesConfig/index.d.ts +2 -1
- package/esm/internals/plugins/models/seriesConfig/index.js +2 -1
- package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +7 -0
- package/esm/models/axis.d.ts +5 -4
- package/esm/models/featureFlags.d.ts +1 -0
- package/esm/models/featureFlags.js +1 -0
- package/esm/models/index.d.ts +1 -0
- package/esm/models/index.js +1 -0
- package/esm/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +13 -0
- package/esm/moduleAugmentation/barChartBatchRendererOnItemClick.js +1 -0
- package/index.js +1 -1
- package/internals/appendAtKey.d.ts +8 -0
- package/internals/appendAtKey.js +23 -0
- package/internals/commonNextFocusItem.js +12 -8
- package/internals/getBarDimensions.d.ts +1 -2
- package/internals/identifierSerializer.d.ts +9 -0
- package/internals/identifierSerializer.js +16 -0
- package/internals/index.d.ts +6 -2
- package/internals/index.js +51 -7
- package/internals/invertScale.d.ts +6 -2
- package/internals/invertScale.js +10 -1
- package/internals/plugins/allPlugins.d.ts +4 -3
- package/internals/plugins/allPlugins.js +2 -1
- package/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.d.ts +14 -0
- package/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.js +25 -0
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +8 -1
- package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +12 -1
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +11 -0
- package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +81 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +20 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -3
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +4 -0
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +89 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +12 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +6 -34
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.d.ts +7 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +15 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +9 -32
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartVisibilityManager/index.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/index.js +39 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.d.ts +4 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.js +12 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.d.ts +3 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.js +85 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.d.ts +16 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.js +25 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.d.ts +90 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.d.ts +4 -0
- package/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.js +18 -0
- package/internals/plugins/models/seriesConfig/identifierSerializer.types.d.ts +2 -0
- package/internals/plugins/models/seriesConfig/identifierSerializer.types.js +5 -0
- package/internals/plugins/models/seriesConfig/index.d.ts +2 -1
- package/internals/plugins/models/seriesConfig/index.js +11 -0
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +7 -0
- package/models/axis.d.ts +5 -4
- package/models/featureFlags.d.ts +1 -0
- package/models/featureFlags.js +5 -0
- package/models/index.d.ts +1 -0
- package/models/index.js +11 -0
- package/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +13 -0
- package/moduleAugmentation/barChartBatchRendererOnItemClick.js +5 -0
- package/package.json +13 -3
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BatchBarPlot } from "./BatchBarPlot.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BatchBarPlot } from "./BatchBarPlot.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ProcessedBarData, ProcessedBarSeriesData } from "../types.js";
|
|
2
|
+
export declare function createPath(barData: ProcessedBarData, borderRadius: number): string;
|
|
3
|
+
/**
|
|
4
|
+
* Hook that creates bar paths for a given series data. Used by the batch bar renderer.
|
|
5
|
+
* @param seriesData
|
|
6
|
+
* @param borderRadius
|
|
7
|
+
*/
|
|
8
|
+
export declare function useCreateBarPaths(seriesData: ProcessedBarSeriesData, borderRadius: number): Map<string, string[]>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { appendAtKey } from "../../internals/appendAtKey.js";
|
|
2
|
+
const MAX_POINTS_PER_PATH = 1000;
|
|
3
|
+
function generateBarPath(x, y, width, height, topLeftBorderRadius, topRightBorderRadius, bottomRightBorderRadius, bottomLeftBorderRadius) {
|
|
4
|
+
const tLBR = Math.min(topLeftBorderRadius, width / 2, height / 2);
|
|
5
|
+
const tRBR = Math.min(topRightBorderRadius, width / 2, height / 2);
|
|
6
|
+
const bRBR = Math.min(bottomRightBorderRadius, width / 2, height / 2);
|
|
7
|
+
const bLBR = Math.min(bottomLeftBorderRadius, width / 2, height / 2);
|
|
8
|
+
return `M${x + tLBR},${y}
|
|
9
|
+
h${width - tLBR - tRBR}
|
|
10
|
+
a${tRBR},${tRBR} 0 0 1 ${tRBR},${tRBR}
|
|
11
|
+
v${height - tRBR - bRBR}
|
|
12
|
+
a${bRBR},${bRBR} 0 0 1 -${bRBR},${bRBR}
|
|
13
|
+
h-${width - bRBR - bLBR}
|
|
14
|
+
a${bLBR},${bLBR} 0 0 1 -${bLBR},-${bLBR}
|
|
15
|
+
v-${height - bLBR - tLBR}
|
|
16
|
+
a${tLBR},${tLBR} 0 0 1 ${tLBR},-${tLBR}
|
|
17
|
+
Z`;
|
|
18
|
+
}
|
|
19
|
+
export function createPath(barData, borderRadius) {
|
|
20
|
+
return generateBarPath(barData.x, barData.y, barData.width, barData.height, barData.borderRadiusSide === 'left' || barData.borderRadiusSide === 'top' ? borderRadius : 0, barData.borderRadiusSide === 'right' || barData.borderRadiusSide === 'top' ? borderRadius : 0, barData.borderRadiusSide === 'right' || barData.borderRadiusSide === 'bottom' ? borderRadius : 0, barData.borderRadiusSide === 'left' || barData.borderRadiusSide === 'bottom' ? borderRadius : 0);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Hook that creates bar paths for a given series data. Used by the batch bar renderer.
|
|
25
|
+
* @param seriesData
|
|
26
|
+
* @param borderRadius
|
|
27
|
+
*/
|
|
28
|
+
export function useCreateBarPaths(seriesData, borderRadius) {
|
|
29
|
+
const paths = new Map();
|
|
30
|
+
const temporaryPaths = new Map();
|
|
31
|
+
for (let j = 0; j < seriesData.data.length; j += 1) {
|
|
32
|
+
const barData = seriesData.data[j];
|
|
33
|
+
const pathString = createPath(barData, borderRadius);
|
|
34
|
+
const tempPath = appendAtKey(temporaryPaths, barData.color, pathString);
|
|
35
|
+
if (tempPath.length >= MAX_POINTS_PER_PATH) {
|
|
36
|
+
appendAtKey(paths, barData.color, tempPath.join(''));
|
|
37
|
+
temporaryPaths.delete(barData.color);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
for (const [fill, tempPath] of temporaryPaths.entries()) {
|
|
41
|
+
if (tempPath.length > 0) {
|
|
42
|
+
appendAtKey(paths, fill, tempPath.join(''));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return paths;
|
|
46
|
+
}
|
|
@@ -22,7 +22,11 @@ export function FocusedBar(props) {
|
|
|
22
22
|
if (focusedItem === null || focusedItem.type !== 'bar' || !barSeries) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
|
-
const series = barSeries
|
|
25
|
+
const series = barSeries.series[focusedItem.seriesId];
|
|
26
|
+
if (series.data[focusedItem.dataIndex] == null) {
|
|
27
|
+
// Handle missing data
|
|
28
|
+
return null;
|
|
29
|
+
}
|
|
26
30
|
const xAxisId = series.xAxisId ?? xAxisIds[0];
|
|
27
31
|
const yAxisId = series.yAxisId ?? yAxisIds[0];
|
|
28
32
|
const xAxisConfig = xAxis[xAxisId];
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type BarPlotSlotProps, type BarPlotSlots } from "./BarPlot.js";
|
|
3
|
+
import { type BarItemIdentifier } from "../models/index.js";
|
|
4
|
+
import { type MaskData, type ProcessedBarSeriesData } from "./types.js";
|
|
5
|
+
export interface IndividualBarPlotProps {
|
|
6
|
+
completedData: ProcessedBarSeriesData[];
|
|
7
|
+
masksData: MaskData[];
|
|
8
|
+
borderRadius?: number;
|
|
9
|
+
skipAnimation?: boolean;
|
|
10
|
+
onItemClick?: (event: React.MouseEvent<SVGElement, MouseEvent>, barItemIdentifier: BarItemIdentifier) => void;
|
|
11
|
+
slotProps?: BarPlotSlotProps;
|
|
12
|
+
slots?: BarPlotSlots;
|
|
13
|
+
}
|
|
14
|
+
export declare function IndividualBarPlot({
|
|
15
|
+
completedData,
|
|
16
|
+
masksData,
|
|
17
|
+
borderRadius,
|
|
18
|
+
onItemClick,
|
|
19
|
+
skipAnimation,
|
|
20
|
+
...other
|
|
21
|
+
}: IndividualBarPlotProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
3
|
+
const _excluded = ["completedData", "masksData", "borderRadius", "onItemClick", "skipAnimation"];
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { BarElement } from "./BarElement.js";
|
|
6
|
+
import { useUtilityClasses } from "./barClasses.js";
|
|
7
|
+
import { BarClipPath } from "./BarClipPath.js";
|
|
8
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
+
export function IndividualBarPlot(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
completedData,
|
|
12
|
+
masksData,
|
|
13
|
+
borderRadius,
|
|
14
|
+
onItemClick,
|
|
15
|
+
skipAnimation
|
|
16
|
+
} = _ref,
|
|
17
|
+
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
18
|
+
const classes = useUtilityClasses();
|
|
19
|
+
const withoutBorderRadius = !borderRadius || borderRadius <= 0;
|
|
20
|
+
return /*#__PURE__*/_jsxs(React.Fragment, {
|
|
21
|
+
children: [!withoutBorderRadius && masksData.map(({
|
|
22
|
+
id,
|
|
23
|
+
x,
|
|
24
|
+
y,
|
|
25
|
+
xOrigin,
|
|
26
|
+
yOrigin,
|
|
27
|
+
width,
|
|
28
|
+
height,
|
|
29
|
+
hasPositive,
|
|
30
|
+
hasNegative,
|
|
31
|
+
layout
|
|
32
|
+
}) => {
|
|
33
|
+
return /*#__PURE__*/_jsx(BarClipPath, {
|
|
34
|
+
maskId: id,
|
|
35
|
+
borderRadius: borderRadius,
|
|
36
|
+
hasNegative: hasNegative,
|
|
37
|
+
hasPositive: hasPositive,
|
|
38
|
+
layout: layout,
|
|
39
|
+
x: x,
|
|
40
|
+
y: y,
|
|
41
|
+
xOrigin: xOrigin,
|
|
42
|
+
yOrigin: yOrigin,
|
|
43
|
+
width: width,
|
|
44
|
+
height: height,
|
|
45
|
+
skipAnimation: skipAnimation ?? false
|
|
46
|
+
}, id);
|
|
47
|
+
}), completedData.map(({
|
|
48
|
+
seriesId,
|
|
49
|
+
layout,
|
|
50
|
+
xOrigin,
|
|
51
|
+
yOrigin,
|
|
52
|
+
data
|
|
53
|
+
}) => {
|
|
54
|
+
return /*#__PURE__*/_jsx("g", {
|
|
55
|
+
"data-series": seriesId,
|
|
56
|
+
className: classes.series,
|
|
57
|
+
children: data.map(({
|
|
58
|
+
dataIndex,
|
|
59
|
+
color,
|
|
60
|
+
maskId,
|
|
61
|
+
x,
|
|
62
|
+
y,
|
|
63
|
+
width,
|
|
64
|
+
height
|
|
65
|
+
}) => {
|
|
66
|
+
const barElement = /*#__PURE__*/_jsx(BarElement, _extends({
|
|
67
|
+
id: seriesId,
|
|
68
|
+
dataIndex: dataIndex,
|
|
69
|
+
color: color,
|
|
70
|
+
skipAnimation: skipAnimation ?? false,
|
|
71
|
+
layout: layout ?? 'vertical',
|
|
72
|
+
x: x,
|
|
73
|
+
xOrigin: xOrigin,
|
|
74
|
+
y: y,
|
|
75
|
+
yOrigin: yOrigin,
|
|
76
|
+
width: width,
|
|
77
|
+
height: height
|
|
78
|
+
}, other, {
|
|
79
|
+
onClick: onItemClick && (event => {
|
|
80
|
+
onItemClick(event, {
|
|
81
|
+
type: 'bar',
|
|
82
|
+
seriesId,
|
|
83
|
+
dataIndex
|
|
84
|
+
});
|
|
85
|
+
})
|
|
86
|
+
}), dataIndex);
|
|
87
|
+
if (withoutBorderRadius) {
|
|
88
|
+
return barElement;
|
|
89
|
+
}
|
|
90
|
+
return /*#__PURE__*/_jsx("g", {
|
|
91
|
+
clipPath: `url(#${maskId})`,
|
|
92
|
+
children: barElement
|
|
93
|
+
}, dataIndex);
|
|
94
|
+
})
|
|
95
|
+
}, seriesId);
|
|
96
|
+
})]
|
|
97
|
+
});
|
|
98
|
+
}
|
|
@@ -9,7 +9,7 @@ export declare function getSeriesWithDefaultValues(seriesData: AllSeriesType<'ba
|
|
|
9
9
|
layout?: "horizontal" | "vertical";
|
|
10
10
|
stackOffset?: import("../../../index.js").StackOffsetType;
|
|
11
11
|
minBarSize?: number;
|
|
12
|
-
barLabel?: "value" | ((item: import("
|
|
12
|
+
barLabel?: "value" | ((item: import("@mui/x-charts/BarChart").BarItem, context: import("@mui/x-charts/BarChart").BarLabelContext) => string | null | undefined);
|
|
13
13
|
barLabelPlacement?: "center" | "outside";
|
|
14
14
|
valueFormatter?: import("../../../internals/index.js").SeriesValueFormatter<number | null> | undefined;
|
|
15
15
|
highlightScope?: import("../../../index.js").HighlightScope;
|
|
@@ -6,6 +6,7 @@ import keyboardFocusHandler from "./bar/keyboardFocusHandler.js";
|
|
|
6
6
|
import tooltipGetter, { axisTooltipGetter } from "./bar/tooltip.js";
|
|
7
7
|
import tooltipItemPositionGetter from "./bar/tooltipPosition.js";
|
|
8
8
|
import { getSeriesWithDefaultValues } from "./bar/getSeriesWithDefaultValues.js";
|
|
9
|
+
import { identifierSerializerSeriesIdDataIndex } from "../../internals/identifierSerializer.js";
|
|
9
10
|
export const barSeriesConfig = {
|
|
10
11
|
seriesProcessor,
|
|
11
12
|
colorProcessor: getColor,
|
|
@@ -16,5 +17,6 @@ export const barSeriesConfig = {
|
|
|
16
17
|
xExtremumGetter: getExtremumX,
|
|
17
18
|
yExtremumGetter: getExtremumY,
|
|
18
19
|
getSeriesWithDefaultValues,
|
|
19
|
-
keyboardFocusHandler
|
|
20
|
+
keyboardFocusHandler,
|
|
21
|
+
identifierSerializer: identifierSerializerSeriesIdDataIndex
|
|
20
22
|
};
|
package/esm/BarChart/types.d.ts
CHANGED
|
@@ -15,12 +15,14 @@ export interface ProcessedBarSeriesData {
|
|
|
15
15
|
xOrigin: number;
|
|
16
16
|
yOrigin: number;
|
|
17
17
|
}
|
|
18
|
+
export type BorderRadiusSide = 'top' | 'bottom' | 'left' | 'right';
|
|
18
19
|
export interface ProcessedBarData extends AnimationData {
|
|
19
20
|
seriesId: SeriesId;
|
|
20
21
|
dataIndex: number;
|
|
21
22
|
color: string;
|
|
22
23
|
value: number | null;
|
|
23
24
|
maskId: string;
|
|
25
|
+
borderRadiusSide?: BorderRadiusSide;
|
|
24
26
|
}
|
|
25
27
|
export interface MaskData extends AnimationData {
|
|
26
28
|
id: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import type
|
|
2
|
+
import { type BarChartProps, type BarSeries } from "./BarChart.js";
|
|
3
3
|
import { type ChartContainerProps } from "../ChartContainer/index.js";
|
|
4
4
|
import { type BarPlotProps } from "./BarPlot.js";
|
|
5
5
|
import { type ChartsGridProps } from "../ChartsGrid/index.js";
|
|
@@ -10,6 +10,10 @@ import { type ChartsAxisHighlightProps } from "../ChartsAxisHighlight/index.js";
|
|
|
10
10
|
import { type ChartsLegendSlotExtension } from "../ChartsLegend/index.js";
|
|
11
11
|
import type { ChartsWrapperProps } from "../ChartsWrapper/index.js";
|
|
12
12
|
import { type BarChartPluginSignatures } from "./BarChart.plugins.js";
|
|
13
|
+
export interface UseBarChartPropsExtensions {}
|
|
14
|
+
export type UseBarChartProps = Omit<BarChartProps, 'series'> & Omit<{
|
|
15
|
+
series: ReadonlyArray<BarSeries>;
|
|
16
|
+
}, keyof UseBarChartPropsExtensions> & UseBarChartPropsExtensions;
|
|
13
17
|
/**
|
|
14
18
|
* A helper function that extracts BarChartProps from the input props
|
|
15
19
|
* and returns an object with props for the children components of BarChart.
|
|
@@ -17,7 +21,7 @@ import { type BarChartPluginSignatures } from "./BarChart.plugins.js";
|
|
|
17
21
|
* @param props The input props for BarChart
|
|
18
22
|
* @returns An object with props for the children components of BarChart
|
|
19
23
|
*/
|
|
20
|
-
export declare const useBarChartProps: (props:
|
|
24
|
+
export declare const useBarChartProps: (props: UseBarChartProps) => {
|
|
21
25
|
chartsWrapperProps: Omit<ChartsWrapperProps, "children">;
|
|
22
26
|
chartContainerProps: ChartContainerProps<"bar", BarChartPluginSignatures>;
|
|
23
27
|
barPlotProps: BarPlotProps;
|
|
@@ -2,12 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend", "showToolbar", "brushConfig"];
|
|
5
|
+
const _excluded = ["xAxis", "yAxis", "series", "width", "height", "margin", "colors", "dataset", "sx", "axisHighlight", "grid", "children", "slots", "slotProps", "skipAnimation", "loading", "layout", "onItemClick", "highlightedItem", "onHighlightChange", "borderRadius", "barLabel", "className", "hideLegend", "showToolbar", "brushConfig", "renderer"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import useId from '@mui/utils/useId';
|
|
8
8
|
import { DEFAULT_X_AXIS_KEY, DEFAULT_Y_AXIS_KEY } from "../constants/index.js";
|
|
9
9
|
import { BAR_CHART_PLUGINS } from "./BarChart.plugins.js";
|
|
10
|
-
|
|
11
10
|
/**
|
|
12
11
|
* A helper function that extracts BarChartProps from the input props
|
|
13
12
|
* and returns an object with props for the children components of BarChart.
|
|
@@ -40,7 +39,8 @@ export const useBarChartProps = props => {
|
|
|
40
39
|
borderRadius,
|
|
41
40
|
barLabel,
|
|
42
41
|
className,
|
|
43
|
-
brushConfig
|
|
42
|
+
brushConfig,
|
|
43
|
+
renderer
|
|
44
44
|
} = props,
|
|
45
45
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
46
46
|
const id = useId();
|
|
@@ -105,6 +105,7 @@ export const useBarChartProps = props => {
|
|
|
105
105
|
slots,
|
|
106
106
|
slotProps,
|
|
107
107
|
borderRadius,
|
|
108
|
+
renderer,
|
|
108
109
|
barLabel
|
|
109
110
|
};
|
|
110
111
|
const gridProps = {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { type ChartsXAxisProps, type ChartsYAxisProps } from "../models/axis.js";
|
|
2
|
-
import { type ChartDrawingArea } from "../hooks/index.js";
|
|
3
2
|
import { type MaskData, type ProcessedBarSeriesData } from "./types.js";
|
|
4
3
|
import { type ComputedAxisConfig } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.js";
|
|
4
|
+
import { type ChartDrawingArea } from "../hooks/useDrawingArea.js";
|
|
5
5
|
export declare function useBarPlotData(drawingArea: ChartDrawingArea, xAxes: ComputedAxisConfig<ChartsXAxisProps>, yAxes: ComputedAxisConfig<ChartsYAxisProps>): {
|
|
6
6
|
completedData: ProcessedBarSeriesData[];
|
|
7
7
|
masksData: MaskData[];
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import getColor from "./seriesConfig/bar/getColor.js";
|
|
3
|
-
import {
|
|
3
|
+
import { useXAxes, useYAxes } from "../hooks/useAxis.js";
|
|
4
4
|
import { checkBarChartScaleErrors } from "./checkBarChartScaleErrors.js";
|
|
5
5
|
import { useBarSeriesContext } from "../hooks/useBarSeries.js";
|
|
6
6
|
import { getBarDimensions } from "../internals/getBarDimensions.js";
|
|
7
|
+
import { useChartId } from "../hooks/useChartId.js";
|
|
7
8
|
export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
8
9
|
const seriesData = useBarSeriesContext() ?? {
|
|
9
10
|
series: {},
|
|
@@ -25,6 +26,8 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
25
26
|
const xMax = drawingArea.left + drawingArea.width;
|
|
26
27
|
const yMin = drawingArea.top;
|
|
27
28
|
const yMax = drawingArea.top + drawingArea.height;
|
|
29
|
+
const lastNegativePerIndex = new Map();
|
|
30
|
+
const lastPositivePerIndex = new Map();
|
|
28
31
|
return seriesIds.map(seriesId => {
|
|
29
32
|
const xAxisId = series[seriesId].xAxisId ?? defaultXAxisId;
|
|
30
33
|
const yAxisId = series[seriesId].yAxisId ?? defaultYAxisId;
|
|
@@ -66,6 +69,22 @@ export function useBarPlotData(drawingArea, xAxes, yAxes) {
|
|
|
66
69
|
if (result.x > xMax || result.x + result.width < xMin || result.y > yMax || result.y + result.height < yMin) {
|
|
67
70
|
continue;
|
|
68
71
|
}
|
|
72
|
+
const lastNegative = lastNegativePerIndex.get(dataIndex);
|
|
73
|
+
const lastPositive = lastPositivePerIndex.get(dataIndex);
|
|
74
|
+
const sign = (reverse ? -1 : 1) * Math.sign(result.value ?? 0);
|
|
75
|
+
if (sign > 0) {
|
|
76
|
+
if (lastPositive) {
|
|
77
|
+
delete lastPositive.borderRadiusSide;
|
|
78
|
+
}
|
|
79
|
+
result.borderRadiusSide = verticalLayout ? 'top' : 'right';
|
|
80
|
+
lastPositivePerIndex.set(dataIndex, result);
|
|
81
|
+
} else if (sign < 0) {
|
|
82
|
+
if (lastNegative) {
|
|
83
|
+
delete lastNegative.borderRadiusSide;
|
|
84
|
+
}
|
|
85
|
+
result.borderRadiusSide = verticalLayout ? 'bottom' : 'left';
|
|
86
|
+
lastNegativePerIndex.set(dataIndex, result);
|
|
87
|
+
}
|
|
69
88
|
if (!masks[result.maskId]) {
|
|
70
89
|
masks[result.maskId] = {
|
|
71
90
|
id: result.maskId,
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type BarItemIdentifier } from "../models/seriesType/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Hook that registers pointer event handlers for chart item clicking.
|
|
4
|
+
* @param onItemClick Callback for item click events.
|
|
5
|
+
*/
|
|
6
|
+
export declare function useRegisterItemClickHandlers(onItemClick: ((event: MouseEvent, barItemIdentifier: BarItemIdentifier) => void) | undefined): void;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { useSvgRef } from "../hooks/useSvgRef.js";
|
|
5
|
+
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
6
|
+
import { getSVGPoint } from "../internals/getSVGPoint.js";
|
|
7
|
+
import { useStore } from "../internals/store/useStore.js";
|
|
8
|
+
import { selectorBarItemAtPosition } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Hook that registers pointer event handlers for chart item clicking.
|
|
12
|
+
* @param onItemClick Callback for item click events.
|
|
13
|
+
*/
|
|
14
|
+
export function useRegisterItemClickHandlers(onItemClick) {
|
|
15
|
+
const {
|
|
16
|
+
instance
|
|
17
|
+
} = useChartContext();
|
|
18
|
+
const svgRef = useSvgRef();
|
|
19
|
+
const store = useStore();
|
|
20
|
+
React.useEffect(() => {
|
|
21
|
+
const element = svgRef.current;
|
|
22
|
+
if (!element || !onItemClick) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
let lastPointerUp = null;
|
|
26
|
+
const onClick = function onClick(event) {
|
|
27
|
+
let point = event;
|
|
28
|
+
|
|
29
|
+
/* The click event doesn't contain decimal values in clientX/Y, but the pointermove does.
|
|
30
|
+
* This caused a problem when rendering many bars that were thinner than a pixel where the tooltip or the highlight
|
|
31
|
+
* would refer to a different bar than the click since those rely on the pointermove event.
|
|
32
|
+
* As a fix, we use the pointerup event to get the decimal values and check if the pointer up event was close enough
|
|
33
|
+
* to the click event (1px difference in each direction); if so, then we can use the pointerup's clientX/Y; if not,
|
|
34
|
+
* we default to the click event's clientX/Y. */
|
|
35
|
+
if (lastPointerUp) {
|
|
36
|
+
if (Math.abs(event.clientX - lastPointerUp.clientX) <= 1 && Math.abs(event.clientY - lastPointerUp.clientY) <= 1) {
|
|
37
|
+
point = {
|
|
38
|
+
clientX: lastPointerUp.clientX,
|
|
39
|
+
clientY: lastPointerUp.clientY
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
lastPointerUp = null;
|
|
44
|
+
const svgPoint = getSVGPoint(element, point);
|
|
45
|
+
if (!instance.isPointInside(svgPoint.x, svgPoint.y)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const item = selectorBarItemAtPosition(store.state, svgPoint);
|
|
49
|
+
if (item) {
|
|
50
|
+
onItemClick(event, {
|
|
51
|
+
type: 'bar',
|
|
52
|
+
seriesId: item.seriesId,
|
|
53
|
+
dataIndex: item.dataIndex
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
const onPointerUp = function onPointerUp(event) {
|
|
58
|
+
lastPointerUp = event;
|
|
59
|
+
};
|
|
60
|
+
element.addEventListener('click', onClick);
|
|
61
|
+
element.addEventListener('pointerup', onPointerUp);
|
|
62
|
+
return () => {
|
|
63
|
+
element.removeEventListener('click', onClick);
|
|
64
|
+
element.removeEventListener('pointerup', onPointerUp);
|
|
65
|
+
};
|
|
66
|
+
}, [instance, onItemClick, store, svgRef]);
|
|
67
|
+
}
|
|
@@ -95,6 +95,35 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
95
95
|
* The height of the chart in px. If not defined, it takes the height of the parent element.
|
|
96
96
|
*/
|
|
97
97
|
height: PropTypes.number,
|
|
98
|
+
/**
|
|
99
|
+
* List of hidden series and/or items.
|
|
100
|
+
*
|
|
101
|
+
* Different chart types use different keys.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```ts
|
|
105
|
+
* [
|
|
106
|
+
* {
|
|
107
|
+
* type: 'pie',
|
|
108
|
+
* seriesId: 'series-1',
|
|
109
|
+
* dataIndex: 3,
|
|
110
|
+
* },
|
|
111
|
+
* {
|
|
112
|
+
* type: 'line',
|
|
113
|
+
* seriesId: 'series-2',
|
|
114
|
+
* }
|
|
115
|
+
* ]
|
|
116
|
+
* ```
|
|
117
|
+
*/
|
|
118
|
+
hiddenItems: PropTypes.arrayOf(PropTypes.shape({
|
|
119
|
+
dataIndex: PropTypes.any,
|
|
120
|
+
seriesId: PropTypes.shape({
|
|
121
|
+
toLocaleString: PropTypes.func.isRequired,
|
|
122
|
+
toString: PropTypes.func.isRequired,
|
|
123
|
+
valueOf: PropTypes.func.isRequired
|
|
124
|
+
}),
|
|
125
|
+
type: PropTypes.object.isRequired
|
|
126
|
+
})),
|
|
98
127
|
/**
|
|
99
128
|
* The controlled axis highlight.
|
|
100
129
|
* Identified by the axis id, and data index.
|
|
@@ -139,6 +168,11 @@ process.env.NODE_ENV !== "production" ? ChartContainer.propTypes = {
|
|
|
139
168
|
* @param {null | ChartsAxisData} data The data about the clicked axis and items associated with it.
|
|
140
169
|
*/
|
|
141
170
|
onAxisClick: PropTypes.func,
|
|
171
|
+
/**
|
|
172
|
+
* Callback fired when any hidden identifiers change.
|
|
173
|
+
* @param {VisibilityIdentifier[]} hiddenItems The new list of hidden identifiers.
|
|
174
|
+
*/
|
|
175
|
+
onHiddenItemsChange: PropTypes.func,
|
|
142
176
|
/**
|
|
143
177
|
* The callback fired when the highlighted item changes.
|
|
144
178
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
|
|
5
|
-
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "highlightedAxis", "onHighlightedAxisChange", "disableVoronoi", "voronoiMaxRadius", "onItemClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "rotationAxis", "radiusAxis", "skipAnimation", "seriesConfig", "plugins", "localeText", "slots", "slotProps", "experimentalFeatures", "enableKeyboardNavigation", "brushConfig"];
|
|
5
|
+
const _excluded = ["width", "height", "margin", "children", "series", "colors", "dataset", "desc", "onAxisClick", "highlightedAxis", "onHighlightedAxisChange", "disableVoronoi", "voronoiMaxRadius", "onItemClick", "disableAxisListener", "highlightedItem", "onHighlightChange", "sx", "title", "xAxis", "yAxis", "zAxis", "rotationAxis", "radiusAxis", "skipAnimation", "seriesConfig", "plugins", "localeText", "slots", "slotProps", "experimentalFeatures", "enableKeyboardNavigation", "brushConfig", "onHiddenItemsChange", "hiddenItems"];
|
|
6
6
|
import { DEFAULT_PLUGINS } from "../internals/plugins/allPlugins.js";
|
|
7
7
|
export const useChartContainerProps = (props, ref) => {
|
|
8
8
|
const _ref = props,
|
|
@@ -39,7 +39,9 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
39
39
|
slotProps,
|
|
40
40
|
experimentalFeatures,
|
|
41
41
|
enableKeyboardNavigation,
|
|
42
|
-
brushConfig
|
|
42
|
+
brushConfig,
|
|
43
|
+
onHiddenItemsChange,
|
|
44
|
+
hiddenItems
|
|
43
45
|
} = _ref,
|
|
44
46
|
other = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
45
47
|
const chartsSurfaceProps = _extends({
|
|
@@ -75,6 +77,8 @@ export const useChartContainerProps = (props, ref) => {
|
|
|
75
77
|
experimentalFeatures,
|
|
76
78
|
enableKeyboardNavigation,
|
|
77
79
|
brushConfig,
|
|
80
|
+
onHiddenItemsChange,
|
|
81
|
+
hiddenItems,
|
|
78
82
|
plugins: plugins ?? DEFAULT_PLUGINS,
|
|
79
83
|
slots,
|
|
80
84
|
slotProps
|
|
@@ -82,7 +82,7 @@ const ChartsLegend = consumeSlots('MuiChartsLegend', 'legend', {
|
|
|
82
82
|
children: data.items.map((item, i) => {
|
|
83
83
|
return /*#__PURE__*/_jsx("li", {
|
|
84
84
|
className: classes?.item,
|
|
85
|
-
"data-series": item.
|
|
85
|
+
"data-series": item.seriesId,
|
|
86
86
|
children: /*#__PURE__*/_jsxs(Element, {
|
|
87
87
|
className: classes?.series,
|
|
88
88
|
role: onItemClick ? 'button' : undefined,
|
|
@@ -99,7 +99,7 @@ const ChartsLegend = consumeSlots('MuiChartsLegend', 'legend', {
|
|
|
99
99
|
children: item.label
|
|
100
100
|
})]
|
|
101
101
|
})
|
|
102
|
-
}, item.
|
|
102
|
+
}, `${item.seriesId}-${item.dataIndex}`);
|
|
103
103
|
})
|
|
104
104
|
}));
|
|
105
105
|
}));
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type ChartsLabelMarkProps } from "../ChartsLabel/ChartsLabelMark.js";
|
|
2
2
|
import { type PieItemId } from "../models/index.js";
|
|
3
3
|
import { type SeriesId } from "../models/seriesType/common.js";
|
|
4
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
4
5
|
interface LegendItemContextBase {
|
|
5
6
|
/**
|
|
6
7
|
* The color used in the legend
|
|
@@ -15,8 +16,14 @@ export interface LegendItemParams extends Partial<Omit<SeriesLegendItemContext,
|
|
|
15
16
|
/**
|
|
16
17
|
* The identifier of the legend element.
|
|
17
18
|
* Used for internal purpose such as `key` props
|
|
19
|
+
* @deprecated use `seriesId` and `dataIndex` instead
|
|
18
20
|
*/
|
|
19
21
|
id: number | string;
|
|
22
|
+
/**
|
|
23
|
+
* The type of the series
|
|
24
|
+
* This property is always defined, but marked as optional to avoid breaking changes. It will become required in a future major version.
|
|
25
|
+
*/
|
|
26
|
+
type?: ChartSeriesType;
|
|
20
27
|
markType: ChartsLabelMarkProps['type'];
|
|
21
28
|
}
|
|
22
29
|
export interface SeriesLegendItemContext extends LegendItemContextBase {
|
|
@@ -32,8 +39,13 @@ export interface SeriesLegendItemContext extends LegendItemContextBase {
|
|
|
32
39
|
seriesId: SeriesId;
|
|
33
40
|
/**
|
|
34
41
|
* The identifier of the pie item
|
|
42
|
+
* @deprecated use `dataIndex` instead
|
|
35
43
|
*/
|
|
36
44
|
itemId?: PieItemId;
|
|
45
|
+
/**
|
|
46
|
+
* The data index of the item in the series data array
|
|
47
|
+
*/
|
|
48
|
+
dataIndex?: number;
|
|
37
49
|
}
|
|
38
50
|
export interface PiecewiseColorLegendItemContext extends LegendItemContextBase {
|
|
39
51
|
/**
|
|
@@ -7,7 +7,10 @@ import { styled } from '@mui/material/styles';
|
|
|
7
7
|
import { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
8
8
|
import { useChartsLocalization } from "../hooks/useChartsLocalization.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
const StyledText = styled('text'
|
|
10
|
+
const StyledText = styled('text', {
|
|
11
|
+
slot: 'internal',
|
|
12
|
+
shouldForwardProp: undefined
|
|
13
|
+
})(({
|
|
11
14
|
theme
|
|
12
15
|
}) => _extends({}, theme.typography.body2, {
|
|
13
16
|
stroke: 'none',
|
|
@@ -7,7 +7,10 @@ import { styled } from '@mui/material/styles';
|
|
|
7
7
|
import { useDrawingArea } from "../hooks/useDrawingArea.js";
|
|
8
8
|
import { useChartsLocalization } from "../hooks/useChartsLocalization.js";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
|
-
const StyledText = styled('text'
|
|
10
|
+
const StyledText = styled('text', {
|
|
11
|
+
slot: 'internal',
|
|
12
|
+
shouldForwardProp: undefined
|
|
13
|
+
})(({
|
|
11
14
|
theme
|
|
12
15
|
}) => _extends({}, theme.typography.body2, {
|
|
13
16
|
stroke: 'none',
|
|
@@ -40,4 +40,4 @@ export type CommonChartsReferenceLineProps = {
|
|
|
40
40
|
*/
|
|
41
41
|
classes?: Partial<ChartsReferenceLineClasses>;
|
|
42
42
|
};
|
|
43
|
-
export declare const ReferenceLineRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, import("react").SVGProps<SVGGElement>, {}>;
|
|
43
|
+
export declare const ReferenceLineRoot: import("@emotion/styled").StyledComponent<import("@mui/system").MUIStyledCommonProps<import("@mui/material/styles").Theme>, Pick<import("react").SVGProps<SVGGElement>, keyof import("react").SVGProps<SVGGElement>>, {}>;
|
|
@@ -3,7 +3,10 @@ import { styled } from '@mui/material/styles';
|
|
|
3
3
|
import { referenceLineClasses } from "./chartsReferenceLineClasses.js";
|
|
4
4
|
export const DEFAULT_SPACING = 5;
|
|
5
5
|
export const DEFAULT_SPACING_MIDDLE_OTHER_AXIS = 0;
|
|
6
|
-
export const ReferenceLineRoot = styled('g'
|
|
6
|
+
export const ReferenceLineRoot = styled('g', {
|
|
7
|
+
slot: 'internal',
|
|
8
|
+
shouldForwardProp: undefined
|
|
9
|
+
})(({
|
|
7
10
|
theme
|
|
8
11
|
}) => ({
|
|
9
12
|
[`& .${referenceLineClasses.line}`]: {
|