fix: improve chart tooltips

This commit is contained in:
zv
2026-06-14 21:00:05 +02:00
parent bdba3c709c
commit 169d5e5e59
3 changed files with 79 additions and 24 deletions

View File

@@ -2,6 +2,7 @@
import { Bar, BarChart, Cell, ResponsiveContainer, Tooltip, XAxis, YAxis } from "recharts";
import type { SynopStation } from "@/types/imgw";
import { ChartTooltip } from "@/components/charts/chart-tooltip";
import { Card } from "@/components/ui/card";
import { useI18n } from "@/lib/i18n";
import { useWeatherStore } from "@/lib/store";
@@ -56,7 +57,14 @@ export function SnapshotChart({ station }: { station: SynopStation }) {
/>
<Tooltip
cursor={{ fill: "hsl(var(--border) / 0.22)" }}
formatter={(_, __, item) => [`${item.payload.value} ${item.payload.unit}`, item.payload.name]}
content={
<ChartTooltip
valueFormatter={(entry) => {
const row = entry.payload;
return `${row?.value ?? "—"} ${row?.unit ?? ""}`.trim();
}}
/>
}
/>
<Bar dataKey="normalized" radius={[0, 8, 8, 0]} barSize={14}>
{rows.map((row) => (