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. qt chart "Can not add series. Series already on the chart."
Forum Updated to NodeBB v4.3 + New Features

qt chart "Can not add series. Series already on the chart."

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.2k 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.
  • I Offline
    I Offline
    IknowQT
    wrote on last edited by
    #1
    QChart* QTemperatureChart::createSplineChart()
    {
    	m_pChart = new QChart();
    	m_pChart->setTitle("Spline chart");
    
    	// The lower series initialized to zero values
    	QString name("Series ");
    	int nameIndex = 0;
    
    	m_pSplineSeries = new QSplineSeries(m_pChart);
    	
    	m_pChart->addSeries(m_pSplineSeries);
    	m_pChart->createDefaultAxes();
    	m_pChart->axes(Qt::Vertical).first()->setRange(0, 10);
    
    	return m_pChart;
    }
    
    void QTemperatureChart::UpdateChart(QPointF point)
    {
    	int randomx = QRandomGenerator::global()->bounded(0, 100);
    	int randomy = QRandomGenerator::global()->bounded(0,100);
    	
    	//QSplineSeries series(m_pChart);
    	m_pSplineSeries->append(m_pSplineSeries->count(), randomy);
    	m_pChart->addSeries(m_pSplineSeries);
    	m_pChart->axisX()->setRange(0, m_pSplineSeries->count());
    	m_pChart->axisY()->setRange(0, 100);
    
    	qDebug() << "UpdateChart(QPointF point) : " << m_pSplineSeries->count();
    	m_pChartViewer->update();
    }
    

    I was trying to draw a chart, and there was a problem, and I wanted to find out how to solve it.

    If you append and add a series to update the chart in real time...
    "Can not add series. Series ready on the chart."
    If you add series again after the removeSeries, the chart looks weird.

    Let me know if there's any problem with my code.

    jsulmJ 1 Reply Last reply
    0
    • I IknowQT
      QChart* QTemperatureChart::createSplineChart()
      {
      	m_pChart = new QChart();
      	m_pChart->setTitle("Spline chart");
      
      	// The lower series initialized to zero values
      	QString name("Series ");
      	int nameIndex = 0;
      
      	m_pSplineSeries = new QSplineSeries(m_pChart);
      	
      	m_pChart->addSeries(m_pSplineSeries);
      	m_pChart->createDefaultAxes();
      	m_pChart->axes(Qt::Vertical).first()->setRange(0, 10);
      
      	return m_pChart;
      }
      
      void QTemperatureChart::UpdateChart(QPointF point)
      {
      	int randomx = QRandomGenerator::global()->bounded(0, 100);
      	int randomy = QRandomGenerator::global()->bounded(0,100);
      	
      	//QSplineSeries series(m_pChart);
      	m_pSplineSeries->append(m_pSplineSeries->count(), randomy);
      	m_pChart->addSeries(m_pSplineSeries);
      	m_pChart->axisX()->setRange(0, m_pSplineSeries->count());
      	m_pChart->axisY()->setRange(0, 100);
      
      	qDebug() << "UpdateChart(QPointF point) : " << m_pSplineSeries->count();
      	m_pChartViewer->update();
      }
      

      I was trying to draw a chart, and there was a problem, and I wanted to find out how to solve it.

      If you append and add a series to update the chart in real time...
      "Can not add series. Series ready on the chart."
      If you add series again after the removeSeries, the chart looks weird.

      Let me know if there's any problem with my code.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by jsulm
      #2

      @IknowQT said in qt chart "Can not add series. Series already on the chart.":

      m_pChart->addSeries(m_pSplineSeries);

      Why do you add same series again? Just append new values to the series...

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      2

      • Login

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