Why my QChartView with QlineSeries finish with line from last data to the first one?



  • Hello, using textfile to insert data to my series with append, I have the last point = firstline, do you know why and how can I remove it?

    void MainWindow::on_actionGraph()
    {
    
        chartView->repaint();
        QFile fileOut("d:/Temp_Hygro.txt");
        fileOut.open(QIODevice::ReadWrite | QIODevice::Text);
    
    
        while( !fileOut.atEnd())//loop until end of QTextStrem
        {
                QString line=fileOut.readLine();
                if(line.size()>=51)
                {
                    date=line.split(":")[0];
                bool ok = false;
                temp=line.split(":")[2].toDouble(&ok);
                hygro=line.split(":")[4].replace(";","").toDouble(&ok);
                axisX->append(date,line_count);
                axisYtemp->append(QString::number(temp),temp);
                axisYhygro->append(QString::number(hygro),hygro);
    
                temperature->append(line_count,temp);
                qDebug()<<line_count<<" "<<temp;
    
                hygrometrie->append(line_count,hygro);
                
    
                }
                line_count++;
    
        }
    line_count=0;
        fileOut.close();
        fileOut.remove();
        const QByteArray data= m_serial->readAll();
        readData(data);
    }
    

    0_1557384775812_graph.png

    Thank you for your help


  • Lifetime Qt Champion

    Hi,

    You don't check whether your conversions are working properly so you might end with an invalid value. Or maybe the last value of your input is the same as the fist ?



  • @SGaist the problem was my upload add all values from file each time then add the new value, then to solve the problem, just make serie.clear().


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.