@mui/x-charts 9.10.1 → 9.11.1

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 (177) hide show
  1. package/BarChart/BarChart.js +4 -2
  2. package/BarChart/BarChart.mjs +4 -2
  3. package/BarChart/BarPlot.d.mts +3 -3
  4. package/BarChart/BarPlot.d.ts +3 -3
  5. package/BarChart/BarPlot.js +1 -1
  6. package/BarChart/BarPlot.mjs +1 -1
  7. package/BarChart/BatchBarPlot/BatchBarPlot.d.mts +2 -2
  8. package/BarChart/BatchBarPlot/BatchBarPlot.d.ts +2 -2
  9. package/BarChart/IndividualBarPlot.d.mts +2 -2
  10. package/BarChart/IndividualBarPlot.d.ts +2 -2
  11. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.mts +4 -4
  12. package/BarChart/seriesConfig/bar/getSeriesWithDefaultValues.d.ts +4 -4
  13. package/BarChart/useRegisterItemClickHandlers.d.mts +2 -1
  14. package/BarChart/useRegisterItemClickHandlers.d.ts +2 -1
  15. package/BarChart/useRegisterItemClickHandlers.js +8 -0
  16. package/BarChart/useRegisterItemClickHandlers.mjs +8 -1
  17. package/CHANGELOG.md +157 -0
  18. package/ChartsContainer/ChartsContainer.js +4 -2
  19. package/ChartsContainer/ChartsContainer.mjs +4 -2
  20. package/ChartsDataProvider/ChartsDataProvider.js +3 -1
  21. package/ChartsDataProvider/ChartsDataProvider.mjs +3 -1
  22. package/ChartsRadialDataProvider/ChartsRadialDataProvider.js +3 -1
  23. package/ChartsRadialDataProvider/ChartsRadialDataProvider.mjs +3 -1
  24. package/ChartsXAxis/useAxisTicksProps.d.mts +101 -101
  25. package/ChartsXAxis/useAxisTicksProps.d.ts +101 -101
  26. package/ChartsYAxis/useAxisTicksProps.d.mts +101 -101
  27. package/ChartsYAxis/useAxisTicksProps.d.ts +101 -101
  28. package/LineChart/AreaPlot.d.mts +3 -2
  29. package/LineChart/AreaPlot.d.ts +3 -2
  30. package/LineChart/AreaPlot.js +8 -2
  31. package/LineChart/AreaPlot.mjs +9 -3
  32. package/LineChart/LineChart.js +2 -1
  33. package/LineChart/LineChart.mjs +2 -1
  34. package/LineChart/LinePlot.d.mts +3 -2
  35. package/LineChart/LinePlot.d.ts +3 -2
  36. package/LineChart/LinePlot.js +2 -2
  37. package/LineChart/LinePlot.mjs +3 -3
  38. package/LineChart/MarkPlot.d.mts +5 -4
  39. package/LineChart/MarkPlot.d.ts +5 -4
  40. package/LineChart/MarkPlot.js +17 -8
  41. package/LineChart/MarkPlot.mjs +17 -8
  42. package/LineChart/useLineItemClickHandler.d.mts +25 -1
  43. package/LineChart/useLineItemClickHandler.d.ts +25 -1
  44. package/LineChart/useLineItemClickHandler.js +48 -1
  45. package/LineChart/useLineItemClickHandler.mjs +47 -1
  46. package/PieChart/PieArcPlot.d.mts +3 -2
  47. package/PieChart/PieArcPlot.d.ts +3 -2
  48. package/PieChart/PieArcPlot.js +16 -1
  49. package/PieChart/PieArcPlot.mjs +16 -1
  50. package/PieChart/PieChart.js +3 -1
  51. package/PieChart/PieChart.mjs +3 -1
  52. package/PieChart/PiePlot.js +1 -1
  53. package/PieChart/PiePlot.mjs +1 -1
  54. package/README.md +1 -11
  55. package/RadarChart/RadarAxis/RadarAxis.utils.d.mts +1 -1
  56. package/RadarChart/RadarAxis/RadarAxis.utils.d.ts +1 -1
  57. package/RadarChart/RadarChart.js +3 -1
  58. package/RadarChart/RadarChart.mjs +3 -1
  59. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.js +3 -1
  60. package/RadarChart/RadarSeriesPlot/RadarSeriesArea.mjs +3 -1
  61. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.js +4 -1
  62. package/RadarChart/RadarSeriesPlot/RadarSeriesMarks.mjs +4 -1
  63. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.mts +5 -4
  64. package/RadarChart/RadarSeriesPlot/RadarSeriesPlot.types.d.ts +5 -4
  65. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.mts +15 -0
  66. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.d.ts +15 -0
  67. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.js +32 -0
  68. package/RadarChart/RadarSeriesPlot/useRegisterRadarItemActivation.mjs +26 -0
  69. package/RadarChart/useRadarChartProps.js +5 -1
  70. package/RadarChart/useRadarChartProps.mjs +5 -1
  71. package/ScatterChart/Scatter.d.mts +3 -2
  72. package/ScatterChart/Scatter.d.ts +3 -2
  73. package/ScatterChart/Scatter.js +10 -1
  74. package/ScatterChart/Scatter.mjs +10 -1
  75. package/ScatterChart/ScatterChart.js +1 -0
  76. package/ScatterChart/ScatterChart.mjs +1 -0
  77. package/ScatterChart/async/ScatterAsync.js +9 -0
  78. package/ScatterChart/async/ScatterAsync.mjs +9 -0
  79. package/SparkLineChart/SparkLineChart.js +2 -1
  80. package/SparkLineChart/SparkLineChart.mjs +2 -1
  81. package/Toolbar/ToolbarButton.js +1 -1
  82. package/Toolbar/ToolbarButton.mjs +1 -1
  83. package/hooks/useFocusedItem.d.mts +1 -1
  84. package/hooks/useFocusedItem.d.ts +1 -1
  85. package/hooks/useItemHighlightStateGetter.d.mts +1 -1
  86. package/hooks/useItemHighlightStateGetter.d.ts +1 -1
  87. package/index.js +1 -1
  88. package/index.mjs +1 -1
  89. package/internals/createCommonKeyboardFocusHandler.d.mts +2 -2
  90. package/internals/createCommonKeyboardFocusHandler.d.ts +2 -2
  91. package/internals/index.d.mts +1 -0
  92. package/internals/index.d.ts +1 -0
  93. package/internals/index.js +8 -0
  94. package/internals/index.mjs +1 -0
  95. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.mts +8 -1
  96. package/internals/plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.d.ts +8 -1
  97. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +11 -3
  98. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.mjs +11 -3
  99. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.mts +1 -0
  100. package/internals/plugins/corePlugins/useChartSeries/useChartSeries.selectors.d.ts +1 -0
  101. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.mts +12 -0
  102. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.d.ts +12 -0
  103. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.js +5 -0
  104. package/internals/plugins/corePlugins/useChartSeriesConfig/types/getItemWithData.types.mjs +1 -0
  105. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.mts +1 -0
  106. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.d.ts +1 -0
  107. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.js +11 -0
  108. package/internals/plugins/corePlugins/useChartSeriesConfig/types/index.mjs +1 -0
  109. package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.mts +6 -0
  110. package/internals/plugins/corePlugins/useChartSeriesConfig/types/seriesConfig.types.d.ts +6 -0
  111. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.mts +21 -0
  112. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.d.ts +21 -0
  113. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.js +46 -0
  114. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisClickPayload.mjs +40 -0
  115. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +13 -31
  116. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.mjs +13 -31
  117. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.mts +2 -2
  118. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -2
  119. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.mts +11 -11
  120. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +11 -11
  121. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.mts +4 -4
  122. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  123. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +19 -0
  124. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.mjs +19 -0
  125. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.mts +5 -3
  126. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.types.d.ts +5 -3
  127. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.js +15 -0
  128. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.mjs +14 -0
  129. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.mts +5 -2
  130. package/internals/plugins/featurePlugins/useChartItemClick/useChartItemClick.types.d.ts +5 -2
  131. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.mts +2 -1
  132. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +2 -1
  133. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +10 -2
  134. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.mjs +2 -1
  135. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.mts +13 -0
  136. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.d.ts +13 -0
  137. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.js +39 -0
  138. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/itemActivation.mjs +32 -0
  139. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +47 -7
  140. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.mjs +47 -7
  141. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.mts +3 -0
  142. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +3 -0
  143. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +3 -1
  144. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.mjs +2 -0
  145. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.mts +39 -2
  146. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +39 -2
  147. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.mts +27 -0
  148. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.d.ts +27 -0
  149. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.js +36 -0
  150. package/internals/plugins/featurePlugins/useChartPolarAxis/getPolarAxisClickPayload.mjs +30 -0
  151. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +19 -20
  152. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.mjs +19 -20
  153. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.mts +2 -2
  154. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.selectors.d.ts +2 -2
  155. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.mts +1 -1
  156. package/internals/plugins/featurePlugins/useChartTooltip/useChartTooltip.selectors.d.ts +1 -1
  157. package/internals/seriesSelectorOfType.d.mts +4 -4
  158. package/internals/seriesSelectorOfType.d.ts +4 -4
  159. package/internals/useRegisterItemActivation.d.mts +23 -0
  160. package/internals/useRegisterItemActivation.d.ts +23 -0
  161. package/internals/useRegisterItemActivation.js +53 -0
  162. package/internals/useRegisterItemActivation.mjs +46 -0
  163. package/models/axis.d.mts +1 -1
  164. package/models/axis.d.ts +1 -1
  165. package/models/events.d.mts +11 -0
  166. package/models/events.d.ts +11 -0
  167. package/models/events.js +5 -0
  168. package/models/events.mjs +1 -0
  169. package/models/index.d.mts +1 -0
  170. package/models/index.d.ts +1 -0
  171. package/moduleAugmentation/barChartBatchRendererOnItemClick.d.mts +3 -4
  172. package/moduleAugmentation/barChartBatchRendererOnItemClick.d.ts +3 -4
  173. package/moduleAugmentation/keyboardActivation.d.mts +7 -0
  174. package/moduleAugmentation/keyboardActivation.d.ts +7 -0
  175. package/moduleAugmentation/keyboardActivation.js +8 -0
  176. package/moduleAugmentation/keyboardActivation.mjs +2 -0
  177. package/package.json +18 -4
