Hello,

I am using the realtime plot example: https://www.qcustomplot.com/index.php/demos/realtimedatademo. In my application there is the possibility to "reset" the plot without exiting the program. So when clicking on reset, the timer (QElapsedTimer) gets invalidate and the static lastPointKey is set to zero, else it would count further because it is static:

void Plotter::updatePlots(float data){

    static double lastPointKey = 0;
    
    // This if statement is true, when the reset button is clicked 
    if(!timer.isValid()){
        timer.start();
        lastPointKey = 0;
    }

    //Calculate two new data points
    double key = timer.elapsed()/1000.0;

    if (key-lastPointKey > 0.002) // at most add point every 2 ms
    {
       // plotting the points here
       // [...]
       //Same as in the example
        lastPointKey = key;
    }
    ui->plot_acceleration->replot();

}

When I start the program for the first time, everything is fine and the plot looks like this: https://ibb.co/Bjg1kcJ
However, when I reset the plot i.e. after 1 minute and then start again, it seems that the plotted points are plotted more then once and it loks like that: https://ibb.co/4dmVgZB but it should be looking like the first screenshot. The weird thing is now,
After the one minute has passed (duration of the first plot), the plot is displayed correctly again. So I think it could be the variable lastPointKey. Do anyone have any suggestions how to fix this?