@mui/x-charts 8.14.1 → 8.16.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 (264) hide show
  1. package/BarChart/BarChart.js +8 -0
  2. package/BarChart/BarChart.plugins.d.ts +2 -1
  3. package/BarChart/BarChart.plugins.js +2 -1
  4. package/BarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  5. package/BarChart/seriesConfig/index.js +2 -0
  6. package/BarChart/seriesConfig/tooltipPosition.d.ts +3 -0
  7. package/BarChart/seriesConfig/tooltipPosition.js +67 -0
  8. package/BarChart/useBarChartProps.js +4 -2
  9. package/BarChart/useBarPlotData.d.ts +17 -2
  10. package/BarChart/useBarPlotData.js +59 -34
  11. package/CHANGELOG.md +207 -0
  12. package/ChartContainer/ChartContainer.js +8 -0
  13. package/ChartContainer/useChartContainerProps.js +4 -2
  14. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +2 -1
  15. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +2 -1
  16. package/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
  17. package/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +9 -0
  18. package/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
  19. package/ChartsBrushOverlay/ChartsBrushOverlay.js +102 -0
  20. package/ChartsBrushOverlay/index.d.ts +4 -0
  21. package/ChartsBrushOverlay/index.js +19 -0
  22. package/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  23. package/ChartsReferenceLine/ChartsXReferenceLine.js +13 -8
  24. package/ChartsReferenceLine/ChartsYReferenceLine.js +13 -8
  25. package/ChartsReferenceLine/common.d.ts +3 -1
  26. package/ChartsReferenceLine/common.js +3 -1
  27. package/ChartsTooltip/ChartsTooltip.js +9 -0
  28. package/ChartsTooltip/ChartsTooltipContainer.d.ts +9 -0
  29. package/ChartsTooltip/ChartsTooltipContainer.js +67 -23
  30. package/ChartsTooltip/useItemTooltip.js +7 -14
  31. package/ChartsWrapper/ChartsWrapper.js +2 -1
  32. package/ChartsXAxis/getVisibleLabels.js +45 -25
  33. package/ChartsXAxis/useAxisTicksProps.d.ts +81 -81
  34. package/ChartsYAxis/useAxisTicksProps.d.ts +81 -81
  35. package/LineChart/LineChart.js +8 -0
  36. package/LineChart/LineChart.plugins.d.ts +2 -1
  37. package/LineChart/LineChart.plugins.js +2 -1
  38. package/LineChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  39. package/LineChart/seriesConfig/index.js +2 -0
  40. package/LineChart/seriesConfig/tooltipPosition.d.ts +3 -0
  41. package/LineChart/seriesConfig/tooltipPosition.js +33 -0
  42. package/LineChart/useLineChartProps.js +4 -2
  43. package/PieChart/seriesConfig/getSeriesWithDefaultValues.js +5 -6
  44. package/PieChart/seriesConfig/index.js +2 -0
  45. package/PieChart/seriesConfig/seriesProcessor.js +2 -1
  46. package/PieChart/seriesConfig/tooltipPosition.d.ts +3 -0
  47. package/PieChart/seriesConfig/tooltipPosition.js +75 -0
  48. package/RadarChart/RadarChart.plugins.d.ts +2 -2
  49. package/RadarChart/RadarChart.plugins.js +1 -1
  50. package/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +1 -1
  51. package/RadarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  52. package/ScatterChart/ScatterChart.js +8 -0
  53. package/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  54. package/ScatterChart/ScatterChart.plugins.js +2 -1
  55. package/ScatterChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  56. package/ScatterChart/seriesConfig/index.js +2 -0
  57. package/ScatterChart/seriesConfig/tooltipPosition.d.ts +3 -0
  58. package/ScatterChart/seriesConfig/tooltipPosition.js +33 -0
  59. package/ScatterChart/useScatterChartProps.js +5 -3
  60. package/SparkLineChart/SparkLineChart.js +8 -0
  61. package/context/ChartProvider/ChartProvider.js +1 -1
  62. package/esm/BarChart/BarChart.js +8 -0
  63. package/esm/BarChart/BarChart.plugins.d.ts +2 -1
  64. package/esm/BarChart/BarChart.plugins.js +2 -1
  65. package/esm/BarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  66. package/esm/BarChart/seriesConfig/index.js +2 -0
  67. package/esm/BarChart/seriesConfig/tooltipPosition.d.ts +3 -0
  68. package/esm/BarChart/seriesConfig/tooltipPosition.js +61 -0
  69. package/esm/BarChart/useBarChartProps.js +4 -2
  70. package/esm/BarChart/useBarPlotData.d.ts +17 -2
  71. package/esm/BarChart/useBarPlotData.js +58 -34
  72. package/esm/ChartContainer/ChartContainer.js +8 -0
  73. package/esm/ChartContainer/useChartContainerProps.js +4 -2
  74. package/esm/ChartsAxisHighlight/ChartsXAxisHighlight.js +1 -2
  75. package/esm/ChartsAxisHighlight/ChartsYAxisHighlight.js +1 -2
  76. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.d.ts +12 -0
  77. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.classes.js +2 -0
  78. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.d.ts +6 -0
  79. package/esm/ChartsBrushOverlay/ChartsBrushOverlay.js +95 -0
  80. package/esm/ChartsBrushOverlay/index.d.ts +4 -0
  81. package/esm/ChartsBrushOverlay/index.js +2 -0
  82. package/esm/ChartsReferenceLine/ChartsReferenceLine.js +1 -1
  83. package/esm/ChartsReferenceLine/ChartsXReferenceLine.js +14 -9
  84. package/esm/ChartsReferenceLine/ChartsYReferenceLine.js +14 -9
  85. package/esm/ChartsReferenceLine/common.d.ts +3 -1
  86. package/esm/ChartsReferenceLine/common.js +2 -0
  87. package/esm/ChartsTooltip/ChartsTooltip.js +9 -0
  88. package/esm/ChartsTooltip/ChartsTooltipContainer.d.ts +9 -0
  89. package/esm/ChartsTooltip/ChartsTooltipContainer.js +68 -24
  90. package/esm/ChartsTooltip/useItemTooltip.js +9 -16
  91. package/esm/ChartsWrapper/ChartsWrapper.js +2 -1
  92. package/esm/ChartsXAxis/getVisibleLabels.js +45 -25
  93. package/esm/ChartsXAxis/useAxisTicksProps.d.ts +81 -81
  94. package/esm/ChartsYAxis/useAxisTicksProps.d.ts +81 -81
  95. package/esm/LineChart/LineChart.js +8 -0
  96. package/esm/LineChart/LineChart.plugins.d.ts +2 -1
  97. package/esm/LineChart/LineChart.plugins.js +2 -1
  98. package/esm/LineChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  99. package/esm/LineChart/seriesConfig/index.js +2 -0
  100. package/esm/LineChart/seriesConfig/tooltipPosition.d.ts +3 -0
  101. package/esm/LineChart/seriesConfig/tooltipPosition.js +27 -0
  102. package/esm/LineChart/useLineChartProps.js +4 -2
  103. package/esm/PieChart/seriesConfig/getSeriesWithDefaultValues.js +5 -6
  104. package/esm/PieChart/seriesConfig/index.js +2 -0
  105. package/esm/PieChart/seriesConfig/seriesProcessor.js +2 -1
  106. package/esm/PieChart/seriesConfig/tooltipPosition.d.ts +3 -0
  107. package/esm/PieChart/seriesConfig/tooltipPosition.js +69 -0
  108. package/esm/RadarChart/RadarChart.plugins.d.ts +2 -2
  109. package/esm/RadarChart/RadarChart.plugins.js +1 -1
  110. package/esm/RadarChart/RadarSeriesPlot/useRadarSeriesData.d.ts +1 -1
  111. package/esm/RadarChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  112. package/esm/ScatterChart/ScatterChart.js +8 -0
  113. package/esm/ScatterChart/ScatterChart.plugins.d.ts +2 -1
  114. package/esm/ScatterChart/ScatterChart.plugins.js +2 -1
  115. package/esm/ScatterChart/seriesConfig/getSeriesWithDefaultValues.js +3 -3
  116. package/esm/ScatterChart/seriesConfig/index.js +2 -0
  117. package/esm/ScatterChart/seriesConfig/tooltipPosition.d.ts +3 -0
  118. package/esm/ScatterChart/seriesConfig/tooltipPosition.js +27 -0
  119. package/esm/ScatterChart/useScatterChartProps.js +5 -3
  120. package/esm/SparkLineChart/SparkLineChart.js +8 -0
  121. package/esm/context/ChartProvider/ChartProvider.js +1 -1
  122. package/esm/hooks/index.d.ts +2 -1
  123. package/esm/hooks/index.js +2 -1
  124. package/esm/hooks/useBrush.d.ts +18 -0
  125. package/esm/hooks/useBrush.js +16 -0
  126. package/esm/hooks/useFocusedItem.d.ts +1 -1
  127. package/esm/hooks/useInteractionItemProps.js +6 -2
  128. package/esm/index.d.ts +2 -1
  129. package/esm/index.js +2 -1
  130. package/esm/internals/configInit.d.ts +1 -1
  131. package/esm/internals/domUtils.d.ts +9 -4
  132. package/esm/internals/domUtils.js +115 -52
  133. package/esm/internals/getScale.js +1 -1
  134. package/esm/internals/index.d.ts +3 -1
  135. package/esm/internals/index.js +3 -1
  136. package/esm/internals/isCartesian.d.ts +3 -2
  137. package/esm/internals/isCartesian.js +3 -0
  138. package/esm/internals/plugins/allPlugins.d.ts +4 -3
  139. package/esm/internals/plugins/allPlugins.js +2 -1
  140. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +19 -10
  141. package/esm/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +6 -4
  142. package/esm/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
  143. package/esm/internals/plugins/featurePlugins/useChartBrush/index.js +3 -0
  144. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
  145. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +126 -0
  146. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
  147. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +75 -0
  148. package/esm/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +81 -0
  149. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  150. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  151. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
  152. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
  153. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +1 -1
  154. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
  155. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  156. package/esm/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
  157. package/esm/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +2 -0
  158. package/esm/internals/plugins/featurePlugins/useChartInteraction/index.d.ts +1 -0
  159. package/esm/internals/plugins/featurePlugins/useChartInteraction/index.js +2 -1
  160. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +2 -1
  161. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +1 -1
  162. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +5 -1
  163. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +14 -0
  164. package/esm/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +40 -0
  165. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +3 -0
  166. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +4 -0
  167. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +5 -4
  168. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +8 -4
  169. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +21 -3
  170. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +13 -6
  171. package/esm/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +4 -3
  172. package/esm/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +1 -1
  173. package/esm/internals/plugins/models/seriesConfig/index.d.ts +1 -0
  174. package/esm/internals/plugins/models/seriesConfig/index.js +1 -0
  175. package/esm/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  176. package/esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +24 -0
  177. package/esm/internals/plugins/utils/selectors.d.ts +1 -1
  178. package/esm/internals/scales/index.d.ts +3 -0
  179. package/esm/internals/scales/index.js +3 -0
  180. package/esm/internals/scales/scaleBand.d.ts +25 -0
  181. package/esm/internals/scales/scaleBand.js +159 -0
  182. package/esm/internals/scales/scalePoint.d.ts +25 -0
  183. package/esm/internals/scales/scalePoint.js +41 -0
  184. package/esm/internals/scales/scaleSymlog.d.ts +38 -0
  185. package/esm/internals/{symlogScale.js → scales/scaleSymlog.js} +40 -2
  186. package/esm/locales/elGR.js +97 -99
  187. package/esm/models/seriesType/common.d.ts +3 -2
  188. package/esm/tests/constants.js +1 -0
  189. package/hooks/index.d.ts +2 -1
  190. package/hooks/index.js +12 -0
  191. package/hooks/useBrush.d.ts +18 -0
  192. package/hooks/useBrush.js +21 -0
  193. package/hooks/useFocusedItem.d.ts +1 -1
  194. package/hooks/useInteractionItemProps.js +6 -2
  195. package/index.d.ts +2 -1
  196. package/index.js +13 -1
  197. package/internals/configInit.d.ts +1 -1
  198. package/internals/domUtils.d.ts +9 -4
  199. package/internals/domUtils.js +119 -54
  200. package/internals/getScale.js +2 -2
  201. package/internals/index.d.ts +3 -1
  202. package/internals/index.js +24 -0
  203. package/internals/isCartesian.d.ts +3 -2
  204. package/internals/isCartesian.js +4 -0
  205. package/internals/plugins/allPlugins.d.ts +4 -3
  206. package/internals/plugins/allPlugins.js +2 -1
  207. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.js +19 -10
  208. package/internals/plugins/corePlugins/useChartInteractionListener/useChartInteractionListener.types.d.ts +6 -4
  209. package/internals/plugins/featurePlugins/useChartBrush/index.d.ts +3 -0
  210. package/internals/plugins/featurePlugins/useChartBrush/index.js +38 -0
  211. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.d.ts +3 -0
  212. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.js +134 -0
  213. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.d.ts +82 -0
  214. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.selectors.js +82 -0
  215. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.d.ts +81 -0
  216. package/internals/plugins/featurePlugins/useChartBrush/useChartBrush.types.js +5 -0
  217. package/internals/plugins/featurePlugins/useChartCartesianAxis/createZoomLookup.js +3 -2
  218. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeAxis.js +2 -2
  219. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.d.ts +2 -1
  220. package/internals/plugins/featurePlugins/useChartCartesianAxis/defaultizeZoom.js +8 -3
  221. package/internals/plugins/featurePlugins/useChartCartesianAxis/getAxisScale.js +3 -3
  222. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianAxis.types.d.ts +3 -1
  223. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.d.ts +4 -4
  224. package/internals/plugins/featurePlugins/useChartCartesianAxis/useChartCartesianHighlight.selectors.js +13 -6
  225. package/internals/plugins/featurePlugins/useChartClosestPoint/useChartClosestPoint.js +2 -0
  226. package/internals/plugins/featurePlugins/useChartInteraction/index.d.ts +1 -0
  227. package/internals/plugins/featurePlugins/useChartInteraction/index.js +12 -0
  228. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.js +2 -1
  229. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.selectors.d.ts +1 -1
  230. package/internals/plugins/featurePlugins/useChartInteraction/useChartInteraction.types.d.ts +5 -1
  231. package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.d.ts +14 -0
  232. package/internals/plugins/featurePlugins/useChartInteraction/useChartTooltip.selectors.js +46 -0
  233. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.d.ts +3 -0
  234. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/isFocusableSeriesType.js +10 -0
  235. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.d.ts +5 -4
  236. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.helpers.js +7 -4
  237. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.d.ts +21 -3
  238. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.selectors.js +14 -7
  239. package/internals/plugins/featurePlugins/useChartKeyboardNavigation/useChartKeyboardNavigation.types.d.ts +4 -3
  240. package/internals/plugins/featurePlugins/useChartPolarAxis/computeAxisValue.js +3 -3
  241. package/internals/plugins/models/seriesConfig/index.d.ts +1 -0
  242. package/internals/plugins/models/seriesConfig/index.js +11 -0
  243. package/internals/plugins/models/seriesConfig/seriesConfig.types.d.ts +2 -0
  244. package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.d.ts +24 -0
  245. package/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.js +5 -0
  246. package/internals/plugins/utils/selectors.d.ts +1 -1
  247. package/internals/scales/index.d.ts +3 -0
  248. package/internals/scales/index.js +38 -0
  249. package/internals/scales/scaleBand.d.ts +25 -0
  250. package/internals/scales/scaleBand.js +167 -0
  251. package/internals/scales/scalePoint.d.ts +25 -0
  252. package/internals/scales/scalePoint.js +46 -0
  253. package/internals/scales/scaleSymlog.d.ts +38 -0
  254. package/internals/{symlogScale.js → scales/scaleSymlog.js} +39 -2
  255. package/locales/elGR.js +97 -99
  256. package/models/seriesType/common.d.ts +3 -2
  257. package/package.json +4 -4
  258. package/tests/constants.js +7 -0
  259. package/esm/internals/Flatbush.bench.js +0 -42
  260. package/esm/internals/symlogScale.d.ts +0 -2
  261. package/internals/Flatbush.bench.js +0 -44
  262. package/internals/symlogScale.d.ts +0 -2
  263. /package/esm/internals/{Flatbush.bench.d.ts → plugins/featurePlugins/useChartBrush/useChartBrush.types.js} +0 -0
  264. /package/{internals/Flatbush.bench.d.ts → esm/internals/plugins/models/seriesConfig/tooltipItemPositionGetter.types.js} +0 -0
