charming_fork_zephyr/component/
parallel_coordinate.rs

1use serde::Serialize;
2
3use crate::{
4    datatype::CompositeValue,
5    element::{
6        AxisLabel, AxisLine, AxisTick, AxisType, BoundaryGap, NameLocation, ParallelLayout,
7        SplitLine, TextStyle,
8    },
9};
10
11#[derive(Serialize)]
12#[serde(rename_all = "camelCase")]
13pub struct ParallelAxisDefault {
14    #[serde(skip_serializing_if = "Option::is_none")]
15    #[serde(rename = "type")]
16    type_: Option<AxisType>,
17
18    #[serde(skip_serializing_if = "Option::is_none")]
19    name: Option<String>,
20
21    #[serde(skip_serializing_if = "Option::is_none")]
22    name_location: Option<NameLocation>,
23
24    #[serde(skip_serializing_if = "Option::is_none")]
25    name_text_style: Option<TextStyle>,
26
27    #[serde(skip_serializing_if = "Option::is_none")]
28    name_gap: Option<i64>,
29
30    #[serde(skip_serializing_if = "Option::is_none")]
31    name_rotate: Option<i64>,
32
33    #[serde(skip_serializing_if = "Option::is_none")]
34    inverse: Option<bool>,
35
36    #[serde(skip_serializing_if = "Option::is_none")]
37    boundary_gap: Option<BoundaryGap>,
38
39    #[serde(skip_serializing_if = "Option::is_none")]
40    min: Option<i64>,
41
42    #[serde(skip_serializing_if = "Option::is_none")]
43    max: Option<i64>,
44
45    #[serde(skip_serializing_if = "Option::is_none")]
46    scale: Option<bool>,
47
48    #[serde(skip_serializing_if = "Option::is_none")]
49    split_number: Option<i64>,
50
51    #[serde(skip_serializing_if = "Option::is_none")]
52    min_interval: Option<i64>,
53
54    #[serde(skip_serializing_if = "Option::is_none")]
55    max_interval: Option<i64>,
56
57    #[serde(skip_serializing_if = "Option::is_none")]
58    interval: Option<i64>,
59
60    #[serde(skip_serializing_if = "Option::is_none")]
61    log_base: Option<i64>,
62
63    #[serde(skip_serializing_if = "Option::is_none")]
64    silent: Option<bool>,
65
66    #[serde(skip_serializing_if = "Option::is_none")]
67    trigger_event: Option<bool>,
68
69    #[serde(skip_serializing_if = "Option::is_none")]
70    axis_line: Option<AxisLine>,
71
72    #[serde(skip_serializing_if = "Option::is_none")]
73    axis_tick: Option<AxisTick>,
74
75    #[serde(skip_serializing_if = "Option::is_none")]
76    axis_label: Option<AxisLabel>,
77
78    #[serde(skip_serializing_if = "Option::is_none")]
79    split_line: Option<SplitLine>,
80
81    #[serde(skip_serializing_if = "Vec::is_empty")]
82    data: Vec<String>,
83}
84
85impl ParallelAxisDefault {
86    pub fn new() -> Self {
87        Self {
88            type_: None,
89            name: None,
90            name_location: None,
91            name_text_style: None,
92            name_gap: None,
93            name_rotate: None,
94            inverse: None,
95            boundary_gap: None,
96            min: None,
97            max: None,
98            scale: None,
99            split_number: None,
100            min_interval: None,
101            max_interval: None,
102            interval: None,
103            log_base: None,
104            silent: None,
105            trigger_event: None,
106            axis_line: None,
107            axis_tick: None,
108            axis_label: None,
109            split_line: None,
110            data: vec![],
111        }
112    }
113
114    pub fn type_<S: Into<AxisType>>(mut self, type_: S) -> Self {
115        self.type_ = Some(type_.into());
116        self
117    }
118
119    pub fn name<S: Into<String>>(mut self, name: S) -> Self {
120        self.name = Some(name.into());
121        self
122    }
123
124    pub fn name_location<S: Into<NameLocation>>(mut self, name_location: S) -> Self {
125        self.name_location = Some(name_location.into());
126        self
127    }
128
129    pub fn name_text_style<T: Into<TextStyle>>(mut self, name_text_style: T) -> Self {
130        self.name_text_style = Some(name_text_style.into());
131        self
132    }
133
134    pub fn name_gap<F: Into<i64>>(mut self, name_gap: F) -> Self {
135        self.name_gap = Some(name_gap.into());
136        self
137    }
138
139    pub fn name_rotate<F: Into<i64>>(mut self, name_rotate: F) -> Self {
140        self.name_rotate = Some(name_rotate.into());
141        self
142    }
143
144    pub fn inverse(mut self, inverse: bool) -> Self {
145        self.inverse = Some(inverse);
146        self
147    }
148
149    pub fn boundary_gap<B: Into<BoundaryGap>>(mut self, boundary_gap: B) -> Self {
150        self.boundary_gap = Some(boundary_gap.into());
151        self
152    }
153
154    pub fn min<F: Into<i64>>(mut self, min: F) -> Self {
155        self.min = Some(min.into());
156        self
157    }
158
159    pub fn max<F: Into<i64>>(mut self, max: F) -> Self {
160        self.max = Some(max.into());
161        self
162    }
163
164    pub fn scale(mut self, scale: bool) -> Self {
165        self.scale = Some(scale);
166        self
167    }
168
169    pub fn split_number<F: Into<i64>>(mut self, split_number: F) -> Self {
170        self.split_number = Some(split_number.into());
171        self
172    }
173
174    pub fn min_interval<F: Into<i64>>(mut self, min_interval: F) -> Self {
175        self.min_interval = Some(min_interval.into());
176        self
177    }
178
179    pub fn max_interval<F: Into<i64>>(mut self, max_interval: F) -> Self {
180        self.max_interval = Some(max_interval.into());
181        self
182    }
183
184    pub fn interval<F: Into<i64>>(mut self, interval: F) -> Self {
185        self.interval = Some(interval.into());
186        self
187    }
188
189    pub fn log_base<F: Into<i64>>(mut self, log_base: F) -> Self {
190        self.log_base = Some(log_base.into());
191        self
192    }
193
194    pub fn silent(mut self, silent: bool) -> Self {
195        self.silent = Some(silent);
196        self
197    }
198
199    pub fn trigger_event(mut self, trigger_event: bool) -> Self {
200        self.trigger_event = Some(trigger_event);
201        self
202    }
203
204    pub fn axis_line<A: Into<AxisLine>>(mut self, axis_line: A) -> Self {
205        self.axis_line = Some(axis_line.into());
206        self
207    }
208
209    pub fn axis_tick<A: Into<AxisTick>>(mut self, axis_tick: A) -> Self {
210        self.axis_tick = Some(axis_tick.into());
211        self
212    }
213
214    pub fn axis_label<A: Into<AxisLabel>>(mut self, axis_label: A) -> Self {
215        self.axis_label = Some(axis_label.into());
216        self
217    }
218
219    pub fn split_line<S: Into<SplitLine>>(mut self, split_line: S) -> Self {
220        self.split_line = Some(split_line.into());
221        self
222    }
223
224    pub fn data<S: Into<String>>(mut self, data: Vec<S>) -> Self {
225        self.data = data.into_iter().map(|s| s.into()).collect();
226        self
227    }
228}
229
230#[derive(Serialize)]
231#[serde(rename_all = "camelCase")]
232pub struct ParallelCoordinate {
233    #[serde(skip_serializing_if = "Option::is_none")]
234    id: Option<String>,
235
236    #[serde(skip_serializing_if = "Option::is_none")]
237    zlevel: Option<i64>,
238
239    #[serde(skip_serializing_if = "Option::is_none")]
240    z: Option<i64>,
241
242    #[serde(skip_serializing_if = "Option::is_none")]
243    left: Option<CompositeValue>,
244
245    #[serde(skip_serializing_if = "Option::is_none")]
246    top: Option<CompositeValue>,
247
248    #[serde(skip_serializing_if = "Option::is_none")]
249    right: Option<CompositeValue>,
250
251    #[serde(skip_serializing_if = "Option::is_none")]
252    bottom: Option<CompositeValue>,
253
254    #[serde(skip_serializing_if = "Option::is_none")]
255    width: Option<CompositeValue>,
256
257    #[serde(skip_serializing_if = "Option::is_none")]
258    height: Option<CompositeValue>,
259
260    #[serde(skip_serializing_if = "Option::is_none")]
261    layout: Option<ParallelLayout>,
262
263    #[serde(skip_serializing_if = "Option::is_none")]
264    parallel_axis_default: Option<ParallelAxisDefault>,
265}
266
267impl ParallelCoordinate {
268    pub fn new() -> Self {
269        Self {
270            id: None,
271            zlevel: None,
272            z: None,
273            left: None,
274            top: None,
275            right: None,
276            bottom: None,
277            width: None,
278            height: None,
279            layout: None,
280            parallel_axis_default: None,
281        }
282    }
283
284    pub fn id<S: Into<String>>(mut self, id: S) -> Self {
285        self.id = Some(id.into());
286        self
287    }
288
289    pub fn zlevel<F: Into<i64>>(mut self, zlevel: F) -> Self {
290        self.zlevel = Some(zlevel.into());
291        self
292    }
293
294    pub fn z<F: Into<i64>>(mut self, z: F) -> Self {
295        self.z = Some(z.into());
296        self
297    }
298
299    pub fn left<C: Into<CompositeValue>>(mut self, left: C) -> Self {
300        self.left = Some(left.into());
301        self
302    }
303
304    pub fn top<C: Into<CompositeValue>>(mut self, top: C) -> Self {
305        self.top = Some(top.into());
306        self
307    }
308
309    pub fn right<C: Into<CompositeValue>>(mut self, right: C) -> Self {
310        self.right = Some(right.into());
311        self
312    }
313
314    pub fn bottom<C: Into<CompositeValue>>(mut self, bottom: C) -> Self {
315        self.bottom = Some(bottom.into());
316        self
317    }
318
319    pub fn width<C: Into<CompositeValue>>(mut self, width: C) -> Self {
320        self.width = Some(width.into());
321        self
322    }
323
324    pub fn height<C: Into<CompositeValue>>(mut self, height: C) -> Self {
325        self.height = Some(height.into());
326        self
327    }
328
329    pub fn layout<L: Into<ParallelLayout>>(mut self, layout: L) -> Self {
330        self.layout = Some(layout.into());
331        self
332    }
333
334    pub fn parallel_axis_default<A: Into<ParallelAxisDefault>>(
335        mut self,
336        parallel_axis_default: A,
337    ) -> Self {
338        self.parallel_axis_default = Some(parallel_axis_default.into());
339        self
340    }
341}