Skip to main content

Viewport

Struct Viewport 

Source
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

Source

pub fn new(start: Timestamp, end: Timestamp) -> Viewport

A following viewport over [start, end].

Source

pub fn start(&self) -> Timestamp

The first visible time.

Source

pub fn end(&self) -> Timestamp

The last visible time.

Source

pub fn span(&self) -> i64

end - start, at least 1.

Source

pub fn is_following(&self) -> bool

Whether new data scrolls the view.

Source

pub fn set_following(&mut self, following: bool)

Turns following on or off.

Source

pub fn right_margin(&self) -> f64

The fraction of the span left empty to the right of the newest sample while following.

Source

pub fn set_right_margin(&mut self, fraction: f64)

Sets the right margin (clamped to 0.0..=0.5).

Source

pub fn set_span_limits(&mut self, min_span: i64, max_span: i64)

Limits how far zoom can go in and out, in milliseconds.

Source

pub fn set_range(&mut self, start: Timestamp, end: Timestamp)

Shows [start, end], keeping the centre if the span has to be clamped.

Source

pub fn pan(&mut self, delta: i64)

Moves the window by delta milliseconds (positive is later). Moving back stops following.

Source

pub fn pan_fraction(&mut self, fraction: f64)

Moves the window by a fraction of its span (positive is later).

Source

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.

Source

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.

Source

pub fn zoom_at_pixel(&mut self, factor: f64, x: f64, width: f64)

zoom around pixel x of a plot width pixels wide.

Source

pub fn follow_to(&mut self, latest: Timestamp)

While following, shifts the window so latest sits at the right edge less the margin.

Source

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.

Source

pub fn scale(&self, x0: f64, x1: f64) -> LinearScale

A scale from this window onto [x0, x1].

Trait Implementations§

Source§

impl Clone for Viewport

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Viewport

Source§

impl Debug for Viewport

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Viewport

Source§

fn default() -> Self

The last hour before the Unix epoch, following.

Source§

impl PartialEq for Viewport

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Viewport

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.