changing

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

changing

Post by daniel shaya » Wed Oct 23, 2002 2:41 pm

I am new to JFreeChart and hope there is a simple answer to this question.

I have constructed a DefaultCatagoryDataSet which I can update using the setValue() method.

My data changes so that the number of points on the x axis or number of catagories change. If I try to call setSeriesNames() with the new number of series I get the following error:

java.lang.IllegalArgumentException: DefaultCategoryDataset.setSeriesNames(): the
number of series names does not match the data.
at com.jrefinery.data.DefaultCategoryDataset.setSeriesNames

I need something like clear before I start resetting the data.

All help much appreciated.

Thanks in advance.

Daniel

Dave Gilbert

Re: changing

Post by Dave Gilbert » Wed Oct 23, 2002 5:55 pm

No, setSeriesNames should work OK as long as the array you pass in has exactly the right number of names. If you can post some sample code I might be able to spot the problem.

Regards,

DG.

daniel shaya

Re: changing

Post by daniel shaya » Thu Oct 24, 2002 9:36 am

But that exactly the point - what do you do if you want to change the number of points in the array.

In the meantime I have found a workaround in that I recreate the JFreechart and use the setChart() method on the ChartPanel everytime I change the number of points in the series.

Dave Gilbert

Re: changing

Post by Dave Gilbert » Thu Oct 24, 2002 10:11 am

I understand now, I think.

The DefaultCategoryDataset class is not very good for adding new series. At the moment I am working on some code for reading CategoryDataset data from an XML format, and that is going to require a better implementation of DefaultCategoryDataset, so I will be overhauling it for the next release.

For now, the best solution is to create a completely new dataset each time the number of series or categories changes, and then do this:

CategoryPlot plot = myChart.getCategoryPlot();
plot.setDataset(myNewDataset);

Regards,

DG.

Locked