charming_fork_zephyr/element/
axis_label.rs1use serde::Serialize;
2
3use super::{color::Color, Formatter};
4
5#[derive(Serialize)]
6#[serde(rename_all = "camelCase")]
7pub struct AxisLabel {
8 #[serde(skip_serializing_if = "Option::is_none")]
9 show: Option<bool>,
10
11 #[serde(skip_serializing_if = "Option::is_none")]
12 distance: Option<i64>,
13
14 #[serde(skip_serializing_if = "Option::is_none")]
15 font_size: Option<i64>,
16
17 #[serde(skip_serializing_if = "Option::is_none")]
18 color: Option<Color>,
19
20 #[serde(skip_serializing_if = "Option::is_none")]
21 formatter: Option<Formatter>,
22
23 #[serde(skip_serializing_if = "Option::is_none")]
24 rotate: Option<i64>,
25
26 #[serde(skip_serializing_if = "Option::is_none")]
27 interval: Option<i64>,
28}
29
30impl AxisLabel {
31 pub fn new() -> Self {
32 Self {
33 show: None,
34 distance: None,
35 font_size: None,
36 color: None,
37 formatter: None,
38 rotate: None,
39 interval: None,
40 }
41 }
42
43 pub fn show(mut self, show: bool) -> Self {
44 self.show = Some(show);
45 self
46 }
47
48 pub fn distance<F: Into<i64>>(mut self, distance: F) -> Self {
49 self.distance = Some(distance.into());
50 self
51 }
52
53 pub fn font_size<F: Into<i64>>(mut self, font_size: F) -> Self {
54 self.font_size = Some(font_size.into());
55 self
56 }
57
58 pub fn color<C: Into<Color>>(mut self, color: C) -> Self {
59 self.color = Some(color.into());
60 self
61 }
62
63 pub fn formatter<F: Into<Formatter>>(mut self, formatter: F) -> Self {
64 self.formatter = Some(formatter.into());
65 self
66 }
67
68 pub fn rotate<F: Into<i64>>(mut self, rotate: F) -> Self {
69 self.rotate = Some(rotate.into());
70 self
71 }
72
73 pub fn interval<F: Into<i64>>(mut self, interval: F) -> Self {
74 self.interval = Some(interval.into());
75 self
76 }
77}