QCustomPlot Discussion and Comments

Realtime plotting with less flickeringReturn to overview

I wants to draw real time data like below link
https://www.youtube.com/watch?v=wuwBfSpVEgw
The dat return in every 200millisecond and i wants to plot like this

Any code snippet for doing the same using QcustomPlot

easy

const int MaxCount = 101;
const int GapCount = 10;
static int CurrentIndex = 0;

void MainWindow::setupEcgDemo(QCustomPlot *customPlot)
{
    customPlot->xAxis->setRange(0, MaxCount - 1);
    customPlot->yAxis->setRange(0, 1000);
    auto *graph = customPlot->addGraph();

    for (int i = 0; i < MaxCount; ++i)
        graph->addData(i, QRandomGenerator::global()->bounded(1000));

    connect(&dataTimer, &QTimer::timeout, [customPlot, graph](){
            *(graph->data()->begin() + CurrentIndex) = QCPGraphData(CurrentIndex, QRandomGenerator::global()->bounded(1000));
            int gapIndex = CurrentIndex;
            CurrentIndex = (CurrentIndex + 1) % MaxCount;

            for (int i = 0; i < GapCount; ++i) {
                gapIndex = (gapIndex + 1) % MaxCount;
                *(graph->data()->begin() + gapIndex) = QCPGraphData(gapIndex, qQNaN());
            }
        customPlot->replot();
    });
    dataTimer.setInterval(100);
    dataTimer.start();
}

Thank you for the quick reply.
Is it possible to change the colour of the line forsome particular value while plotting

yes, see QCPSelectionDecorator