Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why my QChartView with QlineSeries finish with line from last data to the first one?

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

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 483 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    filipdns
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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 ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      F 1 Reply Last reply
      1
      • SGaistS SGaist

        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 ?

        F Offline
        F Offline
        filipdns
        wrote on last edited by
        #3

        @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().

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved