Menu

Components

Radial Bar Chart

A ring for each number: how far round it goes is how big the number is, like the activity rings of a watch.

Introduction

Radial Bar Chart draws a ring for each number, one inside the other, and how far round a ring goes is how big its number is. Use it to show progress toward goals, or to compare a few amounts in a small space.

  • It is drawn as SVG from your data, with no charting library to install, and scales to the width it is given, up to size.
  • maxValue is what a whole ring stands for, 100 for percentages or a goal for a target. Without it the biggest number fills its ring and the others are measured against it.
  • Each ring has a faint track that shows how much is left. Rings end in round caps, and get thinner to fit when there are many.
  • The chart can be a full circle, a 270° gauge, or a half circle, with startAngle and sweep. With one row it is a gauge.
  • Pointing at a ring dims the others and shows its number and name in the middle, and its share in a tooltip. The legend lists the rings with their numbers, lights one up when you point at it, and hides or shows it when you press it.
  • Colors come from the theme in light and dark, and the rings sweep round as they appear, and not for people who prefer reduced motion.
  • The SVG is hidden from screen readers, and the same data is there as a table, under the name you give with aria-label.

It is a Client Component, so functions such as valueFormatter must be defined in a client file. Each row is an object with the name of the ring under the key you give as index and its number under value. Zero and negative numbers draw no ring but the track. For amounts that matter to compare exactly, a BarChart is easier to read.

Installation

centerUI has no CLI or registry yet: components are copied into your project.

# bun
bun add tailwind-variants tailwind-merge clsx

# pnpm
pnpm add tailwind-variants tailwind-merge clsx

# npm
npm install tailwind-variants tailwind-merge clsx

Manual installation

Copy these files into your project and keep the paths, or adjust the imports. It uses the chart colors of Area Chart, the geometry of Pie Chart, and the radial-bar-chart animation from globals.css.

1. Add the shared chart parts

The chart colors --chart-1 to --chart-5 in your theme, and these files.

src/types/area-chart-styles.tsShow code
import { tv } from "tailwind-variants";

// Styles for AreaChart. The chart itself is an SVG, drawn from the numbers in
// area-chart.tsx; these are the parts around it and inside it that are plain
// HTML or take their color from the theme.
export const areaChartStyles = tv({
  slots: {
    root: "flex w-full flex-col gap-3",
    plot: "relative w-full touch-pan-y",
    svg: "block overflow-visible select-none",
    axisText: "fill-muted-fg text-xs tabular-nums",
    gridLine: "stroke-border",
    cursor: "stroke-muted-fg",
    legend: "flex flex-wrap items-center gap-x-2 gap-y-1 text-sm",
    legendItem:
      "inline-flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-fg outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring aria-[pressed=false]:text-muted-fg aria-[pressed=false]:line-through",
    swatch: "size-2.5 shrink-0 rounded-[3px] transition-opacity",
    tooltip:
      "pointer-events-none absolute z-10 min-w-36 rounded-lg border bg-card px-3 py-2 text-xs text-card-fg shadow-lg",
    tooltipTitle: "mb-1.5 font-medium",
    tooltipRow: "flex items-center gap-2",
    tooltipLabel: "text-muted-fg",
    tooltipValue: "ml-auto pl-4 font-medium tabular-nums",
    live: "pointer-events-none absolute top-0 right-3 inline-flex items-center gap-1.5 rounded-full border bg-card px-2 py-0.5 text-xs font-medium text-muted-fg",
    liveDot: "size-1.5 rounded-full bg-success motion-safe:animate-pulse",
    empty: "flex items-center justify-center text-sm text-muted-fg",
  },
  variants: {
    legendPosition: {
      top: { root: "flex-col-reverse" },
      bottom: { root: "flex-col" },
    },
  },
  defaultVariants: { legendPosition: "bottom" },
});

