@mui/x-charts 8.23.0 → 8.24.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 (262) hide show
  1. package/BarChart/BarChart.js +39 -0
  2. package/BarChart/BarChart.plugins.d.ts +2 -1
  3. package/BarChart/BarChart.plugins.js +2 -1
  4. package/BarChart/BarLabel/BarLabel.d.ts +2 -0
  5. package/BarChart/BarLabel/BarLabel.js +8 -3
  6. package/BarChart/BarLabel/BarLabelItem.d.ts +2 -0
  7. package/BarChart/BarLabel/BarLabelItem.js +4 -2
  8. package/BarChart/BarPlot.d.ts +12 -2
  9. package/BarChart/BarPlot.js +29 -86
  10. package/BarChart/BatchBarPlot/BarGroup.d.ts +15 -0
  11. package/BarChart/BatchBarPlot/BarGroup.js +142 -0
  12. package/BarChart/BatchBarPlot/BatchBarPlot.d.ts +12 -0
  13. package/BarChart/BatchBarPlot/BatchBarPlot.js +140 -0
  14. package/BarChart/BatchBarPlot/index.d.ts +1 -0
  15. package/BarChart/BatchBarPlot/index.js +12 -0
  16. package/BarChart/BatchBarPlot/useCreateBarPaths.d.ts +8 -0
  17. package/BarChart/BatchBarPlot/useCreateBarPaths.js +53 -0
  18. package/BarChart/FocusedBar.js +5 -1
  19. package/BarChart/IndividualBarPlot.d.ts +21 -0
  20. package/BarChart/IndividualBarPlot.js +106 -0
  21. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +1 -1
  22. package/BarChart/seriesConfig/bar/legend.js +1 -0
  23. package/BarChart/seriesConfig/index.js +3 -1
  24. package/BarChart/types.d.ts +2 -0
  25. package/BarChart/useBarChartProps.d.ts +6 -2
  26. package/BarChart/useBarChartProps.js +4 -2
  27. package/BarChart/useBarPlotData.d.ts +1 -1
  28. package/BarChart/useBarPlotData.js +23 -4
  29. package/BarChart/useRegisterItemClickHandlers.d.ts +6 -0
  30. package/BarChart/useRegisterItemClickHandlers.js +72 -0
  31. package/CHANGELOG.md +111 -1
  32. package/ChartContainer/ChartContainer.js +34 -0
  33. package/ChartContainer/useChartContainerProps.js +6 -2
  34. package/ChartsLegend/ChartsLegend.js +2 -2
  35. package/ChartsLegend/legendContext.types.d.ts +12 -0
  36. package/ChartsLegend/onClickContextBuilder.js +2 -1
  37. package/ChartsOverlay/ChartsLoadingOverlay.js +4 -1
  38. package/ChartsOverlay/ChartsNoDataOverlay.js +4 -1
  39. package/ChartsReferenceLine/common.d.ts +1 -1
  40. package/ChartsReferenceLine/common.js +4 -1
  41. package/ChartsTooltip/ChartsTooltipContainer.js +25 -21
  42. package/Gauge/GaugeContainer.js +4 -1
  43. package/LineChart/AnimatedLine.js +7 -3
  44. package/LineChart/AppearingMask.js +4 -1
  45. package/LineChart/CircleMarkElement.d.ts +5 -0
  46. package/LineChart/CircleMarkElement.js +13 -5
  47. package/LineChart/FocusedLineMark.js +5 -1
  48. package/LineChart/LineChart.js +30 -0
  49. package/LineChart/LineChart.plugins.d.ts +2 -1
  50. package/LineChart/LineChart.plugins.js +2 -1
  51. package/LineChart/LineElement.d.ts +4 -0
  52. package/LineChart/LineElement.js +7 -3
  53. package/LineChart/MarkElement.d.ts +5 -0
  54. package/LineChart/MarkElement.js +17 -10
  55. package/LineChart/markElementClasses.d.ts +0 -1
  56. package/LineChart/seriesConfig/index.js +3 -1
  57. package/LineChart/seriesConfig/legend.js +1 -0
  58. package/PieChart/FocusedPieArc.js +5 -2
  59. package/PieChart/PieArcLabel.d.ts +2 -0
  60. package/PieChart/PieArcLabel.js +5 -2
  61. package/PieChart/PieChart.js +35 -5
  62. package/PieChart/PieChart.plugins.d.ts +2 -1
  63. package/PieChart/PieChart.plugins.js +2 -1
  64. package/PieChart/seriesConfig/index.js +3 -1
  65. package/PieChart/seriesConfig/legend.js +6 -3
  66. package/RadarChart/RadarChart.js +30 -0
  67. package/RadarChart/RadarChart.plugins.d.ts +3 -2
  68. package/RadarChart/RadarChart.plugins.js +2 -1
  69. package/RadarChart/seriesConfig/index.js +3 -1
  70. package/RadarChart/seriesConfig/legend.js +1 -0
  71. package/ScatterChart/BatchScatter.js +8 -14
  72. package/ScatterChart/ScatterChart.js +30 -0
  73. package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  74. package/ScatterChart/ScatterChart.plugins.js +2 -1
  75. package/ScatterChart/seriesConfig/index.js +3 -1
  76. package/ScatterChart/seriesConfig/legend.js +1 -0
  77. package/SparkLineChart/SparkLineChart.js +46 -0
  78. package/esm/BarChart/BarChart.js +39 -0
  79. package/esm/BarChart/BarChart.plugins.d.ts +2 -1
  80. package/esm/BarChart/BarChart.plugins.js +2 -1
  81. package/esm/BarChart/BarLabel/BarLabel.d.ts +2 -0
  82. package/esm/BarChart/BarLabel/BarLabel.js +8 -3
  83. package/esm/BarChart/BarLabel/BarLabelItem.d.ts +2 -0
  84. package/esm/BarChart/BarLabel/BarLabelItem.js +4 -2
  85. package/esm/BarChart/BarPlot.d.ts +12 -2
  86. package/esm/BarChart/BarPlot.js +29 -86
  87. package/esm/BarChart/BatchBarPlot/BarGroup.d.ts +15 -0
  88. package/esm/BarChart/BatchBarPlot/BarGroup.js +134 -0
  89. package/esm/BarChart/BatchBarPlot/BatchBarPlot.d.ts +12 -0
  90. package/esm/BarChart/BatchBarPlot/BatchBarPlot.js +133 -0
  91. package/esm/BarChart/BatchBarPlot/index.d.ts +1 -0
  92. package/esm/BarChart/BatchBarPlot/index.js +1 -0
  93. package/esm/BarChart/BatchBarPlot/useCreateBarPaths.d.ts +8 -0
  94. package/esm/BarChart/BatchBarPlot/useCreateBarPaths.js +46 -0
  95. package/esm/BarChart/FocusedBar.js +5 -1
  96. package/esm/BarChart/IndividualBarPlot.d.ts +21 -0
  97. package/esm/BarChart/IndividualBarPlot.js +98 -0
  98. package/esm/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +1 -1
  99. package/esm/BarChart/seriesConfig/bar/legend.js +1 -0
  100. package/esm/BarChart/seriesConfig/index.js +3 -1
  101. package/esm/BarChart/types.d.ts +2 -0
  102. package/esm/BarChart/useBarChartProps.d.ts +6 -2
  103. package/esm/BarChart/useBarChartProps.js +4 -3
  104. package/esm/BarChart/useBarPlotData.d.ts +1 -1
  105. package/esm/BarChart/useBarPlotData.js +20 -1
  106. package/esm/BarChart/useRegisterItemClickHandlers.d.ts +6 -0
  107. package/esm/BarChart/useRegisterItemClickHandlers.js +67 -0
  108. package/esm/ChartContainer/ChartContainer.js +34 -0
  109. package/esm/ChartContainer/useChartContainerProps.js +6 -2
  110. package/esm/ChartsLegend/ChartsLegend.js +2 -2
  111. package/esm/ChartsLegend/legendContext.types.d.ts +12 -0
  112. package/esm/ChartsLegend/onClickContextBuilder.js +2 -1
  113. package/esm/ChartsOverlay/ChartsLoadingOverlay.js +4 -1
  114. package/esm/ChartsOverlay/ChartsNoDataOverlay.js +4 -1
  115. package/esm/ChartsReferenceLine/common.d.ts +1 -1
  116. package/esm/ChartsReferenceLine/common.js +4 -1
  117. package/esm/ChartsTooltip/ChartsTooltipContainer.js +26 -22
  118. package/esm/Gauge/GaugeContainer.js +4 -1
  119. package/esm/LineChart/AnimatedLine.js +7 -3
  120. package/esm/LineChart/AppearingMask.js +4 -1
  121. package/esm/LineChart/CircleMarkElement.d.ts +5 -0
  122. package/esm/LineChart/CircleMarkElement.js +13 -5
  123. package/esm/LineChart/FocusedLineMark.js +5 -1
  124. package/esm/LineChart/LineChart.js +30 -0
  125. package/esm/LineChart/LineChart.plugins.d.ts +2 -1
  126. package/esm/LineChart/LineChart.plugins.js +2 -1
  127. package/esm/LineChart/LineElement.d.ts +4 -0
  128. package/esm/LineChart/LineElement.js +7 -3
  129. package/esm/LineChart/MarkElement.d.ts +5 -0
  130. package/esm/LineChart/MarkElement.js +17 -10
  131. package/esm/LineChart/markElementClasses.d.ts +0 -1
  132. package/esm/LineChart/seriesConfig/index.js +3 -1
  133. package/esm/LineChart/seriesConfig/legend.js +1 -0
  134. package/esm/PieChart/FocusedPieArc.js +4 -1
  135. package/esm/PieChart/PieArcLabel.d.ts +2 -0
  136. package/esm/PieChart/PieArcLabel.js +5 -2
  137. package/esm/PieChart/PieChart.js +35 -5
  138. package/esm/PieChart/PieChart.plugins.d.ts +2 -1
  139. package/esm/PieChart/PieChart.plugins.js +2 -1
  140. package/esm/PieChart/seriesConfig/index.js +3 -1
  141. package/esm/PieChart/seriesConfig/legend.js +6 -3
  142. package/esm/RadarChart/RadarChart.js +30 -0
  143. package/esm/RadarChart/RadarChart.plugins.d.ts +3 -2
  144. package/esm/RadarChart/RadarChart.plugins.js +2 -1
  145. package/esm/RadarChart/seriesConfig/index.js +3 -1
  146. package/esm/RadarChart/seriesConfig/legend.js +1 -0
  147. package/esm/ScatterChart/BatchScatter.js +5 -11
  148. package/esm/ScatterChart/ScatterChart.js +30 -0
  149. package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  150. package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
  151. package/esm/ScatterChart/seriesConfig/index.js +3 -1
  152. package/esm/ScatterChart/seriesConfig/legend.js +1 -0
  153. package/esm/SparkLineChart/SparkLineChart.js +46 -0
  154. package/esm/index.js +1 -1
  155. package/esm/internals/appendAtKey.d.ts +8 -0
  156. package/esm/internals/appendAtKey.js +17 -0
  157. package/esm/internals/commonNextFocusItem.js +12 -8
  158. package/esm/internals/getBarDimensions.d.ts +1 -2
  159. package/esm/internals/identifierSerializer.d.ts +9 -0
  160. package/esm/internals/identifierSerializer.js +6 -0
  161. package/esm/internals/index.d.ts +6 -2
  162. package/esm/internals/index.js +6 -2
  163. package/esm/internals/invertScale.d.ts +6 -2
  164. package/esm/internals/invertScale.js +9 -1
  165. package/esm/internals/plugins/allPlugins.d.ts +4 -3
  166. package/esm/internals/plugins/allPlugins.js +2 -1
  167. package/esm/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.d.ts +14 -0
  168. package/esm/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.js +18 -0
  169. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +8 -1
  170. package/esm/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +12 -1
  171. package/esm/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +11 -0
  172. package/esm/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +74 -0
  173. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +20 -3
  174. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -3
  175. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +4 -0
  176. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +83 -0
  177. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.d.ts +3 -0
  178. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +6 -0
  179. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +7 -34
  180. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.d.ts +7 -0
  181. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +9 -0
  182. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +10 -32
  183. package/esm/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
  184. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/index.d.ts +3 -0
  185. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/index.js +3 -0
  186. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.d.ts +4 -0
  187. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.js +5 -0
  188. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.d.ts +3 -0
  189. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.js +78 -0
  190. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.d.ts +16 -0
  191. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.js +19 -0
  192. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.d.ts +90 -0
  193. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.js +1 -0
  194. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.d.ts +4 -0
  195. package/esm/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.js +11 -0
  196. package/esm/internals/plugins/models/seriesConfig/identifierSerializer.types.d.ts +2 -0
  197. package/esm/internals/plugins/models/seriesConfig/identifierSerializer.types.js +1 -0
  198. package/esm/internals/plugins/models/seriesConfig/index.d.ts +2 -1
  199. package/esm/internals/plugins/models/seriesConfig/index.js +2 -1
  200. package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +7 -0
  201. package/esm/models/axis.d.ts +5 -4
  202. package/esm/models/featureFlags.d.ts +1 -0
  203. package/esm/models/featureFlags.js +1 -0
  204. package/esm/models/index.d.ts +1 -0
  205. package/esm/models/index.js +1 -0
  206. package/esm/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +13 -0
  207. package/esm/moduleAugmentation/barChartBatchRendererOnItemClick.js +1 -0
  208. package/index.js +1 -1
  209. package/internals/appendAtKey.d.ts +8 -0
  210. package/internals/appendAtKey.js +23 -0
  211. package/internals/commonNextFocusItem.js +12 -8
  212. package/internals/getBarDimensions.d.ts +1 -2
  213. package/internals/identifierSerializer.d.ts +9 -0
  214. package/internals/identifierSerializer.js +16 -0
  215. package/internals/index.d.ts +6 -2
  216. package/internals/index.js +51 -7
  217. package/internals/invertScale.d.ts +6 -2
  218. package/internals/invertScale.js +10 -1
  219. package/internals/plugins/allPlugins.d.ts +4 -3
  220. package/internals/plugins/allPlugins.js +2 -1
  221. package/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.d.ts +14 -0
  222. package/internals/plugins/corePlugins/useChartSeries/serializeIdentifier.js +25 -0
  223. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.js +8 -1
  224. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.types.d.ts +12 -1
  225. package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.d.ts +11 -0
  226. package/internals/plugins/featurePlugins/shared/useRegisterPointerInteractions.js +81 -0
  227. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +20 -3
  228. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +10 -3
  229. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.d.ts +4 -0
  230. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPosition.selectors.js +89 -0
  231. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.d.ts +3 -0
  232. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getMaxSeriesLength.js +12 -0
  233. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNextNonEmptySeries.js +6 -34
  234. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.d.ts +7 -0
  235. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getNonEmptySeriesArray.js +15 -0
  236. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/utils/getPreviousNonEmptySeries.js +9 -32
  237. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +2 -2
  238. package/internals/plugins/featurePlugins/useChartVisibilityManager/index.d.ts +3 -0
  239. package/internals/plugins/featurePlugins/useChartVisibilityManager/index.js +39 -0
  240. package/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.d.ts +4 -0
  241. package/internals/plugins/featurePlugins/useChartVisibilityManager/isIdentifierVisible.js +12 -0
  242. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.d.ts +3 -0
  243. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.js +85 -0
  244. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.d.ts +16 -0
  245. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.selectors.js +25 -0
  246. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.d.ts +90 -0
  247. package/internals/plugins/featurePlugins/useChartVisibilityManager/useChartVisibilityManager.types.js +5 -0
  248. package/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.d.ts +4 -0
  249. package/internals/plugins/featurePlugins/useChartVisibilityManager/visibilityParamToMap.js +18 -0
  250. package/internals/plugins/models/seriesConfig/identifierSerializer.types.d.ts +2 -0
  251. package/internals/plugins/models/seriesConfig/identifierSerializer.types.js +5 -0
  252. package/internals/plugins/models/seriesConfig/index.d.ts +2 -1
  253. package/internals/plugins/models/seriesConfig/index.js +11 -0
  254. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +7 -0
  255. package/models/axis.d.ts +5 -4
  256. package/models/featureFlags.d.ts +1 -0
  257. package/models/featureFlags.js +5 -0
  258. package/models/index.d.ts +1 -0
  259. package/models/index.js +11 -0
  260. package/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +13 -0
  261. package/moduleAugmentation/barChartBatchRendererOnItemClick.js +5 -0
  262. package/package.json +13 -3
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.serializeIdentifier = void 0;
7
+ /**
8
+ * Serializes a series item identifier into a unique string using the appropriate serializer
9
+ * from the provided series configuration.
10
+ *
11
+ * @param {ChartSeriesConfig<ChartSeriesType>} seriesConfig - The configuration object for chart series.
12
+ * @param {SeriesItemIdentifier<ChartSeriesType>} identifier - The series item identifier to serialize.
13
+ * @returns {string} A unique string representation of the identifier.
14
+ * @throws Will throw an error if no serializer is found for the given series type.
15
+ */
16
+ const serializeIdentifier = (seriesConfig, identifier) => {
17
+ const serializer = seriesConfig[identifier.type]?.identifierSerializer;
18
+ if (!serializer) {
19
+ throw new Error(`MUI X Charts: No identifier serializer found for series type "${identifier.type}".`);
20
+ }
21
+ // @ts-expect-error identifierSerializer expects the full object,
22
+ // but this function accepts a partial one in order be able to serialize all identifiers.
23
+ return serializer(identifier);
24
+ };
25
+ exports.serializeIdentifier = serializeIdentifier;
@@ -8,8 +8,10 @@ Object.defineProperty(exports, "__esModule", {
8
8
  exports.useChartSeries = void 0;
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _useEffectAfterFirstRender = require("@mui/x-internals/useEffectAfterFirstRender");
11
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
11
12
  var _colorPalettes = require("../../../../colorPalettes");
12
13
  var _processSeries = require("./processSeries");
14
+ var _serializeIdentifier = require("./serializeIdentifier");
13
15
  const useChartSeries = ({
14
16
  params,
15
17
  store,
@@ -34,7 +36,12 @@ const useChartSeries = ({
34
36
  dataset
35
37
  }));
36
38
  }, [colors, dataset, series, theme, seriesConfig, store]);
37
- return {};
39
+ const serializeIdentifier = (0, _useEventCallback.default)(identifier => (0, _serializeIdentifier.serializeIdentifier)(seriesConfig, identifier));
40
+ return {
41
+ instance: {
42
+ serializeIdentifier
43
+ }
44
+ };
38
45
  };
