fix: improve chart tooltips
This commit is contained in:
@@ -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) => (
|
||||
|
||||
Reference in New Issue
Block a user