@mui/x-charts 8.11.3 → 8.13.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 (304) 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 +296 -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 +23 -3
  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 +4 -0
  29. package/PieChart/PieArc.js +16 -11
  30. package/PieChart/PieArcPlot.js +28 -3
  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 +23 -3
  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 +4 -0
  87. package/esm/PieChart/PieArc.js +17 -12
  88. package/esm/PieChart/PieArcPlot.js +30 -5
  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/useChartInteractionListener/useChartInteractionListener.js +60 -32
  135. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
  136. package/esm/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
  137. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
  138. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +66 -72
  139. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
  140. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
  141. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
  142. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/{getAxisExtremum.d.ts → getAxisExtrema.d.ts} +1 -1
  143. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +24 -0
  144. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +66 -0
  145. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +121 -0
  146. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
  147. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
  148. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +49 -5
  149. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +20 -0
  150. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +41 -21
  151. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
  152. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
  153. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
  154. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/index.js +2 -0
  155. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
  156. package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +9 -7
  157. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
  158. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +3 -0
  159. package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
  160. package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
  161. package/esm/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +32 -0
  162. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
  163. package/esm/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +5 -0
  164. package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
  165. package/esm/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +3 -0
  166. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
  167. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
  168. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +2 -1
  169. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
  170. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
  171. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +2 -0
  172. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
  173. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
  174. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +88 -0
  175. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +170 -0
  176. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +37 -0
  177. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +33 -0
  178. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +36 -0
  179. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +1 -0
  180. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +2 -5
  181. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
  182. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
  183. package/esm/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
  184. package/esm/internals/scaleGuards.d.ts +7 -0
  185. package/esm/internals/scaleGuards.js +6 -0
  186. package/esm/internals/ticks.d.ts +3 -5
  187. package/esm/internals/ticks.js +6 -5
  188. package/esm/locales/elGR.d.ts +96 -0
  189. package/esm/locales/elGR.js +100 -0
  190. package/esm/locales/enUS.d.ts +96 -0
  191. package/esm/locales/enUS.js +99 -1
  192. package/esm/locales/frFR.d.ts +96 -0
  193. package/esm/locales/frFR.js +100 -2
  194. package/esm/locales/ptBR.d.ts +96 -0
  195. package/esm/locales/ptBR.js +100 -0
  196. package/esm/locales/ptPT.d.ts +96 -0
  197. package/esm/locales/ptPT.js +100 -0
  198. package/esm/locales/svSE.d.ts +97 -1
  199. package/esm/locales/svSE.js +100 -0
  200. package/esm/locales/utils/chartsLocaleTextApi.d.ts +384 -0
  201. package/esm/locales/utils/getChartsLocalization.d.ts +96 -0
  202. package/esm/plugins/index.d.ts +6 -0
  203. package/esm/plugins/index.js +12 -0
  204. package/hooks/useAxis.d.ts +5 -5
  205. package/hooks/useDrawingArea.d.ts +20 -2
  206. package/hooks/useFocusedItem.d.ts +15 -0
  207. package/hooks/useFocusedItem.js +26 -0
  208. package/hooks/useIsItemFocused.d.ts +12 -0
  209. package/hooks/useIsItemFocused.js +20 -0
  210. package/hooks/useIsItemFocusedGetter.d.ts +8 -0
  211. package/hooks/useIsItemFocusedGetter.js +18 -0
  212. package/hooks/useScale.js +6 -0
  213. package/index.d.ts +1 -0
  214. package/index.js +13 -1
  215. package/internals/animation/Transition.js +0 -2
  216. package/internals/index.d.ts +3 -2
  217. package/internals/index.js +20 -8
  218. package/internals/plugins/allPlugins.d.ts +5 -4
  219. package/internals/plugins/allPlugins.js +3 -2
  220. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +59 -31
  221. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +19 -5
  222. package/internals/plugins/corePlugins/useChartSeries/processSeries.d.ts +1 -1
  223. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.d.ts +2 -0
  224. package/internals/plugins/featurePlugins/useChartCartesianAxis/computeAxisValue.js +63 -69
  225. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.d.ts +3 -19
  226. package/internals/plugins/featurePlugins/useChartCartesianAxis/createAxisFilterMapper.js +10 -18
  227. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisDomainLimit.d.ts +1 -1
  228. package/internals/plugins/featurePlugins/useChartCartesianAxis/{getAxisExtremum.d.ts → getAxisExtrema.d.ts} +1 -1
  229. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtrema.js +30 -0
  230. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.d.ts +66 -0
  231. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +131 -0
  232. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.js +8 -6
  233. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.d.ts +2 -0
  234. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisPreview.selectors.js +49 -5
  235. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.d.ts +20 -0
  236. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js +42 -22
  237. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +2 -2
  238. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +30 -7
  239. package/internals/plugins/featurePlugins/useChartClosestPoint/index.d.ts +3 -0
  240. package/internals/plugins/featurePlugins/useChartClosestPoint/index.js +27 -0
  241. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.d.ts +3 -0
  242. package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.js → useChartClosestPoint/useChartClosestPoint.js} +11 -9
  243. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.d.ts +5 -0
  244. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.selectors.js +9 -0
  245. package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.d.ts → useChartClosestPoint/useChartClosestPoint.types.d.ts} +8 -4
  246. package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.d.ts +16 -0
  247. package/internals/plugins/featurePlugins/useChartHighlight/highlightStates.js +41 -0
  248. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.d.ts +4 -0
  249. package/internals/plugins/featurePlugins/useChartHighlight/useChartHighlight.selectors.js +6 -1
  250. package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.d.ts +3 -0
  251. package/internals/plugins/featurePlugins/useChartInteraction/checkHasInteractionPlugin.js +9 -0
  252. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +6 -4
  253. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +6 -1
  254. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.js +3 -2
  255. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +6 -0
  256. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.d.ts +3 -0
  257. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/index.js +27 -0
  258. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.d.ts +3 -0
  259. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +20 -0
  260. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +96 -0
  261. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.js +178 -0
  262. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +37 -0
  263. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +39 -0
  264. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +36 -0
  265. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.js +5 -0
  266. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -4
  267. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.js +10 -8
  268. package/internals/plugins/featurePlugins/useChartPolarAxis/useChartPolarAxis.types.d.ts +2 -1
  269. package/internals/plugins/models/seriesConfig/getSeriesWithDefaultValues.types.d.ts +1 -1
  270. package/internals/scaleGuards.d.ts +7 -0
  271. package/internals/scaleGuards.js +8 -0
  272. package/internals/ticks.d.ts +3 -5
  273. package/internals/ticks.js +7 -5
  274. package/locales/elGR.d.ts +96 -0
  275. package/locales/elGR.js +100 -0
  276. package/locales/enUS.d.ts +96 -0
  277. package/locales/enUS.js +99 -1
  278. package/locales/frFR.d.ts +96 -0
  279. package/locales/frFR.js +100 -2
  280. package/locales/ptBR.d.ts +96 -0
  281. package/locales/ptBR.js +100 -0
  282. package/locales/ptPT.d.ts +96 -0
  283. package/locales/ptPT.js +100 -0
  284. package/locales/svSE.d.ts +97 -1
  285. package/locales/svSE.js +100 -0
  286. package/locales/utils/chartsLocaleTextApi.d.ts +384 -0
  287. package/locales/utils/getChartsLocalization.d.ts +96 -0
  288. package/package.json +5 -5
  289. package/plugins/index.d.ts +6 -0
  290. package/plugins/index.js +47 -0
  291. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -22
  292. package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
  293. package/esm/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -2
  294. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
  295. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
  296. package/esm/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -3
  297. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisExtremum.js +0 -29
  298. package/internals/plugins/featurePlugins/useChartVoronoi/index.d.ts +0 -3
  299. package/internals/plugins/featurePlugins/useChartVoronoi/index.js +0 -27
  300. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.d.ts +0 -3
  301. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.d.ts +0 -5
  302. package/internals/plugins/featurePlugins/useChartVoronoi/useChartVoronoi.selectors.js +0 -9
  303. /package/esm/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
  304. /package/internals/plugins/featurePlugins/{useChartVoronoi/useChartVoronoi.types.js → useChartClosestPoint/useChartClosestPoint.types.js} +0 -0
