Skip to main content

PlotView

Struct PlotView 

Source
pub struct PlotView {
    pub x: AxisView,
    pub y: AxisView,
}
Expand description

A plot’s pan/zoom state: the visible window of each axis. Persisted per node and readable with UiState::plot_view — e.g. for the virtual-data pull, where the app loads or resamples its source to cover the window the user has scrolled into (see docs/PLOT2D_PLAN.md, decision 5).

All projection is parameterised by the axis Scales and the plot’s data rect (the inner area the marks draw into, excluding axes and legend), so the same view projects correctly as the layout resizes.

Fields§

§x: AxisView

The visible window of the horizontal axis.

§y: AxisView

The visible window of the vertical axis.

Implementations§

Source§

impl PlotView

Source

pub fn new(x: AxisView, y: AxisView) -> Self

A view with the given per-axis windows.

Source

pub fn fit(x: (f64, f64), y: (f64, f64), pad: f64) -> Self

A view framing the data bounds ((x_min, x_max), (y_min, y_max)) with a fractional pad of headroom added to each axis (e.g. 0.05 for 5%). Degenerate (zero-width) bounds are nudged to a unit window so the view is always usable.

Source

pub fn project( self, p: (f64, f64), x: Scale, y: Scale, rect: Rect, ) -> (f32, f32)

Project a data-space point to a pixel within rect. The vertical axis is screen-inverted (data grows upward, pixels grow downward).

Source

pub fn unproject( self, s: (f32, f32), x: Scale, y: Scale, rect: Rect, ) -> (f64, f64)

Inverse of project: map a pixel within rect back to a data-space point (e.g. for a crosshair readout).

Source

pub fn pan_pixels(self, d: (f32, f32), x: Scale, y: Scale, rect: Rect) -> Self

Pan the view by a pixel delta within rect — the drag gesture. Dragging the content right (dpx > 0) reveals earlier data on the left; dragging it down (dpy > 0) reveals larger values at the top.

Source

pub fn zoom_about( self, factor: (f64, f64), anchor: (f32, f32), x: Scale, y: Scale, rect: Rect, ) -> Self

Zoom about a pixel anchor within rect, keeping the data under the cursor fixed — the wheel/pinch gesture. factor is per-axis (< 1.0 zooms in); pass equal factors for uniform zoom, or 1.0 on one axis to lock it.

Source

pub fn with_y(self, y: AxisView) -> Self

Replace the vertical window — used by Y::autoscale, which refits the value axis to the data visible in the current horizontal window each frame.

Source

pub fn with_x(self, x: AxisView) -> Self

Replace the horizontal window — used by X::autoscale, which refits the time axis to the full data extent each frame while the user hasn’t taken manual X control (the streaming follow-the-data case).

Trait Implementations§

Source§

impl Clone for PlotView

Source§

fn clone(&self) -> PlotView

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 PlotView

Source§

impl Debug for PlotView

Source§

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

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

impl PartialEq for PlotView

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for PlotView

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.