Skip to main content

nice_scale

Function nice_scale 

Source
pub fn nice_scale(lo: f64, hi: f64, force_zero: bool) -> Scale
Expand description

Picks a “nice” scale (steps of 1, 2 or 5 × 10ⁿ, 4–9 gridlines) covering lo..=hi.

force_zero always includes 0 (columns, bars, areas). Otherwise 0 is still included when the data sits reasonably close to it (min below 5/6 of max), like common spreadsheet behaviour. A little headroom is added past the data so the extreme value doesn’t touch the frame.