@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
@@ -1,48 +1,67 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { GestureManager, MoveGesture, PanGesture, PinchGesture, PressGesture, TapGesture, TurnWheelGesture } from '@mui/x-internal-gestures/core';
4
+ import { GestureManager, MoveGesture, PanGesture, PinchGesture, PressGesture, TapAndDragGesture, TapGesture, TurnWheelGesture } from '@mui/x-internal-gestures/core';
5
5
  const preventDefault = event => event.preventDefault();
6
6
  export const useChartInteractionListener = ({
7
7
  svgRef
8
8
  }) => {
9
+ const gestureManagerRef = React.useRef(null);
9
10
  React.useEffect(() => {
10
11
  const svg = svgRef.current;
11
- if (!svg) {
12
+ if (!gestureManagerRef.current) {
13
+ gestureManagerRef.current = new GestureManager({
14
+ gestures: [
15
+ // We separate the zoom gestures from the gestures that are not zoom related
16
+ // This allows us to configure the zoom gestures based on the zoom configuration.
17
+ new PanGesture({
18
+ name: 'pan',
19
+ threshold: 0,
20
+ maxPointers: 1
21
+ }), new PanGesture({
22
+ name: 'zoomPan',
23
+ threshold: 0,
24
+ maxPointers: 1,
25
+ preventIf: ['zoomTapAndDrag']
26
+ }), new MoveGesture({
27
+ name: 'move',
28
+ preventIf: ['pan', 'zoomPinch', 'zoomPan'] // Prevent move gesture when pan is active
29
+ }), new PinchGesture({
30
+ name: 'zoomPinch',
31
+ threshold: 5,
32
+ preventIf: ['pan', 'zoomPan']
33
+ }), new TurnWheelGesture({
34
+ name: 'zoomTurnWheel',
35
+ sensitivity: 0.01,
36
+ initialDelta: 1
37
+ }), new TapGesture({
38
+ name: 'tap',
39
+ maxDistance: 10,
40
+ preventIf: ['pan', 'zoomPan', 'zoomPinch']
41
+ }), new PressGesture({
42
+ name: 'quickPress',
43
+ duration: 50,
44
+ maxDistance: 10
45
+ }), new TapAndDragGesture({
46
+ name: 'zoomTapAndDrag',
47
+ tapMaxDistance: 10,
48
+ dragThreshold: 10,
49
+ dragTimeout: 1000
50
+ })]
51
+ });
52
+ }
53
+
54
+ // Assign gesture manager after initialization
55
+ const gestureManager = gestureManagerRef.current;
56
+ if (!svg || !gestureManager) {
12
57
  return undefined;
13
58
  }
14
- const gestureManager = new GestureManager({
15
- gestures: [new PanGesture({
16
- name: 'pan',
17
- threshold: 0,
18
- maxPointers: 1
19
- }), new MoveGesture({
20
- name: 'move',
21
- preventIf: ['pan', 'pinch'] // Prevent move gesture when pan is active
22
- }), new PinchGesture({
23
- name: 'pinch',
24
- threshold: 5,
25
- preventIf: ['pan']
26
- }), new TurnWheelGesture({
27
- name: 'turnWheel',
28
- sensitivity: 0.01,
29
- initialDelta: 1
30
- }), new TapGesture({
31
- name: 'tap',
32
- maxDistance: 10,
33
- preventIf: ['pan', 'pinch']
34
- }), new PressGesture({
35
- name: 'quickPress',
36
- duration: 50,
37
- maxDistance: 10
38
- })]
39
- });
40
- gestureManager.registerElement(['pan', 'move', 'pinch', 'turnWheel', 'tap', 'quickPress'], svg);
59
+ gestureManager.registerElement(['pan', 'move', 'zoomPinch', 'zoomPan', 'zoomTurnWheel', 'tap', 'quickPress', 'zoomTapAndDrag'], svg);
41
60
  return () => {
42
61
  // Cleanup gesture manager
43
- gestureManager.destroy();
62
+ gestureManager.unregisterAllGestures(svg);
44
63
  };
45
- }, [svgRef]);
64
+ }, [svgRef, gestureManagerRef]);
46
65
  const addInteractionListener = React.useCallback((interaction, callback, options) => {
47
66
  // Forcefully cast the svgRef to any, it is annoying to fix the types.
48
67
  const svg = svgRef.current;
@@ -51,6 +70,14 @@ export const useChartInteractionListener = ({
51
70
  cleanup: () => svg?.removeEventListener(interaction, callback)
52
71
  };
53
72
  }, [svgRef]);
73
+ const updateZoomInteractionListeners = React.useCallback((interaction, options) => {
74
+ const svg = svgRef.current;
75
+ const gestureManager = gestureManagerRef.current;
76
+ if (!gestureManager || !svg) {
77
+ return;
78
+ }
79
+ gestureManager.setGestureOptions(interaction, svg, options ?? {});
80
+ }, [svgRef, gestureManagerRef]);
54
81
  React.useEffect(() => {
55
82
  const svg = svgRef.current;
56
83
 
@@ -67,7 +94,8 @@ export const useChartInteractionListener = ({
67
94
  }, [svgRef]);
68
95
  return {
69
96
  instance: {
70
- addInteractionListener
97
+ addInteractionListener,
98
+ updateZoomInteractionListeners
71
99
  }
72
100
  };
73
101
  };
@@ -1,16 +1,23 @@
1
- import { MoveEvent, PanEvent, PinchEvent, PressEvent, TapEvent, TurnWheelEvent } from '@mui/x-internal-gestures/core';
1
+ import { MoveEvent, PanEvent, PanGestureOptions, PinchEvent, PinchGestureOptions, PressEvent, TapEvent, TurnWheelEvent, type TapAndDragEvent, type TapAndDragGestureOptions, type TurnWheelGestureOptions } from '@mui/x-internal-gestures/core';
2
2
  import { ChartPluginSignature } from "../../models/index.js";
3
- export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'pinch' | 'pinchStart' | 'pinchEnd' | 'move' | 'moveStart' | 'moveEnd' | 'quickPress' | 'quickPressEnd' | 'turnWheel' | 'tap';
3
+ export type ChartInteraction = 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd' | 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd' | 'move' | 'moveStart' | 'moveEnd' | 'quickPress' | 'quickPressEnd' | 'zoomTurnWheel' | 'tap';
4
4
  export type InteractionListenerResult = {
5
5
  cleanup: () => void;
6
6
  };
7
7
  export type AddInteractionListener = {
8
- <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
9
- <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pinch' | 'pinchStart' | 'pinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
10
- <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'turnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
8
+ <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'pan' | 'panStart' | 'panEnd' | 'zoomPan' | 'zoomPanStart' | 'zoomPanEnd', callback: (event: PanEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
9
+ <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomPinch' | 'zoomPinchStart' | 'zoomPinchEnd', callback: (event: PinchEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
10
+ <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTurnWheel', callback: (event: TurnWheelEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
11
11
  <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'move' | 'moveStart' | 'moveEnd', callback: (event: MoveEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
12
12
  <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'tap', callback: (event: TapEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
13
13
  <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'quickPress' | 'quickPressEnd', callback: (event: PressEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
14
+ <CustomData extends Record<string, unknown> = Record<string, unknown>>(interaction: 'zoomTapAndDrag' | 'zoomTapAndDragStart' | 'zoomTapAndDragEnd', callback: (event: TapAndDragEvent<CustomData>) => void, options?: boolean | AddEventListenerOptions): InteractionListenerResult;
15
+ };
16
+ export type UpdateZoomInteractionListeners = {
17
+ (interaction: 'zoomPan', options?: Omit<PanGestureOptions<'zoomPan'>, 'name'>): void;
18
+ (interaction: 'zoomPinch', options?: Omit<PinchGestureOptions<'zoomPinch'>, 'name'>): void;
19
+ (interaction: 'zoomTurnWheel', options?: Omit<TurnWheelGestureOptions<'zoomTurnWheel'>, 'name'>): void;
20
+ (interaction: 'zoomTapAndDrag', options?: Omit<TapAndDragGestureOptions<'zoomTapAndDrag'>, 'name'>): void;
14
21
  };
15
22
  export interface UseChartInteractionListenerParameters {}
16
23
  export interface UseChartInteractionListenerState {}
@@ -22,6 +29,13 @@ export interface UseChartInteractionListenerInstance {
22
29
  * @param callback The callback to call when the interaction occurs.
23
30
  */
24
31
  addInteractionListener: AddInteractionListener;
32
+ /**
33
+ * Updates the zoom interaction listeners with the provided options.
34
+ *
35
+ * @param interaction The interaction to update.
36
+ * @param options The options to apply to the interaction.
37
+ */
38
+ updateZoomInteractionListeners: UpdateZoomInteractionListeners;
25
39
  }
26
40
  export type UseChartInteractionListenerSignature = ChartPluginSignature<{
27
41
  params: UseChartInteractionListenerParameters;
@@ -17,7 +17,7 @@ export declare const preprocessSeries: <TSeriesType extends ChartSeriesType>({
17
17
  dataset
18
18
  }: {
19
19
  series: Readonly<AllSeriesType<TSeriesType>[]>;
20
- colors: string[];
20
+ colors: readonly string[];
21
21
  seriesConfig: ChartSeriesConfig<TSeriesType>;
22
22
  dataset?: Readonly<DatasetType>;
23
23
  }) => { [type in TSeriesType]?: SeriesProcessorResult<TSeriesType> | undefined };
@@ -5,11 +5,13 @@ import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
5
5
  import { ComputedAxisConfig, DefaultizedZoomOptions } from "./useChartCartesianAxis.types.js";
6
6
  import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
7
7
  import { GetZoomAxisFilters, ZoomData } from "./zoom.types.js";
8
+ import { ScaleDefinition } from "./getAxisScale.js";
8
9
  export type ComputeResult<T extends ChartsAxisProps> = {
9
10
  axis: ComputedAxisConfig<T>;
10
11
  axisIds: AxisId[];
11
12
  };
12
13
  type ComputeCommonParams<T extends ChartSeriesType = ChartSeriesType> = {
14
+ scales: Record<AxisId, ScaleDefinition>;
13
15
  drawingArea: ChartDrawingArea;
14
16
  formattedSeries: ProcessedSeries<T>;
15
17
  seriesConfig: ChartSeriesConfig<T>;
@@ -1,15 +1,14 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
- import { scaleBand, scalePoint } from '@mui/x-charts-vendor/d3-scale';
3
2
  import { createScalarFormatter } from "../../../defaultValueFormatters.js";
4
- import { isBandScaleConfig, isPointScaleConfig, isSymlogScaleConfig } from "../../../../models/axis.js";
5
- import { getColorScale, getOrdinalColorScale } from "../../../colorScale.js";
6
- import { getTickNumber, scaleTickNumberByRange } from "../../../ticks.js";
3
+ import { isBandScaleConfig, isPointScaleConfig } from "../../../../models/axis.js";
4
+ import { getColorScale, getOrdinalColorScale, getSequentialColorScale } from "../../../colorScale.js";
5
+ import { scaleTickNumberByRange } from "../../../ticks.js";
7
6
  import { getScale } from "../../../getScale.js";
8
7
  import { isDateData, createDateFormatter } from "../../../dateHelpers.js";
9
- import { zoomScaleRange } from "./zoom.js";
10
- import { getAxisExtremum } from "./getAxisExtremum.js";
8
+ import { getAxisExtrema } from "./getAxisExtrema.js";
11
9
  import { getAxisTriggerTooltip } from "./getAxisTriggerTooltip.js";
12
- import { getAxisDomainLimit } from "./getAxisDomainLimit.js";
10
+ import { applyDomainLimit, getActualAxisExtrema, getDomainLimit } from "./getAxisScale.js";
11
+ import { isBandScale, isOrdinalScale } from "../../../scaleGuards.js";
13
12
  function getRange(drawingArea, axisDirection,
14
13
  // | 'rotation' | 'radius',
15
14
  reverse) {
@@ -19,6 +18,7 @@ reverse) {
19
18
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
20
19
  const DEFAULT_BAR_GAP_RATIO = 0.1;
21
20
  export function computeAxisValue({
21
+ scales,
22
22
  drawingArea,
23
23
  formattedSeries,
24
24
  axis: allAxis,
@@ -39,97 +39,91 @@ export function computeAxisValue({
39
39
  const completeAxis = {};
40
40
  allAxis.forEach((eachAxis, axisIndex) => {
41
41
  const axis = eachAxis;
42
+ const scaleDefinition = scales[axis.id];
43
+ let scale = scaleDefinition.scale;
42
44
  const zoomOption = zoomOptions?.[axis.id];
43
45
  const zoom = zoomMap?.get(axis.id);
44
46
  const zoomRange = zoom ? [zoom.start, zoom.end] : [0, 100];
45
47
  const range = getRange(drawingArea, axisDirection, axis.reverse ?? false);
46
- const [minData, maxData] = getAxisExtremum(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, zoom === undefined && !zoomOption ? getFilters : undefined // Do not apply filtering if zoom is already defined.
47
- );
48
48
  const triggerTooltip = !axis.ignoreTooltip && axisIdsTriggeringTooltip.has(axis.id);
49
49
  const data = axis.data ?? [];
50
- if (isBandScaleConfig(axis)) {
51
- const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
52
- const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
50
+ if (isOrdinalScale(scale)) {
53
51
  // Reverse range because ordinal scales are presented from top to bottom on y-axis
54
52
  const scaleRange = axisDirection === 'y' ? [range[1], range[0]] : range;
55
- const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
56
- completeAxis[axis.id] = _extends({
57
- offset: 0,
58
- height: 0,
59
- categoryGapRatio,
60
- barGapRatio,
61
- triggerTooltip
62
- }, axis, {
63
- data,
64
- scale: scaleBand(axis.data, zoomedRange).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2),
65
- tickNumber: axis.data.length,
66
- colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
67
- values: axis.data
68
- }, axis.colorMap)) : getColorScale(axis.colorMap))
69
- });
70
- if (isDateData(axis.data)) {
71
- const dateFormatter = createDateFormatter(axis.data, scaleRange, axis.tickNumber);
72
- completeAxis[axis.id].valueFormatter = axis.valueFormatter ?? dateFormatter;
53
+ if (isBandScale(scale) && isBandScaleConfig(axis)) {
54
+ const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
55
+ const barGapRatio = axis.barGapRatio ?? DEFAULT_BAR_GAP_RATIO;
56
+ completeAxis[axis.id] = _extends({
57
+ offset: 0,
58
+ height: 0,
59
+ categoryGapRatio,
60
+ barGapRatio,
61
+ triggerTooltip
62
+ }, axis, {
63
+ data,
64
+ scale,
65
+ tickNumber: axis.data.length,
66
+ colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
67
+ values: axis.data
68
+ }, axis.colorMap)) : getColorScale(axis.colorMap))
69
+ });
70
+ }
71
+ if (isPointScaleConfig(axis)) {
72
+ completeAxis[axis.id] = _extends({
73
+ offset: 0,
74
+ height: 0,
75
+ triggerTooltip
76
+ }, axis, {
77
+ data,
78
+ scale,
79
+ tickNumber: axis.data.length,
80
+ colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
81
+ values: axis.data
82
+ }, axis.colorMap)) : getColorScale(axis.colorMap))
83
+ });
73
84
  }
74
- }
75
- if (isPointScaleConfig(axis)) {
76
- const scaleRange = axisDirection === 'y' ? [...range].reverse() : range;
77
- const zoomedRange = zoomScaleRange(scaleRange, zoomRange);
78
- completeAxis[axis.id] = _extends({
79
- offset: 0,
80
- height: 0,
81
- triggerTooltip
82
- }, axis, {
83
- data,
84
- scale: scalePoint(axis.data, zoomedRange),
85
- tickNumber: axis.data.length,
86
- colorScale: axis.colorMap && (axis.colorMap.type === 'ordinal' ? getOrdinalColorScale(_extends({
87
- values: axis.data
88
- }, axis.colorMap)) : getColorScale(axis.colorMap))
89
- });
90
85
  if (isDateData(axis.data)) {
91
86
  const dateFormatter = createDateFormatter(axis.data, scaleRange, axis.tickNumber);
92
87
  completeAxis[axis.id].valueFormatter = axis.valueFormatter ?? dateFormatter;
93
88
  }
89
+ return;
94
90
  }
95
91
  if (axis.scaleType === 'band' || axis.scaleType === 'point') {
96
92
  // Could be merged with the two previous "if conditions" but then TS does not get that `axis.scaleType` can't be `band` or `point`.
97
93
  return;
98
94
  }
99
- const scaleType = axis.scaleType ?? 'linear';
100
- const domainLimit = preferStrictDomainInLineCharts ? getAxisDomainLimit(axis, axisDirection, axisIndex, formattedSeries) : axis.domainLimit ?? 'nice';
101
- const axisExtremums = [axis.min ?? minData, axis.max ?? maxData];
102
- if (typeof domainLimit === 'function') {
103
- const {
104
- min,
105
- max
106
- } = domainLimit(minData, maxData);
107
- axisExtremums[0] = min;
108
- axisExtremums[1] = max;
109
- }
110
- const rawTickNumber = getTickNumber(_extends({}, axis, {
111
- range,
112
- domain: axisExtremums
113
- }));
95
+ const rawTickNumber = scaleDefinition.tickNumber;
96
+ const continuousAxis = axis;
97
+ const scaleType = continuousAxis.scaleType ?? 'linear';
114
98
  const tickNumber = scaleTickNumberByRange(rawTickNumber, zoomRange);
115
- const zoomedRange = zoomScaleRange(range, zoomRange);
116
- const scale = getScale(scaleType, axisExtremums, zoomedRange);
117
- if (isSymlogScaleConfig(axis) && axis.constant != null) {
118
- scale.constant(axis.constant);
99
+ const filter = zoom === undefined && !zoomOption ? getFilters : undefined; // Do not apply filtering if zoom is already defined.
100
+ if (filter) {
101
+ const [minData, maxData] = getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, filter);
102
+ scale = scale.copy();
103
+ scale.domain([minData, maxData]);
104
+ const domainLimit = getDomainLimit(axis, axisDirection, axisIndex, formattedSeries, preferStrictDomainInLineCharts);
105
+ const axisExtrema = getActualAxisExtrema(axis, minData, maxData);
106
+ if (typeof domainLimit === 'function') {
107
+ const {
108
+ min,
109
+ max
110
+ } = domainLimit(minData, maxData);
111
+ axisExtrema[0] = min;
112
+ axisExtrema[1] = max;
113
+ }
114
+ scale.domain(axisExtrema);
115
+ applyDomainLimit(scale, axis, domainLimit, rawTickNumber);
119
116
  }
120
- const finalScale = domainLimit === 'nice' ? scale.nice(rawTickNumber) : scale;
121
- const [minDomain, maxDomain] = finalScale.domain();
122
- const domain = [axis.min ?? minDomain, axis.max ?? maxDomain];
123
117
  completeAxis[axis.id] = _extends({
124
118
  offset: 0,
125
119
  height: 0,
126
120
  triggerTooltip
127
- }, axis, {
121
+ }, continuousAxis, {
128
122
  data,
129
- scaleType: scaleType,
130
- scale: finalScale.domain(domain),
123
+ scaleType,
124
+ scale,
131
125
  tickNumber,
132
- colorScale: axis.colorMap && getColorScale(axis.colorMap),
126
+ colorScale: continuousAxis.colorMap && getSequentialColorScale(continuousAxis.colorMap),
133
127
  valueFormatter: axis.valueFormatter ?? createScalarFormatter(tickNumber, getScale(scaleType, range.map(v => scale.invert(v)), range))
134
128
  });
135
129
  });
@@ -1,24 +1,8 @@
1
- import { AxisId, ChartsXAxisProps, ChartsYAxisProps, ContinuousScaleName, ScaleName } from "../../../../models/axis.js";
2
- import { CartesianChartSeriesType } from "../../../../models/seriesType/config.js";
3
- import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
1
+ import { AxisId, D3ContinuousScale, D3Scale } from "../../../../models/axis.js";
4
2
  import { AxisConfig } from "../../../../models/index.js";
5
- import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
6
3
  import { DefaultizedZoomOptions, ExtremumFilter } from "./useChartCartesianAxis.types.js";
7
4
  import { GetZoomAxisFilters, ZoomAxisFilters, ZoomData } from "./zoom.types.js";
8
- export declare function createAxisFilterMapper(params: {
9
- zoomMap: Map<AxisId, ZoomData>;
10
- zoomOptions: Record<AxisId, DefaultizedZoomOptions>;
11
- seriesConfig: ChartSeriesConfig<CartesianChartSeriesType>;
12
- formattedSeries: ProcessedSeries;
13
- direction: 'x';
14
- }): (axis: AxisConfig<ScaleName, any, ChartsXAxisProps>, axisIndex: number) => ExtremumFilter | null;
15
- export declare function createAxisFilterMapper(params: {
16
- zoomMap: Map<AxisId, ZoomData>;
17
- zoomOptions: Record<AxisId, DefaultizedZoomOptions>;
18
- seriesConfig: ChartSeriesConfig<CartesianChartSeriesType>;
19
- formattedSeries: ProcessedSeries;
20
- direction: 'y';
21
- }): (axis: AxisConfig<ScaleName, any, ChartsYAxisProps>, axisIndex: number) => ExtremumFilter | null;
5
+ export declare function createAxisFilterMapper(zoomMap: Map<AxisId, ZoomData>, zoomOptions: Record<AxisId, DefaultizedZoomOptions>, direction: 'x' | 'y'): (axisId: AxisId, axisData: AxisConfig['data'], scale: D3Scale) => ExtremumFilter | null;
22
6
  export declare function createDiscreteScaleGetAxisFilter(axisData: AxisConfig['data'], zoomStart: number, zoomEnd: number, direction: 'x' | 'y'): ExtremumFilter;
23
- export declare function createContinuousScaleGetAxisFilter(scaleType: ContinuousScaleName | undefined, extrema: readonly [number, number], zoomStart: number, zoomEnd: number, direction: 'x' | 'y', axisData: AxisConfig['data']): ExtremumFilter;
7
+ export declare function createContinuousScaleGetAxisFilter(scale: D3ContinuousScale, zoomStart: number, zoomEnd: number, direction: 'x' | 'y', axisData: AxisConfig['data']): ExtremumFilter;
24
8
  export declare const createGetAxisFilters: (filters: ZoomAxisFilters) => GetZoomAxisFilters;
@@ -1,28 +1,20 @@
1
1
  import { isDefined } from "../../../isDefined.js";
2
- import { getAxisExtremum } from "./getAxisExtremum.js";
3
- import { getScale } from "../../../getScale.js";
4
- export function createAxisFilterMapper({
5
- zoomMap,
6
- zoomOptions,
7
- seriesConfig,
8
- formattedSeries,
9
- direction
10
- }) {
11
- return (axis, axisIndex) => {
12
- const zoomOption = zoomOptions[axis.id];
2
+ import { isOrdinalScale } from "../../../scaleGuards.js";
3
+ export function createAxisFilterMapper(zoomMap, zoomOptions, direction) {
4
+ return (axisId, axisData, scale) => {
5
+ const zoomOption = zoomOptions[axisId];
13
6
  if (!zoomOption || zoomOption.filterMode !== 'discard') {
14
7
  return null;
15
8
  }
16
- const zoom = zoomMap?.get(axis.id);
9
+ const zoom = zoomMap?.get(axisId);
17
10
  if (zoom === undefined || zoom.start <= 0 && zoom.end >= 100) {
18
11
  // No zoom, or zoom with all data visible
19
12
  return null;
20
13
  }
21
- const scaleType = axis.scaleType;
22
- if (scaleType === 'point' || scaleType === 'band') {
23
- return createDiscreteScaleGetAxisFilter(axis.data, zoom.start, zoom.end, direction);
14
+ if (isOrdinalScale(scale)) {
15
+ return createDiscreteScaleGetAxisFilter(axisData, zoom.start, zoom.end, direction);
24
16
  }
25
- return createContinuousScaleGetAxisFilter(scaleType, getAxisExtremum(axis, direction, seriesConfig, axisIndex, formattedSeries), zoom.start, zoom.end, direction, axis.data);
17
+ return createContinuousScaleGetAxisFilter(scale, zoom.start, zoom.end, direction, axisData);
26
18
  };
27
19
  }
28
20
  export function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, direction) {
@@ -38,10 +30,10 @@ export function createDiscreteScaleGetAxisFilter(axisData, zoomStart, zoomEnd, d
38
30
  return dataIndex >= minVal && dataIndex < maxVal;
39
31
  };
40
32
  }
41
- export function createContinuousScaleGetAxisFilter(scaleType, extrema, zoomStart, zoomEnd, direction, axisData) {
33
+ export function createContinuousScaleGetAxisFilter(scale, zoomStart, zoomEnd, direction, axisData) {
42
34
  let min;
43
35
  let max;
44
- [min, max] = getScale(scaleType ?? 'linear', extrema, [0, 100]).nice().domain();
36
+ [min, max] = scale.domain();
45
37
  min = min instanceof Date ? min.getTime() : min;
46
38
  max = max instanceof Date ? max.getTime() : max;
47
39
  const minVal = min + zoomStart * (max - min) / 100;
@@ -1,7 +1,7 @@
1
1
  import { AxisConfig } from "../../../../models/axis.js";
2
2
  import { CartesianChartSeriesType } from "../../../../models/seriesType/config.js";
3
3
  import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
4
- export declare const getAxisDomainLimit: <T extends CartesianChartSeriesType>(axis: AxisConfig, axisDirection: "x" | "y", axisIndex: number, formattedSeries: ProcessedSeries<T | "line">) => "nice" | "strict" | ((min: number, max: number) => {
4
+ export declare const getAxisDomainLimit: <T extends CartesianChartSeriesType>(axis: Pick<AxisConfig, "id" | "domainLimit">, axisDirection: "x" | "y", axisIndex: number, formattedSeries: ProcessedSeries<T | "line">) => "nice" | "strict" | ((min: number, max: number) => {
5
5
  min: number;
6
6
  max: number;
7
7
  });
@@ -3,4 +3,4 @@ import { CartesianChartSeriesType } from "../../../../models/seriesType/config.j
3
3
  import { ChartSeriesConfig } from "../../models/seriesConfig/index.js";
4
4
  import { ProcessedSeries } from "../../corePlugins/useChartSeries/useChartSeries.types.js";
5
5
  import { GetZoomAxisFilters } from "./zoom.types.js";
6
- export declare const getAxisExtremum: <T extends CartesianChartSeriesType>(axis: AxisConfig, axisDirection: "x" | "y", seriesConfig: ChartSeriesConfig<T>, axisIndex: number, formattedSeries: ProcessedSeries<T>, getFilters?: GetZoomAxisFilters) => [number, number];
6
+ export declare function getAxisExtrema<T extends CartesianChartSeriesType>(axis: AxisConfig, axisDirection: 'x' | 'y', seriesConfig: ChartSeriesConfig<T>, axisIndex: number, formattedSeries: ProcessedSeries<T>, getFilters?: GetZoomAxisFilters): [number, number];
@@ -0,0 +1,24 @@
1
+ import { isCartesianSeriesType } from "../../../isCartesian.js";
2
+ const axisExtremumCallback = (chartType, axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters) => {
3
+ const getter = axisDirection === 'x' ? seriesConfig[chartType].xExtremumGetter : seriesConfig[chartType].yExtremumGetter;
4
+ const series = formattedSeries[chartType]?.series ?? {};
5
+ return getter?.({
6
+ series,
7
+ axis,
8
+ axisIndex,
9
+ isDefaultAxis: axisIndex === 0,
10
+ getFilters
11
+ }) ?? [Infinity, -Infinity];
12
+ };
13
+ export function getAxisExtrema(axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters) {
14
+ const cartesianChartTypes = Object.keys(seriesConfig).filter(isCartesianSeriesType);
15
+ let extrema = [Infinity, -Infinity];
16
+ for (const chartType of cartesianChartTypes) {
17
+ const [min, max] = axisExtremumCallback(chartType, axis, axisDirection, seriesConfig, axisIndex, formattedSeries, getFilters);
18
+ extrema = [Math.min(extrema[0], min), Math.max(extrema[1], max)];
19
+ }
20
+ if (Number.isNaN(extrema[0]) || Number.isNaN(extrema[1])) {
21
+ return [Infinity, -Infinity];
22
+ }
23
+ return extrema;
24
+ }
@@ -0,0 +1,66 @@
1
+ import { AxisConfig, AxisId, D3ContinuousScale, D3OrdinalScale, DefaultedAxis } from "../../../../models/axis.js";
2
+ import { ChartSeriesType } from "../../../../models/seriesType/config.js";
3
+ import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
4
+ import { ChartSeriesConfig } from "../../models/index.js";
5
+ import { ZoomData } from "./zoom.types.js";
6
+ import { ChartDrawingArea } from "../../../../hooks/useDrawingArea.js";
7
+ type GetAxesScalesParams<T extends ChartSeriesType = ChartSeriesType> = {
8
+ drawingArea: ChartDrawingArea;
9
+ formattedSeries: ProcessedSeries<T>;
10
+ seriesConfig: ChartSeriesConfig<T>;
11
+ zoomMap?: Map<AxisId, ZoomData>;
12
+ /**
13
+ * @deprecated To remove in v9. This is an experimental feature to avoid breaking change.
14
+ */
15
+ preferStrictDomainInLineCharts?: boolean;
16
+ defaultTickNumber: number;
17
+ };
18
+ export declare function getXAxesScales<T extends ChartSeriesType>({
19
+ drawingArea,
20
+ formattedSeries,
21
+ axis: axes,
22
+ seriesConfig,
23
+ zoomMap,
24
+ preferStrictDomainInLineCharts,
25
+ defaultTickNumber
26
+ }: GetAxesScalesParams<T> & {
27
+ axis?: DefaultedAxis[];
28
+ }): Record<AxisId, ScaleDefinition>;
29
+ export declare function getYAxesScales<T extends ChartSeriesType>({
30
+ drawingArea,
31
+ formattedSeries,
32
+ axis: axes,
33
+ seriesConfig,
34
+ zoomMap,
35
+ preferStrictDomainInLineCharts,
36
+ defaultTickNumber
37
+ }: GetAxesScalesParams<T> & {
38
+ axis?: DefaultedAxis[];
39
+ }): Record<AxisId, ScaleDefinition>;
40
+ export type ScaleDefinition = {
41
+ scale: D3ContinuousScale;
42
+ tickNumber: number;
43
+ } | {
44
+ scale: D3OrdinalScale;
45
+ tickNumber?: never;
46
+ };
47
+ type DomainLimit = 'nice' | 'strict' | ((min: number, max: number) => {
48
+ min: number;
49
+ max: number;
50
+ });
51
+ export declare function getDomainLimit(axis: Pick<DefaultedAxis, 'id' | 'domainLimit'>, axisDirection: 'x' | 'y', axisIndex: number, formattedSeries: ProcessedSeries, preferStrictDomainInLineCharts: boolean | undefined): "nice" | "strict" | ((min: number, max: number) => {
52
+ min: number;
53
+ max: number;
54
+ });
55
+ export declare function applyDomainLimit(scale: D3ContinuousScale, axis: {
56
+ min?: number | Date;
57
+ max?: number | Date;
58
+ }, domainLimit: DomainLimit, rawTickNumber: number): void;
59
+ /**
60
+ * Get the actual axis extrema considering the user defined min and max values.
61
+ * @param axisExtrema User defined axis extrema.
62
+ * @param minData Minimum value from the data.
63
+ * @param maxData Maximum value from the data.
64
+ */
65
+ export declare function getActualAxisExtrema(axisExtrema: Pick<AxisConfig, 'min' | 'max'>, minData: number, maxData: number): [number | Date, number | Date];
66
+ export {};