/** The colors a series has when it is given none, in order, then again. */
export const areaChartColors = [
  "var(--chart-1)",
  "var(--chart-2)",
  "var(--chart-3)",
  "var(--chart-4)",
  "var(--chart-5)",
] as const;
src/types/pie-chart-utils.tsShow code
// The geometry of PieChart: where a point is at an angle on a circle, and the
// path of a slice. Angles are in degrees, 0 at the top and growing clockwise.
// It knows nothing about React.

const RAD = Math.PI / 180;
const round = (n: number) => Math.round(n * 100) / 100;

/** The point at `angle` degrees on the circle of `radius` around (`cx`, `cy`). */
export function polar(cx: number, cy: number, radius: number, angle: number) {
  const a = (angle - 90) * RAD;
  return { x: cx + radius * Math.cos(a), y: cy + radius * Math.sin(a) };
}

/**
 * The path of a slice from `start` to `end` degrees, between the circles of
 * `inner` and `outer` radius. With an inner radius of 0 it is a wedge that
 * comes to the center. A slice of the whole circle is drawn as two halves,
 * because one arc cannot start and end at the same point.
 */
export function slicePath(
  cx: number,
  cy: number,
  inner: number,
  outer: number,
  start: number,
  end: number,
): string {
  if (end - start >= 359.99) {
    const half = start + 180;
    const ring = `${arc(cx, cy, outer, start, half)}${arc(cx, cy, outer, half, start + 360, false)}`;
    if (inner <= 0) return `${ring}Z`;
    return `${ring}Z${arc(cx, cy, inner, start, half, true, true)}${arc(cx, cy, inner, half, start + 360, false, true)}Z`;
  }
  const large = end - start > 180 ? 1 : 0;
  const o0 = polar(cx, cy, outer, start);
  const o1 = polar(cx, cy, outer, end);
  const outerArc = `M${round(o0.x)} ${round(o0.y)}A${round(outer)} ${round(outer)} 0 ${large} 1 ${round(o1.x)} ${round(o1.y)}`;
  if (inner <= 0) return `${outerArc}L${round(cx)} ${round(cy)}Z`;
  const i1 = polar(cx, cy, inner, end);
  const i0 = polar(cx, cy, inner, start);
  return `${outerArc}L${round(i1.x)} ${round(i1.y)}A${round(inner)} ${round(inner)} 0 ${large} 0 ${round(i0.x)} ${round(i0.y)}Z`;
}

function arc(
  cx: number,
  cy: number,
  radius: number,
  from: number,
  to: number,
  move = true,
  reverse = false,
) {
  const a = polar(cx, cy, radius, reverse ? to : from);
  const b = polar(cx, cy, radius, reverse ? from : to);
  return `${move ? `M${round(a.x)} ${round(a.y)}` : ""}A${round(radius)} ${round(radius)} 0 0 ${reverse ? 0 : 1} ${round(b.x)} ${round(b.y)}`;
}

export const toDegrees = (radians: number) => radians / RAD;

/**
 * The path of an arc of the circle of `radius` from `start` to `end` degrees,
 * for drawing with a stroke rather than a fill. An arc of the whole circle is
 * drawn as two halves, because one arc cannot start and end at the same point.
 */
export function arcPath(
  cx: number,
  cy: number,
  radius: number,
  start: number,
  end: number,
): string {
  const f = (n: number) => Math.round(n * 100) / 100;
  if (end - start >= 359.99) {
    const a = polar(cx, cy, radius, start);
    const b = polar(cx, cy, radius, start + 180);
    return `M${f(a.x)} ${f(a.y)}A${f(radius)} ${f(radius)} 0 0 1 ${f(b.x)} ${f(b.y)}A${f(radius)} ${f(radius)} 0 0 1 ${f(a.x)} ${f(a.y)}`;
  }
  const from = polar(cx, cy, radius, start);
  const to = polar(cx, cy, radius, end);
  const large = end - start > 180 ? 1 : 0;
  return `M${f(from.x)} ${f(from.y)}A${f(radius)} ${f(radius)} 0 ${large} 1 ${f(to.x)} ${f(to.y)}`;
}

