ruler.js
function calcSteps (min, max, room, width) {
  var range = max - min
  var i = 0, e

  while(true) {
    var e = Math.pow(10, i++)
    if(e > 10000000000)
      throw new Error('oops')

    var re = range/e
    var space = width*1.25

    if(room     / (re) > space) return e
    if(room*2   / (re) > space) return e*2
    if(room*2.5 / (re) > space) return e*2.5
    if(room*5   / (re) > space) return e*5
  }
}
function calcSteps (min, max, room, width) {
  var range = max - min
  var i = 0, e

  while(true) {
    var e = Math.pow(10, i++)
    if(e > 10000000000)
      throw new Error('oops')

    var re = range/e
    var space = width*1.25

    if(room     / (re) > space) return e
    if(room*2   / (re) > space) return e*2
    if(room*2.5 / (re) > space) return e*2.5
    if(room*5   / (re) > space) return e*5
  }
}
function calcSteps ( min , max , room , width ) { var range = max - min var i = 0 , e while ( true ) { var e = Math . pow ( 10 , i ++ ) if ( e > 10000000000 ) throw new Error ( 'oops' ) var re = range / e var space = width * 1.25 if ( room / ( re ) > space ) return e if ( room * 2 / ( re ) > space ) return e * 2 if ( room * 2.5 / ( re ) > space ) return e * 2.5 if ( room * 5 / ( re ) > space ) return e * 5 } }
must have range, room, and width
must have range room and width