tickStep function

double tickStep(
  1. double start,
  2. double stop,
  3. int count
)

Calculates the step size for tick generation.

Implementation

double tickStep(double start, double stop, int count) {
  if (count <= 0) return 0;

  final step0 = (stop - start).abs() / count;
  var step1 = math.pow(10, (math.log(step0) / math.ln10).floor());
  final error = step0 / step1;

  if (error >= _e10) {
    step1 *= 10;
  } else if (error >= _e5) {
    step1 *= 5;
  } else if (error >= _e2) {
    step1 *= 2;
  }

  return stop < start ? -step1.toDouble() : step1.toDouble();
}