39
46
  exports.useChartSeries = useChartSeries;
40
47
  useChartSeries.params = {
@@ -45,7 +45,18 @@ export interface UseChartSeriesState<T extends ChartSeriesType = ChartSeriesType
45
45
  dataset?: Readonly<DatasetType>;
46
46
  };
47
47
  }
48
- export interface UseChartSeriesInstance {}
48
+ export type SerializeIdentifierFunction = <T extends {
49
+ type: ChartSeriesType;
50
+ }>(identifier: T) => string;
51
+ export interface UseChartSeriesInstance {
52
+ /**
53
+ * Function to serialize a series item identifier into a unique string.
54
+ *
55
+ * @param identifier The identifier to serialize.
56
+ * @returns A unique string representing the identifier.
57
+ */
58
+ serializeIdentifier: SerializeIdentifierFunction;
59
+ }
49
60
  export type UseChartSeriesSignature<SeriesType extends ChartSeriesType = ChartSeriesType> = ChartPluginSignature<{
50
61
  params: UseChartSeriesParameters;
51
62
  defaultizedParams: UseChartSeriesDefaultizedParameters<SeriesType>;
@@ -0,0 +1,11 @@
1
+ import { type SeriesItemIdentifier } from "../../../../models/seriesType/index.js";
2
+ import { type UseChartHighlightSignature } from "../useChartHighlight/index.js";
3
+ import { type UseChartCartesianAxisSignature } from "../useChartCartesianAxis/index.js";
4
+ import { type ChartState } from "../../models/index.js";
5
+ /**
6
+ * Hook to get pointer interaction props for chart items.
7
+ */
8
+ export declare function useRegisterPointerInteractions(getItemAtPosition: (state: ChartState<[UseChartCartesianAxisSignature, UseChartHighlightSignature]>, point: {
9
+ x: number;
10
+ y: number;
11
+ }) => SeriesItemIdentifier | undefined, onItemEnter?: () => void, onItemLeave?: () => void): void;
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
5
+ var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
6
+ Object.defineProperty(exports, "__esModule", {
7
+ value: true
8
+ });
9
+ exports.useRegisterPointerInteractions = useRegisterPointerInteractions;
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
12
+ var _hooks = require("../../../../hooks");
13
+ var _useStore = require("../../../store/useStore");
14
+ var _ChartProvider = require("../../../../context/ChartProvider");
15
+ var _getSVGPoint = require("../../../getSVGPoint");
16
+ /**
17
+ * Hook to get pointer interaction props for chart items.
18
+ */
19
+ function useRegisterPointerInteractions(getItemAtPosition, onItemEnter, onItemLeave) {
20
+ const {
21
+ instance
22
+ } = (0, _ChartProvider.useChartContext)();
23
+ const svgRef = (0, _hooks.useSvgRef)();
24
+ const store = (0, _useStore.useStore)();
25
+ const interactionActive = React.useRef(false);
26
+ const lastItemRef = React.useRef(undefined);
27
+ const onItemEnterRef = (0, _useEventCallback.default)(() => onItemEnter?.());
28
+ const onItemLeaveRef = (0, _useEventCallback.default)(() => onItemLeave?.());
29
+ React.useEffect(() => {
30
+ const svg = svgRef.current;
31
+ if (!svg) {
32
+ return undefined;
33
+ }
34
+ function onPointerEnter() {
35
+ interactionActive.current = true;
36
+ }
37
+ function reset() {
38
+ const lastItem = lastItemRef.current;
39
+ if (lastItem) {
40
+ lastItemRef.current = undefined;
41
+ instance.removeTooltipItem(lastItem);
42
+ instance.clearHighlight();
43
+ onItemLeaveRef();
44
+ }
45
+ }
46
+ function onPointerLeave() {
47
+ interactionActive.current = false;
48
+ reset();
49
+ }
50
+ const onPointerMove = function onPointerMove(event) {
51
+ const svgPoint = (0, _getSVGPoint.getSVGPoint)(svg, event);
52
+ if (!instance.isPointInside(svgPoint.x, svgPoint.y)) {
53
+ reset();
54
+ return;
55
+ }
56
+ const item = getItemAtPosition(store.state, svgPoint);
57
+ if (item) {
58
+ instance.setLastUpdateSource('pointer');
59
+ instance.setTooltipItem(item);
60
+ instance.setHighlight(item);
61
+ onItemEnterRef();
62
+ lastItemRef.current = item;
63
+ } else {
64
+ reset();
65
+ }
66
+ };
67
+ svg.addEventListener('pointerleave', onPointerLeave);
68
+ svg.addEventListener('pointermove', onPointerMove);
69
+ svg.addEventListener('pointerenter', onPointerEnter);
70
+ return () => {
71
+ svg.removeEventListener('pointerenter', onPointerEnter);
72
+ svg.removeEventListener('pointermove', onPointerMove);
73
+ svg.removeEventListener('pointerleave', onPointerLeave);
74
+
75
+ /* Clean up state if this item is unmounted while active. */
76
+ if (interactionActive.current) {
77
+ onPointerLeave();
78
+ }
79
+ };
80
+ }, [getItemAtPosition, instance, onItemEnterRef, onItemLeaveRef, store, svgRef]);
81
+ }
@@ -20,6 +20,16 @@ reverse) {
20
20
  const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
21
21
  return reverse ? [range[1], range[0]] : range;
22
22
  }
