I'm using a fixed size array of Numbers[MAXSERIES][MAXCATEGORY] initialized to null values and then populate the array by reading category/value pairs from a file. If the array is not filled completely, I get the following exception when trying to create the verticalCategoryPlot. The DefaultCategoryDataset.getCategoryCount() method returns the allocated size of the array. Not knowing how many category/value pairs will be in the file makes it difficult to pre-size the array. Wouldn't it be better to compute the categoryCount by checking the count of non-null values in the array, or provide methods DefaultCategoryDataset.setCategoryCount & setSeriesCount to bound the data set that will be plotted to an upper limit?
I assume others have run into this. How do you get around it?
java.lang.IllegalArgumentException: DefaultCategoryDataset.getValue(...): null category not allowed.
at com.jrefinery.data.DefaultCategoryDataset.getValue(Unknown Source)
at com.jrefinery.data.DatasetUtilities.getMaximumRangeValue(Unknown Source)
at com.jrefinery.chart.VerticalCategoryPlot.getMaximumVerticalDataValue(Unknown Source)
at com.jrefinery.chart.VerticalNumberAxis.autoAdjustRange(Unknown Source)
at com.jrefinery.chart.VerticalNumberAxis.configure(Unknown Source)
at com.jrefinery.chart.Plot.setChart(Unknown Source)
at com.jrefinery.chart.JFreeChart.<init>(Unknown Source)
at com.jrefinery.chart.ChartFactory.createVerticalBarChart(Unknown Source)
at Chart.<init>(Chart.java:44)
at Chart.main(Chart.java:96)
DefaultCategoryDataset.setCategoryCount???
Re: DefaultCategoryDataset.setCategoryCount???
It sounds like you need to write your own class that implements the CategoryDataset interface.
DefaultCategoryDataset isn't a great piece of code...when I get a chance I will rewrite it to include much better support for adding and removing series and categories. Unless someone else writes a better implementation first...
Regards,
DG.
DefaultCategoryDataset isn't a great piece of code...when I get a chance I will rewrite it to include much better support for adding and removing series and categories. Unless someone else writes a better implementation first...
Regards,
DG.