@mui/x-charts 8.11.3 → 8.12.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 (282) hide show
  1. package/BarChart/BarChart.d.ts +2 -2
  2. package/BarChart/BarChart.js +1 -0
  3. package/BarChart/BarChart.plugins.d.ts +3 -2
  4. package/BarChart/BarChart.plugins.js +2 -1
  5. package/BarChart/BarElement.js +10 -2
  6. package/BarChart/index.d.ts +1 -0
  7. package/BarChart/index.js +12 -0
  8. package/BarChart/useBarChartProps.d.ts +2 -2
  9. package/CHANGELOG.md +151 -6
  10. package/ChartContainer/ChartContainer.js +4 -2
  11. package/ChartContainer/useChartContainerProps.js +4 -2
  12. package/ChartsLegend/ContinuousColorLegend.js +1 -0
  13. package/ChartsLegend/PiecewiseColorLegend.js +1 -0
  14. package/ChartsSurface/ChartsSurface.js +21 -2
  15. package/ChartsWrapper/ChartsWrapper.d.ts +2 -1
  16. package/ChartsWrapper/ChartsWrapper.js +49 -46
  17. package/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
  18. package/ChartsYAxis/useAxisTicksProps.d.ts +3 -3
  19. package/LineChart/FocusedMark.d.ts +2 -0
  20. package/LineChart/FocusedMark.js +44 -0
  21. package/LineChart/LineChart.d.ts +2 -2
  22. package/LineChart/LineChart.js +3 -1
  23. package/LineChart/LineChart.plugins.d.ts +3 -2
  24. package/LineChart/LineChart.plugins.js +2 -1
  25. package/LineChart/index.d.ts +1 -0
  26. package/LineChart/index.js +12 -0
  27. package/LineChart/useLineChartProps.d.ts +2 -2
  28. package/PieChart/PieArc.d.ts +1 -0
  29. package/PieChart/PieArc.js +7 -3
  30. package/PieChart/PieArcPlot.js +1 -0
  31. package/PieChart/PieChart.js +1 -0
  32. package/PieChart/PieChart.plugins.d.ts +2 -1
  33. package/PieChart/PieChart.plugins.js +2 -1
  34. package/PieChart/dataTransform/useTransformData.d.ts +1 -0
  35. package/PieChart/dataTransform/useTransformData.js +9 -1
  36. package/PieChart/index.d.ts +1 -0
  37. package/PieChart/index.js +12 -0
  38. package/RadarChart/RadarChart.plugins.d.ts +1 -1
  39. package/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -3
  40. package/RadarChart/index.d.ts +2 -1
  41. package/RadarChart/index.js +12 -0
  42. package/RadarChart/useRadarChartProps.d.ts +2 -2
  43. package/ScatterChart/BatchScatter.d.ts +32 -0
  44. package/ScatterChart/BatchScatter.js +171 -0
  45. package/ScatterChart/Scatter.js +13 -5
  46. package/ScatterChart/ScatterChart.d.ts +4 -4
  47. package/ScatterChart/ScatterChart.js +13 -2
  48. package/ScatterChart/ScatterChart.plugins.d.ts +4 -3
  49. package/ScatterChart/ScatterChart.plugins.js +3 -2
  50. package/ScatterChart/ScatterPlot.d.ts +10 -0
  51. package/ScatterChart/ScatterPlot.js +14 -2
  52. package/ScatterChart/index.d.ts +1 -0
  53. package/ScatterChart/index.js +12 -0
  54. package/ScatterChart/useScatterChartProps.d.ts +2 -2
  55. package/ScatterChart/useScatterChartProps.js +8 -5
  56. package/SparkLineChart/SparkLineChart.js +10 -5
  57. package/Toolbar/Toolbar.js +1 -2
  58. package/colorPalettes/types.d.ts +1 -1
  59. package/context/ChartApi.d.ts +6 -6
  60. package/esm/BarChart/BarChart.d.ts +2 -2
  61. package/esm/BarChart/BarChart.js +1 -0
  62. package/esm/BarChart/BarChart.plugins.d.ts +3 -2
  63. package/esm/BarChart/BarChart.plugins.js +2 -1
  64. package/esm/BarChart/BarElement.js +10 -2
  65. package/esm/BarChart/index.d.ts +1 -0
  66. package/esm/BarChart/index.js +1 -0
  67. package/esm/BarChart/useBarChartProps.d.ts +2 -2
  68. package/esm/ChartContainer/ChartContainer.js +4 -2
  69. package/esm/ChartContainer/useChartContainerProps.js +4 -2
  70. package/esm/ChartsLegend/ContinuousColorLegend.js +1 -0
  71. package/esm/ChartsLegend/PiecewiseColorLegend.js +1 -0
  72. package/esm/ChartsSurface/ChartsSurface.js +21 -2
  73. package/esm/ChartsWrapper/ChartsWrapper.d.ts +2 -1
  74. package/esm/ChartsWrapper/ChartsWrapper.js +49 -46
  75. package/esm/ChartsXAxis/useAxisTicksProps.d.ts +3 -3
  76. package/esm/ChartsYAxis/useAxisTicksProps.d.ts +3 -3
  77. package/esm/LineChart/FocusedMark.d.ts +2 -0
  78. package/esm/LineChart/FocusedMark.js +38 -0
  79. package/esm/LineChart/LineChart.d.ts +2 -2
  80. package/esm/LineChart/LineChart.js +3 -1
  81. package/esm/LineChart/LineChart.plugins.d.ts +3 -2
  82. package/esm/LineChart/LineChart.plugins.js +2 -1
  83. package/esm/LineChart/index.d.ts +1 -0
  84. package/esm/LineChart/index.js +1 -0
  85. package/esm/LineChart/useLineChartProps.d.ts +2 -2
  86. package/esm/PieChart/PieArc.d.ts +1 -0
  87. package/esm/PieChart/PieArc.js +7 -3
  88. package/esm/PieChart/PieArcPlot.js +1 -0
  89. package/esm/PieChart/PieChart.js +1 -0
  90. package/esm/PieChart/PieChart.plugins.d.ts +2 -1
  91. package/esm/PieChart/PieChart.plugins.js +2 -1
  92. package/esm/PieChart/dataTransform/useTransformData.d.ts +1 -0
  93. package/esm/PieChart/dataTransform/useTransformData.js +9 -1
  94. package/esm/PieChart/index.d.ts +1 -0
  95. package/esm/PieChart/index.js +1 -0
  96. package/esm/RadarChart/RadarChart.plugins.d.ts +1 -1
  97. package/esm/RadarChart/RadarDataProvider/RadarDataProvider.d.ts +3 -3
  98. package/esm/RadarChart/index.d.ts +2 -1
  99. package/esm/RadarChart/index.js +2 -1
  100. package/esm/RadarChart/useRadarChartProps.d.ts +2 -2
  101. package/esm/ScatterChart/BatchScatter.d.ts +32 -0
  102. package/esm/ScatterChart/BatchScatter.js +165 -0
  103. package/esm/ScatterChart/Scatter.js +13 -5
  104. package/esm/ScatterChart/ScatterChart.d.ts +4 -4
  105. package/esm/ScatterChart/ScatterChart.js +13 -2
  106. package/esm/ScatterChart/ScatterChart.plugins.d.ts +4 -3
  107. package/esm/ScatterChart/ScatterChart.plugins.js +3 -2
  108. package/esm/ScatterChart/ScatterPlot.d.ts +10 -0
  109. package/esm/ScatterChart/ScatterPlot.js +14 -2
  110. package/esm/ScatterChart/index.d.ts +1 -0
  111. package/esm/ScatterChart/index.js +1 -0
  112. package/esm/ScatterChart/useScatterChartProps.d.ts +2 -2
  113. package/esm/ScatterChart/useScatterChartProps.js +8 -5
  114. package/esm/SparkLineChart/SparkLineChart.js +10 -5
  115. package/esm/Toolbar/Toolbar.js +1 -2
  116. package/esm/colorPalettes/types.d.ts +1 -1
  117. package/esm/context/ChartApi.d.ts +6 -6
  118. package/esm/hooks/useAxis.d.ts +5 -5
  119. package/esm/hooks/useDrawingArea.d.ts +20 -2
  120. package/esm/hooks/useFocusedItem.d.ts +15 -0
  121. package/esm/hooks/useFocusedItem.js +20 -0
  122. package/esm/hooks/useIsItemFocused.d.ts +12 -0
  123. package/esm/hooks/useIsItemFocused.js +15 -0
  124. package/esm/hooks/useIsItemFocusedGetter.d.ts +8 -0
  125. package/esm/hooks/useIsItemFocusedGetter.js +14 -0
  126. package/esm/hooks/useScale.js +6 -0
  127. package/esm/index.d.ts +1 -0
  128. package/esm/index.js +2 -1
  129. package/esm/internals/animation/Transition.js +1 -3
  130. package/esm/internals/index.d.ts +3 -2
  131. package/esm/internals/index.js +3 -2
  132. package/esm/internals/plugins/allPlugins.d.ts +5 -4
  133. package/esm/internals/plugins/allPlugins.js +3 -2
  134. package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
  135. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
  136. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +66 -72
  137. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
  138. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
  139. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
  140. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/{getAxisExtremum.d.ts → getAxisExtrema.d.ts} +1 -1
  141. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +24 -0
  142. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +63 -0
  143. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +123 -0
  144. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
  145. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
  146. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +46 -4
  147. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
  148. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +32 -21
  149. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
  150. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.js +2 -0
  151. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
  152. package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +9 -7
  153. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
  154. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +3 -0
  155. package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
  156. package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
  157. package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +32 -0
  158. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
  159. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +5 -0
  160. package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
  161. package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +3 -0
  162. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
  163. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +2 -0
  164. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
  165. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
  166. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +88 -0
  167. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +210 -0
  168. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +25 -0
  169. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +7 -0
  170. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +34 -0
  171. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +1 -0
  172. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
  173. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
  174. package/esm/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
  175. package/esm/internals/scaleGuards.d.ts +7 -0
  176. package/esm/internals/scaleGuards.js +6 -0
  177. package/esm/locales/elGR.d.ts +96 -0
  178. package/esm/locales/elGR.js +100 -0
  179. package/esm/locales/enUS.d.ts +96 -0
  180. package/esm/locales/enUS.js +99 -1
  181. package/esm/locales/frFR.d.ts +96 -0
  182. package/esm/locales/frFR.js +100 -2
  183. package/esm/locales/ptBR.d.ts +96 -0
  184. package/esm/locales/ptBR.js +100 -0
  185. package/esm/locales/ptPT.d.ts +96 -0
  186. package/esm/locales/ptPT.js +100 -0
  187. package/esm/locales/svSE.d.ts +97 -1
  188. package/esm/locales/svSE.js +100 -0
  189. package/esm/locales/utils/chartsLocaleTextApi.d.ts +384 -0
  190. package/esm/locales/utils/getChartsLocalization.d.ts +96 -0
  191. package/esm/plugins/index.d.ts +6 -0
  192. package/esm/plugins/index.js +12 -0
  193. package/hooks/useAxis.d.ts +5 -5
  194. package/hooks/useDrawingArea.d.ts +20 -2
  195. package/hooks/useFocusedItem.d.ts +15 -0
  196. package/hooks/useFocusedItem.js +26 -0
  197. package/hooks/useIsItemFocused.d.ts +12 -0
  198. package/hooks/useIsItemFocused.js +20 -0
  199. package/hooks/useIsItemFocusedGetter.d.ts +8 -0
  200. package/hooks/useIsItemFocusedGetter.js +18 -0
  201. package/hooks/useScale.js +6 -0
  202. package/index.d.ts +1 -0
  203. package/index.js +13 -1
  204. package/internals/animation/Transition.js +0 -2
  205. package/internals/index.d.ts +3 -2
  206. package/internals/index.js +20 -8
  207. package/internals/plugins/allPlugins.d.ts +5 -4
  208. package/internals/plugins/allPlugins.js +3 -2
  209. package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
  210. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
  211. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +63 -69
  212. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
  213. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
  214. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
  215. package/internals/plugins/featurePlugins/useChartCartesianAxis/{getAxisExtremum.d.ts → getAxisExtrema.d.ts} +1 -1
  216. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +30 -0
  217. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +63 -0
  218. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +134 -0
  219. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
  220. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
  221. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +47 -5
  222. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +10 -0
  223. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +33 -22
  224. package/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
  225. package/internals/plugins/featurePlugins/useChartClosestPoint/index.js +27 -0
  226. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
  227. package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +11 -9
  228. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
  229. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +9 -0
  230. package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
  231. package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
  232. package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +41 -0
  233. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
  234. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +6 -1
  235. package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
  236. package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +9 -0
  237. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
  238. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +27 -0
  239. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
  240. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
  241. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +96 -0
  242. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +218 -0
  243. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +25 -0
  244. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +13 -0
  245. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +34 -0
  246. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +5 -0
  247. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
  248. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
  249. package/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
  250. package/internals/scaleGuards.d.ts +7 -0
  251. package/internals/scaleGuards.js +8 -0
  252. package/locales/elGR.d.ts +96 -0
  253. package/locales/elGR.js +100 -0
  254. package/locales/enUS.d.ts +96 -0
  255. package/locales/enUS.js +99 -1
  256. package/locales/frFR.d.ts +96 -0
  257. package/locales/frFR.js +100 -2
  258. package/locales/ptBR.d.ts +96 -0
  259. package/locales/ptBR.js +100 -0
  260. package/locales/ptPT.d.ts +96 -0
  261. package/locales/ptPT.js +100 -0
  262. package/locales/svSE.d.ts +97 -1
  263. package/locales/svSE.js +100 -0
  264. package/locales/utils/chartsLocaleTextApi.d.ts +384 -0
  265. package/locales/utils/getChartsLocalization.d.ts +96 -0
  266. package/package.json +4 -4
  267. package/plugins/index.d.ts +6 -0
  268. package/plugins/index.js +47 -0
  269. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -22
  270. package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
  271. package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -2
  272. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
  273. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
  274. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -3
  275. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -29
  276. package/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
  277. package/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -27
  278. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
  279. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
  280. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -9
  281. /package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
  282. /package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