23
+ function shouldIgnoreGapRatios(scale, categoryGapRatio) {
24
+ const step = scale.step();
25
+ const paddingPx = step * categoryGapRatio;
26
+
27
+ /* If the padding is less than 0.1px, we consider it negligible and ignore it.
28
+ * This prevents issues where very small gaps cause rendering artifacts or unexpected layouts.
29
+ * A threshold of 0.1px is chosen as it's generally below the perceptible limit for most displays.
30
+ */
31
+ return paddingPx < 0.1;
32
+ }
23
33
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
24
34
  const DEFAULT_BAR_GAP_RATIO = 0.1;
25
35
  function computeAxisValue({
@@ -54,8 +64,10 @@ function computeAxisValue({
54
64
  // Reverse range because ordinal scales are presented from top to bottom on y-axis
55
65
  const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
56
66
  if ((0, _scaleGuards.isBandScale)(scale) && (0, _axis.isBandScaleConfig)(axis)) {
57
- const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
58
- const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
67
+ const desiredCategoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
68
+ const ignoreGapRatios = shouldIgnoreGapRatios(scale, desiredCategoryGapRatio);
69
+ const categoryGapRatio = ignoreGapRatios ? 0 : desiredCategoryGapRatio;
70
+ const barGapRatio = ignoreGapRatios ? 0 : axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
59
71
  completeAxis[axis.id] = (0, _extends2.default)({
60
72
  offset: 0,
61
73
  height: 0,
@@ -64,7 +76,12 @@ function computeAxisValue({
64
76
  triggerTooltip
65
77
  }, axis, {
66
78
  data,
67
- scale,
79
+ /* Doing this here is technically wrong, but acceptable in practice.
80
+ * In theory, this should be done in the normalized scale selector, but then we'd need that selector to depend
81
+ * on the zoom range, which would void its goal (which is to be independent of zoom).
82
+ * Since we only ignore gap ratios when they're practically invisible, the small errors caused by this
83
+ * discrepancy will hopefully not be noticeable. */
84
+ scale: ignoreGapRatios ? scale.copy().padding(0) : scale,
68
85
  tickNumber,
69
86
  colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? (0, _colorScale.getOrdinalColorScale)((0, _extends2.default)({
70
87
  values: axis.data
@@ -23,6 +23,7 @@ var _getSVGPoint = require("../../../getSVGPoint");
23
23
  var _useChartInteraction = require("../useChartInteraction");
24
24
  var _useChartCartesianInteraction = require("./useChartCartesianInteraction.selectors");
25
25
  var _checkHasInteractionPlugin = require("../useChartInteraction/checkHasInteractionPlugin");
26
+ const AXIS_CLICK_SERIES_TYPES = new Set(['bar', 'rangeBar', 'line']);
26
27
  const useChartCartesianAxis = ({
27
28
  params,
28
29
  store,
@@ -172,13 +173,19 @@ const useChartCartesianAxis = ({
172
173
  // The .data exist because otherwise the dataIndex would be null or -1.
173
174
  const axisValue = (isXAxis ? xAxisWithScale : yAxisWithScale)[USED_AXIS_ID].data[dataIndex];
174
175
  const seriesValues = {};
175
- Object.keys(processedSeries).filter(seriesType => ['bar', 'line'].includes(seriesType)).forEach(seriesType => {
176
- processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
177
- const seriesItem = processedSeries[seriesType].series[seriesId];
176
+ Object.keys(processedSeries).filter(seriesType => AXIS_CLICK_SERIES_TYPES.has(seriesType)).forEach(seriesType => {
177
+ // @ts-ignore
178
+ const seriesTypeConfig = processedSeries[seriesType];
179
+ seriesTypeConfig?.seriesOrder.forEach(seriesId => {
180
+ const seriesItem = seriesTypeConfig.series[seriesId];
178
181
  const providedXAxisId = seriesItem.xAxisId;
179
182
  const providedYAxisId = seriesItem.yAxisId;
180
183
  const axisKey = isXAxis ? providedXAxisId : providedYAxisId;
181
184
  if (axisKey === undefined || axisKey === USED_AXIS_ID) {
185
+ // @ts-ignore This is safe because users need to opt in to use range bar series.
186
+ // In that case, they should import the module augmentation from `x-charts-pro/moduleAugmentation/rangeBarOnClick`
187
+ // Which adds the proper type to the series data.
188
+ // TODO(v9): Remove this ts-ignore when we can make the breaking change to ChartsAxisData.
182
189
  seriesValues[seriesId] = seriesItem.data[dataIndex];
183
190
  }
184
191
  });
@@ -0,0 +1,4 @@
1
+ import { type BarItemIdentifier } from "../../../../models/index.js";
2
+ export declare const selectorBarItemAtPosition: (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<{}> & {
3
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
4
+ }, svgPoint: Pick<DOMPoint, "x" | "y">) => BarItemIdentifier | undefined;
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorBarItemAtPosition = void 0;
7
+ var _store = require("@mui/x-internals/store");
8
+ var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.selectors");
9
+ var _useChartSeries = require("../../corePlugins/useChartSeries");
10
+ var _getBandSize = require("../../../../internals/getBandSize");
11
+ var _scaleGuards = require("../../../../internals/scaleGuards");
12
+ var _invertScale = require("../../../../internals/invertScale");
13
+ const selectorBarItemAtPosition = exports.selectorBarItemAtPosition = (0, _store.createSelector)(_useChartCartesianAxisRendering.selectorChartXAxis, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed, function selectorBarItemAtPosition({
14
+ axis: xAxes,
15
+ axisIds: xAxisIds
16
+ }, {
17
+ axis: yAxes,
18
+ axisIds: yAxisIds
19
+ }, processedSeries, svgPoint) {
20
+ const {
21
+ series,
22
+ stackingGroups = []
23
+ } = processedSeries?.bar ?? {};
24
+ const defaultXAxisId = xAxisIds[0];
25
+ const defaultYAxisId = yAxisIds[0];
26
+ let item = undefined;
27
+ for (let stackIndex = 0; stackIndex < stackingGroups.length; stackIndex += 1) {
28
+ const group = stackingGroups[stackIndex];
29
+ const seriesIds = group.ids;
30
+ for (const seriesId of seriesIds) {
31
+ const aSeries = (series ?? {})[seriesId];
32
+ const xAxisId = aSeries.xAxisId ?? defaultXAxisId;
33
+ const yAxisId = aSeries.yAxisId ?? defaultYAxisId;
34
+ const xAxis = xAxes[xAxisId];
35
+ const yAxis = yAxes[yAxisId];
36
+ const bandAxis = aSeries.layout === 'horizontal' ? yAxis : xAxis;
37
+ const continuousAxis = aSeries.layout === 'horizontal' ? xAxis : yAxis;
38
+ const bandScale = bandAxis.scale;
39
+ const svgPointBandCoordinate = aSeries.layout === 'horizontal' ? svgPoint.y : svgPoint.x;
40
+ if (!(0, _scaleGuards.isBandScale)(bandScale)) {
41
+ continue;
42
+ }
43
+ const dataIndex = (0, _invertScale.getDataIndexForOrdinalScaleValue)(bandScale, svgPointBandCoordinate);
44
+ const {
45
+ barWidth,
46
+ offset
47
+ } = (0, _getBandSize.getBandSize)(bandScale.bandwidth(), stackingGroups.length, bandAxis.barGapRatio);
48
+ const barOffset = stackIndex * (barWidth + offset);
49
+ const bandValue = bandAxis.data?.[dataIndex];
50
+ if (bandValue == null) {
51
+ continue;
52
+ }
53
+ const bandStart = bandScale(bandValue);
54
+ if (bandStart == null) {
55
+ continue;
56
+ }
57
+ const bandBarStart = bandStart + barOffset;
58
+ const bandBarEnd = bandBarStart + barWidth;
59
+ const bandBarMin = Math.min(bandBarStart, bandBarEnd);
60
+ const bandBarMax = Math.max(bandBarStart, bandBarEnd);
61
+ if (svgPointBandCoordinate >= bandBarMin && svgPointBandCoordinate <= bandBarMax) {
62
+ // The point is inside the band for this series
63
+ const svgPointContinuousCoordinate = aSeries.layout === 'horizontal' ? svgPoint.x : svgPoint.y;
64
+ const bar = aSeries.stackedData[dataIndex];
65
+ const start = continuousAxis.scale(bar[0]);
66
+ const end = continuousAxis.scale(bar[1]);
67
+ if (start == null || end == null) {
68
+ continue;
69
+ }
70
+ const continuousMin = Math.min(start, end);
71
+ const continuousMax = Math.max(start, end);
72
+ if (svgPointContinuousCoordinate >= continuousMin && svgPointContinuousCoordinate <= continuousMax) {
73
+ item = {
74
+ seriesId,
75
+ dataIndex
76
+ };
77
+ }
78
+ }
79
+ }
80
+ }
81
+ if (item) {
82
+ return {
83
+ type: 'bar',
84
+ seriesId: item.seriesId,
85
+ dataIndex: item.dataIndex
86
+ };
87
+ }
88
+ return undefined;
89
+ });
@@ -0,0 +1,3 @@
1
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
2
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/useChartSeries.types.js";
3
+ export declare function getMaxSeriesLength<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>): number;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getMaxSeriesLength = getMaxSeriesLength;
7
+ function getMaxSeriesLength(series, availableSeriesTypes) {
8
+ return Object.keys(series).filter(type => availableSeriesTypes.has(type)).flatMap(type => {
9
+ const seriesOfType = series[type];
10
+ return seriesOfType.seriesOrder.filter(seriesId => seriesOfType.series[seriesId].data.length > 0 && seriesOfType.series[seriesId].data.some(value => value != null)).map(seriesId => seriesOfType.series[seriesId].data.length);
11
+ }).reduce((maxLengths, length) => Math.max(maxLengths, length), 0);
12
+ }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getNextNonEmptySeries = getNextNonEmptySeries;
7
+ var _getNonEmptySeriesArray = require("./getNonEmptySeriesArray");
7
8
  /**
8
9
  * Returns the next series type and id that contains some data.
9
10
  * Returns `null` if no other series have data.
@@ -13,39 +14,10 @@ exports.getNextNonEmptySeries = getNextNonEmptySeries;
13
14
  * @param seriesId - The current series id.
14
15
  */
15
16
  function getNextNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
16
- const seriesType = Object.keys(series);
17
- const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
18
- const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
19
- const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
20
-
21
- // Loop over all series types starting with the current seriesType
22
- for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
23
- const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
24
- const seriesOfType = series[typesAvailable[typeIndex]];
25
-
26
- // Edge case for the current series type: we don't loop on previous series of the same type.
27
- const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
28
- for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
29
- if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
30
- return {
31
- type: typesAvailable[typeIndex],
32
- seriesId: seriesOfType.seriesOrder[seriesIndex]
33
- };
34
- }
35
- }
36
- }
37
-
38
- // End looping on the initial type up to the initial series (excluded)
39
- const typeIndex = startingTypeIndex;
40
- const seriesOfType = series[typesAvailable[typeIndex]];
41
- const endingSeriesIndex = currentSeriesIndex;
42
- for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
43
- if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
44
- return {
45
- type: typesAvailable[typeIndex],
46
- seriesId: seriesOfType.seriesOrder[seriesIndex]
47
- };
48
- }
17
+ const nonEmptySeries = (0, _getNonEmptySeriesArray.getNonEmptySeriesArray)(series, availableSeriesTypes);
18
+ if (nonEmptySeries.length === 0) {
19
+ return null;
49
20
  }
50
- return null;
21
+ const currentSeriesIndex = type !== undefined && seriesId !== undefined ? nonEmptySeries.findIndex(seriesItem => seriesItem.type === type && seriesItem.seriesId === seriesId) : -1;
22
+ return nonEmptySeries[(currentSeriesIndex + 1) % nonEmptySeries.length];
51
23
  }
@@ -0,0 +1,7 @@
1
+ import type { SeriesId } from "../../../../../models/seriesType/common.js";
2
+ import type { ChartSeriesType } from "../../../../../models/seriesType/config.js";
3
+ import type { ProcessedSeries } from "../../../corePlugins/useChartSeries/useChartSeries.types.js";
4
+ export declare function getNonEmptySeriesArray<OutSeriesType extends Exclude<ChartSeriesType, 'sankey'>>(series: ProcessedSeries<ChartSeriesType>, availableSeriesTypes: Set<OutSeriesType>): {
5
+ seriesId: SeriesId;
6
+ type: OutSeriesType;
7
+ }[];
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getNonEmptySeriesArray = getNonEmptySeriesArray;
7
+ function getNonEmptySeriesArray(series, availableSeriesTypes) {
8
+ return Object.keys(series).filter(type => availableSeriesTypes.has(type)).flatMap(type => {
9
+ const seriesOfType = series[type];
10
+ return seriesOfType.seriesOrder.filter(seriesId => seriesOfType.series[seriesId].data.length > 0 && seriesOfType.series[seriesId].data.some(value => value != null)).map(seriesId => ({
11
+ type,
12
+ seriesId
13
+ }));
14
+ });
15
+ }
@@ -4,43 +4,20 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getPreviousNonEmptySeries = getPreviousNonEmptySeries;
7
+ var _getNonEmptySeriesArray = require("./getNonEmptySeriesArray");
7
8
  /**
8
9
  * Returns the previous series type and id that contains some data.
9
10
  * Returns `null` if no other series have data.
10
11
  */
11
12
  function getPreviousNonEmptySeries(series, availableSeriesTypes, type, seriesId) {
12
- const seriesType = Object.keys(series);
13
- const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
14
- const typesAvailable = seriesType.filter(t => availableSeriesTypes?.has(t));
15
- const startingTypeIndex = type !== undefined && series[type] ? typesAvailable.indexOf(type) : 0;
16
-
17
- // Loop over all series types starting with the current seriesType
18
- for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
19
- const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
20
- const seriesOfType = series[typesAvailable[typeIndex]];
21
- const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
22
- for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
23
- const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
24
- if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
25
- return {
26
- type: typesAvailable[typeIndex],
27
- seriesId: seriesOfType.seriesOrder[seriesIndex]
28
- };
29
- }
30
- }
13
+ const nonEmptySeries = (0, _getNonEmptySeriesArray.getNonEmptySeriesArray)(series, availableSeriesTypes);
14
+ if (nonEmptySeries.length === 0) {
15
+ return null;
31
16
  }
32
-
33
- // End looping on the initial type down to the initial series (excluded)
34
- const typeIndex = startingTypeIndex;
35
- const seriesOfType = series[typesAvailable[typeIndex]];
36
- const availableSeriesIds = seriesOfType.seriesOrder;
37
- for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
38
- if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
39
- return {
40
- type: typesAvailable[typeIndex],
41
- seriesId: seriesOfType.seriesOrder[seriesIndex]
42
- };
43
- }
17
+ const currentSeriesIndex = type !== undefined && seriesId !== undefined ? nonEmptySeries.findIndex(seriesItem => seriesItem.type === type && seriesItem.seriesId === seriesId) : -1;
18
+ if (currentSeriesIndex <= 0) {
19
+ // If no current series, or if it's the first series
20
+ return nonEmptySeries[nonEmptySeries.length - 1];
44
21
  }
45
- return null;
22
+ return nonEmptySeries[(currentSeriesIndex - 1 + nonEmptySeries.length) % nonEmptySeries.length];
46
23
  }
@@ -1,12 +1,12 @@
1
1
  export declare const selectorChartsTooltipPointerItem: (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("./useChartTooltip.types.js").UseChartTooltipState> & {
2
2
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
3
- }) => import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
3
+ }) => import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
4
4
  export declare const selectorChartsTooltipPointerItemIsDefined: (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("./useChartTooltip.types.js").UseChartTooltipState> & {
5
5
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
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 | import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
9
+ }) => import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null;
10
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> & {
11
11
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
12
12
  }) => boolean;
@@ -0,0 +1,3 @@
1
+ export { useChartVisibilityManager } from "./useChartVisibilityManager.js";
2
+ export * from "./useChartVisibilityManager.types.js";
3
+ export * from "./useChartVisibilityManager.selectors.js";
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ useChartVisibilityManager: true
8
+ };
9
+ Object.defineProperty(exports, "useChartVisibilityManager", {
10
+ enumerable: true,
11
+ get: function () {
12
+ return _useChartVisibilityManager.useChartVisibilityManager;
13
+ }
14
+ });
15
+ var _useChartVisibilityManager = require("./useChartVisibilityManager");
16
+ var _useChartVisibilityManager2 = require("./useChartVisibilityManager.types");
17
+ Object.keys(_useChartVisibilityManager2).forEach(function (key) {
18
+ if (key === "default" || key === "__esModule") return;
19
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
20
+ if (key in exports && exports[key] === _useChartVisibilityManager2[key]) return;
21
+ Object.defineProperty(exports, key, {
22
+ enumerable: true,
23
+ get: function () {
24
+ return _useChartVisibilityManager2[key];
25
+ }
26
+ });
27
+ });
28
+ var _useChartVisibilityManager3 = require("./useChartVisibilityManager.selectors");
29
+ Object.keys(_useChartVisibilityManager3).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
+ if (key in exports && exports[key] === _useChartVisibilityManager3[key]) return;
33
+ Object.defineProperty(exports, key, {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _useChartVisibilityManager3[key];
37
+ }
38
+ });
39
+ });
@@ -0,0 +1,4 @@
1
+ import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
2
+ import type { ChartSeriesConfig } from "../../models/index.js";
3
+ import type { VisibilityIdentifier, VisibilityMap } from "./useChartVisibilityManager.types.js";
4
+ export declare const isIdentifierVisible: (visibilityMap: VisibilityMap, identifier: VisibilityIdentifier, seriesConfig: ChartSeriesConfig<ChartSeriesType>) => boolean;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isIdentifierVisible = void 0;
7
+ var _serializeIdentifier = require("../../corePlugins/useChartSeries/serializeIdentifier");
8
+ const isIdentifierVisible = (visibilityMap, identifier, seriesConfig) => {
9
+ const uniqueId = (0, _serializeIdentifier.serializeIdentifier)(seriesConfig, identifier);
10
+ return !visibilityMap.has(uniqueId);
11
+ };
12
+ exports.isIdentifierVisible = isIdentifierVisible;
@@ -0,0 +1,3 @@
1
+ import { type ChartPlugin } from "../../models/index.js";
2
+ import { type UseChartVisibilityManagerSignature } from "./useChartVisibilityManager.types.js";
3
+ export declare const useChartVisibilityManager: ChartPlugin<UseChartVisibilityManagerSignature<any>>;