Skip to documentation content

Radial Chart

Draw values as concentric rings, for progress toward a goal or a short ranked list.

Basic Chart

Overview

A radial chart draws each row as a ring whose length is its value. It works best for progress toward a known maximum, such as activity goals or storage used, and for short ranked lists where a compact, round shape suits a dashboard tile. Outer rings are longer than inner rings at the same value, so use a bar chart when readers must compare values precisely, and a Gauge Chart for a single value with ranges.

Anatomy

RadialChart owns the data, scale, ring geometry, selection, and loading state. Each row is one ring, named by nameKey; the first row is the outermost. Bar draws a series, with a muted track behind it. Add several Bar parts with one stackId to split a ring into segments. Center puts an HTML readout in the hole, Label names each ring, and Legend and Tooltip add context.

Accessibility

The plot has an accessible name listing the series and rings; pass ariaLabel to describe the finding instead. Text in Center is real text drawn over the canvas, so it stays crisp at any zoom, but it is decorative to assistive technology, so keep the same information in the accessible name or nearby text. The tooltip and ring selection are pointer-operated.

Installation

npm install honestui

Usage

import { RadialChart, type ChartConfig } from "honestui/charts";
<RadialChart data={data} dataKey="visitors" nameKey="browser" config={chartConfig}>
  <RadialChart.Bar isClickable />
  <RadialChart.Center label="Visitors" />
  <RadialChart.Legend isClickable />
  <RadialChart.Tooltip />
</RadialChart>

With one series, each ring takes the color of its row's config entry, like a pie sector. With several series, colors come from each Bar's dataKey. Set max when values are a share of a known total; without it the longest ring closes the circle. startAngle and endAngle follow ECharts: degrees, 0 at 3 o'clock, counterclockwise positive. A partial sweep is fitted to its own bounds, so a half circle fills the width it is given.

Examples

Progress rings

max={100}

Stacked half circle

startAngle={180} endAngle={0} stackId

Ring labels

<Label />

API reference

RadialChart
PropTypeDefaultDescription
data*TData[]–One row per ring.
nameKey*keyof TData & string–The row field that names each ring.
config*ChartConfig–Labels and colors for rows and series. See Chart Config.
dataKeykeyof TData & string–The default value field for Bar parts without their own.
maxnumber–The value that closes the sweep. Defaults to the largest (stacked) value.
innerRadiusnumber | string"30%"Hole size, in pixels or a percentage of the outer radius.
outerRadiusnumber | string"100%"Outer size, in pixels or a percentage of the fitted radius.
startAnglenumber90Where rings start, in degrees.
endAnglenumber-270Where a full ring ends, in degrees.
selectedKeystring | null–Controlled selection: a row name with one series, a series key with several.
defaultSelectedKeystring | nullnullSelection on first render.
onSelectionChange(key: string | null) => void–Fires when a ring or legend entry is selected or cleared.
isLoadingbooleanfalseShows the loading skeleton.
animationbooleantruePlays the entrance. Reduced motion turns it off.
ariaLabelstring–Accessible name for the plot.
chartOptionsRecord<string, unknown>–Escape hatch merged over the ECharts option.
Bar
PropTypeDefaultDescription
dataKeystring–The value field. Defaults to the root dataKey.
trackbooleantrueDraws a muted ring behind the value.
cornerRadiusnumber999End rounding in pixels; large values give round caps.
stackIdstring–Stacks bars that share it into one ring.
barSizenumber–Ring thickness in pixels. Defaults to the space available.
isClickablebooleanfalseLets rings be selected.
Center
PropTypeDefaultDescription
valueReactNode–The resting value. Defaults to the total, or the only value.
labelReactNode–The resting caption. Defaults to the row or series label, or "Total".
valueFormatter(value: number) => string–Formats computed and hovered values.
followHoverbooleantrueShows the hovered or selected ring's value.
classNamestring–Classes for the readout.
Label
PropTypeDefaultDescription
dataKeystring–Field for the label text. Defaults to the row's config label.
formatter(value: string, index: number) => string–Formats the label text.
Tooltip
PropTypeDefaultDescription
variantdefault|frosted-glass"default"Tooltip surface.
roundnesssm|md|lg|xl"lg"Tooltip corner radius.
positionfixed|variable"variable"Follow the pointer, or pin near the top.
valueFormatter(value: number) => string–Formats values in the tooltip.
Legend
PropTypeDefaultDescription
variantLegendVariant"rounded-square"Indicator style.
alignleft|center|right"center"Horizontal placement.
verticalAligntop|bottom"bottom"Vertical placement.
isClickablebooleanfalseLets entries select a ring or series.