@mui/x-charts 8.22.0 → 8.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (238) hide show
  1. package/BarChart/BarElement.js +1 -1
  2. package/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
  3. package/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
  4. package/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
  5. package/BarChart/BarLabel/getBarLabel.d.ts +3 -3
  6. package/BarChart/FocusedBar.js +1 -1
  7. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
  8. package/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
  9. package/BarChart/seriesConfig/bar/keyboardFocusHandler.js +23 -0
  10. package/BarChart/seriesConfig/bar/seriesProcessor.js +2 -2
  11. package/BarChart/seriesConfig/index.js +3 -1
  12. package/CHANGELOG.md +202 -0
  13. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
  14. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
  15. package/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
  16. package/ChartsSurface/ChartsSurface.js +7 -8
  17. package/ChartsTooltip/ChartsTooltipContainer.js +4 -5
  18. package/ChartsTooltip/useAxisTooltip.js +3 -4
  19. package/ChartsTooltip/useItemTooltip.js +2 -3
  20. package/ChartsWrapper/ChartsWrapper.js +2 -3
  21. package/LineChart/FocusedLineMark.js +1 -1
  22. package/LineChart/LineHighlightPlot.js +1 -2
  23. package/LineChart/MarkPlot.js +1 -2
  24. package/LineChart/seriesConfig/index.js +3 -1
  25. package/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  26. package/LineChart/seriesConfig/keyboardFocusHandler.js +23 -0
  27. package/LineChart/seriesConfig/seriesProcessor.js +2 -2
  28. package/PieChart/FocusedPieArc.d.ts +2 -0
  29. package/PieChart/FocusedPieArc.js +58 -0
  30. package/PieChart/PieArcPlot.js +3 -31
  31. package/PieChart/PieChart.js +2 -1
  32. package/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
  33. package/PieChart/dataTransform/getModifiedArcProperties.js +42 -0
  34. package/PieChart/dataTransform/useTransformData.js +16 -21
  35. package/PieChart/seriesConfig/index.js +3 -1
  36. package/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  37. package/PieChart/seriesConfig/keyboardFocusHandler.js +23 -0
  38. package/PieChart/seriesConfig/tooltipPosition.js +11 -20
  39. package/RadarChart/RadarAxis/useRadarAxis.js +1 -2
  40. package/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
  41. package/RadarChart/RadarGrid/useRadarGridData.js +1 -2
  42. package/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
  43. package/ScatterChart/BatchScatter.js +4 -5
  44. package/ScatterChart/FocusedScatterMark.js +1 -1
  45. package/ScatterChart/Scatter.js +1 -2
  46. package/ScatterChart/seriesConfig/index.js +3 -1
  47. package/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  48. package/ScatterChart/seriesConfig/keyboardFocusHandler.js +23 -0
  49. package/esm/BarChart/BarElement.js +1 -1
  50. package/esm/BarChart/BarLabel/BarLabel.types.d.ts +3 -3
  51. package/esm/BarChart/BarLabel/BarLabelItem.d.ts +1 -1
  52. package/esm/BarChart/BarLabel/BarLabelPlot.d.ts +9 -9
  53. package/esm/BarChart/BarLabel/getBarLabel.d.ts +3 -3
  54. package/esm/BarChart/FocusedBar.js +1 -1
  55. package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +18 -1
  56. package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.d.ts +3 -0
  57. package/esm/BarChart/seriesConfig/bar/keyboardFocusHandler.js +17 -0
  58. package/esm/BarChart/seriesConfig/bar/seriesProcessor.js +1 -1
  59. package/esm/BarChart/seriesConfig/index.js +3 -1
  60. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -3
  61. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -3
  62. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +6 -7
  63. package/esm/ChartsSurface/ChartsSurface.js +7 -8
  64. package/esm/ChartsTooltip/ChartsTooltipContainer.js +4 -5
  65. package/esm/ChartsTooltip/useAxisTooltip.js +3 -4
  66. package/esm/ChartsTooltip/useItemTooltip.js +2 -3
  67. package/esm/ChartsWrapper/ChartsWrapper.js +2 -3
  68. package/esm/LineChart/FocusedLineMark.js +1 -1
  69. package/esm/LineChart/LineHighlightPlot.js +1 -2
  70. package/esm/LineChart/MarkPlot.js +1 -2
  71. package/esm/LineChart/seriesConfig/index.js +3 -1
  72. package/esm/LineChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  73. package/esm/LineChart/seriesConfig/keyboardFocusHandler.js +17 -0
  74. package/esm/LineChart/seriesConfig/seriesProcessor.js +1 -1
  75. package/esm/PieChart/FocusedPieArc.d.ts +2 -0
  76. package/esm/PieChart/FocusedPieArc.js +51 -0
  77. package/esm/PieChart/PieArcPlot.js +5 -33
  78. package/esm/PieChart/PieChart.js +2 -1
  79. package/esm/PieChart/dataTransform/getModifiedArcProperties.d.ts +11 -0
  80. package/esm/PieChart/dataTransform/getModifiedArcProperties.js +36 -0
  81. package/esm/PieChart/dataTransform/useTransformData.js +16 -21
  82. package/esm/PieChart/seriesConfig/index.js +3 -1
  83. package/esm/PieChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  84. package/esm/PieChart/seriesConfig/keyboardFocusHandler.js +17 -0
  85. package/esm/PieChart/seriesConfig/tooltipPosition.js +11 -20
  86. package/esm/RadarChart/RadarAxis/useRadarAxis.js +1 -2
  87. package/esm/RadarChart/RadarAxisHighlight/useRadarAxisHighlight.js +3 -4
  88. package/esm/RadarChart/RadarGrid/useRadarGridData.js +1 -2
  89. package/esm/RadarChart/RadarSeriesPlot/useRadarRotationIndex.js +1 -2
  90. package/esm/ScatterChart/BatchScatter.js +4 -5
  91. package/esm/ScatterChart/FocusedScatterMark.js +1 -1
  92. package/esm/ScatterChart/Scatter.js +1 -2
  93. package/esm/ScatterChart/seriesConfig/index.js +3 -1
  94. package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.d.ts +3 -0
  95. package/esm/ScatterChart/seriesConfig/keyboardFocusHandler.js +17 -0
  96. package/esm/hooks/useAxis.js +8 -9
  97. package/esm/hooks/useAxisSystem.js +2 -3
  98. package/esm/hooks/useBrush.js +1 -2
  99. package/esm/hooks/useChartId.js +1 -2
  100. package/esm/hooks/useDataset.js +1 -2
  101. package/esm/hooks/useDrawingArea.js +1 -2
  102. package/esm/hooks/useFocusedItem.d.ts +1 -12
  103. package/esm/hooks/useFocusedItem.js +3 -11
  104. package/esm/hooks/useInteractionItemProps.d.ts +3 -2
  105. package/esm/hooks/useInteractionItemProps.js +13 -2
  106. package/esm/hooks/useIsItemFocused.d.ts +4 -3
  107. package/esm/hooks/useIsItemFocused.js +2 -3
  108. package/esm/hooks/useIsItemFocusedGetter.d.ts +3 -2
  109. package/esm/hooks/useIsItemFocusedGetter.js +2 -1
  110. package/esm/hooks/useItemHighlighted.js +2 -3
  111. package/esm/hooks/useItemHighlightedGetter.js +2 -3
  112. package/esm/hooks/useLegend.js +1 -2
  113. package/esm/hooks/usePieSeries.js +1 -2
  114. package/esm/hooks/useSeries.js +1 -2
  115. package/esm/hooks/useSkipAnimation.js +1 -2
  116. package/esm/hooks/useZAxis.js +1 -2
  117. package/esm/index.js +1 -1
  118. package/esm/internals/commonNextFocusItem.d.ts +14 -0
  119. package/esm/internals/commonNextFocusItem.js +84 -0
  120. package/esm/internals/index.d.ts +1 -2
  121. package/esm/internals/index.js +1 -2
  122. package/esm/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
  123. package/esm/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
  124. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
  125. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
  126. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
  127. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
  128. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
  129. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
  130. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +1 -0
  131. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
  132. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +12 -105
  133. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
  134. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +9 -15
  135. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
  136. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
  137. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +45 -0
  138. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
  139. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +40 -0
  140. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
  141. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
  142. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +2 -2
  143. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
  144. package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  145. package/esm/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  146. package/esm/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
  147. package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
  148. package/esm/internals/seriesHasData.d.ts +4 -0
  149. package/esm/internals/seriesHasData.js +8 -0
  150. package/esm/internals/seriesSelectorOfType.js +2 -3
  151. package/esm/internals/stacking/index.d.ts +1 -0
  152. package/esm/internals/stacking/index.js +1 -0
  153. package/esm/internals/stacking/offset/index.d.ts +1 -0
  154. package/esm/internals/stacking/offset/index.js +1 -0
  155. package/esm/internals/stacking/offset/offsetDiverging.d.ts +8 -0
  156. package/esm/internals/stacking/offset/offsetDiverging.js +47 -0
  157. package/esm/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
  158. package/esm/internals/{stackSeries.js → stacking/stackSeries.js} +8 -6
  159. package/esm/models/seriesType/config.d.ts +0 -2
  160. package/esm/models/seriesType/index.d.ts +3 -1
  161. package/hooks/useAxis.js +8 -9
  162. package/hooks/useAxisSystem.js +2 -3
  163. package/hooks/useBrush.js +1 -2
  164. package/hooks/useChartId.js +1 -2
  165. package/hooks/useDataset.js +1 -2
  166. package/hooks/useDrawingArea.js +1 -2
  167. package/hooks/useFocusedItem.d.ts +1 -12
  168. package/hooks/useFocusedItem.js +1 -11
  169. package/hooks/useInteractionItemProps.d.ts +3 -2
  170. package/hooks/useInteractionItemProps.js +13 -2
  171. package/hooks/useIsItemFocused.d.ts +4 -3
  172. package/hooks/useIsItemFocused.js +2 -3
  173. package/hooks/useIsItemFocusedGetter.d.ts +3 -2
  174. package/hooks/useIsItemFocusedGetter.js +2 -1
  175. package/hooks/useItemHighlighted.js +2 -3
  176. package/hooks/useItemHighlightedGetter.js +2 -3
  177. package/hooks/useLegend.js +1 -2
  178. package/hooks/usePieSeries.js +1 -2
  179. package/hooks/useSeries.js +1 -2
  180. package/hooks/useSkipAnimation.js +1 -2
  181. package/hooks/useZAxis.js +1 -2
  182. package/index.js +1 -1
  183. package/internals/commonNextFocusItem.d.ts +14 -0
  184. package/internals/commonNextFocusItem.js +93 -0
  185. package/internals/index.d.ts +1 -2
  186. package/internals/index.js +4 -16
  187. package/internals/plugins/corePlugins/useChartDimensions/useChartDimensions.js +1 -2
  188. package/internals/plugins/corePlugins/useChartSeries/useColorProcessor.js +1 -2
  189. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +1 -2
  190. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +5 -6
  191. package/internals/plugins/featurePlugins/useChartCartesianAxis/useInternalIsZoomInteracting.js +1 -2
  192. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +5 -6
  193. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.js +4 -1
  194. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.d.ts +13 -0
  195. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js +5 -0
  196. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +2 -2
  197. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +11 -104
  198. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +5 -31
  199. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +10 -16
  200. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +6 -21
  201. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.d.ts +15 -0
  202. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +51 -0
  203. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.d.ts +11 -0
  204. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +46 -0
  205. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +6 -7
  206. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -9
  207. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.js +1 -1
  208. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.types.d.ts +7 -6
  209. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  210. package/internals/plugins/models/seriesConfig/seriesProcessor.types.d.ts +1 -1
  211. package/internals/plugins/models/seriesConfig/tooltipGetter.types.d.ts +4 -3
  212. package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +3 -2
  213. package/internals/seriesHasData.d.ts +4 -0
  214. package/internals/seriesHasData.js +14 -0
  215. package/internals/seriesSelectorOfType.js +2 -3
  216. package/internals/stacking/index.d.ts +1 -0
  217. package/internals/stacking/index.js +16 -0
  218. package/internals/stacking/offset/index.d.ts +1 -0
  219. package/internals/stacking/offset/index.js +16 -0
  220. package/internals/stacking/offset/offsetDiverging.d.ts +8 -0
  221. package/internals/stacking/offset/offsetDiverging.js +53 -0
  222. package/internals/{stackSeries.d.ts → stacking/stackSeries.d.ts} +8 -8
  223. package/internals/{stackSeries.js → stacking/stackSeries.js} +3 -1
  224. package/models/seriesType/config.d.ts +0 -2
  225. package/models/seriesType/index.d.ts +3 -1
  226. package/package.json +4 -4
  227. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
  228. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -4
  229. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
  230. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -92
  231. package/esm/internals/store/useSelector.d.ts +0 -2
  232. package/esm/internals/store/useSelector.js +0 -2
  233. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +0 -3
  234. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +0 -10
  235. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +0 -21
  236. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +0 -99
  237. package/internals/store/useSelector.d.ts +0 -2
  238. package/internals/store/useSelector.js +0 -8