@@ -1,6 +1,7 @@
1
1
  import { createSelector } from "../../utils/selectors.js";
2
2
  import { createIsHighlighted } from "./createIsHighlighted.js";
3
3
  import { createIsFaded } from "./createIsFaded.js";
4
+ import { getSeriesHighlightedItem, getSeriesUnfadedItem, isSeriesFaded, isSeriesHighlighted } from "./highlightStates.js";
4
5
  const selectHighlight = state => state.highlight;
5
6
  const selectSeries = state => state.series;
6
7
  export const selectorChartsHighlightScopePerSeriesId = createSelector([selectSeries], series => {
@@ -32,6 +33,10 @@ export const selectorChartsIsFadedCallback = createSelector([selectorChartsHighl
32
33
  export const selectorChartsIsHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsHighlighted(highlightScope, highlightedItem, item) {
33
34
  return createIsHighlighted(highlightScope, highlightedItem)(item);
34
35
  });
36
+ export const selectorChartIsSeriesHighlighted = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], isSeriesHighlighted);
37
+ export const selectorChartIsSeriesFaded = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], isSeriesFaded);
38
+ export const selectorChartSeriesUnfadedItem = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], getSeriesUnfadedItem);
39
+ export const selectorChartSeriesHighlightedItem = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, seriesId) => seriesId], getSeriesHighlightedItem);
35
40
  export const selectorChartsIsFaded = createSelector([selectorChartsHighlightScope, selectorChartsHighlightedItem, (_, item) => item], function selectorChartsIsFaded(highlightScope, highlightedItem, item) {
36
41
  return createIsFaded(highlightScope, highlightedItem)(item);
37
42
  });
