One way to calculate a good step would be to find the value of the most significant digit of the length of the range (i.e. diff = maxVlaue - minValue ) and use it as a step. To calculate the value of the most significant digit, use this simple formula:
pow(10, floor(log10(diff)))
This takes the decimal logarithm of the difference, discards the fractional part, if any, and increments the ten to the extent of this logarithm. For a difference of 7.2165, the calculation will return 1; for 721.65 it will return 100, etc.
One of the drawbacks of this calculation is that the grid pitch for diff from 9.99 and diff from 1.001 will be the same. One way to solve this issue is to calculate the number of grid lines that you get for the step, and reduce the step ten times if the number of lines is not enough (for example, less than three).
source share