Project

General

Profile

Actions

Support #8732

open

Continuous Plotting of Live data on WCartesianChart

Added by Someshwar DK almost 3 years ago. Updated almost 3 years 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!

Actions #1

Updated by Korneel Dumon almost 3 years ago

Hi,

I image your live data is being generated on the server. To show it live in the browser you need to use the server-push mechanism. You can find some documentation here:
https://www.webtoolkit.eu/wt/doc/reference/html/classWt_1_1WApplication.html#ad9631ca64e68d30d40cb49c90e55223d

Other options are to use a periodic WTimer to refresh your table, or a refresh-button in the UI.

Actions

Also available in: Atom PDF