2. Add the styles

src/types/radial-bar-chart-styles.tsShow code
import { tv } from "tailwind-variants";

// Styles for RadialBarChart. The chart is SVG in a fixed coordinate space that
// scales to the width it is given; these are the parts around it and the text
// inside it that take their color from the theme. They match the other charts.
export const radialBarChartStyles = tv({
  slots: {
    root: "flex w-full items-center justify-center gap-6",
    plot: "relative w-full shrink-0",
    svg: "block h-auto w-full overflow-visible select-none",
    track: "cursor-default fill-none stroke-muted",
    bar: "cursor-default fill-none transition-opacity duration-200 motion-reduce:transition-none",
    ringLabel:
      "pointer-events-none fill-fg text-[11px] font-medium [paint-order:stroke] stroke-bg stroke-[3px]",
    centerValue: "pointer-events-none fill-fg font-semibold tabular-nums",
    centerLabel: "pointer-events-none fill-muted-fg",
    legend: "flex flex-wrap gap-x-2 gap-y-1 text-sm",
    legendItem:
      "inline-flex cursor-pointer items-center gap-2 rounded-md px-2 py-1 text-fg outline-none transition-colors hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring aria-[pressed=false]:text-muted-fg aria-[pressed=false]:line-through",
    legendValue: "text-muted-fg tabular-nums",
    swatch: "size-2.5 shrink-0 rounded-[3px] transition-opacity",
    tooltip:
      "pointer-events-none absolute z-10 min-w-36 rounded-lg border bg-card px-3 py-2 text-xs text-card-fg shadow-lg",
    tooltipRow: "flex items-center gap-2",
    tooltipLabel: "text-muted-fg",
    tooltipValue: "ml-auto pl-4 font-medium tabular-nums",
    empty: "flex items-center justify-center text-sm text-muted-fg",
  },
  variants: {
    legendPosition: {
      bottom: { root: "flex-col", legend: "justify-center" },
      right: {
        root: "flex-col sm:flex-row",
        legend: "flex-col gap-y-0.5",
      },
      left: {
        root: "flex-col sm:flex-row-reverse",
        legend: "flex-col gap-y-0.5",
      },
      top: { root: "flex-col-reverse", legend: "justify-center" },
    },
  },
  defaultVariants: { legendPosition: "bottom" },
});

3. Add the Radial Bar Chart file

src/components/ui/radial-bar-chart/radial-bar-chart.tsxShow code
"use client";

import { type PointerEvent, useMemo, useRef, useState } from "react";
import { cn } from "@/lib/cn";
import { areaChartColors } from "@/types/area-chart-styles";
import { arcPath } from "@/types/pie-chart-utils";
import { radialBarChartStyles } from "@/types/radial-bar-chart-styles";

