dataviz\figure\configuration/
figureconfig.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/// Configuration structure for customizing the appearance of a figure.
#[derive(Clone)]
pub struct FigureConfig {
    /// Number of ticks along the axes.
    pub num_axis_ticks: usize,
    /// Number of horizontal grid lines.
    pub num_grid_horizontal: usize,
    /// Number of vertical grid lines.
    pub num_grid_vertical: usize,
    /// Color of the grid lines in RGB format.
    pub color_grid: [u8; 3],
    /// Color of the axes in RGB format.
    pub color_axis: [u8; 3],
    /// Background color of the figure in RGB format.
    pub color_background: [u8; 3],
    /// Color of the title text in RGB format.
    pub color_title: [u8; 3],
    /// Font size for labels.
    pub font_size_label: f32,
    /// Font size for the title.
    pub font_size_title: f32,
    /// Font size for the legend text.
    pub font_size_legend: f32,
    /// Font size for axis labels.
    pub font_size_axis: f32,
    /// File path to the font used for labels.
    pub font_label: String,
    /// File path to the font used for the title.
    pub font_title: String,
}

impl Default for FigureConfig {
    /// Provides a default configuration for a figure.
    ///
    /// # Default Values
    /// - `num_axis_ticks`: 10
    /// - `num_grid_horizontal`: 10
    /// - `num_grid_vertical`: 10
    /// - `color_grid`: `[200, 200, 200]` (light gray)
    /// - `color_axis`: `[0, 0, 0]` (black)
    /// - `color_background`: `[255, 255, 255]` (white)
    /// - `color_title`: `[0, 0, 0]` (black)
    /// - `font_size_label`: 12.0
    /// - `font_size_title`: 24.0
    /// - `font_size_legend`: 10.0
    /// - `font_size_axis`: 10.0
    /// - `font_label`: `../../resources/fonts/Arial.ttf`
    /// - `font_title`: `../../resources/fonts/Arial.ttf`
    ///
    /// # Returns
    /// A `FigureConfig` instance with default settings.
    fn default() -> Self {
        Self {
            num_axis_ticks: 10,
            num_grid_horizontal: 10,
            num_grid_vertical: 10,
            color_grid: [200, 200, 200],       // Light gray
            color_axis: [0, 0, 0],             // Black
            color_background: [255, 255, 255], // White
            color_title: [0, 0, 0],            // Black
            font_size_label: 12.0,
            font_size_title: 24.0,
            font_size_legend: 10.0,
            font_size_axis: 10.0,
            font_label: "../../../resources/fonts/Arial.ttf".to_string(),
            font_title: "../../../resources/fonts/Arial.ttf".to_string(),
        }
    }
}