@mui/x-charts 8.0.0-alpha.0 → 8.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (335) hide show
  1. package/BarChart/AnimatedBarElement.d.ts +15 -0
  2. package/BarChart/AnimatedBarElement.js +21 -0
  3. package/BarChart/BarChart.d.ts +4 -9
  4. package/BarChart/BarChart.js +3 -31
  5. package/BarChart/BarElement.d.ts +5 -1342
  6. package/BarChart/BarElement.js +10 -20
  7. package/BarChart/BarPlot.js +12 -2
  8. package/BarChart/useBarChartProps.d.ts +0 -2
  9. package/BarChart/useBarChartProps.js +2 -8
  10. package/CHANGELOG.md +429 -5
  11. package/ChartContainer/ChartContainer.d.ts +2 -19
  12. package/ChartContainer/ChartContainer.js +10 -20
  13. package/ChartContainer/ResizableContainer.d.ts +17 -4
  14. package/ChartContainer/ResizableContainer.js +36 -2
  15. package/ChartContainer/useChartContainerProps.d.ts +6 -7
  16. package/ChartContainer/useChartContainerProps.js +14 -28
  17. package/ChartsAxisHighlight/ChartsAxisHighlight.d.ts +1 -17
  18. package/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
  19. package/ChartsAxisHighlight/ChartsAxisHighlight.types.d.ts +5 -0
  20. package/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
  21. package/ChartsAxisHighlight/ChartsAxisHighlightPath.d.ts +6 -0
  22. package/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
  23. package/ChartsAxisHighlight/ChartsXAxisHighlight.d.ts +10 -0
  24. package/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
  25. package/ChartsAxisHighlight/ChartsYAxisHighlight.d.ts +10 -0
  26. package/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
  27. package/ChartsAxisHighlight/chartsAxisHighlightClasses.d.ts +7 -0
  28. package/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
  29. package/ChartsAxisHighlight/index.d.ts +3 -0
  30. package/ChartsAxisHighlight/index.js +4 -1
  31. package/ChartsGrid/ChartsGrid.js +1 -1
  32. package/ChartsGrid/ChartsHorizontalGrid.d.ts +2 -2
  33. package/ChartsGrid/ChartsHorizontalGrid.js +3 -3
  34. package/ChartsGrid/ChartsVerticalGrid.d.ts +2 -2
  35. package/ChartsGrid/ChartsVerticalGrid.js +3 -3
  36. package/ChartsLegend/LegendPerItem.d.ts +2 -2
  37. package/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  38. package/ChartsSurface/ChartsSurface.d.ts +0 -15
  39. package/ChartsSurface/ChartsSurface.js +35 -34
  40. package/ChartsTooltip/ChartTooltip.types.d.ts +15 -0
  41. package/ChartsTooltip/ChartTooltip.types.js +1 -0
  42. package/ChartsTooltip/ChartsAxisTooltipContent.d.ts +7 -39
  43. package/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  44. package/ChartsTooltip/ChartsItemTooltipContent.d.ts +5 -28
  45. package/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  46. package/ChartsTooltip/ChartsTooltip.d.ts +3 -69
  47. package/ChartsTooltip/ChartsTooltip.js +161 -145
  48. package/ChartsTooltip/ChartsTooltipContainer.d.ts +33 -0
  49. package/ChartsTooltip/ChartsTooltipContainer.js +298 -0
  50. package/ChartsTooltip/chartsTooltipClasses.d.ts +1 -0
  51. package/ChartsTooltip/chartsTooltipClasses.js +18 -2
  52. package/ChartsTooltip/index.d.ts +3 -3
  53. package/ChartsTooltip/index.js +2 -3
  54. package/ChartsTooltip/useAxisTooltip.d.ts +2 -2
  55. package/ChartsTooltip/useAxisTooltip.js +19 -19
  56. package/ChartsTooltip/useItemTooltip.d.ts +1 -1
  57. package/ChartsTooltip/useItemTooltip.js +5 -4
  58. package/ChartsTooltip/utils.d.ts +0 -3
  59. package/ChartsTooltip/utils.js +0 -8
  60. package/ChartsVoronoiHandler/ChartsVoronoiHandler.js +47 -34
  61. package/Gauge/Gauge.d.ts +1 -1
  62. package/Gauge/Gauge.js +0 -6
  63. package/Gauge/GaugeContainer.d.ts +3 -3
  64. package/Gauge/GaugeContainer.js +60 -61
  65. package/LineChart/AnimatedArea.d.ts +0 -1333
  66. package/LineChart/AnimatedArea.js +9 -18
  67. package/LineChart/AnimatedLine.d.ts +0 -1333
  68. package/LineChart/AnimatedLine.js +9 -20
  69. package/LineChart/AreaPlot.js +12 -2
  70. package/LineChart/CircleMarkElement.js +6 -5
  71. package/LineChart/LineChart.d.ts +4 -10
  72. package/LineChart/LineChart.js +3 -32
  73. package/LineChart/LineHighlightPlot.js +6 -5
  74. package/LineChart/LinePlot.js +12 -2
  75. package/LineChart/MarkElement.js +6 -5
  76. package/LineChart/useLineChartProps.d.ts +0 -2
  77. package/LineChart/useLineChartProps.js +2 -8
  78. package/PieChart/PieChart.d.ts +3 -9
  79. package/PieChart/PieChart.js +5 -37
  80. package/PieChart/PiePlot.js +2 -2
  81. package/PieChart/getPieCoordinates.d.ts +2 -2
  82. package/README.md +2 -2
  83. package/ScatterChart/Scatter.js +6 -5
  84. package/ScatterChart/ScatterChart.d.ts +4 -10
  85. package/ScatterChart/ScatterChart.js +5 -32
  86. package/ScatterChart/useScatterChartProps.d.ts +0 -2
  87. package/ScatterChart/useScatterChartProps.js +1 -9
  88. package/SparkLineChart/SparkLineChart.d.ts +3 -4
  89. package/SparkLineChart/SparkLineChart.js +4 -31
  90. package/context/ChartDataProvider/ChartDataProvider.d.ts +9 -19
  91. package/context/ChartDataProvider/ChartDataProvider.js +30 -43
  92. package/context/ChartDataProvider/useChartDataProviderProps.d.ts +7 -10
  93. package/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
  94. package/context/{DrawingProvider.d.ts → DrawingAreaProvider/DrawingArea.types.d.ts} +3 -14
  95. package/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
  96. package/context/DrawingAreaProvider/DrawingAreaContext.d.ts +8 -0
  97. package/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
  98. package/context/DrawingAreaProvider/DrawingAreaProvider.d.ts +3 -0
  99. package/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  100. package/context/DrawingAreaProvider/index.d.ts +3 -0
  101. package/context/DrawingAreaProvider/index.js +3 -0
  102. package/context/InteractionProvider.d.ts +5 -48
  103. package/context/InteractionProvider.js +8 -64
  104. package/context/InteractionSelectors.d.ts +359 -0
  105. package/context/InteractionSelectors.js +12 -0
  106. package/context/SizeProvider/Size.types.d.ts +30 -0
  107. package/context/SizeProvider/Size.types.js +1 -0
  108. package/context/SizeProvider/SizeContext.d.ts +4 -0
  109. package/context/SizeProvider/SizeContext.js +13 -0
  110. package/context/SizeProvider/SizeProvider.d.ts +11 -0
  111. package/context/SizeProvider/SizeProvider.js +26 -0
  112. package/context/SizeProvider/index.d.ts +4 -0
  113. package/context/SizeProvider/index.js +4 -0
  114. package/{ChartContainer → context/SizeProvider}/useChartContainerDimensions.d.ts +4 -1
  115. package/{modern/ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +11 -5
  116. package/context/SizeProvider/useSize.d.ts +5 -0
  117. package/context/SizeProvider/useSize.js +13 -0
  118. package/context/SvgRefProvider/SvgRef.types.d.ts +8 -0
  119. package/context/SvgRefProvider/SvgRef.types.js +1 -0
  120. package/context/SvgRefProvider/SvgRefContext.d.ts +4 -0
  121. package/context/SvgRefProvider/SvgRefContext.js +17 -0
  122. package/context/SvgRefProvider/SvgRefProvider.d.ts +3 -0
  123. package/context/SvgRefProvider/SvgRefProvider.js +24 -0
  124. package/context/SvgRefProvider/index.d.ts +4 -0
  125. package/context/SvgRefProvider/index.js +4 -0
  126. package/context/SvgRefProvider/useSurfaceRef.d.ts +2 -0
  127. package/context/SvgRefProvider/useSurfaceRef.js +14 -0
  128. package/context/index.d.ts +2 -0
  129. package/context/index.js +2 -1
  130. package/hooks/useAxisEvents.js +32 -19
  131. package/hooks/useChartId.js +2 -2
  132. package/hooks/useDrawingArea.d.ts +2 -2
  133. package/hooks/useDrawingArea.js +2 -2
  134. package/hooks/useInteractionItemProps.js +19 -12
  135. package/hooks/useSvgRef.js +3 -3
  136. package/index.js +1 -1
  137. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.d.ts +1 -1
  138. package/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  139. package/internals/computeAxisValue.d.ts +2 -2
  140. package/internals/index.d.ts +3 -2
  141. package/internals/index.js +3 -2
  142. package/internals/plugins/models/index.d.ts +35 -0
  143. package/internals/plugins/models/index.js +1 -0
  144. package/internals/plugins/utils/ChartStore.d.ts +12 -0
  145. package/internals/plugins/utils/ChartStore.js +26 -0
  146. package/internals/plugins/utils/ChartsStore.d.ts +12 -0
  147. package/internals/plugins/utils/ChartsStore.js +26 -0
  148. package/internals/plugins/utils/selectors.d.ts +9 -0
  149. package/internals/plugins/utils/selectors.js +37 -0
  150. package/internals/useCharts.d.ts +6 -0
  151. package/internals/useCharts.js +29 -0
  152. package/internals/useSelector.d.ts +4 -0
  153. package/internals/useSelector.js +6 -0
  154. package/internals/useStore.d.ts +2 -0
  155. package/internals/useStore.js +17 -0
  156. package/modern/BarChart/AnimatedBarElement.js +21 -0
  157. package/modern/BarChart/BarChart.js +3 -31
  158. package/modern/BarChart/BarElement.js +10 -20
  159. package/modern/BarChart/BarPlot.js +12 -2
  160. package/modern/BarChart/useBarChartProps.js +2 -8
  161. package/modern/ChartContainer/ChartContainer.js +10 -20
  162. package/modern/ChartContainer/ResizableContainer.js +36 -2
  163. package/modern/ChartContainer/useChartContainerProps.js +14 -28
  164. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.js +10 -96
  165. package/modern/ChartsAxisHighlight/ChartsAxisHighlight.types.js +1 -0
  166. package/modern/ChartsAxisHighlight/ChartsAxisHighlightPath.js +34 -0
  167. package/modern/ChartsAxisHighlight/ChartsXAxisHighlight.js +53 -0
  168. package/modern/ChartsAxisHighlight/ChartsYAxisHighlight.js +53 -0
  169. package/modern/ChartsAxisHighlight/chartsAxisHighlightClasses.js +6 -0
  170. package/modern/ChartsAxisHighlight/index.js +4 -1
  171. package/modern/ChartsGrid/ChartsGrid.js +1 -1
  172. package/modern/ChartsGrid/ChartsHorizontalGrid.js +3 -3
  173. package/modern/ChartsGrid/ChartsVerticalGrid.js +3 -3
  174. package/modern/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  175. package/modern/ChartsSurface/ChartsSurface.js +35 -34
  176. package/modern/ChartsTooltip/ChartTooltip.types.js +1 -0
  177. package/modern/ChartsTooltip/ChartsAxisTooltipContent.js +83 -72
  178. package/modern/ChartsTooltip/ChartsItemTooltipContent.js +54 -44
  179. package/modern/ChartsTooltip/ChartsTooltip.js +161 -145
  180. package/modern/ChartsTooltip/ChartsTooltipContainer.js +298 -0
  181. package/modern/ChartsTooltip/chartsTooltipClasses.js +18 -2
  182. package/modern/ChartsTooltip/index.js +2 -3
  183. package/modern/ChartsTooltip/useAxisTooltip.js +19 -19
  184. package/modern/ChartsTooltip/useItemTooltip.js +5 -4
  185. package/modern/ChartsTooltip/utils.js +0 -8
  186. package/modern/ChartsVoronoiHandler/ChartsVoronoiHandler.js +47 -34
  187. package/modern/Gauge/Gauge.js +0 -6
  188. package/modern/Gauge/GaugeContainer.js +60 -61
  189. package/modern/LineChart/AnimatedArea.js +9 -18
  190. package/modern/LineChart/AnimatedLine.js +9 -20
  191. package/modern/LineChart/AreaPlot.js +12 -2
  192. package/modern/LineChart/CircleMarkElement.js +6 -5
  193. package/modern/LineChart/LineChart.js +3 -32
  194. package/modern/LineChart/LineHighlightPlot.js +6 -5
  195. package/modern/LineChart/LinePlot.js +12 -2
  196. package/modern/LineChart/MarkElement.js +6 -5
  197. package/modern/LineChart/useLineChartProps.js +2 -8
  198. package/modern/PieChart/PieChart.js +5 -37
  199. package/modern/PieChart/PiePlot.js +2 -2
  200. package/modern/ScatterChart/Scatter.js +6 -5
  201. package/modern/ScatterChart/ScatterChart.js +5 -32
  202. package/modern/ScatterChart/useScatterChartProps.js +1 -9
  203. package/modern/SparkLineChart/SparkLineChart.js +4 -31
  204. package/modern/context/ChartDataProvider/ChartDataProvider.js +30 -43
  205. package/modern/context/ChartDataProvider/useChartDataProviderProps.js +22 -42
  206. package/modern/context/DrawingAreaProvider/DrawingArea.types.js +1 -0
  207. package/modern/context/DrawingAreaProvider/DrawingAreaContext.js +16 -0
  208. package/modern/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +11 -41
  209. package/modern/context/DrawingAreaProvider/index.js +3 -0
  210. package/modern/context/InteractionProvider.js +8 -64
  211. package/modern/context/InteractionSelectors.js +12 -0
  212. package/modern/context/SizeProvider/Size.types.js +1 -0
  213. package/modern/context/SizeProvider/SizeContext.js +13 -0
  214. package/modern/context/SizeProvider/SizeProvider.js +26 -0
  215. package/modern/context/SizeProvider/index.js +4 -0
  216. package/{ChartContainer → modern/context/SizeProvider}/useChartContainerDimensions.js +11 -5
  217. package/modern/context/SizeProvider/useSize.js +13 -0
  218. package/modern/context/SvgRefProvider/SvgRef.types.js +1 -0
  219. package/modern/context/SvgRefProvider/SvgRefContext.js +17 -0
  220. package/modern/context/SvgRefProvider/SvgRefProvider.js +24 -0
  221. package/modern/context/SvgRefProvider/index.js +4 -0
  222. package/modern/context/SvgRefProvider/useSurfaceRef.js +14 -0
  223. package/modern/context/index.js +2 -1
  224. package/modern/hooks/useAxisEvents.js +32 -19
  225. package/modern/hooks/useChartId.js +2 -2
  226. package/modern/hooks/useDrawingArea.js +2 -2
  227. package/modern/hooks/useInteractionItemProps.js +19 -12
  228. package/modern/hooks/useSvgRef.js +3 -3
  229. package/modern/index.js +1 -1
  230. package/modern/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  231. package/modern/internals/index.js +3 -2
  232. package/modern/internals/plugins/models/index.js +1 -0
  233. package/modern/internals/plugins/utils/ChartStore.js +26 -0
  234. package/modern/internals/plugins/utils/ChartsStore.js +26 -0
  235. package/modern/internals/plugins/utils/selectors.js +37 -0
  236. package/modern/internals/useCharts.js +29 -0
  237. package/modern/internals/useSelector.js +6 -0
  238. package/modern/internals/useStore.js +17 -0
  239. package/node/BarChart/AnimatedBarElement.js +28 -0
  240. package/node/BarChart/BarChart.js +3 -31
  241. package/node/BarChart/BarElement.js +11 -21
  242. package/node/BarChart/BarPlot.js +11 -1
  243. package/node/BarChart/useBarChartProps.js +2 -8
  244. package/node/ChartContainer/ChartContainer.js +10 -20
  245. package/node/ChartContainer/ResizableContainer.js +39 -3
  246. package/node/ChartContainer/useChartContainerProps.js +14 -28
  247. package/node/ChartsAxisHighlight/ChartsAxisHighlight.js +12 -100
  248. package/node/ChartsAxisHighlight/ChartsAxisHighlight.types.js +5 -0
  249. package/node/ChartsAxisHighlight/ChartsAxisHighlightPath.js +40 -0
  250. package/node/ChartsAxisHighlight/ChartsXAxisHighlight.js +57 -0
  251. package/node/ChartsAxisHighlight/ChartsYAxisHighlight.js +57 -0
  252. package/node/ChartsAxisHighlight/chartsAxisHighlightClasses.js +14 -0
  253. package/node/ChartsAxisHighlight/index.js +33 -0
  254. package/node/ChartsGrid/ChartsGrid.js +2 -2
  255. package/node/ChartsGrid/ChartsHorizontalGrid.js +4 -4
  256. package/node/ChartsGrid/ChartsVerticalGrid.js +4 -4
  257. package/node/ChartsOnAxisClickHandler/ChartsOnAxisClickHandler.js +9 -7
  258. package/node/ChartsSurface/ChartsSurface.js +35 -34
  259. package/node/ChartsTooltip/ChartTooltip.types.js +5 -0
  260. package/node/ChartsTooltip/ChartsAxisTooltipContent.js +83 -73
  261. package/node/ChartsTooltip/ChartsItemTooltipContent.js +54 -45
  262. package/node/ChartsTooltip/ChartsTooltip.js +160 -144
  263. package/node/ChartsTooltip/ChartsTooltipContainer.js +304 -0
  264. package/node/ChartsTooltip/chartsTooltipClasses.js +22 -3
  265. package/node/ChartsTooltip/index.js +19 -28
  266. package/node/ChartsTooltip/useAxisTooltip.js +19 -19
  267. package/node/ChartsTooltip/useItemTooltip.js +5 -4
  268. package/node/ChartsTooltip/utils.js +0 -9
  269. package/node/ChartsVoronoiHandler/ChartsVoronoiHandler.js +48 -35
  270. package/node/Gauge/Gauge.js +0 -6
  271. package/node/Gauge/GaugeContainer.js +60 -61
  272. package/node/LineChart/AnimatedArea.js +9 -19
  273. package/node/LineChart/AnimatedLine.js +9 -21
  274. package/node/LineChart/AreaPlot.js +11 -1
  275. package/node/LineChart/CircleMarkElement.js +6 -5
  276. package/node/LineChart/LineChart.js +3 -32
  277. package/node/LineChart/LineHighlightPlot.js +6 -5
  278. package/node/LineChart/LinePlot.js +11 -1
  279. package/node/LineChart/MarkElement.js +6 -5
  280. package/node/LineChart/useLineChartProps.js +2 -8
  281. package/node/PieChart/PieChart.js +5 -37
  282. package/node/PieChart/PiePlot.js +2 -2
  283. package/node/ScatterChart/Scatter.js +6 -5
  284. package/node/ScatterChart/ScatterChart.js +5 -32
  285. package/node/ScatterChart/useScatterChartProps.js +1 -9
  286. package/node/SparkLineChart/SparkLineChart.js +4 -31
  287. package/node/context/ChartDataProvider/ChartDataProvider.js +30 -43
  288. package/node/context/ChartDataProvider/useChartDataProviderProps.js +22 -44
  289. package/node/context/DrawingAreaProvider/DrawingArea.types.js +5 -0
  290. package/node/context/DrawingAreaProvider/DrawingAreaContext.js +22 -0
  291. package/node/context/{DrawingProvider.js → DrawingAreaProvider/DrawingAreaProvider.js} +12 -44
  292. package/node/context/DrawingAreaProvider/index.js +38 -0
  293. package/node/context/InteractionProvider.js +9 -66
  294. package/node/context/InteractionSelectors.js +18 -0
  295. package/node/context/SizeProvider/Size.types.js +5 -0
  296. package/node/context/SizeProvider/SizeContext.js +20 -0
  297. package/node/context/SizeProvider/SizeProvider.js +29 -0
  298. package/node/context/SizeProvider/index.js +49 -0
  299. package/node/{ChartContainer → context/SizeProvider}/useChartContainerDimensions.js +11 -5
  300. package/node/context/SizeProvider/useSize.js +20 -0
  301. package/node/context/SvgRefProvider/SvgRef.types.js +5 -0
  302. package/node/context/SvgRefProvider/SvgRefContext.js +23 -0
  303. package/node/context/SvgRefProvider/SvgRefProvider.js +31 -0
  304. package/node/context/SvgRefProvider/index.js +49 -0
  305. package/node/context/SvgRefProvider/useSurfaceRef.js +20 -0
  306. package/node/context/index.js +10 -2
  307. package/node/hooks/useAxisEvents.js +33 -19
  308. package/node/hooks/useChartId.js +2 -2
  309. package/node/hooks/useDrawingArea.js +2 -2
  310. package/node/hooks/useInteractionItemProps.js +20 -13
  311. package/node/hooks/useSvgRef.js +3 -3
  312. package/node/index.js +1 -1
  313. package/node/internals/components/ChartsAxesGradients/ChartsAxesGradients.js +9 -4
  314. package/node/internals/index.js +28 -16
  315. package/node/internals/plugins/models/index.js +5 -0
  316. package/node/internals/plugins/utils/ChartStore.js +33 -0
  317. package/node/internals/plugins/utils/ChartsStore.js +33 -0
  318. package/node/internals/plugins/utils/selectors.js +44 -0
  319. package/node/internals/useCharts.js +36 -0
  320. package/node/internals/useSelector.js +13 -0
  321. package/node/internals/useStore.js +24 -0
  322. package/package.json +7 -5
  323. package/themeAugmentation/props.d.ts +1 -2
  324. package/ChartsTooltip/DefaultChartsAxisTooltipContent.d.ts +0 -7
  325. package/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  326. package/ChartsTooltip/DefaultChartsItemTooltipContent.d.ts +0 -8
  327. package/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  328. package/modern/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -123
  329. package/modern/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -92
  330. package/node/ChartsTooltip/DefaultChartsAxisTooltipContent.js +0 -129
  331. package/node/ChartsTooltip/DefaultChartsItemTooltipContent.js +0 -98
  332. /package/ChartsGrid/{styledCommonents.d.ts → styledComponents.d.ts} +0 -0
  333. /package/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  334. /package/modern/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
  335. /package/node/ChartsGrid/{styledCommonents.js → styledComponents.js} +0 -0
@@ -0,0 +1,26 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SizeContext } from "./SizeContext.js";
5
+ import { useChartContainerDimensions } from "./useChartContainerDimensions.js";
6
+
7
+ /**
8
+ * The size provider.
9
+ *
10
+ * This differs from the DrawingProvider in that it provides the full size of the container.
11
+ *
12
+ * This provider is also responsible for resolving the size of the container before rendering and if the parent size changes.
13
+ */
14
+ import { jsx as _jsx } from "react/jsx-runtime";
15
+ function SizeProvider(props) {
16
+ const dimensions = useChartContainerDimensions(props.width, props.height);
17
+ const value = React.useMemo(() => ({
18
+ isInitialized: true,
19
+ data: dimensions
20
+ }), [dimensions]);
21
+ return /*#__PURE__*/_jsx(SizeContext.Provider, {
22
+ value: value,
23
+ children: props.children
24
+ });
25
+ }
26
+ export { SizeProvider };
@@ -0,0 +1,4 @@
1
+ export * from './SizeProvider';
2
+ export * from './SizeContext';
3
+ export * from './useSize';
4
+ export * from './Size.types';
@@ -0,0 +1,4 @@
1
+ export * from "./SizeProvider.js";
2
+ export * from "./SizeContext.js";
3
+ export * from "./useSize.js";
4
+ export * from "./Size.types.js";
@@ -1,6 +1,9 @@
1
1
  import * as React from 'react';
