setting tick unit masks for date axis in Timeseries charts

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
hima25
Posts: 1
Joined: Mon Oct 28, 2013 5:58 pm
antibot: No, of course not.

setting tick unit masks for date axis in Timeseries charts

Post by hima25 » Mon Oct 28, 2013 5:59 pm

I have a timeseries chart plotting data for 1 single day.I set the min and max values for the time axis as 00:00:00 till 23:59:59.I used the below code to set the tick labels for every 4 hours.

XYPlot xyplot = (XYPlot)chart.getPlot(); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickUnit(new DateTickUnit((DateTickUnit.HOUR),4,new SimpleDateFormat("HH:mm")));

However this code is giving me the following tick labels - 3:00,7:00,11:00,15:00,19:00,23:00 It should give 4:00,8:00,12:00,16:00,20:00

Then i changed the code to below :

XYPlot xyplot = (XYPlot)chart.getPlot(); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickUnit(new DateTickUnit((DateTickUnit.MINUTE),240,new SimpleDateFormat("HH:mm")));

This gives the correct tick labels but like this - 3:59,7:59,11:59,15:59,19:59 Again it should give 4:00,8:00,12:00,16:00,20:00

Please suggest what's wrong here.

Locked