@@ -1,25 +1,22 @@
1
1
  import { createSelector } from '@mui/x-internals/store';
2
+ import { fastObjectShallowCompare } from '@mui/x-internals/fastObjectShallowCompare';
2
3
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
3
4
  import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
4
5
  const selectKeyboardNavigation = state => state.keyboardNavigation;
5
- export const selectorChartsItemIsFocused = createSelector(selectKeyboardNavigation, (keyboardNavigationState, item) => {
6
- return keyboardNavigationState?.item != null && keyboardNavigationState.item.type === item.seriesType && keyboardNavigationState.item.seriesId === item.seriesId && keyboardNavigationState.item.dataIndex === item.dataIndex;
7
- });
6
+ export const selectorChartsItemIsFocused = createSelector(selectKeyboardNavigation, (keyboardNavigationState, item) => keyboardNavigationState?.item != null && fastObjectShallowCompare(keyboardNavigationState.item, item));
8
7
  export const selectorChartsHasFocusedItem = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item != null);
9
- export const selectorChartsFocusedSeriesType = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.type);
10
- export const selectorChartsFocusedSeriesId = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
11
- export const selectorChartsFocusedDataIndex = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
8
+ export const selectorChartsFocusedItem = createSelector(selectKeyboardNavigation, keyboardNavigationState => keyboardNavigationState?.item ?? null);
12
9
  export const selectorChartsIsKeyboardNavigationEnabled = createSelector(selectKeyboardNavigation, keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
13
10
 
14
11
  /**
15
12
  * Selectors to override highlight behavior.
16
13
  */
17
14
 
18
- const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis, series) => {
19
- if (type === undefined || seriesId === undefined || dataIndex === undefined) {
15
+ const createSelectAxisHighlight = direction => (item, axis, series) => {
16
+ if (item == null || !('dataIndex' in item) || item.dataIndex === undefined) {
20
17
  return undefined;
21
18
  }
22
- const seriesConfig = series[type]?.series[seriesId];
19
+ const seriesConfig = series[item.type]?.series[item.seriesId];
23
20
  if (!seriesConfig) {
24
21
  return undefined;
25
22
  }
@@ -29,11 +26,11 @@ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis,
29
26
  }
30
27
  return {
31
28
  axisId,
32
- dataIndex
29
+ dataIndex: item.dataIndex
33
30
  };
34
31
  };
35
- export const selectorChartsKeyboardXAxisIndex = createSelector(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, selectorChartXAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
36
- export const selectorChartsKeyboardYAxisIndex = createSelector(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, selectorChartYAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
32
+ export const selectorChartsKeyboardXAxisIndex = createSelector(selectorChartsFocusedItem, selectorChartXAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('x'));
33
+ export const selectorChartsKeyboardYAxisIndex = createSelector(selectorChartsFocusedItem, selectorChartYAxis, selectorChartSeriesProcessed, createSelectAxisHighlight('y'));
37
34
  export const selectorChartsKeyboardItem = createSelector(selectKeyboardNavigation, function selectorChartsKeyboardItem(keyboardState) {
38
35
  if (keyboardState?.item == null) {
39
36
  return null;
@@ -46,7 +43,4 @@ export const selectorChartsKeyboardItem = createSelector(selectKeyboardNavigatio
46
43
  return null;
47
44
  }
48
45
  return keyboardState.item;
49
- });
50
- export const selectorChartsKeyboardItemIsDefined = createSelector(selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, function selectorChartsKeyboardItemIsDefined(seriesType, seriesId, dataIndex) {
51
- return seriesId !== undefined && dataIndex !== undefined;
52
46
  });
@@ -1,27 +1,12 @@
1
- import { type ChartPluginSignature } from "../../models/index.js";
2
- import { type ChartSeriesType } from "../../../../models/seriesType/config.js";
3
- import { type SeriesId } from "../../../../models/seriesType/common.js";
4
- import { type UseChartInteractionSignature } from "../useChartInteraction/index.js";
5
- import { type UseChartHighlightSignature } from "../useChartHighlight/index.js";
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 | SeriesItemIdentifier;
9
+ item: null | FocusedItemIdentifier<ChartSeriesType>;
25
10
  enableKeyboardNavigation: boolean;
26
11
  };
27
12
  }
@@ -0,0 +1,15 @@
1
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
2
+ import type { SeriesId } from "../../../../../models/seriesType/common.js";
3
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
4
+ /**
5
+ * Returns the next series type and id that contains some data.
6
+ * Returns `null` if no other series have data.
7
+ * @param series - The processed series from the store.
8
+ * @param availableSeriesTypes - The set of series types that can be focused.
9
+ * @param type - The current series type.
10
+ * @param seriesId - The current series id.
11
+ */
12
+ export declare function getNextNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
13
+ type: OutSeriesType;
14
+ seriesId: SeriesId;
15
+ } | null;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * Returns the next series type and id that contains some data.
3
+ * Returns `null` if no other series have data.
4
+ * @param series - The processed series from the store.
5
+ * @param availableSeriesTypes - The set of series types that can be focused.
6
+ * @param type - The current series type.
7
+ * @param seriesId - The current series id.
8
+ */
9
+ export function getNextNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
10
+ const seriesType = Object.keys(series);
11
+ const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
12
+ const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
13
+ const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
14
+
15
+ // Loop over all series types starting with the current seriesType
16
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
17
+ const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
18
+ const seriesOfType = series[typesAvailable[typeIndex]];
19
+
20
+ // Edge case for the current series type: we don't loop on previous series of the same type.
21
+ const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
22
+ for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
23
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
24
+ return {
25
+ type: typesAvailable[typeIndex],
26
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
27
+ };
28
+ }
29
+ }
30
+ }
31
+
32
+ // End looping on the initial type up to the initial series (excluded)
33
+ const typeIndex = startingTypeIndex;
34
+ const seriesOfType = series[typesAvailable[typeIndex]];
35
+ const endingSeriesIndex = currentSeriesIndex;
36
+ for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
37
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
38
+ return {
39
+ type: typesAvailable[typeIndex],
40
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
41
+ };
42
+ }
43
+ }
44
+ return null;
45
+ }
@@ -0,0 +1,11 @@
1
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
2
+ import type { SeriesId } from "../../../../../models/seriesType/common.js";
3
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/index.js";
4
+ /**
5
+ * Returns the previous series type and id that contains some data.
6
+ * Returns `null` if no other series have data.
7
+ */
8
+ export declare function getPreviousNonEmptySeries<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'> = Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>, type?: ChartSeriesType, seriesId?: SeriesId): {
9
+ type: OutSeriesType;
10
+ seriesId: SeriesId;
11
+ } | null;
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Returns the previous series type and id that contains some data.
3
+ * Returns `null` if no other series have data.
4
+ */
5
+ export function getPreviousNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
6
+ const seriesType = Object.keys(series);
7
+ const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
8
+ const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
9
+ const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
10
+
11
+ // Loop over all series types starting with the current seriesType
12
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
13
+ const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
14
+ const seriesOfType = series[typesAvailable[typeIndex]];
15
+ const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
16
+ for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
17
+ const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
18
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
19
+ return {
20
+ type: typesAvailable[typeIndex],
21
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
22
+ };
23
+ }
24
+ }
25
+ }
26
+
27
+ // End looping on the initial type down to the initial series (excluded)
28
+ const typeIndex = startingTypeIndex;
29
+ const seriesOfType = series[typesAvailable[typeIndex]];
30
+ const availableSeriesIds = seriesOfType.seriesOrder;
31
+ for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
32
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
33
+ return {
34
+ type: typesAvailable[typeIndex],
35
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
36
+ };
37
+ }
38
+ }
39
+ return null;
40
+ }
@@ -3,7 +3,6 @@
3
3
  import _extends from "@babel/runtime/helpers/esm/extends";
