[i18ln] Internationalization

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

[i18ln] Internationalization

Post by Nathan Sequeira » Fri Mar 14, 2003 2:36 am

I would like to internationalize my chart data. For me, it's really just a display issue, and there are only a few areas affected.

I would like to use a given Locale to affect the number value axis and the date format for time series charts. For instance, I would like to display 2.250,00 instead of 2,250.00 for many European locales. And dates obviously have their different formats.

Can anyone point me to the place in the API where I can make these changes? Thanks. This is all probably very obvious stuff, but I haven't been able to figure it out yet.

-- Nate

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

Post by david.gilbert » Fri Mar 14, 2003 12:59 pm

Hi Nate,

The number formatting is set up in the createStandardTickUnits() method in the NumberAxis class. The way I wrote the code doesn't make it easy to localise the formatting. But one approach might be to put all the format strings into a resource bundle, and localise the format strings.

You'll also see a createStandardTickUnits(Locale) method...that might solve your problem, but I think it sets the same format for all tick sizes, which might not give the display you want.

Regards,

Dave Gilbert

nsequeira

Re: [i18ln] Internationalization

Post by nsequeira » Sat Mar 15, 2003 3:54 am

Thanks for the tip on the NumberAxis. I will give that a try. How about setting the Locale for the date axis of a time series chart? Since the actual date format will change depending on the range of dates on the axis (for instance, it might display the years 1982 - 1999 or the dates April 1 - April 3, depending on the size of the range), I need to figure out a good way to make my Locale take precedence. Any ideas on making this work? Thanks.

-- Nate

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

Post by david.gilbert » Mon Mar 17, 2003 10:18 am

Hi Nate,

It's exactly the same problem as with the number axis, but it's easier to see with dates. As you mention, the format applied is a function of the tick size - it might be 'YYYY' for a 1 year tick size, or 'HH:mm' for a 30 minute tick size. I think there are about 7 different format strings used.

What I'm thinking of doing, it adding the 7 format strings to the ResourceBundle, so that they can be localised easily.

There is one further problem with the date formatting - the format should be a function of the tick size AND the axis range. For example, with a 1 hour tick size, the format selected is 'HH:mm', but if the range spans two or more days, you probably want the date displayed as well. For less than one day, you probably don't want the date displayed. So I'm thinking about a way to incorporate this into the default behaviour.

Regards,

Dave Gilbert

Locked