I wanted to add to the chart a scroll bar in order to view big datasets which did not fit on the screen, because to keep all xtick. However, I got the following error message:
The error message is pretty obvious:
org.jfree.data.xy.XYSeriesCollection cannot be cast to org.jfree.data.category.CategoryDataset
You are casting a XYSeriesCollection object to a CategoryDataset object, which does not work. Looking at the lines in the stack trace, it is caused by the following line
dataset = new SlidingCategoryDataset((CategoryDataset) createDataset(), 0, 10);
The createDataset() methods returns a XYSeriesCollection and not a CategoryDataset, so you cannot do this cast. Either adjust the return type of that method, or get rid of the cast