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,92 +1,48 @@
1
- import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
2
- import { cloneElement, useEffect, useMemo } from "react";
3
- import { defaultTooltipStyle, removeTooltip } from "./tooltipUtils";
4
- import * as d3 from "d3";
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo } from "react";
3
+ import { defaultTooltipStyle } from "./tooltipUtils";
5
4
  import { useChart } from "../hooks/useChart";
6
- import { usePlotDimensions } from "../hooks/usePlotDimensions";
5
+ import { TooltipStyleContext } from "./useTooltipStyle";
7
6
  /**
8
- * Tooltip component triggered by mouse-over-series events. When mounted, the tooltip component
9
- * registers a mouse-over handler with the {@link useMouse} hook using the
10
- * {@link UseMouseValues.registerMouseOverHandler} function. The handler renders the tooltip
11
- * by adding it to the SVG plot container. However, to remain general, this {@link Tooltip} also
12
- * uses the {@link useTooltip}'s {@link UseTooltipValues.tooltipContentProvider} to render the actual
13
- * content of the tooltip. The content provider is given the series' name on which the mouse-over
14
- * event occurred, the plot time associated with mouse-over event, and the {@link TimeSeries}
15
- * associated with the mouse-over event. The plot (for example {@link ScatterPlot}) is responsible
16
- * for rendering the tooltip, and it registers this tooltip-content provider with the {@link useTooltip}
17
- * hook.
7
+ * Shows a tooltip when the mouse is over one of the plot's elements (a series, a point, a spike, a
8
+ * bar, a band, and so on), while `visible` is `true`. What the tooltip shows is up to its content
9
+ * (its child -- for example, a `<ScatterPlotTooltipContent>`), which is built on
10
+ * {@link TooltipContent}.
18
11
  *
19
- * The {@link useChart} hook allows the plots and this tooltip to register methods needed its siblings.
12
+ * The plot hit-tests the mouse against what it drew, and calls the mouse-over handler this
13
+ * component registers (see `useMouse`), which hands what the plot knows about the element
14
+ * under the mouse to the content's tooltip-content provider (see `useTooltip`). The content
15
+ * shows itself, and hides itself again when the mouse leaves the element.
20
16
  *
21
- * ## on mount
22
- * 1. The plot (for example {@link ScatterPlot}) adds a d3 mouse-enter and mouse-leave event handlers
23
- * to each series. The mouse-enter event handler performs a few tasks and then calls the
24
- * mouse-over event handler registered by the {@link Tooltip} via the {@link useMouse} hook.
25
- * 2. The plot (for example {@link ScatterPlot}) registers the tooltip-content provider with the {@link useTooltip}
26
- * hook using the {@link UseTooltipValues.registerTooltipContentProvider} function.
27
- * 3. {@link Tooltip} registers the handler for mouse-over events. The handler accepts the series
28
- * name, plot time, and time-series associated with the mouse-over event, and returns the tooltip
29
- * dimensions. In order to create/render the tooltip, it uses the {@link UseTooltipValues.tooltipContentProvider}
30
- * function that was registered via the {@link useTooltip} hook.
31
- *
32
- * ## on mouse-over event
33
- * When the plot's (for example {@link ScatterPlot}) d3 mouse-enter event handler fires, the plot calls this
34
- * {@link Tooltip}'s mouse-over handler, which creates the tooltip, and calls the {@link UseTooltipValues.tooltipContentProvider}
35
- * registered by the plot to render the tooltip content, and get the tooltip size.
36
- *
37
- * @param props The properties of the tooltip (i.e. visibility and style)
38
- * @return null
17
+ * The content gets this tooltip's style (its `style` over the default tooltip style) through
18
+ * {@link useTooltipStyle}, and can override parts of it.
19
+ * @param props Whether the tooltip is shown, its style, and its content
20
+ * @return The content, while the tooltip is shown
21
+ * @template D The type of the series' datum
22
+ * @template S The type of the series style
23
+ * @template TM The type of the tooltip metadata
24
+ * @template AR The type of the axis range
25
+ * @template A The type of the axis
39
26
  */
