Skip to content

Commit 878cbcc

Browse files
Use opacity instead of rendering and unrendering the tooltip.
1 parent 10ca52f commit 878cbcc

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

frontend/src/component/insights/components/LineChart/ChartTooltip/ChartTooltip.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { useEffect, useState, type FC, type VFC } from 'react';
66
import { objectId } from 'utils/objectId';
77

88
export type TooltipState = {
9+
opacity: number;
910
caretX: number;
1011
caretY: number;
1112
title: string;
@@ -85,6 +86,7 @@ export const ChartTooltipContainer: FC<IChartTooltipProps> = ({
8586
return (
8687
<Box
8788
sx={(theme) => ({
89+
opacity: tooltip?.opacity ?? 0,
8890
top: 0,
8991
left: 0,
9092
transform: `translate(${left}px, ${top}px)`,

frontend/src/component/insights/components/LineChart/createTooltip.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,9 @@ export const createTooltip =
88
tooltip: TooltipModel<any>;
99
}) => {
1010
const tooltip = context.tooltip;
11-
if (tooltip.opacity === 0) {
12-
setTooltip(null);
13-
return;
14-
}
1511

1612
setTooltip({
13+
opacity: tooltip?.opacity,
1714
caretX: tooltip?.caretX,
1815
caretY: tooltip?.caretY,
1916
title: tooltip?.title?.join(' ') || '',

0 commit comments

Comments
 (0)