import { Bar, BarChart, CartesianGrid, Legend, Line, LineChart, ResponsiveContainer, Tooltip, XAxis, YAxis, } from 'recharts'; import { SurfaceCard } from '../../../components/ui/surface'; import type { DailyMileageReport } from '../api'; import { fmtDate, fmtKm } from './utils'; interface ReportChartsProps { report: DailyMileageReport; trendTargetId: number | null; onTrendTargetChange: (targetId: number | null) => void; } export default function ReportCharts({ report, trendTargetId, onTrendTargetChange, }: ReportChartsProps) { const comparisonData = report.groups.map(group => ({ name: group.displayName, 运营里程: group.operatingMileage, 库存里程: group.inventoryMileage, })); const trendGroup = trendTargetId == null ? null : report.groups.find(group => group.targetId === trendTargetId) || null; const trendData = trendGroup?.trend || report.trend; const trendName = trendGroup?.displayName || '总计'; const trendSubtitle = '选择总计或车型查看近 7 日每日里程,包含库存车辆里程'; const trendColor = trendGroup ? '#0f766e' : '#2563eb'; return (
{report.groups.map(group => ( ))}
)} >
fmtDate(String(label))} formatter={value => [`${fmtKm(Number(value))} km`, trendName]} contentStyle={{ borderRadius: 8, border: '1px solid #e2e8f0', fontSize: 11 }} />
车型里程构成 统计日期 {fmtDate(report.reportDate)} )} subtitle="运营与库存里程分开展示" >
[`${fmtKm(Number(value))} km`, String(name)]} contentStyle={{ borderRadius: 8, border: '1px solid #e2e8f0', fontSize: 11 }} />
); }