I have a chart that could be displayed in various time lengths (e.g. 1 day, 1 week, 1 month etc).
I'm using
Code: Select all
switch((int)(length / 3600)) //length in hours
{
case 1: return new DateTickUnit(DateTickUnit.MINUTE, 15);
case 6: return new DateTickUnit(DateTickUnit.HOUR, 1);
case 24: return new DateTickUnit(DateTickUnit.HOUR, 4);
case 24 * 7: return new DateTickUnit(DateTickUnit.DAY, 1);
case 24 * 30: return new DateTickUnit(DateTickUnit.DAY, 7);
case 24 * 120: return new DateTickUnit(DateTickUnit.MONTH, 1);
//1 yr won't be changed
default: return null;
}
Code: Select all
Date d2 = calendar.getTime();
if (d2.getTime() >= date.getTime()) {
calendar.set(Calendar.DATE, value - 1);
d2 = calendar.getTime();
}
return d2;
Or is there any other possibility to set the start date/time of the ticks to some value? Note that actually with having the lines commented out it seems to work fine.
Thanks Bye Michael