Skip to main content

ChartSelection

Struct ChartSelection 

Source
pub struct ChartSelection { /* private fields */ }
Expand description

Point-level selection state for a chart, keyed by (series, point index). See module documentation for semantics.

Implementations§

Source§

impl ChartSelection

Source

pub fn new(mode: SelectionMode) -> Self

Create a new chart selection with the given mode.

Source

pub fn attached<T: 'static>(mode: SelectionMode, model: &ChartModel<T>) -> Self

Create a selection that self-wires to model: every ChartChange the model emits is automatically routed through Self::adjust, so a point removed or shifted upstream never leaves a stale selected index behind. Equivalent to ChartSelection::new(mode) plus model.observe_changes(|c| sel.adjust(c)), minus the easy-to-forget wiring — mirrors how crate::ChartWindow and crate::ChartAggregate self-wire in their own constructors. The manual Self::adjust path still works — call it yourself instead if you’d rather relay through a custom change pipeline.

Source

pub fn attach<T: 'static>(&self, model: &ChartModel<T>)

Subscribe this selection to model’s changes, applying Self::adjust on every ChartChange. The subscription is held internally (shared across clones — see Clone), so it stays alive as long as any handle to this selection does; calling attach again (on this handle or any clone) drops the previous subscription and installs the new one.

The subscription closure captures only selection + anchor, not a full Self — capturing Self would pull in attach_handle too, which holds this very ObserverHandle, forming an Rc cycle that would leak the subscription instead of tearing down when every ChartSelection handle drops.

Source

pub fn mode(&self) -> SelectionMode

The selection mode.

Source

pub fn selection_signal(&self) -> Signal<HashSet<(SeriesId, usize)>>

A clone of the selection signal for reactive binding.

Source

pub fn is_selected(&self, series: SeriesId, index: usize) -> bool

Whether (series, index) is currently selected.

Source

pub fn selected_points(&self) -> Vec<(SeriesId, usize)>

The currently selected points (unordered snapshot).

Source

pub fn count(&self) -> usize

Number of selected points.

Source

pub fn select_point(&self, series: SeriesId, index: usize)

Select a single point, clearing the previous selection and setting the anchor.

Source

pub fn toggle_point(&self, series: SeriesId, index: usize)

Toggle a point (Ctrl+click in Multi mode; acts as select_point in Single mode).

Source

pub fn extend_to(&self, series: SeriesId, target: usize)

Extend the selection from the anchor to (series, target) (for Shift+click). Only extends within the anchor’s own series — if the anchor is unset or belongs to a different series, falls back to a single-point select of (series, target).

Source

pub fn select_points( &self, points: impl IntoIterator<Item = (SeriesId, usize)>, additive: bool, )

Replace the selection with points (or, when additive, union them into the current selection). Used by rubber-band / marquee selection. In Single mode an arbitrary one wins; None mode is a no-op.

Source

pub fn clear(&self)

Clear the selection and anchor.

Source

pub fn adjust(&self, change: &ChartChange)

React to an upstream ChartChange, keeping selection consistent with the model: a removed or wholesale-replaced series drops its selected points (and the anchor, if it pointed there); point insertions/removals shift or drop indices within their series. Series metadata changes (rename/recolor/visibility/move/insert) and in-place point updates never affect which points are selected.

Source

pub fn prune(&self, exists: impl Fn(SeriesId, usize) -> bool)

Drop any selected point for which exists returns false.

Source§

impl ChartSelection

Source

pub fn debug_named(self, _name: impl Into<String>) -> Self

Register this selection with the debug inspector under name. In release builds (!cfg(debug_assertions)) this is a no-op pass-through so call sites stay free of #[cfg] lines.

Idempotent on repeated calls — the latest registration wins. The registration drops automatically when the last ChartSelection handle is freed (the strong adapter Rc lives inside a shared holder; the registry holds only a Weak).

Trait Implementations§

Source§

impl Clone for ChartSelection

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 Debug for ChartSelection

Source§

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

Formats the value using the given formatter. Read more

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> 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.