legend.setDisplaySeriesShapes() with Overlaid charts

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

legend.setDisplaySeriesShapes() with Overlaid charts

Post by Tom Mazzotta » Wed Feb 12, 2003 10:31 pm

I am using the new legend.setDisplaySeriesShapes(true).

I am turning this on when I have legends displaying Line Charts... For Bar Charts, it still displays shapes in the legend even though shapes don't really apply to bar charts (all the bar elements are just rectangles, so the shapes in the legend have no meaning).
I've gotten around this issue temporarily by only calling legend.setDisplaySeriesShapes(true) when working with line charts..

My question is how to handle it if I have a 'combination chart' (aka an 'overlaid chart'.) This is where we have some information graphed out using bars (we want just blocks in the legend for these series) and some information is graphed out using lines (we want shapes in the legend for these series).

How would I go about implementing this?

thanks in advance

Tom Mazzotta

Re: legend.setDisplaySeriesShapes() with Overlaid charts

Post by Tom Mazzotta » Wed Feb 12, 2003 10:46 pm

found the answer to my own question... sorry about that... here's the answer in case somebody else runs into the same issue:

When you have an overlaid plot that has both bars and lines on them, you need to explicitly set the shape of each series that is a bar to be a rectangle using something like:
renderer.setSeriesShape(series,new Rectangle2D.Double(-3.0, -3.0, 9.0, 9.0));

That way, the legend.setDisplaySeriesShapes(true) setting will show box shapes for series that are bars

Locked