import { memo } from 'react'; import { LineChart, Line, BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, } from 'recharts'; import { ErrorBanner } from '@/components/ErrorBanner'; import { CalendarHeatmap } from '@/components/CalendarHeatmap'; import type { TopDiagnosis } from './types'; function formatDateLabel(dateStr: string): string { const d = new Date(dateStr); return `${d.getMonth() + 1}/${d.getDate()}`; } interface CaseStatsTabProps { loading: boolean; loaded: boolean; error: string | null; currentDate: string; topDiagnoses: TopDiagnosis[]; caseTrend: Array<{ date: string; cases: number; aqi: number }>; heatmapData: Array<{ date: string; value: number }>; heatmapYear: number | null; onRetry: () => void; onDismissError: () => void; } // 病例统计 tab —— 诊断分布 / 病例与AQI趋势 / 日历热力图。纯展示,数据由父级按需加载。 export const CaseStatsTab = memo(function CaseStatsTab({ loading, loaded, error, currentDate, topDiagnoses, caseTrend, heatmapData, heatmapYear, onRetry, onDismissError, }: CaseStatsTabProps) { if (loading && !loaded) { return (
); } return (
{error && ( )} {/* Top 5 诊断分布 */}

Top 5 诊断分布

{topDiagnoses.length > 0 ? ( [value.toLocaleString(), '病例数']} /> ) : (
暂无数据
)}
{/* 近30日病例与AQI趋势 (driven off Monitoring timeline currentDate) */}

病例与AQI趋势

截至 {currentDate} 的近30日窗口

{caseTrend.length > 0 ? ( ) : (
暂无数据
)}
{/* 日历热力图 (year derived from data) */}

{heatmapYear ? `${heatmapYear}年 ` : ''}每日病例日历

{heatmapYear && heatmapData.length > 0 ? ( ) : (
暂无数据
)}
); });