   need an intelligent scale
  Two pictures to show what I am sitting in front of:- 0.372 and 0.373 have multiple lines- The numbers are a bit too close to each other- one doesn't need hours, minutes and seconds when viewing weeksSince making a halfway intelligent scale is a generic problem I hope that someone can point me  to material covering this topic.thanks in advance.   
  Sorry, I'm not sure if I understand your problem.If they are too close, then why not just show the week number (20w, 40w, 60w...)? If you have multiple of the same number, then just go down another order of magnitude (0.3721, 0.3722, 0.3723...);  Yes you are totally right. It's just two examples of how not doing it.The problem is that I have to invent something, which I think might be already invented because this is a common problem.   ;  Are the time ranges arbitrary? Why would you have to create the scale dynamically instead of just choosing a scale based on the amount of time in the range?If time range > 2 weeks: use weeksIt time range > 2 days: use daysIf time range > 2 hours: use hoursetc...   ;  I think here you could write a specific hard coded solution in a fraction of the time spent just thinking of a generic solution.  (i.e. use tstrimp's solution)If ever you will meet a second problem with similar inputs/outputs you could think of refactoring your specifics to a more generic solution.If you want a custom solution that is not hard coded, you can use an array of value ranges and the proper resolution for each range.   ;Quote:Original post by tstrimpAre the time ranges arbitrary? Why would you have to create the scale dynamically instead of just choosing a scale based on the amount of time in the range?If time range > 2 weeks: use weeksIt time range > 2 days: use daysIf time range > 2 hours: use hoursetc...They are in fact arbitrarily. (Because the user can zoom in and out as he wishes)Ranging from nanoseconds to weeks.And it needs to handle ticks too, not only  time.The more interesting part is of course sub hours.   ;  To address the dynamic part: Why not measure the string that is being displayed? When it is to big scale up.   ;Quote:Original post by tstrimpIf time range > 2 weeks: use weeksIt time range > 2 days: use daysIf time range > 2 hours: use hoursetc...Is a good idea. You could save yourself some if-statements by taking a base-10 logarithm when things get into the decimal range (below 1s).A slightly easier-to-maintain, if less efficient, alternative would be to determine the weeks, days, hours etc. as separate numerical values, then combine the first one or two non-zero sub-units into the string. Depending on your ideal output, this may also require separate treatment in the sub-second range, so it may not be worth the effort.   