stream-charts 1.2.0 → 2.0.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 (463) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +809 -1022
  3. package/changes.md +40 -0
  4. package/dist/app/charts/Chart.d.ts +35 -139
  5. package/dist/app/charts/Chart.d.ts.map +1 -0
  6. package/dist/app/charts/Chart.js +74 -65
  7. package/dist/app/charts/Chart.js.map +1 -1
  8. package/dist/app/charts/axes/AxesState.d.ts +26 -18
  9. package/dist/app/charts/axes/AxesState.d.ts.map +1 -0
  10. package/dist/app/charts/axes/AxesState.js +26 -24
  11. package/dist/app/charts/axes/AxesState.js.map +1 -1
  12. package/dist/app/charts/axes/AxisInterval.d.ts +44 -26
  13. package/dist/app/charts/axes/AxisInterval.d.ts.map +1 -0
  14. package/dist/app/charts/axes/AxisInterval.js +48 -29
  15. package/dist/app/charts/axes/AxisInterval.js.map +1 -1
  16. package/dist/app/charts/axes/BaseAxisRange.d.ts +46 -22
  17. package/dist/app/charts/axes/BaseAxisRange.d.ts.map +1 -0
  18. package/dist/app/charts/axes/BaseAxisRange.js +17 -12
  19. package/dist/app/charts/axes/BaseAxisRange.js.map +1 -1
  20. package/dist/app/charts/axes/ContinuousAxis.d.ts +47 -6
  21. package/dist/app/charts/axes/ContinuousAxis.d.ts.map +1 -0
  22. package/dist/app/charts/axes/ContinuousAxis.js +160 -27
  23. package/dist/app/charts/axes/ContinuousAxis.js.map +1 -1
  24. package/dist/app/charts/axes/ContinuousAxisRange.d.ts +29 -10
  25. package/dist/app/charts/axes/ContinuousAxisRange.d.ts.map +1 -0
  26. package/dist/app/charts/axes/ContinuousAxisRange.js +29 -11
  27. package/dist/app/charts/axes/ContinuousAxisRange.js.map +1 -1
  28. package/dist/app/charts/axes/EmptyAxis.d.ts +5 -2
  29. package/dist/app/charts/axes/EmptyAxis.d.ts.map +1 -0
  30. package/dist/app/charts/axes/EmptyAxis.js +30 -9
  31. package/dist/app/charts/axes/EmptyAxis.js.map +1 -1
  32. package/dist/app/charts/axes/OrdinalAxis.d.ts +5 -3
  33. package/dist/app/charts/axes/OrdinalAxis.d.ts.map +1 -0
  34. package/dist/app/charts/axes/OrdinalAxis.js +39 -16
  35. package/dist/app/charts/axes/OrdinalAxis.js.map +1 -1
  36. package/dist/app/charts/axes/OrdinalAxisRange.d.ts +76 -13
  37. package/dist/app/charts/axes/OrdinalAxisRange.d.ts.map +1 -0
  38. package/dist/app/charts/axes/OrdinalAxisRange.js +95 -16
  39. package/dist/app/charts/axes/OrdinalAxisRange.js.map +1 -1
  40. package/dist/app/charts/axes/autoScale.d.ts +111 -0
  41. package/dist/app/charts/axes/autoScale.d.ts.map +1 -0
  42. package/dist/app/charts/axes/autoScale.js +188 -0
  43. package/dist/app/charts/axes/autoScale.js.map +1 -0
  44. package/dist/app/charts/axes/axes.d.ts +273 -150
  45. package/dist/app/charts/axes/axes.d.ts.map +1 -0
  46. package/dist/app/charts/axes/axes.js +808 -583
  47. package/dist/app/charts/axes/axes.js.map +1 -1
  48. package/dist/app/charts/d3types.d.ts +40 -11
  49. package/dist/app/charts/d3types.d.ts.map +1 -0
  50. package/dist/app/charts/d3types.js +3 -0
  51. package/dist/app/charts/d3types.js.map +1 -1
  52. package/dist/app/charts/datasources/StreamingDataSource.d.ts +149 -0
  53. package/dist/app/charts/datasources/StreamingDataSource.d.ts.map +1 -0
  54. package/dist/app/charts/datasources/StreamingDataSource.js +110 -0
  55. package/dist/app/charts/datasources/StreamingDataSource.js.map +1 -0
  56. package/dist/app/charts/datasources/iteratesDataSource.d.ts +73 -0
  57. package/dist/app/charts/datasources/iteratesDataSource.d.ts.map +1 -0
  58. package/dist/app/charts/datasources/iteratesDataSource.js +87 -0
  59. package/dist/app/charts/datasources/iteratesDataSource.js.map +1 -0
  60. package/dist/app/charts/datasources/ordinalDataSource.d.ts +75 -0
  61. package/dist/app/charts/datasources/ordinalDataSource.d.ts.map +1 -0
  62. package/dist/app/charts/datasources/ordinalDataSource.js +135 -0
  63. package/dist/app/charts/datasources/ordinalDataSource.js.map +1 -0
  64. package/dist/app/charts/datasources/outlierDataSource.d.ts +53 -0
  65. package/dist/app/charts/datasources/outlierDataSource.d.ts.map +1 -0
  66. package/dist/app/charts/datasources/outlierDataSource.js +57 -0
  67. package/dist/app/charts/datasources/outlierDataSource.js.map +1 -0
  68. package/dist/app/charts/datasources/timeSeriesDataSource.d.ts +77 -0
  69. package/dist/app/charts/datasources/timeSeriesDataSource.d.ts.map +1 -0
  70. package/dist/app/charts/datasources/timeSeriesDataSource.js +85 -0
  71. package/dist/app/charts/datasources/timeSeriesDataSource.js.map +1 -0
  72. package/dist/app/charts/filters/regexFilter.d.ts +31 -4
  73. package/dist/app/charts/filters/regexFilter.d.ts.map +1 -0
  74. package/dist/app/charts/filters/regexFilter.js +38 -4
  75. package/dist/app/charts/filters/regexFilter.js.map +1 -1
  76. package/dist/app/charts/hooks/AxesProvider.d.ts +21 -0
  77. package/dist/app/charts/hooks/AxesProvider.d.ts.map +1 -0
  78. package/dist/app/charts/hooks/AxesProvider.js +213 -0
  79. package/dist/app/charts/hooks/AxesProvider.js.map +1 -0
  80. package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts +25 -0
  81. package/dist/app/charts/hooks/CanvasSurfaceProvider.d.ts.map +1 -0
  82. package/dist/app/charts/hooks/CanvasSurfaceProvider.js +76 -0
  83. package/dist/app/charts/hooks/CanvasSurfaceProvider.js.map +1 -0
  84. package/dist/app/charts/hooks/ChartProvider.d.ts +40 -0
  85. package/dist/app/charts/hooks/ChartProvider.d.ts.map +1 -0
  86. package/dist/app/charts/hooks/ChartProvider.js +33 -0
  87. package/dist/app/charts/hooks/ChartProvider.js.map +1 -0
  88. package/dist/app/charts/hooks/InteractionProvider.d.ts +23 -0
  89. package/dist/app/charts/hooks/InteractionProvider.d.ts.map +1 -0
  90. package/dist/app/charts/hooks/InteractionProvider.js +60 -0
  91. package/dist/app/charts/hooks/InteractionProvider.js.map +1 -0
  92. package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts +16 -0
  93. package/dist/app/charts/hooks/PlotDimensionsProvider.d.ts.map +1 -0
  94. package/dist/app/charts/hooks/PlotDimensionsProvider.js +76 -0
  95. package/dist/app/charts/hooks/PlotDimensionsProvider.js.map +1 -0
  96. package/dist/app/charts/hooks/defaultAxesValues.d.ts +11 -0
  97. package/dist/app/charts/hooks/defaultAxesValues.d.ts.map +1 -0
  98. package/dist/app/charts/hooks/defaultAxesValues.js +36 -0
  99. package/dist/app/charts/hooks/defaultAxesValues.js.map +1 -0
  100. package/dist/app/charts/hooks/defaultMouseValues.d.ts +9 -0
  101. package/dist/app/charts/hooks/defaultMouseValues.d.ts.map +1 -0
  102. package/dist/app/charts/hooks/defaultMouseValues.js +23 -0
  103. package/dist/app/charts/hooks/defaultMouseValues.js.map +1 -0
  104. package/dist/app/charts/hooks/defaultPlotDimensions.d.ts +13 -0
  105. package/dist/app/charts/hooks/defaultPlotDimensions.d.ts.map +1 -0
  106. package/dist/app/charts/hooks/defaultPlotDimensions.js +23 -0
  107. package/dist/app/charts/hooks/defaultPlotDimensions.js.map +1 -0
  108. package/dist/app/charts/hooks/defaultTooltipValues.d.ts +9 -0
  109. package/dist/app/charts/hooks/defaultTooltipValues.d.ts.map +1 -0
  110. package/dist/app/charts/hooks/defaultTooltipValues.js +21 -0
  111. package/dist/app/charts/hooks/defaultTooltipValues.js.map +1 -0
  112. package/dist/app/charts/hooks/defaultUseChartValues.d.ts +14 -0
  113. package/dist/app/charts/hooks/defaultUseChartValues.d.ts.map +1 -0
  114. package/dist/app/charts/hooks/defaultUseChartValues.js +30 -0
  115. package/dist/app/charts/hooks/defaultUseChartValues.js.map +1 -0
  116. package/dist/app/charts/hooks/useAxes.d.ts +49 -36
  117. package/dist/app/charts/hooks/useAxes.d.ts.map +1 -0
  118. package/dist/app/charts/hooks/useAxes.js +16 -176
  119. package/dist/app/charts/hooks/useAxes.js.map +1 -1
  120. package/dist/app/charts/hooks/useCanvasSurface.d.ts +25 -0
  121. package/dist/app/charts/hooks/useCanvasSurface.d.ts.map +1 -0
  122. package/dist/app/charts/hooks/useCanvasSurface.js +18 -0
  123. package/dist/app/charts/hooks/useCanvasSurface.js.map +1 -0
  124. package/dist/app/charts/hooks/useChart.d.ts +30 -44
  125. package/dist/app/charts/hooks/useChart.d.ts.map +1 -0
  126. package/dist/app/charts/hooks/useChart.js +26 -48
  127. package/dist/app/charts/hooks/useChart.js.map +1 -1
  128. package/dist/app/charts/hooks/useDataSource.d.ts +68 -0
  129. package/dist/app/charts/hooks/useDataSource.d.ts.map +1 -0
  130. package/dist/app/charts/hooks/useDataSource.js +63 -0
  131. package/dist/app/charts/hooks/useDataSource.js.map +1 -0
  132. package/dist/app/charts/hooks/useHoveredSeries.d.ts +25 -0
  133. package/dist/app/charts/hooks/useHoveredSeries.d.ts.map +1 -0
  134. package/dist/app/charts/hooks/useHoveredSeries.js +15 -0
  135. package/dist/app/charts/hooks/useHoveredSeries.js.map +1 -0
  136. package/dist/app/charts/hooks/useMouse.d.ts +46 -22
  137. package/dist/app/charts/hooks/useMouse.d.ts.map +1 -0
  138. package/dist/app/charts/hooks/useMouse.js +12 -56
  139. package/dist/app/charts/hooks/useMouse.js.map +1 -1
  140. package/dist/app/charts/hooks/usePlotDimensions.d.ts +25 -13
  141. package/dist/app/charts/hooks/usePlotDimensions.d.ts.map +1 -0
  142. package/dist/app/charts/hooks/usePlotDimensions.js +6 -62
  143. package/dist/app/charts/hooks/usePlotDimensions.js.map +1 -1
  144. package/dist/app/charts/hooks/useTooltip.d.ts +24 -26
  145. package/dist/app/charts/hooks/useTooltip.d.ts.map +1 -0
  146. package/dist/app/charts/hooks/useTooltip.js +12 -42
  147. package/dist/app/charts/hooks/useTooltip.js.map +1 -1
  148. package/dist/app/charts/index.d.ts +66 -0
  149. package/dist/app/charts/index.d.ts.map +1 -0
  150. package/dist/app/charts/index.js +87 -0
  151. package/dist/app/charts/index.js.map +1 -0
  152. package/dist/app/charts/legends/Legend.d.ts +33 -12
  153. package/dist/app/charts/legends/Legend.d.ts.map +1 -0
  154. package/dist/app/charts/legends/Legend.js +138 -379
  155. package/dist/app/charts/legends/Legend.js.map +1 -1
  156. package/dist/app/charts/legends/constants.d.ts +19 -0
  157. package/dist/app/charts/legends/constants.d.ts.map +1 -0
  158. package/dist/app/charts/legends/constants.js +34 -0
  159. package/dist/app/charts/legends/constants.js.map +1 -0
  160. package/dist/app/charts/observables/ChartData.d.ts +1 -0
  161. package/dist/app/charts/observables/ChartData.d.ts.map +1 -0
  162. package/dist/app/charts/observables/iterates.d.ts +13 -7
  163. package/dist/app/charts/observables/iterates.d.ts.map +1 -0
  164. package/dist/app/charts/observables/iterates.js +42 -9
  165. package/dist/app/charts/observables/iterates.js.map +1 -1
  166. package/dist/app/charts/observables/ordinals.d.ts +70 -12
  167. package/dist/app/charts/observables/ordinals.d.ts.map +1 -0
  168. package/dist/app/charts/observables/ordinals.js +127 -48
  169. package/dist/app/charts/observables/ordinals.js.map +1 -1
  170. package/dist/app/charts/observables/outliers.d.ts +18 -0
  171. package/dist/app/charts/observables/outliers.d.ts.map +1 -0
  172. package/dist/app/charts/observables/outliers.js +2 -0
  173. package/dist/app/charts/observables/outliers.js.map +1 -0
  174. package/dist/app/charts/plots/BarPlot.d.ts +87 -13
  175. package/dist/app/charts/plots/BarPlot.d.ts.map +1 -0
  176. package/dist/app/charts/plots/BarPlot.js +603 -356
  177. package/dist/app/charts/plots/BarPlot.js.map +1 -1
  178. package/dist/app/charts/plots/OutlierPlot.d.ts +123 -0
  179. package/dist/app/charts/plots/OutlierPlot.d.ts.map +1 -0
  180. package/dist/app/charts/plots/OutlierPlot.js +430 -0
  181. package/dist/app/charts/plots/OutlierPlot.js.map +1 -0
  182. package/dist/app/charts/plots/PoincarePlot.d.ts +92 -14
  183. package/dist/app/charts/plots/PoincarePlot.d.ts.map +1 -0
  184. package/dist/app/charts/plots/PoincarePlot.js +523 -364
  185. package/dist/app/charts/plots/PoincarePlot.js.map +1 -1
  186. package/dist/app/charts/plots/RasterPlot.d.ts +31 -10
  187. package/dist/app/charts/plots/RasterPlot.d.ts.map +1 -0
  188. package/dist/app/charts/plots/RasterPlot.js +198 -306
  189. package/dist/app/charts/plots/RasterPlot.js.map +1 -1
  190. package/dist/app/charts/plots/ScatterPlot.d.ts +77 -21
  191. package/dist/app/charts/plots/ScatterPlot.d.ts.map +1 -0
  192. package/dist/app/charts/plots/ScatterPlot.js +359 -302
  193. package/dist/app/charts/plots/ScatterPlot.js.map +1 -1
  194. package/dist/app/charts/plots/autoScaleYAxes.d.ts +43 -0
  195. package/dist/app/charts/plots/autoScaleYAxes.d.ts.map +1 -0
  196. package/dist/app/charts/plots/autoScaleYAxes.js +71 -0
  197. package/dist/app/charts/plots/autoScaleYAxes.js.map +1 -0
  198. package/dist/app/charts/plots/colorizedLine.d.ts +61 -0
  199. package/dist/app/charts/plots/colorizedLine.d.ts.map +1 -0
  200. package/dist/app/charts/plots/colorizedLine.js +157 -0
  201. package/dist/app/charts/plots/colorizedLine.js.map +1 -0
  202. package/dist/app/charts/plots/constants.d.ts +7 -0
  203. package/dist/app/charts/plots/constants.d.ts.map +1 -0
  204. package/dist/app/charts/plots/constants.js +11 -0
  205. package/dist/app/charts/plots/constants.js.map +1 -0
  206. package/dist/app/charts/plots/hitTesting.d.ts +88 -0
  207. package/dist/app/charts/plots/hitTesting.d.ts.map +1 -0
  208. package/dist/app/charts/plots/hitTesting.js +136 -0
  209. package/dist/app/charts/plots/hitTesting.js.map +1 -0
  210. package/dist/app/charts/plots/plot.d.ts +52 -16
  211. package/dist/app/charts/plots/plot.d.ts.map +1 -0
  212. package/dist/app/charts/plots/plot.js +108 -35
  213. package/dist/app/charts/plots/plot.js.map +1 -1
  214. package/dist/app/charts/plots/useCanvasZoomPan.d.ts +119 -0
  215. package/dist/app/charts/plots/useCanvasZoomPan.d.ts.map +1 -0
  216. package/dist/app/charts/plots/useCanvasZoomPan.js +113 -0
  217. package/dist/app/charts/plots/useCanvasZoomPan.js.map +1 -0
  218. package/dist/app/charts/plots/useStreamingTimeAxes.d.ts +103 -0
  219. package/dist/app/charts/plots/useStreamingTimeAxes.d.ts.map +1 -0
  220. package/dist/app/charts/plots/useStreamingTimeAxes.js +257 -0
  221. package/dist/app/charts/plots/useStreamingTimeAxes.js.map +1 -0
  222. package/dist/app/charts/series/baseSeries.d.ts +60 -8
  223. package/dist/app/charts/series/baseSeries.d.ts.map +1 -0
  224. package/dist/app/charts/series/baseSeries.js +53 -8
  225. package/dist/app/charts/series/baseSeries.js.map +1 -1
  226. package/dist/app/charts/series/iterateSeries.d.ts +9 -8
  227. package/dist/app/charts/series/iterateSeries.d.ts.map +1 -0
  228. package/dist/app/charts/series/iterateSeries.js +7 -7
  229. package/dist/app/charts/series/iterateSeries.js.map +1 -1
  230. package/dist/app/charts/series/ordinalSeries.d.ts +27 -13
  231. package/dist/app/charts/series/ordinalSeries.d.ts.map +1 -0
  232. package/dist/app/charts/series/ordinalSeries.js +29 -15
  233. package/dist/app/charts/series/ordinalSeries.js.map +1 -1
  234. package/dist/app/charts/series/outlierSeries.d.ts +142 -0
  235. package/dist/app/charts/series/outlierSeries.d.ts.map +1 -0
  236. package/dist/app/charts/series/outlierSeries.js +82 -0
  237. package/dist/app/charts/series/outlierSeries.js.map +1 -0
  238. package/dist/app/charts/series/timeSeries.d.ts +13 -9
  239. package/dist/app/charts/series/timeSeries.d.ts.map +1 -0
  240. package/dist/app/charts/series/timeSeries.js +6 -3
  241. package/dist/app/charts/series/timeSeries.js.map +1 -1
  242. package/dist/app/charts/series/timeSeriesChartData.d.ts +18 -10
  243. package/dist/app/charts/series/timeSeriesChartData.d.ts.map +1 -0
  244. package/dist/app/charts/series/timeSeriesChartData.js +28 -14
  245. package/dist/app/charts/series/timeSeriesChartData.js.map +1 -1
  246. package/dist/app/charts/styling/barPlotStyle.d.ts +46 -2
  247. package/dist/app/charts/styling/barPlotStyle.d.ts.map +1 -0
  248. package/dist/app/charts/styling/barPlotStyle.js +37 -3
  249. package/dist/app/charts/styling/barPlotStyle.js.map +1 -1
  250. package/dist/app/charts/styling/canvasStyle.d.ts +53 -0
  251. package/dist/app/charts/styling/canvasStyle.d.ts.map +1 -0
  252. package/dist/app/charts/styling/canvasStyle.js +71 -0
  253. package/dist/app/charts/styling/canvasStyle.js.map +1 -0
  254. package/dist/app/charts/styling/margins.d.ts +21 -2
  255. package/dist/app/charts/styling/margins.d.ts.map +1 -0
  256. package/dist/app/charts/styling/margins.js +25 -4
  257. package/dist/app/charts/styling/margins.js.map +1 -1
  258. package/dist/app/charts/styling/svgStyle.d.ts +10 -56
  259. package/dist/app/charts/styling/svgStyle.d.ts.map +1 -0
  260. package/dist/app/charts/styling/svgStyle.js +3 -78
  261. package/dist/app/charts/styling/svgStyle.js.map +1 -1
  262. package/dist/app/charts/subscriptions/viewDrivers.d.ts +124 -0
  263. package/dist/app/charts/subscriptions/viewDrivers.d.ts.map +1 -0
  264. package/dist/app/charts/subscriptions/viewDrivers.js +338 -0
  265. package/dist/app/charts/subscriptions/viewDrivers.js.map +1 -0
  266. package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts +12 -78
  267. package/dist/app/charts/tooltips/BarPlotTooltipContent.d.ts.map +1 -0
  268. package/dist/app/charts/tooltips/BarPlotTooltipContent.js +65 -257
  269. package/dist/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -1
  270. package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts +9 -0
  271. package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.d.ts.map +1 -0
  272. package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js +16 -0
  273. package/dist/app/charts/tooltips/DefaultOutlierTooltipContent.js.map +1 -0
  274. package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts +30 -0
  275. package/dist/app/charts/tooltips/OutlierPlotTooltipContent.d.ts.map +1 -0
  276. package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js +26 -0
  277. package/dist/app/charts/tooltips/OutlierPlotTooltipContent.js.map +1 -0
  278. package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts +22 -72
  279. package/dist/app/charts/tooltips/PoincarePlotTooltipContent.d.ts.map +1 -0
  280. package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js +104 -171
  281. package/dist/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -1
  282. package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts +32 -8
  283. package/dist/app/charts/tooltips/RasterPlotTooltipContent.d.ts.map +1 -0
  284. package/dist/app/charts/tooltips/RasterPlotTooltipContent.js +62 -115
  285. package/dist/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -1
  286. package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts +39 -12
  287. package/dist/app/charts/tooltips/ScatterPlotTooltipContent.d.ts.map +1 -0
  288. package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js +162 -134
  289. package/dist/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -1
  290. package/dist/app/charts/tooltips/Tooltip.d.ts +27 -32
  291. package/dist/app/charts/tooltips/Tooltip.d.ts.map +1 -0
  292. package/dist/app/charts/tooltips/Tooltip.js +37 -81
  293. package/dist/app/charts/tooltips/Tooltip.js.map +1 -1
  294. package/dist/app/charts/tooltips/TooltipContent.d.ts +81 -0
  295. package/dist/app/charts/tooltips/TooltipContent.d.ts.map +1 -0
  296. package/dist/app/charts/tooltips/TooltipContent.js +99 -0
  297. package/dist/app/charts/tooltips/TooltipContent.js.map +1 -0
  298. package/dist/app/charts/tooltips/tooltipUtils.d.ts +186 -36
  299. package/dist/app/charts/tooltips/tooltipUtils.d.ts.map +1 -0
  300. package/dist/app/charts/tooltips/tooltipUtils.js +277 -48
  301. package/dist/app/charts/tooltips/tooltipUtils.js.map +1 -1
  302. package/dist/app/charts/tooltips/useOutlierTooltip.d.ts +59 -0
  303. package/dist/app/charts/tooltips/useOutlierTooltip.d.ts.map +1 -0
  304. package/dist/app/charts/tooltips/useOutlierTooltip.js +16 -0
  305. package/dist/app/charts/tooltips/useOutlierTooltip.js.map +1 -0
  306. package/dist/app/charts/tooltips/useTooltipPlacement.d.ts +51 -0
  307. package/dist/app/charts/tooltips/useTooltipPlacement.d.ts.map +1 -0
  308. package/dist/app/charts/tooltips/useTooltipPlacement.js +52 -0
  309. package/dist/app/charts/tooltips/useTooltipPlacement.js.map +1 -0
  310. package/dist/app/charts/tooltips/useTooltipStyle.d.ts +11 -0
  311. package/dist/app/charts/tooltips/useTooltipStyle.d.ts.map +1 -0
  312. package/dist/app/charts/tooltips/useTooltipStyle.js +14 -0
  313. package/dist/app/charts/tooltips/useTooltipStyle.js.map +1 -0
  314. package/dist/app/charts/trackers/Tracker.d.ts +22 -6
  315. package/dist/app/charts/trackers/Tracker.d.ts.map +1 -0
  316. package/dist/app/charts/trackers/Tracker.js +36 -22
  317. package/dist/app/charts/trackers/Tracker.js.map +1 -1
  318. package/dist/app/charts/trackers/trackerUtils.d.ts +40 -18
  319. package/dist/app/charts/trackers/trackerUtils.d.ts.map +1 -0
  320. package/dist/app/charts/trackers/trackerUtils.js +213 -300
  321. package/dist/app/charts/trackers/trackerUtils.js.map +1 -1
  322. package/dist/app/charts/utils.d.ts +72 -33
  323. package/dist/app/charts/utils.d.ts.map +1 -0
  324. package/dist/app/charts/utils.js +87 -42
  325. package/dist/app/charts/utils.js.map +1 -1
  326. package/dist/index.d.ts +2 -45
  327. package/dist/index.d.ts.map +1 -0
  328. package/dist/index.js +2 -72
  329. package/dist/index.js.map +1 -1
  330. package/package.json +87 -46
  331. package/src/app/charts/Chart.tsx +132 -168
  332. package/src/app/charts/axes/AxesState.ts +27 -29
  333. package/src/app/charts/axes/AxisInterval.ts +57 -32
  334. package/src/app/charts/axes/BaseAxisRange.ts +47 -27
  335. package/src/app/charts/axes/ContinuousAxis.tsx +235 -39
  336. package/src/app/charts/axes/ContinuousAxisRange.ts +29 -11
  337. package/src/app/charts/axes/EmptyAxis.tsx +52 -17
  338. package/src/app/charts/axes/OrdinalAxis.tsx +54 -28
  339. package/src/app/charts/axes/OrdinalAxisRange.ts +96 -16
  340. package/src/app/charts/axes/autoScale.ts +244 -0
  341. package/src/app/charts/axes/axes.ts +954 -735
  342. package/src/app/charts/d3types.ts +42 -13
  343. package/src/app/charts/datasources/StreamingDataSource.ts +214 -0
  344. package/src/app/charts/datasources/iteratesDataSource.ts +122 -0
  345. package/src/app/charts/datasources/ordinalDataSource.ts +205 -0
  346. package/src/app/charts/datasources/outlierDataSource.ts +90 -0
  347. package/src/app/charts/datasources/timeSeriesDataSource.ts +133 -0
  348. package/src/app/charts/filters/regexFilter.ts +45 -5
  349. package/src/app/charts/hooks/AxesProvider.tsx +301 -0
  350. package/src/app/charts/hooks/CanvasSurfaceProvider.tsx +117 -0
  351. package/src/app/charts/hooks/ChartProvider.tsx +79 -0
  352. package/src/app/charts/hooks/InteractionProvider.tsx +88 -0
  353. package/src/app/charts/hooks/PlotDimensionsProvider.tsx +109 -0
  354. package/src/app/charts/hooks/defaultAxesValues.ts +40 -0
  355. package/src/app/charts/hooks/defaultMouseValues.ts +24 -0
  356. package/src/app/charts/hooks/defaultPlotDimensions.ts +27 -0
  357. package/src/app/charts/hooks/defaultTooltipValues.tsx +23 -0
  358. package/src/app/charts/hooks/defaultUseChartValues.tsx +36 -0
  359. package/src/app/charts/hooks/useAxes.tsx +60 -228
  360. package/src/app/charts/hooks/useCanvasSurface.tsx +35 -0
  361. package/src/app/charts/hooks/useChart.tsx +47 -106
  362. package/src/app/charts/hooks/useDataSource.tsx +106 -0
  363. package/src/app/charts/hooks/useHoveredSeries.tsx +33 -0
  364. package/src/app/charts/hooks/useMouse.tsx +58 -82
  365. package/src/app/charts/hooks/usePlotDimensions.tsx +25 -89
  366. package/src/app/charts/hooks/useTooltip.tsx +32 -63
  367. package/src/app/charts/index.ts +213 -0
  368. package/src/app/charts/legends/Legend.tsx +198 -479
  369. package/src/app/charts/legends/constants.ts +37 -0
  370. package/src/app/charts/observables/iterates.ts +32 -12
  371. package/src/app/charts/observables/ordinals.ts +141 -67
  372. package/src/app/charts/observables/outliers.ts +20 -0
  373. package/src/app/charts/plots/BarPlot.tsx +784 -666
  374. package/src/app/charts/plots/OutlierPlot.tsx +685 -0
  375. package/src/app/charts/plots/PoincarePlot.tsx +707 -489
  376. package/src/app/charts/plots/RasterPlot.tsx +253 -445
  377. package/src/app/charts/plots/ScatterPlot.tsx +480 -463
  378. package/src/app/charts/plots/autoScaleYAxes.ts +102 -0
  379. package/src/app/charts/plots/colorizedLine.ts +185 -0
  380. package/src/app/charts/plots/constants.ts +16 -0
  381. package/src/app/charts/plots/hitTesting.ts +198 -0
  382. package/src/app/charts/plots/plot.ts +138 -44
  383. package/src/app/charts/plots/useCanvasZoomPan.ts +240 -0
  384. package/src/app/charts/plots/useStreamingTimeAxes.ts +384 -0
  385. package/src/app/charts/series/baseSeries.ts +81 -14
  386. package/src/app/charts/series/iterateSeries.ts +8 -8
  387. package/src/app/charts/series/ordinalSeries.ts +35 -20
  388. package/src/app/charts/series/outlierSeries.ts +188 -0
  389. package/src/app/charts/series/timeSeries.ts +14 -12
  390. package/src/app/charts/series/timeSeriesChartData.ts +31 -17
  391. package/src/app/charts/styling/barPlotStyle.ts +48 -5
  392. package/src/app/charts/styling/canvasStyle.ts +86 -0
  393. package/src/app/charts/styling/margins.ts +28 -4
  394. package/src/app/charts/styling/svgStyle.ts +10 -91
  395. package/src/app/charts/subscriptions/viewDrivers.ts +447 -0
  396. package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +156 -380
  397. package/src/app/charts/tooltips/DefaultOutlierTooltipContent.tsx +40 -0
  398. package/src/app/charts/tooltips/OutlierPlotTooltipContent.tsx +67 -0
  399. package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +229 -292
  400. package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +164 -217
  401. package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +373 -236
  402. package/src/app/charts/tooltips/Tooltip.tsx +58 -124
  403. package/src/app/charts/tooltips/TooltipContent.tsx +177 -0
  404. package/src/app/charts/tooltips/tooltipUtils.ts +359 -61
  405. package/src/app/charts/tooltips/useOutlierTooltip.tsx +68 -0
  406. package/src/app/charts/tooltips/useTooltipPlacement.ts +86 -0
  407. package/src/app/charts/tooltips/useTooltipStyle.ts +15 -0
  408. package/src/app/charts/trackers/Tracker.tsx +68 -33
  409. package/src/app/charts/trackers/trackerUtils.ts +263 -376
  410. package/src/app/charts/utils.ts +90 -48
  411. package/src/index.ts +2 -322
  412. package/dist/app/charts/axes/AxesState.test.d.ts +0 -1
  413. package/dist/app/charts/axes/AxesState.test.js +0 -30
  414. package/dist/app/charts/axes/AxesState.test.js.map +0 -1
  415. package/dist/app/charts/axes/AxisInterval.test.d.ts +0 -1
  416. package/dist/app/charts/axes/AxisInterval.test.js +0 -120
  417. package/dist/app/charts/axes/AxisInterval.test.js.map +0 -1
  418. package/dist/app/charts/axes/ContinuousAxisRange.test.d.ts +0 -1
  419. package/dist/app/charts/axes/ContinuousAxisRange.test.js +0 -47
  420. package/dist/app/charts/axes/ContinuousAxisRange.test.js.map +0 -1
  421. package/dist/app/charts/axes/OrdinalAxisRange.test.d.ts +0 -1
  422. package/dist/app/charts/axes/OrdinalAxisRange.test.js +0 -48
  423. package/dist/app/charts/axes/OrdinalAxisRange.test.js.map +0 -1
  424. package/dist/app/charts/filters/regexFilter.test.d.ts +0 -1
  425. package/dist/app/charts/filters/regexFilter.test.js +0 -11
  426. package/dist/app/charts/filters/regexFilter.test.js.map +0 -1
  427. package/dist/app/charts/hooks/useDataObservable.d.ts +0 -72
  428. package/dist/app/charts/hooks/useDataObservable.js +0 -74
  429. package/dist/app/charts/hooks/useDataObservable.js.map +0 -1
  430. package/dist/app/charts/hooks/useInitialData.d.ts +0 -36
  431. package/dist/app/charts/hooks/useInitialData.js +0 -28
  432. package/dist/app/charts/hooks/useInitialData.js.map +0 -1
  433. package/dist/app/charts/observables/iterates.test.d.ts +0 -1
  434. package/dist/app/charts/observables/iterates.test.js +0 -180
  435. package/dist/app/charts/observables/iterates.test.js.map +0 -1
  436. package/dist/app/charts/observables/ordinals.test.d.ts +0 -1
  437. package/dist/app/charts/observables/ordinals.test.js +0 -102
  438. package/dist/app/charts/observables/ordinals.test.js.map +0 -1
  439. package/dist/app/charts/series/datumSeries.test.d.ts +0 -1
  440. package/dist/app/charts/series/datumSeries.test.js +0 -50
  441. package/dist/app/charts/series/datumSeries.test.js.map +0 -1
  442. package/dist/app/charts/styling/margins.test.d.ts +0 -1
  443. package/dist/app/charts/styling/margins.test.js +0 -19
  444. package/dist/app/charts/styling/margins.test.js.map +0 -1
  445. package/dist/app/charts/subscriptions/subscription.test.d.ts +0 -1
  446. package/dist/app/charts/subscriptions/subscription.test.js +0 -395
  447. package/dist/app/charts/subscriptions/subscription.test.js.map +0 -1
  448. package/dist/app/charts/subscriptions/subscriptions.d.ts +0 -100
  449. package/dist/app/charts/subscriptions/subscriptions.js +0 -449
  450. package/dist/app/charts/subscriptions/subscriptions.js.map +0 -1
  451. package/src/app/charts/axes/AxesState.test.ts +0 -34
  452. package/src/app/charts/axes/AxisInterval.test.ts +0 -143
  453. package/src/app/charts/axes/ContinuousAxisRange.test.ts +0 -55
  454. package/src/app/charts/axes/OrdinalAxisRange.test.ts +0 -55
  455. package/src/app/charts/filters/regexFilter.test.ts +0 -13
  456. package/src/app/charts/hooks/useDataObservable.tsx +0 -170
  457. package/src/app/charts/hooks/useInitialData.tsx +0 -64
  458. package/src/app/charts/observables/iterates.test.ts +0 -201
  459. package/src/app/charts/observables/ordinals.test.ts +0 -135
  460. package/src/app/charts/series/datumSeries.test.ts +0 -60
  461. package/src/app/charts/styling/margins.test.ts +0 -22
  462. package/src/app/charts/subscriptions/subscription.test.ts +0 -499
  463. package/src/app/charts/subscriptions/subscriptions.ts +0 -635