@@ -0,0 +1,32 @@
1
+ export function isSeriesHighlighted(scope, item, seriesId) {
2
+ return scope?.highlight === 'series' && item?.seriesId === seriesId;
3
+ }
4
+ export function isSeriesFaded(scope, item, seriesId) {
5
+ if (isSeriesHighlighted(scope, item, seriesId)) {
6
+ return false;
7
+ }
8
+ return scope?.fade === 'global' && item != null || scope?.fade === 'series' && item?.seriesId === seriesId;
9
+ }
10
+
11
+ /**
12
+ * Returns the data index of the highlighted item for a specific series.
13
+ * If the item is not highlighted, it returns `null`.
14
+ */
15
+ export function getSeriesHighlightedItem(scope, item, seriesId) {
16
+ return scope?.highlight === 'item' && item?.seriesId === seriesId ? item.dataIndex : null;
17
+ }
18
+
19
+ /**
20
+ * Returns the data index of the "unfaded item" for a specific series.
21
+ * An "unfaded item" is the only item of a faded series that shouldn't be faded.
22
+ * If the series is not faded or if there is no highlighted item, it returns `null`.
23
+ */
24
+ export function getSeriesUnfadedItem(scope, item, seriesId) {
25
+ if (isSeriesHighlighted(scope, item, seriesId)) {
26
+ return null;
27
+ }
28
+ if (getSeriesHighlightedItem(scope, item, seriesId) === item?.dataIndex) {
29
+ return null;
30
+ }
31
+ return (scope?.fade === 'series' || scope?.fade === 'global') && item?.seriesId === seriesId ? item.dataIndex : null;
32
+ }
@@ -27,4 +27,8 @@ export declare const selectorChartsIsFadedCallback: import("reselect").Selector<
27
27
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
28
28
  } & import("./useChartHighlight.types.js").UseChartHighlightState, (item: HighlightItemData | null) => boolean, any[]>;
