2026-07-11 03:12:56 +03:30
|
|
|
'use client';
|
|
|
|
|
|
2026-07-11 22:32:37 +03:30
|
|
|
import {
|
|
|
|
|
PolarAngleAxis,
|
|
|
|
|
RadialBar,
|
|
|
|
|
RadialBarChart,
|
|
|
|
|
ResponsiveContainer,
|
|
|
|
|
} from 'recharts';
|
2026-07-11 03:12:56 +03:30
|
|
|
|
|
|
|
|
import { TODAY_CHART_PRIMARY_COLOR } from '@/components/today/chart-theme';
|
|
|
|
|
|
|
|
|
|
interface TodayRadialGaugeChartProps {
|
|
|
|
|
percent: number;
|
|
|
|
|
completed: number;
|
|
|
|
|
total: number;
|
|
|
|
|
percentLabel: string;
|
|
|
|
|
tasksLabel: string;
|
2026-07-11 22:32:37 +03:30
|
|
|
size?: 'sm' | 'md';
|
|
|
|
|
fillColor?: string;
|
|
|
|
|
showRatio?: boolean;
|
2026-07-11 03:12:56 +03:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function TodayRadialGaugeChart({
|
|
|
|
|
percent,
|
|
|
|
|
completed,
|
|
|
|
|
total,
|
|
|
|
|
percentLabel,
|
|
|
|
|
tasksLabel,
|
2026-07-11 22:32:37 +03:30
|
|
|
size = 'md',
|
|
|
|
|
fillColor = TODAY_CHART_PRIMARY_COLOR,
|
|
|
|
|
showRatio = true,
|
2026-07-11 03:12:56 +03:30
|
|
|
}: TodayRadialGaugeChartProps) {
|
2026-07-11 22:32:37 +03:30
|
|
|
const isCompact = size === 'sm';
|
2026-07-11 03:12:56 +03:30
|
|
|
const clamped = Math.max(0, Math.min(100, percent));
|
2026-07-11 22:32:37 +03:30
|
|
|
const data = [{ name: 'progress', value: clamped, fill: fillColor }];
|
2026-07-11 03:12:56 +03:30
|
|
|
|
|
|
|
|
return (
|
2026-07-11 22:32:37 +03:30
|
|
|
<div className={`relative w-full ${isCompact ? 'h-[108px]' : 'h-full min-h-0 flex-1'}`}>
|
2026-07-11 03:12:56 +03:30
|
|
|
<ResponsiveContainer width="100%" height="100%">
|
|
|
|
|
<RadialBarChart
|
|
|
|
|
cx="50%"
|
|
|
|
|
cy="50%"
|
2026-07-11 22:32:37 +03:30
|
|
|
innerRadius={isCompact ? '62%' : '68%'}
|
2026-07-11 03:12:56 +03:30
|
|
|
outerRadius="100%"
|
2026-07-11 22:32:37 +03:30
|
|
|
barSize={isCompact ? 9 : 14}
|
2026-07-11 03:12:56 +03:30
|
|
|
data={data}
|
|
|
|
|
startAngle={90}
|
|
|
|
|
endAngle={-270}
|
|
|
|
|
>
|
2026-07-11 22:32:37 +03:30
|
|
|
<PolarAngleAxis type="number" domain={[0, 100]} tick={false} />
|
2026-07-11 03:12:56 +03:30
|
|
|
<RadialBar
|
|
|
|
|
background={{ fill: 'rgba(41, 69, 106, 0.55)' }}
|
|
|
|
|
dataKey="value"
|
2026-07-11 22:32:37 +03:30
|
|
|
cornerRadius={isCompact ? 6 : 8}
|
2026-07-11 03:12:56 +03:30
|
|
|
/>
|
|
|
|
|
</RadialBarChart>
|
|
|
|
|
</ResponsiveContainer>
|
2026-07-11 22:32:37 +03:30
|
|
|
<div className="pointer-events-none absolute inset-0 flex flex-col items-center justify-center text-center px-1">
|
|
|
|
|
<span
|
|
|
|
|
className={`font-semibold text-text-primary ${isCompact ? 'text-base leading-tight' : 'text-3xl'}`}
|
|
|
|
|
>
|
|
|
|
|
{percentLabel}
|
|
|
|
|
</span>
|
|
|
|
|
<span className={`text-text-muted ${isCompact ? 'mt-0.5 text-[10px]' : 'mt-1 text-xs'}`}>
|
|
|
|
|
{tasksLabel}
|
|
|
|
|
</span>
|
|
|
|
|
{showRatio && total > 0 ? (
|
|
|
|
|
<span
|
|
|
|
|
className={`text-text-secondary ${isCompact ? 'mt-0.5 text-[10px]' : 'mt-0.5 text-[11px]'}`}
|
|
|
|
|
>
|
2026-07-11 03:12:56 +03:30
|
|
|
{completed}/{total}
|
|
|
|
|
</span>
|
|
|
|
|
) : null}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|