@mui/x-charts 8.22.1 → 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/FocusedBar.js +1 -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 +101 -0
- package/LineChart/FocusedLineMark.js +1 -1
- 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.js +1 -1
- package/PieChart/dataTransform/useTransformData.js +1 -1
- package/PieChart/seriesConfig/index.js +3 -1
- package/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
- package/PieChart/seriesConfig/keyboardFocusHandler.js +23 -0
- package/ScatterChart/FocusedScatterMark.js +1 -1
- 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/FocusedBar.js +1 -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/LineChart/FocusedLineMark.js +1 -1
- 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.js +1 -1
- package/esm/PieChart/dataTransform/useTransformData.js +1 -1
- 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/ScatterChart/FocusedScatterMark.js +1 -1
- 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/useFocusedItem.d.ts +1 -12
- package/esm/hooks/useFocusedItem.js +3 -10
- package/esm/hooks/useIsItemFocused.d.ts +4 -3
- package/esm/hooks/useIsItemFocused.js +1 -1
- package/esm/hooks/useIsItemFocusedGetter.d.ts +3 -2
- package/esm/hooks/useIsItemFocusedGetter.js +2 -1
- 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 -1
- package/esm/internals/index.js +1 -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/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
- package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +2 -2
- 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/seriesHasData.d.ts +4 -0
- package/esm/internals/seriesHasData.js +8 -0
- 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/index.d.ts +3 -1
- package/hooks/useFocusedItem.d.ts +1 -12
- package/hooks/useFocusedItem.js +1 -10
- package/hooks/useIsItemFocused.d.ts +4 -3
- package/hooks/useIsItemFocused.js +1 -1
- package/hooks/useIsItemFocusedGetter.d.ts +3 -2
- package/hooks/useIsItemFocusedGetter.js +2 -1
- package/index.js +1 -1
- package/internals/commonNextFocusItem.d.ts +14 -0
- package/internals/commonNextFocusItem.js +93 -0
- package/internals/index.d.ts +1 -1
- package/internals/index.js +4 -4
- 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/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
- package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +1 -1
- package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
- package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
- package/internals/seriesHasData.d.ts +4 -0
- package/internals/seriesHasData.js +14 -0
- 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/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/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/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js
CHANGED
|
@@ -11,92 +11,7 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
|
|
13
13
|
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
|
-
var _useChartKeyboardNavigation = require("./useChartKeyboardNavigation.helpers");
|
|
15
14
|
var _useChartSeries = require("../../corePlugins/useChartSeries/useChartSeries.selectors");
|
|
16
|
-
function getNextIndexFocusedItem(state) {
|
|
17
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
18
|
-
let {
|
|
19
|
-
type,
|
|
20
|
-
seriesId
|
|
21
|
-
} = state.keyboardNavigation.item ?? {};
|
|
22
|
-
if (type === undefined ||
|
|
23
|
-
// @ts-ignore sankey is not in MIT version
|
|
24
|
-
type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(processedSeries, type, seriesId)) {
|
|
25
|
-
const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(processedSeries, type, seriesId);
|
|
26
|
-
if (nextSeries === null) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
type = nextSeries.type;
|
|
30
|
-
seriesId = nextSeries.seriesId;
|
|
31
|
-
}
|
|
32
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
33
|
-
return {
|
|
34
|
-
type,
|
|
35
|
-
seriesId,
|
|
36
|
-
dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function getPreviousIndexFocusedItem(state) {
|
|
40
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
41
|
-
let {
|
|
42
|
-
type,
|
|
43
|
-
seriesId
|
|
44
|
-
} = state.keyboardNavigation.item ?? {};
|
|
45
|
-
if (type === undefined ||
|
|
46
|
-
// @ts-ignore sankey is not in MIT version
|
|
47
|
-
type === 'sankey' || seriesId === undefined || !(0, _useChartKeyboardNavigation.seriesHasData)(processedSeries, type, seriesId)) {
|
|
48
|
-
const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(processedSeries, type, seriesId);
|
|
49
|
-
if (previousSeries === null) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
type = previousSeries.type;
|
|
53
|
-
seriesId = previousSeries.seriesId;
|
|
54
|
-
}
|
|
55
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
56
|
-
return {
|
|
57
|
-
type,
|
|
58
|
-
seriesId,
|
|
59
|
-
dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function getNextSeriesFocusedItem(state) {
|
|
63
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
64
|
-
let {
|
|
65
|
-
type,
|
|
66
|
-
seriesId
|
|
67
|
-
} = state.keyboardNavigation.item ?? {};
|
|
68
|
-
const nextSeries = (0, _useChartKeyboardNavigation.getNextSeriesWithData)(processedSeries, type, seriesId);
|
|
69
|
-
if (nextSeries === null) {
|
|
70
|
-
return null; // No series to move the focus to.
|
|
71
|
-
}
|
|
72
|
-
type = nextSeries.type;
|
|
73
|
-
seriesId = nextSeries.seriesId;
|
|
74
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
75
|
-
return {
|
|
76
|
-
type,
|
|
77
|
-
seriesId,
|
|
78
|
-
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
function getPreviousSeriesFocusedItem(state) {
|
|
82
|
-
const processedSeries = (0, _useChartSeries.selectorChartSeriesProcessed)(state);
|
|
83
|
-
let {
|
|
84
|
-
type,
|
|
85
|
-
seriesId
|
|
86
|
-
} = state.keyboardNavigation.item ?? {};
|
|
87
|
-
const previousSeries = (0, _useChartKeyboardNavigation.getPreviousSeriesWithData)(processedSeries, type, seriesId);
|
|
88
|
-
if (previousSeries === null) {
|
|
89
|
-
return null; // No series to move the focus to.
|
|
90
|
-
}
|
|
91
|
-
type = previousSeries.type;
|
|
92
|
-
seriesId = previousSeries.seriesId;
|
|
93
|
-
const dataLength = processedSeries[type].series[seriesId].data.length;
|
|
94
|
-
return {
|
|
95
|
-
type,
|
|
96
|
-
seriesId,
|
|
97
|
-
dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
15
|
const useChartKeyboardNavigation = ({
|
|
101
16
|
params,
|
|
102
17
|
store,
|
|
@@ -116,26 +31,18 @@ const useChartKeyboardNavigation = ({
|
|
|
116
31
|
}
|
|
117
32
|
function keyboardHandler(event) {
|
|
118
33
|
let newFocusedItem = store.state.keyboardNavigation.item;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
break;
|
|
130
|
-
}
|
|
131
|
-
case 'ArrowUp':
|
|
132
|
-
{
|
|
133
|
-
newFocusedItem = getNextSeriesFocusedItem(store.state);
|
|
134
|
-
break;
|
|
135
|
-
}
|
|
136
|
-
default:
|
|
137
|
-
break;
|
|
34
|
+
let seriesType = newFocusedItem?.type;
|
|
35
|
+
if (!seriesType) {
|
|
36
|
+
seriesType = Object.keys((0, _useChartSeries.selectorChartDefaultizedSeries)(store.state)).find(key => store.state.series.seriesConfig[key] !== undefined);
|
|
37
|
+
if (seriesType === undefined) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
const calculateFocusedItem = store.state.series.seriesConfig[seriesType]?.keyboardFocusHandler?.(event);
|
|
42
|
+
if (!calculateFocusedItem) {
|
|
43
|
+
return;
|
|
138
44
|
}
|
|
45
|
+
newFocusedItem = calculateFocusedItem(newFocusedItem, store.state);
|
|
139
46
|
if (newFocusedItem !== store.state.keyboardNavigation.item) {
|
|
140
47
|
event.preventDefault();
|
|
141
48
|
store.update((0, _extends2.default)({}, store.state.highlight && {
|
|
@@ -1,21 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { FocusedItemIdentifier } from "../../../../models/seriesType/index.js";
|
|
2
2
|
import { type AxisItemIdentifier } from "../../../../models/axis.js";
|
|
3
|
-
import { type FocusedItemData } from "../../../../hooks/useFocusedItem.js";
|
|
4
3
|
export declare const selectorChartsItemIsFocused: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
5
4
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
6
|
-
}, item:
|
|
5
|
+
}, item: FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig>) => boolean;
|
|
7
6
|
export declare const selectorChartsHasFocusedItem: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
8
7
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
9
8
|
}) => boolean;
|
|
10
|
-
export declare const
|
|
9
|
+
export declare const selectorChartsFocusedItem: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
11
10
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
12
|
-
}) =>
|
|
13
|
-
export declare const selectorChartsFocusedSeriesId: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
14
|
-
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
15
|
-
}) => SeriesId | undefined;
|
|
16
|
-
export declare const selectorChartsFocusedDataIndex: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
17
|
-
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
18
|
-
}) => number | undefined;
|
|
11
|
+
}) => FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig> | null;
|
|
19
12
|
export declare const selectorChartsIsKeyboardNavigationEnabled: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
20
13
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
21
14
|
}) => boolean;
|
|
@@ -27,23 +20,4 @@ export declare const selectorChartsKeyboardYAxisIndex: (args_0: import("../../co
|
|
|
27
20
|
}) => AxisItemIdentifier | undefined;
|
|
28
21
|
export declare const selectorChartsKeyboardItem: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
29
22
|
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
30
|
-
}) =>
|
|
31
|
-
type: "line";
|
|
32
|
-
seriesId: SeriesId;
|
|
33
|
-
dataIndex: number;
|
|
34
|
-
} | {
|
|
35
|
-
type: "bar";
|
|
36
|
-
seriesId: SeriesId;
|
|
37
|
-
dataIndex: number;
|
|
38
|
-
} | {
|
|
39
|
-
type: "scatter";
|
|
40
|
-
seriesId: SeriesId;
|
|
41
|
-
dataIndex: number;
|
|
42
|
-
} | {
|
|
43
|
-
type: "pie";
|
|
44
|
-
seriesId: SeriesId;
|
|
45
|
-
dataIndex: number;
|
|
46
|
-
} | null;
|
|
47
|
-
export declare const selectorChartsKeyboardItemIsDefined: (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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
|
|
48
|
-
cacheKey: import("../../models/index.js").ChartStateCacheKey;
|
|
49
|
-
}) => boolean;
|
|
23
|
+
}) => FocusedItemIdentifier<keyof import("../../../index.js").ChartsSeriesConfig> | null;
|
|
@@ -3,29 +3,26 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.
|
|
6
|
+
exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItem = exports.selectorChartsItemIsFocused = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedItem = void 0;
|
|
7
7
|
var _store = require("@mui/x-internals/store");
|
|
8
|
+
var _fastObjectShallowCompare = require("@mui/x-internals/fastObjectShallowCompare");
|
|
8
9
|
var _useChartSeries = require("../../corePlugins/useChartSeries");
|
|
9
10
|
var _useChartCartesianAxisRendering = require("../useChartCartesianAxis/useChartCartesianAxisRendering.selectors");
|
|
10
11
|
const selectKeyboardNavigation = state => state.keyboardNavigation;
|
|
11
|
-
const selectorChartsItemIsFocused = exports.selectorChartsItemIsFocused = (0, _store.createSelector)(selectKeyboardNavigation, (keyboardNavigationState, item) =>
|
|
12
|
-
return keyboardNavigationState?.item != null && keyboardNavigationState.item.type === item.seriesType && keyboardNavigationState.item.seriesId === item.seriesId && keyboardNavigationState.item.dataIndex === item.dataIndex;
|
|
13
|
-
});
|
|
12
|
+
const selectorChartsItemIsFocused = exports.selectorChartsItemIsFocused = (0, _store.createSelector)(selectKeyboardNavigation, (keyboardNavigationState, item) => keyboardNavigationState?.item != null && (0, _fastObjectShallowCompare.fastObjectShallowCompare)(keyboardNavigationState.item, item));
|
|
14
13
|
const selectorChartsHasFocusedItem = exports.selectorChartsHasFocusedItem = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item != null);
|
|
15
|
-
const
|
|
16
|
-
const selectorChartsFocusedSeriesId = exports.selectorChartsFocusedSeriesId = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
|
|
17
|
-
const selectorChartsFocusedDataIndex = exports.selectorChartsFocusedDataIndex = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
|
|
14
|
+
const selectorChartsFocusedItem = exports.selectorChartsFocusedItem = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item ?? null);
|
|
18
15
|
const selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsIsKeyboardNavigationEnabled = (0, _store.createSelector)(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
|
|
19
16
|
|
|
20
17
|
/**
|
|
21
18
|
* Selectors to override highlight behavior.
|
|
22
19
|
*/
|
|
23
20
|
|
|
24
|
-
const createSelectAxisHighlight = direction => (
|
|
25
|
-
if (
|
|
21
|
+
const createSelectAxisHighlight = direction => (item, axis, series) => {
|
|
22
|
+
if (item == null || !('dataIndex' in item) || item.dataIndex === undefined) {
|
|
26
23
|
return undefined;
|
|
27
24
|
}
|
|
28
|
-
const seriesConfig = series[type]?.series[seriesId];
|
|
25
|
+
const seriesConfig = series[item.type]?.series[item.seriesId];
|
|
29
26
|
if (!seriesConfig) {
|
|
30
27
|
return undefined;
|
|
31
28
|
}
|
|
@@ -35,11 +32,11 @@ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis,
|
|
|
35
32
|
}
|
|
36
33
|
return {
|
|
37
34
|
axisId,
|
|
38
|
-
dataIndex
|
|
35
|
+
dataIndex: item.dataIndex
|
|
39
36
|
};
|
|
40
37
|
};
|
|
41
|
-
const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _store.createSelector)(
|
|
42
|
-
const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _store.createSelector)(
|
|
38
|
+
const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _store.createSelector)(selectorChartsFocusedItem, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
|
|
39
|
+
const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _store.createSelector)(selectorChartsFocusedItem, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
|
|
43
40
|
const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _store.createSelector)(selectKeyboardNavigation, function selectorChartsKeyboardItem(keyboardState) {
|
|
44
41
|
if (keyboardState?.item == null) {
|
|
45
42
|
return null;
|
|
@@ -52,7 +49,4 @@ const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _sto
|
|
|
52
49
|
return null;
|
|
53
50
|
}
|
|
54
51
|
return keyboardState.item;
|
|
55
|
-
});
|
|
56
|
-
const selectorChartsKeyboardItemIsDefined = exports.selectorChartsKeyboardItemIsDefined = (0, _store.createSelector)(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, function selectorChartsKeyboardItemIsDefined(seriesType, seriesId, dataIndex) {
|
|
57
|
-
return seriesId !== undefined && dataIndex !== undefined;
|
|
58
52
|
});
|
|
@@ -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
|
}
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts
ADDED
|
@@ -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;
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getNextNonEmptySeries = getNextNonEmptySeries;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the next series type and id that contains some data.
|
|
9
|
+
* Returns `null` if no other series have data.
|
|
10
|
+
* @param series - The processed series from the store.
|
|
11
|
+
* @param availableSeriesTypes - The set of series types that can be focused.
|
|
12
|
+
* @param type - The current series type.
|
|
13
|
+
* @param seriesId - The current series id.
|
|
14
|
+
*/
|
|
15
|
+
function getNextNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
|
|
16
|
+
const seriesType = Object.keys(series);
|
|
17
|
+
const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
|
|
18
|
+
const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
|
|
19
|
+
const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
|
|
20
|
+
|
|
21
|
+
// Loop over all series types starting with the current seriesType
|
|
22
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
23
|
+
const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
|
|
24
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
25
|
+
|
|
26
|
+
// Edge case for the current series type: we don't loop on previous series of the same type.
|
|
27
|
+
const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
|
|
28
|
+
for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
|
|
29
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
30
|
+
return {
|
|
31
|
+
type: typesAvailable[typeIndex],
|
|
32
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// End looping on the initial type up to the initial series (excluded)
|
|
39
|
+
const typeIndex = startingTypeIndex;
|
|
40
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
41
|
+
const endingSeriesIndex = currentSeriesIndex;
|
|
42
|
+
for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
|
|
43
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
44
|
+
return {
|
|
45
|
+
type: typesAvailable[typeIndex],
|
|
46
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
@@ -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,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getPreviousNonEmptySeries = getPreviousNonEmptySeries;
|
|
7
|
+
/**
|
|
8
|
+
* Returns the previous series type and id that contains some data.
|
|
9
|
+
* Returns `null` if no other series have data.
|
|
10
|
+
*/
|
|
11
|
+
function getPreviousNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
|
|
12
|
+
const seriesType = Object.keys(series);
|
|
13
|
+
const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
|
|
14
|
+
const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
|
|
15
|
+
const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
|
|
16
|
+
|
|
17
|
+
// Loop over all series types starting with the current seriesType
|
|
18
|
+
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
19
|
+
const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
|
|
20
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
21
|
+
const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
|
|
22
|
+
for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
|
|
23
|
+
const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
|
|
24
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
25
|
+
return {
|
|
26
|
+
type: typesAvailable[typeIndex],
|
|
27
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// End looping on the initial type down to the initial series (excluded)
|
|
34
|
+
const typeIndex = startingTypeIndex;
|
|
35
|
+
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
36
|
+
const availableSeriesIds = seriesOfType.seriesOrder;
|
|
37
|
+
for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
|
|
38
|
+
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
39
|
+
return {
|
|
40
|
+
type: typesAvailable[typeIndex],
|
|
41
|
+
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
@@ -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;
|
|
@@ -16,7 +16,7 @@ const selectTooltip = state => state.tooltip;
|
|
|
16
16
|
const selectorChartsTooltipPointerItem = exports.selectorChartsTooltipPointerItem = (0, _store.createSelector)(selectTooltip, tooltip => tooltip?.item ?? null);
|
|
17
17
|
const selectorChartsTooltipPointerItemIsDefined = exports.selectorChartsTooltipPointerItemIsDefined = (0, _store.createSelector)(selectorChartsTooltipPointerItem, item => item !== null);
|
|
18
18
|
const selectorChartsTooltipItem = exports.selectorChartsTooltipItem = (0, _store.createSelector)(_useChartInteraction.selectorChartsLastInteraction, selectorChartsTooltipPointerItem, _useChartKeyboardNavigation.selectorChartsKeyboardItem, (lastInteraction, pointerItem, keyboardItem) => lastInteraction === 'keyboard' ? keyboardItem : pointerItem ?? null);
|
|
19
|
-
const selectorChartsTooltipItemIsDefined = exports.selectorChartsTooltipItemIsDefined = (0, _store.createSelector)(_useChartInteraction.selectorChartsLastInteraction, selectorChartsTooltipPointerItemIsDefined, _useChartKeyboardNavigation.
|
|
19
|
+
const selectorChartsTooltipItemIsDefined = exports.selectorChartsTooltipItemIsDefined = (0, _store.createSelector)(_useChartInteraction.selectorChartsLastInteraction, selectorChartsTooltipPointerItemIsDefined, _useChartKeyboardNavigation.selectorChartsHasFocusedItem, (lastInteraction, pointerItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : pointerItemIsDefined);
|
|
20
20
|
const selectorChartsTooltipAxisConfig = (0, _store.createSelectorMemoized)(selectorChartsTooltipItem, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartPolarAxis.selectorChartRotationAxis, _useChartPolarAxis.selectorChartRadiusAxis, _useChartSeries.selectorChartSeriesProcessed, function selectorChartsTooltipAxisConfig(identifier, {
|
|
21
21
|
axis: xAxis,
|
|
22
22
|
axisIds: xAxisIds
|
|
@@ -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[];
|
|
@@ -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;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.seriesHasData = seriesHasData;
|
|
7
|
+
function seriesHasData(series, type, seriesId) {
|
|
8
|
+
// @ts-ignore sankey is not in MIT version
|
|
9
|
+
if (type === 'sankey') {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
const data = series[type]?.series[seriesId]?.data;
|
|
13
|
+
return data != null && data.length > 0;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./stackSeries.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _stackSeries = require("./stackSeries");
|
|
7
|
+
Object.keys(_stackSeries).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _stackSeries[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _stackSeries[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./offsetDiverging.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var _offsetDiverging = require("./offsetDiverging");
|
|
7
|
+
Object.keys(_offsetDiverging).forEach(function (key) {
|
|
8
|
+
if (key === "default" || key === "__esModule") return;
|
|
9
|
+
if (key in exports && exports[key] === _offsetDiverging[key]) return;
|
|
10
|
+
Object.defineProperty(exports, key, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () {
|
|
13
|
+
return _offsetDiverging[key];
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -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,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.offsetDiverging = offsetDiverging;
|
|
7
|
+
// Adapted from D3.js's offsetDiverging function https://github.com/d3/d3-shape/blob/main/src/offset/diverging.js
|
|
8
|
+
// Hidden series (with all zero values) affect the stacking in a different way in our implementation compared to the D3 behavior.
|
|
9
|
+
// The D3 stacking keep those values at the 0 "line", which creates issues when animating between hidden and visible states.
|
|
10
|
+
// In our modification, we stack them on top/below already stacked items according to the sign of their original value.
|
|
11
|
+
// A hidden negative value will be placed below all the already stacked negative values
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Positive values are stacked above zero, while negative values are stacked below zero.
|
|
15
|
+
*
|
|
16
|
+
* @param series A series generated by a stack generator.
|
|
17
|
+
* @param order An array of numeric indexes representing the stack order.
|
|
18
|
+
*/
|
|
19
|
+
function offsetDiverging(series, order) {
|
|
20
|
+
if (series.length === 0) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const seriesCount = series.length;
|
|
24
|
+
const numericOrder = order;
|
|
25
|
+
const pointCount = series[numericOrder[0]].length;
|
|
26
|
+
for (let pointIndex = 0; pointIndex < pointCount; pointIndex += 1) {
|
|
27
|
+
let positiveSum = 0;
|
|
28
|
+
let negativeSum = 0;
|
|
29
|
+
for (let seriesIndex = 0; seriesIndex < seriesCount; seriesIndex += 1) {
|
|
30
|
+
const currentSeries = series[numericOrder[seriesIndex]];
|
|
31
|
+
const dataPoint = currentSeries[pointIndex];
|
|
32
|
+
const difference = dataPoint[1] - dataPoint[0];
|
|
33
|
+
if (difference > 0) {
|
|
34
|
+
dataPoint[0] = positiveSum;
|
|
35
|
+
positiveSum += difference;
|
|
36
|
+
dataPoint[1] = positiveSum;
|
|
37
|
+
} else if (difference < 0) {
|
|
38
|
+
dataPoint[1] = negativeSum;
|
|
39
|
+
negativeSum += difference;
|
|
40
|
+
dataPoint[0] = negativeSum;
|
|
41
|
+
} else if (dataPoint.data[currentSeries.key] > 0) {
|
|
42
|
+
dataPoint[0] = positiveSum;
|
|
43
|
+
dataPoint[1] = positiveSum;
|
|
44
|
+
} else if (dataPoint.data[currentSeries.key] < 0) {
|
|
45
|
+
dataPoint[1] = negativeSum;
|
|
46
|
+
dataPoint[0] = negativeSum;
|
|
47
|
+
} else {
|
|
48
|
+
dataPoint[0] = 0;
|
|
49
|
+
dataPoint[1] = 0;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|