Skip to content

Commit 30cfc59

Browse files
authored
fix: error when hover emissions chart (#1230)
1 parent 75a74be commit 30cfc59

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

webapp/src/components/emissions-time-series.tsx

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,12 @@ const chartConfig = {
4141
},
4242
} satisfies ChartConfig;
4343

44+
type TimeSeriesTooltipPayload = Array<{
45+
payload: {
46+
ts: number;
47+
};
48+
}>;
49+
4450
export default function EmissionsTimeSeriesChart({
4551
isPublicView,
4652
runId,
@@ -233,12 +239,22 @@ export default function EmissionsTimeSeriesChart({
233239
content={
234240
<ChartTooltipContent
235241
className="w-[180px]"
236-
labelFormatter={(value) =>
237-
format(
238-
new Date(value as number),
242+
labelFormatter={(_, payload) => {
243+
const tooltipPayload = payload as
244+
| TimeSeriesTooltipPayload
245+
| undefined;
246+
const point =
247+
tooltipPayload?.[0]?.payload;
248+
249+
if (!point) {
250+
return "";
251+
}
252+
253+
return format(
254+
new Date(point.ts),
239255
"MMM d, yyyy HH:mm:ss",
240-
)
241-
}
256+
);
257+
}}
242258
/>
243259
}
244260
/>

0 commit comments

Comments
 (0)