@@ -1,184 +1,24 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
- import { AxesState } from "../axes/AxesState";
3
- import { createContext, useContext, useRef } from "react";
4
- import { usePlotDimensions } from "./usePlotDimensions";
5
- import { Optional } from "result-fn";
1
+ import { createContext, useContext } from "react";
2
+ // the context is generic over the same type parameters as `UseAxesValues`, but a context
3
+ // object can't itself carry unbound generics -- `useAxes` below casts it back to the caller's
4
+ // concrete types, which is safe because `<AxesProvider/>` is what actually supplies the value
5
+ //
6
+ // IMPORTANT: as with `ChartContext` (see its identical note in useChart.tsx), this is NOT
7
+ // statically enforced across the component tree -- each consumer casts to its own hardcoded
8
+ // AR/A, independent of whatever `<AxesProvider<AR, A>>` ancestor actually supplied. A mismatched
9
+ // axis-range/axis kind only fails at runtime, not at compile time.
10
+ export const AxesContext = createContext(undefined);
6
11
  /**
7
- * No operation function for use when a default function is needed
8
- */
9
- const noop = () => {
10
- /* empty on purpose */
11
- };
12
- export const defaultAxesValues = () => ({
13
- xAxesState: AxesState.empty(),
14
- yAxesState: AxesState.empty(),
15
- addXAxis: noop,
16
- addYAxis: noop,
17
- setAxisAssignments: noop,
18
- axisAssignmentsFor: () => ({ xAxis: "", yAxis: "" }),
19
- updateAxisRanges: noop,
20
- axesRanges: () => new Map(),
21
- axisRangeFor: () => Optional.empty(),
22
- setAxesRanges: noop,
23
- setAxisRangeFor: noop,
24
- setAxisIntervalFor: noop,
25
- setOriginalAxisIntervalFor: noop,
26
- resetAxisIntervalFor: noop,
27
- resetAxesRanges: noop,
28
- addAxesRangesUpdateHandler: () => noop,
29
- removeAxesRangesUpdateHandler: () => noop,
30
- });
31
- // the context for axes
32
- const AxesContext = createContext(defaultAxesValues());
33
- /**
34
- * The React context provider for the {@link UseAxesValues}
35
- * @param props The properties
36
- * @return The children wrapped in this provider
37
- */
38
- export default function AxesProvider(props) {
39
- const { onUpdateAxesInterval, children } = props;
40
- const plotDimensions = usePlotDimensions();
41
- const xAxesStateRef = useRef(AxesState.empty());
42
- const yAxesStateRef = useRef(AxesState.empty());
43
- const axisAssignmentsRef = useRef(new Map());
44
- const axesBoundsUpdateHandlersRef = useRef(new Map());
45
- const axesRangeRef = useRef(new Map());
46
- /**
47
- * Retrieves the x-axis and y-axis assignments for the specified series. If the axis does not have
48
- * an assignment, then we assume it is using the default x- and y-axes.
49
- * @param seriesName The name of the series for which to retrieve the axes assignments
50
- * @return An {@link AxesAssignment} for the specified axes.
51
- */
52
- function axisAssignmentsFor(seriesName) {
53
- return axisAssignmentsRef.current.get(seriesName) || {
54
- xAxis: xAxesStateRef.current.axisDefaultId().getOrElse(""),
55
- yAxis: yAxesStateRef.current.axisDefaultId().getOrElse("")
56
- };
57
- }
58
- /**
59
- * Called when the domain/range is updated on one or more of the chart's axes (generally x-axes). In turn,
60
- * dispatches the update to all the internal domain/range update handlers.
61
- * @param updates A map holding the axis ID to the updated axis time-range (i.e., map(axis_id, axis_time_range))
62
- */
63
- function updateAxisRanges(updates) {
64
- // update the current time-ranges reference
65
- updates.forEach((range, id) => {
66
- axesRangeRef.current.set(id, range);
67
- });
68
- // dispatch the updates to all the registered handlers
69
- axesBoundsUpdateHandlersRef.current
70
- .forEach((handler) => handler(updates, plotDimensions.plotDimensions));
71
- }
72
- /**
73
- * Sets the axis ranges specified in the input map
74
- * @param ranges The ranges to set
75
- */
76
- function setAxesRanges(ranges) {
77
- ranges.forEach((range, id) => {
78
- axesRangeRef.current.set(id, range);
79
- });
80
- }
81
- /**
82
- * Sets the axis range for the specified axis ID
83
- * @param axisId The axis ID
84
- * @param range The range to set
85
- */
86
- function setAxisRangeFor(axisId, range) {
87
- axesRangeRef.current.set(axisId, range);
88
- }
89
- /**
90
- * Sets the axis bounds for the specified axis ID. Note that this does not
91
- * change the original axis interval
92
- * @param axisId The axis ID
93
- * @param interval The interval
94
- */
95
- function setAxisIntervalFor(axisId, interval) {
96
- Optional.ofNullable(axesRangeRef.current.get(axisId))
97
- .map(range => range.update(interval.start, interval.end))
98
- .ifPresent(updatedRange => axesRangeRef.current.set(axisId, updatedRange));
99
- }
100
- /**
101
- * Sets the original axis interval for the axis range
102
- * @param axisId The axis ID
103
- * @param interval The interval to which to set the origin interval
104
- */
105
- function setOriginalAxisIntervalFor(axisId, interval) {
106
- Optional.ofNullable(axesRangeRef.current.get(axisId))
107
- .map(range => range.updateOriginal(interval.start, interval.end))
108
- .ifPresent(updatedRange => axesRangeRef.current.set(axisId, updatedRange));
109
- }
110
- /**
111
- * Resets the bounds for the specified axis to the original range
112
- * @param axisId The ID of the axis
113
- */
114
- function resetAxisIntervalFor(axisId) {
115
- Optional
116
- .ofNullable(axesRangeRef.current.get(axisId))
117
- .map(range => new Map([[axisId, range]]))
118
- .ifPresent(updates => updateAxisRanges(updates));
119
- }
120
- /**
121
- * Resets the bounds of all the axes to their original value or to the values specified
122
- * in the optional bounds map.
123
- * @param [axesRanges=new Map()] An optional map holds bounds for specified axes. The map
124
- * associates an axis ID with the new bounds.
125
- */
126
- function resetAxesRanges(axesRanges = new Map()) {
127
- updateAxisRanges(axesRanges);
128
- }
129
- /**
130
- * Adds a handler to deal with updates to the bounds of the axes
131
- * @param handlerId the unique ID of the handler
132
- * @param handler The handler function that accepts a map of updates and a plot dimension
133
- * @return A map with all the handlers
134
- */
135
- function addAxesRangesUpdateHandler(handlerId, handler) {
136
- if (axesBoundsUpdateHandlersRef.current.has(handlerId)) {
137
- throw new Error(`Handler with ID already exists, please remove it before adding it; ` +
138
- `handler_id: ${handlerId}; ` +
139
- `existing_handler_ids: [${Array.from(axesBoundsUpdateHandlersRef.current.keys()).join(", ")}]`);
140
- }
141
- return axesBoundsUpdateHandlersRef.current.set(handlerId, handler);
142
- }
143
- return _jsx(AxesContext.Provider, { value: {
144
- xAxesState: xAxesStateRef.current,
145
- yAxesState: yAxesStateRef.current,
146
- addXAxis: (axis, id, range) => {
147
- xAxesStateRef.current = xAxesStateRef.current.addAxis(axis, id);
148
- if (range !== undefined) {
149
- axesRangeRef.current.set(id, range);
150
- }
151
- },
152
- addYAxis: (axis, id, range) => {
153
- yAxesStateRef.current = yAxesStateRef.current.addAxis(axis, id);
154
- if (range !== undefined) {
155
- axesRangeRef.current.set(id, range);
156
- }
157
- },
158
- setAxisAssignments: assignments => axisAssignmentsRef.current = assignments,
159
- axisAssignmentsFor: seriesName => axisAssignmentsFor(seriesName),
160
- updateAxisRanges,
161
- axesRanges: () => new Map(axesRangeRef.current),
162
- axisRangeFor: axisId => Optional.ofNullable(axesRangeRef.current.get(axisId)),
163
- setAxesRanges,
164
- setAxisRangeFor,
165
- setAxisIntervalFor,
166
- setOriginalAxisIntervalFor,
167
- resetAxesRanges,
168
- resetAxisIntervalFor,
169
- onUpdateAxesInterval,
170
- addAxesRangesUpdateHandler,
171
- removeAxesRangesUpdateHandler: handlerId => axesBoundsUpdateHandlersRef.current.delete(handlerId),
172
- }, children: children });
173
- }
174
- /**
175
- * React hook that sets up the React context for the chart values.
12
+ * React hook for the chart's axes: their state, ranges, and the functions for updating them.
13
+ * Must be used within an {@link AxesProvider} (i.e. within a `<Chart>`).
176
14
  * @return The {@link UseAxesValues} held in the React context.
15
+ * @throws Error when used outside an `<AxesProvider>`
16
+ * @template AR The type of the axis range (e.g. {@link ContinuousAxisRange} or {@link OrdinalAxisRange})
17
+ * @template A The axis type
177
18
  */