40
27
  export function Tooltip(props) {
41
- const { chartId, container, tooltip, mouse } = useChart();
42
- const { tooltipContentProvider, setVisibilityState, } = tooltip;
43
- const { margin, plotDimensions } = usePlotDimensions();
44
28
  const { visible, style, children } = props;
45
- const { registerMouseOverHandler, unregisterMouseOverHandler, registerMouseLeaveHandler, unregisterMouseLeaveHandler } = mouse;
46
- const tooltipStyle = useMemo(() => (Object.assign(Object.assign({}, defaultTooltipStyle), style)), [style]);
47
- // let the tooltip context know whether the tooltip is visible
48
- setVisibilityState(visible);
29
+ const { chartId, tooltip, mouse } = useChart();
30
+ const { tooltipContentProvider, setVisibilityState } = tooltip;
31
+ const { registerMouseOverHandler, unregisterMouseOverHandler } = mouse;
32
+ const tooltipStyle = useMemo(() => ({ ...defaultTooltipStyle, ...style }), [style]);
49
33
  useEffect(() => {
34
+ // let the tooltip context know whether the tooltip is visible
35
+ setVisibilityState(visible);
36
+ if (!visible)
37
+ return;
38
+ // hands the element under the mouse to the content's provider (looked up on each call,
39
+ // so it's always the one the content registered most recently)
50
40
  const handlerId = `tooltip-${chartId}`;
51
- if (visible && container) {
52
- const contentProvider = tooltipContentProvider();
53
- if (contentProvider) {
54
- // register this tooltip's mouse-over event handler with the useCharts hook
55
- // so that the plots can call it when mouse-enter events are triggered (for
56
- // example, a mouse-over a time-series in the plot).
57
- registerMouseOverHandler(handlerId, ((seriesName, time, tooltipData, mouseCoords, providerId) => {
58
- // create the rounded rectangle for the tooltip's background
59
- const rect = d3.select(container)
60
- .append('rect')
61
- .attr('id', `r${time}-${seriesName}-${chartId}`)
62
- .attr('class', 'tooltip')
63
- .attr('rx', tooltipStyle.borderRadius)
64
- .attr('fill', tooltipStyle.backgroundColor)
65
- .attr('fill-opacity', tooltipStyle.backgroundOpacity)
66
- .attr('stroke', tooltipStyle.borderColor)
67
- .attr('stroke-width', tooltipStyle.borderWidth)
68
- .attr('stroke-opacity', tooltipStyle.borderOpacity);
69
- // call the callback to add the content
70
- const { x, y, contentWidth, contentHeight } = contentProvider(seriesName, time, tooltipData, mouseCoords, providerId);
71
- // set the position, width, and height of the tooltip rect based on the text height and width and the padding
72
- rect.attr('x', () => x)
73
- .attr('y', () => y)
74
- .attr('width', contentWidth + tooltipStyle.paddingLeft + tooltipStyle.paddingRight)
75
- .attr('height', contentHeight + tooltipStyle.paddingTop + tooltipStyle.paddingBottom);
76
- }));
77
- registerMouseLeaveHandler(handlerId, () => removeTooltip());
78
- }
79
- }
80
- return () => {
81
- unregisterMouseOverHandler(handlerId);
82
- unregisterMouseLeaveHandler(handlerId);
83
- };
84
- }, [
85
- chartId, container, margin, plotDimensions,
86
- registerMouseOverHandler, tooltipContentProvider, tooltipStyle,
87
- unregisterMouseOverHandler, visible, registerMouseLeaveHandler,
88
- unregisterMouseLeaveHandler
89
- ]);
90
- return _jsx(_Fragment, { children: cloneElement(children, props) });
41
+ registerMouseOverHandler(handlerId, (seriesName, time, tooltipData, mouseCoords, providerId) => { var _a; return (_a = tooltipContentProvider()) === null || _a === void 0 ? void 0 : _a(seriesName, time, tooltipData, mouseCoords, providerId); });
42
+ return () => unregisterMouseOverHandler(handlerId);
43
+ }, [chartId, visible, tooltipContentProvider, setVisibilityState, registerMouseOverHandler, unregisterMouseOverHandler]);
44
+ // (the content is only mounted while the tooltip is visible, so hiding the tooltip also hides
45
+ // any content that's showing)
46
+ return (_jsx(TooltipStyleContext.Provider, { value: tooltipStyle, children: visible ? children : null }));
91
47
  }
92
48
  //# sourceMappingURL=Tooltip.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tooltip.js","sourceRoot":"","sources":["../../../../src/app/charts/tooltips/Tooltip.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,YAAY,EAAE,SAAS,EAAE,OAAO,EAAM,MAAM,OAAO,CAAC;AAC5D,OAAO,EAAC,mBAAmB,EAAE,aAAa,EAAe,MAAM,gBAAgB,CAAC;AAChF,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAW7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,MAAM,UAAU,OAAO,CAA6E,KAAY;IAC5G,MAAM,EACF,OAAO,EACP,SAAS,EACT,OAAO,EACP,KAAK,EACR,GAAG,QAAQ,EAAmB,CAAA;IAE/B,MAAM,EACF,sBAAsB,EACtB,kBAAkB,GACrB,GAAG,OAAO,CAAA;IAEX,MAAM,EAAC,MAAM,EAAE,cAAc,EAAC,GAAG,iBAAiB,EAAE,CAAA;IAEpD,MAAM,EACF,OAAO,EACP,KAAK,EACL,QAAQ,EACX,GAAG,KAAK,CAAA;IAET,MAAM,EACF,wBAAwB,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CAAC,QAAQ,IAAC,KAAK,EAAE,YAAY,YAC5C,OAAO,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,GACC,CAClC,CAAA;AACL,CAAC"}
