@perses-dev/components 0.39.0 → 0.40.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 (328) hide show
  1. package/dist/BarChart/BarChart.d.ts +2 -2
  2. package/dist/BarChart/BarChart.d.ts.map +1 -1
  3. package/dist/BarChart/BarChart.js +8 -8
  4. package/dist/BarChart/BarChart.js.map +1 -1
  5. package/dist/BarChart/index.js.map +1 -1
  6. package/dist/ColorPicker/ColorPicker.js.map +1 -1
  7. package/dist/ColorPicker/index.js.map +1 -1
  8. package/dist/ContentWithLegend/ContentWithLegend.js.map +1 -1
  9. package/dist/ContentWithLegend/index.js.map +1 -1
  10. package/dist/ContentWithLegend/model/content-with-legend-model.d.ts +1 -1
  11. package/dist/ContentWithLegend/model/content-with-legend-model.js +19 -19
  12. package/dist/ContentWithLegend/model/content-with-legend-model.js.map +1 -1
  13. package/dist/DateTimeRangePicker/AbsoluteTimePicker.d.ts.map +1 -1
  14. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js +6 -22
  15. package/dist/DateTimeRangePicker/AbsoluteTimePicker.js.map +1 -1
  16. package/dist/DateTimeRangePicker/DateTimeRangePicker.js.map +1 -1
  17. package/dist/DateTimeRangePicker/TimeRangeSelector.js.map +1 -1
  18. package/dist/DateTimeRangePicker/index.js.map +1 -1
  19. package/dist/DateTimeRangePicker/utils.js.map +1 -1
  20. package/dist/Dialog/Dialog.js.map +1 -1
  21. package/dist/Dialog/DiscardChangesConfirmationDialog.js.map +1 -1
  22. package/dist/Dialog/index.js.map +1 -1
  23. package/dist/Drawer/Drawer.js.map +1 -1
  24. package/dist/Drawer/index.js.map +1 -1
  25. package/dist/EChart/EChart.js +2 -2
  26. package/dist/EChart/EChart.js.map +1 -1
  27. package/dist/EChart/index.js.map +1 -1
  28. package/dist/ErrorAlert.js.map +1 -1
  29. package/dist/ErrorBoundary.js.map +1 -1
  30. package/dist/FontSizeSelector/FontSizeSelector.js.map +1 -1
  31. package/dist/FontSizeSelector/index.js.map +1 -1
  32. package/dist/FormatControls/FormatControls.d.ts +9 -0
  33. package/dist/FormatControls/FormatControls.d.ts.map +1 -0
  34. package/dist/{UnitSelector/UnitSelector.js → FormatControls/FormatControls.js} +26 -26
  35. package/dist/FormatControls/FormatControls.js.map +1 -0
  36. package/dist/FormatControls/index.d.ts +2 -0
  37. package/dist/FormatControls/index.d.ts.map +1 -0
  38. package/dist/{UnitSelector → FormatControls}/index.js +1 -1
  39. package/dist/FormatControls/index.js.map +1 -0
  40. package/dist/GaugeChart/GaugeChart.d.ts +3 -3
  41. package/dist/GaugeChart/GaugeChart.d.ts.map +1 -1
  42. package/dist/GaugeChart/GaugeChart.js +11 -11
  43. package/dist/GaugeChart/GaugeChart.js.map +1 -1
  44. package/dist/GaugeChart/index.js.map +1 -1
  45. package/dist/InfoTooltip/InfoTooltip.js.map +1 -1
  46. package/dist/InfoTooltip/index.js.map +1 -1
  47. package/dist/JSONEditor.js.map +1 -1
  48. package/dist/Legend/CompactLegend.js.map +1 -1
  49. package/dist/Legend/Legend.js +3 -3
  50. package/dist/Legend/Legend.js.map +1 -1
  51. package/dist/Legend/LegendColorBadge.js.map +1 -1
  52. package/dist/Legend/ListLegend.js.map +1 -1
  53. package/dist/Legend/ListLegendItem.js +2 -2
  54. package/dist/Legend/ListLegendItem.js.map +1 -1
  55. package/dist/Legend/TableLegend.js.map +1 -1
  56. package/dist/Legend/index.js.map +1 -1
  57. package/dist/Legend/legend-model.js.map +1 -1
  58. package/dist/LineChart/LineChart.d.ts +2 -2
  59. package/dist/LineChart/LineChart.d.ts.map +1 -1
  60. package/dist/LineChart/LineChart.js +12 -12
  61. package/dist/LineChart/LineChart.js.map +1 -1
  62. package/dist/LineChart/index.js.map +1 -1
  63. package/dist/ModeSelector/ModeSelector.js.map +1 -1
  64. package/dist/ModeSelector/index.js.map +1 -1
  65. package/dist/OptionsEditorLayout/OptionsEditorColumn.js.map +1 -1
  66. package/dist/OptionsEditorLayout/OptionsEditorControl.js.map +1 -1
  67. package/dist/OptionsEditorLayout/OptionsEditorGrid.js.map +1 -1
  68. package/dist/OptionsEditorLayout/OptionsEditorGroup.js.map +1 -1
  69. package/dist/OptionsEditorLayout/index.js.map +1 -1
  70. package/dist/RefreshIntervalPicker/RefreshIntervalPicker.js.map +1 -1
  71. package/dist/RefreshIntervalPicker/index.js.map +1 -1
  72. package/dist/SettingsAutocomplete/SettingsAutocomplete.js +2 -2
  73. package/dist/SettingsAutocomplete/SettingsAutocomplete.js.map +1 -1
  74. package/dist/SettingsAutocomplete/index.js.map +1 -1
  75. package/dist/SortSelector/SortSelector.js.map +1 -1
  76. package/dist/SortSelector/index.js.map +1 -1
  77. package/dist/StatChart/StatChart.d.ts +2 -2
  78. package/dist/StatChart/StatChart.d.ts.map +1 -1
  79. package/dist/StatChart/StatChart.js +7 -7
  80. package/dist/StatChart/StatChart.js.map +1 -1
  81. package/dist/StatChart/calculateFontSize.js +4 -4
  82. package/dist/StatChart/calculateFontSize.js.map +1 -1
  83. package/dist/StatChart/index.js.map +1 -1
  84. package/dist/Table/InnerTable.js.map +1 -1
  85. package/dist/Table/Table.js.map +1 -1
  86. package/dist/Table/TableBody.js.map +1 -1
  87. package/dist/Table/TableCell.js +2 -2
  88. package/dist/Table/TableCell.js.map +1 -1
  89. package/dist/Table/TableCheckbox.js.map +1 -1
  90. package/dist/Table/TableHead.js.map +1 -1
  91. package/dist/Table/TableHeaderCell.js.map +1 -1
  92. package/dist/Table/TableRow.js.map +1 -1
  93. package/dist/Table/VirtualizedTable.js +6 -6
  94. package/dist/Table/VirtualizedTable.js.map +1 -1
  95. package/dist/Table/VirtualizedTableContainer.js.map +1 -1
  96. package/dist/Table/hooks/useTableKeyboardNav.js.map +1 -1
  97. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js +20 -20
  98. package/dist/Table/hooks/useVirtualizedTableKeyboardNav.js.map +1 -1
  99. package/dist/Table/index.js.map +1 -1
  100. package/dist/Table/model/table-model.js +9 -9
  101. package/dist/Table/model/table-model.js.map +1 -1
  102. package/dist/ThresholdsEditor/ThresholdColorPicker.js +1 -1
  103. package/dist/ThresholdsEditor/ThresholdColorPicker.js.map +1 -1
  104. package/dist/ThresholdsEditor/ThresholdInput.js +1 -1
  105. package/dist/ThresholdsEditor/ThresholdInput.js.map +1 -1
  106. package/dist/ThresholdsEditor/ThresholdsEditor.js +17 -17
  107. package/dist/ThresholdsEditor/ThresholdsEditor.js.map +1 -1
  108. package/dist/ThresholdsEditor/index.js.map +1 -1
  109. package/dist/TimeChart/TimeChart.d.ts +2 -2
  110. package/dist/TimeChart/TimeChart.d.ts.map +1 -1
  111. package/dist/TimeChart/TimeChart.js +12 -12
  112. package/dist/TimeChart/TimeChart.js.map +1 -1
  113. package/dist/TimeChart/index.js.map +1 -1
  114. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts +2 -2
  115. package/dist/TimeSeriesTooltip/LineChartTooltip.d.ts.map +1 -1
  116. package/dist/TimeSeriesTooltip/LineChartTooltip.js +7 -7
  117. package/dist/TimeSeriesTooltip/LineChartTooltip.js.map +1 -1
  118. package/dist/TimeSeriesTooltip/SeriesInfo.js +2 -2
  119. package/dist/TimeSeriesTooltip/SeriesInfo.js.map +1 -1
  120. package/dist/TimeSeriesTooltip/SeriesLabelsStack.js.map +1 -1
  121. package/dist/TimeSeriesTooltip/SeriesMarker.js.map +1 -1
  122. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts +2 -2
  123. package/dist/TimeSeriesTooltip/TimeChartTooltip.d.ts.map +1 -1
  124. package/dist/TimeSeriesTooltip/TimeChartTooltip.js +4 -4
  125. package/dist/TimeSeriesTooltip/TimeChartTooltip.js.map +1 -1
  126. package/dist/TimeSeriesTooltip/TooltipContent.js.map +1 -1
  127. package/dist/TimeSeriesTooltip/TooltipHeader.js +6 -6
  128. package/dist/TimeSeriesTooltip/TooltipHeader.js.map +1 -1
  129. package/dist/TimeSeriesTooltip/index.js.map +1 -1
  130. package/dist/TimeSeriesTooltip/nearby-series.d.ts +7 -7
  131. package/dist/TimeSeriesTooltip/nearby-series.d.ts.map +1 -1
  132. package/dist/TimeSeriesTooltip/nearby-series.js +29 -29
  133. package/dist/TimeSeriesTooltip/nearby-series.js.map +1 -1
  134. package/dist/TimeSeriesTooltip/tooltip-model.js.map +1 -1
  135. package/dist/TimeSeriesTooltip/utils.js +3 -3
  136. package/dist/TimeSeriesTooltip/utils.js.map +1 -1
  137. package/dist/YAxisLabel.js.map +1 -1
  138. package/dist/cjs/BarChart/BarChart.js +17 -15
  139. package/dist/cjs/BarChart/index.js +10 -8
  140. package/dist/cjs/ColorPicker/ColorPicker.js +15 -13
  141. package/dist/cjs/ColorPicker/index.js +10 -8
  142. package/dist/cjs/ContentWithLegend/ContentWithLegend.js +12 -10
  143. package/dist/cjs/ContentWithLegend/index.js +10 -8
  144. package/dist/cjs/ContentWithLegend/model/content-with-legend-model.js +27 -23
  145. package/dist/cjs/DateTimeRangePicker/AbsoluteTimePicker.js +29 -43
  146. package/dist/cjs/DateTimeRangePicker/DateTimeRangePicker.js +12 -10
  147. package/dist/cjs/DateTimeRangePicker/TimeRangeSelector.js +13 -11
  148. package/dist/cjs/DateTimeRangePicker/index.js +12 -10
  149. package/dist/cjs/DateTimeRangePicker/utils.js +9 -5
  150. package/dist/cjs/Dialog/Dialog.js +15 -13
  151. package/dist/cjs/Dialog/DiscardChangesConfirmationDialog.js +11 -9
  152. package/dist/cjs/Dialog/index.js +11 -9
  153. package/dist/cjs/Drawer/Drawer.js +5 -3
  154. package/dist/cjs/Drawer/index.js +10 -8
  155. package/dist/cjs/EChart/EChart.js +12 -10
  156. package/dist/cjs/EChart/index.js +10 -8
  157. package/dist/cjs/ErrorAlert.js +5 -3
  158. package/dist/cjs/ErrorBoundary.js +4 -2
  159. package/dist/cjs/FontSizeSelector/FontSizeSelector.js +8 -6
  160. package/dist/cjs/FontSizeSelector/index.js +10 -8
  161. package/dist/cjs/{UnitSelector/UnitSelector.js → FormatControls/FormatControls.js} +38 -36
  162. package/dist/cjs/{UnitSelector → FormatControls}/index.js +10 -8
  163. package/dist/cjs/GaugeChart/GaugeChart.js +22 -18
  164. package/dist/cjs/GaugeChart/index.js +10 -8
  165. package/dist/cjs/InfoTooltip/InfoTooltip.js +13 -11
  166. package/dist/cjs/InfoTooltip/index.js +10 -8
  167. package/dist/cjs/JSONEditor.js +10 -8
  168. package/dist/cjs/Legend/CompactLegend.js +9 -7
  169. package/dist/cjs/Legend/Legend.js +15 -13
  170. package/dist/cjs/Legend/LegendColorBadge.js +7 -5
  171. package/dist/cjs/Legend/ListLegend.js +10 -8
  172. package/dist/cjs/Legend/ListLegendItem.js +12 -10
  173. package/dist/cjs/Legend/TableLegend.js +7 -5
  174. package/dist/cjs/Legend/index.js +11 -9
  175. package/dist/cjs/Legend/legend-model.js +3 -1
  176. package/dist/cjs/LineChart/LineChart.js +24 -22
  177. package/dist/cjs/LineChart/index.js +10 -8
  178. package/dist/cjs/ModeSelector/ModeSelector.js +8 -6
  179. package/dist/cjs/ModeSelector/index.js +10 -8
  180. package/dist/cjs/OptionsEditorLayout/OptionsEditorColumn.js +6 -4
  181. package/dist/cjs/OptionsEditorLayout/OptionsEditorControl.js +16 -14
  182. package/dist/cjs/OptionsEditorLayout/OptionsEditorGrid.js +5 -3
  183. package/dist/cjs/OptionsEditorLayout/OptionsEditorGroup.js +11 -9
  184. package/dist/cjs/OptionsEditorLayout/index.js +13 -11
  185. package/dist/cjs/RefreshIntervalPicker/RefreshIntervalPicker.js +8 -6
  186. package/dist/cjs/RefreshIntervalPicker/index.js +10 -8
  187. package/dist/cjs/SettingsAutocomplete/SettingsAutocomplete.js +12 -10
  188. package/dist/cjs/SettingsAutocomplete/index.js +10 -8
  189. package/dist/cjs/SortSelector/SortSelector.js +8 -6
  190. package/dist/cjs/SortSelector/index.js +10 -8
  191. package/dist/cjs/StatChart/StatChart.js +20 -18
  192. package/dist/cjs/StatChart/calculateFontSize.js +9 -7
  193. package/dist/cjs/StatChart/index.js +10 -8
  194. package/dist/cjs/Table/InnerTable.js +5 -3
  195. package/dist/cjs/Table/Table.js +15 -13
  196. package/dist/cjs/Table/TableBody.js +5 -3
  197. package/dist/cjs/Table/TableCell.js +10 -8
  198. package/dist/cjs/Table/TableCheckbox.js +5 -3
  199. package/dist/cjs/Table/TableHead.js +5 -3
  200. package/dist/cjs/Table/TableHeaderCell.js +8 -6
  201. package/dist/cjs/Table/TableRow.js +5 -3
  202. package/dist/cjs/Table/VirtualizedTable.js +32 -30
  203. package/dist/cjs/Table/VirtualizedTableContainer.js +5 -3
  204. package/dist/cjs/Table/hooks/useTableKeyboardNav.js +3 -1
  205. package/dist/cjs/Table/hooks/useVirtualizedTableKeyboardNav.js +23 -21
  206. package/dist/cjs/Table/index.js +14 -10
  207. package/dist/cjs/Table/model/table-model.js +15 -11
  208. package/dist/cjs/ThresholdsEditor/ThresholdColorPicker.js +15 -13
  209. package/dist/cjs/ThresholdsEditor/ThresholdInput.js +14 -12
  210. package/dist/cjs/ThresholdsEditor/ThresholdsEditor.js +44 -42
  211. package/dist/cjs/ThresholdsEditor/index.js +10 -8
  212. package/dist/cjs/TimeChart/TimeChart.js +31 -29
  213. package/dist/cjs/TimeChart/index.js +10 -8
  214. package/dist/cjs/TimeSeriesTooltip/LineChartTooltip.js +28 -26
  215. package/dist/cjs/TimeSeriesTooltip/SeriesInfo.js +17 -15
  216. package/dist/cjs/TimeSeriesTooltip/SeriesLabelsStack.js +15 -13
  217. package/dist/cjs/TimeSeriesTooltip/SeriesMarker.js +5 -3
  218. package/dist/cjs/TimeSeriesTooltip/TimeChartTooltip.js +22 -20
  219. package/dist/cjs/TimeSeriesTooltip/TooltipContent.js +7 -5
  220. package/dist/cjs/TimeSeriesTooltip/TooltipHeader.js +34 -32
  221. package/dist/cjs/TimeSeriesTooltip/index.js +19 -17
  222. package/dist/cjs/TimeSeriesTooltip/nearby-series.js +56 -38
  223. package/dist/cjs/TimeSeriesTooltip/tooltip-model.js +51 -17
  224. package/dist/cjs/TimeSeriesTooltip/utils.js +17 -13
  225. package/dist/cjs/YAxisLabel.js +6 -4
  226. package/dist/cjs/context/ChartsProvider.js +16 -8
  227. package/dist/cjs/context/SnackbarProvider.js +6 -2
  228. package/dist/cjs/context/TimeZoneProvider.js +13 -7
  229. package/dist/cjs/context/index.js +12 -10
  230. package/dist/cjs/index.js +41 -39
  231. package/dist/cjs/model/graph.js +9 -3
  232. package/dist/cjs/model/index.js +12 -10
  233. package/dist/cjs/test/index.js +10 -8
  234. package/dist/cjs/test/render.js +7 -5
  235. package/dist/cjs/test-utils/index.js +10 -8
  236. package/dist/cjs/test-utils/theme.js +6 -2
  237. package/dist/cjs/theme/component-overrides/alert.js +3 -1
  238. package/dist/cjs/theme/component-overrides/paper.js +3 -1
  239. package/dist/cjs/theme/index.js +10 -8
  240. package/dist/cjs/theme/palette/background.js +6 -2
  241. package/dist/cjs/theme/palette/colors/blue.js +3 -1
  242. package/dist/cjs/theme/palette/colors/common.js +6 -2
  243. package/dist/cjs/theme/palette/colors/green.js +3 -1
  244. package/dist/cjs/theme/palette/colors/grey.js +3 -1
  245. package/dist/cjs/theme/palette/colors/index.js +17 -15
  246. package/dist/cjs/theme/palette/colors/orange.js +3 -1
  247. package/dist/cjs/theme/palette/colors/purple.js +3 -1
  248. package/dist/cjs/theme/palette/colors/red.js +3 -1
  249. package/dist/cjs/theme/palette/error.js +3 -1
  250. package/dist/cjs/theme/palette/grey.js +3 -1
  251. package/dist/cjs/theme/palette/index.js +10 -8
  252. package/dist/cjs/theme/palette/palette-options.js +3 -1
  253. package/dist/cjs/theme/palette/primary.js +3 -1
  254. package/dist/cjs/theme/palette/secondary.js +3 -1
  255. package/dist/cjs/theme/palette/success.js +3 -1
  256. package/dist/cjs/theme/palette/text.js +3 -1
  257. package/dist/cjs/theme/palette/warning.js +3 -1
  258. package/dist/cjs/theme/theme.js +5 -3
  259. package/dist/cjs/theme/typography.js +3 -1
  260. package/dist/cjs/utils/axis.js +8 -4
  261. package/dist/cjs/utils/chart-actions.js +26 -10
  262. package/dist/cjs/utils/combine-sx.js +3 -1
  263. package/dist/cjs/utils/component-ids.js +3 -1
  264. package/dist/cjs/utils/format.js +16 -8
  265. package/dist/cjs/utils/index.js +15 -13
  266. package/dist/cjs/utils/mathjs.js +3 -1
  267. package/dist/cjs/utils/theme-gen.js +12 -10
  268. package/dist/context/ChartsProvider.js.map +1 -1
  269. package/dist/context/SnackbarProvider.js.map +1 -1
  270. package/dist/context/TimeZoneProvider.js.map +1 -1
  271. package/dist/context/index.js.map +1 -1
  272. package/dist/index.d.ts +1 -1
  273. package/dist/index.d.ts.map +1 -1
  274. package/dist/index.js +1 -1
  275. package/dist/index.js.map +1 -1
  276. package/dist/model/graph.js.map +1 -1
  277. package/dist/model/index.js.map +1 -1
  278. package/dist/test/index.js.map +1 -1
  279. package/dist/test/render.js.map +1 -1
  280. package/dist/test/setup-tests.js.map +1 -1
  281. package/dist/test-utils/index.js.map +1 -1
  282. package/dist/test-utils/theme.js.map +1 -1
  283. package/dist/theme/component-overrides/alert.js.map +1 -1
  284. package/dist/theme/component-overrides/paper.js.map +1 -1
  285. package/dist/theme/index.d.ts +1 -0
  286. package/dist/theme/index.d.ts.map +1 -1
  287. package/dist/theme/index.js.map +1 -1
  288. package/dist/theme/palette/background.d.ts.map +1 -1
  289. package/dist/theme/palette/background.js +3 -1
  290. package/dist/theme/palette/background.js.map +1 -1
  291. package/dist/theme/palette/colors/blue.js.map +1 -1
  292. package/dist/theme/palette/colors/common.js.map +1 -1
  293. package/dist/theme/palette/colors/green.js.map +1 -1
  294. package/dist/theme/palette/colors/grey.js.map +1 -1
  295. package/dist/theme/palette/colors/index.js.map +1 -1
  296. package/dist/theme/palette/colors/orange.js.map +1 -1
  297. package/dist/theme/palette/colors/purple.js.map +1 -1
  298. package/dist/theme/palette/colors/red.js.map +1 -1
  299. package/dist/theme/palette/error.js.map +1 -1
  300. package/dist/theme/palette/grey.js.map +1 -1
  301. package/dist/theme/palette/index.js.map +1 -1
  302. package/dist/theme/palette/palette-options.js.map +1 -1
  303. package/dist/theme/palette/primary.js.map +1 -1
  304. package/dist/theme/palette/secondary.js.map +1 -1
  305. package/dist/theme/palette/success.js.map +1 -1
  306. package/dist/theme/palette/text.js.map +1 -1
  307. package/dist/theme/palette/warning.js.map +1 -1
  308. package/dist/theme/theme.js.map +1 -1
  309. package/dist/theme/typography.js.map +1 -1
  310. package/dist/utils/axis.d.ts +2 -2
  311. package/dist/utils/axis.d.ts.map +1 -1
  312. package/dist/utils/axis.js.map +1 -1
  313. package/dist/utils/chart-actions.js +2 -2
  314. package/dist/utils/chart-actions.js.map +1 -1
  315. package/dist/utils/combine-sx.js.map +1 -1
  316. package/dist/utils/component-ids.js.map +1 -1
  317. package/dist/utils/format.js.map +1 -1
  318. package/dist/utils/index.js.map +1 -1
  319. package/dist/utils/mathjs.js.map +1 -1
  320. package/dist/utils/theme-gen.js +7 -7
  321. package/dist/utils/theme-gen.js.map +1 -1
  322. package/package.json +7 -6
  323. package/dist/UnitSelector/UnitSelector.d.ts +0 -9
  324. package/dist/UnitSelector/UnitSelector.d.ts.map +0 -1
  325. package/dist/UnitSelector/UnitSelector.js.map +0 -1
  326. package/dist/UnitSelector/index.d.ts +0 -2
  327. package/dist/UnitSelector/index.d.ts.map +0 -1
  328. package/dist/UnitSelector/index.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeChart/TimeChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { forwardRef, MouseEvent, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport merge from 'lodash/merge';\nimport isEqual from 'lodash/isEqual';\nimport { DatasetOption } from 'echarts/types/dist/shared';\nimport { utcToZonedTime } from 'date-fns-tz';\nimport { getCommonTimeScale, TimeScale, UnitOptions, TimeSeries } from '@perses-dev/core';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart, BarChart as EChartsBarChart } from 'echarts/charts';\nimport {\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { ChartInstanceFocusOpts, ChartInstance, TimeChartSeriesMapping, DEFAULT_PINNED_CROSSHAIR } from '../model';\nimport { useChartsContext } from '../context/ChartsProvider';\nimport {\n clearHighlightedSeries,\n enableDataZoom,\n getClosestTimestamp,\n getFormattedAxisLabel,\n getPointInGrid,\n getFormattedAxis,\n restoreChart,\n ZoomEventData,\n} from '../utils';\nimport { CursorCoordinates, TimeChartTooltip, TooltipConfig, DEFAULT_TOOLTIP_CONFIG } from '../TimeSeriesTooltip';\nimport { useTimeZone } from '../context/TimeZoneProvider';\n\nuse([\n EChartsLineChart,\n EChartsBarChart,\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nexport interface TimeChartProps {\n height: number;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n timeScale?: TimeScale;\n yAxis?: YAXisComponentOption;\n unit?: UnitOptions;\n grid?: GridComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n isStackedBar?: boolean;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const TimeChart = forwardRef<ChartInstance, TimeChartProps>(function TimeChart(\n {\n height,\n data,\n seriesMapping,\n timeScale: timeScaleProp,\n yAxis,\n unit,\n grid,\n isStackedBar = false,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref\n) {\n const { chartsTheme, enablePinning, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } = useChartsContext();\n const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const [pinnedCrosshair, setPinnedCrosshair] = useState<LineSeriesOption | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n const { timeZone } = useTimeZone();\n const totalSeries = data?.length ?? 0;\n let timeScale: TimeScale;\n if (timeScaleProp === undefined) {\n const commonTimeScale = getCommonTimeScale(data);\n if (commonTimeScale === undefined) {\n // set default to past 5 years\n const today = new Date();\n const pastDate = new Date(today);\n pastDate.setFullYear(today.getFullYear() - 5);\n const todayMs = today.getTime();\n const pastDateMs = pastDate.getTime();\n timeScale = { startMs: pastDateMs, endMs: todayMs, stepMs: 1, rangeMs: todayMs - pastDateMs };\n } else {\n timeScale = commonTimeScale;\n }\n } else {\n timeScale = timeScaleProp;\n }\n\n useImperativeHandle(\n ref,\n () => {\n return {\n highlightSeries({ name }: ChartInstanceFocusOpts) {\n if (!chartRef.current) {\n // when chart undef, do not highlight series when hovering over legend\n return;\n }\n\n chartRef.current.dispatchAction({ type: 'highlight', seriesId: name });\n },\n clearHighlightedSeries: () => {\n if (!chartRef.current) {\n // when chart undef, do not clear highlight series\n return;\n }\n clearHighlightedSeries(chartRef.current, totalSeries);\n },\n };\n },\n [totalSeries]\n );\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setTooltipPinnedCoords(null);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const xAxisStartValue = params.batch[0].startValue;\n const xAxisEndValue = params.batch[0].endValue;\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n };\n onDataZoom(zoomEvent);\n }\n },\n finished: () => {\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n },\n };\n }, [onDataZoom, setTooltipPinnedCoords]);\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data === null || (data.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n // Utilizes ECharts dataset so raw data is separate from series option style properties\n // https://apache.github.io/echarts-handbook/en/concepts/dataset/\n const dataset: DatasetOption[] = [];\n const isLocalTimeZone = timeZone === 'local';\n data.map((d, index) => {\n const values = d.values.map(([timestamp, value]) => {\n const val: string | number = value === null ? '-' : value; // echarts use '-' to represent null data\n return [isLocalTimeZone ? timestamp : utcToZonedTime(timestamp, timeZone), val];\n });\n dataset.push({ id: index, source: [...values], dimensions: ['time', 'value'] });\n });\n\n const updatedSeriesMapping =\n enablePinning && pinnedCrosshair !== null ? [...seriesMapping, pinnedCrosshair] : seriesMapping;\n\n const option: EChartsCoreOption = {\n dataset: dataset,\n series: updatedSeriesMapping,\n xAxis: {\n type: 'time',\n min: isLocalTimeZone ? timeScale.startMs : utcToZonedTime(timeScale.startMs, timeZone),\n max: isLocalTimeZone ? timeScale.endMs : utcToZonedTime(timeScale.endMs, timeZone),\n axisLabel: {\n hideOverlap: true,\n formatter: getFormattedAxisLabel(timeScale.rangeMs ?? 0),\n },\n axisPointer: {\n snap: false, // important so shared crosshair does not lag\n },\n },\n yAxis: getFormattedAxis(yAxis, unit),\n animation: false,\n tooltip: {\n show: true,\n // ECharts tooltip content hidden by default since we use custom tooltip instead.\n // Stacked bar uses ECharts tooltip so subgroup data shows correctly.\n showContent: isStackedBar,\n trigger: isStackedBar ? 'item' : 'axis',\n appendToBody: true,\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: false, // xAxis.axisPointer.snap takes priority\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n\n return option;\n }, [\n data,\n seriesMapping,\n timeScale,\n yAxis,\n unit,\n grid,\n noDataOption,\n __experimentalEChartsOptionsOverride,\n noDataVariant,\n timeZone,\n isStackedBar,\n enablePinning,\n pinnedCrosshair,\n ]);\n\n // Update adjacent charts so tooltip is unpinned when current chart is clicked.\n useEffect(() => {\n // Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.\n // Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.\n const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;\n if (multipleTooltipsPinned) {\n if (!isEqual(lastTooltipPinnedCoords, tooltipPinnedCoords)) {\n setTooltipPinnedCoords(null);\n if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {\n setPinnedCrosshair(null);\n }\n }\n }\n // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastTooltipPinnedCoords, seriesMapping]);\n\n return (\n <Box\n sx={{ height }}\n // onContextMenu={(e) => {\n // // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here\n // e.preventDefault(); // Prevent the default behaviour when right clicked\n // }}\n onClick={(e) => {\n // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down\n const isControlKeyPressed = e.ctrlKey || e.metaKey;\n if (isControlKeyPressed) {\n e.preventDefault();\n }\n\n // Determine where on chart canvas to plot pinned crosshair as markLine.\n const pointInGrid = getPointInGrid(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);\n if (pointInGrid === null) {\n return;\n }\n\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {\n // Pin tooltip and update shared charts context to remember these coordinates.\n const pinnedPos: CursorCoordinates = {\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.nativeEvent.offsetX,\n y: e.nativeEvent.offsetY,\n },\n target: e.target,\n };\n\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return pinnedPos;\n } else {\n setPinnedCrosshair(null);\n return null;\n }\n });\n\n setPinnedCrosshair((current) => {\n // Only add pinned crosshair line series when there is not one already in seriesMapping.\n if (current === null) {\n const cursorX = pointInGrid[0];\n\n // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent\n const firstTimeSeriesValues = data[0]?.values;\n const closestTimestamp = getClosestTimestamp(firstTimeSeriesValues, cursorX);\n\n // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right\n const pinnedCrosshair = merge({}, DEFAULT_PINNED_CROSSHAIR, {\n markLine: {\n data: [\n {\n xAxis: closestTimestamp,\n },\n ],\n },\n } as LineSeriesOption);\n return pinnedCrosshair;\n } else {\n // Clear previously set pinned crosshair\n return null;\n }\n });\n\n if (!isControlKeyPressed) {\n setLastTooltipPinnedCoords(pinnedPos);\n }\n }\n }}\n onMouseDown={(e) => {\n const { clientX } = e;\n setIsDragging(true);\n setStartX(clientX);\n }}\n onMouseMove={(e) => {\n // Allow clicking inside tooltip to copy labels.\n if (!(e.target instanceof HTMLCanvasElement)) {\n return;\n }\n const { clientX } = e;\n if (isDragging) {\n const deltaX = clientX - startX;\n if (deltaX > 0) {\n // Hide tooltip when user drags to zoom.\n setShowTooltip(false);\n }\n }\n }}\n onMouseUp={() => {\n setIsDragging(false);\n setStartX(0);\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n if (tooltipPinnedCoords === null) {\n setShowTooltip(false);\n }\n if (chartRef.current !== undefined) {\n clearHighlightedSeries(chartRef.current, totalSeries);\n }\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={(e) => {\n setTooltipPinnedCoords(null);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n }}\n >\n {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead */}\n {showTooltip === true &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeChartTooltip\n containerId={chartsTheme.tooltipPortalContainerId}\n chartRef={chartRef}\n data={data}\n seriesMapping={seriesMapping}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={isPinningEnabled}\n pinnedPos={tooltipPinnedCoords}\n unit={unit}\n onUnpinClick={() => {\n // Unpins tooltip when clicking Pin icon in TooltipHeader.\n setTooltipPinnedCoords(null);\n // Clear previously set pinned crosshair.\n setPinnedCrosshair(null);\n }}\n />\n )}\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n syncGroup={syncGroup}\n />\n </Box>\n );\n});\n"],"names":["forwardRef","useEffect","useImperativeHandle","useMemo","useRef","useState","Box","merge","isEqual","utcToZonedTime","getCommonTimeScale","use","LineChart","EChartsLineChart","BarChart","EChartsBarChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","CanvasRenderer","EChart","DEFAULT_PINNED_CROSSHAIR","useChartsContext","clearHighlightedSeries","enableDataZoom","getClosestTimestamp","getFormattedAxisLabel","getPointInGrid","getFormattedAxis","restoreChart","TimeChartTooltip","DEFAULT_TOOLTIP_CONFIG","useTimeZone","TimeChart","height","data","seriesMapping","timeScale","timeScaleProp","yAxis","unit","grid","isStackedBar","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","option","chartsTheme","enablePinning","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","isPinningEnabled","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","pinnedCrosshair","setPinnedCrosshair","isDragging","setIsDragging","startX","setStartX","timeZone","totalSeries","length","undefined","commonTimeScale","today","Date","pastDate","setFullYear","getFullYear","todayMs","getTime","pastDateMs","startMs","endMs","stepMs","rangeMs","highlightSeries","name","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","setTimeout","batch","xAxisStartValue","startValue","xAxisEndValue","endValue","zoomEvent","start","end","finished","noDataOption","dataset","isLocalTimeZone","map","d","index","values","timestamp","value","val","push","id","source","dimensions","updatedSeriesMapping","series","xAxis","min","max","axisLabel","hideOverlap","formatter","axisPointer","snap","animation","tooltip","show","showContent","trigger","appendToBody","z","triggerEmphasis","triggerTooltip","toolbox","feature","dataZoom","icon","yAxisIndex","multipleTooltipsPinned","sx","onClick","e","isControlKeyPressed","ctrlKey","metaKey","preventDefault","pointInGrid","nativeEvent","offsetX","offsetY","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","width","theme","echartsTheme","onEvents","_instance"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,UAAU,EAAcC,SAAS,EAAEC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC1G,SAASC,GAAG,QAAQ,eAAe,CAAC;AACpC,OAAOC,KAAK,MAAM,cAAc,CAAC;AACjC,OAAOC,OAAO,MAAM,gBAAgB,CAAC;AAErC,SAASC,cAAc,QAAQ,aAAa,CAAC;AAC7C,SAASC,kBAAkB,QAA4C,kBAAkB,CAAC;AAQ1F,SAAqCC,GAAG,QAAQ,cAAc,CAAC;AAC/D,SAASC,SAAS,IAAIC,gBAAgB,EAAEC,QAAQ,IAAIC,eAAe,QAAQ,gBAAgB,CAAC;AAC5F,SACEC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,QACX,oBAAoB,CAAC;AAC5B,SAASC,cAAc,QAAQ,mBAAmB,CAAC;AACnD,SAASC,MAAM,QAAsB,WAAW,CAAC;AACjD,SAAwEC,wBAAwB,QAAQ,UAAU,CAAC;AACnH,SAASC,gBAAgB,QAAQ,2BAA2B,CAAC;AAC7D,SACEC,sBAAsB,EACtBC,cAAc,EACdC,mBAAmB,EACnBC,qBAAqB,EACrBC,cAAc,E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AAd9E,IAAc,WAAwC,GAAvD,KAAA,CAAuD,GAAtDA,IAAc,CAA6BgF,WAAW,CAAA,KAAK,KAAK,IACjEvF,aAAa,CAACoI,MAAM,KAAK,IAAI,kBAC3B,KAACjJ,gBAAgB;gBACfkJ,WAAW,EAAE7H,WAAW,CAAC8H,wBAAwB;gBACjDzH,QAAQ,EAAEA,QAAQ;gBAClBrB,IAAI,EAAEA,IAAI;gBACVC,aAAa,EAAEA,aAAa;gBAC5B8I,UAAU,EAAEvI,aAAa,CAACuI,UAAU;gBACpC9H,aAAa,EAAEG,gBAAgB;gBAC/BoG,SAAS,EAAEhG,mBAAmB;gBAC9BnB,IAAI,EAAEA,IAAI;gBACV2I,YAAY,EAAE,IAAM;oBAClB,0DAA0D;oBAC1DvH,sBAAsB,CAAC,IAAI,CAAC,CAAC;oBAC7B,yCAAyC;oBACzCE,kBAAkB,CAAC,IAAI,CAAC,CAAC;gBAC3B,CAAC;cACD,AACH;0BACH,KAAC1C,MAAM;gBACL0H,EAAE,EAAE;oBACFsC,KAAK,EAAE,MAAM;oBACblJ,MAAM,EAAE,MAAM;iBACf;gBACDgB,MAAM,EAAEA,MAAM;gBACdmI,KAAK,EAAElI,WAAW,CAACmI,YAAY;gBAC/BC,QAAQ,EAAE7F,YAAY;gBACtB8F,SAAS,EAAEhI,QAAQ;gBACnBX,SAAS,EAAEA,SAAS;cACpB;;MACE,CACN;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeChart/TimeChart.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { forwardRef, MouseEvent, useEffect, useImperativeHandle, useMemo, useRef, useState } from 'react';\nimport { Box } from '@mui/material';\nimport merge from 'lodash/merge';\nimport isEqual from 'lodash/isEqual';\nimport { DatasetOption } from 'echarts/types/dist/shared';\nimport { utcToZonedTime } from 'date-fns-tz';\nimport { getCommonTimeScale, TimeScale, FormatOptions, TimeSeries } from '@perses-dev/core';\nimport type {\n EChartsCoreOption,\n GridComponentOption,\n LineSeriesOption,\n YAXisComponentOption,\n TooltipComponentOption,\n} from 'echarts';\nimport { ECharts as EChartsInstance, use } from 'echarts/core';\nimport { LineChart as EChartsLineChart, BarChart as EChartsBarChart } from 'echarts/charts';\nimport {\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n} from 'echarts/components';\nimport { CanvasRenderer } from 'echarts/renderers';\nimport { EChart, OnEventsType } from '../EChart';\nimport { ChartInstanceFocusOpts, ChartInstance, TimeChartSeriesMapping, DEFAULT_PINNED_CROSSHAIR } from '../model';\nimport { useChartsContext } from '../context/ChartsProvider';\nimport {\n clearHighlightedSeries,\n enableDataZoom,\n getClosestTimestamp,\n getFormattedAxisLabel,\n getPointInGrid,\n getFormattedAxis,\n restoreChart,\n ZoomEventData,\n} from '../utils';\nimport { CursorCoordinates, TimeChartTooltip, TooltipConfig, DEFAULT_TOOLTIP_CONFIG } from '../TimeSeriesTooltip';\nimport { useTimeZone } from '../context/TimeZoneProvider';\n\nuse([\n EChartsLineChart,\n EChartsBarChart,\n GridComponent,\n DatasetComponent,\n DataZoomComponent,\n MarkAreaComponent,\n MarkLineComponent,\n MarkPointComponent,\n TitleComponent,\n ToolboxComponent,\n TooltipComponent,\n CanvasRenderer,\n]);\n\nexport interface TimeChartProps {\n height: number;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n timeScale?: TimeScale;\n yAxis?: YAXisComponentOption;\n format?: FormatOptions;\n grid?: GridComponentOption;\n tooltipConfig?: TooltipConfig;\n noDataVariant?: 'chart' | 'message';\n syncGroup?: string;\n isStackedBar?: boolean;\n onDataZoom?: (e: ZoomEventData) => void;\n onDoubleClick?: (e: MouseEvent) => void;\n __experimentalEChartsOptionsOverride?: (options: EChartsCoreOption) => EChartsCoreOption;\n}\n\nexport const TimeChart = forwardRef<ChartInstance, TimeChartProps>(function TimeChart(\n {\n height,\n data,\n seriesMapping,\n timeScale: timeScaleProp,\n yAxis,\n format,\n grid,\n isStackedBar = false,\n tooltipConfig = DEFAULT_TOOLTIP_CONFIG,\n noDataVariant = 'message',\n syncGroup,\n onDataZoom,\n onDoubleClick,\n __experimentalEChartsOptionsOverride,\n },\n ref\n) {\n const { chartsTheme, enablePinning, lastTooltipPinnedCoords, setLastTooltipPinnedCoords } = useChartsContext();\n const isPinningEnabled = tooltipConfig.enablePinning && enablePinning;\n const chartRef = useRef<EChartsInstance>();\n const [showTooltip, setShowTooltip] = useState<boolean>(true);\n const [tooltipPinnedCoords, setTooltipPinnedCoords] = useState<CursorCoordinates | null>(null);\n const [pinnedCrosshair, setPinnedCrosshair] = useState<LineSeriesOption | null>(null);\n const [isDragging, setIsDragging] = useState(false);\n const [startX, setStartX] = useState(0);\n const { timeZone } = useTimeZone();\n const totalSeries = data?.length ?? 0;\n let timeScale: TimeScale;\n if (timeScaleProp === undefined) {\n const commonTimeScale = getCommonTimeScale(data);\n if (commonTimeScale === undefined) {\n // set default to past 5 years\n const today = new Date();\n const pastDate = new Date(today);\n pastDate.setFullYear(today.getFullYear() - 5);\n const todayMs = today.getTime();\n const pastDateMs = pastDate.getTime();\n timeScale = { startMs: pastDateMs, endMs: todayMs, stepMs: 1, rangeMs: todayMs - pastDateMs };\n } else {\n timeScale = commonTimeScale;\n }\n } else {\n timeScale = timeScaleProp;\n }\n\n useImperativeHandle(\n ref,\n () => {\n return {\n highlightSeries({ name }: ChartInstanceFocusOpts) {\n if (!chartRef.current) {\n // when chart undef, do not highlight series when hovering over legend\n return;\n }\n\n chartRef.current.dispatchAction({ type: 'highlight', seriesId: name });\n },\n clearHighlightedSeries: () => {\n if (!chartRef.current) {\n // when chart undef, do not clear highlight series\n return;\n }\n clearHighlightedSeries(chartRef.current, totalSeries);\n },\n };\n },\n [totalSeries]\n );\n\n const handleEvents: OnEventsType<LineSeriesOption['data'] | unknown> = useMemo(() => {\n return {\n datazoom: (params) => {\n if (onDataZoom === undefined) {\n setTimeout(() => {\n // workaround so unpin happens after click event\n setTooltipPinnedCoords(null);\n }, 10);\n }\n if (onDataZoom === undefined || params.batch[0] === undefined) return;\n const xAxisStartValue = params.batch[0].startValue;\n const xAxisEndValue = params.batch[0].endValue;\n if (xAxisStartValue !== undefined && xAxisEndValue !== undefined) {\n const zoomEvent: ZoomEventData = {\n start: xAxisStartValue,\n end: xAxisEndValue,\n };\n onDataZoom(zoomEvent);\n }\n },\n finished: () => {\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n },\n };\n }, [onDataZoom, setTooltipPinnedCoords]);\n\n const { noDataOption } = chartsTheme;\n\n const option: EChartsCoreOption = useMemo(() => {\n // The \"chart\" `noDataVariant` is only used when the `timeSeries` is an\n // empty array because a `null` value will throw an error.\n if (data === null || (data.length === 0 && noDataVariant === 'message')) return noDataOption;\n\n // Utilizes ECharts dataset so raw data is separate from series option style properties\n // https://apache.github.io/echarts-handbook/en/concepts/dataset/\n const dataset: DatasetOption[] = [];\n const isLocalTimeZone = timeZone === 'local';\n data.map((d, index) => {\n const values = d.values.map(([timestamp, value]) => {\n const val: string | number = value === null ? '-' : value; // echarts use '-' to represent null data\n return [isLocalTimeZone ? timestamp : utcToZonedTime(timestamp, timeZone), val];\n });\n dataset.push({ id: index, source: [...values], dimensions: ['time', 'value'] });\n });\n\n const updatedSeriesMapping =\n enablePinning && pinnedCrosshair !== null ? [...seriesMapping, pinnedCrosshair] : seriesMapping;\n\n const option: EChartsCoreOption = {\n dataset: dataset,\n series: updatedSeriesMapping,\n xAxis: {\n type: 'time',\n min: isLocalTimeZone ? timeScale.startMs : utcToZonedTime(timeScale.startMs, timeZone),\n max: isLocalTimeZone ? timeScale.endMs : utcToZonedTime(timeScale.endMs, timeZone),\n axisLabel: {\n hideOverlap: true,\n formatter: getFormattedAxisLabel(timeScale.rangeMs ?? 0),\n },\n axisPointer: {\n snap: false, // important so shared crosshair does not lag\n },\n },\n yAxis: getFormattedAxis(yAxis, format),\n animation: false,\n tooltip: {\n show: true,\n // ECharts tooltip content hidden by default since we use custom tooltip instead.\n // Stacked bar uses ECharts tooltip so subgroup data shows correctly.\n showContent: isStackedBar,\n trigger: isStackedBar ? 'item' : 'axis',\n appendToBody: true,\n },\n // https://echarts.apache.org/en/option.html#axisPointer\n axisPointer: {\n type: 'line',\n z: 0, // ensure point symbol shows on top of dashed line\n triggerEmphasis: false, // https://github.com/apache/echarts/issues/18495\n triggerTooltip: false,\n snap: false, // xAxis.axisPointer.snap takes priority\n },\n toolbox: {\n feature: {\n dataZoom: {\n icon: null, // https://stackoverflow.com/a/67684076/17575201\n yAxisIndex: 'none',\n },\n },\n },\n grid,\n };\n\n if (__experimentalEChartsOptionsOverride) {\n return __experimentalEChartsOptionsOverride(option);\n }\n\n return option;\n }, [\n data,\n seriesMapping,\n timeScale,\n yAxis,\n format,\n grid,\n noDataOption,\n __experimentalEChartsOptionsOverride,\n noDataVariant,\n timeZone,\n isStackedBar,\n enablePinning,\n pinnedCrosshair,\n ]);\n\n // Update adjacent charts so tooltip is unpinned when current chart is clicked.\n useEffect(() => {\n // Only allow pinning one tooltip at a time, subsequent tooltip click unpins previous.\n // Multiple tooltips can only be pinned if Ctrl or Cmd key is pressed while clicking.\n const multipleTooltipsPinned = tooltipPinnedCoords !== null && lastTooltipPinnedCoords !== null;\n if (multipleTooltipsPinned) {\n if (!isEqual(lastTooltipPinnedCoords, tooltipPinnedCoords)) {\n setTooltipPinnedCoords(null);\n if (tooltipPinnedCoords !== null && pinnedCrosshair !== null) {\n setPinnedCrosshair(null);\n }\n }\n }\n // tooltipPinnedCoords CANNOT be in dep array or tooltip pinning breaks in the current chart's onClick\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [lastTooltipPinnedCoords, seriesMapping]);\n\n return (\n <Box\n sx={{ height }}\n // onContextMenu={(e) => {\n // // TODO: confirm tooltip pinning works correctly on Windows, should e.preventDefault() be added here\n // e.preventDefault(); // Prevent the default behaviour when right clicked\n // }}\n onClick={(e) => {\n // Allows user to opt-in to multi tooltip pinning when Ctrl or Cmd key held down\n const isControlKeyPressed = e.ctrlKey || e.metaKey;\n if (isControlKeyPressed) {\n e.preventDefault();\n }\n\n // Determine where on chart canvas to plot pinned crosshair as markLine.\n const pointInGrid = getPointInGrid(e.nativeEvent.offsetX, e.nativeEvent.offsetY, chartRef.current);\n if (pointInGrid === null) {\n return;\n }\n\n // Pin and unpin when clicking on chart canvas but not tooltip text.\n if (isPinningEnabled && e.target instanceof HTMLCanvasElement) {\n // Pin tooltip and update shared charts context to remember these coordinates.\n const pinnedPos: CursorCoordinates = {\n page: {\n x: e.pageX,\n y: e.pageY,\n },\n client: {\n x: e.clientX,\n y: e.clientY,\n },\n plotCanvas: {\n x: e.nativeEvent.offsetX,\n y: e.nativeEvent.offsetY,\n },\n target: e.target,\n };\n\n setTooltipPinnedCoords((current) => {\n if (current === null) {\n return pinnedPos;\n } else {\n setPinnedCrosshair(null);\n return null;\n }\n });\n\n setPinnedCrosshair((current) => {\n // Only add pinned crosshair line series when there is not one already in seriesMapping.\n if (current === null) {\n const cursorX = pointInGrid[0];\n\n // Only need to loop through first dataset source since getCommonTimeScale ensures xAxis timestamps are consistent\n const firstTimeSeriesValues = data[0]?.values;\n const closestTimestamp = getClosestTimestamp(firstTimeSeriesValues, cursorX);\n\n // Crosshair snaps to nearest timestamp since cursor may be slightly to left or right\n const pinnedCrosshair = merge({}, DEFAULT_PINNED_CROSSHAIR, {\n markLine: {\n data: [\n {\n xAxis: closestTimestamp,\n },\n ],\n },\n } as LineSeriesOption);\n return pinnedCrosshair;\n } else {\n // Clear previously set pinned crosshair\n return null;\n }\n });\n\n if (!isControlKeyPressed) {\n setLastTooltipPinnedCoords(pinnedPos);\n }\n }\n }}\n onMouseDown={(e) => {\n const { clientX } = e;\n setIsDragging(true);\n setStartX(clientX);\n }}\n onMouseMove={(e) => {\n // Allow clicking inside tooltip to copy labels.\n if (!(e.target instanceof HTMLCanvasElement)) {\n return;\n }\n const { clientX } = e;\n if (isDragging) {\n const deltaX = clientX - startX;\n if (deltaX > 0) {\n // Hide tooltip when user drags to zoom.\n setShowTooltip(false);\n }\n }\n }}\n onMouseUp={() => {\n setIsDragging(false);\n setStartX(0);\n setShowTooltip(true);\n }}\n onMouseLeave={() => {\n if (tooltipPinnedCoords === null) {\n setShowTooltip(false);\n }\n if (chartRef.current !== undefined) {\n clearHighlightedSeries(chartRef.current, totalSeries);\n }\n }}\n onMouseEnter={() => {\n setShowTooltip(true);\n if (chartRef.current !== undefined) {\n enableDataZoom(chartRef.current);\n }\n }}\n onDoubleClick={(e) => {\n setTooltipPinnedCoords(null);\n // either dispatch ECharts restore action to return to orig state or allow consumer to define behavior\n if (onDoubleClick === undefined) {\n if (chartRef.current !== undefined) {\n restoreChart(chartRef.current);\n }\n } else {\n onDoubleClick(e);\n }\n }}\n >\n {/* Allows overrides prop to hide custom tooltip and use the ECharts option.tooltip instead */}\n {showTooltip === true &&\n (option.tooltip as TooltipComponentOption)?.showContent === false &&\n tooltipConfig.hidden !== true && (\n <TimeChartTooltip\n containerId={chartsTheme.tooltipPortalContainerId}\n chartRef={chartRef}\n data={data}\n seriesMapping={seriesMapping}\n wrapLabels={tooltipConfig.wrapLabels}\n enablePinning={isPinningEnabled}\n pinnedPos={tooltipPinnedCoords}\n format={format}\n onUnpinClick={() => {\n // Unpins tooltip when clicking Pin icon in TooltipHeader.\n setTooltipPinnedCoords(null);\n // Clear previously set pinned crosshair.\n setPinnedCrosshair(null);\n }}\n />\n )}\n <EChart\n sx={{\n width: '100%',\n height: '100%',\n }}\n option={option}\n theme={chartsTheme.echartsTheme}\n onEvents={handleEvents}\n _instance={chartRef}\n syncGroup={syncGroup}\n />\n </Box>\n );\n});\n"],"names":["forwardRef","useEffect","useImperativeHandle","useMemo","useRef","useState","Box","merge","isEqual","utcToZonedTime","getCommonTimeScale","use","LineChart","EChartsLineChart","BarChart","EChartsBarChart","GridComponent","DatasetComponent","DataZoomComponent","MarkAreaComponent","MarkLineComponent","MarkPointComponent","TitleComponent","ToolboxComponent","TooltipComponent","CanvasRenderer","EChart","DEFAULT_PINNED_CROSSHAIR","useChartsContext","clearHighlightedSeries","enableDataZoom","getClosestTimestamp","getFormattedAxisLabel","getPointInGrid","getFormattedAxis","restoreChart","TimeChartTooltip","DEFAULT_TOOLTIP_CONFIG","useTimeZone","TimeChart","height","data","seriesMapping","timeScale","timeScaleProp","yAxis","format","grid","isStackedBar","tooltipConfig","noDataVariant","syncGroup","onDataZoom","onDoubleClick","__experimentalEChartsOptionsOverride","ref","option","chartsTheme","enablePinning","lastTooltipPinnedCoords","setLastTooltipPinnedCoords","isPinningEnabled","chartRef","showTooltip","setShowTooltip","tooltipPinnedCoords","setTooltipPinnedCoords","pinnedCrosshair","setPinnedCrosshair","isDragging","setIsDragging","startX","setStartX","timeZone","totalSeries","length","undefined","commonTimeScale","today","Date","pastDate","setFullYear","getFullYear","todayMs","getTime","pastDateMs","startMs","endMs","stepMs","rangeMs","highlightSeries","name","current","dispatchAction","type","seriesId","handleEvents","datazoom","params","setTimeout","batch","xAxisStartValue","startValue","xAxisEndValue","endValue","zoomEvent","start","end","finished","noDataOption","dataset","isLocalTimeZone","map","d","index","values","timestamp","value","val","push","id","source","dimensions","updatedSeriesMapping","series","xAxis","min","max","axisLabel","hideOverlap","formatter","axisPointer","snap","animation","tooltip","show","showContent","trigger","appendToBody","z","triggerEmphasis","triggerTooltip","toolbox","feature","dataZoom","icon","yAxisIndex","multipleTooltipsPinned","sx","onClick","e","isControlKeyPressed","ctrlKey","metaKey","preventDefault","pointInGrid","nativeEvent","offsetX","offsetY","target","HTMLCanvasElement","pinnedPos","page","x","pageX","y","pageY","client","clientX","clientY","plotCanvas","cursorX","firstTimeSeriesValues","closestTimestamp","markLine","onMouseDown","onMouseMove","deltaX","onMouseUp","onMouseLeave","onMouseEnter","hidden","containerId","tooltipPortalContainerId","wrapLabels","onUnpinClick","width","theme","echartsTheme","onEvents","_instance"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,UAAU,EAAcC,SAAS,EAAEC,mBAAmB,EAAEC,OAAO,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC1G,SAASC,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,WAAW,eAAe;AACjC,OAAOC,aAAa,iBAAiB;AAErC,SAASC,cAAc,QAAQ,cAAc;AAC7C,SAASC,kBAAkB,QAA8C,mBAAmB;AAQ5F,SAAqCC,GAAG,QAAQ,eAAe;AAC/D,SAASC,aAAaC,gBAAgB,EAAEC,YAAYC,eAAe,QAAQ,iBAAiB;AAC5F,SACEC,aAAa,EACbC,gBAAgB,EAChBC,iBAAiB,EACjBC,iBAAiB,EACjBC,iBAAiB,EACjBC,kBAAkB,EAClBC,cAAc,EACdC,gBAAgB,EAChBC,gBAAgB,QACX,qBAAqB;AAC5B,SAASC,cAAc,QAAQ,oBAAoB;AACnD,SAASC,MAAM,QAAsB,YAAY;AACjD,SAAwEC,wBAAwB,QAAQ,WAAW;AACnH,SAASC,gBAAgB,QAAQ,4BAA4B;AAC7D,SACEC,sBAAsB,EACtBC,cAAc,EACdC,mBAAmB,EACnBC,qBAAqB,EACrBC,cAAc,EACdC,gBAAgB,EAChBC,YAAY,QAEP,WAAW;AAClB,SAA4BC,gBAAgB,EAAiBC,sBAAs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wB,MAAM;gBAChCD,eAAe;YACjB;YACA,IAAIF,SAAS8B,YAAYhB,WAAW;gBAClC/C,uBAAuBiC,SAAS8B,SAASlB;YAC3C;QACF;QACA0G,cAAc;YACZpH,eAAe;YACf,IAAIF,SAAS8B,YAAYhB,WAAW;gBAClC9C,eAAegC,SAAS8B;YAC1B;QACF;QACAvC,eAAe,CAACiG;YACdpF,uBAAuB;YACvB,sGAAsG;YACtG,IAAIb,kBAAkBuB,WAAW;gBAC/B,IAAId,SAAS8B,YAAYhB,WAAW;oBAClCzC,aAAa2B,SAAS8B;gBACxB;YACF,OAAO;gBACLvC,cAAciG;YAChB;QACF;;YAGCvF,gBAAgB,QACf,CAAA,CAACP,kBAAAA,OAAO8E,qBAAP9E,6BAAD,KAAA,IAACA,gBAA2CgF,WAAU,MAAM,SAC5DvF,cAAcoI,WAAW,sBACvB,KAACjJ;gBACCkJ,aAAa7H,YAAY8H;gBACzBzH,UAAUA;gBACVrB,MAAMA;gBACNC,eAAeA;gBACf8I,YAAYvI,cAAcuI;gBAC1B9H,eAAeG;gBACfoG,WAAWhG;gBACXnB,QAAQA;gBACR2I,cAAc;oBACZ,0DAA0D;oBAC1DvH,uBAAuB;oBACvB,yCAAyC;oBACzCE,mBAAmB;gBACrB;;0BAGN,KAAC1C;gBACC0H,IAAI;oBACFsC,OAAO;oBACPlJ,QAAQ;gBACV;gBACAgB,QAAQA;gBACRmI,OAAOlI,YAAYmI;gBACnBC,UAAU7F;gBACV8F,WAAWhI;gBACXX,WAAWA;;;;AAInB,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeChart/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeChart';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,aAAa,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeChart/index.ts"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nexport * from './TimeChart';\n"],"names":[],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC,cAAc,cAAc"}
@@ -1,5 +1,5 @@
1
1
  /// <reference types="react" />
2
- import { UnitOptions } from '@perses-dev/core';
2
+ import { FormatOptions } from '@perses-dev/core';
3
3
  import { ECharts as EChartsInstance } from 'echarts/core';
4
4
  import { EChartsDataFormat } from '../model';
5
5
  import { CursorCoordinates } from './tooltip-model';
@@ -8,7 +8,7 @@ export interface TimeSeriesTooltipProps {
8
8
  chartData: EChartsDataFormat;
9
9
  enablePinning?: boolean;
10
10
  wrapLabels?: boolean;
11
- unit?: UnitOptions;
11
+ format?: FormatOptions;
12
12
  onUnpinClick?: () => void;
13
13
  pinnedPos: CursorCoordinates | null;
14
14
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"LineChartTooltip.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/LineChartTooltip.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI7C,OAAO,EACL,iBAAiB,EAOlB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,8DA4F3B,CAAC"}
1
+ {"version":3,"file":"LineChartTooltip.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/LineChartTooltip.tsx"],"names":[],"mappings":";AAcA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAG1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAI7C,OAAO,EACL,iBAAiB,EAOlB,MAAM,iBAAiB,CAAC;AAGzB,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,SAAS,EAAE,iBAAiB,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,8DA4F3B,CAAC"}
@@ -19,7 +19,7 @@ import { TooltipHeader } from './TooltipHeader';
19
19
  import { legacyGetNearbySeriesData } from './nearby-series';
20
20
  import { FALLBACK_CHART_WIDTH, TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_MAX_HEIGHT, TOOLTIP_MAX_WIDTH, TOOLTIP_MIN_WIDTH, useMousePosition } from './tooltip-model';
21
21
  import { assembleTransform } from './utils';
22
- export const LineChartTooltip = /*#__PURE__*/ memo(function LineChartTooltip({ chartRef , chartData , enablePinning =true , wrapLabels , unit , onUnpinClick , pinnedPos , containerId }) {
22
+ export const LineChartTooltip = /*#__PURE__*/ memo(function LineChartTooltip({ chartRef , chartData , enablePinning =true , wrapLabels , format , onUnpinClick , pinnedPos , containerId }) {
23
23
  const [showAllSeries, setShowAllSeries] = useState(false);
24
24
  const mousePos = useMousePosition();
25
25
  const { height , width , ref: tooltipRef } = useResizeObserver();
@@ -29,15 +29,15 @@ export const LineChartTooltip = /*#__PURE__*/ memo(function LineChartTooltip({ c
29
29
  // Ensure user is hovering over a chart before checking for nearby series.
30
30
  if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
31
31
  const chart = chartRef.current;
32
- var ref;
33
- const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
32
+ var _chart_getWidth;
33
+ const chartWidth = (_chart_getWidth = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && _chart_getWidth !== void 0 ? _chart_getWidth : FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
34
34
  // Get series nearby the cursor and pass into tooltip content children.
35
35
  const nearbySeries = legacyGetNearbySeriesData({
36
36
  mousePos,
37
37
  chartData,
38
38
  pinnedPos,
39
39
  chart,
40
- unit,
40
+ format,
41
41
  showAllSeries
42
42
  });
43
43
  if (nearbySeries.length === 0) {
@@ -50,13 +50,13 @@ export const LineChartTooltip = /*#__PURE__*/ memo(function LineChartTooltip({ c
50
50
  if (!isTooltipPinned) {
51
51
  transform.current = assembleTransform(mousePos, chartWidth, pinnedPos, height !== null && height !== void 0 ? height : 0, width !== null && width !== void 0 ? width : 0, containerElement);
52
52
  }
53
- var ref1;
53
+ var _theme_palette_designSystem_grey_;
54
54
  return /*#__PURE__*/ _jsx(Portal, {
55
55
  container: containerElement,
56
56
  children: /*#__PURE__*/ _jsx(Box, {
57
57
  ref: tooltipRef,
58
58
  sx: (theme)=>{
59
- var ref;
59
+ var _theme_palette_designSystem;
60
60
  return {
61
61
  minWidth: TOOLTIP_MIN_WIDTH,
62
62
  maxWidth: TOOLTIP_MAX_WIDTH,
@@ -65,7 +65,7 @@ export const LineChartTooltip = /*#__PURE__*/ memo(function LineChartTooltip({ c
65
65
  position: 'absolute',
66
66
  top: 0,
67
67
  left: 0,
68
- backgroundColor: (ref1 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref1 !== void 0 ? ref1 : TOOLTIP_BG_COLOR_FALLBACK,
68
+ backgroundColor: (_theme_palette_designSystem_grey_ = (_theme_palette_designSystem = theme.palette.designSystem) === null || _theme_palette_designSystem === void 0 ? void 0 : _theme_palette_designSystem.grey[800]) !== null && _theme_palette_designSystem_grey_ !== void 0 ? _theme_palette_designSystem_grey_ : TOOLTIP_BG_COLOR_FALLBACK,
69
69
  borderRadius: '6px',
70
70
  color: '#fff',
71
71
  fontSize: '11px',
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/LineChartTooltip.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Portal, Stack } from '@mui/material';\nimport { UnitOptions } from '@perses-dev/core';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { memo, useRef, useState } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { EChartsDataFormat } from '../model';\nimport { TooltipContent } from './TooltipContent';\nimport { TooltipHeader } from './TooltipHeader';\nimport { legacyGetNearbySeriesData } from './nearby-series';\nimport {\n CursorCoordinates,\n FALLBACK_CHART_WIDTH,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_HEIGHT,\n TOOLTIP_MAX_WIDTH,\n TOOLTIP_MIN_WIDTH,\n useMousePosition,\n} from './tooltip-model';\nimport { assembleTransform } from './utils';\n\nexport interface TimeSeriesTooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n chartData: EChartsDataFormat;\n enablePinning?: boolean;\n wrapLabels?: boolean;\n unit?: UnitOptions;\n onUnpinClick?: () => void;\n pinnedPos: CursorCoordinates | null;\n /**\n * The id of the container that will have the chart tooltip appended to it.\n * By default, the chart tooltip is attached to document.body.\n */\n containerId?: string;\n}\n\nexport const LineChartTooltip = memo(function LineChartTooltip({\n chartRef,\n chartData,\n enablePinning = true,\n wrapLabels,\n unit,\n onUnpinClick,\n pinnedPos,\n containerId,\n}: TimeSeriesTooltipProps) {\n const [showAllSeries, setShowAllSeries] = useState(false);\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n const transform = useRef('');\n\n const isTooltipPinned = pinnedPos !== null && enablePinning;\n\n if (mousePos === null || mousePos.target === null) return null;\n\n // Ensure user is hovering over a chart before checking for nearby series.\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const chartWidth = chart?.getWidth() ?? FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.\n\n // Get series nearby the cursor and pass into tooltip content children.\n const nearbySeries = legacyGetNearbySeriesData({\n mousePos,\n chartData,\n pinnedPos,\n chart,\n unit,\n showAllSeries,\n });\n if (nearbySeries.length === 0) {\n return null;\n }\n\n const totalSeries = chartData.timeSeries.length;\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n // if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n if (!isTooltipPinned) {\n transform.current = assembleTransform(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);\n }\n\n return (\n <Portal container={containerElement}>\n <Box\n ref={tooltipRef}\n sx={(theme) => ({\n minWidth: TOOLTIP_MIN_WIDTH,\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: maxHeight ?? TOOLTIP_MAX_HEIGHT,\n padding: 0,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n // Ensure pinned tooltip shows behind edit panel drawer and sticky header\n zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n })}\n style={{\n transform: transform.current,\n }}\n >\n <Stack spacing={0.5}>\n <TooltipHeader\n nearbySeries={nearbySeries}\n totalSeries={totalSeries}\n enablePinning={enablePinning}\n isTooltipPinned={isTooltipPinned}\n showAllSeries={showAllSeries}\n onShowAllClick={(checked) => setShowAllSeries(checked)}\n onUnpinClick={onUnpinClick}\n />\n <TooltipContent series={nearbySeries} wrapLabels={wrapLabels} />\n </Stack>\n </Box>\n </Portal>\n );\n});\n"],"names":["Box","Portal","Stack","memo","useRef","useState","useResizeObserver","TooltipContent","TooltipHeader","legacyGetNearbySeriesData","FALLBACK_CHART_WIDTH","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_HEIGHT","TOOLTIP_MAX_WIDTH","TOOLTIP_MIN_WIDTH","useMousePosition","assembleTransform","LineChartTooltip","chartRef","chartData","enablePinning","wrapLabels","unit","onUnpinClick","pinnedPos","containerId","showAllSeries","setShowAllSeries","mousePos","height","width","ref","tooltipRef","transform","isTooltipPinned","target","tagName","chart","current","chartWidth","getWidth","nearbySeries","length","totalSeries","timeSeries","containerElement","document","querySelector","undefined","maxHeight","getBoundingClientRect","theme","container","sx","minWidth","maxWidth","padding","position","top","left","backgroundColor","palette","designSystem","grey","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY","style","spacing","onShowAllClick","checked","series"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAEC,MAAM,EAAEC,KAAK,QAAQ,eAAe,CAAC;AAGnD,SAASC,IAAI,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,OAAO,CAAC;AAC/C,OAAOC,iBAAiB,MAAM,qBAAqB,CAAC;AAEpD,SAASC,cAAc,QAAQ,kBAAkB,CAAC;AAClD,SAASC,aAAa,QAAQ,iBAAiB,CAAC;AAChD,SAASC,yBAAyB,QAAQ,iBAAiB,CAAC;AAC5D,SAEEC,oBAAoB,EACpBC,yBAAyB,EACzBC,kBAAkB,EAClBC,iBAAiB,EACjBC,iBA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A,KAAK,CAACU,OAAO,CAACC,YAAY,cAA1BX,GAA0B,WAAM,GAAhCA,KAAAA,CAAgC,GAAhCA,GAA0B,CAAEY,IAAI,CAAC,GAAG,CAAC,cAArCZ,IAAqC,cAArCA,IAAqC,GAAIxC,yBAAyB;oBACnFqD,YAAY,EAAE,KAAK;oBACnBC,KAAK,EAAE,MAAM;oBACbC,QAAQ,EAAE,MAAM;oBAChBC,UAAU,EAAE,SAAS;oBACrBC,OAAO,EAAE,CAAC;oBACVC,UAAU,EAAE,mBAAmB;oBAC/B,yEAAyE;oBACzEC,MAAM,EAAE9C,SAAS,KAAK,IAAI,GAAG,MAAM,GAAG2B,KAAK,CAACmB,MAAM,CAACC,OAAO;oBAC1DC,QAAQ,EAAE,QAAQ;oBAClB,SAAS,EAAE;wBACTC,SAAS,EAAE,MAAM;qBAClB;iBACF,CAAA;aAAC;YACFC,KAAK,EAAE;gBACLzC,SAAS,EAAEA,SAAS,CAACK,OAAO;aAC7B;sBAED,cAAA,MAACpC,KAAK;gBAACyE,OAAO,EAAE,GAAG;;kCACjB,KAACnE,aAAa;wBACZiC,YAAY,EAAEA,YAAY;wBAC1BE,WAAW,EAAEA,WAAW;wBACxBvB,aAAa,EAAEA,aAAa;wBAC5Bc,eAAe,EAAEA,eAAe;wBAChCR,aAAa,EAAEA,aAAa;wBAC5BkD,cAAc,EAAE,CAACC,OAAO,GAAKlD,gBAAgB,CAACkD,OAAO,CAAC;wBACtDtD,YAAY,EAAEA,YAAY;sBAC1B;kCACF,KAAChB,cAAc;wBAACuE,MAAM,EAAErC,YAAY;wBAAEpB,UAAU,EAAEA,UAAU;sBAAI;;cAC1D;UACJ;MACC,CACT;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/LineChartTooltip.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Portal, Stack } from '@mui/material';\nimport { FormatOptions } from '@perses-dev/core';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { memo, useRef, useState } from 'react';\nimport useResizeObserver from 'use-resize-observer';\nimport { EChartsDataFormat } from '../model';\nimport { TooltipContent } from './TooltipContent';\nimport { TooltipHeader } from './TooltipHeader';\nimport { legacyGetNearbySeriesData } from './nearby-series';\nimport {\n CursorCoordinates,\n FALLBACK_CHART_WIDTH,\n TOOLTIP_BG_COLOR_FALLBACK,\n TOOLTIP_MAX_HEIGHT,\n TOOLTIP_MAX_WIDTH,\n TOOLTIP_MIN_WIDTH,\n useMousePosition,\n} from './tooltip-model';\nimport { assembleTransform } from './utils';\n\nexport interface TimeSeriesTooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n chartData: EChartsDataFormat;\n enablePinning?: boolean;\n wrapLabels?: boolean;\n format?: FormatOptions;\n onUnpinClick?: () => void;\n pinnedPos: CursorCoordinates | null;\n /**\n * The id of the container that will have the chart tooltip appended to it.\n * By default, the chart tooltip is attached to document.body.\n */\n containerId?: string;\n}\n\nexport const LineChartTooltip = memo(function LineChartTooltip({\n chartRef,\n chartData,\n enablePinning = true,\n wrapLabels,\n format,\n onUnpinClick,\n pinnedPos,\n containerId,\n}: TimeSeriesTooltipProps) {\n const [showAllSeries, setShowAllSeries] = useState(false);\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n const transform = useRef('');\n\n const isTooltipPinned = pinnedPos !== null && enablePinning;\n\n if (mousePos === null || mousePos.target === null) return null;\n\n // Ensure user is hovering over a chart before checking for nearby series.\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const chartWidth = chart?.getWidth() ?? FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.\n\n // Get series nearby the cursor and pass into tooltip content children.\n const nearbySeries = legacyGetNearbySeriesData({\n mousePos,\n chartData,\n pinnedPos,\n chart,\n format,\n showAllSeries,\n });\n if (nearbySeries.length === 0) {\n return null;\n }\n\n const totalSeries = chartData.timeSeries.length;\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n // if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n if (!isTooltipPinned) {\n transform.current = assembleTransform(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);\n }\n\n return (\n <Portal container={containerElement}>\n <Box\n ref={tooltipRef}\n sx={(theme) => ({\n minWidth: TOOLTIP_MIN_WIDTH,\n maxWidth: TOOLTIP_MAX_WIDTH,\n maxHeight: maxHeight ?? TOOLTIP_MAX_HEIGHT,\n padding: 0,\n position: 'absolute',\n top: 0,\n left: 0,\n backgroundColor: theme.palette.designSystem?.grey[800] ?? TOOLTIP_BG_COLOR_FALLBACK,\n borderRadius: '6px',\n color: '#fff',\n fontSize: '11px',\n visibility: 'visible',\n opacity: 1,\n transition: 'all 0.1s ease-out',\n // Ensure pinned tooltip shows behind edit panel drawer and sticky header\n zIndex: pinnedPos !== null ? 'auto' : theme.zIndex.tooltip,\n overflow: 'hidden',\n '&:hover': {\n overflowY: 'auto',\n },\n })}\n style={{\n transform: transform.current,\n }}\n >\n <Stack spacing={0.5}>\n <TooltipHeader\n nearbySeries={nearbySeries}\n totalSeries={totalSeries}\n enablePinning={enablePinning}\n isTooltipPinned={isTooltipPinned}\n showAllSeries={showAllSeries}\n onShowAllClick={(checked) => setShowAllSeries(checked)}\n onUnpinClick={onUnpinClick}\n />\n <TooltipContent series={nearbySeries} wrapLabels={wrapLabels} />\n </Stack>\n </Box>\n </Portal>\n );\n});\n"],"names":["Box","Portal","Stack","memo","useRef","useState","useResizeObserver","TooltipContent","TooltipHeader","legacyGetNearbySeriesData","FALLBACK_CHART_WIDTH","TOOLTIP_BG_COLOR_FALLBACK","TOOLTIP_MAX_HEIGHT","TOOLTIP_MAX_WIDTH","TOOLTIP_MIN_WIDTH","useMousePosition","assembleTransform","LineChartTooltip","chartRef","chartData","enablePinning","wrapLabels","format","onUnpinClick","pinnedPos","containerId","showAllSeries","setShowAllSeries","mousePos","height","width","ref","tooltipRef","transform","isTooltipPinned","target","tagName","chart","current","chartWidth","getWidth","nearbySeries","length","totalSeries","timeSeries","containerElement","document","querySelector","undefined","maxHeight","getBoundingClientRect","theme","container","sx","minWidth","maxWidth","padding","position","top","left","backgroundColor","palette","designSystem","grey","borderRadius","color","fontSize","visibility","opacity","transition","zIndex","tooltip","overflow","overflowY","style","spacing","onShowAllClick","checked","series"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,EAAEC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAGnD,SAASC,IAAI,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC/C,OAAOC,uBAAuB,sBAAsB;AAEpD,SAASC,cAAc,QAAQ,mBAAmB;AAClD,SAASC,aAAa,QAAQ,kBAAkB;AAChD,SAASC,yBAAyB,QAAQ,kBAAkB;AAC5D,SAEEC,oBAAoB,EACpBC,yBAAyB,EACzBC,kBAAkB,EAClBC,iBAAiB,EACjBC,iBAAiB,EACjBC,gBAAgB,QACX,kBAAkB;AACzB,SAASC,iBAAiB,QAAQ,UAAU;AAiB5C,OAAO,MAAMC,iCAAmBd,KAAK,SAASc,iBAAiB,EAC7DC,SAAQ,EACRC,UAAS,EACTC,eAAgB,KAAI,EACpBC,W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;oBACVC,KAAK;oBACLC,MAAM;oBACNC,iBAAiBT,CAAAA,oCAAAA,CAAAA,8BAAAA,MAAMU,QAAQC,0BAAdX,yCAAAA,KAAAA,IAAAA,4BAA4BY,IAAI,CAAC,IAAI,cAArCZ,+CAAAA,oCAAyCxC;oBAC1DqD,cAAc;oBACdC,OAAO;oBACPC,UAAU;oBACVC,YAAY;oBACZC,SAAS;oBACTC,YAAY;oBACZ,yEAAyE;oBACzEC,QAAQ9C,cAAc,OAAO,SAAS2B,MAAMmB,OAAOC;oBACnDC,UAAU;oBACV,WAAW;wBACTC,WAAW;oBACb;gBACF;;YACAC,OAAO;gBACLzC,WAAWA,UAAUK;YACvB;sBAEA,cAAA,MAACpC;gBAAMyE,SAAS;;kCACd,KAACnE;wBACCiC,cAAcA;wBACdE,aAAaA;wBACbvB,eAAeA;wBACfc,iBAAiBA;wBACjBR,eAAeA;wBACfkD,gBAAgB,CAACC,UAAYlD,iBAAiBkD;wBAC9CtD,cAAcA;;kCAEhB,KAAChB;wBAAeuE,QAAQrC;wBAAcpB,YAAYA;;;;;;AAK5D,GAAG"}
@@ -21,8 +21,8 @@ export function SeriesInfo(props) {
21
21
  // ex with metric name: node_load15{env="demo",job="node"}
22
22
  // ex without metric name: {env="demo",job="node"}
23
23
  const splitName = seriesName.split('{');
24
- var ref;
25
- const seriesLabels = (ref = splitName[1]) !== null && ref !== void 0 ? ref : seriesName;
24
+ var _splitName_;
25
+ const seriesLabels = (_splitName_ = splitName[1]) !== null && _splitName_ !== void 0 ? _splitName_ : seriesName;
26
26
  // remove curly braces that wrap labels
27
27
  const formattedSeriesLabels = seriesLabels.replace(/[{}]/g, '');
28
28
  // determine whether to show labels on separate lines
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesInfo.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { SeriesMarker } from './SeriesMarker';\nimport { SeriesLabelsStack } from './SeriesLabelsStack';\nimport { TOOLTIP_LABELS_MAX_WIDTH, EMPHASIZED_SERIES_DESCRIPTION, NEARBY_SERIES_DESCRIPTION } from './tooltip-model';\n\nexport interface SeriesInfoProps {\n seriesName: string;\n y: number;\n formattedY: string;\n markerColor: string;\n totalSeries: number;\n emphasizeText?: boolean;\n wrapLabels?: boolean;\n}\n\nexport function SeriesInfo(props: SeriesInfoProps) {\n const { seriesName, formattedY, markerColor, totalSeries, emphasizeText = false, wrapLabels = true } = props;\n\n // metric __name__ comes before opening curly brace, ignore if not populated\n // ex with metric name: node_load15{env=\"demo\",job=\"node\"}\n // ex without metric name: {env=\"demo\",job=\"node\"}\n const splitName = seriesName.split('{');\n const seriesLabels = splitName[1] ?? seriesName;\n\n // remove curly braces that wrap labels\n const formattedSeriesLabels = seriesLabels.replace(/[{}]/g, '');\n\n // determine whether to show labels on separate lines\n const splitLabels = formattedSeriesLabels.split(',');\n if (totalSeries === 1 && splitLabels.length > 1) {\n const metricName = splitName[0] ? `${splitName[0]}:` : 'value:';\n return (\n <SeriesLabelsStack\n formattedY={formattedY}\n metricName={metricName}\n metricLabels={splitLabels}\n markerColor={markerColor}\n />\n );\n }\n\n // add space after commas so wrapLabels works\n const formattedSeriesInfo = seriesName.replace(/[,]/g, ', ');\n\n return (\n <Box\n sx={{\n display: 'table-row',\n paddingTop: 0.5,\n }}\n >\n <Box\n sx={{\n display: 'table-cell',\n maxWidth: '520px',\n }}\n >\n <SeriesMarker markerColor={markerColor} sx={{ marginTop: 0.5 }} />\n <Box\n component=\"span\"\n sx={(theme) => ({\n display: 'inline-block',\n width: 'calc(100% - 20px)',\n minWidth: 150,\n maxWidth: TOOLTIP_LABELS_MAX_WIDTH,\n overflow: 'hidden',\n color: theme.palette.common.white,\n fontWeight: emphasizeText ? theme.typography.fontWeightBold : theme.typography.fontWeightRegular,\n textOverflow: 'ellipsis',\n whiteSpace: wrapLabels ? 'normal' : 'nowrap',\n })}\n aria-label={emphasizeText ? EMPHASIZED_SERIES_DESCRIPTION : NEARBY_SERIES_DESCRIPTION}\n >\n {formattedSeriesInfo}\n </Box>\n </Box>\n <Box\n sx={(theme) => ({\n display: 'table-cell',\n paddingLeft: 1.5,\n textAlign: 'right',\n verticalAlign: 'top',\n fontWeight: emphasizeText ? theme.typography.fontWeightBold : theme.typography.fontWeightRegular,\n })}\n >\n {formattedY}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","SeriesMarker","SeriesLabelsStack","TOOLTIP_LABELS_MAX_WIDTH","EMPHASIZED_SERIES_DESCRIPTION","NEARBY_SERIES_DESCRIPTION","SeriesInfo","props","seriesName","formattedY","markerColor","totalSeries","emphasizeText","wrapLabels","splitName","split","seriesLabels","formattedSeriesLabels","replace","splitLabels","length","metricName","metricLabels","formattedSeriesInfo","sx","display","paddingTop","maxWidth","marginTop","component","theme","width","minWidth","overflow","color","palette","common","white","fontWeight","typography","fontWeightBold","fontWeightRegular","textOverflow","whiteSpace","aria-label","paddingLeft","textAlign","verticalAlign"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAQ,eAAe,CAAC;AACpC,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAC9C,SAASC,iBAAiB,QAAQ,qBAAqB,CAAC;AACxD,SAASC,wBAAwB,EAAEC,6BAA6B,EAAEC,yBAAyB,QAAQ,iBAAiB,C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,EAAE;oBACFC,OAAO,EAAE,YAAY;oBACrBE,QAAQ,EAAE,OAAO;iBAClB;;kCAED,KAAC1B,YAAY;wBAACS,WAAW,EAAEA,WAAW;wBAAEc,EAAE,EAAE;4BAAEI,SAAS,EAAE,GAAG;yBAAE;sBAAI;kCAClE,KAAC5B,GAAG;wBACF6B,SAAS,EAAC,MAAM;wBAChBL,EAAE,EAAE,CAACM,KAAK,GAAM,CAAA;gCACdL,OAAO,EAAE,cAAc;gCACvBM,KAAK,EAAE,mBAAmB;gCAC1BC,QAAQ,EAAE,GAAG;gCACbL,QAAQ,EAAExB,wBAAwB;gCAClC8B,QAAQ,EAAE,QAAQ;gCAClBC,KAAK,EAAEJ,KAAK,CAACK,OAAO,CAACC,MAAM,CAACC,KAAK;gCACjCC,UAAU,EAAE1B,aAAa,GAAGkB,KAAK,CAACS,UAAU,CAACC,cAAc,GAAGV,KAAK,CAACS,UAAU,CAACE,iBAAiB;gCAChGC,YAAY,EAAE,UAAU;gCACxBC,UAAU,EAAE9B,UAAU,GAAG,QAAQ,GAAG,QAAQ;6BAC7C,CAAA,AAAC;wBACF+B,YAAU,EAAEhC,aAAa,GAAGR,6BAA6B,GAAGC,yBAAyB;kCAEpFkB,mBAAmB;sBAChB;;cACF;0BACN,KAACvB,GAAG;gBACFwB,EAAE,EAAE,CAACM,KAAK,GAAM,CAAA;wBACdL,OAAO,EAAE,YAAY;wBACrBoB,WAAW,EAAE,GAAG;wBAChBC,SAAS,EAAE,OAAO;wBAClBC,aAAa,EAAE,KAAK;wBACpBT,UAAU,EAAE1B,aAAa,GAAGkB,KAAK,CAACS,UAAU,CAACC,cAAc,GAAGV,KAAK,CAACS,UAAU,CAACE,iBAAiB;qBACjG,CAAA,AAAC;0BAEDhC,UAAU;cACP;;MACF,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesInfo.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box } from '@mui/material';\nimport { SeriesMarker } from './SeriesMarker';\nimport { SeriesLabelsStack } from './SeriesLabelsStack';\nimport { TOOLTIP_LABELS_MAX_WIDTH, EMPHASIZED_SERIES_DESCRIPTION, NEARBY_SERIES_DESCRIPTION } from './tooltip-model';\n\nexport interface SeriesInfoProps {\n seriesName: string;\n y: number;\n formattedY: string;\n markerColor: string;\n totalSeries: number;\n emphasizeText?: boolean;\n wrapLabels?: boolean;\n}\n\nexport function SeriesInfo(props: SeriesInfoProps) {\n const { seriesName, formattedY, markerColor, totalSeries, emphasizeText = false, wrapLabels = true } = props;\n\n // metric __name__ comes before opening curly brace, ignore if not populated\n // ex with metric name: node_load15{env=\"demo\",job=\"node\"}\n // ex without metric name: {env=\"demo\",job=\"node\"}\n const splitName = seriesName.split('{');\n const seriesLabels = splitName[1] ?? seriesName;\n\n // remove curly braces that wrap labels\n const formattedSeriesLabels = seriesLabels.replace(/[{}]/g, '');\n\n // determine whether to show labels on separate lines\n const splitLabels = formattedSeriesLabels.split(',');\n if (totalSeries === 1 && splitLabels.length > 1) {\n const metricName = splitName[0] ? `${splitName[0]}:` : 'value:';\n return (\n <SeriesLabelsStack\n formattedY={formattedY}\n metricName={metricName}\n metricLabels={splitLabels}\n markerColor={markerColor}\n />\n );\n }\n\n // add space after commas so wrapLabels works\n const formattedSeriesInfo = seriesName.replace(/[,]/g, ', ');\n\n return (\n <Box\n sx={{\n display: 'table-row',\n paddingTop: 0.5,\n }}\n >\n <Box\n sx={{\n display: 'table-cell',\n maxWidth: '520px',\n }}\n >\n <SeriesMarker markerColor={markerColor} sx={{ marginTop: 0.5 }} />\n <Box\n component=\"span\"\n sx={(theme) => ({\n display: 'inline-block',\n width: 'calc(100% - 20px)',\n minWidth: 150,\n maxWidth: TOOLTIP_LABELS_MAX_WIDTH,\n overflow: 'hidden',\n color: theme.palette.common.white,\n fontWeight: emphasizeText ? theme.typography.fontWeightBold : theme.typography.fontWeightRegular,\n textOverflow: 'ellipsis',\n whiteSpace: wrapLabels ? 'normal' : 'nowrap',\n })}\n aria-label={emphasizeText ? EMPHASIZED_SERIES_DESCRIPTION : NEARBY_SERIES_DESCRIPTION}\n >\n {formattedSeriesInfo}\n </Box>\n </Box>\n <Box\n sx={(theme) => ({\n display: 'table-cell',\n paddingLeft: 1.5,\n textAlign: 'right',\n verticalAlign: 'top',\n fontWeight: emphasizeText ? theme.typography.fontWeightBold : theme.typography.fontWeightRegular,\n })}\n >\n {formattedY}\n </Box>\n </Box>\n );\n}\n"],"names":["Box","SeriesMarker","SeriesLabelsStack","TOOLTIP_LABELS_MAX_WIDTH","EMPHASIZED_SERIES_DESCRIPTION","NEARBY_SERIES_DESCRIPTION","SeriesInfo","props","seriesName","formattedY","markerColor","totalSeries","emphasizeText","wrapLabels","splitName","split","seriesLabels","formattedSeriesLabels","replace","splitLabels","length","metricName","metricLabels","formattedSeriesInfo","sx","display","paddingTop","maxWidth","marginTop","component","theme","width","minWidth","overflow","color","palette","common","white","fontWeight","typography","fontWeightBold","fontWeightRegular","textOverflow","whiteSpace","aria-label","paddingLeft","textAlign","verticalAlign"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,YAAY,QAAQ,iBAAiB;AAC9C,SAASC,iBAAiB,QAAQ,sBAAsB;AACxD,SAASC,wBAAwB,EAAEC,6BAA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tC,CAAA;wBACA+B,cAAYhC,gBAAgBR,gCAAgCC;kCAE3DkB;;;;0BAGL,KAACvB;gBACCwB,IAAI,CAACM,QAAW,CAAA;wBACdL,SAAS;wBACToB,aAAa;wBACbC,WAAW;wBACXC,eAAe;wBACfT,YAAY1B,gBAAgBkB,MAAMS,WAAWC,iBAAiBV,MAAMS,WAAWE;oBACjF,CAAA;0BAEChC;;;;AAIT"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesLabelsStack.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Divider, Stack, Typography } from '@mui/material';\nimport { SeriesMarker } from './SeriesMarker';\n\nexport interface SeriesLabelsStackProps {\n formattedY: string;\n metricName: string;\n metricLabels: string[];\n markerColor: string;\n}\n\nexport function SeriesLabelsStack(props: SeriesLabelsStackProps) {\n const { formattedY, markerColor, metricName, metricLabels } = props;\n return (\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n display: 'flex',\n height: '16px',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'left',\n color: theme.palette.common.white,\n fontSize: '11px',\n })}\n >\n <SeriesMarker markerColor={markerColor} sx={{ marginTop: 0.25 }} />\n <Box component=\"span\">\n {metricName}\n <Box\n component=\"span\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n paddingLeft: '2px',\n })}\n >\n {formattedY}\n </Box>\n </Box>\n </Box>\n <Divider\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n })}\n />\n <Box\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {metricLabels.map((label) => {\n // show labels on separate lines when many labels and only one focused series\n if (label) {\n const [name, value] = label.split('=');\n const formattedName = value !== undefined ? `${name}: ` : name;\n const formattedValue = value !== undefined ? value.replace(/(^\"|\"$)/g, '') : value;\n return (\n <Box key={label} sx={{ display: 'flex', gap: '4px' }}>\n <Typography sx={{ fontSize: '11px' }}>{formattedName}</Typography>\n <Typography\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n fontSize: '11px',\n })}\n >\n {formattedValue}\n </Typography>\n </Box>\n );\n }\n })}\n </Box>\n </Stack>\n );\n}\n"],"names":["Box","Divider","Stack","Typography","SeriesMarker","SeriesLabelsStack","props","formattedY","markerColor","metricName","metricLabels","spacing","sx","theme","display","height","flexDirection","alignItems","justifyContent","color","palette","common","white","fontSize","marginTop","component","fontWeight","paddingLeft","borderColor","grey","map","label","name","value","split","formattedName","undefined","formattedValue","replace","gap"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,eAAe,CAAC;AAChE,SAASC,YAAY,QAAQ,gBAAgB,CAAC;AAS9C,OAAO,SAASC,iBAAiB,CAACC,KAA6B,EAAE;IAC/D,MAAM,EAAEC,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAEC,UAAU,CAAA,EAAEC,YAAY,CAAA,EAAE,GAAGJ,KAAK,AAAC;IACpE,qBACE,MAACJ,KAAK;QAACS,OAAO,EAAE,GAAG;;0BACjB,MAACX,GAAG;gBACFY,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;wBACdC,OAAO,EAAE,MAAM;wBACfC,MAAM,EAAE,MAAM;wBACdC,aAAa,EAA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,KAAK,KAAKG,SAAS,GAAGH,KAAK,CAACK,OAAO,aAAa,EAAE,CAAC,GAAGL,KAAK,AAAC;wBACnF,qBACE,MAACjC,GAAG;4BAAaY,EAAE,EAAE;gCAAEE,OAAO,EAAE,MAAM;gCAAEyB,GAAG,EAAE,KAAK;6BAAE;;8CAClD,KAACpC,UAAU;oCAACS,EAAE,EAAE;wCAAEW,QAAQ,EAAE,MAAM;qCAAE;8CAAGY,aAAa;kCAAc;8CAClE,KAAChC,UAAU;oCACTS,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;4CACdM,KAAK,EAAEN,KAAK,CAACO,OAAO,CAACC,MAAM,CAACC,KAAK;4CACjCI,UAAU,EAAE,GAAG;4CACfH,QAAQ,EAAE,MAAM;yCACjB,CAAA,AAAC;8CAEDc,cAAc;kCACJ;;2BAVLN,KAAK,CAWT,CACN;oBACJ,CAAC;gBACH,CAAC,CAAC;cACE;;MACA,CACR;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesLabelsStack.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, Divider, Stack, Typography } from '@mui/material';\nimport { SeriesMarker } from './SeriesMarker';\n\nexport interface SeriesLabelsStackProps {\n formattedY: string;\n metricName: string;\n metricLabels: string[];\n markerColor: string;\n}\n\nexport function SeriesLabelsStack(props: SeriesLabelsStackProps) {\n const { formattedY, markerColor, metricName, metricLabels } = props;\n return (\n <Stack spacing={0.5}>\n <Box\n sx={(theme) => ({\n display: 'flex',\n height: '16px',\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'left',\n color: theme.palette.common.white,\n fontSize: '11px',\n })}\n >\n <SeriesMarker markerColor={markerColor} sx={{ marginTop: 0.25 }} />\n <Box component=\"span\">\n {metricName}\n <Box\n component=\"span\"\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n paddingLeft: '2px',\n })}\n >\n {formattedY}\n </Box>\n </Box>\n </Box>\n <Divider\n sx={(theme) => ({\n borderColor: theme.palette.grey['500'],\n })}\n />\n <Box\n sx={(theme) => ({\n color: theme.palette.common.white,\n })}\n >\n {metricLabels.map((label) => {\n // show labels on separate lines when many labels and only one focused series\n if (label) {\n const [name, value] = label.split('=');\n const formattedName = value !== undefined ? `${name}: ` : name;\n const formattedValue = value !== undefined ? value.replace(/(^\"|\"$)/g, '') : value;\n return (\n <Box key={label} sx={{ display: 'flex', gap: '4px' }}>\n <Typography sx={{ fontSize: '11px' }}>{formattedName}</Typography>\n <Typography\n sx={(theme) => ({\n color: theme.palette.common.white,\n fontWeight: 700,\n fontSize: '11px',\n })}\n >\n {formattedValue}\n </Typography>\n </Box>\n );\n }\n })}\n </Box>\n </Stack>\n );\n}\n"],"names":["Box","Divider","Stack","Typography","SeriesMarker","SeriesLabelsStack","props","formattedY","markerColor","metricName","metricLabels","spacing","sx","theme","display","height","flexDirection","alignItems","justifyContent","color","palette","common","white","fontSize","marginTop","component","fontWeight","paddingLeft","borderColor","grey","map","label","name","value","split","formattedName","undefined","formattedValue","replace","gap"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,EAAEC,OAAO,EAAEC,KAAK,EAAEC,UAAU,QAAQ,gBAAgB;AAChE,SAASC,YAAY,QAAQ,iBAAiB;AAS9C,OAAO,SAASC,kBAAkBC,KAA6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;4CAC5BI,YAAY;4CACZH,UAAU;wCACZ,CAAA;8CAECc;;;2BATKN;oBAad;gBACF;;;;AAIR"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesMarker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { combineSx } from '../utils';\n\ninterface SeriesMarkerProps extends BoxProps<'div'> {\n markerColor: string;\n}\n\nexport function SeriesMarker(props: SeriesMarkerProps) {\n const { markerColor, sx } = props;\n return (\n <Box\n sx={combineSx(\n {\n display: 'inline-block',\n width: '11px',\n height: '11px',\n borderRadius: '2px',\n marginRight: 1,\n verticalAlign: 'top',\n },\n sx\n )}\n style={{ backgroundColor: markerColor }}\n ></Box>\n );\n}\n"],"names":["Box","combineSx","SeriesMarker","props","markerColor","sx","display","width","height","borderRadius","marginRight","verticalAlign","style","backgroundColor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,GAAG,QAAkB,eAAe,CAAC;AAC9C,SAASC,SAAS,QAAQ,UAAU,CAAC;AAMrC,OAAO,SAASC,YAAY,CAACC,KAAwB,EAAE;IACrD,MAAM,EAAEC,WAAW,CAAA,EAAEC,EAAE,CAAA,EAAE,GAAGF,KAAK,AAAC;IAClC,qBACE,KAACH,GAAG;QACFK,EAAE,EAAEJ,SAAS,CACX;YACEK,OAAO,EAAE,cAAc;YACvBC,KAAK,EAAE,MAAM;YACbC,MAAM,EAAE,MAAM;YACdC,YAAY,EAAE,KAAK;YACnBC,WAAW,EAAE,CAAC;YACdC,aAAa,EAAE,KAAK;SACrB,EACDN,EAAE,CACH;QACDO,KAAK,EAAE;YAAEC,eAAe,EAAET,WAAW;SAAE;MAClC,CACP;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/SeriesMarker.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { Box, BoxProps } from '@mui/material';\nimport { combineSx } from '../utils';\n\ninterface SeriesMarkerProps extends BoxProps<'div'> {\n markerColor: string;\n}\n\nexport function SeriesMarker(props: SeriesMarkerProps) {\n const { markerColor, sx } = props;\n return (\n <Box\n sx={combineSx(\n {\n display: 'inline-block',\n width: '11px',\n height: '11px',\n borderRadius: '2px',\n marginRight: 1,\n verticalAlign: 'top',\n },\n sx\n )}\n style={{ backgroundColor: markerColor }}\n ></Box>\n );\n}\n"],"names":["Box","combineSx","SeriesMarker","props","markerColor","sx","display","width","height","borderRadius","marginRight","verticalAlign","style","backgroundColor"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,GAAG,QAAkB,gBAAgB;AAC9C,SAASC,SAAS,QAAQ,WAAW;AAMrC,OAAO,SAASC,aAAaC,KAAwB;IACnD,MAAM,EAAEC,YAAW,EAAEC,GAAE,EAAE,GAAGF;IAC5B,qBACE,KAACH;QACCK,IAAIJ,UACF;YACEK,SAAS;YACTC,OAAO;YACPC,QAAQ;YACRC,cAAc;YACdC,aAAa;YACbC,eAAe;QACjB,GACAN;QAEFO,OAAO;YAAEC,iBAAiBT;QAAY;;AAG5C"}
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import { ECharts as EChartsInstance } from 'echarts/core';
3
- import { UnitOptions, TimeSeries } from '@perses-dev/core';
3
+ import { FormatOptions, TimeSeries } from '@perses-dev/core';
4
4
  import { TimeChartSeriesMapping } from '../model';
5
5
  import { CursorCoordinates } from './tooltip-model';
6
6
  export interface TimeChartTooltipProps {
@@ -15,7 +15,7 @@ export interface TimeChartTooltipProps {
15
15
  */
16
16
  containerId?: string;
17
17
  onUnpinClick?: () => void;
18
- unit?: UnitOptions;
18
+ format?: FormatOptions;
19
19
  wrapLabels?: boolean;
20
20
  }
21
21
  export declare const TimeChartTooltip: import("react").NamedExoticComponent<TimeChartTooltipProps>;
@@ -1 +1 @@
1
- {"version":3,"file":"TimeChartTooltip.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TimeChartTooltip.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE3D,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA0C,MAAM,iBAAiB,CAAC;AAM5F,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,aAAa,EAAE,sBAAsB,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,6DA2E3B,CAAC"}
1
+ {"version":3,"file":"TimeChartTooltip.d.ts","sourceRoot":"","sources":["../../src/TimeSeriesTooltip/TimeChartTooltip.tsx"],"names":[],"mappings":";AAeA,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA0C,MAAM,iBAAiB,CAAC;AAM5F,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,KAAK,CAAC,gBAAgB,CAAC,eAAe,GAAG,SAAS,CAAC,CAAC;IAC9D,IAAI,EAAE,UAAU,EAAE,CAAC;IACnB,aAAa,EAAE,sBAAsB,CAAC;IACtC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,SAAS,EAAE,iBAAiB,GAAG,IAAI,CAAC;IACpC;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,eAAO,MAAM,gBAAgB,6DA2E3B,CAAC"}
@@ -19,7 +19,7 @@ import { assembleTransform, getTooltipStyles } from './utils';
19
19
  import { getNearbySeriesData } from './nearby-series';
20
20
  import { TooltipHeader } from './TooltipHeader';
21
21
  import { TooltipContent } from './TooltipContent';
22
- export const TimeChartTooltip = /*#__PURE__*/ memo(function TimeChartTooltip({ containerId , chartRef , data , seriesMapping , enablePinning =true , wrapLabels , unit , onUnpinClick , pinnedPos }) {
22
+ export const TimeChartTooltip = /*#__PURE__*/ memo(function TimeChartTooltip({ containerId , chartRef , data , seriesMapping , enablePinning =true , wrapLabels , format , onUnpinClick , pinnedPos }) {
23
23
  const [showAllSeries, setShowAllSeries] = useState(false);
24
24
  const transform = useRef('');
25
25
  const mousePos = useMousePosition();
@@ -29,8 +29,8 @@ export const TimeChartTooltip = /*#__PURE__*/ memo(function TimeChartTooltip({ c
29
29
  // Ensure user is hovering over a chart before checking for nearby series.
30
30
  if (pinnedPos === null && mousePos.target.tagName !== 'CANVAS') return null;
31
31
  const chart = chartRef.current;
32
- var ref;
33
- const chartWidth = (ref = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && ref !== void 0 ? ref : FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
32
+ var _chart_getWidth;
33
+ const chartWidth = (_chart_getWidth = chart === null || chart === void 0 ? void 0 : chart.getWidth()) !== null && _chart_getWidth !== void 0 ? _chart_getWidth : FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.
34
34
  const containerElement = containerId ? document.querySelector(containerId) : undefined;
35
35
  // if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off
36
36
  const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;
@@ -44,7 +44,7 @@ export const TimeChartTooltip = /*#__PURE__*/ memo(function TimeChartTooltip({ c
44
44
  seriesMapping,
45
45
  pinnedPos,
46
46
  chart,
47
- unit,
47
+ format,
48
48
  showAllSeries
49
49
  });
50
50
  if (nearbySeries.length === 0) {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/TimeChartTooltip.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { memo, useRef, useState } from 'react';\nimport { Box, Portal, Stack } from '@mui/material';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { UnitOptions, TimeSeries } from '@perses-dev/core';\nimport useResizeObserver from 'use-resize-observer';\nimport { TimeChartSeriesMapping } from '../model';\nimport { CursorCoordinates, FALLBACK_CHART_WIDTH, useMousePosition } from './tooltip-model';\nimport { assembleTransform, getTooltipStyles } from './utils';\nimport { getNearbySeriesData } from './nearby-series';\nimport { TooltipHeader } from './TooltipHeader';\nimport { TooltipContent } from './TooltipContent';\n\nexport interface TimeChartTooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n enablePinning?: boolean;\n pinnedPos: CursorCoordinates | null;\n /**\n * The id of the container that will have the chart tooltip appended to it.\n * By default, the chart tooltip is attached to document.body.\n */\n containerId?: string;\n onUnpinClick?: () => void;\n unit?: UnitOptions;\n wrapLabels?: boolean;\n}\n\nexport const TimeChartTooltip = memo(function TimeChartTooltip({\n containerId,\n chartRef,\n data,\n seriesMapping,\n enablePinning = true,\n wrapLabels,\n unit,\n onUnpinClick,\n pinnedPos,\n}: TimeChartTooltipProps) {\n const [showAllSeries, setShowAllSeries] = useState(false);\n const transform = useRef('');\n\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n\n const isTooltipPinned = pinnedPos !== null && enablePinning;\n\n if (mousePos === null || mousePos.target === null || data === null) return null;\n\n // Ensure user is hovering over a chart before checking for nearby series.\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const chartWidth = chart?.getWidth() ?? FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n // if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n\n if (!isTooltipPinned) {\n transform.current = assembleTransform(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);\n }\n\n // Get series nearby the cursor and pass into tooltip content children.\n const nearbySeries = getNearbySeriesData({\n mousePos,\n data,\n seriesMapping,\n pinnedPos,\n chart,\n unit,\n showAllSeries,\n });\n if (nearbySeries.length === 0) {\n return null;\n }\n\n const totalSeries = data.length;\n\n return (\n <Portal container={containerElement}>\n <Box\n ref={tooltipRef}\n sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)}\n style={{\n transform: transform.current,\n }}\n >\n <Stack spacing={0.5}>\n <TooltipHeader\n nearbySeries={nearbySeries}\n totalSeries={totalSeries}\n enablePinning={enablePinning}\n isTooltipPinned={isTooltipPinned}\n showAllSeries={showAllSeries}\n onShowAllClick={(checked) => setShowAllSeries(checked)}\n onUnpinClick={onUnpinClick}\n />\n <TooltipContent series={nearbySeries} wrapLabels={wrapLabels} />\n </Stack>\n </Box>\n </Portal>\n );\n});\n"],"names":["memo","useRef","useState","Box","Portal","Stack","useResizeObserver","FALLBACK_CHART_WIDTH","useMousePosition","assembleTransform","getTooltipStyles","getNearbySeriesData","TooltipHeader","TooltipContent","TimeChartTooltip","containerId","chartRef","data","seriesMapping","enablePinning","wrapLabels","unit","onUnpinClick","pinnedPos","showAllSeries","setShowAllSeries","transform","mousePos","height","width","ref","tooltipRef","isTooltipPinned","target","tagName","chart","current","chartWidth","getWidth","containerElement","document","querySelector","undefined","maxHeight","getBoundingClientRect","nearbySeries","length","totalSeries","container","sx","theme","style","spacing","onShowAllClick","checked","series"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC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,MAAM;QAAC4C,SAAS,EAAET,gBAAgB;kBACjC,cAAA,KAACpC,GAAG;YACF2B,GAAG,EAAEC,UAAU;YACfkB,EAAE,EAAE,CAACC,KAAK,GAAKxC,gBAAgB,CAACwC,KAAK,EAAE3B,SAAS,EAAEoB,SAAS,CAAC;YAC5DQ,KAAK,EAAE;gBACLzB,SAAS,EAAEA,SAAS,CAACU,OAAO;aAC7B;sBAED,cAAA,MAAC/B,KAAK;gBAAC+C,OAAO,EAAE,GAAG;;kCACjB,KAACxC,aAAa;wBACZiC,YAAY,EAAEA,YAAY;wBAC1BE,WAAW,EAAEA,WAAW;wBACxB5B,aAAa,EAAEA,aAAa;wBAC5Ba,eAAe,EAAEA,eAAe;wBAChCR,aAAa,EAAEA,aAAa;wBAC5B6B,cAAc,EAAE,CAACC,OAAO,GAAK7B,gBAAgB,CAAC6B,OAAO,CAAC;wBACtDhC,YAAY,EAAEA,YAAY;sBAC1B;kCACF,KAACT,cAAc;wBAAC0C,MAAM,EAAEV,YAAY;wBAAEzB,UAAU,EAAEA,UAAU;sBAAI;;cAC1D;UACJ;MACC,CACT;AACJ,CAAC,CAAC,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TimeChartTooltip.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { memo, useRef, useState } from 'react';\nimport { Box, Portal, Stack } from '@mui/material';\nimport { ECharts as EChartsInstance } from 'echarts/core';\nimport { FormatOptions, TimeSeries } from '@perses-dev/core';\nimport useResizeObserver from 'use-resize-observer';\nimport { TimeChartSeriesMapping } from '../model';\nimport { CursorCoordinates, FALLBACK_CHART_WIDTH, useMousePosition } from './tooltip-model';\nimport { assembleTransform, getTooltipStyles } from './utils';\nimport { getNearbySeriesData } from './nearby-series';\nimport { TooltipHeader } from './TooltipHeader';\nimport { TooltipContent } from './TooltipContent';\n\nexport interface TimeChartTooltipProps {\n chartRef: React.MutableRefObject<EChartsInstance | undefined>;\n data: TimeSeries[];\n seriesMapping: TimeChartSeriesMapping;\n enablePinning?: boolean;\n pinnedPos: CursorCoordinates | null;\n /**\n * The id of the container that will have the chart tooltip appended to it.\n * By default, the chart tooltip is attached to document.body.\n */\n containerId?: string;\n onUnpinClick?: () => void;\n format?: FormatOptions;\n wrapLabels?: boolean;\n}\n\nexport const TimeChartTooltip = memo(function TimeChartTooltip({\n containerId,\n chartRef,\n data,\n seriesMapping,\n enablePinning = true,\n wrapLabels,\n format,\n onUnpinClick,\n pinnedPos,\n}: TimeChartTooltipProps) {\n const [showAllSeries, setShowAllSeries] = useState(false);\n const transform = useRef('');\n\n const mousePos = useMousePosition();\n const { height, width, ref: tooltipRef } = useResizeObserver();\n\n const isTooltipPinned = pinnedPos !== null && enablePinning;\n\n if (mousePos === null || mousePos.target === null || data === null) return null;\n\n // Ensure user is hovering over a chart before checking for nearby series.\n if (pinnedPos === null && (mousePos.target as HTMLElement).tagName !== 'CANVAS') return null;\n\n const chart = chartRef.current;\n const chartWidth = chart?.getWidth() ?? FALLBACK_CHART_WIDTH; // Fallback width not likely to ever be needed.\n\n const containerElement = containerId ? document.querySelector(containerId) : undefined;\n // if tooltip is attached to a container, set max height to the height of the container so tooltip does not get cut off\n const maxHeight = containerElement ? containerElement.getBoundingClientRect().height : undefined;\n\n if (!isTooltipPinned) {\n transform.current = assembleTransform(mousePos, chartWidth, pinnedPos, height ?? 0, width ?? 0, containerElement);\n }\n\n // Get series nearby the cursor and pass into tooltip content children.\n const nearbySeries = getNearbySeriesData({\n mousePos,\n data,\n seriesMapping,\n pinnedPos,\n chart,\n format,\n showAllSeries,\n });\n if (nearbySeries.length === 0) {\n return null;\n }\n\n const totalSeries = data.length;\n\n return (\n <Portal container={containerElement}>\n <Box\n ref={tooltipRef}\n sx={(theme) => getTooltipStyles(theme, pinnedPos, maxHeight)}\n style={{\n transform: transform.current,\n }}\n >\n <Stack spacing={0.5}>\n <TooltipHeader\n nearbySeries={nearbySeries}\n totalSeries={totalSeries}\n enablePinning={enablePinning}\n isTooltipPinned={isTooltipPinned}\n showAllSeries={showAllSeries}\n onShowAllClick={(checked) => setShowAllSeries(checked)}\n onUnpinClick={onUnpinClick}\n />\n <TooltipContent series={nearbySeries} wrapLabels={wrapLabels} />\n </Stack>\n </Box>\n </Portal>\n );\n});\n"],"names":["memo","useRef","useState","Box","Portal","Stack","useResizeObserver","FALLBACK_CHART_WIDTH","useMousePosition","assembleTransform","getTooltipStyles","getNearbySeriesData","TooltipHeader","TooltipContent","TimeChartTooltip","containerId","chartRef","data","seriesMapping","enablePinning","wrapLabels","format","onUnpinClick","pinnedPos","showAllSeries","setShowAllSeries","transform","mousePos","height","width","ref","tooltipRef","isTooltipPinned","target","tagName","chart","current","chartWidth","getWidth","containerElement","document","querySelector","undefined","maxHeight","getBoundingClientRect","nearbySeries","length","totalSeries","container","sx","theme","style","spacing","onShowAllClick","checked","series"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,IAAI,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,QAAQ;AAC/C,SAASC,GAAG,EAAEC,MAAM,EAAEC,KAAK,QAAQ,gBAAgB;AAGnD,OAAOC,uBAAuB,sBAAsB;AAEpD,SAA4BC,oBAAoB,EAAEC,gBAAgB,QAAQ,kBAAkB;AAC5F,SAASC,iBAAiB,EAAEC,gBAAgB,QAAQ,UAAU;AAC9D,S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c9B,KAAK6B;IAEzB,qBACE,KAAC1C;QAAO4C,WAAWT;kBACjB,cAAA,KAACpC;YACC2B,KAAKC;YACLkB,IAAI,CAACC,QAAUxC,iBAAiBwC,OAAO3B,WAAWoB;YAClDQ,OAAO;gBACLzB,WAAWA,UAAUU;YACvB;sBAEA,cAAA,MAAC/B;gBAAM+C,SAAS;;kCACd,KAACxC;wBACCiC,cAAcA;wBACdE,aAAaA;wBACb5B,eAAeA;wBACfa,iBAAiBA;wBACjBR,eAAeA;wBACf6B,gBAAgB,CAACC,UAAY7B,iBAAiB6B;wBAC9ChC,cAAcA;;kCAEhB,KAACT;wBAAe0C,QAAQV;wBAAczB,YAAYA;;;;;;AAK5D,GAAG"}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo } from 'react';\nimport { Box } from '@mui/material';\nimport { NearbySeriesArray } from './nearby-series';\nimport { SeriesInfo } from './SeriesInfo';\n\nexport interface TooltipContentProps {\n series: NearbySeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { series, wrapLabels } = props;\n\n const sortedFocusedSeries = useMemo(() => {\n if (series === null) return null;\n return series.sort((a, b) => (a.y > b.y ? -1 : 1));\n }, [series]);\n\n if (series === null || sortedFocusedSeries === null) {\n return null;\n }\n // TODO: use react-virtuoso to improve performance\n return (\n <Box\n sx={(theme) => ({\n display: 'table',\n padding: theme.spacing(0.5, 2),\n })}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor, isClosestToCursor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n emphasizeText={isClosestToCursor}\n />\n );\n })}\n </Box>\n );\n}\n"],"names":["useMemo","Box","SeriesInfo","TooltipContent","props","series","wrapLabels","sortedFocusedSeries","sort","a","b","y","sx","theme","display","padding","spacing","map","datumIdx","seriesIdx","seriesName","formattedY","markerColor","isClosestToCursor","key","toString","totalSeries","length","emphasizeText"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;AAEjC;AAAA,SAASA,OAAO,QAAQ,OAAO,CAAC;AAChC,SAASC,GAAG,QAAQ,eAAe,CAAC;AAEpC,SAASC,UAAU,QAAQ,cAAc,CAAC;AAO1C,OAAO,SAASC,cAAc,CAACC,KAA0B,EAAE;IACzD,MAAM,EAAEC,MAAM,CAAA,EAAEC,UAAU,CAAA,EAAE,GAAGF,KAAK,AAAC;IAErC,MAAMG,mBAAmB,GAAGP,OAAO,CAAC,IAAM;QACxC,IAAIK,MAAM,KAAK,IAAI,EAAE,OAAO,IAAI,CAAC;QACjC,OAAOA,MAAM,CAACG,IAAI,CAAC,CAACC,CAAC,EAAEC,CAAC,GAAMD,CAAC,CAACE,CAAC,GAAGD,CAAC,CAACC,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,AAAC,CAAC,CAAC;IACrD,CAAC,EAAE;QAACN,MAAM;KAAC,CAAC,AAAC;IAEb,IAAIA,MAAM,KAAK,IAAI,IAAIE,mBAAmB,KAAK,IAAI,EAAE;QACnD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,kDAAkD;IAClD,qBACE,KAACN,GAAG;QACFW,EAAE,EAAE,CAACC,KAAK,GAAM,CAAA;gBACdC,OAAO,EAAE,OAAO;gBAChBC,OAAO,EAAEF,KAAK,CAACG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;aAC/B,CAAA,AAAC;kBAEDT,mBAAmB,CAACU,GAAG,CAAC,CAAC,EAAEC,QAAQ,CAAA,EAAEC,SAAS,CAAA,EAAEC,UAAU,CAAA,EAAET,CAAC,CAAA,EAAEU,UAAU,CAAA,EAAEC,WAAW,CAAA,EAAEC,iBAAiB,CAAA,EAAE,GAAK;YAC/G,IAAIL,QAAQ,KAAK,IAAI,IAAIC,SAAS,KAAK,IAAI,EAAE,OAAO,IAAI,CAAC;YACzD,MAAMK,GAAG,GAAGL,SAAS,CAACM,QAAQ,EAAE,GAAGP,QAAQ,CAACO,QAAQ,EAAE,AAAC;YAEvD,qBACE,KAACvB,UAAU;gBAETkB,UAAU,EAAEA,UAAU;gBACtBT,CAAC,EAAEA,CAAC;gBACJU,UAAU,EAAEA,UAAU;gBACtBC,WAAW,EAAEA,WAAW;gBACxBI,WAAW,EAAEnB,mBAAmB,CAACoB,MAAM;gBACvCrB,UAAU,EAAEA,UAAU;gBACtBsB,aAAa,EAAEL,iBAAiB;eAP3BC,GAAG,CAQR,CACF;QACJ,CAAC,CAAC;MACE,CACN;AACJ,CAAC"}
1
+ {"version":3,"sources":["../../src/TimeSeriesTooltip/TooltipContent.tsx"],"sourcesContent":["// Copyright 2023 The Perses Authors\n// Licensed under the Apache License, Version 2.0 (the \"License\");\n// you may not use this file except in compliance with the License.\n// You may obtain a copy of the License at\n//\n// http://www.apache.org/licenses/LICENSE-2.0\n//\n// Unless required by applicable law or agreed to in writing, software\n// distributed under the License is distributed on an \"AS IS\" BASIS,\n// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n// See the License for the specific language governing permissions and\n// limitations under the License.\n\nimport { useMemo } from 'react';\nimport { Box } from '@mui/material';\nimport { NearbySeriesArray } from './nearby-series';\nimport { SeriesInfo } from './SeriesInfo';\n\nexport interface TooltipContentProps {\n series: NearbySeriesArray | null;\n wrapLabels?: boolean;\n}\n\nexport function TooltipContent(props: TooltipContentProps) {\n const { series, wrapLabels } = props;\n\n const sortedFocusedSeries = useMemo(() => {\n if (series === null) return null;\n return series.sort((a, b) => (a.y > b.y ? -1 : 1));\n }, [series]);\n\n if (series === null || sortedFocusedSeries === null) {\n return null;\n }\n // TODO: use react-virtuoso to improve performance\n return (\n <Box\n sx={(theme) => ({\n display: 'table',\n padding: theme.spacing(0.5, 2),\n })}\n >\n {sortedFocusedSeries.map(({ datumIdx, seriesIdx, seriesName, y, formattedY, markerColor, isClosestToCursor }) => {\n if (datumIdx === null || seriesIdx === null) return null;\n const key = seriesIdx.toString() + datumIdx.toString();\n\n return (\n <SeriesInfo\n key={key}\n seriesName={seriesName}\n y={y}\n formattedY={formattedY}\n markerColor={markerColor}\n totalSeries={sortedFocusedSeries.length}\n wrapLabels={wrapLabels}\n emphasizeText={isClosestToCursor}\n />\n );\n })}\n </Box>\n );\n}\n"],"names":["useMemo","Box","SeriesInfo","TooltipContent","props","series","wrapLabels","sortedFocusedSeries","sort","a","b","y","sx","theme","display","padding","spacing","map","datumIdx","seriesIdx","seriesName","formattedY","markerColor","isClosestToCursor","key","toString","totalSeries","length","emphasizeText"],"mappings":"AAAA,oCAAoC;AACpC,kEAAkE;AAClE,mEAAmE;AACnE,0CAA0C;AAC1C,EAAE;AACF,6CAA6C;AAC7C,EAAE;AACF,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,sEAAsE;AACtE,iCAAiC;;AAEjC,SAASA,OAAO,QAAQ,QAAQ;AAChC,SAASC,GAAG,QAAQ,gBAAgB;AAEpC,SAASC,UAAU,QAAQ,eAAe;AAO1C,OAAO,SAASC,eAAeC,KAA0B;IACvD,MAAM,EAAEC,OAAM,EAAEC,WAAU,EAAE,GAAGF;IAE/B,MAAMG,sBAAsBP,QAAQ;QAClC,IAAIK,WAAW,MAAM,OAAO;QAC5B,OAAOA,OAAOG,KAAK,CAACC,GAAGC,IAAOD,EAAEE,IAAID,EAAEC,IAAI,CAAC,IAAI;IACjD,GAAG;QAACN;KAAO;IAEX,IAAIA,WAAW,QAAQE,wBAAwB,MAAM;QACnD,OAAO;IACT;IACA,kDAAkD;IAClD,qBACE,KAACN;QACCW,IAAI,CAACC,QAAW,CAAA;gBACdC,SAAS;gBACTC,SAASF,MAAMG,QAAQ,KAAK;YAC9B,CAAA;kBAECT,oBAAoBU,IAAI,CAAC,EAAEC,SAAQ,EAAEC,UAAS,EAAEC,WAAU,EAAET,EAAC,EAAEU,WAAU,EAAEC,YAAW,EAAEC,kBAAiB,EAAE;YAC1G,IAAIL,aAAa,QAAQC,cAAc,MAAM,OAAO;YACpD,MAAMK,MAAML,UAAUM,aAAaP,SAASO;YAE5C,qBACE,KAACvB;gBAECkB,YAAYA;gBACZT,GAAGA;gBACHU,YAAYA;gBACZC,aAAaA;gBACbI,aAAanB,oBAAoBoB;gBACjCrB,YAAYA;gBACZsB,eAAeL;eAPVC;QAUX;;AAGN"}
@@ -18,9 +18,9 @@ import { memo } from 'react';
18
18
  import { format } from 'date-fns';
19
19
  import { TOOLTIP_BG_COLOR_FALLBACK, TOOLTIP_MAX_WIDTH, PIN_TOOLTIP_HELP_TEXT, UNPIN_TOOLTIP_HELP_TEXT } from './tooltip-model';
20
20
  export const TooltipHeader = /*#__PURE__*/ memo(function TooltipHeader({ nearbySeries , totalSeries , isTooltipPinned , showAllSeries , enablePinning =true , onShowAllClick , onUnpinClick }) {
21
- var ref;
22
- var ref1;
23
- const seriesTimeMs = (ref1 = (ref = nearbySeries[0]) === null || ref === void 0 ? void 0 : ref.date) !== null && ref1 !== void 0 ? ref1 : null;
21
+ var _nearbySeries_;
22
+ var _nearbySeries__date;
23
+ const seriesTimeMs = (_nearbySeries__date = (_nearbySeries_ = nearbySeries[0]) === null || _nearbySeries_ === void 0 ? void 0 : _nearbySeries_.date) !== null && _nearbySeries__date !== void 0 ? _nearbySeries__date : null;
24
24
  if (seriesTimeMs === null) {
25
25
  return null;
26
26
  }
@@ -49,15 +49,15 @@ export const TooltipHeader = /*#__PURE__*/ memo(function TooltipHeader({ nearbyS
49
49
  // TODO: accurately calc whether more series are outside scrollable region using yBuffer, avg series name length, TOOLTIP_MAX_HEIGHT
50
50
  const showAllSeriesToggle = enablePinning && totalSeries > 5;
51
51
  const pinTooltipHelpText = isTooltipPinned ? UNPIN_TOOLTIP_HELP_TEXT : PIN_TOOLTIP_HELP_TEXT;
52
- var ref2;
52
+ var _theme_palette_designSystem_grey_;
53
53
  return /*#__PURE__*/ _jsxs(Box, {
54
54
  sx: (theme)=>{
55
- var ref;
55
+ var _theme_palette_designSystem;
56
56
  return {
57
57
  width: '100%',
58
58
  maxWidth: TOOLTIP_MAX_WIDTH,
59
59
  padding: theme.spacing(1.5, 2, 0.5, 2),
60
- backgroundColor: (ref2 = (ref = theme.palette.designSystem) === null || ref === void 0 ? void 0 : ref.grey[800]) !== null && ref2 !== void 0 ? ref2 : TOOLTIP_BG_COLOR_FALLBACK,
60
+ backgroundColor: (_theme_palette_designSystem_grey_ = (_theme_palette_designSystem = theme.palette.designSystem) === null || _theme_palette_designSystem === void 0 ? void 0 : _theme_palette_designSystem.grey[800]) !== null && _theme_palette_designSystem_grey_ !== void 0 ? _theme_palette_designSystem_grey_ : TOOLTIP_BG_COLOR_FALLBACK,
61
61
  position: 'sticky',
62
62
  top: 0,
63
63
  left: 0