@@ -0,0 +1,81 @@
1
+ import { ChartPluginSignature } from "../../models/index.js";
2
+ export type Point = {
3
+ x: number;
4
+ y: number;
5
+ };
6
+ export interface UseChartBrushState {
7
+ brush: {
8
+ /**
9
+ * Whether the brush interaction is enabled.
10
+ */
11
+ enabled: boolean;
12
+ /**
13
+ * Whether the zoom brush interaction is enabled.
14
+ */
15
+ isZoomBrushEnabled: boolean;
16
+ /**
17
+ * Whether to prevent tooltip from showing during brush interaction.
18
+ */
19
+ preventTooltip: boolean;
20
+ /**
21
+ * Whether to prevent highlighting during brush interaction.
22
+ */
23
+ preventHighlight: boolean;
24
+ /**
25
+ * The starting coordinate of the brush interaction.
26
+ */
27
+ start: Point | null;
28
+ /**
29
+ * The current coordinate of the brush interaction.
30
+ */
31
+ current: Point | null;
32
+ };
33
+ }
34
+ export interface UseChartBrushInstance {
35
+ /**
36
+ * Set the brush coordinates.
37
+ * @param {Point | null} point The point coordinate, if start value is null, it will set both start and current to this value.
38
+ */
39
+ setBrushCoordinates: (point: Point | null) => void;
40
+ /**
41
+ * Clear the brush coordinates.
42
+ */
43
+ clearBrush: () => void;
44
+ /**
45
+ * Enable or disable the zoom brush interaction.
46
+ * @param {boolean} enabled Whether to enable the zoom brush interaction.
47
+ */
48
+ setZoomBrushEnabled: (enabled: boolean) => void;
49
+ }
50
+ export interface BrushConfig {
51
+ /**
52
+ * Whether the brush interaction is enabled.
53
+ * @default false
54
+ */
55
+ enabled?: boolean;
56
+ /**
57
+ * Whether to prevent tooltip from showing during brush interaction.
58
+ * @default true
59
+ */
60
+ preventTooltip?: boolean;
61
+ /**
62
+ * Whether to prevent highlighting during brush interaction.
63
+ * @default true
64
+ */
65
+ preventHighlight?: boolean;
66
+ }
67
+ export interface UseChartBrushParameters {
68
+ /**
69
+ * Configuration for the brush interaction.
70
+ */
71
+ brushConfig?: BrushConfig;
72
+ }
73
+ export type UseChartBrushDefaultizedParameters = {
74
+ brushConfig: Required<BrushConfig>;
75
+ };
76
+ export type UseChartBrushSignature = ChartPluginSignature<{
77
+ params: UseChartBrushParameters;
78
+ defaultizedParams: UseChartBrushDefaultizedParameters;
79
+ state: UseChartBrushState;
80
+ instance: UseChartBrushInstance;
81
+ }>;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -9,9 +9,10 @@ const createZoomLookup = axisDirection => (axes = []) => axes.reduce((acc, v) =>
9
9
  // @ts-ignore
10
10
  const {
11
11
  zoom,
12
- id: axisId
12
+ id: axisId,
13
+ reverse
13
14
  } = v;
14
- const defaultizedZoom = (0, _defaultizeZoom.defaultizeZoom)(zoom, axisId, axisDirection);
15
+ const defaultizedZoom = (0, _defaultizeZoom.defaultizeZoom)(zoom, axisId, axisDirection, reverse);
15
16
  if (defaultizedZoom) {
16
17
  acc[axisId] = defaultizedZoom;
17
18
  }
@@ -33,7 +33,7 @@ function defaultizeXAxis(inAxes, dataset) {
33
33
  id,
34
34
  position,
35
35
  height: axisConfig.height ?? defaultHeight,
36
- zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'x')
36
+ zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'x', axisConfig.reverse)
37
37
  });
