charming_fork_zephyr/component/
data_zoom.rs

1use serde::Serialize;
2
3use crate::{
4    datatype::CompositeValue,
5    element::{Color, DataBackground, Orient, TextStyle},
6};
7
8#[derive(Serialize)]
9#[serde(rename_all = "camelCase")]
10pub enum FilterMode {
11    Filter,
12    WeakFilter,
13    Empty,
14    None,
15}
16
17#[derive(Serialize)]
18#[serde(rename_all = "snake_case")]
19pub enum DataZoomType {
20    Inside,
21    Slider,
22    Select,
23}
24
25/// DataZoom component is used for zooming a specific area, which enables user
26/// to investigate data in detail, or get an overview of the data, or get rid
27/// of outlier points.
28#[derive(Serialize)]
29#[serde(rename_all = "camelCase")]
30pub struct DataZoom {
31    #[serde(skip_serializing_if = "Option::is_none")]
32    #[serde(rename = "type")]
33    type_: Option<DataZoomType>,
34
35    /// Component ID.
36    #[serde(skip_serializing_if = "Option::is_none")]
37    id: Option<String>,
38
39    /// Whether to show the component.
40    #[serde(skip_serializing_if = "Option::is_none")]
41    show: Option<bool>,
42
43    /// Whether to enable real-time view update.
44    #[serde(skip_serializing_if = "Option::is_none")]
45    realtime: Option<bool>,
46
47    /// Background color of the component.
48    #[serde(skip_serializing_if = "Option::is_none")]
49    background_color: Option<Color>,
50
51    /// Style of the data shadow.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    data_background: Option<DataBackground>,
54
55    /// Style of the selected data shadow.
56    #[serde(skip_serializing_if = "Option::is_none")]
57    selected_data_background: Option<DataBackground>,
58
59    /// Color to fill selected area.
60    #[serde(skip_serializing_if = "Option::is_none")]
61    filler_color: Option<Color>,
62
63    /// Color of border.
64    #[serde(skip_serializing_if = "Option::is_none")]
65    border_color: Option<Color>,
66
67    #[serde(skip_serializing_if = "Option::is_none")]
68    start: Option<i64>,
69
70    #[serde(skip_serializing_if = "Option::is_none")]
71    end: Option<i64>,
72
73    #[serde(skip_serializing_if = "Option::is_none")]
74    start_value: Option<i64>,
75
76    #[serde(skip_serializing_if = "Option::is_none")]
77    end_value: Option<i64>,
78
79    #[serde(skip_serializing_if = "Option::is_none")]
80    min_span: Option<i64>,
81
82    #[serde(skip_serializing_if = "Option::is_none")]
83    max_span: Option<i64>,
84
85    #[serde(skip_serializing_if = "Option::is_none")]
86    min_value_span: Option<i64>,
87
88    #[serde(skip_serializing_if = "Option::is_none")]
89    max_value_span: Option<i64>,
90
91    #[serde(skip_serializing_if = "Option::is_none")]
92    orient: Option<Orient>,
93
94    #[serde(skip_serializing_if = "Option::is_none")]
95    zoom_lock: Option<bool>,
96
97    #[serde(skip_serializing_if = "Option::is_none")]
98    throttle: Option<i64>,
99
100    #[serde(skip_serializing_if = "Option::is_none")]
101    left: Option<CompositeValue>,
102
103    #[serde(skip_serializing_if = "Option::is_none")]
104    top: Option<CompositeValue>,
105
106    #[serde(skip_serializing_if = "Option::is_none")]
107    right: Option<CompositeValue>,
108
109    #[serde(skip_serializing_if = "Option::is_none")]
110    bottom: Option<CompositeValue>,
111
112    #[serde(skip_serializing_if = "Option::is_none")]
113    x_axis_index: Option<CompositeValue>,
114
115    #[serde(skip_serializing_if = "Option::is_none")]
116    y_axis_index: Option<CompositeValue>,
117
118    #[serde(skip_serializing_if = "Option::is_none")]
119    disabled: Option<bool>,
120
121    #[serde(skip_serializing_if = "Option::is_none")]
122    radius_axis_index: Option<i64>,
123
124    #[serde(skip_serializing_if = "Option::is_none")]
125    angle_axis_index: Option<i64>,
126
127    #[serde(skip_serializing_if = "Option::is_none")]
128    filter_mode: Option<FilterMode>,
129
130    #[serde(skip_serializing_if = "Option::is_none")]
131    text_style: Option<TextStyle>,
132
133    #[serde(skip_serializing_if = "Option::is_none")]
134    handle_icon: Option<String>,
135
136    #[serde(skip_serializing_if = "Option::is_none")]
137    brush_select: Option<bool>,
138}
139
140impl DataZoom {
141    pub fn new() -> Self {
142        Self {
143            type_: None,
144            id: None,
145            show: None,
146            realtime: None,
147            background_color: None,
148            data_background: None,
149            selected_data_background: None,
150            filler_color: None,
151            border_color: None,
152            start: None,
153            end: None,
154            start_value: None,
155            end_value: None,
156            min_span: None,
157            max_span: None,
158            min_value_span: None,
159            max_value_span: None,
160            orient: None,
161            zoom_lock: None,
162            throttle: None,
163            left: None,
164            top: None,
165            right: None,
166            bottom: None,
167            x_axis_index: None,
168            y_axis_index: None,
169            disabled: None,
170            radius_axis_index: None,
171            angle_axis_index: None,
172            filter_mode: None,
173            text_style: None,
174            handle_icon: None,
175            brush_select: None,
176        }
177    }
178
179    pub fn type_<T: Into<DataZoomType>>(mut self, type_: T) -> Self {
180        self.type_ = Some(type_.into());
181        self
182    }
183
184    pub fn id<S: Into<String>>(mut self, id: S) -> Self {
185        self.id = Some(id.into());
186        self
187    }
188
189    pub fn show(mut self, show: bool) -> Self {
190        self.show = Some(show);
191        self
192    }
193
194    pub fn realtime(mut self, realtime: bool) -> Self {
195        self.realtime = Some(realtime);
196        self
197    }
198
199    pub fn background_color<C: Into<Color>>(mut self, background_color: C) -> Self {
200        self.background_color = Some(background_color.into());
201        self
202    }
203
204    pub fn data_background<D: Into<DataBackground>>(mut self, data_background: D) -> Self {
205        self.data_background = Some(data_background.into());
206        self
207    }
208
209    pub fn selected_data_background<D: Into<DataBackground>>(
210        mut self,
211        selected_data_background: D,
212    ) -> Self {
213        self.selected_data_background = Some(selected_data_background.into());
214        self
215    }
216
217    pub fn filler_color<C: Into<Color>>(mut self, filler_color: C) -> Self {
218        self.filler_color = Some(filler_color.into());
219        self
220    }
221
222    pub fn border_color<C: Into<Color>>(mut self, border_color: C) -> Self {
223        self.border_color = Some(border_color.into());
224        self
225    }
226
227    pub fn start<F: Into<i64>>(mut self, start: F) -> Self {
228        self.start = Some(start.into());
229        self
230    }
231
232    pub fn end<F: Into<i64>>(mut self, end: F) -> Self {
233        self.end = Some(end.into());
234        self
235    }
236
237    pub fn start_value<F: Into<i64>>(mut self, start_value: F) -> Self {
238        self.start_value = Some(start_value.into());
239        self
240    }
241
242    pub fn end_value<F: Into<i64>>(mut self, end_value: F) -> Self {
243        self.end_value = Some(end_value.into());
244        self
245    }
246
247    pub fn min_span<F: Into<i64>>(mut self, min_span: F) -> Self {
248        self.min_span = Some(min_span.into());
249        self
250    }
251
252    pub fn max_span<F: Into<i64>>(mut self, max_span: F) -> Self {
253        self.max_span = Some(max_span.into());
254        self
255    }
256
257    pub fn min_value_span<F: Into<i64>>(mut self, min_value_span: F) -> Self {
258        self.min_value_span = Some(min_value_span.into());
259        self
260    }
261
262    pub fn max_value_span<F: Into<i64>>(mut self, max_value_span: F) -> Self {
263        self.max_value_span = Some(max_value_span.into());
264        self
265    }
266
267    pub fn orient<O: Into<Orient>>(mut self, orient: O) -> Self {
268        self.orient = Some(orient.into());
269        self
270    }
271
272    pub fn zoom_lock(mut self, zoom_lock: bool) -> Self {
273        self.zoom_lock = Some(zoom_lock);
274        self
275    }
276
277    pub fn throttle<F: Into<i64>>(mut self, throttle: F) -> Self {
278        self.throttle = Some(throttle.into());
279        self
280    }
281
282    pub fn left<C: Into<CompositeValue>>(mut self, left: C) -> Self {
283        self.left = Some(left.into());
284        self
285    }
286
287    pub fn top<C: Into<CompositeValue>>(mut self, top: C) -> Self {
288        self.top = Some(top.into());
289        self
290    }
291
292    pub fn right<C: Into<CompositeValue>>(mut self, right: C) -> Self {
293        self.right = Some(right.into());
294        self
295    }
296
297    pub fn bottom<C: Into<CompositeValue>>(mut self, bottom: C) -> Self {
298        self.bottom = Some(bottom.into());
299        self
300    }
301
302    pub fn x_axis_index<C: Into<CompositeValue>>(mut self, x_axis_index: C) -> Self {
303        self.x_axis_index = Some(x_axis_index.into());
304        self
305    }
306
307    pub fn y_axis_index<C: Into<CompositeValue>>(mut self, y_axis_index: C) -> Self {
308        self.y_axis_index = Some(y_axis_index.into());
309        self
310    }
311
312    pub fn disabled(mut self, disabled: bool) -> Self {
313        self.disabled = Some(disabled);
314        self
315    }
316
317    pub fn radius_axis_index<F: Into<i64>>(mut self, radius_axis_index: F) -> Self {
318        self.radius_axis_index = Some(radius_axis_index.into());
319        self
320    }
321
322    pub fn angle_axis_index<F: Into<i64>>(mut self, angle_axis_index: F) -> Self {
323        self.angle_axis_index = Some(angle_axis_index.into());
324        self
325    }
326
327    pub fn filter_mode<F: Into<FilterMode>>(mut self, filter_mode: F) -> Self {
328        self.filter_mode = Some(filter_mode.into());
329        self
330    }
331
332    pub fn text_style<T: Into<TextStyle>>(mut self, text_style: T) -> Self {
333        self.text_style = Some(text_style.into());
334        self
335    }
336
337    pub fn handle_icon<S: Into<String>>(mut self, handle_icon: S) -> Self {
338        self.handle_icon = Some(handle_icon.into());
339        self
340    }
341
342    pub fn brush_select(mut self, brush_select: bool) -> Self {
343        self.brush_select = Some(brush_select);
344        self
345    }
346}