'use client'; import { Chart as ChartJS, ArcElement, Tooltip, Legend } from 'chart.js'; import { Doughnut } from 'react-chartjs-2'; // Chart.js Module registrieren (wichtig in v3/v4) ChartJS.register(ArcElement, Tooltip, Legend); interface CategoryChartProps { times: Record; } export default function CategoryChart({ times }: CategoryChartProps) { const labels = Object.keys(times); const dataValues = Object.values(times); const data = { labels, datasets: [ { label: 'Dauer (in Minuten)', data: dataValues, backgroundColor: [ '#3b82f6', // Blau '#10b981', // GrĂ¼n '#f59e0b', // Orange '#ef4444', // Rot '#8b5cf6', // Violett '#ec4899', // Pink '#64748b', // Grau ], borderColor: '#ffffff', borderWidth: 2, }, ], }; const options = { responsive: true, plugins: { legend: { position: 'bottom' as const, }, tooltip: { callbacks: { label: (context: any) => { const minutes = context.raw || 0; const hours = Math.floor(minutes / 60); const remainingMins = Math.round(minutes % 60); return ` ${context.label}: ${hours} Std. ${remainingMins} Min. (${minutes} Min.)`; }, }, }, }, }; return (
); }