Modify-able Legend

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

Modify-able Legend

Post by Ray Clough » Tue Feb 18, 2003 12:59 am

My CombinedXY Plot looks kind of messy because the Legend contains the same symbols with the same colors multiple times, once for each series in the plot.

I would find methods to tailor the series, colors, etc in the Legend very helpful. I probably don't have time to do it myself, but if there is any work on this topic, I'd really appreciate knowing about it. Thanks,

-Ray Clough
ray.c.clough@boeing.com

David Gilbert

Re: Modify-able Legend

Post by David Gilbert » Tue Feb 18, 2003 6:23 am

Hi Ray,

The legend just displays the colors used by the individual renderers that draw the data in the subplots. What you need to do is coordinate the renderers so that they don't duplicate colors.

Take a look at the CombinedXYPlotDemo class, where you will see that a single instance of the DrawingSupplier class is created, and then assigned to each renderer in the subplots. When the renderers are looking for a new color, they ask the DrawingSupplier to supply one - and because all the renderers are using the same supplier, duplication of colors is avoided (at least until the supplier starts repeating the colors, which happens after about 35 series).

Unfortunately I haven't thought of a good way to make this happen by default, so you have to intervene in your code to set up the DrawingSupplier.

Regards,

Dave Gilbert

Locked