ChartToolbar
chartToolbar · Charts · interactive
Charts: a scale, its ticks, and a line or area drawn from data.
Import
#include "gbui/widgets/chart.hpp"Example
Nothing is downloaded until you press it.
bool chartToolbar(Ui& ui, const Interaction& input, std::string_view id, ChartView& view, const ChartToolbarOptions& options = {});The buttons ApexCharts puts in the corner of a chart: zoom in, zoom out, and put it back. A row of ordinary buttons over the caller's own ChartView, and nothing else — which is why it is a component rather than an option on the chart. It has no idea which chart it belongs to, so one row can drive a group of them the same way one view already zooms a price and its volume together, and a caller who wants it somewhere other than the top right corner simply puts it there. The gestures are the primary way in and this is the secondary one, for the same reason a map has both: a sweep says which range, and these say a bit more — and only one of the two can be pressed by someone who has already lost the thread of where they are. Returns true on any frame the view moved.
API
ChartToolbarOptions
| Option | Type | Default | What it does |
|---|---|---|---|
zoomIn | bool | true | Which of the three buttons the strip carries. All of them by default; drop the ones a chart has no room for. |
zoomOut | bool | true | As above. |
reset | bool | true | Puts the whole series back. Disabled while it already is whole, because a button that does nothing is worse than one that is not there — the reader presses it and learns nothing about why. |
step | double | 0.4 | How much of the window a press takes off, as a fraction of it. 0.4 rather than a half: two presses should not lose 75% of the data, and a reader who wants that has the sweep, which says exactly what to keep. |
minSpan | double | 0.02 | The narrowest the view may get, as a fraction of the whole. The same floor BrushOptions uses, so the two controls agree about how far in a reader is allowed to go. |
variant | ButtonVariantPrimary · Secondary · Ghost · Danger | ButtonVariant::Secondary | How the buttons are drawn. Secondary by default, which gives them a surface and an outline: three bare glyphs floating in a card header read as marks rather than as controls, and a reader has to try one to find out it can be pressed. Ghost is the bare version, for a toolbar that sits on top of the plot where a surface would be in the way. |
height | float | 30.0f | The buttons are square, so this is their size. |
iconSize | float | 17.0f | Bigger than a button with a label would use: the glyph is the whole button here, and at fourteen pixels in a thirty-pixel square it reads as a mark stranded in the middle of a box. |