@@ -0,0 +1,27 @@
1
+ import type { ChartsAxisData } from "../../../../models/axis.mjs";
2
+ import type { ProcessedSeries } from "../../corePlugins/useChartSeries/index.mjs";
3
+ import type { ChartSeriesType } from "../../../../models/seriesType/config.mjs";
4
+ type PolarAxes = {
5
+ axis: Record<string, {
6
+ data?: readonly any[];
7
+ }>;
8
+ axisIds: string[];
9
+ };
10
+ /**
11
+ * Builds the `onAxisClick` payload for a data index on a polar axis.
12
+ * Returns `null` when the axis has no value at this index.
13
+ */
14
+ export declare function getPolarAxisClickPayload({
15
+ dataIndex,
16
+ isRotationAxis,
17
+ rotationAxes,
18
+ radiusAxes,
19
+ processedSeries
20
+ }: {
21
+ dataIndex: number;
22
+ isRotationAxis: boolean;
23
+ rotationAxes: PolarAxes;
24
+ radiusAxes: PolarAxes;
25
+ processedSeries: ProcessedSeries<ChartSeriesType>;
26
+ }): ChartsAxisData | null;
27
+ export {};
@@ -0,0 +1,27 @@
1
+ import type { ChartsAxisData } from "../../../../models/axis.js";
2
+ import type { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
3
+ import type { ChartSeriesType } from "../../../../models/seriesType/config.js";
4
+ type PolarAxes = {
5
+ axis: Record<string, {
6
+ data?: readonly any[];
7
+ }>;
8
+ axisIds: string[];
9
+ };
10
+ /**
11
+ * Builds the `onAxisClick` payload for a data index on a polar axis.
12
+ * Returns `null` when the axis has no value at this index.
13
+ */
14
+ export declare function getPolarAxisClickPayload({
15
+ dataIndex,
16
+ isRotationAxis,
17
+ rotationAxes,
18
+ radiusAxes,
19
+ processedSeries
20
+ }: {
21
+ dataIndex: number;
22
+ isRotationAxis: boolean;
23
+ rotationAxes: PolarAxes;
24
+ radiusAxes: PolarAxes;
25
+ processedSeries: ProcessedSeries<ChartSeriesType>;
26
+ }): ChartsAxisData | null;
27
+ export {};
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getPolarAxisClickPayload = getPolarAxisClickPayload;
7
+ var _isPolar = require("../../../isPolar");
8
+ /**
9
+ * Builds the `onAxisClick` payload for a data index on a polar axis.
10
+ * Returns `null` when the axis has no value at this index.
11
+ */
12
+ function getPolarAxisClickPayload({
13
+ dataIndex,
14
+ isRotationAxis,
15
+ rotationAxes,
16
+ radiusAxes,
17
+ processedSeries
18
+ }) {
19
+ const axes = isRotationAxis ? rotationAxes : radiusAxes;
20
+ const axisValue = axes.axis[axes.axisIds[0]]?.data?.[dataIndex];
21
+ if (axisValue === undefined) {
22
+ return null;
23
+ }
24
+ const seriesValues = {};
25
+ Object.keys(processedSeries).filter(_isPolar.isPolarSeriesType).forEach(seriesType => {
26
+ processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
27
+ const seriesItem = processedSeries[seriesType].series[seriesId];
28
+ seriesValues[seriesId] = seriesItem.data[dataIndex];
29
+ });
30
+ });
31
+ return {
32
+ dataIndex,
33
+ axisValue,
34
+ seriesValues
35
+ };
36
+ }
@@ -0,0 +1,30 @@
1
+ import { isPolarSeriesType } from "../../../isPolar.mjs";
2
+ /**
3
+ * Builds the `onAxisClick` payload for a data index on a polar axis.
4
+ * Returns `null` when the axis has no value at this index.
5
+ */
6
+ export function getPolarAxisClickPayload({
7
+ dataIndex,
8
+ isRotationAxis,
9
+ rotationAxes,
10
+ radiusAxes,
11
+ processedSeries
12
+ }) {
13
+ const axes = isRotationAxis ? rotationAxes : radiusAxes;
14
+ const axisValue = axes.axis[axes.axisIds[0]]?.data?.[dataIndex];
15
+ if (axisValue === undefined) {
16
+ return null;
17
+ }
18
+ const seriesValues = {};
19
+ Object.keys(processedSeries).filter(isPolarSeriesType).forEach(seriesType => {
20
+ processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
21
+ const seriesItem = processedSeries[seriesType].series[seriesId];
22
+ seriesValues[seriesId] = seriesItem.data[dataIndex];
23
+ });
24
+ });
25
+ return {
26
+ dataIndex,
27
+ axisValue,
28
+ seriesValues
29
+ };
30
+ }
@@ -19,7 +19,7 @@ var _coordinateTransformation = require("./coordinateTransformation");
19
19
  var _getAxisIndex = require("./getAxisIndex");
