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
repaint / dynamic update issues
Re: repaint / dynamic update issues
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
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
Re: repaint / dynamic update issues
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
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
Re: repaint / dynamic update issues
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.
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.
Re: repaint / dynamic update issues
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
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
Re: repaint / dynamic update issues
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.
> 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.
Re: repaint / dynamic update issues
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
Olli