4
4
  import * as React from 'react';
5
5
  import { warnOnce } from '@mui/x-internals/warning';
6
- import { useSelector } from "../../../store/useSelector.js";
7
6
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
8
7
  import { defaultizeAxis } from "./defaultizeAxis.js";
9
8
  import { selectorChartsInteractionIsInitialized } from "../useChartInteraction/index.js";
@@ -32,18 +31,18 @@ export const useChartPolarAxis = ({
32
31
  warnOnce([`MUI X Charts: The following axis ids are duplicated: ${Array.from(duplicates).join(', ')}.`, `Please make sure that each axis has a unique id.`].join('\n'), 'error');
33
32
  }
34
33
  }
35
- const drawingArea = useSelector(store, selectorChartDrawingArea);
36
- const processedSeries = useSelector(store, selectorChartSeriesProcessed);
37
- const center = useSelector(store, selectorChartPolarCenter);
38
- const isInteractionEnabled = useSelector(store, selectorChartsInteractionIsInitialized);
34
+ const drawingArea = store.use(selectorChartDrawingArea);
35
+ const processedSeries = store.use(selectorChartSeriesProcessed);
36
+ const center = store.use(selectorChartPolarCenter);
37
+ const isInteractionEnabled = store.use(selectorChartsInteractionIsInitialized);
39
38
  const {
40
39
  axis: rotationAxisWithScale,
41
40
  axisIds: rotationAxisIds
42
- } = useSelector(store, selectorChartRotationAxis);
41
+ } = store.use(selectorChartRotationAxis);
43
42
  const {
44
43
  axis: radiusAxisWithScale,
45
44
  axisIds: radiusAxisIds
46
- } = useSelector(store, selectorChartRadiusAxis);
45
+ } = store.use(selectorChartRadiusAxis);
47
46
 
