Skip to main content

esoc_chart/grammar/
stat.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2//! Statistical transforms applied to data before encoding.
3
4/// A statistical transform.
5#[derive(Clone, Debug)]
6pub enum Stat {
7    /// Identity (no transform).
8    Identity,
9    /// Bin data into histogram buckets.
10    Bin {
11        /// Number of bins.
12        bins: usize,
13    },
14    /// Box plot statistics (quartiles, whiskers).
15    BoxPlot,
16    /// LOESS/local regression smoothing.
17    Smooth {
18        /// Bandwidth parameter.
19        bandwidth: f64,
20    },
21    /// Aggregate (mean, sum, count, etc.).
22    Aggregate {
23        /// Aggregation function.
24        func: AggregateFunc,
25    },
26}
27
28/// Aggregation functions.
29#[derive(Clone, Copy, Debug)]
30pub enum AggregateFunc {
31    /// Count of values.
32    Count,
33    /// Sum of values.
34    Sum,
35    /// Arithmetic mean.
36    Mean,
37    /// Median.
38    Median,
39    /// Minimum.
40    Min,
41    /// Maximum.
42    Max,
43}