repaint / dynamic update issues

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

repaint / dynamic update issues

Post by John Michelsen » Mon May 13, 2002 3:30 am

Hi, and thanks in advance for any help.

I have a somewhat similar problem to Gaurav in that I cannot seem to get JFreeCharts to repaint when expected, but there's more...

First issue: repaints
When I change the underlying data and my Dataset does a .fireDatasetChaned() or a .notifyListeners( new DatasetChangedEvent() ) neither seem to convince the chart to update. When I resize the chart's container, it does update and the chart reflects changes, well, more on that... I've tried calling

Second issue: Unable to get auto ranges right

I'm creating a combined XY Series chart. I have .setAutoRange( true ) on the Vertical axis, and the Horizontal axis is set at 50 items. For some reason, the Dataset's vertical axis will not redraw with the correct tick mark values even tho' it correctly displays the graph correctly in relative terms. For example, if my series is X = { 0, 1, 2, 3, ... 50 } and my Y = { 30, 20, 10, 15, null, ... null } then the line of the graph draws right, but the axis values are showing values of 0.0 to 1.0. If I regenerate the chart from scratch periodically from the same dataset, it works! This likely has to do with their being only 1 or maybe 2 datapoints in the Dataset when the chart is constructed (could even be none possibly) but another thread is populating the Dataset over time.
Here's my axis code:
NumberAxis valueAxis = new VerticalNumberAxis( msi.getName() );
valueAxis.setAutoRangeIncludesZero( false );
valueAxis.setCrosshairVisible( false );
valueAxis.setAutoRange( true );

Thanks for any help you guys can shed!!

John

Gaurav Kathotia

Re: repaint / dynamic update issues

Post by Gaurav Kathotia » Mon May 13, 2002 6:13 am

Well John
i solved my problem by just populating the dataset with the new data as it comes and calling the method JFreeChart.setDataset() method .
This eliminates the need for any repainting.
If you really call repaint() explicitly , try using revalidate() instead
since repaint() is used when the java2D graphics underlying a component
is changed, while revalidate() is used when a component is added or removed .Hope that helps.
Sorry , can't really understand your second doubt.
Gaurav Kathotia

John Michelsen

Re: repaint / dynamic update issues

Post by John Michelsen » Mon May 13, 2002 10:42 pm

Gaurav, your suggestion worked perfectly for my first issue, thanks!!!

On the 2nd, let me try again, this time in English :)

When I start populating the Dataset, it has only either 0 or 1 values. Eventually, the Dataset has many values. Despite setting setAutoRange(), the chart's Y axis is not changing. In fact, the chart is throughing a Bad Path Exception when trying to update since the Dataset values are so far out of the range of of the Y axis.

Again, if I recreate the chart from scratch, it'll recalculate the range, and display correctly.

Should I be manually maintaining the range? I do see methods on the axis for setMaximum() and setMinimum() for the range.

Thanks _so_much_.

John

David Gilbert

Re: repaint / dynamic update issues

Post by David Gilbert » Tue May 14, 2002 9:52 am

Hi John,

I think you have found a bug in the combined charts...are you using 0.8.1 or the latest development code from CVS on SourceForge? Some significant changes have been made in the development version to simplify how the axes are being used, and I'm hoping this will make it easier to work with combined charts. But there are still a couple of issues to work on before it is ready for a new release.

Regards,

DG.

John Michelsen

Re: repaint / dynamic update issues

Post by John Michelsen » Tue May 14, 2002 6:30 pm

Hi David, I'm used the published release 0.8.1.

Did you mean the issue was in the upcoming release?

My work around is to recreate, and that is working for me for now.

Thanks!
John

David Gilbert

Re: repaint / dynamic update issues

Post by David Gilbert » Wed May 15, 2002 9:10 pm

John Michelsen wrote:
> Did you mean the issue was in the upcoming release?

Actually, there's issues in both...but I have more chance of resolving the issues in the newer code, since I've cleared out some redundant stuff and it is a little easier to follow now.

DG.

owagner

Re: repaint / dynamic update issues

Post by owagner » Thu May 23, 2002 6:00 pm

I seem to be having a similiar problem with combined charts, in a similiar configuration: A TimeSeries chart in a combined plot doesn't seem to update the vertical axis in response to dataset changes (I've tried fireDatasetChanged on both the individual plot's datasets and on the combined dataset)

Olli

Locked