import { Cell, Pie, PieChart } from 'recharts' import { PanelCard } from '@/components/panel-card' import { Badge } from '@/components/reui/badge' import { ChartContainer, type ChartConfig, } from '@evobgp/ui/components/chart' import type { BreakdownSlice } from '@/lib/metrics' /** chart-27 / chart-13 inspired donut in PanelCard (Frame surface). */ export function DonutBreakdownCard({ title, description, slices, centerLabel, badge, }: { title: string description?: string slices: BreakdownSlice[] centerLabel: string badge?: string }) { const total = slices.reduce((sum, s) => sum + s.count, 0) 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, share: slice.count })) return ( {badge} ) : undefined } >
{total === 0 ? (

Нет данных

) : ( <>
{data.map((entry) => ( ))}
{centerLabel} {total}
    {slices.map((slice) => { const pct = total > 0 ? ((slice.count / total) * 100).toFixed(1) : '0' return (
  • {slice.label} {slice.count} ({pct}%)
  • ) })}
)}
) }