It seems that the caller is not telling you the ranges that he wants.
This way you can change the endpoints until you get it beautifully divisible by the number of shortcuts.
Define "nice." I would call it nice if the labels are disabled:
1. 2^n, for some integer n. eg. ..., .25, .5, 1, 2, 4, 8, 16, ... 2. 10^n, for some integer n. eg. ..., .01, .1, 1, 10, 100 3. n/5 == 0, for some positive integer n, eg, 5, 10, 15, 20, 25, ... 4. n/2 == 0, for some positive integer n, eg, 2, 4, 6, 8, 10, 12, 14, ...
Find the maximum and minimum amount of your data series. Let me call these points:
min_point and max_point.
Now all you have to do is find 3 values:
- start_label, where start_label < min_point and start_label is an integer - end_label, where end_label > max_point and end_label is an integer - label_offset, where label_offset is "nice"
which correspond to the equation:
(end_label - start_label)/label_offset == label_count
There are probably many solutions, so just pick one. In most cases, I am sure you can install
start_label to 0
so just try a different integer
end_label
until the shift is "pleasant"