#[non_exhaustive]pub enum Scale {
Linear,
Log10,
SymLog {
linthresh: f64,
},
Time,
}Expand description
A scale maps data values to the normalized [0, 1] range for axis display.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Linear
Linear mapping from [min, max] to [0, 1].
Log10
Base-10 logarithmic scale. Data must be positive.
SymLog
Symmetric log scale: linear near zero, logarithmic beyond ±linthresh.
Time
Time axis. Values are interpreted as seconds since the Unix epoch (1970-01-01 UTC) and transform linearly; tick labels are rendered as calendar dates/times, with granularity chosen from the visible span.
Implementations§
Source§impl Scale
impl Scale
Sourcepub fn transform(&self, val: f64, min: f64, max: f64) -> f64
pub fn transform(&self, val: f64, min: f64, max: f64) -> f64
Transforms a data value to the [0, 1] range given the axis [min, max].
Values outside [min, max] will map outside [0, 1], which can be used for clipping or extrapolation by the caller.
Sourcepub fn inverse(&self, t: f64, min: f64, max: f64) -> f64
pub fn inverse(&self, t: f64, min: f64, max: f64) -> f64
Inverse transform: maps a normalized [0, 1] value back to data space.
Sourcepub fn requires_positive(&self) -> bool
pub fn requires_positive(&self) -> bool
Returns true if this scale requires strictly positive data values.