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. I can not display two QLineSeries
Forum Updated to NodeBB v4.3 + New Features

I can not display two QLineSeries

Scheduled Pinned Locked Moved Unsolved General and Desktop
1 Posts 1 Posters 226 Views
  • 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.
  • SuppS Offline
    SuppS Offline
    Supp
    wrote on last edited by
    #1

    In this code snippet, I'm trying to display a graph with two series. For faster output, I delete, fill in the Series, and then add them back. The problem is that when you delete and add Series 2 at the same time is not displayed.

    • Series 1 --- This is a normal random function.
    • Series 2 --- level 0, for the test at the moment 400.

    In this case, only Series1 will be displayed:

    void MainWindow::_drawGraphic(QVector<double> dataArray, const double 
                      &minValueOfDataArray, const double &maxValueOfDataArray)
    {
    //Вывод графика
        Series1->clear();
        Series2->clear();
    
        Chart1->removeSeries(Series1);
        Chart1->removeSeries(Series2);
    
        for(int i=0; i<dataArray.size()-1; i++)
        {
            Series1->append(i, dataArray[i]);
            Series2->append(i, 400);
        }
    
        axisX->setRange(firstCount, secondCount);
        axisY->setRange(minValueOfDataArray, maxValueOfDataArray);
        axisZero->setRange(minValueOfDataArray, maxValueOfDataArray);
        Chart1->addSeries(Series1);
        Chart1->addSeries(Series2);
    }
    

    [Wrong work]:

    enter image description here

    If I delete only Series1, then everything will work correctly and Series2 will also appear, but the output will be very slow, and for big data the program will completely fall:

    //Вывод графика
        Series1->clear();
        Series2->clear();
    
        Chart1->removeSeries(Series1);
        //Chart1->removeSeries(Series2);
    
        for(int i=0; i<dataArray.size()-1; i++)
        {
            Series1->append(i, dataArray[i]);
            Series2->append(i, 400);
        }
    
        axisX->setRange(firstCount, secondCount);
        axisY->setRange(minValueOfDataArray, maxValueOfDataArray);
        axisZero->setRange(minValueOfDataArray, maxValueOfDataArray);
        Chart1->addSeries(Series1);
        //Chart1->addSeries(Series2);
    

    [Correct work 'Green Line = Series2']:

    enter image description here

    Have any suggestions or solutions? Thank you in advance.

    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