export interface RadialBarChartProps<T extends Record<string, unknown>> {
  /** One row per ring: `{ goal: "Move", done: 420 }`. */
  data: T[];
  /** The key of the value that names each ring, such as `goal`. */
  index: keyof T & string;
  /** The key of the number of each ring, such as `done`. How far the ring goes round follows it. */
  value: keyof T & string;
  /**
   * What a whole ring stands for. Defaults to the biggest number in the data, so
   * the longest ring is full. Set it to compare against a goal or a total, such
   * as 100 for percentages.
   */
  maxValue?: number;
  /** The colors of the rings in order, any CSS colors. Defaults to the theme's chart colors, then again. */
  colors?: string[];
  /** The order of the rings, the first being the outermost: as given, biggest first, or smallest first. Defaults to `none`. */
  sortOrder?: "none" | "descending" | "ascending";
  /** Where the rings start, in degrees clockwise from the top. Defaults to 0. */
  startAngle?: number;
  /** How far round a full ring goes, in degrees: 360 is a circle, 270 a gauge. Defaults to 360. */
  sweep?: number;
  /** How big the empty space in the middle is, as a share of the radius from 0 to 0.8. Defaults to 0.3. */
  innerRadius?: number;
  /** The thickness of the rings in pixels of the 300 wide drawing. It gets thinner when there are many rings. Defaults to 18. */
  barSize?: number;
  /** The space between rings, in the same units. Defaults to 6. */
  gap?: number;
  /** The rings end in a round cap. Defaults to `true`. */
  isRounded?: boolean;
  /** The faint ring behind each one that shows how much room is left. Defaults to `true`. */
  showTrack?: boolean;
  /** Write the name of each ring at its start. Defaults to `false`. */
  showLabels?: boolean;
  /** The card that follows the pointer with the name, number and share of the ring. Defaults to `true`. */
  showTooltip?: boolean;
  /** The list of rings, which also hides and shows them. Defaults to `true`. */
  showLegend?: boolean;
  legendPosition?: "top" | "bottom" | "left" | "right";
  /** In the middle, the number of the ring under the pointer, with its name. Defaults to `true`. */
  showCenter?: boolean;
  /** In the middle when no ring is under the pointer, such as a total or a score. */
  centerValue?: string;
  /** What it says under `centerValue`. */
  centerLabel?: string;
  /** Where a number is shown, in the tooltip, the legend and the middle: `(v) => v + "%"`. */
  valueFormatter?: (value: number) => string;
  /** Where the name of a ring is shown. */
  indexFormatter?: (value: string) => string;
  /** How wide the chart is at most, in pixels. It gets narrower when its parent is. Defaults to 300. */
  size?: number;
  /** Names the chart for screen readers. A table of the data is there too. */
  "aria-label": string;
  className?: string;
}

type Row = Record<string, unknown>;

// The drawing is in a space of SIZE units, whatever size it is shown at.
const SIZE = 300;
const CENTER = SIZE / 2;
const RADIUS = SIZE / 2 - 6;

const toNumber = (value: unknown) => {
  const n = Number(value);
  return Number.isFinite(n) && n > 0 ? n : 0;
};

const defaultValueFormatter = (value: number) =>
  new Intl.NumberFormat("en-US", { maximumFractionDigits: 2 }).format(value);

const percentFormatter = new Intl.NumberFormat("en-US", {
  maximumFractionDigits: 1,
});

const shorten = (text: string, chars: number) =>
  text.length > chars ? `${text.slice(0, Math.max(chars - 1, 1))}…` : text;

/**
 * A radial bar chart: a ring for each number, and how far round it goes is how
 * big the number is, like the activity rings of a watch. Use it to show
 * progress toward goals, or to compare a few amounts in a small space, where the
 * rings sit inside each other.
 *
 * It is drawn as SVG from your data, with no charting library, and scales to
 * the width it is given. Each ring has a faint track that shows how much is
 * left, pointing at a ring shows its number in the middle and in a tooltip, the
 * legend hides and shows rings, colors follow the theme in light and dark, and
 * screen readers get the data as a table.
 *
 * Set `maxValue` to what a full ring stands for, such as 100 for percentages;
 * without it the biggest number fills its ring and the others are measured
 * against it.
 *
 * @example
 * <RadialBarChart
 *   aria-label="Daily goals"
 *   data={[{ goal: "Move", done: 420 }, { goal: "Exercise", done: 24 }]}
 *   index="goal"
 *   value="done"
 *   maxValue={500}
 * />
 */