@@ -0,0 +1,81 @@
1
+ import { type CSSProperties, type ReactElement, type ReactNode } from "react";
2
+ import type { TooltipData } from "../hooks/useTooltip";
3
+ import type { TooltipStyle } from "./tooltipUtils";
4
+ /**
5
+ * Turns what the plot hands the tooltip about the element under the mouse into the content to show
6
+ * (any value you like), or `undefined` to show nothing.
7
+ * @param seriesName The name of the series under the mouse
8
+ * @param time A value that depends on the plot: usually the time under the mouse (see the plot's
9
+ * documentation)
10
+ * @param tooltipData The series' data, and the plot's metadata about the element under the mouse
11
+ * @param providerId Which kind of element is under the mouse, for a plot that has several (e.g. the
12
+ * bar plot)
13
+ * @return The tooltip's content, or `undefined` to show no tooltip
14
+ * @template D The type of the series' datum
15
+ * @template M The type of the plot's tooltip metadata
16
+ * @template C The type of the tooltip's content
17
+ */
18
+ export type TooltipCapture<D, M, C> = (seriesName: string, time: number, tooltipData: TooltipData<D, M>, providerId?: string) => C | undefined;
19
+ /**
20
+ * The properties of the {@link TooltipContent}
21
+ * @template D The type of the series' datum
22
+ * @template M The type of the plot's tooltip metadata
23
+ * @template C The type of the tooltip's content
24
+ */
25
+ export interface TooltipContentProps<D, M, C> {
26
+ /**
27
+ * Turns what the plot hands the tooltip into the tooltip's content. Called on every mouse move
28
+ * over an element, so keep it quick -- and copy what you need out of the series, which the data
29
+ * source keeps changing.
30
+ */
31
+ capture: TooltipCapture<D, M, C>;
32
+ /**
33
+ * Renders the content (inside the tooltip's box)
34
+ * @param content The content returned by `capture`
35
+ * @param style The tooltip's style
36
+ * @return What to show in the tooltip's box
37
+ */
38
+ children: (content: C, style: TooltipStyle) => ReactNode;
39
+ /**
40
+ * Overrides of the style of the enclosing {@link Tooltip}
41
+ */
42
+ style?: Partial<TooltipStyle>;
43
+ /**
44
+ * Additional CSS for the tooltip's box (e.g. its line height)
45
+ */
46
+ boxStyle?: CSSProperties;
47
+ /**
48
+ * Where the tooltip's top goes (relative to the chart), given its content and its rendered
49
+ * height -- for a tooltip that isn't placed below the mouse (e.g. one centered on a raster
50
+ * plot's row). By default, the tooltip goes just below the mouse.
51
+ */
52
+ topFor?: (content: C, height: number) => number;
53
+ }
54
+ /**
55
+ * The building block of every tooltip's content. Put a component built on it inside a
56
+ * {@link Tooltip}, and when the mouse moves over one of the plot's elements, it calls `capture` with
57
+ * what the plot knows about that element, and shows what `children` renders, in a box next to the
58
+ * mouse (styled like the enclosing `<Tooltip>`). It hides again when the mouse leaves the element.
59
+ *
60
+ * Under the hood, it registers the chart's tooltip-content provider (one per chart: registering
61
+ * replaces the previous one), and a mouse-leave handler, and renders its box as a React portal on
62
+ * the page's `body`, which `useTooltipPlacement` places next to the mouse once it's rendered
63
+ * (and so its size is known).
64
+ * @example
65
+ * function MyScatterTooltip(): JSX.Element {
66
+ * return (
67
+ * <TooltipContent<Datum, ScatterTooltipMetadata, {seriesName: string, count: number}>
68
+ * capture={(seriesName, _time, {series}) => ({seriesName, count: series.length})}
69
+ * >
70
+ * {({seriesName, count}) => <div>{seriesName}: {count} points</div>}
71
+ * </TooltipContent>
72
+ * )
73
+ * }
74
+ * @param props The capture and render functions, and the style
75
+ * @return The tooltip's box (a portal), or `null` when nothing is hovered
76
+ * @template D The type of the series' datum
77
+ * @template M The type of the plot's tooltip metadata
78
+ * @template C The type of the tooltip's content
79
+ */
80
+ export declare function TooltipContent<D, M, C>(props: TooltipContentProps<D, M, C>): ReactElement | null;
81
+ //# sourceMappingURL=TooltipContent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TooltipContent.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/tooltips/TooltipContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,aAAa,EAAE,KAAK,YAAY,EAAE,KAAK,SAAS,EAAuC,MAAM,OAAO,CAAC;AAIlH,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,qBAAqB,CAAC;AAIrD,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,gBAAgB,CAAC;AAIjD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAClC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,MAAM,EACZ,WAAW,EAAE,WAAW,CAAC,CAAC,EAAE,CAAC,CAAC,EAC9B,UAAU,CAAC,EAAE,MAAM,KAClB,CAAC,GAAG,SAAS,CAAA;AAElB;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACxC;;;;OAIG;IACH,OAAO,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAChC;;;;;OAKG;IACH,QAAQ,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,YAAY,KAAK,SAAS,CAAA;IACxD;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC,YAAY,CAAC,CAAA;IAC7B;;OAEG;IACH,QAAQ,CAAC,EAAE,aAAa,CAAA;IACxB;;;;OAIG;IACH,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,KAAK,MAAM,CAAA;CAClD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,cAAc,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,YAAY,GAAG,IAAI,CAiFhG"}
@@ -0,0 +1,99 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useMemo, useRef, useState } from "react";
3
+ import { createPortal } from "react-dom";
4
+ import { useChart } from "../hooks/useChart";
5
+ import { usePlotDimensions } from "../hooks/usePlotDimensions";
6
+ import { withAlpha } from "../styling/canvasStyle";
7
+ import { tooltipAnchorFor, useTooltipPlacement } from "./useTooltipPlacement";
8
+ import { useTooltipStyle } from "./useTooltipStyle";
9
+ /**
10
+ * The building block of every tooltip's content. Put a component built on it inside a
11
+ * {@link Tooltip}, and when the mouse moves over one of the plot's elements, it calls `capture` with
12
+ * what the plot knows about that element, and shows what `children` renders, in a box next to the
13
+ * mouse (styled like the enclosing `<Tooltip>`). It hides again when the mouse leaves the element.
14
+ *
15
+ * Under the hood, it registers the chart's tooltip-content provider (one per chart: registering
16
+ * replaces the previous one), and a mouse-leave handler, and renders its box as a React portal on
17
+ * the page's `body`, which `useTooltipPlacement` places next to the mouse once it's rendered
18
+ * (and so its size is known).
19
+ * @example
20
+ * function MyScatterTooltip(): JSX.Element {
21
+ * return (
22
+ * <TooltipContent<Datum, ScatterTooltipMetadata, {seriesName: string, count: number}>
23
+ * capture={(seriesName, _time, {series}) => ({seriesName, count: series.length})}
24
+ * >
25
+ * {({seriesName, count}) => <div>{seriesName}: {count} points</div>}
26
+ * </TooltipContent>
27
+ * )
28
+ * }
29
+ * @param props The capture and render functions, and the style
30
+ * @return The tooltip's box (a portal), or `null` when nothing is hovered
31
+ * @template D The type of the series' datum
32
+ * @template M The type of the plot's tooltip metadata
33
+ * @template C The type of the tooltip's content
34
+ */
35
+ export function TooltipContent(props) {
36
+ var _a;
37
+ const { capture, children, style, boxStyle, topFor } = props;
38
+ const { chartId, canvas, tooltip, mouse } = useChart();
39
+ const { registerTooltipContentProvider } = tooltip;
40
+ const { registerMouseLeaveHandler, unregisterMouseLeaveHandler } = mouse;
41
+ const { margin, plotDimensions } = usePlotDimensions();
42
+ const enclosingStyle = useTooltipStyle();
43
+ const tooltipStyle = useMemo(() => ({ ...enclosingStyle, ...style }), [enclosingStyle, style]);
44
+ // what's shown, and where (null when nothing is hovered)
45
+ const [shown, setShown] = useState(null);
46
+ const tooltipRef = useRef(null);
47
+ // the latest capture and placement functions, so that the registered provider always uses the
48
+ // current ones without having to be registered again whenever they change
49
+ const captureRef = useRef(capture);
50
+ const topForRef = useRef(topFor);
51
+ useEffect(() => {
52
+ captureRef.current = capture;
53
+ topForRef.current = topFor;
54
+ });
55
+ // the plot calls the provider whenever the mouse is over one of its elements
56
+ useEffect(() => {
57
+ if (canvas === null)
58
+ return;
59
+ registerTooltipContentProvider((seriesName, time, tooltipData, mouseCoords, providerId) => {
60
+ const content = captureRef.current(seriesName, time, tooltipData, providerId);
61
+ if (content === undefined) {
62
+ setShown(null);
63
+ return;
64
+ }
65
+ const placeTop = topForRef.current;
66
+ const anchor = tooltipAnchorFor(mouseCoords, canvas, placeTop !== undefined ? height => placeTop(content, height) : undefined);
67
+ setShown({ content, anchor });
68
+ });
69
+ }, [canvas, registerTooltipContentProvider]);
70
+ // hides the tooltip when the mouse leaves the element
71
+ useEffect(() => {
72
+ const handlerId = `tooltip-content-leave-${chartId}`;
73
+ registerMouseLeaveHandler(handlerId, () => setShown(null));
74
+ return () => unregisterMouseLeaveHandler(handlerId);
75
+ }, [chartId, registerMouseLeaveHandler, unregisterMouseLeaveHandler]);
76
+ // places the tooltip next to the mouse, once it's rendered (and so its size is known)
77
+ useTooltipPlacement(tooltipRef, (_a = shown === null || shown === void 0 ? void 0 : shown.anchor) !== null && _a !== void 0 ? _a : null, plotDimensions, margin, tooltipStyle);
78
+ if (shown === null)
79
+ return null;
80
+ const tooltipBoxStyle = {
81
+ position: 'fixed',
82
+ // (placed next to the mouse, from its rendered size, by `useTooltipPlacement`, before it's
83
+ // painted)
84
+ left: 0,
85
+ top: 0,
86
+ backgroundColor: withAlpha(tooltipStyle.backgroundColor, tooltipStyle.backgroundOpacity),
87
+ border: `${tooltipStyle.borderWidth}px solid ${withAlpha(tooltipStyle.borderColor, tooltipStyle.borderOpacity)}`,
88
+ borderRadius: tooltipStyle.borderRadius,
89
+ padding: `${tooltipStyle.paddingTop}px ${tooltipStyle.paddingRight}px ${tooltipStyle.paddingBottom}px ${tooltipStyle.paddingLeft}px`,
90
+ fontFamily: tooltipStyle.fontFamily,
91
+ fontSize: tooltipStyle.fontSize,
92
+ color: tooltipStyle.fontColor,
93
+ pointerEvents: 'none',
94
+ zIndex: 9999,
95
+ ...boxStyle,
96
+ };
97
+ return createPortal(_jsx("div", { ref: tooltipRef, style: tooltipBoxStyle, children: children(shown.content, tooltipStyle) }), document.body);
98
+ }
99
+ //# sourceMappingURL=TooltipContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TooltipContent.js","sourceRoot":"","sources":["../../../../src/app/charts/tooltips/TooltipContent.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAwD,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAC;AAClH,OAAO,EAAC,YAAY,EAAC,MAAM,WAAW,CAAC;AACvC,OAAO,EAAC,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAI7D,OAAO,EAAC,SAAS,EAAC,MAAM,wBAAwB,CAAC;AAEjD,OAAO,EAAC,gBAAgB,EAAsB,mBAAmB,EAAC,MAAM,uBAAuB,CAAC;AAChG,OAAO,EAAC,eAAe,EAAC,MAAM,mBAAmB,CAAC;AA2DlD;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,cAAc,CAAU,KAAmC;;IACvE,MAAM,EAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAC,GAAG,KAAK,CAAA;IAE1D,MAAM,EAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAC,GAAG,QAAQ,EAA8C,CAAA;IAChG,MAAM,EAAC,8BAA8B,EAAC,GAAG,OAAO,CAAA;IAChD,MAAM,EAAC,yBAAyB,EAAE,2BAA2B,EAAC,GAAG,KAAK,CAAA;IACtE,MAAM,EAAC,MAAM,EAAE,cAAc,EAAC,GAAG,iBAAiB,EAAE,CAA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QAAQ,EAAE,YAAY,CAAC,QAAQ;QAC/B,KAAK,EAAE,YAAY,CAAC,SAAS;QAC7B,aAAa,EAAE,MAAM;QACrB,MAAM,EAAE,IAAI;QACZ,GAAG,QAAQ;KACd,CAAA;IACD,OAAO,YAAY,CACf,cAAK,GAAG,EAAE,UAAU,EAAE,KAAK,EAAE,eAAe,YAAG,QAAQ,CAAC,KAAK,CAAC,OAAO,EAAE,YAAY,CAAC,GAAO,EAC3F,QAAQ,CAAC,IAAI,CAChB,CAAA;AACL,CAAC"}
@@ -1,6 +1,8 @@
1
- import { Series } from "../plots/plot";
2
- import { Dimensions, Margin } from "../styling/margins";
3
- import { OrdinalStringAxis } from "../axes/axes";
1
+ import type { Series } from "../plots/plot";
2
+ import type { Dimensions, Margin } from "../styling/margins";
3
+ import type { OrdinalStringAxis } from "../axes/axes";
4
+ import type { ScaleContinuousNumeric } from "d3";
5
+ import type { Datum } from "../series/timeSeries";
4
6
  /**
5
7
  * Properties for rendering the tooltip. This is the style for the container
6
8
  * of the content.
@@ -40,52 +42,48 @@ export interface TooltipStyle {
40
42
  paddingTop: number;
41
43
  paddingBottom: number;
42
44
  }
43
- export declare const defaultTooltipStyle: TooltipStyle;
44
- export interface TooltipDimensions {
45
- x: number;
46
- y: number;
47
- contentWidth: number;
48
- contentHeight: number;
49
- }
50
45
  /**
51
- * Removes the tooltip when the mouse has moved away from the spike
46
+ * The default tooltip style
52
47
  */
