RadarChart
radarChart · Charts · interactive
Charts: a scale, its ticks, and a line or area drawn from data.
Import
#include "gbui/widgets/chart.hpp"Example
ChartResult radarChart(Ui& ui, const Interaction& input, std::string_view id, const std::vector<Series>& series, const RadarOptions& options = {});One value per axis, per series, on spokes around a common centre. The chart for a profile — a handful of measures that belong together and are compared as a shape rather than read off one at a time: a skills assessment, a wine's tasting notes, one machine's five utilisation figures against another's. Everything it is good at falls apart past about eight axes, where the polygon stops being a shape and becomes a scribble. series is the same Series every other chart here takes; each value is a spoke, in order, starting at twelve o'clock and going clockwise. Hit testing is by angle, so a reader pointing anywhere along a spoke means that axis — the same rule the bars use for a category, for the same reason.
API
RadarOptions
| Option | Type | Default | What it does |
|---|---|---|---|
scale | Scale | 0.0, 0.0 | Fixed bounds. Left alone the chart takes them from the data — and always from zero, whatever the data says. A radar is read as an area, and area from a non-zero baseline is the same lie a truncated bar tells, told about five axes at once: two profiles a hair apart become one enormous and one tiny. |
autoScale | bool | true | |
tickCount optional | std::optional<int> | ||
categories | std::vector<std::string> | One name per axis, drawn outside its spoke. Fewer than there are values leaves the rest unlabelled rather than renumbering them. | |
size | float | 240.0f | The whole chart's box, labels included. |
grid | RadarGridWeb · Polygon · None | RadarGrid::Web | What is drawn behind the data: a mesh, shaded bands, or nothing. |
labelRoom | float | 52.0f | Room between the outermost ring and the edge, for the names. Zero draws none and gives the web the whole box. |
fillAlpha | float | 0.1f | Shading inside a series' polygon, when the series carries no fillAlpha of its own. Filled by default, where a line chart is not. A line is read along, and shading under two of them buries the lower one; a radar is read as a shape, and an unfilled one is a wire outline the eye has to close for itself. Lower than the 0.2 the web charting libraries settle on, and deliberately: the painter composites in linear light, where the same number covers roughly twice as much as it does in a browser blending sRGB directly. |
markerRadius | float | 3.0f | A dot at each vertex. Zero draws none. |
hover | bool | true | |
valueFormat | std::string_view | "%.0f" | Printed in the readout; "%.0f" style, as std::snprintf takes. |
tooltip | ChartTooltip | ||
legend | ChartLegend | ||
name | std::string_view | What the chart is of — "Revenue by month". A chart is the one thing on a screen a reader gets nothing from: the shapes carry all of it, and the numbers behind them are the caller's. A name and a Figure role are the least that makes it navigable, and they are not the whole answer — see the note in docs/reference/accessibility. |