Vaadin Charts: DateTimeLabelFormats does not seem to consider current Local

Hi all

I have an XAxis whe I want to see the month names in abbreviated form:
English: … Oct, Nov, Dec or
German: …Okt, Nov, Dez

My piece of code:

        conf = chart.getConfiguration();
        chart.setLocale(GenUtil.getLocale()); // returns de_CH

        XAxis xAxis = conf.getxAxis();
        xAxis.setType(AxisType.DATETIME);
        DateTimeLabelFormats dateFmt = new DateTimeLabelFormats();
        dateFmt.setMonth("%e. %b");
        xAxis.setDateTimeLabelFormats(dateFmt);

However, the XAxis always shows the month names in English.

This seems to be a bug or have I got something totally wrong?

Cheers,
Håkan

Hi Håkan,

Localization for Vaadin Charts is handled by setting the values on the Lang object, accessible from the ChartOptions singleton. So in order to set the German month names you’d need to do the following:

Lang german = new Lang(); german.setShortMonths("Jan", …, "Okt", "Nov", "Dez"); ChartOptions.get().setLang(german); We do have some plans to include ready-made localizations, but we haven’t gotten around to implementing that yet. The thought for the ready made localizations is to set the relevant strings to the Lang object when you call the setLocale method, just like you tried to do.

HTH,
/Jonatan

Hi Jonatan,

Nice intemediate solution.
I oversaw the “setLang” method. How could that happen? :wink:

Thanks,
Håkan