pub enum ChartAggregateFn {
Mean,
Sum,
Min,
Max,
First,
Last,
Custom(Rc<dyn Fn(&[f32]) -> f32>),
}Expand description
A reduction applied to the numeric values within one bucket.
Variants§
Mean
Arithmetic mean of the bucket’s values (0.0 for an empty bucket).
Sum
Sum of the bucket’s values.
Min
Smallest value in the bucket.
Max
Largest value in the bucket.
First
The bucket’s first value.
Last
The bucket’s last value.
Custom(Rc<dyn Fn(&[f32]) -> f32>)
A caller-supplied reduction.
Implementations§
Source§impl ChartAggregateFn
impl ChartAggregateFn
Sourcepub fn apply(&self, values: &[f32]) -> f32
pub fn apply(&self, values: &[f32]) -> f32
Apply the reduction to a bucket’s values.
On an empty slice, every built-in variant returns 0.0
(Mean/Min/Max/First/Last) or the empty sum (Sum, also
0.0) — a uniform, unsurprising convention rather than Min/Max
leaking their fold seed (±INFINITY) into a chart value. Custom
returns whatever the supplied closure computes for &[]. No internal
caller actually passes an empty slice — compute_bucket_datum bails
out before calling apply for an empty bucket — so this only bites a
direct caller.