nice method

  1. @override
LinearScale nice([
  1. int count = 10
])
override

Returns nicely rounded domain values.

Implementation

@override
LinearScale nice([int count = 10]) {
  final d = _domain;
  const i0 = 0;
  final i1 = d.length - 1;
  var start = d[i0];
  var stop = d[i1];

  if (stop < start) {
    final temp = start;
    start = stop;
    stop = temp;
  }

  final step = tickStep(start, stop, count);
  if (step > 0) {
    start = (start / step).floor() * step;
    stop = (stop / step).ceil() * step;
  } else if (step < 0) {
    start = (start * step).ceil() / step;
    stop = (stop * step).floor() / step;
  }

  if (d[i0] > d[i1]) {
    _domain[i0] = stop;
    _domain[i1] = start;
  } else {
    _domain[i0] = start;
    _domain[i1] = stop;
  }

  return this;
}