53
- export declare function removeTooltip(): void;
48
+ export declare const defaultTooltipStyle: TooltipStyle;
54
49
  /**
55
- * Calculates the x-coordinate of the upper left-hand side of the tooltip rectangle (obviously without
56
- * "rounded corners"). Adjusts the x-coordinate so that tooltip is visible on the edges of the plot.
57
- * @param x The current x-coordinate of the mouse
58
- * @param textWidth The width of the tooltip text
50
+ * Calculates the x-coordinate of the left side of the tooltip. The tooltip goes to the right of the
51
+ * mouse, unless it would run past the right edge of the plot, in which case it goes to the left of
52
+ * the mouse (and never past the left edge of the chart).
53
+ * @param x The x-coordinate of the mouse, relative to the chart
54
+ * @param width The tooltip's (rendered) width, including its padding and border
59
55
  * @param plotDimensions The dimensions of the plot
60
- * @param tooltipStyle The tooltip style information
56
+ * @param tooltipStyle The tooltip style information (its left padding is used as the gap between
57
+ * the mouse and the tooltip)
61
58
  * @param margin The plot margin
62
- * @return The x-coordinate of the lower left-hand side of the tooltip rectangle
59
+ * @return The x-coordinate of the tooltip's left side, relative to the chart
63
60
  */