48
47
  // The effect do not track any value defined synchronously during the 1st render by hooks called after `useChartPolarAxis`
49
48
  // As a consequence, the state generated by the 1st run of this useEffect will always be equal to the initialization one
@@ -6,15 +6,7 @@ export declare const selectorChartsTooltipPointerItemIsDefined: (args_0: import(
6
6
  }) => boolean;
7
7
  export declare const selectorChartsTooltipItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("../useChartInteraction/useChartInteraction.types.js").UseChartInteractionState> & {
8
8
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
9
- }) => import("../../../../index.js").PieItemIdentifier | {
10
- type: "bar";
11
- seriesId: import("../../../index.js").SeriesId;
12
- dataIndex: number;
13
- } | {
14
- type: "scatter";
15
- seriesId: import("../../../index.js").SeriesId;
16
- dataIndex: number;
17
- } | import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
9
+ }) => import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
18
10
  export declare const selectorChartsTooltipItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof import("../../../index.js").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("../../../index.js").UseChartInteractionListenerState & Partial<import("../useChartInteraction/useChartInteraction.types.js").UseChartInteractionState> & {
19
11
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
20
12
  }) => boolean;
@@ -1,7 +1,7 @@
1
1
  import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
2
2
  import { selectorChartSeriesConfig, selectorChartSeriesProcessed, selectorChartSeriesLayout } from "../../corePlugins/useChartSeries/index.js";
