Project

General

Profile

Support #8732

Continuous Plotting of Live data on WCartesianChart

Added by Someshwar DK about 1 year ago. Updated about 1 year ago.

Status:
New
Priority:
Normal
Assignee:
Target version:
-
Start date:
06/25/2021
Due date:
% Done:

0%

Estimated time:

Description

Hello,

I am currently trying to display incoming live data on a WCartesianChart widget. I get two values to plot, date/time on X-axis and the sensor data on Y-axis.

I have created a WStandardItemModel with 32 rows and 2 columns and added it to chart as below,

std::shared_ptr<WStandardItemModel> model = std::make_shared<WStandardItemModel>(32, 2);
std::unique_ptr<NumericItem> prototype = std::make_unique<NumericItem>();

model->setItemPrototype(std::move(prototype));
model->setHeaderData(0, WString("X"));
model->setHeaderData(1, WString("Y"));

auto chart = this->addWidget(std::make_unique<WCartesianChart>());
chart->setModel(model);

Finally, I have created a WDataSeries and added it to chart as below,

std::unique_ptr<WDataSeries> s = std::make_unique<WDataSeries>(1, SeriesType::Line);

chart->addSeries(std::move(s));

With above code, I am able to plot only 32 sensor values, but beyond that, the chart stops loading any value. Because this is live data, what code changes should I do to keep loading new values so that the chart keeps plotting the incoming live data?

Any inputs or code examples to solve the plotting of live data are highly appreciated!

Also available in: Atom PDF