export function RadialBarChart<T extends Row>({
  data,
  index,
  value,
  maxValue,
  colors,
  sortOrder = "none",
  startAngle = 0,
  sweep = 360,
  innerRadius = 0.3,
  barSize = 18,
  gap = 6,
  isRounded = true,
  showTrack = true,
  showLabels = false,
  showTooltip = true,
  showLegend = true,
  legendPosition = "bottom",
  showCenter = true,
  centerValue,
  centerLabel,
  valueFormatter = defaultValueFormatter,
  indexFormatter = (name) => name,
  size = 300,
  "aria-label": ariaLabel,
  className,
}: RadialBarChartProps<T>) {
  const styles = radialBarChartStyles({ legendPosition });
  const plot = useRef<HTMLDivElement>(null);
  const [hidden, setHidden] = useState<string[]>([]);
  const [active, setActive] = useState<string | null>(null);
  const [pointer, setPointer] = useState<{ x: number; y: number } | null>(null);
  const span = Math.min(Math.max(sweep, 10), 360);

  // Every row, with the color it keeps whether or not the others are hidden.
  const items = useMemo(() => {
    const palette = colors?.length ? colors : areaChartColors;
    return data.map((row, i) => {
      const name = String(row[index] ?? "");
      return {
        id: `${i}`,
        label: indexFormatter(name),
        amount: toNumber(row[value]),
        color: palette[i % palette.length],
      };
    });
  }, [data, index, value, colors, indexFormatter]);

  const shown = useMemo(() => {
    const list = items.filter((item) => !hidden.includes(item.id));
    if (sortOrder !== "none") {
      list.sort((a, b) =>
        sortOrder === "descending" ? b.amount - a.amount : a.amount - b.amount,
      );
    }
    return list;
  }, [items, hidden, sortOrder]);

  const whole =
    maxValue ?? Math.max(0, ...items.map((item) => item.amount)) ?? 0;

  // Rings from the outside in, as thick as asked or thinner to fit them all.
  const room = RADIUS - RADIUS * Math.min(Math.max(innerRadius, 0), 0.8);
  const count = Math.max(shown.length, 1);
  const thickness = Math.max(
    Math.min(barSize, (room - gap * (count - 1)) / count),
    2,
  );
  const rings = shown.map((item, i) => {
    const radius = RADIUS - thickness / 2 - i * (thickness + gap);
    const ratio = whole > 0 ? Math.min(item.amount / whole, 1) : 0;
    return { ...item, radius, ratio, share: ratio * 100 };
  });

  function track(event: PointerEvent, id: string) {
    const box = plot.current?.getBoundingClientRect();
    if (!box) return;
    setActive(id);
    setPointer({ x: event.clientX - box.left, y: event.clientY - box.top });
  }

  function leave() {
    setActive(null);
    setPointer(null);
  }

  function toggle(id: string) {
    setHidden((current) =>
      current.includes(id)
        ? current.filter((k) => k !== id)
        : shown.length > 1
          ? [...current, id]
          : current,
    );
  }

  const current = rings.find((r) => r.id === active) ?? null;
  const hasData = items.some((item) => item.amount > 0);
  const flip =
    pointer !== null &&
    plot.current !== null &&
    pointer.x > plot.current.clientWidth / 2;
  const hole = RADIUS * Math.min(Math.max(innerRadius, 0), 0.8);
  const valueSize = Math.min(28, Math.max(hole * 0.5, 13));

  return (
    <figure
      aria-label={ariaLabel}
      className={cn(styles.root(), "m-0", className)}
    >
      {hasData ? (
        <div ref={plot} className={styles.plot()} style={{ maxWidth: size }}>
          <svg
            viewBox={`0 0 ${SIZE} ${SIZE}`}
            aria-hidden="true"
            className={styles.svg()}
          >
            {rings.map((ring, i) => {
              const dim = active !== null && active !== ring.id;
              return (
                <g
                  key={ring.id}
                  onPointerEnter={(event) => track(event, ring.id)}
                  onPointerMove={(event) => track(event, ring.id)}
                  onPointerLeave={leave}
                >
                  {showTrack ? (
                    <path
                      className={styles.track()}
                      d={arcPath(
                        CENTER,
                        CENTER,
                        ring.radius,
                        startAngle,
                        startAngle + span,
                      )}
                      strokeWidth={thickness}
                      strokeLinecap={isRounded ? "round" : "butt"}
                      opacity={0.7}
                    />
                  ) : null}
                  {ring.ratio > 0 ? (
                    <path
                      className={cn(styles.bar(), "radial-bar-chart-in")}
                      d={arcPath(
                        CENTER,
                        CENTER,
                        ring.radius,
                        startAngle,
                        startAngle + span * ring.ratio,
                      )}
                      pathLength={100}
                      stroke={ring.color}
                      strokeWidth={thickness}
                      strokeLinecap={isRounded ? "round" : "butt"}
                      style={{
                        opacity: dim ? 0.4 : 1,
                        animationDelay: `${i * 80}ms`,
                      }}
                    />
                  ) : null}
                </g>
              );
            })}

            {showLabels
              ? rings.map((ring) => {
                  const y = CENTER - ring.radius + 4;
                  return (
                    <text
                      key={ring.id}
                      className={styles.ringLabel()}
                      x={CENTER - 8}
                      y={y}
                      textAnchor="end"
                      dominantBaseline="central"
                      opacity={thickness >= 12 ? 1 : 0}
                    >
                      {shorten(ring.label, 14)}
                    </text>
                  );
                })
              : null}

            {showCenter && (current || centerValue) && hole > 22 ? (
              <g>
                <text
                  className={styles.centerValue()}
                  x={CENTER}
                  y={CENTER}
                  textAnchor="middle"
                  fontSize={valueSize}
                >
                  {current ? valueFormatter(current.amount) : centerValue}
                </text>
                <text
                  className={styles.centerLabel()}
                  x={CENTER}
                  y={CENTER + valueSize * 0.55 + 8}
                  textAnchor="middle"
                  fontSize={Math.max(10, valueSize * 0.42)}
                >
                  {current ? shorten(current.label, 14) : centerLabel}
                </text>
              </g>
            ) : null}
          </svg>

          {showTooltip && current && pointer ? (
            <div
              className={styles.tooltip()}
              style={{
                top: pointer.y,
                left: pointer.x,
                transform: `translate(${flip ? "calc(-100% - 12px)" : "12px"}, -50%)`,
              }}
            >
              <div className={styles.tooltipRow()}>
                <span
                  aria-hidden="true"
                  className={styles.swatch()}
                  style={{ background: current.color }}
                />
                <span className={styles.tooltipLabel()}>{current.label}</span>
                <span className={styles.tooltipValue()}>
                  {valueFormatter(current.amount)}
                </span>
              </div>
              <p className="m-0 mt-1 text-muted-fg">
                {percentFormatter.format(current.share)}% of{" "}
                {valueFormatter(whole)}
              </p>
            </div>
          ) : null}
        </div>
      ) : (
        <div className={styles.empty()} style={{ height: 140 }}>
          No data
        </div>
      )}

      {showLegend && hasData ? (
        <div className={styles.legend()}>
          {items
            .filter((item) => item.amount > 0)
            .map((item) => {
              const isShown = !hidden.includes(item.id);
              return (
                <button
                  key={item.id}
                  type="button"
                  aria-pressed={isShown}
                  onClick={() => toggle(item.id)}
                  onPointerEnter={() => isShown && setActive(item.id)}
                  onPointerLeave={leave}
                  onFocus={() => isShown && setActive(item.id)}
                  onBlur={leave}
                  className={styles.legendItem()}
                >
                  <span
                    aria-hidden="true"
                    className={cn(styles.swatch(), !isShown && "opacity-40")}
                    style={{ background: item.color }}
                  />
                  {item.label}
                  <span className={styles.legendValue()}>
                    {valueFormatter(item.amount)}
                  </span>
                </button>
              );
            })}
        </div>
      ) : null}

      <table className="sr-only">
        <caption>{ariaLabel}</caption>
        <thead>
          <tr>
            <th scope="col">{index}</th>
            <th scope="col">{value}</th>
          </tr>
        </thead>
        <tbody>
          {items.map((item) => (
            <tr key={item.id}>
              <th scope="row">{item.label}</th>
              <td>{valueFormatter(item.amount)}</td>
            </tr>
          ))}
        </tbody>
      </table>
    </figure>
  );
}

