'use client'; import { ResponsiveContainer, LineChart, Line, XAxis, YAxis, Tooltip, CartesianGrid } from 'recharts'; import type { Locale } from '@/lib/locale'; interface DailyData { date: string; amount: number; count: number; } interface DailyChartProps { data: DailyData[]; dark?: boolean; locale?: Locale; } function formatDate(dateStr: string) { const [, m, d] = dateStr.split('-'); return `${m}/${d}`; } function formatAmount(value: number) { if (value >= 10000) return `¥${(value / 10000).toFixed(1)}w`; if (value >= 1000) return `¥${(value / 1000).toFixed(1)}k`; return `¥${value}`; } interface TooltipPayload { value: number; dataKey: string; } function CustomTooltip({ active, payload, label, dark, currency, amountLabel, countLabel, }: { active?: boolean; payload?: TooltipPayload[]; label?: string; dark?: boolean; currency: string; amountLabel: string; countLabel: string; }) { if (!active || !payload?.length) return null; return (
{label}
{payload.map((p) => ({p.dataKey === 'amount' ? amountLabel : countLabel}:{' '} {p.dataKey === 'amount' ? `${currency}${p.value.toLocaleString()}` : p.value}
))}{emptyText}