Algorithm for nice graph labels for time/date axis?

Posted by Aaron on Stack Overflow See other posts from Stack Overflow or by Aaron
Published on 2009-09-14T00:16:21Z Indexed on 2010/04/12 7:03 UTC
Read the original article Hit count: 456

Filed under:
|
|

Hello,

I'm looking for a "nice numbers" algorithm for determining the labels on a date/time value axis. I'm familar with Paul Heckbert's Nice Numbers algorithm (http://tinyurl.com/5gmk2c).

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 familar with such an algorithm?

Thanks

© Stack Overflow or respective owner

Related posts about graphs

Related posts about label