views:

43

answers:

1

Hi! I've got the following chart made with JFreeChart: alt text

Is it possible (and if it is how) to extend the dates on the x-axis so that they contain the year, eg. 4-II-2010, 5-II-2010, ..., 6-III-2010?

A: 

It's not clear how you are formatting the dates now, but setDateFormatOverride in DateAxis allows you to specify a suitable SimpleDateFormat. If not already available, you should be able to override getShortMonths() in DateFormatSymbols for the Roman numerals.

Addendum: For correct localization, it may be easier to do something like this:

DateAxis axis = (DateAxis) plot.getDomainAxis();
DateFormatSymbols dfs = DateFormatSymbols.getInstance(); // default locale
String[] roman = { ... };
dfs.setShortMonths(roman);
axis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy", dfs));
trashgod
Hay, thank you very much!It really worked. This way I have full control on the date format shown on the x-axis.
Vassilen Dontchev
Excellent. Please consider accepting and/or up-voting this answer.
trashgod