DonutChart
donutChart · Charts · interactive
Charts: a scale, its ticks, and a line or area drawn from data.
Import
cpp
#include "gbui/widgets/chart.hpp"Example
cpp
DonutResult donutChart(Ui& ui, const Interaction& input, std::string_view id, const std::vector<Slice>& slices, DonutState& state, const DonutOptions& options = {});A donut, or a pie when thickness is 1. Proof that the canvas node carries more than polylines: each wedge is two arcs and two lines, and an arc is cubics. Nothing here is a special case in the painter — it is the same vector layer the icons ride on.
API
DonutOptions
| Option | Type | Default | What it does |
|---|---|---|---|
size | float | 150.0f | |
thickness optional | std::optional<float> | How thick the ring is, as a share of the radius. 1 is a full pie. Unset takes the design's. | |
padAngle optional | std::optional<float> | A gap between wedges, in degrees, so neighbouring colours do not merge. | |
startAngle | float | -90.0f | Where the first wedge starts. -90 puts it at twelve o'clock, which is where every reader expects a donut to begin. |
hoverGrow | float | 4.0f | The hovered wedge grows outward by this much. |
focusGrow | float | 10.0f | How much further a focused wedge pulls out of the ring. |
dimAlpha | float | 0.3f | What the wedges that were not singled out fade to. |
legend | bool | true | |
legendMaxHeight | float | kAuto | A ceiling on the legend before it scrolls, so a chart with forty contributors does not grow taller than the ring beside it. kAuto matches the donut. |
tooltip | ChartTooltip | The readout beside the hovered wedge. A donut's legend already names every slice, so this one is about the number — which the legend has no room for once there are more than a handful. | |
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. |