diff --git a/src/components/RadialChart.tsx b/src/components/RadialChart.tsx index d8afd6d..bdc4e5d 100644 --- a/src/components/RadialChart.tsx +++ b/src/components/RadialChart.tsx @@ -1,20 +1,5 @@ "use client"; -import { - Label, - PolarGrid, - PolarRadiusAxis, - RadialBar, - RadialBarChart, -} from "recharts"; -import { ChartContainer, type ChartConfig } from "@/components/ui/chart"; - -const chartConfig = { - value: { - label: "Value", - }, -} satisfies ChartConfig; - export default function RadialChart({ value, children, @@ -22,57 +7,70 @@ export default function RadialChart({ value: number; children?: React.ReactNode; }) { - const chartData = [{ value, fill: "var(--color-chart-1)" }]; + const radius = 42; + const stroke = 10; + const circumference = 2 * Math.PI * radius; + + const TRIM_ANGLE = 80; + const ARC_ANGLE = 360 - TRIM_ANGLE; + + const progress = Math.min(Math.max(value, 0), 100); + const arcLength = circumference * (ARC_ANGLE / 360); + const offset = arcLength * (1 - progress / 100); return ( - - - + + {/* background arc */} + - - - - - + + {/* progress arc */} + + + {/* center text */} + + {value.toFixed(1)}% + + + {children && ( + + {children} + + )} + + ); }