I'm calling nice(5) and ticks(5) on a linear scale with a domain of [-4.09, 9.51]. The new domain is [-6, 10] with ticks in steps of 5: [-5, 0, 5, 10].
I would have expected the domain minimum to align with the lowest tick. Is there anything I can do to make this happen?
I did some investigating and found these strange results when niceing domains ranging from [-10,10] to [0,10]:
Starting min | Nice min |
---|
-5.3 | -10 |
-5.2 | -10 |
-5.1 | -10 |
-5 | -10 |
-4.9 | -5 |
-4.8 | -5 |
-4.7 | -5 |
-4.6 | -5 |
-4.5 | -5 |
-4.4 | -5 |
-4.3 | -5 |
-4.2 | -6 |
-4.1 | -6 |
-4 | -6 |
-3.9 | -4 |
-3.8 | -4 |
-3.7 | -4 |
-3.6 | -4 |
-3.5 | -4 |
-3.4 | -4 |
Looks like it jumps down to -6 for a while before going back up to -5 again. In some other testing I've found that it favours even numbers rather than snapping to multiples of 5 at this sized domain.
Sample code for the above:
for (var i = -10; i <= 0; i += 0.1)
console.log("%f %s", i, d3.scale.linear().domain([i, 10]).nice(5).domain()[0])