@@ -0,0 +1,3 @@
1
+ import { ChartAnyPluginSignature, ChartUsedInstance } from "../../models/plugin.js";
2
+ import { UseChartInteractionInstance } from "./useChartInteraction.types.js";
3
+ export declare function checkHasInteractionPlugin<T extends ChartAnyPluginSignature>(instance: ChartUsedInstance<T>): instance is ChartUsedInstance<T> & UseChartInteractionInstance;
@@ -0,0 +1,3 @@
1
+ export function checkHasInteractionPlugin(instance) {
2
+ return instance.setPointerCoordinate !== undefined;
3
+ }
@@ -0,0 +1,3 @@
1
+ export { useChartKeyboardNavigation } from "./useChartKeyboardNavigation.js";
2
+ export * from "./useChartKeyboardNavigation.selectors.js";
3
+ export type { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
@@ -0,0 +1,2 @@
1
+ export { useChartKeyboardNavigation } from "./useChartKeyboardNavigation.js";
2
+ export * from "./useChartKeyboardNavigation.selectors.js";
@@ -0,0 +1,3 @@
1
+ import { ChartPlugin } from "../../models/index.js";
2
+ import { UseChartKeyboardNavigationSignature } from "./useChartKeyboardNavigation.types.js";
3
+ export declare const useChartKeyboardNavigation: ChartPlugin<UseChartKeyboardNavigationSignature>;
@@ -0,0 +1,20 @@
1
+ import { ChartSeriesType, ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
2
+ import { SeriesId } from "../../../../models/seriesType/common.js";
3
+ import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
4
+ /**
5
+ * Returns the next series type and id that contains some data.
6
+ * Returns `null` if no other series have data.
7
+ */
8
+ export declare function getNextSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
9
+ type: Exclude<ChartSeriesType, 'sankey'>;
10
+ seriesId: SeriesId;
11
+ } | null;
12
+ /**
13
+ * Returns the previous series type and id that contains some data.
14
+ * Returns `null` if no other series have data.
15
+ */
16
+ export declare function getPreviousSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
17
+ type: Exclude<ChartSeriesType, 'sankey'>;
18
+ seriesId: SeriesId;
19
+ } | null;
20
+ export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean | undefined;
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Returns the next series type and id that contains some data.
3
+ * Returns `null` if no other series have data.
4
+ */
5
+ export function getNextSeriesWithData(series, type, seriesId) {
6
+ const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
7
+ const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
8
+ const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
9
+
10
+ // Loop over all series types starting with the current seriesType
11
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
12
+ const typeIndex = (startingTypeIndex + typeGap) % typesAvailable.length;
13
+ const seriesOfType = series[typesAvailable[typeIndex]];
14
+
15
+ // Edge case for the current series type: we don't loop on previous series of the same type.
16
+ const startingSeriesIndex = typeGap === 0 ? currentSeriesIndex + 1 : 0;
17
+ for (let seriesIndex = startingSeriesIndex; seriesIndex < seriesOfType.seriesOrder.length; seriesIndex += 1) {
18
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
19
+ return {
20
+ type: typesAvailable[typeIndex],
21
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
22
+ };
23
+ }
24
+ }
25
+ }
26
+
27
+ // End looping on the initial type up to the initial series (excluded)
28
+ const typeIndex = startingTypeIndex;
29
+ const seriesOfType = series[typesAvailable[typeIndex]];
30
+ const endingSeriesIndex = currentSeriesIndex;
31
+ for (let seriesIndex = 0; seriesIndex < endingSeriesIndex; seriesIndex += 1) {
32
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
33
+ return {
34
+ type: typesAvailable[typeIndex],
35
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
36
+ };
37
+ }
38
+ }
39
+ return null;
40
+ }
41
+
42
+ /**
43
+ * Returns the previous series type and id that contains some data.
44
+ * Returns `null` if no other series have data.
45
+ */
46
+ export function getPreviousSeriesWithData(series, type, seriesId) {
47
+ const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
48
+ const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
49
+ const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
50
+
51
+ // Loop over all series types starting with the current seriesType
52
+ for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
53
+ const typeIndex = (typesAvailable.length + startingTypeIndex - typeGap) % typesAvailable.length;
54
+ const seriesOfType = series[typesAvailable[typeIndex]];
55
+ const maxGap = typeGap === 0 ? startingSeriesIndex + 1 : seriesOfType.seriesOrder.length;
56
+ for (let seriesGap = 1; seriesGap < maxGap; seriesGap += 1) {
57
+ const seriesIndex = (seriesOfType.seriesOrder.length + startingSeriesIndex - seriesGap) % seriesOfType.seriesOrder.length;
58
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
59
+ return {
60
+ type: typesAvailable[typeIndex],
61
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
62
+ };
63
+ }
64
+ }
65
+ }
66
+
67
+ // End looping on the initial type down to the initial series (excluded)
68
+ const typeIndex = startingTypeIndex;
69
+ const seriesOfType = series[typesAvailable[typeIndex]];
70
+ const availableSeriesIds = seriesOfType.seriesOrder;
71
+ for (let seriesIndex = availableSeriesIds.length - 1; seriesIndex > startingSeriesIndex; seriesIndex -= 1) {
72
+ if (seriesOfType.series[seriesOfType.seriesOrder[seriesIndex]].data.length > 0) {
73
+ return {
74
+ type: typesAvailable[typeIndex],
75
+ seriesId: seriesOfType.seriesOrder[seriesIndex]
76
+ };
77
+ }
78
+ }
79
+ return null;
80
+ }
81
+ export function seriesHasData(series, type, seriesId) {
82
+ // @ts-ignore snakey is not in MIT version
83
+ if (type === 'sankey') {
84
+ return false;
85
+ }
86
+ const data = series[type]?.series[seriesId]?.data;
87
+ return data && data.length > 0;
88
+ }
@@ -0,0 +1,210 @@
1
+ 'use client';
2
+
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
4
+ import * as React from 'react';
5
+ import useEventCallback from '@mui/utils/useEventCallback';
6
+ import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
7
+ import { getNextSeriesWithData, getPreviousSeriesWithData, seriesHasData } from "./useChartKeyboardNavigation.helpers.js";
8
+ export const useChartKeyboardNavigation = ({
9
+ params,
10
+ store,
11
+ svgRef
12
+ }) => {
13
+ const focusNextItem = useEventCallback(function focusNextItem() {
14
+ store.update(state => {
15
+ let {
16
+ type,
17
+ seriesId
18
+ } = state.keyboardNavigation.item ?? {};
19
+ if (type === undefined ||
20
+ // @ts-ignore sankey is not in MIT version
21
+ type === 'sankey' || seriesId === undefined || !seriesHasData(state.series.processedSeries, type, seriesId)) {
22
+ const nextSeries = getNextSeriesWithData(state.series.processedSeries, type, seriesId);
23
+ if (nextSeries === null) {
24
+ return _extends({}, state, {
25
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
26
+ item: null // No series to move the focus too.
27
+ })
28
+ });
29
+ }
30
+ type = nextSeries.type;
31
+ seriesId = nextSeries.seriesId;
32
+ }
33
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
34
+ return _extends({}, state, {
35
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
36
+ item: {
37
+ type,
38
+ seriesId,
39
+ dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
40
+ }
41
+ })
42
+ });
43
+ });
44
+ });
45
+ const focusPreviousItem = useEventCallback(function focusPreviousItem() {
46
+ store.update(state => {
47
+ let {
48
+ type,
49
+ seriesId
50
+ } = state.keyboardNavigation.item ?? {};
51
+ if (type === undefined ||
52
+ // @ts-ignore sankey is not in MIT version
53
+ type === 'sankey' || seriesId === undefined || !seriesHasData(state.series.processedSeries, type, seriesId)) {
54
+ const previousSeries = getPreviousSeriesWithData(state.series.processedSeries, type, seriesId);
55
+ if (previousSeries === null) {
56
+ return _extends({}, state, {
57
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
58
+ item: null // No series to move the focus too.} };
59
+ })
60
+ });
61
+ }
62
+ type = previousSeries.type;
63
+ seriesId = previousSeries.seriesId;
64
+ }
65
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
66
+ return _extends({}, state, {
67
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
68
+ item: {
69
+ type,
70
+ seriesId,
71
+ dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
72
+ }
73
+ })
74
+ });
75
+ });
76
+ });
77
+ const focusPreviousSeries = useEventCallback(function focusPreviousSeries() {
78
+ let setNewSeries = false;
79
+ store.update(state => {
80
+ let {
81
+ type,
82
+ seriesId
83
+ } = state.keyboardNavigation.item ?? {};
84
+ const previousSeries = getPreviousSeriesWithData(state.series.processedSeries, type, seriesId);
85
+ if (previousSeries === null) {
86
+ return _extends({}, state, {
87
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
88
+ item: null // No series to move the focus too.
89
+ })
90
+ });
91
+ }
92
+ type = previousSeries.type;
93
+ seriesId = previousSeries.seriesId;
94
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
95
+ setNewSeries = true;
96
+ return _extends({}, state, {
97
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
98
+ item: {
99
+ type,
100
+ seriesId,
101
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
102
+ }
103
+ })
104
+ });
105
+ });
106
+ return setNewSeries;
107
+ });
108
+ const focusNextSeries = useEventCallback(function focusNextSeries() {
109
+ let setNewSeries = false;
110
+ store.update(state => {
111
+ let {
112
+ type,
113
+ seriesId
114
+ } = state.keyboardNavigation.item ?? {};
115
+ const nextSeries = getNextSeriesWithData(state.series.processedSeries, type, seriesId);
116
+ if (nextSeries === null) {
117
+ return _extends({}, state, {
118
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
119
+ item: null // No series to move the focus too.
120
+ })
121
+ });
122
+ }
123
+ type = nextSeries.type;
124
+ seriesId = nextSeries.seriesId;
125
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
126
+ setNewSeries = true;
127
+ return _extends({}, state, {
128
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
129
+ item: {
130
+ type,
131
+ seriesId,
132
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
133
+ }
134
+ })
135
+ });
136
+ });
137
+ return setNewSeries;
138
+ });
139
+ const removeFocus = useEventCallback(function removeFocus() {
140
+ store.update(state => {
141
+ if (state.keyboardNavigation.item === null) {
142
+ return state;
143
+ }
144
+ return _extends({}, state, {
145
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
146
+ item: null
147
+ })
148
+ });
149
+ });
150
+ });
151
+ React.useEffect(() => {
152
+ const element = svgRef.current;
153
+ if (!element || !params.enableKeyboardNavigation) {
154
+ return undefined;
155
+ }
156
+ function keyboardHandler(event) {
157
+ switch (event.key) {
158
+ case 'ArrowRight':
159
+ focusNextItem();
160
+ break;
161
+ case 'ArrowLeft':
162
+ focusPreviousItem();
163
+ break;
164
+ case 'ArrowDown':
165
+ {
166
+ const updatedStore = focusPreviousSeries();
167
+ if (updatedStore) {
168
+ // prevents scrolling
169
+ event.preventDefault();
170
+ }
171
+ break;
172
+ }
173
+ case 'ArrowUp':
174
+ {
175
+ const updatedStore = focusNextSeries();
176
+ if (updatedStore) {
177
+ // prevents scrolling
178
+ event.preventDefault();
179
+ }
180
+ break;
181
+ }
182
+ default:
183
+ break;
184
+ }
185
+ }
186
+ element.addEventListener('keydown', keyboardHandler);
187
+ element.addEventListener('blur', removeFocus);
188
+ return () => {
189
+ element.removeEventListener('keydown', keyboardHandler);
190
+ element.removeEventListener('blur', removeFocus);
191
+ };
192
+ }, [svgRef, focusNextItem, focusPreviousItem, removeFocus, focusPreviousSeries, focusNextSeries, params.enableKeyboardNavigation]);
193
+ useEnhancedEffect(() => store.update(prev => prev.keyboardNavigation.enableKeyboardNavigation === params.enableKeyboardNavigation ? prev : _extends({}, prev, {
194
+ keyboardNavigation: _extends({}, prev.keyboardNavigation, {
195
+ enableKeyboardNavigation: !!params.enableKeyboardNavigation
196
+ })
197
+ })), [store, params.enableKeyboardNavigation]);
198
+ return {
199
+ instance: {}
200
+ };
201
+ };
202
+ useChartKeyboardNavigation.getInitialState = params => ({
203
+ keyboardNavigation: {
204
+ item: null,
205
+ enableKeyboardNavigation: !!params.enableKeyboardNavigation
206
+ }
207
+ });
208
+ useChartKeyboardNavigation.params = {
209
+ enableKeyboardNavigation: true
210
+ };
@@ -0,0 +1,25 @@
1
+ export declare const selectorChartsHasFocusedItem: import("reselect").Selector<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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
2
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
3
+ } & {
4
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
5
+ }, boolean, any[]>;
6
+ export declare const selectorChartsFocusedSeriesType: import("reselect").Selector<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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
7
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
8
+ } & {
9
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
10
+ }, keyof import("../../../index.js").ChartsSeriesConfig | undefined, any[]>;
11
+ export declare const selectorChartsFocusedSeriesId: import("reselect").Selector<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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
12
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
13
+ } & {
14
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
15
+ }, import("../../../index.js").SeriesId | undefined, any[]>;
16
+ export declare const selectorChartsFocusedDataIndex: import("reselect").Selector<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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
17
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
18
+ } & {
19
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
20
+ }, number | undefined, any[]>;
21
+ export declare const selectorChartsIsKeyboardNavigationEnabled: import("reselect").Selector<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("./useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & {
22
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
23
+ } & {
24
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
25
+ }, boolean, any[]>;
@@ -0,0 +1,7 @@
1
+ import { createSelector } from "../../utils/selectors.js";
2
+ const selectKeyboardNavigation = state => state.keyboardNavigation;
3
+ export const selectorChartsHasFocusedItem = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item != null);
4
+ export const selectorChartsFocusedSeriesType = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.type);
5
+ export const selectorChartsFocusedSeriesId = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
6
+ export const selectorChartsFocusedDataIndex = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
7
+ export const selectorChartsIsKeyboardNavigationEnabled = createSelector([selectKeyboardNavigation], keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
@@ -0,0 +1,34 @@
1
+ import { ChartPluginSignature } from "../../models/index.js";
2
+ import { ChartSeriesType } from "../../../../models/seriesType/config.js";
3
+ import { SeriesId } from "../../../../models/seriesType/common.js";
4
+ export interface UseChartKeyboardNavigationInstance {}
5
+ type SeriesItemIdentifier = {
6
+ /**
7
+ * The type of the series
8
+ */
9
+ type: ChartSeriesType;
10
+ /**
11
+ * The id of the series with focus.
12
+ */
13
+ seriesId: SeriesId;
14
+ /**
15
+ * The index of the data point with focus.
16
+ */
17
+ dataIndex: number;
18
+ };
19
+ export interface UseChartKeyboardNavigationState {
20
+ keyboardNavigation: {
21
+ item: null | SeriesItemIdentifier;
22
+ enableKeyboardNavigation: boolean;
23
+ };
24
+ }
25
+ type UseChartKeyboardNavigationParameters = {
26
+ enableKeyboardNavigation?: boolean;
27
+ };
28
+ export type UseChartKeyboardNavigationSignature = ChartPluginSignature<{
29
+ params: UseChartKeyboardNavigationParameters;
30
+ defaultizedParams: UseChartKeyboardNavigationParameters;
31
+ instance: UseChartKeyboardNavigationInstance;
32
+ state: UseChartKeyboardNavigationState;
33
+ }>;
34
+ export {};
@@ -12,6 +12,7 @@ import { getSVGPoint } from "../../../getSVGPoint.js";
12
12
  import { generatePolar2svg, generateSvg2polar, generateSvg2rotation } from "./coordinateTransformation.js";
13
13
  import { getAxisIndex } from "./getAxisIndex.js";
14
14
  import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
15
+ import { checkHasInteractionPlugin } from "../useChartInteraction/checkHasInteractionPlugin.js";
15
16
  export const useChartPolarAxis = ({
16
17
  params,
17
18
  store,
@@ -78,9 +79,10 @@ export const useChartPolarAxis = ({
78
79
  const mousePosition = React.useRef({
79
80
  isInChart: false
80
81
  });
82
+ const hasInteractionPlugin = checkHasInteractionPlugin(instance);
81
83
  React.useEffect(() => {
82
84
  const element = svgRef.current;
83
- if (!isInteractionEnabled || element === null || params.disableAxisListener) {
85
+ if (!isInteractionEnabled || !hasInteractionPlugin || element === null || params.disableAxisListener) {
84
86
  return () => {};
85
87
  }
86
88
 
@@ -94,13 +96,13 @@ export const useChartPolarAxis = ({
94
96
  const panEndHandler = instance.addInteractionListener('panEnd', event => {
95
97
  if (!event.detail.activeGestures.move) {
96
98
  mousePosition.current.isInChart = false;
97
- instance.cleanInteraction();
99
+ instance.cleanInteraction?.();
98
100
  }
99
101
  });
100
102
  const pressEndHandler = instance.addInteractionListener('quickPressEnd', event => {
101
103
  if (!event.detail.activeGestures.move && !event.detail.activeGestures.pan) {
102
104
  mousePosition.current.isInChart = false;
103
- instance.cleanInteraction();
105
+ instance.cleanInteraction?.();
104
106
  }
105
107
  });
106
108
  const gestureHandler = event => {
@@ -112,12 +114,12 @@ export const useChartPolarAxis = ({
112
114
  const svgRect = element.getBoundingClientRect();
113
115
  if (srcEvent.clientX < svgRect.left || srcEvent.clientX > svgRect.right || srcEvent.clientY < svgRect.top || srcEvent.clientY > svgRect.bottom) {
114
116
  mousePosition.current.isInChart = false;
115
- instance.cleanInteraction();
117
+ instance.cleanInteraction?.();
116
118
  return;
117
119
  }
118
120
  const svgPoint = getSVGPoint(element, srcEvent);
119
121
  mousePosition.current.isInChart = true;
120
- instance.setPointerCoordinate(svgPoint);
122
+ instance.setPointerCoordinate?.(svgPoint);
121
123
  return;
122
124
  }
123
125
 
@@ -128,7 +130,7 @@ export const useChartPolarAxis = ({
128
130
  // Test if it's in the drawing area
129
131
  if (!instance.isPointInside(svgPoint.x, svgPoint.y, event.detail.target)) {
130
132
  if (mousePosition.current.isInChart) {
131
- instance?.cleanInteraction();
133
+ instance.cleanInteraction?.();
132
134
  mousePosition.current.isInChart = false;
133
135
  }
134
136
  return;
@@ -139,7 +141,7 @@ export const useChartPolarAxis = ({
139
141
  const maxRadius = radiusAxisWithScale[usedRadiusAxisId].scale.range()[1];
140
142
  if (radiusSquare > maxRadius ** 2) {
141
143
  if (mousePosition.current.isInChart) {
142
- instance?.cleanInteraction();
144
+ instance.cleanInteraction?.();
143
145
  mousePosition.current.isInChart = false;
144
146
  }
145
147
  return;
@@ -158,7 +160,7 @@ export const useChartPolarAxis = ({
158
160
  pressHandler.cleanup();
159
161
  pressEndHandler.cleanup();
160
162
  };
161
- }, [svgRef, store, center, radiusAxisWithScale, usedRadiusAxisId, rotationAxisWithScale, usedRotationAxisId, instance, params.disableAxisListener, isInteractionEnabled, svg2rotation]);
163
+ }, [svgRef, store, center, radiusAxisWithScale, usedRadiusAxisId, rotationAxisWithScale, usedRotationAxisId, instance, params.disableAxisListener, isInteractionEnabled, svg2rotation, hasInteractionPlugin]);
162
164
  React.useEffect(() => {
163
165
  const element = svgRef.current;
164
166
  const onAxisClick = params.onAxisClick;
@@ -69,5 +69,6 @@ export type UseChartPolarAxisSignature<SeriesType extends ChartSeriesType = Char
69
69
  defaultizedParams: UseChartPolarAxisDefaultizedParameters;
70
70
  state: UseChartPolarAxisState;
71
71
  instance: UseChartPolarAxisInstance;
72
- dependencies: [UseChartInteractionSignature, UseChartSeriesSignature<SeriesType>];
72
+ dependencies: [UseChartSeriesSignature<SeriesType>];
73
+ optionalDependencies: [UseChartInteractionSignature];
73
74
  }>;
@@ -1,3 +1,3 @@
1
1
  import type { ChartSeries, ChartSeriesType } from "../../../../models/seriesType/config.js";
2
2
  import type { AllSeriesType } from "../../../../models/seriesType/index.js";
3
- export type GetSeriesWithDefaultValues<T extends ChartSeriesType> = (series: AllSeriesType<T>, seriesIndex: number, colors: string[]) => ChartSeries<T>;
3
+ export type GetSeriesWithDefaultValues<T extends ChartSeriesType> = (series: AllSeriesType<T>, seriesIndex: number, colors: readonly string[]) => ChartSeries<T>;
@@ -1,4 +1,11 @@
1
+ import type { ScaleBand } from '@mui/x-charts-vendor/d3-scale';
1
2
  import { D3OrdinalScale, D3Scale } from "../models/axis.js";
2
3
  export declare function isOrdinalScale<T extends {
3
4
  toString(): string;
5
+ }>(scale: D3Scale<T>): scale is D3OrdinalScale<T>;
6
+ export declare function isBandScale<T extends {
7
+ toString(): string;
8
+ }>(scale: D3Scale<T>): scale is ScaleBand<T>;
9
+ export declare function isPointScale<T extends {
10
+ toString(): string;
4
11
  }>(scale: D3Scale<T>): scale is D3OrdinalScale<T>;
@@ -1,3 +1,9 @@
1
1
  export function isOrdinalScale(scale) {
2
2
  return scale.bandwidth !== undefined;
3
+ }
4
+ export function isBandScale(scale) {
5
+ return isOrdinalScale(scale) && scale.paddingOuter !== undefined;
6
+ }
7
+ export function isPointScale(scale) {
8
+ return isOrdinalScale(scale) && !('paddingOuter' in scale);
3
9
  }