#[non_exhaustive]pub enum Scale {
Linear,
Log10,
SymLog {
linthresh: f64,
},
}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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
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.
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.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Scale
impl RefUnwindSafe for Scale
impl Send for Scale
impl Sync for Scale
impl Unpin for Scale
impl UnsafeUnpin for Scale
impl UnwindSafe for Scale
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more