Jfreechart with scroller

前端 未结 1 1651
臣服心动
臣服心动 2021-01-26 11:50

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:

相关标签:
1条回答
  • 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

    0 讨论(0)
提交回复
热议问题