stream-charts 1.0.0 → 1.1.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 (271) hide show
  1. package/README.md +758 -345
  2. package/changes.md +10 -0
  3. package/dist/src/app/charts/Chart.d.ts +116 -87
  4. package/dist/src/app/charts/Chart.js +96 -101
  5. package/dist/src/app/charts/Chart.js.map +1 -1
  6. package/dist/src/app/charts/axes/AxesState.d.ts +64 -0
  7. package/dist/src/app/charts/axes/AxesState.js +97 -0
  8. package/dist/src/app/charts/axes/AxesState.js.map +1 -0
  9. package/dist/src/app/charts/axes/AxesState.test.js +30 -0
  10. package/dist/src/app/charts/axes/AxesState.test.js.map +1 -0
  11. package/dist/src/app/charts/axes/AxisInterval.d.ts +92 -0
  12. package/dist/src/app/charts/axes/AxisInterval.js +126 -0
  13. package/dist/src/app/charts/axes/AxisInterval.js.map +1 -0
  14. package/dist/src/app/charts/axes/AxisInterval.test.js +120 -0
  15. package/dist/src/app/charts/axes/AxisInterval.test.js.map +1 -0
  16. package/dist/src/app/charts/axes/BaseAxisRange.d.ts +83 -0
  17. package/dist/src/app/charts/axes/BaseAxisRange.js +58 -0
  18. package/dist/src/app/charts/axes/BaseAxisRange.js.map +1 -0
  19. package/dist/src/app/charts/axes/ContinuousAxis.d.ts +22 -0
  20. package/dist/src/app/charts/axes/ContinuousAxis.js +96 -0
  21. package/dist/src/app/charts/axes/ContinuousAxis.js.map +1 -0
  22. package/dist/src/app/charts/axes/ContinuousAxisRange.d.ts +59 -0
  23. package/dist/src/app/charts/axes/ContinuousAxisRange.js +84 -0
  24. package/dist/src/app/charts/axes/ContinuousAxisRange.js.map +1 -0
  25. package/dist/src/app/charts/axes/ContinuousAxisRange.test.js +47 -0
  26. package/dist/src/app/charts/axes/ContinuousAxisRange.test.js.map +1 -0
  27. package/dist/src/app/charts/axes/OrdinalAxis.d.ts +23 -0
  28. package/dist/src/app/charts/axes/OrdinalAxis.js +124 -0
  29. package/dist/src/app/charts/axes/OrdinalAxis.js.map +1 -0
  30. package/dist/src/app/charts/axes/OrdinalAxisRange.d.ts +69 -0
  31. package/dist/src/app/charts/axes/OrdinalAxisRange.js +100 -0
  32. package/dist/src/app/charts/axes/OrdinalAxisRange.js.map +1 -0
  33. package/dist/src/app/charts/axes/OrdinalAxisRange.test.js +48 -0
  34. package/dist/src/app/charts/axes/OrdinalAxisRange.test.js.map +1 -0
  35. package/dist/src/app/charts/axes/axes.d.ts +391 -0
  36. package/dist/src/app/charts/axes/axes.js +1046 -0
  37. package/dist/src/app/charts/axes/axes.js.map +1 -0
  38. package/dist/src/app/charts/d3types.d.ts +10 -10
  39. package/dist/src/app/charts/filters/regexFilter.d.ts +9 -0
  40. package/dist/src/app/charts/filters/regexFilter.js +18 -0
  41. package/dist/src/app/charts/filters/regexFilter.js.map +1 -0
  42. package/dist/src/app/charts/filters/regexFilter.test.d.ts +1 -0
  43. package/dist/src/app/charts/filters/regexFilter.test.js +11 -0
  44. package/dist/src/app/charts/filters/regexFilter.test.js.map +1 -0
  45. package/dist/src/app/charts/hooks/useAxes.d.ts +144 -0
  46. package/dist/src/app/charts/hooks/useAxes.js +187 -0
  47. package/dist/src/app/charts/hooks/useAxes.js.map +1 -0
  48. package/dist/src/app/charts/hooks/useChart.d.ts +30 -201
  49. package/dist/src/app/charts/hooks/useChart.js +33 -134
  50. package/dist/src/app/charts/hooks/useChart.js.map +1 -1
  51. package/dist/src/app/charts/hooks/useDataObservable.d.ts +74 -0
  52. package/dist/src/app/charts/hooks/useDataObservable.js +76 -0
  53. package/dist/src/app/charts/hooks/useDataObservable.js.map +1 -0
  54. package/dist/src/app/charts/hooks/useInitialData.d.ts +38 -0
  55. package/dist/src/app/charts/hooks/useInitialData.js +29 -0
  56. package/dist/src/app/charts/hooks/useInitialData.js.map +1 -0
  57. package/dist/src/app/charts/hooks/useMouse.d.ts +53 -0
  58. package/dist/src/app/charts/hooks/useMouse.js +65 -0
  59. package/dist/src/app/charts/hooks/useMouse.js.map +1 -0
  60. package/dist/src/app/charts/hooks/usePlotDimensions.d.ts +34 -0
  61. package/dist/src/app/charts/hooks/usePlotDimensions.js +73 -0
  62. package/dist/src/app/charts/hooks/usePlotDimensions.js.map +1 -0
  63. package/dist/src/app/charts/hooks/useTooltip.d.ts +64 -0
  64. package/dist/src/app/charts/hooks/useTooltip.js +52 -0
  65. package/dist/src/app/charts/hooks/useTooltip.js.map +1 -0
  66. package/dist/src/app/charts/observables/ChartData.d.ts +23 -0
  67. package/dist/src/app/charts/observables/ChartData.js +20 -0
  68. package/dist/src/app/charts/observables/ChartData.js.map +1 -0
  69. package/dist/src/app/charts/observables/iterates.d.ts +52 -0
  70. package/dist/src/app/charts/observables/iterates.js +121 -0
  71. package/dist/src/app/charts/observables/iterates.js.map +1 -0
  72. package/dist/src/app/charts/observables/iterates.test.d.ts +1 -0
  73. package/dist/src/app/charts/observables/iterates.test.js +180 -0
  74. package/dist/src/app/charts/observables/iterates.test.js.map +1 -0
  75. package/dist/src/app/charts/observables/ordinals.d.ts +75 -0
  76. package/dist/src/app/charts/observables/ordinals.js +141 -0
  77. package/dist/src/app/charts/observables/ordinals.js.map +1 -0
  78. package/dist/src/app/charts/observables/ordinals.test.d.ts +1 -0
  79. package/dist/src/app/charts/observables/ordinals.test.js +102 -0
  80. package/dist/src/app/charts/observables/ordinals.test.js.map +1 -0
  81. package/dist/src/app/charts/plots/BarPlot.d.ts +81 -0
  82. package/dist/src/app/charts/plots/BarPlot.js +557 -0
  83. package/dist/src/app/charts/plots/BarPlot.js.map +1 -0
  84. package/dist/src/app/charts/plots/PoincarePlot.d.ts +78 -0
  85. package/dist/src/app/charts/plots/PoincarePlot.js +504 -0
  86. package/dist/src/app/charts/plots/PoincarePlot.js.map +1 -0
  87. package/dist/src/app/charts/{RasterPlot.d.ts → plots/RasterPlot.d.ts} +1 -1
  88. package/dist/src/app/charts/{RasterPlot.js → plots/RasterPlot.js} +152 -133
  89. package/dist/src/app/charts/plots/RasterPlot.js.map +1 -0
  90. package/dist/src/app/charts/{ScatterPlot.d.ts → plots/ScatterPlot.d.ts} +10 -8
  91. package/dist/src/app/charts/plots/ScatterPlot.js +379 -0
  92. package/dist/src/app/charts/plots/ScatterPlot.js.map +1 -0
  93. package/dist/src/app/charts/{plot.d.ts → plots/plot.d.ts} +12 -14
  94. package/dist/src/app/charts/{plot.js → plots/plot.js} +19 -17
  95. package/dist/src/app/charts/plots/plot.js.map +1 -0
  96. package/dist/src/app/charts/series/baseSeries.d.ts +38 -0
  97. package/dist/src/app/charts/series/baseSeries.js +36 -0
  98. package/dist/src/app/charts/series/baseSeries.js.map +1 -0
  99. package/dist/src/app/charts/series/datumSeries.test.d.ts +1 -0
  100. package/dist/src/app/charts/series/datumSeries.test.js +50 -0
  101. package/dist/src/app/charts/series/datumSeries.test.js.map +1 -0
  102. package/dist/src/app/charts/series/iterateSeries.d.ts +42 -0
  103. package/dist/src/app/charts/series/iterateSeries.js +34 -0
  104. package/dist/src/app/charts/series/iterateSeries.js.map +1 -0
  105. package/dist/src/app/charts/series/ordinalSeries.d.ts +54 -0
  106. package/dist/src/app/charts/series/ordinalSeries.js +98 -0
  107. package/dist/src/app/charts/series/ordinalSeries.js.map +1 -0
  108. package/dist/src/app/charts/series/timeSeries.d.ts +30 -0
  109. package/dist/src/app/charts/series/timeSeries.js +19 -0
  110. package/dist/src/app/charts/series/timeSeries.js.map +1 -0
  111. package/dist/src/app/charts/{chartData.d.ts → series/timeSeriesChartData.d.ts} +11 -6
  112. package/dist/src/app/charts/series/timeSeriesChartData.js +32 -0
  113. package/dist/src/app/charts/series/timeSeriesChartData.js.map +1 -0
  114. package/dist/src/app/charts/styling/barPlotStyle.d.ts +41 -0
  115. package/dist/src/app/charts/styling/barPlotStyle.js +84 -0
  116. package/dist/src/app/charts/styling/barPlotStyle.js.map +1 -0
  117. package/dist/src/app/charts/{margins.d.ts → styling/margins.d.ts} +7 -5
  118. package/dist/src/app/charts/{margins.js → styling/margins.js} +19 -9
  119. package/dist/src/app/charts/styling/margins.js.map +1 -0
  120. package/dist/src/app/charts/styling/margins.test.d.ts +1 -0
  121. package/dist/src/app/charts/styling/margins.test.js +19 -0
  122. package/dist/src/app/charts/styling/margins.test.js.map +1 -0
  123. package/dist/src/app/charts/styling/svgStyle.d.ts +76 -0
  124. package/dist/src/app/charts/styling/svgStyle.js +84 -0
  125. package/dist/src/app/charts/styling/svgStyle.js.map +1 -0
  126. package/dist/src/app/charts/subscriptions/subscription.test.d.ts +1 -0
  127. package/dist/src/app/charts/subscriptions/subscription.test.js +395 -0
  128. package/dist/src/app/charts/subscriptions/subscription.test.js.map +1 -0
  129. package/dist/src/app/charts/subscriptions/subscriptions.d.ts +100 -0
  130. package/dist/src/app/charts/subscriptions/subscriptions.js +449 -0
  131. package/dist/src/app/charts/subscriptions/subscriptions.js.map +1 -0
  132. package/dist/src/app/charts/tooltips/BarPlotTooltipContent.d.ts +90 -0
  133. package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js +302 -0
  134. package/dist/src/app/charts/tooltips/BarPlotTooltipContent.js.map +1 -0
  135. package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.d.ts +100 -0
  136. package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js +190 -0
  137. package/dist/src/app/charts/tooltips/PoincarePlotTooltipContent.js.map +1 -0
  138. package/dist/src/app/charts/{RasterPlotTooltipContent.js → tooltips/RasterPlotTooltipContent.js} +40 -44
  139. package/dist/src/app/charts/tooltips/RasterPlotTooltipContent.js.map +1 -0
  140. package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js +154 -0
  141. package/dist/src/app/charts/tooltips/ScatterPlotTooltipContent.js.map +1 -0
  142. package/dist/src/app/charts/{Tooltip.d.ts → tooltips/Tooltip.d.ts} +4 -2
  143. package/dist/src/app/charts/{Tooltip.js → tooltips/Tooltip.js} +23 -28
  144. package/dist/src/app/charts/tooltips/Tooltip.js.map +1 -0
  145. package/dist/src/app/charts/{tooltipUtils.d.ts → tooltips/tooltipUtils.d.ts} +17 -11
  146. package/dist/src/app/charts/{tooltipUtils.js → tooltips/tooltipUtils.js} +52 -25
  147. package/dist/src/app/charts/tooltips/tooltipUtils.js.map +1 -0
  148. package/dist/src/app/charts/{Tracker.d.ts → trackers/Tracker.d.ts} +6 -5
  149. package/dist/src/app/charts/trackers/Tracker.js +60 -0
  150. package/dist/src/app/charts/trackers/Tracker.js.map +1 -0
  151. package/dist/src/app/charts/{trackerUtils.d.ts → trackers/trackerUtils.d.ts} +13 -8
  152. package/dist/src/app/charts/trackers/trackerUtils.js +359 -0
  153. package/dist/src/app/charts/trackers/trackerUtils.js.map +1 -0
  154. package/dist/src/app/charts/utils.d.ts +22 -32
  155. package/dist/src/app/charts/utils.js +36 -37
  156. package/dist/src/app/charts/utils.js.map +1 -1
  157. package/dist/src/index.d.ts +48 -15
  158. package/dist/src/index.js +71 -15
  159. package/dist/src/index.js.map +1 -1
  160. package/package.json +30 -20
  161. package/src/app/charts/Chart.tsx +334 -0
  162. package/src/app/charts/axes/AxesState.test.ts +34 -0
  163. package/src/app/charts/axes/AxesState.ts +112 -0
  164. package/src/app/charts/axes/AxisInterval.test.ts +143 -0
  165. package/src/app/charts/axes/AxisInterval.ts +139 -0
  166. package/src/app/charts/axes/BaseAxisRange.ts +113 -0
  167. package/src/app/charts/axes/ContinuousAxis.tsx +192 -0
  168. package/src/app/charts/axes/ContinuousAxisRange.test.ts +55 -0
  169. package/src/app/charts/axes/ContinuousAxisRange.ts +96 -0
  170. package/src/app/charts/axes/OrdinalAxis.tsx +223 -0
  171. package/src/app/charts/axes/OrdinalAxisRange.test.ts +55 -0
  172. package/src/app/charts/axes/OrdinalAxisRange.ts +112 -0
  173. package/src/app/charts/axes/axes.ts +1569 -0
  174. package/src/app/charts/d3types.ts +16 -0
  175. package/src/app/charts/filters/regexFilter.test.ts +13 -0
  176. package/src/app/charts/filters/regexFilter.ts +17 -0
  177. package/src/app/charts/hooks/useAxes.tsx +341 -0
  178. package/src/app/charts/hooks/useChart.tsx +159 -0
  179. package/src/app/charts/hooks/useDataObservable.tsx +175 -0
  180. package/src/app/charts/hooks/useInitialData.tsx +65 -0
  181. package/src/app/charts/hooks/useMouse.tsx +125 -0
  182. package/src/app/charts/hooks/usePlotDimensions.tsx +120 -0
  183. package/src/app/charts/hooks/useTooltip.tsx +112 -0
  184. package/src/app/charts/observables/ChartData.ts +31 -0
  185. package/src/app/charts/observables/iterates.test.ts +201 -0
  186. package/src/app/charts/observables/iterates.ts +203 -0
  187. package/src/app/charts/observables/ordinals.test.ts +135 -0
  188. package/src/app/charts/observables/ordinals.ts +248 -0
  189. package/src/app/charts/plots/BarPlot.tsx +1088 -0
  190. package/src/app/charts/plots/PoincarePlot.tsx +832 -0
  191. package/src/app/charts/plots/RasterPlot.tsx +676 -0
  192. package/src/app/charts/plots/ScatterPlot.tsx +653 -0
  193. package/src/app/charts/plots/plot.ts +75 -0
  194. package/src/app/charts/series/baseSeries.ts +52 -0
  195. package/src/app/charts/series/datumSeries.test.ts +60 -0
  196. package/src/app/charts/series/iterateSeries.ts +56 -0
  197. package/src/app/charts/series/ordinalSeries.ts +164 -0
  198. package/src/app/charts/series/timeSeries.ts +40 -0
  199. package/src/app/charts/series/timeSeriesChartData.ts +68 -0
  200. package/src/app/charts/styling/barPlotStyle.ts +126 -0
  201. package/src/app/charts/styling/margins.test.ts +22 -0
  202. package/src/app/charts/styling/margins.ts +58 -0
  203. package/src/app/charts/styling/svgStyle.ts +118 -0
  204. package/src/app/charts/subscriptions/subscription.test.ts +499 -0
  205. package/src/app/charts/subscriptions/subscriptions.ts +635 -0
  206. package/src/app/charts/tooltips/BarPlotTooltipContent.tsx +440 -0
  207. package/src/app/charts/tooltips/PoincarePlotTooltipContent.tsx +352 -0
  208. package/src/app/charts/tooltips/RasterPlotTooltipContent.tsx +274 -0
  209. package/src/app/charts/tooltips/ScatterPlotTooltipContent.tsx +319 -0
  210. package/src/app/charts/tooltips/Tooltip.tsx +148 -0
  211. package/src/app/charts/tooltips/tooltipUtils.ts +216 -0
  212. package/src/app/charts/trackers/Tracker.tsx +129 -0
  213. package/src/app/charts/trackers/trackerUtils.ts +494 -0
  214. package/src/app/charts/utils.ts +109 -0
  215. package/dist/src/app/charts/CategoryAxis.d.ts +0 -20
  216. package/dist/src/app/charts/CategoryAxis.js +0 -112
  217. package/dist/src/app/charts/CategoryAxis.js.map +0 -1
  218. package/dist/src/app/charts/ContinuousAxis.d.ts +0 -16
  219. package/dist/src/app/charts/ContinuousAxis.js +0 -186
  220. package/dist/src/app/charts/ContinuousAxis.js.map +0 -1
  221. package/dist/src/app/charts/RasterPlot.js.map +0 -1
  222. package/dist/src/app/charts/RasterPlotTooltipContent.js.map +0 -1
  223. package/dist/src/app/charts/ScatterPlot.js +0 -351
  224. package/dist/src/app/charts/ScatterPlot.js.map +0 -1
  225. package/dist/src/app/charts/ScatterPlotTooltipContent.js +0 -163
  226. package/dist/src/app/charts/ScatterPlotTooltipContent.js.map +0 -1
  227. package/dist/src/app/charts/Tooltip.js.map +0 -1
  228. package/dist/src/app/charts/Tracker.js +0 -65
  229. package/dist/src/app/charts/Tracker.js.map +0 -1
  230. package/dist/src/app/charts/axes.d.ts +0 -132
  231. package/dist/src/app/charts/axes.js +0 -265
  232. package/dist/src/app/charts/axes.js.map +0 -1
  233. package/dist/src/app/charts/chartData.js +0 -32
  234. package/dist/src/app/charts/chartData.js.map +0 -1
  235. package/dist/src/app/charts/continuousAxisRangeFor.d.ts +0 -20
  236. package/dist/src/app/charts/continuousAxisRangeFor.js +0 -68
  237. package/dist/src/app/charts/continuousAxisRangeFor.js.map +0 -1
  238. package/dist/src/app/charts/datumSeries.d.ts +0 -59
  239. package/dist/src/app/charts/datumSeries.js +0 -55
  240. package/dist/src/app/charts/datumSeries.js.map +0 -1
  241. package/dist/src/app/charts/datumSeries.test.js +0 -50
  242. package/dist/src/app/charts/datumSeries.test.js.map +0 -1
  243. package/dist/src/app/charts/hooks/AxesState.d.ts +0 -37
  244. package/dist/src/app/charts/hooks/AxesState.js +0 -44
  245. package/dist/src/app/charts/hooks/AxesState.js.map +0 -1
  246. package/dist/src/app/charts/margins.js.map +0 -1
  247. package/dist/src/app/charts/margins.test.js +0 -14
  248. package/dist/src/app/charts/margins.test.js.map +0 -1
  249. package/dist/src/app/charts/plot.js.map +0 -1
  250. package/dist/src/app/charts/regexFilter.d.ts +0 -9
  251. package/dist/src/app/charts/regexFilter.js +0 -17
  252. package/dist/src/app/charts/regexFilter.js.map +0 -1
  253. package/dist/src/app/charts/regexFilter.test.js +0 -11
  254. package/dist/src/app/charts/regexFilter.test.js.map +0 -1
  255. package/dist/src/app/charts/subscriptions.d.ts +0 -43
  256. package/dist/src/app/charts/subscriptions.js +0 -213
  257. package/dist/src/app/charts/subscriptions.js.map +0 -1
  258. package/dist/src/app/charts/svgStyle.d.ts +0 -27
  259. package/dist/src/app/charts/svgStyle.js +0 -32
  260. package/dist/src/app/charts/svgStyle.js.map +0 -1
  261. package/dist/src/app/charts/timeRange.test.js +0 -54
  262. package/dist/src/app/charts/timeRange.test.js.map +0 -1
  263. package/dist/src/app/charts/tooltipUtils.js.map +0 -1
  264. package/dist/src/app/charts/trackerUtils.js +0 -130
  265. package/dist/src/app/charts/trackerUtils.js.map +0 -1
  266. /package/dist/src/app/charts/{datumSeries.test.d.ts → axes/AxesState.test.d.ts} +0 -0
  267. /package/dist/src/app/charts/{margins.test.d.ts → axes/AxisInterval.test.d.ts} +0 -0
  268. /package/dist/src/app/charts/{regexFilter.test.d.ts → axes/ContinuousAxisRange.test.d.ts} +0 -0
  269. /package/dist/src/app/charts/{timeRange.test.d.ts → axes/OrdinalAxisRange.test.d.ts} +0 -0
  270. /package/dist/src/app/charts/{RasterPlotTooltipContent.d.ts → tooltips/RasterPlotTooltipContent.d.ts} +0 -0
  271. /package/dist/src/app/charts/{ScatterPlotTooltipContent.d.ts → tooltips/ScatterPlotTooltipContent.d.ts} +0 -0
