charming_fork_zephyr/element/
axis_tick.rs

1use serde::Serialize;
2
3use super::line_style::LineStyle;
4
5#[derive(Serialize)]
6#[serde(rename_all = "camelCase")]
7pub struct AxisTick {
8    #[serde(skip_serializing_if = "Option::is_none")]
9    show: Option<bool>,
10
11    #[serde(skip_serializing_if = "Option::is_none")]
12    split_number: Option<i64>,
13
14    #[serde(skip_serializing_if = "Option::is_none")]
15    length: Option<i64>,
16
17    #[serde(skip_serializing_if = "Option::is_none")]
18    distance: Option<i64>,
19
20    #[serde(skip_serializing_if = "Option::is_none")]
21    line_style: Option<LineStyle>,
22}
23
24impl AxisTick {
25    pub fn new() -> Self {
26        Self {
27            show: None,
28            split_number: None,
29            length: None,
30            distance: None,
31            line_style: None,
32        }
33    }
34
35    pub fn show(mut self, show: bool) -> Self {
36        self.show = Some(show);
37        self
38    }
39
40    pub fn split_number<F: Into<i64>>(mut self, split_number: F) -> Self {
41        self.split_number = Some(split_number.into());
42        self
43    }
44
45    pub fn length<F: Into<i64>>(mut self, length: F) -> Self {
46        self.length = Some(length.into());
47        self
48    }
49
50    pub fn distance<F: Into<i64>>(mut self, distance: F) -> Self {
51        self.distance = Some(distance.into());
52        self
53    }
54
55    pub fn line_style<S: Into<LineStyle>>(mut self, line_style: S) -> Self {
56        self.line_style = Some(line_style.into());
57        self
58    }
59}