Skip to content

Commit 4970a32

Browse files
committed
merge
2 parents bff118b + 0e939e7 commit 4970a32

File tree

1 file changed

+70
-2
lines changed

1 file changed

+70
-2
lines changed

src/app/components/ComponentMap.tsx

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// @ts-nocheck
2+
<<<<<<< HEAD
23
import React, { useState } from "react";
34
import { Group } from "@visx/group";
45
import { hierarchy, Tree } from "@visx/hierarchy";
@@ -15,6 +16,20 @@ import {
1516
} from "@visx/tooltip";
1617
import { onHover, onHoverExit } from "../actions/actions";
1718
import { useStoreContext } from "../store";
19+
=======
20+
import React, { useState } from 'react';
21+
import { Group } from '@visx/group';
22+
import { hierarchy, Tree } from '@visx/hierarchy';
23+
import { LinearGradient } from '@visx/gradient';
24+
import { pointRadial } from 'd3-shape';
25+
import useForceUpdate from './useForceUpdate';
26+
import LinkControls from './LinkControls';
27+
import getLinkComponent from './getLinkComponent';
28+
import { localPoint } from '@visx/event';
29+
import { useTooltip, useTooltipInPortal, TooltipWithBounds, defaultStyles } from '@visx/tooltip';
30+
import { onHover, onHoverExit } from '../actions/actions';
31+
import { useStoreContext } from '../store';
32+
>>>>>>> 0e939e7bb8e045845438bf4ffa8825db5fe14cac
1833

1934
const root = hierarchy({
2035
name: "root",
@@ -106,8 +121,12 @@ export default function ComponentMap({
106121
hideTooltip,
107122
} = useTooltip();
108123

109-
const { containerRef, TooltipInPortal } = useTooltipInPortal();
124+
const { containerRef, TooltipInPortal } = useTooltipInPortal({
125+
detectBounds: true,
126+
scroll: true,
127+
});
110128

129+
<<<<<<< HEAD
111130
//mousing controls
112131
const handleMouseOver = (event) => {
113132
// console.log("mouse entered");
@@ -119,6 +138,23 @@ export default function ComponentMap({
119138
tooltipData: "test",
120139
});
121140
};
141+
=======
142+
const tooltipStyles = {
143+
...defaultStyles,
144+
minWidth: 60,
145+
backgroundColor: 'rgba(0,0,0,0.9)',
146+
color: 'white',
147+
fontSize: '14px',
148+
lineHeight: '18px',
149+
fontFamily: 'Roboto',
150+
};
151+
152+
const formatRenderTime = (time) => {
153+
time = time.toFixed(3);
154+
return `${time} ms `;
155+
}
156+
157+
>>>>>>> 0e939e7bb8e045845438bf4ffa8825db5fe14cac
122158

123159
// controls for the map
124160
const LinkComponent = getLinkComponent({ layout, linkType, orientation });
@@ -167,6 +203,8 @@ export default function ComponentMap({
167203
const width = widthFunc(node.data.name);
168204
const height = 25;
169205

206+
207+
170208
let top: number;
171209
let left: number;
172210
if (layout === "polar") {
@@ -181,6 +219,21 @@ export default function ComponentMap({
181219
left = node.y;
182220
}
183221

222+
//mousing controls
223+
const handleMouseOver = (event) => {
224+
() => dispatch(onHover(node.data.rtid));
225+
const coords = localPoint(event.target.ownerSVGElement, event);
226+
const tooltipObj = Object.assign({}, node.data);
227+
if (typeof tooltipObj.state === 'object') tooltipObj.state = 'stateful';
228+
console.log("tooltipObj", tooltipObj)
229+
showTooltip({
230+
tooltipLeft: coords.x,
231+
tooltipTop: coords.y,
232+
tooltipData: tooltipObj
233+
});
234+
}
235+
236+
184237
return (
185238
<Group top={top} left={left} key={key}>
186239
{node.depth === 0 && (
@@ -242,16 +295,31 @@ export default function ComponentMap({
242295
</Tree>
243296
</Group>
244297
</svg>
298+
<<<<<<< HEAD
245299
{tooltipOpen && tooltipData && (
300+
=======
301+
{tooltipOpen && tooltipData && (
302+
>>>>>>> 0e939e7bb8e045845438bf4ffa8825db5fe14cac
246303
<TooltipInPortal
247304
// set this to random so it correctly updates with parent bounds
248305
key={Math.random()}
249306
top={tooltipTop}
250307
left={tooltipLeft}
308+
style={tooltipStyles}
251309
>
252-
Tooltip Data: <strong>{tooltipData}</strong>
310+
<div style={{ }}>
311+
{' '}
312+
<strong>{tooltipData.name}</strong>{' '}
313+
</div>
314+
<div>State: {tooltipData.state}</div>
315+
<div> Render time: {formatRenderTime(tooltipData.componentData.actualDuration)} </div>
316+
253317
</TooltipInPortal>
318+
<<<<<<< HEAD
254319
)}
320+
=======
321+
)}
322+
>>>>>>> 0e939e7bb8e045845438bf4ffa8825db5fe14cac
255323
</div>
256324
);
257325
}

0 commit comments

Comments
 (0)