import { Cell, Label, Pie, PieChart } from 'recharts' import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig, } from '@evobgp/ui/components/chart' import { cn } from '@evobgp/ui/lib/utils' import type { BreakdownSlice } from '@/lib/metrics' export function ChartDonutMetric({ slices, centerLabel, centerValue, className, }: { slices: BreakdownSlice[] centerLabel: string centerValue: string | number className?: string }) { const chartConfig = slices.reduce((acc, slice) => { acc[slice.key] = { label: slice.label, color: slice.color } return acc }, {}) const data = slices.map((slice) => ({ ...slice, fill: slice.color, })) const total = slices.reduce((sum, slice) => sum + slice.count, 0) if (total === 0) { return (
Нет данных
) } return (
} /> {data.map((entry) => ( ))}
) }