Qt Chart is not updated after updating the series
-
I don't see the new point out of bounds of your axis so that is good. From what I understand when appending the series you should be good as long as it is the pointer to the correct series. Assuming the discrepancy for scatter series and line series is an artifact of you swapping between line and scatter series for troubleshooting, are you constantly running something without allowing the event handler to process? Try adding QApplication::processEvents(); after your repaint.
-
I don't see the new point out of bounds of your axis so that is good. From what I understand when appending the series you should be good as long as it is the pointer to the correct series. Assuming the discrepancy for scatter series and line series is an artifact of you swapping between line and scatter series for troubleshooting, are you constantly running something without allowing the event handler to process? Try adding QApplication::processEvents(); after your repaint.
-
Are you sure you are sending it a pointer to the correct series? You are appending your line series but you are attaching a scatter series.
-
I trust you I was just making sure. I really can't think of anything else given what I see from your code.
@MrShawn . You are right, you once suggested. Maybe the only updating the series did not update the pointer .I am not sure thought. But his fixed the problem. Every time I update the series, I have to remove the series and again add the series. I do not understand why is like this.
chart->removeSeries(scatterseries); chart->addSeries(scatterseries);
-
I think on my first code I wrote for Charts I did a similar thing. As I got used to QCharts and how things were working I stopped doing that. Looking back at some code I do recently, where I pull data from DB and populate the series from that data. I can confirm that you should not have to do that. That is why my suspicion is that the series you were appending is not truly on the chart, and by adding that code it does now actually add it.
Anyways if it works it works.
-
I think on my first code I wrote for Charts I did a similar thing. As I got used to QCharts and how things were working I stopped doing that. Looking back at some code I do recently, where I pull data from DB and populate the series from that data. I can confirm that you should not have to do that. That is why my suspicion is that the series you were appending is not truly on the chart, and by adding that code it does now actually add it.
Anyways if it works it works.
-
seen https://doc.qt.io/qt-5/qxyseries.html#replace-5 ?
even if you are doing it just for one point - by destroying and creating a series over and over you do this anyhow. has to be quicker/better.
I belive that also invokes
https://doc.qt.io/qt-5/qxyseries.html#pointsReplacedChartView should handle redraw and everything for you.
-
J JonB referenced this topic on