pub struct ScaleLinear { /* private fields */ }Expand description
Maps a continuous domain to a continuous range via linear interpolation.
Equivalent to D3’s scaleLinear().
Implementations§
Source§impl ScaleLinear
impl ScaleLinear
Sourcepub fn new(domain: (f64, f64), range: (f64, f64)) -> Self
pub fn new(domain: (f64, f64), range: (f64, f64)) -> Self
Create a new linear scale with the given domain and range.
Sourcepub fn map(&self, value: f64) -> f64
pub fn map(&self, value: f64) -> f64
Map a domain value to a range value using linear interpolation.
Sourcepub fn ticks(&self, count: usize) -> Vec<f64>
pub fn ticks(&self, count: usize) -> Vec<f64>
Generate approximately count nice tick values using the D3 “nice numbers” algorithm.
Ticks are returned in the same order as the domain (descending if domain is reversed).
Sourcepub fn nice(self, count: usize) -> Self
pub fn nice(self, count: usize) -> Self
Extend the domain to nice round numbers (like D3’s .nice()).
Uses D3’s iterative algorithm (up to 10 passes) so the domain expands
until the tick step stabilises — matching d3-scale’s linearish.nice().
Preserves domain direction (reversed domains stay reversed).
Trait Implementations§
Source§impl ContinuousScale for ScaleLinear
impl ContinuousScale for ScaleLinear
Auto Trait Implementations§
impl Freeze for ScaleLinear
impl RefUnwindSafe for ScaleLinear
impl Send for ScaleLinear
impl Sync for ScaleLinear
impl Unpin for ScaleLinear
impl UnsafeUnpin for ScaleLinear
impl UnwindSafe for ScaleLinear
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