XY charts - dynamic data, drawing updated area only

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Gotcha
Posts: 7
Joined: Wed Oct 15, 2008 9:13 am

XY charts - dynamic data, drawing updated area only

Post by Gotcha » Wed Jan 28, 2009 10:02 am

Hi,
because we need to show dynamic data faster in graphs we decided to update JFreeChart sources. The reason why I post this here is that somebody can have the same problem with slow drawing of huge dynamic data.
The idea is very simple. Fire an event with desired information (changed dataset, updated rectangle in axis coordinates) and send it through all desired listeners up to JFreeChart where the updated rectangle must be converted to Java2D coordinates (this is the reason why the ChartRenderingInfo object is stored in JFreeChart as member). Also note that the converted rectangle must be merged with older one (which is stored in JFreeChart member) when the notify flag=false.

After that the changed area in Java2D coordinates is send via event to ChartPanel (or ChartComposite) and redraw is called with the dirty rectangle.

I've created an example and it seems that it works correctly. Changed files of JFreeChart 1.0.12 and example are here http://public.dataapex.com/JFreeChartMod.zip. All changes (I hope) are marked with DA_SPECIFIC comment.

It would be better to have something like this integrated to JFreeChart sources but it seems that it is too complicated to code it generally for all chart types.

Gotcha
Posts: 7
Joined: Wed Oct 15, 2008 9:13 am

Post by Gotcha » Wed Jan 28, 2009 10:11 am

I've forgotten to mention that the updated rectangle is always within plot area (inside axis) with full height now.

RichardWest
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA

Post by RichardWest » Wed Jan 28, 2009 6:50 pm

Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA

d_rambabu
Posts: 8
Joined: Mon Apr 14, 2008 8:36 am
Location: Hyderabad, India
Contact:

ETA?

Post by d_rambabu » Thu Feb 12, 2009 10:52 am

Any update on when this would be released?

taojiang_2000
Posts: 6
Joined: Mon Jan 26, 2009 2:12 pm
Location: USA
Contact:

Bugs found

Post by taojiang_2000 » Tue Feb 17, 2009 2:12 pm

I have tried the code and it seems fine. But, we need to be careful the following issues:
1. All collected real-time data are put into dataset, which could consume too much memory if program should run for a long time. You can exaggerate the problem by making the chart refreshing rate very high:

Code: Select all

dataGenerator = new DataGenerator(10, dataset);
also, configure a very small Java Heap Memory. The program will run out of heap memory very quickly.

I think the system should handle the cyclic buffer internally for user.

2. Performance: since all data collected are in dataset, all points are redrawn whenever chart needs to be refreshed. In the demo code, the x axis value is always increasing and point will soon be out of chart range and this hides the problem. However, if you just make let x value always change within the chart range, by adding:

Code: Select all

x += inc; if (x > 100) x = 0;
you will see the CPU usage shot up very quickly because all points are redrawn.

3. the demo program fills in data in dataset in a chunk and explicitly fire event to ask chart to be redrawn. Basically, draw a bunch of data at one time. It can improve the performance. But, it really defeats the purpose of real-time. For example, tick-by-tick real-time stock chart must be drawn once point at a time.

thanks!

anirudhak
Posts: 15
Joined: Thu Apr 30, 2009 11:06 am

Re: XY charts - dynamic data, drawing updated area only

Post by anirudhak » Thu Apr 30, 2009 11:11 am

hi ,
the one which u provided was very good and its running .
but i have a problem which importing the code in eclipse viewpart ..,
the data is not generating automatically , untill i press mouse on the graph ..,
so please can u help me to adjust these error ..
this is my mail id anirudhkaki@gmail.com
please send to this address how to redraw() without placing mouse on it..,

thanks.

anirudhak
Posts: 15
Joined: Thu Apr 30, 2009 11:06 am

Re: XY charts - dynamic data, drawing updated area only

Post by anirudhak » Wed May 06, 2009 7:50 am

thanks now i got the output..

Locked