'use client'; import { Radar, RadarChart, PolarGrid, PolarAngleAxis, PolarRadiusAxis, ResponsiveContainer, Tooltip, } from 'recharts'; import { Badge } from '@/components/ui/badge'; import type { NeighborhoodCategory } from './types'; interface NeighborhoodRadarChartProps { categories: NeighborhoodCategory[]; height?: number; showBadges?: boolean; className?: string; } function getScoreVariant(score: number): 'success' | 'warning' | 'destructive' { if (score > 7) return 'success'; if (score >= 5) return 'warning'; return 'destructive'; } function getScoreLabel(score: number): string { if (score > 7) return 'Tốt'; if (score >= 5) return 'TB'; return 'Yếu'; } export function NeighborhoodRadarChart({ categories, height = 300, showBadges = true, className, }: NeighborhoodRadarChartProps) { const chartData = categories.map((cat) => ({ subject: cat.label, score: cat.score, fullMark: 10, })); return (
[`${Number(value).toFixed(1)}/10`, 'Điểm']} /> {showBadges && (
{categories.map((cat) => ( {cat.label}: {cat.score.toFixed(1)} ({getScoreLabel(cat.score)}) ))}
)}
); }