Skip to content

RadarChart

radarChart · Charts · interactive

Charts: a scale, its ticks, and a line or area drawn from data.

Import

cpp
#include "gbui/widgets/chart.hpp"

Example

Nothing is downloaded until you press it.

cpp
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

OptionTypeDefaultWhat it does
scaleScale0.0, 0.0Fixed 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.
autoScalebooltrue
tickCount optionalstd::optional<int>
categoriesstd::vector<std::string>One name per axis, drawn outside its spoke. Fewer than there are values leaves the rest unlabelled rather than renumbering them.
sizefloat240.0fThe whole chart's box, labels included.
gridRadarGrid
Web · Polygon · None
RadarGrid::WebWhat is drawn behind the data: a mesh, shaded bands, or nothing.
labelRoomfloat52.0fRoom between the outermost ring and the edge, for the names. Zero draws none and gives the web the whole box.
fillAlphafloat0.1fShading 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.
markerRadiusfloat3.0fA dot at each vertex. Zero draws none.
hoverbooltrue
valueFormatstd::string_view"%.0f"Printed in the readout; "%.0f" style, as std::snprintf takes.
tooltipChartTooltip
legendChartLegend
namestd::string_viewWhat 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.

Released under the LGPL-3.0-or-later licence.