Animated charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Andrew Foss
Posts: 36
Joined: Thu Apr 12, 2007 6:54 am

Animated charts

Post by Andrew Foss » Sat Nov 03, 2007 10:48 pm

Has anyone come up w/ a good strategy for animating the charts?

Seems like the in thing in the flash charts is the animated growing of the bars when they plot.

I prototyped extending my dataset, adding a scaler setting and the getYValue returns a scaled value. dataset.setScaler, calls fireDatasetChanged().

When the chart is created, I kickoff a background thread to progressively set the scaler, until getYValue is returning unscaled values.

It works, but it's not synchronized with the drawing of the chart, so if the background thread sets the scaler too fast, it's as if the DatasetChangedEvents are all bundled up and you only see the final draw with full values.

This seems like a hokey approach, I was wondering if anyone had ever done anything more cleanly to animate the drawing of the chart?

thanks,
andrew

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Sun Nov 04, 2007 3:35 am

Did you try calling

Code: Select all

jFreeChart.addProgressListener(ChartProgressListener listener)
and getting the background thread to wait for a notification that the repaint has completed? Or get rid of the background thread and use the listener to advance to the next "frame".

Andrew Foss
Posts: 36
Joined: Thu Apr 12, 2007 6:54 am

Post by Andrew Foss » Sun Nov 04, 2007 1:03 pm

That's much better thankyou, not as smooth as I'd like but this is a much better way to do it...

Andrew Foss
Posts: 36
Joined: Thu Apr 12, 2007 6:54 am

Post by Andrew Foss » Sun Nov 04, 2007 1:11 pm

Is it possible to control the drawing, such that only portions of the chart are redrawn?

skunk
Posts: 1087
Joined: Thu Jun 02, 2005 10:14 pm
Location: Brisbane, Australia

Post by skunk » Sun Nov 04, 2007 1:55 pm

Andrew Foss wrote:Is it possible to control the drawing, such that only portions of the chart are redrawn?
No, the entire plot is redrawn every time.

Andrew Foss
Posts: 36
Joined: Thu Apr 12, 2007 6:54 am

Post by Andrew Foss » Sun Nov 04, 2007 3:49 pm

I'm using a combinedRangeXYPlot, using XYDifference render, which does 2 drawing passes and a bunch of datasets, so a redraw is not a minor event:-)

Can I separate out the plots make them transparent and layer them on top of one another, the redraw the layers? Except making transparent, may cause the whole thing to repaint, each time anyway?

Locked