flow_plots/options/base.rs
1use derive_builder::Builder;
2
3/// Base plot options containing layout and display settings
4///
5/// These options are common to all plot types and control the overall
6/// appearance and layout of the plot.
7///
8/// # Example
9///
10/// ```rust,no_run
11/// use flow_plots::options::BasePlotOptions;
12///
13/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
14/// let base = BasePlotOptions::new()
15/// .width(800u32)
16/// .height(600u32)
17/// .title("My Plot")
18/// .build()?;
19/// # Ok(())
20/// # }
21/// ```
22///
23/// @deprecated The old PlotOptions struct has been removed. Use DensityPlotOptions with builder pattern instead.
24#[derive(Builder, Clone, Debug)]
25#[builder(setter(into, strip_option), default)]
26pub struct BasePlotOptions {
27 /// Plot width in pixels
28 #[builder(default = "400")]
29 pub width: u32,
30
31 /// Plot height in pixels
32 #[builder(default = "400")]
33 pub height: u32,
34
35 /// Margin around the plot area in pixels
36 #[builder(default = "10")]
37 pub margin: u32,
38
39 /// Size of the x-axis label area in pixels
40 #[builder(default = "50")]
41 pub x_label_area_size: u32,
42
43 /// Size of the y-axis label area in pixels
44 #[builder(default = "50")]
45 pub y_label_area_size: u32,
46
47 /// Plot title
48 #[builder(default = "\"Density Plot\".to_string()")]
49 pub title: String,
50}
51
52impl Default for BasePlotOptions {
53 fn default() -> Self {
54 Self {
55 width: 400,
56 height: 400,
57 margin: 10,
58 x_label_area_size: 50,
59 y_label_area_size: 50,
60 title: "Density Plot".to_string(),
61 }
62 }
63}
64
65impl BasePlotOptions {
66 /// Create a new builder for BasePlotOptions
67 pub fn new() -> BasePlotOptionsBuilder {
68 BasePlotOptionsBuilder::default()
69 }
70}