Skip to content

Radardiagram API

Zet een paar kandidaten tegen elkaar af op één gedeelde set criteria en zie in één oogopslag wie waar wint. Zie de Radardiagram-demo.

Import

ts
import "@michi-vz/wc/radar-chart";
// <michi-vz-radar-chart> is now defined
ts
import { mountRadarChart } from "@michi-vz/core";

const chart = mountRadarChart(el, props);

Eigenschappen

PropTypeDefaultDescription
timelineboolean | TimelinePeriodConfig-Opt-in "play through years": snapshots one period at a time over the period tags in the data, with a headless controller (`chart.timeline()`) plus the built-in play button + scrubber. Values tween between periods unless `interpolate: false`. Off by default; wins over `progressiveDraw` when both are set.
progressiveDrawboolean | ProgressiveDrawConfig-Opt-in reveal animation: wipes the marks in left to right on mount (a clip reveal; axes and titles stay put). `true` uses defaults (1200 ms, easeInOutCubic); a config tunes durationMs, easing, autoplay, and replayOnUpdate (`tipLabel` is LineChart-only and ignored here). Off by default; respects prefers-reduced-motion (renders fully drawn instantly) and `replay()` re-runs it.
series*RadarDataItem[]-Array of polygon series to plot, one closed shape per item drawn over the shared polar grid
axesstring[]-spoke labels (the radial axes). Optional when `poles.labels` is supplied (legacy compat).
poles{ labels: string[]; domain?: number[]; range?: number[] }-Legacy pole config; `poles.labels` are used as the axes when `axes` is omitted.
showFilledboolean-Stroke-only when false (no polygon fill); default true (fill at fillOpacity).
showDimmedFillboolean-Fill the DIMMED (e.g. non-current) polygons as a soft background; default true. Set false for stroke-only dimmed paths when the fill obscures the active path.
radialLabelFormatter(value: number) => string-Formats each ring's value label (the radial scale).
poleLabelFormatter(axis: string) => string-Formats each spoke (pole) label.
tooltipContainerStyleRecord<string, string | number>-Inline style merged onto the tooltip container div.
isLoadingboolean-Show the loading overlay and skip the no-data check (legacy michi-vz parity).
isNodataboolean | ((dataSet: RadarDataItem[] | null | undefined) => boolean)-No-data override: boolean, or a predicate on series; default = empty series.
noDataLabelstring-Text for the vanilla default no-data overlay (ignored when suppressed).
suppressDefaultOverlayboolean-A framework wrapper sets this to render its OWN loading/no-data node instead.
titlestring-Optional chart title rendered above the plot
maxValuenumber-Value mapped to the outer ring (full radius), shared by every spoke; defaults to the largest value across all series and axes (or 1 when all are zero)
ringsnumber4number of concentric grid rings (default 4).
fillOpacitynumber0.2polygon fill opacity (default 0.2).
tooltipFormatter(item: RadarDataItem & { date?: string }) => string-Returns custom tooltip HTML for a hovered datum (sanitized before it is inserted). In canvas mode the datum also carries `date` (the hovered pole's axis label).
onHighlightItem(labels: string[]) => void-Called when the hovered/highlighted label(s) change
Common props - shared by every chart (14)
PropTypeDefaultDescription
widthnumber600Chart width in pixels
heightnumber600Chart height in pixels
marginMargin{ top: 60, right: 80, bottom: 60, left: 80 }Inner margins (top/right/bottom/left, in px) reserved for axes, titles, and labels
colorsstring[]-Categorical palette for series/labels without an explicit colour or colorsMapping entry
colorsMappingRecord<string, string>-Explicit label -> colour map; takes precedence over the palette and per-item colours
highlightItemsstring[]-Labels to emphasise; all other marks dim
disabledItemsstring[]-Labels to hide and exclude from scales/stacks
renderer"svg" | "canvas" | "webgpu""svg"Render as inline SVG (default) or to a canvas (faster for large datasets); getContext() is identical either way
localestring-BCP-47 locale used for number and date formatting
skipColorMappingDispatchbooleanfalseExternal-CSS mode: unmapped labels resolve to transparent and onColorMappingGenerated is not emitted, so mark colours come from your CSS via the data-label-safe contract
enableTransitionsbooleantrueAnimate updates with CSS transitions (default true)
onColorMappingGenerated(mapping: Record<string, string>) => void-Called with the resolved label -> colour map after the chart assigns colours
onChartDataProcessed(context: ChartContext) => void-Called with the renderer-agnostic ChartContext whenever the data is (re)processed
onDataWarning(warnings: DataWarning[]) => void-Called with any non-fatal data warnings (duplicate labels, non-finite values, non-monotonic dates, ...)

Gebeurtenissen

Het webcomponent verzendt deze bubbelende CustomEvents (de engine biedt dezelfde functionaliteit via de on*-callbacks in de tabel hierboven):

GebeurtenisDetailWordt geactiveerd wanneer
michi-vz:highlightstring[]de hover-markering verandert
michi-vz:colormappingRecord<string, string>een kleurmapping wordt gegenereerd
michi-vz:dataprocessedChartContextdata (opnieuw) wordt verwerkt
michi-vz:datawarningDataWarning[]invoerwaarschuwingen worden gedetecteerd

getContext()

mountRadarChart(el, props).getContext() retourneert een renderer-onafhankelijke RadarChartContext (gestructureerde statistieken + een deterministische samenvatting in gewone taal + een a11y-tabel). Zie LLM-context.

Bron

Eigenschappen zijn getypeerd als RadarChartProps in @michi-vz/core.