@parca/profile 0.19.140 → 0.19.143

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 (182) hide show
  1. package/CHANGELOG.md +9 -1
  2. package/dist/GraphTooltipArrow/Content.js +224 -30
  3. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
  4. package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
  5. package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
  6. package/dist/GraphTooltipArrow/index.js +86 -56
  7. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
  8. package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +94 -68
  9. package/dist/MatchersInput/SuggestionItem.js +91 -12
  10. package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
  11. package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
  12. package/dist/MatchersInput/SuggestionsList.js +371 -157
  13. package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
  14. package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
  15. package/dist/MatchersInput/index.js +308 -115
  16. package/dist/MetricsCircle/index.js +39 -3
  17. package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
  18. package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
  19. package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
  20. package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
  21. package/dist/MetricsGraph/index.js +552 -203
  22. package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
  23. package/dist/MetricsGraph/utils/colorMapping.js +24 -17
  24. package/dist/MetricsSeries/index.js +70 -7
  25. package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
  26. package/dist/PreSelectedMatchers/index.js +249 -102
  27. package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
  28. package/dist/ProfileExplorer/ProfileExplorerCompare.js +240 -45
  29. package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
  30. package/dist/ProfileExplorer/index.js +183 -32
  31. package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
  32. package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
  33. package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
  34. package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
  35. package/dist/ProfileFlameChart/index.js +260 -126
  36. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
  37. package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
  38. package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
  39. package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
  40. package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
  41. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
  42. package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +71 -45
  43. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
  44. package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
  45. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
  46. package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
  47. package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
  48. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
  49. package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
  50. package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
  51. package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
  52. package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
  53. package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
  54. package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
  55. package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
  56. package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
  57. package/dist/ProfileFlameGraph/index.js +322 -147
  58. package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
  59. package/dist/ProfileMetricsGraph/index.js +515 -256
  60. package/dist/ProfileSelector/CompareButton.js +132 -12
  61. package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
  62. package/dist/ProfileSelector/index.d.ts +1 -1
  63. package/dist/ProfileSelector/index.d.ts.map +1 -1
  64. package/dist/ProfileSelector/index.js +734 -142
  65. package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
  66. package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
  67. package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
  68. package/dist/ProfileSource.js +230 -163
  69. package/dist/ProfileTypeSelector/index.js +214 -125
  70. package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
  71. package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +137 -32
  72. package/dist/ProfileView/components/ColorStackLegend.js +182 -54
  73. package/dist/ProfileView/components/DashboardItems/index.js +87 -28
  74. package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
  75. package/dist/ProfileView/components/DiffLegend.js +172 -29
  76. package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
  77. package/dist/ProfileView/components/InvertCallStack/index.js +97 -9
  78. package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
  79. package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
  80. package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
  81. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +191 -118
  82. package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
  83. package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
  84. package/dist/ProfileView/components/ShareButton/index.js +352 -62
  85. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
  86. package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +664 -192
  87. package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
  88. package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
  89. package/dist/ProfileView/components/Toolbars/index.js +441 -21
  90. package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
  91. package/dist/ProfileView/components/ViewSelector/index.js +186 -82
  92. package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
  93. package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
  94. package/dist/ProfileView/components/VisualizationPanel.js +185 -8
  95. package/dist/ProfileView/context/DashboardContext.js +74 -26
  96. package/dist/ProfileView/context/ProfileViewContext.js +56 -15
  97. package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
  98. package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
  99. package/dist/ProfileView/hooks/useResetFlameGraphState.js +31 -10
  100. package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
  101. package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
  102. package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
  103. package/dist/ProfileView/index.js +383 -45
  104. package/dist/ProfileView/types/visualization.js +1 -13
  105. package/dist/ProfileView/utils/colorUtils.js +8 -7
  106. package/dist/ProfileViewWithData.js +319 -225
  107. package/dist/QueryControls/index.js +418 -47
  108. package/dist/Sandwich/components/CalleesSection.js +54 -4
  109. package/dist/Sandwich/components/CallersSection.js +97 -27
  110. package/dist/Sandwich/components/TableSection.js +77 -4
  111. package/dist/Sandwich/index.js +125 -12
  112. package/dist/Sandwich/utils/processRowData.js +48 -39
  113. package/dist/SelectWithRefresh/index.js +102 -28
  114. package/dist/SimpleMatchers/Select.js +520 -187
  115. package/dist/SimpleMatchers/index.js +590 -288
  116. package/dist/SourceView/Highlighter.js +230 -70
  117. package/dist/SourceView/LineNo.js +72 -17
  118. package/dist/SourceView/index.js +177 -101
  119. package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
  120. package/dist/SourceView/lang-detector/index.js +28 -14
  121. package/dist/SourceView/useSelectedLineRange.js +72 -20
  122. package/dist/Table/ColorCell.js +42 -1
  123. package/dist/Table/ColumnsVisibility.js +114 -6
  124. package/dist/Table/MoreDropdown.js +107 -21
  125. package/dist/Table/TableContextMenu.js +144 -134
  126. package/dist/Table/TableContextMenuWrapper.js +59 -14
  127. package/dist/Table/hooks/useColorManagement.js +58 -16
  128. package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
  129. package/dist/Table/hooks/useTableConfiguration.js +323 -167
  130. package/dist/Table/index.js +217 -123
  131. package/dist/Table/utils/functions.js +169 -144
  132. package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
  133. package/dist/TimelineGuide/index.js +209 -16
  134. package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
  135. package/dist/TopTable/index.js +325 -121
  136. package/dist/contexts/LabelsQueryProvider.js +94 -32
  137. package/dist/contexts/UnifiedLabelsContext.js +114 -49
  138. package/dist/contexts/utils.js +37 -15
  139. package/dist/hooks/urlParsers.js +27 -15
  140. package/dist/hooks/useColorBy.js +47 -10
  141. package/dist/hooks/useCompareModeMeta.js +112 -62
  142. package/dist/hooks/useDashboardItems.js +52 -11
  143. package/dist/hooks/useLabels.js +295 -52
  144. package/dist/hooks/useQueryState.d.ts +1 -1
  145. package/dist/hooks/useQueryState.d.ts.map +1 -1
  146. package/dist/hooks/useQueryState.js +375 -329
  147. package/dist/index.js +11 -6
  148. package/dist/testdata/fg-diff.json +3750 -0
  149. package/dist/testdata/fg-simple.json +1879 -0
  150. package/dist/testdata/link_data.json +56 -0
  151. package/dist/testdata/tabular.json +30 -0
  152. package/dist/testdata/test_flamegraph.json +26846 -0
  153. package/dist/testdata/test_graph.json +53 -0
  154. package/dist/useDelayedLoader.js +32 -18
  155. package/dist/useGrpcQuery/index.js +71 -11
  156. package/dist/useHasProfileData.js +90 -12
  157. package/dist/useQuery.js +205 -64
  158. package/dist/useSumBy.d.ts.map +1 -1
  159. package/dist/useSumBy.js +294 -138
  160. package/dist/utils.js +62 -30
  161. package/package.json +9 -9
  162. package/src/GraphTooltipArrow/index.tsx +3 -0
  163. package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
  164. package/src/MatchersInput/SuggestionsList.tsx +11 -10
  165. package/src/MatchersInput/index.tsx +1 -1
  166. package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
  167. package/src/PreSelectedMatchers/index.tsx +3 -0
  168. package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -2
  169. package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
  170. package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
  171. package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
  172. package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
  173. package/src/ProfileSelector/index.tsx +31 -9
  174. package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
  175. package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
  176. package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
  177. package/src/Table/hooks/useTableConfiguration.tsx +7 -13
  178. package/src/hooks/useQueryState.ts +18 -3
  179. package/src/useDelayedLoader.ts +10 -10
  180. package/src/useSumBy.ts +12 -18
  181. package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
  182. package/dist/hooks/useQueryState.test.js +0 -868
