pub struct ScaleTime { /* private fields */ }Expand description
Maps a temporal domain (NaiveDateTime) to a continuous range via linear interpolation on timestamps.
Equivalent to D3’s scaleUtc().
Implementations§
Source§impl ScaleTime
impl ScaleTime
Sourcepub fn new(domain: (NaiveDateTime, NaiveDateTime), range: (f64, f64)) -> Self
pub fn new(domain: (NaiveDateTime, NaiveDateTime), range: (f64, f64)) -> Self
Create a new time scale with the given domain and range.
Sourcepub fn map(&self, value: &NaiveDateTime) -> f64
pub fn map(&self, value: &NaiveDateTime) -> f64
Map a datetime to a range value via linear interpolation on timestamps.
Sourcepub fn invert(&self, value: f64) -> NaiveDateTime
pub fn invert(&self, value: f64) -> NaiveDateTime
Inverse: range value back to NaiveDateTime.
Sourcepub fn ticks(&self, count: usize) -> Vec<NaiveDateTime>
pub fn ticks(&self, count: usize) -> Vec<NaiveDateTime>
Generate nice time ticks. Strategy: convert to timestamps, use linear tick algorithm on the timestamp space, then convert back to NaiveDateTime.
Sourcepub fn domain(&self) -> (NaiveDateTime, NaiveDateTime)
pub fn domain(&self) -> (NaiveDateTime, NaiveDateTime)
Get the domain extent.
Auto Trait Implementations§
impl Freeze for ScaleTime
impl RefUnwindSafe for ScaleTime
impl Send for ScaleTime
impl Sync for ScaleTime
impl Unpin for ScaleTime
impl UnsafeUnpin for ScaleTime
impl UnwindSafe for ScaleTime
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