38
38
 
39
39
  // Increment the offset for the next axis
@@ -83,7 +83,7 @@ function defaultizeYAxis(inAxes, dataset) {
83
83
  id,
84
84
  position,
85
85
  width: axisConfig.width ?? defaultWidth,
86
- zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'y')
86
+ zoom: (0, _defaultizeZoom.defaultizeZoom)(axisConfig.zoom, id, 'y', axisConfig.reverse)
87
87
  });
88
88
 
89
89
  // Increment the offset for the next axis
@@ -9,6 +9,7 @@ export declare const defaultZoomOptions: {
9
9
  maxSpan: number;
10
10
  panning: true;
11
11
  filterMode: "keep";
12
+ reverse: false;
12
13
  slider: {
13
14
  enabled: false;
14
15
  preview: false;
@@ -16,4 +17,4 @@ export declare const defaultZoomOptions: {
16
17
  showTooltip: import("./zoom.types.js").ZoomSliderShowTooltip;
17
18
  };
18
19
  };
19
- export declare const defaultizeZoom: (zoom: boolean | ZoomOptions | undefined, axisId: AxisId, axisDirection: "x" | "y") => DefaultizedZoomOptions | undefined;
20
+ export declare const defaultizeZoom: (zoom: boolean | ZoomOptions | undefined, axisId: AxisId, axisDirection: "x" | "y", reverse?: boolean) => DefaultizedZoomOptions | undefined;
@@ -15,6 +15,7 @@ const defaultZoomOptions = exports.defaultZoomOptions = {
15
15
  maxSpan: 100,
16
16
  panning: true,
17
17
  filterMode: 'keep',
18
+ reverse: false,
18
19
  slider: {
19
20
  enabled: false,
20
21
  preview: false,
@@ -22,7 +23,7 @@ const defaultZoomOptions = exports.defaultZoomOptions = {
22
23
  showTooltip: _constants.DEFAULT_ZOOM_SLIDER_SHOW_TOOLTIP
23
24
  }
24
25
  };
25
- const defaultizeZoom = (zoom, axisId, axisDirection) => {
26
+ const defaultizeZoom = (zoom, axisId, axisDirection, reverse) => {
26
27
  if (!zoom) {
27
28
  return undefined;
28
29
  }
@@ -30,12 +31,16 @@ const defaultizeZoom = (zoom, axisId, axisDirection) => {
30
31
  return (0, _extends2.default)({
31
32
  axisId,
32
33
  axisDirection
33
- }, defaultZoomOptions);
34
+ }, defaultZoomOptions, {
35
+ reverse: reverse ?? false
36
+ });
34
37
  }
35
38
  return (0, _extends2.default)({
36
39
  axisId,
37
40
  axisDirection
38
- }, defaultZoomOptions, zoom, {
41
+ }, defaultZoomOptions, {
42
+ reverse: reverse ?? false
43
+ }, zoom, {
39
44
  slider: (0, _extends2.default)({}, defaultZoomOptions.slider, {
40
45
  size: zoom.slider?.preview ?? defaultZoomOptions.slider.preview ? _constants.DEFAULT_ZOOM_SLIDER_PREVIEW_SIZE : _constants.DEFAULT_ZOOM_SLIDER_SIZE
41
46
  }, zoom.slider)
@@ -5,9 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getNormalizedAxisScale = getNormalizedAxisScale;
7
7
  exports.getRange = getRange;
8
- var _d3Scale = require("@mui/x-charts-vendor/d3-scale");
9
8
  var _axis = require("../../../../models/axis");
10
9
  var _getScale = require("../../../getScale");
10
+ var _scales = require("../../../scales");
11
11
  const DEFAULT_CATEGORY_GAP_RATIO = 0.2;
12
12
  function getRange(drawingArea, axisDirection, axis) {
13
13
  const range = axisDirection === 'x' ? [drawingArea.left, drawingArea.left + drawingArea.width] : [drawingArea.top + drawingArea.height, drawingArea.top];
@@ -17,10 +17,10 @@ function getNormalizedAxisScale(axis, domain) {
17
17
  const range = [0, 1];
18
18
  if ((0, _axis.isBandScaleConfig)(axis)) {
19
19
  const categoryGapRatio = axis.categoryGapRatio ?? DEFAULT_CATEGORY_GAP_RATIO;
20
- return (0, _d3Scale.scaleBand)(domain, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2);
20
+ return (0, _scales.scaleBand)(domain, range).paddingInner(categoryGapRatio).paddingOuter(categoryGapRatio / 2);
21
21
  }
22
22
  if ((0, _axis.isPointScaleConfig)(axis)) {
23
- return (0, _d3Scale.scalePoint)(domain, range);
23
+ return (0, _scales.scalePoint)(domain, range);
24
24
  }
25
25
  const scaleType = axis.scaleType ?? 'linear';
26
26
  const scale = (0, _getScale.getScale)(scaleType, domain, range);
@@ -5,6 +5,7 @@ import type { UseChartSeriesSignature } from "../../corePlugins/useChartSeries/i
5
5
  import type { ZoomData, ZoomOptions, ZoomSliderShowTooltip } from "./zoom.types.js";
6
6
  import type { UseChartInteractionSignature } from "../useChartInteraction/index.js";
7
7
  import type { ChartsAxisProps } from "../../../../ChartsAxis/index.js";
8
+ import type { UseChartBrushSignature } from "../useChartBrush/index.js";
8
9
  /**
9
10
  * The axes' configuration after computing.
10
11
  * An axis in this state already contains a scale function and all the necessary properties to be rendered.
@@ -67,6 +68,7 @@ export interface DefaultizedZoomOptions extends Required<Omit<ZoomOptions, 'slid
67
68
  axisId: AxisId;
68
69
  axisDirection: 'x' | 'y';
69
70
  slider: DefaultedZoomSliderOptions;
71
+ reverse: boolean;
70
72
  }
71
73
  export interface UseChartCartesianAxisState {
72
74
  /**
@@ -94,5 +96,5 @@ export type UseChartCartesianAxisSignature<SeriesType extends ChartSeriesType =
94
96
  defaultizedParams: UseChartCartesianAxisDefaultizedParameters;
95
97
  state: UseChartCartesianAxisState;
96
98
  dependencies: [UseChartSeriesSignature<SeriesType>];
97
- optionalDependencies: [UseChartInteractionSignature];
99
+ optionalDependencies: [UseChartInteractionSignature, UseChartBrushSignature];
98
100
  }>;
@@ -3,17 +3,17 @@ export declare const selectorChartsHighlightXAxisIndex: import("reselect").Selec
3
3
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
4
4
  } & {
5
5
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
6
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
6
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
7
7
  export declare const selectorChartsHighlightYAxisIndex: 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/useChartInteraction.types.js").UseChartInteractionState> & {
8
8
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
9
9
  } & {
10
10
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
11
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
11
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, AxisItemIdentifier[], [id?: import("../../../index.js").AxisId | undefined]>;
12
12
  export declare const selectorChartsHighlightXAxisValue: 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/useChartInteraction.types.js").UseChartInteractionState> & {
13
13
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
14
14
  } & {
15
15
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
16
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
16
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, {
17
17
  value: any;
18
18
  axisId: import("../../../index.js").AxisId;
19
19
  dataIndex: number;
@@ -26,7 +26,7 @@ export declare const selectorChartsHighlightYAxisValue: import("reselect").Selec
26
26
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
27
27
  } & {
28
28
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
29
- } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, {
29
+ } & Partial<import("./useChartCartesianAxis.types.js").UseChartCartesianAxisState> & Partial<{}> & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState> & Partial<import("../useChartBrush/index.js").UseChartBrushState>, {
30
30
  value: any;
31
31
  axisId: import("../../../index.js").AxisId;
32
32
  dataIndex: number;
@@ -11,8 +11,12 @@ var _useChartCartesianAxisRendering = require("./useChartCartesianAxisRendering.
11
11
  var _useChartCartesianInteraction = require("./useChartCartesianInteraction.selectors");
12
12
  var _useChartKeyboardNavigation = require("../useChartKeyboardNavigation/useChartKeyboardNavigation.selectors");
13
13
  var _useChartInteraction = require("../useChartInteraction/useChartInteraction.selectors");
14
+ var _useChartBrush = require("../useChartBrush");
14
15
  const selectorChartControlledCartesianAxisHighlight = state => state.controlledCartesianAxisHighlight;
15
- const selectAxisHighlight = (computedIndex, axis, axisItems) => {
16
+ const selectAxisHighlight = (computedIndex, axis, axisItems, isBrushSelectionActive) => {
17
+ if (isBrushSelectionActive) {
18
+ return [];
19
+ }
16
20
  if (axisItems !== undefined) {
17
21
  return axisItems.filter(item => axis.axis[item.axisId] !== undefined).map(item => item);
18
22
  }
@@ -21,9 +25,12 @@ const selectAxisHighlight = (computedIndex, axis, axisItems) => {
21
25
  dataIndex: computedIndex
22
26
  }];
23
27
  };
24
- const selectorChartsHighlightXAxisIndex = exports.selectorChartsHighlightXAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlight);
25
- const selectorChartsHighlightYAxisIndex = exports.selectorChartsHighlightYAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight], selectAxisHighlight);
26
- const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, controlledAxisItems, keyboardAxisItem, lastInteractionUpdate) => {
28
+ const selectorChartsHighlightXAxisIndex = exports.selectorChartsHighlightXAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlight);
29
+ const selectorChartsHighlightYAxisIndex = exports.selectorChartsHighlightYAxisIndex = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlight);
30
+ const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, controlledAxisItems, keyboardAxisItem, lastInteractionUpdate, isBrushSelectionActive) => {
31
+ if (isBrushSelectionActive) {
32
+ return [];
33
+ }
27
34
  if (controlledAxisItems !== undefined) {
28
35
  return controlledAxisItems.map(item => (0, _extends2.default)({}, item, {
29
36
  value: axis.axis[item.axisId]?.data?.[item.dataIndex]
@@ -58,8 +65,8 @@ const selectAxisHighlightWithValue = (computedIndex, computedValue, axis, contro
58
65
  }
59
66
  return [];
60
67
  };
61
- const selectorChartsHighlightXAxisValue = exports.selectorChartsHighlightXAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionXAxisValue, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardXAxisIndex, _useChartInteraction.selectorChartsLastInteraction], selectAxisHighlightWithValue);
62
- const selectorChartsHighlightYAxisValue = exports.selectorChartsHighlightYAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionYAxisValue, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardYAxisIndex, _useChartInteraction.selectorChartsLastInteraction], selectAxisHighlightWithValue);
68
+ const selectorChartsHighlightXAxisValue = exports.selectorChartsHighlightXAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionXAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionXAxisValue, _useChartCartesianAxisRendering.selectorChartXAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardXAxisIndex, _useChartInteraction.selectorChartsLastInteraction, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlightWithValue);
69
+ const selectorChartsHighlightYAxisValue = exports.selectorChartsHighlightYAxisValue = (0, _selectors.createSelector)([_useChartCartesianInteraction.selectorChartsInteractionYAxisIndex, _useChartCartesianInteraction.selectorChartsInteractionYAxisValue, _useChartCartesianAxisRendering.selectorChartYAxis, selectorChartControlledCartesianAxisHighlight, _useChartKeyboardNavigation.selectorChartsKeyboardYAxisIndex, _useChartInteraction.selectorChartsLastInteraction, _useChartBrush.selectorBrushShouldPreventAxisHighlight], selectAxisHighlightWithValue);
63
70
 
64
71
  /**
65
72
  * Get the scale of the axis with highlight if controlled. The default axis otherwise.
@@ -145,6 +145,8 @@ const useChartClosestPoint = ({
145
145
  type: 'scatter',
146
146
  seriesId,
147
147
  dataIndex
148
+ }, {
149
+ interaction: 'pointer'
148
150
  });
149
151
  instance.setHighlight?.({
150
152
  seriesId,
@@ -1,3 +1,4 @@
1
1
  export { useChartInteraction } from "./useChartInteraction.js";
2
2
  export * from "./useChartInteraction.selectors.js";
3
+ export * from "./useChartTooltip.selectors.js";
3
4
  export type { UseChartInteractionSignature } from "./useChartInteraction.types.js";
@@ -24,4 +24,16 @@ Object.keys(_useChartInteraction2).forEach(function (key) {
24
24
  return _useChartInteraction2[key];
25
25
  }
26
26
  });
27
+ });
28
+ var _useChartTooltip = require("./useChartTooltip.selectors");
29
+ Object.keys(_useChartTooltip).forEach(function (key) {
30
+ if (key === "default" || key === "__esModule") return;
31
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
32
+ if (key in exports && exports[key] === _useChartTooltip[key]) return;
33
+ Object.defineProperty(exports, key, {
34
+ enumerable: true,
35
+ get: function () {
36
+ return _useChartTooltip[key];
37
+ }
38
+ });
27
39
  });
@@ -43,13 +43,14 @@ const useChartInteraction = ({
43
43
  });
44
44
  });
45
45
  });
46
- const setItemInteraction = (0, _useEventCallback.default)(function setItemInteraction(newItem) {
46
+ const setItemInteraction = (0, _useEventCallback.default)(function setItemInteraction(newItem, context) {
47
47
  store.update(prev => {
48
48
  if ((0, _fastObjectShallowCompare.fastObjectShallowCompare)(prev.interaction.item, newItem)) {
49
49
  return prev;
50
50
  }
51
51
  return (0, _extends2.default)({}, prev, {
52
52
  interaction: (0, _extends2.default)({}, prev.interaction, {
53
+ lastUpdate: context.interaction,
53
54
  item: newItem
54
55
  })
55
56
  });
@@ -7,7 +7,7 @@ export declare const selectorChartsInteractionItem: import("reselect").Selector<
7
7
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
8
8
  } & {
9
9
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
10
- }, import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null, any[]>;
10
+ }, import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null, any[]>;
11
11
  export declare const selectorChartsInteractionPointer: 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> & {
12
12
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
13
13
  } & {
@@ -13,8 +13,12 @@ export interface UseChartInteractionInstance {
13
13
  /**
14
14
  * Setter for the item the user is interacting with.
15
15
  * @param {ChartItemIdentifier} newItem The identifier of the item.
16
+ * @param {{ interaction: InteractionUpdateSource }} context The context of the interaction.
17
+ * @param {InteractionUpdateSource} context.interaction The source of the interaction update (pointer or keyboard).
16
18
  */
17
- setItemInteraction: (newItem: ChartItemIdentifierWithData<ChartSeriesType>) => void;
19
+ setItemInteraction: (newItem: ChartItemIdentifierWithData<ChartSeriesType>, context: {
20
+ interaction: InteractionUpdateSource;
21
+ }) => void;
18
22
  /**
19
23
  * Remove item interaction if the current if the provided item is still the one interacting.
20
24
  * @param {ChartItemIdentifier} itemToRemove The identifier of the item.
@@ -0,0 +1,14 @@
1
+ export declare const selectorChartsTooltipItem: 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> & {
2
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
3
+ } & {
4
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
5
+ } & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, import("../../../../index.js").LineItemIdentifier | import("../../../../index.js").BarItemIdentifier | import("../../../../index.js").ScatterItemIdentifier | import("../../../../index.js").PieItemIdentifier | import("../../../../index.js").RadarItemIdentifier | null, any[]>;
6
+ export declare const selectorChartsTooltipItemIsDefined: 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> & {
7
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
8
+ } & {
9
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
10
+ } & Partial<import("../useChartKeyboardNavigation/useChartKeyboardNavigation.types.js").UseChartKeyboardNavigationState>, boolean, any[]>;
11
+ export declare const selectorChartsTooltipItemPosition: import("reselect").Selector<any, {
12
+ x: number;
13
+ y: number;
14
+ } | null, [placement?: "bottom" | "left" | "right" | "top" | undefined]>;
@@ -0,0 +1,46 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.selectorChartsTooltipItemPosition = exports.selectorChartsTooltipItemIsDefined = exports.selectorChartsTooltipItem = void 0;
7
+ var _useChartSeries = require("../../corePlugins/useChartSeries");
8
+ var _selectors = require("../../utils/selectors");
9
+ var _useChartCartesianAxisRendering = require("../useChartCartesianAxis/useChartCartesianAxisRendering.selectors");
10
+ var _useChartKeyboardNavigation = require("../useChartKeyboardNavigation");
11
+ var _useChartInteraction = require("./useChartInteraction.selectors");
12
+ var _useChartDimensions = require("../../corePlugins/useChartDimensions/useChartDimensions.selectors");
13
+ var _isCartesian = require("../../../isCartesian");
14
+ const selectorChartsTooltipItem = exports.selectorChartsTooltipItem = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsLastInteraction, _useChartInteraction.selectorChartsInteractionItem, _useChartKeyboardNavigation.selectorChartsKeyboardItem], (lastInteraction, interactionItem, keyboardItem) => lastInteraction === 'keyboard' ? keyboardItem : interactionItem ?? null);
15
+ const selectorChartsTooltipItemIsDefined = exports.selectorChartsTooltipItemIsDefined = (0, _selectors.createSelector)([_useChartInteraction.selectorChartsLastInteraction, _useChartInteraction.selectorChartsInteractionItemIsDefined, _useChartKeyboardNavigation.selectorChartsKeyboardItemIsDefined], (lastInteraction, interactionItemIsDefined, keyboardItemIsDefined) => lastInteraction === 'keyboard' ? keyboardItemIsDefined : interactionItemIsDefined);
16
+ const selectorChartsTooltipItemPosition = exports.selectorChartsTooltipItemPosition = (0, _selectors.createSelector)([selectorChartsTooltipItem, _useChartDimensions.selectorChartDrawingArea, _useChartSeries.selectorChartSeriesConfig, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed, (_, placement) => placement], function selectorChartsTooltipItemPosition(identifier, drawingArea, seriesConfig, {
17
+ axis: xAxis,
18
+ axisIds: xAxisIds
19
+ }, {
20
+ axis: yAxis,
21
+ axisIds: yAxisIds
22
+ }, series, placement = 'top') {
23
+ if (!identifier) {
24
+ return null;
25
+ }
26
+ const itemSeries = series[identifier.type]?.series[identifier.seriesId];
27
+ if (itemSeries) {
28
+ const axesConfig = {};
29
+ const xAxisId = (0, _isCartesian.isCartesianSeries)(itemSeries) ? itemSeries.xAxisId ?? xAxisIds[0] : undefined;
30
+ const yAxisId = (0, _isCartesian.isCartesianSeries)(itemSeries) ? itemSeries.yAxisId ?? yAxisIds[0] : undefined;
31
+ if (xAxisId !== undefined) {
32
+ axesConfig.x = xAxis[xAxisId];
33
+ }
34
+ if (yAxisId !== undefined) {
35
+ axesConfig.y = yAxis[yAxisId];
36
+ }
37
+ return seriesConfig[itemSeries.type].tooltipItemPositionGetter?.({
38
+ series,
39
+ drawingArea,
40
+ axesConfig,
41
+ identifier,
42
+ placement
43
+ }) ?? null;
44
+ }
45
+ return null;
46
+ });
@@ -0,0 +1,3 @@
1
+ import { ChartSeriesType } from "../../../../models/seriesType/config.js";
2
+ import { FocusableSeriesTypes } from "./useChartKeyboardNavigation.types.js";
3
+ export declare function isFocusableSeriesType(type: ChartSeriesType): type is FocusableSeriesTypes;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.isFocusableSeriesType = isFocusableSeriesType;
7
+ const FOCUSABLE_SERIES_TYPES = new Set(['bar', 'line', 'scatter', 'pie']);
8
+ function isFocusableSeriesType(type) {
9
+ return FOCUSABLE_SERIES_TYPES.has(type);
10
+ }
@@ -1,20 +1,21 @@
1
1
  import { ChartSeriesType, ChartsSeriesConfig } from "../../../../models/seriesType/config.js";
2
2
  import { SeriesId } from "../../../../models/seriesType/common.js";
3
3
  import { ProcessedSeries } from "../../corePlugins/useChartSeries/index.js";
4
+ import { FocusableSeriesTypes } from "./useChartKeyboardNavigation.types.js";
4
5
  /**
5
6
  * Returns the next series type and id that contains some data.
6
7
  * Returns `null` if no other series have data.
7
8
  */
8
- export declare function getNextSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
9
- type: Exclude<ChartSeriesType, 'sankey'>;
9
+ export declare function getNextSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: FocusableSeriesTypes, seriesId?: SeriesId): {
10
+ type: FocusableSeriesTypes;
10
11
  seriesId: SeriesId;
11
12
  } | null;
12
13
  /**
13
14
  * Returns the previous series type and id that contains some data.
14
15
  * Returns `null` if no other series have data.
15
16
  */
16
- export declare function getPreviousSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: ChartSeriesType, seriesId?: SeriesId): {
17
- type: Exclude<ChartSeriesType, 'sankey'>;
17
+ export declare function getPreviousSeriesWithData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type?: FocusableSeriesTypes, seriesId?: SeriesId): {
18
+ type: FocusableSeriesTypes;
18
19
  seriesId: SeriesId;
19
20
  } | null;
20
21
  export declare function seriesHasData(series: ProcessedSeries<keyof ChartsSeriesConfig>, type: ChartSeriesType, seriesId: SeriesId): boolean | undefined;
@@ -6,14 +6,16 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.getNextSeriesWithData = getNextSeriesWithData;
7
7
  exports.getPreviousSeriesWithData = getPreviousSeriesWithData;
8
8
  exports.seriesHasData = seriesHasData;
9
+ var _isFocusableSeriesType = require("./isFocusableSeriesType");
9
10
  /**
10
11
  * Returns the next series type and id that contains some data.
11
12
  * Returns `null` if no other series have data.
12
13
  */
13
14
  function getNextSeriesWithData(series, type, seriesId) {
14
- const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
15
+ const seriesType = Object.keys(series);
16
+ const startingTypeIndex = type !== undefined && series[type] ? seriesType.indexOf(type) : 0;
15
17
  const currentSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : -1;
16
- const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
18
+ const typesAvailable = seriesType.filter(_isFocusableSeriesType.isFocusableSeriesType);
17
19
 
18
20
  // Loop over all series types starting with the current seriesType
19
21
  for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
@@ -52,9 +54,10 @@ function getNextSeriesWithData(series, type, seriesId) {
52
54
  * Returns `null` if no other series have data.
53
55
  */
54
56
  function getPreviousSeriesWithData(series, type, seriesId) {
55
- const startingTypeIndex = type !== undefined && series[type] ? Object.keys(series).indexOf(type) : 0;
57
+ const seriesType = Object.keys(series);
58
+ const startingTypeIndex = type !== undefined && series[type] ? seriesType.indexOf(type) : 0;
56
59
  const startingSeriesIndex = type !== undefined && seriesId !== undefined && series[type] && series[type].series[seriesId] ? series[type].seriesOrder.indexOf(seriesId) : 1;
57
- const typesAvailable = Object.keys(series).filter(t => t !== 'sankey');
60
+ const typesAvailable = seriesType.filter(_isFocusableSeriesType.isFocusableSeriesType);
58
61
 
59
62
  // Loop over all series types starting with the current seriesType
60
63
  for (let typeGap = 0; typeGap < typesAvailable.length; typeGap += 1) {
@@ -9,7 +9,7 @@ export declare const selectorChartsFocusedSeriesType: import("reselect").Selecto
9
9
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
10
10
  } & {
11
11
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
12
- }, keyof import("../../../index.js").ChartsSeriesConfig | undefined, any[]>;
12
+ }, "line" | "bar" | "scatter" | "pie" | undefined, any[]>;
13
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
14
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
15
15
  } & {
@@ -40,6 +40,24 @@ export declare const selectorChartsKeyboardItem: import("reselect").Selector<imp
40
40
  } & {
41
41
  cacheKey: import("../../models/index.js").ChartStateCacheKey;
42
42
  }, {
43
+ type: "line";
43
44
  seriesId: SeriesId;
44
- dataIndex: number | undefined;
45
- } | null, any[]>;
45
+ dataIndex: number;
46
+ } | {
47
+ type: "bar";
48
+ seriesId: SeriesId;
49
+ dataIndex: number;
50
+ } | {
51
+ type: "scatter";
52
+ seriesId: SeriesId;
53
+ dataIndex: number;
54
+ } | {
55
+ type: "pie";
56
+ seriesId: SeriesId;
57
+ dataIndex: number;
58
+ } | null, any[]>;
59
+ export declare const selectorChartsKeyboardItemIsDefined: 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> & {
60
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
61
+ } & {
62
+ cacheKey: import("../../models/index.js").ChartStateCacheKey;
63
+ }, boolean, any[]>;
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItem = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesId = exports.selectorChartsFocusedDataIndex = void 0;
6
+ exports.selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardItemIsDefined = exports.selectorChartsKeyboardItem = exports.selectorChartsIsKeyboardNavigationEnabled = exports.selectorChartsHasFocusedItem = exports.selectorChartsFocusedSeriesType = exports.selectorChartsFocusedSeriesId = exports.selectorChartsFocusedDataIndex = void 0;
7
7
  var _selectors = require("../../utils/selectors");
8
8
  var _useChartSeries = require("../../corePlugins/useChartSeries");
9
9
  var _useChartCartesianAxisRendering = require("../useChartCartesianAxis/useChartCartesianAxisRendering.selectors");
@@ -37,12 +37,19 @@ const createSelectAxisHighlight = direction => (type, seriesId, dataIndex, axis,
37
37
  };
38
38
  const selectorChartsKeyboardXAxisIndex = exports.selectorChartsKeyboardXAxisIndex = (0, _selectors.createSelector)([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, _useChartCartesianAxisRendering.selectorChartXAxis, _useChartSeries.selectorChartSeriesProcessed], createSelectAxisHighlight('x'));
39
39
  const selectorChartsKeyboardYAxisIndex = exports.selectorChartsKeyboardYAxisIndex = (0, _selectors.createSelector)([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex, _useChartCartesianAxisRendering.selectorChartYAxis, _useChartSeries.selectorChartSeriesProcessed], createSelectAxisHighlight('y'));
40
- const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _selectors.createSelector)([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex], function selectorChartsKeyboardItem(seriesType, seriesId, dataIndex) {
41
- if (seriesId === undefined) {
40
+ const selectorChartsKeyboardItem = exports.selectorChartsKeyboardItem = (0, _selectors.createSelector)([selectKeyboardNavigation], function selectorChartsKeyboardItem(keyboardState) {
41
+ if (keyboardState?.item == null) {
42
42
  return null;
43
43
  }
44
- return {
45
- seriesId,
46
- dataIndex: seriesType === 'line' ? undefined : dataIndex
47
- };
44
+ const {
45
+ type,
46
+ seriesId
47
+ } = keyboardState.item;
48
+ if (type === undefined || seriesId === undefined) {
49
+ return null;
50
+ }
51
+ return keyboardState.item;
52
+ });
53
+ const selectorChartsKeyboardItemIsDefined = exports.selectorChartsKeyboardItemIsDefined = (0, _selectors.createSelector)([selectorChartsFocusedSeriesType, selectorChartsFocusedSeriesId, selectorChartsFocusedDataIndex], function selectorChartsKeyboardItemIsDefined(seriesType, seriesId, dataIndex) {
54
+ return seriesId !== undefined && dataIndex !== undefined;
48
55
  });
@@ -4,11 +4,11 @@ import { SeriesId } from "../../../../models/seriesType/common.js";
4
4
  import { UseChartInteractionSignature } from "../useChartInteraction/index.js";
5
5
  import { UseChartHighlightSignature } from "../useChartHighlight/index.js";
6
6
  export interface UseChartKeyboardNavigationInstance {}
7
- type SeriesItemIdentifier = {
7
+ type SeriesItemIdentifier<SeriesType extends ChartSeriesType = FocusableSeriesTypes> = SeriesType extends FocusableSeriesTypes ? {
8
8
  /**
9
9
  * The type of the series
10
10
  */
11
- type: ChartSeriesType;
11
+ type: SeriesType;
12
12
  /**
13
13
  * The id of the series with focus.
14
14
  */
@@ -17,7 +17,8 @@ type SeriesItemIdentifier = {
17
17
  * The index of the data point with focus.
18
18
  */
19
19
  dataIndex: number;
20
- };
20
+ } : never;
21
+ export type FocusableSeriesTypes = 'bar' | 'line' | 'scatter' | 'pie';
21
22
  export interface UseChartKeyboardNavigationState {
22
23
  keyboardNavigation: {
23
24
  item: null | SeriesItemIdentifier;