charming_fork_zephyr/series/
boxplot.rs

1use serde::Serialize;
2
3use crate::element::{ColorBy, CoordinateSystem};
4
5#[derive(Serialize)]
6#[serde(rename_all = "camelCase")]
7pub struct Boxplot {
8    #[serde(rename = "type")]
9    type_: String,
10
11    #[serde(skip_serializing_if = "Option::is_none")]
12    id: Option<String>,
13
14    #[serde(skip_serializing_if = "Option::is_none")]
15    name: Option<String>,
16
17    #[serde(skip_serializing_if = "Option::is_none")]
18    coordinate_system: Option<CoordinateSystem>,
19
20    #[serde(skip_serializing_if = "Option::is_none")]
21    color_by: Option<ColorBy>,
22
23    #[serde(skip_serializing_if = "Option::is_none")]
24    legend_hover_link: Option<bool>,
25
26    #[serde(skip_serializing_if = "Option::is_none")]
27    hover_animation: Option<bool>,
28
29    #[serde(skip_serializing_if = "Option::is_none")]
30    dataset_index: Option<u64>,
31}
32
33impl Boxplot {
34    pub fn new() -> Self {
35        Boxplot {
36            type_: String::from("boxplot"),
37            id: None,
38            name: None,
39            coordinate_system: None,
40            color_by: None,
41            legend_hover_link: None,
42            hover_animation: None,
43            dataset_index: None,
44        }
45    }
46
47    pub fn id<S: Into<String>>(mut self, id: S) -> Self {
48        self.id = Some(id.into());
49        self
50    }
51
52    pub fn name<S: Into<String>>(mut self, name: S) -> Self {
53        self.name = Some(name.into());
54        self
55    }
56
57    pub fn coordinate_system<C: Into<CoordinateSystem>>(mut self, coordinate_system: C) -> Self {
58        self.coordinate_system = Some(coordinate_system.into());
59        self
60    }
61
62    pub fn color_by<C: Into<ColorBy>>(mut self, color_by: C) -> Self {
63        self.color_by = Some(color_by.into());
64        self
65    }
66
67    pub fn legend_hover_link(mut self, legend_hover_link: bool) -> Self {
68        self.legend_hover_link = Some(legend_hover_link);
69        self
70    }
71
72    pub fn hover_animation(mut self, hover_animation: bool) -> Self {
73        self.hover_animation = Some(hover_animation);
74        self
75    }
76
77    pub fn dataset_index(mut self, dataset_index: u64) -> Self {
78        self.dataset_index = Some(dataset_index);
79        self
80    }
81}