pub struct PlotState {
pub annotations: Vec<PlotAnnotation>,
pub measurements: Vec<PlotMeasurement>,
pub measurement: MeasurementConfig,
pub measurement_label_offsets: Vec<[f32; 2]>,
/* private fields */
}Expand description
The interactive state of one plot. Keep it in the application model.
Fields§
§annotations: Vec<PlotAnnotation>Text notes, arrows, spans, and regions.
measurements: Vec<PlotMeasurement>Distance and area measurements drawn over the data.
measurement: MeasurementConfigLive measurement settings. The chart config seeds them until the user edits them.
measurement_label_offsets: Vec<[f32; 2]>Screen offset, in points, the user dragged each measurement label by. Index
aligned with measurements; missing entries mean no offset.
Implementations§
Source§impl PlotState
impl PlotState
Sourcepub fn measurement_label_offset(&self, index: usize) -> Vec2
pub fn measurement_label_offset(&self, index: usize) -> Vec2
The offset, in points, the label of measurement index was dragged by.
Sourcepub fn move_measurement_label(&mut self, index: usize, delta: Vec2)
pub fn move_measurement_label(&mut self, index: usize, delta: Vec2)
Move the label of measurement index by delta points.
Sourcepub fn measurements(&self) -> &[PlotMeasurement]
pub fn measurements(&self) -> &[PlotMeasurement]
Every distance and area measurement, in the order they were added.
Sourcepub fn add_measurement(&mut self, measurement: PlotMeasurement)
pub fn add_measurement(&mut self, measurement: PlotMeasurement)
Add a measurement. The plot draws it on the next frame.
Sourcepub fn remove_measurement(&mut self, index: usize) -> Option<PlotMeasurement>
pub fn remove_measurement(&mut self, index: usize) -> Option<PlotMeasurement>
Remove the measurement at index.
Sourcepub fn pop_measurement(&mut self) -> Option<PlotMeasurement>
pub fn pop_measurement(&mut self) -> Option<PlotMeasurement>
Remove the newest measurement and return it.
Sourcepub fn clear_measurements(&mut self)
pub fn clear_measurements(&mut self)
Remove every measurement.
Sourcepub fn pipeline_mut(&mut self) -> &mut Pipeline
pub fn pipeline_mut(&mut self) -> &mut Pipeline
The filter/transform pipeline, mutably.
Sourcepub fn toggle_filter(&mut self, filter: FilterKind)
pub fn toggle_filter(&mut self, filter: FilterKind)
Enable or disable one filter.
Sourcepub fn set_filter(&mut self, filter: FilterKind, enabled: bool)
pub fn set_filter(&mut self, filter: FilterKind, enabled: bool)
Enable or disable one filter explicitly.
Sourcepub fn set_transform(&mut self, transform: Option<TransformKind>)
pub fn set_transform(&mut self, transform: Option<TransformKind>)
Replace the transform. A new transform clears measurements because the data domain changed.
Sourcepub fn clear_analysis(&mut self)
pub fn clear_analysis(&mut self)
Disable every filter and transform.
Sourcepub fn set_measurement(&mut self, measurement: MeasurementConfig)
pub fn set_measurement(&mut self, measurement: MeasurementConfig)
Replace the live measurement settings and mark them user-edited.
Sourcepub fn clear_overlays(&mut self)
pub fn clear_overlays(&mut self)
Clear every painted overlay: measurements, selection, annotations, and analysis.
Sourcepub fn has_overlays(&self) -> bool
pub fn has_overlays(&self) -> bool
Whether a clear action would remove anything.
Methods from Deref<Target = ViewState>§
Sourcepub fn cached_extent(&self, fingerprint: u64) -> Option<Bounds>
pub fn cached_extent(&self, fingerprint: u64) -> Option<Bounds>
The cached extent of a series with fingerprint, if it is current.
Sourcepub fn legend_hover(&self) -> Option<usize>
pub fn legend_hover(&self) -> Option<usize>
The series whose legend row the pointer is over.
Sourcepub fn legend_hover_start(&self) -> f64
pub fn legend_hover_start(&self) -> f64
When the current legend hover began.
Sourcepub fn set_legend_hover(&mut self, series: Option<usize>, now: f64)
pub fn set_legend_hover(&mut self, series: Option<usize>, now: f64)
Set the hovered legend row and restart the animation when it changes.
Sourcepub fn hovered_series(&self) -> Option<usize>
pub fn hovered_series(&self) -> Option<usize>
The series whose legend row is under the pointer, if any.
Sourcepub fn reset_view(&mut self)
pub fn reset_view(&mut self)
Fit the view to the data again.
Sourcepub fn is_auto(&self) -> bool
pub fn is_auto(&self) -> bool
Whether the view follows the data (no zoom or pan since the last reset).
Sourcepub fn set_view(&mut self, bounds: Bounds)
pub fn set_view(&mut self, bounds: Bounds)
Show bounds (data coordinates, linear axes) on the x and left y axes.
Sourcepub fn set_y2_view(&mut self, min: f64, max: f64)
pub fn set_y2_view(&mut self, min: f64, max: f64)
Show min..=max (data coordinates, linear axis) on the right y axis.
Sourcepub fn pipeline_mut(&mut self) -> &mut Pipeline
pub fn pipeline_mut(&mut self) -> &mut Pipeline
The filter/transform pipeline, mutably.
Sourcepub fn toggle_filter(&mut self, filter: FilterKind)
pub fn toggle_filter(&mut self, filter: FilterKind)
Enable or disable one filter.
Sourcepub fn set_filter(&mut self, filter: FilterKind, enabled: bool)
pub fn set_filter(&mut self, filter: FilterKind, enabled: bool)
Enable or disable one filter explicitly.
Sourcepub fn set_transform(&mut self, transform: Option<TransformKind>)
pub fn set_transform(&mut self, transform: Option<TransformKind>)
Replace the transform.
Sourcepub fn clear_analysis(&mut self)
pub fn clear_analysis(&mut self)
Disable every filter and transform.
Sourcepub fn pin_toolbar(&mut self, pinned: bool)
pub fn pin_toolbar(&mut self, pinned: bool)
Pin the tool ribbon open or let it unroll on hover.
Sourcepub fn collapse_toolbar(&mut self)
pub fn collapse_toolbar(&mut self)
Collapse the ribbon and unpin it.
Sourcepub fn legend_position(&self) -> Option<[f32; 2]>
pub fn legend_position(&self) -> Option<[f32; 2]>
Where the legend was dragged to, as fractions of the room around it.
Sourcepub fn set_legend_position(&mut self, position: Option<[f32; 2]>)
pub fn set_legend_position(&mut self, position: Option<[f32; 2]>)
Place the legend; None returns it to its configured corner.
Whether the legend has hidden the series called name.
Show or hide a series by name.
Sourcepub fn has_overlays(&self) -> bool
pub fn has_overlays(&self) -> bool
Whether the view or the analysis would be cleared by a reset.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for PlotState
Available on crate feature serde only.
impl<'de> Deserialize<'de> for PlotState
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Forget for PlotState
impl Freeze for PlotStatewhere
*const u8 is !null: Freeze,
PhantomData<String>: Freeze,
PhantomData<(u64, Bounds)>: Freeze,
PhantomData<FilterKind>: Freeze,
PhantomData<PlotAnnotation>: Freeze,
PhantomData<PlotMeasurement>: Freeze,
PhantomData<[f32; 2]>: Freeze,
PhantomData<(usize, Rect)>: Freeze,
impl Move for PlotState
impl RefUnwindSafe for PlotState
impl Send for PlotStatewhere
RawVecInner: Send,
impl Sync for PlotStatewhere
RawVecInner: Sync,
impl Unpin for PlotState
impl UnsafeUnpin for PlotStatewhere
*const u8 is !null: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<(u64, Bounds)>: UnsafeUnpin,
PhantomData<FilterKind>: UnsafeUnpin,
PhantomData<PlotAnnotation>: UnsafeUnpin,
PhantomData<PlotMeasurement>: UnsafeUnpin,
PhantomData<[f32; 2]>: UnsafeUnpin,
PhantomData<(usize, Rect)>: UnsafeUnpin,
impl UnwindSafe for PlotStatewhere
RawVecInner: UnwindSafe,
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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