Components
DonutChart
SVG donut chart implemented in pure React without dependencies
Overview
DonutChart is a pure SVG-based donut chart. It renders using arc-path calculations without any external chart libraries.
- No dependency — No need for D3, Chart.js, or other external libraries
- Interactive — Supports segment click events
- Customizable — Size, inner ratio, start angle, and colors are all customizable
- Accessible —
role="img"andaria-labelapplied by default
Basic Usage
Interaction
Customization
Props
| Prop | Type | Default | Required | Description |
|---|---|---|---|---|
segments | DonutChartSegment[] | - | Yes | Slices with value, fill and optional id, stroke, ariaLabel |
size | number | '180' | No | Width and height in px |
innerRatio | number | '0.55' | No | Hole size as a share of the radius (0 to 1) |
startAngle | number | '0' | No | Angle where the first slice starts, in degrees |
defaultStrokeWidth | number | '0.75' | No | Stroke width for slices without their own |
emptyFill | string | 'var(--background-default-tertiary)' | No | Fill when there is no data |
emptyStroke | string | 'var(--border-default-default)' | No | Stroke when there is no data |
onSegmentClick | (segment: DonutChartSegment, index: number) => void | - | No | Called when a slice is clicked |
segmentKey | (segment: DonutChartSegment, index: number) => string | - | No | React key for each slice |
DonutChartSegment
export type DonutChartSegment = {
id?: string
value: number
fill: string
stroke?: string
strokeWidth?: number
ariaLabel?: string
}Specification
base
| 상태 | 요소 | 속성 | 값 |
|---|---|---|---|
| enabled | empty | fill | $color.background.default.tertiary |
| enabled | empty | stroke | $color.border.default.default |
| enabled | segment | strokeWidth | 0.75토큰 아님 — defaultStrokeWidth prop default |
Guidelines
- When all segment values are 0, an empty gray ring is displayed
- For data visualization, consider using TimeDistribution instead of DonutChart alone