178
19
  export function useAxes() {
179
20
  const context = useContext(AxesContext);
180
- const { xAxesState } = context;
181
- if (xAxesState === undefined || xAxesState === null) {
21
+ if (context === undefined) {
182
22
  throw new Error("useAxes can only be used when the parent is a <AxesProvider/>");
183
23
  }
184
24
  return context;
@@ -1 +1 @@
1
- {"version":3,"file":"useAxes.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useAxes.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,mBAAmB,CAAC;AAG5C,OAAO,EAAC,aAAa,EAAO,UAAU,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AAE7D,OAAO,EAAC,iBAAiB,EAAC,MAAM,qBAAqB,CAAC;AAGtD,OAAO,EAAC,QAAQ,EAAC,MAAM,WA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AA;AAE5D;;;;;;;GAOG;AACH,MAAM,UAAU,OAAO;IACnB,MAAM,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAA;IACvC,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAA;IACpF,CAAC;IACD,OAAO,OAA+B,CAAA;AAC1C,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { CanvasContext } from "../d3types";
2
+ /**
3
+ * The values exposed through the {@link useCanvasSurface} react hook.
4
+ */
5
+ export type UseCanvasSurfaceValues = {
6
+ /**
7
+ * The `<canvas>` element backing the chart.
8
+ */
9
+ canvas: HTMLCanvasElement | null;
10
+ /**
11
+ * The canvas drawing context and redraw-registration API for the chart.
12
+ */
13
+ canvasContext: CanvasContext | null;
14
+ };
15
+ export declare const CanvasSurfaceContext: import("react").Context<UseCanvasSurfaceValues>;
16
+ /**
17
+ * React hook that reads the canvas element and canvas drawing context from context. This is set
18
+ * up by {@link CanvasSurfaceProvider}, which sizes the canvas from {@link usePlotDimensions} (the
19
+ * single source of truth for the chart's dimensions) rather than from static width/height props,
20
+ * so that the canvas stays correctly sized even if dimensions change via
21
+ * `usePlotDimensions().updateDimensions(...)` independent of any prop.
22
+ * @return The {@link UseCanvasSurfaceValues} held in the React context.
23
+ */
24
+ export declare function useCanvasSurface(): UseCanvasSurfaceValues;
25
+ //# sourceMappingURL=useCanvasSurface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCanvasSurface.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useCanvasSurface.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACjC;;OAEG;IACH,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAChC;;OAEG;IACH,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;CACtC,CAAA;AAOD,eAAO,MAAM,oBAAoB,iDAAoE,CAAA;AAErG;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,IAAI,sBAAsB,CAEzD"}
@@ -0,0 +1,18 @@
1
+ import { createContext, useContext } from "react";
2
+ const defaultCanvasSurfaceValues = {
3
+ canvas: null,
4
+ canvasContext: null,
5
+ };
6
+ export const CanvasSurfaceContext = createContext(defaultCanvasSurfaceValues);
7
+ /**
8
+ * React hook that reads the canvas element and canvas drawing context from context. This is set
9
+ * up by {@link CanvasSurfaceProvider}, which sizes the canvas from {@link usePlotDimensions} (the
10
+ * single source of truth for the chart's dimensions) rather than from static width/height props,
11
+ * so that the canvas stays correctly sized even if dimensions change via
12
+ * `usePlotDimensions().updateDimensions(...)` independent of any prop.
13
+ * @return The {@link UseCanvasSurfaceValues} held in the React context.
14
+ */
15
+ export function useCanvasSurface() {
16
+ return useContext(CanvasSurfaceContext);
17
+ }
18
+ //# sourceMappingURL=useCanvasSurface.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCanvasSurface.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useCanvasSurface.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AAiBhD,MAAM,0BAA0B,GAA2B;IACvD,MAAM,EAAE,IAAI;IACZ,aAAa,EAAE,IAAI;CACtB,CAAA;AAED,MAAM,CAAC,MAAM,oBAAoB,GAAG,aAAa,CAAyB,0BAA0B,CAAC,CAAA;AAErG;;;;;;;GAOG;AACH,MAAM,UAAU,gBAAgB;IAC5B,OAAO,UAAU,CAAC,oBAAoB,CAAC,CAAA;AAC3C,CAAC"}
@@ -1,20 +1,20 @@
1
- import { JSX, MutableRefObject } from "react";
2
- import { GSelection } from "../d3types";
3
- import { BaseAxis, SeriesLineStyle, SeriesStyle } from "../axes/axes";
4
- import { UseAxesValues } from "./useAxes";
5
- import { UseMouseValues } from "./useMouse";
6
- import { UseTooltipValues } from "./useTooltip";
7
- import { SvgStyle } from "../styling/svgStyle";
1
+ import type { CanvasContext } from "../d3types";
2
+ import type { BaseAxis, SeriesStyle } from "../axes/axes";
3
+ import { type UseAxesValues } from "./useAxes";
4
+ import { type UseMouseValues } from "./useMouse";
5
+ import { type UseTooltipValues } from "./useTooltip";
8
6
  import { BaseAxisRange } from "../axes/BaseAxisRange";
9
- export type NoTooltipMetadata = {};
7
+ export type NoTooltipMetadata = object;
10
8
  /**
11
9
  * The values exposed through the {@link useChart} react hook
12
10
  * @param chartId The unique ID for the chart
13
- * @param mainG The root <g> element for the chart
14
- * @param container The SVG element which is the container for this chart
11
+ * @param canvasContext The canvas drawing context and redraw-registration API for the chart
12
+ * @param canvas The `<canvas>` element which is the container for this chart
15
13
  * @template D The type of the series' datum
16
14
  * @template S The type of the series style
17
15
  * @template TM The type of the tooltip's metadata (data about the series data)
16
+ * @template AR The type of the axis range
17
+ * @template A The type of the axis
18
18
  */
19
19
  export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis> {
20
20
  /**
@@ -22,62 +22,48 @@ export interface UseChartValues<D, S extends SeriesStyle, TM, AR extends BaseAxi
22
22
  */
23
23
  chartId: number;
24
24
  /**
25
- * The root <g> element for the chart
25
+ * The canvas drawing context and redraw-registration API for the chart. Axes, plots, and the
26
+ * tracker register a draw function here (via `canvasContext.register(id, drawFn, zIndex)`)
27
+ * instead of creating/updating SVG elements. Replaces the old `mainG`.
26
28
  */
27
- mainG: GSelection | null;
29
+ canvasContext: CanvasContext | null;
28
30
  /**
29
- * The SVG element which is the container for this chart
31
+ * The `<canvas>` element which is the container for this chart. Replaces the old `container`
32
+ * (root `<svg>` element).
30
33
  */
31
- container: SVGSVGElement | null;
34
+ canvas: HTMLCanvasElement | null;
32
35
  /**
33
36
  * Base color
34
37
  */
35
38
  color: string;
36
39
  /**
37
- * The base/default background color. This can be overridden by the {@link Props.svgStyle} property.
40
+ * The base/default background color. This can be overridden by the {@link ChartProps.svgStyle} property.
38
41
  */
39
42
  backgroundColor: string;
40
- /**
41
- * Overrides for the SVG style
42
- */
43
- svgStyle: Partial<SvgStyle>;
44
43
  /**
45
44
  * A `map(series_name -> series_line_style)`
46
45
  */
47
46
  seriesStyles: Map<string, S>;
48
47
  axes: UseAxesValues<AR, A>;
49
48
  /**
50
- * A regular expression uses against the series names to determine which series to show in the chart
49
+ * A regular expression used against the series names to determine which series to show in the chart
51
50
  */
52
51
  seriesFilter: RegExp;
53
52
  mouse: UseMouseValues<D, TM>;
54
53
  tooltip: UseTooltipValues<D, TM>;
55
- /**
56
- * Ref tracking the currently-hovered series name (null when nothing is hovered).
57
- * Updated by the Legend; read by plots so new path elements use the correct stroke.
58
- */
59
- hoveredSeriesRef: MutableRefObject<string | null>;
60
54
  }
61
- export interface Props {
62
- chartId: number;
63
- container: SVGSVGElement | null;
64
- mainG: GSelection | null;
65
- color: string;
66
- backgroundColor: string;
67
- svgStyle: Partial<SvgStyle>;
68
- seriesStyles?: Map<string, SeriesLineStyle>;
69
- seriesFilter?: RegExp;
70
- hoveredSeriesRef: MutableRefObject<string | null>;
71
- children: JSX.Element | Array<JSX.Element>;
72
- }
73
- /**
74
- * The React context provider for the {@link UseChartValues}
75
- * @param props The properties
76
- * @return The children wrapped in this provider
77
- */
78
- export default function ChartProvider(props: Props): JSX.Element;
55
+ export declare const ChartContext: import("react").Context<unknown>;
79
56
  /**
80
- * React hook that sets up the React context for the chart values.
57
+ * React hook for the chart's values: its ID, canvas, colors, styles, axes, mouse and tooltip
58
+ * handlers, and highlighted series. Must be used within a `ChartProvider` (i.e. within a
59
+ * `<Chart>`).
81
60
  * @return The {@link UseChartValues} held in the React context.
61
+ * @throws Error when used outside a `<ChartProvider>`
62
+ * @template D The type of the series' datum
63
+ * @template S The type of the series style
64
+ * @template TM The type of the tooltip's metadata (data about the series data)
65
+ * @template AR The type of the axis range
66
+ * @template A The type of the axis
82
67
  */
83
68
  export declare function useChart<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis>(): UseChartValues<D, S, TM, AR, A>;
69
+ //# sourceMappingURL=useChart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useChart.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useChart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAC,QAAQ,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AACxD,OAAO,EAAC,KAAK,aAAa,EAAC,MAAM,WAAW,CAAC;AAC7C,OAAO,EAAC,KAAK,cAAc,EAAC,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAC,KAAK,gBAAgB,EAAC,MAAM,cAAc,CAAC;AACnD,OAAO,EAAC,aAAa,EAAC,MAAM,uBAAuB,CAAC;AAGpD,MAAM,MAAM,iBAAiB,GAAG,MAAM,CAAA;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,aAAa,EAAE,CAAC,SAAS,QAAQ;IACtG;;OAEG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;OAIG;IACH,aAAa,EAAE,aAAa,GAAG,IAAI,CAAA;IACnC;;;OAGG;IACH,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAChC;;OAEG;IACH,KAAK,EAAE,MAAM,CAAA;IACb;;OAEG;IACH,eAAe,EAAE,MAAM,CAAA;IACvB;;OAEG;IACH,YAAY,EAAE,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA;IAK5B,IAAI,EAAE,aAAa,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;IAK1B;;OAEG;IACH,YAAY,EAAE,MAAM,CAAA;IAKpB,KAAK,EAAE,cAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;IAC5B,OAAO,EAAE,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;CACnC;AAiBD,eAAO,MAAM,YAAY,kCAAkD,CAAA;AAE3E;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,SAAS,WAAW,EAAE,EAAE,EAAE,EAAE,SAAS,aAAa,EAAE,CAAC,SAAS,QAAQ,KAAK,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAOtI"}
@@ -1,54 +1,32 @@
1
- import { jsx as _jsx } from "react/jsx-runtime";
2
1
  import { createContext, useContext } from "react";
3
- import { defaultAxesValues, useAxes } from "./useAxes";
4
- import { defaultMouseValues, useMouse } from "./useMouse";
5
- import { defaultTooltipValues, useTooltip } from "./useTooltip";
6
- const defaultUseChartValues = {
7
- chartId: NaN,
8
- container: null,
9
- mainG: null,
10
- color: '#d2933f',
11
- backgroundColor: '#EEE',
12
- svgStyle: new Map(),
13
- seriesStyles: new Map(),
14
- // axes
15
- axes: defaultAxesValues(),
16
- // data
17
- seriesFilter: /./,
18
- // internal chart-interaction event handlers
19
- mouse: defaultMouseValues(),
20
- tooltip: defaultTooltipValues(),
21
- hoveredSeriesRef: { current: null },
22
- };
23
- const ChartContext = createContext(defaultUseChartValues);
2
+ import { defaultUseChartValues } from "./defaultUseChartValues";
3
+ // the context is generic over the same type parameters as `UseChartValues`, but a context
4
+ // object can't itself carry unbound generics -- `useChart` below casts it back to the caller's
5
+ // concrete types, which is safe because `<ChartProvider/>` is what actually supplies the value
6
+ //
7
+ // IMPORTANT: this is NOT statically enforced across the component tree. `<Chart<CD, D, S, TM, AR,
8
+ // A>>`'s AR/A are never referenced by its own Props type, so they can't even be inferred from
9
+ // JSX; and every descendant (each axis component) calls `useChart<...>()` with its OWN hardcoded
10
+ // generic arguments, entirely independent of whatever the ancestor `<Chart<...>>` was
11
+ // instantiated with. Nothing at the type level stops e.g. a `<Chart<..., ContinuousAxisRange,
12
+ // ContinuousNumericAxis>>` from having an `<OrdinalAxis>` child that casts this same context to
13
+ // `UseChartValues<..., OrdinalAxisRange, OrdinalStringAxis>` internally -- a real mismatch here
14
+ // only fails at runtime (a bad cast surfacing as a confusing error deeper in axis/plot code), not
15
+ // at compile time. Making this a real compile-time guarantee would need a per-instantiation-typed
16
+ // context (e.g. a context factory called once per concrete AR/A pairing) -- a broader refactor
17
+ // than the type parameters alone might suggest, and not something to casually "fix" locally.
18
+ export const ChartContext = createContext(defaultUseChartValues());
24
19
  /**
25
- * The React context provider for the {@link UseChartValues}
26
- * @param props The properties
27
- * @return The children wrapped in this provider
28
- */
29
- export default function ChartProvider(props) {
30
- const { chartId, container, mainG, color, backgroundColor, seriesFilter = defaultUseChartValues.seriesFilter, svgStyle, seriesStyles = new Map(), hoveredSeriesRef, } = props;
31
- const axes = useAxes();
32
- const mouse = useMouse();
33
- const tooltip = useTooltip();
34
- return _jsx(ChartContext.Provider, { value: {
35
- chartId,
36
- color,
37
- backgroundColor,
38
- svgStyle,
39
- seriesStyles,
40
- seriesFilter,
41
- mainG,
42
- container,
43
- axes,
44
- mouse,
45
- tooltip,
46
- hoveredSeriesRef,
47
- }, children: props.children });
48
- }
49
- /**
50
- * React hook that sets up the React context for the chart values.
20
+ * React hook for the chart's values: its ID, canvas, colors, styles, axes, mouse and tooltip
21
+ * handlers, and highlighted series. Must be used within a `ChartProvider` (i.e. within a
22
+ * `<Chart>`).
51
23
  * @return The {@link UseChartValues} held in the React context.
24
+ * @throws Error when used outside a `<ChartProvider>`
25
+ * @template D The type of the series' datum
26
+ * @template S The type of the series style
27
+ * @template TM The type of the tooltip's metadata (data about the series data)
28
+ * @template AR The type of the axis range
29
+ * @template A The type of the axis
52
30
  */
53
31
  export function useChart() {
54
32
  const context = useContext(ChartContext);
@@ -1 +1 @@
1
- {"version":3,"file":"useChart.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useChart.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,aAAa,EAAyB,UAAU,EAA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,KAAK;YACL,SAAS;YAET,IAAI;YACJ,KAAK;YACL,OAAO;YACP,gBAAgB;SACnB,YAEA,KAAK,CAAC,QAAQ,GACK,CAAA;AAC5B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,QAAQ;IACpB,MAAM,OAAO,GAAG,UAAU,CAAkC,YAAY,CAAC,CAAA;IACzE,MAAM,EAAC,OAAO,EAAC,GAAG,OAAO,CAAA;IACzB,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;IACtF,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
1
+ {"version":3,"file":"useChart.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useChart.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,UAAU,EAAC,MAAM,OAAO,CAAC;AAOhD,OAAO,EAAC,qBAAqB,EAAC,MAAM,yBAAyB,CAAC;AAgE9D,0FAA0F;AAC1F,+FAA+F;AAC/F,+FAA+F;AAC/F,EAAE;AACF,kGAAkG;AAClG,8FAA8F;AAC9F,iGAAiG;AACjG,sFAAsF;AACtF,8FAA8F;AAC9F,gGAAgG;AAChG,gGAAgG;AAChG,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAC/F,6FAA6F;AAC7F,MAAM,CAAC,MAAM,YAAY,GAAG,aAAa,CAAU,qBAAqB,EAAE,CAAC,CAAA;AAE3E;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ;IACpB,MAAM,OAAO,GAAG,UAAU,CAAC,YAAY,CAAoC,CAAA;IAC3E,MAAM,EAAC,OAAO,EAAC,GAAG,OAAO,CAAA;IACzB,IAAI,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC;QACjB,MAAM,IAAI,KAAK,CAAC,iEAAiE,CAAC,CAAA;IACtF,CAAC;IACD,OAAO,OAAO,CAAA;AAClB,CAAC"}
@@ -0,0 +1,68 @@
1
+ import type { ChartData } from "../observables/ChartData";
2
+ import type { BaseSeries } from "../series/baseSeries";
3
+ import type { StreamingDataSource } from "../datasources/StreamingDataSource";
4
+ /**
5
+ * The chart's data: its data source, the series the source held when it was handed to the chart,
6
+ * and the chart's streaming settings and callbacks
7
+ * @template CD The type of the chart data
8
+ * @template D The type of datum held in each series
9
+ * @template S The type of series
10
+ */
11
+ export interface ChartDataValues<CD extends ChartData, D, S extends BaseSeries<D> = BaseSeries<D>> {
12
+ /**
13
+ * The data source handed to the chart (its `dataSource` prop)
14
+ */
15
+ dataSource: StreamingDataSource<CD, D, S>;
16
+ /**
17
+ * The series the data source held when it was handed to the chart (a new data source means
18
+ * new initial data, so plots keyed on it reset)
19
+ */
20
+ initialData: Array<S>;
21
+ /**
22
+ * The time (ms) over which incoming data is batched before the plot redraws
23
+ */
24
+ windowingTime: number;
25
+ /**
26
+ * The period (ms) at which the data source's generator emits new data, when known. When
27
+ * provided, batching switches from wall-clock-based to a fixed tick count derived from
28
+ * `windowingTime / dataUpdatePeriod` (see the view drivers in `subscriptions/viewDrivers.ts`).
29
+ */
30
+ dataUpdatePeriod?: number;
31
+ /**
32
+ * Called when the chart time is updated (e.g. by plots whose axes aren't time)
33
+ * @param time The new chart time
34
+ */
35
+ onUpdateChartTime: (time: number) => void;
36
+ }
37
+ export declare const ChartDataContext: import("react").Context<unknown>;
38
+ /**
39
+ * @return The {@link StreamingDataSource} handed to the enclosing {@link Chart} through its
40
+ * `dataSource` prop (`undefined` only outside of a chart)
41
+ * @template CD The type of the chart data
42
+ * @template D The type of datum held in each series
43
+ * @template S The type of series
44
+ */
45
+ export declare function useDataSource<CD extends ChartData, D, S extends BaseSeries<D> = BaseSeries<D>>(): StreamingDataSource<CD, D, S> | undefined;
46
+ /**
47
+ * @return The series the chart's data source held when it was handed to the chart (for
48
+ * components that need the set of series up front, e.g. the legend, or a plot resetting itself
49
+ * for new data)
50
+ * @throws Error when used outside a `<Chart>`
51
+ * @template D The type of the datum held in each series
52
+ */
53
+ export declare function useInitialData<D>(): {
54
+ initialData: Array<BaseSeries<D>>;
55
+ };
56
+ /**
57
+ * @return The chart's streaming settings (how updates are batched for rendering) and callbacks
58
+ * @throws Error when used outside a `<Chart>`
59
+ */
60
+ export declare function useStreamingSettings(): Pick<ChartDataValues<ChartData, unknown>, 'windowingTime' | 'dataUpdatePeriod' | 'onUpdateChartTime'>;
61
+ /**
62
+ * Subscribes the calling component to the data source's running state, so it re-renders when the
63
+ * source starts or stops (e.g. to switch the zoom pivot, or hide markers while running).
64
+ * @param dataSource The data source, or `undefined` (in which case this is always `false`)
65
+ * @return Whether the data source is currently running
66
+ */
67
+ export declare function useDataSourceRunning<CD extends ChartData, D>(dataSource: StreamingDataSource<CD, D> | undefined): boolean;
68
+ //# sourceMappingURL=useDataSource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataSource.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useDataSource.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AACrD,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,oCAAoC,CAAC;AAE5E;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC;IAC7F;;OAEG;IACH,UAAU,EAAE,mBAAmB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IACzC;;;OAGG;IACH,WAAW,EAAE,KAAK,CAAC,CAAC,CAAC,CAAA;IACrB;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAA;IACzB;;;OAGG;IACH,iBAAiB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5C;AAKD,eAAO,MAAM,gBAAgB,kCAAoC,CAAA;AAcjE;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC,EAAE,CAAC,SAAS,UAAU,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,mBAAmB,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,SAAS,CAE3I;AAED;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,CAAC,KAAK;IAAC,WAAW,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;CAAC,CAGvE;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,IAAI,IAAI,CAAC,eAAe,CAAC,SAAS,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,kBAAkB,GAAG,mBAAmB,CAAC,CAG5I;AAED;;;;;GAKG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,SAAS,SAAS,EAAE,CAAC,EAAE,UAAU,EAAE,mBAAmB,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,GAAG,OAAO,CAWzH"}
@@ -0,0 +1,63 @@
1
+ import { createContext, useCallback, useContext, useSyncExternalStore } from "react";
2
+ // the context is generic over the same type parameters as `ChartDataValues`, but a context object
3
+ // can't itself carry unbound generics -- the hooks below cast it back to the caller's concrete
4
+ // types, which is safe because `<Chart/>` is what actually supplies the value
5
+ export const ChartDataContext = createContext(undefined);
6
+ /**
7
+ * @return The chart's data, and its streaming settings
8
+ * @throws Error when used outside a `<Chart>`
9
+ */
10
+ function useChartData() {
11
+ const context = useContext(ChartDataContext);
12
+ if (context === undefined) {
13
+ throw new Error("The chart's data can only be used within a <Chart/>");
14
+ }
15
+ return context;
16
+ }
17
+ /**
18
+ * @return The {@link StreamingDataSource} handed to the enclosing {@link Chart} through its
19
+ * `dataSource` prop (`undefined` only outside of a chart)
20
+ * @template CD The type of the chart data
21
+ * @template D The type of datum held in each series
22
+ * @template S The type of series
23
+ */
24
+ export function useDataSource() {
25
+ var _a;
26
+ return (_a = useContext(ChartDataContext)) === null || _a === void 0 ? void 0 : _a.dataSource;
27
+ }
28
+ /**
29
+ * @return The series the chart's data source held when it was handed to the chart (for
30
+ * components that need the set of series up front, e.g. the legend, or a plot resetting itself
31
+ * for new data)
32
+ * @throws Error when used outside a `<Chart>`
33
+ * @template D The type of the datum held in each series
34
+ */
35
+ export function useInitialData() {
36
+ const { initialData } = useChartData();
37
+ return { initialData };
38
+ }
39
+ /**
40
+ * @return The chart's streaming settings (how updates are batched for rendering) and callbacks
41
+ * @throws Error when used outside a `<Chart>`
42
+ */
43
+ export function useStreamingSettings() {
44
+ const { windowingTime, dataUpdatePeriod, onUpdateChartTime } = useChartData();
45
+ return { windowingTime, dataUpdatePeriod, onUpdateChartTime };
46
+ }
47
+ /**
48
+ * Subscribes the calling component to the data source's running state, so it re-renders when the
49
+ * source starts or stops (e.g. to switch the zoom pivot, or hide markers while running).
50
+ * @param dataSource The data source, or `undefined` (in which case this is always `false`)
51
+ * @return Whether the data source is currently running
52
+ */
53
+ export function useDataSourceRunning(dataSource) {
54
+ const subscribe = useCallback((onChange) => {
55
+ if (dataSource === undefined)
56
+ return () => {
57
+ };
58
+ const subscription = dataSource.isRunningObservable.subscribe(() => onChange());
59
+ return () => subscription.unsubscribe();
60
+ }, [dataSource]);
61
+ return useSyncExternalStore(subscribe, () => { var _a; return (_a = dataSource === null || dataSource === void 0 ? void 0 : dataSource.running) !== null && _a !== void 0 ? _a : false; });
62
+ }
63
+ //# sourceMappingURL=useDataSource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useDataSource.js","sourceRoot":"","sources":["../../../../src/app/charts/hooks/useDataSource.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,oBAAoB,EAAC,MAAM,OAAO,CAAC;AAuCnF,kGAAkG;AAClG,+FAA+F;AAC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