20
20
  var _useChartSeries = require("../../corePlugins/useChartSeries");
21
21
  var _checkHasInteractionPlugin = require("../useChartInteraction/checkHasInteractionPlugin");
22
- var _isPolar = require("../../../isPolar");
22
+ var _getPolarAxisClickPayload = require("./getPolarAxisClickPayload");
23
23
  const useChartPolarAxis = ({
24
24
  params,
25
25
  store,
@@ -174,34 +174,33 @@ const useChartPolarAxis = ({
174
174
  return () => {};
175
175
  }
176
176
  const axisClickHandler = instance.addInteractionListener('tap', event => {
177
- let dataIndex = null;
178
- let isRotationAxis = false;
179
177
  const svgPoint = (0, _getChartPoint.getChartPoint)(element, event.detail.srcEvent);
180
178
  const rotation = (0, _coordinateTransformation.generateSvg2rotation)(center)(svgPoint.x, svgPoint.y);
181
179
  const rotationIndex = (0, _getAxisIndex.getRotationAxisIndex)(rotationAxisWithScale[usedRotationAxisId], rotation);
182
180
  const radius = (0, _coordinateTransformation.generateSvg2radius)(center)(svgPoint.x, svgPoint.y);
183
181
  const radiusIndex = (0, _getAxisIndex.getRadiusAxisIndex)(radiusAxisWithScale[usedRadiusAxisId], radius);
184
- isRotationAxis = rotationIndex !== -1;
185
- dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
186
- const USED_AXIS_ID = isRotationAxis ? usedRotationAxisId : usedRadiusAxisId;
187
- if (dataIndex == null || dataIndex === -1) {
182
+ const isRotationAxis = rotationIndex !== -1;
183
+ const dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
184
+ if (dataIndex === -1) {
188
185
  return;
189
186
  }
190
-
191
- // The .data exist because otherwise the dataIndex would be null or -1.
192
- const axisValue = (isRotationAxis ? rotationAxisWithScale : radiusAxisWithScale)[USED_AXIS_ID].data[dataIndex];
193
- const seriesValues = {};
194
- Object.keys(processedSeries).filter(_isPolar.isPolarSeriesType).forEach(seriesType => {
195
- processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
196
- const seriesItem = processedSeries[seriesType].series[seriesId];
197
- seriesValues[seriesId] = seriesItem.data[dataIndex];
198
- });
199
- });
200
- onAxisClick(event.detail.srcEvent, {
187
+ const payload = (0, _getPolarAxisClickPayload.getPolarAxisClickPayload)({
201
188
  dataIndex,
202
- axisValue,
203
- seriesValues
189
+ isRotationAxis,
190
+ rotationAxes: {
191
+ axis: rotationAxisWithScale,
192
+ axisIds: [usedRotationAxisId]
193
+ },
194
+ radiusAxes: {
195
+ axis: radiusAxisWithScale,
196
+ axisIds: [usedRadiusAxisId]
197
+ },
198
+ processedSeries
204
199
  });
200
+ if (payload === null) {
201
+ return;
202
+ }
203
+ onAxisClick(event.detail.srcEvent, payload);
205
204
  });
206
205
  return () => {
207
206
  axisClickHandler.cleanup();
@@ -12,7 +12,7 @@ import { generatePolar2svg, generateSvg2polar, generateSvg2radius, generateSvg2r
12
12
  import { getRadiusAxisIndex, getRotationAxisIndex } from "./getAxisIndex.mjs";
13
13
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.mjs";
14
14
  import { checkHasInteractionPlugin } from "../useChartInteraction/checkHasInteractionPlugin.mjs";
15
- import { isPolarSeriesType } from "../../../isPolar.mjs";
15
+ import { getPolarAxisClickPayload } from "./getPolarAxisClickPayload.mjs";
16
16
  export const useChartPolarAxis = ({
17
17
  params,
18
18
  store,
@@ -167,34 +167,33 @@ export const useChartPolarAxis = ({
167
167
  return () => {};
168
168
  }
169
169
  const axisClickHandler = instance.addInteractionListener('tap', event => {
170
- let dataIndex = null;
171
- let isRotationAxis = false;
172
170
  const svgPoint = getChartPoint(element, event.detail.srcEvent);
173
171
  const rotation = generateSvg2rotation(center)(svgPoint.x, svgPoint.y);
174
172
  const rotationIndex = getRotationAxisIndex(rotationAxisWithScale[usedRotationAxisId], rotation);
175
173
  const radius = generateSvg2radius(center)(svgPoint.x, svgPoint.y);
176
174
  const radiusIndex = getRadiusAxisIndex(radiusAxisWithScale[usedRadiusAxisId], radius);
177
- isRotationAxis = rotationIndex !== -1;
178
- dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
179
- const USED_AXIS_ID = isRotationAxis ? usedRotationAxisId : usedRadiusAxisId;
180
- if (dataIndex == null || dataIndex === -1) {
175
+ const isRotationAxis = rotationIndex !== -1;
176
+ const dataIndex = isRotationAxis ? rotationIndex : radiusIndex;
177
+ if (dataIndex === -1) {
181
178
  return;
182
179
  }
183
-
184
- // The .data exist because otherwise the dataIndex would be null or -1.
185
- const axisValue = (isRotationAxis ? rotationAxisWithScale : radiusAxisWithScale)[USED_AXIS_ID].data[dataIndex];
186
- const seriesValues = {};
187
- Object.keys(processedSeries).filter(isPolarSeriesType).forEach(seriesType => {
188
- processedSeries[seriesType]?.seriesOrder.forEach(seriesId => {
189
- const seriesItem = processedSeries[seriesType].series[seriesId];
190
- seriesValues[seriesId] = seriesItem.data[dataIndex];
191
- });
192
- });
193
- onAxisClick(event.detail.srcEvent, {
180
+ const payload = getPolarAxisClickPayload({
194
181
  dataIndex,
195
- axisValue,
196
- seriesValues
182
+ isRotationAxis,
183
+ rotationAxes: {
184
+ axis: rotationAxisWithScale,
185
+ axisIds: [usedRotationAxisId]
186
+ },
187
+ radiusAxes: {
188
+ axis: radiusAxisWithScale,
189
+ axisIds: [usedRadiusAxisId]
190
+ },
191
+ processedSeries
197
192
  });
193
+ if (payload === null) {
194
+ return;
195
+ }
196
+ onAxisClick(event.detail.srcEvent, payload);
198
197
  });
199
198
  return () => {
200
199
  axisClickHandler.cleanup();
@@ -2,8 +2,8 @@ import type { UseChartPolarAxisSignature } from "./useChartPolarAxis.types.mjs";
2
2
  import type { ChartState } from "../../models/chart.mjs";
3
3
  import type { ChartDrawingArea } from "../../../../hooks/useDrawingArea.mjs";
4
4
  export declare const selectorChartPolarAxisState: (state: ChartState<[], [UseChartPolarAxisSignature]>) => {
5
- rotation: import("../../../index.mjs").PolarAxisConfig<import("../../../index.mjs").ScaleName, any, import("../../../index.mjs").ChartsRotationAxisProps>[];
6
- radius: import("../../../index.mjs").PolarAxisConfig<import("../../../index.mjs").ScaleName, any, import("../../../index.mjs").ChartsRadiusAxisProps>[];
5
+ rotation: import("../../../index.mjs").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.mjs").ChartsRotationAxisProps>[];
6
+ radius: import("../../../index.mjs").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.mjs").ChartsRadiusAxisProps>[];
7
7
  } | undefined;
8
8
  export declare const selectorChartRawRotationAxis: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartPolarAxis.types.mjs").UseChartPolarAxisState> & {
9
9
  cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
@@ -2,8 +2,8 @@ import type { UseChartPolarAxisSignature } from "./useChartPolarAxis.types.js";
2
2
  import type { ChartState } from "../../models/chart.js";
3
3
  import type { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
4
4
  export declare const selectorChartPolarAxisState: (state: ChartState<[], [UseChartPolarAxisSignature]>) => {
5
- rotation: import("../../../index.js").PolarAxisConfig<import("../../../index.js").ScaleName, any, import("../../../index.js").ChartsRotationAxisProps>[];
6
- radius: import("../../../index.js").PolarAxisConfig<import("../../../index.js").ScaleName, any, import("../../../index.js").ChartsRadiusAxisProps>[];
5
+ rotation: import("../../../index.js").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.js").ChartsRotationAxisProps>[];
6
+ radius: import("../../../index.js").PolarAxisConfig<import("@mui/x-charts/models").ScaleName, any, import("../../../index.js").ChartsRadiusAxisProps>[];
7
7
  } | undefined;
8
8
  export declare const selectorChartRawRotationAxis: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & 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("./useChartPolarAxis.types.js").UseChartPolarAxisState> & {
9
9
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
@@ -1,7 +1,7 @@
1
1
  import type { SeriesItemIdentifierWithType } from "../../../../models/index.mjs";
2
2
  export declare const selectorChartsTooltipPointerItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartTooltip.types.mjs").UseChartTooltipState<keyof import("../../../index.mjs").ChartsSeriesConfig>> & {
3
3
  cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
4
- }) => import("../../../index.mjs").BarItemIdentifier | import("../../../index.mjs").LineItemIdentifier | import("../../../../index.mjs").PieItemIdentifier | import("../../../../index.mjs").RadarItemIdentifier | import("../../../../index.mjs").ScatterItemIdentifier | null;
4
+ }) => import("@mui/x-charts/models").BarItemIdentifier | import("@mui/x-charts/models").LineItemIdentifier | import("@mui/x-charts/models").PieItemIdentifier | import("@mui/x-charts/models").RadarItemIdentifier | import("@mui/x-charts/models").ScatterItemIdentifier | null;
5
5
  export declare const selectorChartsTooltipPointerItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("../../corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("../../corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof import("../../../index.mjs").ChartsSeriesConfig> & import("../../corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("../../../index.mjs").UseChartInteractionListenerState & Partial<import("./useChartTooltip.types.mjs").UseChartTooltipState<keyof import("../../../index.mjs").ChartsSeriesConfig>> & {
6
6
  cacheKey: import("../../models/index.mjs").ChartStateCacheKey;
7
7
  }) => boolean;
@@ -1,7 +1,7 @@
1
1
  import type { SeriesItemIdentifierWithType } from "../../../../models/index.js";
2
2
  export declare const selectorChartsTooltipPointerItem: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & 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<keyof import("../../../index.js").ChartsSeriesConfig>> & {
3
3
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
4
- }) => import("../../../index.js").BarItemIdentifier | import("../../../index.js").LineItemIdentifier | import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").RadarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | null;
4
+ }) => import("@mui/x-charts/models").BarItemIdentifier | import("@mui/x-charts/models").LineItemIdentifier | import("@mui/x-charts/models").PieItemIdentifier | import("@mui/x-charts/models").RadarItemIdentifier | import("@mui/x-charts/models").ScatterItemIdentifier | null;
5
5
  export declare const selectorChartsTooltipPointerItemIsDefined: (args_0: import("../../corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("../../corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof import("../../../index.js").ChartsSeriesConfig> & 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<keyof import("../../../index.js").ChartsSeriesConfig>> & {
6
6
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
7
7
  }) => boolean;
@@ -4,17 +4,17 @@ import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index
4
4
  export declare const selectorAllSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("./index.mjs").UseChartInteractionListenerState & Partial<{}> & {
5
5
  cacheKey: import("./index.mjs").ChartStateCacheKey;
6
6
  }, seriesType: keyof ChartsSeriesConfig) => {
7
- series: Record<string, import("../index.mjs").DefaultizedPieSeriesType>;
7
+ series: Record<string, import("@mui/x-charts/models").DefaultizedPieSeriesType>;
8
8
  seriesOrder: SeriesId[];
9
9
  } | {
10
- series: Record<string, import("../index.mjs").DefaultizedRadarSeriesType>;
10
+ series: Record<string, import("@mui/x-charts/models").DefaultizedRadarSeriesType>;
11
11
  seriesOrder: SeriesId[];
12
12
  } | {
13
- series: Record<string, import("../index.mjs").DefaultizedScatterSeriesType>;
13
+ series: Record<string, import("@mui/x-charts/models").DefaultizedScatterSeriesType>;
14
14
  seriesOrder: SeriesId[];
15
15
  } | import("./index.mjs").SeriesProcessorResult<"bar"> | import("./index.mjs").SeriesProcessorResult<"line"> | undefined;
16
16
  export declare const selectorSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.mjs").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.mjs").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.mjs").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.mjs").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.mjs").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.mjs").UseChartAnimationState & import("./index.mjs").UseChartInteractionListenerState & Partial<{}> & {
17
17
  cacheKey: import("./index.mjs").ChartStateCacheKey;
18
- }, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("../index.mjs").DefaultizedBarSeriesType | import("../index.mjs").DefaultizedLineSeriesType | import("../index.mjs").DefaultizedPieSeriesType | import("../index.mjs").DefaultizedRadarSeriesType | import("../index.mjs").DefaultizedScatterSeriesType | undefined)[] | import("../index.mjs").DefaultizedBarSeriesType | import("../index.mjs").DefaultizedLineSeriesType | import("../index.mjs").DefaultizedPieSeriesType | import("../index.mjs").DefaultizedRadarSeriesType | import("../index.mjs").DefaultizedScatterSeriesType | undefined;
18
+ }, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined)[] | import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined;
19
19
  export declare const useAllSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T) => ProcessedSeries[T];
20
20
  export declare const useSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T, seriesId?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | ChartSeriesDefaultized<T>[] | undefined;
@@ -4,17 +4,17 @@ import type { ProcessedSeries } from "./plugins/corePlugins/useChartSeries/index
4
4
  export declare const selectorAllSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
5
5
  cacheKey: import("./index.js").ChartStateCacheKey;
6
6
  }, seriesType: keyof ChartsSeriesConfig) => {
7
- series: Record<string, import("../index.js").DefaultizedPieSeriesType>;
7
+ series: Record<string, import("@mui/x-charts/models").DefaultizedPieSeriesType>;
8
8
  seriesOrder: SeriesId[];
9
9
  } | {
10
- series: Record<string, import("../index.js").DefaultizedRadarSeriesType>;
10
+ series: Record<string, import("@mui/x-charts/models").DefaultizedRadarSeriesType>;
11
11
  seriesOrder: SeriesId[];
12
12
  } | {
13
- series: Record<string, import("../index.js").DefaultizedScatterSeriesType>;
13
+ series: Record<string, import("@mui/x-charts/models").DefaultizedScatterSeriesType>;
14
14
  seriesOrder: SeriesId[];
15
15
  } | import("./index.js").SeriesProcessorResult<"bar"> | import("./index.js").SeriesProcessorResult<"line"> | undefined;
