Skip to content

Radar ​

renderRadarChart draws a radar (spider) chart: one closed polygon per series over three or more axes. Use it to compare a few items across the same set of attributes.

Live example

Basic usage ​

ts
import { Charturbo } from 'charturbo';

const canvas = document.querySelector('canvas')!;
const sdk = await Charturbo.create(canvas);

sdk.renderRadarChart(
  {
    axes: ['Speed', 'Range', 'Cost', 'Comfort', 'Safety'],
    series: [
      { name: 'Model A', values: [82, 64, null, 71, 90] }, // null = missing
      { name: 'Model B', values: [55, 88, 70, 62, 74], color: '#d95926' },
    ],
  },
  { title: 'Vehicle comparison', max: 100, rings: 4, format: '.0f' }
);
sdk.enableNodeInteractions(canvas, { autoRender: true });
sdk.render();

Signature:

ts
renderRadarChart(data: RadarChartData, options?: RadarChartOptions): { axisCount: number; seriesCount: number }

Data format ​

ts
interface RadarChartData {
  axes: string[];          // axis names, clockwise from startAngle; at least 3
  series: RadarSeries[];   // 1 to 8 series
}

interface RadarSeries {
  name: string;
  values: ArrayLike<number | null>;  // one per axis; finite and >= 0, null / NaN = missing
  color?: ColorInput;                // default: theme palette slot of the series
}
  • Each series must have exactly one value per axis, and there must be 1 to 8 series; otherwise a RangeError is thrown.
  • Negative or infinite values throw. A missing value (null / NaN) makes the polygon pass through the center at that axis, with no marker.
  • Series colors follow the theme palette in fixed order (no cycling).

Options ​

OptionTypeDefaultDescription
maxnumber | (number | null | undefined)[]nice max of the dataRadial max shared by all axes, or one per axis (null = the shared max). Ring labels show only on a shared scale.
ringsnumber4Target ring count (nice steps).
fillOpacitynumber0.2Polygon fill opacity. 0 = outlines only.
strokeWidthnumber2Polygon stroke width in CSS px.
markersboolean | numbertrue (radius 3.5 px)Vertex markers: true, false, or a radius in CSS px.
startAnglenumber0Degrees clockwise from 12 o'clock of the first axis.
grid'polygon' | 'circle''polygon'Shape of the concentric grid.
showGridbooleantrueRings and spokes.
formatChartValueFormatlocale numberValue text of rings, tooltip and accessibility (spec, Intl options or function). See Number & Date Formats.
valueLabelstring'Value' (localized)Name of the values in the tooltip and data table.
titlestringChart title.
descriptionstringAccessible name of the canvas.
legendChartLegendOptions | booleanshown with 2+ series{ show, toggle, emphasize }. Click toggles a series, hover emphasizes it.
paddingChartPaddingOptionsderivedPlot margins in CSS px.

Interactions ​

Call enableNodeInteractions(canvas) to turn them on.

  • Hover picks the axis nearest to the pointer angle and returns every visible series on that axis; the nearest vertex is the primary item. The spoke is highlighted and its markers are enlarged.
  • Legend click hides a series; legend hover fades the others and draws the emphasized series on top.
  • Brush, zoom and pan are disabled.
  • Data point ids are series * axes + axis.

Tooltip context (see Tooltips & Hover):

ts
// ctx.chartType === 'radar'
// ctx.index = axis index
// ctx.items = every visible series on that axis
// ctx.radar = { axis, max }

Notes ​

  • The nice radial scale, per-axis maxima, polygon / grid / marker geometry, hit testing and label anchors are computed in the engine (Rust). Lines and markers are sized in CSS px on the GPU.
  • With per-axis maxima, ring value labels are omitted.
  • Accessibility: summary (top axis per series), a data table (axis × series), left / right arrows move between axes and up / down between series. See Accessibility.

See also ​

MIT License