stream-charts 1.0.1 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/README.md +757 -342
  2. package/changes.md +11 -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} +11 -6
  146. package/dist/src/app/charts/{tooltipUtils.js → tooltips/tooltipUtils.js} +33 -17
  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,359 @@
1
+ import * as d3 from "d3";
2
+ import { containerDimensionsFrom, plotDimensionsFrom } from "../styling/margins";
3
+ import { mouseInPlotAreaFor, textDimensions } from "../utils";
4
+ import { AxisLocation } from "../axes/axes";
5
+ import { TrackerLabelLocation } from "./Tracker";
6
+ export const defaultTrackerLabelFont = {
7
+ size: 12,
8
+ color: '#d2933f',
9
+ weight: 300,
10
+ family: 'sans-serif'
11
+ };
12
+ export const defaultTrackerStyle = {
13
+ visible: false,
14
+ color: '#d2933f',
15
+ lineWidth: 1,
16
+ };
17
+ // create namespaced "mousemoved" event names to distinguish between vertical and horizontal trackers
18
+ const MOUSE_MOVED_EVENT_VERTICAL_AXIS = "mousemove.vertical";
19
+ const MOUSE_MOVED_EVENT_HORIZONTAL_AXIS = "mousemove.horizontal";
20
+ const TRACKER_ID = "stream-chart-tracker";
21
+ /**
22
+ * SVG ID for the vertical tracker line
23
+ * @param chartId The ID of the chart
24
+ * @return SVG ID for the vertical tracker line
25
+ */
26
+ function verticalTrackerLineId(chartId) {
27
+ return `${TRACKER_ID}-line-vertical-${chartId}`;
28
+ }
29
+ /**
30
+ * SVG ID for the horizontal tracker line
31
+ * @param chartId The ID of the chart
32
+ * @return SVG ID for the vertical tracker line
33
+ */
34
+ function horizontalTrackerLineId(chartId) {
35
+ return `${TRACKER_ID}-line-horizontal-${chartId}`;
36
+ }
37
+ /**
38
+ * SVG ID for the tracker label
39
+ * @param chartId The ID of the chart
40
+ * @param axisLocation The location of the axis for which the tracker label is to be shown
41
+ * @return SVG ID for the vertical tracker line
42
+ */
43
+ function trackerLabelId(chartId, axisLocation) {
44
+ switch (axisLocation) {
45
+ case AxisLocation.Bottom:
46
+ case AxisLocation.Top:
47
+ return `${TRACKER_ID}-label-vertical-${chartId}-${axisLocation}`;
48
+ case AxisLocation.Left:
49
+ case AxisLocation.Right:
50
+ return `${TRACKER_ID}-label-horizontal-${chartId}-${axisLocation}`;
51
+ }
52
+ }
53
+ /**
54
+ * Creates or returns the existing SVG elements for displaying a tracker line that is either
55
+ * vertical (for x-axes) or horizontal (for y-axes).
56
+ * @param chartId The ID of the chart
57
+ * @param container The SVG container
58
+ * @param svg The SVG selection
59
+ * @param plotDimensions The dimensions of the plot
60
+ * @param margin The margins around the plot
61
+ * @param style The tracker style
62
+ * @param labelFont The font used for the axis labels
63
+ * @param label A function that returns the tracker label string for a given x-value
64
+ * @param labelStyle The location style for the tracker (i.e. on the axes, next to the mouse, none shown)
65
+ * @param onTrackerUpdate A callback function that accepts the current tracker's axis information
66
+ * @param [axisLocation = AxisLocation.Bottom] The optional location of the axis for which the tracker is to
67
+ * be shown. Default is bottom.
68
+ * @param backgroundColor The background color of the tracker label
69
+ * @return The tracker selection
70
+ */
71
+ export function trackerControlInstance(chartId, container, svg, plotDimensions, margin, style, labelFont, label, labelStyle, onTrackerUpdate, axisLocation = AxisLocation.Bottom, backgroundColor) {
72
+ switch (axisLocation) {
73
+ case AxisLocation.Bottom:
74
+ case AxisLocation.Top:
75
+ return verticalTrackerControlInstance(chartId, container, svg, plotDimensions, margin, style, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor);
76
+ case AxisLocation.Left:
77
+ case AxisLocation.Right:
78
+ default:
79
+ return horizontalTrackerControlInstance(chartId, container, svg, plotDimensions, margin, style, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor);
80
+ }
81
+ }
82
+ /**
83
+ * Creates or returns the existing SVG elements for displaying a vertical tracker line
84
+ * @param chartId The ID of the chart
85
+ * @param container The SVG container
86
+ * @param svg The SVG selection
87
+ * @param plotDimensions The dimensions of the plot
88
+ * @param margin The margins around the plot
89
+ * @param style The tracker style
90
+ * @param labelFont The font used for the axis labels
91
+ * @param label A function that returns the tracker label string for a given x-value
92
+ * @param labelStyle The location style for the tracker (i.e. on the axes, next to the mouse, none shown)
93
+ * @param onTrackerUpdate A callback function that accepts the current tracker's axis information
94
+ * @param backgroundColor The background color of the tracker label
95
+ * @return The tracker selection
96
+ */
97
+ function verticalTrackerControlInstance(chartId, container, svg, plotDimensions, margin, style, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor) {
98
+ const trackerLine = svg
99
+ .append('line')
100
+ .attr('id', verticalTrackerLineId(chartId))
101
+ .attr('class', 'tracker')
102
+ .attr('y1', margin.top)
103
+ .attr('y2', plotDimensions.height + margin.top)
104
+ .attr('stroke', style.color)
105
+ .attr('stroke-width', style.lineWidth)
106
+ .attr('opacity', 0);
107
+ if (labelStyle === TrackerLabelLocation.ByAxis) {
108
+ label.forEach((_, axis) => {
109
+ // create the text element holding the tracker time
110
+ const labelY = axis.location === AxisLocation.Top ?
111
+ Math.max(0, margin.top - 20) :
112
+ Math.max(0, plotDimensions.height + margin.top - 3);
113
+ svg
114
+ .append('rect')
115
+ .attr('id', `${trackerLabelId(chartId, axis.location)}-background`)
116
+ .attr('y', labelY)
117
+ .attr('fill', backgroundColor)
118
+ .attr('opacity', 0);
119
+ svg
120
+ .append('text')
121
+ .attr('id', trackerLabelId(chartId, axis.location))
122
+ .attr('y', labelY)
123
+ .attr('fill', labelFont.color)
124
+ .attr('font-family', labelFont.family)
125
+ .attr('font-size', labelFont.size)
126
+ .attr('font-weight', labelFont.weight)
127
+ .attr('opacity', 0)
128
+ .text(() => '');
129
+ });
130
+ }
131
+ const containerDimensions = containerDimensionsFrom(plotDimensions, margin);
132
+ svg.on(MOUSE_MOVED_EVENT_VERTICAL_AXIS, event => handleShowVerticalTracker(chartId, container, event, margin, containerDimensions, style, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor));
133
+ return trackerLine;
134
+ }
135
+ /**
136
+ * Creates or returns the existing SVG elements for displaying a horizontal tracker line
137
+ * @param chartId The ID of the chart
138
+ * @param container The SVG container
139
+ * @param svg The SVG selection
140
+ * @param plotDimensions The dimensions of the plot
141
+ * @param margin The margins around the plot
142
+ * @param style The tracker style
143
+ * @param labelFont The font used for the axis labels
144
+ * @param label A function that returns the tracker label string for a given x-value
145
+ * @param labelStyle The location style for the tracker (i.e. on the axes, next to the mouse, none shown)
146
+ * @param onTrackerUpdate A callback function that accepts the current tracker's axis information
147
+ * @param backgroundColor The background color of the tracker label
148
+ * @return The tracker selection
149
+ */
150
+ function horizontalTrackerControlInstance(chartId, container, svg, plotDimensions, margin, style, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor) {
151
+ const trackerLine = svg
152
+ .append('line')
153
+ .attr('id', horizontalTrackerLineId(chartId))
154
+ .attr('class', 'tracker')
155
+ .attr('x1', margin.left)
156
+ .attr('x2', plotDimensions.width + margin.left)
157
+ .attr('stroke', style.color)
158
+ .attr('stroke-width', style.lineWidth)
159
+ .attr('opacity', 0);
160
+ label.forEach((_, axis) => {
161
+ // create the text element holding the tracker time
162
+ const labelY = axis.location === AxisLocation.Left ?
163
+ Math.max(0, margin.left - 20) :
164
+ Math.max(0, plotDimensions.width + margin.left - 3);
165
+ svg
166
+ .append('rect')
167
+ .attr('id', `${trackerLabelId(chartId, axis.location)}-background`)
168
+ .attr('y', labelY)
169
+ .attr('fill', backgroundColor)
170
+ .attr('opacity', 0);
171
+ svg
172
+ .append('text')
173
+ .attr('id', trackerLabelId(chartId, axis.location))
174
+ .attr('y', labelY)
175
+ .attr('fill', labelFont.color)
176
+ .attr('font-family', labelFont.family)
177
+ .attr('font-size', labelFont.size)
178
+ .attr('font-weight', labelFont.weight)
179
+ .attr('opacity', 0)
180
+ .text(() => '');
181
+ });
182
+ const containerDimensions = containerDimensionsFrom(plotDimensions, margin);
183
+ svg.on(MOUSE_MOVED_EVENT_HORIZONTAL_AXIS, event => handleShowHorizontalTracker(chartId, container, event, margin, containerDimensions, style, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor));
184
+ return trackerLine;
185
+ }
186
+ /**
187
+ * Removes the tracker control from the chart
188
+ * @param svg The svg selection holding the tracker control
189
+ * @param axisLocation The location of the axis for which the tracker is to be removed.
190
+ */
191
+ export function removeTrackerControl(svg, axisLocation) {
192
+ switch (axisLocation) {
193
+ case AxisLocation.Bottom:
194
+ case AxisLocation.Top:
195
+ svg.on(MOUSE_MOVED_EVENT_VERTICAL_AXIS, () => null);
196
+ break;
197
+ case AxisLocation.Left:
198
+ case AxisLocation.Right:
199
+ default:
200
+ svg.on(MOUSE_MOVED_EVENT_HORIZONTAL_AXIS, () => null);
201
+ }
202
+ }
203
+ /**
204
+ * Callback when the vertical mouse tracker is to be shown
205
+ * @param chartId The ID number of the chart
206
+ * @param container The svg container
207
+ * @param event The mouse-over series event
208
+ * @param margin The plot margins
209
+ * @param dimensions The container dimensions (i.e., the plot dimensions plus its margins)
210
+ * @param trackerStyle The style settings for the tracker line
211
+ * @param labelFont The style settings for the tracker font
212
+ * @param label A function that returns the tracker label string
213
+ * @param labelStyle Where to display the tracker labels (i.e., with-mouse, with-axes, no-where)
214
+ * @param onTrackerUpdate A callback function that accepts the current tracker's axis information
215
+ * @param backgroundColor The background color of the tracker label
216
+ */
217
+ function handleShowVerticalTracker(chartId, container, event, margin, dimensions, trackerStyle, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor) {
218
+ // determine whether the mouse is in the plot area
219
+ const [x, y] = d3.pointer(event, container);
220
+ const inPlot = mouseInPlotAreaFor(x, y, margin, dimensions);
221
+ const updateInfo = Array.from(label.entries())
222
+ .map(([axis, trackerLabel]) => {
223
+ // when the mouse is in the plot area, then set the opacity of the tracker line and label to 1,
224
+ // which means it is fully visible. when the mouse is not in the plot area, set the opacity to 0,
225
+ // which means the tracker line and label are invisible.
226
+ d3.select(`#${verticalTrackerLineId(chartId)}`)
227
+ .attr('x1', x)
228
+ .attr('x2', x)
229
+ .attr('stroke', trackerStyle.color)
230
+ .attr('stroke-width', trackerStyle.lineWidth)
231
+ .attr('opacity', () => inPlot ? 1 : 0);
232
+ // when the label-style is to be with the mouse
233
+ if (labelStyle === TrackerLabelLocation.ByAxis) {
234
+ const label = d3.select(`#${trackerLabelId(chartId, axis.location)}`)
235
+ .attr('fill', labelFont.color)
236
+ .attr('font-family', labelFont.family)
237
+ .attr('font-size', labelFont.size)
238
+ .attr('font-weight', labelFont.weight)
239
+ .attr('opacity', () => inPlot ? 1 : 0)
240
+ .text(() => trackerLabel(axis.scale.invert(x - margin.left)));
241
+ const labelBackground = d3.select(`#${trackerLabelId(chartId, axis.location)}-background`)
242
+ .attr('fill', backgroundColor)
243
+ .attr('opacity', () => inPlot ? 0.8 : 0)
244
+ .attr('rx', '5px');
245
+ const space = 10;
246
+ const { height } = plotDimensionsFrom(dimensions.width, dimensions.height, margin);
247
+ const labelY = axis.location === AxisLocation.Top ?
248
+ margin.top + labelFont.size + space :
249
+ margin.top + height - space;
250
+ label.attr('y', labelY);
251
+ // adjust the label position when the tracker is at the right-most edges of the plot so that
252
+ // the label remains visible (i.e., doesn't get clipped)
253
+ const xOffset = TrackerLabelLocation.ByAxis ? 10 : 0;
254
+ const { width: labelWidth, height: labelHeight } = textDimensions(label);
255
+ const labelX = Math.min(dimensions.width - margin.right - labelWidth, x + xOffset);
256
+ label.attr('x', labelX);
257
+ // set the background location and width
258
+ const padding = 3;
259
+ labelBackground
260
+ .attr('x', labelX - padding)
261
+ .attr('y', labelY - labelHeight - padding)
262
+ .attr('width', labelWidth + 2 * padding)
263
+ .attr('height', labelHeight + 2 * padding);
264
+ }
265
+ const trackerInfo = {
266
+ x: axis.scale.invert(x - margin.left),
267
+ axisLocation: axis.location
268
+ };
269
+ return [axis.axisId, trackerInfo];
270
+ });
271
+ if (inPlot) {
272
+ onTrackerUpdate(new Map(updateInfo));
273
+ }
274
+ }
275
+ /**
276
+ * Callback when the horizontal mouse tracker is to be shown
277
+ * @param chartId The ID number of the chart
278
+ * @param container The svg container
279
+ * @param event The mouse-over series event
280
+ * @param margin The plot margins
281
+ * @param dimensions The container dimensions (i.e., the plot dimensions plus its margins)
282
+ * @param trackerStyle The style settings for the tracker line
283
+ * @param labelFont The style settings for the tracker font
284
+ * @param label A function that returns the tracker label string
285
+ * @param labelStyle Where to display the tracker labels (i.e., with-mouse, with-axes, no-where)
286
+ * @param onTrackerUpdate A callback function that accepts the current tracker's axis information
287
+ * @param backgroundColor The background color of the tracker label
288
+ */
289
+ function handleShowHorizontalTracker(chartId, container, event, margin, dimensions, trackerStyle, labelFont, label, labelStyle, onTrackerUpdate, backgroundColor) {
290
+ var _a;
291
+ // determine whether the mouse is in the plot area
292
+ const [x, y] = d3.pointer(event, container);
293
+ const inPlot = mouseInPlotAreaFor(x, y, margin, dimensions);
294
+ //
295
+ // need to calculate each axis-label position separately, because at the plot edges, the axis-label
296
+ // positions depend on each other. For example, at the left edge, the left-axis label needs to move
297
+ // to the right of the mouse to remain in the plot area. Therefore, the right-axis label needs
298
+ // to move as well but needs to know the width of the left-axis label to do so.
299
+ //
300
+ // add the labels and calculate the bounding boxes
301
+ const boundingBoxes = new Map(Array.from(label.entries())
302
+ .map(([axis, trackerLabel]) => {
303
+ // when the mouse is in the plot area, then set the opacity of the tracker line and label to 1,
304
+ // which means it is fully visible. when the mouse is not in the plot area, set the opacity to 0,
305
+ // which means the tracker line and label are invisible.
306
+ d3.select(`#${horizontalTrackerLineId(chartId)}`)
307
+ .attr('y1', y)
308
+ .attr('y2', y)
309
+ .attr('stroke', trackerStyle.color)
310
+ .attr('stroke-width', trackerStyle.lineWidth)
311
+ .attr('opacity', () => inPlot ? 1 : 0);
312
+ const label = d3.select(`#${trackerLabelId(chartId, axis.location)}`)
313
+ .attr('fill', labelFont.color)
314
+ .attr('font-family', labelFont.family)
315
+ .attr('font-size', labelFont.size)
316
+ .attr('font-weight', labelFont.weight)
317
+ .attr('opacity', () => inPlot ? 1 : 0)
318
+ .text(() => trackerLabel(axis.scale.invert(y - margin.top)));
319
+ const labelBackground = d3.select(`#${trackerLabelId(chartId, axis.location)}-background`)
320
+ .attr('fill', backgroundColor)
321
+ .attr('opacity', () => inPlot && labelStyle !== TrackerLabelLocation.Nowhere ? 0.8 : 0)
322
+ .attr('rx', '5px');
323
+ return [axis.location, { axis, labelSelection: label, labelBoundingBox: textDimensions(label), labelBackground }];
324
+ }));
325
+ // place the labels so that they remain in the plot area
326
+ const space = 10;
327
+ const rightLabelWidth = (((_a = boundingBoxes.get(AxisLocation.Right)) === null || _a === void 0 ? void 0 : _a.labelBoundingBox.width) || -space) + space;
328
+ const updateInfo = Array.from(boundingBoxes.entries())
329
+ .map(([location, { axis, labelSelection, labelBoundingBox, labelBackground }]) => {
330
+ if (labelStyle === TrackerLabelLocation.ByAxis) {
331
+ const { width } = plotDimensionsFrom(dimensions.width, dimensions.height, margin);
332
+ const labelX = location === AxisLocation.Left ?
333
+ margin.left + space :
334
+ margin.left + width - rightLabelWidth - space;
335
+ labelSelection.attr('x', labelX);
336
+ // adjust the label position when the tracker is at the right-most edges of the plot so that
337
+ // the label remains visible (i.e., doesn't get clipped)
338
+ const yOffset = labelStyle === TrackerLabelLocation.ByAxis ? space : 0;
339
+ const labelY = Math.max(y - yOffset, margin.top + yOffset + labelBoundingBox.height);
340
+ labelSelection.attr('y', labelY);
341
+ // set the background location and width
342
+ const padding = 5;
343
+ labelBackground
344
+ .attr('x', labelX - padding)
345
+ .attr('y', labelY - labelBoundingBox.height - 1)
346
+ .attr('width', labelBoundingBox.width + 2 * padding)
347
+ .attr('height', labelBoundingBox.height + 2 * padding);
348
+ }
349
+ const trackerInfo = {
350
+ x: axis.scale.invert(y - margin.top + margin.bottom),
351
+ axisLocation: axis.location
352
+ };
353
+ return [axis.axisId, trackerInfo];
354
+ });
355
+ if (inPlot) {
356
+ onTrackerUpdate(new Map(updateInfo));
357
+ }
358
+ }
359
+ //# sourceMappingURL=trackerUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trackerUtils.js","sourceRoot":"","sources":["../../../../../src/app/charts/trackers/trackerUtils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,OAAO,EAAC,uBAAuB,EAAsB,kBAAkB,EAAC,MAAM,oBAAoB,CAAC;AACnG,OAAO,EAAc,kBAAkB,EAAE,cAAc,EAAC,MAAM,UAAU,CAAC;AACzE,OAAO,EAAC,YAAY,EAAwB,M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xC,MAAM,OAAO,GAAW,CAAC,CAAA;YACzB,eAAe;iBACV,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;iBAC3B,IAAI,CAAC,GAAG,EAAE,MAAM,GAAG,gBAAgB,CAAC,MAAM,GAAG,CAAC,CAAC;iBAC/C,IAAI,CAAC,OAAO,EAAE,gBAAgB,CAAC,KAAK,GAAG,CAAC,GAAG,OAAO,CAAC;iBACnD,IAAI,CAAC,QAAQ,EAAE,gBAAgB,CAAC,MAAM,GAAG,CAAC,GAAG,OAAO,CAAC,CAAA;QAC9D,CAAC;QAED,MAAM,WAAW,GAAoB;YACjC,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC;YACpD,YAAY,EAAE,IAAI,CAAC,QAAQ;SAC9B,CAAA;QACD,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,WAAW,CAAC,CAAA;IACrC,CAAC,CAAC,CAAA;IAEN,IAAI,MAAM,EAAE,CAAC;QACT,eAAe,CAAC,IAAI,GAAG,CAA0B,UAAU,CAAC,CAAC,CAAA;IACjE,CAAC;AACL,CAAC"}
@@ -1,7 +1,5 @@
1
- import { Dimensions, Margin } from "./margins";
2
- import { Selection, ZoomTransform } from "d3";
3
- import { ContinuousNumericAxis } from "./axes";
4
- import { ContinuousAxisRange } from "./continuousAxisRangeFor";
1
+ import { Dimensions, Margin } from "./styling/margins";
2
+ import { Selection } from "d3";
5
3
  /**
6
4
  * No operation function for use when a default function is needed
7
5
  */
