Hi
I am using a HorizontalDateAxis for my xAxis. I would like to control the frequency of tick labels and have used the following code:
xAxis.setAutoTickUnitSelection(false);
xAxis.setTickUnit(new DateUnit(Calendar.YEAR, 1));
This would set a label every year.
However, the labels look weird. Instead of coming out 1998, 1997 as they would if I used the Default JFreeChart labelling, they display the full day including time. I haven't been able to find a method to change the date format. (I.e. using SimpleDateFormat).
Could you please let me know how I can control the frequency as well as the format of the date labels?
Thanks in advance,
Belinda
Date labels on the x axis
Re: Date labels on the x axis
Hi!
I do something like this - it seems to work...
axis.setAutoTickUnitSelection(false);
axis.setTickUnit(new DateUnit(Calendar.MONTH,1));
SimpleDateFormat sdf = axis.getTickLabelFormatter();
sdf.applyPattern("dd-MM-yy");
I do something like this - it seems to work...
axis.setAutoTickUnitSelection(false);
axis.setTickUnit(new DateUnit(Calendar.MONTH,1));
SimpleDateFormat sdf = axis.getTickLabelFormatter();
sdf.applyPattern("dd-MM-yy");