let delta = ticks.length > 3 ? ticks[2].value - ticks[1].value : ticks[1].value - ticks[0].value;
// If we have a number like 2.5 as the delta, figure out how many decimal places we need
- if (Math.abs(delta) > 1 && tickValue !== Math.floor(tickValue)) {
+ if (Math.abs(delta) >= 1 && tickValue !== Math.floor(tickValue)) {
// not an integer
delta = tickValue - Math.floor(tickValue);
}
// The spacing will have changed in cases 1, 2, and 3 so the factor cannot be computed
// until this point
- factor = Math.pow(10, isNullOrUndef(precision) ? _decimalPlaces(spacing) : precision);
+ const decimalPlaces = Math.max(
+ _decimalPlaces(spacing),
+ _decimalPlaces(niceMin),
+ );
+ factor = Math.pow(10, isNullOrUndef(precision) ? decimalPlaces : precision);
niceMin = Math.round(niceMin * factor) / factor;
niceMax = Math.round(niceMax * factor) / factor;