@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.
Files changed (124) hide show
  1. package/BarChart/BarElement.js +1 -1
  2. package/BarChart/FocusedBar.js +1 -1
  3. package/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
  4. package/BarChart/seriesConfig/bar/keyboardFocusHandler.js +23 -0
  5. package/BarChart/seriesConfig/bar/seriesProcessor.js +2 -2
  6. package/BarChart/seriesConfig/index.js +3 -1
  7. package/CHANGELOG.md +101 -0
  8. package/LineChart/FocusedLineMark.js +1 -1
  9. package/LineChart/seriesConfig/index.js +3 -1
  10. package/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  11. package/LineChart/seriesConfig/keyboardFocusHandler.js +23 -0
  12. package/LineChart/seriesConfig/seriesProcessor.js +2 -2
  13. package/PieChart/FocusedPieArc.js +1 -1
  14. package/PieChart/dataTransform/useTransformData.js +1 -1
  15. package/PieChart/seriesConfig/index.js +3 -1
  16. package/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  17. package/PieChart/seriesConfig/keyboardFocusHandler.js +23 -0
  18. package/ScatterChart/FocusedScatterMark.js +1 -1
  19. package/ScatterChart/seriesConfig/index.js +3 -1
  20. package/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  21. package/ScatterChart/seriesConfig/keyboardFocusHandler.js +23 -0
  22. package/esm/BarChart/BarElement.js +1 -1
  23. package/esm/BarChart/FocusedBar.js +1 -1
  24. package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
  25. package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.js +17 -0
  26. package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +1 -1
  27. package/esm/BarChart/seriesConfig/index.js +3 -1
  28. package/esm/LineChart/FocusedLineMark.js +1 -1
  29. package/esm/LineChart/seriesConfig/index.js +3 -1
  30. package/esm/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  31. package/esm/LineChart/seriesConfig/keyboardFocusHandler.js +17 -0
  32. package/esm/LineChart/seriesConfig/seriesProcessor.js +1 -1
  33. package/esm/PieChart/FocusedPieArc.js +1 -1
  34. package/esm/PieChart/dataTransform/useTransformData.js +1 -1
  35. package/esm/PieChart/seriesConfig/index.js +3 -1
  36. package/esm/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  37. package/esm/PieChart/seriesConfig/keyboardFocusHandler.js +17 -0
  38. package/esm/ScatterChart/FocusedScatterMark.js +1 -1
  39. package/esm/ScatterChart/seriesConfig/index.js +3 -1
  40. package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  41. package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.js +17 -0
  42. package/esm/hooks/useFocusedItem.d.ts +1 -12
  43. package/esm/hooks/useFocusedItem.js +3 -10
  44. package/esm/hooks/useIsItemFocused.d.ts +4 -3
  45. package/esm/hooks/useIsItemFocused.js +1 -1
  46. package/esm/hooks/useIsItemFocusedGetter.d.ts +3 -2
  47. package/esm/hooks/useIsItemFocusedGetter.js +2 -1
  48. package/esm/index.js +1 -1
  49. package/esm/internals/commonNextFocusItem.d.ts +14 -0
  50. package/esm/internals/commonNextFocusItem.js +84 -0
  51. package/esm/internals/index.d.ts +1 -1
  52. package/esm/internals/index.js +1 -1
  53. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
  54. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +1 -0
  55. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
  56. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +12 -105
  57. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
  58. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +9 -15
  59. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
  60. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
  61. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +45 -0
  62. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
  63. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +40 -0
  64. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
  65. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +2 -2
  66. package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  67. package/esm/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  68. package/esm/internals/seriesHasData.d.ts +4 -0
  69. package/esm/internals/seriesHasData.js +8 -0
  70. package/esm/internals/stacking/index.d.ts +1 -0
  71. package/esm/internals/stacking/index.js +1 -0
  72. package/esm/internals/stacking/offset/index.d.ts +1 -0
  73. package/esm/internals/stacking/offset/index.js +1 -0
  74. package/esm/internals/stacking/offset/offsetDiverging.d.ts +8 -0
  75. package/esm/internals/stacking/offset/offsetDiverging.js +47 -0
  76. package/esm/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
  77. package/esm/internals/{stackSeries.js → stacking/stackSeries.js} +8 -6
  78. package/esm/models/seriesType/index.d.ts +3 -1
  79. package/hooks/useFocusedItem.d.ts +1 -12
  80. package/hooks/useFocusedItem.js +1 -10
  81. package/hooks/useIsItemFocused.d.ts +4 -3
  82. package/hooks/useIsItemFocused.js +1 -1
  83. package/hooks/useIsItemFocusedGetter.d.ts +3 -2
  84. package/hooks/useIsItemFocusedGetter.js +2 -1
  85. package/index.js +1 -1
  86. package/internals/commonNextFocusItem.d.ts +14 -0
  87. package/internals/commonNextFocusItem.js +93 -0
  88. package/internals/index.d.ts +1 -1
  89. package/internals/index.js +4 -4
  90. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
  91. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +5 -0
  92. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
  93. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +11 -104
  94. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
  95. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -16
  96. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
  97. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
  98. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +51 -0
  99. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
  100. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +46 -0
  101. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
  102. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +1 -1
  103. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  104. package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  105. package/internals/seriesHasData.d.ts +4 -0
  106. package/internals/seriesHasData.js +14 -0
  107. package/internals/stacking/index.d.ts +1 -0
  108. package/internals/stacking/index.js +16 -0
  109. package/internals/stacking/offset/index.d.ts +1 -0
  110. package/internals/stacking/offset/index.js +16 -0
  111. package/internals/stacking/offset/offsetDiverging.d.ts +8 -0
  112. package/internals/stacking/offset/offsetDiverging.js +53 -0
  113. package/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
  114. package/internals/{stackSeries.js → stacking/stackSeries.js} +3 -1
  115. package/models/seriesType/index.d.ts +3 -1
  116. package/package.json +4 -4
  117. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
  118. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -4
  119. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
  120. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -92
  121. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
  122. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -10
  123. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
  124. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -99