64
- export declare function tooltipX(x: number, textWidth: number, plotDimensions: Dimensions, tooltipStyle: TooltipStyle, margin: Margin): number;
61
+ export declare function tooltipX(x: number, width: number, plotDimensions: Dimensions, tooltipStyle: TooltipStyle, margin: Margin): number;
65
62
  /**
66
- * Calculates the y-coordinate of the upper-left-hand corner of the tooltip rectangle. Adjusts the y-coordinate
67
- * so that the tooltip is visible on the upper edge of the plot
68
- * @param y The y-coordinate of the mouse
69
- * @param textHeight The height of the header and neuron ID text
63
+ * Calculates the y-coordinate of the top of the tooltip. The tooltip goes below the mouse, unless it
64
+ * would run past the bottom of the plot, in which case it's moved up so that its bottom lines up
65
+ * with the plot's bottom (and never past the top edge of the chart).
66
+ * @param y The y-coordinate of the mouse, relative to the chart
67
+ * @param height The tooltip's (rendered) height, including its padding and border
70
68
  * @param plotDimensions The dimensions of the plot
71
- * @param tooltipStyle The tooltip style information
69
+ * @param tooltipStyle The tooltip style information (its top padding is used as the gap between
70
+ * the mouse and the tooltip)
72
71
  * @param margin The plot margin
73
- * @return The y-coordinate of the lower-left-hand corner of the tooltip rectangle
72
+ * @return The y-coordinate of the tooltip's top, relative to the chart
74
73
  */
