Skip to content

Commit 4b22c64

Browse files
committed
adding hover functionality to the bar graph
1 parent 47a2472 commit 4b22c64

File tree

2 files changed

+34
-7
lines changed

2 files changed

+34
-7
lines changed

src/app/components/BarGraph.tsx

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ const BarGraph = props => {
103103
// }
104104
const rgb = ['rgba(50, 100, 241, .5)', 'rgba(90, 150, 217, .5)', 'rgba(200, 30, 7, .5)', 'rgba(23, 233, 217, .5)', 'rgba(150, 227, 19, .5)'];
105105
for (const [key, value] of Object.entries(data.barStack[0])) {
106+
const toolTipData = {key: key, value: value}
106107
console.log(xMax, '<-- xmax');
107108
if (key !== 'snapshotId' && key !== 'route') {
108109
// console.log(`${key}: ${value}`);
@@ -135,7 +136,7 @@ const BarGraph = props => {
135136
const top = event.clientY - margin.top - value * 25;
136137
const left = 10 + 10 * i + barWidth * i + barWidth / 2;
137138
showTooltip({
138-
tooltipData: value,
139+
tooltipData: toolTipData,
139140
tooltipTop: top,
140141
tooltipLeft: left,
141142
});
@@ -169,7 +170,7 @@ const BarGraph = props => {
169170
const top = event.clientY - margin.top - value * 25;
170171
const left = 10 + 10 * i + barWidth * i + barWidth / 2;
171172
showTooltip({
172-
tooltipData: value,
173+
tooltipData: toolTipData,
173174
tooltipTop: top,
174175
tooltipLeft: left,
175176
});
@@ -511,7 +512,10 @@ const BarGraph = props => {
511512

512513
</svg>
513514
{/* FOR HOVER OVER DISPLAY */}
514-
{tooltipOpen && tooltipData && (
515+
{/* Ths conditional statement displays a different tooltip
516+
configuration depending on if we are trying do display a specific
517+
snapshot through options menu or all snapshots together in bargraph */}
518+
{snapshot === 'All Snapshots' ? (tooltipOpen && tooltipData && (
515519
<TooltipInPortal
516520
key={Math.random()} // update tooltip bounds each render
517521
top={tooltipTop}
@@ -536,7 +540,30 @@ const BarGraph = props => {
536540
</small>
537541
</div>
538542
</TooltipInPortal>
539-
)}
543+
))
544+
: (tooltipOpen && tooltipData && (
545+
<TooltipInPortal
546+
key={Math.random()} // update tooltip bounds each render
547+
top={tooltipTop}
548+
left={tooltipLeft}
549+
style={tooltipStyles}
550+
>
551+
{console.log(tooltipData, '<------tooltipData')}
552+
<div style={{ color: colorScale(tooltipData.key) }}>
553+
{' '}
554+
<strong>{tooltipData.key}</strong>
555+
{' '}
556+
</div>
557+
<div>
558+
{' '}
559+
{formatRenderTime(tooltipData.value)}
560+
{' '}
561+
</div>
562+
<div>
563+
{' '}
564+
</div>
565+
</TooltipInPortal>
566+
))}
540567
</div>
541568
);
542569
};

src/app/components/PerformanceVisx.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ const PerformanceVisx = (props: BarStackProps) => {
250250
if (route !== 'All Routes') {
251251
data.barStack = filteredSnapshots;
252252
}
253-
console.log(snapshot);
253+
// console.log(snapshot);
254254
// snapshot = '2.0' parseInt(snapshot) = 3
255255
// 2-1 =
256256
// data.barStack[] // 0: 1.0 snapshot 1: 2.0 snapshot 2: 3.0 snapshot
257257
// data.barStack[{123123},{123123},12312,12312]
258258
// && data.barStack[parseInt(snapshot, 10) - 1]
259259
if (snapshot !== 'All Snapshots') {
260-
console.log(data.barStack, '<---------data.barstack', snapshot, '<-----snapshot');
260+
// console.log(data.barStack, '<---------data.barstack', snapshot, '<-----snapshot');
261261
// const checkData = [];
262262
// for (let i = 0; i < data.barStack.length; i++) {
263263
// if (data.barStack[i].snapshotId === snapshot) {
@@ -275,7 +275,7 @@ const PerformanceVisx = (props: BarStackProps) => {
275275
// });
276276
const checkData = [data.barStack.find(comp => comp.snapshotId === snapshot)];
277277
// checkData = checkData.filter(element => { return element !== undefined; })
278-
console.log(checkData, '<-- checkData');
278+
// console.log(checkData, '<-- checkData');
279279
if (checkData) data.barStack = checkData;
280280
}
281281
// data.barStack = [

0 commit comments

Comments
 (0)