@@ -0,0 +1,190 @@
1
+ import { createTable, TableData, TableFormatter, TableStyler } from "svg-table";
2
+ import { defaultTooltipStyle, findPointAndNeighbors, tooltipX, tooltipY } from "./tooltipUtils";
3
+ import { formatTime, formatTimeChange, formatValue, formatValueChange } from "../utils";
4
+ import { useEffect, useMemo } from "react";
5
+ import { useChart } from "../hooks/useChart";
6
+ import { usePlotDimensions } from "../hooks/usePlotDimensions";
7
+ import { emptyIterateDatum } from "../series/iterateSeries";
8
+ import { DataFrame } from "data-frame-ts";
9
+ /**
10
+ * Adds tooltip content as a table. The columns of the table are the "label", the value before
11
+ * the mouse cursor, then value after the mouse cursor, and the difference between the two values.
12
+ * The rows of the table are x-values for the first row, and the y-values for the second row.
13
+ * The table has the following form.
14
+ * ```
15
+ * series name
16
+ * previous current next
17
+ * time x_tb x_ta x_ta - x_tb
18
+ * value y_tb y_ta y_ta - y_tb
19
+ * ```
20
+ *
21
+ * Registers the tooltip-content provider with the `ChartContext` so that when d3 fires a mouse-over
22
+ * event on a series. The content provider is returns the {@link addTooltipContent} function
23
+ * when called. And when called the {@link addTooltipContent} function adds the actual tooltip
24
+ * content to the SVG element.
25
+ * @param props The properties describing the tooltip content
26
+ * @return null
27
+ * @constructor
28
+ */
29
+ export function PoincarePlotTooltipContent(props) {
30
+ const { chartId, container, tooltip } = useChart();
31
+ const { registerTooltipContentProvider } = tooltip;
32
+ const { margin, plotDimensions, } = usePlotDimensions();
33
+ const { xLabel, yLabel, nMinusLagHeader = ' f[n-1](x)', nHeader = ' f[n](x) ', nPlusLagHeader = ' f[n+1](x)', xValueFormatter = formatTime, yValueFormatter = formatValue, xChangeFormatter = formatTimeChange, yChangeFormatter = formatValueChange, style, } = props;
34
+ const tooltipStyle = useMemo(() => (Object.assign(Object.assign({}, defaultTooltipStyle), style)), [style]);
35
+ // register the tooltip content provider, which when called on mouse-enter-series events
36
+ // will render the tooltip container and then the tooltip content. recall that the
37
+ // tooltip content is generated in this plot (because this is the plot that holds all the
38
+ // information needed to render it), and the container for the content is rendered by
39
+ // the <Tooltip>, which this knows nothing about.
40
+ //
41
+ // the 'registration function accepts a function of the form (seriesName, time, series) => TooltipDimensions.
42
+ // and that function has a closure on the content-specific information needed to add the
43
+ // actual content
44
+ useEffect(() => {
45
+ if (container) {
46
+ // register the tooltip content provider function with the chart hook (useChart) so that
47
+ // it is visible to all children of the Chart (i.e. the <Tooltip>).
48
+ registerTooltipContentProvider((seriesName, time, tooltipData, mouseCoords) => addTooltipContent(seriesName, time, tooltipData, mouseCoords, chartId, container, margin, plotDimensions, tooltipStyle));
49
+ }
50
+ }, [
51
+ chartId, container, margin, plotDimensions, registerTooltipContentProvider,
52
+ xLabel, xChangeFormatter, xValueFormatter,
53
+ yLabel, yChangeFormatter, yValueFormatter,
54
+ nMinusLagHeader, nHeader, nPlusLagHeader,
55
+ tooltipStyle
56
+ ]);
57
+ return null;
58
+ }
59
+ const dimension = {
60
+ width: 60,
61
+ defaultWidth: 70,
62
+ minWidth: 50,
63
+ maxWidth: 100,
64
+ height: 15,
65
+ defaultHeight: 15,
66
+ minHeight: 10,
67
+ maxHeight: 50
68
+ };
69
+ /**
70
+ * Callback function that adds tooltip content and returns the tooltip width and text height
71
+ * @param seriesName The name of the series (i.e. the neuron ID)
72
+ * @param time The time (x-coordinate value) corresponding to the mouse location
73
+ * @param tooltipData The series data and metadata
74
+ * @param mouseCoords The coordinates of the mouse when the event was fired (relative to the plot container)
75
+ * @param chartId The ID of this chart
76
+ * @param container The plot container (SVGSVGElement)
77
+ * @param margin The plot margins
78
+ * @param tooltipStyle The style properties for the tooltip
79
+ * @param plotDimensions The dimensions of the plot
80
+ * @return The width and text height of the tooltip content
81
+ */
82
+ function addTooltipContent(seriesName, time, tooltipData, mouseCoords, chartId, container, margin, plotDimensions, tooltipStyle) {
83
+ const [x, y] = mouseCoords;
84
+ const { series } = tooltipData;
85
+ const [lower, point, upper, index] = findPointAndNeighbors(series, time, 0.1, value => value.time, () => emptyIterateDatum);
86
+ const defaultBorderElement = {
87
+ color: tooltipStyle.borderColor,
88
+ radius: 0,
89
+ width: 0,
90
+ opacity: 0
91
+ };
92
+ const border = {
93
+ top: defaultBorderElement,
94
+ bottom: defaultBorderElement,
95
+ left: defaultBorderElement,
96
+ right: defaultBorderElement,
97
+ };
98
+ const background = {
99
+ color: tooltipStyle.backgroundColor,
100
+ opacity: tooltipStyle.backgroundOpacity
101
+ };
102
+ const font = {
103
+ size: tooltipStyle.fontSize,
104
+ family: tooltipStyle.fontFamily,
105
+ color: tooltipStyle.fontColor,
106
+ weight: tooltipStyle.fontWeight
107
+ };
108
+ const padding = {
109
+ top: tooltipStyle.paddingTop,
110
+ bottom: tooltipStyle.paddingBottom,
111
+ right: tooltipStyle.paddingRight,
112
+ left: tooltipStyle.paddingLeft
113
+ };
114
+ const currentIterateStyle = {
115
+ border,
116
+ dimension,
117
+ background,
118
+ font: Object.assign(Object.assign({}, font), { weight: 550 }),
119
+ padding,
120
+ alignText: 'right',
121
+ verticalAlignText: 'middle'
122
+ };
123
+ return DataFrame
124
+ .from([
125
+ [lower.time, point.time, upper.time],
126
+ [lower.iterateN_1, point.iterateN_1, upper.iterateN_1]
127
+ ])
128
+ // create the table data that has the column headers
129
+ .flatMap(df => TableData
130
+ .fromDataFrame(df)
131
+ .withColumnHeader([
132
+ index > 0 ? `f[${index - 1}](x)` : '- n/a -',
133
+ `f[${index}](x)`,
134
+ index < series.length - 1 ? `f[${index + 1}](x)` : '- n/a -'
135
+ ])
136
+ .flatMap(td => td.withRowHeader(['t (ms)', 'value'])))
137
+ // add the dat formatters for the (x, y) values of the iterates
138
+ .flatMap(tableData => TableFormatter.fromTableData(tableData)
139
+ .addRowFormatter(1, value => formatTime(value, ""))
140
+ .flatMap(tf => tf.addRowFormatter(2, value => formatValue(value)))
141
+ .flatMap(tf => tf.formatTable()))
142
+ .map(tableData => TableStyler.fromTableData(tableData)
143
+ .withTableFont(font)
144
+ .withPadding(padding)
145
+ .withColumnHeaderStyle({
146
+ font: Object.assign(Object.assign({}, font), { weight: 650 }),
147
+ padding: { top: 0, bottom: 10 },
148
+ dimension: Object.assign(Object.assign({}, dimension), { maxHeight: 70 }),
149
+ alignText: 'center',
150
+ })
151
+ .withRowHeaderStyle({
152
+ font: Object.assign(Object.assign({}, font), { weight: 650 }),
153
+ padding: { left: 0, right: 10 },
154
+ dimension: dimension,
155
+ alignText: 'center',
156
+ })
157
+ .withColumnStyles([], {
158
+ padding: { left: 10, right: 10 },
159
+ alignText: 'right',
160
+ })
161
+ .withCellStyle(1, 2, currentIterateStyle)
162
+ .withCellStyle(2, 2, currentIterateStyle)
163
+ .withRowStyles([], {
164
+ font,
165
+ dimension: Object.assign(Object.assign({}, dimension), { maxHeight: 20 }),
166
+ padding: { top: 0, bottom: 0 }
167
+ })
168
+ .styleTable())
169
+ .flatMap(styledTable => createTable(styledTable, container, `t${time}-${seriesName}-header-${chartId}`, tooltipCoordinates))
170
+ .map(renderingInfo => {
171
+ const { tableX: x, tableY: y, tableWidth: contentWidth, tableHeight: contentHeight } = renderingInfo;
172
+ return { x, y, contentWidth, contentHeight };
173
+ })
174
+ .getOrThrow();
175
+ /**
176
+ * Calculates the coordinates of the tooltip based on the width and height of the SVG
177
+ * table. This is needed because the tooltip needs to be adjusted relative mouse location
178
+ * when the mouse coordinates are too close to an edge.
179
+ * @param width The SVG table width
180
+ * @param height The SVG table height
181
+ * @return The updated tooltip coordinates
182
+ */
183
+ function tooltipCoordinates(width, height) {
184
+ return [
185
+ tooltipX(x, width, plotDimensions, tooltipStyle, margin),
186
+ tooltipY(y, height, plotDimensions, tooltipStyle, margin)
187
+ ];
188
+ }
189
+ }
190
+ //# sourceMappingURL=PoincarePlotTooltipContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PoincarePlotTooltipContent.js","sourceRoot":"","sources":["../../../../../src/app/charts/tooltips/PoincarePlotTooltipContent.tsx"],"names":[],"mappings":"AAAA,OAAO,EAEH,WAAW,EAGX,SAAS,EACT,cAAc,EACd,WAAW,EACd,MAAM,WAAW,CAAC;AACnB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AE,YAAY,EAAE,MAAM,CAAC;YACxD,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,CAAC;SAC5D,CAAA;IACL,CAAC;AAEL,CAAC"}
@@ -1,19 +1,9 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
1
  import { categoryTooltipY, defaultTooltipStyle, tooltipX } from "./tooltipUtils";
