'use client'; import { PolarAngleAxis, RadialBar, RadialBarChart, ResponsiveContainer, } from 'recharts'; import { TODAY_CHART_PRIMARY_COLOR } from '@/components/today/chart-theme'; interface TodayRadialGaugeChartProps { percent: number; completed: number; total: number; percentLabel: string; tasksLabel: string; size?: 'sm' | 'md'; fillColor?: string; showRatio?: boolean; /** Override ring hole size (e.g. "72%" leaves more room for center labels). */ innerRadius?: string | number; /** Override compact chart wrapper height class when size is "sm". */ compactClassName?: string; /** Ring thickness when size is "sm". */ compactBarSize?: number; } export function TodayRadialGaugeChart({ percent, completed, total, percentLabel, tasksLabel, size = 'md', fillColor = TODAY_CHART_PRIMARY_COLOR, showRatio = true, innerRadius, compactClassName, compactBarSize, }: TodayRadialGaugeChartProps) { const isCompact = size === 'sm'; const clamped = Math.max(0, Math.min(100, percent)); const data = [{ name: 'progress', value: clamped, fill: fillColor }]; const resolvedInnerRadius = innerRadius ?? (isCompact ? '62%' : '68%'); const resolvedBarSize = isCompact ? (compactBarSize ?? 9) : 14; const wrapperClass = isCompact ? compactClassName ?? 'h-[108px]' : 'h-full min-h-0 flex-1'; return (
{percentLabel} {tasksLabel} {showRatio && total > 0 ? ( {completed}/{total} ) : null}
); }