pub struct Viewport { /* private fields */ }Expand description
The visible time range [start, end] of a chart.
While following, new data keeps the newest sample at the right edge (less a small
margin). Panning back in time stops following; Chart turns it back on when
the view is panned or zoomed back to the newest sample.
Implementations§
Source§impl Viewport
impl Viewport
Sourcepub fn new(start: Timestamp, end: Timestamp) -> Viewport
pub fn new(start: Timestamp, end: Timestamp) -> Viewport
A following viewport over [start, end].
Sourcepub fn is_following(&self) -> bool
pub fn is_following(&self) -> bool
Whether new data scrolls the view.
Sourcepub fn set_following(&mut self, following: bool)
pub fn set_following(&mut self, following: bool)
Turns following on or off.
Sourcepub fn right_margin(&self) -> f64
pub fn right_margin(&self) -> f64
The fraction of the span left empty to the right of the newest sample while following.
Sourcepub fn set_right_margin(&mut self, fraction: f64)
pub fn set_right_margin(&mut self, fraction: f64)
Sets the right margin (clamped to 0.0..=0.5).
Sourcepub fn set_span_limits(&mut self, min_span: i64, max_span: i64)
pub fn set_span_limits(&mut self, min_span: i64, max_span: i64)
Limits how far zoom can go in and out, in milliseconds.
Sourcepub fn set_range(&mut self, start: Timestamp, end: Timestamp)
pub fn set_range(&mut self, start: Timestamp, end: Timestamp)
Shows [start, end], keeping the centre if the span has to be clamped.
Sourcepub fn pan(&mut self, delta: i64)
pub fn pan(&mut self, delta: i64)
Moves the window by delta milliseconds (positive is later). Moving back stops following.
Sourcepub fn pan_fraction(&mut self, fraction: f64)
pub fn pan_fraction(&mut self, fraction: f64)
Moves the window by a fraction of its span (positive is later).
Sourcepub fn pan_pixels(&mut self, dx: f64, width: f64)
pub fn pan_pixels(&mut self, dx: f64, width: f64)
Moves the window for a drag of dx pixels across a plot width pixels wide:
dragging right shows earlier times.
Sourcepub fn zoom(&mut self, factor: f64, anchor: f64)
pub fn zoom(&mut self, factor: f64, anchor: f64)
Scales the span by factor (below 1 zooms in) keeping the time at anchor (a fraction
of the width, 0 is the left edge) in place.
Sourcepub fn zoom_at_pixel(&mut self, factor: f64, x: f64, width: f64)
pub fn zoom_at_pixel(&mut self, factor: f64, x: f64, width: f64)
zoom around pixel x of a plot width pixels wide.
Sourcepub fn follow_to(&mut self, latest: Timestamp)
pub fn follow_to(&mut self, latest: Timestamp)
While following, shifts the window so latest sits at the right edge less the margin.
Sourcepub fn time_at(&self, x: f64, left: f64, width: f64) -> Timestamp
pub fn time_at(&self, x: f64, left: f64, width: f64) -> Timestamp
The time at pixel x of a plot from left that is width pixels wide.
Sourcepub fn scale(&self, x0: f64, x1: f64) -> LinearScale
pub fn scale(&self, x0: f64, x1: f64) -> LinearScale
A scale from this window onto [x0, x1].
Trait Implementations§
impl Copy for Viewport
impl StructuralPartialEq for Viewport
Auto Trait Implementations§
impl Forget for Viewport
impl Freeze for Viewport
impl Move for Viewport
impl RefUnwindSafe for Viewport
impl Send for Viewport
impl Sync for Viewport
impl Unpin for Viewport
impl UnsafeUnpin for Viewport
impl UnwindSafe for Viewport
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
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> ⓘ
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> ⓘ
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