2026-01-04 17:08:28 +07:00
|
|
|
'use client'
|
|
|
|
|
|
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';
|
|
|
|
|
|
2026-01-07 13:03:50 +07:00
|
|
|
export const PieChartComponent = ({ data, show }: {
|
2025-12-11 18:28:35 +07:00
|
|
|
data: {
|
|
|
|
|
name: string,
|
|
|
|
|
value: number,
|
|
|
|
|
color: string
|
2026-01-07 13:03:50 +07:00
|
|
|
}[],
|
|
|
|
|
show: number | string
|
2025-12-11 18:28:35 +07:00
|
|
|
}) => {
|
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>
|
2025-12-16 10:17:26 +07:00
|
|
|
<text x={100} y={75} className="pie-char-text">
|
2026-01-07 13:03:50 +07:00
|
|
|
{show}
|
2025-12-11 18:28:35 +07:00
|
|
|
</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>
|
2025-12-16 10:17:26 +07:00
|
|
|
<text x={100} y={125} className="pie-char-text">
|
2025-12-11 18:28:35 +07:00
|
|
|
0
|
|
|
|
|
</text>
|
|
|
|
|
<Pie
|
|
|
|
|
data={data}
|
|
|
|
|
cx="50%"
|
|
|
|
|
cy="50%"
|
2026-01-05 16:15:07 +07:00
|
|
|
innerRadius={65}
|
2026-01-05 15:07:10 +07:00
|
|
|
outerRadius={100}
|
2025-12-11 18:28:35 +07:00
|
|
|
paddingAngle={0}
|
|
|
|
|
dataKey="value"
|
2026-01-05 15:07:10 +07:00
|
|
|
stroke="none"
|
2025-12-11 18:28:35 +07:00
|
|
|
>
|
|
|
|
|
{data.map((entry, index) => (
|
2026-01-05 15:07:10 +07:00
|
|
|
<Cell key={`cell-${index}`} fill={entry.color} stroke="none" />
|
2025-12-11 18:28:35 +07:00
|
|
|
))}
|
|
|
|
|
</Pie>
|
|
|
|
|
</PieChart>
|
|
|
|
|
</ResponsiveContainer>
|
2026-01-07 19:38:21 +07:00
|
|
|
<div className="flex gap-6 mt-4">
|
2025-12-11 18:28:35 +07:00
|
|
|
{data.map((entry, index) => (
|
2026-01-05 15:07:10 +07:00
|
|
|
<div key={`cell-${index}`} className="">
|
2025-12-11 18:28:35 +07:00
|
|
|
<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>
|
|
|
|
|
)
|
|
|
|
|
};
|