@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
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
import { createSelector } from '@mui/x-internals/store';
|
|
2
|
+
import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
|
|
2
3
|
import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
|
|
3
4
|
import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
|
|
4
5
|
const selectKeyboardNavigation = state => state.keyboardNavigation;
|
|
5
|
-
export const selectorChartsItemIsFocused = createSelector(selectKeyboardNavigation, (keyboardNavigationState, item) =>
|
|
6
|
-
return keyboardNavigationState?.item != null && keyboardNavigationState.item.type === item.seriesType && keyboardNavigationState.item.seriesId === item.seriesId && keyboardNavigationState.item.dataIndex === item.dataIndex;
|
|
7
|
-
});
|
|
6
|
+
export const selectorChartsItemIsFocused = createSelector(selectKeyboardNavigation, (keyboardNavigationState, item) => keyboardNavigationState?.item != null && fastObjectShallowCompare(keyboardNavigationState.item, item));
|
|
8
7
|
export const selectorChartsHasFocusedItem = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item != null);
|
|
9
|
-
export const
|
|
10
|
-
export const selectorChartsFocusedSeriesId = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
|
|
11
|
-
export const selectorChartsFocusedDataIndex = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
|
|
8
|
+
export const selectorChartsFocusedItem = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item ?? null);
|
|
12
9
|
export const selectorChartsIsKeyboardNavigationEnabled = createSelector(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
|
|
13
10
|
|
|
14
11
|
/**
|
|
15
12
|
* Selectors to override highlight behavior.
|
|
16
13
|
*/
|
|
17
14
|
|
|
18
|
-
const createSelectAxisHighlight = direction => (
|
|
19
|
-
if (
|
|
15
|
+
const createSelectAxisHighlight = direction => (item, axis, series) => {
|
|
16
|
+
if (item == null || !('dataIndex' in item) || item.dataIndex === undefined) {
|
|
20
17
|
return undefined;
|
|
21
18
|
}
|
|
22
|
-
const seriesConfig = series[type]?.series[seriesId];
|
|
19
|
+
const seriesConfig = series[item.type]?.series[item.seriesId];
|
|
23
20
|
if (!seriesConfig) {
|
|
24
21
|
return undefined;
|
|
25
22
|
}
|
|
@@ -29,11 +26,11 @@ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis,
|
|
|
29
26
|
}
|
|
30
27
|
return {
|
|
31
28
|
axisId,
|
|
32
|
-
dataIndex
|
|
29
|
+
dataIndex: item.dataIndex
|
|
33
30
|
};
|
|
34
31
|
};
|
|
35
|
-
export const selectorChartsKeyboardXAxisIndex = createSelector(
|
|
36
|
-
export const selectorChartsKeyboardYAxisIndex = createSelector(
|
|
32
|
+
export const selectorChartsKeyboardXAxisIndex = createSelector(selectorChartsFocusedItem, selectorChartXAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
|
|
33
|
+
export const selectorChartsKeyboardYAxisIndex = createSelector(selectorChartsFocusedItem, selectorChartYAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
|
|
37
34
|
export const selectorChartsKeyboardItem = createSelector(selectKeyboardNavigation, function selectorChartsKeyboardItem(keyboardState) {
|
|
38
35
|
if (keyboardState?.item == null) {
|
|
39
36
|
return null;
|
|
@@ -46,7 +43,4 @@ export const selectorChartsKeyboardItem = createSelector(selectKeyboardNavigatio
|
|
|
46
43
|
return null;
|
|
47
44
|
}
|
|
48
45
|
return keyboardState.item;
|
|
49
|
-
});
|
|
50
|
-
export const selectorChartsKeyboardItemIsDefined = createSelector(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, function selectorChartsKeyboardItemIsDefined(seriesType, seriesId, dataIndex) {
|
|
51
|
-
return seriesId !== undefined && dataIndex !== undefined;
|
|
52
46
|
});
|
|
@@ -1,27 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import type { ChartPluginSignature } from "../../models/index.js";
|
|
2
|
+
import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
|
|
3
|
+
import type { UseChartHighlightSignature } from "../useChartHighlight/index.js";
|
|
4
|
+
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
5
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
6
6
|
export interface UseChartKeyboardNavigationInstance {}
|
|
7
|
-
type SeriesItemIdentifier<SeriesType extends ChartSeriesType = FocusableSeriesTypes> = SeriesType extends FocusableSeriesTypes ? {
|
|
8
|
-
/**
|
|
9
|
-
* The type of the series
|
|
10
|
-
*/
|
|
11
|
-
type: SeriesType;
|
|
12
|
-
/**
|
|
13
|
-
* The id of the series with focus.
|
|
14
|
-
*/
|
|
15
|
-
seriesId: SeriesId;
|
|
16
|
-
/**
|
|
17
|
-
* The index of the data point with focus.
|
|
18
|
-
*/
|
|
19
|
-
dataIndex: number;
|
|
20
|
-
} : never;
|
|
21
|
-
export type FocusableSeriesTypes = 'bar' | 'line' | 'scatter' | 'pie';
|
|
22
7
|
export interface UseChartKeyboardNavigationState {
|
|
23
8
|
keyboardNavigation: {
|
|
24
|
-
item: null |
|
|
9
|
+
item: null | FocusedItemIdentifier<ChartSeriesType>;
|
|
25
10
|
enableKeyboardNavigation: boolean;
|
|
26
11
|
};
|
|
27
12
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
|
|
2
|
+
import type { SeriesId } from "../../../../../models/seriesType/common.js";
|
|
3
|
+
import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the next series type and id that contains some data.
|
|
6
|
+
* Returns `null` if no other series have data.
|
|
7
|
+
* @param series - The processed series from the store.
|
|
8
|
+
* @param availableSeriesTypes - The set of series types that can be focused.
|
|
9
|
+
* @param type - The current series type.
|
|
10
|
+
* @param seriesId - The current series id.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getNextNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
|
|
13
|
+
type: OutSeriesType;
|
|
14
|
+
seriesId: SeriesId;
|
|
15
|
+
} | null;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the next series type and id that contains some data.
|
|
3
|
+
* Returns `null` if no other series have data.
|
|
4
|
+
* @param series - The processed series from the store.
|
|
5
|
+
* @param availableSeriesTypes - The set of series types that can be focused.
|
|
6
|
+
* @param type - The current series type.
|
|
7
|
+
* @param seriesId - The current series id.
|
|
8
|
+
*/
|
|
9
|
+
export function getNextNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
|
|
10
|
+
const seriesType = Object.keys(series);
|
|
11
|
+
const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
|
|
12
|
+
const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
|
|
13
|
+
const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
|
|
14
|
+
|
|
15
|
+
// Loop over all series types starting with the current seriesType
|
|
16
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
17
|
+
const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
|
|
18
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
19
|
+
|
|
20
|
+
// Edge case for the current series type: we don't loop on previous series of the same type.
|
|
21
|
+
const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
|
|
22
|
+
for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
|
|
23
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
24
|
+
return {
|
|
25
|
+
type: typesAvailable[typeIndex],
|
|
26
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// End looping on the initial type up to the initial series (excluded)
|
|
33
|
+
const typeIndex = startingTypeIndex;
|
|
34
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
35
|
+
const endingSeriesIndex = currentSeriesIndex;
|
|
36
|
+
for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
|
|
37
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
38
|
+
return {
|
|
39
|
+
type: typesAvailable[typeIndex],
|
|
40
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return null;
|
|
45
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
|
|
2
|
+
import type { SeriesId } from "../../../../../models/seriesType/common.js";
|
|
3
|
+
import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
|
|
4
|
+
/**
|
|
5
|
+
* Returns the previous series type and id that contains some data.
|
|
6
|
+
* Returns `null` if no other series have data.
|
|
7
|
+
*/
|
|
8
|
+
export declare function getPreviousNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
|
|
9
|
+
type: OutSeriesType;
|
|
10
|
+
seriesId: SeriesId;
|
|
11
|
+
} | null;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the previous series type and id that contains some data.
|
|
3
|
+
* Returns `null` if no other series have data.
|
|
4
|
+
*/
|
|
5
|
+
export function getPreviousNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
|
|
6
|
+
const seriesType = Object.keys(series);
|
|
7
|
+
const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
|
|
8
|
+
const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
|
|
9
|
+
const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
|
|
10
|
+
|
|
11
|
+
// Loop over all series types starting with the current seriesType
|
|
12
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
13
|
+
const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
|
|
14
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
15
|
+
const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
|
|
16
|
+
for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
|
|
17
|
+
const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
|
|
18
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
19
|
+
return {
|
|
20
|
+
type: typesAvailable[typeIndex],
|
|
21
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// End looping on the initial type down to the initial series (excluded)
|
|
28
|
+
const typeIndex = startingTypeIndex;
|
|
29
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
30
|
+
const availableSeriesIds = seriesOfType.seriesOrder;
|
|
31
|
+
for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
|
|
32
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
33
|
+
return {
|
|
34
|
+
type: typesAvailable[typeIndex],
|
|
35
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
4
4
|
import * as React from 'react';
|
|
5
5
|
import { warnOnce } from '@mui/x-internals/warning';
|
|
6
|
-
import { useSelector } from "../../../store/useSelector.js";
|
|
7
6
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
|
|
8
7
|
import { defaultizeAxis } from "./defaultizeAxis.js";
|
|
9
8
|
import { selectorChartsInteractionIsInitialized } from "../useChartInteraction/index.js";
|
|
@@ -32,18 +31,18 @@ export const useChartPolarAxis = ({
|
|
|
32
31
|
warnOnce([`MUI X Charts: The following axis ids are duplicated: ${Array.from(duplicates).join(', ')}.`, `Please make sure that each axis has a unique id.`].join('\n'), 'error');
|
|
33
32
|
}
|
|
34
33
|
}
|
|
35
|
-
const drawingArea =
|
|
36
|
-
const processedSeries =
|
|
37
|
-
const center =
|
|
38
|
-
const isInteractionEnabled =
|
|
34
|
+
const drawingArea = store.use(selectorChartDrawingArea);
|
|
35
|
+
const processedSeries = store.use(selectorChartSeriesProcessed);
|
|
36
|
+
const center = store.use(selectorChartPolarCenter);
|
|
37
|
+
const isInteractionEnabled = store.use(selectorChartsInteractionIsInitialized);
|
|
39
38
|
const {
|
|
40
39
|
axis: rotationAxisWithScale,
|
|
41
40
|
axisIds: rotationAxisIds
|
|
42
|
-
} =
|
|
41
|
+
} = store.use(selectorChartRotationAxis);
|
|
43
42
|
const {
|
|
44
43
|
axis: radiusAxisWithScale,
|
|
45
44
|
axisIds: radiusAxisIds
|
|
46
|
-
} =
|
|
45
|
+
} = store.use(selectorChartRadiusAxis);
|
|
47
46
|
|
|
48
47
|
// The effect do not track any value defined synchronously during the 1st render by hooks called after `useChartPolarAxis`
|
|
49
48
|
// As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
|
|
@@ -6,15 +6,7 @@ export declare const selectorChartsTooltipPointerItemIsDefined: (args_0: import(
|
|
|
6
6
|
}) => boolean;
|
|
7
7
|
export declare const selectorChartsTooltipItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("../useChartInteraction/useChartInteraction.types.js").UseChartInteractionState> & {
|
|
8
8
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
|
-
}) => import("../../../../index.js").PieItemIdentifier |
|
|
10
|
-
type: "bar";
|
|
11
|
-
seriesId: import("../../../index.js").SeriesId;
|
|
12
|
-
dataIndex: number;
|
|
13
|
-
} | {
|
|
14
|
-
type: "scatter";
|
|
15
|
-
seriesId: import("../../../index.js").SeriesId;
|
|
16
|
-
dataIndex: number;
|
|
17
|
-
} | import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
|
|
9
|
+
}) => import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
|
|
18
10
|
export declare const selectorChartsTooltipItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("../useChartInteraction/useChartInteraction.types.js").UseChartInteractionState> & {
|
|
19
11
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
20
12
|
}) => boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
2
2
|
import { selectorChartSeriesConfig, selectorChartSeriesProcessed, selectorChartSeriesLayout } from "../../corePlugins/useChartSeries/index.js";
|
|
3
3
|
import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
|
|
4
|
-
import { selectorChartsKeyboardItem,
|
|
4
|
+
import { selectorChartsKeyboardItem, selectorChartsHasFocusedItem } from "../useChartKeyboardNavigation/index.js";
|
|
5
5
|
import { selectorChartsLastInteraction } from "../useChartInteraction/useChartInteraction.selectors.js";
|
|
6
6
|
import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
|
|
7
7
|
import { isCartesianSeries } from "../../../isCartesian.js";
|
|
@@ -10,7 +10,7 @@ const selectTooltip = state => state.tooltip;
|
|
|
10
10
|
export const selectorChartsTooltipPointerItem = createSelector(selectTooltip, tooltip => tooltip?.item ?? null);
|
|
11
11
|
export const selectorChartsTooltipPointerItemIsDefined = createSelector(selectorChartsTooltipPointerItem, item => item !== null);
|
|
12
12
|
export const selectorChartsTooltipItem = createSelector(selectorChartsLastInteraction, selectorChartsTooltipPointerItem, selectorChartsKeyboardItem, (lastInteraction, pointerItem, keyboardItem) => lastInteraction === 'keyboard' ? keyboardItem : pointerItem ?? null);
|
|
13
|
-
export const selectorChartsTooltipItemIsDefined = createSelector(selectorChartsLastInteraction, selectorChartsTooltipPointerItemIsDefined,
|
|
13
|
+
export const selectorChartsTooltipItemIsDefined = createSelector(selectorChartsLastInteraction, selectorChartsTooltipPointerItemIsDefined, selectorChartsHasFocusedItem, (lastInteraction, pointerItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : pointerItemIsDefined);
|
|
14
14
|
const selectorChartsTooltipAxisConfig = createSelectorMemoized(selectorChartsTooltipItem, selectorChartXAxis, selectorChartYAxis, selectorChartRotationAxis, selectorChartRadiusAxis, selectorChartSeriesProcessed, function selectorChartsTooltipAxisConfig(identifier, {
|
|
15
15
|
axis: xAxis,
|
|
16
16
|
axisIds: xAxisIds
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import type { ChartPluginSignature } from "../../models/index.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { SeriesItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
3
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
3
4
|
export interface UseChartTooltipInstance {
|
|
4
5
|
/**
|
|
5
6
|
* Setter for the item the user is pointing at.
|
|
6
|
-
* @param {
|
|
7
|
+
* @param {SeriesItemIdentifier} newItem The identifier of the item.
|
|
7
8
|
*/
|
|
8
|
-
setTooltipItem: (newItem:
|
|
9
|
+
setTooltipItem: (newItem: SeriesItemIdentifier<ChartSeriesType>) => void;
|
|
9
10
|
/**
|
|
10
11
|
* Remove the item the user was pointing at.
|
|
11
12
|
* - If `itemToRemove` is provided, it removes the item only if it matches the current one.
|
|
12
13
|
* Otherwise it assumes the item got already updated and does nothing.
|
|
13
14
|
* - If `itemToRemove` is not provided, it removes the current item unconditionally.
|
|
14
|
-
* @param {
|
|
15
|
+
* @param {SeriesItemIdentifier} itemToRemove The identifier of the item.
|
|
15
16
|
*/
|
|
16
|
-
removeTooltipItem: (itemToRemove?:
|
|
17
|
+
removeTooltipItem: (itemToRemove?: SeriesItemIdentifier<ChartSeriesType>) => void;
|
|
17
18
|
}
|
|
18
19
|
export interface UseChartTooltipState {
|
|
19
20
|
tooltip: {
|
|
20
21
|
/**
|
|
21
22
|
* The item currently under the pointer.
|
|
22
23
|
*/
|
|
23
|
-
item: null |
|
|
24
|
+
item: null | SeriesItemIdentifier<ChartSeriesType>;
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
export type UseChartTooltipSignature = ChartPluginSignature<{
|
|
@@ -8,6 +8,7 @@ import { type PolarExtremumGetter } from "./polarExtremumGetter.types.js";
|
|
|
8
8
|
import { type GetSeriesWithDefaultValues } from "./getSeriesWithDefaultValues.types.js";
|
|
9
9
|
import { type TooltipItemPositionGetter } from "./tooltipItemPositionGetter.types.js";
|
|
10
10
|
import { type SeriesLayoutGetter } from "./seriesLayout.types.js";
|
|
11
|
+
import { type KeyboardFocusHandler } from "../../featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js";
|
|
11
12
|
export type ChartSeriesTypeConfig<TSeriesType extends ChartSeriesType> = {
|
|
12
13
|
seriesProcessor: SeriesProcessor<TSeriesType>;
|
|
13
14
|
/**
|
|
@@ -19,6 +20,7 @@ export type ChartSeriesTypeConfig<TSeriesType extends ChartSeriesType> = {
|
|
|
19
20
|
tooltipGetter: TooltipGetter<TSeriesType>;
|
|
20
21
|
tooltipItemPositionGetter?: TooltipItemPositionGetter<TSeriesType>;
|
|
21
22
|
getSeriesWithDefaultValues: GetSeriesWithDefaultValues<TSeriesType>;
|
|
23
|
+
keyboardFocusHandler?: KeyboardFocusHandler<TSeriesType>;
|
|
22
24
|
} & (TSeriesType extends CartesianChartSeriesType ? {
|
|
23
25
|
xExtremumGetter: CartesianExtremumGetter<TSeriesType>;
|
|
24
26
|
yExtremumGetter: CartesianExtremumGetter<TSeriesType>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ChartSeriesDefaultized, ChartSeriesType, ChartsSeriesConfig, DatasetType } from "../../../../models/seriesType/config.js";
|
|
2
2
|
import type { SeriesId } from "../../../../models/seriesType/common.js";
|
|
3
|
-
import type { StackingGroupsType } from "../../../
|
|
3
|
+
import type { StackingGroupsType } from "../../../stacking/index.js";
|
|
4
4
|
export type SeriesProcessorParams<TSeriesType extends ChartSeriesType> = {
|
|
5
5
|
series: Record<SeriesId, ChartsSeriesConfig[TSeriesType]['seriesInput']>;
|
|
6
6
|
seriesOrder: SeriesId[];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SeriesItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
2
|
+
import type { ChartSeriesDefaultized, ChartSeriesType, ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
|
|
2
3
|
import { type SeriesId } from "../../../../models/seriesType/common.js";
|
|
3
4
|
import { type AxisId, type ChartsRotationAxisProps, type ChartsRadiusAxisProps, type PolarAxisDefaultized, type ComputedXAxis, type ComputedYAxis } from "../../../../models/axis.js";
|
|
4
5
|
import { type ChartsLabelMarkProps } from "../../../../ChartsLabel/ChartsLabelMark.js";
|
|
@@ -7,7 +8,7 @@ export interface ItemTooltip<T extends ChartSeriesType> {
|
|
|
7
8
|
/**
|
|
8
9
|
* An object that identifies the item to display.
|
|
9
10
|
*/
|
|
10
|
-
identifier:
|
|
11
|
+
identifier: SeriesItemIdentifier<T>;
|
|
11
12
|
/**
|
|
12
13
|
* The color associated with the item.
|
|
13
14
|
*/
|
|
@@ -59,7 +60,7 @@ export type TooltipGetter<TSeriesType extends ChartSeriesType> = (params: {
|
|
|
59
60
|
series: ChartSeriesDefaultized<TSeriesType>;
|
|
60
61
|
axesConfig: TooltipGetterAxesConfig;
|
|
61
62
|
getColor: ColorGetter<TSeriesType>;
|
|
62
|
-
identifier:
|
|
63
|
+
identifier: SeriesItemIdentifier<TSeriesType> | null;
|
|
63
64
|
}) => (TSeriesType extends 'radar' ? ItemTooltipWithMultipleValues<TSeriesType> : ItemTooltip<TSeriesType>) | null;
|
|
64
65
|
/**
|
|
65
66
|
* If `axisId` is set to undefined, the default axis will be used.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SeriesItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
2
|
+
import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
|
|
2
3
|
import { type ChartsRotationAxisProps, type ChartsRadiusAxisProps, type ComputedXAxis, type ComputedYAxis } from "../../../../models/axis.js";
|
|
3
4
|
import { type ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
|
|
4
5
|
import { type ProcessedSeries, type SeriesLayout } from "../../corePlugins/useChartSeries/index.js";
|
|
@@ -13,7 +14,7 @@ export type TooltipItemPositionGetter<TSeriesType extends ChartSeriesType> = (pa
|
|
|
13
14
|
series: ProcessedSeries<TSeriesType>;
|
|
14
15
|
axesConfig: TooltipPositionGetterAxesConfig;
|
|
15
16
|
drawingArea: ChartDrawingArea;
|
|
16
|
-
identifier:
|
|
17
|
+
identifier: SeriesItemIdentifier<TSeriesType> | null;
|
|
17
18
|
seriesLayout: SeriesLayout<TSeriesType>;
|
|
18
19
|
/**
|
|
19
20
|
* The preferred placement of the tooltip related to the element.
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SeriesId } from "../models/seriesType/common.js";
|
|
2
|
+
import type { ChartSeriesType, ChartsSeriesConfig } from "../models/seriesType/config.js";
|
|
3
|
+
import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index.js";
|
|
4
|
+
export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean;
|
|
@@ -2,7 +2,6 @@ import { warnOnce } from '@mui/x-internals/warning';
|
|
|
2
2
|
import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
|
|
3
3
|
import { selectorChartSeriesProcessed } from "./plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
|
|
4
4
|
import { useStore } from "./store/useStore.js";
|
|
5
|
-
import { useSelector } from "./store/useSelector.js";
|
|
6
5
|
export const selectorAllSeriesOfType = createSelector(selectorChartSeriesProcessed, (processedSeries, seriesType) => processedSeries[seriesType]);
|
|
7
6
|
export const selectorSeriesOfType = createSelectorMemoized(selectorChartSeriesProcessed, (processedSeries, seriesType, ids) => {
|
|
8
7
|
if (ids === undefined || Array.isArray(ids) && ids.length === 0) {
|
|
@@ -30,9 +29,9 @@ export const selectorSeriesOfType = createSelectorMemoized(selectorChartSeriesPr
|
|
|
30
29
|
});
|
|
31
30
|
export const useAllSeriesOfType = seriesType => {
|
|
32
31
|
const store = useStore();
|
|
33
|
-
return
|
|
32
|
+
return store.use(selectorAllSeriesOfType, seriesType);
|
|
34
33
|
};
|
|
35
34
|
export const useSeriesOfType = (seriesType, seriesId) => {
|
|
36
35
|
const store = useStore();
|
|
37
|
-
return
|
|
36
|
+
return store.use(selectorSeriesOfType, seriesType, seriesId);
|
|
38
37
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./stackSeries.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./stackSeries.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./offsetDiverging.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./offsetDiverging.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Series } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
/**
|
|
3
|
+
* Positive values are stacked above zero, while negative values are stacked below zero.
|
|
4
|
+
*
|
|
5
|
+
* @param series A series generated by a stack generator.
|
|
6
|
+
* @param order An array of numeric indexes representing the stack order.
|
|
7
|
+
*/
|
|
8
|
+
export declare function offsetDiverging(series: Series<any, any>[], order: Iterable<number>): void;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Adapted from D3.js's offsetDiverging function https://github.com/d3/d3-shape/blob/main/src/offset/diverging.js
|
|
2
|
+
// Hidden series (with all zero values) affect the stacking in a different way in our implementation compared to the D3 behavior.
|
|
3
|
+
// The D3 stacking keep those values at the 0 "line", which creates issues when animating between hidden and visible states.
|
|
4
|
+
// In our modification, we stack them on top/below already stacked items according to the sign of their original value.
|
|
5
|
+
// A hidden negative value will be placed below all the already stacked negative values
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Positive values are stacked above zero, while negative values are stacked below zero.
|
|
9
|
+
*
|
|
10
|
+
* @param series A series generated by a stack generator.
|
|
11
|
+
* @param order An array of numeric indexes representing the stack order.
|
|
12
|
+
*/
|
|
13
|
+
export function offsetDiverging(series, order) {
|
|
14
|
+
if (series.length === 0) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
const seriesCount = series.length;
|
|
18
|
+
const numericOrder = order;
|
|
19
|
+
const pointCount = series[numericOrder[0]].length;
|
|
20
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex += 1) {
|
|
21
|
+
let positiveSum = 0;
|
|
22
|
+
let negativeSum = 0;
|
|
23
|
+
for (let seriesIndex = 0; seriesIndex < seriesCount; seriesIndex += 1) {
|
|
24
|
+
const currentSeries = series[numericOrder[seriesIndex]];
|
|
25
|
+
const dataPoint = currentSeries[pointIndex];
|
|
26
|
+
const difference = dataPoint[1] - dataPoint[0];
|
|
27
|
+
if (difference > 0) {
|
|
28
|
+
dataPoint[0] = positiveSum;
|
|
29
|
+
positiveSum += difference;
|
|
30
|
+
dataPoint[1] = positiveSum;
|
|
31
|
+
} else if (difference < 0) {
|
|
32
|
+
dataPoint[1] = negativeSum;
|
|
33
|
+
negativeSum += difference;
|
|
34
|
+
dataPoint[0] = negativeSum;
|
|
35
|
+
} else if (dataPoint.data[currentSeries.key] > 0) {
|
|
36
|
+
dataPoint[0] = positiveSum;
|
|
37
|
+
dataPoint[1] = positiveSum;
|
|
38
|
+
} else if (dataPoint.data[currentSeries.key] < 0) {
|
|
39
|
+
dataPoint[1] = negativeSum;
|
|
40
|
+
dataPoint[0] = negativeSum;
|
|
41
|
+
} else {
|
|
42
|
+
dataPoint[0] = 0;
|
|
43
|
+
dataPoint[1] = 0;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type { StackOffsetType, StackOrderType } from "
|
|
3
|
-
import { type SeriesId, type StackableSeriesType } from "
|
|
1
|
+
import { stackOrderNone as d3StackOrderNone, stackOrderReverse as d3StackOrderReverse, stackOrderAppearance as d3OrderAppearance, stackOrderAscending as d3OrderAscending, stackOrderDescending as d3OrderDescending, stackOrderInsideOut as d3OrderInsideOut, stackOffsetExpand as d3StackOffsetExpand, stackOffsetNone as d3StackOffsetNone, stackOffsetSilhouette as d3StackOffsetSilhouette, stackOffsetWiggle as d3StackOffsetWiggle, type Series } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
import type { StackOffsetType, StackOrderType } from "../../models/stacking.js";
|
|
3
|
+
import { type SeriesId, type StackableSeriesType } from "../../models/seriesType/common.js";
|
|
4
4
|
type FormatterParams<T> = {
|
|
5
5
|
series: Record<SeriesId, T>;
|
|
6
6
|
seriesOrder: SeriesId[];
|
|
@@ -18,19 +18,19 @@ export declare const StackOrder: {
|
|
|
18
18
|
/**
|
|
19
19
|
* Series order such that the earliest series (according to the maximum value) is at the bottom.
|
|
20
20
|
* */
|
|
21
|
-
appearance: typeof
|
|
21
|
+
appearance: typeof d3OrderAppearance;
|
|
22
22
|
/**
|
|
23
23
|
* Series order such that the smallest series (according to the sum of values) is at the bottom.
|
|
24
24
|
* */
|
|
25
|
-
ascending: typeof
|
|
25
|
+
ascending: typeof d3OrderAscending;
|
|
26
26
|
/**
|
|
27
27
|
* Series order such that the largest series (according to the sum of values) is at the bottom.
|
|
28
28
|
*/
|
|
29
|
-
descending: typeof
|
|
29
|
+
descending: typeof d3OrderDescending;
|
|
30
30
|
/**
|
|
31
31
|
* Series order such that the earliest series (according to the maximum value) are on the inside and the later series are on the outside. This order is recommended for streamgraphs in conjunction with the wiggle offset. See Stacked Graphs—Geometry & Aesthetics by Byron & Wattenberg for more information.
|
|
32
32
|
*/
|
|
33
|
-
insideOut: typeof
|
|
33
|
+
insideOut: typeof d3OrderInsideOut;
|
|
34
34
|
/**
|
|
35
35
|
* Given series order [0, 1, … n - 1] where n is the number of elements in series. Thus, the stack order is given by the key accessor.
|
|
36
36
|
*/
|
|
@@ -48,7 +48,7 @@ export declare const StackOffset: {
|
|
|
48
48
|
/**
|
|
49
49
|
* Positive values are stacked above zero, negative values are stacked below zero, and zero values are stacked at zero.
|
|
50
50
|
* */
|
|
51
|
-
diverging:
|
|
51
|
+
diverging: (series: Series<any, any>, order: Iterable<number>) => void;
|
|
52
52
|
/**
|
|
53
53
|
* Applies a zero baseline.
|
|
54
54
|
* */
|
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stackOrderNone as d3StackOrderNone, stackOrderReverse as d3StackOrderReverse, stackOrderAppearance as d3OrderAppearance, stackOrderAscending as d3OrderAscending, stackOrderDescending as d3OrderDescending, stackOrderInsideOut as d3OrderInsideOut, stackOffsetExpand as d3StackOffsetExpand, stackOffsetNone as d3StackOffsetNone, stackOffsetSilhouette as d3StackOffsetSilhouette, stackOffsetWiggle as d3StackOffsetWiggle } from '@mui/x-charts-vendor/d3-shape';
|
|
2
|
+
import { offsetDiverging } from "./offset/index.js";
|
|
2
3
|
export const StackOrder = {
|
|
3
4
|
/**
|
|
4
5
|
* Series order such that the earliest series (according to the maximum value) is at the bottom.
|
|
5
6
|
* */
|
|
6
|
-
appearance:
|
|
7
|
+
appearance: d3OrderAppearance,
|
|
7
8
|
/**
|
|
8
9
|
* Series order such that the smallest series (according to the sum of values) is at the bottom.
|
|
9
10
|
* */
|
|
10
|
-
ascending:
|
|
11
|
+
ascending: d3OrderAscending,
|
|
11
12
|
/**
|
|
12
13
|
* Series order such that the largest series (according to the sum of values) is at the bottom.
|
|
13
14
|
*/
|
|
14
|
-
descending:
|
|
15
|
+
descending: d3OrderDescending,
|
|
15
16
|
/**
|
|
16
17
|
* Series order such that the earliest series (according to the maximum value) are on the inside and the later series are on the outside. This order is recommended for streamgraphs in conjunction with the wiggle offset. See Stacked Graphs—Geometry & Aesthetics by Byron & Wattenberg for more information.
|
|
17
18
|
*/
|
|
18
|
-
insideOut:
|
|
19
|
+
insideOut: d3OrderInsideOut,
|
|
19
20
|
/**
|
|
20
21
|
* Given series order [0, 1, … n - 1] where n is the number of elements in series. Thus, the stack order is given by the key accessor.
|
|
21
22
|
*/
|
|
@@ -33,7 +34,8 @@ export const StackOffset = {
|
|
|
33
34
|
/**
|
|
34
35
|
* Positive values are stacked above zero, negative values are stacked below zero, and zero values are stacked at zero.
|
|
35
36
|
* */
|
|
36
|
-
|
|
37
|
+
// @ts-expect-error, d3 types are wrong, our custom function implements the correct signature
|
|
38
|
+
diverging: offsetDiverging,
|
|
37
39
|
/**
|
|
38
40
|
* Applies a zero baseline.
|
|
39
41
|
* */
|
|
@@ -90,8 +90,6 @@ export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConf
|
|
|
90
90
|
stackedData: [number, number][];
|
|
91
91
|
} : ChartsSeriesConfig[T]['series'];
|
|
92
92
|
export type ChartSeriesLayout<T extends ChartSeriesType> = ChartsSeriesConfig[T] extends any ? ChartsSeriesConfig[T]['seriesLayout'] : never;
|
|
93
|
-
export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
|
|
94
|
-
export type ChartItemIdentifierWithData<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifierWithData'];
|
|
95
93
|
export type DatasetElementType<T> = {
|
|
96
94
|
[key: string]: T;
|
|
97
95
|
};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { DefaultizedProps } from '@mui/x-internals/types';
|
|
2
|
+
import type { BarSeriesType, DefaultizedBarSeriesType } from "./bar.js";
|
|
2
3
|
import { type CartesianChartSeriesType, type ChartSeriesType, type ChartsSeriesConfig, type StackableChartSeriesType } from "./config.js";
|
|
3
4
|
type AllSeriesType<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['seriesProp'];
|
|
4
5
|
/**
|
|
@@ -19,6 +20,7 @@ type DefaultizedCartesianSeriesType = DefaultizedSeriesType<CartesianChartSeries
|
|
|
19
20
|
type StackableSeriesType = DefaultizedSeriesType<StackableChartSeriesType>;
|
|
20
21
|
export type SeriesItemIdentifier<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
|
|
21
22
|
export type SeriesItemIdentifierWithData<T extends ChartSeriesType = ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifierWithData'];
|
|
23
|
+
export type FocusedItemIdentifier<T extends ChartSeriesType = ChartSeriesType> = T extends 'line' ? DefaultizedProps<ChartsSeriesConfig[T]['itemIdentifier'], 'dataIndex'> : ChartsSeriesConfig[T]['itemIdentifier'];
|
|
22
24
|
export { type SeriesId } from "./common.js";
|
|
23
25
|
export * from "./line.js";
|
|
24
26
|
export * from "./bar.js";
|