16
16
  export declare const selectorSeriesOfType: (args_0: import("./plugins/corePlugins/useChartId/useChartId.types.js").UseChartIdState & import("./plugins/corePlugins/useChartSeriesConfig/useChartSeriesConfig.types.js").UseChartSeriesConfigState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartExperimentalFeature/useChartExperimentalFeature.types.js").UseChartExperimentalFeaturesState & import("./plugins/corePlugins/useChartDimensions/useChartDimensions.types.js").UseChartDimensionsState & import("./plugins/corePlugins/useChartSeries/useChartSeries.types.js").UseChartSeriesState<keyof ChartsSeriesConfig> & import("./plugins/corePlugins/useChartAnimation/useChartAnimation.types.js").UseChartAnimationState & import("./index.js").UseChartInteractionListenerState & Partial<{}> & {
17
17
  cacheKey: import("./index.js").ChartStateCacheKey;
18
- }, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("../index.js").DefaultizedBarSeriesType | import("../index.js").DefaultizedLineSeriesType | import("../index.js").DefaultizedPieSeriesType | import("../index.js").DefaultizedRadarSeriesType | import("../index.js").DefaultizedScatterSeriesType | undefined)[] | import("../index.js").DefaultizedBarSeriesType | import("../index.js").DefaultizedLineSeriesType | import("../index.js").DefaultizedPieSeriesType | import("../index.js").DefaultizedRadarSeriesType | import("../index.js").DefaultizedScatterSeriesType | undefined;
18
+ }, seriesType: keyof ChartsSeriesConfig, ids: string | string[] | undefined) => (import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined)[] | import("@mui/x-charts/models").DefaultizedBarSeriesType | import("@mui/x-charts/models").DefaultizedLineSeriesType | import("@mui/x-charts/models").DefaultizedPieSeriesType | import("@mui/x-charts/models").DefaultizedRadarSeriesType | import("@mui/x-charts/models").DefaultizedScatterSeriesType | undefined;
19
19
  export declare const useAllSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T) => ProcessedSeries[T];
