Best way to convert line chart to bar chart?

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

Best way to convert line chart to bar chart?

Post by Stacey » Thu Oct 24, 2002 9:31 pm

I have a line chart using a StandardXYItemRenderer. Is there an easy way to convert my line chart to a bar chart, I mean, without having to reconstruct my dataset? Right now I currently create a TimeSeriesCollection dataset for lines and a DefalutCategoryDataset for bars. Thanks for any/all input!

Stacey

Stacey

P.S.... Best way to convert line chart to bar chart?

Post by Stacey » Thu Oct 24, 2002 9:38 pm

PS...

I should have mentioned that I would like all series to be visible (side by side) not overtop of each other.

Dave Gilbert

Re: Best way to convert line chart to bar chart?

Post by Dave Gilbert » Fri Oct 25, 2002 9:40 am

The TimeSeriesCollection class implements the XYDataset interface.

The DefaultCategoryDataset class implements the CategoryDataset interface.

These two interfaces are quite different, so you can't interchange them. But you can create a simple bar chart using a TimeSeriesCollection...try the createVerticalXYBarChart(...) method in the ChartFactory class. This 'XY' bar chart doesn't have the same range of options as the regular bar charts based on the CategoryDataset interface, but maybe it will be enough for you.

Regards,

DG.

Locked