Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How to get scrolling horizontal labels on a dynamic QChart? (Qt5.7.0)
Peter_Du last edited by
I have a regular QChart (Qt v5.7.0) in a QChartView widget. I've added a QDateTimeAxis for the horizontal axis, and a QValueAxis for the vertical axis. I've added a QLineSeries to the chart, and I periodically append points to the series, using the toMSecsSinceEpoch() of the arrival time as the X value for each point, and at the same time I change the range of the X axis (so that the max is now, and the min is now less 60 seconds). I also remove values from the series once there are enough of them to fill the range of the X axis.
It produces the effect of having the signal appear on the right hand edge of the chart and then scroll nicely across the chart and then disappear off the left hand edge. While it is happening, the major vertical gridlines are fixed, with the time label under each gridline updating as time passes. This is acceptable, but I would like to be able to have the gridlines and the labels appear at the right hand edge and scroll across the chart with the signal (so that the label is fixed once it appears). Can anyone suggest how I might achieve this? I am a newcomer to Qt, so feel free to explain very basic concepts if needed.
Using the PyQt bindings.