20
20
  export declare const useSeriesOfType: <T extends keyof ChartsSeriesConfig>(seriesType: T, seriesId?: SeriesId | SeriesId[]) => ChartSeriesDefaultized<T> | ChartSeriesDefaultized<T>[] | undefined;
@@ -0,0 +1,23 @@
1
+ import type { ChartSeriesType } from "../models/seriesType/config.mjs";
2
+ import type { SeriesId } from "../models/seriesType/common.mjs";
3
+ import type { FocusedItemIdentifier } from "../models/seriesType/index.mjs";
4
+ /**
5
+ * Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
6
+ * <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
7
+ *
8
+ * Scope the registration as tightly as the caller knows: when several plots handle the same item,
9
+ * the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
10
+ * handler runs once.
11
+ *
12
+ * The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
13
+ * to only describe the pointer event unless the user augments `keyboardActivationOverride`.
14
+ *
15
+ * @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
16
+ * @param handler The handler to call on activation, or `undefined` to register nothing.
17
+ */
18
+ export declare function useRegisterItemActivation<SeriesType extends ChartSeriesType = ChartSeriesType>(scope: {
19
+ type?: SeriesType;
20
+ seriesId?: SeriesId;
21
+ priority?: number;
22
+ canActivate?: (item: FocusedItemIdentifier<SeriesType>) => boolean;
23
+ }, handler: ((event: any, item: FocusedItemIdentifier<SeriesType>) => void) | undefined): void;
@@ -0,0 +1,23 @@
1
+ import type { ChartSeriesType } from "../models/seriesType/config.js";
2
+ import type { SeriesId } from "../models/seriesType/common.js";
3
+ import type { FocusedItemIdentifier } from "../models/seriesType/index.js";
4
+ /**
5
+ * Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
6
+ * <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
7
+ *
8
+ * Scope the registration as tightly as the caller knows: when several plots handle the same item,
9
+ * the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
10
+ * handler runs once.
11
+ *
12
+ * The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
13
+ * to only describe the pointer event unless the user augments `keyboardActivationOverride`.
14
+ *
15
+ * @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
16
+ * @param handler The handler to call on activation, or `undefined` to register nothing.
17
+ */
18
+ export declare function useRegisterItemActivation<SeriesType extends ChartSeriesType = ChartSeriesType>(scope: {
19
+ type?: SeriesType;
20
+ seriesId?: SeriesId;
21
+ priority?: number;
22
+ canActivate?: (item: FocusedItemIdentifier<SeriesType>) => boolean;
23
+ }, handler: ((event: any, item: FocusedItemIdentifier<SeriesType>) => void) | undefined): void;
@@ -0,0 +1,53 @@
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.useRegisterItemActivation = useRegisterItemActivation;
10
+ var React = _interopRequireWildcard(require("react"));
11
+ var _useEventCallback = _interopRequireDefault(require("@mui/utils/useEventCallback"));
12
+ var _ChartsProvider = require("../context/ChartsProvider");
13
+ /**
14
+ * Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
15
+ * <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
16
+ *
17
+ * Scope the registration as tightly as the caller knows: when several plots handle the same item,
18
+ * the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
19
+ * handler runs once.
20
+ *
21
+ * The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
22
+ * to only describe the pointer event unless the user augments `keyboardActivationOverride`.
23
+ *
24
+ * @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
25
+ * @param handler The handler to call on activation, or `undefined` to register nothing.
26
+ */
27
+ function useRegisterItemActivation(scope, handler) {
28
+ const {
29
+ instance
30
+ } = (0, _ChartsProvider.useChartsContext)();
31
+ const {
32
+ type,
33
+ seriesId,
34
+ priority,
35
+ canActivate
36
+ } = scope;
37
+ const hasHandler = handler !== undefined;
38
+ const stableHandler = (0, _useEventCallback.default)((event, item) => handler?.(event, item));
39
+ const hasCanActivate = canActivate !== undefined;
40
+ const stableCanActivate = (0, _useEventCallback.default)(item => canActivate ? canActivate(item) : true);
41
+ const registerItemActivationHandler = instance.registerItemActivationHandler;
42
+ React.useEffect(() => {
43
+ if (!hasHandler || !registerItemActivationHandler) {
44
+ return undefined;
45
+ }
46
+ return registerItemActivationHandler({
47
+ type,
48
+ seriesId,
49
+ priority,
50
+ canActivate: hasCanActivate ? stableCanActivate : undefined
51
+ }, stableHandler);
52
+ }, [registerItemActivationHandler, hasHandler, type, seriesId, priority, hasCanActivate, stableCanActivate, stableHandler]);
53
+ }
@@ -0,0 +1,46 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import useEventCallback from '@mui/utils/useEventCallback';
5
+ import { useChartsContext } from "../context/ChartsProvider/index.mjs";
6
+ /**
7
+ * Registers a handler fired when the keyboard-focused item is activated with <kbd>Enter</kbd> or
8
+ * <kbd>Space</kbd>. It is a no-op when the `keyboardActivation` experimental feature is off.
9
+ *
10
+ * Scope the registration as tightly as the caller knows: when several plots handle the same item,
11
+ * the most specific scope wins, `priority` breaks ties, `canActivate` can decline an item, and the
12
+ * handler runs once.
13
+ *
14
+ * The handler receives the `KeyboardEvent`, typed as `any` because the click callbacks it forwards
15
+ * to only describe the pointer event unless the user augments `keyboardActivationOverride`.
16
+ *
17
+ * @param scope The items covered by the handler. Omit `seriesId` to cover a whole series type.
18
+ * @param handler The handler to call on activation, or `undefined` to register nothing.
19
+ */
20
+ export function useRegisterItemActivation(scope, handler) {
21
+ const {
22
+ instance
23
+ } = useChartsContext();
24
+ const {
25
+ type,
26
+ seriesId,
27
+ priority,
28
+ canActivate
29
+ } = scope;
30
+ const hasHandler = handler !== undefined;
31
+ const stableHandler = useEventCallback((event, item) => handler?.(event, item));
32
+ const hasCanActivate = canActivate !== undefined;
33
+ const stableCanActivate = useEventCallback(item => canActivate ? canActivate(item) : true);
34
+ const registerItemActivationHandler = instance.registerItemActivationHandler;
35
+ React.useEffect(() => {
36
+ if (!hasHandler || !registerItemActivationHandler) {
37
+ return undefined;
38
+ }
39
+ return registerItemActivationHandler({
40
+ type,
41
+ seriesId,
42
+ priority,
43
+ canActivate: hasCanActivate ? stableCanActivate : undefined
44
+ }, stableHandler);
45
+ }, [registerItemActivationHandler, hasHandler, type, seriesId, priority, hasCanActivate, stableCanActivate, stableHandler]);
46
+ }
package/models/axis.d.mts CHANGED
@@ -627,7 +627,7 @@ export interface ChartsAxisData {
627
627
  /**
628
628
  * The mapping of series ids to their value for this particular axis index.
629
629
  */
630
- seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, 'seriesValueOverride'> extends true ? ChartsTypeFeatureFlags['seriesValuesOverride'] : number | null | undefined>;
630
+ seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, 'seriesValuesOverride'> extends true ? ChartsTypeFeatureFlags['seriesValuesOverride'] : number | null | undefined>;
631
631
  }
