pub struct SeriesBuf { /* private fields */ }Expand description
a time series for line_chart: (t, value) points in a ring that keeps the newest
capacity (a full buffer drops its oldest point on push). Times never decrease (push
refuses an earlier one, so every lookup is a binary search); a value that is not finite
(NaN) is a gap where the line breaks. ver() changes with every change: a chart redraws
only then.
Implementations§
Source§impl SeriesBuf
impl SeriesBuf
Sourcepub fn new(capacity: usize) -> SeriesBuf
pub fn new(capacity: usize) -> SeriesBuf
an empty series that keeps the newest capacity points (at least one)
Sourcepub fn push(&mut self, t: f64, v: f64) -> bool
pub fn push(&mut self, t: f64, v: f64) -> bool
append a point (t: the time, or any x that never decreases; v NaN: a gap); false (nothing added) when t is not finite or earlier than the last point’s
Sourcepub fn iter(
&self,
) -> impl DoubleEndedIterator<Item = (f64, f64)> + ExactSizeIterator + '_
pub fn iter( &self, ) -> impl DoubleEndedIterator<Item = (f64, f64)> + ExactSizeIterator + '_
the points, the oldest first
Sourcepub fn lower_bound(&self, t: f64) -> usize
pub fn lower_bound(&self, t: f64) -> usize
the index of the first point at t or later (len() when there is none)
Sourcepub fn nearest(&self, t: f64) -> Option<usize>
pub fn nearest(&self, t: f64) -> Option<usize>
the index of the point with a finite value nearest to t (of two as near the earlier)
Sourcepub fn min_max(&self) -> Option<(f64, f64)>
pub fn min_max(&self) -> Option<(f64, f64)>
the smallest and the largest finite value (None without one); looks at every point
Sourcepub fn min_max_in(&self, t0: f64, t1: f64) -> Option<(f64, f64)>
pub fn min_max_in(&self, t0: f64, t1: f64) -> Option<(f64, f64)>
the smallest and the largest finite value of the points with t0 <= t <= t1
Sourcepub fn columns(&self, t0: f64, t1: f64, n: usize) -> Vec<SeriesCol>
pub fn columns(&self, t0: f64, t1: f64, n: usize) -> Vec<SeriesCol>
the points with t0 <= t <= t1 in n columns of equal width (t1 belongs to the last): per column the range of its values, its first and its last value. Columns without a point with a value are left out; the work is one pass over the points, the result at most n entries (plus one per gap)