@parca/profile 0.19.140 → 0.19.142
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.
- package/CHANGELOG.md +5 -1
- package/dist/GraphTooltipArrow/Content.js +224 -30
- package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +192 -33
- package/dist/GraphTooltipArrow/ExpandOnHoverValue.js +53 -3
- package/dist/GraphTooltipArrow/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/index.js +86 -56
- package/dist/GraphTooltipArrow/useGraphTooltip/index.js +37 -37
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.d.ts.map +1 -1
- package/dist/GraphTooltipArrow/useGraphTooltipMetaInfo/index.js +104 -72
- package/dist/MatchersInput/SuggestionItem.js +91 -12
- package/dist/MatchersInput/SuggestionsList.d.ts +2 -1
- package/dist/MatchersInput/SuggestionsList.d.ts.map +1 -1
- package/dist/MatchersInput/SuggestionsList.js +371 -157
- package/dist/MatchersInput/SuggestionsList.test.d.ts +2 -0
- package/dist/MatchersInput/SuggestionsList.test.d.ts.map +1 -0
- package/dist/MatchersInput/index.js +308 -115
- package/dist/MetricsCircle/index.js +39 -3
- package/dist/MetricsGraph/MetricsContextMenu/index.js +119 -19
- package/dist/MetricsGraph/MetricsInfoPanel/index.js +81 -20
- package/dist/MetricsGraph/MetricsTooltip/index.d.ts.map +1 -1
- package/dist/MetricsGraph/MetricsTooltip/index.js +107 -74
- package/dist/MetricsGraph/index.js +552 -203
- package/dist/MetricsGraph/useMetricsGraphDimensions.js +46 -25
- package/dist/MetricsGraph/utils/colorMapping.js +24 -17
- package/dist/MetricsSeries/index.js +70 -7
- package/dist/PreSelectedMatchers/index.d.ts.map +1 -1
- package/dist/PreSelectedMatchers/index.js +249 -102
- package/dist/ProfileExplorer/ProfileExplorerCompare.d.ts.map +1 -1
- package/dist/ProfileExplorer/ProfileExplorerCompare.js +241 -45
- package/dist/ProfileExplorer/ProfileExplorerSingle.js +98 -11
- package/dist/ProfileExplorer/index.js +183 -32
- package/dist/ProfileFlameChart/SamplesStrips/SamplesGraph/index.js +333 -148
- package/dist/ProfileFlameChart/SamplesStrips/SamplesStrips.stories.js +69 -35
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts +2 -2
- package/dist/ProfileFlameChart/SamplesStrips/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/SamplesStrips/index.js +645 -134
- package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
- package/dist/ProfileFlameChart/index.d.ts.map +1 -1
- package/dist/ProfileFlameChart/index.js +267 -129
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +288 -89
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenuWrapper.js +56 -20
- package/dist/ProfileFlameGraph/FlameGraphArrow/FlameGraphNodes.js +211 -140
- package/dist/ProfileFlameGraph/FlameGraphArrow/MemoizedTooltip.js +133 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/MiniMap.js +261 -216
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.js +72 -47
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/TooltipContext.js +58 -28
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/ZoomControls.js +59 -8
- package/dist/ProfileFlameGraph/FlameGraphArrow/index.js +396 -179
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.js +68 -50
- package/dist/ProfileFlameGraph/FlameGraphArrow/useMappingList.js +62 -38
- package/dist/ProfileFlameGraph/FlameGraphArrow/useNodeColor.js +14 -6
- package/dist/ProfileFlameGraph/FlameGraphArrow/useScrollViewport.js +124 -82
- package/dist/ProfileFlameGraph/FlameGraphArrow/useVisibleNodes.js +160 -98
- package/dist/ProfileFlameGraph/FlameGraphArrow/useZoom.js +232 -112
- package/dist/ProfileFlameGraph/FlameGraphArrow/utils.js +137 -114
- package/dist/ProfileFlameGraph/benchmarks/benchdata/populateData.js +85 -0
- package/dist/ProfileFlameGraph/index.d.ts.map +1 -1
- package/dist/ProfileFlameGraph/index.js +324 -150
- package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
- package/dist/ProfileMetricsGraph/index.d.ts.map +1 -1
- package/dist/ProfileMetricsGraph/index.js +519 -258
- package/dist/ProfileSelector/CompareButton.js +132 -12
- package/dist/ProfileSelector/MetricsGraphSection.d.ts.map +1 -1
- package/dist/ProfileSelector/MetricsGraphSection.js +236 -64
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +727 -141
- package/dist/ProfileSelector/useAutoQuerySelector.js +249 -130
- package/dist/ProfileSource.js +230 -163
- package/dist/ProfileTypeSelector/index.js +214 -125
- package/dist/ProfileView/components/ActionButtons/GroupByDropdown.js +50 -4
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/ActionButtons/SortByDropdown.js +141 -35
- package/dist/ProfileView/components/ColorStackLegend.d.ts.map +1 -1
- package/dist/ProfileView/components/ColorStackLegend.js +185 -55
- package/dist/ProfileView/components/DashboardItems/index.js +87 -28
- package/dist/ProfileView/components/DashboardLayout/index.js +108 -16
- package/dist/ProfileView/components/DiffLegend.js +172 -29
- package/dist/ProfileView/components/GroupByLabelsDropdown/index.js +199 -55
- package/dist/ProfileView/components/InvertCallStack/index.d.ts.map +1 -1
- package/dist/ProfileView/components/InvertCallStack/index.js +100 -12
- package/dist/ProfileView/components/ProfileFilters/filterPresets.js +260 -315
- package/dist/ProfileView/components/ProfileFilters/index.js +518 -215
- package/dist/ProfileView/components/ProfileFilters/useProfileFilters.js +370 -306
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts +2 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.d.ts.map +1 -1
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.js +188 -118
- package/dist/ProfileView/components/ProfileHeader/index.js +105 -11
- package/dist/ProfileView/components/ShareButton/ResultBox.js +119 -16
- package/dist/ProfileView/components/ShareButton/index.js +352 -62
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/MultiLevelDropdown.js +678 -194
- package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +199 -157
- package/dist/ProfileView/components/Toolbars/index.d.ts +2 -2
- package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
- package/dist/ProfileView/components/Toolbars/index.js +441 -21
- package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
- package/dist/ProfileView/components/ViewSelector/index.d.ts.map +1 -1
- package/dist/ProfileView/components/ViewSelector/index.js +212 -86
- package/dist/ProfileView/components/VisualizationContainer/index.d.ts.map +1 -1
- package/dist/ProfileView/components/VisualizationContainer/index.js +52 -7
- package/dist/ProfileView/components/VisualizationPanel.js +185 -8
- package/dist/ProfileView/context/DashboardContext.d.ts.map +1 -1
- package/dist/ProfileView/context/DashboardContext.js +85 -29
- package/dist/ProfileView/context/ProfileViewContext.js +56 -15
- package/dist/ProfileView/hooks/useAutoSelectDimension.js +71 -41
- package/dist/ProfileView/hooks/useProfileMetadata.js +50 -18
- package/dist/ProfileView/hooks/useResetFlameGraphState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetFlameGraphState.js +32 -12
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +40 -19
- package/dist/ProfileView/hooks/useVisualizationState.d.ts +3 -3
- package/dist/ProfileView/hooks/useVisualizationState.d.ts.map +1 -1
- package/dist/ProfileView/hooks/useVisualizationState.js +258 -67
- package/dist/ProfileView/index.js +383 -45
- package/dist/ProfileView/types/visualization.js +1 -13
- package/dist/ProfileView/utils/colorUtils.js +8 -7
- package/dist/ProfileViewWithData.d.ts.map +1 -1
- package/dist/ProfileViewWithData.js +332 -228
- package/dist/QueryControls/index.js +418 -47
- package/dist/Sandwich/components/CalleesSection.js +54 -4
- package/dist/Sandwich/components/CallersSection.js +97 -27
- package/dist/Sandwich/components/TableSection.js +77 -4
- package/dist/Sandwich/index.d.ts.map +1 -1
- package/dist/Sandwich/index.js +126 -14
- package/dist/Sandwich/utils/processRowData.js +48 -39
- package/dist/SelectWithRefresh/index.js +102 -28
- package/dist/SimpleMatchers/Select.js +520 -187
- package/dist/SimpleMatchers/index.js +590 -288
- package/dist/SourceView/Highlighter.js +230 -70
- package/dist/SourceView/LineNo.js +72 -17
- package/dist/SourceView/index.d.ts.map +1 -1
- package/dist/SourceView/index.js +178 -104
- package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
- package/dist/SourceView/lang-detector/index.js +28 -14
- package/dist/SourceView/useSelectedLineRange.d.ts.map +1 -1
- package/dist/SourceView/useSelectedLineRange.js +99 -23
- package/dist/Table/ColorCell.js +42 -1
- package/dist/Table/ColumnsVisibility.js +114 -6
- package/dist/Table/MoreDropdown.d.ts.map +1 -1
- package/dist/Table/MoreDropdown.js +122 -25
- package/dist/Table/TableContextMenu.d.ts.map +1 -1
- package/dist/Table/TableContextMenu.js +151 -137
- package/dist/Table/TableContextMenuWrapper.js +59 -14
- package/dist/Table/hooks/useColorManagement.js +58 -16
- package/dist/Table/hooks/useTableConfiguration.d.ts.map +1 -1
- package/dist/Table/hooks/useTableConfiguration.js +333 -169
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +222 -128
- package/dist/Table/utils/functions.js +169 -144
- package/dist/Table/utils/topAndBottomExpandedRowModel.js +69 -52
- package/dist/TimelineGuide/index.js +209 -16
- package/dist/TopTable/benchmarks/benchdata/populateData.js +91 -0
- package/dist/TopTable/index.d.ts.map +1 -1
- package/dist/TopTable/index.js +342 -123
- package/dist/contexts/LabelsQueryProvider.js +94 -32
- package/dist/contexts/UnifiedLabelsContext.js +114 -49
- package/dist/contexts/utils.js +37 -15
- package/dist/hooks/useCompareModeMeta.d.ts.map +1 -1
- package/dist/hooks/useCompareModeMeta.js +158 -64
- package/dist/hooks/useLabels.js +295 -52
- package/dist/hooks/useQueryState.d.ts +3 -3
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +373 -332
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +22 -8
- package/dist/testdata/fg-diff.json +3750 -0
- package/dist/testdata/fg-simple.json +1879 -0
- package/dist/testdata/link_data.json +56 -0
- package/dist/testdata/tabular.json +30 -0
- package/dist/testdata/test_flamegraph.json +26846 -0
- package/dist/testdata/test_graph.json +53 -0
- package/dist/useDelayedLoader.js +32 -18
- package/dist/useGrpcQuery/index.js +71 -11
- package/dist/useHasProfileData.js +90 -12
- package/dist/useQuery.js +205 -64
- package/dist/useSumBy.d.ts +1 -1
- package/dist/useSumBy.d.ts.map +1 -1
- package/dist/useSumBy.js +294 -138
- package/dist/utils.js +62 -30
- package/package.json +9 -10
- package/src/GraphTooltipArrow/index.tsx +3 -0
- package/src/GraphTooltipArrow/useGraphTooltipMetaInfo/index.ts +13 -11
- package/src/MatchersInput/SuggestionsList.test.tsx +70 -0
- package/src/MatchersInput/SuggestionsList.tsx +11 -10
- package/src/MatchersInput/index.tsx +1 -1
- package/src/MetricsGraph/MetricsTooltip/index.tsx +22 -34
- package/src/PreSelectedMatchers/index.tsx +3 -0
- package/src/ProfileExplorer/ProfileExplorerCompare.tsx +9 -4
- package/src/ProfileFlameChart/SamplesStrips/index.tsx +2 -2
- package/src/ProfileFlameChart/index.tsx +28 -21
- package/src/ProfileFlameGraph/FlameGraphArrow/ContextMenu.tsx +9 -10
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +6 -5
- package/src/ProfileFlameGraph/FlameGraphArrow/TooltipContext.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/ZoomControls.tsx +3 -0
- package/src/ProfileFlameGraph/FlameGraphArrow/useBatchedRendering.ts +3 -0
- package/src/ProfileFlameGraph/index.tsx +9 -6
- package/src/ProfileMetricsGraph/index.tsx +8 -6
- package/src/ProfileSelector/MetricsGraphSection.tsx +10 -5
- package/src/ProfileSelector/index.tsx +61 -39
- package/src/ProfileView/components/ActionButtons/SortByDropdown.tsx +6 -10
- package/src/ProfileView/components/ColorStackLegend.tsx +4 -2
- package/src/ProfileView/components/InvertCallStack/index.tsx +4 -5
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.tsx +192 -94
- package/src/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.ts +21 -21
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +28 -24
- package/src/ProfileView/components/Toolbars/TableColumnsDropdown.tsx +5 -4
- package/src/ProfileView/components/Toolbars/index.tsx +3 -3
- package/src/ProfileView/components/ViewSelector/index.tsx +16 -9
- package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
- package/src/ProfileView/context/DashboardContext.tsx +6 -6
- package/src/ProfileView/hooks/useResetFlameGraphState.ts +4 -6
- package/src/ProfileView/hooks/useResetStateOnProfileTypeChange.ts +26 -24
- package/src/ProfileView/hooks/useResetStateOnSeriesChange.ts +8 -16
- package/src/ProfileView/hooks/useVisualizationState.ts +69 -61
- package/src/ProfileViewWithData.tsx +35 -29
- package/src/Sandwich/index.tsx +3 -4
- package/src/SourceView/index.tsx +2 -4
- package/src/SourceView/useSelectedLineRange.ts +19 -34
- package/src/Table/MoreDropdown.tsx +11 -9
- package/src/Table/TableContextMenu.tsx +13 -10
- package/src/Table/hooks/useTableConfiguration.tsx +11 -16
- package/src/Table/index.tsx +21 -12
- package/src/TopTable/index.tsx +4 -3
- package/src/hooks/useCompareModeMeta.ts +91 -61
- package/src/hooks/useQueryState.test.tsx +345 -275
- package/src/hooks/useQueryState.ts +118 -136
- package/src/index.tsx +15 -16
- package/src/useDelayedLoader.ts +10 -10
- package/src/useSumBy.ts +15 -21
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
- package/dist/hooks/urlParsers.d.ts +0 -18
- package/dist/hooks/urlParsers.d.ts.map +0 -1
- package/dist/hooks/urlParsers.js +0 -32
- package/dist/hooks/useColorBy.d.ts +0 -5
- package/dist/hooks/useColorBy.d.ts.map +0 -1
- package/dist/hooks/useColorBy.js +0 -26
- package/dist/hooks/useDashboardItems.d.ts +0 -5
- package/dist/hooks/useDashboardItems.d.ts.map +0 -1
- package/dist/hooks/useDashboardItems.js +0 -27
- package/dist/hooks/useQueryState.test.js +0 -868
- package/src/hooks/urlParsers.ts +0 -38
- package/src/hooks/useColorBy.ts +0 -42
- package/src/hooks/useDashboardItems.ts +0 -46
|
@@ -1,4 +1,16 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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
|
-
|
|
39
|
-
|
|
40
|
-
export
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
-
|
|
138
|
-
|
|
139
|
-
x: xScale(point[0]),
|
|
140
|
-
y: yScale(point[1]),
|
|
251
|
+
pointIndex: undefined,
|
|
252
|
+
distance: Infinity
|
|
141
253
|
};
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
//
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
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
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
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
|
-
|
|
206
|
-
|
|
207
|
-
|
|
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
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
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
|
+
};
|