@parca/profile 0.17.1 → 0.17.3

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 (120) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/GraphTooltipArrow/Content.d.ts +1 -2
  3. package/dist/GraphTooltipArrow/Content.d.ts.map +1 -1
  4. package/dist/GraphTooltipArrow/Content.js +1 -2
  5. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.d.ts +1 -2
  6. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.d.ts.map +1 -1
  7. package/dist/GraphTooltipArrow/DockedGraphTooltip/index.js +1 -2
  8. package/dist/GraphTooltipArrow/useGraphTooltip/index.d.ts +1 -2
  9. package/dist/GraphTooltipArrow/useGraphTooltip/index.d.ts.map +1 -1
  10. package/dist/GraphTooltipArrow/useGraphTooltip/index.js +2 -2
  11. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.d.ts +2 -6
  12. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.d.ts.map +1 -1
  13. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.js +4 -5
  14. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.d.ts +20 -0
  15. package/dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.d.ts.map +1 -0
  16. package/{src/Callgraph/constants.ts → dist/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.js} +12 -3
  17. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts +8 -51
  18. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.d.ts.map +1 -1
  19. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.js +59 -136
  20. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.d.ts +8 -0
  21. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.d.ts.map +1 -0
  22. package/dist/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.js +40 -0
  23. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.d.ts +32 -0
  24. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.d.ts.map +1 -0
  25. package/dist/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.js +40 -0
  26. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts +4 -5
  27. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.d.ts.map +1 -1
  28. package/dist/ProfileIcicleGraph/IcicleGraphArrow/index.js +62 -76
  29. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts +3 -3
  30. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.d.ts.map +1 -1
  31. package/dist/ProfileIcicleGraph/IcicleGraphArrow/utils.js +9 -7
  32. package/dist/ProfileIcicleGraph/index.d.ts +3 -6
  33. package/dist/ProfileIcicleGraph/index.d.ts.map +1 -1
  34. package/dist/ProfileIcicleGraph/index.js +8 -17
  35. package/dist/ProfileView/components/DashboardItems/index.d.ts +3 -5
  36. package/dist/ProfileView/components/DashboardItems/index.d.ts.map +1 -1
  37. package/dist/ProfileView/components/DashboardItems/index.js +4 -9
  38. package/dist/ProfileView/components/Toolbars/index.d.ts.map +1 -1
  39. package/dist/ProfileView/components/Toolbars/index.js +1 -2
  40. package/dist/ProfileView/index.d.ts +1 -1
  41. package/dist/ProfileView/index.d.ts.map +1 -1
  42. package/dist/ProfileView/index.js +1 -13
  43. package/dist/ProfileView/types/visualization.d.ts +1 -1
  44. package/dist/ProfileView/types/visualization.d.ts.map +1 -1
  45. package/dist/index.d.ts +0 -4
  46. package/dist/index.d.ts.map +1 -1
  47. package/dist/index.js +0 -2
  48. package/dist/styles.css +1 -1
  49. package/package.json +5 -5
  50. package/src/GraphTooltipArrow/Content.tsx +0 -3
  51. package/src/GraphTooltipArrow/DockedGraphTooltip/index.tsx +0 -3
  52. package/src/GraphTooltipArrow/useGraphTooltip/index.ts +1 -3
  53. package/src/ProfileIcicleGraph/IcicleGraphArrow/ContextMenu.tsx +5 -13
  54. package/src/ProfileIcicleGraph/IcicleGraphArrow/ContextMenuWrapper.tsx +53 -0
  55. package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleGraphNodes.tsx +96 -310
  56. package/src/ProfileIcicleGraph/IcicleGraphArrow/MemoizedTooltip.tsx +78 -0
  57. package/src/ProfileIcicleGraph/IcicleGraphArrow/TooltipContext.tsx +93 -0
  58. package/src/ProfileIcicleGraph/IcicleGraphArrow/index.tsx +108 -216
  59. package/src/ProfileIcicleGraph/IcicleGraphArrow/utils.ts +8 -15
  60. package/src/ProfileIcicleGraph/index.tsx +7 -38
  61. package/src/ProfileView/components/DashboardItems/index.tsx +2 -27
  62. package/src/ProfileView/components/Toolbars/index.tsx +0 -2
  63. package/src/ProfileView/index.tsx +0 -14
  64. package/src/ProfileView/types/visualization.ts +1 -1
  65. package/src/index.tsx +0 -5
  66. package/dist/Callgraph/constants.d.ts +0 -3
  67. package/dist/Callgraph/constants.d.ts.map +0 -1
  68. package/dist/Callgraph/constants.js +0 -14
  69. package/dist/Callgraph/index.d.ts +0 -11
  70. package/dist/Callgraph/index.d.ts.map +0 -1
  71. package/dist/Callgraph/index.js +0 -104
  72. package/dist/Callgraph/mockData/index.d.ts +0 -149
  73. package/dist/Callgraph/mockData/index.d.ts.map +0 -1
  74. package/dist/Callgraph/mockData/index.js +0 -594
  75. package/dist/Callgraph/utils.d.ts +0 -20
  76. package/dist/Callgraph/utils.d.ts.map +0 -1
  77. package/dist/Callgraph/utils.js +0 -97
  78. package/dist/GraphTooltip/ExpandOnHoverValue.d.ts +0 -7
  79. package/dist/GraphTooltip/ExpandOnHoverValue.d.ts.map +0 -1
  80. package/dist/GraphTooltip/ExpandOnHoverValue.js +0 -4
  81. package/dist/GraphTooltip/index.d.ts +0 -41
  82. package/dist/GraphTooltip/index.d.ts.map +0 -1
  83. package/dist/GraphTooltip/index.js +0 -201
  84. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts +0 -6
  85. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.d.ts.map +0 -1
  86. package/dist/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.js +0 -59
  87. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts +0 -47
  88. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.d.ts.map +0 -1
  89. package/dist/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.js +0 -93
  90. package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts +0 -14
  91. package/dist/ProfileIcicleGraph/IcicleGraph/index.d.ts.map +0 -1
  92. package/dist/ProfileIcicleGraph/IcicleGraph/index.js +0 -48
  93. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.d.ts +0 -15
  94. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.d.ts.map +0 -1
  95. package/dist/ProfileIcicleGraph/IcicleGraph/useColoredGraph.js +0 -57
  96. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.d.ts +0 -8
  97. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.d.ts.map +0 -1
  98. package/dist/ProfileIcicleGraph/IcicleGraph/useNodeColor.js +0 -32
  99. package/dist/ProfileIcicleGraph/IcicleGraph/utils.d.ts +0 -7
  100. package/dist/ProfileIcicleGraph/IcicleGraph/utils.d.ts.map +0 -1
  101. package/dist/ProfileIcicleGraph/IcicleGraph/utils.js +0 -66
  102. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.d.ts +0 -9
  103. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.d.ts.map +0 -1
  104. package/dist/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.js +0 -45
  105. package/dist/ProfileView/hooks/useGraphviz.d.ts +0 -12
  106. package/dist/ProfileView/hooks/useGraphviz.d.ts.map +0 -1
  107. package/dist/ProfileView/hooks/useGraphviz.js +0 -42
  108. package/src/Callgraph/index.tsx +0 -177
  109. package/src/Callgraph/mockData/index.ts +0 -605
  110. package/src/Callgraph/utils.ts +0 -141
  111. package/src/GraphTooltip/ExpandOnHoverValue.tsx +0 -30
  112. package/src/GraphTooltip/index.tsx +0 -509
  113. package/src/ProfileIcicleGraph/IcicleGraph/ColorStackLegend.tsx +0 -96
  114. package/src/ProfileIcicleGraph/IcicleGraph/IcicleGraphNodes.tsx +0 -266
  115. package/src/ProfileIcicleGraph/IcicleGraph/index.tsx +0 -123
  116. package/src/ProfileIcicleGraph/IcicleGraph/useColoredGraph.ts +0 -117
  117. package/src/ProfileIcicleGraph/IcicleGraph/useNodeColor.ts +0 -54
  118. package/src/ProfileIcicleGraph/IcicleGraph/utils.ts +0 -102
  119. package/src/ProfileIcicleGraph/IcicleGraphArrow/IcicleChartRootNode.tsx +0 -130
  120. package/src/ProfileView/hooks/useGraphviz.ts +0 -69
