tick_spec = function(lo, hi) -- given an interval of numbers, return a nice set of ticks to draw for the interval -- the ticks will try to be at multiples of 10, or some multiple of a power of 10 -- we don't want to overwhelm the viewer, so we'll aim for between 2 and 4 ticks -- the ticks will be specified as a low and high value, and a delta between consecutive ticks local anchorlo, scale = approximate(lo, order_of_magnitude(hi-lo)) local anchorhi = approximate_up(hi, order_of_magnitude(hi-lo)) -- print('---', lo, hi, order_of_magnitude(hi-lo), anchorlo, anchorhi, scale) while (anchorhi-anchorlo)/scale < 4 do -- print('a', anchorlo, anchorhi, scale, (anchorhi-anchorlo)/scale) scale = scale/2 end while (anchorhi-anchorlo)/scale > 8 do -- print('b', scale, (anchorhi-anchorlo)/scale) scale = scale*2 end -- print('c', scale, (anchorhi-anchorlo)/scale) while vy(anchorlo-scale) > Menu_bar_height+20 do anchorlo = anchorlo-scale end while vy(anchorhi+scale) < App.screen.height-20 do anchorhi = anchorhi+scale end -- print('d', scale, (anchorhi-anchorlo)/scale) return anchorlo, anchorhi, scale end