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
changing
Re: changing
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.
Regards,
DG.
Re: changing
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.
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.
Re: changing
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.
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.