Chart.h header
#include <ew/core/Chart.h>
Namespace ew::core
Chart class
class ew::core::Chart
A chart: a titled visualization of tabular data as bars, lines, a filled area, or a pie. A Chart is a first-class content object, so charts are saved with the project, listed, searched, embedded in prose by title (an ![[…]] marker naming the chart, like any other embeddable object), shared through a library, and undone/redone like anything else. Rendering lives in the desktop layer (Qt Charts) so the core stays GUI-free; a Chart holds only the data and the presentation choices.
Members
ew::core::Chart::Chart(ContentId id, QString title)
Creates an empty bar chart with identity id and the given title.
const QString & ew::core::Chart::title() const
The chart's display name (e.g. "Chapter word counts").
void ew::core::Chart::setTitle(QString title)
Sets the chart's display name.
ChartKind ew::core::Chart::kind() const
How the data is drawn.
void ew::core::Chart::setKind(ChartKind kind)
Sets how the data is drawn.
const std::vector< QString > & ew::core::Chart::categories() const
The category (x-axis) labels shared by every series; also the pie-slice labels.
void ew::core::Chart::setCategories(std::vector< QString > categories)
Sets the category (x-axis) labels.
const std::vector< ChartSeries > & ew::core::Chart::series() const
The data series drawn on the chart (a pie uses only the first).
void ew::core::Chart::setSeries(std::vector< ChartSeries > series)
Sets the data series drawn on the chart.
const QString & ew::core::Chart::valueAxisTitle() const
The value-axis (y) title; ignored by a pie chart.
void ew::core::Chart::setValueAxisTitle(QString title)
Sets the value-axis (y) title.
const QString & ew::core::Chart::categoryAxisTitle() const
The category-axis (x) title; ignored by a pie chart.
void ew::core::Chart::setCategoryAxisTitle(QString title)
Sets the category-axis (x) title.
ChartSeries struct
struct ew::core::ChartSeries
One named data series on a Chart: a value per chart category, so values[i] pairs with the chart's categories[i]. A series shorter than the category list reads as 0 for the missing tail.
Members
QString ew::core::ChartSeries::name
The series' display name (shown in the legend), e.g. "Words written".
std::vector<double> ew::core::ChartSeries::values
The value for each category, in category order.
bool ew::core::ChartSeries::operator==(const ChartSeries &other) const =default
Defaulted equality comparison.
Enumerations
enum class ChartKind { Bar, Line, Area, Pie }
The visual form a Chart draws its data in.
Functions
std::optional< ChartKind > ew::core::chartKindFromToken(QStringView token)
Parses a chart kind from its serialization token; std::nullopt if unrecognized.
QString ew::core::toToken(ChartKind kind)
Returns the stable serialization token for kind (e.g. "bar").