I'm looking for a "nice numbers" algorithm for determining the labels on a date/time value axis. I'm familiar with Paul Heckbert's Nice Numbers algorithm.

I have a plot that displays time/date on the X axis and the user can zoom in and look at a smaller time frame. I'm looking for an algorithm that picks nice dates to display on the ticks.

For example:

  • Looking at a day or so: 1/1 12:00, 1/1 4:00, 1/1 8:00...
  • Looking at a week: 1/1, 1/2, 1/3...
  • Looking at a month: 1/09, 2/09, 3/09...

The nice label ticks don't need to correspond to the first visible point, but close to it.

Is anybody familiar with such an algorithm?

Edit
Report