Skip to main content

optionstratlib_visualization/visualization/
config.rs

1use crate::visualization::styles::{ColorScheme, LineStyle};
2use serde::{Deserialize, Serialize};
3
4/// Represents the configuration parameters for a graph or chart visualization.
5///
6/// This struct encapsulates all the settings needed to define how a graph should be
7/// displayed, including its dimensions, labels, styling options, and legend configuration.
8#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
9pub struct GraphConfig {
10    /// The main title of the graph to be displayed
11    pub title: String,
12
13    /// The width of the graph in pixels
14    pub width: u32,
15
16    /// The height of the graph in pixels
17    pub height: u32,
18
19    /// Optional label for the x-axis
20    pub x_label: Option<String>,
21
22    /// Optional label for the y-axis
23    pub y_label: Option<String>,
24
25    /// Optional label for the z-axis (for 3D graphs)
26    pub z_label: Option<String>,
27
28    /// The style of lines used in the graph (solid, dotted, dashed)
29    pub line_style: LineStyle,
30
31    /// The color scheme applied to the graph elements
32    pub color_scheme: ColorScheme,
33
34    /// Optional list of labels for the legend entries
35    pub legend: Option<Vec<String>>,
36
37    /// Flag indicating whether to display the legend
38    pub show_legend: bool,
39}
40
41impl Default for GraphConfig {
42    fn default() -> Self {
43        let title = "Graph".to_string();
44        let legend = None;
45        Self {
46            title,
47            width: 1280,
48            height: 720,
49            x_label: None,
50            y_label: None,
51            z_label: None,
52            line_style: LineStyle::Solid,
53            color_scheme: ColorScheme::Default,
54            legend,
55            show_legend: true,
56        }
57    }
58}