29
29
  export declare const selectorChartsIsHighlighted: import("reselect").Selector<any, boolean, [item: HighlightItemData | null]>;
30
+ export declare const selectorChartIsSeriesHighlighted: import("reselect").Selector<any, boolean, [seriesId: SeriesId]>;
31
+ export declare const selectorChartIsSeriesFaded: import("reselect").Selector<any, boolean, [seriesId: SeriesId]>;
32
+ export declare const selectorChartSeriesUnfadedItem: import("reselect").Selector<any, number | null | undefined, [seriesId: SeriesId]>;
33
+ export declare const selectorChartSeriesHighlightedItem: import("reselect").Selector<any, number | null | undefined, [seriesId: SeriesId]>;
30
34
  export declare const selectorChartsIsFaded: import("reselect").Selector<any, boolean, [item: HighlightItemData | null]>;
@@ -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
+ }
@@ -7,10 +7,10 @@ export const useChartInteraction = ({
7
7
  const cleanInteraction = useEventCallback(function cleanInteraction() {
8
8
  store.update(prev => {
9
9
  return _extends({}, prev, {
10
- interaction: {
10
+ interaction: _extends({}, prev.interaction, {
11
11
  pointer: null,
12
12
  item: null
13
- }
13
+ })
14
14
  });
15
15
  });
16
16
  });
@@ -51,7 +51,8 @@ export const useChartInteraction = ({
51
51
  const setPointerCoordinate = useEventCallback(function setPointerCoordinate(coordinate) {
52
52
  store.update(prev => _extends({}, prev, {
53
53
  interaction: _extends({}, prev.interaction, {
54
- pointer: coordinate
54
+ pointer: coordinate,
55
+ lastUpdate: coordinate !== null ? 'pointer' : prev.interaction.lastUpdate
55
56
  })
56
57
  }));
57
58
  });
@@ -67,7 +68,8 @@ export const useChartInteraction = ({
67
68
  useChartInteraction.getInitialState = () => ({
68
69
  interaction: {
69
70
  item: null,
70
- pointer: null
71
+ pointer: null,
72
+ lastUpdate: 'pointer'
71
73
  }
72
74
  });
73
75
  useChartInteraction.params = {};
@@ -27,4 +27,9 @@ export declare const selectorChartsInteractionItemIsDefined: import("reselect").
27
27
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
28
28
  } & {
29
29
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
30
- }, boolean, any[]>;
30
+ }, boolean, any[]>;
31
+ export declare const selectorChartsLastInteraction: 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("./useChartInteraction.types.js").UseChartInteractionState> & {
32
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
33
+ } & {
34
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
35
+ }, import("./useChartInteraction.types.js").InteractionUpdateSource | undefined, any[]>;
@@ -5,4 +5,5 @@ export const selectorChartsInteractionItem = createSelector([selectInteraction],
5
5
  export const selectorChartsInteractionPointer = createSelector([selectInteraction], interaction => interaction?.pointer ?? null);
6
6
  export const selectorChartsInteractionPointerX = createSelector([selectorChartsInteractionPointer], pointer => pointer && pointer.x);
7
7
  export const selectorChartsInteractionPointerY = createSelector([selectorChartsInteractionPointer], pointer => pointer && pointer.y);
8
- export const selectorChartsInteractionItemIsDefined = createSelector([selectorChartsInteractionItem], item => item !== null);
8
+ export const selectorChartsInteractionItemIsDefined = createSelector([selectorChartsInteractionItem], item => item !== null);
9
+ export const selectorChartsLastInteraction = createSelector([selectInteraction], interaction => interaction?.lastUpdate);
@@ -4,6 +4,7 @@ export type Coordinate = {
4
4
  x: number;
5
5
  y: number;
6
6
  };
7
+ export type InteractionUpdateSource = 'pointer' | 'keyboard';
7
8
  export interface UseChartInteractionInstance {
8
9
  /**
9
10
  * Remove all interaction.
@@ -35,6 +36,11 @@ export interface UseChartInteractionState {
35
36
  * The x/y SVG coordinate of the "main" pointer
36
37
  */
37
38
  pointer: Coordinate | null;
39
+ /**
40
+ * The last interaction highlight update.
41
+ * Used to decide if highlight should be based on pointer position or keyboard navigation.
42
+ */
43
+ lastUpdate: InteractionUpdateSource;
38
44
  };
39
45
  }
40
46
  export type UseChartInteractionSignature = ChartPluginSignature<{
@@ -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,170 @@
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
+ function getNextIndexFocusedItem(state) {
9
+ let {
10
+ type,
11
+ seriesId
12
+ } = state.keyboardNavigation.item ?? {};
13
+ if (type === undefined ||
14
+ // @ts-ignore sankey is not in MIT version
15
+ type === 'sankey' || seriesId === undefined || !seriesHasData(state.series.processedSeries, type, seriesId)) {
16
+ const nextSeries = getNextSeriesWithData(state.series.processedSeries, type, seriesId);
17
+ if (nextSeries === null) {
18
+ return null;
19
+ }
20
+ type = nextSeries.type;
21
+ seriesId = nextSeries.seriesId;
22
+ }
23
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
24
+ return {
25
+ type,
26
+ seriesId,
27
+ dataIndex: ((state.keyboardNavigation.item?.dataIndex ?? -1) + 1) % dataLength
28
+ };
29
+ }
30
+ function getPreviousIndexFocusedItem(state) {
31
+ let {
32
+ type,
33
+ seriesId
34
+ } = state.keyboardNavigation.item ?? {};
35
+ if (type === undefined ||
36
+ // @ts-ignore sankey is not in MIT version
37
+ type === 'sankey' || seriesId === undefined || !seriesHasData(state.series.processedSeries, type, seriesId)) {
38
+ const previousSeries = getPreviousSeriesWithData(state.series.processedSeries, type, seriesId);
39
+ if (previousSeries === null) {
40
+ return null;
41
+ }
42
+ type = previousSeries.type;
43
+ seriesId = previousSeries.seriesId;
44
+ }
45
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
46
+ return {
47
+ type,
48
+ seriesId,
49
+ dataIndex: (dataLength + (state.keyboardNavigation.item?.dataIndex ?? 1) - 1) % dataLength
50
+ };
51
+ }
52
+ function getNextSeriesFocusedItem(state) {
53
+ let {
54
+ type,
55
+ seriesId
56
+ } = state.keyboardNavigation.item ?? {};
57
+ const nextSeries = getNextSeriesWithData(state.series.processedSeries, type, seriesId);
58
+ if (nextSeries === null) {
59
+ return null; // No series to move the focus to.
60
+ }
61
+ type = nextSeries.type;
62
+ seriesId = nextSeries.seriesId;
63
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
64
+ return {
65
+ type,
66
+ seriesId,
67
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
68
+ };
69
+ }
70
+ function getPreviousSeriesFocusedItem(state) {
71
+ let {
72
+ type,
73
+ seriesId
74
+ } = state.keyboardNavigation.item ?? {};
75
+ const previousSeries = getPreviousSeriesWithData(state.series.processedSeries, type, seriesId);
76
+ if (previousSeries === null) {
77
+ return null; // No series to move the focus to.
78
+ }
79
+ type = previousSeries.type;
80
+ seriesId = previousSeries.seriesId;
81
+ const dataLength = state.series.processedSeries[type].series[seriesId].data.length;
82
+ return {
83
+ type,
84
+ seriesId,
85
+ dataIndex: Math.min(dataLength - 1, state.keyboardNavigation.item?.dataIndex ?? 0)
86
+ };
87
+ }
88
+ export const useChartKeyboardNavigation = ({
89
+ params,
90
+ store,
91
+ svgRef
92
+ }) => {
93
+ const removeFocus = useEventCallback(function removeFocus() {
94
+ store.update(state => {
95
+ if (state.keyboardNavigation.item === null) {
96
+ return state;
97
+ }
98
+ return _extends({}, state, {
99
+ keyboardNavigation: _extends({}, state.keyboardNavigation, {
100
+ item: null
101
+ })
102
+ });
103
+ });
104
+ });
105
+ React.useEffect(() => {
106
+ const element = svgRef.current;
107
+ if (!element || !params.enableKeyboardNavigation) {
108
+ return undefined;
109
+ }
110
+ function keyboardHandler(event) {
111
+ store.update(prevState => {
112
+ let newFocusedItem = prevState.keyboardNavigation.item;
113
+ switch (event.key) {
114
+ case 'ArrowRight':
115
+ newFocusedItem = getNextIndexFocusedItem(prevState);
116
+ break;
117
+ case 'ArrowLeft':
118
+ newFocusedItem = getPreviousIndexFocusedItem(prevState);
119
+ break;
120
+ case 'ArrowDown':
121
+ {
122
+ newFocusedItem = getPreviousSeriesFocusedItem(prevState);
123
+ break;
124
+ }
125
+ case 'ArrowUp':
126
+ {
127
+ newFocusedItem = getNextSeriesFocusedItem(prevState);
128
+ break;
129
+ }
130
+ default:
131
+ break;
132
+ }
133
+ if (newFocusedItem !== prevState.keyboardNavigation.item) {
134
+ event.preventDefault();
135
+ return _extends({}, prevState, prevState.interaction && {
136
+ interaction: _extends({}, prevState.interaction, {
137
+ lastUpdate: 'keyboard'
138
+ })
139
+ }, {
140
+ keyboardNavigation: _extends({}, prevState.keyboardNavigation, {
141
+ item: newFocusedItem
142
+ })
143
+ });
144
+ }
145
+ return prevState;
146
+ });
147
+ }
148
+ element.addEventListener('keydown', keyboardHandler);
149
+ element.addEventListener('blur', removeFocus);
150
+ return () => {
151
+ element.removeEventListener('keydown', keyboardHandler);
152
+ element.removeEventListener('blur', removeFocus);
153
+ };
154
+ }, [svgRef, removeFocus, params.enableKeyboardNavigation, store]);
155
+ useEnhancedEffect(() => store.update(prev => prev.keyboardNavigation.enableKeyboardNavigation === params.enableKeyboardNavigation ? prev : _extends({}, prev, {
156
+ keyboardNavigation: _extends({}, prev.keyboardNavigation, {
157
+ enableKeyboardNavigation: !!params.enableKeyboardNavigation
158
+ })
159
+ })), [store, params.enableKeyboardNavigation]);
160
+ return {};
161
+ };
162
+ useChartKeyboardNavigation.getInitialState = params => ({
163
+ keyboardNavigation: {
164
+ item: null,
165
+ enableKeyboardNavigation: !!params.enableKeyboardNavigation
166
+ }
167
+ });
168
+ useChartKeyboardNavigation.params = {
169
+ enableKeyboardNavigation: true
170
+ };
@@ -0,0 +1,37 @@
1
+ import { SeriesId } from "../../../../models/seriesType/common.js";
2
+ import { AxisItemIdentifier } from "../../../../models/axis.js";
3
+ 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> & {
4
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
5
+ } & {
6
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
7
+ }, boolean, any[]>;
8
+ 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> & {
9
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
10
+ } & {
11
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
12
+ }, keyof import("../../../index.js").ChartsSeriesConfig | undefined, any[]>;
13
+ 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> & {
14
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
15
+ } & {
16
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
17
+ }, SeriesId | undefined, any[]>;
18
+ 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> & {
19
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
20
+ } & {
21
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
22
+ }, number | undefined, any[]>;
23
+ 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> & {
24
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
25
+ } & {
26
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
27
+ }, boolean, any[]>;
28
+ export declare const selectorChartsKeyboardXAxisIndex: 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> & {
29
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
30
+ } & {
31
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
32
+ } & Partial<import("../useChartCartesianAxis/index.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier | undefined, any[]>;
33
+ export declare const selectorChartsKeyboardYAxisIndex: 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> & {
34
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
35
+ } & {
36
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
37
+ } & Partial<import("../useChartCartesianAxis/index.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier | undefined, any[]>;
@@ -0,0 +1,33 @@
1
+ import { createSelector } from "../../utils/selectors.js";
2
+ import { selectorChartSeriesProcessed } from "../../corePlugins/useChartSeries/index.js";
3
+ import { selectorChartXAxis, selectorChartYAxis } from "../useChartCartesianAxis/useChartCartesianAxisRendering.selectors.js";
4
+ const selectKeyboardNavigation = state => state.keyboardNavigation;
5
+ export const selectorChartsHasFocusedItem = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item != null);
6
+ export const selectorChartsFocusedSeriesType = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.type);
7
+ export const selectorChartsFocusedSeriesId = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.seriesId);
8
+ export const selectorChartsFocusedDataIndex = createSelector([selectKeyboardNavigation], keyboardNavigationState => keyboardNavigationState?.item?.dataIndex);
9
+ export const selectorChartsIsKeyboardNavigationEnabled = createSelector([selectKeyboardNavigation], keyboardNavigationState => !!keyboardNavigationState?.enableKeyboardNavigation);
10
+
11
+ /**
12
+ * Selectors to override highlight behavior.
13
+ */
14
+
15
+ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis, series) => {
16
+ if (type === undefined || seriesId === undefined || dataIndex === undefined) {
17
+ return undefined;
18
+ }
19
+ const seriesConfig = series[type]?.series[seriesId];
20
+ if (!seriesConfig) {
21
+ return undefined;
22
+ }
23
+ let axisId = direction === 'x' ? 'xAxisId' in seriesConfig && seriesConfig.xAxisId : 'yAxisId' in seriesConfig && seriesConfig.yAxisId;
24
+ if (axisId === undefined || axisId === false) {
25
+ axisId = axis.axisIds[0];
26
+ }
27
+ return {
28
+ axisId,
29
+ dataIndex
30
+ };
31
+ };
32
+ export const selectorChartsKeyboardXAxisIndex = createSelector([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, selectorChartXAxis, selectorChartSeriesProcessed], createSelectAxisHighlight('x'));
33
+ export const selectorChartsKeyboardYAxisIndex = createSelector([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, selectorChartYAxis, selectorChartSeriesProcessed], createSelectAxisHighlight('y'));
@@ -0,0 +1,36 @@
1
+ import { ChartPluginSignature } from "../../models/index.js";
2
+ import { ChartSeriesType } from "../../../../models/seriesType/config.js";
3
+ import { SeriesId } from "../../../../models/seriesType/common.js";
4
+ import { UseChartInteractionSignature } from "../useChartInteraction/index.js";
5
+ export interface UseChartKeyboardNavigationInstance {}
6
+ type SeriesItemIdentifier = {
7
+ /**
8
+ * The type of the series
9
+ */
10
+ type: ChartSeriesType;
11
+ /**
12
+ * The id of the series with focus.
13
+ */
14
+ seriesId: SeriesId;
15
+ /**
16
+ * The index of the data point with focus.
17
+ */
18
+ dataIndex: number;
19
+ };
20
+ export interface UseChartKeyboardNavigationState {
21
+ keyboardNavigation: {
22
+ item: null | SeriesItemIdentifier;
23
+ enableKeyboardNavigation: boolean;
24
+ };
25
+ }
26
+ type UseChartKeyboardNavigationParameters = {
27
+ enableKeyboardNavigation?: boolean;
28
+ };
29
+ export type UseChartKeyboardNavigationSignature = ChartPluginSignature<{
30
+ params: UseChartKeyboardNavigationParameters;
31
+ defaultizedParams: UseChartKeyboardNavigationParameters;
32
+ instance: UseChartKeyboardNavigationInstance;
33
+ state: UseChartKeyboardNavigationState;
34
+ optionalDependencies: [UseChartInteractionSignature];
35
+ }>;
36
+ export {};
@@ -2,7 +2,7 @@ import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
3
3
  import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
4
4
  import { getColorScale, getOrdinalColorScale } from "../../../colorScale.js";
5
- import { getTickNumber, scaleTickNumberByRange } from "../../../ticks.js";
5
+ import { getDefaultTickNumber, getTickNumber, scaleTickNumberByRange } from "../../../ticks.js";
6
6
  import { getScale } from "../../../getScale.js";
7
7
  import { isDateData, createDateFormatter } from "../../../dateHelpers.js";
8
8
  import { getAxisExtremum } from "./getAxisExtremum.js";
@@ -99,10 +99,7 @@ export function computeAxisValue({
99
99
  axisExtremums[0] = min;
100
100
  axisExtremums[1] = max;
101
101
  }
102
- const rawTickNumber = getTickNumber(_extends({}, axis, {
103
- range,
104
- domain: axisExtremums
105
- }));
102
+ const rawTickNumber = getTickNumber(axis, axisExtremums, getDefaultTickNumber(Math.abs(range[1] - range[0])));
106
103
  const tickNumber = scaleTickNumberByRange(rawTickNumber, range);
107
104
  const scale = getScale(scaleType, axisExtremums, range);
108
105
  const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;