Interactive Answers

Radial Dots

A cycle as rings of dots — hours of the day or days of the week, stacked by series, with the headline in the middle.

3 variantsMIT

Preview

Installation

Copies the component into components/ui and installs its dependencies and theme tokens.

pnpm dlx shadcn@latest add https://uilab.tmih06.com/r/radial-dots.json

Usage

Pass your own data and wire the callbacks to your agent runtime.

import { RadialDots } from "@/components/ui/radial-dots";

export function RunsByHour({ stats }: { stats: HourlyStats }) {
  return (
    <RadialDots
      title="Runs by hour"
      subtitle="Last 7 days, UTC"
      labels={stats.hours} // "00" … "23"
      series={[
        { id: "people", label: "Started by people", values: stats.manual },
        { id: "scheduled", label: "Scheduled", values: stats.scheduled },
      ]}
      center={{ value: `${stats.medianSeconds} s`, caption: "per run" }}
      onSelect={(hour) => filterRuns(hour)}
    />
  );
}

// Pass null while the telemetry request is in flight; keep stale data and
// set loading when refetching.
export function CycleState({ query }: { query: RunsQuery }) {
  return (
    <RadialDots
      title="Runs by hour"
      labels={query.data?.labels ?? null}
      series={query.data?.series ?? null}
      center={query.data?.center ?? null}
      loading={query.isRefetching}
      skeleton={{ count: 24 }}
    />
  );
}

Props

PropTypeDefaultDescription
labels*string[] | null—One label per sector, clockwise from the top.
series*RadialSeries[] | null—Stacked outward in order. The busiest sector fills every ring.
loadingbooleanfalseForce the fixed-footprint skeleton while refetching, even when stale cycle data is available.
skeleton{ count?: number }—Loading footprint hint for the number of radial positions. Falls back to stale labels, then 24.
title*string—Header title.
subtitlestring—Secondary line under the title.
center*{ value: string; caption?: string } | null—Headline in the middle. Hovering a sector shows its numbers there instead.
axisnumber[]—Indexes of the labels drawn around the edge. Defaults to the four quarters.
format(value: number) => string—Formats sector values. Defaults to 1,234.
onSelect(index: number) => void—Called when a sector is hovered or reached with the arrow keys.
stringsPartial<RadialDotsLabels>—Your own UI strings (loading announcement and screen-reader hints), for translating. Right-to-left works under `dir="rtl"`; the cycle still runs clockwise.
localestring—BCP 47 locale for the default number format. Defaults to en-US.
classNamestring—Extra classes for the root element.
type RadialSeries = {
  id: string;
  label: string;
  values: number[]; // one per sector
  color?: string;   // defaults to brand, foreground, muted
};