stream-charts 1.2.1 → 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 +36 -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,12 +1,13 @@
1
- import {BaseSeries, seriesFrom} from "./baseSeries";
1
+ import {type BaseSeries, seriesFrom} from "./baseSeries";
2
2
  import {
3
3
  initialMaxTimeDatum,
4
4
  initialMaxValueDatum, initialMinTimeDatum,
5
5
  initialMinValueDatum,
6
- OrdinalChartData,
7
- OrdinalStats,
8
- OrdinalValueStats
6
+ type OrdinalChartData,
7
+ type OrdinalStats,
8
+ type OrdinalValueStats
9
9
  } from "../observables/ordinals";
10
+ import type {FastShiftArray} from "fast-shift-array";
10
11
 
11
12
  /**
12
13
  * An immutable datum object for series with a category and value.
@@ -22,7 +23,7 @@ export interface OrdinalDatum {
22
23
 
23
24
 
24
25
  /**
25
- * Creates an empty ordinal datum
26
+ * An empty ordinal datum (`NaN` time and value, and an empty ordinal)
26
27
  */
27
28
  export const emptyOrdinalDatum: OrdinalDatum = {
28
29
  time: NaN,
@@ -30,6 +31,11 @@ export const emptyOrdinalDatum: OrdinalDatum = {
30
31
  value: NaN,
31
32
  }
32
33
 
34
+ /**
35
+ * Copies an ordinal datum
36
+ * @param datum The datum to copy
37
+ * @return The copy
38
+ */
33
39
  export const copyOrdinalDatum = (datum: OrdinalDatum): OrdinalDatum => ({
34
40
  time: datum.time,
35
41
  ordinal: datum.ordinal,
@@ -37,11 +43,11 @@ export const copyOrdinalDatum = (datum: OrdinalDatum): OrdinalDatum => ({
37
43
  })
38
44
 
39
45
  /**
40
- * Creates an iterate datum
46
+ * Creates an ordinal datum
41
47
  * @param time The datum time, which is mostly informational
42
48
  * @param ordinal The category name or identifier
43
49
  * @param value The value
44
- * @return An iterate datum
50
+ * @return An ordinal datum
45
51
  */
46
52
  export const ordinalDatumOf = (time: number, ordinal: string, value: number): OrdinalDatum => ({
47
53
  time,
@@ -51,11 +57,10 @@ export const ordinalDatumOf = (time: number, ordinal: string, value: number): Or
51
57
 
52
58
 
53
59
  /**
54
- * Returns whether the ordinal datum is empty. An ordinal datum is considered empty
55
- * when the time is NaN, the ordinal is blank (empty or only whitespace), and the value
56
- * is NaN.
57
- * @param datum The iterate datum to test
58
- * @return `true` if the iterate datum is empty; `false` otherwise
60
+ * Returns whether the ordinal datum is non-empty. An ordinal datum is considered empty when its
61
+ * time is NaN, its ordinal is blank (empty or only whitespace), or its value is NaN.
62
+ * @param datum The ordinal datum to test
63
+ * @return `true` if the ordinal datum is non-empty; `false` otherwise
59
64
  */
60
65
  export const nonEmptyOrdinalDatum = (datum: OrdinalDatum): boolean =>
61
66
  !isNaN(datum.time) && datum.ordinal.replace(/\s/g, "").length > 0 && !isNaN(datum.value)
@@ -84,15 +89,17 @@ export function ordinateSeriesFromTuples(
84
89
  }
85
90
 
86
91
  /**
87
- * Creates an empty chart data object with all the values set to 0
88
- * @param seriesList The list of series names (identifiers) to update
89
- * @return An empty chart data object
92
+ * Creates the ordinal chart data for the specified series: their names, the stats calculated over
93
+ * their data (see {@link calculateOrdinalStats}), and copies of all their data as the new points
94
+ * @param seriesList The series
95
+ * @return The ordinal chart data for the series
90
96
  */
91
97
  export function initialOrdinalChartData(seriesList: Array<OrdinalSeries>): OrdinalChartData {
92
98
  return {
93
99
  seriesNames: new Set(seriesList.map(series => series.name)),
94
100
  stats: calculateOrdinalStats(seriesList),
95
- newPoints: new Map<string, Array<OrdinalDatum>>(seriesList.map(series => [
101
+ // newPoints: new Map<string, Array<OrdinalDatum>>(seriesList.map(series => [
102
+ newPoints: new Map<string, FastShiftArray<OrdinalDatum>>(seriesList.map(series => [
96
103
  series.name,
97
104
  series.data.map(datum => ({
98
105
  time: datum.time,
@@ -103,6 +110,14 @@ export function initialOrdinalChartData(seriesList: Array<OrdinalSeries>): Ordin
103
110
  }
104
111
  }
105
112
 
113
+ /**
114
+ * Calculates the stats of the specified series: the data with the min and max time, and with the
115
+ * min and max value, over all the series, and each series' value stats (its min, max, count, sum,
116
+ * sum of squares, and mean)
117
+ * @param seriesList The series
118
+ * @return The stats (when there's no data, the extremes are the initial ones that searches start
119
+ * from -- see e.g. `initialMinTimeDatum`)
120
+ */
106
121
  export function calculateOrdinalStats(seriesList: Array<OrdinalSeries>): OrdinalStats {
107
122
  const ordinalValueStats = new Map<string, OrdinalValueStats>(seriesList.map(
108
123
  (series: OrdinalSeries) => {
@@ -138,20 +153,20 @@ export function calculateOrdinalStats(seriesList: Array<OrdinalSeries>): Ordinal
138
153
  const minTimeDatum: OrdinalDatum = seriesList.reduce(
139
154
  (globalMin: OrdinalDatum, series: OrdinalSeries) => {
140
155
  const seriesMin = series.data.reduce(
141
- (min, datum) => datum.value < min.value ? datum : min,
156
+ (min, datum) => datum.time < min.time ? datum : min,
142
157
  globalMin
143
158
  )
144
- return seriesMin.value < globalMin.value ? seriesMin : globalMin
159
+ return seriesMin.time < globalMin.time ? seriesMin : globalMin
145
160
  },
146
161
  initialMinTimeDatum()
147
162
  )
148
163
  const maxTimeDatum: OrdinalDatum = seriesList.reduce(
149
164
  (globalMax: OrdinalDatum, series: OrdinalSeries) => {
150
165
  const seriesMax = series.data.reduce(
151
- (max, datum) => datum.value > max.value ? datum : max,
166
+ (max, datum) => datum.time > max.time ? datum : max,
152
167
  globalMax
153
168
  )
154
- return seriesMax.value > globalMax.value ? seriesMax : globalMax
169
+ return seriesMax.time > globalMax.time ? seriesMax : globalMax
155
170
  },
156
171
  initialMaxTimeDatum()
157
172
  )
@@ -0,0 +1,188 @@
1
+ import type {Datum} from "./timeSeries";
2
+ import {type BaseSeries, seriesFrom} from "./baseSeries";
3
+ import {failureResult, type Result, resultFromAll, successResult} from "result-fn";
4
+ import type {FastShiftArray} from "fast-shift-array";
5
+
6
+ /**
7
+ * A series of {@link OutlierDatum}s, along with the measures that the data's bounds are for
8
+ * @template M The type of the measures that is expressed as a tuple of numbers.
9
+ */
10
+ export interface OutlierSeries<M extends readonly number[]> extends BaseSeries<OutlierDatum<M>> {
11
+ /**
12
+ * The measures of the datum. For example, this could be a series of probabilities of
13
+ * the point being an outlier.
14
+ */
15
+ readonly measures: readonly [...M]
16
+ /**
17
+ * The descriptions of the measures. For example, this could be a series of descriptions
18
+ * of the probabilities of the point being an outlier.
19
+ */
20
+ readonly measureDescriptions?: {readonly [K in keyof M]: string}
21
+ }
22
+
23
+ /**
24
+ * The bounds of a datum.
25
+ */
26
+ export interface OutlierBounds {
27
+ /**
28
+ * The lower bound of the datum
29
+ */
30
+ readonly lower: number
31
+ /**
32
+ * The upper bound of the datum
33
+ */
34
+ readonly upper: number
35
+ }
36
+
37
+ /**
38
+ * A datum with an upper and lower bounds B(L, U) associated with each measure. The idea is the
39
+ * following. We have a datum (x, y) value. The bounds determine whether the datum is
40
+ * within the range associated with the measure. For example, the measure could be the
41
+ * 0.95 probability that the datum falls within that bound. And if the (x, y) value falls
42
+ * outside the bounds B(L, U), the datum could be considered an "outlier".
43
+ *
44
+ * Often we would like to have a set of measures that mean different things. For example, if
45
+ * the datum falls outside the bounds B1(L, U) representing the range in which we expect
46
+ * the datum to fall with a 0.95 probability, then we could consider the datum an "outlier". We
47
+ * may also want to consider the datum an "outlier" if it falls outside the bounds B2(L, U)
48
+ * representing the range in which we expect the datum to fall with a 0.75 probability. If the
49
+ * datum falls outside B2(L, U), then we could consider the datum a "possible outlier" and
50
+ * treat it differently from an "outlier".
51
+ *
52
+ * Note that there are constraints.
53
+ * 1. The cardinality of the measures and the bounds must be the same.
54
+ * 2. The i-th bound is associated with the i-th measure.
55
+ *
56
+ * @template M The type of the measures that is expressed as a tuple of numbers.
57
+ * @see OutlierBounds
58
+ * @see outlierBoundsFor
59
+ * @see outlierDatumFor
60
+ * @see outlierSeriesFor
61
+ *
62
+ * @example
63
+ * // possible-outlier = 0.75, outlier = 0.95
64
+ * const Measures = [0.75, 0.95] as const;
65
+ * const value: Datum = datumOf(1, 10);
66
+ * const bounds = [
67
+ * outlierBoundsFor(21, 121),
68
+ * outlierBoundsFor(2, 52)
69
+ * ] as const;
70
+ * const datum = outlierDatumFor<typeof Measures>(value, Measures, bounds);
71
+ */
72
+ export interface OutlierDatum<M extends readonly number[]> {
73
+ /**
74
+ * The datum with the x and y values
75
+ */
76
+ readonly datum: Datum
77
+ /**
78
+ * The bounds of the measures. For example, if the measures are probabilities, then
79
+ * the bounds are a series that hold the lower and upper bounds for each probability
80
+ * in the measures.
81
+ */
82
+ readonly bounds: {readonly [K in keyof M]: OutlierBounds}
83
+ }
84
+
85
+ /**
86
+ * Convenience function to create an outlier bounds object.
87
+ * @param lower The lower bound of the measure
88
+ * @param upper The upper bound of the measure
89
+ * @return An outlier bounds object
90
+ */
91
+ export function outlierBoundsFor(lower: number, upper: number): OutlierBounds {
92
+ return {lower, upper}
93
+ }
94
+
95
+ /**
96
+ * Creates an outlier datum from the (x, y) value and the bounds associated with each measure. Because
97
+ * the length of the bounds-array must be the same as the length of the measures-array, this returns
98
+ * a {@link Result} object with the outcome of the operation.
99
+ * @param datum The (x, y) value
100
+ * @param measures The measures array where each measure is associated with a bound of the same index
101
+ * @param bounds The bounds array where each bound is associated with a measure of the same index
102
+ * @return A {@link Result} object with the outcome of the operation. If the operation is successful,
103
+ * then the result is an {@link OutlierDatum} object. If the operation is not successful, then
104
+ * the result is a `string` with the error message.
105
+ * @template M The type of the measures that is expressed as a tuple of numbers.
106
+ */
107
+ export function outlierDatumFor<M extends readonly number[]>(
108
+ datum: Datum,
109
+ measures: readonly [...M],
110
+ bounds: {readonly [K in keyof M]: OutlierBounds},
111
+ ): Result<OutlierDatum<M>, string> {
112
+ if (measures.length !== bounds.length) {
113
+ return failureResult(
114
+ `The number of measures and bounds must be the same; ` +
115
+ `datum: (${datum.x}, ${datum.y}); ` +
116
+ `measures_length: ${measures.length}; ` +
117
+ `bounds_length: ${bounds.length}; ` +
118
+ `measures: [${measures.join(", ")}]; ` +
119
+ `bounds: [${Object.values(bounds).map(b => `(${b.lower}, ${b.upper})`).join(", ")}]`
120
+ )
121
+ }
122
+ return successResult({datum, bounds})
123
+ }
124
+
125
+ /**
126
+ * Creates an outlier series from the name and the array of (x, y, bounds) tuples. If any of the
127
+ * datum have bounds that do not have the same length as the measures, then this function will fail and
128
+ * return a failure result. Otherwise, it will return a success result with the outlier series.
129
+ * @param name The name of the series
130
+ * @param measures The measures that are associated with the series
131
+ * @param data The array of (x, y, bounds) tuples that define the series
132
+ * @param [measureDescriptions=undefined] The descriptions of the measures
133
+ * @return A {@link Result} object with the outcome of the operation. If the operation is successful,
134
+ * then the result is an {@link OutlierSeries} object. If the operation is not successful, then
135
+ * the result is an array of error messages.
136
+ * @template M The type of the measures that is expressed as a tuple of numbers.
137
+ */
138
+ export function outlierSeriesFor<M extends readonly number[]>(
139
+ name: string,
140
+ measures: readonly [...M],
141
+ data: Array<[time: number, value: number, bounds: { readonly [K in keyof M]: OutlierBounds}]>,
142
+ measureDescriptions?: {readonly [K in keyof M]: string}
143
+ ): Result<OutlierSeries<M>, Array<string>> {
144
+ // enrich each datum in the data array with the measures
145
+ const outlierData = data.map(
146
+ ([time, value, bounds]) =>
147
+ outlierDatumFor({x: time, y: value}, measures, bounds)
148
+ )
149
+
150
+ // if all data has bounds-dimensions that match the measures-dimensions, then we can safely
151
+ // create the outlier series, otherwise we must report the errors
152
+ if (outlierData.filter(datum => datum.succeeded).length === data.length) {
153
+ // convert the Array<Result<OutlierDatum<M>, string>> to Result<Array<OutlierDatum<M>>, Array<string>>
154
+ return resultFromAll(outlierData)
155
+ .map(data => outlierSeriesFrom(name, data, measures, measureDescriptions))
156
+ .mapFailure(failure => [failure])
157
+ }
158
+
159
+ // collect all the errors for datum whose bounds and measures dimensions did not
160
+ // match and report each error
161
+ return failureResult(outlierData
162
+ .filter(result => result.failed)
163
+ .map(result => result.error!)
164
+ )
165
+ }
166
+
167
+ /**
168
+ * Creates an outlier series for the data and measures
169
+ *
170
+ * **Ownership warning:** `outlierData` is forwarded directly to {@link seriesFrom}, which wraps a
171
+ * plain array (or `FastShiftArray`) **by reference**, not a copy -- see {@link seriesFrom}'s own
172
+ * ownership warning for the full explanation. If you keep your own reference to `outlierData`,
173
+ * pass `outlierData.slice()` instead if you need an independent copy.
174
+ * @param name The name of the series
175
+ * @param outlierData The data for the series
176
+ * @param measures The measure defining the outlier bands
177
+ * @param measureDescriptions The (optional) meaning of each band
178
+ * @return An outlier series
179
+ * @template M The type of the measures that is expressed as a tuple of numbers.
180
+ */
181
+ export function outlierSeriesFrom<M extends readonly number[]>(
182
+ name: string,
183
+ outlierData: Array<OutlierDatum<M>> | FastShiftArray<OutlierDatum<M>>,
184
+ measures: readonly [...M],
185
+ measureDescriptions?: {readonly [K in keyof M]: string}
186
+ ): OutlierSeries<M> {
187
+ return {...seriesFrom(name, outlierData), measures, measureDescriptions}
188
+ }
@@ -1,11 +1,12 @@
1
- import {BaseSeries, seriesFrom} from "./baseSeries";
1
+ import {type BaseSeries, seriesFrom} from "./baseSeries";
2
2
 
3
3
  /**
4
- * An immutable datum object that holds the spike (time, value) representing a neuron spike
4
+ * An immutable datum object that holds an (x, y) value -- for a time series, a (time, value) pair
5
+ * (e.g. a neuron spike, or a weight)
5
6
  */
6
7
  export interface Datum {
7
- readonly time: number;
8
- readonly value: number;
8
+ readonly x: number;
9
+ readonly y: number;
9
10
  }
10
11
 
11
12
  /**
@@ -14,10 +15,16 @@ export interface Datum {
14
15
  * @param value The value
15
16
  * @return A {@link Datum} instance with the specified (time, value)
16
17
  */
17
- export const datumOf = (time: number, value: number): Datum => ({time, value})
18
+ export const datumOf = (time: number, value: number): Datum => ({x: time, y: value})
18
19
 
19
- export const emptyDatum = (): Datum => ({time: NaN, value: NaN})
20
+ /**
21
+ * @return An empty datum (its x and y are `NaN`)
22
+ */
23
+ export const emptyDatum = (): Datum => ({x: NaN, y: NaN})
20
24
 
25
+ /**
26
+ * A series of (time, value) data (e.g. for the scatter and raster plots)
27
+ */
21
28
  export type TimeSeries = BaseSeries<Datum>
22
29
 
23
30
 
@@ -25,16 +32,11 @@ export type TimeSeries = BaseSeries<Datum>
25
32
  * Creates a series from the name and the optional array of (x, y) pairs (tuples)
26
33
  * @param name The name of the series
27
34
  * @param data The optional array of (x, y) pairs (tuples)
28
- * @return A `Series` for object that can be used by the `RasterChart`
35
+ * @return A {@link TimeSeries} that can be used by, e.g., the `ScatterPlot` and the `RasterPlot`
29
36
  * @see seriesFrom
30
37
  * @see emptySeries
31
38
  */
32
39
  export const timeSeriesFromTuples = (name: string, data: Array<[number, number]> = []): TimeSeries =>
33
40
  seriesFrom(name, data.map(([t, y]) => datumOf(t, y)))
34
41
 
35
- export interface PixelDatum extends Datum {
36
- x: number;
37
- y: number;
38
- }
39
-
40
42
 
@@ -1,8 +1,11 @@
1
- import {Datum, TimeSeries} from "./timeSeries";
2
- import {ChartData, defaultChartData} from "../observables/ChartData";
1
+ import type {Datum, TimeSeries} from "./timeSeries";
2
+ import {type ChartData, defaultChartData} from "../observables/ChartData";
3
+ import {FastShiftArray} from "fast-shift-array";
4
+ import {DEFAULT_COMPACTING_SIZE} from "./baseSeries";
3
5
 
4
6
  /**
5
- * The spike-chart data produced by the rxjs observable that is pushed to a streaming chart
7
+ * The time-series chart data produced by the rxjs observable that is pushed to a streaming chart
8
+ * (e.g. the scatter and raster charts): each chunk's new points, and the latest times
6
9
  */
7
10
  export interface TimeSeriesChartData extends ChartData {
8
11
  /**
@@ -28,40 +31,51 @@ export interface TimeSeriesChartData extends ChartData {
28
31
  }
29
32
 
30
33
  /**
31
- * Creates an empty chart data object with all the values set to 0
32
- * @param {Array<string>} series The list of series names (identifiers) to update
33
- * @return {TimeSeriesChartData} An empty chart data object
34
+ * Creates a chart data object for the specified series whose times are all 0, and whose new
35
+ * points are a single (0, 0) point for each series
36
+ * @param series The list of series names (identifiers) to update
37
+ * @return The chart data object
34
38
  */
35
39
  export function emptyTimeSeriesChartData(series: Array<string>): TimeSeriesChartData {
36
40
  return {
37
41
  ...defaultChartData(),
42
+ seriesNames: new Set(series),
38
43
  maxTime: 0,
39
44
  maxTimes: new Map(series.map(name => [name, 0])),
40
- newPoints: new Map<string, Array<Datum>>(series.map(name => [name, [{time: 0, value: 0}]]))
45
+ newPoints: new Map<string, Array<Datum>>(series.map(name => [name, [{x: 0, y: 0}]]))
41
46
  }
42
47
  }
43
48
 
44
49
  /**
45
- * Creates an empty chart data object with all the values set to 0
46
- * @param seriesList The list of series names (identifiers) to update
50
+ * Creates the chart data object to start a stream from, for the specified series: its new points
51
+ * are each series' last datum (or (0, 0), for an empty series), each series' max time is the
52
+ * time of its last datum (or 0), and the max time is the latest of those (or `-Infinity`, when
53
+ * there are no series)
54
+ * @param seriesList The series
47
55
  * @param [currentTime=0] The current time
48
- * @return An empty chart data object
56
+ * @param [compactingSize=DEFAULT_COMPACTING_SIZE] The number of shifts each new-points array
57
+ * accumulates before it's compacted
58
+ * @return The chart data object
49
59
  */
50
- export function initialTimeSeriesChartData(seriesList: Array<TimeSeries>, currentTime: number = 0): TimeSeriesChartData {
60
+ export function initialTimeSeriesChartData(
61
+ seriesList: Array<TimeSeries>,
62
+ currentTime: number = 0,
63
+ compactingSize: number = DEFAULT_COMPACTING_SIZE
64
+ ): TimeSeriesChartData {
51
65
  const maxTime = seriesList.reduce(
52
- (tMax, series) => Math.max(tMax, series.last().map(datum => datum.time).getOrElse(-Infinity)),
66
+ (tMax, series) => Math.max(tMax, series.last().map(datum => datum.x).getOrElse(-Infinity)),
53
67
  -Infinity
54
68
  )
55
69
  return {
56
70
  seriesNames: new Set(seriesList.map(series => series.name)),
57
71
  maxTime,
58
- maxTimes: new Map(seriesList.map(series => [series.name, series.last().map(datum => datum.time).getOrElse(0)])),
72
+ maxTimes: new Map(seriesList.map(series => [series.name, series.last().map(datum => datum.x).getOrElse(0)])),
59
73
  newPoints: new Map<string, Array<Datum>>(seriesList.map(series => [
60
74
  series.name,
61
- [{
62
- time: series.last().map(datum => datum.time).getOrElse(0),
63
- value: series.last().map(datum => datum.value).getOrElse(0)
64
- }]
75
+ FastShiftArray.fromArray([{
76
+ x: series.last().map(datum => datum.x).getOrElse(0),
77
+ y: series.last().map(datum => datum.y).getOrElse(0)
78
+ }], true, compactingSize)
65
79
  ])),
66
80
  currentTime: currentTime
67
81
  }
@@ -1,7 +1,10 @@
1
- import {SeriesStyle} from "../axes/axes";
2
- import {SvgFillStyle, SvgStrokeStyle} from "./svgStyle";
1
+ import type {SeriesStyle} from "../axes/axes";
2
+ import type {SvgFillStyle, SvgStrokeStyle} from "./svgStyle";
3
3
  import * as d3 from "d3";
4
4
 
5
+ /**
6
+ * The style of a bar series: the style of each of its bars and lines
7
+ */
5
8
  export interface BarSeriesStyle extends SeriesStyle {
6
9
  /**
7
10
  * The bar style for the lifetime min/max range bar. The style is for the width, fill,
@@ -27,17 +30,29 @@ export interface BarSeriesStyle extends SeriesStyle {
27
30
  windowedMeanValueLine: LineStyle
28
31
  }
29
32
 
33
+ /**
34
+ * The style of a bar: its width (as a fraction of the category's width), its fill, and its stroke
35
+ */
30
36
  export interface BarStyle {
31
37
  widthFraction: number
32
38
  fill: SvgFillStyle
33
39
  stroke: SvgStrokeStyle
34
40
  }
35
41
 
42
+ /**
43
+ * The style of a line: normally, and when highlighted
44
+ */
36
45
  export interface LineStyle {
37
46
  regular: SvgStrokeStyle
38
47
  highlight: SvgStrokeStyle
39
48
  }
40
49
 
50
+ /**
51
+ * The default style for the lifetime min/max bar: 65% of the category's width, a translucent fill,
52
+ * and a thin stroke
53
+ * @param [color="#008aad"] The bar's fill and stroke color
54
+ * @return The bar style
55
+ */
41
56
  export function defaultMinMaxBarStyle(color: string = "#008aad"): BarStyle {
42
57
  return {
43
58
  widthFraction: 0.65,
@@ -53,6 +68,12 @@ export function defaultMinMaxBarStyle(color: string = "#008aad"): BarStyle {
53
68
  }
54
69
  }
55
70
 
71
+ /**
72
+ * The default style for the windowed min/max bar: 25% of the category's width (narrower than the
73
+ * lifetime bar, so both can be seen), filled with a slightly darker color, and no stroke
74
+ * @param [color="#008aad"] The color to darken for the bar's fill (used as-is when it can't be parsed)
75
+ * @return The bar style
76
+ */
56
77
  export function defaultWindowedMinMaxBarStyle(color: string = "#008aad"): BarStyle {
57
78
  return {
58
79
  widthFraction: 0.25,
@@ -68,6 +89,11 @@ export function defaultWindowedMinMaxBarStyle(color: string = "#008aad"): BarSty
68
89
  }
69
90
  }
70
91
 
92
+ /**
93
+ * The default style for the current-value line: 3 pixels wide (5 when highlighted)
94
+ * @param [color="#008aad"] The line's color
95
+ * @return The line style
96
+ */
71
97
  export function defaultValueLineStyle(color: string = "#008aad"): LineStyle {
72
98
  return {
73
99
  regular: {
@@ -83,6 +109,11 @@ export function defaultValueLineStyle(color: string = "#008aad"): LineStyle {
83
109
  }
84
110
  }
85
111
 
112
+ /**
113
+ * The default style for the (lifetime) mean-value line: 1 pixel wide (3 when highlighted)
114
+ * @param [color="#008aad"] The line's color
115
+ * @return The line style
116
+ */
86
117
  export function defaultMeanValueLineStyle(color: string = "#008aad"): LineStyle {
87
118
  return {
88
119
  regular: {
@@ -98,21 +129,33 @@ export function defaultMeanValueLineStyle(color: string = "#008aad"): LineStyle
98
129
  }
99
130
  }
100
131
 
101
- export function defaultWindowedMeanValueLineStyle(color: string = "#008aad"): LineStyle {
132
+ /**
133
+ * The default style for the windowed mean-value line: 1 pixel wide (3 when highlighted), and red
134
+ * by default to set it apart from the other lines
135
+ * @param [color="#ad0000"] The line's color
136
+ * @return The line style
137
+ */
138
+ export function defaultWindowedMeanValueLineStyle(color: string = "#ad0000"): LineStyle {
102
139
  return {
103
140
  regular: {
104
- color: 'red',
141
+ color: color,
105
142
  opacity: 0.6,
106
143
  width: 1
107
144
  },
108
145
  highlight: {
109
- color: 'red',
146
+ color: color,
110
147
  opacity: 1,
111
148
  width: 3
112
149
  }
113
150
  }
114
151
  }
115
152
 
153
+ /**
154
+ * The default style for a bar series: all the bars and lines in the specified color (see the
155
+ * default styles above), except for the windowed min/max bar's darker fill
156
+ * @param [color="#008aad"] The series' color
157
+ * @return The bar series style
158
+ */
116
159
  export function defaultBarSeriesStyle(color: string = "#008aad"): BarSeriesStyle {
117
160
  return {
118
161
  color,
@@ -0,0 +1,86 @@
1
+ // Canvas equivalents of the stroke/fill helpers that used to live in svgStyle.ts. The old versions
2
+ // mutated a *persistent* SVG element's CSS style (`selection.style('stroke', ...)`), so it stuck
3
+ // around until changed again. Canvas has no persistent elements -- `ctx.strokeStyle`/`ctx.fillStyle`
4
+ // /`ctx.lineWidth` are transient 2D-context state that only affects the *next* stroke()/fill() call,
5
+ // so these must be (re-)applied immediately before every draw, every frame.
6
+ //
7
+ // IMPORTANT DIFFERENCE FROM SVG: canvas has a single `ctx.globalAlpha` shared between stroke and
8
+ // fill, unlike SVG's independent `stroke-opacity`/`fill-opacity`. If a shape needs different
9
+ // stroke and fill opacity in the same draw call, bake the opacity into the color string with
10
+ // `withAlpha(...)` instead of relying on `globalAlpha` for one of them.
11
+
12
+ import * as d3 from "d3"
13
+
14
+ /**
15
+ * The style of a stroke (a line, or a shape's outline)
16
+ */
17
+ export interface CanvasStrokeStyle {
18
+ readonly color: string
19
+ readonly width: number
20
+ readonly opacity: number
21
+ }
22
+
23
+ /**
24
+ * Applies a stroke style to the canvas context. Call this immediately before `ctx.stroke()` --
25
+ * unlike the old SVG version, the effect is not persistent.
26
+ * @param context The canvas 2D context to apply the style to
27
+ * @param style The (partial) stroke style to apply; unset fields are left untouched on `ctx`
28
+ * @return `ctx`, for chaining
29
+ */
30
+ export function applyStrokeStyle(context: CanvasRenderingContext2D, style: Partial<CanvasStrokeStyle>): CanvasRenderingContext2D {
31
+ if (style.color !== undefined) context.strokeStyle = style.color
32
+ if (style.width !== undefined) context.lineWidth = style.width
33
+ if (style.opacity !== undefined) context.globalAlpha = style.opacity
34
+ return context
35
+ }
36
+
37
+ /**
38
+ * The style of a (shape's) fill
39
+ */
40
+ export interface CanvasFillStyle {
41
+ readonly color: string
42
+ readonly opacity: number
43
+ }
44
+
45
+ /**
46
+ * Applies a fill style to the canvas context. Call this immediately before `ctx.fill()`/
47
+ * `ctx.fillText()`/`ctx.fillRect()` -- unlike the old SVG version, the effect is not persistent.
48
+ * @param context The canvas 2D context to apply the style to
49
+ * @param style The (partial) fill style to apply; unset fields are left untouched on `ctx`
50
+ * @return `ctx`, for chaining
51
+ */
52
+ export function applyFillStyle(context: CanvasRenderingContext2D, style: Partial<CanvasFillStyle>): CanvasRenderingContext2D {
53
+ if (style.color !== undefined) context.fillStyle = style.color
54
+ if (style.opacity !== undefined) context.globalAlpha = style.opacity
55
+ return context
56
+ }
57
+
58
+ /**
59
+ * Bakes an opacity into a color string by resolving it to `rgba(...)`. Needed because canvas has
60
+ * a single `globalAlpha` shared between stroke and fill (see the module-level note above); when a
61
+ * shape needs independent stroke and fill opacity, use this to bake opacity into the color passed
62
+ * to `applyStrokeStyle`/`applyFillStyle` instead of setting `opacity` on both.
63
+ *
64
+ * Uses `d3.color(...)` (already the project's convention for this elsewhere -- see `Legend.tsx`,
65
+ * `barPlotStyle.ts`) rather than the previous approach of assigning `color` to a single
66
+ * module-level, lazily-created `<canvas>` context's `fillStyle` and reading back the browser's
67
+ * normalized value: assigning an unparseable CSS string to `fillStyle` is a silent no-op per the
68
+ * Canvas 2D spec, so an invalid `color` would have silently resolved to whatever the *previous,
69
+ * unrelated* `withAlpha` call (from any chart/tooltip/legend on the page, since the context was a
70
+ * single shared singleton) happened to leave `fillStyle` at -- order-dependent and effectively
71
+ * nondeterministic. `d3.color` instead returns `null` for unparseable input, so an invalid color
72
+ * falls through to the same "fall back to the original string" behavior this always had for the
73
+ * "no canvas 2d support" case, deterministically, with no shared state at all.
74
+ * @param color Any valid CSS color string (named, hex, rgb, rgba, hsl, etc)
75
+ * @param opacity The opacity to bake in, from 0 (transparent) to 1 (opaque)
76
+ * @return An `rgba(...)` string equivalent to `color` at the given `opacity`
77
+ */
78
+ export function withAlpha(color: string, opacity: number): string {
79
+ const parsed = d3.color(color)
80
+ if (parsed === null) {
81
+ // unparseable color string; nothing sensible to bake an opacity into
82
+ return color
83
+ }
84
+ const {r, g, b} = parsed.rgb()
85
+ return `rgba(${r}, ${g}, ${b}, ${opacity})`
86
+ }