13
2
  import * as d3 from "d3";
14
- import { formatTime, formatValue } from "./utils";
3
+ import { formatTime, formatValue } from "../utils";
15
4
  import { useEffect, useMemo } from "react";
16
- import { useChart } from "./hooks/useChart";
5
+ import { useChart } from "../hooks/useChart";
6
+ import { usePlotDimensions } from "../hooks/usePlotDimensions";
17
7
  /**
18
8
  * Adds tooltip content that shows the series name and the (time, value) of the selected point.
19
9
  * ```
@@ -30,9 +20,12 @@ import { useChart } from "./hooks/useChart";
30
20
  * @constructor
31
21
  */
32
22
  export function RasterPlotTooltipContent(props) {
33
- var _a = useChart(), chartId = _a.chartId, container = _a.container, margin = _a.margin, plotDimensions = _a.plotDimensions, registerTooltipContentProvider = _a.registerTooltipContentProvider, yAxesState = _a.yAxesState, axisAssignmentsFor = _a.axisAssignmentsFor;
34
- var _b = props.xFormatter, xFormatter = _b === void 0 ? formatTime : _b, _c = props.yFormatter, yFormatter = _c === void 0 ? formatValue : _c, style = props.style;
35
- var tooltipStyle = useMemo(function () { return (__assign(__assign({}, defaultTooltipStyle), style)); }, [style]);
23
+ const { chartId, container, tooltip, axes } = useChart();
24
+ const { registerTooltipContentProvider } = tooltip;
25
+ const { yAxesState, axisAssignmentsFor } = axes;
26
+ const { margin, plotDimensions } = usePlotDimensions();
27
+ const { xFormatter = formatTime, yFormatter = formatValue, style, } = props;
28
+ const tooltipStyle = useMemo(() => (Object.assign(Object.assign({}, defaultTooltipStyle), style)), [style]);
36
29
  // register the tooltip content provider, which when called on mouse-enter-series events
37
30
  // will render the tooltip container and then the tooltip content. recall that that the
38
31
  // tooltip content is generated in this plot (because this is the plot that holds all the
@@ -42,10 +35,10 @@ export function RasterPlotTooltipContent(props) {
42
35
  // the 'registration function accepts a function of the form (seriesName, time, series) => TooltipDimensions.
43
36
  // and that function has a closure on the content-specific information needed to add the
44
37
  // actual content
45
- useEffect(function () {
38
+ useEffect(() => {
46
39
  if (container) {
47
40
  // assemble the options for adding the tooltip
48
- var options_1 = {
41
+ const options = {
49
42
  formatters: {
50
43
  x: xFormatter,
51
44
  y: yFormatter,
@@ -58,13 +51,17 @@ export function RasterPlotTooltipContent(props) {
58
51
  *
59
52
  * @param seriesName The name of the series
60
53
  * @param time The mouse time
61
- * @param series One point that has the (time, value) of the selected element
54
+ * @param tooltipData The tooltip data holding the series and metadata (data about the series)
62
55
  * @param mouseCoords The coordinates of the mouse
63
56
  * @return The tooltip contents
64
57
  */
65
- function (seriesName, time, series, mouseCoords) {
66
- var assignedAxis = yAxesState.axisFor(axisAssignmentsFor(seriesName).yAxis);
67
- return addTooltipContent(seriesName, time, series[0], mouseCoords, chartId, container, margin, plotDimensions, tooltipStyle, assignedAxis, options_1);
58
+ (seriesName, time, tooltipData, mouseCoords) => {
59
+ const yAxisId = axisAssignmentsFor(seriesName).yAxis;
60
+ const assignedAxis = yAxesState
61
+ .axisFor(yAxisId)
62
+ // .getOrElse(undefined as unknown as OrdinalStringAxis)
63
+ .getOrThrow(() => new Error(`No assigned y-axis exists; axis_id: ${yAxisId}`));
64
+ return addTooltipContent(seriesName, time, tooltipData.series[0], mouseCoords, chartId, container, margin, plotDimensions, tooltipStyle, assignedAxis, options);
68
65
  });
69
66
  }
70
67
  }, [
@@ -93,48 +90,47 @@ export function RasterPlotTooltipContent(props) {
93
90
  */
94
91
  function addTooltipContent(seriesName, time, selected, mouseCoords, chartId, container, margin, plotDimensions, tooltipStyle, axis, options) {
95
92
  var _a, _b, _c, _d, _e, _f, _g, _h;
96
- var formatters = options.formatters;
97
- var x = mouseCoords[0];
98
- var spikeTime = selected[0], value = selected[1];
93
+ const { formatters } = options;
94
+ const [x,] = mouseCoords;
95
+ const { time: spikeTime, value } = selected;
99
96
  // display the neuron ID in the tooltip
100
- var header = d3.select(container)
97
+ const header = d3.select(container)
101
98
  .append("text")
102
- .attr('id', "tn" + spikeTime + "-" + seriesName + "-" + chartId)
99
+ .attr('id', `tn${spikeTime}-${seriesName}-${chartId}`)
103
100
  .attr('class', 'tooltip')
104
101
  .attr('fill', tooltipStyle.fontColor)
105
102
  .attr('font-family', 'sans-serif')
106
103
  .attr('font-size', tooltipStyle.fontSize)
107
104
  .attr('font-weight', tooltipStyle.fontWeight)
108
- .text(function () { return seriesName; });
105
+ .text(() => seriesName);
109
106
  // display the time (ms) and spike strength (mV) in the tooltip
110
- var text = d3.select(container)
107
+ const text = d3.select(container)
111
108
  .append("text")
112
- .attr('id', "t" + spikeTime + "-" + seriesName + "-" + chartId)
109
+ .attr('id', `t${spikeTime}-${seriesName}-${chartId}`)
113
110
  .attr('class', 'tooltip')
114
111
  .attr('fill', tooltipStyle.fontColor)
115
112
  .attr('font-family', 'sans-serif')
116
113
  .attr('font-size', tooltipStyle.fontSize + 2)
117
114
  .attr('font-weight', tooltipStyle.fontWeight + 150)
118
- .text(function () { return formatters.x(spikeTime) + ", " + formatters.y(value); });
119
- // .text(() => `${d3.format(",.0f")(spikeTime)} ms, ${d3.format(",.2f")(value)} mV`)
115
+ .text(() => `${formatters.x(spikeTime)}, ${formatters.y(value)}`);
120
116
  // calculate the max width and height of the text
121
- var tooltipWidth = Math.max(((_b = (_a = header.node()) === null || _a === void 0 ? void 0 : _a.getBBox()) === null || _b === void 0 ? void 0 : _b.width) || 0, ((_d = (_c = text.node()) === null || _c === void 0 ? void 0 : _c.getBBox()) === null || _d === void 0 ? void 0 : _d.width) || 0);
122
- var headerTextHeight = ((_f = (_e = header.node()) === null || _e === void 0 ? void 0 : _e.getBBox()) === null || _f === void 0 ? void 0 : _f.height) || 0;
123
- var idHeight = ((_h = (_g = text.node()) === null || _g === void 0 ? void 0 : _g.getBBox()) === null || _h === void 0 ? void 0 : _h.height) || 0;
124
- var textHeight = headerTextHeight + idHeight;
117
+ const tooltipWidth = Math.max(((_b = (_a = header.node()) === null || _a === void 0 ? void 0 : _a.getBBox()) === null || _b === void 0 ? void 0 : _b.width) || 0, ((_d = (_c = text.node()) === null || _c === void 0 ? void 0 : _c.getBBox()) === null || _d === void 0 ? void 0 : _d.width) || 0);
118
+ const headerTextHeight = ((_f = (_e = header.node()) === null || _e === void 0 ? void 0 : _e.getBBox()) === null || _f === void 0 ? void 0 : _f.height) || 0;
119
+ const idHeight = ((_h = (_g = text.node()) === null || _g === void 0 ? void 0 : _g.getBBox()) === null || _h === void 0 ? void 0 : _h.height) || 0;
120
+ const textHeight = headerTextHeight + idHeight;
125
121
  // set the header text location
126
122
  // const spikeHeight = plotDimensions.height / liveDataRef.current.size
127
- var xCoord = tooltipX(x, tooltipWidth, plotDimensions, tooltipStyle, margin);
128
- var yCoord = categoryTooltipY(seriesName, textHeight, axis, tooltipStyle, margin, axis.categorySize);
129
- var xTooltip = xCoord + tooltipStyle.paddingLeft;
130
- var yTooltip = yCoord + tooltipStyle.paddingTop;
123
+ const xCoord = tooltipX(x, tooltipWidth, plotDimensions, tooltipStyle, margin);
124
+ const yCoord = categoryTooltipY(seriesName, textHeight, axis, tooltipStyle, margin, axis.scale.bandwidth(), plotDimensions);
125
+ const xTooltip = xCoord + tooltipStyle.paddingLeft;
126
+ const yTooltip = yCoord + tooltipStyle.paddingTop;
131
127
  header
132
- .attr('x', function () { return xTooltip; })
133
- .attr('y', function () { return yTooltip - idHeight + textHeight; });
128
+ .attr('x', () => xTooltip)
129
+ .attr('y', () => yTooltip - idHeight + textHeight);
134
130
  // set the tooltip text (i.e. neuron ID) location
135
131
  text
136
- .attr('x', function () { return xTooltip; })
137
- .attr('y', function () { return yTooltip + textHeight; });
132
+ .attr('x', () => xTooltip)
133
+ .attr('y', () => yTooltip + textHeight);
138
134
  return { x: xCoord, y: yCoord, contentWidth: tooltipWidth, contentHeight: textHeight };
139
135
  }
140
136
  //# sourceMappingURL=RasterPlotTooltipContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RasterPlotTooltipContent.js","sourceRoot":"","sources":["../../../../../src/app/charts/tooltips/RasterPlotTooltipContent.tsx"],"names":[],"mappings":"AACA,OAAO,EAAC,gBAAgB,EAAE,mBAAmB,EAAmC,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AAChH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAC,UAAU,EAAE,WAAW,EAAC,MAAM,UAAU,CAAC;AACjD,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACzC,OAAO,EAAoB,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAE9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AA2F7D;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAY;IACjD,MAAM,EACF,OAAO,EACP,SAAS,EACT,OAAO,EACP,IAAI,EACP,GAAG,QAAQ,EAAqF,CAAA;IAEjG,MAAM,EAAC,8BAA8B,EAAC,GAAG,OAAO,CAAA;IAEhD,MAAM,EACF,UAAU,EACV,kBAAkB,EACrB,GAAG,IAAI,CAAA;IAER,MAAM,EAAC,MAAM,EAAE,cAAc,EAAC,GAAG,iBAAiB,EAAE,CAAA;IAEpD,MAAM,EACF,UAAU,GAAG,UAAU,EACvB,UAAU,GAAG,WAAW,EACxB,KAAK,GACR,GAAG,KAAK,CAAA;IAET,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,iCAAK,mBAAmB,GAAK,KAAK,EAAE,EAAE,CAAC,KAAK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AC,CAAA;IAEtD,iDAAiD;IACjD,IAAI;SACC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC;SACzB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,QAAQ,GAAG,UAAU,CAAC,CAAA;IAE3C,OAAO,EAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAC,CAAA;AACxF,CAAC"}
@@ -0,0 +1,154 @@
1
+ import { boundingPoints, defaultTooltipStyle, tooltipX, tooltipY } from "./tooltipUtils";
2
+ import * as d3 from "d3";
3
+ import { formatTime, formatTimeChange, formatValue, formatValueChange } from "../utils";
4
+ import { useEffect, useMemo } from "react";
5
+ import { useChart } from "../hooks/useChart";
6
+ import { usePlotDimensions } from "../hooks/usePlotDimensions";
7
+ import { emptyDatum } from "../series/timeSeries";
8
+ /**
9
+ * Adds tooltip content as a table. The columns of the table are the "label", the value before
10
+ * the mouse cursor, then value after the mouse cursor, and the difference between the two values.
11
+ * The rows of the table are x-values for the first row, and the y-values for the second row.
12
+ * The table has the following form.
13
+ * ```
14
+ * series name
15
+ * before after ∆
16
+ * x-label x_tb x_ta x_ta - x_tb
17
+ * y-label y_tb y_ta y_ta - y_tb
18
+ * ```
19
+ *
20
+ * Registers the tooltip-content provider with the `ChartContext` so that when d3 fires a mouse-over
21
+ * event on a series. The content provider is returns the {@link addTooltipContent} function
22
+ * when called. And when called the {@link addTooltipContent} function adds the actual tooltip
23
+ * content to the SVG element.
24
+ * @param props The properties describing the tooltip content
25
+ * @return null
26
+ * @constructor
27
+ */
28
+ export function ScatterPlotTooltipContent(props) {
29
+ const { chartId, container, tooltip } = useChart();
30
+ const { registerTooltipContentProvider } = tooltip;
31
+ const { margin, plotDimensions } = usePlotDimensions();
32
+ const { xLabel, yLabel, beforeHeader = 'before', afterHeader = 'after', deltaHeader = '∆', xValueFormatter = formatTime, yValueFormatter = formatValue, xChangeFormatter = formatTimeChange, yChangeFormatter = formatValueChange, style, } = props;
33
+ const tooltipStyle = useMemo(() => (Object.assign(Object.assign({}, defaultTooltipStyle), style)), [style]);
34
+ // register the tooltip content provider, which when called on mouse-enter-series events
35
+ // will render the tooltip container and then the tooltip content. recall that that the
36
+ // tooltip content is generated in this plot (because this is the plot that holds all the
37
+ // information needed to render it), and the container for the content is rendered by
38
+ // the <Tooltip>, which this know nothing about.
39
+ //
40
+ // the 'registration function accepts a function of the form (seriesName, time, series) => TooltipDimensions.
41
+ // and that function has a closure on the content-specific information needed to add the
42
+ // actual content
43
+ useEffect(() => {
44
+ if (container) {
45
+ // assemble the options for adding the tooltip
46
+ const options = {
47
+ labels: { x: xLabel, y: yLabel },
48
+ headers: { before: beforeHeader, after: afterHeader, delta: deltaHeader },
49
+ formatters: {
50
+ x: { value: xValueFormatter, change: xChangeFormatter },
51
+ y: { value: yValueFormatter, change: yChangeFormatter },
52
+ }
53
+ };
54
+ // register the tooltip content provider function with the chart hook (useChart) so that
55
+ // it is visible to all children of the Chart (i.e. the <Tooltip>).
56
+ registerTooltipContentProvider((seriesName, time, tooltipData, mouseCoords) => addTooltipContent(seriesName, time, tooltipData.series, mouseCoords, chartId, container, margin, plotDimensions, tooltipStyle, options));
57
+ }
58
+ }, [
59
+ chartId, container, margin, plotDimensions, registerTooltipContentProvider,
60
+ xLabel, xChangeFormatter, xValueFormatter,
61
+ yLabel, yChangeFormatter, yValueFormatter,
62
+ beforeHeader, afterHeader, deltaHeader,
63
+ tooltipStyle
64
+ ]);
65
+ return null;
66
+ }
67
+ /**
68
+ * Callback function that adds tooltip content and returns the tooltip width and text height
69
+ * @param seriesName The name of the series (i.e. the neuron ID)
70
+ * @param time The time (x-coordinate value) corresponding to the mouse location
71
+ * @param series The datum (t ms, s mV)
72
+ * @param mouseCoords The coordinates of the mouse when the event was fired (relative to the plot container)
73
+ * @param chartId The ID of this chart
74
+ * @param container The plot container (SVGSVGElement)
75
+ * @param margin The plot margins
76
+ * @param tooltipStyle The style properties for the tooltip
77
+ * @param plotDimensions The dimensions of the plot
78
+ * @param options The options passed through the function that adds the tooltip content
79
+ * @return The width and text height of the tooltip content
80
+ */
81
+ function addTooltipContent(seriesName, time, series, mouseCoords, chartId, container, margin, plotDimensions, tooltipStyle, options) {
82
+ const { labels, formatters } = options;
83
+ const [x, y] = mouseCoords;
84
+ const [lower, upper] = boundingPoints(series, time, value => value.time, () => emptyDatum());
85
+ // display the neuron ID in the tooltip
86
+ const header = d3.select(container)
87
+ .append("text")
88
+ .attr('id', `tn${time}-${seriesName}-${chartId}`)
89
+ .attr('class', 'tooltip')
90
+ .attr('fill', tooltipStyle.fontColor)
91
+ .attr('font-family', 'sans-serif')
92
+ .attr('font-size', tooltipStyle.fontSize)
93
+ .attr('font-weight', tooltipStyle.fontWeight)
94
+ .text(() => seriesName);
95
+ // create the table that shows the points that come before and after the mouse time, and the
96
+ // changes in the time and value
97
+ const table = d3.select(container)
98
+ .append("g")
99
+ .attr('id', `t${time}-${seriesName}-header-${chartId}`)
100
+ .attr('class', 'tooltip')
101
+ .attr('fill', tooltipStyle.fontColor)
102
+ .attr('font-family', 'sans-serif')
103
+ .attr('font-size', tooltipStyle.fontSize + 2)
104
+ .attr('font-weight', tooltipStyle.fontWeight + 150);
105
+ const headerRow = table.append('g').attr('font-weight', tooltipStyle.fontWeight + 550);
106
+ const hrLower = headerRow.append("text").text(() => options.headers.before);
107
+ const hrUpper = headerRow.append("text").text(() => options.headers.after);
108
+ const hrDelta = headerRow.append("text").text(() => options.headers.delta);
109
+ const trHeader = table.append("text").text(() => labels.x);
110
+ const trLower = table.append("text").text(() => formatters.x.value(lower.time));
111
+ const trUpper = table.append("text").text(() => formatters.x.value(upper.time));
112
+ const trDelta = table.append("text").text(() => formatters.x.change(lower.time, upper.time));
113
+ const vrHeader = table.append("text").text(() => labels.y);
114
+ const vrLower = table.append("text").text(() => formatters.y.value(lower.value));
115
+ const vrUpper = table.append("text").text(() => formatters.y.value(upper.value));
116
+ const vrDelta = table.append("text").text(() => formatters.y.change(lower.value, upper.value));
117
+ const textWidthOf = (elem) => { var _a, _b; return ((_b = (_a = elem.node()) === null || _a === void 0 ? void 0 : _a.getBBox()) === null || _b === void 0 ? void 0 : _b.width) || 0; };
118
+ const textHeightOf = (elem) => { var _a, _b; return ((_b = (_a = elem.node()) === null || _a === void 0 ? void 0 : _a.getBBox()) === null || _b === void 0 ? void 0 : _b.height) || 0; };
119
+ const spacesWidthFor = (spaces) => spaces * textWidthOf(hrLower) / 5;
120
+ // calculate the max width and height of the text
121
+ const tooltipWidth = Math.max(textWidthOf(header), spacesWidthFor(33));
122
+ const headerTextHeight = textHeightOf(header);
123
+ const headerRowHeight = textHeightOf(hrLower);
124
+ const timeRowHeight = textHeightOf(trHeader);
125
+ const valueRowHeight = textHeightOf(vrHeader);
126
+ const textHeight = headerTextHeight + headerRowHeight + timeRowHeight + valueRowHeight;
127
+ // set the header text location
128
+ const xCoord = tooltipX(x, tooltipWidth, plotDimensions, tooltipStyle, margin);
129
+ const yCoord = tooltipY(y, textHeight, plotDimensions, tooltipStyle, margin);
130
+ const xTooltip = xCoord + tooltipStyle.paddingLeft;
131
+ const yTooltip = yCoord + tooltipStyle.paddingTop;
132
+ header
133
+ .attr('x', () => xTooltip)
134
+ .attr('y', () => yTooltip - (headerRowHeight + timeRowHeight + valueRowHeight) + textHeight);
135
+ const hrRowY = yTooltip + headerTextHeight + headerRowHeight;
136
+ const hrLowerX = spacesWidthFor(14);
137
+ const hrUpperX = spacesWidthFor(24);
138
+ const hrDeltaX = spacesWidthFor(32);
139
+ hrLower.attr('x', () => xTooltip + hrLowerX - textWidthOf(hrLower)).attr('y', () => hrRowY);
140
+ hrUpper.attr('x', () => xTooltip + hrUpperX - textWidthOf(hrUpper)).attr('y', () => hrRowY);
141
+ hrDelta.attr('x', () => xTooltip + hrDeltaX - textWidthOf(hrDelta)).attr('y', () => hrRowY);
142
+ const trRowY = hrRowY + timeRowHeight;
143
+ trHeader.attr('x', () => xTooltip).attr('y', () => trRowY);
144
+ trLower.attr('x', () => xTooltip + hrLowerX - textWidthOf(trLower)).attr('y', () => trRowY);
145
+ trUpper.attr('x', () => xTooltip + hrUpperX - textWidthOf(trUpper)).attr('y', () => trRowY);
146
+ trDelta.attr('x', () => xTooltip + hrDeltaX - textWidthOf(trDelta)).attr('y', () => trRowY);
147
+ const vrRowY = trRowY + valueRowHeight;
148
+ vrHeader.attr('x', () => xTooltip).attr('y', () => vrRowY);
149
+ vrLower.attr('x', () => xTooltip + hrLowerX - textWidthOf(vrLower)).attr('y', () => vrRowY);
150
+ vrUpper.attr('x', () => xTooltip + hrUpperX - textWidthOf(vrUpper)).attr('y', () => vrRowY);
151
+ vrDelta.attr('x', () => xTooltip + hrDeltaX - textWidthOf(vrDelta)).attr('y', () => vrRowY);
152
+ return { x: xCoord, y: yCoord, contentWidth: tooltipWidth, contentHeight: textHeight };
153
+ }
154
+ //# sourceMappingURL=ScatterPlotTooltipContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ScatterPlotTooltipContent.js","sourceRoot":"","sources":["../../../../../src/app/charts/tooltips/ScatterPlotTooltipContent.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAC,cAAc,EAAE,mBAAmB,EAAmC,QAAQ,EAAE,QAAQ,EAAC,MAAM,gBAAgB,CAAC;AACxH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AACzB,OAAO,EAAC,UAAU,EAAE,gBAAgB,EAAE,WAAW,EAAE,iBAAiB,EAAC,MAAM,UAAU,CAAC;AAEtF,OAAO,EAAC,SAAS,EAAE,OAAO,EAAC,MAAM,OAAO,CAAC;AACzC,OAAO,EAAoB,QAAQ,EAAC,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAC,iBAAiB,EAAC,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EAAQ,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAwGvD;;;;;;;;;;;;;;;;;;;GAmBG;AACH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,QAAQ,GAAG,QAAQ,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,CAAA;IAE3F,OAAO,EAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,EAAE,aAAa,EAAE,UAAU,EAAC,CAAA;AACxF,CAAC"}
@@ -1,5 +1,7 @@
1
- /// <reference types="react" />
1
+ import { JSX } from "react";
2
2
  import { TooltipStyle } from "./tooltipUtils";
3
+ import { BaseAxis, SeriesStyle } from "../axes/axes";
4
+ import { BaseAxisRange } from "../axes/BaseAxisRange";
3
5
  export interface Props {
4
6
  visible: boolean;
5
7
  style?: Partial<TooltipStyle>;
@@ -39,4 +41,4 @@ export interface Props {
39
41
  * @return null
40
42
  * @constructor
41
43
  */
42
- export declare function Tooltip(props: Props): JSX.Element;
44
+ export declare function Tooltip<D, S extends SeriesStyle, TM, AR extends BaseAxisRange, A extends BaseAxis>(props: Props): JSX.Element;