3
3
  import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
4
- import { selectorChartsKeyboardItem, selectorChartsKeyboardItemIsDefined } from "../useChartKeyboardNavigation/index.js";
4
+ import { selectorChartsKeyboardItem, selectorChartsHasFocusedItem } from "../useChartKeyboardNavigation/index.js";
5
5
  import { selectorChartsLastInteraction } from "../useChartInteraction/useChartInteraction.selectors.js";
6
6
  import { selectorChartDrawingArea } from "../../corePlugins/useChartDimensions/useChartDimensions.selectors.js";
7
7
  import { isCartesianSeries } from "../../../isCartesian.js";
@@ -10,7 +10,7 @@ const selectTooltip = state => state.tooltip;
10
10
  export const selectorChartsTooltipPointerItem = createSelector(selectTooltip, tooltip => tooltip?.item ?? null);
11
11
  export const selectorChartsTooltipPointerItemIsDefined = createSelector(selectorChartsTooltipPointerItem, item => item !== null);
12
12
  export const selectorChartsTooltipItem = createSelector(selectorChartsLastInteraction, selectorChartsTooltipPointerItem, selectorChartsKeyboardItem, (lastInteraction, pointerItem, keyboardItem) => lastInteraction === 'keyboard' ? keyboardItem : pointerItem ?? null);
