Fluent-Qt

Charts

LineChart

Shows how values change over time or order with lines.

Example

LineChart: Response time

Usage

Response time

Write points and labels into a ChartModel and call setModel(). addSeries() adds a second series for comparison.

#include <FluentQt/Charts.h>
using namespace fluent::charts;

auto* chart = new LineChart(this);
chart->setObjectName("chartPresentation");
chart->setMinimumHeight(420);
chart->setTitle("Response time");
chart->setSubtitle("Milliseconds · last 7 days");
auto* model = new ChartModel(chart);
model->setName("Primary");
const QStringList labels = {"Mon",        "Mon, 04:48", "Mon, 09:36", "Mon, 14:24", "Mon, 19:12", "Tue",
     "Tue, 04:48", "Tue, 09:36", "Tue, 14:24", "Tue, 19:12", "Wed",        "Wed, 04:48",
     "Wed, 09:36", "Wed, 14:24", "Wed, 19:12", "Thu",        "Thu, 04:48", "Thu, 09:36",
     "Thu, 14:24", "Thu, 19:12", "Fri",        "Fri, 04:48", "Fri, 09:36", "Fri, 14:24",
     "Fri, 19:12", "Sat",        "Sat, 04:48", "Sat, 09:36", "Sat, 14:24", "Sat, 19:12",
     "Sun"};
model->setPoints(
    {{0, 27},  {1, 32},  {2, 28},  {3, 34},  {4, 30},  {5, 36},  {6, 34},  {7, 32},
     {8, 41},  {9, 39},  {10, 37}, {11, 42}, {12, 46}, {13, 43}, {14, 40}, {15, 46},
     {16, 42}, {17, 47}, {18, 52}, {19, 48}, {20, 54}, {21, 59}, {22, 56}, {23, 61},
     {24, 57}, {25, 60}, {26, 58}, {27, 64}, {28, 59}, {29, 66}, {30, 62}},
    labels);
chart->setModel(model);
auto* secondary = new ChartModel(chart);
secondary->setName("Secondary");
secondary->setPoints(
    {{0, 14},  {1, 18},  {2, 16},  {3, 20},  {4, 17},  {5, 22},  {6, 20},  {7, 18},
     {8, 25},  {9, 23},  {10, 22}, {11, 26}, {12, 29}, {13, 27}, {14, 25}, {15, 28},
     {16, 26}, {17, 31}, {18, 34}, {19, 30}, {20, 35}, {21, 41}, {22, 38}, {23, 42},
     {24, 39}, {25, 43}, {26, 40}, {27, 44}, {28, 41}, {29, 46}, {30, 43}}, labels);
chart->addSeries(secondary);
chart->setValueSuffix(" ms");
chart->setYRange(0, 80);

fluent::charts::LineChart

Inherits ChartView

A dedicated line chart with its own bounded renderer.

Constructors

Inherited from fluent::charts::ChartView

Properties

ChartType chartType
Read chartType()Write setChartType()Notify chartTypeChanged()
QString title
Read title()Write setTitle()Notify titleChanged()
QString subtitle
Read subtitle()Write setSubtitle()Notify subtitleChanged()
QString valueSuffix

Suffix for value readouts, for example " ms" or "%"; does not rescale data.

Read valueSuffix()Write setValueSuffix()Notify valueSuffixChanged()
QString centerText
Read centerText()Write setCenterText()Notify centerTextChanged()
QString centerCaption
Read centerCaption()Write setCenterCaption()Notify centerCaptionChanged()
bool loading

Host-controlled presentation while preparing a snapshot; owns no worker task.

Read isLoading()Write setLoading()Notify loadingChanged()
bool autoYRange
Read isAutoYRange()Notify yRangeChanged()
bool legendVisible
Read isLegendVisible()Write setLegendVisible()Notify legendVisibleChanged()
int maximumPointCount
Read maximumPointCount()Write setMaximumPointCount()Notify maximumPointCountChanged()
int maximumFrameRate
Read maximumFrameRate()Write setMaximumFrameRate()Notify maximumFrameRateChanged()
bool autoRange
Read isAutoRange()Notify xRangeChanged()

Methods

void setModel(ChartModel* model)

Replaces series with one borrowed model; nullptr clears.

bool addSeries(ChartModel* model)

Adds a borrowed series, up to 32; duplicates are no-ops.

void setChartType(ChartType type)

Changes a generic ChartView; dedicated chart components keep their fixed type.

QString valueSuffix() const

Suffix for value readouts, for example " ms" or "%"; does not rescale data.

