Skip to main content

ChartAggregate

Struct ChartAggregate 

Source
pub struct ChartAggregate<T: 'static> { /* private fields */ }
Expand description

A bucket/rollup projection over a ChartModel<T>.

See the module documentation for semantics.

Implementations§

Source§

impl<T: Clone + 'static> ChartAggregate<T>

Source

pub fn new( source: ChartModel<T>, bucket_size: usize, aggregate_fn: ChartAggregateFn, ) -> Self

Wrap source, bucketing every series into groups of bucket_size source points reduced via aggregate_fn. bucket_size is clamped to a minimum of 1.

Source

pub fn set_bucket_size(&self, bucket_size: usize)

Change the bucket size, rebuilding every series and emitting ChartChange::Reset. Clamped to a minimum of 1.

Source

pub fn set_aggregate_fn(&self, aggregate_fn: ChartAggregateFn)

Change the aggregate reduction, rebuilding every series and emitting ChartChange::Reset.

Source§

impl<T: 'static> ChartAggregate<T>

Source

pub fn bucket_size(&self) -> usize

The configured bucket size.

Source

pub fn series_count(&self) -> usize

Number of series (same set as the source).

Source

pub fn series_ids(&self) -> Vec<SeriesId>

The series ids, in the source’s display order.

Source

pub fn point_count(&self, series: SeriesId) -> usize

Number of buckets currently materialized for series.

Source

pub fn with_series<R>( &self, series: SeriesId, f: impl FnOnce(&str, Option<&ColorProp>, bool) -> R, ) -> Option<R>

Access a series’ metadata (delegates straight through to the source). Returns None if series is unknown.

Source

pub fn with_point<R>( &self, series: SeriesId, index: usize, f: impl FnOnce(&ChartDatum<T>) -> R, ) -> Option<R>

Access the bucket at index within series. Returns None if series or index is unknown.

Source

pub fn observe_changes( &self, f: impl Fn(&ChartChange) + 'static, ) -> ObserverHandle

Register an observer for translated bucket changes. Returns an ObserverHandle — dropping it removes the callback.

Source

pub fn first_changed_index(&self, series: SeriesId) -> Option<usize>

First bucket index of series whose content may differ since the latest translated change. None if series is unknown or unaffected yet.

Trait Implementations§

Source§

impl<T: 'static> Clone for ChartAggregate<T>

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<T: 'static> Debug for ChartAggregate<T>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for ChartAggregate<T>

§

impl<T> !Send for ChartAggregate<T>

§

impl<T> !Sync for ChartAggregate<T>

§

impl<T> !UnwindSafe for ChartAggregate<T>

§

impl<T> Freeze for ChartAggregate<T>

§

impl<T> Unpin for ChartAggregate<T>

§

impl<T> UnsafeUnpin for ChartAggregate<T>

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.