custom itemLabelGenerator

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
guymac
Posts: 7
Joined: Wed Feb 18, 2004 12:56 am

custom itemLabelGenerator

Post by guymac » Wed Feb 18, 2004 1:00 am

I need help figuring out how to do a custom itemLabelGenerator. I would like the label to include the numerical value and the percentage of some other value. E.g a bar chart with

Item A XXXXXXXXXXXXXX 1000 (100%)
Item B XXXXXXXXXXX 777 (77.7%)
Item C XXXXX 333 (33.3%)

Thanks.

phamdinhnguyen
Posts: 22
Joined: Thu Jan 29, 2004 8:28 pm

custom itemLabelGenerator

Post by phamdinhnguyen » Mon Mar 01, 2004 7:54 pm

If you were describing category labels (domain axis) in your example, one way I think possible is to use the DefaultCategoryDataset. For each value of the x-axis, ie 1000, 777, 333, you derive a associated category string, ie "1000 (100%)", "777 (77.7%)", and "333 (33.3%)", respectively.

Then invoking

DefaultCategoryDataset.addValue(aRangeValue, "SeriesString", theAboveAssociatedCategoryLabel);

I believe that should do it.
Use LineChart, or BarChart

Hope it works!

Locked