4. Use it

import { RadialBarChart } from "@/components/ui/radial-bar-chart/radial-bar-chart";

Anatomy

An SVG with a tooltip over it, and a legend under it.

<RadialBarChart
  aria-label="Visitors by browser"
  data={[{ browser: "Chrome", visitors: 275 }, ...]}
  index="browser"
  value="visitors"
/>
PartRendered asNotes
Ringsvg pathOne per row, from the outside in. How far round it goes is its number out of maxValue.
Tracksvg pathThe faint ring behind each one, which shows how much is left.
Centersvg textThe number and name of the ring under the pointer, or centerValue and centerLabel when there is none.
TooltipdivA card that follows the pointer with the name, number and share of the ring.
LegendbuttonOne button per row, with its number. Pressing it hides or shows the ring.
Data tabletable, sr-onlyThe same data as a table for screen readers. The SVG is hidden from them.

Examples

Usage

Point at a ring or at a name in the legend, and press a name to hide its ring. Here the biggest number fills its ring.

Visitors by browser
browservisitors
Chrome275
Safari200
Firefox187
Edge173
Other90

Progress toward goals

Set maxValue to what a full ring stands for. With percentages that is 100, and a ring at 84 goes 84% of the way round. centerValue and centerLabel fill the middle when nothing is under the pointer.

