import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend, } from 'recharts' const levelLabels = { 1: { label: 'Débutant', color: '#9ca3af' }, 2: { label: 'Intermédiaire', color: '#60a5fa' }, 3: { label: 'Avancé', color: '#fbbf24' }, 4: { label: 'Expert', color: '#34d399' }, } export default function BarChartView({ categories, skills: allSkills, members, levels, filterCat, onBarClick, }) { const cats = filterCat === 'all' ? categories : categories.filter((c) => c.id === filterCat) const data = cats.map((cat) => { const catSkills = allSkills.filter((s) => s.category_id === cat.id) const buckets = { 1: 0, 2: 0, 3: 0, 4: 0 } members.forEach((m) => { catSkills.forEach((s) => { const key = `${m.id}-${s.id}` const lvl = levels[key]?.level if (lvl) buckets[lvl]++ }) }) return { name: cat.name, color: cat.color, id: cat.id, ...buckets, } }) if (data.length === 0) { return
Aucune donnée à afficher
} function handleClick(entry, _index, level) { if (onBarClick && entry?.id) { onBarClick(entry.id, level) } } return (
({ value: `${l} - ${levelLabels[l].label}`, type: 'rect', color: levelLabels[l].color, }))} /> {[1, 2, 3, 4].map((lvl) => ( handleClick(entry, null, lvl)} /> ))}
) }