632
632
  export type CartesianDirection = 'x' | 'y';
633
633
  export type PolarDirection = 'rotation' | 'radius';
package/models/axis.d.ts CHANGED
@@ -627,7 +627,7 @@ export interface ChartsAxisData {
627
627
  /**
628
628
  * The mapping of series ids to their value for this particular axis index.
629
629
  */
630
- seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, 'seriesValueOverride'> extends true ? ChartsTypeFeatureFlags['seriesValuesOverride'] : number | null | undefined>;
630
+ seriesValues: Record<string, HasProperty<ChartsTypeFeatureFlags, 'seriesValuesOverride'> extends true ? ChartsTypeFeatureFlags['seriesValuesOverride'] : number | null | undefined>;
631
631
  }
632
632
  export type CartesianDirection = 'x' | 'y';
633
633
  export type PolarDirection = 'rotation' | 'radius';
@@ -0,0 +1,11 @@
1
+ import type * as React from 'react';
2
+ import type { HasProperty } from '@mui/x-internals/types';
3
+ import type { ChartsTypeFeatureFlags } from "./featureFlags.mjs";
4
+ /**
5
+ * The event a click callback receives.
6
+ *
7
+ * It only describes the pointer event by default. Add
8
+ * `import type {} from '@mui/x-charts/moduleAugmentation/keyboardActivation'` to also get the
9
+ * `KeyboardEvent` fired by the `keyboardActivation` experimental feature.
10
+ */
11
+ export type ChartsActivationEvent<Element = never> = ([Element] extends [never] ? MouseEvent : React.MouseEvent<Element, MouseEvent>) | (HasProperty<ChartsTypeFeatureFlags, 'keyboardActivationOverride'> extends true ? ChartsTypeFeatureFlags['keyboardActivationOverride'] : never);
@@ -0,0 +1,11 @@
1
+ import type * as React from 'react';
2
+ import type { HasProperty } from '@mui/x-internals/types';
3
+ import type { ChartsTypeFeatureFlags } from "./featureFlags.js";
4
+ /**
5
+ * The event a click callback receives.
6
+ *
7
+ * It only describes the pointer event by default. Add
8
+ * `import type {} from '@mui/x-charts/moduleAugmentation/keyboardActivation'` to also get the
9
+ * `KeyboardEvent` fired by the `keyboardActivation` experimental feature.
10
+ */
11
+ export type ChartsActivationEvent<Element = never> = ([Element] extends [never] ? MouseEvent : React.MouseEvent<Element, MouseEvent>) | (HasProperty<ChartsTypeFeatureFlags, 'keyboardActivationOverride'> extends true ? ChartsTypeFeatureFlags['keyboardActivationOverride'] : never);
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -2,6 +2,7 @@ export * from "./seriesType/index.mjs";
2
2
  export * from "./stacking.mjs";
