Skip to main content

flow_plots/options/
axis.rs

1use crate::PlotRange;
2use derive_builder::Builder;
3use flow_fcs::TransformType;
4
5/// Options for configuring a plot axis
6///
7/// Controls the range, transformation, and label for a single axis.
8///
9/// # Example
10///
11/// ```rust,no_run
12/// use flow_plots::options::AxisOptions;
13/// use flow_fcs::TransformType;
14///
15/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
16/// let axis = AxisOptions::new()
17///     .range(0.0..=200_000.0)
18///     .transform(TransformType::Arcsinh { cofactor: 150.0 })
19///     .label("FSC-A")
20///     .build()?;
21/// # Ok(())
22/// # }
23/// ```
24#[derive(Builder, Clone, Debug)]
25#[builder(setter(into, strip_option), default)]
26pub struct AxisOptions {
27    /// Data range for this axis
28    #[builder(default = "0f32..=200_000f32")]
29    pub range: PlotRange,
30
31    /// Transform to apply to axis labels
32    #[builder(default = "TransformType::default()")]
33    pub transform: TransformType,
34
35    /// Optional axis label
36    pub label: Option<String>,
37}
38
39impl Default for AxisOptions {
40    fn default() -> Self {
41        Self {
42            range: 0f32..=200_000f32,
43            transform: TransformType::default(),
44            label: None,
45        }
46    }
47}
48
49impl AxisOptions {
50    /// Create a new builder for AxisOptions
51    pub fn new() -> AxisOptionsBuilder {
52        AxisOptionsBuilder::default()
53    }
54}