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: AxisViewThe visible window of the horizontal axis.
y: AxisViewThe visible window of the vertical axis.
Implementations§
Source§impl PlotView
impl PlotView
Sourcepub fn fit(x: (f64, f64), y: (f64, f64), pad: f64) -> Self
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.
Sourcepub fn project(
self,
p: (f64, f64),
x: Scale,
y: Scale,
rect: Rect,
) -> (f32, f32)
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).
Sourcepub fn unproject(
self,
s: (f32, f32),
x: Scale,
y: Scale,
rect: Rect,
) -> (f64, f64)
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).
Sourcepub fn pan_pixels(self, d: (f32, f32), x: Scale, y: Scale, rect: Rect) -> Self
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.
Sourcepub fn zoom_about(
self,
factor: (f64, f64),
anchor: (f32, f32),
x: Scale,
y: Scale,
rect: Rect,
) -> Self
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.
Trait Implementations§
impl Copy for PlotView
impl StructuralPartialEq for PlotView
Auto Trait Implementations§
impl Freeze for PlotView
impl RefUnwindSafe for PlotView
impl Send for PlotView
impl Sync for PlotView
impl Unpin for PlotView
impl UnsafeUnpin for PlotView
impl UnwindSafe for PlotView
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.