3
3
  export * from "./slots/index.mjs";
4
4
  export * from "./featureFlags.mjs";
5
+ export type { ChartsActivationEvent } from "./events.mjs";
5
6
  export * from "./chartsSlotsComponentsProps.mjs";
6
7
  export type { AxisConfig, ChartsYAxisProps, ChartsXAxisProps, ScaleName, ContinuousScaleName, ChartsAxisData, XAxis, YAxis, RadiusAxis, RotationAxis, AxisItemIdentifier, AxisValueFormatterContext } from "./axis.mjs";
7
8
  export type { NumberValue } from '@mui/x-charts-vendor/d3-scale';
package/models/index.d.ts CHANGED
@@ -2,6 +2,7 @@ export * from "./seriesType/index.js";
2
2
  export * from "./stacking.js";
3
3
  export * from "./slots/index.js";
4
4
  export * from "./featureFlags.js";
5
+ export type { ChartsActivationEvent } from "./events.js";
5
6
  export * from "./chartsSlotsComponentsProps.js";
6
7
  export type { AxisConfig, ChartsYAxisProps, ChartsXAxisProps, ScaleName, ContinuousScaleName, ChartsAxisData, XAxis, YAxis, RadiusAxis, RotationAxis, AxisItemIdentifier, AxisValueFormatterContext } from "./axis.js";