75
- export declare function tooltipY(y: number, textHeight: number, plotDimensions: Dimensions, tooltipStyle: TooltipStyle, margin: Margin): number;
74
+ export declare function tooltipY(y: number, height: number, plotDimensions: Dimensions, tooltipStyle: TooltipStyle, margin: Margin): number;
76
75
  /**
77
- * Calculates the y-coordinate for the upper-left-hand the tooltip rectangle. Adjusts the y-coordinate so
78
- * that the tooltip is visible on the upper and lower edges of the plot
79
- * @param seriesName The name of the series
80
- * @param textHeight The height of the header and neuron ID text
76
+ * Calculates the y-coordinate of the top of a tooltip for a category (e.g. a raster plot's row):
77
+ * the tooltip is centered on the category, but kept within the plot's top and bottom edges.
78
+ * @param seriesName The name of the series (the category)
79
+ * @param height The tooltip's (rendered) height, including its padding and border
81
80
  * @param axis The category axis for determining the y-value of the tooltip
82
- * @param tooltipStyle The tooltip style
83
81
  * @param margin The plot margin
84
82
  * @param categoryHeight The height (in pixels) of the category
85
83
  * @param plotDimensions The dimensions of the plot
86
- * @return The y-coordinate of the lower-left-hand corner of the tooltip rectangle
84
+ * @return The y-coordinate of the tooltip's top, relative to the chart
87
85
  */
