add scrollbar to JFreeChart 3DBarChart

2019-01-29 13:06发布

问题:

Can I add a scroll bar to the JFreeChart that allows me horizontally move the bar ?

JFreeChart chart = ChartFactory.createBarChart3D(
    title, 
    "X",
    "Y",
    dataset, 
    PlotOrientation.VERTICAL, 
    true, 
    false, 
    false
);

Because the dataset could be very long that there's not enough width to show the result...

Can I use JSlide on it? or other methods?

If possible, please show me some sample code. Thank you!

回答1:

.Yes you can, if you have access to the JFreeChart demo code just modify SlidingCategoryDatasetDemo2 and replace createBarChart3D with createBarChart3D and you will get this:

You will need to use a SlidingCategoryDataset. You can find the source code and demos here JFreeChart