I use Windows 7 x64, Qt 5.6, Visual Studio 2015, QCustomPlot 1.3.2. I need to draw temperature graph from a sensor (real time). I receive temperature value every 500 ms (frequency
= 2 Hz). What settings should I apply to QCustomPlot
instance in order to have the last values received during time_period
= 10 minutes?
Here is a fragment of renewal slot:
double key = QDateTime::currentDateTime().toMSecsSinceEpoch() / 1000.0;
custom_plot_->graph(0)->addData(key, value);
custom_plot_->graph(0)->removeDataBefore(old_items_count);
custom_plot_->xAxis->setRange(key + some_delta, old_items_count, Qt::AlignRight);
What are the formulas for variables old_items_count = func1(time_period, frequency)
and some_delta = func2(time_period, frequency)
?
Official demo contains the following values: old_items_count = 8
, some_delta = 0.25
.
If your xAxis
is in seconds, in order to have a constant range of 10 minutes (600 seconds) you will need to set its range as follows:
custom_plot_->xAxis->setRange(key + some_delta, 600, Qt::AlignRight);
Where the value of some_delta
is up to you. Take a look at the QCPAxis Class Reference.