|
XYChart.setSize() question |
Posted by Lee Baxter on Jul-14-2009 19:49 |
|
Hi,
Sorry to bother you all again; within the system that I'm producing, there is a lot of data being plotted, so I'm looking to optimize it whereever possible.
I'm extending the ChartViewer control so that it resizes my chart when the viewer is resized (as I have resizable windows). I've came across XYChart.setSize() in the documentation and have a few questions;
1.> When I use setSize(), will it keep the data currently in my chart?
2.> Will I need to set the plot area again, or will it automatically adjust it?
Cheers, and thanks again for everyones help!
Lee. |
Re: XYChart.setSize() question |
Posted by Peter Kwan on Jul-15-2009 01:21 |
|
Hi Lee,
Once you draw the chart (eg. using BaseChart.makeImage), the chart cannot be changed any more. So the setSize will have no effect if your chart has already been displayed. If you want to change the chart, you would need to re-create a new XYChart object.
We have done a lot of performance testing for our code. One of our findings is that the overhead to set up the XYChart object and entering data to it is negligible compared to the time to redraw the chart.
Because you always need to redraw the chart, so whether you re-create the XYChart or simply call setSize (if this is possible at all) does not matter to performance. For this reason, we have not designed ChartDirector to allow the XYChart to be changed at all after makeImage.
Furthermore, resizing a chart is not like resizing a photograph. It is more like resizing a geographic map, in which the number of labels, number of grid lines, etc, may change. See my other message:
http://www.chartdir.com/forum/download_thread.php?site=chartdir&bn=chartdir_support&thread=1247565500#N1247591184
From experience, to optimize resizing, you may note the following techniques:
(a) If the user can drag the window to resize it, do not create the image map when the window is still being dragged. For complex charts, the image map can have a much higher overlap than the chart itself. When the window is still being dragged, there is no chance the user can click on the chart or access tooltips, so the image map is useless. Create the image map only when the user finishes dragging (drops the mouse) or if the mouse actually enters the chart (can be detected using mouse move events).
(b) When your redraw the chart, make sure you do not reload the data from the database. The data should be retrieved from the database only once, and be stored in variables, so they can repeatedly be used to redraw the chart.
Hope this can help.
Regards
Peter Kwan |
|