ChartDirector 7.1 (C++ Edition)

Real-Time Charts (Qt)


NOTE: This section describes Real-Time Charts for Qt only. For MFC, please refer to Real-Time Charts (MFC).

NOTE: For conciseness, some of the following descriptions only mention QChartViewer (for Qt Widgets applications). Those descriptions apply to QmlChartViewer (for QML/Qt Quick applications) as well.

In ChartDirector, a real-time chart may be achieved by simply redrawing the chart periodically.

Typically, a data buffer is used to store the data to be displayed in the chart. A data update routine updates the values in the buffer in real-time. A charting routine uses the data in the buffer to create the chart.

If the data update rate is not very fast (eg. once per second), one can simply redraw the chart immediately when the data buffer is updated.

If the data update rate is very fast (eg. 1000 times per second), a better design is to update the data buffer and the chart asynchronously. In this case, the data update routine can still update the data buffer as fast as it needs to. The charting routine updates the chart at a slower rate, such as a few times per second. Essentially, the charting routine is taking a "snapshot" of the data buffer a few times per second and displays them on screen.

To facilitate creation of real-time charts with fast update rate (faster than several times per second), the QChartViewer control contains built-in rate control features. It ensures there is at least 20ms (configurable using QChartViewer.setUpdateInterval) between two consecutive chart updates. This allows the GUI to remain smooth and responsive even with extremely fast chart update rate.

To use the rate control features of ChartDirector, instead of updating the chart directly, QChartViewer.updateViewPort may be used to trigger the viewPortChanged signal, and the chart is updated in the signal handler. QChartViewer will ensure there is at least 20ms between two viewPortChanged signals, and will delay the signal and merge multiple signals into one signal if necessary.