1use crate::common::color::{Color, ColorWrapper};
2use crate::common::{
3 Anchor, Calendar, ColorBar, ColorScale, DashType, Font, Label, Orientation, Side,
4 TickFormatStop, TickMode, Title,
5};
6use crate::plot::Trace;
7use crate::private;
8use crate::private::{to_num_or_string_wrapper, NumOrString, NumOrStringWrapper, TruthyEnum};
9use serde::Serialize;
10
11#[derive(Serialize, Debug)]
12pub enum AxisType {
13 #[serde(rename = "-")]
14 Default,
15 #[serde(rename = "linear")]
16 Linear,
17 #[serde(rename = "log")]
18 Log,
19 #[serde(rename = "date")]
20 Date,
21 #[serde(rename = "category")]
22 Category,
23 #[serde(rename = "multicategory")]
24 MultiCategory,
25}
26
27#[derive(Serialize, Debug)]
28pub enum AxisConstrain {
29 #[serde(rename = "range")]
30 Range,
31 #[serde(rename = "domain")]
32 Domain,
33}
34
35#[derive(Serialize, Debug)]
36pub enum ConstrainDirection {
37 #[serde(rename = "left")]
38 Left,
39 #[serde(rename = "center")]
40 Center,
41 #[serde(rename = "right")]
42 Right,
43 #[serde(rename = "top")]
44 Top,
45 #[serde(rename = "middle")]
46 Middle,
47 #[serde(rename = "bottom")]
48 Bottom,
49}
50
51#[derive(Serialize, Debug)]
52pub enum RangeMode {
53 #[serde(rename = "normal")]
54 Normal,
55 #[serde(rename = "tozero")]
56 ToZero,
57 #[serde(rename = "nonnegative")]
58 NonNegative,
59}
60
61#[derive(Serialize, Debug)]
62pub enum TicksDirection {
63 #[serde(rename = "outside")]
64 Outside,
65 #[serde(rename = "inside")]
66 Inside,
67}
68
69#[derive(Serialize, Debug)]
70pub enum TicksPosition {
71 #[serde(rename = "labels")]
72 Labels,
73 #[serde(rename = "boundaries")]
74 Boundaries,
75}
76
77#[derive(Serialize, Debug)]
78pub enum ArrayShow {
79 #[serde(rename = "all")]
80 All,
81 #[serde(rename = "first")]
82 First,
83 #[serde(rename = "last")]
84 Last,
85 #[serde(rename = "none")]
86 None,
87}
88
89#[derive(Serialize, Debug)]
90pub enum BarMode {
91 #[serde(rename = "stack")]
92 Stack,
93 #[serde(rename = "group")]
94 Group,
95 #[serde(rename = "overlay")]
96 Overlay,
97 #[serde(rename = "relative")]
98 Relative,
99}
100
101#[derive(Serialize, Debug)]
102pub enum BarNorm {
103 #[serde(rename = "")]
104 Empty,
105 #[serde(rename = "fraction")]
106 Fraction,
107 #[serde(rename = "percent")]
108 Percent,
109}
110
111#[derive(Serialize, Debug)]
112pub enum BoxMode {
113 #[serde(rename = "group")]
114 Group,
115 #[serde(rename = "overlay")]
116 Overlay,
117}
118
119#[derive(Serialize, Debug)]
120pub enum ViolinMode {
121 #[serde(rename = "group")]
122 Group,
123 #[serde(rename = "overlay")]
124 Overlay,
125}
126
127#[derive(Serialize, Debug)]
128pub enum WaterfallMode {
129 #[serde(rename = "group")]
130 Group,
131 #[serde(rename = "overlay")]
132 Overlay,
133}
134
135#[derive(Serialize, Debug, Default)]
136pub struct Legend {
137 #[serde(skip_serializing_if = "Option::is_none", rename = "bgcolor")]
138 background_color: Option<ColorWrapper>,
139 #[serde(skip_serializing_if = "Option::is_none", rename = "bordercolor")]
140 border_color: Option<ColorWrapper>,
141 #[serde(skip_serializing_if = "Option::is_none", rename = "borderwidth")]
142 border_width: Option<usize>,
143 #[serde(skip_serializing_if = "Option::is_none")]
144 font: Option<Font>,
145 #[serde(skip_serializing_if = "Option::is_none")]
146 orientation: Option<Orientation>,
147 #[serde(skip_serializing_if = "Option::is_none", rename = "traceorder")]
148 trace_order: Option<String>,
149 #[serde(skip_serializing_if = "Option::is_none", rename = "tracegroupgap")]
150 trace_group_gap: Option<usize>,
151 #[serde(skip_serializing_if = "Option::is_none", rename = "itemsizing")]
152 item_sizing: Option<String>,
153 #[serde(skip_serializing_if = "Option::is_none", rename = "itemclick")]
154 item_click: Option<String>,
155 #[serde(skip_serializing_if = "Option::is_none", rename = "itemdoubleclick")]
156 item_double_click: Option<String>,
157 #[serde(skip_serializing_if = "Option::is_none")]
158 x: Option<f64>,
159 #[serde(skip_serializing_if = "Option::is_none", rename = "xanchor")]
160 x_anchor: Option<Anchor>,
161 #[serde(skip_serializing_if = "Option::is_none")]
162 y: Option<f64>,
163 #[serde(skip_serializing_if = "Option::is_none", rename = "yanchor")]
164 y_anchor: Option<Anchor>,
165 #[serde(skip_serializing_if = "Option::is_none")]
166 valign: Option<VAlign>,
167 #[serde(skip_serializing_if = "Option::is_none")]
168 title: Option<Title>,
169}
170
171impl Legend {
172 pub fn new() -> Legend {
173 Default::default()
174 }
175
176 pub fn background_color<C: Color>(mut self, background_color: C) -> Legend {
177 self.background_color = Some(background_color.to_color());
178 self
179 }
180
181 pub fn border_color<C: Color>(mut self, border_color: C) -> Legend {
182 self.border_color = Some(border_color.to_color());
183 self
184 }
185
186 pub fn border_width(mut self, border_width: usize) -> Legend {
187 self.border_width = Some(border_width);
188 self
189 }
190
191 pub fn font(mut self, font: Font) -> Legend {
192 self.font = Some(font);
193 self
194 }
195
196 pub fn orientation(mut self, orientation: Orientation) -> Legend {
197 self.orientation = Some(orientation);
198 self
199 }
200
201 pub fn trace_order(mut self, trace_order: &str) -> Legend {
202 self.trace_order = Some(trace_order.to_owned());
203 self
204 }
205
206 pub fn trace_group_gap(mut self, trace_group_gap: usize) -> Legend {
207 self.trace_group_gap = Some(trace_group_gap);
208 self
209 }
210
211 pub fn item_sizing(mut self, item_sizing: &str) -> Legend {
212 self.item_sizing = Some(item_sizing.to_owned());
213 self
214 }
215
216 pub fn item_click(mut self, item_click: &str) -> Legend {
217 self.item_click = Some(item_click.to_owned());
218 self
219 }
220
221 pub fn item_double_click(mut self, item_double_click: &str) -> Legend {
222 self.item_double_click = Some(item_double_click.to_owned());
223 self
224 }
225
226 pub fn x(mut self, x: f64) -> Legend {
227 self.x = Some(x);
228 self
229 }
230
231 pub fn x_anchor(mut self, x_anchor: Anchor) -> Legend {
232 self.x_anchor = Some(x_anchor);
233 self
234 }
235
236 pub fn y(mut self, y: f64) -> Legend {
237 self.y = Some(y);
238 self
239 }
240
241 pub fn y_anchor(mut self, y_anchor: Anchor) -> Legend {
242 self.y_anchor = Some(y_anchor);
243 self
244 }
245
246 pub fn valign(mut self, valign: VAlign) -> Legend {
247 self.valign = Some(valign);
248 self
249 }
250
251 pub fn title(mut self, title: Title) -> Legend {
252 self.title = Some(title);
253 self
254 }
255}
256
257#[derive(Serialize, Debug)]
258pub enum VAlign {
259 #[serde(rename = "top")]
260 Top,
261 #[serde(rename = "middle")]
262 Middle,
263 #[serde(rename = "bottom")]
264 Bottom,
265}
266
267#[derive(Serialize, Debug)]
268pub enum HAlign {
269 #[serde(rename = "left")]
270 Left,
271 #[serde(rename = "center")]
272 Center,
273 #[serde(rename = "right")]
274 Right,
275}
276
277#[derive(Serialize, Debug, Default)]
278pub struct Margin {
279 #[serde(skip_serializing_if = "Option::is_none")]
280 l: Option<usize>,
281 #[serde(skip_serializing_if = "Option::is_none")]
282 r: Option<usize>,
283 #[serde(skip_serializing_if = "Option::is_none")]
284 t: Option<usize>,
285 #[serde(skip_serializing_if = "Option::is_none")]
286 b: Option<usize>,
287 #[serde(skip_serializing_if = "Option::is_none")]
288 pad: Option<usize>,
289 #[serde(skip_serializing_if = "Option::is_none", rename = "autoexpand")]
290 auto_expand: Option<bool>,
291}
292
293impl Margin {
294 pub fn new() -> Margin {
295 Default::default()
296 }
297
298 pub fn left(mut self, left: usize) -> Margin {
299 self.l = Some(left);
300 self
301 }
302
303 pub fn right(mut self, right: usize) -> Margin {
304 self.r = Some(right);
305 self
306 }
307
308 pub fn top(mut self, top: usize) -> Margin {
309 self.t = Some(top);
310 self
311 }
312
313 pub fn bottom(mut self, bottom: usize) -> Margin {
314 self.b = Some(bottom);
315 self
316 }
317
318 pub fn pad(mut self, pad: usize) -> Margin {
319 self.pad = Some(pad);
320 self
321 }
322
323 pub fn auto_expand(mut self, auto_expand: bool) -> Margin {
324 self.auto_expand = Some(auto_expand);
325 self
326 }
327}
328
329#[derive(Serialize, Debug, Default)]
330pub struct LayoutColorScale {
331 #[serde(skip_serializing_if = "Option::is_none")]
332 sequential: Option<ColorScale>,
333 #[serde(skip_serializing_if = "Option::is_none", rename = "sequentialminus")]
334 sequential_minus: Option<ColorScale>,
335 #[serde(skip_serializing_if = "Option::is_none")]
336 diverging: Option<ColorScale>,
337}
338
339impl LayoutColorScale {
340 pub fn new() -> LayoutColorScale {
341 Default::default()
342 }
343
344 pub fn sequential(mut self, sequential: ColorScale) -> LayoutColorScale {
345 self.sequential = Some(sequential);
346 self
347 }
348
349 pub fn sequential_minus(mut self, sequential_minus: ColorScale) -> LayoutColorScale {
350 self.sequential_minus = Some(sequential_minus);
351 self
352 }
353
354 pub fn diverging(mut self, diverging: ColorScale) -> LayoutColorScale {
355 self.diverging = Some(diverging);
356 self
357 }
358}
359
360#[derive(Serialize, Debug)]
361pub enum SliderRangeMode {
362 #[serde(rename = "auto")]
363 Auto,
364 #[serde(rename = "fixed")]
365 Fixed,
366 #[serde(rename = "match")]
367 Match,
368}
369
370#[derive(Serialize, Debug, Default)]
371pub struct RangeSliderYAxis {
372 #[serde(skip_serializing_if = "Option::is_none", rename = "rangemode")]
373 range_mode: Option<SliderRangeMode>,
374 #[serde(skip_serializing_if = "Option::is_none")]
375 range: Option<Vec<NumOrStringWrapper>>,
376}
377
378impl RangeSliderYAxis {
379 pub fn new() -> RangeSliderYAxis {
380 Default::default()
381 }
382
383 pub fn range_mode(mut self, range_mode: SliderRangeMode) -> RangeSliderYAxis {
384 self.range_mode = Some(range_mode);
385 self
386 }
387
388 pub fn range<C: NumOrString>(mut self, range: Vec<C>) -> RangeSliderYAxis {
389 let wrapped = to_num_or_string_wrapper(range);
390 self.range = Some(wrapped);
391 self
392 }
393}
394
395#[derive(Serialize, Debug, Default)]
396pub struct RangeSlider {
397 #[serde(skip_serializing_if = "Option::is_none", rename = "bgcolor")]
398 background_color: Option<ColorWrapper>,
399 #[serde(skip_serializing_if = "Option::is_none", rename = "bordercolor")]
400 border_color: Option<ColorWrapper>,
401 #[serde(skip_serializing_if = "Option::is_none", rename = "borderwidth")]
402 border_width: Option<u64>,
403 #[serde(skip_serializing_if = "Option::is_none", rename = "autorange")]
404 auto_range: Option<bool>,
405 #[serde(skip_serializing_if = "Option::is_none")]
406 range: Option<Vec<NumOrStringWrapper>>,
407 #[serde(skip_serializing_if = "Option::is_none")]
408 thickness: Option<f64>,
409 #[serde(skip_serializing_if = "Option::is_none")]
410 visible: Option<bool>,
411 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis")]
412 y_axis: Option<RangeSliderYAxis>,
413}
414
415impl RangeSlider {
416 pub fn new() -> RangeSlider {
417 Default::default()
418 }
419
420 pub fn background_color<C: Color>(mut self, background_color: C) -> RangeSlider {
421 self.background_color = Some(background_color.to_color());
422 self
423 }
424
425 pub fn border_color<C: Color>(mut self, border_color: C) -> RangeSlider {
426 self.border_color = Some(border_color.to_color());
427 self
428 }
429
430 pub fn border_width(mut self, border_width: u64) -> RangeSlider {
431 self.border_width = Some(border_width);
432 self
433 }
434
435 pub fn auto_range(mut self, auto_range: bool) -> RangeSlider {
436 self.auto_range = Some(auto_range);
437 self
438 }
439
440 pub fn range<C: NumOrString>(mut self, range: Vec<C>) -> RangeSlider {
441 let wrapped = to_num_or_string_wrapper(range);
442 self.range = Some(wrapped);
443 self
444 }
445
446 pub fn thickness(mut self, thickness: f64) -> RangeSlider {
447 self.thickness = Some(thickness);
448 self
449 }
450
451 pub fn visible(mut self, visible: bool) -> RangeSlider {
452 self.visible = Some(visible);
453 self
454 }
455
456 pub fn y_axis(mut self, axis: RangeSliderYAxis) -> RangeSlider {
457 self.y_axis = Some(axis);
458 self
459 }
460}
461
462#[derive(Serialize, Debug)]
463pub enum SelectorStep {
464 #[serde(rename = "month")]
465 Month,
466 #[serde(rename = "year")]
467 Year,
468 #[serde(rename = "day")]
469 Day,
470 #[serde(rename = "hour")]
471 Hour,
472 #[serde(rename = "minute")]
473 Minute,
474 #[serde(rename = "second")]
475 Second,
476 #[serde(rename = "all")]
477 All,
478}
479
480#[derive(Serialize, Debug)]
481pub enum StepMode {
482 #[serde(rename = "backward")]
483 Backward,
484 #[serde(rename = "todate")]
485 ToDate,
486}
487
488#[derive(Serialize, Debug, Default)]
489pub struct SelectorButton {
490 #[serde(skip_serializing_if = "Option::is_none")]
491 visible: Option<bool>,
492 #[serde(skip_serializing_if = "Option::is_none")]
493 step: Option<SelectorStep>,
494 #[serde(skip_serializing_if = "Option::is_none", rename = "stepmode")]
495 step_mode: Option<StepMode>,
496 #[serde(skip_serializing_if = "Option::is_none")]
497 count: Option<usize>,
498 #[serde(skip_serializing_if = "Option::is_none")]
499 label: Option<String>,
500 #[serde(skip_serializing_if = "Option::is_none")]
501 name: Option<String>,
502 #[serde(skip_serializing_if = "Option::is_none", rename = "templateitemname")]
503 template_item_name: Option<String>,
504}
505
506impl SelectorButton {
507 pub fn new() -> SelectorButton {
508 Default::default()
509 }
510
511 pub fn visible(mut self, visible: bool) -> SelectorButton {
512 self.visible = Some(visible);
513 self
514 }
515
516 pub fn step(mut self, step: SelectorStep) -> SelectorButton {
517 self.step = Some(step);
518 self
519 }
520
521 pub fn step_mode(mut self, step_mode: StepMode) -> SelectorButton {
522 self.step_mode = Some(step_mode);
523 self
524 }
525
526 pub fn count(mut self, count: usize) -> SelectorButton {
527 self.count = Some(count);
528 self
529 }
530
531 pub fn label(mut self, label: &str) -> SelectorButton {
532 self.label = Some(label.to_owned());
533 self
534 }
535
536 pub fn name(mut self, name: &str) -> SelectorButton {
537 self.name = Some(name.to_owned());
538 self
539 }
540
541 pub fn template_item_name(mut self, template_item_name: &str) -> SelectorButton {
542 self.template_item_name = Some(template_item_name.to_owned());
543 self
544 }
545}
546
547#[derive(Serialize, Debug, Default)]
548pub struct RangeSelector {
549 #[serde(skip_serializing_if = "Option::is_none")]
550 visible: Option<bool>,
551 #[serde(skip_serializing_if = "Option::is_none")]
552 buttons: Option<Vec<SelectorButton>>,
553 #[serde(skip_serializing_if = "Option::is_none")]
554 x: Option<f64>,
555 #[serde(skip_serializing_if = "Option::is_none", rename = "xanchor")]
556 x_anchor: Option<Anchor>,
557 #[serde(skip_serializing_if = "Option::is_none")]
558 y: Option<f64>,
559 #[serde(skip_serializing_if = "Option::is_none", rename = "yanchor")]
560 y_anchor: Option<Anchor>,
561 #[serde(skip_serializing_if = "Option::is_none")]
562 font: Option<Font>,
563 #[serde(skip_serializing_if = "Option::is_none", rename = "bgcolor")]
564 background_color: Option<ColorWrapper>,
565 #[serde(skip_serializing_if = "Option::is_none", rename = "activecolor")]
566 active_color: Option<ColorWrapper>,
567 #[serde(skip_serializing_if = "Option::is_none", rename = "bordercolor")]
568 border_color: Option<ColorWrapper>,
569 #[serde(skip_serializing_if = "Option::is_none", rename = "borderwidth")]
570 border_width: Option<usize>,
571}
572
573impl RangeSelector {
574 pub fn new() -> RangeSelector {
575 Default::default()
576 }
577
578 pub fn visible(mut self, visible: bool) -> RangeSelector {
579 self.visible = Some(visible);
580 self
581 }
582
583 pub fn buttons(mut self, buttons: Vec<SelectorButton>) -> RangeSelector {
584 self.buttons = Some(buttons);
585 self
586 }
587
588 pub fn x(mut self, x: f64) -> RangeSelector {
589 self.x = Some(x);
590 self
591 }
592
593 pub fn x_anchor(mut self, x_anchor: Anchor) -> RangeSelector {
594 self.x_anchor = Some(x_anchor);
595 self
596 }
597
598 pub fn y(mut self, y: f64) -> RangeSelector {
599 self.y = Some(y);
600 self
601 }
602
603 pub fn y_anchor(mut self, y_anchor: Anchor) -> RangeSelector {
604 self.y_anchor = Some(y_anchor);
605 self
606 }
607
608 pub fn font(mut self, font: Font) -> RangeSelector {
609 self.font = Some(font);
610 self
611 }
612
613 pub fn background_color<C: Color>(mut self, background_color: C) -> RangeSelector {
614 self.background_color = Some(background_color.to_color());
615 self
616 }
617
618 pub fn active_color<C: Color>(mut self, active_color: C) -> RangeSelector {
619 self.background_color = Some(active_color.to_color());
620 self
621 }
622
623 pub fn border_color<C: Color>(mut self, border_color: C) -> RangeSelector {
624 self.border_color = Some(border_color.to_color());
625 self
626 }
627
628 pub fn border_width(mut self, border_width: usize) -> RangeSelector {
629 self.border_width = Some(border_width);
630 self
631 }
632}
633
634#[derive(Serialize, Debug, Default)]
635pub struct ColorAxis {
636 #[serde(skip_serializing_if = "Option::is_none")]
637 cauto: Option<bool>,
638 #[serde(skip_serializing_if = "Option::is_none")]
639 cmin: Option<f64>,
640 #[serde(skip_serializing_if = "Option::is_none")]
641 cmax: Option<f64>,
642 #[serde(skip_serializing_if = "Option::is_none")]
643 cmid: Option<f64>,
644 #[serde(skip_serializing_if = "Option::is_none", rename = "colorscale")]
645 color_scale: Option<ColorScale>,
646 #[serde(skip_serializing_if = "Option::is_none", rename = "autocolorscale")]
647 auto_color_scale: Option<bool>,
648 #[serde(skip_serializing_if = "Option::is_none", rename = "reversescale")]
649 reverse_scale: Option<bool>,
650 #[serde(skip_serializing_if = "Option::is_none", rename = "showscale")]
651 show_scale: Option<bool>,
652 #[serde(skip_serializing_if = "Option::is_none", rename = "colorbar")]
653 color_bar: Option<ColorBar>,
654}
655
656impl ColorAxis {
657 pub fn new() -> ColorAxis {
658 Default::default()
659 }
660
661 pub fn cauto(mut self, cauto: bool) -> ColorAxis {
662 self.cauto = Some(cauto);
663 self
664 }
665
666 pub fn cmin(mut self, cmin: f64) -> ColorAxis {
667 self.cmin = Some(cmin);
668 self
669 }
670
671 pub fn cmax(mut self, cmax: f64) -> ColorAxis {
672 self.cmax = Some(cmax);
673 self
674 }
675
676 pub fn cmid(mut self, cmid: f64) -> ColorAxis {
677 self.cmid = Some(cmid);
678 self
679 }
680
681 pub fn color_scale(mut self, color_scale: ColorScale) -> ColorAxis {
682 self.color_scale = Some(color_scale);
683 self
684 }
685
686 pub fn auto_color_scale(mut self, auto_color_scale: bool) -> ColorAxis {
687 self.auto_color_scale = Some(auto_color_scale);
688 self
689 }
690
691 pub fn reverse_scale(mut self, reverse_scale: bool) -> ColorAxis {
692 self.reverse_scale = Some(reverse_scale);
693 self
694 }
695
696 pub fn show_scale(mut self, show_scale: bool) -> ColorAxis {
697 self.show_scale = Some(show_scale);
698 self
699 }
700
701 pub fn color_bar(mut self, color_bar: ColorBar) -> ColorAxis {
702 self.color_bar = Some(color_bar);
703 self
704 }
705}
706
707#[derive(Serialize, Debug, Default)]
708pub struct Axis {
709 #[serde(skip_serializing_if = "Option::is_none")]
710 visible: Option<bool>,
711 #[serde(skip_serializing_if = "Option::is_none")]
712 color: Option<ColorWrapper>,
713 #[serde(skip_serializing_if = "Option::is_none")]
714 title: Option<Title>,
715 #[serde(skip_serializing_if = "Option::is_none")]
716 r#type: Option<AxisType>,
717 #[serde(skip_serializing_if = "Option::is_none", rename = "auto_range")]
718 auto_range: Option<bool>,
719 #[serde(skip_serializing_if = "Option::is_none", rename = "rangemode")]
720 range_mode: Option<RangeMode>,
721 #[serde(skip_serializing_if = "Option::is_none")]
722 range: Option<Vec<NumOrStringWrapper>>,
723 #[serde(skip_serializing_if = "Option::is_none", rename = "fixedrange")]
724 fixed_range: Option<bool>,
725 #[serde(skip_serializing_if = "Option::is_none")]
726 constrain: Option<AxisConstrain>,
727 #[serde(skip_serializing_if = "Option::is_none", rename = "constraintoward")]
728 constrain_toward: Option<ConstrainDirection>,
729 #[serde(skip_serializing_if = "Option::is_none", rename = "tickmode")]
730 tick_mode: Option<TickMode>,
731 #[serde(skip_serializing_if = "Option::is_none", rename = "nticks")]
732 n_ticks: Option<usize>,
733
734 #[serde(skip_serializing_if = "Option::is_none")]
735 tick0: Option<f64>,
736 #[serde(skip_serializing_if = "Option::is_none")]
737 dtick: Option<f64>,
738
739 #[serde(skip_serializing_if = "Option::is_none", rename = "tickvals")]
740 tick_values: Option<Vec<f64>>,
741 #[serde(skip_serializing_if = "Option::is_none", rename = "tick_text")]
742 tick_text: Option<Vec<String>>,
743 #[serde(skip_serializing_if = "Option::is_none")]
744 ticks: Option<TicksDirection>,
745 #[serde(skip_serializing_if = "Option::is_none", rename = "tickson")]
746 ticks_on: Option<TicksPosition>,
747 #[serde(skip_serializing_if = "Option::is_none")]
748 mirror: Option<bool>,
749 #[serde(skip_serializing_if = "Option::is_none", rename = "ticklen")]
750 tick_length: Option<usize>,
751 #[serde(skip_serializing_if = "Option::is_none", rename = "tickwidth")]
752 tick_width: Option<usize>,
753 #[serde(skip_serializing_if = "Option::is_none", rename = "tickcolor")]
754 tick_color: Option<ColorWrapper>,
755 #[serde(skip_serializing_if = "Option::is_none", rename = "showticklabels")]
756 show_tick_labels: Option<bool>,
757 #[serde(skip_serializing_if = "Option::is_none", rename = "automargin")]
758 auto_margin: Option<bool>,
759 #[serde(skip_serializing_if = "Option::is_none", rename = "showspikes")]
760 show_spikes: Option<bool>,
761 #[serde(skip_serializing_if = "Option::is_none", rename = "spikecolor")]
762 spike_color: Option<ColorWrapper>,
763 #[serde(skip_serializing_if = "Option::is_none", rename = "spikethickness")]
764 spike_thickness: Option<usize>,
765 #[serde(skip_serializing_if = "Option::is_none", rename = "spikedash")]
766 spike_dash: Option<DashType>,
767 #[serde(skip_serializing_if = "Option::is_none", rename = "spikemode")]
768 spike_mode: Option<String>,
769 #[serde(skip_serializing_if = "Option::is_none", rename = "spikesnap")]
770 spike_snap: Option<String>,
771 #[serde(skip_serializing_if = "Option::is_none", rename = "tickfont")]
772 tick_font: Option<Font>,
773 #[serde(skip_serializing_if = "Option::is_none", rename = "tickangle")]
774 tick_angle: Option<f64>,
775 #[serde(skip_serializing_if = "Option::is_none", rename = "tickprefix")]
776 tick_prefix: Option<String>,
777 #[serde(skip_serializing_if = "Option::is_none", rename = "showtickprefix")]
778 show_tick_prefix: Option<ArrayShow>,
779 #[serde(skip_serializing_if = "Option::is_none", rename = "ticksuffix")]
780 tick_suffix: Option<String>,
781 #[serde(skip_serializing_if = "Option::is_none", rename = "showticksuffix")]
782 show_tick_suffix: Option<ArrayShow>,
783 #[serde(skip_serializing_if = "Option::is_none", rename = "showexponent")]
784 show_exponent: Option<ArrayShow>,
785 #[serde(skip_serializing_if = "Option::is_none", rename = "exponentformat")]
786 exponent_format: Option<String>,
787 #[serde(skip_serializing_if = "Option::is_none", rename = "separatethousands")]
788 separate_thousands: Option<bool>,
789 #[serde(skip_serializing_if = "Option::is_none", rename = "tickformat")]
790 tick_format: Option<String>,
791 #[serde(skip_serializing_if = "Option::is_none", rename = "tickformatstops")]
792 tick_format_stops: Option<Vec<TickFormatStop>>,
793 #[serde(skip_serializing_if = "Option::is_none", rename = "hoverformat")]
794 hover_format: Option<String>,
795 #[serde(skip_serializing_if = "Option::is_none", rename = "showline")]
796 show_line: Option<bool>,
797 #[serde(skip_serializing_if = "Option::is_none", rename = "linecolor")]
798 line_color: Option<ColorWrapper>,
799 #[serde(skip_serializing_if = "Option::is_none", rename = "linewidth")]
800 line_width: Option<usize>,
801 #[serde(skip_serializing_if = "Option::is_none", rename = "showgrid")]
802 show_grid: Option<bool>,
803 #[serde(skip_serializing_if = "Option::is_none", rename = "gridcolor")]
804 grid_color: Option<ColorWrapper>,
805 #[serde(skip_serializing_if = "Option::is_none", rename = "gridwidth")]
806 grid_width: Option<usize>,
807 #[serde(skip_serializing_if = "Option::is_none", rename = "zeroline")]
808 zero_line: Option<bool>,
809 #[serde(skip_serializing_if = "Option::is_none", rename = "zerolinecolor")]
810 zero_line_color: Option<ColorWrapper>,
811 #[serde(skip_serializing_if = "Option::is_none", rename = "zerolinewidth")]
812 zero_line_width: Option<usize>,
813 #[serde(skip_serializing_if = "Option::is_none", rename = "showdividers")]
814 show_dividers: Option<bool>,
815 #[serde(skip_serializing_if = "Option::is_none", rename = "dividercolor")]
816 divider_color: Option<ColorWrapper>,
817 #[serde(skip_serializing_if = "Option::is_none", rename = "dividerwidth")]
818 divider_width: Option<usize>,
819 #[serde(skip_serializing_if = "Option::is_none")]
820 anchor: Option<String>,
821 #[serde(skip_serializing_if = "Option::is_none")]
822 side: Option<Side>,
823 #[serde(skip_serializing_if = "Option::is_none")]
824 overlaying: Option<String>,
825 #[serde(skip_serializing_if = "Option::is_none")]
826 domain: Option<Vec<f64>>,
827 #[serde(skip_serializing_if = "Option::is_none")]
828 position: Option<f64>,
829 #[serde(skip_serializing_if = "Option::is_none", rename = "rangeslider")]
830 range_slider: Option<RangeSlider>,
831 #[serde(skip_serializing_if = "Option::is_none", rename = "rangeselector")]
832 range_selector: Option<RangeSelector>,
833 #[serde(skip_serializing_if = "Option::is_none")]
834 calendar: Option<Calendar>,
835}
836
837impl Axis {
838 pub fn new() -> Axis {
839 Default::default()
840 }
841
842 pub fn visible(mut self, visible: bool) -> Axis {
843 self.visible = Some(visible);
844 self
845 }
846
847 pub fn color<C: Color>(mut self, color: C) -> Axis {
848 self.color = Some(color.to_color());
849 self
850 }
851
852 pub fn title(mut self, title: Title) -> Axis {
853 self.title = Some(title);
854 self
855 }
856
857 pub fn type_(mut self, t: AxisType) -> Axis {
858 self.r#type = Some(t);
859 self
860 }
861
862 pub fn auto_range(mut self, auto_range: bool) -> Axis {
863 self.auto_range = Some(auto_range);
864 self
865 }
866
867 pub fn range_mode(mut self, range_mode: RangeMode) -> Axis {
868 self.range_mode = Some(range_mode);
869 self
870 }
871
872 pub fn range<C: NumOrString>(mut self, range: Vec<C>) -> Axis {
873 let wrapped = to_num_or_string_wrapper(range);
874 self.range = Some(wrapped);
875 self
876 }
877
878 pub fn fixed_range(mut self, fixed_range: bool) -> Axis {
879 self.fixed_range = Some(fixed_range);
880 self
881 }
882
883 pub fn constrain(mut self, constrain: AxisConstrain) -> Axis {
884 self.constrain = Some(constrain);
885 self
886 }
887
888 pub fn constrain_toward(mut self, constrain_toward: ConstrainDirection) -> Axis {
889 self.constrain_toward = Some(constrain_toward);
890 self
891 }
892
893 pub fn tick_mode(mut self, tick_mode: TickMode) -> Axis {
894 self.tick_mode = Some(tick_mode);
895 self
896 }
897
898 pub fn n_ticks(mut self, n_ticks: usize) -> Axis {
899 self.n_ticks = Some(n_ticks);
900 self
901 }
902
903 pub fn tick0(mut self, tick0: f64) -> Axis {
904 self.tick0 = Some(tick0);
905 self
906 }
907
908 pub fn dtick(mut self, dtick: f64) -> Axis {
909 self.dtick = Some(dtick);
910 self
911 }
912
913 pub fn tick_values(mut self, tick_values: Vec<f64>) -> Axis {
914 self.tick_values = Some(tick_values);
915 self
916 }
917
918 pub fn tick_text(mut self, tick_text: Vec<String>) -> Axis {
919 self.tick_text = Some(tick_text);
920 self
921 }
922
923 pub fn ticks(mut self, ticks: TicksDirection) -> Axis {
924 self.ticks = Some(ticks);
925 self
926 }
927
928 pub fn ticks_on(mut self, ticks_on: TicksPosition) -> Axis {
929 self.ticks_on = Some(ticks_on);
930 self
931 }
932
933 pub fn mirror(mut self, mirror: bool) -> Axis {
934 self.mirror = Some(mirror);
935 self
936 }
937
938 pub fn tick_length(mut self, tick_length: usize) -> Axis {
939 self.tick_length = Some(tick_length);
940 self
941 }
942
943 pub fn tick_width(mut self, tick_width: usize) -> Axis {
944 self.tick_width = Some(tick_width);
945 self
946 }
947
948 pub fn tick_color<C: Color>(mut self, tick_color: C) -> Axis {
949 self.tick_color = Some(tick_color.to_color());
950 self
951 }
952
953 pub fn show_tick_labels(mut self, show_tick_labels: bool) -> Axis {
954 self.show_tick_labels = Some(show_tick_labels);
955 self
956 }
957
958 pub fn auto_margin(mut self, auto_margin: bool) -> Axis {
959 self.auto_margin = Some(auto_margin);
960 self
961 }
962
963 pub fn show_spikes(mut self, show_spikes: bool) -> Axis {
964 self.show_spikes = Some(show_spikes);
965 self
966 }
967
968 pub fn spike_color<C: Color>(mut self, spike_color: C) -> Axis {
969 self.spike_color = Some(spike_color.to_color());
970 self
971 }
972
973 pub fn spike_thickness(mut self, spike_thickness: usize) -> Axis {
974 self.spike_thickness = Some(spike_thickness);
975 self
976 }
977
978 pub fn spike_dash(mut self, spike_dash: DashType) -> Axis {
979 self.spike_dash = Some(spike_dash);
980 self
981 }
982
983 pub fn spike_mode(mut self, spike_mode: &str) -> Axis {
984 self.spike_mode = Some(spike_mode.to_owned());
985 self
986 }
987
988 pub fn spike_snap(mut self, spike_snap: &str) -> Axis {
989 self.spike_snap = Some(spike_snap.to_owned());
990 self
991 }
992
993 pub fn tick_font(mut self, tick_font: Font) -> Axis {
994 self.tick_font = Some(tick_font);
995 self
996 }
997
998 pub fn tick_angle(mut self, tick_angle: f64) -> Axis {
999 self.tick_angle = Some(tick_angle);
1000 self
1001 }
1002
1003 pub fn tick_prefix(mut self, tick_prefix: &str) -> Axis {
1004 self.tick_prefix = Some(tick_prefix.to_owned());
1005 self
1006 }
1007
1008 pub fn show_tick_prefix(mut self, show_tick_prefix: ArrayShow) -> Axis {
1009 self.show_tick_prefix = Some(show_tick_prefix);
1010 self
1011 }
1012
1013 pub fn tick_suffix(mut self, tick_suffix: &str) -> Axis {
1014 self.tick_suffix = Some(tick_suffix.to_owned());
1015 self
1016 }
1017
1018 pub fn show_tick_suffix(mut self, show_tick_suffix: ArrayShow) -> Axis {
1019 self.show_tick_suffix = Some(show_tick_suffix);
1020 self
1021 }
1022
1023 pub fn show_exponent(mut self, show_exponent: ArrayShow) -> Axis {
1024 self.show_exponent = Some(show_exponent);
1025 self
1026 }
1027
1028 pub fn exponent_format(mut self, exponent_format: &str) -> Axis {
1029 self.exponent_format = Some(exponent_format.to_owned());
1030 self
1031 }
1032
1033 pub fn separate_thousands(mut self, separate_thousands: bool) -> Axis {
1034 self.separate_thousands = Some(separate_thousands);
1035 self
1036 }
1037
1038 pub fn tick_format(mut self, tick_format: &str) -> Axis {
1039 self.tick_format = Some(tick_format.to_owned());
1040 self
1041 }
1042
1043 pub fn tick_format_stops(mut self, tick_format_stops: Vec<TickFormatStop>) -> Axis {
1044 self.tick_format_stops = Some(tick_format_stops);
1045 self
1046 }
1047
1048 pub fn hover_format(mut self, hover_format: &str) -> Axis {
1049 self.hover_format = Some(hover_format.to_owned());
1050 self
1051 }
1052
1053 pub fn show_line(mut self, show_line: bool) -> Axis {
1054 self.show_line = Some(show_line);
1055 self
1056 }
1057
1058 pub fn line_color<C: Color>(mut self, line_color: C) -> Axis {
1059 self.line_color = Some(line_color.to_color());
1060 self
1061 }
1062
1063 pub fn line_width(mut self, line_width: usize) -> Axis {
1064 self.line_width = Some(line_width);
1065 self
1066 }
1067
1068 pub fn show_grid(mut self, show_grid: bool) -> Axis {
1069 self.show_grid = Some(show_grid);
1070 self
1071 }
1072
1073 pub fn grid_color<C: Color>(mut self, grid_color: C) -> Axis {
1074 self.grid_color = Some(grid_color.to_color());
1075 self
1076 }
1077
1078 pub fn grid_width(mut self, grid_width: usize) -> Axis {
1079 self.grid_width = Some(grid_width);
1080 self
1081 }
1082
1083 pub fn zero_line(mut self, zero_line: bool) -> Axis {
1084 self.zero_line = Some(zero_line);
1085 self
1086 }
1087
1088 pub fn zero_line_color<C: Color>(mut self, zero_line_color: C) -> Axis {
1089 self.zero_line_color = Some(zero_line_color.to_color());
1090 self
1091 }
1092
1093 pub fn zero_line_width(mut self, zero_line_width: usize) -> Axis {
1094 self.zero_line_width = Some(zero_line_width);
1095 self
1096 }
1097
1098 pub fn show_dividers(mut self, show_dividers: bool) -> Axis {
1099 self.show_dividers = Some(show_dividers);
1100 self
1101 }
1102
1103 pub fn divider_color<C: Color>(mut self, divider_color: C) -> Axis {
1104 self.divider_color = Some(divider_color.to_color());
1105 self
1106 }
1107
1108 pub fn divider_width(mut self, divider_width: usize) -> Axis {
1109 self.divider_width = Some(divider_width);
1110 self
1111 }
1112
1113 pub fn anchor(mut self, anchor: &str) -> Axis {
1114 self.anchor = Some(anchor.to_owned());
1115 self
1116 }
1117
1118 pub fn side(mut self, side: Side) -> Axis {
1119 self.side = Some(side);
1120 self
1121 }
1122
1123 pub fn overlaying(mut self, overlaying: &str) -> Axis {
1124 self.overlaying = Some(overlaying.to_owned());
1125 self
1126 }
1127
1128 pub fn domain(mut self, domain: &[f64]) -> Axis {
1129 self.domain = Some(domain.to_vec());
1130 self
1131 }
1132
1133 pub fn position(mut self, position: f64) -> Axis {
1134 self.position = Some(position);
1135 self
1136 }
1137
1138 pub fn range_slider(mut self, slider: RangeSlider) -> Axis {
1139 self.range_slider = Some(slider);
1140 self
1141 }
1142
1143 pub fn range_selector(mut self, range_selector: RangeSelector) -> Axis {
1144 self.range_selector = Some(range_selector);
1145 self
1146 }
1147
1148 pub fn calendar(mut self, calendar: Calendar) -> Axis {
1149 self.calendar = Some(calendar);
1150 self
1151 }
1152}
1153
1154#[derive(Serialize, Debug)]
1155pub enum RowOrder {
1156 #[serde(rename = "top to bottom")]
1157 TopToBottom,
1158 #[serde(rename = "bottom to top")]
1159 BottomToTop,
1160}
1161
1162#[derive(Serialize, Debug)]
1163pub enum GridPattern {
1164 #[serde(rename = "independent")]
1165 Independent,
1166 #[serde(rename = "coupled")]
1167 Coupled,
1168}
1169
1170#[derive(Serialize, Debug)]
1171pub enum GridXSide {
1172 #[serde(rename = "bottom")]
1173 Bottom,
1174 #[serde(rename = "bottom plot")]
1175 BottomPlot,
1176 #[serde(rename = "top plot")]
1177 TopPlot,
1178 #[serde(rename = "top")]
1179 Top,
1180}
1181
1182#[derive(Serialize, Debug)]
1183pub enum GridYSide {
1184 #[serde(rename = "left")]
1185 Left,
1186 #[serde(rename = "left plot")]
1187 LeftPlot,
1188 #[serde(rename = "right plot")]
1189 RightPlot,
1190 #[serde(rename = "right")]
1191 Right,
1192}
1193
1194#[derive(Serialize, Debug, Default)]
1195pub struct GridDomain {
1196 #[serde(skip_serializing_if = "Option::is_none")]
1197 x: Option<Vec<f64>>,
1198 #[serde(skip_serializing_if = "Option::is_none")]
1199 y: Option<Vec<f64>>,
1200}
1201
1202impl GridDomain {
1203 pub fn new() -> GridDomain {
1204 Default::default()
1205 }
1206
1207 pub fn x(mut self, x: Vec<f64>) -> GridDomain {
1208 self.x = Some(x);
1209 self
1210 }
1211
1212 pub fn y(mut self, y: Vec<f64>) -> GridDomain {
1213 self.y = Some(y);
1214 self
1215 }
1216}
1217
1218#[derive(Serialize, Debug, Default)]
1219pub struct LayoutGrid {
1220 #[serde(skip_serializing_if = "Option::is_none")]
1221 rows: Option<usize>,
1222 #[serde(skip_serializing_if = "Option::is_none", rename = "roworder")]
1223 row_order: Option<RowOrder>,
1224 #[serde(skip_serializing_if = "Option::is_none")]
1225 columns: Option<usize>,
1226 #[serde(skip_serializing_if = "Option::is_none", rename = "subplots")]
1227 sub_plots: Option<Vec<String>>,
1228 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxes")]
1229 x_axes: Option<Vec<String>>,
1230 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxes")]
1231 y_axes: Option<Vec<String>>,
1232 #[serde(skip_serializing_if = "Option::is_none")]
1233 pattern: Option<GridPattern>,
1234 #[serde(skip_serializing_if = "Option::is_none", rename = "xgap")]
1235 x_gap: Option<f64>,
1236 #[serde(skip_serializing_if = "Option::is_none", rename = "ygap")]
1237 y_gap: Option<f64>,
1238 #[serde(skip_serializing_if = "Option::is_none")]
1239 domain: Option<GridDomain>,
1240 #[serde(skip_serializing_if = "Option::is_none", rename = "xside")]
1241 x_side: Option<GridXSide>,
1242 #[serde(skip_serializing_if = "Option::is_none", rename = "yside")]
1243 y_side: Option<GridYSide>,
1244}
1245
1246impl LayoutGrid {
1247 pub fn new() -> LayoutGrid {
1248 Default::default()
1249 }
1250
1251 pub fn rows(mut self, rows: usize) -> LayoutGrid {
1252 self.rows = Some(rows);
1253 self
1254 }
1255
1256 pub fn row_order(mut self, row_order: RowOrder) -> LayoutGrid {
1257 self.row_order = Some(row_order);
1258 self
1259 }
1260
1261 pub fn columns(mut self, columns: usize) -> LayoutGrid {
1262 self.columns = Some(columns);
1263 self
1264 }
1265
1266 pub fn sub_plots(mut self, sub_plots: Vec<String>) -> LayoutGrid {
1267 self.sub_plots = Some(sub_plots);
1268 self
1269 }
1270
1271 pub fn x_axes(mut self, x_axes: Vec<String>) -> LayoutGrid {
1272 self.x_axes = Some(x_axes);
1273 self
1274 }
1275
1276 pub fn y_axes(mut self, y_axes: Vec<String>) -> LayoutGrid {
1277 self.y_axes = Some(y_axes);
1278 self
1279 }
1280
1281 pub fn pattern(mut self, pattern: GridPattern) -> LayoutGrid {
1282 self.pattern = Some(pattern);
1283 self
1284 }
1285
1286 pub fn x_gap(mut self, x_gap: f64) -> LayoutGrid {
1287 self.x_gap = Some(x_gap);
1288 self
1289 }
1290
1291 pub fn y_gap(mut self, y_gap: f64) -> LayoutGrid {
1292 self.y_gap = Some(y_gap);
1293 self
1294 }
1295
1296 pub fn domain(mut self, domain: GridDomain) -> LayoutGrid {
1297 self.domain = Some(domain);
1298 self
1299 }
1300
1301 pub fn x_side(mut self, x_side: GridXSide) -> LayoutGrid {
1302 self.x_side = Some(x_side);
1303 self
1304 }
1305 pub fn y_side(mut self, y_side: GridYSide) -> LayoutGrid {
1306 self.y_side = Some(y_side);
1307 self
1308 }
1309}
1310
1311#[derive(Serialize, Debug)]
1312pub enum UniformTextMode {
1313 #[serde(rename = "false")]
1314 False,
1315 #[serde(rename = "hide")]
1316 Hide,
1317 #[serde(rename = "show")]
1318 Show,
1319}
1320
1321#[derive(Serialize, Debug, Default)]
1322pub struct UniformText {
1323 #[serde(skip_serializing_if = "Option::is_none")]
1324 mode: Option<TruthyEnum<UniformTextMode>>,
1325 #[serde(skip_serializing_if = "Option::is_none")]
1326 min_size: Option<usize>,
1327}
1328
1329impl UniformText {
1330 pub fn new() -> UniformText {
1331 Default::default()
1332 }
1333
1334 pub fn mode(mut self, mode: UniformTextMode) -> UniformText {
1335 self.mode = Some(TruthyEnum { e: mode });
1336 self
1337 }
1338
1339 pub fn min_size(mut self, min_size: usize) -> UniformText {
1340 self.min_size = Some(min_size);
1341 self
1342 }
1343}
1344
1345#[derive(Serialize, Debug)]
1346pub enum HoverMode {
1347 #[serde(rename = "x")]
1348 X,
1349 #[serde(rename = "y")]
1350 Y,
1351 #[serde(rename = "closest")]
1352 Closest,
1353 #[serde(rename = "false")]
1354 False,
1355 #[serde(rename = "x unified")]
1356 XUnified,
1357 #[serde(rename = "y unified")]
1358 YUnified,
1359}
1360
1361#[derive(Serialize, Debug, Default)]
1362pub struct ModeBar {
1363 #[serde(skip_serializing_if = "Option::is_none")]
1364 orientation: Option<Orientation>,
1365 #[serde(skip_serializing_if = "Option::is_none", rename = "bgcolor")]
1366 background_color: Option<ColorWrapper>,
1367 #[serde(skip_serializing_if = "Option::is_none")]
1368 color: Option<ColorWrapper>,
1369 #[serde(skip_serializing_if = "Option::is_none", rename = "activecolor")]
1370 active_color: Option<ColorWrapper>,
1371}
1372
1373impl ModeBar {
1374 pub fn new() -> ModeBar {
1375 Default::default()
1376 }
1377
1378 pub fn orientation<C: Color>(mut self, orientation: Orientation) -> ModeBar {
1379 self.orientation = Some(orientation);
1380 self
1381 }
1382
1383 pub fn background_color<C: Color>(mut self, background_color: C) -> ModeBar {
1384 self.background_color = Some(background_color.to_color());
1385 self
1386 }
1387
1388 pub fn color<C: Color>(mut self, color: C) -> ModeBar {
1389 self.color = Some(color.to_color());
1390 self
1391 }
1392
1393 pub fn active_color<C: Color>(mut self, active_color: C) -> ModeBar {
1394 self.active_color = Some(active_color.to_color());
1395 self
1396 }
1397}
1398
1399#[derive(Serialize, Debug)]
1400pub enum ShapeType {
1401 #[serde(rename = "circle")]
1402 Circle,
1403 #[serde(rename = "rect")]
1404 Rect,
1405 #[serde(rename = "path")]
1406 Path,
1407 #[serde(rename = "line")]
1408 Line,
1409}
1410
1411#[derive(Serialize, Debug)]
1412pub enum ShapeLayer {
1413 #[serde(rename = "below")]
1414 Below,
1415 #[serde(rename = "above")]
1416 Above,
1417}
1418
1419#[derive(Serialize, Debug)]
1420pub enum ShapeSizeMode {
1421 #[serde(rename = "scaled")]
1422 Scaled,
1423 #[serde(rename = "pixel")]
1424 Pixel,
1425}
1426
1427#[derive(Serialize, Debug)]
1428pub enum FillRule {
1429 #[serde(rename = "evenodd")]
1430 EvenOdd,
1431 #[serde(rename = "nonzero")]
1432 NonZero,
1433}
1434
1435#[derive(Serialize, Debug, Default)]
1436pub struct ShapeLine {
1437 #[serde(skip_serializing_if = "Option::is_none")]
1438 color: Option<ColorWrapper>,
1439 #[serde(skip_serializing_if = "Option::is_none")]
1440 width: Option<f64>,
1441 #[serde(skip_serializing_if = "Option::is_none")]
1442 dash: Option<String>,
1443}
1444
1445impl ShapeLine {
1446 pub fn new() -> ShapeLine {
1447 Default::default()
1448 }
1449
1450 pub fn color<C: Color>(mut self, color: C) -> ShapeLine {
1452 self.color = Some(color.to_color());
1453 self
1454 }
1455
1456 pub fn width(mut self, width: f64) -> ShapeLine {
1458 self.width = Some(width);
1459 self
1460 }
1461
1462 pub fn dash(mut self, dash: &str) -> ShapeLine {
1465 self.dash = Some(dash.to_owned());
1466 self
1467 }
1468}
1469
1470#[derive(Serialize, Debug, Default)]
1471pub struct Shape {
1472 #[serde(skip_serializing_if = "Option::is_none")]
1473 visible: Option<bool>,
1474 #[serde(skip_serializing_if = "Option::is_none")]
1475 r#type: Option<ShapeType>,
1476 #[serde(skip_serializing_if = "Option::is_none")]
1477 layer: Option<ShapeLayer>,
1478 #[serde(skip_serializing_if = "Option::is_none", rename = "xref")]
1479 x_ref: Option<String>,
1480 #[serde(skip_serializing_if = "Option::is_none", rename = "xsizemode")]
1481 x_size_mode: Option<ShapeSizeMode>,
1482 #[serde(skip_serializing_if = "Option::is_none", rename = "xanchor")]
1483 x_anchor: Option<NumOrStringWrapper>,
1484 #[serde(skip_serializing_if = "Option::is_none")]
1485 x0: Option<NumOrStringWrapper>,
1486 #[serde(skip_serializing_if = "Option::is_none")]
1487 x1: Option<NumOrStringWrapper>,
1488 #[serde(skip_serializing_if = "Option::is_none", rename = "yref")]
1489 y_ref: Option<String>,
1490 #[serde(skip_serializing_if = "Option::is_none", rename = "ysizemode")]
1491 y_size_mode: Option<ShapeSizeMode>,
1492 #[serde(skip_serializing_if = "Option::is_none", rename = "yanchor")]
1493 y_anchor: Option<NumOrStringWrapper>,
1494 #[serde(skip_serializing_if = "Option::is_none")]
1495 y0: Option<NumOrStringWrapper>,
1496 #[serde(skip_serializing_if = "Option::is_none")]
1497 y1: Option<NumOrStringWrapper>,
1498 #[serde(skip_serializing_if = "Option::is_none")]
1499 path: Option<String>,
1500 #[serde(skip_serializing_if = "Option::is_none")]
1501 opacity: Option<f64>,
1502 #[serde(skip_serializing_if = "Option::is_none")]
1503 line: Option<ShapeLine>,
1504 #[serde(skip_serializing_if = "Option::is_none", rename = "fillcolor")]
1505 fill_color: Option<ColorWrapper>,
1506 #[serde(skip_serializing_if = "Option::is_none", rename = "fillrule")]
1507 fill_rule: Option<FillRule>,
1508 #[serde(skip_serializing_if = "Option::is_none")]
1509 editable: Option<bool>,
1510 #[serde(skip_serializing_if = "Option::is_none")]
1511 name: Option<String>,
1512 #[serde(skip_serializing_if = "Option::is_none", rename = "templateitemname")]
1513 template_item_name: Option<String>,
1514}
1515
1516impl Shape {
1517 pub fn new() -> Shape {
1518 Default::default()
1519 }
1520
1521 pub fn visible(mut self, visible: bool) -> Shape {
1523 self.visible = Some(visible);
1524 self
1525 }
1526
1527 pub fn shape_type(mut self, shape_type: ShapeType) -> Shape {
1535 self.r#type = Some(shape_type);
1536 self
1537 }
1538
1539 pub fn layer(mut self, layer: ShapeLayer) -> Shape {
1541 self.layer = Some(layer);
1542 self
1543 }
1544
1545 pub fn x_ref(mut self, x_ref: &str) -> Shape {
1552 self.x_ref = Some(x_ref.to_owned());
1553 self
1554 }
1555
1556 pub fn x_size_mode(mut self, x_size_mode: ShapeSizeMode) -> Shape {
1563 self.x_size_mode = Some(x_size_mode);
1564 self
1565 }
1566
1567 pub fn x_anchor<C: NumOrString>(mut self, x_anchor: C) -> Shape {
1572 self.x_anchor = Some(x_anchor.to_num_or_string());
1573 self
1574 }
1575
1576 pub fn x0<C: NumOrString>(mut self, x0: C) -> Shape {
1578 self.x0 = Some(x0.to_num_or_string());
1579 self
1580 }
1581
1582 pub fn x1<C: NumOrString>(mut self, x1: C) -> Shape {
1584 self.x1 = Some(x1.to_num_or_string());
1585 self
1586 }
1587
1588 pub fn y_ref(mut self, y_ref: &str) -> Shape {
1593 self.y_ref = Some(y_ref.to_owned());
1594 self
1595 }
1596
1597 pub fn y_size_mode(mut self, y_size_mode: ShapeSizeMode) -> Shape {
1604 self.y_size_mode = Some(y_size_mode);
1605 self
1606 }
1607
1608 pub fn y_anchor<C: NumOrString>(mut self, y_anchor: C) -> Shape {
1613 self.y_anchor = Some(y_anchor.to_num_or_string());
1614 self
1615 }
1616
1617 pub fn y0<C: NumOrString>(mut self, y0: C) -> Shape {
1619 self.y0 = Some(y0.to_num_or_string());
1620 self
1621 }
1622
1623 pub fn y1<C: NumOrString>(mut self, y1: C) -> Shape {
1625 self.y1 = Some(y1.to_num_or_string());
1626 self
1627 }
1628
1629 pub fn path(mut self, path: &str) -> Shape {
1643 self.path = Some(path.to_owned());
1644 self
1645 }
1646
1647 pub fn opacity(mut self, opacity: f64) -> Shape {
1649 self.opacity = Some(opacity);
1650 self
1651 }
1652
1653 pub fn line(mut self, line: ShapeLine) -> Shape {
1655 self.line = Some(line);
1656 self
1657 }
1658
1659 pub fn fill_color<C: Color>(mut self, fill_color: C) -> Shape {
1661 self.fill_color = Some(fill_color.to_color());
1662 self
1663 }
1664
1665 pub fn fill_rule(mut self, fill_rule: FillRule) -> Shape {
1668 self.fill_rule = Some(fill_rule);
1669 self
1670 }
1671
1672 pub fn editable(mut self, editable: bool) -> Shape {
1675 self.editable = Some(editable);
1676 self
1677 }
1678
1679 pub fn name(mut self, name: &str) -> Shape {
1685 self.name = Some(name.to_owned());
1686 self
1687 }
1688
1689 pub fn template_item_name(mut self, template_item_name: &str) -> Shape {
1695 self.template_item_name = Some(template_item_name.to_owned());
1696 self
1697 }
1698}
1699
1700#[derive(Serialize, Debug)]
1701pub enum DrawDirection {
1702 #[serde(rename = "ortho")]
1703 Ortho,
1704 #[serde(rename = "horizontal")]
1705 Horizontal,
1706 #[serde(rename = "vertical")]
1707 Vertical,
1708 #[serde(rename = "diagonal")]
1709 Diagonal,
1710}
1711
1712#[derive(Serialize, Debug, Default)]
1713pub struct NewShape {
1714 #[serde(skip_serializing_if = "Option::is_none")]
1715 line: Option<ShapeLine>,
1716 #[serde(skip_serializing_if = "Option::is_none", rename = "fillcolor")]
1717 fill_color: Option<ColorWrapper>,
1718 #[serde(skip_serializing_if = "Option::is_none", rename = "fillrule")]
1719 fill_rule: Option<FillRule>,
1720 #[serde(skip_serializing_if = "Option::is_none")]
1721 opacity: Option<f64>,
1722 #[serde(skip_serializing_if = "Option::is_none")]
1723 layer: Option<ShapeLayer>,
1724 #[serde(skip_serializing_if = "Option::is_none", rename = "drawdirection")]
1725 draw_direction: Option<DrawDirection>,
1726}
1727
1728impl NewShape {
1729 pub fn new() -> NewShape {
1730 Default::default()
1731 }
1732
1733 pub fn line(mut self, line: ShapeLine) -> NewShape {
1735 self.line = Some(line);
1736 self
1737 }
1738
1739 pub fn fill_color<C: Color>(mut self, fill_color: C) -> NewShape {
1743 self.fill_color = Some(fill_color.to_color());
1744 self
1745 }
1746
1747 pub fn fill_rule(mut self, fill_rule: FillRule) -> NewShape {
1750 self.fill_rule = Some(fill_rule);
1751 self
1752 }
1753
1754 pub fn opacity(mut self, opacity: f64) -> NewShape {
1756 self.opacity = Some(opacity);
1757 self
1758 }
1759
1760 pub fn layer(mut self, layer: ShapeLayer) -> NewShape {
1762 self.layer = Some(layer);
1763 self
1764 }
1765
1766 pub fn draw_direction(mut self, draw_direction: DrawDirection) -> NewShape {
1771 self.draw_direction = Some(draw_direction);
1772 self
1773 }
1774}
1775
1776#[derive(Serialize, Debug, Default)]
1777pub struct ActiveShape {
1778 #[serde(skip_serializing_if = "Option::is_none", rename = "fillcolor")]
1779 fill_color: Option<ColorWrapper>,
1780 #[serde(skip_serializing_if = "Option::is_none")]
1781 opacity: Option<f64>,
1782}
1783
1784impl ActiveShape {
1785 pub fn new() -> ActiveShape {
1786 Default::default()
1787 }
1788
1789 pub fn fill_color<C: Color>(mut self, fill_color: C) -> ActiveShape {
1791 self.fill_color = Some(fill_color.to_color());
1792 self
1793 }
1794
1795 pub fn opacity(mut self, opacity: f64) -> ActiveShape {
1797 self.opacity = Some(opacity);
1798 self
1799 }
1800}
1801
1802#[derive(Serialize, Debug)]
1803pub enum ArrowSide {
1804 #[serde(rename = "end")]
1805 End,
1806 #[serde(rename = "start")]
1807 Start,
1808 #[serde(rename = "end+start")]
1809 StartEnd,
1810 #[serde(rename = "none")]
1811 None,
1812}
1813
1814#[derive(Serialize, Debug)]
1815pub enum ClickToShow {
1816 #[serde(rename = "false")]
1817 False,
1818 #[serde(rename = "onoff")]
1819 OnOff,
1820 #[serde(rename = "onout")]
1821 OnOut,
1822}
1823
1824#[derive(Serialize, Debug, Default)]
1825pub struct Annotation {
1826 #[serde(skip_serializing_if = "Option::is_none")]
1827 visible: Option<bool>,
1828 #[serde(skip_serializing_if = "Option::is_none")]
1829 text: Option<String>,
1830 #[serde(skip_serializing_if = "Option::is_none", rename = "textangle")]
1831 text_angle: Option<f64>,
1832 #[serde(skip_serializing_if = "Option::is_none")]
1833 font: Option<Font>,
1834 #[serde(skip_serializing_if = "Option::is_none")]
1835 width: Option<f64>,
1836 #[serde(skip_serializing_if = "Option::is_none")]
1837 height: Option<f64>,
1838 #[serde(skip_serializing_if = "Option::is_none")]
1839 opacity: Option<f64>,
1840 #[serde(skip_serializing_if = "Option::is_none")]
1841 align: Option<HAlign>,
1842 #[serde(skip_serializing_if = "Option::is_none")]
1843 valign: Option<VAlign>,
1844 #[serde(skip_serializing_if = "Option::is_none", rename = "bgcolor")]
1845 background_color: Option<ColorWrapper>,
1846 #[serde(skip_serializing_if = "Option::is_none", rename = "bordercolor")]
1847 border_color: Option<ColorWrapper>,
1848 #[serde(skip_serializing_if = "Option::is_none", rename = "borderpad")]
1849 border_pad: Option<f64>,
1850 #[serde(skip_serializing_if = "Option::is_none", rename = "borderwidth")]
1851 border_width: Option<f64>,
1852 #[serde(skip_serializing_if = "Option::is_none", rename = "showarrow")]
1853 show_arrow: Option<bool>,
1854 #[serde(skip_serializing_if = "Option::is_none", rename = "arrowcolor")]
1855 arrow_color: Option<ColorWrapper>,
1856 #[serde(skip_serializing_if = "Option::is_none", rename = "arrowhead")]
1857 arrow_head: Option<u8>,
1858 #[serde(skip_serializing_if = "Option::is_none", rename = "startarrowhead")]
1859 start_arrow_head: Option<u8>,
1860 #[serde(skip_serializing_if = "Option::is_none", rename = "arrowside")]
1861 arrow_side: Option<ArrowSide>,
1862 #[serde(skip_serializing_if = "Option::is_none", rename = "arrowsize")]
1863 arrow_size: Option<f64>,
1864 #[serde(skip_serializing_if = "Option::is_none", rename = "startarrowsize")]
1865 start_arrow_size: Option<f64>,
1866 #[serde(skip_serializing_if = "Option::is_none", rename = "arrowwidth")]
1867 arrow_width: Option<f64>,
1868 #[serde(skip_serializing_if = "Option::is_none", rename = "standoff")]
1869 stand_off: Option<f64>,
1870 #[serde(skip_serializing_if = "Option::is_none", rename = "startstandoff")]
1871 start_stand_off: Option<f64>,
1872 #[serde(skip_serializing_if = "Option::is_none")]
1873 ax: Option<NumOrStringWrapper>,
1874 #[serde(skip_serializing_if = "Option::is_none")]
1875 ay: Option<NumOrStringWrapper>,
1876 #[serde(skip_serializing_if = "Option::is_none", rename = "axref")]
1877 ax_ref: Option<String>,
1878 #[serde(skip_serializing_if = "Option::is_none", rename = "ayref")]
1879 ay_ref: Option<String>,
1880 #[serde(skip_serializing_if = "Option::is_none", rename = "xref")]
1881 x_ref: Option<String>,
1882 #[serde(skip_serializing_if = "Option::is_none")]
1883 x: Option<NumOrStringWrapper>,
1884 #[serde(skip_serializing_if = "Option::is_none", rename = "xanchor")]
1885 x_anchor: Option<Anchor>,
1886 #[serde(skip_serializing_if = "Option::is_none", rename = "xshift")]
1887 x_shift: Option<f64>,
1888 #[serde(skip_serializing_if = "Option::is_none", rename = "yref")]
1889 y_ref: Option<String>,
1890 #[serde(skip_serializing_if = "Option::is_none")]
1891 y: Option<NumOrStringWrapper>,
1892 #[serde(skip_serializing_if = "Option::is_none", rename = "yanchor")]
1893 y_anchor: Option<Anchor>,
1894 #[serde(skip_serializing_if = "Option::is_none", rename = "yshift")]
1895 y_shift: Option<f64>,
1896 #[serde(skip_serializing_if = "Option::is_none", rename = "clicktoshow")]
1897 click_to_show: Option<TruthyEnum<ClickToShow>>,
1898 #[serde(skip_serializing_if = "Option::is_none", rename = "xclick")]
1899 x_click: Option<NumOrStringWrapper>,
1900 #[serde(skip_serializing_if = "Option::is_none", rename = "yclick")]
1901 y_click: Option<NumOrStringWrapper>,
1902 #[serde(skip_serializing_if = "Option::is_none", rename = "hovertext")]
1903 hover_text: Option<String>,
1904 #[serde(skip_serializing_if = "Option::is_none", rename = "hoverlabel")]
1905 hover_label: Option<Label>,
1906 #[serde(skip_serializing_if = "Option::is_none", rename = "captureevents")]
1907 capture_events: Option<bool>,
1908 #[serde(skip_serializing_if = "Option::is_none")]
1909 name: Option<String>,
1910 #[serde(skip_serializing_if = "Option::is_none", rename = "templateitemname")]
1911 template_item_name: Option<String>,
1912}
1913
1914impl Annotation {
1915 pub fn new() -> Annotation {
1916 Default::default()
1917 }
1918
1919 pub fn visible(mut self, visible: bool) -> Annotation {
1921 self.visible = Some(visible);
1922 self
1923 }
1924
1925 pub fn text(mut self, text: &str) -> Annotation {
1929 self.text = Some(text.to_owned());
1930 self
1931 }
1932
1933 pub fn text_angle(mut self, text_angle: f64) -> Annotation {
1935 self.text_angle = Some(text_angle);
1936 self
1937 }
1938
1939 pub fn font(mut self, font: Font) -> Annotation {
1941 self.font = Some(font);
1942 self
1943 }
1944
1945 pub fn width(mut self, width: f64) -> Annotation {
1948 self.width = Some(width);
1949 self
1950 }
1951
1952 pub fn height(mut self, height: f64) -> Annotation {
1955 self.height = Some(height);
1956 self
1957 }
1958
1959 pub fn opacity(mut self, opacity: f64) -> Annotation {
1961 self.opacity = Some(opacity);
1962 self
1963 }
1964
1965 pub fn align(mut self, align: HAlign) -> Annotation {
1969 self.align = Some(align);
1970 self
1971 }
1972
1973 pub fn valign(mut self, valign: VAlign) -> Annotation {
1976 self.valign = Some(valign);
1977 self
1978 }
1979
1980 pub fn background_color<C: Color>(mut self, background_color: C) -> Annotation {
1982 self.background_color = Some(background_color.to_color());
1983 self
1984 }
1985
1986 pub fn border_color<C: Color>(mut self, border_color: C) -> Annotation {
1988 self.border_color = Some(border_color.to_color());
1989 self
1990 }
1991
1992 pub fn border_pad(mut self, border_pad: f64) -> Annotation {
1994 self.border_pad = Some(border_pad);
1995 self
1996 }
1997
1998 pub fn border_width(mut self, border_width: f64) -> Annotation {
2000 self.border_width = Some(border_width);
2001 self
2002 }
2003
2004 pub fn show_arrow(mut self, show_arrow: bool) -> Annotation {
2007 self.show_arrow = Some(show_arrow);
2008 self
2009 }
2010
2011 pub fn arrow_color<C: Color>(mut self, arrow_color: C) -> Annotation {
2013 self.arrow_color = Some(arrow_color.to_color());
2014 self
2015 }
2016
2017 pub fn arrow_head(mut self, arrow_head: u8) -> Annotation {
2019 self.arrow_head = Some(arrow_head);
2020 self
2021 }
2022
2023 pub fn start_arrow_head(mut self, start_arrow_head: u8) -> Annotation {
2025 self.start_arrow_head = Some(start_arrow_head);
2026 self
2027 }
2028
2029 pub fn arrow_side(mut self, arrow_side: ArrowSide) -> Annotation {
2031 self.arrow_side = Some(arrow_side);
2032 self
2033 }
2034
2035 pub fn arrow_size(mut self, arrow_size: f64) -> Annotation {
2038 self.arrow_size = Some(arrow_size);
2039 self
2040 }
2041
2042 pub fn start_arrow_size(mut self, start_arrow_size: f64) -> Annotation {
2045 self.start_arrow_size = Some(start_arrow_size);
2046 self
2047 }
2048
2049 pub fn arrow_width(mut self, arrow_width: f64) -> Annotation {
2051 self.arrow_width = Some(arrow_width);
2052 self
2053 }
2054
2055 pub fn stand_off(mut self, stand_off: f64) -> Annotation {
2060 self.stand_off = Some(stand_off);
2061 self
2062 }
2063
2064 pub fn start_stand_off(mut self, start_stand_off: f64) -> Annotation {
2069 self.start_stand_off = Some(start_stand_off);
2070 self
2071 }
2072
2073 pub fn ax<C: NumOrString>(mut self, ax: C) -> Annotation {
2078 self.ax = Some(ax.to_num_or_string());
2079 self
2080 }
2081
2082 pub fn ay<C: NumOrString>(mut self, ay: C) -> Annotation {
2087 self.ay = Some(ay.to_num_or_string());
2088 self
2089 }
2090
2091 pub fn ax_ref(mut self, ax_ref: &str) -> Annotation {
2096 self.ax_ref = Some(ax_ref.to_owned());
2097 self
2098 }
2099
2100 pub fn ay_ref(mut self, ay_ref: &str) -> Annotation {
2105 self.ay_ref = Some(ay_ref.to_owned());
2106 self
2107 }
2108
2109 pub fn x_ref(mut self, x_ref: &str) -> Annotation {
2114 self.x_ref = Some(x_ref.to_owned());
2115 self
2116 }
2117
2118 pub fn x<C: NumOrString>(mut self, x: C) -> Annotation {
2124 self.x = Some(x.to_num_or_string());
2125 self
2126 }
2127
2128 pub fn x_anchor(mut self, x_anchor: Anchor) -> Annotation {
2135 self.x_anchor = Some(x_anchor);
2136 self
2137 }
2138
2139 pub fn x_shift(mut self, x_shift: f64) -> Annotation {
2142 self.x_shift = Some(x_shift);
2143 self
2144 }
2145
2146 pub fn y_ref(mut self, y_ref: &str) -> Annotation {
2151 self.y_ref = Some(y_ref.to_owned());
2152 self
2153 }
2154
2155 pub fn y<C: NumOrString>(mut self, y: C) -> Annotation {
2161 self.y = Some(y.to_num_or_string());
2162 self
2163 }
2164
2165 pub fn y_anchor(mut self, y_anchor: Anchor) -> Annotation {
2172 self.y_anchor = Some(y_anchor);
2173 self
2174 }
2175
2176 pub fn y_shift(mut self, y_shift: f64) -> Annotation {
2179 self.y_shift = Some(y_shift);
2180 self
2181 }
2182
2183 pub fn click_to_show(mut self, click_to_show: TruthyEnum<ClickToShow>) -> Annotation {
2192 self.click_to_show = Some(click_to_show);
2193 self
2194 }
2195
2196 pub fn x_click<C: NumOrString>(mut self, x_click: C) -> Annotation {
2199 self.x_click = Some(x_click.to_num_or_string());
2200 self
2201 }
2202
2203 pub fn y_click<C: NumOrString>(mut self, y_click: C) -> Annotation {
2206 self.y_click = Some(y_click.to_num_or_string());
2207 self
2208 }
2209
2210 pub fn hover_text(mut self, hover_text: &str) -> Annotation {
2213 self.hover_text = Some(hover_text.to_owned());
2214 self
2215 }
2216
2217 pub fn hover_label(mut self, hover_label: Label) -> Annotation {
2219 self.hover_label = Some(hover_label);
2220 self
2221 }
2222
2223 pub fn capture_events(mut self, capture_events: bool) -> Annotation {
2228 self.capture_events = Some(capture_events);
2229 self
2230 }
2231
2232 pub fn name(mut self, name: &str) -> Annotation {
2238 self.name = Some(name.to_owned());
2239 self
2240 }
2241
2242 pub fn template_item_name(mut self, template_item_name: &str) -> Annotation {
2248 self.template_item_name = Some(template_item_name.to_owned());
2249 self
2250 }
2251}
2252
2253#[derive(Serialize, Debug, Default)]
2254pub struct Layout {
2255 #[serde(skip_serializing_if = "Option::is_none")]
2256 title: Option<Title>,
2257 #[serde(skip_serializing_if = "Option::is_none", rename = "showlegend")]
2258 show_legend: Option<bool>,
2259 #[serde(skip_serializing_if = "Option::is_none")]
2260 legend: Option<Legend>,
2261 #[serde(skip_serializing_if = "Option::is_none")]
2262 margin: Option<Margin>,
2263 #[serde(skip_serializing_if = "Option::is_none", rename = "autosize")]
2264 auto_size: Option<bool>,
2265 #[serde(skip_serializing_if = "Option::is_none")]
2266 width: Option<usize>,
2267 #[serde(skip_serializing_if = "Option::is_none")]
2268 height: Option<usize>,
2269 #[serde(skip_serializing_if = "Option::is_none")]
2270 font: Option<Font>,
2271 #[serde(skip_serializing_if = "Option::is_none")]
2272 uniform_text: Option<UniformText>,
2273 #[serde(skip_serializing_if = "Option::is_none")]
2274 separators: Option<String>,
2275 #[serde(skip_serializing_if = "Option::is_none", rename = "paper_bgcolor")]
2276 paper_background_color: Option<ColorWrapper>,
2277 #[serde(skip_serializing_if = "Option::is_none", rename = "plot_bgcolor")]
2278 plot_background_color: Option<ColorWrapper>,
2279 #[serde(skip_serializing_if = "Option::is_none", rename = "colorscale")]
2280 color_scale: Option<LayoutColorScale>,
2281 #[serde(skip_serializing_if = "Option::is_none")]
2282 colorway: Option<Vec<ColorWrapper>>,
2283 #[serde(skip_serializing_if = "Option::is_none", rename = "coloraxis")]
2284 color_axis: Option<ColorAxis>,
2285 #[serde(skip_serializing_if = "Option::is_none", rename = "modebar")]
2286 mode_bar: Option<ModeBar>,
2287 #[serde(skip_serializing_if = "Option::is_none", rename = "hovermode")]
2288 hover_mode: Option<TruthyEnum<HoverMode>>,
2289 #[serde(skip_serializing_if = "Option::is_none", rename = "clickmode")]
2290 click_mode: Option<String>,
2291 #[serde(skip_serializing_if = "Option::is_none", rename = "dragmode")]
2292 drag_mode: Option<String>,
2293 #[serde(skip_serializing_if = "Option::is_none", rename = "selectdirection")]
2294 select_direction: Option<String>,
2295 #[serde(skip_serializing_if = "Option::is_none", rename = "hoverdistance")]
2296 hover_distance: Option<i32>,
2297 #[serde(skip_serializing_if = "Option::is_none", rename = "spikedistance")]
2298 spike_distance: Option<i32>,
2299 #[serde(skip_serializing_if = "Option::is_none", rename = "hoverlabel")]
2300 hover_label: Option<Label>,
2301
2302 #[serde(skip_serializing_if = "Option::is_none")]
2303 template: Option<String>,
2304
2305 #[serde(skip_serializing_if = "Option::is_none")]
2306 grid: Option<LayoutGrid>,
2307 #[serde(skip_serializing_if = "Option::is_none")]
2308 calendar: Option<Calendar>,
2309 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis")]
2310 x_axis: Option<Axis>,
2311 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis")]
2312 y_axis: Option<Axis>,
2313
2314 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis2")]
2315 x_axis2: Option<Axis>,
2316 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis2")]
2317 y_axis2: Option<Axis>,
2318 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis3")]
2319 x_axis3: Option<Axis>,
2320 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis3")]
2321 y_axis3: Option<Axis>,
2322 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis4")]
2323 x_axis4: Option<Axis>,
2324 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis4")]
2325 y_axis4: Option<Axis>,
2326 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis5")]
2327 x_axis5: Option<Axis>,
2328 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis5")]
2329 y_axis5: Option<Axis>,
2330 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis6")]
2331 x_axis6: Option<Axis>,
2332 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis6")]
2333 y_axis6: Option<Axis>,
2334 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis7")]
2335 x_axis7: Option<Axis>,
2336 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis7")]
2337 y_axis7: Option<Axis>,
2338 #[serde(skip_serializing_if = "Option::is_none", rename = "xaxis8")]
2339 x_axis8: Option<Axis>,
2340 #[serde(skip_serializing_if = "Option::is_none", rename = "yaxis8")]
2341 y_axis8: Option<Axis>,
2342
2343 #[serde(skip_serializing_if = "Option::is_none")]
2347 annotations: Option<Vec<Annotation>>,
2348 #[serde(skip_serializing_if = "Option::is_none")]
2349 shapes: Option<Vec<Shape>>,
2350 #[serde(skip_serializing_if = "Option::is_none", rename = "newshape")]
2351 new_shape: Option<NewShape>,
2352 #[serde(skip_serializing_if = "Option::is_none", rename = "activeshape")]
2353 active_shape: Option<ActiveShape>,
2354
2355 #[serde(skip_serializing_if = "Option::is_none", rename = "boxmode")]
2356 box_mode: Option<BoxMode>,
2357 #[serde(skip_serializing_if = "Option::is_none", rename = "boxgap")]
2358 box_gap: Option<f64>,
2359 #[serde(skip_serializing_if = "Option::is_none", rename = "boxgroupgap")]
2360 box_group_gap: Option<f64>,
2361
2362 #[serde(skip_serializing_if = "Option::is_none", rename = "barmode")]
2363 bar_mode: Option<BarMode>,
2364 #[serde(skip_serializing_if = "Option::is_none", rename = "barnorm")]
2365 bar_norm: Option<BarNorm>,
2366 #[serde(skip_serializing_if = "Option::is_none", rename = "bargap")]
2367 bar_gap: Option<f64>,
2368 #[serde(skip_serializing_if = "Option::is_none", rename = "bargroupgap")]
2369 bar_group_gap: Option<f64>,
2370
2371 #[serde(skip_serializing_if = "Option::is_none", rename = "violinmode")]
2372 violin_mode: Option<ViolinMode>,
2373 #[serde(skip_serializing_if = "Option::is_none", rename = "violingap")]
2374 violin_gap: Option<f64>,
2375 #[serde(skip_serializing_if = "Option::is_none", rename = "violingroupgap")]
2376 violin_group_gap: Option<f64>,
2377
2378 #[serde(skip_serializing_if = "Option::is_none", rename = "waterfallmode")]
2379 waterfall_mode: Option<WaterfallMode>,
2380 #[serde(skip_serializing_if = "Option::is_none", rename = "waterfallgap")]
2381 waterfall_gap: Option<f64>,
2382 #[serde(skip_serializing_if = "Option::is_none", rename = "waterfallgroupgap")]
2383 waterfall_group_gap: Option<f64>,
2384
2385 #[serde(skip_serializing_if = "Option::is_none", rename = "piecolorway")]
2386 pie_colorway: Option<Vec<ColorWrapper>>,
2387 #[serde(skip_serializing_if = "Option::is_none", rename = "extendpiecolors")]
2388 extend_pie_colors: Option<bool>,
2389
2390 #[serde(skip_serializing_if = "Option::is_none", rename = "sunburstcolorway")]
2391 sunburst_colorway: Option<Vec<ColorWrapper>>,
2392 #[serde(
2393 skip_serializing_if = "Option::is_none",
2394 rename = "extendsuburstcolors"
2395 )]
2396 extend_sunburst_colors: Option<bool>,
2397}
2398
2399impl Layout {
2400 pub fn new() -> Layout {
2401 Default::default()
2402 }
2403
2404 pub fn title(mut self, title: Title) -> Layout {
2405 self.title = Some(title);
2406 self
2407 }
2408
2409 pub fn show_legend(mut self, show_legend: bool) -> Layout {
2410 self.show_legend = Some(show_legend);
2411 self
2412 }
2413
2414 pub fn legend(mut self, legend: Legend) -> Layout {
2415 self.legend = Some(legend);
2416 self
2417 }
2418
2419 pub fn margin(mut self, margin: Margin) -> Layout {
2420 self.margin = Some(margin);
2421 self
2422 }
2423
2424 pub fn auto_size(mut self, auto_size: bool) -> Layout {
2425 self.auto_size = Some(auto_size);
2426 self
2427 }
2428
2429 pub fn width(mut self, width: usize) -> Layout {
2430 self.width = Some(width);
2431 self
2432 }
2433
2434 pub fn height(mut self, height: usize) -> Layout {
2435 self.height = Some(height);
2436 self
2437 }
2438
2439 pub fn font(mut self, font: Font) -> Layout {
2440 self.font = Some(font);
2441 self
2442 }
2443
2444 pub fn uniform_text(mut self, uniform_text: UniformText) -> Layout {
2445 self.uniform_text = Some(uniform_text);
2446 self
2447 }
2448
2449 pub fn separators(mut self, separators: &str) -> Layout {
2450 self.separators = Some(separators.to_owned());
2451 self
2452 }
2453
2454 pub fn paper_background_color<C: Color>(mut self, paper_background_color: C) -> Layout {
2455 self.paper_background_color = Some(paper_background_color.to_color());
2456 self
2457 }
2458
2459 pub fn plot_background_color<C: Color>(mut self, plot_background_color: C) -> Layout {
2460 self.plot_background_color = Some(plot_background_color.to_color());
2461 self
2462 }
2463
2464 pub fn color_scale(mut self, color_scale: LayoutColorScale) -> Layout {
2465 self.color_scale = Some(color_scale);
2466 self
2467 }
2468
2469 pub fn colorway<C: Color>(mut self, colorway: Vec<C>) -> Layout {
2470 let colorway = private::to_color_array(colorway);
2471 self.colorway = Some(colorway);
2472 self
2473 }
2474
2475 pub fn color_axis(mut self, color_axis: ColorAxis) -> Layout {
2476 self.color_axis = Some(color_axis);
2477 self
2478 }
2479
2480 pub fn mode_bar(mut self, mode_bar: ModeBar) -> Layout {
2481 self.mode_bar = Some(mode_bar);
2482 self
2483 }
2484
2485 pub fn hover_mode(mut self, hover_mode: HoverMode) -> Layout {
2496 self.hover_mode = Some(TruthyEnum { e: hover_mode });
2497 self
2498 }
2499
2500 pub fn click_mode(mut self, click_mode: &str) -> Layout {
2501 self.click_mode = Some(click_mode.to_owned());
2502 self
2503 }
2504
2505 pub fn drag_mode(mut self, drag_mode: &str) -> Layout {
2506 self.drag_mode = Some(drag_mode.to_owned());
2507 self
2508 }
2509
2510 pub fn select_direction(mut self, select_direction: &str) -> Layout {
2511 self.select_direction = Some(select_direction.to_owned());
2512 self
2513 }
2514
2515 pub fn hover_distance(mut self, hover_distance: i32) -> Layout {
2516 self.hover_distance = Some(hover_distance);
2517 self
2518 }
2519
2520 pub fn spike_distance(mut self, spike_distance: i32) -> Layout {
2521 self.spike_distance = Some(spike_distance);
2522 self
2523 }
2524
2525 pub fn hover_label(mut self, hover_label: Label) -> Layout {
2526 self.hover_label = Some(hover_label);
2527 self
2528 }
2529
2530 pub fn grid(mut self, grid: LayoutGrid) -> Layout {
2531 self.grid = Some(grid);
2532 self
2533 }
2534
2535 pub fn calendar(mut self, calendar: Calendar) -> Layout {
2536 self.calendar = Some(calendar);
2537 self
2538 }
2539
2540 pub fn x_axis(mut self, xaxis: Axis) -> Layout {
2541 self.x_axis = Some(xaxis);
2542 self
2543 }
2544
2545 pub fn y_axis(mut self, yaxis: Axis) -> Layout {
2546 self.y_axis = Some(yaxis);
2547 self
2548 }
2549
2550 pub fn x_axis2(mut self, xaxis: Axis) -> Layout {
2551 self.x_axis2 = Some(xaxis);
2552 self
2553 }
2554
2555 pub fn y_axis2(mut self, yaxis: Axis) -> Layout {
2556 self.y_axis2 = Some(yaxis);
2557 self
2558 }
2559
2560 pub fn x_axis3(mut self, xaxis: Axis) -> Layout {
2561 self.x_axis3 = Some(xaxis);
2562 self
2563 }
2564
2565 pub fn y_axis3(mut self, yaxis: Axis) -> Layout {
2566 self.y_axis3 = Some(yaxis);
2567 self
2568 }
2569
2570 pub fn x_axis4(mut self, xaxis: Axis) -> Layout {
2571 self.x_axis4 = Some(xaxis);
2572 self
2573 }
2574
2575 pub fn y_axis4(mut self, yaxis: Axis) -> Layout {
2576 self.y_axis4 = Some(yaxis);
2577 self
2578 }
2579
2580 pub fn x_axis5(mut self, xaxis: Axis) -> Layout {
2581 self.x_axis5 = Some(xaxis);
2582 self
2583 }
2584
2585 pub fn y_axis5(mut self, yaxis: Axis) -> Layout {
2586 self.y_axis5 = Some(yaxis);
2587 self
2588 }
2589
2590 pub fn x_axis6(mut self, xaxis: Axis) -> Layout {
2591 self.x_axis6 = Some(xaxis);
2592 self
2593 }
2594
2595 pub fn y_axis6(mut self, yaxis: Axis) -> Layout {
2596 self.y_axis6 = Some(yaxis);
2597 self
2598 }
2599
2600 pub fn x_axis7(mut self, xaxis: Axis) -> Layout {
2601 self.x_axis7 = Some(xaxis);
2602 self
2603 }
2604
2605 pub fn y_axis7(mut self, yaxis: Axis) -> Layout {
2606 self.y_axis7 = Some(yaxis);
2607 self
2608 }
2609
2610 pub fn x_axis8(mut self, xaxis: Axis) -> Layout {
2611 self.x_axis8 = Some(xaxis);
2612 self
2613 }
2614
2615 pub fn y_axis8(mut self, yaxis: Axis) -> Layout {
2616 self.y_axis8 = Some(yaxis);
2617 self
2618 }
2619
2620 pub fn annotations(mut self, annotations: Vec<Annotation>) -> Layout {
2621 self.annotations = Some(annotations);
2622 self
2623 }
2624
2625 pub fn add_annotation(&mut self, annotation: Annotation) {
2626 if self.annotations.is_none() {
2627 self.annotations = Some(Vec::new());
2628 }
2629 self.annotations.as_mut().unwrap().push(annotation);
2630 }
2631
2632 pub fn shapes(mut self, shapes: Vec<Shape>) -> Layout {
2633 self.shapes = Some(shapes);
2634 self
2635 }
2636
2637 pub fn add_shape(&mut self, shape: Shape) {
2638 if self.shapes.is_none() {
2639 self.shapes = Some(Vec::new());
2640 }
2641 self.shapes.as_mut().unwrap().push(shape);
2642 }
2643
2644 pub fn new_shape(mut self, new_shape: NewShape) -> Layout {
2645 self.new_shape = Some(new_shape);
2646 self
2647 }
2648
2649 pub fn active_shape(mut self, active_shape: ActiveShape) -> Layout {
2650 self.active_shape = Some(active_shape);
2651 self
2652 }
2653
2654 pub fn template(mut self, template: &str) -> Layout {
2655 self.template = Some(template.to_owned());
2656 self
2657 }
2658
2659 pub fn box_mode(mut self, box_mode: BoxMode) -> Layout {
2660 self.box_mode = Some(box_mode);
2661 self
2662 }
2663
2664 pub fn box_gap(mut self, box_gap: f64) -> Layout {
2665 self.box_gap = Some(box_gap);
2666 self
2667 }
2668
2669 pub fn box_group_gap(mut self, box_group_gap: f64) -> Layout {
2670 self.box_group_gap = Some(box_group_gap);
2671 self
2672 }
2673
2674 pub fn bar_mode(mut self, bar_mode: BarMode) -> Layout {
2675 self.bar_mode = Some(bar_mode);
2676 self
2677 }
2678
2679 pub fn bar_norm(mut self, bar_norm: BarNorm) -> Layout {
2680 self.bar_norm = Some(bar_norm);
2681 self
2682 }
2683
2684 pub fn bar_gap(mut self, bar_gap: f64) -> Layout {
2685 self.bar_gap = Some(bar_gap);
2686 self
2687 }
2688
2689 pub fn bar_group_gap(mut self, bar_group_gap: f64) -> Layout {
2690 self.bar_group_gap = Some(bar_group_gap);
2691 self
2692 }
2693
2694 pub fn violin_mode(mut self, violin_mode: ViolinMode) -> Layout {
2695 self.violin_mode = Some(violin_mode);
2696 self
2697 }
2698
2699 pub fn violin_gap(mut self, violin_gap: f64) -> Layout {
2700 self.violin_gap = Some(violin_gap);
2701 self
2702 }
2703
2704 pub fn violin_group_gap(mut self, violin_group_gap: f64) -> Layout {
2705 self.violin_group_gap = Some(violin_group_gap);
2706 self
2707 }
2708
2709 pub fn waterfall_mode(mut self, waterfall_mode: WaterfallMode) -> Layout {
2710 self.waterfall_mode = Some(waterfall_mode);
2711 self
2712 }
2713
2714 pub fn waterfall_gap(mut self, waterfall_gap: f64) -> Layout {
2715 self.waterfall_gap = Some(waterfall_gap);
2716 self
2717 }
2718
2719 pub fn waterfall_group_gap(mut self, waterfall_group_gap: f64) -> Layout {
2720 self.waterfall_group_gap = Some(waterfall_group_gap);
2721 self
2722 }
2723
2724 pub fn pie_colorway<C: Color>(mut self, pie_colorway: Vec<C>) -> Layout {
2725 let pie_colorway = private::to_color_array(pie_colorway);
2726 self.pie_colorway = Some(pie_colorway);
2727 self
2728 }
2729
2730 pub fn extend_pie_colors(mut self, extend_pie_colors: bool) -> Layout {
2731 self.extend_pie_colors = Some(extend_pie_colors);
2732 self
2733 }
2734
2735 pub fn sunburst_colorway<C: Color>(mut self, sunburst_colorway: Vec<C>) -> Layout {
2736 let sunburst_colorway = private::to_color_array(sunburst_colorway);
2737 self.sunburst_colorway = Some(sunburst_colorway);
2738 self
2739 }
2740
2741 pub fn extend_sunburst_colors(mut self, extend_sunburst_colors: bool) -> Layout {
2742 self.extend_sunburst_colors = Some(extend_sunburst_colors);
2743 self
2744 }
2745}
2746
2747impl Trace for Layout {
2748 fn serialize(&self) -> String {
2749 serde_json::to_string(&self).unwrap()
2750 }
2751}