Radar Chart

Series as polygons over the categories, each on its spoke: filled or outlined, with dots, on a polygon or circle grid. 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, ScChartRadar } from '@semantic-components/ui/charts';

Usage

import { DecimalPipe } from '@angular/common';import { Component, ViewEncapsulation } from '@angular/core';import {  ScChart,  type ScChartConfig,  ScChartPlot,  ScChartPolarAngleAxis,  ScChartPolarGrid,  ScChartRadar,  ScChartTooltip,  ScChartTooltipIndicator,  ScChartTooltipItem,  ScChartTooltipLabel,  ScChartTooltipName,  ScChartTooltipPortal,  ScChartTooltipProvider,  ScChartTooltipValue,} from '@semantic-components/ui/charts';
@Component({  selector: 'app-radar-chart-usage-demo',  imports: [    ScChart,    ScChartPlot,    ScChartPolarGrid,    ScChartPolarAngleAxis,    ScChartRadar,    ScChartTooltip,    ScChartTooltipPortal,    ScChartTooltipProvider,    DecimalPipe,    ScChartTooltipLabel,    ScChartTooltipIndicator,    ScChartTooltipItem,    ScChartTooltipName,    ScChartTooltipValue,  ],  template: `    <div      scChart      class="mx-auto aspect-square max-h-72"      [config]="config"      [data]="data"    >      <svg        scChartPlot        categoryKey="month"        aria-label="Desktop visitors, January to June"      >        <g scChartPolarGrid />        <g scChartPolarAngleAxis [tickFormatter]="short" />        <g scChartRadar key="desktop" dots />      </svg>      <div scChartTooltipProvider>        <ng-template scChartTooltipPortal>          <div scChartTooltip #tooltip="scChartTooltip">            <div scChartTooltipLabel>{{ tooltip.label() }}</div>            @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 RadarChartUsageDemo {  private readonly data = [    { month: 'January', desktop: 186, mobile: 80 },    { month: 'February', desktop: 305, mobile: 200 },    { month: 'March', desktop: 237, mobile: 120 },    { month: 'April', desktop: 73, mobile: 190 },    { month: 'May', desktop: 209, mobile: 130 },    { month: 'June', desktop: 214, mobile: 140 },  ];  private readonly config: ScChartConfig = {    desktop: { label: 'Desktop', color: 'var(--chart-1)' },    mobile: { label: 'Mobile', color: 'var(--chart-2)' },  };  /** January → Jan. */  private readonly short = (month: string) => month.slice(0, 3);}

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, ScChartPolarAngleAxis, ScChartPolarGrid, ScChartRadar, ScChartTooltip, ScChartTooltipIndicator, ScChartTooltipItem, ScChartTooltipName, ScChartTooltipPortal, ScChartTooltipProvider, ScChartTooltipValue, ScChartLegend, ScChartLegendIndicator, ScChartLegendItem } from '@semantic-components/ui/charts';
<div scChart [config]="…" [data]="…">  <svg scChartPlot categoryKey="…" aria-label="…">    <g scChartPolarGrid />    <g scChartPolarAngleAxis />    <g scChartRadar key="…" />  </svg>  <div scChartTooltipProvider>    <ng-template scChartTooltipPortal>      <div scChartTooltip #tooltip="scChartTooltip">        <div scChartTooltipLabel>…</div>        <div scChartTooltipItem [item]="…">          <span scChartTooltipIndicator></span>          <span scChartTooltipName>…</span>          <span scChartTooltipValue>…</span>        </div>      </div>    </ng-template>  </div>  <div scChartLegend #legend="scChartLegend">    <div scChartLegendItem [item]="…">      <span scChartLegendIndicator></span>    </div>  </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 spokes; 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 — its spokes counterclockwise from the top — and ← goes to the next.
  • With reduced motion (prefers-reduced-motion), it appears and changes at once.

Examples

Radar, two series

Desktop
Mobile
import { DecimalPipe } from '@angular/common';import { Component, ViewEncapsulation } from '@angular/core';import {  ScChart,  type ScChartConfig,  ScChartLegend,  ScChartLegendIndicator,  ScChartLegendItem,  ScChartPlot,  ScChartPolarAngleAxis,

Outlines, on circles

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

RTL

import { Dir } from '@angular/cdk/bidi';import { Component, LOCALE_ID, ViewEncapsulation } from '@angular/core';import {  ScChart,  type ScChartConfig,  ScChartPlot,  ScChartPolarAngleAxis,  ScChartPolarGrid,  ScChartRadar,  ScChartTooltip,

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
fillOpacitynumber (00.6 outline only, with stroke)
strokebooleanfalse its outline
dotsbooleanfalse a dot at each value
activeDotbooleantrue a dot on the spoke pointed at
isAnimationActivebooleantrue its points move out from the center 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'index' how its shapes before and after a change are paired (Recharts')
classstring'' Merged over its own classes.