2
- export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number, resolveSizeBeforeRender?: boolean) => {
2
+ export declare const useChartContainerDimensions: (inWidth?: number, inHeight?: number) => {
3
3
  containerRef: React.RefObject<HTMLDivElement>;
4
4
  width: number;
5
5
  height: number;
6
+ hasIntrinsicSize: boolean;
7
+ inWidth: number | undefined;
8
+ inHeight: number | undefined;
6
9
  };
@@ -4,7 +4,8 @@
4
4
  import * as React from 'react';
5
5
  import useEnhancedEffect from '@mui/utils/useEnhancedEffect';
6
6
  import ownerWindow from '@mui/utils/ownerWindow';
7
- export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBeforeRender) => {
7
+ const MAX_COMPUTE_RUN = 10;
8
+ export const useChartContainerDimensions = (inWidth, inHeight) => {
8
9
  const hasInSize = inWidth !== undefined && inHeight !== undefined;
9
10
  const stateRef = React.useRef({
10
11
  displayError: false,
@@ -42,7 +43,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
42
43
  // https://github.com/mui/mui-x/issues/13477#issuecomment-2336634785
43
44
  useEnhancedEffect(() => {
44
45
  // computeRun is used to avoid infinite loops.
45
- if (hasInSize || !resolveSizeBeforeRender || !stateRef.current.initialCompute || stateRef.current.computeRun > 20) {
46
+ if (hasInSize || !stateRef.current.initialCompute || stateRef.current.computeRun > MAX_COMPUTE_RUN) {
46
47
  return;
47
48
  }
48
49
  const computedSize = computeSize();
@@ -51,7 +52,7 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
51
52
  } else if (stateRef.current.initialCompute) {
52
53
  stateRef.current.initialCompute = false;
53
54
  }
54
- }, [width, height, computeSize, resolveSizeBeforeRender, hasInSize]);
55
+ }, [width, height, computeSize, hasInSize]);
55
56
  useEnhancedEffect(() => {
56
57
  if (hasInSize) {
57
58
  return () => {};
@@ -90,9 +91,14 @@ export const useChartContainerDimensions = (inWidth, inHeight, resolveSizeBefore
90
91
  stateRef.current.displayError = false;
91
92
  }
92
93
  }
94
+ const finalWidth = inWidth ?? width;
95
+ const finalHeight = inHeight ?? height;
93
96
  return {
94
97
  containerRef: rootRef,
95
- width: inWidth ?? width,
96
- height: inHeight ?? height
98
+ width: finalWidth,
99
+ height: finalHeight,
100
+ hasIntrinsicSize: finalWidth > 0 && finalHeight > 0,
101
+ inWidth,
102
+ inHeight
97
103
  };
98
104
  };
@@ -0,0 +1,5 @@
1
+ import { SizeContextState } from './Size.types';
2
+ /**
3
+ * Returns the size of the chart. And the ref of the container element that the chart is rendered in.
4
+ */
5
+ export declare const useSize: () => SizeContextState;
@@ -0,0 +1,13 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SizeContext } from "./SizeContext.js";
5
+ /**
6
+ * Returns the size of the chart. And the ref of the container element that the chart is rendered in.
7
+ */
8
+ export const useSize = () => {
9
+ const {
10
+ data
11
+ } = React.useContext(SizeContext);
12
+ return data;
13
+ };
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export interface SvgRefProviderProps {
3
+ children: React.ReactNode;
4
+ }
5
+ export type SvgRefState = {
6
+ svgRef: React.Ref<SVGSVGElement>;
7
+ surfaceRef: React.Ref<SVGSVGElement>;
8
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ import { Initializable } from '../context.types';
3
+ import { SvgRefState } from './SvgRef.types';
4
+ export declare const SvgRefContext: React.Context<Initializable<SvgRefState>>;
@@ -0,0 +1,17 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ export const SvgRefContext = /*#__PURE__*/React.createContext({
5
+ isInitialized: false,
6
+ data: {
7
+ svgRef: {
8
+ current: null
9
+ },
10
+ surfaceRef: {
11
+ current: null
12
+ }
13
+ }
14
+ });
15
+ if (process.env.NODE_ENV !== 'production') {
16
+ SvgRefContext.displayName = 'SvgRefContext';
17
+ }
@@ -0,0 +1,3 @@
1
+ import * as React from 'react';
2
+ import { SvgRefProviderProps } from './SvgRef.types';
3
+ export declare function SvgRefProvider(props: SvgRefProviderProps): React.JSX.Element;
@@ -0,0 +1,24 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import useForkRef from '@mui/utils/useForkRef';
5
+ import { SvgRefContext } from "./SvgRefContext.js";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ export function SvgRefProvider(props) {
8
+ const {
9
+ children
10
+ } = props;
11
+ const svgRef = React.useRef(null);
12
+ const surfaceRef = useForkRef(svgRef);
13
+ const refValue = React.useMemo(() => ({
14
+ isInitialized: true,
15
+ data: {
16
+ svgRef,
17
+ surfaceRef
18
+ }
19
+ }), [svgRef, surfaceRef]);
20
+ return /*#__PURE__*/_jsx(SvgRefContext.Provider, {
21
+ value: refValue,
22
+ children: children
23
+ });
24
+ }
@@ -0,0 +1,4 @@
1
+ export * from './SvgRef.types';
2
+ export * from './SvgRefProvider';
3
+ export * from './SvgRefContext';
4
+ export * from './useSurfaceRef';
@@ -0,0 +1,4 @@
1
+ export * from "./SvgRef.types.js";
2
+ export * from "./SvgRefProvider.js";
3
+ export * from "./SvgRefContext.js";
4
+ export * from "./useSurfaceRef.js";
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare function useSurfaceRef(): React.MutableRefObject<SVGSVGElement>;
@@ -0,0 +1,14 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import { SvgRefContext } from "./SvgRefContext.js";
5
+ export function useSurfaceRef() {
6
+ const {
7
+ isInitialized,
8
+ data
9
+ } = React.useContext(SvgRefContext);
10
+ if (!isInitialized) {
11
+ throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
12
+ }
13
+ return data.surfaceRef;
14
+ }
@@ -1,3 +1,5 @@
1
1
  export * from './HighlightedProvider';
2
2
  export { ZAxisContextProvider } from './ZAxisContextProvider';
3
3
  export type { ZAxisContextProviderProps } from './ZAxisContextProvider';
4
+ export { ChartDataProvider } from './ChartDataProvider';
5
+ export type { ChartDataProviderProps } from './ChartDataProvider';
package/context/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from "./HighlightedProvider/index.js";
2
- export { ZAxisContextProvider } from "./ZAxisContextProvider.js";
2
+ export { ZAxisContextProvider } from "./ZAxisContextProvider.js";
3
+ export { ChartDataProvider } from "./ChartDataProvider/index.js";
@@ -1,12 +1,13 @@
1
1
  'use client';
2
2
 
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
3
4
  import * as React from 'react';
4
- import { InteractionContext } from "../context/InteractionProvider.js";
5
5
  import { useCartesianContext } from "../context/CartesianProvider/index.js";
6
6
  import { isBandScale } from "../internals/isBandScale.js";
7
7
  import { getSVGPoint } from "../internals/getSVGPoint.js";
8
8
  import { useSvgRef } from "./useSvgRef.js";
9
9
  import { useDrawingArea } from "./useDrawingArea.js";
10
+ import { useStore } from "../internals/useStore.js";
10
11
  function getAsANumber(value) {
11
12
  return value instanceof Date ? value.getTime() : value;
12
13
  }
@@ -19,9 +20,7 @@ export const useAxisEvents = disableAxisListener => {
19
20
  xAxisIds,
20
21
  yAxisIds
21
22
  } = useCartesianContext();
22
- const {
23
- dispatch
24
- } = React.useContext(InteractionContext);
23
+ const store = useStore(disableAxisListener);
25
24
  const usedXAxis = xAxisIds[0];
26
25
  const usedYAxis = yAxisIds[0];
27
26
 
@@ -33,7 +32,7 @@ export const useAxisEvents = disableAxisListener => {
33
32
  });
34
33
  React.useEffect(() => {
35
34
  const element = svgRef.current;
36
- if (element === null || disableAxisListener) {
35
+ if (element === null || disableAxisListener || !store) {
37
36
  return () => {};
38
37
  }
39
38
  function getNewAxisState(axisConfig, mouseValue) {
@@ -92,9 +91,15 @@ export const useAxisEvents = disableAxisListener => {
92
91
  x: -1,
93
92
  y: -1
94
93
  };
95
- dispatch({
96
- type: 'exitChart'
97
- });
94
+ store.update(prev => _extends({}, prev, {
95
+ interaction: {
96
+ item: null,
97
+ axis: {
98
+ x: null,
99
+ y: null
100
+ }
101
+ }
102
+ }));
98
103
  };
99
104
  const handleMove = event => {
100
105
  const target = 'targetTouches' in event ? event.targetTouches[0] : event;
@@ -105,9 +110,15 @@ export const useAxisEvents = disableAxisListener => {
105
110
  targetElement: event.target
106
111
  })) {
107
112
  if (mousePosition.current.isInChart) {
108
- dispatch({
109
- type: 'exitChart'
110
- });
113
+ store.update(prev => _extends({}, prev, {
114
+ interaction: {
115
+ item: null,
116
+ axis: {
117
+ x: null,
118
+ y: null
119
+ }
120
+ }
121
+ }));
111
122
  mousePosition.current.isInChart = false;
112
123
  }
113
124
  return;
@@ -115,13 +126,15 @@ export const useAxisEvents = disableAxisListener => {
115
126
  mousePosition.current.isInChart = true;
116
127
  const newStateX = getNewAxisState(xAxis[usedXAxis], svgPoint.x);
117
128
  const newStateY = getNewAxisState(yAxis[usedYAxis], svgPoint.y);
118
- dispatch({
119
- type: 'updateAxis',
120
- data: {
121
- x: newStateX,
122
- y: newStateY
123
- }
124
- });
129
+ store.update(prev => _extends({}, prev, {
130
+ interaction: _extends({}, prev.interaction, {
131
+ axis: _extends({}, prev.interaction.axis, prev.interaction.axis.x?.index !== newStateX?.index || prev.interaction.axis.x?.value !== newStateX?.value ? {
132
+ x: newStateX
133
+ } : {}, prev.interaction.axis.y?.index !== newStateY?.index || prev.interaction.axis.y?.value !== newStateY?.value ? {
134
+ y: newStateY
135
+ } : {})
136
+ })
137
+ }));
125
138
  };
126
139
  const handleDown = event => {
127
140
  const target = event.currentTarget;
@@ -144,5 +157,5 @@ export const useAxisEvents = disableAxisListener => {
144
157
  element.removeEventListener('pointercancel', handleOut);
145
158
  element.removeEventListener('pointerleave', handleOut);
146
159
  };
147
- }, [svgRef, dispatch, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
160
+ }, [svgRef, store, usedYAxis, yAxis, usedXAxis, xAxis, disableAxisListener, drawingArea]);
148
161
  };
@@ -1,10 +1,10 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { DrawingContext } from "../context/DrawingProvider.js";
4
+ import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
5
5
  export function useChartId() {
6
6
  const {
7
7
  chartId
8
- } = React.useContext(DrawingContext);
8
+ } = React.useContext(DrawingAreaContext);
9
9
  return React.useMemo(() => chartId, [chartId]);
10
10
  }
@@ -1,2 +1,2 @@
1
- import { DrawingArea } from '../context/DrawingProvider';
2
- export declare function useDrawingArea(): DrawingArea;
1
+ import { DrawingAreaState } from '../context/DrawingAreaProvider';
2
+ export declare function useDrawingArea(): DrawingAreaState;
@@ -1,7 +1,7 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { DrawingContext } from "../context/DrawingProvider.js";
4
+ import { DrawingAreaContext } from "../context/DrawingAreaProvider/index.js";
5
5
  export function useDrawingArea() {
6
6
  const {
7
7
  left,
@@ -11,7 +11,7 @@ export function useDrawingArea() {
11
11
  bottom,
12
12
  right,
13
13
  isPointInside
14
- } = React.useContext(DrawingContext);
14
+ } = React.useContext(DrawingAreaContext);
15
15
  return React.useMemo(() => ({
16
16
  left,
17
17
  top,
@@ -1,12 +1,10 @@
1
1
  'use client';
2
2
 
3
- import * as React from 'react';
4
- import { InteractionContext } from "../context/InteractionProvider.js";
3
+ import _extends from "@babel/runtime/helpers/esm/extends";
5
4
  import { useHighlighted } from "../context/index.js";
5
+ import { useStore } from "../internals/useStore.js";
6
6
  export const useInteractionItemProps = skip => {
7
- const {
8
- dispatch: dispatchInteraction
9
- } = React.useContext(InteractionContext);
7
+ const store = useStore();
10
8
  const {
11
9
  setHighlighted,
12
10
  clearHighlighted
@@ -21,10 +19,11 @@ export const useInteractionItemProps = skip => {
21
19
  }
22
20
  };
23
21
  const onPointerEnter = () => {
24
- dispatchInteraction({
25
- type: 'enterItem',
26
- data
27
- });
22
+ store.update(prev => _extends({}, prev, {
23
+ interaction: _extends({}, prev.interaction, {
24
+ item: data
25
+ })
26
+ }));
28
27
  setHighlighted({
29
28
  seriesId: data.seriesId,
30
29
  dataIndex: data.dataIndex
@@ -32,9 +31,17 @@ export const useInteractionItemProps = skip => {
32
31
  };
33
32
  const onPointerLeave = event => {
34
33
  event.currentTarget.releasePointerCapture(event.pointerId);
35
- dispatchInteraction({
36
- type: 'leaveItem',
37
- data
34
+ store.update(prev => {
35
+ const prevItem = prev.interaction.item;
36
+ if (prevItem === null || Object.keys(data).some(key => data[key] !== prevItem[key])) {
37
+ // The item is already something else, no need to clean it.
38
+ return prev;
39
+ }
40
+ return _extends({}, prev, {
41
+ interaction: _extends({}, prev.interaction, {
42
+ item: null
43
+ })
44
+ });
38
45
  });
39
46
  clearHighlighted();
40
47
  };
@@ -1,14 +1,14 @@
1
1
  'use client';
2
2
 
3
3
  import * as React from 'react';
4
- import { SvgContext } from "../context/DrawingProvider.js";
4
+ import { SvgRefContext } from "../context/SvgRefProvider/index.js";
5
5
  export function useSvgRef() {
6
6
  const {
7
7
  isInitialized,
8
8
  data
9
- } = React.useContext(SvgContext);
9
+ } = React.useContext(SvgRefContext);
10
10
  if (!isInitialized) {
11
11
  throw new Error(['MUI X: Could not find the svg ref context.', 'It looks like you rendered your component outside of a ChartsContainer parent component.'].join('\n'));
12
12
  }
13
- return data;
13
+ return data.svgRef;
14
14
  }
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/x-charts v8.0.0-alpha.0
2
+ * @mui/x-charts v8.0.0-alpha.1
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -1,4 +1,4 @@
1
1
  import * as React from 'react';
2
2
  import { AxisId } from '../../../models/axis';
3
3
  export declare function useChartGradient(): (axisId: AxisId, direction: "x" | "y") => string;
4
- export declare function ChartsAxesGradients(): React.JSX.Element;
4
+ export declare function ChartsAxesGradients(): React.JSX.Element | null;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import { useCartesianContext } from "../../../context/CartesianProvider/index.js";
3
- import { DrawingContext } from "../../../context/DrawingProvider.js";
3
+ import { DrawingAreaContext } from "../../../context/DrawingAreaProvider/index.js";
4
4
  import { useDrawingArea } from "../../../hooks/index.js";
5
5
  import ChartsPiecewiseGradient from "./ChartsPiecewiseGradient.js";
6
6
  import ChartsContinuousGradient from "./ChartsContinuousGradient.js";
@@ -8,7 +8,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
8
8
  export function useChartGradient() {
9
9
  const {
10
10
  chartId
11
- } = React.useContext(DrawingContext);
11
+ } = React.useContext(DrawingAreaContext);
12
12
  return React.useCallback((axisId, direction) => `${chartId}-gradient-${direction}-${axisId}`, [chartId]);
13
13
  }
14
14
  export function ChartsAxesGradients() {
@@ -29,8 +29,13 @@ export function ChartsAxesGradients() {
29
29
  yAxisIds,
30
30
  yAxis
31
31
  } = useCartesianContext();
32
+ const filteredYAxisIds = yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined);
33
+ const filteredXAxisIds = xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined);
34
+ if (filteredYAxisIds.length === 0 && filteredXAxisIds.length === 0) {
35
+ return null;
36
+ }
32
37
  return /*#__PURE__*/_jsxs("defs", {
33
- children: [yAxisIds.filter(axisId => yAxis[axisId].colorMap !== undefined).map(axisId => {
38
+ children: [filteredYAxisIds.map(axisId => {
34
39
  const gradientId = getGradientId(axisId, 'y');
35
40
  const {
36
41
  colorMap,
@@ -60,7 +65,7 @@ export function ChartsAxesGradients() {
60
65
  }, gradientId);
61
66
  }
62
67
  return null;
63
- }), xAxisIds.filter(axisId => xAxis[axisId].colorMap !== undefined).map(axisId => {
68
+ }), filteredXAxisIds.map(axisId => {
64
69
  const gradientId = getGradientId(axisId, 'x');
65
70
  const {
66
71
  colorMap,
@@ -1,7 +1,7 @@
1
1
  import { AxisConfig, ScaleName } from '../models';
2
2
  import { ChartsXAxisProps, ChartsAxisProps, ChartsYAxisProps, ChartsRadiusAxisProps, ChartsRotationAxisProps } from '../models/axis';
3
3
  import { CartesianChartSeriesType } from '../models/seriesType/config';
4
- import { DrawingArea } from '../context/DrawingProvider';
4
+ import { DrawingAreaState } from '../context/DrawingAreaProvider';
5
5
  import { FormattedSeries } from '../context/SeriesProvider';
6
6
  import { ExtremumGetter } from '../context/PluginProvider';
7
7
  import { DefaultizedAxisConfig, ZoomData, ZoomOptions, GetZoomAxisFilters } from '../context/CartesianProvider/Cartesian.types';
@@ -10,7 +10,7 @@ type ComputeResult<T extends ChartsAxisProps> = {
10
10
  axisIds: string[];
11
11
  };
12
12
  type ComputeCommonParams = {
13
- drawingArea: DrawingArea;
13
+ drawingArea: DrawingAreaState;
14
14
  formattedSeries: FormattedSeries;
15
15
  extremumGetters: {
16
16
  [K in CartesianChartSeriesType]?: ExtremumGetter<K>;
@@ -1,5 +1,4 @@
1
1
  export * from './components/ChartsAxesGradients';
2
- export * from '../ChartContainer/useChartContainerDimensions';
3
2
  export * from '../ChartContainer/ResizableContainer';
4
3
  export { useSeries } from '../hooks/useSeries';
5
4
  export { useInteractionItemProps } from '../hooks/useInteractionItemProps';
@@ -18,7 +17,7 @@ export { unstable_cleanupDOM } from './domUtils';
18
17
  export * from './getScale';
19
18
  export * from './computeAxisValue';
20
19
  export * from '../context/CartesianProvider';
21
- export * from '../context/DrawingProvider';
20
+ export * from '../context/DrawingAreaProvider';
22
21
  export * from '../context/InteractionProvider';
23
22
  export * from '../context/SeriesProvider';
24
23
  export * from '../context/ZAxisContextProvider';
@@ -27,6 +26,8 @@ export * from '../context/AnimationProvider';
27
26
  export type * from '../context/context.types';
28
27
  export { getAxisExtremum } from '../context/CartesianProvider/getAxisExtremum';
29
28
  export * from '../context/ChartDataProvider';
29
+ export * from '../context/SizeProvider';
30
+ export * from '../context/SvgRefProvider';
30
31
  export * from '../models/seriesType/config';
31
32
  export * from '../models/seriesType/common';
32
33
  export * from '../models/z-axis';
@@ -1,6 +1,5 @@
1
1
  // Components
2
2
  export * from "./components/ChartsAxesGradients/index.js";
3
- export * from "../ChartContainer/useChartContainerDimensions.js";
4
3
  export * from "../ChartContainer/ResizableContainer.js";
5
4
 
6
5
  // hooks
@@ -26,7 +25,7 @@ export * from "./computeAxisValue.js";
26
25
  // contexts
27
26
 
28
27
  export * from "../context/CartesianProvider/index.js";
29
- export * from "../context/DrawingProvider.js";
28
+ export * from "../context/DrawingAreaProvider/index.js";
30
29
  export * from "../context/InteractionProvider.js";
31
30
  export * from "../context/SeriesProvider/index.js";
32
31
  export * from "../context/ZAxisContextProvider.js";
@@ -34,6 +33,8 @@ export * from "../context/PluginProvider/index.js";
34
33
  export * from "../context/AnimationProvider/index.js";
35
34
  export { getAxisExtremum } from "../context/CartesianProvider/getAxisExtremum.js";
36
35
  export * from "../context/ChartDataProvider/index.js";
36
+ export * from "../context/SizeProvider/index.js";
37
+ export * from "../context/SvgRefProvider/index.js";
37
38
 
38
39
  // series configuration
39
40
  export * from "../models/seriesType/config.js";
@@ -0,0 +1,35 @@
1
+ import { ChartItemIdentifier, ChartSeriesType } from '../../../models/seriesType/config';
2
+ export type ItemInteractionData<T extends ChartSeriesType> = ChartItemIdentifier<T>;
3
+ export type AxisInteractionData = {
4
+ x: null | {
5
+ value: number | Date | string;
6
+ index: number;
7
+ };
8
+ y: null | {
9
+ value: number | Date | string;
10
+ index: number;
11
+ };
12
+ };
13
+ type InteractionState = {
14
+ /**
15
+ * The item currently interacting.
16
+ */
17
+ item: null | ItemInteractionData<ChartSeriesType>;
18
+ /**
19
+ * The x- and y-axes currently interacting.
20
+ */
21
+ axis: AxisInteractionData;
22
+ /**
23
+ * Set to `true` when `VoronoiHandler` is active.
24
+ * Used to prevent collision with mouseEnter events.
25
+ */
26
+ isVoronoiEnabled?: boolean;
27
+ };
28
+ export type ChartStateCacheKey = {
29
+ id: number;
30
+ };
31
+ export type ChartState = {
32
+ interaction: InteractionState;
33
+ cacheKey: ChartStateCacheKey;
34
+ };
35
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { ChartState } from '../models';
2
+ type Listener<T> = (value: T) => void;
3
+ export type StoreUpdater = (prevState: ChartState) => ChartState;
4
+ export declare class ChartStore {
5
+ value: ChartState;
6
+ private listeners;
7
+ constructor(value: ChartState);
8
+ subscribe: (fn: Listener<ChartState>) => () => void;
9
+ getSnapshot: () => ChartState;
10
+ update: (updater: StoreUpdater) => void;
11
+ }
12
+ export {};
@@ -0,0 +1,26 @@
1
+ // For now this is fixed. Will need to support generic if we add plugins
2
+
3
+ export class ChartStore {
4
+ constructor(value) {
5
+ this.value = void 0;
6
+ this.listeners = void 0;
7
+ this.subscribe = fn => {
8
+ this.listeners.add(fn);
9
+ return () => {
10
+ this.listeners.delete(fn);
11
+ };
12
+ };
13
+ this.getSnapshot = () => {
14
+ return this.value;
15
+ };
16
+ this.update = updater => {
17
+ const newState = updater(this.value);
18
+ if (newState !== this.value) {
19
+ this.value = newState;
20
+ this.listeners.forEach(l => l(newState));
21
+ }
22
+ };
23
+ this.value = value;
24
+ this.listeners = new Set();
25
+ }
26
+ }