# Ring chart

Concentric progress rings with a hover glow and a counting center value.

Section: Charts / Radial
Page: https://ui.heyramzi.com/components/ring-chart
Import path: `@heyramzi/ui/charts`

## Import

```ts
import { RingChart } from "@heyramzi/ui/charts";
```

## Usage

```svelte
<RingChart
  data={[{ label: "Move", value: 520, maxValue: 600, color: "var(--chart-4)" }]}
  size={240}
  defaultLabel="Today"
/>
```

## Demo

```svelte
<script lang="ts">
	import { RingChart } from "@heyramzi/ui/charts";

	const data = [
		{ label: "Move", value: 520, maxValue: 600, color: "var(--chart-4)" },
		{ label: "Exercise", value: 24, maxValue: 30, color: "var(--chart-2)" },
		{ label: "Stand", value: 9, maxValue: 12, color: "var(--chart-1)" },
	];
</script>

<div class="flex flex-wrap items-center justify-center gap-10">
	<RingChart {data} size={240} defaultLabel="Today" />
	<RingChart
		data={[{ label: "Training", value: 74, maxValue: 100, color: "var(--chart-4)" }]}
		size={104}
		showGlow={false}
		ariaLabel="12 days to race"
	>
		<span class="text-2xl leading-none font-bold tabular-nums">12</span>
		<span class="text-muted-foreground mt-1 text-[10px] font-medium uppercase">days to race</span>
	</RingChart>
</div>
```

## API

| Prop | Type | Default | Notes |
| --- | --- | --- | --- |
| `data` | `RingData[]` |  | required |
| `size` | `number` |  | Fixed square size in px. Omit to fill the parent (responsive). |
| `strokeWidth` | `number` | `11` | Ring thickness in viewBox units. |
| `ringGap` | `number` | `6` | Gap between concentric rings in viewBox units. |
| `baseInnerRadius` | `number` | `48` | Inner radius of the innermost ring in viewBox units. |
| `lineCap` | `"round" \| "butt"` | `"round"` |  |
| `defaultLabel` | `string` | `"Total"` | Center label when nothing is hovered. |
| `formatValue` | `(v: number) => string` | `(v) => v.toLocaleString()` |  |
| `animate` | `boolean` | `true` | Animate arcs on mount. |
| `showGlow` | `boolean` | `true` | Glow the hovered ring. |
| `hoveredIndex` | `number \| null` | `null` | bindable. Hovered ring index, bindable for legend hover-sync. |
| `onHoveredIndexChange` | `(index: number \| null) => void` |  |  |
| `minWidth` | `number` | `170` |  |
| `ariaLabel` | `string` |  |  |
| `children` | `Snippet` |  | Replaces the center readout, for a number that isn't the ring's own value. |
| `class` | `string` |  |  |
