@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.
- package/CHANGELOG.md +9 -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.js +94 -68
- 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 +240 -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.js +645 -134
- package/dist/ProfileFlameChart/SamplesStrips/labelSetUtils.js +114 -55
- package/dist/ProfileFlameChart/index.js +260 -126
- package/dist/ProfileFlameGraph/FlameGraphArrow/ContextMenu.js +283 -85
- 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 +71 -45
- 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.js +322 -147
- package/dist/ProfileMetricsGraph/hooks/useQueryRange.js +140 -32
- package/dist/ProfileMetricsGraph/index.js +515 -256
- package/dist/ProfileSelector/CompareButton.js +132 -12
- package/dist/ProfileSelector/MetricsGraphSection.js +228 -63
- package/dist/ProfileSelector/index.d.ts +1 -1
- package/dist/ProfileSelector/index.d.ts.map +1 -1
- package/dist/ProfileSelector/index.js +734 -142
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts +1 -3
- package/dist/ProfileSelector/useAutoQuerySelector.d.ts.map +1 -1
- package/dist/ProfileSelector/useAutoQuerySelector.js +280 -132
- 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.js +137 -32
- package/dist/ProfileView/components/ColorStackLegend.js +182 -54
- 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.js +97 -9
- 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.js +191 -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 +664 -192
- package/dist/ProfileView/components/Toolbars/SwitchMenuItem.js +94 -7
- package/dist/ProfileView/components/Toolbars/TableColumnsDropdown.js +196 -155
- package/dist/ProfileView/components/Toolbars/index.js +441 -21
- package/dist/ProfileView/components/ViewSelector/Dropdown.js +233 -22
- package/dist/ProfileView/components/ViewSelector/index.js +186 -82
- 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.js +74 -26
- 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.js +31 -10
- package/dist/ProfileView/hooks/useResetStateOnProfileTypeChange.js +71 -27
- package/dist/ProfileView/hooks/useResetStateOnSeriesChange.js +53 -17
- package/dist/ProfileView/hooks/useVisualizationState.js +229 -69
- 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.js +319 -225
- 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.js +125 -12
- 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.js +177 -101
- package/dist/SourceView/lang-detector/ext-to-lang.json +798 -798
- package/dist/SourceView/lang-detector/index.js +28 -14
- package/dist/SourceView/useSelectedLineRange.js +72 -20
- package/dist/Table/ColorCell.js +42 -1
- package/dist/Table/ColumnsVisibility.js +114 -6
- package/dist/Table/MoreDropdown.js +107 -21
- package/dist/Table/TableContextMenu.js +144 -134
- 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 +323 -167
- package/dist/Table/index.js +217 -123
- 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.js +325 -121
- package/dist/contexts/LabelsQueryProvider.js +94 -32
- package/dist/contexts/UnifiedLabelsContext.js +114 -49
- package/dist/contexts/utils.js +37 -15
- package/dist/hooks/urlParsers.js +27 -15
- package/dist/hooks/useColorBy.js +47 -10
- package/dist/hooks/useCompareModeMeta.js +112 -62
- package/dist/hooks/useDashboardItems.js +52 -11
- package/dist/hooks/useLabels.js +295 -52
- package/dist/hooks/useQueryState.d.ts +1 -1
- package/dist/hooks/useQueryState.d.ts.map +1 -1
- package/dist/hooks/useQueryState.js +375 -329
- package/dist/index.js +11 -6
- 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.map +1 -1
- package/dist/useSumBy.js +294 -138
- package/dist/utils.js +62 -30
- package/package.json +9 -9
- package/src/GraphTooltipArrow/index.tsx +3 -0
- 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 -2
- package/src/ProfileFlameGraph/FlameGraphArrow/TextWithEllipsis.tsx +3 -0
- 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/ProfileSelector/index.tsx +31 -9
- package/src/ProfileSelector/useAutoQuerySelector.ts +64 -42
- package/src/ProfileView/components/Toolbars/MultiLevelDropdown.tsx +3 -0
- package/src/ProfileView/components/VisualizationContainer/index.tsx +3 -0
- package/src/Table/hooks/useTableConfiguration.tsx +7 -13
- package/src/hooks/useQueryState.ts +18 -3
- package/src/useDelayedLoader.ts +10 -10
- package/src/useSumBy.ts +12 -18
- package/dist/ProfileView/components/ProfileFilters/useProfileFiltersUrlState.test.js +0 -455
- package/dist/hooks/useQueryState.test.js +0 -868
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
2
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
3
|
+
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
4
|
+
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
5
|
+
function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
|
|
6
|
+
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."); }
|
|
7
|
+
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; } }
|
|
8
|
+
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; }
|
|
9
|
+
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; } }
|
|
10
|
+
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
+
import { c as _c } from "react-compiler-runtime";
|
|
2
12
|
// Copyright 2022 The Parca Authors
|
|
3
13
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
14
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,158 +21,333 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
11
21
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
22
|
// See the License for the specific language governing permissions and
|
|
13
23
|
// limitations under the License.
|
|
24
|
+
|
|
14
25
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
15
26
|
import { Icon } from '@iconify/react';
|
|
16
27
|
import cx from 'classnames';
|
|
17
28
|
import * as d3 from 'd3';
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
29
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
30
|
+
var DraggingWindow = function DraggingWindow(t0) {
|
|
31
|
+
var $ = _c(9);
|
|
32
|
+
var dragStart = t0.dragStart,
|
|
33
|
+
currentX = t0.currentX;
|
|
34
|
+
var start = Math.min(dragStart !== null && dragStart !== void 0 ? dragStart : 0, currentX !== null && currentX !== void 0 ? currentX : 0);
|
|
35
|
+
var t1;
|
|
36
|
+
if ($[0] !== currentX || $[1] !== dragStart) {
|
|
37
|
+
t1 = Math.abs((dragStart !== null && dragStart !== void 0 ? dragStart : 0) - (currentX !== null && currentX !== void 0 ? currentX : 0));
|
|
38
|
+
$[0] = currentX;
|
|
39
|
+
$[1] = dragStart;
|
|
40
|
+
$[2] = t1;
|
|
41
|
+
} else {
|
|
42
|
+
t1 = $[2];
|
|
43
|
+
}
|
|
44
|
+
var width = t1;
|
|
45
|
+
if (dragStart === undefined || currentX === undefined) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
var t2;
|
|
49
|
+
if ($[3] !== start || $[4] !== width) {
|
|
50
|
+
t2 = {
|
|
51
|
+
height: "100%",
|
|
52
|
+
width: width,
|
|
53
|
+
left: start
|
|
54
|
+
};
|
|
55
|
+
$[3] = start;
|
|
56
|
+
$[4] = width;
|
|
57
|
+
$[5] = t2;
|
|
58
|
+
} else {
|
|
59
|
+
t2 = $[5];
|
|
60
|
+
}
|
|
61
|
+
var t3;
|
|
62
|
+
if ($[6] === Symbol["for"]("react.memo_cache_sentinel")) {
|
|
63
|
+
t3 = cx("bg-gray-500 absolute top-0 opacity-50 border-x-2 border-gray-900 dark:border-gray-100");
|
|
64
|
+
$[6] = t3;
|
|
65
|
+
} else {
|
|
66
|
+
t3 = $[6];
|
|
67
|
+
}
|
|
68
|
+
var t4;
|
|
69
|
+
if ($[7] !== t2) {
|
|
70
|
+
t4 = /*#__PURE__*/_jsx("div", {
|
|
71
|
+
style: t2,
|
|
72
|
+
className: t3
|
|
73
|
+
});
|
|
74
|
+
$[7] = t2;
|
|
75
|
+
$[8] = t4;
|
|
76
|
+
} else {
|
|
77
|
+
t4 = $[8];
|
|
78
|
+
}
|
|
79
|
+
return t4;
|
|
25
80
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
81
|
+
var ZoomWindow = function ZoomWindow(_ref) {
|
|
82
|
+
var zoomWindow = _ref.zoomWindow,
|
|
83
|
+
onZoomWindowChange = _ref.onZoomWindowChange,
|
|
84
|
+
setIsHoveringDragHandle = _ref.setIsHoveringDragHandle;
|
|
85
|
+
var windowStartHandleRef = useRef(null);
|
|
86
|
+
var windowEndHandleRef = useRef(null);
|
|
87
|
+
var _useState = useState(zoomWindow),
|
|
88
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
89
|
+
zoomWindowState = _useState2[0],
|
|
90
|
+
setZoomWindowState = _useState2[1];
|
|
91
|
+
var _useState3 = useState(false),
|
|
92
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
93
|
+
dragginStart = _useState4[0],
|
|
94
|
+
setDraggingStart = _useState4[1];
|
|
95
|
+
var _useState5 = useState(false),
|
|
96
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
97
|
+
draggingEnd = _useState6[0],
|
|
98
|
+
setDraggingEnd = _useState6[1];
|
|
99
|
+
useEffect(function () {
|
|
100
|
+
if (zoomWindow === undefined || zoomWindowState === undefined || zoomWindow[0] !== zoomWindowState[0] || zoomWindow[1] !== zoomWindowState[1]) {
|
|
101
|
+
setZoomWindowState(zoomWindow);
|
|
43
102
|
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const newStart = Math.min(x, beforeWidth);
|
|
62
|
-
const newEnd = Math.max(x, beforeWidth);
|
|
63
|
-
setZoomWindowState([newStart, newEnd]);
|
|
64
|
-
}
|
|
65
|
-
}, onMouseLeave: () => {
|
|
66
|
-
setDraggingStart(false);
|
|
67
|
-
setDraggingEnd(false);
|
|
68
|
-
}, onMouseUp: () => {
|
|
69
|
-
if (dragginStart) {
|
|
70
|
-
setDraggingStart(false);
|
|
71
|
-
}
|
|
72
|
-
if (draggingEnd) {
|
|
73
|
-
setDraggingEnd(false);
|
|
74
|
-
}
|
|
75
|
-
if (zoomWindowState[0] === zoomWindow?.[0] && zoomWindowState[1] === zoomWindow?.[1]) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
onZoomWindowChange(zoomWindowState);
|
|
79
|
-
setZoomWindowState(undefined);
|
|
80
|
-
}, children: _jsxs("div", { style: {
|
|
81
|
-
height: '100%',
|
|
82
|
-
width: zoomWindowState[1] - zoomWindowState[0],
|
|
83
|
-
left: zoomWindowState[0],
|
|
84
|
-
}, className: cx('bg-gray-500/50 dark:bg-gray-400/90 absolute top-0 border-x-2 border-gray-900 dark:border-gray-100 z-20'), children: [_jsx("div", { className: "w-3 h-4 absolute top-0 left-[-7px] rounded-b bg-gray-200 dark:bg-gray-600 cursor-ew-resize flex justify-center z-30", onMouseDown: e => {
|
|
85
|
-
setDraggingStart(true);
|
|
86
|
-
e.stopPropagation();
|
|
87
|
-
e.preventDefault();
|
|
88
|
-
}, ref: windowStartHandleRef, onMouseEnter: () => {
|
|
89
|
-
setIsHoveringDragHandle(true);
|
|
90
|
-
}, onMouseLeave: () => {
|
|
91
|
-
setIsHoveringDragHandle(false);
|
|
92
|
-
}, children: _jsx(Icon, { icon: "si:drag-handle-line", className: "rotate-90", fontSize: 16 }) }), _jsx("div", { className: "w-3 h-4 absolute top-0 rounded-b bg-gray-200 dark:bg-gray-600 cursor-ew-resize flex justify-center right-[-7px]", onMouseDown: e => {
|
|
93
|
-
setDraggingEnd(true);
|
|
94
|
-
e.stopPropagation();
|
|
95
|
-
e.preventDefault();
|
|
96
|
-
}, ref: windowEndHandleRef, onMouseEnter: () => {
|
|
97
|
-
setIsHoveringDragHandle(true);
|
|
98
|
-
}, onMouseLeave: () => {
|
|
99
|
-
setIsHoveringDragHandle(false);
|
|
100
|
-
}, children: _jsx(Icon, { icon: "si:drag-handle-line", className: "rotate-90", fontSize: 16 }) })] }) }));
|
|
101
|
-
};
|
|
102
|
-
export const SamplesGraph = ({ data, height, width, marginLeft = 0, marginRight = 0, marginBottom = 0, marginTop = 0, fill = 'gray', selectionBounds, setSelectionBounds, stepMs, onDragStart, dragState, isAnyDragActive = false, timeBounds, }) => {
|
|
103
|
-
const [mousePosition, setMousePosition] = useState(undefined);
|
|
104
|
-
const [isHoveringDragHandle, setIsHoveringDragHandle] = useState(false);
|
|
105
|
-
// use the bounds from props if provided, else compute from data
|
|
106
|
-
const xDomain = timeBounds ?? d3.extent(data, d => d.timestamp);
|
|
107
|
-
const x = d3.scaleUtc(xDomain, [marginLeft, width - marginRight]);
|
|
108
|
-
// Calculate sample count range for opacity scaling
|
|
109
|
-
const sampleCounts = data.map(d => Number(d.sampleCount ?? 1));
|
|
110
|
-
const maxSampleCount = Math.max(...sampleCounts);
|
|
111
|
-
const minSampleCount = Math.min(...sampleCounts);
|
|
112
|
-
// Create opacity scale: more samples = higher opacity
|
|
113
|
-
const opacityScale = d3
|
|
114
|
-
.scaleLinear()
|
|
115
|
-
.domain([minSampleCount, maxSampleCount])
|
|
116
|
-
.range([0.5, 1.0])
|
|
117
|
-
.clamp(true);
|
|
118
|
-
const zoomWindow = useMemo(() => {
|
|
119
|
-
if (selectionBounds === undefined) {
|
|
120
|
-
return undefined;
|
|
103
|
+
|
|
104
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
105
|
+
}, [zoomWindow]);
|
|
106
|
+
if (zoomWindowState === undefined) {
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
var beforeWidth = zoomWindowState[0];
|
|
110
|
+
var afterStart = zoomWindowState[1];
|
|
111
|
+
return /*#__PURE__*/_jsx("div", {
|
|
112
|
+
className: "absolute w-full h-full",
|
|
113
|
+
onMouseMove: function onMouseMove(e) {
|
|
114
|
+
if (dragginStart) {
|
|
115
|
+
var _d3$pointer = d3.pointer(e),
|
|
116
|
+
_d3$pointer2 = _slicedToArray(_d3$pointer, 1),
|
|
117
|
+
x = _d3$pointer2[0];
|
|
118
|
+
if (x >= afterStart - 10) {
|
|
119
|
+
return;
|
|
121
120
|
}
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
121
|
+
var newStart = Math.min(x, afterStart);
|
|
122
|
+
var newEnd = Math.max(x, afterStart);
|
|
123
|
+
setZoomWindowState([newStart, newEnd]);
|
|
124
|
+
}
|
|
125
|
+
if (draggingEnd) {
|
|
126
|
+
var _d3$pointer3 = d3.pointer(e),
|
|
127
|
+
_d3$pointer4 = _slicedToArray(_d3$pointer3, 1),
|
|
128
|
+
_x = _d3$pointer4[0];
|
|
129
|
+
if (_x <= beforeWidth + 10) {
|
|
130
|
+
return;
|
|
131
|
+
}
|
|
132
|
+
var _newStart = Math.min(_x, beforeWidth);
|
|
133
|
+
var _newEnd = Math.max(_x, beforeWidth);
|
|
134
|
+
setZoomWindowState([_newStart, _newEnd]);
|
|
135
|
+
}
|
|
136
|
+
},
|
|
137
|
+
onMouseLeave: function onMouseLeave() {
|
|
138
|
+
setDraggingStart(false);
|
|
139
|
+
setDraggingEnd(false);
|
|
140
|
+
},
|
|
141
|
+
onMouseUp: function onMouseUp() {
|
|
142
|
+
if (dragginStart) {
|
|
143
|
+
setDraggingStart(false);
|
|
144
|
+
}
|
|
145
|
+
if (draggingEnd) {
|
|
146
|
+
setDraggingEnd(false);
|
|
147
|
+
}
|
|
148
|
+
if (zoomWindowState[0] === (zoomWindow === null || zoomWindow === void 0 ? void 0 : zoomWindow[0]) && zoomWindowState[1] === (zoomWindow === null || zoomWindow === void 0 ? void 0 : zoomWindow[1])) {
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
onZoomWindowChange(zoomWindowState);
|
|
152
|
+
setZoomWindowState(undefined);
|
|
153
|
+
},
|
|
154
|
+
children: /*#__PURE__*/_jsxs("div", {
|
|
155
|
+
style: {
|
|
156
|
+
height: '100%',
|
|
157
|
+
width: zoomWindowState[1] - zoomWindowState[0],
|
|
158
|
+
left: zoomWindowState[0]
|
|
159
|
+
},
|
|
160
|
+
className: cx('bg-gray-500/50 dark:bg-gray-400/90 absolute top-0 border-x-2 border-gray-900 dark:border-gray-100 z-20'),
|
|
161
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
162
|
+
className: "w-3 h-4 absolute top-0 left-[-7px] rounded-b bg-gray-200 dark:bg-gray-600 cursor-ew-resize flex justify-center z-30",
|
|
163
|
+
onMouseDown: function onMouseDown(e) {
|
|
164
|
+
setDraggingStart(true);
|
|
165
|
+
e.stopPropagation();
|
|
166
|
+
e.preventDefault();
|
|
167
|
+
},
|
|
168
|
+
ref: windowStartHandleRef,
|
|
169
|
+
onMouseEnter: function onMouseEnter() {
|
|
170
|
+
setIsHoveringDragHandle(true);
|
|
171
|
+
},
|
|
172
|
+
onMouseLeave: function onMouseLeave() {
|
|
173
|
+
setIsHoveringDragHandle(false);
|
|
174
|
+
},
|
|
175
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
176
|
+
icon: "si:drag-handle-line",
|
|
177
|
+
className: "rotate-90",
|
|
178
|
+
fontSize: 16
|
|
179
|
+
})
|
|
180
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
181
|
+
className: "w-3 h-4 absolute top-0 rounded-b bg-gray-200 dark:bg-gray-600 cursor-ew-resize flex justify-center right-[-7px]",
|
|
182
|
+
onMouseDown: function onMouseDown(e) {
|
|
183
|
+
setDraggingEnd(true);
|
|
184
|
+
e.stopPropagation();
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
},
|
|
187
|
+
ref: windowEndHandleRef,
|
|
188
|
+
onMouseEnter: function onMouseEnter() {
|
|
189
|
+
setIsHoveringDragHandle(true);
|
|
190
|
+
},
|
|
191
|
+
onMouseLeave: function onMouseLeave() {
|
|
192
|
+
setIsHoveringDragHandle(false);
|
|
193
|
+
},
|
|
194
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
195
|
+
icon: "si:drag-handle-line",
|
|
196
|
+
className: "rotate-90",
|
|
197
|
+
fontSize: 16
|
|
198
|
+
})
|
|
199
|
+
})]
|
|
200
|
+
})
|
|
201
|
+
});
|
|
168
202
|
};
|
|
203
|
+
export var SamplesGraph = function SamplesGraph(_ref2) {
|
|
204
|
+
var _mousePosition$;
|
|
205
|
+
var data = _ref2.data,
|
|
206
|
+
height = _ref2.height,
|
|
207
|
+
width = _ref2.width,
|
|
208
|
+
_ref2$marginLeft = _ref2.marginLeft,
|
|
209
|
+
marginLeft = _ref2$marginLeft === void 0 ? 0 : _ref2$marginLeft,
|
|
210
|
+
_ref2$marginRight = _ref2.marginRight,
|
|
211
|
+
marginRight = _ref2$marginRight === void 0 ? 0 : _ref2$marginRight,
|
|
212
|
+
_ref2$marginBottom = _ref2.marginBottom,
|
|
213
|
+
marginBottom = _ref2$marginBottom === void 0 ? 0 : _ref2$marginBottom,
|
|
214
|
+
_ref2$marginTop = _ref2.marginTop,
|
|
215
|
+
marginTop = _ref2$marginTop === void 0 ? 0 : _ref2$marginTop,
|
|
216
|
+
_ref2$fill = _ref2.fill,
|
|
217
|
+
fill = _ref2$fill === void 0 ? 'gray' : _ref2$fill,
|
|
218
|
+
selectionBounds = _ref2.selectionBounds,
|
|
219
|
+
setSelectionBounds = _ref2.setSelectionBounds,
|
|
220
|
+
stepMs = _ref2.stepMs,
|
|
221
|
+
onDragStart = _ref2.onDragStart,
|
|
222
|
+
dragState = _ref2.dragState,
|
|
223
|
+
_ref2$isAnyDragActive = _ref2.isAnyDragActive,
|
|
224
|
+
isAnyDragActive = _ref2$isAnyDragActive === void 0 ? false : _ref2$isAnyDragActive,
|
|
225
|
+
timeBounds = _ref2.timeBounds;
|
|
226
|
+
var _useState7 = useState(undefined),
|
|
227
|
+
_useState8 = _slicedToArray(_useState7, 2),
|
|
228
|
+
mousePosition = _useState8[0],
|
|
229
|
+
setMousePosition = _useState8[1];
|
|
230
|
+
var _useState9 = useState(false),
|
|
231
|
+
_useState0 = _slicedToArray(_useState9, 2),
|
|
232
|
+
isHoveringDragHandle = _useState0[0],
|
|
233
|
+
setIsHoveringDragHandle = _useState0[1];
|
|
234
|
+
|
|
235
|
+
// use the bounds from props if provided, else compute from data
|
|
236
|
+
var xDomain = timeBounds !== null && timeBounds !== void 0 ? timeBounds : d3.extent(data, function (d) {
|
|
237
|
+
return d.timestamp;
|
|
238
|
+
});
|
|
239
|
+
var x = d3.scaleUtc(xDomain, [marginLeft, width - marginRight]);
|
|
240
|
+
|
|
241
|
+
// Calculate sample count range for opacity scaling
|
|
242
|
+
var sampleCounts = data.map(function (d) {
|
|
243
|
+
var _d$sampleCount;
|
|
244
|
+
return Number((_d$sampleCount = d.sampleCount) !== null && _d$sampleCount !== void 0 ? _d$sampleCount : 1);
|
|
245
|
+
});
|
|
246
|
+
var maxSampleCount = Math.max.apply(Math, _toConsumableArray(sampleCounts));
|
|
247
|
+
var minSampleCount = Math.min.apply(Math, _toConsumableArray(sampleCounts));
|
|
248
|
+
|
|
249
|
+
// Create opacity scale: more samples = higher opacity
|
|
250
|
+
var opacityScale = d3.scaleLinear().domain([minSampleCount, maxSampleCount]).range([0.5, 1.0]).clamp(true);
|
|
251
|
+
var zoomWindow = useMemo(function () {
|
|
252
|
+
if (selectionBounds === undefined) {
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
return [x(selectionBounds[0]), x(selectionBounds[1])];
|
|
256
|
+
|
|
257
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
258
|
+
}, [selectionBounds]);
|
|
259
|
+
var setSelectionBoundsWithScaling = function setSelectionBoundsWithScaling(_ref3) {
|
|
260
|
+
var _ref4 = _slicedToArray(_ref3, 2),
|
|
261
|
+
startPx = _ref4[0],
|
|
262
|
+
endPx = _ref4[1];
|
|
263
|
+
setSelectionBounds([x.invert(startPx).getTime(), x.invert(endPx).getTime()]);
|
|
264
|
+
};
|
|
265
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
266
|
+
style: {
|
|
267
|
+
height: height,
|
|
268
|
+
width: width
|
|
269
|
+
},
|
|
270
|
+
className: "relative",
|
|
271
|
+
onMouseMove: function onMouseMove(e) {
|
|
272
|
+
// Only track hover position when no drag is active anywhere
|
|
273
|
+
if (isAnyDragActive) return;
|
|
274
|
+
var _d3$pointer5 = d3.pointer(e),
|
|
275
|
+
_d3$pointer6 = _slicedToArray(_d3$pointer5, 2),
|
|
276
|
+
xPos = _d3$pointer6[0],
|
|
277
|
+
yPos = _d3$pointer6[1];
|
|
278
|
+
if (xPos >= marginLeft && xPos <= width - marginRight && yPos >= marginTop && yPos <= height - marginBottom) {
|
|
279
|
+
setMousePosition([xPos, yPos]);
|
|
280
|
+
} else {
|
|
281
|
+
setMousePosition(undefined);
|
|
282
|
+
}
|
|
283
|
+
},
|
|
284
|
+
onMouseLeave: function onMouseLeave() {
|
|
285
|
+
// Only clear hover position, drag is managed by parent
|
|
286
|
+
setMousePosition(undefined);
|
|
287
|
+
},
|
|
288
|
+
onMouseDown: function onMouseDown(e) {
|
|
289
|
+
// only left mouse button
|
|
290
|
+
if (e.button !== 0) {
|
|
291
|
+
return;
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// X/Y coordinate array relative to element
|
|
295
|
+
var rel = d3.pointer(e);
|
|
296
|
+
var xCoordinate = rel[0];
|
|
297
|
+
if (xCoordinate >= 0 && onDragStart !== undefined) {
|
|
298
|
+
onDragStart(xCoordinate);
|
|
299
|
+
}
|
|
300
|
+
e.stopPropagation();
|
|
301
|
+
e.preventDefault();
|
|
302
|
+
},
|
|
303
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
304
|
+
style: {
|
|
305
|
+
height: height,
|
|
306
|
+
width: 2,
|
|
307
|
+
left: (_mousePosition$ = mousePosition === null || mousePosition === void 0 ? void 0 : mousePosition[0]) !== null && _mousePosition$ !== void 0 ? _mousePosition$ : -1
|
|
308
|
+
},
|
|
309
|
+
className: cx('bg-gray-700/75 dark:bg-gray-200/75 absolute top-0', {
|
|
310
|
+
hidden: mousePosition === undefined || isAnyDragActive || isHoveringDragHandle
|
|
311
|
+
})
|
|
312
|
+
}), /*#__PURE__*/_jsx(DraggingWindow, {
|
|
313
|
+
dragStart: dragState === null || dragState === void 0 ? void 0 : dragState.startX,
|
|
314
|
+
currentX: dragState === null || dragState === void 0 ? void 0 : dragState.currentX
|
|
315
|
+
}), /*#__PURE__*/_jsx(ZoomWindow, {
|
|
316
|
+
zoomWindow: zoomWindow,
|
|
317
|
+
width: width,
|
|
318
|
+
onZoomWindowChange: setSelectionBoundsWithScaling,
|
|
319
|
+
setIsHoveringDragHandle: setIsHoveringDragHandle
|
|
320
|
+
}), /*#__PURE__*/_jsxs("svg", {
|
|
321
|
+
style: {
|
|
322
|
+
width: '100%',
|
|
323
|
+
height: '100%'
|
|
324
|
+
},
|
|
325
|
+
children: [/*#__PURE__*/_jsx("rect", {
|
|
326
|
+
x: marginLeft,
|
|
327
|
+
y: 0,
|
|
328
|
+
width: width - marginLeft - marginRight,
|
|
329
|
+
height: height,
|
|
330
|
+
fill: fill,
|
|
331
|
+
fillOpacity: 0.1
|
|
332
|
+
}), /*#__PURE__*/_jsx("g", {
|
|
333
|
+
children: data.map(function (d, i) {
|
|
334
|
+
var _d$sampleCount2;
|
|
335
|
+
var xPosition = x(d.timestamp);
|
|
336
|
+
// Use stepMs for bucket width
|
|
337
|
+
var rectWidth = x(d.timestamp + stepMs) - xPosition;
|
|
338
|
+
|
|
339
|
+
// Calculate opacity based on sample count
|
|
340
|
+
var opacity = opacityScale(Number((_d$sampleCount2 = d.sampleCount) !== null && _d$sampleCount2 !== void 0 ? _d$sampleCount2 : 1));
|
|
341
|
+
return /*#__PURE__*/_jsx("rect", {
|
|
342
|
+
x: xPosition,
|
|
343
|
+
y: 0,
|
|
344
|
+
width: rectWidth,
|
|
345
|
+
height: height,
|
|
346
|
+
fill: fill,
|
|
347
|
+
fillOpacity: opacity
|
|
348
|
+
}, i);
|
|
349
|
+
})
|
|
350
|
+
})]
|
|
351
|
+
})]
|
|
352
|
+
});
|
|
353
|
+
};
|
|
@@ -1,4 +1,15 @@
|
|
|
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; }
|
|
2
13
|
// Copyright 2022 The Parca Authors
|
|
3
14
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4
15
|
// you may not use this file except in compliance with the License.
|
|
@@ -11,47 +22,70 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
11
22
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12
23
|
// See the License for the specific language governing permissions and
|
|
13
24
|
// limitations under the License.
|
|
25
|
+
|
|
14
26
|
// eslint-disable-next-line import/named
|
|
15
27
|
import { useArgs } from '@storybook/preview-api';
|
|
28
|
+
// eslint-disable-next-line import/named
|
|
29
|
+
|
|
16
30
|
import { SamplesStrip } from './index';
|
|
31
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
32
|
function seededRandom(seed) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
33
|
+
return function () {
|
|
34
|
+
seed = seed * 16807 % 2147483647;
|
|
35
|
+
return (seed - 1) / 2147483646;
|
|
36
|
+
};
|
|
22
37
|
}
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
for (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
38
|
+
var mockData = [[], [], []];
|
|
39
|
+
var random = seededRandom(42);
|
|
40
|
+
for (var i = 0; i < 200; i++) {
|
|
41
|
+
for (var j = 0; j < mockData.length; j++) {
|
|
42
|
+
mockData[j].push({
|
|
43
|
+
timestamp: 1731326092000 + i * 100,
|
|
44
|
+
value: Math.floor(random() * 100)
|
|
45
|
+
});
|
|
46
|
+
}
|
|
32
47
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
var meta = {
|
|
49
|
+
title: 'components/SamplesStrip',
|
|
50
|
+
component: SamplesStrip
|
|
36
51
|
};
|
|
37
52
|
export default meta;
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
export var ThreeCPUStrips = {
|
|
54
|
+
args: {
|
|
55
|
+
cpus: Array.from(mockData, function (_, i) {
|
|
56
|
+
return {
|
|
57
|
+
labels: [{
|
|
58
|
+
name: 'cpuid',
|
|
59
|
+
value: i + 1
|
|
60
|
+
}]
|
|
61
|
+
};
|
|
62
|
+
}),
|
|
63
|
+
data: mockData,
|
|
64
|
+
selectedTimeframe: {
|
|
65
|
+
index: 1,
|
|
66
|
+
bounds: [mockData[0][25].timestamp, mockData[0][100].timestamp]
|
|
48
67
|
},
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const onSelectedTimeframe = (index, bounds) => {
|
|
52
|
-
args.onSelectedTimeframe(index, bounds);
|
|
53
|
-
setArgs({ ...args, selectedTimeframe: { index, bounds } });
|
|
54
|
-
};
|
|
55
|
-
return _jsx(SamplesStrip, { ...args, onSelectedTimeframe: onSelectedTimeframe });
|
|
68
|
+
onSelectedTimeframe: function onSelectedTimeframe(index, bounds) {
|
|
69
|
+
console.log('onSelectedTimeframe', index, bounds);
|
|
56
70
|
},
|
|
57
|
-
|
|
71
|
+
bounds: [mockData[0][0].timestamp, mockData[0][mockData[0].length - 1].timestamp],
|
|
72
|
+
stepMs: 100
|
|
73
|
+
},
|
|
74
|
+
render: function Component(args) {
|
|
75
|
+
var _useArgs = useArgs(),
|
|
76
|
+
_useArgs2 = _slicedToArray(_useArgs, 2),
|
|
77
|
+
setArgs = _useArgs2[1];
|
|
78
|
+
var onSelectedTimeframe = function onSelectedTimeframe(index, bounds) {
|
|
79
|
+
args.onSelectedTimeframe(index, bounds);
|
|
80
|
+
setArgs(_objectSpread(_objectSpread({}, args), {}, {
|
|
81
|
+
selectedTimeframe: {
|
|
82
|
+
index: index,
|
|
83
|
+
bounds: bounds
|
|
84
|
+
}
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
return /*#__PURE__*/_jsx(SamplesStrip, _objectSpread(_objectSpread({}, args), {}, {
|
|
88
|
+
onSelectedTimeframe: onSelectedTimeframe
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
};
|