XY charts - dynamic data, drawing updated area only

A discussion forum for JFreeChart (a 2D chart library for the Java platform).

XY charts - dynamic data, drawing updated area only

Postby Gotcha » Wed Jan 28, 2009 10:02 am

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.
Posts: 7
Joined: Wed Oct 15, 2008 9:13 am

Postby 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.
Posts: 7
Joined: Wed Oct 15, 2008 9:13 am

Postby RichardWest » Wed Jan 28, 2009 6:50 pm

Richard West
Design Engineer II
Advanced Micro Devices
Sunnyvale, CA
Posts: 844
Joined: Fri Oct 13, 2006 9:29 pm
Location: Sunnyvale, CA


Postby d_rambabu » Thu Feb 12, 2009 10:52 am

Any update on when this would be released?
Posts: 8
Joined: Mon Apr 14, 2008 8:36 am
Location: Hyderabad, India

Bugs found

Postby 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.

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

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

Postby 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..,

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

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

Postby anirudhak » Wed May 06, 2009 7:50 am

thanks now i got the output..
Posts: 15
Joined: Thu Apr 30, 2009 11:06 am

Return to JFreeChart

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot] and 6 guests