Help !! ClassCastException

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

Help !! ClassCastException

Post by hag » Wed Dec 04, 2002 6:38 pm

Why I got this error:
"java.lang.ClassCastException" when I use the
HorizontalNumberAxis axisN = (HorizontalNumberAxis) plot.getDomainAxis();

But I don't have the problem if I use this:
HorizontalDateAxis axis = (HorizontalDateAxis) plot.getDomainAxis();

I think I need to use the Number because the data in the x-values are numbers or what's wrong?.

Thanks,
ID.

hag

Re: Help !! ClassCastException

Post by hag » Wed Dec 04, 2002 6:45 pm

I forgot to tell you that I have this.

xys = new XYSeries("test XY)",true);
xys.add((double)0, (double)100);
xys.add((double)1, (double)100);
xys.add((double)2, (double)100);
xys.add((double)3, (double)100);
xys.add((double)4, (double)100);


public Object produceDataset(Map params) throws DatasetProduceException {
return new XYSeriesCollection(xys);
}

David Gilbert

Re: Help !! ClassCastException

Post by David Gilbert » Wed Dec 04, 2002 11:49 pm

The domain axis will be a HorizontalDateAxis for time series charts, and a HorizontalNumberAxis for line charts or scatter plots. Did you use one of the methods in the ChartFactory class to create your chart? Take a look in the source code if you want to see what type of axis was used...

Regards,

DG

Locked