@@ -14,35 +12,35 @@ export declare const noop: () => void;
14
12
  * @param dimensions The the overall dimensions (plot dimensions plus margin)
15
13
  * @return `true` if the mouse is in the plot area; `false` if the mouse is not in the plot area
16
14
  */
17
- export declare const mouseInPlotAreaFor: (x: number, y: number, margin: Margin, dimensions: Dimensions) => boolean;
15
+ export declare function mouseInPlotAreaFor(x: number, y: number, margin: Margin, dimensions: Dimensions): boolean;
18
16
  /**
19
17
  * Calculates the width of an SVG text element, based on its bounding box
20
18
  * @param elem The SVG text element
21
19
  * @return The width in pixels, or 0 if SVG text element has not children
22
20
  */
23
- export declare const textWidthOf: (elem: Selection<SVGTextElement, any, HTMLElement, any>) => number;
21
+ export declare function textWidthOf(elem: Selection<SVGTextElement, any, any, any>): number;
24
22
  /**
25
- * The object returned by the zoom
23
+ * Type for representing the dimensions and location of the bounding box for an
24
+ * SVG text element.
26
25
  */
27
- export interface Zoom {
28
- zoomFactor: number;
29
- timeRange: ContinuousAxisRange;
30
- }
26
+ export type BoundingBox = {
27
+ x: number;
28
+ y: number;
29
+ width: number;
30
+ height: number;
31
+ };
31
32
  /**
32
- * Called when the user uses the scroll wheel (or scroll gesture) to zoom in or out. Zooms in/out
33
- * at the location of the mouse when the scroll wheel or gesture was applied.
34
- * @param transform The d3 zoom transformation information
35
- * @param x The x-position of the mouse when the scroll wheel or gesture is used
36
- * @param plotDimensions The current dimensions of the plot
37
- * @param containerWidth The container width
38
- * @param margin The plot margins
39
- * @param xAxis The linear x-axis
40
- * @param timeRange The time-range of the current x-axis
41
- * @return The zoom factor and updated time-range
33
+ * @return An empty bounding box with x, y, width, height set to 0.
34
+ */
35
+ export declare function emptyBoundingBox(): BoundingBox;
36
+ /**
37
+ * Calculates the width and height of the text element
38
+ * @param elem The SVG text element
39
+ * @return The width and height of the bounding box
42
40
  */