Daily goals
goaldone
Move84%
Exercise80%
Stand75%

Gauge and half circle

startAngle is where the rings start, in degrees clockwise from the top, and sweep how far round a full ring goes. 270 from -135 makes a gauge, and 180 from -90 a half circle.

A 270° gauge

Score as a gauge
namevalue
Score78

A half circle

Score as a half circle
skillscore
Speed82
Design64
Testing91
Docs47

Names on the rings

showLabels writes the name of each ring at its start. Give the rings room with barSize and gap, because the names are left out when the rings are too thin.

Skill scores with the names on the rings
skillscore
Speed82
Design64
Testing91
Docs47

Order

The first row is the outermost ring. sortOrder puts the biggest or the smallest there.

Biggest outside

Skill scores, biggest outside
skillscore
Speed82
Design64
Testing91
Docs47

Smallest outside

Skill scores, smallest outside
skillscore
Speed82
Design64
Testing91
Docs47

Ends, track and thickness

isRounded chooses round or square ends, showTrack the faint ring behind, and barSize and gap the thickness and the space between rings.

Square ends

Skill scores, square ends
skillscore
Speed82
Design64
Testing91
Docs47

No track

Skill scores, no track
skillscore
Speed82
Design64
Testing91
Docs47

Thin rings

Skill scores, thin rings
skillscore
Speed82
Design64
Testing91
Docs47

Legend

Put the legend below, above, or at either side of the chart, or turn it off.

Visitors by browser, with the legend on the right
browservisitors
Chrome275
Safari200
Firefox187
Edge173
Other90

Formatting values

valueFormatter writes the numbers, in the tooltip, the legend and the middle, and indexFormatter the names.

Storage used
typegb
PHOTOS62 GB
APPS38 GB
MAIL11 GB

No data

With no rows, or only zeros, it says so instead of drawing empty rings.

No data
No goals yet
goaldone

Component API

RadialBarChart takes the props below.

PropTypeDefault
dataRecord<string, unknown>[]-
indexstring-
valuestring-
aria-labelstring-
maxValuenumberthe biggest value
colorsstring[]the theme's chart colors
sortOrder"none" | "descending" | "ascending""none"
startAnglenumber (degrees)0
sweepnumber (10 to 360 degrees)360
innerRadiusnumber (0 to 0.8)0.3
barSizenumber18
gapnumber6
isRoundedbooleantrue
showTrackbooleantrue
showLabelsbooleanfalse
showTooltipbooleantrue
showLegendbooleantrue
legendPosition"top" | "bottom" | "left" | "right""bottom"
showCenterbooleantrue
centerValuestring-
centerLabelstring-
valueFormatter(value: number) => stringnumber with grouping
indexFormatter(value: string) => stringthe value
sizenumber (px)300
classNamestring-