# Radial Chart

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

Source: https://www.honestui.com/docs/charts/radial-chart/static

### Basic Chart

```tsx
"use client";

import { RadialChart, type ChartConfig } from "honestui/charts";

// Scenario: Visitors by browser this month
const data = [
  { browser: "chrome", visitors: 4280 },
  { browser: "safari", visitors: 2960 },
  { browser: "firefox", visitors: 1540 },
  { browser: "edge", visitors: 980 },
];

const chartConfig = {
  visitors: { label: "Visitors" },
  chrome: { label: "Chrome", colors: { light: ["#3b82f6"], dark: ["#60a5fa"] } },
  safari: { label: "Safari", colors: { light: ["#10b981"], dark: ["#34d399"] } },
  firefox: { label: "Firefox", colors: { light: ["#f59e0b"], dark: ["#fbbf24"] } },
  edge: { label: "Edge", colors: { light: ["#8b5cf6"], dark: ["#a78bfa"] } },
} satisfies ChartConfig;

export function ExampleRadialChart() {
  return (
    <RadialChart
      className="h-full w-full p-4"
      data={data}
      dataKey="visitors"
      nameKey="browser"
      config={chartConfig}
      innerRadius="38%"
    >
      <RadialChart.Bar isClickable />
      <RadialChart.Center label="Visitors" />
      <RadialChart.Legend isClickable />
      <RadialChart.Tooltip />
    </RadialChart>
  );
}

```

## Overview [#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](/docs/charts/gauge-chart/static) for a single value with ranges.

## Anatomy [#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 [#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 [#installation]

<CommandBlock commands="[&#x22;honestui&#x22;]" />

## Usage [#usage]

```tsx
import { RadialChart, type ChartConfig } from "honestui/charts";
```

```tsx
<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 [#examples]

### Progress rings [#progress-rings]

### max={100}

```tsx
"use client";

import { RadialChart, type ChartConfig } from "honestui/charts";

// Scenario: Daily activity goals, as a percent of each target
const data = [
  { goal: "move", percent: 82 },
  { goal: "exercise", percent: 64 },
  { goal: "stand", percent: 100 },
];

const chartConfig = {
  percent: { label: "Progress" },
  move: { label: "Move", colors: { light: ["#f43f5e"], dark: ["#fb7185"] } },
  exercise: { label: "Exercise", colors: { light: ["#84cc16"], dark: ["#a3e635"] } },
  stand: { label: "Stand", colors: { light: ["#06b6d4"], dark: ["#22d3ee"] } },
} satisfies ChartConfig;

export function ExampleRadialChart() {
  return (
    <RadialChart
      className="h-full w-full p-4"
      data={data}
      dataKey="percent"
      nameKey="goal"
      config={chartConfig}
      max={100} // [!code highlight]
      innerRadius="45%"
    >
      <RadialChart.Bar />
      <RadialChart.Center value="1 of 3" label="Rings closed" valueFormatter={(value) => `${value}%`} />
      <RadialChart.Tooltip valueFormatter={(value) => `${value}%`} />
    </RadialChart>
  );
}

```

> 
  
    Set `max` to the goal so each ring shows progress toward it. The `Center` shows its own `value` at rest and the hovered ring's value on hover.
  


### Stacked half circle [#stacked-half-circle]

### startAngle={180} endAngle={0} stackId

```tsx
"use client";

import { RadialChart, type ChartConfig } from "honestui/charts";

// Scenario: Storage used, split by kind of file
const data = [{ plan: "storage", photos: 128, documents: 46, backups: 72 }];

const chartConfig = {
  photos: { label: "Photos", colors: { light: ["#3b82f6"], dark: ["#60a5fa"] } },
  documents: { label: "Documents", colors: { light: ["#10b981"], dark: ["#34d399"] } },
  backups: { label: "Backups", colors: { light: ["#f59e0b"], dark: ["#fbbf24"] } },
} satisfies ChartConfig;

export function ExampleRadialChart() {
  return (
    <RadialChart
      className="h-full w-full p-4"
      data={data}
      nameKey="plan"
      config={chartConfig}
      max={512}
      startAngle={180} // [!code highlight]
      endAngle={0} // [!code highlight]
      innerRadius="78%"
    >
      <RadialChart.Bar dataKey="photos" stackId="used" cornerRadius={6} />
      <RadialChart.Bar dataKey="documents" stackId="used" cornerRadius={6} />
      <RadialChart.Bar dataKey="backups" stackId="used" cornerRadius={6} />
      <RadialChart.Center label="GB of 512 used" />
      <RadialChart.Legend isClickable />
      <RadialChart.Tooltip valueFormatter={(value) => `${value} GB`} />
    </RadialChart>
  );
}

