@Perdrix said in Updating a Chart when appending to a Line Series.:
The only way I have (so far) managed to get a Chart to refresh when adding a new point is to remove the current line series (without deleting it), append the new point to the series, and re-add the line series.
I have not used QCharts(!), but that would sound very surprising. You would not be able to e.g. append new points over time and have the chart display them, which does not sound right.
I note that, for example, QXYSeries has signals void QXYSeries::pointReplaced(int index) or void QXYSeries::pointsReplaced() (and similarly for adding or removing points). (Note these are signals on the series, not on the whole chart.) One/I would have thought this would get used to cause the chart view to be refreshed? You might attach your own slots to some of these to check they are indeed being emitted. I presume QChartView is supposed to hook onto those signals itself.
I have come across How to update/redraw QChart after data is added to QLineSeries?
Appending a value to QLineSeries using the operator << or the append method should repaint the graph. If it does not happen form some reason, you could trying calling the repaint method on the QChartView.
and
void QWidget::repaint() Repaints the widget directly by calling paintEvent() immediately, unless updates are disabled or the widget is hidden. We suggest only using repaint() if you need an immediate repaint, for example during animation. In almost all circumstances update() is better, as it permits Qt to optimize for speed and minimize flicker.
Also read Qt Chart is not updated after updating the series in this forum, where the OP says just as you do. And at the end the repsonder says:
ChartView should handle redraw and everything for you.
Finally I also encountered Updating QLineSeries in Chart doesnt work at all. A suggestion there is that it is a axes issue, do you use something like createDefaultAxes()? I think the "point" here [excuse the pun!] is that if the new point now lies outside of the current axes range it might be regarded as "off screen" and so need some extra work to get the axes rescaled to view.
I cannot comment on setPointConfiguration(), that is a call introduced in Qt6.x so relatively new.
P.S.
See also https://forum.qt.io/topic/145986/qchart-line-series-not-shown/3.