Search code examples
javajfreechart

Resize Vertical Tick Label Height (XYStepChart)


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?


Solution

  • 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));