niceAxis function
A rounded axis maximum and step for max split into steps.
Implementation
(double, double) niceAxis(double max, int steps) {
if (max <= 0 || steps <= 0) return (math.max(1, steps).toDouble(), 1);
final double raw = max / steps;
final double mag = math
.pow(10, (math.log(raw) / math.ln10).floor())
.toDouble();
final double n = raw / mag;
final double step =
(n <= 1
? 1
: n <= 2
? 2
: n <= 2.5
? 2.5
: n <= 5
? 5
: 10) *
mag;
return (step * steps, step);
}