13
- export const selectorChartsTooltipItemIsDefined = createSelector(selectorChartsLastInteraction, selectorChartsTooltipPointerItemIsDefined, selectorChartsKeyboardItemIsDefined, (lastInteraction, pointerItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : pointerItemIsDefined);
13
+ export const selectorChartsTooltipItemIsDefined = createSelector(selectorChartsLastInteraction, selectorChartsTooltipPointerItemIsDefined, selectorChartsHasFocusedItem, (lastInteraction, pointerItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : pointerItemIsDefined);
14
14
  const selectorChartsTooltipAxisConfig = createSelectorMemoized(selectorChartsTooltipItem, selectorChartXAxis, selectorChartYAxis, selectorChartRotationAxis, selectorChartRadiusAxis, selectorChartSeriesProcessed, function selectorChartsTooltipAxisConfig(identifier, {
15
15
  axis: xAxis,
16
16
  axisIds: xAxisIds
@@ -1,26 +1,27 @@
1
1
  import type { ChartPluginSignature } from "../../models/index.js";
2
- import type { ChartItemIdentifier, ChartSeriesType } from "../../../../models/seriesType/config.js";
2
+ import type { SeriesItemIdentifier } from "../../../../models/seriesType/index.js";
3
+ import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
3
4
  export interface UseChartTooltipInstance {
4
5
  /**
5
6
  * Setter for the item the user is pointing at.
6
- * @param {ChartItemIdentifier} newItem The identifier of the item.
7
+ * @param {SeriesItemIdentifier} newItem The identifier of the item.
7
8
  */
8
- setTooltipItem: (newItem: ChartItemIdentifier<ChartSeriesType>) => void;
9
+ setTooltipItem: (newItem: SeriesItemIdentifier<ChartSeriesType>) => void;
9
10
  /**
10
11
  * Remove the item the user was pointing at.
11
12
  * - If `itemToRemove` is provided, it removes the item only if it matches the current one.
12
13
  * Otherwise it assumes the item got already updated and does nothing.
13
14
  * - If `itemToRemove` is not provided, it removes the current item unconditionally.
14
- * @param {ChartItemIdentifier} itemToRemove The identifier of the item.
15
+ * @param {SeriesItemIdentifier} itemToRemove The identifier of the item.
15
16
  */
16
- removeTooltipItem: (itemToRemove?: ChartItemIdentifier<ChartSeriesType>) => void;
17
+ removeTooltipItem: (itemToRemove?: SeriesItemIdentifier<ChartSeriesType>) => void;
17
18
  }
18
19
  export interface UseChartTooltipState {
19
20
  tooltip: {
20
21
  /**
21
22
  * The item currently under the pointer.
22
23
  */
23
- item: null | ChartItemIdentifier<ChartSeriesType>;
24
+ item: null | SeriesItemIdentifier<ChartSeriesType>;
24
25
  };
25
26
  }
26
27
  export type UseChartTooltipSignature = ChartPluginSignature<{
@@ -8,6 +8,7 @@ import { type PolarExtremumGetter } from "./polarExtremumGetter.types.js";
8
8
  import { type GetSeriesWithDefaultValues } from "./getSeriesWithDefaultValues.types.js";
9
9
  import { type TooltipItemPositionGetter } from "./tooltipItemPositionGetter.types.js";
10
10
  import { type SeriesLayoutGetter } from "./seriesLayout.types.js";
11
+ import { type KeyboardFocusHandler } from "../../featurePlugins/useChartKeyboardNavigation/keyboardFocusHandler.types.js";
11
12
  export type ChartSeriesTypeConfig<TSeriesType extends ChartSeriesType> = {
12
13
  seriesProcessor: SeriesProcessor<TSeriesType>;
13
14
  /**
@@ -19,6 +20,7 @@ export type ChartSeriesTypeConfig<TSeriesType extends ChartSeriesType> = {
19
20
  tooltipGetter: TooltipGetter<TSeriesType>;
20
21
  tooltipItemPositionGetter?: TooltipItemPositionGetter<TSeriesType>;
21
22
  getSeriesWithDefaultValues: GetSeriesWithDefaultValues<TSeriesType>;
23
+ keyboardFocusHandler?: KeyboardFocusHandler<TSeriesType>;
22
24
  } & (TSeriesType extends CartesianChartSeriesType ? {
23
25
  xExtremumGetter: CartesianExtremumGetter<TSeriesType>;
24
26
  yExtremumGetter: CartesianExtremumGetter<TSeriesType>;
@@ -1,6 +1,6 @@
1
1
  import type { ChartSeriesDefaultized, ChartSeriesType, ChartsSeriesConfig, DatasetType } from "../../../../models/seriesType/config.js";
2
2
  import type { SeriesId } from "../../../../models/seriesType/common.js";
3
- import type { StackingGroupsType } from "../../../stackSeries.js";
3
+ import type { StackingGroupsType } from "../../../stacking/index.js";
4
4
  export type SeriesProcessorParams<TSeriesType extends ChartSeriesType> = {
5
5
  series: Record<SeriesId, ChartsSeriesConfig[TSeriesType]['seriesInput']>;
6
6
  seriesOrder: SeriesId[];
@@ -1,4 +1,5 @@
1
- import type { ChartItemIdentifier, ChartSeriesDefaultized, ChartSeriesType, ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
1
+ import type { SeriesItemIdentifier } from "../../../../models/seriesType/index.js";
2
+ import type { ChartSeriesDefaultized, ChartSeriesType, ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
2
3
  import { type SeriesId } from "../../../../models/seriesType/common.js";
3
4
  import { type AxisId, type ChartsRotationAxisProps, type ChartsRadiusAxisProps, type PolarAxisDefaultized, type ComputedXAxis, type ComputedYAxis } from "../../../../models/axis.js";
4
5
  import { type ChartsLabelMarkProps } from "../../../../ChartsLabel/ChartsLabelMark.js";
@@ -7,7 +8,7 @@ export interface ItemTooltip<T extends ChartSeriesType> {
7
8
  /**
8
9
  * An object that identifies the item to display.
9
10
  */
10
- identifier: ChartItemIdentifier<T>;
11
+ identifier: SeriesItemIdentifier<T>;
11
12
  /**
12
13
  * The color associated with the item.
13
14
  */
@@ -59,7 +60,7 @@ export type TooltipGetter<TSeriesType extends ChartSeriesType> = (params: {
59
60
  series: ChartSeriesDefaultized<TSeriesType>;
60
61
  axesConfig: TooltipGetterAxesConfig;
61
62
  getColor: ColorGetter<TSeriesType>;
62
- identifier: ChartItemIdentifier<TSeriesType> | null;
63
+ identifier: SeriesItemIdentifier<TSeriesType> | null;
63
64
  }) => (TSeriesType extends 'radar' ? ItemTooltipWithMultipleValues<TSeriesType> : ItemTooltip<TSeriesType>) | null;
64
65
  /**
65
66
  * If `axisId` is set to undefined, the default axis will be used.
@@ -1,4 +1,5 @@
1
- import type { ChartItemIdentifier, ChartSeriesType } from "../../../../models/seriesType/config.js";
1
+ import type { SeriesItemIdentifier } from "../../../../models/seriesType/index.js";
2
+ import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
2
3
  import { type ChartsRotationAxisProps, type ChartsRadiusAxisProps, type ComputedXAxis, type ComputedYAxis } from "../../../../models/axis.js";
3
4
  import { type ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
4
5
  import { type ProcessedSeries, type SeriesLayout } from "../../corePlugins/useChartSeries/index.js";
@@ -13,7 +14,7 @@ export type TooltipItemPositionGetter<TSeriesType extends ChartSeriesType> = (pa
13
14
  series: ProcessedSeries<TSeriesType>;
14
15
  axesConfig: TooltipPositionGetterAxesConfig;
15
16
  drawingArea: ChartDrawingArea;
16
- identifier: ChartItemIdentifier<TSeriesType> | null;
17
+ identifier: SeriesItemIdentifier<TSeriesType> | null;
17
18
  seriesLayout: SeriesLayout<TSeriesType>;
18
19
  /**
19
20
  * The preferred placement of the tooltip related to the element.
@@ -0,0 +1,4 @@
1
+ import type { SeriesId } from "../models/seriesType/common.js";
2
+ import type { ChartSeriesType, ChartsSeriesConfig } from "../models/seriesType/config.js";
3
+ import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index.js";
4
+ export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean;
@@ -0,0 +1,8 @@
1
+ export function seriesHasData(series, type, seriesId) {
2
+ // @ts-ignore sankey is not in MIT version
3
+ if (type === 'sankey') {
4
+ return false;
5
+ }
6
+ const data = series[type]?.series[seriesId]?.data;
7
+ return data != null && data.length > 0;
8
+ }
@@ -2,7 +2,6 @@ import { warnOnce } from '@mui/x-internals/warning';
2
2
  import { createSelector, createSelectorMemoized } from '@mui/x-internals/store';
3
3
  import { selectorChartSeriesProcessed } from "./plugins/corePlugins/useChartSeries/useChartSeries.selectors.js";
4
4
  import { useStore } from "./store/useStore.js";
5
- import { useSelector } from "./store/useSelector.js";
6
5
  export const selectorAllSeriesOfType = createSelector(selectorChartSeriesProcessed, (processedSeries, seriesType) => processedSeries[seriesType]);
7
6
  export const selectorSeriesOfType = createSelectorMemoized(selectorChartSeriesProcessed, (processedSeries, seriesType, ids) => {
8
7
  if (ids === undefined || Array.isArray(ids) && ids.length === 0) {
@@ -30,9 +29,9 @@ export const selectorSeriesOfType = createSelectorMemoized(selectorChartSeriesPr
30
29
  });
31
30
  export const useAllSeriesOfType = seriesType => {
32
31
  const store = useStore();
33
- return useSelector(store, selectorAllSeriesOfType, seriesType);
32
+ return store.use(selectorAllSeriesOfType, seriesType);
34
33
  };
35
34
  export const useSeriesOfType = (seriesType, seriesId) => {
36
35
  const store = useStore();
37
- return useSelector(store, selectorSeriesOfType, seriesType, seriesId);
36
+ return store.use(selectorSeriesOfType, seriesType, seriesId);
38
37
  };
@@ -0,0 +1 @@
1
+ export * from "./stackSeries.js";
@@ -0,0 +1 @@
1
+ export * from "./stackSeries.js";
@@ -0,0 +1 @@
1
+ export * from "./offsetDiverging.js";
@@ -0,0 +1 @@
1
+ export * from "./offsetDiverging.js";
@@ -0,0 +1,8 @@
1
+ import type { Series } from '@mui/x-charts-vendor/d3-shape';
2
+ /**
3
+ * Positive values are stacked above zero, while negative values are stacked below zero.
4
+ *
5
+ * @param series A series generated by a stack generator.
6
+ * @param order An array of numeric indexes representing the stack order.
7
+ */
8
+ export declare function offsetDiverging(series: Series<any, any>[], order: Iterable<number>): void;
@@ -0,0 +1,47 @@
1
+ // Adapted from D3.js's offsetDiverging function https://github.com/d3/d3-shape/blob/main/src/offset/diverging.js
2
+ // Hidden series (with all zero values) affect the stacking in a different way in our implementation compared to the D3 behavior.
3
+ // The D3 stacking keep those values at the 0 "line", which creates issues when animating between hidden and visible states.
4
+ // In our modification, we stack them on top/below already stacked items according to the sign of their original value.
5
+ // A hidden negative value will be placed below all the already stacked negative values
6
+
7
+ /**
8
+ * Positive values are stacked above zero, while negative values are stacked below zero.
9
+ *
10
+ * @param series A series generated by a stack generator.
11
+ * @param order An array of numeric indexes representing the stack order.
12
+ */
13
+ export function offsetDiverging(series, order) {
14
+ if (series.length === 0) {
15
+ return;
16
+ }
17
+ const seriesCount = series.length;
18
+ const numericOrder = order;
19
+ const pointCount = series[numericOrder[0]].length;
20
+ for (let pointIndex = 0; pointIndex < pointCount; pointIndex += 1) {
21
+ let positiveSum = 0;
22
+ let negativeSum = 0;
23
+ for (let seriesIndex = 0; seriesIndex < seriesCount; seriesIndex += 1) {
24
+ const currentSeries = series[numericOrder[seriesIndex]];
25
+ const dataPoint = currentSeries[pointIndex];
26
+ const difference = dataPoint[1] - dataPoint[0];
27
+ if (difference > 0) {
28
+ dataPoint[0] = positiveSum;
29
+ positiveSum += difference;
30
+ dataPoint[1] = positiveSum;
31
+ } else if (difference < 0) {
32
+ dataPoint[1] = negativeSum;
33
+ negativeSum += difference;
34
+ dataPoint[0] = negativeSum;
35
+ } else if (dataPoint.data[currentSeries.key] > 0) {
36
+ dataPoint[0] = positiveSum;
37
+ dataPoint[1] = positiveSum;
38
+ } else if (dataPoint.data[currentSeries.key] < 0) {
39
+ dataPoint[1] = negativeSum;
40
+ dataPoint[0] = negativeSum;
41
+ } else {
42
+ dataPoint[0] = 0;
43
+ dataPoint[1] = 0;
44
+ }
45
+ }
46
+ }
47
+ }
@@ -1,6 +1,6 @@
1
- import { 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
  * */
@@ -1,21 +1,22 @@
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 } from '@mui/x-charts-vendor/d3-shape';
1
+ import { stackOrderNone as d3StackOrderNone, stackOrderReverse as d3StackOrderReverse, stackOrderAppearance as d3OrderAppearance, stackOrderAscending as d3OrderAscending, stackOrderDescending as d3OrderDescending, stackOrderInsideOut as d3OrderInsideOut, stackOffsetExpand as d3StackOffsetExpand, stackOffsetNone as d3StackOffsetNone, stackOffsetSilhouette as d3StackOffsetSilhouette, stackOffsetWiggle as d3StackOffsetWiggle } from '@mui/x-charts-vendor/d3-shape';
2
+ import { offsetDiverging } from "./offset/index.js";
2
3
  export const StackOrder = {
3
4
  /**
4
5
  * Series order such that the earliest series (according to the maximum value) is at the bottom.
5
6
  * */
6
- appearance: d3StackOrderAppearance,
7
+ appearance: d3OrderAppearance,
7
8
  /**
8
9
  * Series order such that the smallest series (according to the sum of values) is at the bottom.
9
10
  * */
10
- ascending: d3StackOrderAscending,
11
+ ascending: d3OrderAscending,
11
12
  /**
12
13
  * Series order such that the largest series (according to the sum of values) is at the bottom.
13
14
  */
14
- descending: d3StackOrderDescending,
15
+ descending: d3OrderDescending,
15
16
  /**
16
17
  * Series order such that the earliest series (according to the maximum value) are on the inside and the later series are on the outside. This order is recommended for streamgraphs in conjunction with the wiggle offset. See Stacked Graphs—Geometry & Aesthetics by Byron & Wattenberg for more information.
17
18
  */
18
- insideOut: d3StackOrderInsideOut,
19
+ insideOut: d3OrderInsideOut,
19
20
  /**
20
21
  * Given series order [0, 1, … n - 1] where n is the number of elements in series. Thus, the stack order is given by the key accessor.
21
22
  */
@@ -33,7 +34,8 @@ export const StackOffset = {
33
34
  /**
34
35
  * Positive values are stacked above zero, negative values are stacked below zero, and zero values are stacked at zero.
35
36
  * */
36
- diverging: d3StackOffsetDiverging,
37
+ // @ts-expect-error, d3 types are wrong, our custom function implements the correct signature
38
+ diverging: offsetDiverging,
37
39
  /**
38
40
  * Applies a zero baseline.
39
41
  * */
@@ -90,8 +90,6 @@ export type ChartSeriesDefaultized<T extends ChartSeriesType> = ChartsSeriesConf
90
90
  stackedData: [number, number][];
91
91
  } : ChartsSeriesConfig[T]['series'];
92
92
  export type ChartSeriesLayout<T extends ChartSeriesType> = ChartsSeriesConfig[T] extends any ? ChartsSeriesConfig[T]['seriesLayout'] : never;
93
- export type ChartItemIdentifier<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifier'];
94
- export type ChartItemIdentifierWithData<T extends ChartSeriesType> = ChartsSeriesConfig[T]['itemIdentifierWithData'];
95
93
  export type DatasetElementType<T> = {
96
94
  [key: string]: T;
97
95
  };
@@ -1,4 +1,5 @@
1
- import { 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";