Skip to main content

AreaChart

#include "toolkit/charts/area_chart.hpp"

A multi-series filled line (area) chart with grid, legend, hover tooltips, and pan & zoom (see the charts overview). Inherits Widget.

AreaChart screenshot

Data types​

struct AreaDataPoint { float x, y; std::string label; };
struct AreaSeries { std::string name; Color line_color; Color fill_color; std::vector<AreaDataPoint> points; };

Example​

auto chart = std::make_unique<toolkit::AreaChart>();
chart->set_y_unit_suffix("%");
chart->add_series({"CPU", toolkit::Color::rgb(0.9f, 0.3f, 0.2f),
toolkit::Color::rgba(0.9f, 0.3f, 0.2f, 0.3f), {{0, 20, ""}, {1, 45, ""}}});

Construction​

AreaChart();

API​

MemberDescription
add_series(AreaSeries) / clear_series() / series_count()Manage data series
set_title(std::string)Chart title
set_x_label(std::string) / set_y_label(std::string)Axis labels
set_y_unit_suffix(std::string)Appended to Y-axis tick labels, e.g. "%" → "20%"
set_show_grid(bool) / set_show_legend(bool)Toggle chrome
set_auto_range(bool)Auto-fit the Y range to data (default: on)
set_y_range(float min, float max)Fix the Y range explicitly (disables auto-range)

Callbacks​

CallbackDescription
on_hover — std::function<void(size_t series_idx, size_t point_idx)>Fired as the pointer hovers a data point