Is it possible to set a date format for X axis, if I use java.util.Date as a source item for X axis data?
I have a code:
BeanItemContainer<ChartDataRow> cnt = new BeanItemContainer<ChartDataRow>(ChartDataRow.class);
cnt.addAll(DataService.getYearlyData());
ContainerDataSeries cds = new ContainerDataSeries(cnt);
cds.setXPropertyId("date");
cds.setYPropertyId("value");
conf.addSeries(cds);
After adding the datasource to chart, the chart shows X axis categories as numeric value of Date, not as dates.
In documentation I’ve found that you can set X axis categories manually by defining custom values for the axis. But in this case setting axis min/max values is not working.
What is a possible solution to show dates on X axis as dates, e.g. ‘22 Jul 2014’ and be able to set X axis min and max values?
Hello, I think this should work for 22 Jul 2014 format
configuration.getxAxis().getDateTimeLabelFormats().setDay("%e %b %Y");
The format is based on PHP strftime function, the info about it you can get
here :
If you want to change a format not for labels, but for a tooltip you should do the following: