ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Updating graph from live data stream
Posted by Rand on Jun-17-2020 02:05
We are plotting real time data as it comes in (max rate 4x second).  Every time a new data point arrives we have to delete the existing BaseChart and create a new one.  Is there a way to keep the existing BaseChart object and add a new data point to it?

  Re: Updating graph from live data stream
Posted by Peter Kwan on Jun-17-2020 13:15
Hi Rand,

In ChartDirector, you would need to create a new chart to update the chart. That means you do not need to write additional code to update the chart, because it is the same code that creates the chart in the first place. The keeps the code simple and in practice it is just as fast as comparing to re-using the BaseChart.

Creating the BaseChart takes negligible CPU time comparing to redrawing the chart image on screen. When a new data point arrive, many things on the chart can change. For example, the axis scale may need to be extended to accommodate the data point. That means the entire chart would need to be redrawn even if you can reuse the BaseChart.

In ChartDirector, what you need to to add a new data point to your data array, then call the "drawChart" subroutine to redraw the chart.

You mentioned the data rate is 4x seconds. I assume it means 4 updates per second. At this rate you can just update the chart when new data arrive.

If the rate is much higher, you can consider to update the data array and the chart display at different rates, or to run the data array update and chart update in different threads. We have customers that need to update the data 4000 times per second. In this case, the chart should be updated at a slower rate (like 10 updates per second), because it better fit human vision capabilities, and the computer cannot refresh the screen at such high rate anyway.

Regards
Peter Kwan