@@ -1,4 +1,16 @@
1
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
5
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
6
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
7
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
8
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
9
+ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
10
+ function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
11
+ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
13
+ import { c as _c } from "react-compiler-runtime";
2
14
  // Copyright 2022 The Parca Authors
3
15
  // Licensed under the Apache License, Version 2.0 (the "License");
4
16
  // you may not use this file except in compliance with the License.
@@ -11,7 +23,8 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
11
23
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
24
  // See the License for the specific language governing permissions and
13
25
  // limitations under the License.
14
- import { Fragment, useCallback, useId, useMemo, useRef, useState } from 'react';
26
+
27
+ import React, { Fragment, useCallback, useId, useMemo, useRef, useState } from 'react';
15
28
  import * as d3 from 'd3';
16
29
  import { pointer } from 'd3-selection';
17
30
  import throttle from 'lodash.throttle';
@@ -24,214 +37,550 @@ import MetricsSeries from '../MetricsSeries';
24
37
  import MetricsContextMenu from './MetricsContextMenu';
25
38
  import MetricsInfoPanel from './MetricsInfoPanel';
26
39
  import MetricsTooltip from './MetricsTooltip';
27
- const MetricsGraph = ({ data, from, to, onSampleClick, setTimeRange, yAxisLabel, yAxisUnit, width = 0, height = 0, margin = 0, selectedPoint, contextMenuItems, renderTooltipContent, }) => {
28
- const [isInfoPanelOpen, setIsInfoPanelOpen] = useState(false);
29
- return (_jsxs("div", { className: "relative", ...testId(TEST_IDS.METRICS_GRAPH), onClick: () => isInfoPanelOpen && setIsInfoPanelOpen(false), children: [_jsx("div", { className: "absolute right-0 top-0", children: _jsx(MetricsInfoPanel, { isInfoPanelOpen: isInfoPanelOpen, onInfoIconClick: () => setIsInfoPanelOpen(true) }) }), _jsx(RawMetricsGraph, { data: data, from: from, to: to, onSampleClick: onSampleClick, setTimeRange: setTimeRange, yAxisLabel: yAxisLabel, yAxisUnit: yAxisUnit, width: width, height: height, margin: margin, selectedPoint: selectedPoint, contextMenuItems: contextMenuItems, renderTooltipContent: renderTooltipContent })] }));
40
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
41
+ var MetricsGraph = function MetricsGraph(t0) {
42
+ var $ = _c(24);
43
+ var data = t0.data,
44
+ from = t0.from,
45
+ to = t0.to,
46
+ onSampleClick = t0.onSampleClick,
47
+ setTimeRange = t0.setTimeRange,
48
+ yAxisLabel = t0.yAxisLabel,
49
+ yAxisUnit = t0.yAxisUnit,
50
+ t1 = t0.width,
51
+ t2 = t0.height,
52
+ t3 = t0.margin,
53
+ selectedPoint = t0.selectedPoint,
54
+ contextMenuItems = t0.contextMenuItems,
55
+ renderTooltipContent = t0.renderTooltipContent;
56
+ var width = t1 === undefined ? 0 : t1;
57
+ var height = t2 === undefined ? 0 : t2;
58
+ var margin = t3 === undefined ? 0 : t3;
59
+ var _useState = useState(false),
60
+ _useState2 = _slicedToArray(_useState, 2),
61
+ isInfoPanelOpen = _useState2[0],
62
+ setIsInfoPanelOpen = _useState2[1];
63
+ var t4;
64
+ if ($[0] === Symbol["for"]("react.memo_cache_sentinel")) {
65
+ t4 = testId(TEST_IDS.METRICS_GRAPH);
66
+ $[0] = t4;
67
+ } else {
68
+ t4 = $[0];
69
+ }
70
+ var t5;
71
+ if ($[1] !== isInfoPanelOpen) {
72
+ t5 = function t5() {
73
+ return isInfoPanelOpen && setIsInfoPanelOpen(false);
74
+ };
75
+ $[1] = isInfoPanelOpen;
76
+ $[2] = t5;
77
+ } else {
78
+ t5 = $[2];
79
+ }
80
+ var t6;
81
+ if ($[3] === Symbol["for"]("react.memo_cache_sentinel")) {
82
+ t6 = function t6() {
83
+ return setIsInfoPanelOpen(true);
84
+ };
85
+ $[3] = t6;
86
+ } else {
87
+ t6 = $[3];
88
+ }
89
+ var t7;
90
+ if ($[4] !== isInfoPanelOpen) {
91
+ t7 = /*#__PURE__*/_jsx("div", {
92
+ className: "absolute right-0 top-0",
93
+ children: /*#__PURE__*/_jsx(MetricsInfoPanel, {
94
+ isInfoPanelOpen: isInfoPanelOpen,
95
+ onInfoIconClick: t6
96
+ })
97
+ });
98
+ $[4] = isInfoPanelOpen;
99
+ $[5] = t7;
100
+ } else {
101
+ t7 = $[5];
102
+ }
103
+ var t8;
104
+ if ($[6] !== contextMenuItems || $[7] !== data || $[8] !== from || $[9] !== height || $[10] !== margin || $[11] !== onSampleClick || $[12] !== renderTooltipContent || $[13] !== selectedPoint || $[14] !== setTimeRange || $[15] !== to || $[16] !== width || $[17] !== yAxisLabel || $[18] !== yAxisUnit) {
105
+ t8 = /*#__PURE__*/_jsx(RawMetricsGraph, {
106
+ data: data,
107
+ from: from,
108
+ to: to,
109
+ onSampleClick: onSampleClick,
110
+ setTimeRange: setTimeRange,
111
+ yAxisLabel: yAxisLabel,
112
+ yAxisUnit: yAxisUnit,
113
+ width: width,
114
+ height: height,
115
+ margin: margin,
116
+ selectedPoint: selectedPoint,
117
+ contextMenuItems: contextMenuItems,
118
+ renderTooltipContent: renderTooltipContent
119
+ });
120
+ $[6] = contextMenuItems;
121
+ $[7] = data;
122
+ $[8] = from;
123
+ $[9] = height;
124
+ $[10] = margin;
125
+ $[11] = onSampleClick;
126
+ $[12] = renderTooltipContent;
127
+ $[13] = selectedPoint;
128
+ $[14] = setTimeRange;
129
+ $[15] = to;
130
+ $[16] = width;
131
+ $[17] = yAxisLabel;
132
+ $[18] = yAxisUnit;
133
+ $[19] = t8;
134
+ } else {
135
+ t8 = $[19];
136
+ }
137
+ var t9;
138
+ if ($[20] !== t5 || $[21] !== t7 || $[22] !== t8) {
139
+ t9 = /*#__PURE__*/_jsxs("div", _objectSpread(_objectSpread({
140
+ className: "relative"
141
+ }, t4), {}, {
142
+ onClick: t5,
143
+ children: [t7, t8]
144
+ }));
145
+ $[20] = t5;
146
+ $[21] = t7;
147
+ $[22] = t8;
148
+ $[23] = t9;
149
+ } else {
150
+ t9 = $[23];
151
+ }
152
+ return t9;
30
153
  };
31
154
  export default MetricsGraph;
32
- export const parseValue = (value) => {
33
- const val = parseFloat(value);
34
- // "+Inf", "-Inf", "+Inf" will be parsed into NaN by parseFloat(). They
35
- // can't be graphed, so show them as gaps (null).
36
- return isNaN(val) ? null : val;
155
+ export var parseValue = function parseValue(value) {
156
+ var val = parseFloat(value);
157
+ // "+Inf", "-Inf", "+Inf" will be parsed into NaN by parseFloat(). They
158
+ // can't be graphed, so show them as gaps (null).
159
+ return isNaN(val) ? null : val;
37
160
  };
38
- const lineStroke = '1px';
39
- const lineStrokeHover = '2px';
40
- export const RawMetricsGraph = ({ data, from, to, onSampleClick, setTimeRange, yAxisLabel, yAxisUnit, width, height = 50, margin = 0, selectedPoint, contextMenuItems, renderTooltipContent, }) => {
41
- const { timezone } = useParcaContext();
42
- const graph = useRef(null);
43
- const [dragging, setDragging] = useState(false);
44
- const [hovering, setHovering] = useState(false);
45
- const [relPos, setRelPos] = useState(-1);
46
- const [pos, setPos] = useState([0, 0]);
47
- const [isContextMenuOpen, setIsContextMenuOpen] = useState(false);
48
- const metricPointRef = useRef(null);
49
- const idForContextMenu = useId();
50
- if (width === undefined || width == null) {
51
- width = 0;
52
- }
53
- const graphWidth = useMemo(() => width - margin * 1.5 - margin / 2, [width, margin]);
54
- const graphTransform = useMemo(() => {
55
- // Adds 6px padding which aligns the graph on the grid
56
- return `translate(6, 0) scale(${(graphWidth - 6) / graphWidth}, 1)`;
57
- }, [graphWidth]);
58
- const series = data;
59
- const extentsY = series.map(function (s) {
60
- return d3.extent(s.values, function (d) {
61
- return d[1]; // d[1] is the value
62
- });
63
- });
64
- const minY = d3.min(extentsY, function (d) {
65
- return d[0];
161
+ var lineStroke = '1px';
162
+ var lineStrokeHover = '2px';
163
+ export var RawMetricsGraph = function RawMetricsGraph(_ref) {
164
+ var _series$highlighted$s, _series$highlighted$s2, _series$selected$seri, _series$selected$seri2;
165
+ var data = _ref.data,
166
+ from = _ref.from,
167
+ to = _ref.to,
168
+ onSampleClick = _ref.onSampleClick,
169
+ setTimeRange = _ref.setTimeRange,
170
+ yAxisLabel = _ref.yAxisLabel,
171
+ yAxisUnit = _ref.yAxisUnit,
172
+ width = _ref.width,
173
+ _ref$height = _ref.height,
174
+ height = _ref$height === void 0 ? 50 : _ref$height,
175
+ _ref$margin = _ref.margin,
176
+ margin = _ref$margin === void 0 ? 0 : _ref$margin,
177
+ selectedPoint = _ref.selectedPoint,
178
+ contextMenuItems = _ref.contextMenuItems,
179
+ renderTooltipContent = _ref.renderTooltipContent;
180
+ var _useParcaContext = useParcaContext(),
181
+ timezone = _useParcaContext.timezone;
182
+ var graph = useRef(null);
183
+ var _useState3 = useState(false),
184
+ _useState4 = _slicedToArray(_useState3, 2),
185
+ dragging = _useState4[0],
186
+ setDragging = _useState4[1];
187
+ var _useState5 = useState(false),
188
+ _useState6 = _slicedToArray(_useState5, 2),
189
+ hovering = _useState6[0],
190
+ setHovering = _useState6[1];
191
+ var _useState7 = useState(-1),
192
+ _useState8 = _slicedToArray(_useState7, 2),
193
+ relPos = _useState8[0],
194
+ setRelPos = _useState8[1];
195
+ var _useState9 = useState([0, 0]),
196
+ _useState0 = _slicedToArray(_useState9, 2),
197
+ pos = _useState0[0],
198
+ setPos = _useState0[1];
199
+ var _useState1 = useState(false),
200
+ _useState10 = _slicedToArray(_useState1, 2),
201
+ isContextMenuOpen = _useState10[0],
202
+ setIsContextMenuOpen = _useState10[1];
203
+ var metricPointRef = useRef(null);
204
+ var idForContextMenu = useId();
205
+ if (width === undefined || width == null) {
206
+ width = 0;
207
+ }
208
+ var graphWidth = useMemo(function () {
209
+ return width - margin * 1.5 - margin / 2;
210
+ }, [width, margin]);
211
+ var graphTransform = useMemo(function () {
212
+ // Adds 6px padding which aligns the graph on the grid
213
+ return "translate(6, 0) scale(".concat((graphWidth - 6) / graphWidth, ", 1)");
214
+ }, [graphWidth]);
215
+ var series = data;
216
+ var extentsY = series.map(function (s) {
217
+ return d3.extent(s.values, function (d) {
218
+ return d[1]; // d[1] is the value
66
219
  });
67
- const maxY = d3.max(extentsY, function (d) {
68
- return d[1];
69
- });
70
- /* Scale */
71
- const xScale = d3.scaleUtc().domain([from, to]).range([0, graphWidth]);
72
- const yScale = d3
73
- .scaleLinear()
74
- // tslint:disable-next-line
75
- .domain([minY, maxY])
76
- .range([height - margin, 0])
77
- .nice();
78
- // Create deterministic color mapping based on series IDs
79
- const color = useMemo(() => d3.scaleOrdinal(d3.schemeCategory10), []);
80
- const l = d3.line(d => xScale(d[0]), d => yScale(d[1]));
81
- const closestPoint = useMemo(() => {
82
- // Guard against empty series
83
- if (series.length === 0) {
84
- return null;
85
- }
86
- const closestPointPerSeries = series.map(function (s) {
87
- if (s.values.length === 0) {
88
- return {
89
- pointIndex: undefined,
90
- distance: Infinity,
91
- };
92
- }
93
- const distances = s.values.map(d => {
94
- const x = xScale(d[0]) + margin / 2; // d[0] is timestamp_ms
95
- const y = yScale(d[1]) - margin / 3; // d[1] is value
96
- // Cartesian distance from the mouse position to the point
97
- return Math.sqrt(Math.pow(pos[0] - x, 2) + Math.pow(pos[1] - y, 2));
98
- });
99
- const pointIndex = d3.minIndex(distances);
100
- const minDistance = pointIndex != null ? distances[pointIndex] : Infinity;
101
- return {
102
- pointIndex,
103
- distance: minDistance,
104
- };
105
- });
106
- const closestSeriesIndex = d3.minIndex(closestPointPerSeries, s => s.distance);
107
- if (closestSeriesIndex == null || closestPointPerSeries[closestSeriesIndex] == null) {
108
- return null;
109
- }
110
- const pointIndex = closestPointPerSeries[closestSeriesIndex].pointIndex;
111
- if (pointIndex == null) {
112
- return null;
113
- }
114
- return {
115
- seriesIndex: closestSeriesIndex,
116
- pointIndex,
117
- };
118
- }, [pos, series, xScale, yScale, margin]);
119
- const highlighted = useMemo(() => {
120
- if (series.length === 0 || closestPoint == null) {
121
- return null;
122
- }
123
- const point = series[closestPoint.seriesIndex].values[closestPoint.pointIndex];
124
- return {
125
- seriesIndex: closestPoint.seriesIndex,
126
- pointIndex: closestPoint.pointIndex,
127
- x: xScale(point[0]),
128
- y: yScale(point[1]),
129
- };
130
- }, [closestPoint, series, xScale, yScale]);
131
- const selected = useMemo(() => {
132
- if (series.length === 0 || selectedPoint == null) {
133
- return null;
134
- }
135
- const point = series[selectedPoint.seriesIndex].values[selectedPoint.pointIndex];
220
+ });
221
+ var minY = d3.min(extentsY, function (d_0) {
222
+ return d_0[0];
223
+ });
224
+ var maxY = d3.max(extentsY, function (d_1) {
225
+ return d_1[1];
226
+ });
227
+
228
+ /* Scale */
229
+ var xScale = d3.scaleUtc().domain([from, to]).range([0, graphWidth]);
230
+ var yScale = d3.scaleLinear()
231
+ // tslint:disable-next-line
232
+ .domain([minY, maxY]).range([height - margin, 0]).nice();
233
+
234
+ // Create deterministic color mapping based on series IDs
235
+ var color = useMemo(function () {
236
+ return d3.scaleOrdinal(d3.schemeCategory10);
237
+ }, []);
238
+ var l = d3.line(function (d_2) {
239
+ return xScale(d_2[0]);
240
+ }, function (d_3) {
241
+ return yScale(d_3[1]);
242
+ });
243
+ var closestPoint = useMemo(function () {
244
+ // Guard against empty series
245
+ if (series.length === 0) {
246
+ return null;
247
+ }
248
+ var closestPointPerSeries = series.map(function (s_0) {
249
+ if (s_0.values.length === 0) {
136
250
  return {
137
- seriesIndex: selectedPoint.seriesIndex,
138
- pointIndex: selectedPoint.pointIndex,
139
- x: xScale(point[0]),
140
- y: yScale(point[1]),
251
+ pointIndex: undefined,
252
+ distance: Infinity
141
253
  };
142
- }, [selectedPoint, series, xScale, yScale]);
143
- const onMouseDown = (e) => {
144
- // only left mouse button
145
- if (e.button !== 0) {
146
- return;
147
- }
148
- // X/Y coordinate array relative to svg
149
- const rel = pointer(e);
150
- const xCoordinate = rel[0];
151
- const xCoordinateWithoutMargin = xCoordinate - margin;
152
- if (xCoordinateWithoutMargin >= 0) {
153
- setRelPos(xCoordinateWithoutMargin);
154
- setDragging(true);
155
- }
156
- e.stopPropagation();
157
- e.preventDefault();
158
- };
159
- const handleClosestPointClick = () => {
160
- if (closestPoint != null) {
161
- onSampleClick(closestPoint);
162
- }
254
+ }
255
+ var distances = s_0.values.map(function (d_4) {
256
+ var x = xScale(d_4[0]) + margin / 2; // d[0] is timestamp_ms
257
+ var y = yScale(d_4[1]) - margin / 3; // d[1] is value
258
+
259
+ // Cartesian distance from the mouse position to the point
260
+ return Math.sqrt(Math.pow(pos[0] - x, 2) + Math.pow(pos[1] - y, 2));
261
+ });
262
+ var pointIndex = d3.minIndex(distances);
263
+ var minDistance = pointIndex != null ? distances[pointIndex] : Infinity;
264
+ return {
265
+ pointIndex: pointIndex,
266
+ distance: minDistance
267
+ };
268
+ });
269
+ var closestSeriesIndex = d3.minIndex(closestPointPerSeries, function (s_1) {
270
+ return s_1.distance;
271
+ });
272
+ if (closestSeriesIndex == null || closestPointPerSeries[closestSeriesIndex] == null) {
273
+ return null;
274
+ }
275
+ var pointIndex_0 = closestPointPerSeries[closestSeriesIndex].pointIndex;
276
+ if (pointIndex_0 == null) {
277
+ return null;
278
+ }
279
+ return {
280
+ seriesIndex: closestSeriesIndex,
281
+ pointIndex: pointIndex_0
163
282
  };
164
- const onMouseUp = (e) => {
165
- setDragging(false);
166
- if (relPos === -1) {
167
- // MouseDown happened outside of this element.
168
- return;
169
- }
170
- // This is a normal click. We tolerate tiny movements to still be a
171
- // click as they can occur when clicking based on user feedback.
172
- if (Math.abs(relPos - pos[0]) <= 1) {
173
- handleClosestPointClick();
174
- setRelPos(-1);
175
- return;
176
- }
177
- let startPos = relPos;
178
- let endPos = pos[0];
179
- if (startPos > endPos) {
180
- startPos = pos[0];
181
- endPos = relPos;
182
- }
183
- const startCorrection = 10;
184
- const endCorrection = 30;
185
- const firstTime = xScale.invert(startPos - startCorrection).valueOf();
186
- const secondTime = xScale.invert(endPos - endCorrection).valueOf();
187
- setTimeRange(DateTimeRange.fromAbsoluteDates(firstTime, secondTime));
188
- setRelPos(-1);
189
- e.stopPropagation();
190
- e.preventDefault();
283
+ }, [pos, series, xScale, yScale, margin]);
284
+ var highlighted = useMemo(function () {
285
+ if (series.length === 0 || closestPoint == null) {
286
+ return null;
287
+ }
288
+ var point = series[closestPoint.seriesIndex].values[closestPoint.pointIndex];
289
+ return {
290
+ seriesIndex: closestPoint.seriesIndex,
291
+ pointIndex: closestPoint.pointIndex,
292
+ x: xScale(point[0]),
293
+ y: yScale(point[1])
191
294
  };
192
- const throttledSetPos = throttle(setPos, 20);
193
- const onMouseMove = (e) => {
194
- if (isContextMenuOpen) {
195
- return;
196
- }
197
- // X/Y coordinate array relative to svg
198
- const rel = pointer(e);
199
- const xCoordinate = rel[0];
200
- const xCoordinateWithoutMargin = xCoordinate - margin;
201
- const yCoordinate = rel[1];
202
- const yCoordinateWithoutMargin = yCoordinate - margin;
203
- throttledSetPos([xCoordinateWithoutMargin, yCoordinateWithoutMargin]);
295
+ }, [closestPoint, series, xScale, yScale]);
296
+ var selected = useMemo(function () {
297
+ if (series.length === 0 || selectedPoint == null) {
298
+ return null;
299
+ }
300
+ var point_0 = series[selectedPoint.seriesIndex].values[selectedPoint.pointIndex];
301
+ return {
302
+ seriesIndex: selectedPoint.seriesIndex,
303
+ pointIndex: selectedPoint.pointIndex,
304
+ x: xScale(point_0[0]),
305
+ y: yScale(point_0[1])
204
306
  };
205
- const MENU_ID = `metrics-context-menu-${idForContextMenu}`;
206
- const { show } = useContextMenu({
207
- id: MENU_ID,
307
+ }, [selectedPoint, series, xScale, yScale]);
308
+ var onMouseDown = function onMouseDown(e) {
309
+ // only left mouse button
310
+ if (e.button !== 0) {
311
+ return;
312
+ }
313
+
314
+ // X/Y coordinate array relative to svg
315
+ var rel = pointer(e);
316
+ var xCoordinate = rel[0];
317
+ var xCoordinateWithoutMargin = xCoordinate - margin;
318
+ if (xCoordinateWithoutMargin >= 0) {
319
+ setRelPos(xCoordinateWithoutMargin);
320
+ setDragging(true);
321
+ }
322
+ e.stopPropagation();
323
+ e.preventDefault();
324
+ };
325
+ var handleClosestPointClick = function handleClosestPointClick() {
326
+ if (closestPoint != null) {
327
+ onSampleClick(closestPoint);
328
+ }
329
+ };
330
+ var onMouseUp = function onMouseUp(e_0) {
331
+ setDragging(false);
332
+ if (relPos === -1) {
333
+ // MouseDown happened outside of this element.
334
+ return;
335
+ }
336
+
337
+ // This is a normal click. We tolerate tiny movements to still be a
338
+ // click as they can occur when clicking based on user feedback.
339
+ if (Math.abs(relPos - pos[0]) <= 1) {
340
+ handleClosestPointClick();
341
+ setRelPos(-1);
342
+ return;
343
+ }
344
+ var startPos = relPos;
345
+ var endPos = pos[0];
346
+ if (startPos > endPos) {
347
+ startPos = pos[0];
348
+ endPos = relPos;
349
+ }
350
+ var startCorrection = 10;
351
+ var endCorrection = 30;
352
+ var firstTime = xScale.invert(startPos - startCorrection).valueOf();
353
+ var secondTime = xScale.invert(endPos - endCorrection).valueOf();
354
+ setTimeRange(DateTimeRange.fromAbsoluteDates(firstTime, secondTime));
355
+ setRelPos(-1);
356
+ e_0.stopPropagation();
357
+ e_0.preventDefault();
358
+ };
359
+ var throttledSetPos = throttle(setPos, 20);
360
+ var onMouseMove = function onMouseMove(e_1) {
361
+ if (isContextMenuOpen) {
362
+ return;
363
+ }
364
+
365
+ // X/Y coordinate array relative to svg
366
+ var rel_0 = pointer(e_1);
367
+ var xCoordinate_0 = rel_0[0];
368
+ var xCoordinateWithoutMargin_0 = xCoordinate_0 - margin;
369
+ var yCoordinate = rel_0[1];
370
+ var yCoordinateWithoutMargin = yCoordinate - margin;
371
+ throttledSetPos([xCoordinateWithoutMargin_0, yCoordinateWithoutMargin]);
372
+ };
373
+ var MENU_ID = "metrics-context-menu-".concat(idForContextMenu);
374
+ var _useContextMenu = useContextMenu({
375
+ id: MENU_ID
376
+ }),
377
+ show = _useContextMenu.show;
378
+ var displayMenu = useCallback(function (e_2) {
379
+ show({
380
+ event: e_2
208
381
  });
209
- const displayMenu = useCallback((e) => {
210
- show({
211
- event: e,
212
- });
213
- }, [show]);
214
- const trackVisibility = (isVisible) => {
215
- setIsContextMenuOpen(isVisible);
216
- };
217
- return (_jsxs(_Fragment, { children: [contextMenuItems != null && (_jsx(MetricsContextMenu, { menuId: MENU_ID, closestPoint: closestPoint, series: series, trackVisibility: trackVisibility, menuItems: contextMenuItems })), highlighted != null && hovering && !dragging && pos[0] !== 0 && pos[1] !== 0 && (_jsx("div", { onMouseMove: onMouseMove, onMouseEnter: () => setHovering(true), onMouseLeave: () => setHovering(false), children: !isContextMenuOpen && (_jsx(MetricsTooltip, { x: pos[0] + margin, y: pos[1] + margin, contextElement: graph.current, content: renderTooltipContent?.(highlighted.seriesIndex, highlighted.pointIndex) })) })), _jsx("div", { ref: graph, onMouseEnter: function () {
218
- setHovering(true);
219
- }, onMouseLeave: () => setHovering(false), onContextMenu: displayMenu, children: _jsxs("svg", { width: `${width}px`, height: `${height + margin}px`, onMouseDown: onMouseDown, onMouseUp: onMouseUp, onMouseMove: onMouseMove, children: [_jsx("g", { transform: `translate(${margin}, 0)`, children: dragging && (_jsx("g", { className: "zoom-time-rect", children: _jsx("rect", { className: "bar", x: pos[0] - relPos < 0 ? pos[0] : relPos, y: 0, height: height, width: Math.abs(pos[0] - relPos), fill: 'rgba(0, 0, 0, 0.125)' }) })) }), _jsxs("g", { transform: `translate(${margin * 1.5}, ${margin / 1.5})`, children: [_jsxs("g", { className: "y axis", textAnchor: "end", fontSize: "10", fill: "none", children: [yScale.ticks(5).map((d, i, allTicks) => {
220
- let decimals = 2;
221
- const intervalBetweenTicks = allTicks[1] - allTicks[0];
222
- if (intervalBetweenTicks < 1) {
223
- const precision = getPrecision(intervalBetweenTicks);
224
- decimals = precision;
225
- }
226
- return (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick",
227
- /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
228
- transform: `translate(0, ${yScale(d)})`, children: [_jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x2: -6 }), _jsx("text", { fill: "currentColor", x: -9, dy: '0.32em', children: valueFormatter(d, yAxisUnit, decimals) })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(from), x2: xScale(to), y1: yScale(d), y2: yScale(d) }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`));
229
- }), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: 0, x2: 0, y1: 0, y2: height - margin }), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(to), x2: xScale(to), y1: 0, y2: height - margin }), _jsx("g", { transform: `translate(${-margin}, ${(height - margin) / 2}) rotate(270)`, children: _jsx("text", { fill: "currentColor", dy: "-0.7em", className: "text-sm capitalize", textAnchor: "middle", children: yAxisLabel }) })] }), _jsxs("g", { className: "x axis", fill: "none", fontSize: "10", textAnchor: "middle", transform: `translate(0,${height - margin})`, children: [xScale.ticks(5).map((d, i) => (_jsxs(Fragment, { children: [_jsxs("g", { className: "tick",
230
- /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */
231
- transform: `translate(${xScale(d)}, 0)`, children: [_jsx("line", { y2: 6, className: "stroke-gray-300 dark:stroke-gray-500" }), _jsx("text", { fill: "currentColor", dy: ".71em", y: 9, children: formatDate(d, formatForTimespan(from, to), timezone) })] }, `tick-${i}`), _jsx("g", { children: _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: xScale(d), x2: xScale(d), y1: 0, y2: -height + margin }) }, `grid-${i}`)] }, `${i.toString()}-${d.toString()}`))), _jsx("line", { className: "stroke-gray-300 dark:stroke-gray-500", x1: 0, x2: graphWidth, y1: 0, y2: 0 }), _jsx("g", { transform: `translate(${(width - 2.5 * margin) / 2}, ${margin / 2})`, children: _jsx("text", { fill: "currentColor", dy: ".71em", y: 5, className: "text-sm", children: "Time" }) })] }), _jsx("g", { className: "lines fill-transparent", transform: graphTransform, width: graphWidth - 100, children: series.map((s, i) => (_jsx("g", { className: "line", children: _jsx(MetricsSeries, { data: s, line: l, color: color(s.id), strokeWidth: (hovering && highlighted != null && i === highlighted.seriesIndex) ||
232
- s.highlighted === true
233
- ? lineStrokeHover
234
- : lineStroke, xScale: xScale, yScale: yScale }) }, s.id))) }), hovering && highlighted != null && (_jsx("g", { className: "circle-group", ref: metricPointRef, style: { fill: color(series[highlighted.seriesIndex]?.id ?? '0') }, transform: graphTransform, children: _jsx(MetricsCircle, { cx: highlighted.x, cy: highlighted.y }) })), selected != null && (_jsx("g", { className: "circle-group", style: selected?.seriesIndex != null
235
- ? { fill: color(series[selected.seriesIndex]?.id ?? '0') }
236
- : {}, transform: graphTransform, children: _jsx(MetricsCircle, { cx: selected.x, cy: selected.y, radius: 5 }) }))] })] }) })] }));
237
- };
382
+ }, [show]);
383
+ var trackVisibility = function trackVisibility(isVisible) {
384
+ setIsContextMenuOpen(isVisible);
385
+ };
386
+ return /*#__PURE__*/_jsxs(_Fragment, {
387
+ children: [contextMenuItems != null && /*#__PURE__*/_jsx(MetricsContextMenu, {
388
+ menuId: MENU_ID,
389
+ closestPoint: closestPoint,
390
+ series: series,
391
+ trackVisibility: trackVisibility,
392
+ menuItems: contextMenuItems
393
+ }), highlighted != null && hovering && !dragging && pos[0] !== 0 && pos[1] !== 0 && /*#__PURE__*/_jsx("div", {
394
+ onMouseMove: onMouseMove,
395
+ onMouseEnter: function onMouseEnter() {
396
+ return setHovering(true);
397
+ },
398
+ onMouseLeave: function onMouseLeave() {
399
+ return setHovering(false);
400
+ },
401
+ children: !isContextMenuOpen && /*#__PURE__*/_jsx(MetricsTooltip, {
402
+ x: pos[0] + margin,
403
+ y: pos[1] + margin,
404
+ contextElement: graph.current,
405
+ content: renderTooltipContent === null || renderTooltipContent === void 0 ? void 0 : renderTooltipContent(highlighted.seriesIndex, highlighted.pointIndex)
406
+ })
407
+ }), /*#__PURE__*/_jsx("div", {
408
+ ref: graph,
409
+ onMouseEnter: function onMouseEnter() {
410
+ setHovering(true);
411
+ },
412
+ onMouseLeave: function onMouseLeave() {
413
+ return setHovering(false);
414
+ },
415
+ onContextMenu: displayMenu,
416
+ children: /*#__PURE__*/_jsxs("svg", {
417
+ width: "".concat(width, "px"),
418
+ height: "".concat(height + margin, "px"),
419
+ onMouseDown: onMouseDown,
420
+ onMouseUp: onMouseUp,
421
+ onMouseMove: onMouseMove,
422
+ children: [/*#__PURE__*/_jsx("g", {
423
+ transform: "translate(".concat(margin, ", 0)"),
424
+ children: dragging && /*#__PURE__*/_jsx("g", {
425
+ className: "zoom-time-rect",
426
+ children: /*#__PURE__*/_jsx("rect", {
427
+ className: "bar",
428
+ x: pos[0] - relPos < 0 ? pos[0] : relPos,
429
+ y: 0,
430
+ height: height,
431
+ width: Math.abs(pos[0] - relPos),
432
+ fill: 'rgba(0, 0, 0, 0.125)'
433
+ })
434
+ })
435
+ }), /*#__PURE__*/_jsxs("g", {
436
+ transform: "translate(".concat(margin * 1.5, ", ").concat(margin / 1.5, ")"),
437
+ children: [/*#__PURE__*/_jsxs("g", {
438
+ className: "y axis",
439
+ textAnchor: "end",
440
+ fontSize: "10",
441
+ fill: "none",
442
+ children: [yScale.ticks(5).map(function (d_5, i, allTicks) {
443
+ var decimals = 2;
444
+ var intervalBetweenTicks = allTicks[1] - allTicks[0];
445
+ if (intervalBetweenTicks < 1) {
446
+ var precision = getPrecision(intervalBetweenTicks);
447
+ decimals = precision;
448
+ }
449
+ return /*#__PURE__*/_jsxs(Fragment, {
450
+ children: [/*#__PURE__*/_jsxs("g", {
451
+ className: "tick"
452
+ /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */,
453
+ transform: "translate(0, ".concat(yScale(d_5), ")"),
454
+ children: [/*#__PURE__*/_jsx("line", {
455
+ className: "stroke-gray-300 dark:stroke-gray-500",
456
+ x2: -6
457
+ }), /*#__PURE__*/_jsx("text", {
458
+ fill: "currentColor",
459
+ x: -9,
460
+ dy: '0.32em',
461
+ children: valueFormatter(d_5, yAxisUnit, decimals)
462
+ })]
463
+ }, "tick-".concat(i)), /*#__PURE__*/_jsx("g", {
464
+ children: /*#__PURE__*/_jsx("line", {
465
+ className: "stroke-gray-300 dark:stroke-gray-500",
466
+ x1: xScale(from),
467
+ x2: xScale(to),
468
+ y1: yScale(d_5),
469
+ y2: yScale(d_5)
470
+ })
471
+ }, "grid-".concat(i))]
472
+ }, "".concat(i.toString(), "-").concat(d_5.toString()));
473
+ }), /*#__PURE__*/_jsx("line", {
474
+ className: "stroke-gray-300 dark:stroke-gray-500",
475
+ x1: 0,
476
+ x2: 0,
477
+ y1: 0,
478
+ y2: height - margin
479
+ }), /*#__PURE__*/_jsx("line", {
480
+ className: "stroke-gray-300 dark:stroke-gray-500",
481
+ x1: xScale(to),
482
+ x2: xScale(to),
483
+ y1: 0,
484
+ y2: height - margin
485
+ }), /*#__PURE__*/_jsx("g", {
486
+ transform: "translate(".concat(-margin, ", ").concat((height - margin) / 2, ") rotate(270)"),
487
+ children: /*#__PURE__*/_jsx("text", {
488
+ fill: "currentColor",
489
+ dy: "-0.7em",
490
+ className: "text-sm capitalize",
491
+ textAnchor: "middle",
492
+ children: yAxisLabel
493
+ })
494
+ })]
495
+ }), /*#__PURE__*/_jsxs("g", {
496
+ className: "x axis",
497
+ fill: "none",
498
+ fontSize: "10",
499
+ textAnchor: "middle",
500
+ transform: "translate(0,".concat(height - margin, ")"),
501
+ children: [xScale.ticks(5).map(function (d_6, i_0) {
502
+ return /*#__PURE__*/_jsxs(Fragment, {
503
+ children: [/*#__PURE__*/_jsxs("g", {
504
+ className: "tick"
505
+ /* eslint-disable-next-line @typescript-eslint/restrict-template-expressions */,
506
+ transform: "translate(".concat(xScale(d_6), ", 0)"),
507
+ children: [/*#__PURE__*/_jsx("line", {
508
+ y2: 6,
509
+ className: "stroke-gray-300 dark:stroke-gray-500"
510
+ }), /*#__PURE__*/_jsx("text", {
511
+ fill: "currentColor",
512
+ dy: ".71em",
513
+ y: 9,
514
+ children: formatDate(d_6, formatForTimespan(from, to), timezone)
515
+ })]
516
+ }, "tick-".concat(i_0)), /*#__PURE__*/_jsx("g", {
517
+ children: /*#__PURE__*/_jsx("line", {
518
+ className: "stroke-gray-300 dark:stroke-gray-500",
519
+ x1: xScale(d_6),
520
+ x2: xScale(d_6),
521
+ y1: 0,
522
+ y2: -height + margin
523
+ })
524
+ }, "grid-".concat(i_0))]
525
+ }, "".concat(i_0.toString(), "-").concat(d_6.toString()));
526
+ }), /*#__PURE__*/_jsx("line", {
527
+ className: "stroke-gray-300 dark:stroke-gray-500",
528
+ x1: 0,
529
+ x2: graphWidth,
530
+ y1: 0,
531
+ y2: 0
532
+ }), /*#__PURE__*/_jsx("g", {
533
+ transform: "translate(".concat((width - 2.5 * margin) / 2, ", ").concat(margin / 2, ")"),
534
+ children: /*#__PURE__*/_jsx("text", {
535
+ fill: "currentColor",
536
+ dy: ".71em",
537
+ y: 5,
538
+ className: "text-sm",
539
+ children: "Time"
540
+ })
541
+ })]
542
+ }), /*#__PURE__*/_jsx("g", {
543
+ className: "lines fill-transparent",
544
+ transform: graphTransform,
545
+ width: graphWidth - 100,
546
+ children: series.map(function (s_2, i_1) {
547
+ return /*#__PURE__*/_jsx("g", {
548
+ className: "line",
549
+ children: /*#__PURE__*/_jsx(MetricsSeries, {
550
+ data: s_2,
551
+ line: l,
552
+ color: color(s_2.id),
553
+ strokeWidth: hovering && highlighted != null && i_1 === highlighted.seriesIndex || s_2.highlighted === true ? lineStrokeHover : lineStroke,
554
+ xScale: xScale,
555
+ yScale: yScale
556
+ })
557
+ }, s_2.id);
558
+ })
559
+ }), hovering && highlighted != null && /*#__PURE__*/_jsx("g", {
560
+ className: "circle-group",
561
+ ref: metricPointRef,
562
+ style: {
563
+ fill: color((_series$highlighted$s = (_series$highlighted$s2 = series[highlighted.seriesIndex]) === null || _series$highlighted$s2 === void 0 ? void 0 : _series$highlighted$s2.id) !== null && _series$highlighted$s !== void 0 ? _series$highlighted$s : '0')
564
+ },
565
+ transform: graphTransform,
566
+ children: /*#__PURE__*/_jsx(MetricsCircle, {
567
+ cx: highlighted.x,
568
+ cy: highlighted.y
569
+ })
570
+ }), selected != null && /*#__PURE__*/_jsx("g", {
571
+ className: "circle-group",
572
+ style: (selected === null || selected === void 0 ? void 0 : selected.seriesIndex) != null ? {
573
+ fill: color((_series$selected$seri = (_series$selected$seri2 = series[selected.seriesIndex]) === null || _series$selected$seri2 === void 0 ? void 0 : _series$selected$seri2.id) !== null && _series$selected$seri !== void 0 ? _series$selected$seri : '0')
574
+ } : {},
575
+ transform: graphTransform,
576
+ children: /*#__PURE__*/_jsx(MetricsCircle, {
577
+ cx: selected.x,
578
+ cy: selected.y,
579
+ radius: 5
580
+ })
581
+ })]
582
+ })]
583
+ })
584
+ })]
585
+ });
586
+ };