Skip to content

ChartToolbar

chartToolbar · 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
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

OptionTypeDefaultWhat it does
zoomInbooltrueWhich of the three buttons the strip carries. All of them by default; drop the ones a chart has no room for.
zoomOutbooltrueAs above.
resetbooltruePuts 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.
stepdouble0.4How 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.
minSpandouble0.02The 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.
variantButtonVariant
Primary · Secondary · Ghost · Danger
ButtonVariant::SecondaryHow 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.
heightfloat30.0fThe buttons are square, so this is their size.
iconSizefloat17.0fBigger 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.

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