@@ -1,6 +1,6 @@
1
- import { stackOrderAppearance as d3StackOrderAppearance, stackOrderAscending as d3StackOrderAscending, stackOrderDescending as d3StackOrderDescending, stackOrderInsideOut as d3StackOrderInsideOut, stackOrderNone as d3StackOrderNone, stackOrderReverse as d3StackOrderReverse, stackOffsetExpand as d3StackOffsetExpand, stackOffsetDiverging as d3StackOffsetDiverging, 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";
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 d3StackOrderAppearance;
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 d3StackOrderAscending;
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 d3StackOrderDescending;
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 d3StackOrderInsideOut;
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: typeof d3StackOffsetDiverging;
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
- diverging: _d3Shape.stackOffsetDiverging,
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 { type BarSeriesType, type DefaultizedBarSeriesType } from "./bar.js";
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.22.1",
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.22.0",
38
- "@mui/x-internals": "8.22.0",
39
- "@mui/x-internal-gestures": "0.3.6"
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,3 +0,0 @@
1
- import { type ChartSeriesType } from "../../../../models/seriesType/config.js";
2
- import { type FocusableSeriesTypes } from "./useChartKeyboardNavigation.types.js";
3
- export declare function isFocusableSeriesType(type: ChartSeriesType): type is FocusableSeriesTypes;
@@ -1,4 +0,0 @@
1
- const FOCUSABLE_SERIES_TYPES = new Set(['bar', 'line', 'scatter', 'pie']);
2
- export function isFocusableSeriesType(type) {
3
- return FOCUSABLE_SERIES_TYPES.has(type);
4
- }
@@ -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
- }
@@ -1,3 +0,0 @@
1
- import { type ChartSeriesType } from "../../../../models/seriesType/config.js";
2
- import { type FocusableSeriesTypes } from "./useChartKeyboardNavigation.types.js";
3
- export declare function isFocusableSeriesType(type: ChartSeriesType): type is FocusableSeriesTypes;
@@ -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
- }