Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 567725
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T13:06:49+00:00 2026-05-13T13:06:49+00:00

I’m looking for a nice numbers algorithm for determining the labels on a date/time

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T13:06:50+00:00Added an answer on May 13, 2026 at 1:06 pm

    The ‘nice numbers’ article you linked to mentioned that

    the nicest numbers in decimal are 1, 2, 5 and all power-of-10 multiples of these numbers

    So I think for doing something similar with date/time you need to start by similarly breaking down the component pieces. So take the nice factors of each type of interval:

    • If you’re showing seconds or minutes use 1, 2, 3, 5, 10, 15, 30
      (I skipped 6, 12, 15, 20 because they don’t “feel” right).
    • If you’re showing hours use 1, 2, 3, 4, 6, 8, 12
    • for days use 1, 2, 7
    • for weeks use 1, 2, 4 (13 and 26 fit the model but seem too odd to me)
    • for months use 1, 2, 3, 4, 6
    • for years use 1, 2, 5 and power-of-10 multiples

    Now obviously this starts to break down as you get into larger amounts. Certainly you don’t want to do show 5 weeks worth of minutes, even in “pretty” intervals of 30 minutes or something. On the other hand, when you only have 48 hours worth, you don’t want to show 1 day intervals. The trick as you have already pointed out is finding decent transition points.

    Just on a hunch, I would say a reasonable crossover point would be about twice as much as the next interval. That would give you the following (min and max number of intervals shown afterwards)

    • use seconds if you have less than 2 minutes worth (1-120)
    • use minutes if you have less than 2 hours worth (2-120)
    • use hours if you have less than 2 days worth (2-48)
    • use days if you have less than 2 weeks worth (2-14)
    • use weeks if you have less than 2 months worth (2-8/9)
    • use months if you have less than 2 years worth (2-24)
    • otherwise use years (although you could continue with decades, centuries, etc if your ranges can be that long)

    Unfortunately, our inconsistent time intervals mean that you end up with some cases that can have over 1 hundred intervals while others have at most 8 or 9. So you’ll want to pick the size of your intervals such than you don’t have more than 10-15 intervals at most (or less than 5 for that matter). Also, you could break from a strict definition of 2 times the next biggest interval if you think its easy to keep track of. For instance, you could use hours up to 3 days (72 hours) and weeks up to 4 months. A little trial and error might be necessary.

    So to go back over, choose the interval type based on the size of your range, then choose the interval size by picking one of the “nice” numbers that will leave you with between 5 and about 15 tick marks. Or if you know and/or can control the actual number of pixels between tick marks you could put upper and lower bounds on how many pixels are acceptable between ticks (if they are spaced too far apart the graph may be hard to read, but if there are too many ticks the graph will be cluttered and your labels may overlap).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 379k
  • Answers 379k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Since it sounds from your comments like you're trying to… May 14, 2026 at 9:31 pm
  • Editorial Team
    Editorial Team added an answer To fix your code, save a string in the ViewData["message"]… May 14, 2026 at 9:31 pm
  • Editorial Team
    Editorial Team added an answer Try this RewriteEngine on RewriteBase / RewriteRule ([0-9]+)/([^.]+) myblog.php?id=$1&title=$2 May 14, 2026 at 9:31 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.