@mui/x-charts 8.22.0 → 8.23.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/BarElement.js +1 -1
- package/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
- package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
- package/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
- package/BarChart/BarLabel/getBarLabel.d.ts +3 -3
- package/BarChart/FocusedBar.js +1 -1
- package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
- package/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
- package/BarChart/seriesConfig/bar/keyboardFocusHandler.js +23 -0
- package/BarChart/seriesConfig/bar/seriesProcessor.js +2 -2
- package/BarChart/seriesConfig/index.js +3 -1
- package/CHANGELOG.md +202 -0
- package/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
- package/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
- package/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
- package/ChartsSurface/ChartsSurface.js +7 -8
- package/ChartsTooltip/ChartsTooltipContainer.js +4 -5
- package/ChartsTooltip/useAxisTooltip.js +3 -4
- package/ChartsTooltip/useItemTooltip.js +2 -3
- package/ChartsWrapper/ChartsWrapper.js +2 -3
- package/LineChart/FocusedLineMark.js +1 -1
- package/LineChart/LineHighlightPlot.js +1 -2
- package/LineChart/MarkPlot.js +1 -2
- package/LineChart/seriesConfig/index.js +3 -1
- package/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/LineChart/seriesConfig/keyboardFocusHandler.js +23 -0
- package/LineChart/seriesConfig/seriesProcessor.js +2 -2
- package/PieChart/FocusedPieArc.d.ts +2 -0
- package/PieChart/FocusedPieArc.js +58 -0
- package/PieChart/PieArcPlot.js +3 -31
- package/PieChart/PieChart.js +2 -1
- package/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
- package/PieChart/dataTransform/getModifiedArcProperties.js +42 -0
- package/PieChart/dataTransform/useTransformData.js +16 -21
- package/PieChart/seriesConfig/index.js +3 -1
- package/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/PieChart/seriesConfig/keyboardFocusHandler.js +23 -0
- package/PieChart/seriesConfig/tooltipPosition.js +11 -20
- package/RadarChart/RadarAxis/useRadarAxis.js +1 -2
- package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
- package/RadarChart/RadarGrid/useRadarGridData.js +1 -2
- package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
- package/ScatterChart/BatchScatter.js +4 -5
- package/ScatterChart/FocusedScatterMark.js +1 -1
- package/ScatterChart/Scatter.js +1 -2
- package/ScatterChart/seriesConfig/index.js +3 -1
- package/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/ScatterChart/seriesConfig/keyboardFocusHandler.js +23 -0
- package/esm/BarChart/BarElement.js +1 -1
- package/esm/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
- package/esm/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
- package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
- package/esm/BarChart/BarLabel/getBarLabel.d.ts +3 -3
- package/esm/BarChart/FocusedBar.js +1 -1
- package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
- package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
- package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.js +17 -0
- package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +1 -1
- package/esm/BarChart/seriesConfig/index.js +3 -1
- package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
- package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
- package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
- package/esm/ChartsSurface/ChartsSurface.js +7 -8
- package/esm/ChartsTooltip/ChartsTooltipContainer.js +4 -5
- package/esm/ChartsTooltip/useAxisTooltip.js +3 -4
- package/esm/ChartsTooltip/useItemTooltip.js +2 -3
- package/esm/ChartsWrapper/ChartsWrapper.js +2 -3
- package/esm/LineChart/FocusedLineMark.js +1 -1
- package/esm/LineChart/LineHighlightPlot.js +1 -2
- package/esm/LineChart/MarkPlot.js +1 -2
- package/esm/LineChart/seriesConfig/index.js +3 -1
- package/esm/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/esm/LineChart/seriesConfig/keyboardFocusHandler.js +17 -0
- package/esm/LineChart/seriesConfig/seriesProcessor.js +1 -1
- package/esm/PieChart/FocusedPieArc.d.ts +2 -0
- package/esm/PieChart/FocusedPieArc.js +51 -0
- package/esm/PieChart/PieArcPlot.js +5 -33
- package/esm/PieChart/PieChart.js +2 -1
- package/esm/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
- package/esm/PieChart/dataTransform/getModifiedArcProperties.js +36 -0
- package/esm/PieChart/dataTransform/useTransformData.js +16 -21
- package/esm/PieChart/seriesConfig/index.js +3 -1
- package/esm/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/esm/PieChart/seriesConfig/keyboardFocusHandler.js +17 -0
- package/esm/PieChart/seriesConfig/tooltipPosition.js +11 -20
- package/esm/RadarChart/RadarAxis/useRadarAxis.js +1 -2
- package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
- package/esm/RadarChart/RadarGrid/useRadarGridData.js +1 -2
- package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
- package/esm/ScatterChart/BatchScatter.js +4 -5
- package/esm/ScatterChart/FocusedScatterMark.js +1 -1
- package/esm/ScatterChart/Scatter.js +1 -2
- package/esm/ScatterChart/seriesConfig/index.js +3 -1
- package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.js +17 -0
- package/esm/hooks/useAxis.js +8 -9
- package/esm/hooks/useAxisSystem.js +2 -3
- package/esm/hooks/useBrush.js +1 -2
- package/esm/hooks/useChartId.js +1 -2
- package/esm/hooks/useDataset.js +1 -2
- package/esm/hooks/useDrawingArea.js +1 -2
- package/esm/hooks/useFocusedItem.d.ts +1 -12
- package/esm/hooks/useFocusedItem.js +3 -11
- package/esm/hooks/useInteractionItemProps.d.ts +3 -2
- package/esm/hooks/useInteractionItemProps.js +13 -2
- package/esm/hooks/useIsItemFocused.d.ts +4 -3
- package/esm/hooks/useIsItemFocused.js +2 -3
- package/esm/hooks/useIsItemFocusedGetter.d.ts +3 -2
- package/esm/hooks/useIsItemFocusedGetter.js +2 -1
- package/esm/hooks/useItemHighlighted.js +2 -3
- package/esm/hooks/useItemHighlightedGetter.js +2 -3
- package/esm/hooks/useLegend.js +1 -2
- package/esm/hooks/usePieSeries.js +1 -2
- package/esm/hooks/useSeries.js +1 -2
- package/esm/hooks/useSkipAnimation.js +1 -2
- package/esm/hooks/useZAxis.js +1 -2
- package/esm/index.js +1 -1
- package/esm/internals/commonNextFocusItem.d.ts +14 -0
- package/esm/internals/commonNextFocusItem.js +84 -0
- package/esm/internals/index.d.ts +1 -2
- package/esm/internals/index.js +1 -2
- package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
- package/esm/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
- package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
- package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
- package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
- package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +1 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +12 -105
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +9 -15
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +45 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +40 -0
- package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +2 -2
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
- package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
- package/esm/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
- package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
- package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
- package/esm/internals/seriesHasData.d.ts +4 -0
- package/esm/internals/seriesHasData.js +8 -0
- package/esm/internals/seriesSelectorOfType.js +2 -3
- package/esm/internals/stacking/index.d.ts +1 -0
- package/esm/internals/stacking/index.js +1 -0
- package/esm/internals/stacking/offset/index.d.ts +1 -0
- package/esm/internals/stacking/offset/index.js +1 -0
- package/esm/internals/stacking/offset/offsetDiverging.d.ts +8 -0
- package/esm/internals/stacking/offset/offsetDiverging.js +47 -0
- package/esm/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
- package/esm/internals/{stackSeries.js → stacking/stackSeries.js} +8 -6
- package/esm/models/seriesType/config.d.ts +0 -2
- package/esm/models/seriesType/index.d.ts +3 -1
- package/hooks/useAxis.js +8 -9
- package/hooks/useAxisSystem.js +2 -3
- package/hooks/useBrush.js +1 -2
- package/hooks/useChartId.js +1 -2
- package/hooks/useDataset.js +1 -2
- package/hooks/useDrawingArea.js +1 -2
- package/hooks/useFocusedItem.d.ts +1 -12
- package/hooks/useFocusedItem.js +1 -11
- package/hooks/useInteractionItemProps.d.ts +3 -2
- package/hooks/useInteractionItemProps.js +13 -2
- package/hooks/useIsItemFocused.d.ts +4 -3
- package/hooks/useIsItemFocused.js +2 -3
- package/hooks/useIsItemFocusedGetter.d.ts +3 -2
- package/hooks/useIsItemFocusedGetter.js +2 -1
- package/hooks/useItemHighlighted.js +2 -3
- package/hooks/useItemHighlightedGetter.js +2 -3
- package/hooks/useLegend.js +1 -2
- package/hooks/usePieSeries.js +1 -2
- package/hooks/useSeries.js +1 -2
- package/hooks/useSkipAnimation.js +1 -2
- package/hooks/useZAxis.js +1 -2
- package/index.js +1 -1
- package/internals/commonNextFocusItem.d.ts +14 -0
- package/internals/commonNextFocusItem.js +93 -0
- package/internals/index.d.ts +1 -2
- package/internals/index.js +4 -16
- package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
- package/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
- package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
- package/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
- package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
- package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +5 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +11 -104
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -16
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +51 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +46 -0
- package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +1 -1
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
- package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
- package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
- package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
- package/internals/seriesHasData.d.ts +4 -0
- package/internals/seriesHasData.js +14 -0
- package/internals/seriesSelectorOfType.js +2 -3
- package/internals/stacking/index.d.ts +1 -0
- package/internals/stacking/index.js +16 -0
- package/internals/stacking/offset/index.d.ts +1 -0
- package/internals/stacking/offset/index.js +16 -0
- package/internals/stacking/offset/offsetDiverging.d.ts +8 -0
- package/internals/stacking/offset/offsetDiverging.js +53 -0
- package/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
- package/internals/{stackSeries.js → stacking/stackSeries.js} +3 -1
- package/models/seriesType/config.d.ts +0 -2
- package/models/seriesType/index.d.ts +3 -1
- package/package.json +4 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -4
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
- package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -92
- package/esm/internals/store/useSelector.d.ts +0 -2
- package/esm/internals/store/useSelector.js +0 -2
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -10
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
- package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -99
- package/internals/store/useSelector.d.ts +0 -2
- package/internals/store/useSelector.js +0 -8
|
@@ -67,7 +67,7 @@ export type BarLabelItemProps<V extends BarValueType | null> = Omit<BarLabelOwne
|
|
|
67
67
|
* @param {BarLabelContext} context data about the bar.
|
|
68
68
|
* @returns {string} The formatted label.
|
|
69
69
|
*/
|
|
70
|
-
barLabel?: 'value' | ((item: BarItem
|
|
70
|
+
barLabel?: 'value' | ((item: BarItem, context: BarLabelContext) => string | null | undefined);
|
|
71
71
|
/**
|
|
72
72
|
* The placement of the bar label.
|
|
73
73
|
* It controls whether the label is rendered in the center or outside the bar.
|
|
@@ -3,29 +3,29 @@ import { type BarLabelItemProps } from "./BarLabelItem.js";
|
|
|
3
3
|
import type { SeriesId } from "../../models/seriesType/common.js";
|
|
4
4
|
import { type BarSeriesType, type BarValueType } from "../../models/seriesType/bar.js";
|
|
5
5
|
import { type BarLabelFunction } from "./BarLabel.types.js";
|
|
6
|
-
interface BarLabelPlotProps
|
|
7
|
-
processedSeries: ProcessedBarLabelSeriesData
|
|
6
|
+
interface BarLabelPlotProps {
|
|
7
|
+
processedSeries: ProcessedBarLabelSeriesData;
|
|
8
8
|
className: string;
|
|
9
9
|
skipAnimation?: boolean;
|
|
10
|
-
barLabel?: BarLabelItemProps<
|
|
10
|
+
barLabel?: BarLabelItemProps<BarValueType | null>['barLabel'];
|
|
11
11
|
}
|
|
12
|
-
export interface ProcessedBarLabelSeriesData
|
|
12
|
+
export interface ProcessedBarLabelSeriesData {
|
|
13
13
|
seriesId: SeriesId;
|
|
14
|
-
data: ProcessedBarLabelData
|
|
15
|
-
barLabel?: 'value' | BarLabelFunction
|
|
14
|
+
data: ProcessedBarLabelData[];
|
|
15
|
+
barLabel?: 'value' | BarLabelFunction;
|
|
16
16
|
barLabelPlacement?: BarSeriesType['barLabelPlacement'];
|
|
17
17
|
layout?: 'vertical' | 'horizontal';
|
|
18
18
|
xOrigin: number;
|
|
19
19
|
yOrigin: number;
|
|
20
20
|
}
|
|
21
|
-
export interface ProcessedBarLabelData
|
|
21
|
+
export interface ProcessedBarLabelData extends AnimationData {
|
|
22
22
|
seriesId: SeriesId;
|
|
23
23
|
dataIndex: number;
|
|
24
24
|
color: string;
|
|
25
|
-
value:
|
|
25
|
+
value: BarValueType | null;
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* @ignore - internal component.
|
|
29
29
|
*/
|
|
30
|
-
declare function BarLabelPlot
|
|
30
|
+
declare function BarLabelPlot(props: BarLabelPlotProps): import("react/jsx-runtime").JSX.Element | null;
|
|
31
31
|
export { BarLabelPlot };
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type SeriesId } from "../../models/seriesType/common.js";
|
|
2
2
|
import { type BarLabelFunction } from "./BarLabel.types.js";
|
|
3
3
|
import { type BarValueType } from "../../models/seriesType/bar.js";
|
|
4
|
-
export declare function getBarLabel
|
|
5
|
-
barLabel: 'value' | BarLabelFunction
|
|
6
|
-
value:
|
|
4
|
+
export declare function getBarLabel(options: {
|
|
5
|
+
barLabel: 'value' | BarLabelFunction;
|
|
6
|
+
value: BarValueType | null;
|
|
7
7
|
dataIndex: number;
|
|
8
8
|
seriesId: SeriesId;
|
|
9
9
|
height: number;
|
|
@@ -19,7 +19,7 @@ export function FocusedBar(props) {
|
|
|
19
19
|
yAxis,
|
|
20
20
|
yAxisIds
|
|
21
21
|
} = useYAxes();
|
|
22
|
-
if (focusedItem === null || focusedItem.
|
|
22
|
+
if (focusedItem === null || focusedItem.type !== 'bar' || !barSeries) {
|
|
23
23
|
return null;
|
|
24
24
|
}
|
|
25
25
|
const series = barSeries?.series[focusedItem.seriesId];
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import { type AllSeriesType } from "../../../models/seriesType/index.js";
|
|
2
|
-
export declare function getSeriesWithDefaultValues
|
|
2
|
+
export declare function getSeriesWithDefaultValues(seriesData: AllSeriesType<'bar'>, seriesIndex: number, colors: readonly string[]): {
|
|
3
3
|
id: import("../../../index.js").SeriesId;
|
|
4
4
|
color: string;
|
|
5
|
+
type: "bar";
|
|
6
|
+
data?: ReadonlyArray<import("../../../index.js").BarValueType | null>;
|
|
7
|
+
dataKey?: string;
|
|
8
|
+
label?: string | ((location: "tooltip" | "legend") => string);
|
|
9
|
+
layout?: "horizontal" | "vertical";
|
|
10
|
+
stackOffset?: import("../../../index.js").StackOffsetType;
|
|
11
|
+
minBarSize?: number;
|
|
12
|
+
barLabel?: "value" | ((item: import("../../index.js").BarItem, context: import("../../index.js").BarLabelContext) => string | null | undefined);
|
|
13
|
+
barLabelPlacement?: "center" | "outside";
|
|
14
|
+
valueFormatter?: import("../../../internals/index.js").SeriesValueFormatter<number | null> | undefined;
|
|
15
|
+
highlightScope?: import("../../../index.js").HighlightScope;
|
|
16
|
+
labelMarkType?: import("../../../internals/index.js").ChartsLabelMarkType;
|
|
17
|
+
colorGetter?: ((data: import("../../../internals/index.js").ColorCallbackValue<number | null>) => string) | undefined;
|
|
18
|
+
xAxisId?: import("../../../internals/index.js").AxisId;
|
|
19
|
+
yAxisId?: import("../../../internals/index.js").AxisId;
|
|
20
|
+
stack?: string;
|
|
21
|
+
stackOrder?: import("../../../index.js").StackOrderType;
|
|
5
22
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { KeyboardFocusHandler } from "../../../internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js";
|
|
2
|
+
declare const keyboardFocusHandler: KeyboardFocusHandler<'bar', 'bar' | 'line' | 'scatter'>;
|
|
3
|
+
export default keyboardFocusHandler;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createGetNextIndexFocusedItem, createGetPreviousIndexFocusedItem, createGetNextSeriesFocusedItem, createGetPreviousSeriesFocusedItem } from "../../../internals/commonNextFocusItem.js";
|
|
2
|
+
const outSeriesTypes = new Set(['bar', 'line', 'scatter']);
|
|
3
|
+
const keyboardFocusHandler = event => {
|
|
4
|
+
switch (event.key) {
|
|
5
|
+
case 'ArrowRight':
|
|
6
|
+
return createGetNextIndexFocusedItem(outSeriesTypes);
|
|
7
|
+
case 'ArrowLeft':
|
|
8
|
+
return createGetPreviousIndexFocusedItem(outSeriesTypes);
|
|
9
|
+
case 'ArrowDown':
|
|
10
|
+
return createGetPreviousSeriesFocusedItem(outSeriesTypes);
|
|
11
|
+
case 'ArrowUp':
|
|
12
|
+
return createGetNextSeriesFocusedItem(outSeriesTypes);
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export default keyboardFocusHandler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
|
|
3
3
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
|
-
import { getStackingGroups } from "../../../internals/
|
|
4
|
+
import { getStackingGroups } from "../../../internals/stacking/index.js";
|
|
5
5
|
const barValueFormatter = v => v == null ? '' : v.toLocaleString();
|
|
6
6
|
const seriesProcessor = (params, dataset) => {
|
|
7
7
|
const {
|
|
@@ -2,6 +2,7 @@ import { getExtremumX, getExtremumY } from "./bar/extremums.js";
|
|
|
2
2
|
import seriesProcessor from "./bar/seriesProcessor.js";
|
|
3
3
|
import legendGetter from "./bar/legend.js";
|
|
4
4
|
import getColor from "./bar/getColor.js";
|
|
5
|
+
import keyboardFocusHandler from "./bar/keyboardFocusHandler.js";
|
|
5
6
|
import tooltipGetter, { axisTooltipGetter } from "./bar/tooltip.js";
|
|
6
7
|
import tooltipItemPositionGetter from "./bar/tooltipPosition.js";
|
|
7
8
|
import { getSeriesWithDefaultValues } from "./bar/getSeriesWithDefaultValues.js";
|
|
@@ -14,5 +15,6 @@ export const barSeriesConfig = {
|
|
|
14
15
|
axisTooltipGetter,
|
|
15
16
|
xExtremumGetter: getExtremumX,
|
|
16
17
|
yExtremumGetter: getExtremumY,
|
|
17
|
-
getSeriesWithDefaultValues
|
|
18
|
+
getSeriesWithDefaultValues,
|
|
19
|
+
keyboardFocusHandler
|
|
18
20
|
};
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
5
5
|
import { isOrdinalScale } from "../internals/scaleGuards.js";
|
|
6
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
6
|
import { useStore } from "../internals/store/useStore.js";
|
|
8
7
|
import { selectorChartsHighlightXAxisValue, selectorChartXAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
9
8
|
import { useDrawingArea } from "../hooks/index.js";
|
|
@@ -22,8 +21,8 @@ export default function ChartsXHighlight(props) {
|
|
|
22
21
|
height
|
|
23
22
|
} = useDrawingArea();
|
|
24
23
|
const store = useStore();
|
|
25
|
-
const axisXValues =
|
|
26
|
-
const xAxes =
|
|
24
|
+
const axisXValues = store.use(selectorChartsHighlightXAxisValue);
|
|
25
|
+
const xAxes = store.use(selectorChartXAxis);
|
|
27
26
|
if (axisXValues.length === 0) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
5
5
|
import { isOrdinalScale } from "../internals/scaleGuards.js";
|
|
6
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
6
|
import { useStore } from "../internals/store/useStore.js";
|
|
8
7
|
import { selectorChartsHighlightYAxisValue, selectorChartYAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
9
8
|
import { useDrawingArea } from "../hooks/index.js";
|
|
@@ -22,8 +21,8 @@ export default function ChartsYHighlight(props) {
|
|
|
22
21
|
width
|
|
23
22
|
} = useDrawingArea();
|
|
24
23
|
const store = useStore();
|
|
25
|
-
const axisYValues =
|
|
26
|
-
const yAxes =
|
|
24
|
+
const axisYValues = store.use(selectorChartsHighlightYAxisValue);
|
|
25
|
+
const yAxes = store.use(selectorChartYAxis);
|
|
27
26
|
if (axisYValues.length === 0) {
|
|
28
27
|
return null;
|
|
29
28
|
}
|
|
@@ -7,7 +7,6 @@ import { useTheme } from '@mui/material/styles';
|
|
|
7
7
|
import { brushOverlayClasses } from "./ChartsBrushOverlay.classes.js";
|
|
8
8
|
import { selectorChartDrawingArea } from "../internals/plugins/corePlugins/useChartDimensions/index.js";
|
|
9
9
|
import { selectorBrushStartX, selectorBrushStartY, selectorBrushCurrentX, selectorBrushCurrentY, selectorBrushConfig } from "../internals/plugins/featurePlugins/useChartBrush/index.js";
|
|
10
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
11
10
|
import { useStore } from "../internals/store/useStore.js";
|
|
12
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
function BrushRect(props) {
|
|
@@ -23,13 +22,13 @@ function BrushRect(props) {
|
|
|
23
22
|
*/
|
|
24
23
|
export function ChartsBrushOverlay(props) {
|
|
25
24
|
const store = useStore();
|
|
26
|
-
const drawingArea =
|
|
25
|
+
const drawingArea = store.use(selectorChartDrawingArea);
|
|
27
26
|
const theme = useTheme();
|
|
28
|
-
const brushStartX =
|
|
29
|
-
const brushStartY =
|
|
30
|
-
const brushCurrentX =
|
|
31
|
-
const brushCurrentY =
|
|
32
|
-
const brushConfig =
|
|
27
|
+
const brushStartX = store.use(selectorBrushStartX);
|
|
28
|
+
const brushStartY = store.use(selectorBrushStartY);
|
|
29
|
+
const brushCurrentX = store.use(selectorBrushCurrentX);
|
|
30
|
+
const brushCurrentY = store.use(selectorBrushCurrentY);
|
|
31
|
+
const brushConfig = store.use(selectorBrushConfig);
|
|
33
32
|
if (brushStartX === null || brushStartY === null || brushCurrentX === null || brushCurrentY === null) {
|
|
34
33
|
return null;
|
|
35
34
|
}
|
|
@@ -10,7 +10,6 @@ import useForkRef from '@mui/utils/useForkRef';
|
|
|
10
10
|
import clsx from 'clsx';
|
|
11
11
|
import { ChartsAxesGradients } from "../internals/components/ChartsAxesGradients/index.js";
|
|
12
12
|
import { useSvgRef } from "../hooks/useSvgRef.js";
|
|
13
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
14
13
|
import { useStore } from "../internals/store/useStore.js";
|
|
15
14
|
import { selectorChartPropsHeight, selectorChartPropsWidth, selectorChartSvgWidth, selectorChartSvgHeight } from "../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js";
|
|
16
15
|
import { selectorChartsHasFocusedItem, selectorChartsIsKeyboardNavigationEnabled } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
@@ -57,13 +56,13 @@ const ChartsSurfaceStyles = styled('svg', {
|
|
|
57
56
|
*/
|
|
58
57
|
const ChartsSurface = /*#__PURE__*/React.forwardRef(function ChartsSurface(inProps, ref) {
|
|
59
58
|
const store = useStore();
|
|
60
|
-
const svgWidth =
|
|
61
|
-
const svgHeight =
|
|
62
|
-
const propsWidth =
|
|
63
|
-
const propsHeight =
|
|
64
|
-
const isKeyboardNavigationEnabled =
|
|
65
|
-
const hasFocusedItem =
|
|
66
|
-
const hasZoom =
|
|
59
|
+
const svgWidth = store.use(selectorChartSvgWidth);
|
|
60
|
+
const svgHeight = store.use(selectorChartSvgHeight);
|
|
61
|
+
const propsWidth = store.use(selectorChartPropsWidth);
|
|
62
|
+
const propsHeight = store.use(selectorChartPropsHeight);
|
|
63
|
+
const isKeyboardNavigationEnabled = store.use(selectorChartsIsKeyboardNavigationEnabled);
|
|
64
|
+
const hasFocusedItem = store.use(selectorChartsHasFocusedItem);
|
|
65
|
+
const hasZoom = store.use(selectorChartHasZoom);
|
|
67
66
|
const svgRef = useSvgRef();
|
|
68
67
|
const handleRef = useForkRef(svgRef, ref);
|
|
69
68
|
const themeProps = useThemeProps({
|
|
@@ -13,7 +13,6 @@ import NoSsr from '@mui/material/NoSsr';
|
|
|
13
13
|
import { rafThrottle } from '@mui/x-internals/rafThrottle';
|
|
14
14
|
import { useIsFineMainPointer, usePointerType } from "./utils.js";
|
|
15
15
|
import { useUtilityClasses } from "./chartsTooltipClasses.js";
|
|
16
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
17
16
|
import { useStore } from "../internals/store/useStore.js";
|
|
18
17
|
import { selectorChartsLastInteraction } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
19
18
|
import { selectorChartsTooltipItemIsDefined, selectorChartsTooltipItemPosition } from "../internals/plugins/featurePlugins/useChartTooltip/index.js";
|
|
@@ -83,11 +82,11 @@ function ChartsTooltipContainer(inProps) {
|
|
|
83
82
|
}));
|
|
84
83
|
const axisSystem = useAxisSystem();
|
|
85
84
|
const store = useStore();
|
|
86
|
-
const shouldPreventBecauseOfBrush =
|
|
87
|
-
const isOpen =
|
|
88
|
-
const lastInteraction =
|
|
85
|
+
const shouldPreventBecauseOfBrush = store.use(selectorBrushShouldPreventTooltip);
|
|
86
|
+
const isOpen = store.use(getIsOpenSelector(trigger, axisSystem, shouldPreventBecauseOfBrush));
|
|
87
|
+
const lastInteraction = store.use(selectorChartsLastInteraction);
|
|
89
88
|
const computedAnchor = lastInteraction === 'keyboard' ? 'node' : anchor;
|
|
90
|
-
const itemPosition =
|
|
89
|
+
const itemPosition = store.use(trigger === 'item' && computedAnchor === 'node' ? selectorChartsTooltipItemPosition : selectorReturnNull, position);
|
|
91
90
|
React.useEffect(() => {
|
|
92
91
|
const svgElement = svgRef.current;
|
|
93
92
|
if (svgElement === null) {
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import { useSeries } from "../hooks/useSeries.js";
|
|
4
4
|
import { useColorProcessor } from "../internals/plugins/corePlugins/useChartSeries/useColorProcessor.js";
|
|
5
5
|
import { useStore } from "../internals/store/useStore.js";
|
|
6
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
7
6
|
import { getLabel } from "../internals/getLabel.js";
|
|
8
7
|
import { isCartesianSeriesType } from "../internals/isCartesian.js";
|
|
9
8
|
import { utcFormatter } from "./utils.js";
|
|
@@ -43,9 +42,9 @@ export function useAxisTooltip(params = {}) {
|
|
|
43
42
|
const defaultYAxis = useYAxis();
|
|
44
43
|
const defaultRotationAxis = useRotationAxis();
|
|
45
44
|
const store = useStore();
|
|
46
|
-
const tooltipXAxes =
|
|
47
|
-
const tooltipYAxes =
|
|
48
|
-
const tooltipRotationAxes =
|
|
45
|
+
const tooltipXAxes = store.use(selectorChartsInteractionTooltipXAxes);
|
|
46
|
+
const tooltipYAxes = store.use(selectorChartsInteractionTooltipYAxes);
|
|
47
|
+
const tooltipRotationAxes = store.use(selectorChartsInteractionTooltipRotationAxes);
|
|
49
48
|
const series = useSeries();
|
|
50
49
|
const {
|
|
51
50
|
xAxis
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { useSeries } from "../hooks/useSeries.js";
|
|
4
4
|
import { selectorChartsTooltipItem } from "../internals/plugins/featurePlugins/useChartTooltip/index.js";
|
|
5
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
6
5
|
import { useStore } from "../internals/store/useStore.js";
|
|
7
6
|
import { useRotationAxes, useXAxes, useYAxes } from "../hooks/useAxis.js";
|
|
8
7
|
import { useZAxes } from "../hooks/useZAxis.js";
|
|
@@ -10,8 +9,8 @@ import { selectorChartSeriesConfig } from "../internals/plugins/corePlugins/useC
|
|
|
10
9
|
import { isCartesianSeries } from "../internals/isCartesian.js";
|
|
11
10
|
export function useInternalItemTooltip() {
|
|
12
11
|
const store = useStore();
|
|
13
|
-
const identifier =
|
|
14
|
-
const seriesConfig =
|
|
12
|
+
const identifier = store.use(selectorChartsTooltipItem);
|
|
13
|
+
const seriesConfig = store.use(selectorChartSeriesConfig);
|
|
15
14
|
const series = useSeries();
|
|
16
15
|
const {
|
|
17
16
|
xAxis,
|
|
@@ -4,7 +4,6 @@ import { styled } from '@mui/material/styles';
|
|
|
4
4
|
import { shouldForwardProp } from '@mui/system/createStyled';
|
|
5
5
|
import { useChartRootRef } from "../hooks/useChartRootRef.js";
|
|
6
6
|
import { useStore } from "../internals/store/useStore.js";
|
|
7
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
8
7
|
import { selectorChartPropsHeight, selectorChartPropsWidth } from "../internals/plugins/corePlugins/useChartDimensions/index.js";
|
|
9
8
|
import { chartsToolbarClasses } from "../Toolbar/index.js";
|
|
10
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -117,8 +116,8 @@ function ChartsWrapper(props) {
|
|
|
117
116
|
} = props;
|
|
118
117
|
const chartRootRef = useChartRootRef();
|
|
119
118
|
const store = useStore();
|
|
120
|
-
const propsWidth =
|
|
121
|
-
const propsHeight =
|
|
119
|
+
const propsWidth = store.use(selectorChartPropsWidth);
|
|
120
|
+
const propsHeight = store.use(selectorChartPropsHeight);
|
|
122
121
|
return /*#__PURE__*/_jsx(Root, {
|
|
123
122
|
ref: chartRootRef,
|
|
124
123
|
ownerState: props,
|
|
@@ -17,7 +17,7 @@ export function FocusedLineMark() {
|
|
|
17
17
|
yAxis,
|
|
18
18
|
yAxisIds
|
|
19
19
|
} = useYAxes();
|
|
20
|
-
if (focusedItem === null || focusedItem.
|
|
20
|
+
if (focusedItem === null || focusedItem.type !== 'line' || !lineSeries) {
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
const series = lineSeries?.series[focusedItem.seriesId];
|
|
@@ -6,7 +6,6 @@ const _excluded = ["slots", "slotProps"];
|
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
import { useStore } from "../internals/store/useStore.js";
|
|
9
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
10
9
|
import { LineHighlightElement } from "./LineHighlightElement.js";
|
|
11
10
|
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
12
11
|
import { DEFAULT_X_AXIS_KEY } from "../constants/index.js";
|
|
@@ -45,7 +44,7 @@ function LineHighlightPlot(props) {
|
|
|
45
44
|
instance
|
|
46
45
|
} = useChartContext();
|
|
47
46
|
const store = useStore();
|
|
48
|
-
const highlightedIndexes =
|
|
47
|
+
const highlightedIndexes = store.use(selectorChartsHighlightXAxisIndex);
|
|
49
48
|
if (highlightedIndexes.length === 0) {
|
|
50
49
|
return null;
|
|
51
50
|
}
|
|
@@ -11,7 +11,6 @@ import { MarkElement } from "./MarkElement.js";
|
|
|
11
11
|
import { useItemHighlightedGetter, useXAxes, useYAxes } from "../hooks/index.js";
|
|
12
12
|
import { useInternalIsZoomInteracting } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js";
|
|
13
13
|
import { selectorChartsHighlightXAxisIndex } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
14
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
15
14
|
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
16
15
|
import { useMarkPlotData } from "./useMarkPlotData.js";
|
|
17
16
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -48,7 +47,7 @@ function MarkPlot(props) {
|
|
|
48
47
|
isFaded,
|
|
49
48
|
isHighlighted
|
|
50
49
|
} = useItemHighlightedGetter();
|
|
51
|
-
const xAxisHighlightIndexes =
|
|
50
|
+
const xAxisHighlightIndexes = store.use(selectorChartsHighlightXAxisIndex);
|
|
52
51
|
const highlightedItems = React.useMemo(() => {
|
|
53
52
|
const rep = {};
|
|
54
53
|
for (const {
|
|
@@ -5,6 +5,7 @@ import legendGetter from "./legend.js";
|
|
|
5
5
|
import tooltipGetter, { axisTooltipGetter } from "./tooltip.js";
|
|
6
6
|
import getSeriesWithDefaultValues from "./getSeriesWithDefaultValues.js";
|
|
7
7
|
import tooltipItemPositionGetter from "./tooltipPosition.js";
|
|
8
|
+
import keyboardFocusHandler from "./keyboardFocusHandler.js";
|
|
8
9
|
export const lineSeriesConfig = {
|
|
9
10
|
colorProcessor: getColor,
|
|
10
11
|
seriesProcessor,
|
|
@@ -14,5 +15,6 @@ export const lineSeriesConfig = {
|
|
|
14
15
|
axisTooltipGetter,
|
|
15
16
|
xExtremumGetter: getExtremumX,
|
|
16
17
|
yExtremumGetter: getExtremumY,
|
|
17
|
-
getSeriesWithDefaultValues
|
|
18
|
+
getSeriesWithDefaultValues,
|
|
19
|
+
keyboardFocusHandler
|
|
18
20
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createGetNextIndexFocusedItem, createGetPreviousIndexFocusedItem, createGetNextSeriesFocusedItem, createGetPreviousSeriesFocusedItem } from "../../internals/commonNextFocusItem.js";
|
|
2
|
+
const outSeriesTypes = new Set(['bar', 'line', 'scatter']);
|
|
3
|
+
const keyboardFocusHandler = event => {
|
|
4
|
+
switch (event.key) {
|
|
5
|
+
case 'ArrowRight':
|
|
6
|
+
return createGetNextIndexFocusedItem(outSeriesTypes);
|
|
7
|
+
case 'ArrowLeft':
|
|
8
|
+
return createGetPreviousIndexFocusedItem(outSeriesTypes);
|
|
9
|
+
case 'ArrowDown':
|
|
10
|
+
return createGetPreviousSeriesFocusedItem(outSeriesTypes);
|
|
11
|
+
case 'ArrowUp':
|
|
12
|
+
return createGetNextSeriesFocusedItem(outSeriesTypes);
|
|
13
|
+
default:
|
|
14
|
+
return null;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export default keyboardFocusHandler;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
2
|
import { stack as d3Stack } from '@mui/x-charts-vendor/d3-shape';
|
|
3
3
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
4
|
-
import { getStackingGroups } from "../../internals/
|
|
4
|
+
import { getStackingGroups } from "../../internals/stacking/index.js";
|
|
5
5
|
const seriesProcessor = (params, dataset) => {
|
|
6
6
|
const {
|
|
7
7
|
seriesOrder,
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
|
+
import * as React from 'react';
|
|
5
|
+
import { useTheme } from '@mui/material/styles';
|
|
6
|
+
import { useFocusedItem } from "../hooks/useFocusedItem.js";
|
|
7
|
+
import { usePieSeriesContext, usePieSeriesLayout } from "../hooks/usePieSeries.js";
|
|
8
|
+
import { PieArc, pieArcClasses } from "./PieArc.js";
|
|
9
|
+
import { useItemHighlighted } from "../hooks/useItemHighlighted.js";
|
|
10
|
+
import { getModifiedArcProperties } from "./dataTransform/getModifiedArcProperties.js";
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
export function FocusedPieArc(props) {
|
|
13
|
+
const theme = useTheme();
|
|
14
|
+
const focusedItem = useFocusedItem();
|
|
15
|
+
const pieSeriesLayout = usePieSeriesLayout();
|
|
16
|
+
const {
|
|
17
|
+
isHighlighted,
|
|
18
|
+
isFaded
|
|
19
|
+
} = useItemHighlighted(focusedItem);
|
|
20
|
+
const pieSeries = usePieSeriesContext();
|
|
21
|
+
if (focusedItem === null || focusedItem.type !== 'pie' || !pieSeries) {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
const series = pieSeries?.series[focusedItem.seriesId];
|
|
25
|
+
const {
|
|
26
|
+
center,
|
|
27
|
+
radius
|
|
28
|
+
} = pieSeriesLayout[focusedItem.seriesId];
|
|
29
|
+
if (!series || !center || !radius) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const item = series.data[focusedItem.dataIndex];
|
|
33
|
+
const arcSizes = getModifiedArcProperties(series, pieSeriesLayout[focusedItem.seriesId], isHighlighted, isFaded);
|
|
34
|
+
return /*#__PURE__*/_jsx(PieArc, _extends({
|
|
35
|
+
transform: `translate(${pieSeriesLayout[series.id].center.x}, ${pieSeriesLayout[series.id].center.y})`,
|
|
36
|
+
startAngle: item.startAngle,
|
|
37
|
+
endAngle: item.endAngle,
|
|
38
|
+
color: "transparent",
|
|
39
|
+
pointerEvents: "none",
|
|
40
|
+
skipInteraction: true,
|
|
41
|
+
skipAnimation: true,
|
|
42
|
+
stroke: (theme.vars ?? theme).palette.text.primary,
|
|
43
|
+
id: series.id,
|
|
44
|
+
className: pieArcClasses.focusIndicator,
|
|
45
|
+
dataIndex: focusedItem.dataIndex,
|
|
46
|
+
isFaded: false,
|
|
47
|
+
isHighlighted: false,
|
|
48
|
+
isFocused: false,
|
|
49
|
+
strokeWidth: 3
|
|
50
|
+
}, arcSizes, props));
|
|
51
|
+
}
|
|
@@ -5,11 +5,9 @@ import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWith
|
|
|
5
5
|
const _excluded = ["slots", "slotProps", "innerRadius", "outerRadius", "cornerRadius", "paddingAngle", "id", "highlighted", "faded", "data", "onItemClick", "skipAnimation"];
|
|
6
6
|
import * as React from 'react';
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
|
-
import {
|
|
9
|
-
import { useFocusedItem } from "../hooks/useFocusedItem.js";
|
|
10
|
-
import { PieArc, pieArcClasses } from "./PieArc.js";
|
|
8
|
+
import { PieArc } from "./PieArc.js";
|
|
11
9
|
import { useTransformData } from "./dataTransform/useTransformData.js";
|
|
12
|
-
import { jsx as _jsx
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
11
|
function PieArcPlot(props) {
|
|
14
12
|
const {
|
|
15
13
|
slots,
|
|
@@ -28,7 +26,6 @@ function PieArcPlot(props) {
|
|
|
28
26
|
skipAnimation
|
|
29
27
|
} = props,
|
|
30
28
|
other = _objectWithoutPropertiesLoose(props, _excluded);
|
|
31
|
-
const theme = useTheme();
|
|
32
29
|
const transformedData = useTransformData({
|
|
33
30
|
innerRadius,
|
|
34
31
|
outerRadius,
|
|
@@ -39,18 +36,12 @@ function PieArcPlot(props) {
|
|
|
39
36
|
faded,
|
|
40
37
|
data
|
|
41
38
|
});
|
|
42
|
-
const {
|
|
43
|
-
dataIndex,
|
|
44
|
-
seriesId,
|
|
45
|
-
seriesType
|
|
46
|
-
} = useFocusedItem() ?? {};
|
|
47
|
-
const focusedItem = dataIndex !== undefined && seriesId === id && seriesType === 'pie' ? transformedData[dataIndex] : null;
|
|
48
39
|
if (data.length === 0) {
|
|
49
40
|
return null;
|
|
50
41
|
}
|
|
51
42
|
const Arc = slots?.pieArc ?? PieArc;
|
|
52
|
-
return /*#__PURE__*/
|
|
53
|
-
children:
|
|
43
|
+
return /*#__PURE__*/_jsx("g", _extends({}, other, {
|
|
44
|
+
children: transformedData.map((item, index) => /*#__PURE__*/_jsx(Arc, _extends({
|
|
54
45
|
startAngle: item.startAngle,
|
|
55
46
|
endAngle: item.endAngle,
|
|
56
47
|
paddingAngle: item.paddingAngle,
|
|
@@ -71,26 +62,7 @@ function PieArcPlot(props) {
|
|
|
71
62
|
dataIndex: index
|
|
72
63
|
}, item);
|
|
73
64
|
})
|
|
74
|
-
}, slotProps?.pieArc), item.dataIndex))
|
|
75
|
-
startAngle: focusedItem.startAngle,
|
|
76
|
-
endAngle: focusedItem.endAngle,
|
|
77
|
-
paddingAngle: focusedItem.paddingAngle,
|
|
78
|
-
innerRadius: focusedItem.innerRadius,
|
|
79
|
-
color: "transparent",
|
|
80
|
-
pointerEvents: "none",
|
|
81
|
-
skipInteraction: true,
|
|
82
|
-
outerRadius: focusedItem.outerRadius,
|
|
83
|
-
cornerRadius: focusedItem.cornerRadius,
|
|
84
|
-
skipAnimation: true,
|
|
85
|
-
stroke: (theme.vars ?? theme).palette.text.primary,
|
|
86
|
-
id: id,
|
|
87
|
-
className: pieArcClasses.focusIndicator,
|
|
88
|
-
dataIndex: focusedItem.dataIndex,
|
|
89
|
-
isFaded: false,
|
|
90
|
-
isHighlighted: false,
|
|
91
|
-
isFocused: false,
|
|
92
|
-
strokeWidth: 3
|
|
93
|
-
})]
|
|
65
|
+
}, slotProps?.pieArc), item.dataIndex))
|
|
94
66
|
}));
|
|
95
67
|
}
|
|
96
68
|
process.env.NODE_ENV !== "production" ? PieArcPlot.propTypes = {
|
package/esm/PieChart/PieChart.js
CHANGED
|
@@ -17,6 +17,7 @@ import { useChartContainerProps } from "../ChartContainer/useChartContainerProps
|
|
|
17
17
|
import { ChartsWrapper } from "../ChartsWrapper/index.js";
|
|
18
18
|
import { PIE_CHART_PLUGINS } from "./PieChart.plugins.js";
|
|
19
19
|
import { defaultizeMargin } from "../internals/defaultizeMargin.js";
|
|
20
|
+
import { FocusedPieArc } from "./FocusedPieArc.js";
|
|
20
21
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
22
|
/**
|
|
22
23
|
* Demos:
|
|
@@ -88,7 +89,7 @@ const PieChart = /*#__PURE__*/React.forwardRef(function PieChart(inProps, ref) {
|
|
|
88
89
|
slots: slots,
|
|
89
90
|
slotProps: slotProps,
|
|
90
91
|
onItemClick: onItemClick
|
|
91
|
-
}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
92
|
+
}), /*#__PURE__*/_jsx(FocusedPieArc, {}), /*#__PURE__*/_jsx(ChartsOverlay, {
|
|
92
93
|
loading: loading,
|
|
93
94
|
slots: slots,
|
|
94
95
|
slotProps: slotProps
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { DefaultizedPieSeriesType, PieSeriesLayout } from "../../models/seriesType/pie.js";
|
|
2
|
+
/**
|
|
3
|
+
* Function that returns arc properties after applying transformation from highlight/fade states.
|
|
4
|
+
*/
|
|
5
|
+
export declare function getModifiedArcProperties(seriesDef: Pick<DefaultizedPieSeriesType, 'cornerRadius' | 'paddingAngle' | 'id' | 'highlighted' | 'faded' | 'data'>, seriesLayout: Pick<PieSeriesLayout, 'radius'>, isHighlighted: boolean, isFaded: boolean): {
|
|
6
|
+
paddingAngle: number;
|
|
7
|
+
innerRadius: number;
|
|
8
|
+
outerRadius: number;
|
|
9
|
+
cornerRadius: number;
|
|
10
|
+
arcLabelRadius: number;
|
|
11
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { deg2rad } from "../../internals/angleConversion.js";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Function that returns arc properties after applying transformation from highlight/fade states.
|
|
6
|
+
*/
|
|
7
|
+
export function getModifiedArcProperties(seriesDef, seriesLayout, isHighlighted, isFaded) {
|
|
8
|
+
const {
|
|
9
|
+
faded,
|
|
10
|
+
highlighted,
|
|
11
|
+
paddingAngle: basePaddingAngle = 0,
|
|
12
|
+
cornerRadius: baseCornerRadius = 0
|
|
13
|
+
} = seriesDef;
|
|
14
|
+
const {
|
|
15
|
+
radius: {
|
|
16
|
+
inner: baseInnerRadius = 0,
|
|
17
|
+
label: baseArcLabelRadius,
|
|
18
|
+
outer: baseOuterRadius
|
|
19
|
+
}
|
|
20
|
+
} = seriesLayout;
|
|
21
|
+
const attributesOverride = _extends({
|
|
22
|
+
additionalRadius: 0
|
|
23
|
+
}, isFaded && faded || isHighlighted && highlighted || {});
|
|
24
|
+
const paddingAngle = Math.max(0, deg2rad(attributesOverride.paddingAngle ?? basePaddingAngle));
|
|
25
|
+
const innerRadius = Math.max(0, attributesOverride.innerRadius ?? baseInnerRadius);
|
|
26
|
+
const outerRadius = Math.max(0, attributesOverride.outerRadius ?? baseOuterRadius + attributesOverride.additionalRadius);
|
|
27
|
+
const cornerRadius = attributesOverride.cornerRadius ?? baseCornerRadius;
|
|
28
|
+
const arcLabelRadius = attributesOverride.arcLabelRadius ?? baseArcLabelRadius ?? (innerRadius + outerRadius) / 2;
|
|
29
|
+
return {
|
|
30
|
+
paddingAngle,
|
|
31
|
+
innerRadius,
|
|
32
|
+
outerRadius,
|
|
33
|
+
cornerRadius,
|
|
34
|
+
arcLabelRadius
|
|
35
|
+
};
|
|
36
|
+
}
|