43
- export declare function handleZoom(transform: ZoomTransform, x: number, plotDimensions: Dimensions, containerWidth: number, margin: Margin, xAxis: ContinuousNumericAxis, timeRange: ContinuousAxisRange): Zoom | undefined;
41
+ export declare function textDimensions(elem: Selection<SVGTextElement, any, any, any>): BoundingBox;
44
42
  export declare function formatNumber(value: number, format: string): string;
45
- export declare function formatTime(value: number): string;
43
+ export declare function formatTime(value: number, units?: string): string;
46
44
  export declare function formatValue(value: number): string;
47
45
  export declare function formatChange(v1: number, v2: number, format: string): string;
48
46
  export declare function formatTimeChange(v1: number, v2: number): string;
@@ -64,12 +62,4 @@ export declare function formatValueChange(v1: number, v2: number): string;
64
62
  * const minMaxTimeSeriesY: (data: Array<TimeSeries>, currentMinMax: [number, number]) => [number, number] =
65
63
  minMaxOf((datum: [number, number]): number => datum[1])
66
64
  */
67
- export declare const minMaxOf: <T>(accessor: (v: T) => number) => (data: T[][], currentMinMax: [number, number]) => [number, number];
68
- /**
69
- * Sets up the min-max function to extract the y-value of the time-series.
70
- *
71
- * Defines a function that accepts an array of time-series (matrixish) and returns the min and max
72
- * y-value for all the values in all the series.
73
- * @see minMaxOf
74
- */
75
- export declare const minMaxYFor: (data: [number, number][][], currentMinMax: [number, number]) => [number, number];
65
+ export declare const minMaxOf: <T>(accessor: (v: T) => number) => (data: Array<Array<T>>, currentMinMax: [number, number]) => [number, number];
@@ -1,9 +1,9 @@
1
1
  import * as d3 from "d3";