7
8
  export type { NumberValue } from '@mui/x-charts-vendor/d3-scale';
@@ -1,13 +1,12 @@
1
- import type * as React from 'react';
2
- import type { BarItemIdentifier } from "../models/index.mjs";
1
+ import type { BarItemIdentifier, ChartsActivationEvent } from "../models/index.mjs";
3
2
  declare module '@mui/x-charts/BarChart' {
4
3
  interface BarPlotProps {
5
4
  /**
6
5
  * Callback fired when a bar item is clicked.
7
- * @param {MouseEvent | React.MouseEvent<SVGElement, MouseEvent>} event The event source of the callback.
6
+ * @param {ChartsActivationEvent | ChartsActivationEvent<SVGElement>} event The event source of the callback.
8
7
  * It is a native MouseEvent for `svg-batch` renderer and a React MouseEvent for `svg-single` renderer.
9
8
  * @param {BarItemIdentifier} barItemIdentifier The bar item identifier.
10
9
  */
11
- onItemClick?(event: MouseEvent | React.MouseEvent<SVGElement, MouseEvent>, barItemIdentifier: BarItemIdentifier): void;
10
+ onItemClick?(event: ChartsActivationEvent | ChartsActivationEvent<SVGElement>, barItemIdentifier: BarItemIdentifier): void;
12
11
  }
13
12
  }