88
- export declare function categoryTooltipY(seriesName: string, textHeight: number, axis: OrdinalStringAxis, tooltipStyle: TooltipStyle, margin: Margin, categoryHeight: number, plotDimensions: Dimensions): number;
86
+ export declare function categoryTooltipY(seriesName: string, height: number, axis: OrdinalStringAxis, margin: Margin, categoryHeight: number, plotDimensions: Dimensions): number;
89
87
  /**
90
88
  * Returns the (time, value) point that comes just before the mouse and just after the mouse
91
89
  * @param data The time-series data
@@ -93,9 +91,161 @@ export declare function categoryTooltipY(seriesName: string, textHeight: number,
93
91
  * @param xFrom A function that extracts the x-value from the datum
94
92
  * @param emptyDatum A function that returns an empty datum
95
93
  * @template D The type of the datum in the data-series
96
- * @return {[[number, number], [number, number]]} the (time, value) point that comes just before
97
- * the mouse and just after the mouse. If the mouse is after the last point, then the "after" point
98
- * is `[NaN, NaN]`. If the mouse is before the first point, then the "before" point is `[NaN, NaN]`.
94
+ * @return The point that comes just before the mouse and just after the mouse. If the mouse is
95
+ * after the last point, then the "after" point is the empty datum. If the mouse is before the
96
+ * first point, then the "before" point is the empty datum. (Both are, for an empty series.)
99
97
  */
100
98
  export declare function boundingPoints<D>(data: Series<D>, value: number, xFrom: (value: D) => number, emptyDatum: () => D): [D, D];
99
+ /**
100
+ * Finds the first point whose x-value is within the tolerance of the specified value, along with
101
+ * the points before and after it
102
+ * @param data The series' data
103
+ * @param value The x-value to look for
104
+ * @param tolerance How far (in the x-value's units) a point's x-value may be from the value
105
+ * @param xFrom A function that extracts the x-value from the datum
106
+ * @param emptyDatum A function that returns an empty datum (for a point that doesn't exist)
107
+ * @return The point before, the point, the point after, and the point's index (-1 when no point
108
+ * is within the tolerance, in which case the point and the point before are empty, and the point
109
+ * after is the series' first point)
110
+ * @template D The type of the datum in the data-series
111
+ */
101
112
  export declare function findPointAndNeighbors<D>(data: Series<D>, value: number, tolerance: number, xFrom: (value: D) => number, emptyDatum: () => D): [D, D, D, number];
