Display non-unique categories in bar chart?

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

Display non-unique categories in bar chart?

Post by Joel Norevik » Tue Feb 18, 2003 11:45 am

Hi,

I would like to display the value of the bars on the domain-axis
instead of category names. I use the DefaultCategorySet, which
I add values to like this:
dataset.addValue(2.5, null, "Cat 1");
dataset.addValue(2.7, null, "Cat 2");

This displays "Cat 1" and "Cat 2" on the domain axis,
but I would like to show the values "2.5" and "2.6".
It works fine as long as the values differs, but when
the values are the same, the bars are merged into one.

Is it possible to display categories that are not unique
on the domain axis?

This may seem strange, but the categories will be shown as icons
above the chart.

Regards,
Joel

David Gilbert

Re: Display non-unique categories in bar chart?

Post by David Gilbert » Tue Feb 18, 2003 4:16 pm

Hi Joel,

The categories must be unique, since they are used as a key for accessing the data. The approach I would use to display values along the category axis is to subclass the HorizontalCategoryAxis class and override the refreshTicks(...) method. There is a line:

String label = category.toString();

You could change that to the value for the category.

Regards,

Dave Gilbert

Locked