tick label - own format

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

tick label - own format

Post by Danik » Mon Dec 20, 2004 7:14 pm

Hallo,

I am the part of larger project and my task is to paint charts. Naturally, I choose JFreeChart (together with pdf documentation).

My task is to paint different kind of charts, where Y-values are defined as numbers. But the problem is, that those numbers can have different meaning (and format) and I do not know this meaning; only a set of y values together with formatting method is given to me - this metod (used in other parts of the project as well) can convert a number to String in required format (somtimes time, sometimes percentage, sometimes numbers in different format, etc).

So, it is no problem to create a dataset and fill it by obtained values. But how can I print tick labels in specified format? Is there a possibility to use obtained formating method for tick labels formating? As ticks are determined automatically, there could only be a similar method to:

Code: Select all

String getTickLabel( Number arg );
Could you give me a hint which to focus on in the pdf documentation, or how to solve it?

Thank you very much,
Dan

angel
Posts: 899
Joined: Thu Jan 15, 2004 12:07 am
Location: Germany - Palatinate

Post by angel » Tue Dec 21, 2004 8:22 am

You can override the label formats for the most axis:

Code: Select all

domainAxis.setDateFormatOverride(new SimpleDateFormat("MM.yy"));
rangeAxis.setNumberFormatOverride(new DecimalFormat("###,##0.00"));

Danik

Post by Danik » Wed Dec 22, 2004 2:21 pm

Exactly. I realized it several dosen minutes after the question.

For any other people with similar problem: Overide NumberFormat or DateFormat (or other) class and implement your own fomater in abstract methods.

rlenard
Posts: 7
Joined: Thu Jun 10, 2004 4:37 am

Post by rlenard » Tue Jan 18, 2005 4:28 am

Danik wrote:Exactly. I realized it several dosen minutes after the question.

For any other people with similar problem: Overide NumberFormat or DateFormat (or other) class and implement your own fomater in abstract methods.
Course it'd be nicer to just be able to use a Format rather than a NumberFormat - then a MessageFormat can be used - ala "{0,choice,0#null|1#positive|2#big value}"

Guest

Post by Guest » Tue Jan 18, 2005 10:28 am

rlenard wrote:
Danik wrote:Exactly. I realized it several dosen minutes after the question.

For any other people with similar problem: Overide NumberFormat or DateFormat (or other) class and implement your own fomater in abstract methods.
Course it'd be nicer to just be able to use a Format rather than a NumberFormat - then a MessageFormat can be used - ala "{0,choice,0#null|1#positive|2#big value}"
Ah perhaps this'd be a better example - ala "{0,choice,0#null|1#positive|2#{0} is a big value}"

The example above could be done with a choice format. The better example couldn't.

Locked