113
+ /**
114
+ * The points of a scatter series that a tooltip shows (and the plot highlights), depending on
115
+ * where the mouse is over the series:
116
+ * - directly over a data point: that `point`, along with the points `before` and `after` it
117
+ * - over a line segment between two points: the points `before` and `after` the mouse
118
+ *
119
+ * `before` and `after` are undefined when there's no such point (e.g. before the first point).
120
+ */
121
+ export type ScatterTooltipPoints = {
122
+ kind: 'point';
123
+ before?: Datum;
124
+ point: Datum;
125
+ after?: Datum;
126
+ } | {
127
+ kind: 'segment';
128
+ before?: Datum;
129
+ after?: Datum;
130
+ };
131
+ /**
132
+ * The scatter plot's tooltip metadata: the points the tooltip shows
133
+ */
134
+ export interface ScatterTooltipMetadata {
135
+ points: ScatterTooltipPoints;
136
+ }
137
+ /**
138
+ * Determines which of a scatter series' points a tooltip shows, from where the mouse is: when the
139
+ * mouse is over a data point, that point (and its neighbors); otherwise the points on either side
140
+ * of the mouse (the segment it's over).
141
+ *
142
+ * The mouse is over a point when it's within `pointRadius` pixels of it -- or, when the point's
143
+ * nearest neighbor is closer than three times that, within a third of the way to that neighbor.
144
+ * Otherwise, with dense data (points a few pixels apart), the mouse would almost always be within
145
+ * the radius of some point, and the segments between them could hardly be hovered at all.
146
+ * @param data The series' data, ordered by x
147
+ * @param mouse The mouse's coordinates, within the plot area (i.e. in the axes' ranges)
148
+ * @param xScale The series' x-axis scale
149
+ * @param yScale The series' y-axis scale
150
+ * @param pointRadius How close (in pixels) the mouse must be to a data point to be over it
151
+ * @return The points the tooltip shows
152
+ */
153
+ export declare function scatterTooltipPoints(data: {
154
+ length: number;
155
+ [index: number]: Datum;
156
+ }, mouse: [x: number, y: number], xScale: ScaleContinuousNumeric<number, number>, yScale: ScaleContinuousNumeric<number, number>, pointRadius: number): ScatterTooltipPoints;
157
+ /**
158
+ * The points a scatter tooltip shows, as a list (e.g. for highlighting them)
159
+ * @param points The points the tooltip shows
160
+ * @return The points, in order
161
+ */
162
+ export declare function scatterTooltipPointList(points: ScatterTooltipPoints): Array<Datum>;
163
+ /**
164
+ * A sparkline: a small line chart of a series' values over time (e.g. for a tooltip), as an SVG
165
+ * path, and where its last point is
166
+ */
167
+ export interface Sparkline {
168
+ path: string;
169
+ end: [x: number, y: number];
170
+ mark?: [x: number, y: number];
171
+ }
172
+ /**
173
+ * Creates a sparkline of the specified (time-ordered) values: time runs left to right across the
174
+ * width, and the values are scaled to fill the height (the highest at the top). Values that
175
+ * aren't finite are skipped.
176
+ *
177
+ * A long series is reduced to (at most) four points per pixel column -- the column's first,
178
+ * lowest, highest, and last values, in the order they occurred -- so that the path stays small,
179
+ * while still tracing the line's true shape, spikes included.
180
+ * @param data The values, ordered by time
181
+ * @param width The sparkline's width (in pixels)
182
+ * @param height The sparkline's height (in pixels)
183
+ * @param padding The space (in pixels) to leave around the line, within the width and height
184
+ * @param valueRange The (fixed) range of values the height spans (values outside it are drawn at
185
+ * its edge) -- by default, the range of the values themselves
186
+ * @param markedTime The time of a point to mark (e.g. the hovered point), whose position is
187
+ * returned as the sparkline's `mark` -- by default, none
188
+ * @return The sparkline, or `undefined` when there are fewer than two values to draw
189
+ */
190
+ export declare function sparklineFor(data: {
191
+ length: number;
192
+ [index: number]: {
193
+ time: number;
194
+ value: number;
195
+ };
196
+ }, width: number, height: number, padding?: number, valueRange?: [min: number, max: number], markedTime?: number): Sparkline | undefined;
197
+ /**
198
+ * The raster plot's tooltip metadata: all of the hovered series' spikes that the chart holds (the
199
+ * tooltip data's `series` holds just the hovered spike)
200
+ */
201
+ export interface RasterTooltipMetadata {
202
+ spikes: Series<Datum>;
203
+ }
204
+ /**
205
+ * Statistics of a series' (time, value) points -- e.g. a raster chart's spikes, or a scatter
206
+ * chart's points -- over the window of data that the chart holds. Those that need at least two
207
+ * points are undefined when there's only one.
208
+ */
209
+ export interface SeriesStatistics {
210
+ count: number;
211
+ meanValue: number | undefined;
212
+ valueStandardDeviation: number | undefined;
213
+ meanInterval: number | undefined;
214
+ }
215
+ /**
216
+ * Calculates the statistics of a series' (time, value) points: their count, the mean and the
217
+ * (sample) standard deviation of their values, and the mean time between consecutive points.
218
+ * Points whose value or time isn't finite are skipped.
219
+ * @param spikes The points (e.g. spikes), ordered by time
220
+ * @return The statistics
221
+ */
222
+ export declare function seriesStatistics(spikes: {
223
+ length: number;
224
+ [index: number]: Datum;
225
+ }): SeriesStatistics;
226
+ /**
227
+ * Formats a value, or shows a dash when there isn't one (e.g. the standard deviation of a single
228
+ * point)
229
+ * @param value The value, if there is one
230
+ * @param formatter Formats the value
231
+ * @return The formatted value, or a dash
232
+ */
233
+ export declare function valueOrMissing(value: number | undefined, formatter: (value: number) => string): string;
234
+ /**
235
+ * Calculates the (sample) autocorrelation of a series' values, by lag: for each lag `k` (in
236
+ * points, not time -- a series' points needn't be evenly spaced in time), the correlation between
237
+ * the values and the values `k` points later,
238
+ * <p>`r[k] = sum[t](x[t] - mean) * (x[t+k] - mean) / sum[t](x[t] - mean)^2`</p>
239
+ * so `r[0]` is 1, and the values are between -1 and 1. Points whose value or time isn't finite are
240
+ * skipped.
241
+ * @param points The series' points, ordered by time
242
+ * @param maxLag The largest lag -- by default, a quarter of the number of points (the usual rule
243
+ * of thumb, since the estimates for larger lags rest on too few pairs of points), but no more than 50
244
+ * @return The autocorrelation for each lag, from 0 to the largest lag, or `undefined` when there
245
+ * are fewer than four points (so no lag beyond 0), or the values don't vary
246
+ */
247
+ export declare function autocorrelation(points: {
248
+ length: number;
249
+ [index: number]: Datum;
250
+ }, maxLag?: number): Array<number> | undefined;
251
+ //# sourceMappingURL=tooltipUtils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tooltipUtils.d.ts","sourceRoot":"","sources":["../../../../src/app/charts/tooltips/tooltipUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAC,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,oBAAoB,CAAC;AAC3D,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,cAAc,CAAC;AACpD,OAAO,KAAK,EAAC,sBAAsB,EAAC,MAAM,IAAI,CAAC;AAC/C,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,sBAAsB,CAAC;AAGhD;;;GAGG;AACH,MAAM,WAAW,YAAY;IACzB;;OAEG;IACH,OAAO,EAAE,OAAO,CAAA;IAEhB;;OAEG;IACH,QAAQ,EAAE,MAAM,CAAA;IAChB;;OAEG;IACH,SAAS,EAAE,MAAM,CAAA;IACjB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAElB;;OAEG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAE1B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IAErB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,MAAM,CAAC;CACzB;AAED;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAsBjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,UA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