```

> 
  
    Give several `Bar` parts one `stackId` to split a single ring. Segments are parted by a background-colored edge.
  


### Ring labels [#ring-labels]

<ComponentPreview className="mb-0" title="<Label />" name="ex-labels-echarts-radial-chart" />

> 
  
    `Label` writes each ring's name just before its start. Pair it with a partial sweep, such as `endAngle={-180}`, so the names have an open quarter to sit in.
  


## API reference [#api-reference]

<ApiHeading>
  RadialChart
</ApiHeading>


  ### `data`

type: `TData[]`

One row per ring.

  ### `nameKey`

type: `keyof TData & string`

The row field that names each ring.

  ### `config`

type: `ChartConfig`

Labels and colors for rows and series. See 

    [Chart Config](/docs/charts/chart-config)

    .

  ### `dataKey`

type: `keyof TData & string`

The default value field for 

    `Bar`

     parts without their own.

  ### `max`

type: `number`

The value that closes the sweep. Defaults to the largest (stacked) value.

  ### `innerRadius`

type: `number | string` · default: `&#x22;30%&#x22;`

Hole size, in pixels or a percentage of the outer radius.

  ### `outerRadius`

type: `number | string` · default: `&#x22;100%&#x22;`

Outer size, in pixels or a percentage of the fitted radius.

  ### `startAngle`

type: `number` · default: `90`

Where rings start, in degrees.

  ### `endAngle`

type: `number` · default: `-270`

Where a full ring ends, in degrees.

  ### `selectedKey`

type: `string | null`

Controlled selection: a row name with one series, a series key with several.

  ### `defaultSelectedKey`

type: `string | null` · default: `null`

Selection on first render.

  ### `onSelectionChange`



void">
    Fires when a ring or legend entry is selected or cleared.

  ### `isLoading`

type: `boolean` · default: `false`

Shows the loading skeleton.

  ### `animation`

type: `boolean` · default: `true`

Plays the entrance. Reduced motion turns it off.

  ### `ariaLabel`

type: `string`

Accessible name for the plot.

  ### `chartOptions`



">
    Escape hatch merged over the ECharts option.


<ApiHeading>
  Bar
</ApiHeading>


  ### `dataKey`

type: `string`

The value field. Defaults to the root 

    `dataKey`

    .

  ### `track`

type: `boolean` · default: `true`

Draws a muted ring behind the value.

  ### `cornerRadius`

type: `number` · default: `999`

End rounding in pixels; large values give round caps.

  ### `stackId`

type: `string`

Stacks bars that share it into one ring.

  ### `barSize`

type: `number`

Ring thickness in pixels. Defaults to the space available.

  ### `isClickable`

type: `boolean` · default: `false`

Lets rings be selected.


<ApiHeading>
  Center
</ApiHeading>


  ### `value`

type: `ReactNode`

The resting value. Defaults to the total, or the only value.

  ### `label`

type: `ReactNode`

The resting caption. Defaults to the row or series label, or "Total".

  ### `valueFormatter`



string">
    Formats computed and hovered values.

  ### `followHover`

type: `boolean` · default: `true`

Shows the hovered or selected ring's value.

  ### `className`

type: `string`

Classes for the readout.


<ApiHeading>
  Label
</ApiHeading>


  ### `dataKey`

type: `string`

Field for the label text. Defaults to the row's 

    `config`

     label.

  ### `formatter`



string">
    Formats the label text.


<ApiHeading>
  Tooltip
</ApiHeading>


  ### `variant`

type: `&#x22;default&#x22; | &#x22;frosted-glass&#x22;` · default: `&#x22;default&#x22;`

Tooltip surface.

  ### `roundness`

type: `&#x22;sm&#x22; | &#x22;md&#x22; | &#x22;lg&#x22; | &#x22;xl&#x22;` · default: `&#x22;lg&#x22;`

Tooltip corner radius.

  ### `position`

type: `&#x22;fixed&#x22; | &#x22;variable&#x22;` · default: `&#x22;variable&#x22;`

Follow the pointer, or pin near the top.

  ### `valueFormatter`



string">
    Formats values in the tooltip.


<ApiHeading>
  Legend
</ApiHeading>


  ### `variant`

type: `LegendVariant` · default: `&#x22;rounded-square&#x22;`

Indicator style.

  ### `align`

type: `&#x22;left&#x22; | &#x22;center&#x22; | &#x22;right&#x22;` · default: `&#x22;center&#x22;`

Horizontal placement.

  ### `verticalAlign`

type: `&#x22;top&#x22; | &#x22;bottom&#x22;` · default: `&#x22;bottom&#x22;`

Vertical placement.

  ### `isClickable`

type: `boolean` · default: `false`

Lets entries select a ring or series.
