2025-12-12 11:00:23 +07:00
|
|
|
import { useTranslations } from 'next-intl';
|
2025-12-11 18:28:35 +07:00
|
|
|
import { PieChart, Pie, Cell, ResponsiveContainer } from 'recharts';
|
|
|
|
|
|
|
|
|
|
export const PieChartComponent = ({ data }: {
|
|
|
|
|
data: {
|
|
|
|
|
name: string,
|
|
|
|
|
value: number,
|
|
|
|
|
color: string
|
|
|
|
|
}[]
|
|
|
|
|
}) => {
|
2025-12-12 11:00:23 +07:00
|
|
|
const t = useTranslations('Global');
|
|
|
|
|
|
2025-12-11 18:28:35 +07:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
className="flex flex-col items-center"
|
|
|
|
|
>
|
|
|
|
|
<ResponsiveContainer width={200} height={200}>
|
|
|
|
|
<PieChart>
|
|
|
|
|
<text x={100} y={80} className="pie-char-text">
|
|
|
|
|
0
|
|
|
|
|
</text>
|
|
|
|
|
<text x={100} y={100} className="pie-char-text">
|
2025-12-12 11:00:23 +07:00
|
|
|
{t('out-of')}
|
2025-12-11 18:28:35 +07:00
|
|
|
</text>
|
|
|
|
|
<text x={100} y={120} className="pie-char-text">
|
|
|
|
|
0
|
|
|
|
|
</text>
|
|
|
|
|
<Pie
|
|
|
|
|
data={data}
|
|
|
|
|
cx="50%"
|
|
|
|
|
cy="50%"
|
|
|
|
|
innerRadius={70}
|
|
|
|
|
outerRadius={90}
|
|
|
|
|
paddingAngle={0}
|
|
|
|
|
dataKey="value"
|
|
|
|
|
>
|
|
|
|
|
{data.map((entry, index) => (
|
|
|
|
|
<Cell key={`cell-${index}`} fill={entry.color} />
|
|
|
|
|
))}
|
|
|
|
|
</Pie>
|
|
|
|
|
</PieChart>
|
|
|
|
|
</ResponsiveContainer>
|
|
|
|
|
<div className="flex gap-6">
|
|
|
|
|
{data.map((entry, index) => (
|
|
|
|
|
<div key={`cell-${index}`} className="text-white">
|
|
|
|
|
<span className="w-2 h-2 rounded-full font-bold inline-block mr-1.5" style={{ backgroundColor: entry.color }}></span>
|
2025-12-12 11:00:23 +07:00
|
|
|
<span>{t(entry.name)}</span>
|
2025-12-11 18:28:35 +07:00
|
|
|
</div>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
};
|