Can I invert legend (without inverting the whole chart)?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
Elly
Posts: 19
Joined: Tue Jun 07, 2005 2:26 pm
Location: Germany
Contact:

Can I invert legend (without inverting the whole chart)?

Post by Elly » Thu Jan 12, 2006 2:53 pm

Hello,
I have following problem:
the customer wants the legend for the stacked bar chart to be inverted as he supposes that in such way it is easier to read the graph.

That means, that not the whole graph must be inverted, but only the order of series in a legend (the colors must still correspond with the graph!).

Is it possible???? And how???

Thank you very much in advance!
using JFreeChart 1.0.0 rc1, Java 1.4.2

Elly
Posts: 19
Joined: Tue Jun 07, 2005 2:26 pm
Location: Germany
Contact:

Post by Elly » Fri Jan 13, 2006 4:21 pm

Well, I found it out myself, maybe it can help somebody:

Code: Select all


LegendItemCollection lic =  plot.getLegendItems();
LegendItemCollection licInverted = new LegendItemCollection();
int NumberOfLegendItems = lic.getItemCount();

for (int ItemCount = NumberOfLegendItems-1; ItemCount>=0; ItemCount--)
{
    licInverted.add(lic.get(ItemCount));
}
plot.setFixedLegendItems(licInverted);

best wishes, Elena
using JFreeChart 1.0.0 rc1, Java 1.4.2

Jack Lee

thanks

Post by Jack Lee » Thu Jan 19, 2006 6:50 am

thanks

Locked