2
- import { calculateZoomFor } from "./axes";
3
2
  /**
4
3
  * No operation function for use when a default function is needed
5
4
  */
6
- export var noop = function () {
5
+ export const noop = () => {
6
+ /* empty on purpose */
7
7
  };
8
8
  /**
9
9
  * Calculates whether the mouse is in the plot-area
@@ -13,38 +13,47 @@ export var noop = function () {
13
13
  * @param dimensions The the overall dimensions (plot dimensions plus margin)
14
14
  * @return `true` if the mouse is in the plot area; `false` if the mouse is not in the plot area
15
15
  */
16
- export var mouseInPlotAreaFor = function (x, y, margin, dimensions) {
17
- return x > margin.left && x < dimensions.width - margin.right && y > margin.top && y < dimensions.height - margin.bottom;
18
- };
16
+ export function mouseInPlotAreaFor(x, y, margin, dimensions) {
17
+ return x > margin.left &&
18
+ x < dimensions.width - margin.right &&
19
+ y > margin.top &&
20
+ y < dimensions.height - margin.bottom;
21
+ }
19
22
  /**
20
23
  * Calculates the width of an SVG text element, based on its bounding box
21
24
  * @param elem The SVG text element
22
25
  * @return The width in pixels, or 0 if SVG text element has not children
23
26
  */
24
- export var textWidthOf = function (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; };
27
+ export function textWidthOf(elem) {
28
+ var _a, _b;
29
+ return ((_b = (_a = elem.node()) === null || _a === void 0 ? void 0 : _a.getBBox()) === null || _b === void 0 ? void 0 : _b.width) || 0;
30
+ }
25
31
  /**
26
- * Called when the user uses the scroll wheel (or scroll gesture) to zoom in or out. Zooms in/out
27
- * at the location of the mouse when the scroll wheel or gesture was applied.
28
- * @param transform The d3 zoom transformation information
29
- * @param x The x-position of the mouse when the scroll wheel or gesture is used
30
- * @param plotDimensions The current dimensions of the plot
31
- * @param containerWidth The container width
32
- * @param margin The plot margins
33
- * @param xAxis The linear x-axis
34
- * @param timeRange The time-range of the current x-axis
35
- * @return The zoom factor and updated time-range
32
+ * @return An empty bounding box with x, y, width, height set to 0.
33
+ */
34
+ export function emptyBoundingBox() {
35
+ return { x: 0, y: 0, width: 0, height: 0 };
36
+ }
37
+ /**
38
+ * Calculates the width and height of the text element
39
+ * @param elem The SVG text element
40
+ * @return The width and height of the bounding box
36
41
  */
37
- export function handleZoom(transform, x, plotDimensions, containerWidth, margin, xAxis, timeRange) {
38
- if (x > 0 && x < containerWidth - margin.right) {
39
- var _a = calculateZoomFor(transform, x, plotDimensions, xAxis, timeRange), range = _a.range, zoomFactor = _a.zoomFactor;
40
- return { zoomFactor: zoomFactor, timeRange: range };
41
- }
42
+ export function textDimensions(elem) {
43
+ var _a;
44
+ const boundingBox = (_a = elem.node()) === null || _a === void 0 ? void 0 : _a.getBBox();
45
+ return {
46
+ width: (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.width) || 0,
47
+ height: (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.height) || 0,
48
+ x: (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.x) || 0,
49
+ y: (boundingBox === null || boundingBox === void 0 ? void 0 : boundingBox.y) || 0
50
+ };
42
51
  }
43
52
  export function formatNumber(value, format) {
44
53
  return isNaN(value) ? '---' : d3.format(format)(value);
45
54
  }
46
- export function formatTime(value) {
47
- return formatNumber(value, " ,.0f");
55
+ export function formatTime(value, units = "") {
56
+ return `${formatNumber(value, " ,.0f")}${!isNaN(value) && units ? ` ${units}` : ""}`;
48
57
  }
49
58
  export function formatValue(value) {
50
59
  return formatNumber(value, " ,.3f");
@@ -75,18 +84,8 @@ export function formatValueChange(v1, v2) {
75
84
  * const minMaxTimeSeriesY: (data: Array<TimeSeries>, currentMinMax: [number, number]) => [number, number] =
76
85
  minMaxOf((datum: [number, number]): number => datum[1])
77
86
  */
78
- export var minMaxOf = function (accessor) {
79
- return function (data, currentMinMax) { return [
80
- Math.min(d3.min(data, function (series) { return d3.min(series, function (datum) { return accessor(datum); }); }) || 0, currentMinMax[0]),
81
- Math.max(d3.max(data, function (series) { return d3.max(series, function (datum) { return accessor(datum); }); }) || 1, currentMinMax[1])
82
- ]; };
83
- };
84
- /**
85
- * Sets up the min-max function to extract the y-value of the time-series.
86
- *
87
- * Defines a function that accepts an array of time-series (matrixish) and returns the min and max
88
- * y-value for all the values in all the series.
89
- * @see minMaxOf
90
- */
91
- export var minMaxYFor = minMaxOf(function (datum) { return datum[1]; });
87
+ export const minMaxOf = (accessor) => (data, currentMinMax) => [
88
+ Math.min(d3.min(data, series => d3.min(series, datum => accessor(datum))) || 0, currentMinMax[0]),
89
+ Math.max(d3.max(data, series => d3.max(series, datum => accessor(datum))) || 1, currentMinMax[1])
90
+ ];
92
91
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/app/charts/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,OAAO,EAAC,gBAAgB,EAAwB,MAAM,QAAQ,CAAC;AAG/D;;GAEG;AACH,MAAM,CAAC,IAAM,IAAI,GAAG;AACpB,CAAC,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,IAAM,kBAAkB,GAC3B,UAAC,CAAS,EAAE,CAAS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