Radial Chart

A series as radial bars: a ring per row, its value as an arc — on a track, stacked, on a half circle with your text in its center. Names and colors come from the chart's config; the keyboard moves through the rows, and the tooltip says their values.

ChartsExperimental

Installation

It has its own entry point, @semantic-components/ui/charts, built on d3-scale d3-shape — an optional peer of ui: install it where you use the component.

ts
import { ScChart, ScChartPlot, ScChartRadialBar } from '@semantic-components/ui/charts';

Usage

import { DecimalPipe } from '@angular/common';import { Component, ViewEncapsulation } from '@angular/core';import {  ScChart,  type ScChartConfig,  ScChartPlot,  ScChartRadialBar,  ScChartTooltip,  ScChartTooltipIndicator,  ScChartTooltipItem,  ScChartTooltipName,  ScChartTooltipPortal,  ScChartTooltipProvider,  ScChartTooltipValue,} from '@semantic-components/ui/charts';
@Component({  selector: 'app-radial-chart-usage-demo',  imports: [    ScChart,    ScChartPlot,    ScChartRadialBar,    ScChartTooltip,    ScChartTooltipPortal,    ScChartTooltipProvider,    DecimalPipe,    ScChartTooltipIndicator,    ScChartTooltipItem,    ScChartTooltipName,    ScChartTooltipValue,  ],  template: `    <div      scChart      class="mx-auto aspect-square max-h-72"      [config]="config"      [data]="data"    >      <svg scChartPlot categoryKey="browser" aria-label="Visitors by browser">        <g scChartRadialBar key="visitors" colorBy="category" track />      </svg>      <div scChartTooltipProvider>        <ng-template scChartTooltipPortal>          <div scChartTooltip #tooltip="scChartTooltip">            @for (item of tooltip.payload(); track item.dataKey) {              <div scChartTooltipItem [item]="item">                <span scChartTooltipIndicator></span>                <span scChartTooltipName>{{ item.name }}</span>                <span scChartTooltipValue>{{ item.value | number }}</span>              </div>            }          </div>        </ng-template>      </div>    </div>  `,  host: { class: 'block w-full max-w-xl' },  encapsulation: ViewEncapsulation.None,})export class RadialChartUsageDemo {  private readonly data = [    { browser: 'chrome', visitors: 275 },    { browser: 'safari', visitors: 200 },    { browser: 'firefox', visitors: 187 },    { browser: 'edge', visitors: 173 },    { browser: 'other', visitors: 90 },  ];  private readonly config: ScChartConfig = {    visitors: { label: 'Visitors' },    chrome: { label: 'Chrome', color: 'var(--chart-1)' },    safari: { label: 'Safari', color: 'var(--chart-2)' },    firefox: { label: 'Firefox', color: 'var(--chart-3)' },    edge: { label: 'Edge', color: 'var(--chart-4)' },    other: { label: 'Other', color: 'var(--chart-5)' },  };}

Anatomy

A chart (its rows and config), its plot with the series, and the tooltip and legend you write from their state.

import { ScChart, ScChartPlot, ScChartRadialBar, ScChartTooltip, ScChartTooltipIndicator, ScChartTooltipItem, ScChartTooltipName, ScChartTooltipPortal, ScChartTooltipProvider, ScChartTooltipValue } from '@semantic-components/ui/charts';
<div scChart [config]="…" [data]="…">  <svg scChartPlot categoryKey="…" aria-label="…">    <g scChartRadialBar key="…" />  </svg>  <div scChartTooltipProvider>    <ng-template scChartTooltipPortal>      <div scChartTooltip #tooltip="scChartTooltip">        <div scChartTooltipItem [item]="…">          <span scChartTooltipIndicator></span>          <span scChartTooltipName>…</span>          <span scChartTooltipValue>…</span>        </div>      </div>    </ng-template>  </div></div>

Accessibility

  • The plot is one tab stop, a group named by its aria-label: the arrow keys, Home and End move through its rings; Escape closes the tooltip.
  • As the keyboard moves, screen readers hear what the tooltip says, through the CDK's LiveAnnouncer (politely).
  • Right to left, with the app following the direction (charts.followDirection), it is mirrored — from 9 o’clock, clockwise — and ← goes to the next.
  • With reduced motion (prefers-reduced-motion), it appears and changes at once.

Examples

Stacked, on a half circle

0 Visitors
import { DecimalPipe } from '@angular/common';import { Component, ViewEncapsulation } from '@angular/core';import { ScNumberTicker } from '@semantic-components/ui';import {  ScChart,  ScChartCenter,  type ScChartConfig,  ScChartPlot,  ScChartRadialBar,  ScChartTooltip,

On a grid

import { DecimalPipe } from '@angular/common';import { Component, ViewEncapsulation } from '@angular/core';import {  ScChart,  type ScChartConfig,  ScChartPlot,  ScChartPolarGrid,  ScChartRadialBar,  ScChartTooltip,  ScChartTooltipIndicator,

Its name on each ring

import { DecimalPipe } from '@angular/common';import { Component, ViewEncapsulation } from '@angular/core';import {  ScChart,  type ScChartConfig,  ScChartLabels,  ScChartPlot,  ScChartRadialBar,  ScChartTooltip,  ScChartTooltipIndicator,

RTL

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScChart,  type ScChartConfig,  ScChartPlot,  ScChartRadialBar,  ScChartTooltip,  ScChartTooltipIndicator,  ScChartTooltipItem,

API reference

The series' inputs. The chart, its plot, axes, tooltip and legend are on the Chart page.

InputTypeDefaultDescription
keystring (required)— the series' key in the rows
stackstring | nullnull along the ring, one after the other
colorBy'key' | 'category''key' its key's color, or each row's
innerRadiusnumber0.3 where the rings start, a share of the radius
outerRadiusnumber1 where they end
cornerRadiusnumber— Its ends' rounding, in px — unset, the style's (--sc-chart-bar-radius, as the bars'; square in Lyra and Sera).
trackbooleanfalse each ring's full length behind it
isAnimationActivebooleantrue its arcs grow along their rings when it appears (Recharts' entrance)
animationBeginnumber0 the wait before it starts, in ms
animationDurationnumber1500 how long it lasts, in ms
animationEasingease, ease-in, ease-out, ease-in-out, linearease
animationMatchBy'index' (by position, stretched), 'append' (the first with the first) or (row, index) => key'append' how its shapes before and after a change are paired (Recharts')
classstring'' Merged over its own classes.