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

Message ListMessage List     Post MessagePost Message

  How to draw a scatter diagram that has dynamically changed data source?
Posted by HuiminQi on Jan-27-2012 08:24
Dear ChartDirector support,

The project I am working on requires display a set of data in Scatter diagram. The number of data items keeps increasing by 1 as long as the software receives a interrupt reporting "new data" comming. We need to display all the data in the same Chart. The data set size could be large and unknown.

I follows the sample codes and be able to disply the scatter diagram successfully. Every time I pass the entire data array to the _xychart object than call makeImage(), even only one data is new. The problem I have is the performance. Sometime my drawing module misses some interrupts and could not show all the data items on the screen.

Is there any way to handle my case? Let me you if you need more info.

Thanks in advance.

Huimin

  Re: How to draw a scatter diagram that has dynamically changed data source?
Posted by Peter Kwan on Jan-28-2012 23:58
Hi HuiminQi,

Passing the entire data array to ChartDirector by itself should not have any performance impact. The majority of the CPU is used in makeImage (updating the chart and the screen), which is required when the chart changes. In a typical chart, the update may require around 20 to 100ms. Note that if you have a lot of points, we suggest you do not enable image maps (that is, do not use getHTMLImageMap). It is because for large number of points, the image map may consume significant more CPU than the chart itself.

In any case, I think updating the chart should not affect your interrupts. The suggested code structure is like the followings:

(1) In your interrupt handler, please read your new data, and append them to the data array. Do not draw or update the chart in the interrupt handler.

(2) In your main GUI thread, please set a timer to update the chart. For example, the timer may "attempt" to update the chart once per second. In other words, every one second, your timer can check if there is new data. If there is new data, update the chart.

Because the timer runs in the GUI thread, and the chart is generated in the main GUI thread, it should not affect the interrupts for collecting data. (I assume the interrupts you use for collecting data should have higher priority than the GUI thread.) In general, the data collection code and the chart update code should run separately, and not in the same routine.

Hope this can help.

Regards
Peter Kwan