interface DistributionChartProps { distribution: { high: number; medium_high: number; medium: number; medium_low: number; low: number; }; } const LEVELS = [ { key: 'high', label: '高风险 (86-100%)', color: 'bg-danger' }, { key: 'medium_high', label: '中高风险 (71-85%)', color: 'bg-[#FB923C]' }, { key: 'medium', label: '中风险 (51-70%)', color: 'bg-warning' }, { key: 'medium_low', label: '中低风险 (31-50%)', color: 'bg-[#7DD3FC]' }, { key: 'low', label: '低风险 (0-30%)', color: 'bg-success' }, ]; export function DistributionChart({ distribution }: DistributionChartProps) { const total = Object.values(distribution).reduce((sum, val) => sum + val, 0); return (
风险等级分布
{LEVELS.map((level) => { const value = distribution[level.key as keyof typeof distribution]; const percentage = total > 0 ? (value / total) * 100 : 0; return (
{level.label} {value} ({percentage.toFixed(1)}%)
); })}
); }