AutoScaler class

Computes "nice" chart axis bounds and gridlines for a data range.

the core rounding idea here - snapping to a step drawn from {1, 2, 5, 10} × 10^n and flooring/ceiling the data bounds to that step - is Paul Heckbert's "Nice Numbers for Graph Labels" algorithm (Graphics Gems I, 1990).

Pipeline:

  1. If the data range is degenerate (min == max), fall back to a nominal range centered on the value.
  2. Apply minSpan: if the data range is narrower than this, widen it. Same-sign data is widened toward zero first (e.g. [100, 100.001] with minSpan: 10 moves min down toward 0 before moving max up); data that already straddles zero is widened symmetrically.
  3. Apply forceZero: if true and the data doesn't already straddle zero, pin the near-zero bound to exactly 0 (min to 0 for non-negative data, max to 0 for non-positive data).
  4. Search "nice" steps (finest first) and floor/ceil the bounds to the first step that keeps the line count within minLines, maxLines.

This rounds to the minimal nice bound that covers the data (e.g. a raw range of 7 becomes 8, not 10) rather than rounding the whole span up to a clean number — deliberately tighter than some "nice axis" examples you'll see elsewhere.

Constructors

AutoScaler()

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

autoFit(ChartScale scale, {required num dataMin, required num dataMax, int minLines = 4, int maxLines = 7, bool forceZero = false, double minSpan = 0}) → void
Computes chart-friendly axis bounds and gridlines.