@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
|
@@ -4,18 +4,13 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { useItemHighlightedGetter } from "../../hooks/useItemHighlightedGetter.js";
|
|
6
6
|
import { useIsItemFocusedGetter } from "../../hooks/useIsItemFocusedGetter.js";
|
|
7
|
-
import {
|
|
7
|
+
import { getModifiedArcProperties } from "./getModifiedArcProperties.js";
|
|
8
8
|
export function useTransformData(series) {
|
|
9
9
|
const {
|
|
10
10
|
id: seriesId,
|
|
11
11
|
data,
|
|
12
12
|
faded,
|
|
13
|
-
highlighted
|
|
14
|
-
paddingAngle: basePaddingAngle = 0,
|
|
15
|
-
innerRadius: baseInnerRadius = 0,
|
|
16
|
-
arcLabelRadius: baseArcLabelRadius,
|
|
17
|
-
outerRadius: baseOuterRadius,
|
|
18
|
-
cornerRadius: baseCornerRadius = 0
|
|
13
|
+
highlighted
|
|
19
14
|
} = series;
|
|
20
15
|
const {
|
|
21
16
|
isFaded: isItemFaded,
|
|
@@ -30,29 +25,29 @@ export function useTransformData(series) {
|
|
|
30
25
|
const isHighlighted = isItemHighlighted(currentItem);
|
|
31
26
|
const isFaded = !isHighlighted && isItemFaded(currentItem);
|
|
32
27
|
const isFocused = isItemFocused({
|
|
33
|
-
|
|
28
|
+
type: 'pie',
|
|
34
29
|
seriesId,
|
|
35
30
|
dataIndex: itemIndex
|
|
36
31
|
});
|
|
32
|
+
|
|
33
|
+
// TODO v9: Replace the second argument with the result of useSeriesLayout
|
|
34
|
+
const arcSizes = getModifiedArcProperties(series, {
|
|
35
|
+
radius: {
|
|
36
|
+
inner: series.innerRadius ?? 0,
|
|
37
|
+
outer: series.outerRadius,
|
|
38
|
+
label: series.arcLabelRadius ?? 0,
|
|
39
|
+
available: 0
|
|
40
|
+
}
|
|
41
|
+
}, isHighlighted, isFaded);
|
|
37
42
|
const attributesOverride = _extends({
|
|
38
43
|
additionalRadius: 0
|
|
39
44
|
}, isFaded && faded || isHighlighted && highlighted || {});
|
|
40
|
-
const paddingAngle = Math.max(0, deg2rad(attributesOverride.paddingAngle ?? basePaddingAngle));
|
|
41
|
-
const innerRadius = Math.max(0, attributesOverride.innerRadius ?? baseInnerRadius);
|
|
42
|
-
const outerRadius = Math.max(0, attributesOverride.outerRadius ?? baseOuterRadius + attributesOverride.additionalRadius);
|
|
43
|
-
const cornerRadius = attributesOverride.cornerRadius ?? baseCornerRadius;
|
|
44
|
-
const arcLabelRadius = attributesOverride.arcLabelRadius ?? baseArcLabelRadius ?? (innerRadius + outerRadius) / 2;
|
|
45
45
|
return _extends({}, item, attributesOverride, {
|
|
46
46
|
dataIndex: itemIndex,
|
|
47
47
|
isFaded,
|
|
48
48
|
isHighlighted,
|
|
49
|
-
isFocused
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
outerRadius,
|
|
53
|
-
cornerRadius,
|
|
54
|
-
arcLabelRadius
|
|
55
|
-
});
|
|
56
|
-
}), [baseCornerRadius, baseInnerRadius, baseOuterRadius, basePaddingAngle, baseArcLabelRadius, data, faded, highlighted, isItemFaded, isItemHighlighted, isItemFocused, seriesId]);
|
|
49
|
+
isFocused
|
|
50
|
+
}, arcSizes);
|
|
51
|
+
}), [data, seriesId, isItemHighlighted, isItemFaded, isItemFocused, series, faded, highlighted]);
|
|
57
52
|
return dataWithHighlight;
|
|
58
53
|
}
|
|
@@ -5,6 +5,7 @@ import tooltipGetter from "./tooltip.js";
|
|
|
5
5
|
import seriesLayout from "./seriesLayout.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 pieSeriesConfig = {
|
|
9
10
|
colorProcessor: getColor,
|
|
10
11
|
seriesProcessor,
|
|
@@ -12,5 +13,6 @@ export const pieSeriesConfig = {
|
|
|
12
13
|
legendGetter,
|
|
13
14
|
tooltipGetter,
|
|
14
15
|
tooltipItemPositionGetter,
|
|
15
|
-
getSeriesWithDefaultValues
|
|
16
|
+
getSeriesWithDefaultValues,
|
|
17
|
+
keyboardFocusHandler
|
|
16
18
|
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { createGetNextIndexFocusedItem, createGetPreviousIndexFocusedItem, createGetNextSeriesFocusedItem, createGetPreviousSeriesFocusedItem } from "../../internals/commonNextFocusItem.js";
|
|
2
|
+
const outSeriesTypes = new Set(['pie']);
|
|
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,44 +1,35 @@
|
|
|
1
1
|
import { findMinMax } from "../../internals/findMinMax.js";
|
|
2
|
-
import { getPercentageValue } from "../../internals/getPercentageValue.js";
|
|
3
|
-
import { getPieCoordinates } from "../getPieCoordinates.js";
|
|
4
2
|
const tooltipItemPositionGetter = params => {
|
|
5
3
|
const {
|
|
6
4
|
series,
|
|
7
|
-
drawingArea,
|
|
8
5
|
identifier,
|
|
9
|
-
placement
|
|
6
|
+
placement,
|
|
7
|
+
seriesLayout
|
|
10
8
|
} = params;
|
|
11
9
|
if (!identifier || identifier.dataIndex === undefined) {
|
|
12
10
|
return null;
|
|
13
11
|
}
|
|
14
12
|
const itemSeries = series.pie?.series[identifier.seriesId];
|
|
15
|
-
|
|
13
|
+
const layout = seriesLayout.pie?.[identifier.seriesId];
|
|
14
|
+
if (itemSeries == null || layout == null) {
|
|
16
15
|
return null;
|
|
17
16
|
}
|
|
18
17
|
const {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
} = getPieCoordinates({
|
|
23
|
-
cx: itemSeries.cx,
|
|
24
|
-
cy: itemSeries.cy
|
|
25
|
-
}, drawingArea);
|
|
18
|
+
center,
|
|
19
|
+
radius
|
|
20
|
+
} = layout;
|
|
26
21
|
const {
|
|
27
|
-
data
|
|
28
|
-
innerRadius: baseInnerRadius = 0,
|
|
29
|
-
outerRadius: baseOuterRadius
|
|
22
|
+
data
|
|
30
23
|
} = itemSeries;
|
|
31
|
-
const innerRadius = Math.max(0, getPercentageValue(baseInnerRadius ?? 0, availableRadius));
|
|
32
|
-
const outerRadius = Math.max(0, getPercentageValue(baseOuterRadius ?? availableRadius, availableRadius));
|
|
33
24
|
const dataItem = data[identifier.dataIndex];
|
|
34
25
|
if (!dataItem) {
|
|
35
26
|
return null;
|
|
36
27
|
}
|
|
37
28
|
|
|
38
29
|
// Compute the 4 corner points of the arc to get the bounding box.
|
|
39
|
-
const points = [[
|
|
40
|
-
x:
|
|
41
|
-
y:
|
|
30
|
+
const points = [[radius.inner, dataItem.startAngle], [radius.inner, dataItem.endAngle], [radius.outer, dataItem.startAngle], [radius.outer, dataItem.endAngle]].map(([r, angle]) => ({
|
|
31
|
+
x: center.x + r * Math.sin(angle),
|
|
32
|
+
y: center.y - r * Math.cos(angle)
|
|
42
33
|
}));
|
|
43
34
|
const [x0, x1] = findMinMax(points.map(p => p.x));
|
|
44
35
|
const [y0, y1] = findMinMax(points.map(p => p.y));
|
|
@@ -6,7 +6,6 @@ import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins
|
|
|
6
6
|
import { isOrdinalScale } from "../../internals/scaleGuards.js";
|
|
7
7
|
import { degToRad } from "../../internals/degToRad.js";
|
|
8
8
|
import { clampAngle } from "../../internals/clampAngle.js";
|
|
9
|
-
import { useSelector } from "../../internals/store/useSelector.js";
|
|
10
9
|
import { rad2deg } from "../../internals/angleConversion.js";
|
|
11
10
|
/**
|
|
12
11
|
* Returns an array with on item par metrics with the different point to label.
|
|
@@ -28,7 +27,7 @@ export function useRadarAxis(params) {
|
|
|
28
27
|
const {
|
|
29
28
|
cx,
|
|
30
29
|
cy
|
|
31
|
-
} =
|
|
30
|
+
} = store.use(selectorChartPolarCenter);
|
|
32
31
|
if (metric === undefined || !rotationScale || rotationScale.domain().length === 0) {
|
|
33
32
|
return null;
|
|
34
33
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { useRadiusAxes } from "../../hooks/useAxis.js";
|
|
2
2
|
import { useRadarSeries } from "../../hooks/useRadarSeries.js";
|
|
3
3
|
import { useRotationScale } from "../../hooks/useScale.js";
|
|
4
|
-
import { useSelector } from "../../internals/store/useSelector.js";
|
|
5
4
|
import { useStore } from "../../internals/store/useStore.js";
|
|
6
5
|
import { useChartContext } from "../../context/ChartProvider/useChartContext.js";
|
|
7
6
|
import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
@@ -17,9 +16,9 @@ export function useRadarAxisHighlight() {
|
|
|
17
16
|
instance
|
|
18
17
|
} = useChartContext();
|
|
19
18
|
const store = useStore();
|
|
20
|
-
const rotationAxisIndex =
|
|
21
|
-
const rotationAxisValue =
|
|
22
|
-
const center =
|
|
19
|
+
const rotationAxisIndex = store.use(selectorChartsInteractionRotationAxisIndex);
|
|
20
|
+
const rotationAxisValue = store.use(selectorChartsInteractionRotationAxisValue);
|
|
21
|
+
const center = store.use(selectorChartPolarCenter);
|
|
23
22
|
const highlightedIndex = rotationAxisIndex;
|
|
24
23
|
if (!rotationScale) {
|
|
25
24
|
return null;
|
|
@@ -2,7 +2,6 @@ import { useRotationScale } from "../../hooks/useScale.js";
|
|
|
2
2
|
import { useRadiusAxes } from "../../hooks/index.js";
|
|
3
3
|
import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
4
4
|
import { useChartContext } from "../../context/ChartProvider/useChartContext.js";
|
|
5
|
-
import { useSelector } from "../../internals/store/useSelector.js";
|
|
6
5
|
export function useRadarGridData() {
|
|
7
6
|
const {
|
|
8
7
|
instance,
|
|
@@ -15,7 +14,7 @@ export function useRadarGridData() {
|
|
|
15
14
|
const {
|
|
16
15
|
cx,
|
|
17
16
|
cy
|
|
18
|
-
} =
|
|
17
|
+
} = store.use(selectorChartPolarCenter);
|
|
19
18
|
if (!rotationScale || rotationScale.domain().length === 0) {
|
|
20
19
|
return null;
|
|
21
20
|
}
|
|
@@ -2,7 +2,6 @@ import * as React from 'react';
|
|
|
2
2
|
import { selectorChartPolarCenter } from "../../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
3
3
|
import { getSVGPoint } from "../../internals/getSVGPoint.js";
|
|
4
4
|
import { generateSvg2rotation } from "../../internals/plugins/featurePlugins/useChartPolarAxis/coordinateTransformation.js";
|
|
5
|
-
import { useSelector } from "../../internals/store/useSelector.js";
|
|
6
5
|
import { getAxisIndex } from "../../internals/plugins/featurePlugins/useChartPolarAxis/getAxisIndex.js";
|
|
7
6
|
import { useStore } from "../../internals/store/useStore.js";
|
|
8
7
|
import { useSvgRef } from "../../hooks/useSvgRef.js";
|
|
@@ -16,7 +15,7 @@ export function useRadarRotationIndex() {
|
|
|
16
15
|
const svgRef = useSvgRef();
|
|
17
16
|
const store = useStore();
|
|
18
17
|
const rotationAxis = useRotationAxis();
|
|
19
|
-
const center =
|
|
18
|
+
const center = store.use(selectorChartPolarCenter);
|
|
20
19
|
const rotationIndexGetter = React.useCallback(function rotationIndexGetter(event) {
|
|
21
20
|
const element = svgRef.current;
|
|
22
21
|
if (!element || !rotationAxis) {
|
|
@@ -5,7 +5,6 @@ import { styled } from '@mui/material/styles';
|
|
|
5
5
|
import { useUtilityClasses } from "./scatterClasses.js";
|
|
6
6
|
import { useChartContext } from "../context/ChartProvider/index.js";
|
|
7
7
|
import { getValueToPositionMapper } from "../hooks/useScale.js";
|
|
8
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
9
8
|
import { selectorChartIsSeriesFaded, selectorChartIsSeriesHighlighted, selectorChartSeriesUnfadedItem, selectorChartSeriesHighlightedItem } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
10
9
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
10
|
const MAX_POINTS_PER_PATH = 1000;
|
|
@@ -119,10 +118,10 @@ export function BatchScatter(props) {
|
|
|
119
118
|
const {
|
|
120
119
|
store
|
|
121
120
|
} = useChartContext();
|
|
122
|
-
const isSeriesHighlighted =
|
|
123
|
-
const isSeriesFaded =
|
|
124
|
-
const seriesHighlightedItem =
|
|
125
|
-
const seriesUnfadedItem =
|
|
121
|
+
const isSeriesHighlighted = store.use(selectorChartIsSeriesHighlighted, series.id);
|
|
122
|
+
const isSeriesFaded = store.use(selectorChartIsSeriesFaded, series.id);
|
|
123
|
+
const seriesHighlightedItem = store.use(selectorChartSeriesHighlightedItem, series.id);
|
|
124
|
+
const seriesUnfadedItem = store.use(selectorChartSeriesUnfadedItem, series.id);
|
|
126
125
|
const highlightedModifier = 1.2;
|
|
127
126
|
const markerSize = series.markerSize * (isSeriesHighlighted ? highlightedModifier : 1);
|
|
128
127
|
const classes = useUtilityClasses(inClasses);
|
|
@@ -18,7 +18,7 @@ export function FocusedScatterMark(props) {
|
|
|
18
18
|
yAxis,
|
|
19
19
|
yAxisIds
|
|
20
20
|
} = useYAxes();
|
|
21
|
-
if (focusedItem === null || focusedItem.
|
|
21
|
+
if (focusedItem === null || focusedItem.type !== 'scatter' || !scatterSeries) {
|
|
22
22
|
return null;
|
|
23
23
|
}
|
|
24
24
|
const series = scatterSeries?.series[focusedItem.seriesId];
|
|
@@ -8,7 +8,6 @@ import PropTypes from 'prop-types';
|
|
|
8
8
|
import useSlotProps from '@mui/utils/useSlotProps';
|
|
9
9
|
import { getInteractionItemProps } from "../hooks/useInteractionItemProps.js";
|
|
10
10
|
import { useStore } from "../internals/store/useStore.js";
|
|
11
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
12
11
|
import { useItemHighlightedGetter } from "../hooks/useItemHighlightedGetter.js";
|
|
13
12
|
import { selectorChartsIsVoronoiEnabled } from "../internals/plugins/featurePlugins/useChartClosestPoint/index.js";
|
|
14
13
|
import { ScatterMarker } from "./ScatterMarker.js";
|
|
@@ -41,7 +40,7 @@ function Scatter(props) {
|
|
|
41
40
|
instance
|
|
42
41
|
} = useChartContext();
|
|
43
42
|
const store = useStore();
|
|
44
|
-
const isVoronoiEnabled =
|
|
43
|
+
const isVoronoiEnabled = store.use(selectorChartsIsVoronoiEnabled);
|
|
45
44
|
const skipInteractionHandlers = isVoronoiEnabled || series.disableHover;
|
|
46
45
|
const {
|
|
47
46
|
isFaded,
|
|
@@ -5,6 +5,7 @@ import legendGetter from "./legend.js";
|
|
|
5
5
|
import tooltipGetter 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 scatterSeriesConfig = {
|
|
9
10
|
seriesProcessor,
|
|
10
11
|
colorProcessor: getColor,
|
|
@@ -13,5 +14,6 @@ export const scatterSeriesConfig = {
|
|
|
13
14
|
tooltipItemPositionGetter,
|
|
14
15
|
xExtremumGetter: getExtremumX,
|
|
15
16
|
yExtremumGetter: getExtremumY,
|
|
16
|
-
getSeriesWithDefaultValues
|
|
17
|
+
getSeriesWithDefaultValues,
|
|
18
|
+
keyboardFocusHandler
|
|
17
19
|
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { KeyboardFocusHandler } from "../../internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js";
|
|
2
|
+
declare const keyboardFocusHandler: KeyboardFocusHandler<'scatter', '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;
|
package/esm/hooks/useAxis.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { selectorChartXAxis, selectorChartYAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
|
|
4
4
|
import { selectorChartRadiusAxis, selectorChartRotationAxis } from "../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
5
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
6
5
|
import { useStore } from "../internals/store/useStore.js";
|
|
7
6
|
/**
|
|
8
7
|
* Get all the x-axes.
|
|
@@ -24,7 +23,7 @@ export function useXAxes() {
|
|
|
24
23
|
const {
|
|
25
24
|
axis: xAxis,
|
|
26
25
|
axisIds: xAxisIds
|
|
27
|
-
} =
|
|
26
|
+
} = store.use(selectorChartXAxis);
|
|
28
27
|
return {
|
|
29
28
|
xAxis,
|
|
30
29
|
xAxisIds
|
|
@@ -51,7 +50,7 @@ export function useYAxes() {
|
|
|
51
50
|
const {
|
|
52
51
|
axis: yAxis,
|
|
53
52
|
axisIds: yAxisIds
|
|
54
|
-
} =
|
|
53
|
+
} = store.use(selectorChartYAxis);
|
|
55
54
|
return {
|
|
56
55
|
yAxis,
|
|
57
56
|
yAxisIds
|
|
@@ -79,7 +78,7 @@ export function useXAxis(axisId) {
|
|
|
79
78
|
const {
|
|
80
79
|
axis: xAxis,
|
|
81
80
|
axisIds: xAxisIds
|
|
82
|
-
} =
|
|
81
|
+
} = store.use(selectorChartXAxis);
|
|
83
82
|
const id = axisId ?? xAxisIds[0];
|
|
84
83
|
return xAxis[id];
|
|
85
84
|
}
|
|
@@ -105,7 +104,7 @@ export function useYAxis(axisId) {
|
|
|
105
104
|
const {
|
|
106
105
|
axis: yAxis,
|
|
107
106
|
axisIds: yAxisIds
|
|
108
|
-
} =
|
|
107
|
+
} = store.use(selectorChartYAxis);
|
|
109
108
|
const id = axisId ?? yAxisIds[0];
|
|
110
109
|
return yAxis[id];
|
|
111
110
|
}
|
|
@@ -130,7 +129,7 @@ export function useRotationAxes() {
|
|
|
130
129
|
const {
|
|
131
130
|
axis: rotationAxis,
|
|
132
131
|
axisIds: rotationAxisIds
|
|
133
|
-
} =
|
|
132
|
+
} = store.use(selectorChartRotationAxis);
|
|
134
133
|
return {
|
|
135
134
|
rotationAxis,
|
|
136
135
|
rotationAxisIds
|
|
@@ -157,7 +156,7 @@ export function useRadiusAxes() {
|
|
|
157
156
|
const {
|
|
158
157
|
axis: radiusAxis,
|
|
159
158
|
axisIds: radiusAxisIds
|
|
160
|
-
} =
|
|
159
|
+
} = store.use(selectorChartRadiusAxis);
|
|
161
160
|
return {
|
|
162
161
|
radiusAxis,
|
|
163
162
|
radiusAxisIds
|
|
@@ -188,7 +187,7 @@ export function useRotationAxis(axisId) {
|
|
|
188
187
|
const {
|
|
189
188
|
axis: rotationAxis,
|
|
190
189
|
axisIds: rotationAxisIds
|
|
191
|
-
} =
|
|
190
|
+
} = store.use(selectorChartRotationAxis);
|
|
192
191
|
const id = axisId ?? rotationAxisIds[0];
|
|
193
192
|
return rotationAxis[id];
|
|
194
193
|
}
|
|
@@ -217,7 +216,7 @@ export function useRadiusAxis(axisId) {
|
|
|
217
216
|
const {
|
|
218
217
|
axis: radiusAxis,
|
|
219
218
|
axisIds: radiusAxisIds
|
|
220
|
-
} =
|
|
219
|
+
} = store.use(selectorChartRadiusAxis);
|
|
221
220
|
const id = axisId ?? radiusAxisIds[0];
|
|
222
221
|
return radiusAxis[id];
|
|
223
222
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { selectorChartRawXAxis } from "../internals/plugins/featurePlugins/useChartCartesianAxis/index.js";
|
|
4
4
|
import { selectorChartRawRotationAxis } from "../internals/plugins/featurePlugins/useChartPolarAxis/index.js";
|
|
5
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
6
5
|
import { useStore } from "../internals/store/useStore.js";
|
|
7
6
|
|
|
8
7
|
/**
|
|
@@ -14,8 +13,8 @@ import { useStore } from "../internals/store/useStore.js";
|
|
|
14
13
|
*/
|
|
15
14
|
export function useAxisSystem() {
|
|
16
15
|
const store = useStore();
|
|
17
|
-
const rawRotationAxis =
|
|
18
|
-
const rawXAxis =
|
|
16
|
+
const rawRotationAxis = store.use(selectorChartRawRotationAxis);
|
|
17
|
+
const rawXAxis = store.use(selectorChartRawXAxis);
|
|
19
18
|
if (rawRotationAxis !== undefined) {
|
|
20
19
|
return 'polar';
|
|
21
20
|
}
|
package/esm/hooks/useBrush.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { selectorBrushState } from "../internals/plugins/featurePlugins/useChartBrush/index.js";
|
|
2
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
3
2
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
3
|
|
|
5
4
|
/**
|
|
@@ -12,5 +11,5 @@ import { useStore } from "../internals/store/useStore.js";
|
|
|
12
11
|
*/
|
|
13
12
|
export function useBrush() {
|
|
14
13
|
const store = useStore();
|
|
15
|
-
return
|
|
14
|
+
return store.use(selectorBrushState);
|
|
16
15
|
}
|
package/esm/hooks/useChartId.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
5
4
|
import { selectorChartId } from "../internals/plugins/corePlugins/useChartId/useChartId.selectors.js";
|
|
6
5
|
|
|
7
6
|
/**
|
|
@@ -10,5 +9,5 @@ import { selectorChartId } from "../internals/plugins/corePlugins/useChartId/use
|
|
|
10
9
|
*/
|
|
11
10
|
export function useChartId() {
|
|
12
11
|
const store = useStore();
|
|
13
|
-
return
|
|
12
|
+
return store.use(selectorChartId);
|
|
14
13
|
}
|
package/esm/hooks/useDataset.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
5
4
|
import { selectorChartDataset } from "../internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
6
5
|
/**
|
|
7
6
|
* Get access to the dataset used to populate series and axes data.
|
|
@@ -9,5 +8,5 @@ import { selectorChartDataset } from "../internals/plugins/corePlugins/useChartS
|
|
|
9
8
|
*/
|
|
10
9
|
export function useDataset() {
|
|
11
10
|
const store = useStore();
|
|
12
|
-
return
|
|
11
|
+
return store.use(selectorChartDataset);
|
|
13
12
|
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
5
4
|
import { selectorChartDrawingArea } from "../internals/plugins/corePlugins/useChartDimensions/useChartDimensions.selectors.js";
|
|
6
5
|
/**
|
|
7
6
|
* Get the drawing area dimensions and coordinates. The drawing area is the area where the chart is rendered.
|
|
@@ -12,5 +11,5 @@ import { selectorChartDrawingArea } from "../internals/plugins/corePlugins/useCh
|
|
|
12
11
|
*/
|
|
13
12
|
export function useDrawingArea() {
|
|
14
13
|
const store = useStore();
|
|
15
|
-
return
|
|
14
|
+
return store.use(selectorChartDrawingArea);
|
|
16
15
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import { type ChartSeriesType } from "../models/seriesType/config.js";
|
|
2
|
-
import { type SeriesId } from "../models/seriesType/common.js";
|
|
3
|
-
export type FocusedItemData = {
|
|
4
|
-
seriesType: ChartSeriesType;
|
|
5
|
-
seriesId: SeriesId;
|
|
6
|
-
dataIndex: number;
|
|
7
|
-
};
|
|
8
1
|
/**
|
|
9
2
|
* Get the focused item from keyboard navigation.
|
|
10
3
|
*/
|
|
11
|
-
export declare function useFocusedItem():
|
|
12
|
-
seriesType: "line" | "bar" | "scatter" | "pie";
|
|
13
|
-
seriesId: SeriesId;
|
|
14
|
-
dataIndex: number;
|
|
15
|
-
} | null;
|
|
4
|
+
export declare function useFocusedItem(): import("../index.js").FocusedItemIdentifier<keyof import("../internals/index.js").ChartsSeriesConfig> | null;
|
|
@@ -1,20 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import * as React from 'react';
|
|
4
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
5
|
-
import {
|
|
6
|
-
|
|
4
|
+
import { selectorChartsFocusedItem } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
5
|
+
|
|
7
6
|
/**
|
|
8
7
|
* Get the focused item from keyboard navigation.
|
|
9
8
|
*/
|
|
10
9
|
export function useFocusedItem() {
|
|
11
10
|
const store = useStore();
|
|
12
|
-
|
|
13
|
-
const focusedSeriesId = useSelector(store, selectorChartsFocusedSeriesId);
|
|
14
|
-
const focusedDataIndex = useSelector(store, selectorChartsFocusedDataIndex);
|
|
15
|
-
return React.useMemo(() => focusedSeriesType === undefined || focusedSeriesId === undefined || focusedDataIndex === undefined ? null : {
|
|
16
|
-
seriesType: focusedSeriesType,
|
|
17
|
-
seriesId: focusedSeriesId,
|
|
18
|
-
dataIndex: focusedDataIndex
|
|
19
|
-
}, [focusedSeriesType, focusedSeriesId, focusedDataIndex]);
|
|
11
|
+
return store.use(selectorChartsFocusedItem);
|
|
20
12
|
}
|
|
@@ -2,7 +2,8 @@ import * as React from 'react';
|
|
|
2
2
|
import { type SeriesItemIdentifierWithData } from "../models/index.js";
|
|
3
3
|
import type { UseChartHighlightSignature } from "../internals/plugins/featurePlugins/useChartHighlight/index.js";
|
|
4
4
|
import type { UseChartInteractionSignature } from "../internals/plugins/featurePlugins/useChartInteraction/index.js";
|
|
5
|
-
import type { ChartSeriesType
|
|
5
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
6
|
+
import type { SeriesItemIdentifier } from "../models/seriesType/index.js";
|
|
6
7
|
import type { ChartInstance } from "../internals/plugins/models/index.js";
|
|
7
8
|
import type { UseChartTooltipSignature } from "../internals/plugins/featurePlugins/useChartTooltip/index.js";
|
|
8
9
|
export declare const useInteractionItemProps: (data: SeriesItemIdentifierWithData, skip?: boolean) => {
|
|
@@ -10,7 +11,7 @@ export declare const useInteractionItemProps: (data: SeriesItemIdentifierWithDat
|
|
|
10
11
|
onPointerLeave?: () => void;
|
|
11
12
|
onPointerDown?: (event: React.PointerEvent) => void;
|
|
12
13
|
};
|
|
13
|
-
export declare function getInteractionItemProps(instance: ChartInstance<[UseChartInteractionSignature, UseChartHighlightSignature, UseChartTooltipSignature]>, item:
|
|
14
|
+
export declare function getInteractionItemProps(instance: ChartInstance<[UseChartInteractionSignature, UseChartHighlightSignature, UseChartTooltipSignature]>, item: SeriesItemIdentifier<ChartSeriesType>): {
|
|
14
15
|
onPointerEnter?: () => void;
|
|
15
16
|
onPointerLeave?: () => void;
|
|
16
17
|
onPointerDown?: (event: React.PointerEvent) => void;
|
|
@@ -17,7 +17,13 @@ export const useInteractionItemProps = (data, skip) => {
|
|
|
17
17
|
interactionActive.current = true;
|
|
18
18
|
instance.setLastUpdateSource('pointer');
|
|
19
19
|
instance.setTooltipItem(data);
|
|
20
|
-
|
|
20
|
+
// TODO: uniformize sankey and other types to get a single plugin
|
|
21
|
+
instance.setHighlight(
|
|
22
|
+
// @ts-ignore
|
|
23
|
+
data.type === 'sankey' ? data : {
|
|
24
|
+
seriesId: data.seriesId,
|
|
25
|
+
dataIndex: data.dataIndex
|
|
26
|
+
});
|
|
21
27
|
});
|
|
22
28
|
const onPointerLeave = useEventCallback(() => {
|
|
23
29
|
interactionActive.current = false;
|
|
@@ -45,7 +51,12 @@ export function getInteractionItemProps(instance, item) {
|
|
|
45
51
|
}
|
|
46
52
|
instance.setLastUpdateSource('pointer');
|
|
47
53
|
instance.setTooltipItem(item);
|
|
48
|
-
instance.setHighlight(
|
|
54
|
+
instance.setHighlight(
|
|
55
|
+
// @ts-ignore
|
|
56
|
+
item.type === 'sankey' ? item : {
|
|
57
|
+
seriesId: item.seriesId,
|
|
58
|
+
dataIndex: item.dataIndex
|
|
59
|
+
});
|
|
49
60
|
}
|
|
50
61
|
function onPointerLeave() {
|
|
51
62
|
if (!item) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type
|
|
1
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
2
|
+
import type { FocusedItemIdentifier } from "../models/seriesType/index.js";
|
|
3
|
+
type UseItemFocusedParams = FocusedItemIdentifier<ChartSeriesType>;
|
|
3
4
|
/**
|
|
4
5
|
* A hook to check if an item has the focus.
|
|
5
6
|
*
|
|
6
7
|
* If you need to process multiple points, use the `useIsItemFocusedGetter` hook instead.
|
|
7
8
|
*
|
|
8
|
-
* @param {
|
|
9
|
+
* @param {FocusedItemIdentifier} item is the item to check
|
|
9
10
|
* @returns {boolean} the focus state
|
|
10
11
|
*/
|
|
11
12
|
export declare function useIsItemFocused(item: UseItemFocusedParams): boolean;
|
|
@@ -1,17 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { useStore } from "../internals/store/useStore.js";
|
|
4
|
-
import { useSelector } from "../internals/store/useSelector.js";
|
|
5
4
|
import { selectorChartsItemIsFocused } from "../internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js";
|
|
6
5
|
/**
|
|
7
6
|
* A hook to check if an item has the focus.
|
|
8
7
|
*
|
|
9
8
|
* If you need to process multiple points, use the `useIsItemFocusedGetter` hook instead.
|
|
10
9
|
*
|
|
11
|
-
* @param {
|
|
10
|
+
* @param {FocusedItemIdentifier} item is the item to check
|
|
12
11
|
* @returns {boolean} the focus state
|
|
13
12
|
*/
|
|
14
13
|
export function useIsItemFocused(item) {
|
|
15
14
|
const store = useStore();
|
|
16
|
-
return
|
|
15
|
+
return store.use(selectorChartsItemIsFocused, item);
|
|
17
16
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FocusedItemIdentifier } from "../models/seriesType/index.js";
|
|
2
|
+
import type { ChartSeriesType } from "../models/seriesType/config.js";
|
|
2
3
|
/**
|
|
3
4
|
* A hook to check focus state of multiple items.
|
|
4
5
|
* If you're interested by a single one, consider using `useIsItemFocused`.
|
|
5
6
|
*
|
|
6
7
|
* @returns {(item: FocusedItemData) => boolean} callback to get the state of the item.
|
|
7
8
|
*/
|
|
8
|
-
export declare function useIsItemFocusedGetter(): (item:
|
|
9
|
+
export declare function useIsItemFocusedGetter(): (item: FocusedItemIdentifier<ChartSeriesType>) => boolean;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
+
import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
|
|
3
4
|
import { useFocusedItem } from "./useFocusedItem.js";
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -10,5 +11,5 @@ import { useFocusedItem } from "./useFocusedItem.js";
|
|
|
10
11
|
*/
|
|
11
12
|
export function useIsItemFocusedGetter() {
|
|
12
13
|
const focusedItem = useFocusedItem();
|
|
13
|
-
return item => focusedItem !== null && focusedItem
|
|
14
|
+
return item => focusedItem !== null && fastObjectShallowCompare(focusedItem, item);
|
|
14
15
|
}
|