@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
|
@@ -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
|
* */
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.getStackingGroups = exports.StackOrder = exports.StackOffset = void 0;
|
|
7
7
|
var _d3Shape = require("@mui/x-charts-vendor/d3-shape");
|
|
8
|
+
var _offset = require("./offset");
|
|
8
9
|
const StackOrder = exports.StackOrder = {
|
|
9
10
|
/**
|
|
10
11
|
* Series order such that the earliest series (according to the maximum value) is at the bottom.
|
|
@@ -39,7 +40,8 @@ const StackOffset = exports.StackOffset = {
|
|
|
39
40
|
/**
|
|
40
41
|
* Positive values are stacked above zero, negative values are stacked below zero, and zero values are stacked at zero.
|
|
41
42
|
* */
|
|
42
|
-
|
|
43
|
+
// @ts-expect-error, d3 types are wrong, our custom function implements the correct signature
|
|
44
|
+
diverging: _offset.offsetDiverging,
|
|
43
45
|
/**
|
|
44
46
|
* Applies a zero baseline.
|
|
45
47
|
* */
|
|
@@ -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";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/x-charts",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.23.0",
|
|
4
4
|
"author": "MUI Team",
|
|
5
5
|
"description": "The community edition of MUI X Charts components.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"prop-types": "^15.8.1",
|
|
35
35
|
"reselect": "^5.1.1",
|
|
36
36
|
"use-sync-external-store": "^1.6.0",
|
|
37
|
-
"@mui/x-charts-vendor": "8.
|
|
38
|
-
"@mui/x-internals": "8.
|
|
39
|
-
"@mui/x-internal-gestures": "0.
|
|
37
|
+
"@mui/x-charts-vendor": "8.23.0",
|
|
38
|
+
"@mui/x-internals": "8.23.0",
|
|
39
|
+
"@mui/x-internal-gestures": "0.4.0"
|
|
40
40
|
},
|
|
41
41
|
"peerDependencies": {
|
|
42
42
|
"@emotion/react": "^11.9.0",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ChartSeriesType, type ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
|
|
2
|
-
import { type SeriesId } from "../../../../models/seriesType/common.js";
|
|
3
|
-
import { type ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
-
import { type FocusableSeriesTypes } from "./useChartKeyboardNavigation.types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Returns the next series type and id that contains some data.
|
|
7
|
-
* Returns `null` if no other series have data.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getNextSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: FocusableSeriesTypes, seriesId?: SeriesId): {
|
|
10
|
-
type: FocusableSeriesTypes;
|
|
11
|
-
seriesId: SeriesId;
|
|
12
|
-
} | null;
|
|
13
|
-
/**
|
|
14
|
-
* Returns the previous series type and id that contains some data.
|
|
15
|
-
* Returns `null` if no other series have data.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getPreviousSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: FocusableSeriesTypes, seriesId?: SeriesId): {
|
|
18
|
-
type: FocusableSeriesTypes;
|
|
19
|
-
seriesId: SeriesId;
|
|
20
|
-
} | null;
|
|
21
|
-
export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean | undefined;
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { isFocusableSeriesType } from "./isFocusableSeriesType.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the next series type and id that contains some data.
|
|
5
|
-
* Returns `null` if no other series have data.
|
|
6
|
-
*/
|
|
7
|
-
export function getNextSeriesWithData(series, type, seriesId) {
|
|
8
|
-
const seriesType = Object.keys(series);
|
|
9
|
-
const startingTypeIndex = type !== undefined && series[type] ? seriesType.indexOf(type) : 0;
|
|
10
|
-
const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
|
|
11
|
-
const typesAvailable = seriesType.filter(isFocusableSeriesType);
|
|
12
|
-
|
|
13
|
-
// Loop over all series types starting with the current seriesType
|
|
14
|
-
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
15
|
-
const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
|
|
16
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
17
|
-
|
|
18
|
-
// Edge case for the current series type: we don't loop on previous series of the same type.
|
|
19
|
-
const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
|
|
20
|
-
for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
|
|
21
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
22
|
-
return {
|
|
23
|
-
type: typesAvailable[typeIndex],
|
|
24
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// End looping on the initial type up to the initial series (excluded)
|
|
31
|
-
const typeIndex = startingTypeIndex;
|
|
32
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
33
|
-
const endingSeriesIndex = currentSeriesIndex;
|
|
34
|
-
for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
|
|
35
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
36
|
-
return {
|
|
37
|
-
type: typesAvailable[typeIndex],
|
|
38
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Returns the previous series type and id that contains some data.
|
|
47
|
-
* Returns `null` if no other series have data.
|
|
48
|
-
*/
|
|
49
|
-
export function getPreviousSeriesWithData(series, type, seriesId) {
|
|
50
|
-
const seriesType = Object.keys(series);
|
|
51
|
-
const startingTypeIndex = type !== undefined && series[type] ? seriesType.indexOf(type) : 0;
|
|
52
|
-
const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
|
|
53
|
-
const typesAvailable = seriesType.filter(isFocusableSeriesType);
|
|
54
|
-
|
|
55
|
-
// Loop over all series types starting with the current seriesType
|
|
56
|
-
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
57
|
-
const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
|
|
58
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
59
|
-
const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
|
|
60
|
-
for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
|
|
61
|
-
const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
|
|
62
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
63
|
-
return {
|
|
64
|
-
type: typesAvailable[typeIndex],
|
|
65
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// End looping on the initial type down to the initial series (excluded)
|
|
72
|
-
const typeIndex = startingTypeIndex;
|
|
73
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
74
|
-
const availableSeriesIds = seriesOfType.seriesOrder;
|
|
75
|
-
for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
|
|
76
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
77
|
-
return {
|
|
78
|
-
type: typesAvailable[typeIndex],
|
|
79
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
80
|
-
};
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return null;
|
|
84
|
-
}
|
|
85
|
-
export function seriesHasData(series, type, seriesId) {
|
|
86
|
-
// @ts-ignore snakey is not in MIT version
|
|
87
|
-
if (type === 'sankey') {
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
|
-
const data = series[type]?.series[seriesId]?.data;
|
|
91
|
-
return data && data.length > 0;
|
|
92
|
-
}
|
package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.isFocusableSeriesType = isFocusableSeriesType;
|
|
7
|
-
const FOCUSABLE_SERIES_TYPES = new Set(['bar', 'line', 'scatter', 'pie']);
|
|
8
|
-
function isFocusableSeriesType(type) {
|
|
9
|
-
return FOCUSABLE_SERIES_TYPES.has(type);
|
|
10
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { type ChartSeriesType, type ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
|
|
2
|
-
import { type SeriesId } from "../../../../models/seriesType/common.js";
|
|
3
|
-
import { type ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
|
|
4
|
-
import { type FocusableSeriesTypes } from "./useChartKeyboardNavigation.types.js";
|
|
5
|
-
/**
|
|
6
|
-
* Returns the next series type and id that contains some data.
|
|
7
|
-
* Returns `null` if no other series have data.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getNextSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: FocusableSeriesTypes, seriesId?: SeriesId): {
|
|
10
|
-
type: FocusableSeriesTypes;
|
|
11
|
-
seriesId: SeriesId;
|
|
12
|
-
} | null;
|
|
13
|
-
/**
|
|
14
|
-
* Returns the previous series type and id that contains some data.
|
|
15
|
-
* Returns `null` if no other series have data.
|
|
16
|
-
*/
|
|
17
|
-
export declare function getPreviousSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: FocusableSeriesTypes, seriesId?: SeriesId): {
|
|
18
|
-
type: FocusableSeriesTypes;
|
|
19
|
-
seriesId: SeriesId;
|
|
20
|
-
} | null;
|
|
21
|
-
export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean | undefined;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getNextSeriesWithData = getNextSeriesWithData;
|
|
7
|
-
exports.getPreviousSeriesWithData = getPreviousSeriesWithData;
|
|
8
|
-
exports.seriesHasData = seriesHasData;
|
|
9
|
-
var _isFocusableSeriesType = require("./isFocusableSeriesType");
|
|
10
|
-
/**
|
|
11
|
-
* Returns the next series type and id that contains some data.
|
|
12
|
-
* Returns `null` if no other series have data.
|
|
13
|
-
*/
|
|
14
|
-
function getNextSeriesWithData(series, type, seriesId) {
|
|
15
|
-
const seriesType = Object.keys(series);
|
|
16
|
-
const startingTypeIndex = type !== undefined && series[type] ? seriesType.indexOf(type) : 0;
|
|
17
|
-
const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
|
|
18
|
-
const typesAvailable = seriesType.filter(_isFocusableSeriesType.isFocusableSeriesType);
|
|
19
|
-
|
|
20
|
-
// Loop over all series types starting with the current seriesType
|
|
21
|
-
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
22
|
-
const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
|
|
23
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
24
|
-
|
|
25
|
-
// Edge case for the current series type: we don't loop on previous series of the same type.
|
|
26
|
-
const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
|
|
27
|
-
for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
|
|
28
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
29
|
-
return {
|
|
30
|
-
type: typesAvailable[typeIndex],
|
|
31
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// End looping on the initial type up to the initial series (excluded)
|
|
38
|
-
const typeIndex = startingTypeIndex;
|
|
39
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
40
|
-
const endingSeriesIndex = currentSeriesIndex;
|
|
41
|
-
for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
|
|
42
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
43
|
-
return {
|
|
44
|
-
type: typesAvailable[typeIndex],
|
|
45
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Returns the previous series type and id that contains some data.
|
|
54
|
-
* Returns `null` if no other series have data.
|
|
55
|
-
*/
|
|
56
|
-
function getPreviousSeriesWithData(series, type, seriesId) {
|
|
57
|
-
const seriesType = Object.keys(series);
|
|
58
|
-
const startingTypeIndex = type !== undefined && series[type] ? seriesType.indexOf(type) : 0;
|
|
59
|
-
const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
|
|
60
|
-
const typesAvailable = seriesType.filter(_isFocusableSeriesType.isFocusableSeriesType);
|
|
61
|
-
|
|
62
|
-
// Loop over all series types starting with the current seriesType
|
|
63
|
-
for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
|
|
64
|
-
const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
|
|
65
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
66
|
-
const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
|
|
67
|
-
for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
|
|
68
|
-
const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
|
|
69
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
70
|
-
return {
|
|
71
|
-
type: typesAvailable[typeIndex],
|
|
72
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// End looping on the initial type down to the initial series (excluded)
|
|
79
|
-
const typeIndex = startingTypeIndex;
|
|
80
|
-
const seriesOfType = series[typesAvailable[typeIndex]];
|
|
81
|
-
const availableSeriesIds = seriesOfType.seriesOrder;
|
|
82
|
-
for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
|
|
83
|
-
if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
|
|
84
|
-
return {
|
|
85
|
-
type: typesAvailable[typeIndex],
|
|
86
|
-
seriesId: seriesOfType.seriesOrder[seriesIndex]
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return null;
|
|
91
|
-
}
|
|
92
|
-
function seriesHasData(series, type, seriesId) {
|
|
93
|
-
// @ts-ignore snakey is not in MIT version
|
|
94
|
-
if (type === 'sankey') {
|
|
95
|
-
return false;
|
|
96
|
-
}
|
|
97
|
-
const data = series[type]?.series[seriesId]?.data;
|
|
98
|
-
return data && data.length > 0;
|
|
99
|
-
}
|