setLinesByStep method
void
setLinesByStep(
- double step
)
Implementation
void setLinesByStep(double step) {
// Round away float dust (e.g. 0.30000000000000004), keyed off the
// step's own precision.
final decimals = math.max(0, -((math.log(step) / math.ln10).floor()) + 6);
final factor = math.pow(10, decimals.clamp(0, 10)).toDouble();
double clean(double v) => (v * factor).round() / factor;
final sections = ((max! - min!) / step).round();
lines = <double>[
for (var i = 0; i <= sections; i++) clean(min! + step * i),
];
min = clean(min!);
max = clean(max!);
}