void setValueSuffix(const QString& suffix)

Suffix for value readouts, for example " ms" or "%"; does not rescale data.

bool isLoading() const

Host-controlled presentation while preparing a snapshot; owns no worker task.

void setLoading(bool loading)

Host-controlled presentation while preparing a snapshot; owns no worker task.

void setYRange(double minimum, double maximum)

Sets a finite increasing value range; percentage bars should use [0, 100].

void setMaximumPointCount(int count)

Total projection budget, [512, 65536], additionally limited by viewport width.

void setMaximumFrameRate(int rate)

Coalesces model update bursts at [1, 60] Hz; hidden views do no projection work.

void setXRange(double minimum, double maximum)

Sets a finite increasing X viewport; invalid ranges are ignored.

void setCurrentPoint(int series, int row)

Moves the data cursor without copying model data; -1 clears it.

int renderedPointCount() const

Number of cached representative points, after the last paint.

QImage exportImage(double scale = 1.0)

Renders the current logical layout at a pixel scale, without cursor or focus chrome.

QByteArray exportPng(double scale = 1.0)

Encodes exportImage as PNG; an empty result means failure.

QByteArray exportCsv(bool visibleRangeOnly = false) const

Exports original rows as UTF-8 CSV: series, name, x, y, label, unit.

void copyImage(double scale = 1.0)

Copies a PNG through the host clipboard, reporting actual completion.

void copyData(bool visibleRangeOnly = false)

Copies original CSV rows through the host clipboard.

Signals

void valueSuffixChanged(const QString& suffix)

Suffix for value readouts, for example " ms" or "%"; does not rescale data.

void loadingChanged(bool loading)

Host-controlled presentation while preparing a snapshot; owns no worker task.

void rangeActivated(int series, int first, int last)

Activates the displayed half-open source range; aggregate bars/slices keep their range.

Enumerations

enum ChartType
  • Line
  • Area
  • Bar
  • HorizontalBar
  • Pie
  • Donut
  • Scatter
  • Sparkline
Inherited from fluent::FluentElement

Methods

static void setTheme(Theme theme)

Updates the global theme and notifies active FluentElement instances.

static void setThemeDeferred(Theme theme)

Schedules a visible-first batched theme refresh without blocking the current interaction.

static Theme currentTheme()

Returns the currently active global theme.

static bool themeUsesDarkAppearance(Theme theme)

Returns whether a theme uses dark-backed chrome and material tokens.

static void refreshTheme()

Re-broadcasts the current theme to repaint after a design-token change.

static int themeGeneration()

Monotonic counter bumped on every theme change, for staleness checks.

Theme effectiveTheme() const

Resolves the theme used by this element, honoring an inherited QWidget override.

bool effectiveThemeUsesDarkAppearance() const

Returns whether this element's effective theme uses dark-backed chrome.

QJsonObject themeOverrides() const

Returns this element's authored overrides.

void clearThemeOverrides()

Restores all token fields to global theme defaults.

const Colors& themeColorsRef() const

Non-copying access to the active color set (for hot paint paths).

Material::AcrylicToken themeAcrylic() const

Material, elevation, and adaptive layout tokens.

QColor themeBackdrop(bool active) const

Window-chrome backdrop color for the given activation state.

virtual void onThemeUpdated()

Called after the global theme changes.

Enumerations

enum Theme

Global visual theme used when resolving design tokens.

  • Light = 0
  • Dark = 1
  • HighContrast = 2

Types and aliases

struct Colors

Design token snapshots returned to components.

Inherited from fluent::QMLPlus

Methods

AnchorLayout::Anchors* anchors()

Returns mutable anchors for the QWidget host.

void setState(const QString& name)

Applies a named state, or clears state when name is empty.

void addState(const QMLState& state)

Registers or replaces a named state definition.

void evaluateStates()

Reevaluates conditions; the first registered true condition wins.

QMLPlusRuntime* runtime()

Returns the lazy host-owned state observation object.

void setAnchors(const AnchorLayout::Anchors& anchors)

Replaces all host anchors and invalidates the parent layout.

void resetAnchors()

Clears all host anchors and invalidates the parent layout.

void addTransition(const StateTransition& transition)

Registers a state transition in precedence order.

void setBehavior(const char* propertyName, const PropertyAnimation& animation)

Sets the default animation for this host's managed property writes.

void clearBehavior(const char* propertyName)

Removes the default animation for future managed writes.

bool writeProperty(const char* propertyName, const QVariant& value)

Writes a host property through Behavior without removing its binding.

All inherited Qt members:QWidget