qt chart "Can not add series. Series already on the chart."
Solved
General and Desktop
-
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.
-
@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...