@@ -15,14 +15,12 @@ import {Profiler, ProfilerOnRenderCallback} from 'react';
15
15
 
16
16
  import {ConditionalWrapper} from '@parca/components';
17
17
 
18
- import Callgraph from '../../../Callgraph';
19
18
  import ProfileIcicleGraph from '../../../ProfileIcicleGraph';
20
19
  import {CurrentPathFrame} from '../../../ProfileIcicleGraph/IcicleGraphArrow/utils';
21
20
  import {ProfileSource} from '../../../ProfileSource';
22
21
  import {SourceView} from '../../../SourceView';
23
22
  import {Table} from '../../../Table';
24
23
  import type {
25
- CallgraphData,
26
24
  FlamegraphData,
27
25
  SourceData,
28
26
  TopTableData,
@@ -36,9 +34,8 @@ interface GetDashboardItemProps {
36
34
  flamegraphData: FlamegraphData;
37
35
  flamechartData: FlamegraphData;
38
36
  topTableData?: TopTableData;
39
- callgraphData?: CallgraphData;
40
37
  sourceData?: SourceData;
41
- profileSource?: ProfileSource;
38
+ profileSource: ProfileSource;
42
39
  total: bigint;
43
40
  filtered: bigint;
44
41
  curPath: string[];
@@ -47,7 +44,6 @@ interface GetDashboardItemProps {
47
44
  setNewCurPathArrow: (path: CurrentPathFrame[]) => void;
48
45
  currentSearchString?: string;
49
46
  setSearchString?: (value: string) => void;
50
- callgraphSVG?: string;
51
47
  perf?: {
52
48
  onRender?: ProfilerOnRenderCallback;
53
49
  };
@@ -60,18 +56,14 @@ export const getDashboardItem = ({
60
56
  flamegraphData,
61
57
  flamechartData,
62
58
  topTableData,
63
- callgraphData,
64
59
  sourceData,
65
60
  profileSource,
66
61
  total,
67
62
  filtered,
68
- curPath,
69
- setNewCurPath,
70
63
  curPathArrow,
71
64
  setNewCurPathArrow,
72
65
  currentSearchString,
73
66
  setSearchString,
74
- callgraphSVG,
75
67
  perf,
76
68
  }: GetDashboardItemProps): JSX.Element => {
77
69
  switch (type) {
@@ -86,12 +78,9 @@ export const getDashboardItem = ({
86
78
  }}
87
79
  >
88
80
  <ProfileIcicleGraph
89
- curPath={curPath}
90
- setNewCurPath={setNewCurPath}
91
81
  curPathArrow={curPathArrow}
92
82
  setNewCurPathArrow={setNewCurPathArrow}
93
83
  arrow={flamegraphData?.arrow}
94
- graph={flamegraphData?.data}
95
84
  total={total}
96
85
  filtered={filtered}
97
86
  profileType={profileSource?.ProfileType()}
@@ -107,14 +96,13 @@ export const getDashboardItem = ({
107
96
  }
108
97
  metadataMappingFiles={flamegraphData.metadataMappingFiles}
109
98
  metadataLoading={flamegraphData.metadataLoading}
99
+ profileSource={profileSource}
110
100
  />
111
101
  </ConditionalWrapper>
112
102
  );
113
103
  case 'iciclechart':
114
104
  return (
115
105
  <ProfileIcicleGraph
116
- curPath={[]}
117
- setNewCurPath={() => {}}
118
106
  curPathArrow={[]}
119
107
  setNewCurPathArrow={() => {}}
120
108
  arrow={flamechartData?.arrow}
@@ -137,19 +125,6 @@ export const getDashboardItem = ({
137
125
  isIcicleChart={true}
138
126
  />
139
127
  );
140
- case 'callgraph':
141
- return callgraphData?.data !== undefined &&
142
- callgraphSVG !== undefined &&
143
- dimensions?.width !== undefined ? (
144
- <Callgraph
145
- data={callgraphData.data}
146
- svgString={callgraphSVG}
147
- profileType={profileSource?.ProfileType()}
148
- width={isHalfScreen ? dimensions?.width / 2 : dimensions?.width}
149
- />
150
- ) : (
151
- <></>
152
- );
153
128
  case 'table':
154
129
  return topTableData != null ? (
155
130
  <Table
@@ -23,7 +23,6 @@ import {CurrentPathFrame} from '../../../ProfileIcicleGraph/IcicleGraphArrow/uti
23
23
  import {ProfileSource} from '../../../ProfileSource';
24
24
  import {useDashboard} from '../../context/DashboardContext';
25
25
  import GroupByDropdown from '../ActionButtons/GroupByDropdown';
26
- import SortByDropdown from '../ActionButtons/SortByDropdown';
27
26
  import FilterByFunctionButton from '../FilterByFunctionButton';
28
27
  import ShareButton from '../ShareButton';
29
28
  import ViewSelector from '../ViewSelector';
@@ -95,7 +94,6 @@ export const IcicleGraphToolbar: FC<IcicleGraphToolbarProps> = ({curPath, setNew
95
94
  return (
96
95
  <>
97
96
  <div className="flex w-full gap-2 items-end">
98
- <SortByDropdown />
99
97
  <Button
100
98
  variant="neutral"
101
99
  className="gap-2 w-max h-fit"
@@ -13,7 +13,6 @@
13
13
 
14
14
  import {KeyDownProvider, useParcaContext} from '@parca/components';
15
15
  import {useContainerDimensions} from '@parca/hooks';
16
- import {selectDarkMode, useAppSelector} from '@parca/store';
17
16
  import {selectQueryParam} from '@parca/utilities';
18
17
 
19
18
  import ColorStackLegend from './components/ColorStackLegend';
@@ -23,11 +22,9 @@ import {ProfileHeader} from './components/ProfileHeader';
23
22
  import {IcicleGraphToolbar, TableToolbar, VisualisationToolbar} from './components/Toolbars';
24
23
  import {DashboardProvider} from './context/DashboardContext';
25
24
  import {ProfileViewContextProvider} from './context/ProfileViewContext';
26
- import {useGraphviz} from './hooks/useGraphviz';
27
25
  import {useProfileMetadata} from './hooks/useProfileMetadata';
28
26
  import {useVisualizationState} from './hooks/useVisualizationState';
29
27
  import type {ProfileViewProps, VisualizationType} from './types/visualization';
30
- import {getColorRange} from './utils/colorUtils';
31
28
 
32
29
  export const ProfileView = ({
33
30
  total,
@@ -35,7 +32,6 @@ export const ProfileView = ({
35
32
  flamegraphData,
36
33
  flamechartData,
37
34
  topTableData,
38
- callgraphData,
39
35
  sourceData,
40
36
  profileSource,
41
37
  queryClient,
@@ -52,8 +48,6 @@ export const ProfileView = ({
52
48
  profileViewExternalSubActions,
53
49
  } = useParcaContext();
54
50
  const {ref, dimensions} = useContainerDimensions();
55
- const isDarkMode = useAppSelector(selectDarkMode);
56
- const colorRange = getColorRange(isDarkMode);
57
51
 
58
52
  const {
59
53
  curPath,
@@ -70,12 +64,6 @@ export const ProfileView = ({
70
64
  setGroupByLabels,
71
65
  } = useVisualizationState();
72
66
 
73
- const {callgraphSVG} = useGraphviz({
74
- callgraphData: callgraphData?.data,
75
- width: dimensions?.width,
76
- colorRange,
77
- });
78
-
79
67
  const {colorMappings} = useProfileMetadata({
80
68
  flamegraphArrow: flamegraphData.arrow,
81
69
  metadataMappingFiles: flamegraphData.metadataMappingFiles,
@@ -102,7 +90,6 @@ export const ProfileView = ({
102
90
  flamegraphData,
103
91
  flamechartData,
104
92
  topTableData,
105
- callgraphData,
106
93
  sourceData,
107
94
  profileSource,
108
95
  total,
@@ -113,7 +100,6 @@ export const ProfileView = ({
113
100
  setNewCurPathArrow: setCurPathArrow,
114
101
  currentSearchString,
115
102
  setSearchString,
116
- callgraphSVG,
117
103
  perf,
118
104
  });
119
105
  };
@@ -67,7 +67,7 @@ export interface ProfileViewProps {
67
67
  topTableData?: TopTableData;
68
68
  callgraphData?: CallgraphData;
69
69
  sourceData?: SourceData;
70
- profileSource?: ProfileSource;
70
+ profileSource: ProfileSource;
71
71
  queryClient?: QueryServiceClient;
72
72
  compare?: boolean;
73
73
  onDownloadPProf: () => void;
package/src/index.tsx CHANGED
@@ -11,13 +11,11 @@
11
11
  // See the License for the specific language governing permissions and
12
12
  // limitations under the License.
13
13
 
14
- import type {Props as CallgraphProps} from './Callgraph';
15
14
  import {useLabelNames} from './MatchersInput';
16
15
  import ProfileExplorer, {getExpressionAsAString} from './ProfileExplorer';
17
16
  import ProfileTypeSelector from './ProfileTypeSelector';
18
17
  import CustomSelect from './SimpleMatchers/Select';
19
18
 
20
- export * from './ProfileIcicleGraph/IcicleGraph';
21
19
  export * from './ProfileIcicleGraph';
22
20
  export * from './ProfileSource';
23
21
  export * from './ProfileView';
@@ -26,12 +24,9 @@ export * from './utils';
26
24
  export * from './ProfileTypeSelector';
27
25
  export * from './SourceView';
28
26
  export * from './ProfileMetricsGraph';
29
- export {default as Callgraph} from './Callgraph';
30
27
 
31
28
  export const DEFAULT_PROFILE_EXPLORER_PARAM_VALUES = {
32
29
  dashboard_items: 'icicle',
33
30
  };
34
31
 
35
- export type {CallgraphProps};
36
-
37
32
  export {ProfileExplorer, ProfileTypeSelector, getExpressionAsAString, CustomSelect, useLabelNames};
@@ -1,3 +0,0 @@
1
- export declare const DEFAULT_NODE_HEIGHT = 20;
2
- export declare const GRAPH_MARGIN = 15;
3
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/Callgraph/constants.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,mBAAmB,KAAK,CAAC;AACtC,eAAO,MAAM,YAAY,KAAK,CAAC"}
@@ -1,14 +0,0 @@
1
- // Copyright 2022 The Parca Authors
2
- // Licensed under the Apache License, Version 2.0 (the "License");
3
- // you may not use this file except in compliance with the License.
4
- // You may obtain a copy of the License at
5
- //
6
- // http://www.apache.org/licenses/LICENSE-2.0
7
- //
8
- // Unless required by applicable law or agreed to in writing, software
9
- // distributed under the License is distributed on an "AS IS" BASIS,
10
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
- // See the License for the specific language governing permissions and
12
- // limitations under the License.
13
- export const DEFAULT_NODE_HEIGHT = 20;
14
- export const GRAPH_MARGIN = 15;
@@ -1,11 +0,0 @@
1
- import { Callgraph as CallgraphType } from '@parca/client';
2
- import { ProfileType } from '@parca/parser';
3
- export interface Props {
4
- data: CallgraphType;
5
- svgString: string;
6
- profileType: ProfileType | undefined;
7
- width: number;
8
- }
9
- declare const Callgraph: ({ data, svgString, profileType, width }: Props) => JSX.Element;
10
- export default Callgraph;
11
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/Callgraph/index.tsx"],"names":[],"mappings":"AAoBA,OAAO,EAAgB,SAAS,IAAI,aAAa,EAAC,MAAM,eAAe,CAAC;AAExE,OAAO,EAAC,WAAW,EAAC,MAAM,eAAe,CAAC;AAM1C,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,KAAK,EAAE,MAAM,CAAC;CACf;AAOD,QAAA,MAAM,SAAS,4CAA2C,KAAK,KAAG,GAAG,CAAC,OAsIrE,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,104 +0,0 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // Copyright 2022 The Parca Authors
3
- // Licensed under the Apache License, Version 2.0 (the "License");
4
- // you may not use this file except in compliance with the License.
5
- // You may obtain a copy of the License at
6
- //
7
- // http://www.apache.org/licenses/LICENSE-2.0
8
- //
9
- // Unless required by applicable law or agreed to in writing, software
10
- // distributed under the License is distributed on an "AS IS" BASIS,
11
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- // See the License for the specific language governing permissions and
13
- // limitations under the License.
14
- import { useEffect, useRef, useState } from 'react';
15
- import cx from 'classnames';
16
- import * as d3 from 'd3';
17
- import SVG from 'react-inlinesvg';
18
- import { MapInteractionCSS } from 'react-map-interaction';
19
- import { Button, useKeyDown, useURLState } from '@parca/components';
20
- import { selectDarkMode, setHoveringNode, useAppDispatch, useAppSelector } from '@parca/store';
21
- import { getNewSpanColor } from '@parca/utilities';
22
- import GraphTooltip from '../GraphTooltip';
23
- const Callgraph = ({ data, svgString, profileType, width }) => {
24
- const originalView = {
25
- scale: 1,
26
- translation: { x: 0, y: 0 },
27
- };
28
- const [view, setView] = useState(originalView);
29
- const containerRef = useRef(null);
30
- const svgRef = useRef(null);
31
- const svgWrapper = useRef(null);
32
- const [svgWrapperLoaded, setSvgWrapperLoaded] = useState(false);
33
- const dispatch = useAppDispatch();
34
- const { isShiftDown } = useKeyDown();
35
- // TODO: implement highlighting nodes on user search
36
- // const currentSearchString = (selectQueryParam('search_string') as string) ?? '';
37
- // const isSearchEmpty = currentSearchString === undefined || currentSearchString === '';
38
- // const isCurrentSearchMatch = isSearchEmpty
39
- // ? true
40
- // : isSearchMatch(currentSearchString, sourceNode.functionName) &&
41
- // isSearchMatch(currentSearchString, targetNode.functionName);
42
- const [dashboardItems] = useURLState('dashboard_items', {
43
- alwaysReturnArray: true,
44
- });
45
- const isDarkMode = useAppSelector(selectDarkMode);
46
- const maxColor = getNewSpanColor(isDarkMode);
47
- const minColor = d3.scaleLinear([isDarkMode ? 'black' : 'white', maxColor])(0.3);
48
- const colorRange = [minColor, maxColor];
49
- const cumulatives = data.edges.map((edge) => edge.cumulative.toString());
50
- const cumulativesRange = d3.extent(cumulatives);
51
- const colorScale = d3
52
- .scaleSequentialLog(d3.interpolateBlues)
53
- .domain([Number(cumulativesRange[0]), Number(cumulativesRange[1])])
54
- .range(colorRange);
55
- useEffect(() => {
56
- setSvgWrapperLoaded(true);
57
- }, []);
58
- useEffect(() => {
59
- if (svgWrapperLoaded && svgRef.current !== null) {
60
- const addInteraction = () => {
61
- const svg = d3.select(svgRef.current);
62
- const nodes = svg.selectAll('.node');
63
- nodes.each(function () {
64
- const nodeData = data.nodes.find((n) => {
65
- return n.id === this.id;
66
- });
67
- const defaultColor = colorScale(Number(nodeData?.cumulative));
68
- const node = d3.select(this);
69
- const path = node.select('path');
70
- node
71
- .style('cursor', 'pointer')
72
- .on('mouseenter', function () {
73
- if (isShiftDown)
74
- return;
75
- d3.select(this).select('path').style('fill', 'white');
76
- const hoveringNode = {
77
- ...nodeData,
78
- meta: { ...nodeData?.meta, lineIndex: 0, locationIndex: 0 },
79
- };
80
- // @ts-expect-error
81
- dispatch(setHoveringNode(hoveringNode));
82
- })
83
- .on('mouseleave', function () {
84
- if (isShiftDown)
85
- return;
86
- d3.select(this).select('path').style('fill', defaultColor);
87
- dispatch(setHoveringNode(undefined));
88
- });
89
- path.style('fill', defaultColor);
90
- });
91
- };
92
- setTimeout(addInteraction, 1000);
93
- }
94
- // eslint-disable-next-line react-hooks/exhaustive-deps
95
- }, [svgWrapper.current, svgWrapperLoaded]);
96
- if (data.nodes.length < 1)
97
- return _jsx("div", { className: "mx-auto text-center", children: "Profile has no samples" });
98
- const resetView = () => setView(originalView);
99
- const isResetViewButtonEnabled = view.scale !== originalView.scale ||
100
- view.translation.x !== originalView.translation.x ||
101
- view.translation.y !== originalView.translation.y;
102
- return (_jsxs("div", { className: "relative w-full", children: [_jsxs("div", { ref: containerRef, className: "w-full overflow-hidden", children: [_jsx(MapInteractionCSS, { showControls: true, minScale: 1, maxScale: 5, value: view, onChange: (value) => setView(value), children: _jsx(SVG, { ref: svgWrapper, src: svgString, width: width, height: "auto", title: "Callgraph", innerRef: svgRef }) }), svgRef.current !== null && (_jsx(GraphTooltip, { type: "callgraph", unit: profileType?.sampleUnit ?? '', total: data.cumulative, totalUnfiltered: data.cumulative, contextElement: containerRef.current }))] }), _jsx("div", { className: cx(dashboardItems.length > 1 ? 'left-[25px]' : 'left-0', 'absolute top-[-46px] w-auto'), children: _jsx(Button, { variant: "neutral", onClick: resetView, className: "z-50", disabled: !isResetViewButtonEnabled, children: "Reset View" }) })] }));
103
- };
104
- export default Callgraph;
@@ -1,149 +0,0 @@
1
- export declare const dotGraph = "{\n n1 [Label = \"n1\"];\n n2 [Label = \"n2\"];\n n3 [Label = \"n3\"];\n n1 -- n2;\n n1 -- n3;\n n2 -- n2;\n}";
2
- export declare const jsonGraph: {
3
- total: string;
4
- unit: string;
5
- nodes: {
6
- id: string;
7
- label: string;
8
- value: number;
9
- }[];
10
- edges: {
11
- id: string;
12
- source: string;
13
- target: string;
14
- label: string;
15
- }[];
16
- };
17
- export declare const graphvizDot = "\ndigraph {\n N1 [id=\"node1\"]\n N2 [id=\"node2\"]\n N3 [id=\"node3\"]\n N4 [id=\"node4\"]\n N1 -> N2 [id=\"e1\" label=\"e1 fdskjao fdjksaol\"]\n N2 -> N3 [id=\"e2\" label=\"e2\"]\n N3 -> N4 [id=\"e3\" label=\"e3\"]\n N3 -> N1 [id=\"e4\" label=\"e4\"]\n }";
18
- export declare const jsonGraphWithGraphvizPositions: {
19
- name: string;
20
- directed: boolean;
21
- strict: boolean;
22
- _draw_: ({
23
- op: string;
24
- grad: string;
25
- color: string;
26
- points?: undefined;
27
- } | {
28
- op: string;
29
- points: number[][];
30
- grad?: undefined;
31
- color?: undefined;
32
- })[];
33
- bb: string;
34
- xdotversion: string;
35
- _subgraph_cnt: number;
36
- objects: {
37
- _gvid: number;
38
- name: string;
39
- Label: string;
40
- _draw_: ({
41
- op: string;
42
- grad: string;
43
- color: string;
44
- rect?: undefined;
45
- } | {
46
- op: string;
47
- rect: number[];
48
- grad?: undefined;
49
- color?: undefined;
50
- })[];
51
- _ldraw_: ({
52
- op: string;
53
- size: number;
54
- face: string;
55
- grad?: undefined;
56
- color?: undefined;
57
- pt?: undefined;
58
- align?: undefined;
59
- width?: undefined;
60
- text?: undefined;
61
- } | {
62
- op: string;
63
- grad: string;
64
- color: string;
65
- size?: undefined;
66
- face?: undefined;
67
- pt?: undefined;
68
- align?: undefined;
69
- width?: undefined;
70
- text?: undefined;
71
- } | {
72
- op: string;
73
- pt: number[];
74
- align: string;
75
- width: number;
76
- text: string;
77
- size?: undefined;
78
- face?: undefined;
79
- grad?: undefined;
80
- color?: undefined;
81
- })[];
82
- fillcolor: string;
83
- fixedsize: string;
84
- fontcolor: string;
85
- height: string;
86
- label: string;
87
- margin: string;
88
- pos: string;
89
- shape: string;
90
- style: string;
91
- width: string;
92
- }[];
93
- edges: {
94
- _gvid: number;
95
- tail: number;
96
- head: number;
97
- _draw_: ({
98
- op: string;
99
- grad: string;
100
- color: string;
101
- points?: undefined;
102
- } | {
103
- op: string;
104
- points: number[][];
105
- grad?: undefined;
106
- color?: undefined;
107
- })[];
108
- _hdraw_: ({
109
- op: string;
110
- style: string;
111
- grad?: undefined;
112
- color?: undefined;
113
- points?: undefined;
114
- } | {
115
- op: string;
116
- grad: string;
117
- color: string;
118
- style?: undefined;
119
- points?: undefined;
120
- } | {
121
- op: string;
122
- points: number[][];
123
- style?: undefined;
124
- grad?: undefined;
125
- color?: undefined;
126
- })[];
127
- pos: string;
128
- }[];
129
- };
130
- export declare const nodeWithMetaData: (id: string, name: string) => {
131
- id: string;
132
- cumulative: number;
133
- meta: any;
134
- };
135
- export declare const jsonGraphWithMetaData: {
136
- total: string;
137
- nodes: {
138
- id: string;
139
- cumulative: number;
140
- meta: any;
141
- }[];
142
- edges: {
143
- id: string;
144
- source: string;
145
- target: string;
146
- cumulative: string;
147
- }[];
148
- };
149
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/Callgraph/mockData/index.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,QAAQ,kHAOnB,CAAC;AAEH,eAAO,MAAM,SAAS;;;;;;;;;;;;;;CAqFrB,CAAC;AAGF,eAAO,MAAM,WAAW,8QAUpB,CAAC;AAEL,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAsU1C,CAAC;AAEF,eAAO,MAAM,gBAAgB,OACvB,MAAM,QACJ,MAAM,KACX;IAAC,EAAE,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,GAAG,CAAA;CAyH3C,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;YA3H1B,MAAM;oBAAc,MAAM;cAAQ,GAAG;;;;;;;;CAuJ5C,CAAC"}