43 lines
1.7 KiB
C++
43 lines
1.7 KiB
C++
#pragma once
|
|
#include <plot/core/color.hpp>
|
|
#include <plot/core/types.hpp>
|
|
#include <plot/data/series.hpp>
|
|
#include <string>
|
|
|
|
namespace plot {
|
|
|
|
/// How a caller asks for a trace. The series pointer is borrowed and must outlive
|
|
/// the plot's use of it; `axis_x`/`axis_y` index the plot's x and y axis lists.
|
|
struct TraceDesc {
|
|
const data::Series* series = nullptr;
|
|
Color color = Color::hex(0x4FA3FF);
|
|
f32 width = 1.5f;
|
|
u32 axis_x = 0, axis_y = 0;
|
|
/// What the trace is called, for the legend. Empty means "do not list it", which
|
|
/// is the whole cost of a legend for a caller that never names one: the trailing
|
|
/// default is what keeps the five-field aggregate initialisation every existing
|
|
/// caller writes -- `{&series, colour, width, axis_x, axis_y}` -- working
|
|
/// unchanged, exactly as `AxisDesc`'s trailing format does (and, in a build with
|
|
/// `-Wextra`, warning-clean).
|
|
std::string name{};
|
|
};
|
|
|
|
/// A series bound to a colour, width and axis pair. The series pointer may be
|
|
/// null (a trace whose data has not arrived yet): every consumer skips such a
|
|
/// trace rather than dereferencing it.
|
|
struct Trace {
|
|
const data::Series* series = nullptr;
|
|
Color color = Color::hex(0x4FA3FF);
|
|
f32 width = 1.5f;
|
|
u32 axis_x = 0, axis_y = 0;
|
|
/// The legend's entry for this trace, empty when it has none. A name does not
|
|
/// make a trace drawable: the legend lists a trace only when it is visible, so a
|
|
/// null series is skipped there exactly as it is by every other consumer.
|
|
std::string name{};
|
|
|
|
/// True when the trace has a series with at least one sample to draw.
|
|
bool visible() const noexcept { return series != nullptr && series->size() > 0; }
|
|
};
|
|
|
|
} // namespace plot
|