Custom label for bar chart-Using CategoryItemLabelGenerator?

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
rahul
Posts: 6
Joined: Thu Jun 26, 2008 1:08 pm

Custom label for bar chart-Using CategoryItemLabelGenerator?

Post by rahul » Thu Jun 26, 2008 1:11 pm

Hi,
I have a bar chart on which I want to display a date below each bar on the X -axis. I got to know that CategoryItemLabelGenerator is to be used. But I am not able to understand how to do that. Can somebody please help me??

david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: Custom label for bar chart-Using CategoryItemLabelGenera

Post by david.gilbert » Thu Jun 26, 2008 3:00 pm

rahul wrote:Hi,
I have a bar chart on which I want to display a date below each bar on the X -axis. I got to know that CategoryItemLabelGenerator is to be used. But I am not able to understand how to do that. Can somebody please help me??
No, the x-axis labels in a CategoryPlot are derived by JFreeChart calling the toString() method on the objects you are using for the column keys in your dataset. These keys can be any instance of Comparable (for example, the String class). If you use the String class, then obviously the toString() method returns the string itself, so the label is the same as the key. But you could just as easily implement your own CustomCategory class that implements Comparable (so can be used as a key in the dataset) *and* overrides the toString() method to return whatever label you want.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

rahul
Posts: 6
Joined: Thu Jun 26, 2008 1:08 pm

Post by rahul » Fri Jun 27, 2008 6:22 am

Hi, I think I need to explain my problem in detail
This is the chart that I have
http://picasaweb.google.com/khirerahul/JFreeChart

Just below the keys on the X-axis I want to display another text(dates) for each bar. How to do that?

Thanks.

Locked